[libnb-javaparser-java] 01/01: Imported Upstream version 7.4

Andrew Ross rockclimb-guest at alioth.debian.org
Tue Oct 22 22:33:52 UTC 2013


This is an automated email from the git hooks/post-receive script.

rockclimb-guest pushed a commit to annotated tag upstream/7.4
in repository libnb-javaparser-java.

commit 87f2523a28fe497f4cf5fc30f9bd7bab5bfd79dc
Author: Andrew Ross <ubuntu at rossfamily.co.uk>
Date:   Wed Oct 16 19:07:58 2013 +0100

    Imported Upstream version 7.4
---
 .hg_archival.txt                                   |    6 +-
 .hgignore                                          |    1 +
 .hgtags                                            |  193 +-
 .jcheck/conf                                       |    3 +-
 THIRD_PARTY_README                                 |   27 +-
 make/Makefile-classic                              |  419 ---
 make/build.properties                              |   38 +-
 make/build.xml                                     |  227 +-
 make/conf/checkstyle-emacs.xsl                     |   24 +
 make/conf/checkstyle-langtools.xml                 |   47 +
 make/jprt.properties                               |   22 +-
 make/netbeans/README                               |    2 +-
 make/netbeans/langtools/build.xml                  |    5 +-
 make/netbeans/langtools/nbproject/project.xml      |  234 +-
 make/netbeans/nb-javac/nbproject/build-impl.xml    |  654 +++-
 .../nb-javac/nbproject/genfiles.properties         |    4 +-
 .../netbeans/nb-javac/nbproject/project.properties |    6 +-
 .../sun/source/tree/CompilationUnitTreeTest.java   |    1 -
 .../test/com/sun/source/tree/TreeTest.java         |   15 +-
 .../test/com/sun/source/util/TreesTest.java        |   68 +
 .../test/com/sun/tools/javac/code/FlagsTest.java   |    2 +-
 .../test/com/sun/tools/javac/code/TypesTest.java   |   18 +
 .../test/com/sun/tools/javac/comp/AttrTest.java    |  298 +-
 .../test/com/sun/tools/javac/comp/FlowTest.java    |   41 +
 .../com/sun/tools/javac/comp/MemberEnterTest.java  |   13 +
 .../com/sun/tools/javac/jvm/ClassReaderTest.java   |   65 +-
 .../tools/javac/parser/DocCommentParserTest.java   |  157 +
 .../sun/tools/javac/parser/JavacParserTest.java    |   86 +-
 .../test/global/AnnotationProcessingTest.java      |   19 +
 make/test/lib/apt.sh                               |   42 -
 make/test/lib/src.gold.txt                         |   10 -
 .../tools/CompileProperties/CompileProperties.java |  402 ---
 .../CompileProperties/CompilePropertiesTask.java   |   97 -
 make/tools/GenStubs/GenStubs.java                  |  448 ---
 make/tools/SelectTool/SelectToolTask.java          |  284 --
 make/tools/anttasks/CompilePropertiesTask.java     |  101 +
 make/tools/anttasks/GenStubsTask.java              |  162 +
 make/tools/anttasks/SelectToolTask.java            |  286 ++
 .../tools/compileproperties/CompileProperties.java |  404 +++
 make/tools/crules/AbstractCodingRulesAnalyzer.java |  117 +
 make/tools/crules/MutableFieldsAnalyzer.java       |  118 +
 make/tools/crules/resources/crules.properties      |   28 +
 make/tools/genstubs/GenStubs.java                  |  336 ++
 makefiles/BuildLangtools.gmk                       |  192 +
 makefiles/Makefile                                 |   49 +
 .../classes/com/sun/javadoc/AnnotatedType.java     |   45 +
 .../classes/com/sun/javadoc/AnnotationDesc.java    |    6 +
 src/share/classes/com/sun/javadoc/ClassDoc.java    |    8 +-
 src/share/classes/com/sun/javadoc/Doc.java         |    6 +-
 .../com/sun/javadoc/ExecutableMemberDoc.java       |   18 +-
 src/share/classes/com/sun/javadoc/MethodDoc.java   |    7 +-
 .../classes/com/sun/javadoc/SerialFieldTag.java    |    4 +-
 src/share/classes/com/sun/javadoc/Tag.java         |   34 +-
 src/share/classes/com/sun/javadoc/Type.java        |   21 +-
 .../classes/com/sun/javadoc/TypeVariable.java      |    9 +-
 .../com/sun/mirror/apt/AnnotationProcessor.java    |   70 -
 .../mirror/apt/AnnotationProcessorEnvironment.java |  182 -
 .../sun/mirror/apt/AnnotationProcessorFactory.java |  109 -
 .../mirror/apt/AnnotationProcessorListener.java    |   42 -
 .../com/sun/mirror/apt/AnnotationProcessors.java   |  123 -
 src/share/classes/com/sun/mirror/apt/Filer.java    |  162 -
 src/share/classes/com/sun/mirror/apt/Messager.java |   92 -
 .../com/sun/mirror/apt/RoundCompleteEvent.java     |   75 -
 .../com/sun/mirror/apt/RoundCompleteListener.java  |   49 -
 .../classes/com/sun/mirror/apt/RoundState.java     |   66 -
 .../classes/com/sun/mirror/apt/package-info.java   |   38 -
 .../sun/mirror/declaration/AnnotationMirror.java   |   87 -
 .../declaration/AnnotationTypeDeclaration.java     |   57 -
 .../AnnotationTypeElementDeclaration.java          |   57 -
 .../sun/mirror/declaration/AnnotationValue.java    |   82 -
 .../sun/mirror/declaration/ClassDeclaration.java   |   89 -
 .../mirror/declaration/ConstructorDeclaration.java |   44 -
 .../com/sun/mirror/declaration/Declaration.java    |  169 -
 .../declaration/EnumConstantDeclaration.java       |   48 -
 .../sun/mirror/declaration/EnumDeclaration.java    |   55 -
 .../mirror/declaration/ExecutableDeclaration.java  |   85 -
 .../sun/mirror/declaration/FieldDeclaration.java   |   79 -
 .../mirror/declaration/InterfaceDeclaration.java   |   57 -
 .../sun/mirror/declaration/MemberDeclaration.java  |   57 -
 .../sun/mirror/declaration/MethodDeclaration.java  |   59 -
 .../com/sun/mirror/declaration/Modifier.java       |   77 -
 .../sun/mirror/declaration/PackageDeclaration.java |  101 -
 .../mirror/declaration/ParameterDeclaration.java   |   54 -
 .../sun/mirror/declaration/TypeDeclaration.java    |  146 -
 .../declaration/TypeParameterDeclaration.java      |   69 -
 .../com/sun/mirror/declaration/package-info.java   |   40 -
 src/share/classes/com/sun/mirror/overview.html     |  111 -
 .../com/sun/mirror/type/AnnotationType.java        |   52 -
 .../classes/com/sun/mirror/type/ArrayType.java     |   53 -
 .../classes/com/sun/mirror/type/ClassType.java     |   74 -
 .../classes/com/sun/mirror/type/DeclaredType.java  |  111 -
 .../classes/com/sun/mirror/type/EnumType.java      |   52 -
 .../classes/com/sun/mirror/type/InterfaceType.java |   59 -
 .../com/sun/mirror/type/MirroredTypeException.java |   88 -
 .../sun/mirror/type/MirroredTypesException.java    |   97 -
 .../classes/com/sun/mirror/type/PrimitiveType.java |   73 -
 .../classes/com/sun/mirror/type/ReferenceType.java |   45 -
 .../classes/com/sun/mirror/type/TypeMirror.java    |   85 -
 .../classes/com/sun/mirror/type/TypeVariable.java  |   57 -
 .../classes/com/sun/mirror/type/VoidType.java      |   49 -
 .../classes/com/sun/mirror/type/WildcardType.java  |   74 -
 .../classes/com/sun/mirror/type/package-info.java  |   37 -
 .../com/sun/mirror/util/DeclarationFilter.java     |  319 --
 .../com/sun/mirror/util/DeclarationScanner.java    |  267 --
 .../com/sun/mirror/util/DeclarationVisitor.java    |  149 -
 .../com/sun/mirror/util/DeclarationVisitors.java   |  104 -
 .../classes/com/sun/mirror/util/Declarations.java  |   69 -
 .../sun/mirror/util/SimpleDeclarationVisitor.java  |  216 --
 .../com/sun/mirror/util/SimpleTypeVisitor.java     |  175 -
 .../sun/mirror/util/SourceOrderDeclScanner.java    |  258 --
 .../com/sun/mirror/util/SourcePosition.java        |   75 -
 .../classes/com/sun/mirror/util/TypeVisitor.java   |  137 -
 src/share/classes/com/sun/mirror/util/Types.java   |  189 -
 .../classes/com/sun/mirror/util/package-info.java  |   37 -
 .../com/sun/source/doctree/AttributeTree.java      |   44 +
 .../classes/com/sun/source/doctree/AuthorTree.java |   41 +
 .../com/sun/source/doctree/BlockTagTree.java       |   37 +
 .../com/sun/source/doctree/CommentTree.java        |   40 +
 .../com/sun/source/doctree/DeprecatedTree.java     |   41 +
 .../com/sun/source/doctree/DocCommentTree.java     |   43 +
 .../com/sun/source/doctree/DocRootTree.java        |   37 +
 .../classes/com/sun/source/doctree/DocTree.java    |  256 ++
 .../com/sun/source/doctree/DocTreeVisitor.java     |   88 +
 .../com/sun/source/doctree/EndElementTree.java     |   41 +
 .../classes/com/sun/source/doctree/EntityTree.java |   42 +
 .../com/sun/source/doctree/ErroneousTree.java      |   44 +
 .../com/sun/source/doctree/IdentifierTree.java     |   41 +
 .../com/sun/source/doctree/InheritDocTree.java     |   38 +
 .../com/sun/source/doctree/InlineTagTree.java      |   37 +
 .../classes/com/sun/source/doctree/LinkTree.java   |   43 +
 .../com/sun/source/doctree/LiteralTree.java        |   40 +
 .../classes/com/sun/source/doctree/ParamTree.java  |   43 +
 .../com/sun/source/doctree/ReferenceTree.java      |   39 +
 .../classes/com/sun/source/doctree/ReturnTree.java |   41 +
 .../classes/com/sun/source/doctree/SeeTree.java    |   44 +
 .../com/sun/source/doctree/SerialDataTree.java     |   41 +
 .../com/sun/source/doctree/SerialFieldTree.java    |   43 +
 .../classes/com/sun/source/doctree/SerialTree.java |   41 +
 .../classes/com/sun/source/doctree/SinceTree.java  |   41 +
 .../com/sun/source/doctree/StartElementTree.java   |   44 +
 .../classes/com/sun/source/doctree/TextTree.java   |   36 +
 .../classes/com/sun/source/doctree/ThrowsTree.java |   45 +
 .../sun/source/doctree/UnknownBlockTagTree.java    |   41 +
 .../sun/source/doctree/UnknownInlineTagTree.java   |   41 +
 .../classes/com/sun/source/doctree/ValueTree.java  |   39 +
 .../com/sun/source/doctree/VersionTree.java        |   42 +
 .../com/sun/source/doctree/package-info.java       |   35 +
 .../com/sun/source/tree/AnnotatedTypeTree.java     |   48 +
 .../com/sun/source/tree/AnnotationTree.java        |    3 +-
 .../com/sun/source/tree/ArrayAccessTree.java       |    3 +-
 .../classes/com/sun/source/tree/ArrayTypeTree.java |    3 +-
 .../classes/com/sun/source/tree/AssertTree.java    |    3 +-
 .../com/sun/source/tree/AssignmentTree.java        |    3 +-
 .../classes/com/sun/source/tree/BinaryTree.java    |    3 +-
 .../classes/com/sun/source/tree/BlockTree.java     |    3 +-
 .../classes/com/sun/source/tree/BreakTree.java     |    3 +-
 .../classes/com/sun/source/tree/CaseTree.java      |    3 +-
 .../classes/com/sun/source/tree/CatchTree.java     |    3 +-
 .../classes/com/sun/source/tree/ClassTree.java     |    3 +-
 .../com/sun/source/tree/CompilationUnitTree.java   |    4 +-
 .../sun/source/tree/CompoundAssignmentTree.java    |    3 +-
 .../sun/source/tree/ConditionalExpressionTree.java |    3 +-
 .../classes/com/sun/source/tree/ContinueTree.java  |    3 +-
 .../com/sun/source/tree/DoWhileLoopTree.java       |    3 +-
 .../com/sun/source/tree/EmptyStatementTree.java    |    3 +-
 .../com/sun/source/tree/EnhancedForLoopTree.java   |    3 +-
 .../classes/com/sun/source/tree/ErroneousTree.java |    3 +-
 .../sun/source/tree/ExpressionStatementTree.java   |    3 +-
 .../com/sun/source/tree/ExpressionTree.java        |    3 +-
 .../classes/com/sun/source/tree/ForLoopTree.java   |    3 +-
 .../com/sun/source/tree/IdentifierTree.java        |    3 +-
 src/share/classes/com/sun/source/tree/IfTree.java  |    3 +-
 .../classes/com/sun/source/tree/ImportTree.java    |    3 +-
 .../com/sun/source/tree/InstanceOfTree.java        |    3 +-
 .../com/sun/source/tree/IntersectionTypeTree.java  |   40 +
 .../com/sun/source/tree/LabeledStatementTree.java  |    3 +-
 .../com/sun/source/tree/LambdaExpressionTree.java  |   58 +
 src/share/classes/com/sun/source/tree/LineMap.java |    7 +-
 .../classes/com/sun/source/tree/LiteralTree.java   |    3 +-
 .../com/sun/source/tree/MemberReferenceTree.java   |   60 +
 .../com/sun/source/tree/MemberSelectTree.java      |    3 +-
 .../com/sun/source/tree/MethodInvocationTree.java  |    3 +-
 .../classes/com/sun/source/tree/MethodTree.java    |    4 +-
 .../classes/com/sun/source/tree/ModifiersTree.java |    3 +-
 .../classes/com/sun/source/tree/NewArrayTree.java  |    3 +-
 .../classes/com/sun/source/tree/NewClassTree.java  |    3 +-
 .../com/sun/source/tree/ParameterizedTypeTree.java |    3 +-
 .../com/sun/source/tree/ParenthesizedTree.java     |    3 +-
 .../com/sun/source/tree/PrimitiveTypeTree.java     |    3 +-
 .../classes/com/sun/source/tree/ReturnTree.java    |    3 +-
 src/share/classes/com/sun/source/tree/Scope.java   |    5 +-
 .../classes/com/sun/source/tree/StatementTree.java |    3 +-
 .../classes/com/sun/source/tree/SwitchTree.java    |    3 +-
 .../com/sun/source/tree/SynchronizedTree.java      |    3 +-
 .../classes/com/sun/source/tree/ThrowTree.java     |    3 +-
 src/share/classes/com/sun/source/tree/Tree.java    |   32 +-
 .../classes/com/sun/source/tree/TreeVisitor.java   |    7 +-
 src/share/classes/com/sun/source/tree/TryTree.java |    3 +-
 .../classes/com/sun/source/tree/TypeCastTree.java  |    3 +-
 .../com/sun/source/tree/TypeParameterTree.java     |    4 +-
 .../classes/com/sun/source/tree/UnaryTree.java     |    3 +-
 .../classes/com/sun/source/tree/UnionTypeTree.java |    3 +-
 .../classes/com/sun/source/tree/VariableTree.java  |    5 +-
 .../classes/com/sun/source/tree/WhileLoopTree.java |    3 +-
 .../classes/com/sun/source/tree/WildcardTree.java  |    3 +-
 .../classes/com/sun/source/tree/package-info.java  |    3 +-
 .../com/sun/source/util/DocSourcePositions.java    |   98 +
 .../classes/com/sun/source/util/DocTreePath.java   |  171 +
 .../com/sun/source/util/DocTreePathScanner.java    |   80 +
 .../com/sun/source/util/DocTreeScanner.java        |  274 ++
 .../classes/com/sun/source/util/DocTrees.java      |   90 +
 .../classes/com/sun/source/util/JavacTask.java     |   84 +-
 src/share/classes/com/sun/source/util/Plugin.java  |   65 +
 .../com/sun/source/util/SimpleDocTreeVisitor.java  |  180 +
 .../com/sun/source/util/SimpleTreeVisitor.java     |   19 +-
 .../com/sun/source/util/SourcePositions.java       |    5 +-
 .../classes/com/sun/source/util/TaskEvent.java     |    9 +-
 .../classes/com/sun/source/util/TaskListener.java  |    3 +-
 .../classes/com/sun/source/util/TreePath.java      |   21 +-
 .../com/sun/source/util/TreePathScanner.java       |    3 +-
 .../classes/com/sun/source/util/TreeScanner.java   |   32 +-
 src/share/classes/com/sun/source/util/Trees.java   |   11 +-
 .../classes/com/sun/source/util/package-info.java  |    3 +-
 src/share/classes/com/sun/tools/apt/Main.java      |  115 -
 .../tools/apt/comp/AnnotationProcessingError.java  |   33 -
 src/share/classes/com/sun/tools/apt/comp/Apt.java  |  509 ---
 .../com/sun/tools/apt/comp/BootstrapAPF.java       |   59 -
 .../classes/com/sun/tools/apt/comp/PrintAP.java    |  467 ---
 .../apt/comp/UsageMessageNeededException.java      |   31 -
 .../com/sun/tools/apt/main/AptJavaCompiler.java    |  292 --
 .../com/sun/tools/apt/main/CommandLine.java        |   90 -
 src/share/classes/com/sun/tools/apt/main/Main.java | 1281 -------
 .../classes/com/sun/tools/apt/mirror/AptEnv.java   |  107 -
 .../apt/AnnotationProcessorEnvironmentImpl.java    |  185 -
 .../com/sun/tools/apt/mirror/apt/FilerImpl.java    |  354 --
 .../com/sun/tools/apt/mirror/apt/MessagerImpl.java |  121 -
 .../apt/mirror/apt/RoundCompleteEventImpl.java     |   40 -
 .../sun/tools/apt/mirror/apt/RoundStateImpl.java   |   82 -
 .../mirror/declaration/AnnotationMirrorImpl.java   |  136 -
 .../mirror/declaration/AnnotationProxyMaker.java   |  355 --
 .../declaration/AnnotationTypeDeclarationImpl.java |   63 -
 .../AnnotationTypeElementDeclarationImpl.java      |   68 -
 .../mirror/declaration/AnnotationValueImpl.java    |  121 -
 .../mirror/declaration/ClassDeclarationImpl.java   |  115 -
 .../tools/apt/mirror/declaration/Constants.java    |  294 --
 .../declaration/ConstructorDeclarationImpl.java    |   65 -
 .../apt/mirror/declaration/DeclarationImpl.java    |  254 --
 .../apt/mirror/declaration/DeclarationMaker.java   |  270 --
 .../declaration/EnumConstantDeclarationImpl.java   |   59 -
 .../mirror/declaration/EnumDeclarationImpl.java    |   63 -
 .../declaration/ExecutableDeclarationImpl.java     |   89 -
 .../mirror/declaration/FieldDeclarationImpl.java   |   98 -
 .../declaration/InterfaceDeclarationImpl.java      |   52 -
 .../mirror/declaration/MemberDeclarationImpl.java  |  111 -
 .../mirror/declaration/MethodDeclarationImpl.java  |   61 -
 .../mirror/declaration/PackageDeclarationImpl.java |  126 -
 .../declaration/ParameterDeclarationImpl.java      |  100 -
 .../mirror/declaration/TypeDeclarationImpl.java    |  157 -
 .../declaration/TypeParameterDeclarationImpl.java  |  121 -
 .../tools/apt/mirror/type/AnnotationTypeImpl.java  |   61 -
 .../sun/tools/apt/mirror/type/ArrayTypeImpl.java   |   63 -
 .../sun/tools/apt/mirror/type/ClassTypeImpl.java   |   72 -
 .../tools/apt/mirror/type/DeclaredTypeImpl.java    |  112 -
 .../sun/tools/apt/mirror/type/EnumTypeImpl.java    |   60 -
 .../tools/apt/mirror/type/InterfaceTypeImpl.java   |   61 -
 .../tools/apt/mirror/type/PrimitiveTypeImpl.java   |   84 -
 .../com/sun/tools/apt/mirror/type/TypeMaker.java   |  160 -
 .../sun/tools/apt/mirror/type/TypeMirrorImpl.java  |   76 -
 .../tools/apt/mirror/type/TypeVariableImpl.java    |   77 -
 .../sun/tools/apt/mirror/type/VoidTypeImpl.java    |   50 -
 .../tools/apt/mirror/type/WildcardTypeImpl.java    |  111 -
 .../tools/apt/mirror/util/DeclarationsImpl.java    |  135 -
 .../tools/apt/mirror/util/SourcePositionImpl.java  |   94 -
 .../com/sun/tools/apt/mirror/util/TypesImpl.java   |  229 --
 .../com/sun/tools/apt/resources/apt.properties     |  184 -
 .../com/sun/tools/apt/resources/apt_ja.properties  |  126 -
 .../sun/tools/apt/resources/apt_zh_CN.properties   |  126 -
 src/share/classes/com/sun/tools/apt/util/Bark.java |  174 -
 .../com/sun/tools/classfile/AccessFlags.java       |   26 +-
 .../classes/com/sun/tools/classfile/Attribute.java |   21 +-
 .../classfile/BootstrapMethods_attribute.java      |    6 +-
 .../classes/com/sun/tools/classfile/ClassFile.java |   28 +-
 .../com/sun/tools/classfile/ClassTranslator.java   |    5 +-
 .../com/sun/tools/classfile/ClassWriter.java       |  116 +-
 .../com/sun/tools/classfile/Code_attribute.java    |    6 +-
 .../com/sun/tools/classfile/DefaultAttribute.java  |   16 +-
 .../com/sun/tools/classfile/Dependencies.java      |  114 +-
 .../com/sun/tools/classfile/Dependency.java        |   12 +
 .../com/sun/tools/classfile/Descriptor.java        |    6 +-
 .../com/sun/tools/classfile/Instruction.java       |   18 +-
 .../classfile/MethodParameters_attribute.java      |   87 +
 .../classes/com/sun/tools/classfile/Opcode.java    |   34 +-
 .../com/sun/tools/classfile/ReferenceFinder.java   |  240 ++
 .../RuntimeInvisibleTypeAnnotations_attribute.java |   56 +
 .../RuntimeTypeAnnotations_attribute.java          |   61 +
 .../RuntimeVisibleTypeAnnotations_attribute.java   |   56 +
 .../classfile/SourceDebugExtension_attribute.java  |   12 +-
 .../com/sun/tools/classfile/TypeAnnotation.java    |  657 ++++
 .../html/AbstractExecutableMemberWriter.java       |  153 +-
 .../doclets/formats/html/AbstractIndexWriter.java  |   51 +-
 .../doclets/formats/html/AbstractMemberWriter.java |  197 +-
 .../formats/html/AbstractPackageIndexWriter.java   |   55 +-
 .../formats/html/AbstractProfileIndexWriter.java   |  276 ++
 .../doclets/formats/html/AbstractTreeWriter.java   |   49 +-
 .../formats/html/AllClassesFrameWriter.java        |   40 +-
 .../AnnotationTypeOptionalMemberWriterImpl.java    |   25 +-
 .../AnnotationTypeRequiredMemberWriterImpl.java    |   45 +-
 .../formats/html/AnnotationTypeWriterImpl.java     |   61 +-
 .../tools/doclets/formats/html/ClassUseWriter.java |  124 +-
 .../doclets/formats/html/ClassWriterImpl.java      |  158 +-
 .../doclets/formats/html/ConfigurationImpl.java    |  141 +-
 .../formats/html/ConstantsSummaryWriterImpl.java   |   46 +-
 .../formats/html/ConstructorWriterImpl.java        |   47 +-
 .../doclets/formats/html/DeprecatedListWriter.java |   19 +-
 .../formats/html/EnumConstantWriterImpl.java       |   43 +-
 .../doclets/formats/html/FieldWriterImpl.java      |   67 +-
 .../doclets/formats/html/FrameOutputWriter.java    |   36 +-
 .../sun/tools/doclets/formats/html/HelpWriter.java |   40 +-
 .../sun/tools/doclets/formats/html/HtmlDoclet.java |  170 +-
 .../doclets/formats/html/HtmlDocletWriter.java     | 1997 ++++-------
 .../formats/html/HtmlSerialFieldWriter.java        |   51 +-
 .../formats/html/HtmlSerialMethodWriter.java       |   35 +-
 .../doclets/formats/html/LinkFactoryImpl.java      |  123 +-
 .../tools/doclets/formats/html/LinkInfoImpl.java   |  550 ++-
 .../tools/doclets/formats/html/LinkOutputImpl.java |   18 +-
 .../doclets/formats/html/MethodWriterImpl.java     |   91 +-
 .../formats/html/NestedClassWriterImpl.java        |   57 +-
 .../doclets/formats/html/PackageFrameWriter.java   |   40 +-
 .../formats/html/PackageIndexFrameWriter.java      |   47 +-
 .../doclets/formats/html/PackageIndexWriter.java   |   70 +-
 .../doclets/formats/html/PackageTreeWriter.java    |   35 +-
 .../doclets/formats/html/PackageUseWriter.java     |   47 +-
 .../doclets/formats/html/PackageWriterImpl.java    |   59 +-
 .../formats/html/ProfileIndexFrameWriter.java      |  173 +
 .../formats/html/ProfilePackageFrameWriter.java    |  186 +
 .../html/ProfilePackageIndexFrameWriter.java       |  200 ++
 .../formats/html/ProfilePackageWriterImpl.java     |  296 ++
 .../doclets/formats/html/ProfileWriterImpl.java    |  208 ++
 .../doclets/formats/html/PropertyWriterImpl.java   |  141 +-
 .../formats/html/SerializedFormWriterImpl.java     |   72 +-
 .../doclets/formats/html/SingleIndexWriter.java    |   18 +-
 .../formats/html/SourceToHTMLConverter.java        |  142 +-
 .../doclets/formats/html/SplitIndexWriter.java     |   35 +-
 .../formats/html/SubWriterHolderWriter.java        |  145 +-
 .../doclets/formats/html/TagletOutputImpl.java     |   76 -
 .../doclets/formats/html/TagletWriterImpl.java     |  285 +-
 .../sun/tools/doclets/formats/html/TreeWriter.java |   17 +-
 .../doclets/formats/html/WriterFactoryImpl.java    |   69 +-
 .../tools/doclets/formats/html/markup/Comment.java |   26 +-
 .../formats/html/markup/ContentBuilder.java        |   97 +
 .../tools/doclets/formats/html/markup/DocType.java |   46 +-
 .../doclets/formats/html/markup/HtmlAttr.java      |    7 +-
 .../doclets/formats/html/markup/HtmlConstants.java |   12 +-
 .../doclets/formats/html/markup/HtmlDocWriter.java |  309 +-
 .../doclets/formats/html/markup/HtmlDocument.java  |   17 +-
 .../doclets/formats/html/markup/HtmlStyle.java     |    9 +-
 .../tools/doclets/formats/html/markup/HtmlTag.java |   20 +-
 .../doclets/formats/html/markup/HtmlTree.java      |  156 +-
 .../doclets/formats/html/markup/HtmlWriter.java    | 1261 +------
 .../tools/doclets/formats/html/markup/RawHtml.java |   80 +-
 .../doclets/formats/html/markup/StringContent.java |   41 +-
 .../formats/html/resources/standard.properties     |  137 +-
 .../formats/html/resources/standard_ja.properties  |  113 +-
 .../html/resources/standard_zh_CN.properties       |   52 +-
 .../doclets/internal/toolkit/AbstractDoclet.java   |   43 +-
 .../AnnotationTypeOptionalMemberWriter.java        |    9 +-
 .../AnnotationTypeRequiredMemberWriter.java        |   10 +-
 .../internal/toolkit/AnnotationTypeWriter.java     |   11 +-
 .../doclets/internal/toolkit/ClassWriter.java      |   18 +-
 .../doclets/internal/toolkit/Configuration.java    |  357 +-
 .../internal/toolkit/ConstantsSummaryWriter.java   |   14 +-
 .../internal/toolkit/ConstructorWriter.java        |    9 +-
 .../tools/doclets/internal/toolkit/Content.java    |   64 +-
 .../internal/toolkit/EnumConstantWriter.java       |   11 +-
 .../doclets/internal/toolkit/FieldWriter.java      |    9 +-
 .../internal/toolkit/MemberSummaryWriter.java      |   19 +-
 .../doclets/internal/toolkit/MethodWriter.java     |    9 +-
 .../internal/toolkit/NestedClassWriter.java        |    9 +-
 .../internal/toolkit/PackageSummaryWriter.java     |   21 +-
 .../toolkit/ProfilePackageSummaryWriter.java       |  116 +
 .../internal/toolkit/ProfileSummaryWriter.java     |  120 +
 .../doclets/internal/toolkit/PropertyWriter.java   |   77 +-
 .../internal/toolkit/SerializedFormWriter.java     |   11 +-
 .../doclets/internal/toolkit/WriterFactory.java    |   39 +-
 .../internal/toolkit/builders/AbstractBuilder.java |   52 +-
 .../toolkit/builders/AbstractMemberBuilder.java    |   16 +-
 .../toolkit/builders/AnnotationTypeBuilder.java    |   64 +-
 .../AnnotationTypeOptionalMemberBuilder.java       |   49 +-
 .../AnnotationTypeRequiredMemberBuilder.java       |   57 +-
 .../internal/toolkit/builders/BuilderFactory.java  |   93 +-
 .../internal/toolkit/builders/ClassBuilder.java    |   98 +-
 .../toolkit/builders/ConstantsSummaryBuilder.java  |   49 +-
 .../toolkit/builders/ConstructorBuilder.java       |   74 +-
 .../toolkit/builders/EnumConstantBuilder.java      |   69 +-
 .../internal/toolkit/builders/FieldBuilder.java    |   69 +-
 .../internal/toolkit/builders/LayoutParser.java    |   27 +-
 .../toolkit/builders/MemberSummaryBuilder.java     |  136 +-
 .../internal/toolkit/builders/MethodBuilder.java   |   64 +-
 .../toolkit/builders/PackageSummaryBuilder.java    |   96 +-
 .../builders/ProfilePackageSummaryBuilder.java     |  374 ++
 .../toolkit/builders/ProfileSummaryBuilder.java    |  328 ++
 .../internal/toolkit/builders/PropertyBuilder.java |  149 +-
 .../toolkit/builders/SerializedFormBuilder.java    |   32 +-
 .../doclets/internal/toolkit/builders/XMLNode.java |    7 +-
 .../internal/toolkit/resources/activetitlebar.gif  |  Bin 0 -> 10824 bytes
 .../toolkit/resources/activetitlebar_end.gif       |  Bin 0 -> 909 bytes
 .../doclets/internal/toolkit/resources/doclet.xml  |   19 +-
 .../internal/toolkit/resources/doclets.properties  |   16 +-
 .../toolkit/resources/doclets_ja.properties        |   26 +-
 .../toolkit/resources/doclets_zh_CN.properties     |   20 +-
 .../doclets/internal/toolkit/resources/script.js   |   30 +
 .../internal/toolkit/resources/stylesheet.css      |   47 +
 .../taglets/BaseExecutableMemberTaglet.java        |    9 +-
 .../internal/toolkit/taglets/BaseInlineTaglet.java |    9 +-
 .../toolkit/taglets/BasePropertyTaglet.java        |   21 +-
 .../internal/toolkit/taglets/BaseTaglet.java       |   15 +-
 .../internal/toolkit/taglets/CodeTaglet.java       |   39 +-
 .../internal/toolkit/taglets/DeprecatedTaglet.java |   12 +-
 .../internal/toolkit/taglets/DocRootTaglet.java    |   12 +-
 .../internal/toolkit/taglets/ExpertTaglet.java     |   93 -
 .../internal/toolkit/taglets/InheritDocTaglet.java |   89 +-
 .../toolkit/taglets/InheritableTaglet.java         |    7 +-
 .../internal/toolkit/taglets/LegacyTaglet.java     |   23 +-
 .../internal/toolkit/taglets/LiteralTaglet.java    |   63 +-
 .../internal/toolkit/taglets/ParamTaglet.java      |   63 +-
 .../toolkit/taglets/PropertyGetterTaglet.java      |    9 +-
 .../toolkit/taglets/PropertySetterTaglet.java      |   11 +-
 .../internal/toolkit/taglets/ReturnTaglet.java     |   18 +-
 .../internal/toolkit/taglets/SeeTaglet.java        |   18 +-
 .../internal/toolkit/taglets/SimpleTaglet.java     |   28 +-
 .../doclets/internal/toolkit/taglets/Taglet.java   |   13 +-
 .../internal/toolkit/taglets/TagletManager.java    |  281 +-
 .../internal/toolkit/taglets/TagletOutput.java     |   55 -
 .../internal/toolkit/taglets/TagletWriter.java     |   97 +-
 .../internal/toolkit/taglets/ThrowsTaglet.java     |   53 +-
 .../internal/toolkit/taglets/ValueTaglet.java      |   19 +-
 .../internal/toolkit/util/ClassDocCatalog.java     |   11 +-
 .../doclets/internal/toolkit/util/ClassTree.java   |   22 +-
 .../internal/toolkit/util/ClassUseMapper.java      |   12 +-
 .../toolkit/util/CommentedMethodFinder.java        |    9 +-
 .../toolkit/util/DeprecatedAPIListBuilder.java     |   12 +-
 .../internal/toolkit/util/DirectoryManager.java    |  317 --
 .../doclets/internal/toolkit/util/DocFile.java     |  259 ++
 .../internal/toolkit/util/DocFileFactory.java      |  100 +
 .../doclets/internal/toolkit/util/DocFinder.java   |  114 +-
 .../doclets/internal/toolkit/util/DocLink.java     |   97 +
 .../doclets/internal/toolkit/util/DocPath.java     |  191 +
 .../doclets/internal/toolkit/util/DocPaths.java    |  141 +
 .../toolkit/util/DocletAbortException.java         |    8 +-
 .../internal/toolkit/util/DocletConstants.java     |   45 +-
 .../doclets/internal/toolkit/util/Extern.java      |  153 +-
 .../tools/doclets/internal/toolkit/util/Group.java |   14 +-
 .../internal/toolkit/util/ImplementedMethods.java  |   12 +-
 .../internal/toolkit/util/IndexBuilder.java        |   35 +-
 .../internal/toolkit/util/MessageRetriever.java    |   23 +-
 .../internal/toolkit/util/MetaKeywords.java        |   29 +-
 .../internal/toolkit/util/MethodFinder.java        |    9 +-
 .../doclets/internal/toolkit/util/MethodTypes.java |   69 +
 .../internal/toolkit/util/PackageListWriter.java   |   19 +-
 .../internal/toolkit/util/PathDocFileFactory.java  |  317 ++
 .../toolkit/util/SimpleDocFileFactory.java         |  292 ++
 .../doclets/internal/toolkit/util/SourcePath.java  |  133 -
 .../toolkit/util/StandardDocFileFactory.java       |  322 ++
 .../internal/toolkit/util/TaggedMethodFinder.java  |    9 +-
 .../doclets/internal/toolkit/util/TextTag.java     |    9 +-
 .../tools/doclets/internal/toolkit/util/Util.java  |  540 +--
 .../internal/toolkit/util/VisibleMemberMap.java    |   99 +-
 .../internal/toolkit/util/links/LinkFactory.java   |  158 +-
 .../internal/toolkit/util/links/LinkInfo.java      |   49 +-
 .../internal/toolkit/util/links/LinkOutput.java    |   15 +-
 .../classes/com/sun/tools/doclets/package.html     |    4 +-
 .../classes/com/sun/tools/doclint/Checker.java     |  850 +++++
 .../classes/com/sun/tools/doclint/DocLint.java     |  360 ++
 .../classes/com/sun/tools/doclint/Entity.java      |  326 ++
 src/share/classes/com/sun/tools/doclint/Env.java   |  173 +
 .../classes/com/sun/tools/doclint/HtmlTag.java     |  455 +++
 .../classes/com/sun/tools/doclint/Messages.java    |  348 ++
 .../sun/tools/doclint/resources/doclint.properties |  116 +
 .../tools/doclint/resources/doclint_ja.properties  |   68 +
 .../doclint/resources/doclint_zh_CN.properties     |   68 +
 .../classes/com/sun/tools/javac/Launcher.java      |   73 -
 src/share/classes/com/sun/tools/javac/Main.java    |    7 +-
 src/share/classes/com/sun/tools/javac/Server.java  |  196 -
 .../com/sun/tools/javac/api/BasicJavacTask.java    |  161 +
 .../com/sun/tools/javac/api/ClientCodeWrapper.java |   63 +-
 .../sun/tools/javac/api/DiagnosticFormatter.java   |    4 +-
 .../com/sun/tools/javac/api/JavacScope.java        |    2 +-
 .../com/sun/tools/javac/api/JavacTaskImpl.java     |  131 +-
 .../classes/com/sun/tools/javac/api/JavacTool.java |  140 +-
 .../com/sun/tools/javac/api/JavacTrees.java        |  655 +++-
 .../com/sun/tools/javac/api/MultiTaskListener.java |  118 +
 .../tools/javac/api/WrappingJavaFileManager.java   |    5 +-
 .../com/sun/tools/javac/code/Annotations.java      |  451 +++
 .../com/sun/tools/javac/code/Attribute.java        |   90 +-
 .../sun/tools/javac/code/DeferredLintHandler.java  |    4 +-
 .../classes/com/sun/tools/javac/code/Flags.java    |  217 +-
 .../classes/com/sun/tools/javac/code/Kinds.java    |   43 +-
 .../classes/com/sun/tools/javac/code/Lint.java     |   30 +-
 .../classes/com/sun/tools/javac/code/Printer.java  |  103 +-
 .../classes/com/sun/tools/javac/code/Scope.java    |   10 +-
 .../classes/com/sun/tools/javac/code/Source.java   |   62 +-
 .../classes/com/sun/tools/javac/code/Symbol.java   |  499 ++-
 .../classes/com/sun/tools/javac/code/Symtab.java   |  159 +-
 .../com/sun/tools/javac/code/TargetType.java       |  230 +-
 .../classes/com/sun/tools/javac/code/Type.java     | 1055 +++++-
 .../tools/javac/code/TypeAnnotationPosition.java   |  233 +-
 .../com/sun/tools/javac/code/TypeAnnotations.java  | 1288 +++++++
 .../classes/com/sun/tools/javac/code/TypeTag.java  |  240 ++
 .../classes/com/sun/tools/javac/code/TypeTags.java |  136 -
 .../classes/com/sun/tools/javac/code/Types.java    | 1516 ++++++--
 .../classes/com/sun/tools/javac/comp/Annotate.java |  379 +-
 .../classes/com/sun/tools/javac/comp/Attr.java     | 3197 ++++++++++++-----
 .../com/sun/tools/javac/comp/AttrContext.java      |   30 +-
 .../classes/com/sun/tools/javac/comp/Check.java    | 1213 +++++--
 .../com/sun/tools/javac/comp/CompileStates.java    |   92 +
 .../com/sun/tools/javac/comp/ConstFold.java        |   23 +-
 .../com/sun/tools/javac/comp/DeferredAttr.java     | 1076 ++++++
 .../classes/com/sun/tools/javac/comp/Enter.java    |   51 +-
 .../classes/com/sun/tools/javac/comp/Env.java      |    7 +-
 .../classes/com/sun/tools/javac/comp/Flow.java     | 3351 ++++++++++-------
 .../classes/com/sun/tools/javac/comp/Infer.java    | 2292 +++++++++---
 .../com/sun/tools/javac/comp/LambdaToMethod.java   | 2007 +++++++++++
 .../classes/com/sun/tools/javac/comp/Lower.java    |  775 ++--
 .../com/sun/tools/javac/comp/MemberEnter.java      |  703 ++--
 .../classes/com/sun/tools/javac/comp/Repair.java   |   89 +-
 .../classes/com/sun/tools/javac/comp/Resolve.java  | 3194 +++++++++++++----
 .../classes/com/sun/tools/javac/comp/Todo.java     |    7 +-
 .../com/sun/tools/javac/comp/TransTypes.java       |  190 +-
 .../com/sun/tools/javac/file/JavacFileManager.java |  104 +-
 .../com/sun/tools/javac/file/Locations.java        |  776 ++++
 .../classes/com/sun/tools/javac/file/Paths.java    |  558 ---
 .../com/sun/tools/javac/file/ZipFileIndex.java     |   20 +-
 .../classes/com/sun/tools/javac/jvm/ByteCodes.java |    4 +-
 .../classes/com/sun/tools/javac/jvm/CRTable.java   |   30 +-
 .../classes/com/sun/tools/javac/jvm/ClassFile.java |   44 +-
 .../com/sun/tools/javac/jvm/ClassReader.java       |  442 ++-
 .../com/sun/tools/javac/jvm/ClassWriter.java       |  739 ++--
 .../classes/com/sun/tools/javac/jvm/Code.java      |  237 +-
 src/share/classes/com/sun/tools/javac/jvm/Gen.java |  376 +-
 .../classes/com/sun/tools/javac/jvm/Items.java     |   44 +-
 .../classes/com/sun/tools/javac/jvm/JNIWriter.java |  856 +++++
 .../classes/com/sun/tools/javac/jvm/Pool.java      |  227 +-
 .../classes/com/sun/tools/javac/jvm/Profile.java   |  105 +
 .../classes/com/sun/tools/javac/jvm/Target.java    |   55 +-
 .../com/sun/tools/javac/jvm/UninitializedType.java |    8 +-
 .../com/sun/tools/javac/main/JavaCompiler.java     |  368 +-
 .../com/sun/tools/javac/main/JavacOption.java      |  298 --
 .../classes/com/sun/tools/javac/main/Main.java     |  373 +-
 .../classes/com/sun/tools/javac/main/Option.java   |  729 ++++
 .../com/sun/tools/javac/main/OptionHelper.java     |  117 +
 .../com/sun/tools/javac/main/OptionName.java       |  105 -
 .../sun/tools/javac/main/RecognizedOptions.java    |  643 ----
 .../tools/javac/model/AnnotationProxyMaker.java    |   15 +-
 .../sun/tools/javac/model/JavacAnnoConstructs.java |  437 +++
 .../com/sun/tools/javac/model/JavacElements.java   |   84 +-
 .../com/sun/tools/javac/model/JavacTypes.java      |   41 +-
 .../sun/tools/javac/nio/JavacPathFileManager.java  |   25 +-
 .../com/sun/tools/javac/nio/PathFileManager.java   |    5 +-
 .../com/sun/tools/javac/nio/PathFileObject.java    |    3 +-
 .../sun/tools/javac/parser/DocCommentParser.java   | 1391 ++++++++
 .../sun/tools/javac/parser/DocCommentScanner.java  |  420 ---
 .../com/sun/tools/javac/parser/EndPosParser.java   |  103 -
 .../com/sun/tools/javac/parser/JavaTokenizer.java  |  897 +++++
 .../com/sun/tools/javac/parser/JavacParser.java    | 3347 +++++++++++------
 .../sun/tools/javac/parser/JavadocTokenizer.java   |  447 +++
 .../com/sun/tools/javac/parser/Keywords.java       |   98 -
 .../tools/javac/parser/LazyDocCommentTable.java    |   98 +
 .../classes/com/sun/tools/javac/parser/Lexer.java  |   95 +-
 .../com/sun/tools/javac/parser/ParserFactory.java  |   38 +-
 .../com/sun/tools/javac/parser/Scanner.java        | 1127 +-----
 .../com/sun/tools/javac/parser/ScannerFactory.java |    8 +-
 .../classes/com/sun/tools/javac/parser/Token.java  |  198 -
 .../classes/com/sun/tools/javac/parser/Tokens.java |  481 +++
 .../com/sun/tools/javac/parser/UnicodeReader.java  |  285 ++
 .../com/sun/tools/javac/processing/JavacFiler.java |    2 +-
 .../sun/tools/javac/processing/JavacMessager.java  |    4 +-
 .../processing/JavacProcessingEnvironment.java     |  287 +-
 .../javac/processing/JavacRoundEnvironment.java    |   23 +-
 .../tools/javac/processing/PrintingProcessor.java  |    7 +-
 .../sun/tools/javac/processing/ServiceProxy.java   |    4 +-
 .../sun/tools/javac/resources/compiler.properties  |  672 +++-
 .../tools/javac/resources/compiler_ja.properties   | 1758 +++++++++
 .../javac/resources/compiler_zh_CN.properties      | 1758 +++++++++
 .../com/sun/tools/javac/resources/javac.properties |   38 +-
 .../com/sun/tools/javac/sym/CreateSymbols.java     |   42 +-
 .../classes/com/sun/tools/javac/sym/Profiles.java  |  297 ++
 .../classes/com/sun/tools/javac/tree/DCTree.java   |  888 +++++
 .../com/sun/tools/javac/tree/DocCommentTable.java  |   66 +
 .../com/sun/tools/javac/tree/DocPretty.java        |  520 +++
 .../com/sun/tools/javac/tree/DocTreeMaker.java     |  277 ++
 .../com/sun/tools/javac/tree/EndPosTable.java      |   55 +
 .../classes/com/sun/tools/javac/tree/JCTree.java   | 1123 +++---
 .../classes/com/sun/tools/javac/tree/Pretty.java   |  313 +-
 .../com/sun/tools/javac/tree/TreeCopier.java       |   58 +-
 .../classes/com/sun/tools/javac/tree/TreeInfo.java |  920 +++--
 .../com/sun/tools/javac/tree/TreeMaker.java        |  132 +-
 .../com/sun/tools/javac/tree/TreeScanner.java      |   29 +-
 .../com/sun/tools/javac/tree/TreeTranslator.java   |   32 +-
 .../javac/util/AbstractDiagnosticFormatter.java    |   30 +-
 .../com/sun/tools/javac/util/AbstractLog.java      |    3 +-
 .../com/sun/tools/javac/util/ArrayUtils.java       |   88 +
 .../com/sun/tools/javac/util/BaseFileManager.java  |   78 +-
 .../tools/javac/util/BasicDiagnosticFormatter.java |    8 +-
 .../classes/com/sun/tools/javac/util/Bits.java     |  232 +-
 .../com/sun/tools/javac/util/ByteBuffer.java       |   16 +-
 .../tools/javac/util/CloseableURLClassLoader.java  |  108 -
 .../com/sun/tools/javac/util/Constants.java        |    8 +-
 .../classes/com/sun/tools/javac/util/Context.java  |   15 +-
 .../classes/com/sun/tools/javac/util/Convert.java  |   22 +-
 .../com/sun/tools/javac/util/DiagnosticSource.java |   11 +-
 .../com/sun/tools/javac/util/GraphUtils.java       |  145 +
 .../com/sun/tools/javac/util/JCDiagnostic.java     |   53 +-
 .../com/sun/tools/javac/util/JavacMessages.java    |    4 +-
 .../classes/com/sun/tools/javac/util/List.java     |   51 +-
 .../classes/com/sun/tools/javac/util/Log.java      |  439 ++-
 .../tools/javac/util/MandatoryWarningHandler.java  |    4 +-
 .../classes/com/sun/tools/javac/util/Name.java     |   10 +-
 .../classes/com/sun/tools/javac/util/Names.java    |  384 +-
 .../classes/com/sun/tools/javac/util/Options.java  |   41 +-
 .../classes/com/sun/tools/javac/util/Pair.java     |   12 +-
 .../classes/com/sun/tools/javac/util/Position.java |   28 +-
 .../tools/javac/util/RawDiagnosticFormatter.java   |   20 +-
 .../tools/javac/util/RichDiagnosticFormatter.java  |   77 +-
 .../com/sun/tools/javac/util/ServiceLoader.java    |  437 +++
 .../com/sun/tools/javac/util/SharedNameTable.java  |   17 +-
 .../sun/tools/javac/util/UnsharedNameTable.java    |    4 +-
 .../classes/com/sun/tools/javac/util/Warner.java   |    1 -
 .../com/sun/tools/javadoc/AbstractTypeImpl.java    |   16 +-
 .../com/sun/tools/javadoc/AnnotatedTypeImpl.java   |  125 +
 .../com/sun/tools/javadoc/AnnotationDescImpl.java  |   17 +-
 .../sun/tools/javadoc/AnnotationTypeDocImpl.java   |   20 +-
 .../javadoc/AnnotationTypeElementDocImpl.java      |   19 +-
 .../com/sun/tools/javadoc/AnnotationValueImpl.java |   17 +-
 .../com/sun/tools/javadoc/ClassDocImpl.java        |   81 +-
 .../classes/com/sun/tools/javadoc/Comment.java     |   50 +-
 .../com/sun/tools/javadoc/ConstructorDocImpl.java  |   15 +-
 .../classes/com/sun/tools/javadoc/DocEnv.java      |  119 +-
 .../classes/com/sun/tools/javadoc/DocImpl.java     |   60 +-
 .../classes/com/sun/tools/javadoc/DocLocale.java   |   16 +-
 .../com/sun/tools/javadoc/DocletInvoker.java       |  102 +-
 .../sun/tools/javadoc/ExecutableMemberDocImpl.java |   28 +-
 .../com/sun/tools/javadoc/FieldDocImpl.java        |   40 +-
 .../com/sun/tools/javadoc/JavadocClassReader.java  |    8 +-
 .../com/sun/tools/javadoc/JavadocEnter.java        |   23 +-
 .../com/sun/tools/javadoc/JavadocMemberEnter.java  |   32 +-
 .../classes/com/sun/tools/javadoc/JavadocTodo.java |    8 +-
 .../classes/com/sun/tools/javadoc/JavadocTool.java |   48 +-
 src/share/classes/com/sun/tools/javadoc/Main.java  |    7 +-
 .../com/sun/tools/javadoc/MemberDocImpl.java       |   14 +-
 .../classes/com/sun/tools/javadoc/Messager.java    |  278 +-
 .../com/sun/tools/javadoc/MethodDocImpl.java       |   58 +-
 .../com/sun/tools/javadoc/ModifierFilter.java      |   10 +-
 .../com/sun/tools/javadoc/PackageDocImpl.java      |   42 +-
 .../com/sun/tools/javadoc/ParamTagImpl.java        |   13 +-
 .../com/sun/tools/javadoc/ParameterImpl.java       |   12 +-
 .../sun/tools/javadoc/ParameterizedTypeImpl.java   |   13 +-
 .../com/sun/tools/javadoc/PrimitiveType.java       |   28 +-
 .../sun/tools/javadoc/ProgramElementDocImpl.java   |   41 +-
 .../classes/com/sun/tools/javadoc/RootDocImpl.java |   29 +-
 .../classes/com/sun/tools/javadoc/SeeTagImpl.java  |   71 +-
 .../com/sun/tools/javadoc/SerialFieldTagImpl.java  |    7 +-
 .../com/sun/tools/javadoc/SerializedForm.java      |   15 +-
 .../com/sun/tools/javadoc/SourcePositionImpl.java  |    7 +-
 src/share/classes/com/sun/tools/javadoc/Start.java |  390 +-
 .../classes/com/sun/tools/javadoc/TagImpl.java     |    7 +-
 .../com/sun/tools/javadoc/ThrowsTagImpl.java       |   11 +-
 .../classes/com/sun/tools/javadoc/ToolOption.java  |  332 ++
 .../classes/com/sun/tools/javadoc/TypeMaker.java   |   59 +-
 .../com/sun/tools/javadoc/TypeVariableImpl.java    |   33 +-
 .../com/sun/tools/javadoc/WildcardTypeImpl.java    |    8 +-
 .../com/sun/tools/javadoc/api/JavadocTaskImpl.java |  100 +
 .../com/sun/tools/javadoc/api/JavadocTool.java     |  172 +
 .../sun/tools/javadoc/resources/javadoc.properties |   71 +-
 .../tools/javadoc/resources/javadoc_ja.properties  |   14 +-
 .../javadoc/resources/javadoc_zh_CN.properties     |   12 +-
 src/share/classes/com/sun/tools/javah/Gen.java     |    6 +-
 .../com/sun/tools/javah/JavahFileManager.java      |    8 +-
 .../classes/com/sun/tools/javah/JavahTask.java     |   21 +-
 src/share/classes/com/sun/tools/javah/LLNI.java    |    8 +-
 src/share/classes/com/sun/tools/javah/Mangle.java  |    8 +-
 .../com/sun/tools/javah/NativeHeaderTool.java      |    4 +-
 .../classes/com/sun/tools/javah/TypeSignature.java |    6 +-
 src/share/classes/com/sun/tools/javah/Util.java    |    6 +-
 .../com/sun/tools/javah/resources/l10n.properties  |    5 +-
 .../sun/tools/javah/resources/l10n_ja.properties   |    6 +-
 .../tools/javah/resources/l10n_zh_CN.properties    |    2 +-
 .../com/sun/tools/javap/AnnotationWriter.java      |  120 +-
 .../com/sun/tools/javap/AttributeWriter.java       |   69 +-
 .../classes/com/sun/tools/javap/ClassWriter.java   |   19 +-
 .../classes/com/sun/tools/javap/CodeWriter.java    |    9 +-
 .../com/sun/tools/javap/ConstantWriter.java        |    2 +-
 .../com/sun/tools/javap/DisassemblerTool.java      |    8 +-
 .../sun/tools/javap/InstructionDetailWriter.java   |    7 +-
 .../com/sun/tools/javap/JavapFileManager.java      |    8 +-
 .../classes/com/sun/tools/javap/JavapTask.java     |   70 +-
 src/share/classes/com/sun/tools/javap/Options.java |    4 +-
 .../com/sun/tools/javap/StackMapWriter.java        |   12 +-
 .../com/sun/tools/javap/TypeAnnotationWriter.java  |  126 +
 .../com/sun/tools/javap/resources/javap.properties |    5 +-
 .../sun/tools/javap/resources/javap_ja.properties  |   63 +
 .../tools/javap/resources/javap_zh_CN.properties   |   63 +
 .../classes/com/sun/tools/jdeps/Analyzer.java      |  238 ++
 src/share/classes/com/sun/tools/jdeps/Archive.java |   97 +
 .../com/sun/tools/jdeps/ClassFileReader.java       |  336 ++
 .../classes/com/sun/tools/jdeps/JdepsTask.java     |  575 +++
 src/share/classes/com/sun/tools/jdeps/Main.java    |   66 +
 .../com/sun/tools/jdeps/PlatformClassPath.java     |  107 +
 .../classes/com/sun/tools/jdeps/Profiles.java      |  241 ++
 .../com/sun/tools/jdeps/resources/jdeps.properties |   59 +
 .../sun/tools/jdeps/resources/jdeps_ja.properties  |   40 +
 .../tools/jdeps/resources/jdeps_zh_CN.properties   |   40 +
 .../jdeps/resources/version.properties-template    |   28 +
 .../classes/com/sun/tools/sjavac/BuildState.java   |  275 ++
 .../com/sun/tools/sjavac/CleanProperties.java      |  148 +
 .../classes/com/sun/tools/sjavac/CompileChunk.java |   57 +
 .../com/sun/tools/sjavac/CompileJavaPackages.java  |  345 ++
 .../com/sun/tools/sjavac/CompileProperties.java    |  221 ++
 .../classes/com/sun/tools/sjavac/CopyFile.java     |  116 +
 .../classes/com/sun/tools/sjavac/JavacState.java   |  857 +++++
 src/share/classes/com/sun/tools/sjavac/Log.java    |   92 +
 src/share/classes/com/sun/tools/sjavac/Main.java   |  966 +++++
 src/share/classes/com/sun/tools/sjavac/Module.java |  141 +
 .../classes/com/sun/tools/sjavac/Package.java      |  307 ++
 .../com/sun/tools/sjavac/ProblemException.java     |   41 +
 src/share/classes/com/sun/tools/sjavac/Source.java |  400 +++
 .../classes/com/sun/tools/sjavac/Transformer.java  |   99 +
 src/share/classes/com/sun/tools/sjavac/Util.java   |  160 +
 .../com/sun/tools/sjavac/comp/Dependencies.java    |  185 +
 .../tools/sjavac/comp/JavaCompilerWithDeps.java    |  109 +
 .../com/sun/tools/sjavac/comp/PubapiVisitor.java   |  157 +
 .../com/sun/tools/sjavac/comp/ResolveWithDeps.java |   67 +
 .../sun/tools/sjavac/comp/SmartFileManager.java    |  221 ++
 .../com/sun/tools/sjavac/comp/SmartFileObject.java |  126 +
 .../com/sun/tools/sjavac/comp/SmartWriter.java     |   78 +
 .../com/sun/tools/sjavac/server/CompilerPool.java  |  163 +
 .../sun/tools/sjavac/server/CompilerThread.java    |  420 +++
 .../com/sun/tools/sjavac/server/JavacServer.java   |  751 ++++
 .../com/sun/tools/sjavac/server/PortFile.java      |  259 ++
 .../com/sun/tools/sjavac/server/SysInfo.java       |   45 +
 .../annotation/processing/AbstractProcessor.java   |    8 +-
 .../javax/annotation/processing/Completions.java   |    4 +-
 .../annotation/processing/FilerException.java      |    3 +-
 .../processing/ProcessingEnvironment.java          |    4 +-
 .../javax/annotation/processing/Processor.java     |   61 +-
 .../processing/SupportedAnnotationTypes.java       |    8 +-
 .../annotation/processing/SupportedOptions.java    |    8 +-
 .../processing/SupportedSourceVersion.java         |    6 +-
 .../javax/lang/model/AnnotatedConstruct.java       |  235 ++
 .../classes/javax/lang/model/SourceVersion.java    |   29 +-
 .../javax/lang/model/element/AnnotationValue.java  |    6 +-
 .../lang/model/element/AnnotationValueVisitor.java |   14 +-
 .../classes/javax/lang/model/element/Element.java  |  103 +-
 .../javax/lang/model/element/ElementVisitor.java   |   14 +-
 .../lang/model/element/ExecutableElement.java      |   32 +-
 .../classes/javax/lang/model/element/Modifier.java |   15 +-
 .../javax/lang/model/element/NestingKind.java      |   18 +-
 .../javax/lang/model/element/PackageElement.java   |   18 +-
 .../javax/lang/model/element/TypeElement.java      |   12 +-
 .../javax/lang/model/element/VariableElement.java  |   28 +-
 .../javax/lang/model/element/package-info.java     |   11 +-
 .../javax/lang/model/type/ExecutableType.java      |   22 +-
 .../javax/lang/model/type/IntersectionType.java    |   47 +
 .../lang/model/type/MirroredTypeException.java     |    3 +-
 .../lang/model/type/MirroredTypesException.java    |    3 +-
 .../classes/javax/lang/model/type/TypeKind.java    |   11 +-
 .../classes/javax/lang/model/type/TypeMirror.java  |    6 +-
 .../classes/javax/lang/model/type/TypeVisitor.java |   24 +-
 .../util/AbstractAnnotationValueVisitor6.java      |   14 +-
 .../util/AbstractAnnotationValueVisitor7.java      |   16 +-
 .../util/AbstractAnnotationValueVisitor8.java      |   79 +
 .../lang/model/util/AbstractElementVisitor6.java   |   17 +-
 .../lang/model/util/AbstractElementVisitor7.java   |   17 +-
 .../lang/model/util/AbstractElementVisitor8.java   |   82 +
 .../lang/model/util/AbstractTypeVisitor6.java      |   26 +-
 .../lang/model/util/AbstractTypeVisitor7.java      |   12 +-
 .../lang/model/util/AbstractTypeVisitor8.java      |   87 +
 .../javax/lang/model/util/ElementFilter.java       |   16 +-
 .../javax/lang/model/util/ElementKindVisitor6.java |   12 +-
 .../javax/lang/model/util/ElementKindVisitor7.java |   17 +-
 .../javax/lang/model/util/ElementKindVisitor8.java |  106 +
 .../javax/lang/model/util/ElementScanner6.java     |   11 +-
 .../javax/lang/model/util/ElementScanner7.java     |    6 +-
 .../javax/lang/model/util/ElementScanner8.java     |  110 +
 .../classes/javax/lang/model/util/Elements.java    |   22 +-
 .../model/util/SimpleAnnotationValueVisitor6.java  |   12 +-
 .../model/util/SimpleAnnotationValueVisitor7.java  |   20 +-
 .../model/util/SimpleAnnotationValueVisitor8.java  |   96 +
 .../lang/model/util/SimpleElementVisitor6.java     |   13 +-
 .../lang/model/util/SimpleElementVisitor7.java     |   13 +-
 .../lang/model/util/SimpleElementVisitor8.java     |  101 +
 .../javax/lang/model/util/SimpleTypeVisitor6.java  |   16 +-
 .../javax/lang/model/util/SimpleTypeVisitor7.java  |   12 +-
 .../javax/lang/model/util/SimpleTypeVisitor8.java  |  101 +
 .../javax/lang/model/util/TypeKindVisitor6.java    |   18 +-
 .../javax/lang/model/util/TypeKindVisitor7.java    |   13 +-
 .../javax/lang/model/util/TypeKindVisitor8.java    |  104 +
 src/share/classes/javax/lang/model/util/Types.java |   13 +-
 .../classes/javax/tools/DocumentationTool.java     |  183 +
 .../javax/tools/ForwardingJavaFileManager.java     |    3 +-
 src/share/classes/javax/tools/JavaCompiler.java    |   12 +-
 src/share/classes/javax/tools/JavaFileObject.java  |    8 +-
 .../classes/javax/tools/StandardLocation.java      |   21 +-
 src/share/classes/javax/tools/ToolProvider.java    |   15 +-
 src/share/classes/jdk/Supported.java               |   53 +
 .../javac/processing/src/CheckNamesProcessor.java  |    6 +-
 .../language/model/CoreReflectionFactory.java      | 3767 ++++++++++++++++++++
 test/Makefile                                      |   46 +-
 test/com/sun/javadoc/5093723/T5093723.java         |    2 +-
 test/com/sun/javadoc/AuthorDD/AuthorDD.java        |    6 +-
 .../com/sun/javadoc/DocRootSlash/DocRootSlash.java |    3 +-
 .../sun/javadoc/InheritDocForUserTags/DocTest.java |  261 ++
 test/com/sun/javadoc/MetaTag/MetaTag.java          |   11 +-
 test/com/sun/javadoc/T6735320/T6735320.java        |    6 +-
 .../sun/javadoc/VersionNumber/VersionNumber.java   |    4 +-
 test/com/sun/javadoc/_template/Template.java       |   18 +-
 .../sun/javadoc/_template/TemplateComplete.java    |   18 +-
 .../testAbstractMethod/TestAbstractMethod.java     |  121 +
 test/com/sun/javadoc/testAbstractMethod/pkg/A.java |   31 +
 test/com/sun/javadoc/testAbstractMethod/pkg/B.java |   31 +
 test/com/sun/javadoc/testAbstractMethod/pkg/C.java |   29 +
 .../TestAnnotationOptional.java                    |   77 +
 .../pkg/AnnotationOptional.java                    |   36 +
 .../testBadSourceFile/TestBadSourceFile.java       |    4 +-
 .../TestConstructorIndent.java                     |    6 +-
 .../javadoc/testDocEncoding/TestDocEncoding.java   |   81 +
 test/com/sun/javadoc/testDocEncoding/pkg/Test.java |   31 +
 .../sun/javadoc/testDocFileDir/TestDocFileDir.java |   18 +-
 .../com/sun/javadoc/testDocFiles/TestDocFiles.java |   67 +
 test/com/sun/javadoc/testDocFiles/pkg/Test.java    |   27 +
 .../javadoc/testDocFiles/pkg/doc-files/test.txt    |    2 +
 .../javadoc/testGeneratedBy/TestGeneratedBy.java   |  112 +
 .../sun/javadoc/testGeneratedBy/pkg/MyClass.java   |   29 +
 .../sun/javadoc/testHelpOption/TestHelpOption.java |    3 +-
 test/com/sun/javadoc/testHref/TestHref.java        |    4 +-
 .../TestHtmlDefinitionListTag.java                 |  134 +-
 .../javadoc/testHtmlDocument/TestHtmlDocument.java |    4 +-
 .../testHtmlTableTags/TestHtmlTableTags.java       |   12 +-
 .../javadoc/testIndentation/TestIndentation.java   |   77 +
 test/com/sun/javadoc/testIndentation/p/Indent.java |   28 +
 test/com/sun/javadoc/testIndex/TestIndex.java      |   28 +-
 test/com/sun/javadoc/testJavaFX/C.java             |    3 +-
 test/com/sun/javadoc/testJavaFX/D.java             |    2 +-
 test/com/sun/javadoc/testJavaFX/TestJavaFX.java    |   22 +-
 .../sun/javadoc/testJavascript/TestJavascript.java |   42 +-
 .../testLambdaFeature/TestLambdaFeature.java       |  102 +
 test/com/sun/javadoc/testLambdaFeature/pkg/A.java  |   31 +
 test/com/sun/javadoc/testLambdaFeature/pkg/B.java  |   31 +
 .../testLiteralCodeInPre/TestLiteralCodeInPre.java |  117 +
 .../sun/javadoc/testLiteralCodeInPre/pkg/Test.java |   99 +
 .../javadoc/testMethodTypes/TestMethodTypes.java   |  139 +
 test/com/sun/javadoc/testMethodTypes/pkg1/A.java   |   77 +
 test/com/sun/javadoc/testMethodTypes/pkg1/B.java   |   56 +
 test/com/sun/javadoc/testMethodTypes/pkg1/D.java   |   53 +
 .../testNestedInlineTag/TestNestedInlineTag.java   |    9 +-
 .../testtaglets/BoldTaglet.java                    |    4 +-
 .../testtaglets/GreenTaglet.java                   |    4 +-
 .../testtaglets/UnderlineTaglet.java               |    4 +-
 .../TestNewLanguageFeatures.java                   |   40 +-
 .../javadoc/testPackagePage/TestPackagePage.java   |    4 +-
 .../javadoc/testParamTaglet/TestParamTaglet.java   |   10 +-
 .../testPrivateClasses/TestPrivateClasses.java     |   25 +-
 .../com/sun/javadoc/testProfiles/TestProfiles.java |  190 +
 .../sun/javadoc/testProfiles/pkg1/Class1Pkg1.java  |   32 +
 .../sun/javadoc/testProfiles/pkg1/Class2Pkg1.java  |   32 +
 .../sun/javadoc/testProfiles/pkg1/Class3Pkg1.java  |   32 +
 .../javadoc/testProfiles/pkg1/Interface1Pkg1.java  |   48 +
 .../sun/javadoc/testProfiles/pkg2/Anno1Pkg2.java   |   40 +
 .../sun/javadoc/testProfiles/pkg2/Anno2Pkg2.java   |   35 +
 .../sun/javadoc/testProfiles/pkg2/Class1Pkg2.java  |   51 +
 .../sun/javadoc/testProfiles/pkg3/Class1Pkg3.java  |   32 +
 .../sun/javadoc/testProfiles/pkg3/Class2Pkg3.java  |   32 +
 .../javadoc/testProfiles/pkg3/Interface1Pkg3.java  |   48 +
 .../sun/javadoc/testProfiles/pkg4/Anno1Pkg4.java   |   40 +
 .../sun/javadoc/testProfiles/pkg4/Class1Pkg4.java  |   32 +
 .../sun/javadoc/testProfiles/pkg5/Class1Pkg5.java  |   32 +
 .../javadoc/testProfiles/pkg5/Interface1Pkg5.java  |   40 +
 .../testProfiles/profile-rtjar-includes.txt        |   42 +
 .../TestRepeatedAnnotations.java                   |  187 +
 .../sun/javadoc/testRepeatedAnnotations/pkg/C.java |   39 +
 .../pkg/ContaineeRegDoc.java                       |   36 +
 .../pkg/ContaineeSynthDoc.java                     |   37 +
 .../pkg/ContainerRegDoc.java                       |   38 +
 .../pkg/ContainerRegNotDoc.java                    |   37 +
 .../pkg/ContainerSynthDoc.java                     |   38 +
 .../sun/javadoc/testRepeatedAnnotations/pkg/D.java |   37 +
 .../pkg/NonSynthDocContainer.java                  |   38 +
 .../testRepeatedAnnotations/pkg/RegArryDoc.java    |   38 +
 .../pkg/RegContaineeDoc.java                       |   36 +
 .../pkg/RegContaineeNotDoc.java                    |   36 +
 .../pkg/RegContainerDoc.java                       |   38 +
 .../pkg/RegContainerNotDoc.java                    |   37 +
 .../testRepeatedAnnotations/pkg/RegDoc.java        |   38 +
 .../javadoc/testRepeatedAnnotations/pkg1/C.java    |   38 +
 .../pkg1/ContaineeNotDoc.java                      |   36 +
 .../pkg1/ContaineeSynthDoc.java                    |   37 +
 .../pkg1/ContainerSynthNotDoc.java                 |   37 +
 .../pkg1/ContainerValDoc.java                      |   40 +
 .../pkg1/ContainerValNotDoc.java                   |   39 +
 .../pkg1/RegContaineeDoc.java                      |   36 +
 .../pkg1/RegContaineeNotDoc.java                   |   35 +
 .../pkg1/RegContainerValDoc.java                   |   40 +
 .../pkg1/RegContainerValNotDoc.java                |   39 +
 .../sun/javadoc/testReturnTag/TestReturnTag.java   |    4 +-
 .../TestSerializedFormDeprecationInfo.java         |   22 +-
 .../testSimpleTagInherit/TestSimpleTagInherit.java |   80 +
 .../javadoc/testSimpleTagInherit/p/BaseClass.java  |   34 +
 .../javadoc/testSimpleTagInherit/p/TestClass.java  |   34 +
 .../com/sun/javadoc/testSinceTag/TestSinceTag.java |   10 +-
 .../sun/javadoc/testStylesheet/TestStylesheet.java |   46 +-
 .../testTagInheritence/TestTagInheritence.java     |    4 +-
 .../sun/javadoc/testTagMisuse/TestTagMisuse.java   |    7 +-
 test/com/sun/javadoc/testTaglets/taglets/Foo.java  |    4 +-
 .../testTypeAnnotations/TestTypeAnnotations.java   |  401 +++
 .../typeannos/ClassExtends.java                    |   45 +
 .../typeannos/ClassParameters.java                 |   60 +
 .../testTypeAnnotations/typeannos/Fields.java      |   82 +
 .../typeannos/MethodReturnType.java                |   78 +
 .../typeannos/MethodTypeParameters.java            |   52 +
 .../testTypeAnnotations/typeannos/Parameters.java  |   54 +
 .../testTypeAnnotations/typeannos/Receivers.java   |  131 +
 .../testTypeAnnotations/typeannos/Throws.java      |   51 +
 .../typeannos/TypeParameters.java                  |   60 +
 .../testTypeAnnotations/typeannos/Varargs.java     |   42 +
 .../testTypeAnnotations/typeannos/Wildcards.java   |   74 +
 .../javadoc/testTypeParams/TestTypeParameters.java |    4 +-
 .../com/sun/javadoc/testValueTag/TestValueTag.java |    5 +-
 .../TestWarnBadParamNames.java                     |    4 +-
 .../com/sun/javadoc/testWarnings/TestWarnings.java |    6 +-
 test/com/sun/javadoc/testXOption/TestXOption.java  |   85 +
 .../javadoc/typeAnnotations/smoke/TestSmoke.java   |  133 +
 .../typeAnnotations/smoke/pkg/TargetTypes.java     |  234 ++
 test/tools/apt/Basics/Aggregate.java               |   42 -
 test/tools/apt/Basics/CheckAptIsRemovedTest.java   |   96 +
 test/tools/apt/Basics/ClassAnnotations.java        |   47 -
 test/tools/apt/Basics/FreshnessApf.java            |   90 -
 test/tools/apt/Basics/GenClass.java                |   30 -
 test/tools/apt/Basics/Indirect.java                |   31 -
 test/tools/apt/Basics/Lacuna.java                  |   25 -
 test/tools/apt/Basics/MethodAnnotations.java       |   47 -
 test/tools/apt/Basics/Milk.java                    |   34 -
 test/tools/apt/Basics/MisMatch.java                |   67 -
 test/tools/apt/Basics/Misc.java                    |   49 -
 test/tools/apt/Basics/MyMarker.java                |   27 -
 test/tools/apt/Basics/MySimple.java                |   28 -
 test/tools/apt/Basics/NestedClassAnnotations.java  |   50 -
 test/tools/apt/Basics/NullAPF.java                 |   72 -
 test/tools/apt/Basics/ParameterAnnotations.java    |   47 -
 test/tools/apt/Basics/StaticFieldAnnotations.java  |   47 -
 test/tools/apt/Basics/StaticMethodAnnotations.java |   50 -
 test/tools/apt/Basics/TestGetPackageApf.java       |  118 -
 .../apt/Basics/TestGetTypeDeclarationApf.java      |  140 -
 test/tools/apt/Basics/annot/AnnotMarker.java       |   28 -
 test/tools/apt/Basics/annot/AnnotShangri_la.java   |   34 -
 test/tools/apt/Basics/annot/AnnotSimple.java       |   29 -
 .../apt/Basics/annot/annot2/AnnotMarker2.java      |   28 -
 .../apt/Basics/annot/annot2/AnnotSimple2.java      |   29 -
 test/tools/apt/Basics/apt.sh                       |  176 -
 .../com.sun.mirror.apt.AnnotationProcessorFactory  |    1 -
 test/tools/apt/Basics/foo/bar/Baz.java             |   33 -
 test/tools/apt/Basics/foo/bar/Quux.java            |   33 -
 test/tools/apt/Basics/golden.txt                   |    1 -
 test/tools/apt/Basics/goldenAggregate.txt          |   14 -
 test/tools/apt/Basics/p1/p2.java                   |   29 -
 test/tools/apt/Basics/p1/p2/C1.java                |   28 -
 test/tools/apt/Basics/print.sh                     |  102 -
 test/tools/apt/Compile/ClassDeclApf.java           |  120 -
 test/tools/apt/Compile/ClassDeclApf2.java          |  123 -
 test/tools/apt/Compile/Dummy1.java                 |   25 -
 test/tools/apt/Compile/ErrorAPF.java               |   82 -
 test/tools/apt/Compile/HelloAnnotation.java        |    8 -
 test/tools/apt/Compile/HelloWorld.java             |    6 -
 test/tools/apt/Compile/Round1Apf.java              |  121 -
 test/tools/apt/Compile/Round2Apf.java              |  126 -
 test/tools/apt/Compile/Round3Apf.java              |   85 -
 test/tools/apt/Compile/Round4Apf.java              |   98 -
 test/tools/apt/Compile/Rounds.java                 |   33 -
 test/tools/apt/Compile/StaticApf.java              |  104 -
 test/tools/apt/Compile/WarnAPF.java                |  101 -
 test/tools/apt/Compile/WrappedStaticApf.java       |   36 -
 test/tools/apt/Compile/compile.sh                  |  533 ---
 test/tools/apt/Compile/golden.txt                  |    6 -
 test/tools/apt/Compile/goldenFactory.txt           |   29 -
 test/tools/apt/Compile/goldenWarn.txt              |   14 -
 test/tools/apt/Compile/servicesRound1              |    1 -
 test/tools/apt/Compile/servicesRound2              |    1 -
 test/tools/apt/Compile/servicesRound3              |    1 -
 test/tools/apt/Compile/servicesRound4              |    1 -
 test/tools/apt/Compile/servicesStaticApf           |    1 -
 test/tools/apt/Compile/src/AhOneClass.java         |   25 -
 test/tools/apt/Compile/src/AndAhTwoClass.java      |   25 -
 test/tools/apt/Compile/src/Round1Class.java        |   25 -
 test/tools/apt/Discovery/Dee.java                  |   72 -
 test/tools/apt/Discovery/Dum.java                  |   72 -
 test/tools/apt/Discovery/Empty.java                |   26 -
 test/tools/apt/Discovery/PhantomTouch.java         |   93 -
 test/tools/apt/Discovery/PhantomUpdate.java        |   84 -
 test/tools/apt/Discovery/Touch.java                |  116 -
 test/tools/apt/Discovery/discovery.sh              |  410 ---
 test/tools/apt/Discovery/servicesBadTouch          |    1 -
 test/tools/apt/Discovery/servicesPhantomTouch      |    1 -
 test/tools/apt/Discovery/servicesTouch             |    1 -
 test/tools/apt/Discovery/servicesTweedle           |    2 -
 test/tools/apt/Misc/Marked.java                    |   51 -
 test/tools/apt/Misc/Marker.java                    |   25 -
 test/tools/apt/Misc/Misc.java                      |   84 -
 test/tools/apt/Misc/misc.sh                        |  100 -
 test/tools/apt/Misc/servicesMisc                   |    2 -
 test/tools/apt/Options/Marked.java                 |   27 -
 test/tools/apt/Options/Marker.java                 |   25 -
 test/tools/apt/Options/OptionChecker.java          |  117 -
 test/tools/apt/Options/options.sh                  |  116 -
 test/tools/apt/Options/servicesOptions             |    1 -
 test/tools/apt/Scanners/Counter.java               |  108 -
 test/tools/apt/Scanners/MemberOrderApf.java        |   86 -
 test/tools/apt/Scanners/Order.java                 |   54 -
 test/tools/apt/Scanners/Scanner.java               |  123 -
 test/tools/apt/Scanners/TestEnum.java              |   31 -
 test/tools/apt/Scanners/VisitOrder.java            |   32 -
 test/tools/apt/Scanners/scanner.sh                 |  146 -
 test/tools/apt/Scanners/servicesScanner            |    1 -
 test/tools/apt/lib/Ignore.java                     |   41 -
 test/tools/apt/lib/Test.java                       |   49 -
 test/tools/apt/lib/TestProcessor.java              |  132 -
 test/tools/apt/lib/TestProcessorFactory.java       |   80 -
 test/tools/apt/lib/Tester.java                     |  160 -
 test/tools/apt/mirror/declaration/AnnoMirror.java  |  124 -
 .../tools/apt/mirror/declaration/AnnoTypeDecl.java |   93 -
 .../apt/mirror/declaration/AnnoTypeElemDecl.java   |  194 -
 test/tools/apt/mirror/declaration/AnnoVal.java     |  200 --
 test/tools/apt/mirror/declaration/ClassDecl.java   |  250 --
 test/tools/apt/mirror/declaration/ConstExpr.java   |  116 -
 .../apt/mirror/declaration/ConstructorDecl.java    |  199 --
 test/tools/apt/mirror/declaration/EnumDecl.java    |  127 -
 test/tools/apt/mirror/declaration/FieldDecl.java   |  161 -
 test/tools/apt/mirror/declaration/GetAnno.java     |  167 -
 .../apt/mirror/declaration/InterfaceDecl.java      |  243 --
 test/tools/apt/mirror/declaration/MethodDecl.java  |  244 --
 test/tools/apt/mirror/declaration/PackageDecl.java |  167 -
 .../apt/mirror/declaration/ParameterDecl.java      |  137 -
 test/tools/apt/mirror/declaration/pkg1/AClass.java |   28 -
 .../apt/mirror/declaration/pkg1/AnAnnoType.java    |   29 -
 test/tools/apt/mirror/declaration/pkg1/AnEnum.java |   28 -
 .../apt/mirror/declaration/pkg1/AnInterface.java   |   29 -
 .../apt/mirror/declaration/pkg1/package-info.java  |   30 -
 .../mirror/declaration/pkg1/pkg2/AnInterface.java  |   27 -
 .../apt/mirror/declaration/pkg1/pkg2/package.html  |   36 -
 test/tools/apt/mirror/type/AnnoTyp.java            |   92 -
 test/tools/apt/mirror/type/ArrayTyp.java           |  105 -
 test/tools/apt/mirror/type/ClassTyp.java           |  240 --
 test/tools/apt/mirror/type/EnumTyp.java            |   98 -
 test/tools/apt/mirror/type/InterfaceTyp.java       |  202 --
 test/tools/apt/mirror/type/PrimitiveTyp.java       |   92 -
 test/tools/apt/mirror/type/TypeVar.java            |  100 -
 test/tools/apt/mirror/type/WildcardTyp.java        |  170 -
 test/tools/apt/mirror/util/Overrides.java          |  152 -
 test/tools/apt/mirror/util/TypeCreation.java       |  121 -
 test/tools/apt/verifyVariables.sh                  |   45 -
 test/tools/doclint/AccessTest.java                 |   65 +
 test/tools/doclint/AccessTest.package.out          |   20 +
 test/tools/doclint/AccessTest.private.out          |   27 +
 test/tools/doclint/AccessTest.protected.out        |    8 +
 test/tools/doclint/AccessTest.public.out           |    5 +
 test/tools/doclint/AccessibilityTest.java          |   44 +
 test/tools/doclint/AccessibilityTest.out           |   13 +
 test/tools/doclint/AnchorTest.java                 |   93 +
 test/tools/doclint/AnchorTest.out                  |   37 +
 test/tools/doclint/BadPackageCommentTest.java      |   13 +
 test/tools/doclint/BadPackageCommentTest.out       |   10 +
 test/tools/doclint/CoverageExtras.java             |   71 +
 test/tools/doclint/DocLintTester.java              |  150 +
 test/tools/doclint/EmptyAuthorTest.java            |   12 +
 test/tools/doclint/EmptyAuthorTest.out             |    5 +
 test/tools/doclint/EmptyExceptionTest.java         |   14 +
 test/tools/doclint/EmptyExceptionTest.out          |    4 +
 test/tools/doclint/EmptyParamTest.java             |   14 +
 test/tools/doclint/EmptyParamTest.out              |    5 +
 test/tools/doclint/EmptyPreTest.java               |   44 +
 test/tools/doclint/EmptyReturnTest.java            |   14 +
 test/tools/doclint/EmptyReturnTest.out             |    5 +
 test/tools/doclint/EmptySerialDataTest.java        |   17 +
 test/tools/doclint/EmptySerialDataTest.out         |    5 +
 test/tools/doclint/EmptySerialFieldTest.java       |   22 +
 test/tools/doclint/EmptySerialFieldTest.out        |    5 +
 test/tools/doclint/EmptySinceTest.java             |   14 +
 test/tools/doclint/EmptySinceTest.out              |    5 +
 test/tools/doclint/EmptyVersionTest.java           |   14 +
 test/tools/doclint/EmptyVersionTest.out            |    4 +
 test/tools/doclint/EndTagsTest.java                |   39 +
 test/tools/doclint/EndTagsTest.out                 |   25 +
 test/tools/doclint/EndWithIdentifierTest.java      |   32 +
 test/tools/doclint/EndWithIdentifierTest.out       |   20 +
 test/tools/doclint/HtmlAttrsTest.java              |   27 +
 test/tools/doclint/HtmlAttrsTest.out               |   12 +
 test/tools/doclint/HtmlTagsTest.java               |   70 +
 test/tools/doclint/HtmlTagsTest.out                |   44 +
 test/tools/doclint/LiteralTest.java                |   16 +
 test/tools/doclint/LiteralTest.out                 |    4 +
 test/tools/doclint/MissingCommentTest.java         |   14 +
 test/tools/doclint/MissingCommentTest.out          |   14 +
 test/tools/doclint/MissingParamsTest.java          |   23 +
 test/tools/doclint/MissingParamsTest.out           |   14 +
 test/tools/doclint/MissingReturnTest.java          |   23 +
 test/tools/doclint/MissingReturnTest.out           |    5 +
 test/tools/doclint/MissingThrowsTest.java          |   14 +
 test/tools/doclint/MissingThrowsTest.out           |    4 +
 test/tools/doclint/OptionTest.java                 |   96 +
 test/tools/doclint/OverridesTest.java              |   93 +
 test/tools/doclint/ParaTagTest.java                |   55 +
 test/tools/doclint/ReferenceTest.java              |   52 +
 test/tools/doclint/ReferenceTest.out               |   30 +
 test/tools/doclint/ResourceTest.java               |   81 +
 test/tools/doclint/RunTest.java                    |  101 +
 test/tools/doclint/SyntaxTest.java                 |   17 +
 test/tools/doclint/SyntaxTest.out                  |    5 +
 test/tools/doclint/SyntheticTest.java              |   50 +
 test/tools/doclint/UnfinishedInlineTagTest.java    |   17 +
 test/tools/doclint/UnfinishedInlineTagTest.out     |    5 +
 test/tools/doclint/ValidTest.java                  |  112 +
 test/tools/doclint/html/AAA.java                   |   35 +
 test/tools/doclint/html/BlockTagsTest.java         |   57 +
 test/tools/doclint/html/EntitiesTest.java          |  317 ++
 test/tools/doclint/html/EntitiesTest.out           |   19 +
 test/tools/doclint/html/InlineTagsTest.java        |   57 +
 test/tools/doclint/html/ListTagsTest.java          |   21 +
 test/tools/doclint/html/ListTagsTest.out           |    7 +
 test/tools/doclint/html/OtherTagsTest.java         |   24 +
 test/tools/doclint/html/OtherTagsTest.out          |   28 +
 test/tools/doclint/html/TableTagsTest.java         |   44 +
 test/tools/doclint/html/TagNotAllowed.java         |   30 +
 test/tools/doclint/html/TagNotAllowed.out          |   61 +
 test/tools/doclint/html/TextNotAllowed.java        |   32 +
 test/tools/doclint/html/TextNotAllowed.out         |   85 +
 test/tools/doclint/tidy/AAA.java                   |   35 +
 test/tools/doclint/tidy/AnchorAlreadyDefined.java  |   17 +
 test/tools/doclint/tidy/AnchorAlreadyDefined.out   |    7 +
 test/tools/doclint/tidy/BadEnd.java                |   16 +
 test/tools/doclint/tidy/BadEnd.out                 |   17 +
 test/tools/doclint/tidy/InsertImplicit.java        |   16 +
 test/tools/doclint/tidy/InsertImplicit.out         |    7 +
 test/tools/doclint/tidy/InvalidEntity.java         |   22 +
 test/tools/doclint/tidy/InvalidEntity.out          |   10 +
 test/tools/doclint/tidy/InvalidName.java           |   18 +
 test/tools/doclint/tidy/InvalidName.out            |    4 +
 test/tools/doclint/tidy/InvalidTag.java            |   15 +
 test/tools/doclint/tidy/InvalidTag.out             |   10 +
 test/tools/doclint/tidy/InvalidURI.java            |   21 +
 test/tools/doclint/tidy/InvalidURI.out             |   13 +
 test/tools/doclint/tidy/MissingGT.java             |   16 +
 test/tools/doclint/tidy/MissingGT.out              |    4 +
 test/tools/doclint/tidy/MissingTag.java            |   17 +
 test/tools/doclint/tidy/MissingTag.out             |    7 +
 test/tools/doclint/tidy/NestedTag.java             |   16 +
 test/tools/doclint/tidy/NestedTag.out              |    7 +
 test/tools/doclint/tidy/ParaInPre.java             |   20 +
 test/tools/doclint/tidy/ParaInPre.out              |    4 +
 test/tools/doclint/tidy/README.txt                 |   21 +
 test/tools/doclint/tidy/RepeatedAttr.java          |   15 +
 test/tools/doclint/tidy/RepeatedAttr.out           |    4 +
 test/tools/doclint/tidy/TextNotAllowed.java        |   26 +
 test/tools/doclint/tidy/TextNotAllowed.out         |   19 +
 test/tools/doclint/tidy/TrimmingEmptyTag.java      |   29 +
 test/tools/doclint/tidy/TrimmingEmptyTag.out       |   46 +
 .../doclint/tidy/UnescapedOrUnknownEntity.java     |   19 +
 .../doclint/tidy/UnescapedOrUnknownEntity.out      |   11 +
 test/tools/doclint/tidy/util/Main.java             |  182 +
 test/tools/doclint/tidy/util/tidy.sh               |   52 +
 test/tools/doclint/tool/AAA.java                   |   35 +
 test/tools/doclint/tool/HelpTest.java              |   38 +
 test/tools/doclint/tool/HelpTest.out               |   43 +
 test/tools/doclint/tool/MaxDiagsTest.java          |   21 +
 test/tools/doclint/tool/MaxDiagsTest.out           |   14 +
 test/tools/doclint/tool/PathsTest.java             |  136 +
 test/tools/doclint/tool/RunTest.java               |  200 ++
 test/tools/doclint/tool/StatsTest.java             |   19 +
 test/tools/doclint/tool/StatsTest.out              |   43 +
 .../tools/javac/4846262/CheckEBCDICLocaleTest.java |   96 +
 test/tools/javac/4846262/Test.java                 |    6 -
 test/tools/javac/4846262/Test.out                  |    7 -
 test/tools/javac/4846262/Test.sh                   |   80 -
 test/tools/javac/5045412/Bar.java                  |    8 +-
 test/tools/javac/5045412/Foo.java                  |    7 +-
 .../HiddenOptionsShouldUseGivenEncodingTest.java   |   49 +
 test/tools/javac/6302184/T6302184.sh               |   71 -
 test/tools/javac/6304921/TestLog.java              |    9 +-
 test/tools/javac/6330997/T6330997.java             |    8 +-
 test/tools/javac/6360970/T6360970.java             |   25 +
 test/tools/javac/6360970/T6360970.out              |    2 +
 test/tools/javac/6402516/CheckLocalElements.java   |    4 +-
 test/tools/javac/6402516/TestLocalElements.java    |    6 +-
 test/tools/javac/6410653/T6410653.java             |   13 +-
 .../javac/6563143/EqualsHashCodeWarningTest.java   |   71 +
 .../javac/6563143/EqualsHashCodeWarningTest.out    |    2 +
 test/tools/javac/6567415/T6567415.java             |    4 +-
 test/tools/javac/6758789/T6758789a.out             |    4 +-
 test/tools/javac/6758789/T6758789b.out             |    2 +-
 test/tools/javac/6840059/T6840059.out              |    5 +-
 test/tools/javac/6857948/T6857948.out              |    3 +-
 test/tools/javac/6889255/T6889255.java             |   10 +-
 .../6979683/TestCast6979683_BAD34.java.errlog      |    2 +-
 .../6979683/TestCast6979683_BAD35.java.errlog      |    2 +-
 .../6979683/TestCast6979683_BAD36.java.errlog      |    2 +-
 .../6979683/TestCast6979683_BAD37.java.errlog      |    2 +-
 .../6979683/TestCast6979683_BAD38.java.errlog      |    2 +-
 .../6979683/TestCast6979683_BAD39.java.errlog      |    2 +-
 .../tools/javac/7079713/TestCircularClassfile.java |  168 +
 test/tools/javac/7129225/TestImportStar.java       |    6 +-
 test/tools/javac/7129225/TestImportStar.ref        |    1 +
 test/tools/javac/7132880/T7132880.java             |   60 +
 test/tools/javac/7132880/T7132880.out              |    4 +
 .../7144981/IgnoreIgnorableCharactersInInput.java  |   92 +
 .../7153958/CPoolRefClassContainingInlinedCts.java |  134 +
 .../7153958/pkg/ClassToBeStaticallyImported.java   |   29 +
 .../7166455/CheckACC_STRICTFlagOnclinitTest.java   |  107 +
 .../DiffResultAfterSameOperationInnerClasses.java  |   94 +
 .../javac/7199823/InnerClassCannotBeVerified.java  |  110 +
 .../javac/8000518/DuplicateConstantPoolEntry.java  |  119 +
 test/tools/javac/8002286/T8002286.java             |   12 +
 test/tools/javac/8002286/T8002286.out              |    3 +
 .../CheckACC_STRICTFlagOnPkgAccessClassTest.java   |  130 +
 .../8009170/RedundantByteCodeInArrayTest.java      |   71 +
 test/tools/javac/8015701/AnonymousParameters.java  |   89 +
 .../javac/ClassFileModifiers/MemberModifiers.java  |    4 +-
 test/tools/javac/ClassPathTest/ClassPathTest.java  |  178 +
 test/tools/javac/ClassPathTest/ClassPathTest.sh    |  134 -
 test/tools/javac/ClassPathTest/ClassPathTest1.java |   29 -
 test/tools/javac/ClassPathTest/ClassPathTest2.java |   29 -
 test/tools/javac/ClassPathTest/ClassPathTest3.java |   29 -
 .../ClassPathTest/bar/pkg/ClassPathTestAux2.java   |   26 -
 .../ClassPathTest/foo/pkg/ClassPathTestAux1.java   |   26 -
 .../javac/ClassPathTest/pkg/ClassPathTestAux3.java |   26 -
 test/tools/javac/DefiniteAssignment/T7181578.java  |   46 +
 .../javac/Diagnostics/6722234/T6722234a_1.out      |    2 +-
 .../javac/Diagnostics/6722234/T6722234a_2.out      |    2 +-
 .../javac/Diagnostics/6722234/T6722234b_1.out      |    2 +-
 .../javac/Diagnostics/6722234/T6722234b_2.out      |    2 +-
 test/tools/javac/Diagnostics/6722234/T6722234c.out |    2 +-
 .../javac/Diagnostics/6722234/T6722234d_1.out      |    2 +-
 .../javac/Diagnostics/6722234/T6722234d_2.out      |    2 +-
 test/tools/javac/Diagnostics/6769027/T6769027.java |  123 +-
 test/tools/javac/Diagnostics/6799605/T6799605.out  |    6 +-
 test/tools/javac/Diagnostics/6862608/T6862608a.out |    2 +-
 test/tools/javac/Diagnostics/6862608/T6862608b.out |    2 +-
 test/tools/javac/Diagnostics/7116676/T7116676.java |  109 +
 test/tools/javac/Diagnostics/8010387/T8010387.java |   17 +
 test/tools/javac/Diagnostics/8010387/T8010387.out  |    3 +
 .../javac/Diagnostics/compressed/T8012003a.java    |   24 +
 .../javac/Diagnostics/compressed/T8012003a.out     |    6 +
 .../javac/Diagnostics/compressed/T8012003b.java    |   37 +
 .../javac/Diagnostics/compressed/T8012003b.out     |    8 +
 .../javac/Diagnostics/compressed/T8012003c.java    |   24 +
 .../javac/Diagnostics/compressed/T8012003c.out     |    3 +
 .../javac/Diagnostics/compressed/T8020286.java     |   15 +
 .../javac/Diagnostics/compressed/T8020286.out      |    4 +
 test/tools/javac/ExtDirs/ExtDirTest.java           |  176 +
 test/tools/javac/ExtDirs/ExtDirTest_1.java         |   28 -
 test/tools/javac/ExtDirs/ExtDirTest_2.java         |   30 -
 test/tools/javac/ExtDirs/ExtDirTest_3.java         |   30 -
 test/tools/javac/ExtDirs/ExtDirs.sh                |  100 -
 test/tools/javac/HiddenAbstractMethod/Test         |   12 -
 test/tools/javac/HiddenAbstractMethod/Test.java    |   12 +
 .../javac/MethodParameters/AnnotationTest.java     |   54 +
 .../javac/MethodParameters/AnonymousClass.java     |  104 +
 .../javac/MethodParameters/AttributeVisitor.java   |   59 +
 .../javac/MethodParameters/ClassFileVisitor.java   |  390 ++
 .../tools/javac/MethodParameters/Constructors.java |   41 +
 test/tools/javac/MethodParameters/EnumTest.java    |   45 +
 .../javac/MethodParameters/InstanceMethods.java    |   46 +
 test/tools/javac/MethodParameters/LambdaTest.java  |   51 +
 .../javac/MethodParameters/LocalClassTest.java     |   50 +
 .../javac/MethodParameters/MemberClassTest.java    |   86 +
 .../javac/MethodParameters/ReflectionVisitor.java  |  265 ++
 .../javac/MethodParameters/StaticMethods.java      |   46 +
 test/tools/javac/MethodParameters/Tester.java      |  161 +
 .../javac/MethodParameters/UncommonParamNames.java |   68 +
 test/tools/javac/MethodParametersTest.java         |  344 ++
 test/tools/javac/MissingInclude.java               |   33 -
 test/tools/javac/MissingInclude.sh                 |   77 -
 .../javac/MissingInclude/MissingIncludeTest.java   |   50 +
 test/tools/javac/NonAmbiguousField/Test            |   10 -
 test/tools/javac/NonAmbiguousField/Test.java       |   10 +
 test/tools/javac/NonAmbiguousField/two/Child2.java |    8 +-
 .../javac/OverrideChecks/6400189/T6400189a.out     |    2 +-
 .../javac/OverrideChecks/6400189/T6400189b.out     |    2 +-
 .../javac/Paths/TestCompileJARInClassPath.java     |  132 +
 .../ProtectedInnerClass/ProtectedInnerClass.sh     |   84 -
 .../ProtectedInnerClass/ProtectedInnerClass_2.java |   33 -
 .../ProtectedInnerClassesTest.java                 |  118 +
 .../p1/ProtectedInnerClass1.java                   |   37 -
 .../p2/ProtectedInnerClass2.java                   |   45 -
 .../p2/ProtectedInnerClass3.java                   |   36 -
 .../javac/StringsInSwitch/BadlyTypedLabel1.out     |    2 +-
 .../javac/StringsInSwitch/BadlyTypedLabel2.out     |    2 +-
 .../javac/StringsInSwitch/StringSwitches.java      |    2 +-
 .../javac/T4965689/ClassLiteralWastesByteTest.java |   66 +
 .../T5053846/MethodRefDupInConstantPoolTest.java   |  110 +
 .../tools/javac/T5090006/AssertionFailureTest.java |   69 +
 test/tools/javac/T5090006/T5090006.java            |   47 -
 test/tools/javac/T5090006/compiler.sh              |   72 -
 test/tools/javac/T6181889/EmptyFinallyTest.java    |   67 +
 .../FinalVariableAssignedToInCatchBlockTest.java   |   94 +
 .../FinalVariableAssignedToInCatchBlockTest.out    |    3 +
 test/tools/javac/T6326754.out                      |    4 +-
 ...bleAbstractClassWithNonAbstractMethodsTest.java |   48 +
 ...ableAbstractClassWithNonAbstractMethodsTest.out |    5 +
 test/tools/javac/T6558476.java                     |    7 +-
 ...AnnotationsAreNotCopiedToBridgeMethodsTest.java |  103 +
 test/tools/javac/T6725036.java                     |    1 +
 test/tools/javac/T6873845.java                     |    7 +-
 test/tools/javac/T6900149.java                     |   10 +-
 .../T6970173/DebugPointerAtBadPositionTest.java    |  112 +
 test/tools/javac/T6985181.java                     |   88 +
 .../InlinedFinallyConfuseDebuggersTest.java        |  117 +
 .../VerifyErrorWithDoubleAssignmentTest.java       |   51 +
 test/tools/javac/T7093325.java                     |  269 ++
 test/tools/javac/T7120266.java                     |   34 +
 test/tools/javac/T7159016.java                     |    2 +-
 .../InnerClassAttrMustNotHaveStrictFPFlagTest.java |   71 +
 .../T7179353/GenericsAndTWRCompileErrorTest.java   |   42 +
 .../javac/T8003967/DetectMutableStaticFields.java  |  242 ++
 test/tools/javac/T8004969.java                     |  103 +
 ...pilerCrashWhenMixingBinariesAndSourcesTest.java |   66 +
 ...ameterNamesAreNotCopiedToAnonymousInitTest.java |  239 ++
 .../T8011181/EmptyUTF8ForInnerClassNameTest.java   |   81 +
 .../T8016099/UncheckedWarningRegressionTest.java   |   32 +
 .../T8016099/UncheckedWarningRegressionTest.out    |    5 +
 test/tools/javac/TryWithResources/T7164542.java    |   44 +
 .../javac/TryWithResources/TwrOnNonResource.out    |    6 +-
 test/tools/javac/VersionOpt.java                   |    4 +-
 test/tools/javac/annotations/6881115/T6881115.java |   10 +-
 test/tools/javac/annotations/6881115/T6881115.out  |   27 +-
 .../javac/annotations/clinit/AnnoWithClinit1.java  |   52 +
 .../annotations/clinit/AnnoWithClinitFail.java     |   45 +
 .../annotations/clinit/AnnoWithClinitFail.out      |    3 +
 .../BaseAnnoAsContainerAnno.java                   |   18 +
 .../BaseAnnoAsContainerAnno.out                    |    2 +
 .../BasicRepeatingAnnotations.java                 |   78 +
 .../repeatingAnnotations/CheckTargets.java         |   64 +
 .../repeatingAnnotations/ClassReaderDefault.java   |   44 +
 .../ContainerHasRepeatedContained.java             |   44 +
 .../repeatingAnnotations/CyclicAnnotation.java     |   23 +
 .../repeatingAnnotations/CyclicAnnotation.out      |    2 +
 .../repeatingAnnotations/DefaultCasePresent.java   |   44 +
 .../repeatingAnnotations/DefaultTarget.java        |   47 +
 .../DefaultTargetTypeParameter.java                |   40 +
 .../DefaultTargetTypeParameter.out                 |    2 +
 .../repeatingAnnotations/DefaultTargetTypeUse.java |   40 +
 .../repeatingAnnotations/DefaultTargetTypeUse.out  |    2 +
 .../DelayRepeatedContainer.java                    |   49 +
 .../DocumentedContainerAnno.java                   |   21 +
 .../DocumentedContainerAnno.out                    |    2 +
 .../repeatingAnnotations/DuplicateErrors.java      |   37 +
 .../repeatingAnnotations/DuplicateErrors.out       |    3 +
 .../InheritedContainerAnno.java                    |   22 +
 .../InheritedContainerAnno.out                     |    2 +
 .../repeatingAnnotations/InvalidTarget.java        |   44 +
 .../repeatingAnnotations/MissingContainer.java     |   19 +
 .../repeatingAnnotations/MissingContainer.out      |    4 +
 .../repeatingAnnotations/MissingDefaultCase1.java  |   20 +
 .../repeatingAnnotations/MissingDefaultCase1.out   |    3 +
 .../repeatingAnnotations/MissingDefaultCase2.java  |   20 +
 .../repeatingAnnotations/MissingDefaultCase2.out   |    3 +
 .../repeatingAnnotations/MissingValueMethod.java   |   20 +
 .../repeatingAnnotations/MissingValueMethod.out    |    4 +
 .../MultiLevelRepeatableAnno.java                  |   48 +
 .../MultipleAnnoMixedOrder.java                    |   57 +
 .../repeatingAnnotations/NestedContainers.java     |   72 +
 .../repeatingAnnotations/NoRepeatableAnno.java     |   12 +
 .../repeatingAnnotations/NoRepeatableAnno.out      |    2 +
 .../repeatingAnnotations/NoTargetOnContainer.java  |   49 +
 .../repeatingAnnotations/NoTargetOnContainer2.java |   50 +
 .../repeatingAnnotations/RepMemberAnno.java        |   47 +
 .../repeatingAnnotations/RepSelfMemberAnno.java    |   58 +
 .../RepeatingAndContainerPresent.java              |   44 +
 .../RepeatingTargetNotAllowed.java                 |   44 +
 .../RepeatingTargetNotAllowed.out                  |    2 +
 .../SelfRepeatingAnnotations.java                  |   54 +
 .../repeatingAnnotations/SeparateCompile.java      |   30 +
 .../SingleRepeatingAndContainer.java               |   42 +
 .../repeatingAnnotations/UseWrongRepeatable.java   |   41 +
 .../WrongReturnTypeForValue.java                   |   21 +
 .../WrongReturnTypeForValue.out                    |    4 +
 .../combo/BasicSyntaxCombo.java                    |  208 ++
 .../combo/DeprecatedAnnoCombo.java                 |  152 +
 .../combo/DocumentedAnnoCombo.java                 |  125 +
 .../repeatingAnnotations/combo/Helper.java         |  208 ++
 .../combo/InheritedAnnoCombo.java                  |  126 +
 .../repeatingAnnotations/combo/ReflectionTest.java | 2932 +++++++++++++++
 .../combo/RetentionAnnoCombo.java                  |  200 ++
 .../combo/TargetAnnoCombo.java                     |  508 +++
 .../combo/expectedFiles/ExpectedBase.java          |   39 +
 .../combo/expectedFiles/ExpectedContainer.java     |   39 +
 .../typeAnnotations/6967002/T6967002.java          |   35 +
 .../typeAnnotations/6967002/T6967002.out           |    8 +
 .../typeAnnotations/8013180/QualifiedName.java     |   39 +
 .../annotations/typeAnnotations/InnerClass.java    |   65 +
 .../typeAnnotations/MultipleTargets.java           |   41 +
 .../annotations/typeAnnotations/TargetTypes.java   |  206 ++
 .../typeAnnotations/TypeParameterTarget.java       |   46 +
 .../annotations/typeAnnotations/TypeProcOnly.java  |  127 +
 .../annotations/typeAnnotations/TypeUseTarget.java |   62 +
 .../typeAnnotations/api/AnnotatedArrayOrder.java   |  161 +
 .../typeAnnotations/api/ArrayCreationTree.java     |  152 +
 .../api/ArrayPositionConsistency.java              |  141 +
 .../typeAnnotations/attribution/Scopes.java        |   44 +
 .../classfile/ClassfileTestHelper.java             |  246 ++
 .../classfile/CombinationsTargetTest1.java         |  381 ++
 .../classfile/CombinationsTargetTest2.java         |  365 ++
 .../classfile/CombinationsTargetTest3.java         |  539 +++
 .../typeAnnotations/classfile/DeadCode.java        |   82 +
 .../classfile/NewTypeArguments.java                |   72 +
 .../classfile/NoTargetAnnotations.java             |  204 ++
 .../typeAnnotations/classfile/T8008762.java        |   76 +
 .../typeAnnotations/classfile/T8008769.java        |   64 +
 .../typeAnnotations/classfile/T8010015.java        |   79 +
 .../classfile/TestNewCastArray.java                |  375 ++
 .../typeAnnotations/classfile/TypeCasts.java       |   87 +
 .../typeAnnotations/classfile/Wildcards.java       |   73 +
 .../typeAnnotations/failures/AnnotatedImport.java  |   15 +
 .../typeAnnotations/failures/AnnotatedImport.out   |    7 +
 .../failures/AnnotatedPackage1.java                |   13 +
 .../typeAnnotations/failures/AnnotatedPackage1.out |    3 +
 .../failures/AnnotatedPackage2.java                |   13 +
 .../typeAnnotations/failures/AnnotatedPackage2.out |    3 +
 .../failures/AnnotationVersion.java                |   13 +
 .../typeAnnotations/failures/AnnotationVersion.out |    2 +
 .../failures/AnnotationVersion7.out                |    2 +
 .../typeAnnotations/failures/BadCast.java          |   14 +
 .../typeAnnotations/failures/BadCast.out           |    2 +
 .../failures/CantAnnotateStaticClass.java          |   41 +
 .../failures/CantAnnotateStaticClass.out           |    1 +
 .../typeAnnotations/failures/IncompleteArray.java  |   12 +
 .../typeAnnotations/failures/IncompleteArray.out   |    2 +
 .../typeAnnotations/failures/IncompleteVararg.java |   13 +
 .../typeAnnotations/failures/IncompleteVararg.out  |    2 +
 .../typeAnnotations/failures/IndexArray.java       |   13 +
 .../typeAnnotations/failures/IndexArray.out        |    2 +
 .../failures/LazyConstantValue.java                |   48 +
 .../typeAnnotations/failures/LintCast.java         |   69 +
 .../typeAnnotations/failures/LintCast.out          |   11 +
 .../typeAnnotations/failures/OldArray.java         |   35 +
 .../typeAnnotations/failures/Scopes.java           |   17 +
 .../typeAnnotations/failures/Scopes.out            |    3 +
 .../typeAnnotations/failures/StaticFields.java     |   13 +
 .../typeAnnotations/failures/StaticFields.out      |    2 +
 .../typeAnnotations/failures/StaticMethods.java    |   12 +
 .../typeAnnotations/failures/StaticMethods.out     |    2 +
 .../typeAnnotations/failures/T8008751.java         |   48 +
 .../typeAnnotations/failures/T8009360.java         |   49 +
 .../typeAnnotations/failures/T8011722.java         |   38 +
 .../typeAnnotations/failures/TypeAndField.java     |   40 +
 .../typeAnnotations/failures/TypeVariable.java     |   43 +
 .../failures/VoidGenericMethod.java                |   38 +
 .../common/arrays/DeclarationAnnotation.java       |   19 +
 .../common/arrays/DeclarationAnnotation.out        |    4 +
 .../common/arrays/DuplicateAnnotationValue.java    |   16 +
 .../common/arrays/DuplicateAnnotationValue.out     |    2 +
 .../common/arrays/DuplicateTypeAnnotation.java     |   16 +
 .../common/arrays/DuplicateTypeAnnotation.out      |    2 +
 .../failures/common/arrays/InvalidLocation.java    |   16 +
 .../failures/common/arrays/InvalidLocation.out     |    2 +
 .../common/arrays/MissingAnnotationValue.java      |   14 +
 .../common/arrays/MissingAnnotationValue.out       |    2 +
 .../innertypeparams/DuplicateAnnotationValue.java  |   16 +
 .../innertypeparams/DuplicateAnnotationValue.out   |    2 +
 .../innertypeparams/DuplicateTypeAnnotation.java   |   16 +
 .../innertypeparams/DuplicateTypeAnnotation.out    |    2 +
 .../common/innertypeparams/InvalidLocation.java    |   15 +
 .../common/innertypeparams/InvalidLocation.out     |    2 +
 .../innertypeparams/MissingAnnotationValue.java    |   14 +
 .../innertypeparams/MissingAnnotationValue.out     |    2 +
 .../common/newarray/DuplicateAnnotationValue.java  |   16 +
 .../common/newarray/DuplicateAnnotationValue.out   |    2 +
 .../common/newarray/DuplicateTypeAnnotation.java   |   16 +
 .../common/newarray/DuplicateTypeAnnotation.out    |    2 +
 .../failures/common/newarray/InvalidLocation.java  |   16 +
 .../failures/common/newarray/InvalidLocation.out   |    2 +
 .../common/newarray/MissingAnnotationValue.java    |   14 +
 .../common/newarray/MissingAnnotationValue.out     |    2 +
 .../common/parambounds/BrokenAnnotation.java       |   99 +
 .../common/parambounds/BrokenAnnotation.out        |    3 +
 .../parambounds/DuplicateAnnotationValue.java      |   13 +
 .../parambounds/DuplicateAnnotationValue.out       |    2 +
 .../parambounds/DuplicateTypeAnnotation.java       |   13 +
 .../common/parambounds/DuplicateTypeAnnotation.out |    2 +
 .../common/parambounds/InvalidLocation.java        |   13 +
 .../common/parambounds/InvalidLocation.out         |    2 +
 .../common/parambounds/MissingAnnotationValue.java |   14 +
 .../common/parambounds/MissingAnnotationValue.out  |    2 +
 .../common/receiver/DeclarationAnnotation.java     |   21 +
 .../common/receiver/DeclarationAnnotation.out      |    2 +
 .../common/receiver/DuplicateAnnotationValue.java  |   14 +
 .../common/receiver/DuplicateAnnotationValue.out   |    2 +
 .../common/receiver/DuplicateTypeAnnotation.java   |   14 +
 .../common/receiver/DuplicateTypeAnnotation.out    |    2 +
 .../failures/common/receiver/InvalidLocation.java  |   15 +
 .../failures/common/receiver/InvalidLocation.out   |    2 +
 .../common/receiver/MissingAnnotationValue.java    |   12 +
 .../common/receiver/MissingAnnotationValue.out     |    2 +
 .../failures/common/receiver/Nesting.java          |   50 +
 .../failures/common/receiver/StaticThings.java     |   56 +
 .../failures/common/receiver/StaticThings.out      |    5 +
 .../failures/common/receiver/WrongType.java        |   72 +
 .../failures/common/receiver/WrongType.out         |    9 +
 .../common/rest/DuplicateAnnotationValue.java      |   16 +
 .../common/rest/DuplicateAnnotationValue.out       |    2 +
 .../common/rest/DuplicateTypeAnnotation.java       |   16 +
 .../common/rest/DuplicateTypeAnnotation.out        |    2 +
 .../failures/common/rest/InvalidLocation.java      |   16 +
 .../failures/common/rest/InvalidLocation.out       |    2 +
 .../common/rest/MissingAnnotationValue.java        |   19 +
 .../common/rest/MissingAnnotationValue.out         |    2 +
 .../common/typeArgs/DuplicateAnnotationValue.java  |   14 +
 .../common/typeArgs/DuplicateAnnotationValue.out   |    2 +
 .../common/typeArgs/DuplicateTypeAnnotation.java   |   14 +
 .../common/typeArgs/DuplicateTypeAnnotation.out    |    2 +
 .../failures/common/typeArgs/InvalidLocation.java  |   14 +
 .../failures/common/typeArgs/InvalidLocation.out   |    2 +
 .../common/typeArgs/MissingAnnotationValue.java    |   12 +
 .../common/typeArgs/MissingAnnotationValue.out     |    2 +
 .../typeparams/DuplicateAnnotationValue.java       |   13 +
 .../common/typeparams/DuplicateAnnotationValue.out |    2 +
 .../common/typeparams/DuplicateTypeAnnotation.java |   13 +
 .../common/typeparams/DuplicateTypeAnnotation.out  |    2 +
 .../common/typeparams/InvalidLocation.java         |   13 +
 .../failures/common/typeparams/InvalidLocation.out |    2 +
 .../common/typeparams/MissingAnnotationValue.java  |   11 +
 .../common/typeparams/MissingAnnotationValue.out   |    2 +
 .../common/wildcards/DeclarationAnnotation.java    |   22 +
 .../common/wildcards/DeclarationAnnotation.out     |    2 +
 .../common/wildcards/DuplicateAnnotationValue.java |   14 +
 .../common/wildcards/DuplicateAnnotationValue.out  |    2 +
 .../common/wildcards/DuplicateTypeAnnotation.java  |   14 +
 .../common/wildcards/DuplicateTypeAnnotation.out   |    2 +
 .../failures/common/wildcards/InvalidLocation.java |   14 +
 .../failures/common/wildcards/InvalidLocation.out  |    2 +
 .../common/wildcards/MissingAnnotationValue.java   |   12 +
 .../common/wildcards/MissingAnnotationValue.out    |    2 +
 .../failures/target/Constructor.java               |   37 +
 .../failures/target/Constructor.out                |    2 +
 .../typeAnnotations/failures/target/DotClass.java  |   74 +
 .../typeAnnotations/failures/target/DotClass.out   |   17 +
 .../failures/target/IncompleteArray.java           |   12 +
 .../failures/target/IncompleteArray.out            |    2 +
 .../failures/target/NotTypeParameter.java          |   25 +
 .../failures/target/NotTypeParameter.out           |    4 +
 .../failures/target/NotTypeUse.java                |   17 +
 .../typeAnnotations/failures/target/NotTypeUse.out |    2 +
 .../failures/target/VoidMethod.java                |   33 +
 .../typeAnnotations/failures/target/VoidMethod.out |    3 +
 .../newlocations/AnonymousClass.java               |   45 +
 .../typeAnnotations/newlocations/BasicTest.java    |   81 +
 .../typeAnnotations/newlocations/ClassExtends.java |   45 +
 .../newlocations/ClassParameters.java              |   60 +
 .../newlocations/ConstructorTypeArgs.java          |   59 +
 .../newlocations/ExceptionParameters.java          |   76 +
 .../typeAnnotations/newlocations/Expressions.java  |   79 +
 .../typeAnnotations/newlocations/Fields.java       |   77 +
 .../typeAnnotations/newlocations/Lambda.java       |   66 +
 .../newlocations/LocalVariables.java               |   81 +
 .../newlocations/MethodReturnType.java             |   79 +
 .../newlocations/MethodTypeArgs.java               |   67 +
 .../newlocations/MethodTypeParameters.java         |   53 +
 .../typeAnnotations/newlocations/MultiCatch.java   |   78 +
 .../typeAnnotations/newlocations/NestedTypes.java  |  212 ++
 .../typeAnnotations/newlocations/Parameters.java   |   55 +
 .../typeAnnotations/newlocations/Receivers.java    |  131 +
 .../newlocations/RepeatingTypeAnnotations.java     |  126 +
 .../newlocations/RepeatingTypeAnnotations.out      |   28 +
 .../newlocations/ResourceVariables.java            |   46 +
 .../typeAnnotations/newlocations/Throws.java       |   51 +
 .../newlocations/TopLevelBlocks.java               |   50 +
 .../typeAnnotations/newlocations/TypeCasts.java    |   48 +
 .../newlocations/TypeParameters.java               |   60 +
 .../typeAnnotations/newlocations/Varargs.java      |   45 +
 .../typeAnnotations/newlocations/Wildcards.java    |   74 +
 .../packageanno/PackageProcessor.java              |  105 +
 .../packageanno/mypackage/Anno.java                |   28 +
 .../packageanno/mypackage/MyClass.java             |   25 +
 .../packageanno/mypackage/package-info.java        |   25 +
 .../referenceinfos/ClassExtends.java               |   96 +
 .../referenceinfos/ClassTypeParam.java             |  158 +
 .../referenceinfos/Constructors.java               |   88 +
 .../typeAnnotations/referenceinfos/Driver.java     |  289 ++
 .../referenceinfos/ExceptionParameters.java        |   89 +
 .../typeAnnotations/referenceinfos/Fields.java     |  128 +
 .../referenceinfos/FromSpecification.java          |  122 +
 .../referenceinfos/Initializers.java               |   95 +
 .../typeAnnotations/referenceinfos/Lambda.java     |  288 ++
 .../referenceinfos/MethodParameters.java           |  173 +
 .../referenceinfos/MethodReceivers.java            |   79 +
 .../referenceinfos/MethodReturns.java              |  186 +
 .../referenceinfos/MethodThrows.java               |   77 +
 .../referenceinfos/MethodTypeParam.java            |  251 ++
 .../typeAnnotations/referenceinfos/MultiCatch.java |   67 +
 .../referenceinfos/NestedTypes.java                |  878 +++++
 .../typeAnnotations/referenceinfos/NewObjects.java |  155 +
 .../referenceinfos/ReferenceInfoUtil.java          |  347 ++
 .../referenceinfos/RepeatingTypeAnnotations.java   |   75 +
 .../typeAnnotations/referenceinfos/Test.java       |   33 +
 .../typeAnnotations/referenceinfos/TypeCasts.java  |  200 ++
 .../typeAnnotations/referenceinfos/TypeTests.java  |  130 +
 test/tools/javac/api/6406133/T6406133.java         |    4 +-
 test/tools/javac/api/6410643/T6410643.java         |    4 +-
 test/tools/javac/api/6411310/T6411310.java         |    3 +-
 test/tools/javac/api/6411333/T6411333.java         |    3 +-
 test/tools/javac/api/6412656/T6412656.java         |    4 +-
 test/tools/javac/api/6415780/T6415780.java         |    4 +-
 test/tools/javac/api/6418694/T6418694.java         |    3 +-
 test/tools/javac/api/6421111/T6421111.java         |    3 +-
 test/tools/javac/api/6421756/T6421756.java         |    3 +-
 test/tools/javac/api/6422215/T6422215.java         |    4 +-
 test/tools/javac/api/6422327/T6422327.java         |    4 +-
 test/tools/javac/api/6423003/T6423003.java         |    3 +-
 test/tools/javac/api/6431257/T6431257.java         |    3 +-
 test/tools/javac/api/6437349/T6437349.java         |    3 +-
 test/tools/javac/api/6437999/T6437999.java         |   26 +-
 test/tools/javac/api/6437999/Utf8.java             |   27 -
 test/tools/javac/api/6440333/T6440333.java         |    3 +-
 test/tools/javac/api/6440528/T6440528.java         |    3 +-
 test/tools/javac/api/6468404/T6468404.java         |    3 +-
 test/tools/javac/api/6731573/T6731573.java         |    4 +-
 test/tools/javac/api/6733837/T6733837.java         |    4 +-
 test/tools/javac/api/7086261/T7086261.java         |    2 +-
 test/tools/javac/api/8007344/Test.java             |  229 ++
 test/tools/javac/api/EndPositions.java             |   95 +
 test/tools/javac/api/T6306137.java                 |   32 +-
 test/tools/javac/api/T6395981.java                 |    6 +-
 test/tools/javac/api/T6397104.java                 |    2 +-
 test/tools/javac/api/T6838467.java                 |    1 -
 test/tools/javac/api/TestGetElementReference.java  |  120 +
 .../javac/api/TestGetElementReferenceData.java     |   50 +
 test/tools/javac/api/TestGetScope.java             |  101 +
 test/tools/javac/api/TestJavacTaskScanner.java     |   21 +-
 test/tools/javac/api/TestOperators.java            |   10 +-
 test/tools/javac/api/guide/Test.java               |    3 +-
 test/tools/javac/api/lib/ToolTester.java           |   33 +-
 .../api/taskListeners/TestSimpleAddRemove.java     |  351 ++
 test/tools/javac/apt.sh                            |   68 -
 test/tools/javac/cast/6270087/T6270087neg.out      |    2 +-
 test/tools/javac/cast/6557182/T6557182.out         |    2 +-
 test/tools/javac/cast/6665356/T6665356.out         |   14 +-
 test/tools/javac/cast/6795580/T6795580.out         |   14 +-
 test/tools/javac/cast/6932571/T6932571neg.out      |    2 +-
 test/tools/javac/cast/7005095/T7005095neg.out      |    2 +-
 test/tools/javac/cast/7005671/T7005671.out         |   32 +-
 test/tools/javac/cast/7123100/T7123100a.out        |    2 +-
 test/tools/javac/cast/7126754/T7126754.java        |   14 +
 test/tools/javac/cast/7126754/T7126754.out         |    4 +
 .../intersection/IntersectionTypeCastTest.java     |  359 ++
 .../intersection/IntersectionTypeParserTest.java   |  191 +
 .../tools/javac/cast/intersection/model/Check.java |   27 +
 .../intersection/model/IntersectionTypeInfo.java   |   29 +
 .../javac/cast/intersection/model/Member.java      |   31 +
 .../javac/cast/intersection/model/Model01.java     |   52 +
 .../cast/intersection/model/ModelChecker.java      |  153 +
 .../javac/classfiles/ClassVersionChecker.java      |  149 +
 test/tools/javac/classreader/T7031108.java         |    2 +-
 test/tools/javac/conditional/Conditional.java      |    3 +-
 test/tools/javac/conditional/T8016702.java         |   66 +
 test/tools/javac/constDebug/ConstDebug.java        |   35 -
 test/tools/javac/constDebug/ConstDebug.sh          |   80 -
 test/tools/javac/constDebug/ConstDebugTest.java    |   50 +
 .../CheckACC_STRICTFlagOnDefaultMethodTest.java    |   96 +
 .../ClassReaderTest/ClassReaderTest.java           |   32 +
 .../defaultMethods/ClassReaderTest/pkg/Foo.java    |   34 +
 .../javac/defaultMethods/DefaultMethodFlags.java   |  111 +
 test/tools/javac/defaultMethods/Neg01.java         |   18 +
 test/tools/javac/defaultMethods/Neg01.out          |    2 +
 test/tools/javac/defaultMethods/Neg02.java         |   26 +
 test/tools/javac/defaultMethods/Neg02.out          |    2 +
 test/tools/javac/defaultMethods/Neg03.java         |   38 +
 test/tools/javac/defaultMethods/Neg03.out          |    4 +
 test/tools/javac/defaultMethods/Neg04.java         |   14 +
 test/tools/javac/defaultMethods/Neg04.out          |    2 +
 test/tools/javac/defaultMethods/Neg05.java         |   16 +
 test/tools/javac/defaultMethods/Neg05.out          |    3 +
 test/tools/javac/defaultMethods/Neg06.java         |   16 +
 test/tools/javac/defaultMethods/Neg06.out          |    2 +
 test/tools/javac/defaultMethods/Neg07.java         |   21 +
 test/tools/javac/defaultMethods/Neg07.out          |    3 +
 test/tools/javac/defaultMethods/Neg08.java         |   20 +
 test/tools/javac/defaultMethods/Neg08.out          |    3 +
 test/tools/javac/defaultMethods/Neg09.java         |   22 +
 test/tools/javac/defaultMethods/Neg09.out          |    5 +
 test/tools/javac/defaultMethods/Neg10.java         |   20 +
 test/tools/javac/defaultMethods/Neg10.out          |    5 +
 test/tools/javac/defaultMethods/Neg11.java         |   20 +
 test/tools/javac/defaultMethods/Neg11.out          |    3 +
 test/tools/javac/defaultMethods/Neg12.java         |   27 +
 test/tools/javac/defaultMethods/Neg12.out          |    4 +
 test/tools/javac/defaultMethods/Neg13.java         |   18 +
 test/tools/javac/defaultMethods/Neg13.out          |   12 +
 test/tools/javac/defaultMethods/Neg14.java         |   11 +
 test/tools/javac/defaultMethods/Neg14.out          |    2 +
 test/tools/javac/defaultMethods/Neg15.java         |   14 +
 test/tools/javac/defaultMethods/Neg15.out          |    2 +
 test/tools/javac/defaultMethods/Neg16.java         |   13 +
 test/tools/javac/defaultMethods/Neg16.out          |    2 +
 test/tools/javac/defaultMethods/Pos01.java         |   59 +
 test/tools/javac/defaultMethods/Pos02.java         |   48 +
 test/tools/javac/defaultMethods/Pos04.java         |   43 +
 test/tools/javac/defaultMethods/Pos05.java         |   45 +
 test/tools/javac/defaultMethods/Pos06.java         |   49 +
 test/tools/javac/defaultMethods/Pos07.java         |   44 +
 test/tools/javac/defaultMethods/Pos08.java         |   46 +
 test/tools/javac/defaultMethods/Pos10.java         |   43 +
 test/tools/javac/defaultMethods/Pos11.java         |   56 +
 test/tools/javac/defaultMethods/Pos12.java         |   39 +
 test/tools/javac/defaultMethods/Pos13.java         |   62 +
 test/tools/javac/defaultMethods/Pos14.java         |   39 +
 test/tools/javac/defaultMethods/Pos15.java         |   39 +
 test/tools/javac/defaultMethods/Pos16.java         |   42 +
 .../javac/defaultMethods/TestDefaultBody.java      |  122 +
 .../defaultMethods/TestNoBridgeOnDefaults.java     |   84 +
 .../javac/defaultMethods/crossCompile/Clinit.java  |   29 +
 .../defaultMethods/crossCompile/CrossCompile.java  |   34 +
 .../DefaultMethodRegressionTests.java              |  138 +
 .../javac/defaultMethods/separate/Separate.java    |   40 +
 .../javac/defaultMethods/separate/pkg1/A.java      |   32 +
 .../javac/defaultMethods/static/Static01.java      |   51 +
 .../javac/defaultMethods/static/Static02.java      |   42 +
 .../tools/javac/defaultMethods/static/Static02.out |    2 +
 .../static/hiding/InterfaceMethodHidingTest.java   |  243 ++
 .../static/import/StaticImport1.java               |   38 +
 .../static/import/StaticImport2.java               |   38 +
 .../defaultMethods/static/import/StaticImport2.out |    2 +
 .../static/import/StaticImport3.java               |   38 +
 .../defaultMethods/static/import/StaticImport3.out |    2 +
 .../javac/defaultMethods/static/import/pkg/A.java  |   28 +
 .../javac/defaultMethods/static/import/pkg/B.java  |   26 +
 .../javac/defaultMethods/static/import/pkg/C.java  |   26 +
 .../defaultMethods/super/TestDefaultSuperCall.java |  417 +++
 .../syntax/TestDefaultMethodsSyntax.java           |  287 ++
 .../javac/depDocComment/DeprecatedDocComment3.java |   41 +
 .../javac/depDocComment/DeprecatedDocComment4.java |   20 +
 .../javac/depDocComment/DeprecatedDocComment4.out  |    6 +
 test/tools/javac/diags/ArgTypeCompilerFactory.java |   22 +-
 test/tools/javac/diags/CheckExamples.java          |   48 +-
 test/tools/javac/diags/CheckResourceKeys.java      |   11 +-
 test/tools/javac/diags/DocCommentProcessor.java    |  114 +
 test/tools/javac/diags/Example.java                |   21 +-
 test/tools/javac/diags/MessageFile.java            |    4 +-
 test/tools/javac/diags/MessageInfo.java            |    2 -
 test/tools/javac/diags/RunExamples.java            |   54 +-
 test/tools/javac/diags/examples.not-yet.txt        |   25 +-
 .../diags/examples/ApplicableMethodFound.java      |   33 +
 .../diags/examples/ApplicableMethodFound1.java     |   34 +
 .../javac/diags/examples/ArrayAndReceiver.java     |   31 +
 .../AuxiliaryClassWarning/ClassUsingAuxiliary.java |   29 +
 .../AuxiliaryClassWarning/ClassWithAuxiliary.java  |   29 +
 .../javac/diags/examples/BadArgTypesInLambda.java  |   41 +
 test/tools/javac/diags/examples/BadEntity.java     |   32 +
 .../diags/examples/BadFunctionalIntfAnno.java      |   28 +
 .../tools/javac/diags/examples/BadGreaterThan.java |   32 +
 test/tools/javac/diags/examples/BadInlineTag.java  |   32 +
 .../diags/examples/CantAccessInnerClsConstr.java   |   39 +
 .../diags/examples/CantAnnotateNestedType.java     |   41 +
 .../diags/examples/CantAnnotateStaticClass.java    |   41 +
 .../javac/diags/examples/CantApplyDiamond1.java    |   36 +
 .../diags/examples/CantApplySymbolFragment.java    |   41 +
 .../diags/examples/CantApplySymbolsFragment.java   |   45 +
 .../examples/CantRefNonEffectivelyFinalVar.java    |   44 +
 .../examples/CantResolveLocationArgsFragment.java  |   37 +
 .../CantResolveLocationArgsParamsFragment.java     |   37 +
 .../diags/examples/CantReturnValueForVoid.java     |   30 -
 .../javac/diags/examples/CatchWithoutTry.java      |    4 +-
 .../javac/diags/examples/CompressedDiags.java      |   39 +
 .../examples/ConditionalTargetCantBeVoid.java      |   37 +
 .../javac/diags/examples/CyclicInference.java      |   37 +
 .../diags/examples/DefaultMethodNotSupported.java  |   29 +
 .../examples/DefaultOverridesObjectMember.java     |   28 +
 .../javac/diags/examples/DeferredMethodInst.java   |   35 +
 .../javac/diags/examples/DuplicateAnnotation.java  |    4 +-
 .../diags/examples/DuplicateAnnotationJava8.java   |   30 +
 .../ExplicitParamsDoNotConformToBounds.java        |    2 +-
 .../diags/examples/ForeachBadInitialization.java   |   31 +
 .../javac/diags/examples/GreaterThanExpected.java  |   34 +
 test/tools/javac/diags/examples/IllegalChar.java   |    4 +-
 test/tools/javac/diags/examples/IllegalDot.java    |   30 +
 .../javac/diags/examples/IllegalStartOfStmt.java   |   31 +
 .../diags/examples/IllegalStaticIntfMethCall.java  |   34 +
 .../InaccessibleVarargsType.java                   |    2 +-
 .../diags/examples/IncompatibleAbstracts.java      |   36 +
 .../examples/IncompatibleArgTypesInLambda.java     |   33 +
 .../examples/IncompatibleArgTypesInMethodRef.java  |   40 +
 .../IncompatibleDescsInFunctionalIntf.java         |   42 +
 .../diags/examples/IncompatibleEqUpperBounds.java  |   35 +
 .../examples/IncompatibleRetTypeInLambda.java      |   34 +
 .../diags/examples/IncompatibleRetTypeInMref.java  |   36 +
 .../examples/IncompatibleThrownTypesInMref.java    |   34 +
 .../javac/diags/examples/IncompatibleTypes1.java   |    7 +-
 .../examples/IncompatibleTypesInConditional.java   |   34 +
 .../javac/diags/examples/InconvertibleTypes.java   |    2 +-
 .../examples/IncorrectConstructorReceiverName.java |   30 +
 .../examples/IncorrectConstructorReceiverType.java |   30 +
 .../diags/examples/IncorrectReceiverName.java      |   30 +
 .../diags/examples/IncorrectReceiverType.java      |   28 +
 .../diags/examples/InferArgsLengthMismatch.java    |    2 +-
 .../examples/InferNoConformingAssignment.java      |   34 +
 .../examples/InferVarargsArgumentMismatch.java     |   31 +
 .../examples/InferredDoNotConformToBounds.java     |   35 -
 .../diags/examples/InferredDoNotConformToEq.java   |   33 +
 .../examples/InferredDoNotConformToUpper.java      |   33 +
 .../IntersectionTypesInCastNotSupported.java       |   29 +
 .../diags/examples/InvalidDuplicateAnnotation.java |   39 +
 .../diags/examples/InvalidGenericLambdaTarget.java |   34 +
 .../javac/diags/examples/InvalidInferredTypes.java |   38 -
 .../javac/diags/examples/KindnameConstructor.java  |   10 +-
 .../javac/diags/examples/LambdaNotSupported.java   |   29 +
 test/tools/javac/diags/examples/LambdaStat.java    |   29 +
 .../javac/diags/examples/LocalVarNeedsFinal.java   |    1 +
 test/tools/javac/diags/examples/MalformedHTML.java |   31 +
 .../examples/MethodReferencesNotSupported.java     |   29 +
 .../javac/diags/examples/MissingReturnValue.java   |    5 +-
 .../diags/examples/MissingReturnValueFragment.java |   36 +
 .../javac/diags/examples/MissingSemicolon.java     |   32 +
 test/tools/javac/diags/examples/MrefStat.java      |   31 +
 test/tools/javac/diags/examples/MrefStat.java.rej  |   34 +
 test/tools/javac/diags/examples/MrefStat1.java     |   34 +
 test/tools/javac/diags/examples/MrefStat1.java.rej |   37 +
 test/tools/javac/diags/examples/NoAbstracts.java   |   33 +
 .../diags/examples/NoAnnotationsOnDotClass.java    |   31 +
 test/tools/javac/diags/examples/NoArgs.java        |    2 +-
 test/tools/javac/diags/examples/NoContent.java     |   33 +
 .../examples/NoSuitableFunctionalIntfInst.java     |   34 +
 test/tools/javac/diags/examples/NoTagName.java     |   32 +
 .../diags/examples/NonStaticCantBeRefFragment.java |   38 +
 .../javac/diags/examples/NotAFunctionalIntf.java   |   34 +
 test/tools/javac/diags/examples/NotAStatement.java |   30 +
 .../javac/diags/examples/NotAllowedClass.java      |   31 +
 .../javac/diags/examples/NotAllowedVariable.java   |   31 +
 .../diags/examples/NotAnInterfaceComponent.java    |   30 +
 .../diags/examples/NotApplicableMethodFound.java   |   36 +
 .../NotDefAccessClassIntfCantAccessFragment.java   |   46 +
 .../NotDefPublicCantAccessFragment.java            |   36 +
 .../NotDefPublicCantAccessFragment/p/C.java        |   28 +
 test/tools/javac/diags/examples/NotInProfile.java  |   29 +
 .../javac/diags/examples/OverriddenDefault.java    |   35 +
 .../tools/javac/diags/examples/PartialInstSig.java |   34 +
 .../diags/examples/PossibleLossPrecision.java      |    2 +-
 .../javac/diags/examples/PotentialLambdaFound.java |   34 +
 .../javac/diags/examples/ProbFoundReqFragment.java |   44 +
 .../ReceiverParameterNotApplicableConstructor.java |   28 +
 .../javac/diags/examples/RedundantSupertype.java   |   34 +
 .../javac/diags/examples/RefAmbiguousFragment.java |   40 +
 test/tools/javac/diags/examples/RefBadParens.java  |   32 +
 .../diags/examples/RefIdentifierExpected.java      |   34 +
 .../tools/javac/diags/examples/RefSyntaxError.java |   32 +
 .../javac/diags/examples/RefUnexpectedInput.java   |   32 +
 .../examples/RepeatableDocumentedMismatch.java     |   36 +
 .../examples/RepeatableInheritedMismatch.java      |   36 +
 .../javac/diags/examples/RepeatableNoValue.java    |   35 +
 .../javac/diags/examples/RepeatableNonDefault.java |   33 +
 .../examples/RepeatableRetentionMismatch.java      |   36 +
 .../diags/examples/RepeatableTargetMismatch.java   |   34 +
 .../diags/examples/RepeatableWrongValueType.java   |   35 +
 .../examples/RepeatingAnnotationAndContainer.java  |   36 +
 .../examples/ResourceNotApplicableToType.java      |    3 +-
 .../javac/diags/examples/StaticBoundMref.java      |   32 +
 .../examples/StaticIntfMethodNotSupported.java     |   29 +
 .../examples/StaticMethodInUnboundLookup.java      |   36 +
 .../javac/diags/examples/StaticMrefWithTargs.java  |   32 +
 .../javac/diags/examples/ThisAsIdentifier.java     |   28 +
 .../examples/TypeAnnotationsNotSupported.java      |   34 +
 .../examples/TypesIncompatibleAbstractDefault.java |   36 +
 .../TypesIncompatibleUnrelatedDefaults.java        |   36 +
 .../diags/examples/UnderscoreAsIdentifier.java     |   28 +
 .../javac/diags/examples/UndeterminedType1.java    |   34 -
 .../javac/diags/examples/UnexpectedContent.java    |   32 +
 .../javac/diags/examples/UnexpectedLambda.java     |   28 +
 .../tools/javac/diags/examples/UnexpectedMref.java |   28 +
 .../diags/examples/UnexpectedReturnValue.java      |   31 +
 .../javac/diags/examples/UnsupportedEncoding.java  |    3 +-
 .../diags/examples/UnterminatedInlineTag.java      |   32 +
 .../diags/examples/UnterminatedSignature.java      |   32 +
 .../javac/diags/examples/VarargsAndReceiver.java   |   28 +
 .../diags/examples/VarargsArgumentMismatch.java    |    5 +-
 .../javac/diags/examples/VerboseResolveMulti.java  |   33 +
 .../javac/diags/examples/VerboseResolveMulti1.java |   36 +
 test/tools/javac/diags/examples/WhereCaptured.java |    6 +-
 .../tools/javac/diags/examples/WhereCaptured1.java |    6 +-
 .../tools/javac/diags/examples/WhereFreshTvar.java |   37 +
 .../javac/diags/examples/WhereIntersection.java    |    4 +-
 test/tools/javac/diags/examples/WhereTypeVar.java  |    5 +-
 test/tools/javac/doclint/DocLintTest.java          |  225 ++
 test/tools/javac/doclint/ImplicitHeadersTest.java  |   35 +
 test/tools/javac/doctree/AttrTest.java             |  281 ++
 test/tools/javac/doctree/AuthorTest.java           |   46 +
 test/tools/javac/doctree/BadTest.java              |   52 +
 test/tools/javac/doctree/CodeTest.java             |  133 +
 test/tools/javac/doctree/DeprecatedTest.java       |   64 +
 test/tools/javac/doctree/DocCommentTester.java     |  779 ++++
 test/tools/javac/doctree/DocRootTest.java          |   84 +
 .../javac/doctree/DocTreePathScannerTest.java      |  161 +
 test/tools/javac/doctree/ElementTest.java          |  250 ++
 test/tools/javac/doctree/EntityTest.java           |  165 +
 test/tools/javac/doctree/ExceptionTest.java        |   69 +
 test/tools/javac/doctree/FirstSentenceTest.java    |  198 +
 test/tools/javac/doctree/InheritDocTest.java       |   84 +
 test/tools/javac/doctree/LinkPlainTest.java        |  192 +
 test/tools/javac/doctree/LinkTest.java             |  192 +
 test/tools/javac/doctree/LiteralTest.java          |  134 +
 test/tools/javac/doctree/ParamTest.java            |   68 +
 test/tools/javac/doctree/ReferenceTest.java        |  216 ++
 test/tools/javac/doctree/ReturnTest.java           |   51 +
 test/tools/javac/doctree/SeeTest.java              |  174 +
 test/tools/javac/doctree/SerialDataTest.java       |   50 +
 test/tools/javac/doctree/SerialFieldTest.java      |   74 +
 test/tools/javac/doctree/SerialTest.java           |   97 +
 .../javac/doctree/SimpleDocTreeVisitorTest.java    |  166 +
 test/tools/javac/doctree/SinceTest.java            |   53 +
 test/tools/javac/doctree/TagTest.java              |  149 +
 test/tools/javac/doctree/ThrowableTest.java        |   69 +
 test/tools/javac/doctree/ValueTest.java            |  103 +
 test/tools/javac/doctree/VersionTest.java          |   51 +
 .../javac/doctree/positions/TestPosition.java      |  105 +
 .../tools/javac/doctree/positions/TestPosition.out |   99 +
 .../doctree/positions/TestPositionSource.java      |   71 +
 test/tools/javac/enum/6350057/T6350057.java        |   12 +-
 test/tools/javac/enum/6424358/T6424358.java        |   17 +-
 test/tools/javac/enum/7160084/T7160084a.java       |   60 +
 test/tools/javac/enum/7160084/T7160084b.java       |   68 +
 test/tools/javac/failover/CheckAttributedTree.java |  196 +-
 test/tools/javac/fatalErrors/NoJavaLang.java       |   40 -
 test/tools/javac/fatalErrors/NoJavaLang.out        |    1 -
 test/tools/javac/fatalErrors/NoJavaLang.sh         |  114 -
 test/tools/javac/fatalErrors/NoJavaLangTest.java   |   76 +
 test/tools/javac/file/T7018098.java                |    2 +-
 .../8003512/LoadClassFromJava6CreatedJarTest.java  |  183 +
 test/tools/javac/file/zip/Utils.java               |    8 +-
 test/tools/javac/foreach/7139681/T7139681neg.java  |   16 +
 test/tools/javac/foreach/7139681/T7139681neg.out   |    3 +
 test/tools/javac/foreach/7139681/T7139681pos.java  |   46 +
 test/tools/javac/generics/6207386/T6207386.out     |    2 +-
 test/tools/javac/generics/6723444/T6723444.java    |    3 +-
 test/tools/javac/generics/6723444/T6723444.out     |   13 -
 test/tools/javac/generics/6723444/T6723444_1.out   |   13 +
 test/tools/javac/generics/6723444/T6723444_2.out   |   11 +
 test/tools/javac/generics/7015430/T7015430.java    |    3 +-
 test/tools/javac/generics/7015430/T7015430.out     |   19 -
 test/tools/javac/generics/7015430/T7015430_1.out   |   19 +
 test/tools/javac/generics/7015430/T7015430_2.out   |   15 +
 .../tools/javac/generics/7022054/T7022054pos1.java |    3 +-
 test/tools/javac/generics/7022054/T7022054pos1.out |    2 +
 .../tools/javac/generics/7022054/T7022054pos2.java |    4 +-
 test/tools/javac/generics/7022054/T7022054pos2.out |    2 +
 test/tools/javac/generics/7034511/T7034511a.java   |    3 +-
 test/tools/javac/generics/7034511/T7034511a.out    |    2 +-
 test/tools/javac/generics/7034511/T7034511b.java   |    3 +-
 test/tools/javac/generics/7034511/T7034511b.out    |    2 +-
 test/tools/javac/generics/7034511/T7041019.java    |   39 +
 test/tools/javac/generics/7151802/T7151802.java    |   43 +
 test/tools/javac/generics/7151802/T7151802.out     |    9 +
 test/tools/javac/generics/8004094/B.java           |   47 +
 test/tools/javac/generics/8004094/T8004094.java    |   32 +
 test/tools/javac/generics/8016640/T8016640.java    |   11 +
 test/tools/javac/generics/8016640/T8016640.out     |    2 +
 test/tools/javac/generics/OverrideBridge.java      |    6 +-
 test/tools/javac/generics/bridges/Bridge.java      |   28 +
 .../javac/generics/bridges/BridgeHarness.java      |  219 ++
 test/tools/javac/generics/bridges/Bridges.java     |   25 +
 .../bridges/tests/TestBridgeWithDefault.java       |   31 +
 .../TestClassAndInterfaceBridgeIdentical01.java    |   45 +
 .../TestClassAndInterfaceBridgeIdentical02.java    |   45 +
 .../bridges/tests/TestNoBridgeInSiblingsSuper.java |   34 +
 .../bridges/tests/TestNoDuplicateBridges01.java    |   29 +
 .../bridges/tests/TestNoDuplicateBridges02.java    |   38 +
 .../javac/generics/diamond/6939780/T6939780.java   |   50 +
 .../javac/generics/diamond/6939780/T6939780_7.out  |    4 +
 .../javac/generics/diamond/6939780/T6939780_8.out  |    7 +
 .../javac/generics/diamond/7002837/T7002837.java   |    2 +-
 .../javac/generics/diamond/7002837/T7002837.out    |    4 +
 .../diamond/7046778/DiamondAndInnerClassTest.java  |  127 +-
 .../javac/generics/diamond/7188968/T7188968.java   |   25 +
 .../javac/generics/diamond/7188968/T7188968.out    |    7 +
 test/tools/javac/generics/diamond/T6939780.java    |   25 -
 test/tools/javac/generics/diamond/T6939780.out     |    3 -
 test/tools/javac/generics/diamond/neg/Neg05.out    |   16 +-
 test/tools/javac/generics/diamond/neg/Neg06.out    |    2 +-
 test/tools/javac/generics/diamond/neg/Neg07.out    |    2 +-
 test/tools/javac/generics/diamond/neg/Neg10.java   |    3 +-
 test/tools/javac/generics/diamond/neg/Neg10.out    |    2 +-
 .../generics/inference/6278587/T6278587Neg.java    |    7 +-
 .../javac/generics/inference/6315770/T6315770.out  |    4 +-
 .../javac/generics/inference/6611449/T6611449.out  |    8 +-
 .../javac/generics/inference/6638712/T6638712a.out |    2 +-
 .../javac/generics/inference/6638712/T6638712b.out |    2 +-
 .../javac/generics/inference/6638712/T6638712c.out |    2 +-
 .../javac/generics/inference/6638712/T6638712d.out |    2 +-
 .../javac/generics/inference/6638712/T6638712e.out |    2 +-
 .../javac/generics/inference/6650759/T6650759m.out |    2 +-
 .../javac/generics/inference/6718364/T6718364.out  |    2 +-
 .../javac/generics/inference/6838943/T6838943.out  |    2 +-
 .../javac/generics/inference/7086586/T7086586.out  |    8 +-
 .../generics/inference/7086586/T7086586b.java      |   54 +
 .../javac/generics/inference/7086601/T7086601a.out |    8 +-
 .../generics/inference/7086601/T7086601b.java      |    2 +-
 .../javac/generics/inference/7154127/T7154127.java |   22 +
 .../javac/generics/inference/7154127/T7154127.out  |    2 +
 .../generics/inference/7177306/T7177306a.java      |   19 +
 .../javac/generics/inference/7177306/T7177306a.out |    6 +
 .../generics/inference/7177306/T7177306b.java      |   18 +
 .../javac/generics/inference/7177306/T7177306b.out |    2 +
 .../generics/inference/7177306/T7177306c.java      |   38 +
 .../generics/inference/7177306/T7177306d.java      |   53 +
 .../generics/inference/7177306/T7177306e.java      |   18 +
 .../javac/generics/inference/7177306/T7177306e.out |    2 +
 .../javac/generics/inference/8006692/T8006692.java |   38 +
 .../javac/generics/inference/8015505/T8015505.java |   18 +
 .../javac/generics/inference/8015505/T8015505.out  |    2 +
 .../javac/generics/inference/8019824/T8019824.java |   15 +
 .../javac/generics/inference/8019824/T8019824.out  |    2 +
 .../javac/generics/inference/8020149/T8020149.java |   48 +
 test/tools/javac/generics/odersky/BadTest4.java    |    5 +-
 .../tools/javac/generics/rare/6665356/T6665356.out |    2 +-
 .../rawOverride/7062745/GenericOverrideTest.java   |   90 +-
 .../generics/rawOverride/7062745/T7062745neg.out   |    2 +-
 .../javac/generics/rawOverride/7157798/Test1.java  |  116 +
 .../javac/generics/rawOverride/7157798/Test2.java  |   76 +
 .../javac/generics/rawOverride/7157798/Test3.java  |   37 +
 .../javac/generics/rawOverride/7157798/Test3.out   |    6 +
 .../javac/generics/rawOverride/7157798/Test4.java  |   29 +
 .../javac/generics/rawOverride/7157798/Test4.out   |    6 +
 .../tools/javac/generics/rawOverride/T8008627.java |   47 +
 .../generics/wildcards/6886247/T6886247_2.out      |    2 +-
 .../tools/javac/incompleteStatements/T8000484.java |   17 +
 test/tools/javac/incompleteStatements/T8000484.out |   10 +
 test/tools/javac/innerClassFile/Driver.sh          |   73 -
 .../javac/innerClassFile/InnerClassFileTest.java   |  127 +
 test/tools/javac/innerClassFile/x/B.java           |   30 -
 test/tools/javac/innerClassFile/x/C.java           |   28 -
 test/tools/javac/innerClassFile/y/Main.java        |   30 -
 test/tools/javac/innerClassFile/y/R1.java          |   30 -
 test/tools/javac/innerClassFile/y/R2.java          |   29 -
 test/tools/javac/innerClassFile/y/R3.java          |   30 -
 test/tools/javac/javazip/A.java                    |   27 -
 test/tools/javac/javazip/JavaZipTest.java          |  126 +
 test/tools/javac/javazip/Test.sh                   |  111 -
 test/tools/javac/javazip/bad/B.java                |   25 -
 test/tools/javac/javazip/good/B.java               |   26 -
 test/tools/javac/jvm/T7024096.java                 |   31 +
 test/tools/javac/lambda/8019480/T8019480.java      |   23 +
 test/tools/javac/lambda/8019480/T8019480.out       |    3 +
 test/tools/javac/lambda/8020147/T8020147.java      |   19 +
 test/tools/javac/lambda/8020147/T8020147.out       |    5 +
 test/tools/javac/lambda/BadAccess.java             |   30 +
 test/tools/javac/lambda/BadAccess.out              |    2 +
 test/tools/javac/lambda/BadAccess02.java           |   31 +
 test/tools/javac/lambda/BadAccess02.out            |    3 +
 test/tools/javac/lambda/BadAccess03.java           |   15 +
 test/tools/javac/lambda/BadAccess03.out            |    2 +
 test/tools/javac/lambda/BadBreakContinue.java      |   44 +
 test/tools/javac/lambda/BadBreakContinue.out       |   13 +
 test/tools/javac/lambda/BadConv03.java             |   20 +
 test/tools/javac/lambda/BadConv03.out              |    2 +
 test/tools/javac/lambda/BadConv04.java             |   22 +
 test/tools/javac/lambda/BadConv04.out              |    3 +
 test/tools/javac/lambda/BadExpressionLambda.java   |   21 +
 test/tools/javac/lambda/BadExpressionLambda.out    |    2 +
 test/tools/javac/lambda/BadLambdaExpr.java         |  191 +
 test/tools/javac/lambda/BadLambdaPos.java          |   31 +
 test/tools/javac/lambda/BadLambdaPos.out           |    9 +
 test/tools/javac/lambda/BadMethodCall.java         |   16 +
 test/tools/javac/lambda/BadMethodCall.out          |    2 +
 test/tools/javac/lambda/BadMethodCall2.java        |   13 +
 test/tools/javac/lambda/BadMethodCall2.out         |    4 +
 test/tools/javac/lambda/BadNestedLambda.java       |   11 +
 test/tools/javac/lambda/BadNestedLambda.out        |    3 +
 test/tools/javac/lambda/BadRecovery.java           |   19 +
 test/tools/javac/lambda/BadRecovery.out            |    2 +
 test/tools/javac/lambda/BadReturn.java             |   38 +
 test/tools/javac/lambda/BadReturn.out              |    3 +
 test/tools/javac/lambda/BadStatementInLambda.java  |   19 +
 test/tools/javac/lambda/BadStatementInLambda.out   |    4 +
 .../tools/javac/lambda/BadStatementInLambda02.java |   19 +
 test/tools/javac/lambda/BadStatementInLambda02.out |    2 +
 test/tools/javac/lambda/BadTargetType.java         |   23 +
 test/tools/javac/lambda/BadTargetType.out          |    5 +
 test/tools/javac/lambda/Conditional01.java         |   45 +
 test/tools/javac/lambda/Conditional02.java         |   42 +
 test/tools/javac/lambda/Conditional03.java         |   43 +
 test/tools/javac/lambda/Conformance01.java         |   36 +
 test/tools/javac/lambda/Defender01.java            |   45 +
 test/tools/javac/lambda/DisjunctiveTypeTest.java   |   52 +
 test/tools/javac/lambda/DoubleStaticImport.java    |   38 +
 test/tools/javac/lambda/EffectivelyFinal01.java    |   18 +
 test/tools/javac/lambda/EffectivelyFinal01.out     |    2 +
 test/tools/javac/lambda/EffectivelyFinalTest.java  |   55 +
 test/tools/javac/lambda/EffectivelyFinalTest01.out |    6 +
 test/tools/javac/lambda/EffectivelyFinalTest02.out |   14 +
 test/tools/javac/lambda/ErroneousArg.java          |   36 +
 test/tools/javac/lambda/ErroneousArg.out           |    7 +
 test/tools/javac/lambda/ErroneousLambdaExpr.java   |   65 +
 test/tools/javac/lambda/ExceptionsInLambda.java    |   61 +
 test/tools/javac/lambda/ExceptionsInLambda.out     |    4 +
 .../javac/lambda/FunctionalInterfaceAnno.java      |   33 +
 .../tools/javac/lambda/FunctionalInterfaceAnno.out |    9 +
 .../javac/lambda/FunctionalInterfaceAnno02.java    |   38 +
 .../lambda/FunctionalInterfaceConversionTest.java  |  309 ++
 .../javac/lambda/GenericMethodRefImplClass.java    |   81 +
 test/tools/javac/lambda/IdentifierTest.java        |  182 +
 test/tools/javac/lambda/IdentifierTest.out         |   47 +
 test/tools/javac/lambda/InnerConstructor.java      |   56 +
 test/tools/javac/lambda/Intersection01.java        |   42 +
 test/tools/javac/lambda/Intersection02.java        |   41 +
 test/tools/javac/lambda/Intersection02.out         |    4 +
 test/tools/javac/lambda/Intersection03.java        |   49 +
 test/tools/javac/lambda/LambdaCapture01.java       |  107 +
 test/tools/javac/lambda/LambdaCapture02.java       |  107 +
 test/tools/javac/lambda/LambdaCapture03.java       |   99 +
 test/tools/javac/lambda/LambdaCapture04.java       |  143 +
 test/tools/javac/lambda/LambdaCapture05.java       |   81 +
 test/tools/javac/lambda/LambdaCapture06.java       |   56 +
 test/tools/javac/lambda/LambdaCapture07.java       |   60 +
 test/tools/javac/lambda/LambdaConv01.java          |  145 +
 test/tools/javac/lambda/LambdaConv03.java          |  121 +
 test/tools/javac/lambda/LambdaConv05.java          |   62 +
 test/tools/javac/lambda/LambdaConv06.java          |   52 +
 test/tools/javac/lambda/LambdaConv08.java          |   57 +
 test/tools/javac/lambda/LambdaConv09.java          |   50 +
 test/tools/javac/lambda/LambdaConv09.out           |    5 +
 test/tools/javac/lambda/LambdaConv10.java          |   17 +
 test/tools/javac/lambda/LambdaConv10.out           |    2 +
 test/tools/javac/lambda/LambdaConv11.java          |   42 +
 test/tools/javac/lambda/LambdaConv12.java          |   45 +
 test/tools/javac/lambda/LambdaConv13.java          |   48 +
 test/tools/javac/lambda/LambdaConv16.java          |   63 +
 test/tools/javac/lambda/LambdaConv17.java          |   38 +
 test/tools/javac/lambda/LambdaConv18.java          |   24 +
 test/tools/javac/lambda/LambdaConv18.out           |    4 +
 test/tools/javac/lambda/LambdaConv19.java          |   39 +
 test/tools/javac/lambda/LambdaConv20.java          |   56 +
 test/tools/javac/lambda/LambdaConv21.java          |   38 +
 test/tools/javac/lambda/LambdaConv21.out           |    5 +
 test/tools/javac/lambda/LambdaConv22.java          |   42 +
 test/tools/javac/lambda/LambdaConv23.java          |   62 +
 test/tools/javac/lambda/LambdaConv24.java          |   64 +
 test/tools/javac/lambda/LambdaConv25.java          |   21 +
 test/tools/javac/lambda/LambdaConv25.out           |    2 +
 test/tools/javac/lambda/LambdaConv26.java          |   41 +
 test/tools/javac/lambda/LambdaConv27.java          |   40 +
 .../javac/lambda/LambdaEffectivelyFinalTest.java   |   60 +
 .../javac/lambda/LambdaEffectivelyFinalTest.out    |    6 +
 test/tools/javac/lambda/LambdaExpr01.java          |  133 +
 test/tools/javac/lambda/LambdaExpr02.java          |  133 +
 test/tools/javac/lambda/LambdaExpr04.java          |   46 +
 test/tools/javac/lambda/LambdaExpr05.java          |   39 +
 test/tools/javac/lambda/LambdaExpr06.java          |   51 +
 test/tools/javac/lambda/LambdaExpr07.java          |   57 +
 test/tools/javac/lambda/LambdaExpr08.java          |   43 +
 test/tools/javac/lambda/LambdaExpr09.java          |   54 +
 test/tools/javac/lambda/LambdaExpr10.java          |   37 +
 test/tools/javac/lambda/LambdaExpr10.out           |    9 +
 test/tools/javac/lambda/LambdaExpr11.java          |   89 +
 test/tools/javac/lambda/LambdaExpr12.java          |   66 +
 test/tools/javac/lambda/LambdaExpr13.java          |   47 +
 test/tools/javac/lambda/LambdaExpr14.java          |   43 +
 test/tools/javac/lambda/LambdaExpr15.java          |   66 +
 test/tools/javac/lambda/LambdaExpr16.java          |   76 +
 test/tools/javac/lambda/LambdaExpr17.java          |   63 +
 test/tools/javac/lambda/LambdaExpr18.java          |   62 +
 test/tools/javac/lambda/LambdaExpr19.java          |   53 +
 test/tools/javac/lambda/LambdaExpr19.out           |    6 +
 test/tools/javac/lambda/LambdaExpr20.java          |   45 +
 test/tools/javac/lambda/LambdaExpr21.java          |   67 +
 test/tools/javac/lambda/LambdaExprNotVoid.java     |   16 +
 test/tools/javac/lambda/LambdaExprNotVoid.out      |    3 +
 .../tools/javac/lambda/LambdaInnerTypeVarArgs.java |   80 +
 .../lambda/LambdaInnerTypeVarArgsSerialize.java    |   80 +
 .../javac/lambda/LambdaInnerTypeVarReflect.java    |   86 +
 .../javac/lambda/LambdaInnerTypeVarSerialize.java  |   75 +
 .../javac/lambda/LambdaInterfaceStaticField.java   |   38 +
 .../tools/javac/lambda/LambdaLambdaSerialized.java |   79 +
 test/tools/javac/lambda/LambdaParserTest.java      |  317 ++
 test/tools/javac/lambda/LambdaScope01.java         |   79 +
 test/tools/javac/lambda/LambdaScope02.java         |   63 +
 test/tools/javac/lambda/LambdaScope03.java         |   64 +
 test/tools/javac/lambda/LambdaScope04.java         |  163 +
 test/tools/javac/lambda/LambdaScope04.out          |   37 +
 test/tools/javac/lambda/LambdaScope05.java         |   31 +
 test/tools/javac/lambda/LambdaScope05.out          |    7 +
 .../javac/lambda/LambdaWithInterfaceSuper.java     |   43 +
 test/tools/javac/lambda/LocalBreakAndContinue.java |   42 +
 test/tools/javac/lambda/MethodReference01.java     |   92 +
 test/tools/javac/lambda/MethodReference02.java     |   42 +
 test/tools/javac/lambda/MethodReference03.java     |   55 +
 test/tools/javac/lambda/MethodReference04.java     |   14 +
 test/tools/javac/lambda/MethodReference04.out      |    2 +
 test/tools/javac/lambda/MethodReference05.java     |   54 +
 test/tools/javac/lambda/MethodReference06.java     |   62 +
 test/tools/javac/lambda/MethodReference07.java     |   45 +
 test/tools/javac/lambda/MethodReference08.java     |   24 +
 test/tools/javac/lambda/MethodReference08.out      |    5 +
 test/tools/javac/lambda/MethodReference09.java     |   25 +
 test/tools/javac/lambda/MethodReference09.out      |    4 +
 test/tools/javac/lambda/MethodReference10.java     |   53 +
 test/tools/javac/lambda/MethodReference11.java     |   46 +
 test/tools/javac/lambda/MethodReference12.java     |   77 +
 test/tools/javac/lambda/MethodReference13.java     |   51 +
 test/tools/javac/lambda/MethodReference14.java     |   54 +
 test/tools/javac/lambda/MethodReference15.java     |   44 +
 test/tools/javac/lambda/MethodReference16.java     |   61 +
 test/tools/javac/lambda/MethodReference17.java     |   61 +
 test/tools/javac/lambda/MethodReference18.java     |   65 +
 test/tools/javac/lambda/MethodReference19.java     |   61 +
 test/tools/javac/lambda/MethodReference20.java     |   24 +
 test/tools/javac/lambda/MethodReference20.out      |    3 +
 test/tools/javac/lambda/MethodReference21.java     |   23 +
 test/tools/javac/lambda/MethodReference21.out      |    3 +
 test/tools/javac/lambda/MethodReference22.java     |   67 +
 test/tools/javac/lambda/MethodReference22.out      |   15 +
 test/tools/javac/lambda/MethodReference23.java     |   74 +
 test/tools/javac/lambda/MethodReference23.out      |    6 +
 test/tools/javac/lambda/MethodReference24.java     |   57 +
 test/tools/javac/lambda/MethodReference25.java     |   50 +
 test/tools/javac/lambda/MethodReference25.out      |    2 +
 test/tools/javac/lambda/MethodReference26.java     |   44 +
 test/tools/javac/lambda/MethodReference27.java     |   62 +
 test/tools/javac/lambda/MethodReference28.java     |   56 +
 test/tools/javac/lambda/MethodReference28.out      |   14 +
 test/tools/javac/lambda/MethodReference29.java     |   53 +
 test/tools/javac/lambda/MethodReference30.java     |   55 +
 test/tools/javac/lambda/MethodReference31.java     |  217 ++
 test/tools/javac/lambda/MethodReference32.java     |   22 +
 test/tools/javac/lambda/MethodReference32.out      |    7 +
 test/tools/javac/lambda/MethodReference33.java     |   66 +
 test/tools/javac/lambda/MethodReference34.java     |   65 +
 test/tools/javac/lambda/MethodReference35.java     |   64 +
 test/tools/javac/lambda/MethodReference36.java     |   91 +
 test/tools/javac/lambda/MethodReference37.java     |   40 +
 test/tools/javac/lambda/MethodReference37.out      |    5 +
 test/tools/javac/lambda/MethodReference38.java     |   29 +
 test/tools/javac/lambda/MethodReference38.out      |    5 +
 test/tools/javac/lambda/MethodReference39.java     |   25 +
 test/tools/javac/lambda/MethodReference39.out      |    2 +
 test/tools/javac/lambda/MethodReference40.java     |   24 +
 test/tools/javac/lambda/MethodReference40.out      |    2 +
 test/tools/javac/lambda/MethodReference41.java     |   66 +
 test/tools/javac/lambda/MethodReference42.java     |   65 +
 test/tools/javac/lambda/MethodReference43.java     |   71 +
 test/tools/javac/lambda/MethodReference44.java     |   67 +
 test/tools/javac/lambda/MethodReference45.java     |   40 +
 test/tools/javac/lambda/MethodReference45.out      |    2 +
 test/tools/javac/lambda/MethodReference46.java     |   67 +
 test/tools/javac/lambda/MethodReference47.java     |   40 +
 test/tools/javac/lambda/MethodReference47.out      |    2 +
 test/tools/javac/lambda/MethodReference48.java     |   65 +
 test/tools/javac/lambda/MethodReference49.java     |   50 +
 test/tools/javac/lambda/MethodReference50.java     |   25 +
 test/tools/javac/lambda/MethodReference50.out      |    2 +
 test/tools/javac/lambda/MethodReference51.java     |   46 +
 test/tools/javac/lambda/MethodReference51.out      |    7 +
 test/tools/javac/lambda/MethodReference52.java     |   39 +
 test/tools/javac/lambda/MethodReference52.out      |    3 +
 test/tools/javac/lambda/MethodReference53.java     |   24 +
 test/tools/javac/lambda/MethodReference53.out      |    2 +
 test/tools/javac/lambda/MethodReference54.java     |   19 +
 test/tools/javac/lambda/MethodReference54.out      |    2 +
 test/tools/javac/lambda/MethodReference55.java     |   45 +
 test/tools/javac/lambda/MethodReference55.out      |    3 +
 test/tools/javac/lambda/MethodReference56.java     |   45 +
 test/tools/javac/lambda/MethodReference56.out      |    3 +
 test/tools/javac/lambda/MethodReference57.java     |   41 +
 test/tools/javac/lambda/MethodReference58.java     |   46 +
 test/tools/javac/lambda/MethodReference58.out      |    2 +
 test/tools/javac/lambda/MethodReference59.java     |   52 +
 test/tools/javac/lambda/MethodReference60.java     |   55 +
 test/tools/javac/lambda/MethodReference60.out      |    6 +
 test/tools/javac/lambda/MethodReference61.java     |   43 +
 test/tools/javac/lambda/MethodReference62.java     |   22 +
 test/tools/javac/lambda/MethodReference62.out      |    2 +
 test/tools/javac/lambda/MethodReference63.java     |   43 +
 test/tools/javac/lambda/MethodReference64.java     |   46 +
 test/tools/javac/lambda/MethodReference64.out      |   13 +
 test/tools/javac/lambda/MethodReference65.java     |   41 +
 test/tools/javac/lambda/MethodReference66.java     |   53 +
 test/tools/javac/lambda/MethodReference67.java     |   18 +
 test/tools/javac/lambda/MethodReference67.out      |    7 +
 test/tools/javac/lambda/MethodReference68.java     |   23 +
 test/tools/javac/lambda/MethodReference68.out      |    2 +
 test/tools/javac/lambda/MethodReference69.java     |   21 +
 test/tools/javac/lambda/MethodReference69.out      |    2 +
 test/tools/javac/lambda/MethodReference70.java     |   28 +
 test/tools/javac/lambda/MethodReference70.out      |    3 +
 test/tools/javac/lambda/MethodReference71.java     |   26 +
 test/tools/javac/lambda/MethodReference71.out      |    3 +
 test/tools/javac/lambda/MethodReference72.java     |   20 +
 test/tools/javac/lambda/MethodReference72.out      |    2 +
 .../javac/lambda/MethodReferenceParserTest.java    |  265 ++
 test/tools/javac/lambda/MostSpecific01.java        |   25 +
 test/tools/javac/lambda/MostSpecific01.out         |    2 +
 test/tools/javac/lambda/MostSpecific02.java        |   25 +
 test/tools/javac/lambda/MostSpecific02.out         |    2 +
 test/tools/javac/lambda/MostSpecific03.java        |   63 +
 test/tools/javac/lambda/MostSpecific03.out         |   13 +
 test/tools/javac/lambda/MostSpecific04.java        |   58 +
 test/tools/javac/lambda/MostSpecific05.java        |   58 +
 test/tools/javac/lambda/MostSpecific06.java        |   30 +
 test/tools/javac/lambda/MostSpecific06.out         |    4 +
 test/tools/javac/lambda/MostSpecific07.java        |   31 +
 test/tools/javac/lambda/MostSpecific07.out         |    4 +
 test/tools/javac/lambda/MostSpecific08.java        |   62 +
 test/tools/javac/lambda/NakedThis.java             |   42 +
 test/tools/javac/lambda/NestedCapture01.java       |   43 +
 test/tools/javac/lambda/NestedCapture02.java       |   43 +
 test/tools/javac/lambda/NestedCapture03.java       |   36 +
 .../tools/javac/lambda/NoWarnOnImplicitParams.java |   26 +
 test/tools/javac/lambda/NoWarnOnImplicitParams.out |    4 +
 .../tools/javac/lambda/SerializedLambdaInInit.java |  118 +
 test/tools/javac/lambda/SourceLevelTest.java       |   23 +
 test/tools/javac/lambda/SourceLevelTest.out        |    6 +
 test/tools/javac/lambda/StaticMethodNegTest.java   |   26 +
 test/tools/javac/lambda/StaticMethodNegTest.out    |    2 +
 test/tools/javac/lambda/TargetType01.java          |   47 +
 test/tools/javac/lambda/TargetType02.java          |   62 +
 test/tools/javac/lambda/TargetType03.java          |   68 +
 test/tools/javac/lambda/TargetType04.java          |   18 +
 test/tools/javac/lambda/TargetType04.out           |    3 +
 test/tools/javac/lambda/TargetType05.java          |   53 +
 test/tools/javac/lambda/TargetType06.java          |   27 +
 test/tools/javac/lambda/TargetType07.java          |   45 +
 test/tools/javac/lambda/TargetType08.java          |   45 +
 test/tools/javac/lambda/TargetType10.java          |   19 +
 test/tools/javac/lambda/TargetType10.out           |    2 +
 test/tools/javac/lambda/TargetType11.java          |   22 +
 test/tools/javac/lambda/TargetType12.java          |   45 +
 test/tools/javac/lambda/TargetType13.java          |   21 +
 test/tools/javac/lambda/TargetType13.out           |    2 +
 test/tools/javac/lambda/TargetType14.java          |   25 +
 test/tools/javac/lambda/TargetType14.out           |    2 +
 test/tools/javac/lambda/TargetType15.java          |   52 +
 test/tools/javac/lambda/TargetType16.java          |   25 +
 test/tools/javac/lambda/TargetType16.out           |    2 +
 test/tools/javac/lambda/TargetType17.java          |   22 +
 test/tools/javac/lambda/TargetType17.out           |    9 +
 test/tools/javac/lambda/TargetType18.java          |   42 +
 test/tools/javac/lambda/TargetType19.java          |   43 +
 test/tools/javac/lambda/TargetType19.out           |    2 +
 test/tools/javac/lambda/TargetType20.java          |   44 +
 test/tools/javac/lambda/TargetType21.java          |   33 +
 test/tools/javac/lambda/TargetType21.out           |    5 +
 test/tools/javac/lambda/TargetType22.java          |   44 +
 test/tools/javac/lambda/TargetType22.out           |    4 +
 test/tools/javac/lambda/TargetType23.java          |   37 +
 test/tools/javac/lambda/TargetType23.out           |    2 +
 test/tools/javac/lambda/TargetType24.java          |   39 +
 test/tools/javac/lambda/TargetType24.out           |    5 +
 test/tools/javac/lambda/TargetType25.java          |   65 +
 test/tools/javac/lambda/TargetType26.java          |   17 +
 test/tools/javac/lambda/TargetType26.out           |    2 +
 test/tools/javac/lambda/TargetType27.java          |   20 +
 test/tools/javac/lambda/TargetType27.out           |    2 +
 test/tools/javac/lambda/TargetType28.java          |   23 +
 test/tools/javac/lambda/TargetType28.out           |    2 +
 test/tools/javac/lambda/TargetType29.java          |   44 +
 test/tools/javac/lambda/TargetType30.java          |   51 +
 test/tools/javac/lambda/TargetType31.java          |   51 +
 test/tools/javac/lambda/TargetType32.java          |   77 +
 test/tools/javac/lambda/TargetType33.java          |   25 +
 test/tools/javac/lambda/TargetType33.out           |    5 +
 test/tools/javac/lambda/TargetType34.java          |   41 +
 test/tools/javac/lambda/TargetType35.java          |   75 +
 test/tools/javac/lambda/TargetType36.java          |   42 +
 test/tools/javac/lambda/TargetType36.out           |    3 +
 test/tools/javac/lambda/TargetType37.java          |   38 +
 test/tools/javac/lambda/TargetType38.java          |   22 +
 test/tools/javac/lambda/TargetType38.out           |    3 +
 test/tools/javac/lambda/TargetType39.java          |   22 +
 test/tools/javac/lambda/TargetType39.out           |    3 +
 test/tools/javac/lambda/TargetType40.java          |   18 +
 test/tools/javac/lambda/TargetType40.out           |    2 +
 test/tools/javac/lambda/TargetType41.java          |   15 +
 test/tools/javac/lambda/TargetType41.out           |    2 +
 test/tools/javac/lambda/TargetType42.java          |   42 +
 test/tools/javac/lambda/TargetType43.java          |   16 +
 test/tools/javac/lambda/TargetType43.out           |    4 +
 test/tools/javac/lambda/TargetType44.java          |   27 +
 test/tools/javac/lambda/TargetType44.out           |    3 +
 test/tools/javac/lambda/TargetType45.java          |   29 +
 test/tools/javac/lambda/TargetType46.java          |   29 +
 test/tools/javac/lambda/TargetType46.out           |    3 +
 test/tools/javac/lambda/TargetType47.java          |   44 +
 test/tools/javac/lambda/TargetType48.java          |   48 +
 test/tools/javac/lambda/TargetType49.java          |   19 +
 test/tools/javac/lambda/TargetType49.out           |    3 +
 test/tools/javac/lambda/TargetType50.java          |   51 +
 test/tools/javac/lambda/TargetType51.java          |   68 +
 test/tools/javac/lambda/TargetType52.java          |   19 +
 test/tools/javac/lambda/TargetType52.out           |    2 +
 test/tools/javac/lambda/TargetType53.java          |   46 +
 test/tools/javac/lambda/TargetType54.java          |   44 +
 test/tools/javac/lambda/TargetType55.java          |   42 +
 test/tools/javac/lambda/TargetType56.java          |   40 +
 test/tools/javac/lambda/TargetType57.java          |   20 +
 test/tools/javac/lambda/TargetType57.out           |    2 +
 test/tools/javac/lambda/TargetType58.java          |   45 +
 test/tools/javac/lambda/TargetType59.java          |   48 +
 test/tools/javac/lambda/TargetType60.java          |   65 +
 test/tools/javac/lambda/TargetType60.out           |    8 +
 test/tools/javac/lambda/TargetType61.java          |   47 +
 test/tools/javac/lambda/TargetType62.java          |   45 +
 test/tools/javac/lambda/TargetType63.java          |   40 +
 test/tools/javac/lambda/TargetType63.out           |    9 +
 test/tools/javac/lambda/TargetType64.java          |   41 +
 test/tools/javac/lambda/TargetType65.java          |   58 +
 test/tools/javac/lambda/TargetType66.java          |   26 +
 test/tools/javac/lambda/TargetType66.out           |    4 +
 test/tools/javac/lambda/TargetType67.java          |   50 +
 test/tools/javac/lambda/TargetType68.java          |   63 +
 test/tools/javac/lambda/TargetType69.java          |   51 +
 test/tools/javac/lambda/TargetType70.java          |   52 +
 test/tools/javac/lambda/TargetType71.java          |   34 +
 test/tools/javac/lambda/TargetType72.java          |   39 +
 test/tools/javac/lambda/TargetType73.java          |   47 +
 test/tools/javac/lambda/TargetType74.java          |   39 +
 test/tools/javac/lambda/TargetType75.java          |   41 +
 test/tools/javac/lambda/TargetType76.java          |   65 +
 test/tools/javac/lambda/TestInvokeDynamic.java     |  494 +++
 .../javac/lambda/TestLambdaToMethodStats.java      |  192 +
 test/tools/javac/lambda/TestSelfRef.java           |  201 ++
 test/tools/javac/lambda/VoidCompatibility.java     |   26 +
 test/tools/javac/lambda/WarnUnderscoreAsIdent.java |   55 +
 test/tools/javac/lambda/WarnUnderscoreAsIdent.out  |   20 +
 test/tools/javac/lambda/abort/Abort.java           |  119 +
 .../javac/lambda/abort/CompletionFailure.java      |  137 +
 .../javac/lambda/badMemberRefBytecode/Main.java    |    9 +
 .../TestBadMemberRefBytecode.java                  |   32 +
 .../javac/lambda/badMemberRefBytecode/Use.java     |    3 +
 .../lambda/bridge/TestMetafactoryBridges.java      |  359 ++
 .../javac/lambda/bytecode/TestLambdaBytecode.java  |  365 ++
 test/tools/javac/lambda/funcInterfaces/Helper.java |  138 +
 .../javac/lambda/funcInterfaces/LambdaTest1.java   |  119 +
 .../lambda/funcInterfaces/LambdaTest1_neg1.java    |   15 +
 .../lambda/funcInterfaces/LambdaTest1_neg1.out     |    3 +
 .../lambda/funcInterfaces/LambdaTest1_neg2.java    |   17 +
 .../lambda/funcInterfaces/LambdaTest1_neg2.out     |    2 +
 .../lambda/funcInterfaces/LambdaTest1_neg3.java    |   19 +
 .../lambda/funcInterfaces/LambdaTest1_neg3.out     |    2 +
 .../lambda/funcInterfaces/LambdaTest2_SAM1.java    |   99 +
 .../lambda/funcInterfaces/LambdaTest2_SAM2.java    |  225 ++
 .../lambda/funcInterfaces/LambdaTest2_SAM3.java    |   86 +
 .../lambda/funcInterfaces/LambdaTest2_neg1.java    |   19 +
 .../lambda/funcInterfaces/LambdaTest2_neg1.out     |    2 +
 .../tools/javac/lambda/funcInterfaces/NonSAM1.java |   14 +
 test/tools/javac/lambda/funcInterfaces/NonSAM1.out |    2 +
 .../tools/javac/lambda/funcInterfaces/NonSAM2.java |   21 +
 test/tools/javac/lambda/funcInterfaces/NonSAM2.out |    5 +
 .../tools/javac/lambda/funcInterfaces/NonSAM3.java |   24 +
 test/tools/javac/lambda/funcInterfaces/NonSAM3.out |    9 +
 .../inaccessibleMref01/InaccessibleMref01.java     |   39 +
 .../inaccessibleMref01/InaccessibleMref01.out      |    2 +
 .../javac/lambda/inaccessibleMref01/p1/C.java      |   27 +
 .../inaccessibleMref02/InaccessibleMref02.java     |   40 +
 .../javac/lambda/inaccessibleMref02/p1/C.java      |   29 +
 .../intersection/IntersectionTargetTypeTest.java   |  337 ++
 .../javac/lambda/lambdaExecution/InInterface.java  |   65 +
 .../lambda/lambdaExecution/InnerConstructor.java   |   75 +
 .../lambdaExecution/LambdaTranslationTest1.java    |  234 ++
 .../lambdaExecution/LambdaTranslationTest2.java    |  355 ++
 .../tools/javac/lambda/lambdaExecution/TBlock.java |   36 +
 .../javac/lambda/lambdaExecution/TMapper.java      |   68 +
 .../javac/lambda/lambdaExecution/TPredicate.java   |   64 +
 .../lambda/lambdaExpression/AbstractClass_neg.java |   18 +
 .../lambda/lambdaExpression/AbstractClass_neg.out  |    2 +
 .../lambdaExpression/AccessNonStatic_neg.java      |   26 +
 .../lambdaExpression/AccessNonStatic_neg.out       |    5 +
 .../lambdaExpression/EffectivelyFinal_neg.java     |   25 +
 .../lambdaExpression/EffectivelyFinal_neg.out      |    5 +
 .../lambdaExpression/InvalidExpression1.java       |   17 +
 .../lambda/lambdaExpression/InvalidExpression1.out |    3 +
 .../lambdaExpression/InvalidExpression3.java       |   16 +
 .../lambda/lambdaExpression/InvalidExpression3.out |    2 +
 .../lambdaExpression/InvalidExpression4.java       |   18 +
 .../lambda/lambdaExpression/InvalidExpression4.out |    2 +
 .../lambdaExpression/InvalidExpression5.java       |   14 +
 .../lambda/lambdaExpression/InvalidExpression5.out |    2 +
 .../lambdaExpression/InvalidExpression6.java       |   19 +
 .../lambda/lambdaExpression/InvalidExpression6.out |    3 +
 .../javac/lambda/lambdaExpression/LambdaTest1.java |  119 +
 .../javac/lambda/lambdaExpression/LambdaTest2.java |  118 +
 .../javac/lambda/lambdaExpression/LambdaTest3.java |   56 +
 .../javac/lambda/lambdaExpression/LambdaTest4.java |   72 +
 .../javac/lambda/lambdaExpression/LambdaTest5.java |   79 +
 .../javac/lambda/lambdaExpression/LambdaTest6.java |  118 +
 .../lambda/lambdaExpression/SamConversion.java     |  151 +
 .../lambdaExpression/SamConversionComboTest.java   |  276 ++
 .../javac/lambda/methodReference/BridgeMethod.java |  117 +
 .../javac/lambda/methodReference/MethodRef1.java   |   79 +
 .../javac/lambda/methodReference/MethodRef2.java   |   69 +
 .../javac/lambda/methodReference/MethodRef3.java   |   60 +
 .../javac/lambda/methodReference/MethodRef4.java   |   79 +
 .../javac/lambda/methodReference/MethodRef5.java   |   96 +
 .../javac/lambda/methodReference/MethodRef6.java   |   66 +
 .../javac/lambda/methodReference/MethodRef7.java   |  105 +
 .../lambda/methodReference/MethodRef_neg.java      |   36 +
 .../javac/lambda/methodReference/MethodRef_neg.out |    5 +
 .../lambda/methodReference/SamConversion.java      |  320 ++
 .../methodReference/SamConversionComboTest.java    |  262 ++
 .../methodReference/TreeMakerParamsIsGoofy.java    |   53 +
 .../MethodReferenceTestFDCCE.java                  |  154 +
 .../MethodReferenceTestInnerDefault.java           |   88 +
 .../MethodReferenceTestInnerInstance.java          |   95 +
 .../MethodReferenceTestInnerVarArgsThis.java       |  250 ++
 .../MethodReferenceTestInstance.java               |   70 +
 .../MethodReferenceTestKinds.java                  |  170 +
 .../MethodReferenceTestNew.java                    |  138 +
 .../MethodReferenceTestNewInner.java               |  157 +
 .../MethodReferenceTestNewInnerImplicitArgs.java   |   82 +
 .../MethodReferenceTestSueCase1.java               |   54 +
 .../MethodReferenceTestSueCase2.java               |   54 +
 .../MethodReferenceTestSueCase4.java               |   59 +
 .../MethodReferenceTestSuper.java                  |  120 +
 .../MethodReferenceTestSuperDefault.java           |   82 +
 .../MethodReferenceTestTypeConversion.java         |   62 +
 .../MethodReferenceTestVarArgs.java                |  204 ++
 .../MethodReferenceTestVarArgsExt.java             |  191 +
 .../MethodReferenceTestVarArgsSuper.java           |  207 ++
 .../MethodReferenceTestVarArgsSuperDefault.java    |  189 +
 .../MethodReferenceTestVarArgsThis.java            |  186 +
 .../mostSpecific/StructuralMostSpecificTest.java   |  312 ++
 test/tools/javac/lambda/separate/Foo.java          |   30 +
 test/tools/javac/lambda/separate/Test.java         |   34 +
 test/tools/javac/lambda/speculative/A.java         |   26 +
 .../javac/lambda/speculative/DiamondFinder.java    |   35 +
 test/tools/javac/lambda/speculative/Main.java      |   15 +
 test/tools/javac/lambda/speculative/Main.out       |    2 +
 .../javac/lambda/speculative/MissingError.java     |   17 +
 .../javac/lambda/speculative/MissingError.out      |    3 +
 .../lambda/typeInference/InferenceTest11.java      |   67 +
 .../javac/lambda/typeInference/InferenceTest2.java |  115 +
 .../lambda/typeInference/InferenceTest2b.java      |   76 +
 .../javac/lambda/typeInference/InferenceTest3.java |   79 +
 .../javac/lambda/typeInference/InferenceTest4.java |   73 +
 .../javac/lambda/typeInference/InferenceTest5.java |  122 +
 .../lambda/typeInference/InferenceTest789.java     |   67 +
 .../lambda/typeInference/InferenceTest_neg1_2.java |   58 +
 .../lambda/typeInference/InferenceTest_neg1_2.out  |    4 +
 .../lambda/typeInference/InferenceTest_neg5.java   |   26 +
 .../lambda/typeInference/InferenceTest_neg5.out    |    2 +
 .../combo/TypeInferenceComboTest.java              |  397 +++
 test/tools/javac/lambdaShapes/TEST.properties      |    2 +
 .../org/openjdk/tests/javac/FDTest.java            |  193 +
 .../openjdk/tests/separate/AttributeInjector.java  |   73 +
 .../org/openjdk/tests/separate/ClassFile.java      |  454 +++
 .../tests/separate/ClassFilePreprocessor.java      |   30 +
 .../tests/separate/ClassToInterfaceConverter.java  |   94 +
 .../org/openjdk/tests/separate/Compiler.java       |  232 ++
 .../tests/separate/DirectedClassLoader.java        |  101 +
 .../org/openjdk/tests/separate/SourceModel.java    |  582 +++
 .../org/openjdk/tests/separate/TestHarness.java    |  354 ++
 .../org/openjdk/tests/shapegen/ClassCase.java      |  312 ++
 .../org/openjdk/tests/shapegen/Hierarchy.java      |  209 ++
 .../openjdk/tests/shapegen/HierarchyGenerator.java |  192 +
 .../org/openjdk/tests/shapegen/Rule.java           |   48 +
 .../org/openjdk/tests/shapegen/RuleGroup.java      |  206 ++
 .../org/openjdk/tests/shapegen/TTNode.java         |  126 +
 .../org/openjdk/tests/shapegen/TTParser.java       |  100 +
 .../org/openjdk/tests/shapegen/TTShape.java        |  104 +
 .../org/openjdk/tests/vm/DefaultMethodsTest.java   |  820 +++++
 .../tests/vm/FDSeparateCompilationTest.java        |  200 ++
 test/tools/javac/lib/CompileFail.java              |   30 +-
 test/tools/javac/lib/DPrinter.java                 | 1333 +++++++
 .../javac/lib/JavacTestingAbstractProcessor.java   |  161 +
 .../lib/JavacTestingAbstractThreadedTest.java      |  154 +
 test/tools/javac/lib/ToolBox.java                  |  977 +++++
 .../javac/limits/NestedClassConstructorArgs.java   |   45 +
 test/tools/javac/limits/NestedClassMethodArgs.java |   45 +
 test/tools/javac/limits/NumArgs1.java              |  552 ---
 test/tools/javac/limits/NumArgs2.java              |  550 ---
 test/tools/javac/limits/NumArgs3.java              |  292 --
 test/tools/javac/limits/NumArgs4.java              |  291 --
 test/tools/javac/limits/NumArgsTest.java           |  269 ++
 .../limits/StaticNestedClassConstructorArgs.java   |   45 +
 .../javac/limits/TopLevelClassConstructorArgs.java |   40 +
 .../javac/limits/TopLevelClassMethodArgs.java      |   40 +
 .../limits/TopLevelClassStaticMethodArgs.java      |   40 +
 test/tools/javac/links/LinksTest.java              |   66 +
 test/tools/javac/links/T.java                      |   24 -
 test/tools/javac/links/b/B.java                    |   26 -
 test/tools/javac/links/links.sh                    |   74 -
 test/tools/javac/literals/UnderscoreLiterals.java  |   42 +-
 test/tools/javac/main/Option_J_At_Test.java        |   70 +
 .../javac/mandatoryWarnings/deprecated/Test.java   |   92 +-
 .../javac/mandatoryWarnings/unchecked/Test.java    |   80 +-
 test/tools/javac/meth/VarargsWarn.java             |   17 +
 test/tools/javac/meth/VarargsWarn.out              |    4 +
 .../7030606/DisjunctiveTypeWellFormednessTest.java |   50 +-
 test/tools/javac/multicatch/Neg06.out              |    4 +-
 test/tools/javac/multicatch/Neg07.out              |    2 +-
 test/tools/javac/multicatch/Pos11.java             |  132 +
 test/tools/javac/multicatch/Pos12.java             |   76 +
 .../tools/javac/multicatch/model/ModelChecker.java |    6 +-
 .../javac/nativeHeaders/NativeHeaderTest.java      |  274 ++
 .../nativeHeaders/javahComparison/CompareTest.java |  169 +
 .../nativeHeaders/javahComparison/TestClass1.java  |  475 +++
 .../nativeHeaders/javahComparison/TestClass4.java  |   50 +
 .../nativeHeaders/javahComparison/TestClass5.java  |   60 +
 test/tools/javac/newlines/NewLineTest.java         |   61 +
 test/tools/javac/newlines/Newlines.sh              |   76 -
 test/tools/javac/options/T6949443.java             |   36 +
 test/tools/javac/options/T7022337.java             |    2 +-
 test/tools/javac/parser/7157165/T7157165.java      |   12 +
 test/tools/javac/parser/7157165/T7157165.out       |    4 +
 test/tools/javac/parser/8014643/T8014643.java      |   41 +
 test/tools/javac/parser/JavacParserTest.java       |  978 +++++
 .../javac/parser/SingleCommaAnnotationValue.java   |   39 +
 .../parser/SingleCommaAnnotationValueFail.java     |   36 +
 .../parser/SingleCommaAnnotationValueFail.out      |    6 +
 test/tools/javac/parser/T4881269.java              |   35 +
 test/tools/javac/parser/T4881269.out               |    9 +
 .../javac/parser/netbeans/JavacParserTest.java     |  716 ----
 test/tools/javac/plugin/showtype/Identifiers.java  |    7 +
 test/tools/javac/plugin/showtype/Identifiers.out   |   21 +
 .../tools/javac/plugin/showtype/Identifiers_PI.out |    6 +
 .../javac/plugin/showtype/ShowTypePlugin.java      |  106 +
 test/tools/javac/plugin/showtype/Test.java         |  170 +
 test/tools/javac/policy/test3/Test.java            |   46 +-
 test/tools/javac/positions/T6264029.out            |    3 +-
 test/tools/javac/processing/6348499/T6348499.java  |    7 +-
 test/tools/javac/processing/6359313/T6359313.java  |    2 +-
 test/tools/javac/processing/6365040/T6365040.java  |    2 +-
 test/tools/javac/processing/6413690/T6413690.java  |    2 +-
 test/tools/javac/processing/6414633/T6414633.java  |   19 +-
 test/tools/javac/processing/6430209/T6430209.java  |    2 +-
 .../javac/processing/6499119/ClassProcessor.java   |    2 +-
 test/tools/javac/processing/6511613/clss41701.java |    2 +-
 test/tools/javac/processing/6512707/T6512707.java  |    2 +-
 test/tools/javac/processing/6634138/T6634138.java  |    2 +-
 .../processing/6994946/SemanticErrorTest.2.out     |    3 +-
 .../processing/6994946/SemanticErrorTest.java      |    2 +-
 .../javac/processing/6994946/SyntaxErrorTest.java  |    2 +-
 test/tools/javac/processing/T6920317.java          |    8 +-
 test/tools/javac/processing/T7196462.java          |   44 +
 .../tools/javac/processing/TestWarnErrorCount.java |    6 +-
 .../processing/environment/TestSourceVersion.java  |    2 +-
 .../processing/environment/round/TestContext.java  |    2 +-
 .../round/TestElementsAnnotatedWith.java           |    4 +-
 .../javac/processing/environment/round/TpAnno.java |   29 +
 .../round/TypeParameterAnnotations.java            |   37 +
 .../javac/processing/errors/TestErrorCount.java    |    2 +-
 .../errors/TestFatalityOfParseErrors.java          |    2 +-
 .../processing/errors/TestOptionSyntaxErrors.java  |    2 +-
 .../errors/TestParseErrors/TestParseErrors.java    |    2 +-
 .../javac/processing/errors/TestReturnCode.java    |    2 +-
 .../processing/filer/TestFilerConstraints.java     |    2 +-
 .../javac/processing/filer/TestGetResource.java    |    2 +-
 .../javac/processing/filer/TestGetResource2.java   |    2 +-
 .../processing/filer/TestInvalidRelativeNames.java |    2 +-
 .../javac/processing/filer/TestLastRound.java      |    2 +-
 .../javac/processing/filer/TestPackageInfo.java    |    2 +-
 .../processing/filer/TestValidRelativeNames.java   |    2 +-
 .../processing/loader/testClose/TestClose.java     |  229 ++
 .../processing/loader/testClose/TestClose2.java    |  141 +
 .../processing/messager/6362067/T6362067.java      |    2 +-
 .../javac/processing/messager/MessagerBasics.java  |    2 +-
 .../javac/processing/messager/MessagerDiags.java   |  131 +
 .../javac/processing/model/6194785/T6194785.java   |   11 +-
 .../javac/processing/model/6341534/T6341534.java   |    2 +-
 .../javac/processing/model/TestSourceVersion.java  |   45 +
 .../javac/processing/model/TestSymtabItems.java    |    8 +-
 .../model/element/TestAnonClassNames.java          |   14 +-
 .../processing/model/element/TestElement.java      |    2 +-
 .../model/element/TestExecutableElement.java       |  145 +
 .../TestMissingElement/TestMissingElement.java     |   12 +-
 .../TestMissingElement/TestMissingElement.ref      |   49 +
 .../TestMissingElement2/TestMissingClass.java      |    2 +-
 .../TestMissingGenericClass1.java                  |    2 +-
 .../TestMissingGenericClass2.java                  |    2 +-
 .../TestMissingGenericInterface1.java              |    2 +-
 .../TestMissingGenericInterface2.java              |    2 +-
 .../TestMissingElement2/TestMissingInterface.java  |    2 +-
 .../javac/processing/model/element/TestNames.java  |    2 +-
 .../model/element/TestPackageElement.java          |    2 +-
 .../model/element/TestResourceElement.java         |    2 +-
 .../model/element/TestResourceVariable.java        |   15 +-
 .../model/element/TestTypeParameter.java           |    2 +-
 .../element/TestTypeParameterAnnotations.java      |  190 +
 .../processing/model/element/TypeParamBounds.java  |    2 +-
 .../repeatingAnnotations/ElementRepAnnoTester.java |  555 +++
 ...MixRepeatableAndOfficialContainerBasicTest.java |  119 +
 ...eatableAndOfficialContainerInheritedA1Test.java |   65 +
 ...eatableAndOfficialContainerInheritedA2Test.java |   67 +
 ...eatableAndOfficialContainerInheritedB1Test.java |   62 +
 ...eatableAndOfficialContainerInheritedB2Test.java |   63 +
 ...MixSingularAndUnofficialContainerBasicTest.java |  112 +
 ...gularAndUnofficialContainerInheritedA1Test.java |   61 +
 ...gularAndUnofficialContainerInheritedA2Test.java |   63 +
 ...gularAndUnofficialContainerInheritedB1Test.java |   61 +
 ...gularAndUnofficialContainerInheritedB2Test.java |   62 +
 .../OfficialContainerBasicTest.java                |  106 +
 .../OfficialContainerInheritedTest.java            |   60 +
 .../repeatingAnnotations/RepeatableBasicTest.java  |  109 +
 .../RepeatableInheritedTest.java                   |   61 +
 .../RepeatableOfficialContainerBasicTest.java      |  106 +
 .../RepeatableOfficialContainerInheritedTest.java  |   66 +
 .../RepeatableOverrideATest.java                   |   62 +
 .../RepeatableOverrideBTest.java                   |   65 +
 .../repeatingAnnotations/SingularBasicTest.java    |   89 +
 .../SingularInheritedATest.java                    |   52 +
 .../SingularInheritedBTest.java                    |   57 +
 .../UnofficialContainerBasicTest.java              |   97 +
 .../UnofficialContainerInheritedTest.java          |   58 +
 .../supportingAnnotations/Bar.java                 |   32 +
 .../supportingAnnotations/BarContainer.java        |   32 +
 .../BarContainerContainer.java                     |   32 +
 .../supportingAnnotations/BarInherited.java        |   33 +
 .../BarInheritedContainer.java                     |   33 +
 .../BarInheritedContainerContainer.java            |   32 +
 .../supportingAnnotations/ExpectedBase.java        |   36 +
 .../supportingAnnotations/ExpectedContainer.java   |   34 +
 .../supportingAnnotations/Foo.java                 |   30 +
 .../supportingAnnotations/FooInherited.java        |   32 +
 .../supportingAnnotations/UnofficialContainer.java |   30 +
 .../UnofficialInheritedContainer.java              |   32 +
 .../processing/model/type/BasicAnnoTests.java      |  287 ++
 .../model/type/MirroredTypeEx/OverEager.java       |    2 +-
 .../model/type/MirroredTypeEx/Plurality.java       |    2 +-
 .../tools/javac/processing/model/type/NoTypes.java |   16 +-
 .../javac/processing/model/type/TestUnionType.java |    7 +-
 .../javac/processing/model/util/BinaryName.java    |    2 +-
 .../processing/model/util/GetTypeElemBadArg.java   |    2 +-
 .../javac/processing/model/util/NoSupers.java      |    2 +-
 .../processing/model/util/OverridesSpecEx.java     |    2 +-
 .../javac/processing/model/util/TypesBadArg.java   |    2 +-
 .../model/util/deprecation/TestDeprecation.java    |    6 +-
 .../util/directSupersOfErr/DirectSupersOfErr.java  |    6 +-
 .../util/directSupersOfErr/DirectSupersOfErr.ref   |    2 +
 .../util/elements/TestGetConstantExpression.java   |    2 +-
 .../model/util/elements/TestGetPackageOf.java      |    2 +-
 .../util/elements/TestIsFunctionalInterface.java   |  115 +
 .../model/util/filter/TestIterables.java           |    2 +-
 .../options/testCommandLineClasses/Test.java       |    2 +-
 .../options/testPrintProcessorInfo/Test.java       |    2 +-
 .../testPrintProcessorInfo/TestWithXstdout.java    |   92 +
 .../warnings/TestSourceVersionWarnings.java        |   10 +-
 .../UseImplicit/TestProcUseImplicitWarning.java    |    2 +-
 test/tools/javac/processing/werror/WError1.java    |    2 +-
 test/tools/javac/processing/werror/WErrorGen.java  |    2 +-
 test/tools/javac/processing/werror/WErrorLast.java |    2 +-
 test/tools/javac/profiles/ProfileOptionTest.java   |  267 ++
 test/tools/javac/quid/T6999438.java                |    2 +-
 test/tools/javac/quid/T6999438.out                 |    2 +-
 test/tools/javac/resolve/Candidate.java            |   68 +
 test/tools/javac/resolve/Pos.java                  |   31 +
 test/tools/javac/resolve/ResolveHarness.java       |  505 +++
 test/tools/javac/resolve/TraceResolve.java         |   29 +
 test/tools/javac/resolve/tests/AbstractMerge.java  |  107 +
 .../javac/resolve/tests/AmbiguityPrecedence.java   |   45 +
 .../resolve/tests/BoxedReturnTypeInference.java    |   60 +
 test/tools/javac/resolve/tests/InnerOverOuter.java |   39 +
 .../resolve/tests/PrimitiveBinopOverload.java      |   71 +
 .../tests/PrimitiveOverReferenceOverInferred.java  |   92 +
 .../tests/PrimitiveOverReferenceOverVarargs.java   |  108 +
 .../PrimitiveOverReferenceVarargsAmbiguous.java    |   76 +
 .../javac/resolve/tests/PrimitiveOverload.java     |  113 +
 .../tests/PrimitiveReturnTypeInference.java        |   60 +
 .../javac/resolve/tests/ReferenceOverInferred.java |   76 +
 .../javac/resolve/tests/ReferenceOverVarargs.java  |   93 +
 .../javac/resolve/tests/ReferenceOverload.java     |   95 +
 .../javac/scope/7017664/CompoundScopeTest.java     |    4 +-
 .../7046348/EagerInterfaceCompletionTest.java      |   45 +-
 test/tools/javac/stackmap/StackMapTest.java        |   65 +
 test/tools/javac/stackmap/T4955930.java            |   47 -
 test/tools/javac/stackmap/T4955930.sh              |   76 -
 test/tools/javac/tree/AbstractTreeScannerTest.java |    4 +-
 test/tools/javac/tree/DocCommentToplevelTest.java  |  197 +
 test/tools/javac/tree/MakeLiteralTest.java         |   11 +-
 test/tools/javac/tree/PrettySimpleStringTest.java  |   73 +
 test/tools/javac/tree/SourceTreeScannerTest.java   |    2 +-
 test/tools/javac/tree/TestToString.java            |  159 +
 test/tools/javac/tree/TreeKindTest.java            |    9 +-
 test/tools/javac/tree/TreePosTest.java             |   96 +-
 test/tools/javac/treeannotests/AnnoTreeTests.java  |   44 +
 test/tools/javac/treeannotests/TestProcessor.java  |    9 +-
 .../typeAnnotations/newlocations/BasicTest.java    |   77 -
 .../typeAnnotations/newlocations/BasicTest.out     |   66 -
 .../javac/types/CastObjectToPrimitiveTest.out      |    2 +-
 test/tools/javac/types/TestComparisons.java        |  362 ++
 test/tools/javac/types/TypeHarness.java            |    4 +-
 test/tools/javac/unicode/SupplementaryJavaID6.java |   14 +-
 test/tools/javac/unicode/SupplementaryJavaID6.sh   |  114 -
 test/tools/javac/util/T6597678.java                |   35 +-
 test/tools/javac/util/context/T7021650.java        |    8 +-
 test/tools/javac/varargs/6313164/T6313164.out      |    6 +-
 test/tools/javac/varargs/6313164/T7175433.java     |   59 +
 test/tools/javac/varargs/7042566/T7042566.java     |  105 +-
 test/tools/javac/varargs/7097436/T7097436.out      |    4 +-
 test/tools/javac/varargs/warning/Warn4.java        |  109 +-
 test/tools/javac/varargs/warning/Warn5.java        |   89 +-
 test/tools/javac/versions/check.sh                 |   59 +-
 test/tools/javac/warnings/6594914/Auxiliary.java   |    5 +
 .../javac/warnings/6594914/ExplicitCompilation.out |    2 +
 .../warnings/6594914/ImplicitCompilation.java      |   13 +
 .../javac/warnings/6594914/ImplicitCompilation.out |    2 +
 test/tools/javac/warnings/7090499/T7090499.java    |   37 +
 test/tools/javac/warnings/7090499/T7090499.out     |   17 +
 .../AuxiliaryClass/ClassUsingAnotherAuxiliary.java |   35 +
 .../AuxiliaryClass/ClassUsingAnotherAuxiliary.out  |    4 +
 .../AuxiliaryClass/ClassUsingAuxiliary.java        |   35 +
 .../AuxiliaryClass/ClassUsingAuxiliary1.out        |    4 +
 .../AuxiliaryClass/ClassUsingAuxiliary2.out        |    4 +
 .../AuxiliaryClass/ClassWithAuxiliary.java         |   31 +
 .../warnings/AuxiliaryClass/NotAClassName.java     |   25 +
 .../warnings/AuxiliaryClass/SelfClassWithAux.java  |   45 +
 test/tools/javadoc/6958836/Test.java               |    5 +-
 test/tools/javadoc/6964914/Test.java               |    3 +-
 test/tools/javadoc/6964914/TestStdDoclet.java      |    3 +-
 test/tools/javadoc/CheckResourceKeys.java          |  247 ++
 test/tools/javadoc/MaxWarns.java                   |  112 +
 test/tools/javadoc/T4696488.java                   |   56 +
 test/tools/javadoc/T6551367.java                   |    4 +-
 test/tools/javadoc/api/basic/APITest.java          |  212 ++
 test/tools/javadoc/api/basic/DocletPathTest.java   |  110 +
 .../javadoc/api/basic/GetSourceVersionsTest.java   |   61 +
 .../api/basic/GetTask_DiagListenerTest.java        |   88 +
 .../javadoc/api/basic/GetTask_DocletClassTest.java |  157 +
 .../javadoc/api/basic/GetTask_FileManagerTest.java |  111 +
 .../javadoc/api/basic/GetTask_FileObjectsTest.java |  130 +
 .../javadoc/api/basic/GetTask_OptionsTest.java     |   94 +
 .../javadoc/api/basic/GetTask_WriterTest.java      |   79 +
 .../javadoc/api/basic/IsSupportedOptionTest.java   |   67 +
 .../javadoc/api/basic/JavadocTaskImplTest.java     |  108 +
 test/tools/javadoc/api/basic/RunTest.java          |  148 +
 test/tools/javadoc/api/basic/TagletPathTest.java   |  106 +
 test/tools/javadoc/api/basic/Task_reuseTest.java   |   93 +
 test/tools/javadoc/api/basic/pkg/C.java            |   27 +
 .../javadoc/api/basic/taglets/UnderlineTaglet.java |  152 +
 test/tools/javadoc/doclint/DocLintTest.java        |  255 ++
 .../tools/javadoc/doclint/ImplicitHeadersTest.java |   45 +
 test/tools/javah/6257087/T6257087.java             |   76 +
 test/tools/javah/6257087/foo.java                  |   29 -
 test/tools/javah/6257087/foo.sh                    |   74 -
 test/tools/javah/6257087/foo_bar.h                 |   21 -
 test/tools/javah/ConstMacroTest.sh                 |  102 -
 test/tools/javah/MissingParamClassException.java   |   35 -
 test/tools/javah/MissingParamClassTest.sh          |  124 -
 test/tools/javah/ParamClassTest.java               |   41 -
 test/tools/javah/SubClassConsts.java               |   40 -
 test/tools/javah/SubClassConsts.out                |   31 -
 test/tools/javah/SubClassConsts.win                |   31 -
 test/tools/javah/SuperClassConsts.java             |   66 -
 .../javah/T4942232/MissingParamClassTest.java      |   89 +
 .../tools/javah/constMacroTest/ConstMacroTest.java |  117 +
 .../JavapShouldLoadClassesFromRTJarTest.java       |   43 +
 test/tools/javap/4866831/PublicInterfaceTest.java  |   52 +
 .../javap/8006334/JavapTaskCtorFailWithNPE.java    |   84 +
 .../JavapReturns0AfterClassNotFoundTest.java       |   75 +
 test/tools/javap/DescriptorTest.java               |   91 +
 test/tools/javap/MethodParameters.java             |  174 +
 test/tools/javap/NotPackagePrivateInterface.java   |   34 -
 test/tools/javap/PublicInterfaceTest.sh            |   62 -
 test/tools/javap/T4777949.java                     |    6 +-
 test/tools/javap/T7186925.java                     |   78 +
 test/tools/javap/T7190862.java                     |  156 +
 .../javap/output/RepeatingTypeAnnotations.java     |  427 +++
 test/tools/javap/output/Tester.java                |  389 ++
 test/tools/javap/pathsep.sh                        |   63 -
 test/tools/javap/stackmap/StackmapTest.java        |   98 +
 test/tools/javap/stackmap/T6271292.java            |   49 -
 test/tools/javap/stackmap/T6271292.out             |   14 -
 test/tools/javap/stackmap/T6271292.sh              |   88 -
 .../javap/typeAnnotations/JSR175Annotations.java   |  152 +
 test/tools/javap/typeAnnotations/NewArray.java     |  140 +
 test/tools/javap/typeAnnotations/Presence.java     |  218 ++
 .../tools/javap/typeAnnotations/PresenceInner.java |  187 +
 test/tools/javap/typeAnnotations/T6855990.java     |   51 +
 test/tools/javap/typeAnnotations/TypeCasts.java    |  155 +
 test/tools/javap/typeAnnotations/Visibility.java   |  145 +
 test/tools/javap/typeAnnotations/Wildcards.java    |  177 +
 test/tools/jdeps/Basic.java                        |  213 ++
 test/tools/jdeps/Test.java                         |   28 +
 test/tools/jdeps/p/Foo.java                        |   37 +
 test/tools/jdeps/profiles.properties               |  263 ++
 test/tools/sjavac/SJavac.java                      |  573 +++
 test/tools/sjavac/SJavacWrapper.java               |   67 +
 2875 files changed, 180789 insertions(+), 56173 deletions(-)

diff --git a/.hg_archival.txt b/.hg_archival.txt
index 3292698..0f1ec56 100644
--- a/.hg_archival.txt
+++ b/.hg_archival.txt
@@ -1,5 +1,5 @@
 repo: 9a66ca7c79fab293c1bb0534e0d208c7e4f58b01
-node: 38fd251c6715c7ef58fe42a7d0e2214facc41ca6
+node: bf149ece9888c021529b10395ce16b772521f817
 branch: default
-tag: release73_base
-tag: release73_fcs
+tag: release74_base
+tag: release74_fcs
diff --git a/.hgignore b/.hgignore
index 5242b91..ff56119 100644
--- a/.hgignore
+++ b/.hgignore
@@ -7,3 +7,4 @@
 ^make/netbeans/nb-javac/ext/
 /nbproject/private/
 ^.hgtip
+.DS_Store
diff --git a/.hgtags b/.hgtags
index 061f68b..a231006 100644
--- a/.hgtags
+++ b/.hgtags
@@ -10,7 +10,9 @@ a5ca9c2dcc78db1644157c8afdea37653379e3de release70_base
 923f5fa30e1353e04696d6a350cba7dd9e9d451f release701_base
 939d2012e9a5bb8835cb77516e996cb26681c0de release71_base
 8c7740fb544f72c79c6bd6dc3b7bd58d824de321 release72_base
-abab66e88efd0eb4a5e8c94949656de37310288d last_langtools
+38fd251c6715c7ef58fe42a7d0e2214facc41ca6 release73_base
+38fd251c6715c7ef58fe42a7d0e2214facc41ca6 release73_fcs
+09f65aad475903e2f418ca25c68ad4cc244f7e88 last_langtools
 9a66ca7c79fab293c1bb0534e0d208c7e4f58b01 jdk7-b24
 58039502942e52f4144a33f36290a2bd2f3581e6 jdk7-b25
 c46d25a2350ac147d0121d9c9725af6fcb1b4dbe jdk7-b26
@@ -134,92 +136,105 @@ a15c9b058ae007d4ccb7e35ce44e4dfa977f090b jdk7-b137
 8eb952f43b117d538f6ca5e9e43ff9ce7646c7ee jdk7-b144
 c455e2ae5c93014ae3fc475aba4509b5f70465f7 jdk7-b145
 9425dd4f53d5bfcd992d9aecea0eb7d8b2d4f62b jdk7-b146
-d34578643d1c6c752d4a6b5e79c6ab1b60850b4a jdk7u1-b01
 58bc532d63418ac3c9b42460d89cdaf595c6f3e1 jdk7-b147
-cd2cc8b5edb045b950aed46d159b4fb8fc2fd1df jdk7u1-b02
-82820a30201dbf4b80f1916f3d0f4a92ad21b61a jdk7u1-b03
-baa2c13c70fea3d6e259a34f0903197fdceb64b5 jdk7u1-b04
-7e0f2dcbf41ecbf61475e13ea32436e80f39b513 jdk7u1-b05
-ce654f4ecfd8fd5f81618c7e0949f22db08de4d5 jdk7u2-b01
-d5d8654d8180dc31a746253e11ac2747292154b4 jdk7u2-b04
-1f1c1763ac31e5e1264b0784f48e75cc109e60f4 jdk7u2-b05
-4c5514d422c43e23af2437001ae0595d62b6cb19 jdk7u2-b06
-0959cd580bf5748a3dfc5c431483d2abef7dd875 jdk7u2-b07
-16e34b70cea7fd68ac0aef5f2f56ea6245e4582f jdk7u2-b08
-c91ffd7f2c3fa619d4d2228f16f85a4f5aa13914 jdk7u2-b09
-5935f69f4e558d2bc88c20c55f3de54a457fd26b jdk7u1-b06
-ef15185867cf89e606239f216ff34154ce50563b jdk7u1-b07
-ee94565d9f57ee9885e3af44891877163b637cc3 jdk7u1-b08
-d37897312d318c18b0a855ce80f70c410865d105 jdk7u2-b11
-f0802d8a0909f66ce19d3d44b33ddf4943aee076 jdk7u2-b12
-f474527e77e4797d78bd6c3b31923fddcfd9d5c6 jdk7u2-b13
-fc0769df8cd03fffc38c7a1ab6b2e2e7cc2506a8 jdk7u2-b21
-fc0769df8cd03fffc38c7a1ab6b2e2e7cc2506a8 jdk7u3-b02
-0ffc4995457773085f61c39f6d33edc242b41bcf jdk7u3-b03
-f6de36b195cd315646213c7affd2cc15702edbfb jdk7u3-b04
-8851e7f3721f8f756cc9f5731600a152506542db jdk7u4-b200
-358c42289352a2288084039e7c9d3f134c9c29e9 jdk7u4-b04
-8556ecc20a5b32ae7f336ecf3c420d7feb88d323 jdk7u4-b02
-62ee502a464924d68d398899570c1ad27fbe6cc4 jdk7u4-b05
-083eac71addfccb75f2794b8b5ab5a74c10e005d jdk7u4-b06
-c864786394dc3d78c1d155d8cd62faf3385a7bc0 jdk7u4-b225
-10a63f9cdcb9bbbcc1a5780c19a23087e216db40 jdk7u4-b07
-4be7205dae8923fc7906925a2ba30df55de6770c jdk7u4-b08
-1bee7edbb4b455dd6c2a4ef9d08d28dd63fde59b jdk7u4-b227
-cbd359dd543961530565a0b261be418ded02e664 jdk7u4-b09
-8919b2b02fcba65f833c68374f3bfdd9bc3ba814 jdk7u4-b10
-4672e092f0968d503dc37f860b15ae7e2653f8d7 jdk7u4-b11
-a4bf6a1aff54a98e9ff2b3fb53c719f658bec677 jdk7u4-b12
-56eb9150d9ffdb71c47d72871e8ecc98b5f402de jdk7u4-b13
-0e55881c2ee2984048c179d1e031cefb56a36bec jdk7u4-b14
-0bea057f7ce1577e1b0306f2027c057e35394398 jdk7u5-b01
-0bea057f7ce1577e1b0306f2027c057e35394398 jdk7u4-b15
-b05d9de909321f3cd97f066b3614f3117b7c15c4 jdk7u4-b16
-80552e34be80bdd77a0c9dd96d5a87e70542de00 jdk7u4-b17
-c65b573ccae35395053390952b4593e97c6f1c89 jdk7u4-b18
-12cdf04507b4930a6ab36b39dbd972772fc8bd31 jdk7u4-b19
-83b2485f2acb254c5173979452c31bfe7b8f3b94 jdk7u4-b20
-b11f11a79fe7264162dd2733985b6c9645ff0867 jdk7u5-b02
-463face16af6cde12dde0be11b22db63d3eb210e jdk7u4-b30
-a7e6a43c5e3732f539ed0e92701c9011b678c6f1 jdk7u4-b21
-79cee842266bd986a10107988d24d7b4ff5eec25 jdk7u4-b22
-862c6e4b265217ad0d877b409a4bba4348b63c30 jdk7u4-b31
-6cf7f5783c961cf72b1621bf165f5cb39a9397f0 jdk7u5-b04
-0c76aeb6f6fe448d6a149eadd6354a6366dac636 jdk7u5-b05
-14a321b5bf14bd259cc7fd5a0259a5098defe2f1 jdk7u5-b30
-0e55881c2ee2984048c179d1e031cefb56a36bec jdk7u6-b01
-5765d01e226369e44a6afc4431f83a633983bc04 jdk7u6-b02
-039b1ce6c63fa6837233980a13a7bffcf039b360 jdk7u6-b03
-ef568ee2f96f2f91b3ac4b1d1a5291aaa3cfb2e7 jdk7u6-b04
-bbf655c7f3594eda674a1662739a0ac9c78d0047 jdk7u6-b05
-74278b8cdeea86bb6082ea8c19c01b2008cf39a9 jdk7u6-b06
-870ec15296f34e973bc256b7a14a4ce7eaa1af7e jdk7u6-b07
-ed00f61a5de82f63449ea6ad0a17c0ad7177aaf9 jdk7u6-b08
-3e268ea565efb2fd1df1d1b733512c202d83cf4f jdk7u6-b09
-21d2313dfeac8c52a04b837d13958c86346a4b12 jdk7u6-b10
-13d3c624291615593b4299a273085441b1dd2f03 jdk7u6-b11
-f0be10a26af08c33d9afe8fe51df29572d431bac jdk7u6-b12
-fcebf337f5c1d342973573d9c6f758443c8aefcf jdk7u6-b13
-35b2699c6243e9fb33648c2c25e97ec91d0e3553 jdk7u6-b14
-47ae28da508861d77ee6dd408d822acf507b28ec jdk7u6-b15
-5c7763489f4d2727c6d9de11f4114fb8ed839042 jdk7u6-b16
-66c671f28cb2840ceec5b44c44bac073fc0b4256 jdk7u6-b17
-6aa859ef42876c51bb1b1d7fb4db32a916a7dcaa jdk7u6-b18
-474a52eeeafb1feccffda68b96f651e65415c01d jdk7u6-b19
-32acb67a79531daf678577c7ef1bde1867da807d jdk7u6-b20
-a35ca56cf8d09b92511f0cd71208a2ea05c8a338 jdk7u6-b21
-4f3aafa690d1fcb18693fc4085049eeffe4778f7 jdk7u6-b22
-dd3e29d8892fcaba6d76431d5fa9d49e7c088f76 jdk7u6-b23
-6aac89e84fc96d15bb78b13aa71c9e6b73d7237e jdk7u6-b24
-bcd1d067d525065630deb98b678bc00b499adbe1 jdk7u6-b30
-2d6017454236d4e95aad7feaff5fc92a612598f4 jdk7u7-b10
-27041587508dbc4e08c956ba98a11ce0d5608dc4 jdk7u7-b30
-a35ca56cf8d09b92511f0cd71208a2ea05c8a338 jdk7u8-b01
-41bc8da868e58f7182d26b2ab9b6f8a4b09894ed jdk7u8-b02
-df5cbe436d3460af4667d416877e03400de54524 jdk7u8-b03
-d4296a07e45a0cffbca17c608916ff6bcec78d75 jdk7u8-b04
-1b7eaaffd58359639346661196309005a374192f jdk7u8-b05
-e1f380574f5490ef785282b81b6b38626109444b jdk7u10-b06
-cd18b83736af19afbccce4b7351c5a3c857356ac jdk7u10-b07
-3204f355a32d83ffceeed1c0c8a52a2d834ae29f jdk7u10-b08
-0b90d3480dbfc16aa3901df249b3cb21bcfa0b32 jdk7u10-b09
+e9f118c2bd3c4690d8d2e6b108b5bad7e226634c jdk8-b01
+b3c059de2a61fc122c99d555cdd8b85f112393c1 jdk8-b02
+f497fac86cf9ada4801ecaf49eb0d2307a2b61c8 jdk8-b03
+5df63fd8fa64741e829281ee6febe9954932841b jdk8-b04
+5304c2a17d4b001e365a8f0163082dc375f1abab jdk8-b05
+d2422276f9dabc848b7a079025719826d2f9a30f jdk8-b06
+116980ecec5cc7d52736f09cf332321e0773265f jdk8-b07
+e8acc2d6c32f0c8321e642e1a86672a2e196a056 jdk8-b08
+b7a7e47c8d3daf7822abf7c37e5179ccbbf53008 jdk8-b09
+f6c783e18bdf4d46a0ab273868afebbf32600ff7 jdk8-b10
+4bf01f1c4e3464f378959d10f3983a0469181d94 jdk8-b11
+f2d6ed25857dfa7f269ac66e13666d648cb988c6 jdk8-b12
+ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13
+58f1325d72b2bacc901f5189ee5e4e81e81ea657 jdk8-b14
+07599bd780cab1f40da7915e1dc6774629b0cf8c jdk8-b15
+1cbe86c11ba69521875c0b0357d7540781eb334d jdk8-b17
+ec2c0973cc31e143cffc05ceb63d98fae76f97d4 jdk8-b16
+ab1b1cc7857716914f2bb20b3128e5a8978290f7 jdk8-b18
+77b2c066084cbc75150efc6603a713c558329813 jdk8-b19
+ffd294128a48cbb90ce8f0569f82b61f1f164a18 jdk8-b20
+bcb21abf1c4177baf4574f99709513dcd4474727 jdk8-b21
+390a7828ae18324030c0546b6452d51093ffa451 jdk8-b22
+601ffcc6551d5414ef871be306c3a26396cf16a7 jdk8-b23
+6c9d21ca92c41ff5fcfa76c5b7fafe0f042f4aef jdk8-b24
+520c30f85bb529a3daf5d7623764c2464f00fd19 jdk8-b25
+b556aa8a99c358469861770aebdce884e06fa178 jdk8-b26
+be456f9c64e818161c789252145d4ddc292ae863 jdk8-b27
+5bed623b0c773aa8a8d5f8d4004ce9d3974143cc jdk8-b28
+e974e82abe51ef66dc32bb6ab5d0733753d3c7d7 jdk8-b29
+08a3425f39f829502ca0ddbfb2d051c31710cb19 jdk8-b30
+b28cfbe7e8b196da954bed9a22bfd790e55333aa jdk8-b31
+be069d72dde2bfe6f996c46325a320961ca854c2 jdk8-b32
+46831c72b7f6c69fef2cc2935001863643a65f94 jdk8-b33
+6b105afbb77ca9600a99eade31f686d070c70581 jdk8-b34
+defd666a786334465496c8901fa302b779c7e045 jdk8-b35
+94bbaa67686f44a124cd16fd9f1e8a6a3f684d2d jdk8-b36
+5891b38985e8b2502296fc29e726b527d03116d2 jdk8-b37
+1f224f160aa852c9541380735a27a3439dfb7217 jdk8-b38
+a9f547c218d957306dfc0cdd710be041bb62a555 jdk8-b39
+86e0dad6aadf626bf5755f503aee2d0da525d9d5 jdk8-b40
+179fa85aeefab338cccf1cbe8b494c59bc5df122 jdk8-b41
+02c5a3575539e737a1855b31287654e843edd6da jdk8-b42
+f8c64d835b2806293b8e924b44f0e32b20657ed3 jdk8-b43
+59cbead12ff46dbb397120bd26635bcd7d41ff21 jdk8-b44
+e111e4587ccada8eb93f72e834e378c76256f4b7 jdk8-b45
+4ca5994971724731233735f055f33d4936fd11d3 jdk8-b46
+7e6be2f239c9a4ac6dec280bd18ec296dd78e464 jdk8-b47
+afb0a523155727d42b1c773f783ff3a7cfab8e86 jdk8-b48
+c72c164ced676d3c360d99b1c52cc80940fc3122 jdk8-b49
+b2d8a270f5f2144e14a1fe97fbda9e4391a5332e jdk8-b50
+c4cd4cab2220817c88c8c139c9bfc91c36b48826 jdk8-b51
+1d2db0e5eabc2eaf865986f7b7ffbf7b14b00232 jdk8-b52
+d3d0b9cd76e04bf9e381b402630ac3cfe464bb38 jdk8-b53
+9cf72631baf5cb1ebd8736c5efeab7746977ea68 jdk8-b54
+e48e7e1f026b82d921433150180799898c088890 jdk8-b55
+363e9198b9de68ebf37a3e2c2f3f23543d3915cd jdk8-b56
+86d5740b9fdc20ababb8aefde89ae1509ff216a9 jdk8-b57
+804a3fbc86e28a4d9e77c30aa0bd4aa68056f23f jdk8-b58
+f299927fc31689385f67ab7322c18eb41d8bd71e jdk8-b59
+3d2b98ffcb534b0e5be87bb1f9f68d1518ad7729 jdk8-b60
+26020b247ad3806dbca33e029ee12e1b191f59f9 jdk8-b61
+b47bb81ba962ef80bb6f0b863c33a0afcfb0b49e jdk8-b62
+92e6f2190ca0567c857f85c3fb7a2be5adf079d0 jdk8-b63
+e6ee43b3e2473798b17a556e9f11eebe25ab81d4 jdk8-b64
+5f2faba89cac665e365c05074064ffc934a495eb jdk8-b65
+20230f8b0eef92a57043735fc2ca00fea7e510a0 jdk8-b66
+303b09787a69136cd2019f9edfed3f308572e9fc jdk8-b67
+014a6a11dfe5ddc23ec8c76bb42ac998dbf49acb jdk8-b68
+d7360bf35ee1f40ff78c2e83a22b5446ee464346 jdk8-b69
+47f71d7c124f24c2fe2dfc49865b332345b458ed jdk8-b70
+467e4d9281bcf119eaec42af1423c96bd401871c jdk8-b71
+6f0986ed9b7e11d6eb06618f27e20b18f19fb797 jdk8-b72
+8d0baee36c7184d55c80354b45704c37d6b7ac79 jdk8-b73
+56c97aff46bb577b8668874154c24115a7e8a3e8 jdk8-b74
+c2e11e2ec4a3682513e566849e5562f31ded8c65 jdk8-b75
+e81839b3233792415daaab051698edc6067f1a16 jdk8-b76
+89c66415168925dffe492356ff893ff248bb5603 jdk8-b77
+af8417e590f4e76e0dfed09e71239fb102ef0d43 jdk8-b78
+56dfafbb9e1ad7548a4415316dc003296fb498cb jdk8-b79
+a8227c61768499dac847ea718af6719027c949f2 jdk8-b80
+ed69d087fdfd394491657a28ba9bc58e7849b7db jdk8-b81
+825da6847791994a8f405ee397df9e7fa638a458 jdk8-b82
+22ba3f92d4ae43bbc19793e854171cae2586f644 jdk8-b83
+cfb65ca92082b2412aed66c8422c2466bde544ef jdk8-b84
+4a48f31735349782ad13980267358c97076adc66 jdk8-b85
+6ab578e141dfd17c4dc03869bb204aafa490c9f4 jdk8-b86
+1329f9c38d93c8caf339d7687df8371d06fe9e56 jdk8-b87
+a1e10f3adc47c8602a72e43a41403a642e73e0b1 jdk8-b88
+ec434cfd2752a7742c875c2fe7d556d8b81c0f3a jdk8-b89
+e19283cd30a43fca94d8f7639c73ef66db493b1e jdk8-b90
+997c0fae2b12108959387862be54b78ca0ae3fca jdk8-b91
+149890642a0ed5138a4f16fe08ddbfeb8f8a1cb4 jdk8-b92
+2c5a568ee36eb2d9471483b7a310c49ed545db55 jdk8-b93
+48c6e6ab7c815fd41d747f0218f8041c22f3a460 jdk8-b94
+4cb1136231275a1f8af53f5bfdef0b488e4b5bab jdk8-b95
+988aef3a8c3adac482363293f65e77ec4c5ce98d jdk8-b96
+6a11a81a8824c17f6cd2ec8f8492e1229b694e96 jdk8-b97
+ce5a90df517bdceb2739d7dd3e6764b070def802 jdk8-b98
+6d85acab769eb79bc058f5640fa86a6ef096a583 jdk8-b99
+82f68da70e471ee5640016e3f38c014347a5c785 jdk8-b100
+0324dbf07b0f1cc51ad9fa18976489d02d23b60d jdk8-b101
diff --git a/.jcheck/conf b/.jcheck/conf
index 7880a0e..6d0dbe4 100644
--- a/.jcheck/conf
+++ b/.jcheck/conf
@@ -1,2 +1 @@
-project=jdk7
-bugids=dup
+project=jdk8
diff --git a/THIRD_PARTY_README b/THIRD_PARTY_README
index 77e3510..ee5463a 100644
--- a/THIRD_PARTY_README
+++ b/THIRD_PARTY_README
@@ -216,16 +216,15 @@ site-policy at w3.org.
 is included with JRE 7, JDK 7, and OpenJDK 7.
 
 You are receiving a copy of the Elliptic Curve Cryptography library in source
-form with the JDK 7 and OpenJDK7 source distributions, and as object code in
-the JRE 7 & JDK 7 runtimes.
-
-In the case of the JRE 7 & JDK 7 runtimes, the terms of the Oracle license do
-NOT apply to the Elliptic Curve Cryptography library; it is licensed under the
-following license, separately from Oracle's JDK & JRE.  If you do not wish to
-install the Elliptic Curve Cryptography library, you may delete the library
-named libsunec.so (on Solaris and Linux systems) or sunec.dll (on Windows
-systems) from the JRE bin directory reserved for native libraries.
+form with the JDK 7 source distribution and object code in the JRE 7 & JDK 7
+runtime.
 
+The terms of the Oracle license do NOT apply to the Elliptic Curve
+Cryptography library program; it is licensed under the following license,
+separately from the Oracle programs you receive. If you do not wish to install
+this program, you may delete the library named libsunec.so (on Solaris and
+Linux systems) or sunec.dll (on Windows systems) from the JRE bin directory
+reserved for native libraries.
 
 --- begin of LICENSE ---
 
@@ -1001,7 +1000,7 @@ included with JDK 7 and OpenJDK 7 source distributions.
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libpng 1.5.4, which is 
+%% This notice is provided with respect to libpng 1.2.18, which is 
 included with JRE 7, JDK 7, and OpenJDK 7.
 
 --- begin of LICENSE ---
@@ -1015,10 +1014,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-This code is released under the libpng license.
-
-libpng versions 1.2.6, August 15, 2004, through 1.5.4, July 7, 2011, are
-Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
+libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are
+Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
 
@@ -1115,7 +1112,7 @@ certification mark of the Open Source Initiative.
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-July 7, 2011
+May 15, 2007
 
 --- end of LICENSE ---
 
diff --git a/make/Makefile-classic b/make/Makefile-classic
deleted file mode 100644
index 90926d4..0000000
--- a/make/Makefile-classic
+++ /dev/null
@@ -1,419 +0,0 @@
-#
-# Copyright (c) 2007, 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.
-#
-
-#
-# Makefile for building the langtools workspace.
-#
-
-#
-# On Solaris, the standard 'make' utility will not work with these makefiles.
-#    This little rule is only understood by Solaris make, and is harmless
-#    when seen by the GNU make tool. If using Solaris make, this causes the
-#    make command to fail.
-#
-SUN_MAKE_TEST:sh = @echo "ERROR: PLEASE USE GNU VERSION OF MAKE"; exit 33
-
-#----- cancel implicit rules
-
-%: %.o
-%: %.obj
-%: %.dll
-%: %.c
-%: %.cc
-%: %.C
-%: %.p
-%: %.f
-%: %.s
-%: %.F
-%: %.r
-%: %.S
-%: %.mod
-%: %.sh
-%: %,v
-%: RCS/%,v
-
-#----- imports
-
-ifdef ALT_BOOT_JAVA_HOME
-  BOOT_JAVA_HOME = $(ALT_BOOT_JAVA_HOME)
-else 
-  ifdef ALT_BOOTDIR
-    BOOT_JAVA_HOME = $(ALT_BOOTDIR)
-  else
-    BOOT_JAVA_HOME=/java/re/jdk/1.5.0/archive/fcs/binaries/solaris-sparc
-  endif
-endif
-
-BOOT_JAVA=$(BOOT_JAVA_HOME)/bin/java
-BOOT_JAVAC=$(BOOT_JAVA_HOME)/bin/javac
-BOOTJAR=$(BOOT_JAVA_HOME)/bin/jar
-
-ifdef ALT_TESTJAVA_HOME
-  TESTJAVA_HOME = $(ALT_TESTJAVA_HOME)
-else
-  TESTJAVA_HOME=/java/re/jdk/1.6.0/archive/fcs/binaries/solaris-sparc
-endif
-
-TESTJAVA=$(TESTJAVA_HOME)/bin/java
-
-ifdef ALT_FINDBUGS_HOME
-  FINDBUGS_HOME = $(ALT_FINDBUGS_HOME)
-else
-  FINDBUGS_HOME = /java/devtools/share/findbugs/1.1.2-rc4
-endif
-
-FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs
-
-#----- commands
-
-CHMOD = chmod
-CP = cp
-ECHO = echo # FIXME
-FIND = find
-MKDIR = mkdir
-SED = sed
-ZIP = zip
-
-#-----  locations and deliverables
-
-TOPDIR = ..
-SRC_BIN_DIR = $(TOPDIR)/src/share/bin
-SRC_CLASSES_DIR = $(TOPDIR)/src/share/classes
-
-BUILD_DIR = $(TOPDIR)/build
-
-CLASSES_DIR = $(BUILD_DIR)/classes
-GENSRC_DIR = $(BUILD_DIR)/gensrc
-
-DIST_DIR = $(TOPDIR)/dist
-BIN_DIR = $(DIST_DIR)/bin
-LIB_DIR = $(DIST_DIR)/lib
-
-JAVAC_JAR = $(LIB_DIR)/javac.jar
-JAVADOC_JAR = $(LIB_DIR)/javadoc.jar
-JAVAH_JAR = $(LIB_DIR)/javah.jar
-JAVAP_JAR = $(LIB_DIR)/javap.jar
-APT_JAR = $(LIB_DIR)/apt.jar
-
-CLASSES_JAR = $(DIST_DIR)/classes.jar
-SRC_ZIP = $(DIST_DIR)/src.zip
-
-BUILDTOOLSRC_DIR = tools
-BUILDTOOLCLASSES_DIR = $(BUILD_DIR)/toolclasses
-
-#-----
-
-ifndef JDK_MAJOR_VERSION
-  JDK_MAJOR_VERSION = 1
-endif
-
-ifndef JDK_MINOR_VERSION
-  JDK_MINOR_VERSION = 7
-endif
-
-ifndef JDK_MICRO_VERSION
-  JDK_MICRO_VERSION = 0
-endif
-
-ifndef JDK_VERSION
-  JDK_VERSION = $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
-endif
-
-ifndef MILESTONE
-  MILESTONE = internal
-endif
-
-# RELEASE is JDK_VERSION and -MILESTONE if MILESTONE is set
-ifneq ($(MILESTONE),fcs)
-  RELEASE      = $(JDK_VERSION)-$(MILESTONE)$(BUILD_VARIANT_RELEASE)
-else
-  RELEASE      = $(JDK_VERSION)$(BUILD_VARIANT_RELEASE)
-endif
-
-# FULL_VERSION is RELEASE and -BUILD_NUMBER if BUILD_NUMBER is set
-ifdef BUILD_NUMBER
-  FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
-else
-  BUILD_NUMBER = b00
-  USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`)
-  FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
-endif
-
-#----- useful macros
-
-TOOLS =  javac javadoc javah javap apt
-
-SOURCE_LEVEL = 5
-BOOTSTRAP_TARGET_LEVEL = 5
-TARGET_LEVEL = 6
-
-ifndef TARGET_JAVA
-  TARGET_JAVA = java
-endif
-
-NO_PROPRIETARY_API_WARNINGS = -XDignore.symbol.file=true
-
-SELF = $(lastword $(MAKEFILE_LIST))
-
-#-----
-
-# the default is to generate the following:
-# dist/{bin,lib}: 
-# 	lang tools compiled to run on the target JDK
-
-default:  
-	$(MAKE) -f $(SELF) \
-		MILESTONE=bootstrap \
-		TARGET_LEVEL=$(BOOTSTRAP_TARGET_LEVEL) \
-		TARGET_JAVA=$(BOOT_JAVA_HOME)/bin/java \
-		GENSRC_DIR=$(BUILD_DIR)/bootstrap/gensrc \
-		CLASSES_DIR=$(BUILD_DIR)/bootstrap/classes \
-		BIN_DIR=$(BUILD_DIR)/bootstrap/bin \
-		LIB_DIR=$(BUILD_DIR)/bootstrap/lib \
-		$(BUILD_DIR)/bootstrap/lib/javac.jar \
-		$(BUILD_DIR)/bootstrap/bin/javac
-	$(MAKE) -f $(SELF) \
-		BOOT_JAVAC=$(BUILD_DIR)/bootstrap/bin/javac \
-		tools
-
-# for jdk, we generate the following:
-# dist/bootstrap/{bin,lib}:
-#	lang tools compiled to run on the boot JDK
-# dist/lib/classes.jar:
-#	lang tools recompiled to run on the target JDK,
-#	ready for inclusion in rt.jar and tools.jar
-# dist/lib/src.zip
-#	.properties and .java files for classes in classes.jar,
-#	ready for jdk src.zip 
-
-jdk:
-	$(MAKE) -f $(SELF) \
-		MILESTONE=bootstrap \
-		TARGET_LEVEL=$(BOOTSTRAP_TARGET_LEVEL) \
-		TARGET_JAVA=$(BOOT_JAVA_HOME)/bin/java \
-		GENSRC_DIR=$(BUILD_DIR)/bootstrap/gensrc \
-		CLASSES_DIR=$(BUILD_DIR)/bootstrap/classes \
-		BIN_DIR=$(DIST_DIR)/bootstrap/bin \
-		LIB_DIR=$(DIST_DIR)/bootstrap/lib \
-		tools
-	$(MAKE) -f $(SELF) \
-		BOOT_JAVAC=$(DIST_DIR)/bootstrap/bin/javac \
-		LIB_DIR=$(BUILD_DIR)/jdk/lib \
-		$(DIST_DIR)/lib/classes.jar \
-		$(DIST_DIR)/lib/src.zip
-
-tools: $(TOOLS:%=$(LIB_DIR)/%.jar) $(TOOLS:%=$(BIN_DIR)/%)
-
-clean:
-	$(RM) -r $(BUILD_DIR)
-
-really-clean: clean
-	$(RM) -r $(DIST_DIR)
-
-jprt_product_build \
-jprt_debug_build \
-jprt_fastdebug_build: lib
-
-#-----  javac
-
-JAVAC_DIRS = \
-	javax/annotation/processing \
-	javax/lang/model \
-	javax/tools \
-	com/sun/source \
-	com/sun/tools/javac 
-
-JAVAC_RESOURCE_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAC_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-JAVAC_JAVA_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAC_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
-	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAC_RESOURCE_FILES)) \
-	$(GENSRC_DIR)/com/sun/tools/javac/resources/version.java
-
-$(JAVAC_JAR): $(JAVAC_JAVA_FILES)
-	$(MKDIR) -p $(CLASSES_DIR) $(@D)
-	$(BOOT_JAVAC) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) $(JAVAC_JAVA_FILES)
-	( $(ECHO) Main-Class: com.sun.tools.javac.Main ) > $(BUILD_DIR)/javac.mf
-	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javac.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAC_DIRS))
-
-#----- javadoc
-
-### FIXME -- javadoc has a couple of extra non-property resource files
-### that need to be included
-
-JAVADOC_DIRS = \
-	com/sun/javadoc \
-	com/sun/tools/doclets \
-	com/sun/tools/javadoc
-
-JAVADOC_RESOURCE_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVADOC_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-JAVADOC_JAVA_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVADOC_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
-	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVADOC_RESOURCE_FILES))
- 
-$(JAVADOC_JAR): $(JAVADOC_JAVA_FILES) $(JAVAC_JAR)
-	$(MKDIR) -p $(CLASSES_DIR) $(@D)
-	$(BOOT_JAVAC) -sourcepath "" -classpath $(JAVAC_JAR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVADOC_JAVA_FILES)
-	( $(ECHO) Main-Class: com.sun.tools.javadoc.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/javadoc.mf
-	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javadoc.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVADOC_DIRS))
-
-#----- javah
-
-JAVAH_DIRS = \
-	com/sun/tools/javah
-
-JAVAH_RESOURCE_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAH_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-JAVAH_JAVA_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAH_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
-	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAH_RESOURCE_FILES))
- 
-$(JAVAH_JAR): $(JAVAH_JAVA_FILES) $(JAVADOC_JAR)
-	$(MKDIR) -p $(CLASSES_DIR) $(@D)
-	$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVAH_JAVA_FILES)
-	( $(ECHO) Main-Class: com.sun.tools.javah.Main ; $(ECHO) Class-Path: javadoc.jar ) > $(BUILD_DIR)/javah.mf
-	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javah.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAH_DIRS))
-
-#----- javap
-
-JAVAP_DIRS = \
-	sun/tools/javap
-
-JAVAP_RESOURCE_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAP_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-JAVAP_JAVA_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(JAVAP_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
-	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAP_RESOURCE_FILES))
- 
-$(JAVAP_JAR): $(JAVAP_JAVA_FILES) \
-		$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(JAVAP_RESOURCE_FILES))
-	$(MKDIR) -p $(CLASSES_DIR)
-	$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(JAVAP_JAVA_FILES)
-	( $(ECHO) Main-Class: sun.tools.javap.Main ) > $(BUILD_DIR)/javap.mf
-	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javap.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAP_DIRS))
-
-#----- apt
-
-APT_DIRS = \
-	com/sun/mirror \
-	com/sun/tools/apt
-
-APT_RESOURCE_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-APT_JAVA_FILES = \
-	$(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
-	$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
- 
-$(APT_JAR): $(APT_JAVA_FILES) $(JAVAC_JAR) \
-		$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
-	$(MKDIR) -p $(CLASSES_DIR) $(@D)
-	$(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) \
-		$(APT_JAVA_FILES) \
-		$(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
-	( $(ECHO) Main-Class: com.sun.tools.apt.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/apt.mf
-	$(BOOTJAR) -cfm $@ $(BUILD_DIR)/apt.mf $(patsubst %,-C $(CLASSES_DIR) %, $(APT_DIRS))
-
-#-----
-
-build-tools: $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
-
-$(GENSRC_DIR)/%.java: $(SRC_CLASSES_DIR)/%.properties $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
-	$(MKDIR) -p $(@D)
-	$(BOOT_JAVA) -cp $(BUILDTOOLCLASSES_DIR)/CompileProperties CompileProperties $< $(patsubst $(CLASSES_DIR)/%.class,$(GENSRC_DIR)/%.java,$@)
-
-$(GENSRC_DIR)/%.java: $(GENSRC_DIR)/%.properties $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
-	$(MKDIR) -p $(@D)
-	$(BOOT_JAVA) -cp $(BUILDTOOLCLASSES_DIR)/CompileProperties CompileProperties $< $(patsubst $(CLASSES_DIR)/%.class,$(GENSRC_DIR)/%.java,$@)
-
-$(GENSRC_DIR)/%.properties: $(SRC_CLASSES_DIR)/%.properties-template
-	$(MKDIR) -p $(@D)
-	$(SED)  -e 's/$$(JDK_VERSION)/$(JDK_VERSION)/'  \
-		-e 's/$$(FULL_VERSION)/$(FULL_VERSION)/' \
-		-e 's/$$(RELEASE)/$(RELEASE)/' \
-		< $< > $@
-
-$(BUILDTOOLCLASSES_DIR)/%.class : $(BUILDTOOLSRC_DIR)/%.java
-	$(MKDIR) -p $(@D)
-	$(BOOT_JAVAC) -d $(@D) $<
-
-#----- all classes
-
-$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR) $(APT_JAR)
-	$(MKDIR) -p $(@D)
-	$(BOOTJAR) -cf $@ -C $(CLASSES_DIR) .
-
-#----- src.zip
-
-SRC_ZIP_FILES = $(shell $(FIND) $(SRC_CLASSES_DIR) \( -name SCCS -o -name \*-template \) -prune -o -type f -print )
-
-$(DIST_DIR)/%/src.zip: $(SRC_ZIP_FILES)
-	abs_src_zip=`cd $(@D) ; pwd`/$(@F) ; \
-	( cd $(SRC_CLASSES_DIR) ; $(FIND) . \( -name SCCS -o -name \*-template \) -prune -o -type f -print | $(ZIP) -q $$abs_src_zip -@ ) ; \
-	( cd $(SRC_CLASSES_DIR) ; $(FIND) . -name SCCS -prune -o -name \*-template -print | $(SED) -e 's/-template//' ) | ( cd $(GENSRC_DIR) ; $(ZIP) -q $$abs_src_zip -@ ) 
-
-#----- bin files
-
-$(BIN_DIR)/%: $(SRC_BIN_DIR)/launcher.sh-template
-	$(MKDIR) -p $(@D)
-	$(SED) -e 's|#PROGRAM#|$(@F)|' -e 's|#TARGET_JAVA#|$(TARGET_JAVA)|' $< > $@
-	$(CHMOD) +x $@
-
-#-----
-
-findbugs: $(BUILD_DIR)/findbugs.txt
-
-$(BUILD_DIR)/findbugs.txt: $(CLASSES_JAR)
-	$(MKDIR) -p $(@D)
-	$(FINDBUGS) -textui -javahome $(BOOT_JAVA_HOME) -high -emacs -outputFile $@ $<
-
-#-----
-
-quick-check: $(patsubst %, $(DIST_LIB_DIR)/%.jar, $(TOOLS))
-	$(TESTJAVA) -jar $(JAVAC_JAR) -version
-	- $(TESTJAVA) -jar $(JAVADOC_JAR) -version
-	$(TESTJAVA) -jar $(JAVAH_JAR) -version
-	- $(TESTJAVA) -jar $(JAVAP_JAR) -version
-	$(TESTJAVA) -jar $(APT_JAR) -version
-
-#-----
-
-.PHONY: \
-	all \
-	build \
-	build-tools \
-	clean \
-	default \
-	findbugs \
-	jprt_product_build \
-	jprt_debug_build \
-	jprt_fastdebug_build \
-	tools
-
diff --git a/make/build.properties b/make/build.properties
index 5c4ad09..d16be20 100644
--- a/make/build.properties
+++ b/make/build.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2010, 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
@@ -29,22 +29,22 @@
 # Override this path as needed, either on the command line or in
 # one of the standard user build.properties files (see build.xml)
 
-# boot.java.home = /opt/jdk/1.6.0
+# boot.java.home = /opt/jdk/1.7.0
 boot.java = ${boot.java.home}/bin/java
 boot.javac = ${boot.java.home}/bin/javac
-boot.javac.source = 6
-boot.javac.target = 6
+boot.javac.source = 7
+boot.javac.target = 7
 
 # This is the JDK used to run the product version of the tools,
 # for example, for testing. If you're building a complete JDK, specify that.
 # Override this path as needed, either on the command line or in
 # one of the standard user build.properties files (see build.xml)
 
-# target.java.home = /opt/jdk/1.7.0
+# target.java.home = /opt/jdk/1.8.0
 target.java = ${target.java.home}/bin/java
 
 # Version info -- override as needed
-jdk.version = 1.7.0
+jdk.version = 1.8.0
 build.number = b00
 milestone = internal
 
@@ -60,15 +60,15 @@ full.version = ${release}-${build.number}
 bootstrap.full.version = ${bootstrap.release}-${build.number}
 
 # options for the <javac> tasks used to compile the tools
-javac.source = 7
-javac.target = 7
+javac.source = 8
+javac.target = 8
 javac.debug = true
 javac.debuglevel = source,lines
 javac.no.jdk.warnings = -XDignore.symbol.file=true
 # set the following to -version to verify the versions of javac being used
 javac.version.opt =
 # in time, there should be no exceptions to -Xlint:all
-javac.lint.opts = -Xlint:all,-deprecation -Werror
+javac.lint.opts = -Xlint:all -Werror
 
 # options for the <javadoc> task for javac
 #javadoc.jls3.url=http://java.sun.com/docs/books/jls/
@@ -116,8 +116,10 @@ javac.includes = \
         javax/annotation/processing/ \
         javax/lang/model/ \
         javax/tools/ \
+        jdk/ \
         com/sun/source/ \
-        com/sun/tools/javac/
+        com/sun/tools/javac/ \
+        com/sun/tools/doclint/
 
 javac.tests = \
         tools/javac
@@ -152,6 +154,7 @@ javah.tests = \
 javap.includes = \
         com/sun/tools/classfile/ \
         com/sun/tools/javap/ \
+        com/sun/tools/jdeps/ \
         sun/tools/javap/
 
 javap.tests = \
@@ -159,13 +162,12 @@ javap.tests = \
 
 #
 
-apt.includes = \
-        com/sun/mirror/ \
-        com/sun/tools/apt/
-
-apt.tests = \
-        tools/apt/
+sjavac.includes = \
+        com/sun/tools/sjavac/ 
 
+sjavac.tests = \
+        tools/sjavac
+        
 #
 
 # The following files require the latest JDK to be available.
@@ -196,3 +198,7 @@ import.jdk.stub.files = \
 # An empty value means all tests
 # Override as desired to run a specific set of tests
 jtreg.tests =
+
+# Check style configuration
+# overridable name and version
+checkstyle.name.version = checkstyle-5.4
diff --git a/make/build.xml b/make/build.xml
index 42020b3..d242e72 100644
--- a/make/build.xml
+++ b/make/build.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- Copyright (c) 2007, 2011, 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
@@ -83,7 +83,7 @@
  - global property definitions
  - general top level targets
  - general diagnostic/debugging targets
- - groups of targets for each tool: javac, javadoc, doclets, javah, javap, apt
+ - groups of targets for each tool: javac, javadoc, doclets, javah, javap
     Within each group, the following targets are provided, where applicable
       build-bootstrap-TOOL      build the bootstrap version of the tool
       build-classes-TOOL        build the classes for the tool
@@ -131,8 +131,10 @@
     <property name="dist.bin.dir" location="${dist.dir}/bin"/>
     <property name="dist.coverage.dir" location="${dist.dir}/coverage"/>
     <property name="dist.findbugs.dir" location="${dist.dir}/findbugs"/>
+    <property name="dist.checkstyle.dir" location="${dist.dir}/checkstyle"/>
     <property name="dist.lib.dir" location="${dist.dir}/lib"/>
     <property name="make.dir" location="make"/>
+    <property name="make.conf.dir" location="${make.dir}/conf"/>
     <property name="make.tools.dir" location="${make.dir}/tools"/>
     <property name="src.dir" location="src"/>
     <property name="src.bin.dir" location="${src.dir}/share/bin"/>
@@ -239,15 +241,15 @@
     </target>
 
     <target name="build-bootstrap-tools"
-        depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah"
+        depends="build-bootstrap-javac,build-bootstrap-javadoc,build-bootstrap-doclets,build-bootstrap-javah,build-bootstrap-sjavac"
     />
 
     <target name="build-all-tools"
-        depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"
+        depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-sjavac"
     />
 
     <target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
-        <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${apt.includes}"/>
+        <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${sjavac.includes}"/>
     </target>
 
     <!-- clean -->
@@ -263,6 +265,41 @@
         <jtreg-tool name="all" tests="${jtreg.tests}"/>
     </target>
 
+    <target name="checkstyle" depends="-def-checkstyle"
+        description="Generates reports for code convention violations.">
+        <mkdir dir="${dist.checkstyle.dir}"/>
+        <checkstyle config="${make.conf.dir}/checkstyle-langtools.xml"
+              failureProperty="checkstyle.failure"
+              failOnViolation="false">
+            <formatter type="xml" tofile="${dist.checkstyle.dir}/checkstyle_report.xml"/>
+            <fileset dir="src" includes="**/*.java, **/*.properties"/>
+        </checkstyle>
+        <!-- transform the output to a simple html -->
+        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
+               out="${dist.checkstyle.dir}/checkstyle_report.html"
+               style="${checkstyle.home}/contrib/checkstyle-simple.xsl"/>
+        <!-- transform the output to a very simple emacs friendly text file -->
+        <xslt  in="${dist.checkstyle.dir}/checkstyle_report.xml"
+               out="${dist.checkstyle.dir}/checkstyle_report.tmp"
+               style="${make.conf.dir}/checkstyle-emacs.xsl"/>
+        <!-- beautify remove extra lines -->
+        <move file="${dist.checkstyle.dir}/checkstyle_report.tmp"
+             toFile="${dist.checkstyle.dir}/checkstyle_report.emacs.txt">
+            <filterchain>
+                <ignoreblank/>
+                <replaceregex byline="true" pattern="^File:" replace="${line.separator}File:"/>
+            </filterchain>
+        </move>
+    </target>
+    <!-- target can be invoked from an ide, the output of which can be used
+         to access and fix the errors directly.
+     -->
+    <target name="checkstyle-ide" depends="checkstyle">
+        <concat>
+            <fileset file="${dist.checkstyle.dir}/checkstyle_report.emacs.txt"/>
+        </concat>
+    </target>
+
     <target name="findbugs" depends="-def-findbugs,build-all-tools">
         <property name="findbugs.reportLevel" value="medium"/>
         <mkdir dir="${dist.findbugs.dir}"/>
@@ -331,17 +368,20 @@
             executable="${dist.bin.dir}/javac"
             srcdir="test/tools/javac/diags"
             destdir="${build.dir}/diag-examples/classes"
-            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java"
+            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
             sourcepath=""
             classpath="${dist.lib.dir}/javac.jar"
             includeAntRuntime="no"
             debug="${javac.debug}"
-            debuglevel="${javac.debuglevel}"/>
+            debuglevel="${javac.debuglevel}">
+            <compilerarg line="${javac.lint.opts}"/>
+        </javac>
         <java fork="true"
             jvm="${target.java.home}/bin/java"
             dir="test/tools/javac/diags"
             classpath="${build.dir}/diag-examples/classes;${dist.lib.dir}/javac.jar"
             classname="RunExamples">
+            <jvmarg value="-Dtest.classes=${build.dir}/diag-examples/classes"/>
             <arg value="-examples"/>
             <arg value="examples"/>
             <arg value="-o"/>
@@ -392,6 +432,31 @@
         </zip>
     </target>
 
+    <target name="doclint-api" depends="build-all-classes">
+        <delete dir="${build.dir}/doclint/classes"/>
+        <mkdir dir="${build.dir}/doclint/classes"/>
+        <javac fork="true"
+               executable="${boot.javac}"
+               srcdir="${src.classes.dir}:${build.gensrc.dir}"
+               destdir="${build.dir}/doclint/classes"
+               includes="javax/lang/model/** com/sun/javadoc/** com/sun/source/**"
+               excludes=""
+               sourcepath="${javac.sourcepath}"
+               classpath="${javac.classpath}"
+               includeAntRuntime="no"
+               source="${javac.source}"
+               target="${javac.target}"
+               debug="${javac.debug}"
+               debuglevel="${javac.debuglevel}">
+            <compilerarg value="-implicit:none"/>
+            <compilerarg value="-Xprefer:source"/>
+            <compilerarg value="-J-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
+            <compilerarg line="${javac.no.jdk.warnings}"/>
+            <compilerarg line="${javac.version.opt}"/>
+            <compilerarg line="-Xdoclint:all/protected,-missing"/>
+        </javac>
+    </target>
+
     <!--
     **** Debugging/diagnostic targets.
     -->
@@ -404,6 +469,7 @@
         <echo level="info">target.java.home = ${target.java.home}</echo>
         <echo level="info">jtreg.home = ${jtreg.home}</echo>
         <echo level="info">findbugs.home = ${findbugs.home}</echo>
+        <echo level="info">checkstyle.home = ${checkstyle.home}</echo>
     </target>
 
     <target name="post-sanity" depends="-def-jtreg,sanity,build"
@@ -615,42 +681,63 @@
 
     <target name="javap" depends="build-javap,jtreg-javap,findbugs-javap"/>
 
-
     <!--
-    **** apt targets.
+    **** sjavac targets.
     -->
 
-    <target name="build-bootstrap-apt" depends="build-bootstrap-javac">
-        <build-bootstrap-classes includes="${apt.includes}"/>
-        <build-bootstrap-jar     name="apt" includes="${apt.includes}"
-                                 jarclasspath="javac.jar"/>
-        <build-bootstrap-tool    name="apt"/>
-    </target>
-
-    <target name="build-apt" depends="build-javac,build-classes-apt">
-        <build-jar  name="apt" includes="${apt.includes}" jarclasspath="javac.jar"/>
-        <build-tool name="apt"/>
+    <target name="build-bootstrap-sjavac"
+            depends="-def-build-bootstrap-classes,-def-build-bootstrap-jar,-def-build-bootstrap-tool">
+        <build-bootstrap-classes includes="${sjavac.includes}"/>
+        <build-bootstrap-jar     name="sjavac" includes="${sjavac.includes}"
+                                 jarmainclass="com.sun.tools.sjavac.Main"/>
+        <build-bootstrap-tool    name="sjavac"/>
     </target>
 
-    <target name="build-classes-apt" depends="build-classes-javac">
-        <build-classes includes="${apt.includes}"/>
+    <target name="build-classes-sjavac" depends="build-classes-javac">
+        <build-classes includes="${sjavac.includes}"/>
     </target>
 
-    <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
-        <javadoc-tool name="apt" includes="${apt.includes}"/>
+    <target name="build-sjavac" depends="build-classes-sjavac">
+        <build-jar  name="sjavac" includes="${sjavac.includes}"
+                    jarmainclass="com.sun.tools.sjavac.Main"
+                    jarclasspath="sjavac.jar"/>
+        <build-tool name="sjavac"/>
     </target>
 
+    <!-- (no javadoc for javap) -->
 
-    <target name="jtreg-apt" depends="build-apt,-def-jtreg">
-        <jtreg-tool name="apt" tests="${apt.tests}"/>
+    <target name="jtreg-sjavac" depends="build-sjavac,-def-jtreg">
+        <jtreg-tool name="sjavac" tests="${sjavac.tests}"/>
     </target>
 
-    <target name="findbugs-apt" depends="build-apt,-def-findbugs">
-        <findbugs-tool name="apt"/>
+    <target name="findbugs-sjavac" depends="build-sjavac,-def-findbugs">
+        <findbugs-tool name="sjavac"/>
     </target>
 
-    <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>
+    <target name="sjavac" depends="build-sjavac,jtreg-sjavac,findbugs-sjavac"/>
+
+    <!--
+    **** crules targets.
+    -->
+
+    <target name="build-crules" depends="-def-compilecrules,-def-build-jar-with-services">
+        <compilecrules/>
+        <build-jar-with-services
+                    name="crules"
+                    includes="crules/* crules/resources/*"
+                    classes.dir="${build.toolclasses.dir}"
+                    lib.dir="${build.toolclasses.dir}"
+                    jarmainclass=""
+                    jarclasspath="crules.jar"
+                    service.type="com.sun.source.util.Plugin"
+                    service.provider="crules.MutableFieldsAnalyzer"/>
+        <build-tool name="crules"/>
+    </target>
 
+    <target name="check-coding-rules" depends="build-bootstrap-javac,-create-import-jdk-stubs,build-crules">
+        <build-classes includes="${javac.includes}"
+            plugin.options="-J-Xbootclasspath/a:${build.toolclasses.dir}/crules.jar -Xplugin:mutable_fields_analyzer" />
+    </target>
 
     <!--
     **** Create import JDK stubs.
@@ -688,6 +775,10 @@
         <check name="findbugs" property="findbugs.home" marker="lib/findbugs.jar"/>
     </target>
 
+    <target name="-check-checkstyle.home" depends="-def-check">
+        <check name="checkstyle" property="checkstyle.home" marker="${checkstyle.name.version}.jar"/>
+    </target>
+
     <target name="-check-jtreg.home" depends="-def-check">
         <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
     </target>
@@ -743,6 +834,31 @@
         </macrodef>
     </target>
 
+    <target name="-def-build-jar-with-services">
+        <macrodef name="build-jar-with-services">
+            <attribute name="name"/>
+            <attribute name="includes"/>
+            <attribute name="classes.dir" default="${build.classes.dir}"/>
+            <attribute name="lib.dir" default="${dist.lib.dir}"/>
+            <attribute name="jarmainclass" default="com.sun.tools.@{name}.Main"/>
+            <attribute name="jarclasspath" default=""/>
+            <attribute name="service.type" default=""/>
+            <attribute name="service.provider" default=""/>
+            <sequential>
+                <mkdir dir="${build.toolclasses.dir}"/>
+                <jar destfile="@{lib.dir}/@{name}.jar"
+                     basedir="@{classes.dir}"
+                     includes="@{includes}">
+                    <service type="@{service.type}" provider="@{service.provider}"/>
+                    <manifest>
+                        <attribute name="Main-Class" value="@{jarmainclass}"/>
+                        <attribute name="Class-Path" value="@{jarclasspath}"/>
+                    </manifest>
+                </jar>
+            </sequential>
+        </macrodef>
+    </target>
+
     <target name="-def-build-classes" depends="-def-pcompile">
         <macrodef name="build-classes">
             <attribute name="includes"/>
@@ -758,6 +874,7 @@
             <attribute name="target" default="${javac.target}"/>
             <attribute name="release" default="${release}"/>
             <attribute name="full.version" default="${full.version}"/>
+            <attribute name="plugin.options" default=""/>
             <sequential>
                 <echo level="verbose" message="build-classes: excludes=@{excludes}"/>
                 <echo level="verbose" message="build-classes: bootclasspath.opt=@{bootclasspath.opt}"/>
@@ -800,6 +917,7 @@
                     <compilerarg line="${javac.no.jdk.warnings}"/>
                     <compilerarg line="${javac.version.opt}"/>
                     <compilerarg line="${javac.lint.opts}"/>
+                    <compilerarg line="@{plugin.options}"/>
                 </javac>
                 <copy todir="@{classes.dir}" includeemptydirs="false">
                     <fileset dir="${src.classes.dir}" includes="@{includes}" excludes="@{excludes}">
@@ -854,29 +972,61 @@
                source="${boot.javac.source}"
                target="${boot.javac.target}"
                executable="${boot.java.home}/bin/javac"
-               srcdir="${make.tools.dir}/CompileProperties"
+               srcdir="${make.tools.dir}"
+               includes="compileproperties/* anttasks/CompileProperties*"
                destdir="${build.toolclasses.dir}/"
                classpath="${ant.core.lib}"
-               includeantruntime="false"/>
+               bootclasspath="${boot.java.home}/jre/lib/rt.jar"
+               includeantruntime="false">
+            <compilerarg line="${javac.lint.opts}"/>
+        </javac>
         <taskdef name="pcompile"
-                 classname="CompilePropertiesTask"
+                 classname="anttasks.CompilePropertiesTask"
                  classpath="${build.toolclasses.dir}/"/>
     </target>
 
+    <target name="-def-compilecrules">
+        <macrodef name="compilecrules">
+            <sequential>
+                <mkdir dir="${build.toolclasses.dir}"/>
+                <javac fork="true"
+                       source="${boot.javac.source}"
+                       target="${boot.javac.target}"
+                       executable="${boot.java.home}/bin/javac"
+                       srcdir="${make.tools.dir}"
+                       includes="crules/*"
+                       destdir="${build.toolclasses.dir}/"
+                       classpath="${ant.core.lib}"
+                       bootclasspath="${boot.java.home}/jre/lib/rt.jar"
+                       includeantruntime="false">
+                    <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
+                    <compilerarg line="${javac.lint.opts}"/>
+                </javac>
+                <copy todir="${build.toolclasses.dir}/" includeemptydirs="false">
+                    <fileset dir="${make.tools.dir}">
+                        <include name="**/*.properties"/>
+                    </fileset>
+                </copy>
+            </sequential>
+        </macrodef>
+    </target>
+
     <target name="-def-genstubs" depends="build-bootstrap-javac" if="require.import.jdk.stubs">
         <mkdir dir="${build.toolclasses.dir}"/>
         <javac fork="true"
                source="${boot.javac.source}"
                target="${boot.javac.target}"
                executable="${boot.java.home}/bin/javac"
-               srcdir="${make.tools.dir}/GenStubs"
+               srcdir="${make.tools.dir}"
+               includes="genstubs/* anttasks/GenStubs*"
                destdir="${build.toolclasses.dir}/"
                classpath="${ant.core.lib}"
                includeantruntime="false">
             <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
+            <compilerarg line="${javac.lint.opts}"/>
         </javac>
         <taskdef name="genstubs"
-                 classname="GenStubs$$Ant"
+                 classname="anttasks.GenStubsTask"
                  classpath="${build.toolclasses.dir}/"/>
     </target>
 
@@ -919,7 +1069,6 @@
                             <filename name="java/"/>
                             <filename name="javax/"/>
                             <filename name="com/sun/javadoc/"/>
-                            <filename name="com/sun/mirror/"/>
                             <filename name="com/sun/source/"/>
                         </or>
                     </packageset>
@@ -983,6 +1132,16 @@
         <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
     </target>
 
+    <target name="-def-checkstyle" unless="checkstyle.defined"
+        depends="-check-checkstyle.home">
+        <taskdef resource="checkstyletask.properties">
+            <classpath>
+                <pathelement location="${checkstyle.home}/${checkstyle.name.version}-all.jar"/>
+            </classpath>
+        </taskdef>
+        <property name="checkstyle.defined" value="true"/>
+    </target>
+
     <target name="-def-findbugs" unless="findbugs.defined"
         depends="-check-findbugs.home,-check-target.java.home">
         <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
diff --git a/make/conf/checkstyle-emacs.xsl b/make/conf/checkstyle-emacs.xsl
new file mode 100644
index 0000000..836bb40
--- /dev/null
+++ b/make/conf/checkstyle-emacs.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="text" omit-xml-declaration="yes"/>
+
+<xsl:template match="/">
+Coding Style Check Results
+--------------------------
+Total files checked: <xsl:number level="any" value="count(descendant::file)"/>
+  Files with errors: <xsl:number level="any" value="count(descendant::file[error])"/>
+       Total errors: <xsl:number level="any" value="count(descendant::error)"/>
+    Errors per file: <xsl:number level="any" value="count(descendant::error) div count(descendant::file)"/>
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="file[error]">
+<xsl:apply-templates select="error"/>
+</xsl:template>
+
+<xsl:template match="error">
+<xsl:value-of select="../@name"/>:<xsl:value-of select="@line"/><xsl:text>: </xsl:text><xsl:value-of select="@message"/><xsl:text>
+</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/make/conf/checkstyle-langtools.xml b/make/conf/checkstyle-langtools.xml
new file mode 100644
index 0000000..148161a
--- /dev/null
+++ b/make/conf/checkstyle-langtools.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC
+          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+
+<!--
+   Checks for initial langtools code conventions, we are starting with
+   imports and import orders and this will grow to encompass other
+   violations over time. 
+-->
+
+<module name="Checker">
+    
+    <!-- Checks for whitespace. -->
+    <module name="FileTabCharacter">
+        <property name="fileExtensions" value=".java"/>
+    </module>
+
+    <!-- Miscellaneous other checks.                   -->
+    <module name="RegexpSingleline">
+        <property name="format" value="\s+$"/>
+        <property name="minimum" value="0"/>
+        <property name="maximum" value="0"/>
+        <property name="message" value="Line has trailing spaces."/>
+        <property name="fileExtensions" value=".java .html"/>
+    </module>
+
+    <module name="TreeWalker">
+    <!-- Checks for imports                              -->
+    <!--
+        <module name="AvoidStarImport"/>
+        <module name="IllegalImport"/>
+    -->
+        <module name="GenericWhitespace"/>
+        <module name="RedundantImport"/>
+        <module name="UnusedImports"/>  
+        <module name="ImportOrder">
+            <property name="groups" value="java, javax, org, com"/>
+            <property name="ordered" value="true"/>
+            <property name="separated" value="true"/>
+        </module>        
+        <module name="EmptyForInitializerPad">
+            <property name="option" value="space"/>
+        </module>
+        <module name="WhitespaceAfter"/>
+    </module>
+</module>
\ No newline at end of file
diff --git a/make/jprt.properties b/make/jprt.properties
index 79afe89..c0399ed 100644
--- a/make/jprt.properties
+++ b/make/jprt.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -25,8 +25,8 @@
 
 # Properties for jprt
 
-# Locked down to jdk7
-jprt.tools.default.release=jdk7
+# Locked down to jdk8
+jprt.tools.default.release=jdk8
 
 # The different build flavors we want, we override here so we just get these 2
 jprt.build.flavors=product,fastdebug
@@ -43,6 +43,22 @@ jprt.build.targets=                                             \
     windows_i586_5.1-{product|fastdebug},                       \
     windows_x64_5.2-{product|fastdebug}
 
+# Test target list (no fastdebug & limited c2 testing)
+jprt.my.test.target.set= 					\
+    solaris_sparc_5.10-product-c1-TESTNAME,                     \
+    solaris_sparcv9_5.10-product-c2-TESTNAME,                   \
+    solaris_i586_5.10-product-c1-TESTNAME,                      \
+    solaris_x64_5.10-product-c2-TESTNAME,                       \
+    linux_i586_2.6-product-{c1|c2}-TESTNAME,                    \
+    linux_x64_2.6-product-c2-TESTNAME,                          \
+    macosx_x64_10.7-product-c2-TESTNAME,                        \
+    windows_i586_5.1-product-c1-TESTNAME,                       \
+    windows_x64_5.2-product-c2-TESTNAME
+
+# Default test targets
+jprt.make.rule.test.targets=					\
+    ${jprt.my.test.target.set:TESTNAME=jtreg}
+
 # Directories to be excluded from the source bundles
 jprt.bundle.exclude.src.dirs=build dist webrev
 
diff --git a/make/netbeans/README b/make/netbeans/README
index 58cfec0..308e6af 100644
--- a/make/netbeans/README
+++ b/make/netbeans/README
@@ -7,7 +7,7 @@ edit, run, test and debug the tools in the OpenJDK langtools
 repository.
 
 The repository contains a number of tools:
-    apt, javac, javadoc and its doclets, javah and javap.
+    javac, javadoc and its doclets, javah and javap.
 
 Build Properties.
 
diff --git a/make/netbeans/langtools/build.xml b/make/netbeans/langtools/build.xml
index d7e8f37..dd2caf9 100644
--- a/make/netbeans/langtools/build.xml
+++ b/make/netbeans/langtools/build.xml
@@ -261,7 +261,8 @@
 
     <target name="-def-select-tool">
         <mkdir dir="${build.toolclasses.dir}"/>
-        <javac srcdir="${make.tools.dir}/SelectTool"
+        <javac srcdir="${make.tools.dir}"
+               includes="anttasks/SelectTool*"
                destdir="${build.toolclasses.dir}/"
                classpath="${ant.core.lib}"
                includeantruntime="false"
@@ -270,7 +271,7 @@
                    <compilerarg line="-Xlint"/>
         </javac>
         <taskdef name="select-tool"
-                 classname="SelectToolTask"
+                 classname="anttasks.SelectToolTask"
                  classpath="${build.toolclasses.dir}/"/>
     </target>
 
diff --git a/make/netbeans/langtools/nbproject/project.xml b/make/netbeans/langtools/nbproject/project.xml
index 3e1c631..710d523 100644
--- a/make/netbeans/langtools/nbproject/project.xml
+++ b/make/netbeans/langtools/nbproject/project.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
- Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2007, 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
@@ -29,15 +29,13 @@
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->
-
-<!DOCTYPE project [
-    <!ENTITY standard-ide-actions SYSTEM "standard-ide-actions.ent">
-    <!ENTITY standard-context-menu-items SYSTEM "standard-context-menu-items.ent">
-]>
 <project xmlns="http://www.netbeans.org/ns/project/1">
     <type>org.netbeans.modules.ant.freeform</type>
     <configuration>
         <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
+            <name>langtools</name>
+        </general-data>
+        <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
             <!-- Do not use Project Properties customizer when editing this file manually. -->
             <name>langtools</name>
             <properties>
@@ -49,11 +47,6 @@
                     <location>${root}</location>
                 </source-folder>
                 <source-folder>
-                    <label>Source files</label>
-                    <type>java</type>
-                    <location>${root}/src/share/classes</location>
-                </source-folder>
-                <source-folder>
                     <label>Test files</label>
                     <type>tests</type>
                     <location>${root}/test</location>
@@ -63,9 +56,169 @@
                     <type>build</type>
                     <location>${root}/make</location>
                 </source-folder>
+                <source-folder>
+                    <label>Source files</label>
+                    <type>java</type>
+                    <location>${root}/src/share/classes</location>
+                </source-folder>
+                <build-file>
+                    <location>${root}/build/classes</location>
+                </build-file>
             </folders>
             <ide-actions>
-                &standard-ide-actions;
+                <!--
+ Copyright (c) 2007, 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.
+-->
+                <!--
+ This file defines the standard actions accepted by langtools projects.
+ It is normally included as an entity into a project's project.xml file.
+
+ For information on these actions, see
+   - NetBeans: Setting Up Projects
+     at http://www.netbeans.org/kb/55/using-netbeans/project_setup.html
+   - NetBeans: Advanced Freeform Project Configuration
+     at http://www.netbeans.org/kb/41/freeform-config.html
+-->
+                <action name="build">
+                    <target>build</target>
+                </action>
+                <action name="clean">
+                    <target>clean</target>
+                </action>
+                <action name="rebuild">
+                    <target>clean</target>
+                    <target>build</target>
+                </action>
+                <action name="compile.single">
+                    <target>compile-single</target>
+                    <property name="srcdir">${root}/src/share/classes</property>
+                    <context>
+                        <property>includes</property>
+                        <folder>${root}/src/share/classes</folder>
+                        <pattern>\.java$</pattern>
+                        <format>relative-path</format>
+                        <arity>
+                            <separated-files>,</separated-files>
+                        </arity>
+                    </context>
+                </action>
+                <action name="run">
+                    <target>run</target>
+                </action>
+                <action name="run.single">
+                    <target>run-single</target>
+                    <context>
+                        <property>run.classname</property>
+                        <folder>${root}/src/share/classes</folder>
+                        <pattern>\.java$</pattern>
+                        <format>java-name</format>
+                        <arity>
+                            <one-file-only/>
+                        </arity>
+                    </context>
+                </action>
+                <!--
+ Note: NetBeans does not appear to support context menu items
+ on shell scripts :-(
+-->
+                <action name="run.single">
+                    <target>jtreg</target>
+                    <context>
+                        <property>jtreg.tests</property>
+                        <folder>${root}/test</folder>
+                        <pattern>\.(java|sh)$</pattern>
+                        <format>relative-path</format>
+                        <arity>
+                            <separated-files>,</separated-files>
+                        </arity>
+                    </context>
+                </action>
+                <action name="test">
+                    <target>jtreg</target>
+                </action>
+                <action name="debug">
+                    <target>debug</target>
+                </action>
+                <action name="debug.single">
+                    <target>debug-single</target>
+                    <context>
+                        <property>debug.classname</property>
+                        <folder>${root}/src/share/classes</folder>
+                        <pattern>\.java$</pattern>
+                        <format>java-name</format>
+                        <arity>
+                            <one-file-only/>
+                        </arity>
+                    </context>
+                </action>
+                <!--
+ Note: NetBeans does not appear to support context menu items
+ on shell scripts :-(
+-->
+                <action name="debug.single">
+                    <target>debug-jtreg</target>
+                    <context>
+                        <property>jtreg.tests</property>
+                        <folder>${root}/test</folder>
+                        <pattern>\.(java|sh)$</pattern>
+                        <format>relative-path</format>
+                        <arity>
+                            <one-file-only/>
+                        </arity>
+                    </context>
+                </action>
+                <action name="debug.fix">
+                    <target>debug-fix</target>
+                    <property name="srcdir">${root}/src/share/classes</property>
+                    <context>
+                        <property>class</property>
+                        <folder>${root}/src/share/classes</folder>
+                        <pattern>\.java$</pattern>
+                        <format>relative-path-noext</format>
+                        <arity>
+                            <one-file-only/>
+                        </arity>
+                    </context>
+                </action>
+                <action name="javadoc">
+                    <target>javadoc</target>
+                </action>
+                <action name="select-tool">
+                    <target>select-tool</target>
+                </action>
+                <action name="test-select-tool-1">
+                    <target>test-select-tool-1</target>
+                </action>
+                <action name="test-select-tool-2">
+                    <target>test-select-tool-2</target>
+                </action>
             </ide-actions>
             <export>
                 <type>folder</type>
@@ -92,16 +245,67 @@
                     </source-file>
                 </items>
                 <context-menu>
-                    &standard-context-menu-items;
+                    <!--
+ Copyright (c) 2007, 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.
+-->
+                    <!--
+ This file defines the actions that will appear on the project's context
+ menu, in the Projects viewer.
+ It is normally included as an entity into a project's project.xml file.
+
+ For information on these actions, see
+   - NetBeans: Setting Up Projects
+     at http://www.netbeans.org/kb/55/using-netbeans/project_setup.html
+   - NetBeans: Advanced Freeform Project Configuration
+     at http://www.netbeans.org/kb/41/freeform-config.html
+-->
+                    <ide-action name="select-tool"/>
+                    <separator/>
+                    <ide-action name="build"/>
+                    <ide-action name="rebuild"/>
+                    <ide-action name="clean"/>
+                    <ide-action name="javadoc"/>
+                    <separator/>
+                    <ide-action name="run"/>
+                    <ide-action name="debug"/>
+                    <separator/>
+                    <ide-action name="test"/>
                 </context-menu>
             </view>
             <subprojects/>
         </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
+        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
             <compilation-unit>
                 <package-root>${root}/src/share/classes</package-root>
                 <built-to>${root}/build/classes</built-to>
-                <source-level>1.5</source-level>  <!-- FIXME -->
+                <source-level>1.7</source-level>
             </compilation-unit>
         </java-data>
     </configuration>
diff --git a/make/netbeans/nb-javac/nbproject/build-impl.xml b/make/netbeans/nb-javac/nbproject/build-impl.xml
index d0aa3ef..49dcfc6 100644
--- a/make/netbeans/nb-javac/nbproject/build-impl.xml
+++ b/make/netbeans/nb-javac/nbproject/build-impl.xml
@@ -12,18 +12,18 @@ is divided into following sections:
   - execution
   - debugging
   - javadoc
-  - junit compilation
-  - junit execution
-  - junit debugging
+  - test compilation
+  - test execution
+  - test debugging
   - applet
   - cleanup
 
         -->
 <project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="nb-javac-impl">
-    <fail message="Please build using Ant 1.7.1 or higher.">
+    <fail message="Please build using Ant 1.8.0 or higher.">
         <condition>
             <not>
-                <antversion atleast="1.7.1"/>
+                <antversion atleast="1.8.0"/>
             </not>
         </condition>
     </fail>
@@ -54,6 +54,7 @@ is divided into following sections:
         <property file="nbproject/project.properties"/>
     </target>
     <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <property name="platform.java" value="${java.home}/bin/java"/>
         <available file="${manifest.file}" property="manifest.available"/>
         <condition property="splashscreen.available">
             <and>
@@ -71,58 +72,48 @@ is divided into following sections:
                 </not>
             </and>
         </condition>
-        <condition property="manifest.available+main.class">
+        <condition property="profile.available">
             <and>
-                <isset property="manifest.available"/>
-                <isset property="main.class.available"/>
+                <isset property="javac.profile"/>
+                <length length="0" string="${javac.profile}" when="greater"/>
+                <matches pattern="1\.[89](\..*)?" string="${javac.source}"/>
             </and>
         </condition>
+        <condition property="do.archive">
+            <not>
+                <istrue value="${jar.archive.disabled}"/>
+            </not>
+        </condition>
         <condition property="do.mkdist">
             <and>
+                <isset property="do.archive"/>
                 <isset property="libs.CopyLibs.classpath"/>
                 <not>
                     <istrue value="${mkdist.disabled}"/>
                 </not>
             </and>
         </condition>
-        <condition property="manifest.available+main.class+mkdist.available">
-            <and>
-                <istrue value="${manifest.available+main.class}"/>
-                <isset property="do.mkdist"/>
-            </and>
-        </condition>
-        <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
-            <and>
-                <istrue value="${manifest.available+main.class+mkdist.available}"/>
-                <istrue value="${splashscreen.available}"/>
-            </and>
-        </condition>
-        <condition property="do.archive">
-            <not>
-                <istrue value="${jar.archive.disabled}"/>
-            </not>
-        </condition>
         <condition property="do.archive+manifest.available">
             <and>
                 <isset property="manifest.available"/>
                 <istrue value="${do.archive}"/>
             </and>
         </condition>
-        <condition property="do.archive+manifest.available+main.class">
+        <condition property="do.archive+main.class.available">
             <and>
-                <istrue value="${manifest.available+main.class}"/>
+                <isset property="main.class.available"/>
                 <istrue value="${do.archive}"/>
             </and>
         </condition>
-        <condition property="do.archive+manifest.available+main.class+mkdist.available">
+        <condition property="do.archive+splashscreen.available">
             <and>
-                <istrue value="${manifest.available+main.class+mkdist.available}"/>
+                <isset property="splashscreen.available"/>
                 <istrue value="${do.archive}"/>
             </and>
         </condition>
-        <condition property="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available">
+        <condition property="do.archive+profile.available">
             <and>
-                <istrue value="${manifest.available+main.class+mkdist.available+splashscreen.available}"/>
+                <isset property="profile.available"/>
                 <istrue value="${do.archive}"/>
             </and>
         </condition>
@@ -149,6 +140,7 @@ is divided into following sections:
             </and>
         </condition>
         <property name="run.jvmargs" value=""/>
+        <property name="run.jvmargs.ide" value=""/>
         <property name="javac.compilerargs" value=""/>
         <property name="work.dir" value="${basedir}"/>
         <condition property="no.deps">
@@ -178,11 +170,50 @@ is divided into following sections:
         </condition>
         <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
         <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
-            <length length="0" string="${endorsed.classpath}" when="greater"/>
+            <and>
+                <isset property="endorsed.classpath"/>
+                <not>
+                    <equals arg1="${endorsed.classpath}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition else="" property="javac.profile.cmd.line.arg" value="-profile ${javac.profile}">
+            <isset property="profile.available"/>
         </condition>
-        <property name="javac.fork" value="false"/>
+        <condition else="false" property="jdkBug6558476">
+            <and>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
+            </and>
+        </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
         <property name="jar.index" value="false"/>
+        <property name="jar.index.metainf" value="${jar.index}"/>
+        <property name="copylibs.rebase" value="true"/>
         <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
+        <condition property="junit.available">
+            <or>
+                <available classname="org.junit.Test" classpath="${run.test.classpath}"/>
+                <available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
+            </or>
+        </condition>
+        <condition property="testng.available">
+            <available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
+        </condition>
+        <condition property="junit+testng.available">
+            <and>
+                <istrue value="${junit.available}"/>
+                <istrue value="${testng.available}"/>
+            </and>
+        </condition>
+        <condition else="testng" property="testng.mode" value="mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
+        <condition else="" property="testng.debug.mode" value="-mixed">
+            <istrue value="${junit+testng.available}"/>
+        </condition>
     </target>
     <target name="-post-init">
         <!-- Empty placeholder for easier customization. -->
@@ -236,6 +267,7 @@ is divided into following sections:
                         <path path="@{classpath}"/>
                     </classpath>
                     <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.profile.cmd.line.arg}"/>
                     <compilerarg line="${javac.compilerargs}"/>
                     <compilerarg value="-processorpath"/>
                     <compilerarg path="@{processorpath}:${empty.dir}"/>
@@ -275,6 +307,7 @@ is divided into following sections:
                         <path path="@{classpath}"/>
                     </classpath>
                     <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.profile.cmd.line.arg}"/>
                     <compilerarg line="${javac.compilerargs}"/>
                     <customize/>
                 </javac>
@@ -298,23 +331,74 @@ is divided into following sections:
             <attribute default="${build.classes.dir}" name="destdir"/>
             <sequential>
                 <fail unless="javac.includes">Must set javac.includes</fail>
-                <pathconvert pathsep="," property="javac.includes.binary">
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
                     <path>
                         <filelist dir="@{destdir}" files="${javac.includes}"/>
                     </path>
                     <globmapper from="*.java" to="*.class"/>
                 </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
                 <delete>
-                    <files includes="${javac.includes.binary}"/>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete>
+                    <fileset file="${javac.includesfile.binary}"/>
                 </delete>
             </sequential>
         </macrodef>
     </target>
-    <target name="-init-macrodef-junit">
+    <target if="${junit.available}" name="-init-macrodef-junit-init">
+        <condition else="false" property="nb.junit.batch" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <not>
+                    <isset property="test.method"/>
+                </not>
+            </and>
+        </condition>
+        <condition else="false" property="nb.junit.single" value="true">
+            <and>
+                <istrue value="${junit.available}"/>
+                <isset property="test.method"/>
+            </and>
+        </condition>
+    </target>
+    <target name="-init-test-properties">
+        <property name="test.binaryincludes" value="<nothing>"/>
+        <property name="test.binarytestincludes" value=""/>
+        <property name="test.binaryexcludes" value=""/>
+    </target>
+    <target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
         <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
             <attribute default="${includes}" name="includes"/>
             <attribute default="${excludes}" name="excludes"/>
             <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
             <sequential>
                 <property name="junit.forkmode" value="perTest"/>
                 <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
@@ -322,32 +406,277 @@ is divided into following sections:
                         <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
                         </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
                     </batchtest>
-                    <classpath>
-                        <path path="${run.test.classpath}"/>
-                    </classpath>
                     <syspropertyset>
                         <propertyref prefix="test-sys-prop."/>
                         <mapper from="test-sys-prop.*" to="*" type="glob"/>
                     </syspropertyset>
                     <formatter type="brief" usefile="false"/>
                     <formatter type="xml"/>
-                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
-                    <jvmarg line="${run.jvmargs}"/>
+                    <jvmarg value="-ea"/>
+                    <customize/>
                 </junit>
             </sequential>
         </macrodef>
     </target>
-    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
-    <target name="-profile-pre-init">
+    <target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
+    <target if="${testng.available}" name="-init-macrodef-testng">
+        <macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
+                    <isset property="test.method"/>
+                </condition>
+                <union id="test.set">
+                    <fileset dir="${test.test.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
+                        <filename name="@{testincludes}"/>
+                    </fileset>
+                </union>
+                <taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
+                <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="nb-javac" testname="TestNG tests" workingDir="${work.dir}">
+                    <xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
+                    <propertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </propertyset>
+                    <customize/>
+                </testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-test-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <echo>No tests executed.</echo>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
+        <macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:testng>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
+        <macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <sequential>
+                <j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${run.jvmargs}"/>
+                        <jvmarg line="${run.jvmargs.ide}"/>
+                    </customize>
+                </j2seproject3:test-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-test-properties" if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
+        <macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.test.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
+                            <filename name="${test.binarytestincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <customize/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
+        <macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <element implicit="true" name="customize" optional="true"/>
+            <sequential>
+                <j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize/>
+                </j2seproject3:junit-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target if="${testng.available}" name="-init-macrodef-testng-debug">
+        <macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element name="customize2" optional="true"/>
+            <sequential>
+                <condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
+                    <isset property="test.method"/>
+                </condition>
+                <condition else="-suitename nb-javac -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+                    <matches pattern=".*\.xml" string="@{testClass}"/>
+                </condition>
+                <delete dir="${build.test.results.dir}" quiet="true"/>
+                <mkdir dir="${build.test.results.dir}"/>
+                <j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">
+                    <customize>
+                        <customize2/>
+                        <jvmarg value="-ea"/>
+                        <arg line="${testng.debug.mode}"/>
+                        <arg line="-d ${build.test.results.dir}"/>
+                        <arg line="-listener org.testng.reporters.VerboseReporter"/>
+                        <arg line="${testng.cmd.args}"/>
+                    </customize>
+                </j2seproject3:debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
+        <macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <element implicit="true" name="customize2" optional="true"/>
+            <sequential>
+                <j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2/>
+                </j2seproject3:testng-debug>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
+                    <customize>
+                        <classpath>
+                            <path path="${run.test.classpath}"/>
+                        </classpath>
+                        <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                        <jvmarg line="${run.jvmargs}"/>
+                        <jvmarg line="${run.jvmargs.ide}"/>
+                    </customize>
+                </j2seproject3:test-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
+        <macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <attribute default="" name="testmethods"/>
+            <attribute default="${main.class}" name="testClass"/>
+            <attribute default="" name="testMethod"/>
+            <sequential>
+                <j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
+                    <customize2>
+                        <syspropertyset>
+                            <propertyref prefix="test-sys-prop."/>
+                            <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                        </syspropertyset>
+                    </customize2>
+                </j2seproject3:testng-debug-impl>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
+    <!--
+                pre NB7.2 profiling section; consider it deprecated
+            -->
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
+    <target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target name="-profile-post-init">
+    <target if="profiler.info.jvmargs.agent" name="-profile-post-init">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target name="-profile-init-macrodef-profile">
+    <target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">
         <macrodef name="resolve">
             <attribute name="name"/>
             <attribute name="value"/>
@@ -362,6 +691,7 @@ is divided into following sections:
                 <property environment="env"/>
                 <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
                 <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg value="${profiler.info.jvmargs.agent}"/>
                     <jvmarg line="${profiler.info.jvmargs}"/>
                     <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
@@ -378,10 +708,13 @@ is divided into following sections:
             </sequential>
         </macrodef>
     </target>
-    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">
         <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
         <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
     </target>
+    <!--
+                end of pre NB7.2 profiling section
+            -->
     <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
         <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
             <attribute default="${main.class}" name="name"/>
@@ -439,6 +772,7 @@ is divided into following sections:
                     <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
                     <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
                     <jvmarg line="${run.jvmargs}"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
                     <classpath>
                         <path path="@{classpath}"/>
                     </classpath>
@@ -455,6 +789,7 @@ is divided into following sections:
         <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
             <attribute default="${main.class}" name="classname"/>
             <attribute default="${run.classpath}" name="classpath"/>
+            <attribute default="jvm" name="jvm"/>
             <element name="customize" optional="true"/>
             <sequential>
                 <java classname="@{classname}" dir="${work.dir}" fork="true">
@@ -462,6 +797,7 @@ is divided into following sections:
                     <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
                     <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
                     <jvmarg line="${run.jvmargs}"/>
+                    <jvmarg line="${run.jvmargs.ide}"/>
                     <classpath>
                         <path path="@{classpath}"/>
                     </classpath>
@@ -476,6 +812,7 @@ is divided into following sections:
     </target>
     <target name="-init-macrodef-copylibs">
         <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${manifest.file}" name="manifest"/>
             <element name="customize" optional="true"/>
             <sequential>
                 <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
@@ -487,12 +824,15 @@ is divided into following sections:
                     <path path="${run.classpath.without.build.classes.dir}"/>
                     <chainedmapper>
                         <flattenmapper/>
+                        <filtermapper>
+                            <replacestring from=" " to="%20"/>
+                        </filtermapper>
                         <globmapper from="*" to="lib/*"/>
                     </chainedmapper>
                 </pathconvert>
                 <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
-                <copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
-                    <fileset dir="${build.classes.dir}"/>
+                <copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
                     <manifest>
                         <attribute name="Class-Path" value="${jar.classpath}"/>
                         <customize/>
@@ -504,7 +844,7 @@ is divided into following sections:
     <target name="-init-presetdef-jar">
         <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
             <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
-                <j2seproject1:fileset dir="${build.classes.dir}"/>
+                <j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
             </jar>
         </presetdef>
     </target>
@@ -532,7 +872,7 @@ is divided into following sections:
     <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
         <property name="ap.cmd.line.internal" value=""/>
     </target>
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
     <!--
                 ===================
                 COMPILATION SECTION
@@ -585,7 +925,7 @@ is divided into following sections:
     <target if="has.persistence.xml" name="-copy-persistence-xml">
         <mkdir dir="${build.classes.dir}/META-INF"/>
         <copy todir="${build.classes.dir}/META-INF">
-            <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
         </copy>
     </target>
     <target name="-post-compile">
@@ -620,56 +960,67 @@ is divided into following sections:
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available">
-        <j2seproject1:jar/>
+    <target depends="init" if="do.archive" name="-do-jar-create-manifest" unless="manifest.available">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <touch file="${tmp.manifest.file}" verbose="false"/>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
-        <j2seproject1:jar manifest="${manifest.file}"/>
+    <target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
-        <j2seproject1:jar manifest="${manifest.file}">
-            <j2seproject1:manifest>
-                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
-            </j2seproject1:manifest>
-        </j2seproject1:jar>
-        <echo>To run this application from the command line without Ant, try:</echo>
-        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
-        <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <pathconvert property="run.classpath.with.dist.jar">
-            <path path="${run.classpath}"/>
-            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
-        </pathconvert>
-        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+        </manifest>
+    </target>
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Profile" value="${javac.profile}"/>
+        </manifest>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
+    <target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-set-splashscreen">
         <basename file="${application.splash}" property="splashscreen.basename"/>
         <mkdir dir="${build.classes.dir}/META-INF"/>
         <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
-        <j2seproject3:copylibs>
-            <customize>
-                <attribute name="Main-Class" value="${main.class}"/>
-                <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
-            </customize>
-        </j2seproject3:copylibs>
-        <echo>To run this application from the command line without Ant, try:</echo>
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+        </manifest>
+    </target>
+    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.mkdist" name="-do-jar-copylibs">
+        <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <echo>java -jar "${dist.jar.resolved}"</echo>
+        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
-        <j2seproject3:copylibs>
-            <customize>
-                <attribute name="Main-Class" value="${main.class}"/>
-            </customize>
-        </j2seproject3:copylibs>
-        <echo>To run this application from the command line without Ant, try:</echo>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen" if="do.archive" name="-do-jar-jar" unless="do.mkdist">
+        <j2seproject1:jar manifest="${tmp.manifest.file}"/>
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <echo>java -jar "${dist.jar.resolved}"</echo>
+        <pathconvert property="run.classpath.with.dist.jar">
+            <path path="${run.classpath}"/>
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+        </pathconvert>
+        <condition else="" property="jar.usage.message" value="To run this application from the command line without Ant, try:${line.separator}${platform.java} -cp ${run.classpath.with.dist.jar} ${main.class}">
+            <isset property="main.class.available"/>
+        </condition>
+        <condition else="debug" property="jar.usage.level" value="info">
+            <isset property="main.class.available"/>
+        </condition>
+        <echo level="${jar.usage.level}" message="${jar.usage.message}"/>
     </target>
+    <target depends="-do-jar-copylibs" if="do.archive" name="-do-jar-delete-manifest">
+        <delete>
+            <fileset file="${tmp.manifest.file}"/>
+        </delete>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-jar,-do-jar-delete-manifest" name="-do-jar-without-libraries"/>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-create-manifest,-do-jar-copy-manifest,-do-jar-set-mainclass,-do-jar-set-profile,-do-jar-set-splashscreen,-do-jar-copylibs,-do-jar-delete-manifest" name="-do-jar-with-libraries"/>
     <target name="-post-jar">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries-and-splashscreen,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
+    <target depends="init,compile,-pre-jar,-do-jar-without-libraries,-do-jar-with-libraries,-post-jar" name="-do-jar"/>
+    <target depends="init,compile,-pre-jar,-do-jar,-post-jar" description="Build JAR." name="jar"/>
     <!--
                 =================
                 EXECUTION SECTION
@@ -739,7 +1090,11 @@ is divided into following sections:
                 PROFILING SECTION
                 =================
             -->
-    <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
+    <!--
+                pre NB7.2 profiler integration
+            -->
+    <target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
         <nbprofiledirect>
             <classpath>
                 <path path="${run.classpath}"/>
@@ -747,8 +1102,9 @@ is divided into following sections:
         </nbprofiledirect>
         <profile/>
     </target>
-    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
+    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">
         <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
         <nbprofiledirect>
             <classpath>
                 <path path="${run.classpath}"/>
@@ -756,12 +1112,8 @@ is divided into following sections:
         </nbprofiledirect>
         <profile classname="${profile.class}"/>
     </target>
-    <!--
-                =========================
-                APPLET PROFILING  SECTION
-                =========================
-            -->
-    <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
+    <target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
         <nbprofiledirect>
             <classpath>
                 <path path="${run.classpath}"/>
@@ -773,12 +1125,8 @@ is divided into following sections:
             </customize>
         </profile>
     </target>
-    <!--
-                =========================
-                TESTS PROFILING  SECTION
-                =========================
-            -->
-    <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
+    <target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
+        <fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
         <nbprofiledirect>
             <classpath>
                 <path path="${run.test.classpath}"/>
@@ -801,22 +1149,68 @@ is divided into following sections:
         </junit>
     </target>
     <!--
+                end of pre NB72 profiling section
+            -->
+    <target if="netbeans.home" name="-profile-check">
+        <condition property="profiler.configured">
+            <or>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
+                <contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
+            </or>
+        </condition>
+    </target>
+    <target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
+        <startprofiler/>
+        <antcall target="run"/>
+    </target>
+    <target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <startprofiler/>
+        <antcall target="run-single"/>
+    </target>
+    <target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>
+    <target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <startprofiler/>
+        <antcall target="test-single"/>
+    </target>
+    <target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <startprofiler/>
+        <antcal target="run-test-with-main"/>
+    </target>
+    <target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <startprofiler/>
+        <antcall target="run-applet"/>
+    </target>
+    <!--
                 ===============
                 JAVADOC SECTION
                 ===============
             -->
     <target depends="init" if="have.sources" name="-javadoc-build">
         <mkdir dir="${dist.javadoc.dir}"/>
+        <condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
+            <and>
+                <isset property="endorsed.classpath.cmd.line.arg"/>
+                <not>
+                    <equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
+                </not>
+            </and>
+        </condition>
         <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
             <classpath>
                 <path path="${javac.classpath}"/>
             </classpath>
-            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+            <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
                 <filename name="**/*.java"/>
             </fileset>
             <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
                 <include name="**/*.java"/>
+                <exclude name="*.java"/>
             </fileset>
+            <arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
         </javadoc>
         <copy todir="${dist.javadoc.dir}">
             <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
@@ -833,7 +1227,7 @@ is divided into following sections:
     <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
     <!--
                 =========================
-                JUNIT COMPILATION SECTION
+                TEST COMPILATION SECTION
                 =========================
             -->
     <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
@@ -846,7 +1240,7 @@ is divided into following sections:
     <target if="do.depend.true" name="-compile-test-depend">
         <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.test.dir}"/>
     </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
         <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.test.dir}"/>
         <copy todir="${build.test.classes.dir}">
             <fileset dir="${test.test.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
@@ -861,7 +1255,7 @@ is divided into following sections:
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
         <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
         <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
         <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.test.dir}" srcdir="${test.test.dir}"/>
@@ -876,14 +1270,14 @@ is divided into following sections:
     <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
     <!--
                 =======================
-                JUNIT EXECUTION SECTION
+                TEST EXECUTION SECTION
                 =======================
             -->
     <target depends="init" if="have.tests" name="-pre-test-run">
         <mkdir dir="${build.test.results.dir}"/>
     </target>
     <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
-        <j2seproject3:junit testincludes="**/*Test.java"/>
+        <j2seproject3:test testincludes="**/*Test.java"/>
     </target>
     <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
         <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
@@ -896,39 +1290,40 @@ is divided into following sections:
     </target>
     <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
         <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
-        <j2seproject3:junit excludes="" includes="${test.includes}"/>
+        <j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
     </target>
     <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
         <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
     </target>
     <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
+        <fail unless="test.class">Must select some files in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
     <!--
                 =======================
-                JUNIT DEBUGGING SECTION
+                TEST DEBUGGING SECTION
                 =======================
             -->
-    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
         <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
-        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
-        <delete file="${test.report.file}"/>
-        <mkdir dir="${build.test.results.dir}"/>
-        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
-            <customize>
-                <syspropertyset>
-                    <propertyref prefix="test-sys-prop."/>
-                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
-                </syspropertyset>
-                <arg value="${test.class}"/>
-                <arg value="showoutput=true"/>
-                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
-                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
-            </customize>
-        </j2seproject3:debug>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
+        <j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
     </target>
     <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
         <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
     </target>
     <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
     <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
         <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
     </target>
@@ -993,9 +1388,12 @@ is divided into following sections:
     <target name="-check-call-dep">
         <property file="${call.built.properties}" prefix="already.built."/>
         <condition property="should.call.dep">
-            <not>
-                <isset property="already.built.${call.subproject}"/>
-            </not>
+            <and>
+                <not>
+                    <isset property="already.built.${call.subproject}"/>
+                </not>
+                <available file="${call.script}"/>
+            </and>
         </condition>
     </target>
     <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
diff --git a/make/netbeans/nb-javac/nbproject/genfiles.properties b/make/netbeans/nb-javac/nbproject/genfiles.properties
index c292f4f..5f44b25 100644
--- a/make/netbeans/nb-javac/nbproject/genfiles.properties
+++ b/make/netbeans/nb-javac/nbproject/genfiles.properties
@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=be360661
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=0dbef76c
-nbproject/build-impl.xml.script.CRC32=4cd331df
-nbproject/build-impl.xml.stylesheet.CRC32=e9ff88b2 at 1.39.0.45
+nbproject/build-impl.xml.script.CRC32=732cb6b1
+nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7 at 1.68.0.46
diff --git a/make/netbeans/nb-javac/nbproject/project.properties b/make/netbeans/nb-javac/nbproject/project.properties
index 26cb6b1..4921651 100644
--- a/make/netbeans/nb-javac/nbproject/project.properties
+++ b/make/netbeans/nb-javac/nbproject/project.properties
@@ -23,7 +23,7 @@ dist.dir=dist
 dist.jar=${dist.dir}/nb-javac.jar
 dist.javadoc.dir=${dist.dir}/javadoc
 endorsed.classpath=
-excludes=com/sun/mirror/,com/sun/tools/apt/,com/sun/tools/doclets/,com/sun/tools/javah/,com/sun/tools/javac/sym/,com/sun/tools/javac/nio/,sun/
+excludes=com/sun/mirror/,com/sun/tools/apt/,com/sun/tools/doclets/,com/sun/tools/javah/,com/sun/tools/javac/sym/,com/sun/tools/javac/nio/,sun/,com/sun/tools/jdeps/,com/sun/tools/sjavac/
 file.reference.share-classes=../../../src/share/classes
 includes=**
 jar.archive.disabled=${jnlp.enabled}
@@ -35,8 +35,8 @@ javac.compilerargs=-Xbootclasspath/p:${basedir}/dist/javac-api.jar
 javac.deprecation=false
 javac.processorpath=\
     ${javac.classpath}
-javac.source=1.5
-javac.target=1.5
+javac.source=1.7
+javac.target=1.7
 javac.test.classpath=\
     ${javac.classpath}:\
     ${build.classes.dir}:\
diff --git a/make/netbeans/nb-javac/test/com/sun/source/tree/CompilationUnitTreeTest.java b/make/netbeans/nb-javac/test/com/sun/source/tree/CompilationUnitTreeTest.java
index 1287d37..dfbbecc 100644
--- a/make/netbeans/nb-javac/test/com/sun/source/tree/CompilationUnitTreeTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/source/tree/CompilationUnitTreeTest.java
@@ -26,7 +26,6 @@
 package com.sun.source.tree;
 
 import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.parser.DocCommentScanner;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Arrays;
diff --git a/make/netbeans/nb-javac/test/com/sun/source/tree/TreeTest.java b/make/netbeans/nb-javac/test/com/sun/source/tree/TreeTest.java
index 1c7c36b..af2df3c 100644
--- a/make/netbeans/nb-javac/test/com/sun/source/tree/TreeTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/source/tree/TreeTest.java
@@ -26,7 +26,6 @@
 package com.sun.source.tree;
 
 import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.parser.DocCommentScanner;
 import java.io.IOException;
 import java.net.URI;
 import java.util.Arrays;
@@ -70,5 +69,19 @@ public class TreeTest extends TestCase {
 
         assertEquals("večerníček", cut.getPackageName().toString());
     }
+    
+    public void testArrayWithInitializerToString() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package večerníček; class A { private String[] arr = new String[] { };}";
+
+        JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath), null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        assertEquals("package večerníček;\n\nclass A {\n    private String[] arr = new String[]{};\n}", cut.toString());
+    }
 
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/source/util/TreesTest.java b/make/netbeans/nb-javac/test/com/sun/source/util/TreesTest.java
index 8bbac12..e736cb8 100644
--- a/make/netbeans/nb-javac/test/com/sun/source/util/TreesTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/source/util/TreesTest.java
@@ -27,6 +27,7 @@ package com.sun.source.util;
 
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberReferenceTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
@@ -40,6 +41,7 @@ import java.util.Arrays;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.TypeElement;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
@@ -229,4 +231,70 @@ public class TreesTest extends TestCase {
 
         assertTrue(found.get());
     }
+
+    public void XtestStartPositionForBrokenLambdaParameter() throws IOException {
+        final String code = "package test;\n" +
+                  "public class Test {\n" +
+                  "    public Test() {\n" +
+                  "        Object o = (str -> {System.err.println(str);});\n" +
+                  "    }\n" +
+                  "}\n";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        final JavacTask ct = (JavacTask)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath, "-XDide"), null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ct.analyze();
+
+        final Trees trees = JavacTrees.instance(ct);
+        final AtomicBoolean found = new AtomicBoolean();
+
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitVariable(VariableTree node, Void p) {
+                if ("str".equals(node.getName().toString())) {
+                    assertEquals(74, trees.getSourcePositions().getStartPosition(cut, node));
+                    found.set(true);
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+
+        assertTrue(found.get());
+    }
+
+    public void testGetElementForMemberReference() throws IOException {
+        final String code = "package test;\n" +
+                  "public class Test {\n" +
+                  "    private static void method() {\n" +
+                  "        javax.swing.SwingUtilities.invokeLater(Test::method);\n" +
+                  "    }\n" +
+                  "}\n";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        final JavacTask ct = (JavacTask)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath, "-source", "1.8"), null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ct.analyze();
+
+        final Trees trees = JavacTrees.instance(ct);
+        final AtomicBoolean found = new AtomicBoolean();
+
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
+                Element el = trees.getElement(getCurrentPath());
+                assertNotNull(el);
+                assertEquals(ElementKind.METHOD, el.getKind());
+                assertEquals("method", el.getSimpleName().toString());
+                assertEquals("test.Test", ((TypeElement) el.getEnclosingElement()).getQualifiedName().toString());
+                found.set(true);
+                return super.visitMemberReference(node, p);
+            }
+        }.scan(cut, null);
+
+        assertTrue(found.get());
+    }
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/code/FlagsTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/code/FlagsTest.java
index e2333e4..e82ff30 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/code/FlagsTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/code/FlagsTest.java
@@ -43,7 +43,7 @@ public class FlagsTest extends TestCase {
         super(testName);
     }
 
-    private static final Set<String> ignoredFields = new HashSet<String>(Arrays.asList("ACC_SUPER", "ACC_BRIDGE", "ACC_VARARGS"));
+    private static final Set<String> ignoredFields = new HashSet<String>(Arrays.asList("ACC_SUPER", "ACC_BRIDGE", "ACC_VARARGS", "ACC_DEFENDER", "BAD_OVERRIDE"));
     public void testCheckFlagsNotClashing() throws Exception {
         Map<Long, String> value2Name = new HashMap<Long, String>();
 
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/code/TypesTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/code/TypesTest.java
index e203b83..729ed3c 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/code/TypesTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/code/TypesTest.java
@@ -108,5 +108,23 @@ public class TypesTest extends TestCase {
             }            
         }.scan(tree, null);
     }
+    
+    public void testDuplicateTest() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        String code = "class Test { abstract void t(); }";
+        final JavacTask ct = (JavacTask) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-source", "1.8", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(new MyFileObject(code), new MyFileObject(code)));
+        ct.analyze();
+    }
+    
+    public void testTypeVarBOT() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        String code = "import java.util.Comparator; public class Test<E> { public static <T extends Comparable<? super T>> Comparator<T> naturalOrder() { return null; } public void t() { Object o = (Comparator<? super E>) naturalOrder(); } }";
+        final JavacTask ct = (JavacTask) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-source", "1.8", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(new MyFileObject(code), new MyFileObject(code)));
+        ct.analyze();
+    }
 
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/AttrTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/AttrTest.java
index 620d68a..d416e1d 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/AttrTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/AttrTest.java
@@ -25,23 +25,49 @@
 package com.sun.tools.javac.comp;
 
 import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.LambdaExpressionTree;
+import com.sun.source.tree.LiteralTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.NewClassTree;
+import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreePath;
 import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.TreeScanner;
 import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacScope;
 import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCLambda;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
+import javax.tools.FileObject;
+import javax.tools.ForwardingJavaFileManager;
 import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
 import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
 import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
 import junit.framework.TestCase;
 
 /**
@@ -288,7 +314,7 @@ public class AttrTest extends TestCase {
             diagnostics.add(d.getSource().getName() + ":" + d.getStartPosition() + "-" + d.getEndPosition() + ":" + d.getCode());
         }
         
-        assertEquals(new HashSet<String>(Arrays.asList("/Use.java:93-104:compiler.err.cant.apply.diamond.1")), diagnostics);
+        assertEquals(new HashSet<String>(Arrays.asList("/Use.java:93-104:compiler.err.cant.apply.diamond.1", "/Use.java:89-110:compiler.err.cant.resolve.args")), diagnostics);
     }
 
     public void testErrorConstructor1() throws IOException {
@@ -311,4 +337,274 @@ public class AttrTest extends TestCase {
         
         assertEquals(new HashSet<String>(Arrays.asList("/API.java:44-49:compiler.err.cant.resolve.location", "/Use.java:64-77:compiler.err.type.error")), diagnostics);
     }
+
+    public void testLambda1() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; public class Test { public static void main(String[] args) { Task<String> t = (String c) -> { System.err.println(\"Lambda!\"); return ; }; } public interface Task<C> { public void run(C c); } }";
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, dc, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        ct.analyze();
+
+        assertEquals(dc.getDiagnostics().toString(), 0, dc.getDiagnostics().size());
+    }
+
+    public void testLambda2() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; public class Test { Task<String> t = (String c) -> { System.err.println(\"Lambda!\"); return ; }; public interface Task<C> { public void run(C c); } }";
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, dc, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        ct.analyze();
+
+        assertEquals(dc.getDiagnostics().toString(), 0, dc.getDiagnostics().size());
+    }
+    
+    public void testNonVoidReturnType() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; public class Test { private void t() { r(() -> { return 1; }); } private int r(Task t) { return t.run(); } public interface Task { public int run(); } }";
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, dc, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        ct.analyze();
+
+        assertEquals(dc.getDiagnostics().toString(), 0, dc.getDiagnostics().size());
+    }
+    
+    public void testBreakAttrDuringLambdaAttribution() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; public class Test { public void t(Comparable c) { } }";
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, dc, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        final JavacScope[] scope = new JavacScope[1];
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitMethod(MethodTree node, Void p) {
+                if (node.getName().contentEquals("t"))
+                    scope[0] = JavacTrees.instance(ct.getContext()).getScope(new TreePath(getCurrentPath(), node.getBody()));
+                return super.visitMethod(node, p); //To change body of generated methods, choose Tools | Templates.
+            }
+        }.scan(cut, null);
+        
+        JCTree.JCStatement statement = ct.parseStatement("t((other) -> {return 0;})", new SourcePositions[1], new DiagnosticCollector<JavaFileObject>());
+        
+        final JCTree[] attributeTo = new JCTree[1];
+        final JCLambda[] lambdaTree = new JCLambda[1];
+        
+        new TreeScanner<Void, Void>() {
+            @Override public Void visitVariable(VariableTree node, Void p) {
+                attributeTo[0] = (JCTree) node;
+                return super.visitVariable(node, p); //To change body of generated methods, choose Tools | Templates.
+            }
+
+            @Override
+            public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
+                lambdaTree[0] = (JCLambda) node;
+                return super.visitLambdaExpression(node, p); //To change body of generated methods, choose Tools | Templates.
+            }            
+        }.scan(statement, null);
+                
+        ct.attributeTreeTo(statement, scope[0].getEnv(), attributeTo[0]);
+        assertNotNull(lambdaTree[0].type);
+    }
+
+    public void testCheckMethodNPE() throws Exception {
+        String code = "public class Test { class Inner { Inner(int i) {} } public static void main(String[] args) { int i = 1; Test c = null; c.new Inner(i++) {}; } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitNewClass(NewClassTree node, Void p) {
+                assertNotNull(node.getEnclosingExpression());
+                assertEquals(1, node.getArguments().size());
+                return super.visitNewClass(node, p);
+            }
+        }.scan(cut, null);
+        
+        ct.generate(); //verify no exceptions during generate
+    }
+    
+    public void test208454() throws Exception {
+        String code = "public class Test { public static void main(String[] args) { String.new Runnable() { public void run() {} }; } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void scan(Tree tree, Void p) {
+                if (tree == null) return null;
+                
+                TreePath path = new TreePath(getCurrentPath(), tree);
+                
+                Trees.instance(ct).getScope(path);
+                return super.scan(tree, p);
+            }
+        }.scan(cut, null);
+        
+        ct.generate(); //verify no exceptions during generate
+    }
+
+    public void testNewClassWithEnclosingNoAnonymous() throws Exception {
+        String code = "public class Test { class Inner { Inner(int i) {} } public static void main(String[] args) { int i = 1; Test c = null; c.new Inner(i++); } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitNewClass(NewClassTree node, Void p) {
+                assertNotNull(node.getEnclosingExpression());
+                assertEquals(1, node.getArguments().size());
+                return super.visitNewClass(node, p);
+            }
+        }.scan(cut, null);
+        
+        ct.generate(); //verify no exceptions during generate
+    }
+    
+    public void testNewClassWithoutEnclosingAnonymous() throws Exception {
+        String code = "public class Test { class Inner { Inner(int i) {} } public static void main(String[] args) { int i = 1; new Inner(i++) {}; } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitNewClass(NewClassTree node, Void p) {
+                assertNull(node.getEnclosingExpression());
+                assertEquals(1, node.getArguments().size());
+                return super.visitNewClass(node, p);
+            }
+        }.scan(cut, null);
+        
+        ct.generate(); //verify no exceptions during generate
+    }
+    
+    public void testNewClassWithoutEnclosingNoAnonymous() throws Exception {
+        String code = "public class Test { class Inner { Inner(int i) {} } public static void main(String[] args) { int i = 1; new Inner(i++); } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitNewClass(NewClassTree node, Void p) {
+                assertNull(node.getEnclosingExpression());
+                assertEquals(1, node.getArguments().size());
+                return super.visitNewClass(node, p);
+            }
+        }.scan(cut, null);
+        
+        ct.generate(); //verify no exceptions during generate
+    }
+
+    public void testNPEForEmptyTargetOfTypeAnnotation() throws Exception {
+        String code = "class Test { private void t(@NonNull String a) {} } @java.lang.annotation.Target() @interface NonNull { }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDshouldStopPolicy=FLOW"), null, Arrays.asList(new MyFileObject(code)));
+        
+        ct.analyze();
+    }
+    
+    public void testAssignmentToError() throws Exception {
+        String code = "public class Test { public static void main(String[] args) { bbb = 0; } }";
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+        
+        JavaFileManager fm = new MemoryOutputJFM(tool.getStandardFileManager(null, null, null));
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        final Trees trees = Trees.instance(ct);
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        
+        ct.analyze();
+        
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitLiteral(LiteralTree node, Void p) {
+                TypeMirror type = trees.getTypeMirror(getCurrentPath());
+                
+                assertNotNull(type);
+                assertEquals(TypeKind.INT, type.getKind());
+                
+                return super.visitLiteral(node, p);
+            }
+        }.scan(cut, null);
+    }
+    private static class MemoryOutputJFM extends ForwardingJavaFileManager<StandardJavaFileManager> {
+
+        private final Map<String, byte[]> writtenClasses = new HashMap<String, byte[]>();
+        
+        public MemoryOutputJFM(StandardJavaFileManager m) {
+            super(m);
+        }
+
+        @Override
+        public JavaFileObject getJavaFileForOutput(Location location, final String className, Kind kind, FileObject sibling) throws IOException {
+            if (location.isOutputLocation() && kind == Kind.CLASS) {
+                return new SimpleJavaFileObject(URI.create("myfo:/" + className), kind) {
+                    @Override
+                    public OutputStream openOutputStream() throws IOException {
+                        return new ByteArrayOutputStream() {
+                            @Override public void close() throws IOException {
+                                super.close();
+                                writtenClasses.put(className, toByteArray());
+                            }
+                        };
+                    }
+                };
+            } else {
+                return super.getJavaFileForOutput(location, className, kind, sibling);
+            }
+        }
+        
+    }
+
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/FlowTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/FlowTest.java
index 6795fd9..f716298 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/FlowTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/FlowTest.java
@@ -196,4 +196,45 @@ public class FlowTest extends TestCase {
         assertNotNull("Must run on JDK7 with ARM", ct.getElements().getTypeElement("java.lang.AutoCloseable"));
         ct.analyze();
     }
+
+    public void testReturnInInitializer() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test;\n" +
+                      "class Test{\n" +
+                      "    {\n" +
+                      "        return ;\n" +
+                      "    }\n" +
+                      "}";
+
+        DiagnosticCollector<JavaFileObject> c = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, c, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDshouldStopPolicy=FLOW"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ct.analyze();
+    }
+    
+    public void testBreakContinueUnresolvedTarget() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test;\n" +
+                      "class Test{\n" +
+                      "    private void test() {\n" +
+                      "        while (true) {\n" +
+                      "            break undef;\n" +
+                      "        }\n" +
+                      "    }\n" +
+                      "}";
+
+        DiagnosticCollector<JavaFileObject> c = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, c, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDshouldStopPolicy=FLOW"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ct.analyze();
+    }
+    
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/MemberEnterTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/MemberEnterTest.java
index 23f66db..b90baf1 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/MemberEnterTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/comp/MemberEnterTest.java
@@ -32,11 +32,13 @@ import com.sun.source.util.TreePathScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import global.AnnotationProcessingTest;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import javax.tools.DiagnosticCollector;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
@@ -116,4 +118,15 @@ public class MemberEnterTest extends TestCase {
         assertEquals(3, found[0]);
     }
 
+    public void testVeryBrokenLambdaNoException() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; public class Test { private void t() { Iterable<Integer> map = null; Integer reduce = map.reduce(0, (o, t) -); } }";
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        final JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, dc, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDshouldStopPolicy=FLOW"), null, Arrays.asList(new com.sun.tools.javac.comp.AttrTest.MyFileObject(code)));
+        ct.analyze();
+    }
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/jvm/ClassReaderTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/jvm/ClassReaderTest.java
index 662f8a4..6c6a6fd 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/jvm/ClassReaderTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/jvm/ClassReaderTest.java
@@ -28,13 +28,19 @@ package com.sun.tools.javac.jvm;
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Set;
 import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+import javax.tools.FileObject;
 import javax.tools.ForwardingJavaFileManager;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileManager;
@@ -123,6 +129,23 @@ public class ClassReaderTest extends TestCase {
         assertNotNull(v48gen);
         assertEquals(1, v48gen.getTypeParameters().size());
     }
+    
+    public void testMethodParamAnnotations() throws Exception {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        JFM fileManager = new JFM(tool.getStandardFileManager(null, null, null));
+        JavacTask ct = (JavacTask)tool.getTask(null, fileManager, null, Arrays.asList("-bootclasspath",  bootPath, "-XDide"), null, Arrays.<JavaFileObject>asList(new SourceFileObject("public class Test { public static void t(@Deprecated int p) { } }")));
+
+        ct.generate();
+        
+        JFM readingFileManager = new JFM(tool.getStandardFileManager(null, null, null), new ClassJFO(new URI("mem://Test.class"), "Test", 0, fileManager.writtenClasses.get("Test")));
+        JavacTask readCT = (JavacTask)tool.getTask(null, readingFileManager, null, Arrays.asList("-bootclasspath",  bootPath, "-XDide"), null, null);
+        TypeElement test = readCT.getElements().getTypeElement("Test");
+        
+        assertNotNull(ElementFilter.methodsIn(test.getEnclosedElements()).get(0).getParameters().get(0).getAnnotation(Deprecated.class));
+    }
 
     private static final class JFM extends ForwardingJavaFileManager<JavaFileManager> {
 
@@ -152,17 +175,43 @@ public class ClassReaderTest extends TestCase {
             return super.inferBinaryName(location, file);
         }
 
+        private final Map<String, byte[]> writtenClasses = new HashMap<String, byte[]>();
+        
+        @Override
+        public JavaFileObject getJavaFileForOutput(Location location, final String className, Kind kind, FileObject sibling) throws IOException {
+            if (location.isOutputLocation() && kind == Kind.CLASS) {
+                return new SimpleJavaFileObject(URI.create("myfo:/" + className), kind) {
+                    @Override
+                    public OutputStream openOutputStream() throws IOException {
+                        return new ByteArrayOutputStream() {
+                            @Override public void close() throws IOException {
+                                super.close();
+                                writtenClasses.put(className, toByteArray());
+                            }
+                        };
+                    }
+                };
+            } else {
+                return super.getJavaFileForOutput(location, className, kind, sibling);
+            }
+        }
     }
 
     private static final class ClassJFO extends SimpleJavaFileObject {
 
         private final String binaryName;
         private final long lastModified;
+        private final byte[] data;
 
         public ClassJFO(URI uri, String binaryName, long lastModified) {
+            this(uri, binaryName, lastModified, null);
+        }
+        
+        public ClassJFO(URI uri, String binaryName, long lastModified, byte[] data) {
             super(uri, Kind.CLASS);
             this.binaryName = binaryName;
             this.lastModified = lastModified;
+            this.data = data;
         }
 
         public static final ClassJFO create(String name, String binName, long lastModified) throws URISyntaxException {
@@ -171,7 +220,7 @@ public class ClassReaderTest extends TestCase {
 
         @Override
         public InputStream openInputStream() throws IOException {
-            return uri.toURL().openStream();
+            return data != null ? new ByteArrayInputStream(data) : uri.toURL().openStream();
         }
 
         @Override
@@ -181,4 +230,18 @@ public class ClassReaderTest extends TestCase {
 
     }
 
+    private static class SourceFileObject extends SimpleJavaFileObject {
+        private String text;
+        public SourceFileObject(String text) {
+            this("Test", text);
+        }
+        public SourceFileObject(String name, String text) {
+            super(URI.create("myfo:/" + name + ".java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
 }
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/DocCommentParserTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/DocCommentParserTest.java
new file mode 100644
index 0000000..c262264
--- /dev/null
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/DocCommentParserTest.java
@@ -0,0 +1,157 @@
+package com.sun.tools.javac.parser;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.DocSourcePositions;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author lahvac
+ */
+public class DocCommentParserTest extends TestCase {
+    
+    public DocCommentParserTest(String testName) {
+        super(testName);
+    }
+    
+    public void testErrorRecovery1() throws IOException {
+        doTestErrorRecovery("{@link\n" +
+                            "{@link Object\n" +
+                            "{@link Object#\n" +
+                            "{@link Object#wait(lo\n" +
+                            "{@link Object#wait(long)\n" +
+                            "@see\n" +
+                            "@see Object\n" +
+                            "@see Object#\n" +
+                            "@see Object#wait(lo\n" +
+                            "@see Object#wait(long)\n",
+                            "DOC_COMMENT:{@link\n" +
+                            "{@link Object\n" +
+                            "{@link Object#\n" +
+                            "{@link Object#wait(lo\n" +
+                            "{@link Object#wait(long)\n" +
+                            "@see\n" +
+                            "@see Object\n" +
+                            "@see Object#\n" +
+                            "@see Object#wait(lo\n" +
+                            "@see Object#wait(long)",
+                            "LINK:{@link\n",
+                            "REFERENCE:",
+                            "LINK:{@link Object\n",
+                            "REFERENCE:Object",
+                            "LINK:{@link Object#\n",
+                            "REFERENCE:Object#",
+                            "LINK:{@link Object#wait(lo\n",
+                            "REFERENCE:Object#wait(lo\n",
+                            "LINK:{@link Object#wait(long)\n",
+                            "REFERENCE:Object#wait(long)",
+                            "SEE:@see",
+                            "SEE:@see Object",
+                            "REFERENCE:Object",
+                            "SEE:@see Object#",
+                            "REFERENCE:Object#",
+                            "SEE:@see Object#wait(lo\n",
+                            "REFERENCE:Object#wait(lo\n",
+                            "SEE:@see Object#wait(long)",
+                            "REFERENCE:Object#wait(long)"
+                           );
+    }
+    
+    public void testErrorRecoveryValue() throws IOException {
+        doTestErrorRecovery("{@value Math#PI\n" +
+                            "@see Object#wait(long)\n",
+                            "DOC_COMMENT:{@value Math#PI\n" +
+                            "@see Object#wait(long)",
+                            "VALUE:{@value Math#PI\n",
+                            "REFERENCE:Math#PI",
+                            "SEE:@see Object#wait(long)",
+                            "REFERENCE:Object#wait(long)"
+                           );
+    }
+    
+    public void test229748() throws IOException {
+        doTestErrorRecovery("{@literal http://wikis.sun.com/display/mlvm/ProjectCoinProposal\n" +
+                            "@see String\n",
+                            "DOC_COMMENT:{@literal http://wikis.sun.com/display/mlvm/ProjectCoinProposal\n" +
+                            "@see String",
+                            "LITERAL:{@literal http://wikis.sun.com/display/mlvm/ProjectCoinProposal\n",
+                            "TEXT:http://wikis.sun.com/display/mlvm/ProjectCoinProposal\n",
+                            "SEE:@see String",
+                            "REFERENCE:String");
+    }
+    
+    public void test229725() throws IOException {
+        doTestErrorRecovery("{@link http://wikis.sun.com/display/mlvm/ProjectCoinProposal}\n" +
+                            "@see http://wikis.sun.com/display/mlvm/ProjectCoinProposal\n",
+                            "DOC_COMMENT:{@link http://wikis.sun.com/display/mlvm/ProjectCoinProposal}\n" +
+                            "@see http://wikis.sun.com/display/mlvm/ProjectCoinProposal",
+                            "LINK:{@link http://wikis.sun.com/display/mlvm/ProjectCoinProposal}",
+                            "REFERENCE:http://wikis.sun.com/display/mlvm/ProjectCoinProposal",
+                            "SEE:@see http://wikis.sun.com/display/mlvm/ProjectCoinProposal",
+                            "REFERENCE:http://wikis.sun.com/display/mlvm/ProjectCoinProposal"
+                           );
+    }
+    
+    public void testInlineSpan() throws IOException {
+        doTestErrorRecovery("{@literal code}\n",
+                            "DOC_COMMENT:{@literal code}",
+                            "LITERAL:{@literal code}",
+                            "TEXT:code"
+                           );
+    }
+    
+    private void doTestErrorRecovery(String javadocCode, String... golden) throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        final String code = "package test; /** " + javadocCode + " */public class Test {}";
+
+        JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDkeepComments=true", "-XDbreakDocCommentParsingOnError=false"), null, Arrays.asList(new MyFileObject(code)));
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        DocTrees trees = DocTrees.instance(ct);
+        final DocSourcePositions pos = trees.getSourcePositions();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        final DocCommentTree dct = trees.getDocCommentTree(TreePath.getPath(cut, clazz));
+        final List<String> result = new ArrayList<String>();
+        
+        new DocTreeScanner<Void, Object>() {
+            @Override public Void scan(DocTree node, Object p) {
+                if (node == null) return null;
+                int start = (int) pos.getStartPosition(cut, dct, node);
+                int end = (int) pos.getEndPosition(cut, dct, node);
+                result.add(node.getKind() + ":" + code.substring(start, end));
+                return super.scan(node, p);
+            }
+        }.scan(dct, null);
+        
+        assertEquals(Arrays.asList(golden), result);
+    }
+    private static class MyFileObject extends SimpleJavaFileObject {
+        private String text;
+        public MyFileObject(String text) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+}
diff --git a/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/JavacParserTest.java b/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/JavacParserTest.java
index c5753ae..8e626e1 100644
--- a/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/JavacParserTest.java
+++ b/make/netbeans/nb-javac/test/com/sun/tools/javac/parser/JavacParserTest.java
@@ -31,6 +31,7 @@ import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.ExpressionStatementTree;
 import com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.LambdaExpressionTree;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.ModifiersTree;
@@ -40,15 +41,18 @@ import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreePathScanner;
 import com.sun.source.util.TreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.tree.JCTree;
 import java.io.IOException;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import javax.lang.model.element.Modifier;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
 import javax.tools.DiagnosticListener;
@@ -184,6 +188,7 @@ public class JavacParserTest extends TestCase {
             "throw UnsupportedOperationException()",
             "assert true",
             "1 + 1",
+            "vartype varname",
         };
 
         for (String command : commands) {
@@ -301,6 +306,7 @@ public class JavacParserTest extends TestCase {
         performPositionsSanityTest("package test; class Test { private void method() { java.util.List<? extends java.util.List<? extends String>> l; } }");
         performPositionsSanityTest("package test; class Test { private void method() { java.util.List<? super java.util.List<? super String>> l; } }");
         performPositionsSanityTest("package test; class Test { private void method() { java.util.List<? super java.util.List<?>> l; } }");
+        performPositionsSanityTest("package test; class Test { private void method() { java.util.List<String> l = null; l.reduce(null, (String s1, String s2) -> { return s1; }); } }");
     }
 
     private void performPositionsSanityTest(String code) throws IOException {
@@ -479,7 +485,7 @@ public class JavacParserTest extends TestCase {
         Trees t = Trees.instance(ct);
         int start = (int) t.getSourcePositions().getStartPosition(cut, enumAAA.getInitializer());
 
-        assertEquals(-1, start);
+        assertEquals("; }", code.substring(start));
     }
 
     public void testVariableInIfThen1() throws IOException {
@@ -539,7 +545,8 @@ public class JavacParserTest extends TestCase {
             codes.add(d.getCode());
         }
 
-        assertEquals(Arrays.<String>asList("compiler.err.illegal.start.of.expr"), codes);
+        assertEquals(Arrays.<String>asList("compiler.err.expected3"), codes);//TODO: was "compiler.err.illegal.start.of.expr" before JDK8 merge
+//        assertEquals(Arrays.<String>asList("compiler.err.illegal.start.of.expr"), codes);
     }
 
     //see javac bug #6882235, NB bug #98234:
@@ -599,4 +606,79 @@ public class JavacParserTest extends TestCase {
         }.scan(cut, null);
     }
 
+    public void testLambdaPositions() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        final String code = "package test; class Test { private void method() { java.util.List<String> l = null; l.reduce(null, (String s1, String s2) -> { return s1 + s2; }); } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        final Trees trees = Trees.instance(ct);
+        final List<String> content = new ArrayList<String>();
+
+        new TreePathScanner<Void, Void>() {
+            boolean record;
+            @Override
+            public Void scan(Tree node, Void p) {
+                if (node == null) return null;
+
+                if (record) {
+                    long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+                    if (start == (-1)) {
+                        return null; //synthetic tree
+                    }
+
+                    long end = trees.getSourcePositions().getEndPosition(cut, node);
+
+                    content.add(code.substring((int) start, (int) end));
+                }
+
+                return super.scan(node, p);
+            }
+
+            @Override
+            public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
+                boolean old = record;
+
+                record = true;
+
+                try {
+                    return super.visitLambdaExpression(node, p);
+                } finally {
+                    record = old;
+                }
+            }
+
+        }.scan(cut, null);
+
+        assertEquals(Arrays.asList("String s1", "String", "String s2", "String", "{ return s1 + s2; }", "return s1 + s2;", "s1 + s2", "s1", "s2"), content);
+    }
+
+    public void testInfiniteParsing() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        final String code = "111\npackage t; class Test { }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        assertNotNull(cut);
+    }
+    
+    public void testShouldNotSkipFirstStrictFP8005931() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        final String code = "strictfp class Test { }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        assertTrue(((ClassTree) cut.getTypeDecls().get(0)).getModifiers().getFlags().contains(Modifier.STRICTFP));
+    }
 }
diff --git a/make/netbeans/nb-javac/test/global/AnnotationProcessingTest.java b/make/netbeans/nb-javac/test/global/AnnotationProcessingTest.java
index ff7f24e..6a5eeb1 100644
--- a/make/netbeans/nb-javac/test/global/AnnotationProcessingTest.java
+++ b/make/netbeans/nb-javac/test/global/AnnotationProcessingTest.java
@@ -27,6 +27,7 @@ package global;
 
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.Main;
+import com.sun.tools.javac.api.JavacTaskImpl;
 import global.ap1.AP;
 import global.ap1.ClassBasedAP;
 import global.ap1.ErrorProducingAP;
@@ -40,12 +41,15 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import javax.tools.ToolProvider;
+import static junit.framework.Assert.assertEquals;
 import junit.framework.TestCase;
 
 /**
@@ -244,4 +248,19 @@ public class AnnotationProcessingTest extends TestCase {
             this.content = content;
         }
     }
+
+    public void testKeepBrokenAttributes228628() throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        String code = "package test; @Test(NonExistent.class) public @interface Test { public Class<?> value(); }";
+
+        JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, null, null, Arrays.asList("-bootclasspath",  bootPath, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(new global.Test116436.MyFileObject(code)));
+        Iterable<? extends Element> classes = ct.enter();
+        TypeElement test = (TypeElement) classes.iterator().next();
+        
+        assertEquals(1, test.getAnnotationMirrors().get(0).getElementValues().size());
+    }
+    
 }
diff --git a/make/test/lib/apt.sh b/make/test/lib/apt.sh
deleted file mode 100644
index 52077a1..0000000
--- a/make/test/lib/apt.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2007, 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 Verify the basic execution of the apt classes in classes.jar.
-
-TESTSRC=${TESTSRC:-.}
-TOPDIR=${TESTSRC}/../../..
-TESTJAVAEXE="${TESTJAVA:+${TESTJAVA}/bin/}java"
-
-"${TESTJAVAEXE}" -Xbootclasspath/p:${TOPDIR}/dist/lib/classes.jar \
-    com.sun.tools.apt.Main \
-    -print "${TESTSRC}"/../HelloWorld.java > apt.tmp
-
-if diff ${TESTSRC}/../HelloWorld.apt.gold.txt apt.tmp ; then
-    echo "Test passed."
-else
-    echo "Test failed."
-    exit 1
-fi
diff --git a/make/test/lib/src.gold.txt b/make/test/lib/src.gold.txt
index 921d5e2..84ccb50 100644
--- a/make/test/lib/src.gold.txt
+++ b/make/test/lib/src.gold.txt
@@ -1,14 +1,4 @@
 com/sun/javadoc/package.html
-com/sun/mirror/apt/package.html
-com/sun/mirror/declaration/package.html
-com/sun/mirror/overview.html
-com/sun/mirror/type/package.html
-com/sun/mirror/util/package.html
-com/sun/tools/apt/Main.java
-com/sun/tools/apt/main/Main.java
-com/sun/tools/apt/resources/apt.properties
-com/sun/tools/apt/resources/apt_ja.properties
-com/sun/tools/apt/resources/apt_zh_CN.properties
 com/sun/tools/doclets/formats/html/markup/package.html
 com/sun/tools/doclets/formats/html/package.html
 com/sun/tools/doclets/formats/html/resources/standard.properties
diff --git a/make/tools/CompileProperties/CompileProperties.java b/make/tools/CompileProperties/CompileProperties.java
deleted file mode 100644
index 8889c59..0000000
--- a/make/tools/CompileProperties/CompileProperties.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 2002, 2010, 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.
- */
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-/** Translates a .properties file into a .java file containing the
- *  definition of a java.util.Properties subclass which can then be
- *  compiled with javac. <P>
- *
- *  Usage: java CompileProperties [path to .properties file] [path to .java file to be output] [super class]
- *
- *  Infers the package by looking at the common suffix of the two
- *  inputs, eliminating "classes" from it.
- *
- * @author Scott Violet
- * @author Kenneth Russell
- */
-
-public class CompileProperties {
-
-    public static void main(String[] args) {
-        CompileProperties cp = new CompileProperties();
-        boolean ok = cp.run(args);
-        if ( !ok ) {
-            System.exit(1);
-        }
-    }
-
-    static interface Log {
-        void info(String msg);
-        void verbose(String msg);
-        void error(String msg, Exception e);
-    }
-
-    private String propfiles[];
-    private String outfiles[] ;
-    private String supers[]   ;
-    private int compileCount = 0;
-    private boolean quiet = false;
-    private Log log;
-
-    public void setLog(Log log) {
-        this.log = log;
-    }
-
-    public boolean run(String[] args) {
-        if (log == null) {
-            log = new Log() {
-                public void error(String msg, Exception e) {
-                    System.err.println("ERROR: CompileProperties: " + msg);
-                    if ( e != null ) {
-                        System.err.println("EXCEPTION: " + e.toString());
-                        e.printStackTrace();
-                    }
-                }
-                public void info(String msg) {
-                    System.out.println(msg);
-                }
-                public void verbose(String msg) {
-                    if (!quiet)
-                        System.out.println(msg);
-                }
-            };
-        }
-
-        boolean ok = true;
-        /* Original usage */
-        if (args.length == 2 && args[0].charAt(0) != '-' ) {
-            ok = createFile(args[0], args[1], "java.util.ListResourceBundle");
-        } else if (args.length == 3) {
-            ok = createFile(args[0], args[1], args[2]);
-        } else if (args.length == 0) {
-            usage(log);
-            ok = false;
-        } else {
-            /* New batch usage */
-            ok = parseOptions(args);
-            if ( ok && compileCount == 0 ) {
-                log.error("options parsed but no files to compile", null);
-                ok = false;
-            }
-            /* Need at least one file. */
-            if ( !ok ) {
-                usage(log);
-            } else {
-                /* Process files */
-                for ( int i = 0; i < compileCount && ok ; i++ ) {
-                    ok = createFile(propfiles[i], outfiles[i], supers[i]);
-                }
-            }
-        }
-        return ok;
-    }
-
-    private boolean parseOptions(String args[]) {
-        boolean ok = true;
-        if ( compileCount > 0 ) {
-            String new_propfiles[] = new String[compileCount + args.length];
-            String new_outfiles[]  = new String[compileCount + args.length];
-            String new_supers[]    = new String[compileCount + args.length];
-            System.arraycopy(propfiles, 0, new_propfiles, 0, compileCount);
-            System.arraycopy(outfiles, 0, new_outfiles, 0, compileCount);
-            System.arraycopy(supers, 0, new_supers, 0, compileCount);
-            propfiles = new_propfiles;
-            outfiles  = new_outfiles;
-            supers    = new_supers;
-        } else {
-            propfiles = new String[args.length];
-            outfiles  = new String[args.length];
-            supers    = new String[args.length];
-        }
-
-        for ( int i = 0; i < args.length ; i++ ) {
-            if ( "-compile".equals(args[i]) && i+3 < args.length ) {
-                propfiles[compileCount] = args[++i];
-                outfiles[compileCount]  = args[++i];
-                supers[compileCount]    = args[++i];
-                compileCount++;
-            } else if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) {
-                String filename = args[++i];
-                FileInputStream finput = null;
-                byte contents[] = null;
-                try {
-                    finput = new FileInputStream(filename);
-                    int byteCount = finput.available();
-                    if ( byteCount <= 0 ) {
-                        log.error("The -optionsfile file is empty", null);
-                        ok = false;
-                    } else {
-                        contents = new byte[byteCount];
-                        int bytesRead = finput.read(contents);
-                        if ( byteCount != bytesRead ) {
-                            log.error("Cannot read all of -optionsfile file", null);
-                            ok = false;
-                        }
-                    }
-                } catch ( IOException e ) {
-                    log.error("cannot open " + filename, e);
-                    ok = false;
-                }
-                if ( finput != null ) {
-                    try {
-                        finput.close();
-                    } catch ( IOException e ) {
-                        ok = false;
-                        log.error("cannot close " + filename, e);
-                    }
-                }
-                if ( ok = true && contents != null ) {
-                    String tokens[] = (new String(contents)).split("\\s+");
-                    if ( tokens.length > 0 ) {
-                        ok = parseOptions(tokens);
-                    }
-                }
-                if ( !ok ) {
-                    break;
-                }
-            } else if ( "-quiet".equals(args[i]) ) {
-                quiet = true;
-            } else {
-                log.error("argument error", null);
-                ok = false;
-            }
-        }
-        return ok;
-    }
-
-    private boolean createFile(String propertiesPath, String outputPath,
-            String superClass) {
-        boolean ok = true;
-        log.verbose("parsing: " + propertiesPath);
-        Properties p = new Properties();
-        try {
-            p.load(new FileInputStream(propertiesPath));
-        } catch ( FileNotFoundException e ) {
-            ok = false;
-            log.error("Cannot find file " + propertiesPath, e);
-        } catch ( IOException e ) {
-            ok = false;
-            log.error("IO error on file " + propertiesPath, e);
-        }
-        if ( ok ) {
-            String packageName = inferPackageName(propertiesPath, outputPath);
-            log.verbose("inferred package name: " + packageName);
-            List<String> sortedKeys = new ArrayList<String>();
-            for ( Object key : p.keySet() ) {
-                sortedKeys.add((String)key);
-            }
-            Collections.sort(sortedKeys);
-            Iterator keys = sortedKeys.iterator();
-
-            StringBuffer data = new StringBuffer();
-
-            while (keys.hasNext()) {
-                Object key = keys.next();
-                data.append("            { \"" + escape((String)key) + "\", \"" +
-                        escape((String)p.get(key)) + "\" },\n");
-            }
-
-            // Get class name from java filename, not the properties filename.
-            //   (zh_TW properties might be used to create zh_HK files)
-            File file = new File(outputPath);
-            String name = file.getName();
-            int dotIndex = name.lastIndexOf('.');
-            String className;
-            if (dotIndex == -1) {
-                className = name;
-            } else {
-                className = name.substring(0, dotIndex);
-            }
-
-            String packageString = "";
-            if (packageName != null && !packageName.equals("")) {
-                packageString = "package " + packageName + ";\n\n";
-            }
-
-            Writer writer = null;
-            try {
-                writer = new BufferedWriter(
-                        new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1"));
-                MessageFormat format = new MessageFormat(FORMAT);
-                writer.write(format.format(new Object[] { packageString, className, superClass, data }));
-            } catch ( IOException e ) {
-                ok = false;
-                log.error("IO error writing to file " + outputPath, e);
-            }
-            if ( writer != null ) {
-                try {
-                    writer.flush();
-                } catch ( IOException e ) {
-                    ok = false;
-                    log.error("IO error flush " + outputPath, e);
-                }
-                try {
-                    writer.close();
-                } catch ( IOException e ) {
-                    ok = false;
-                    log.error("IO error close " + outputPath, e);
-                }
-            }
-            log.verbose("wrote: " + outputPath);
-        }
-        return ok;
-    }
-
-    private static void usage(Log log) {
-        log.info("usage:");
-        log.info("    java CompileProperties path_to_properties_file path_to_java_output_file [super_class]");
-        log.info("      -OR-");
-        log.info("    java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename");
-        log.info("");
-        log.info("Example:");
-        log.info("    java CompileProperties -compile test.properties test.java java.util.ListResourceBundle");
-        log.info("    java CompileProperties -optionsfile option_file");
-        log.info("option_file contains: -compile test.properties test.java java.util.ListResourceBundle");
-    }
-
-    private static String escape(String theString) {
-        // This is taken from Properties.saveConvert with changes for Java strings
-        int len = theString.length();
-        StringBuffer outBuffer = new StringBuffer(len*2);
-
-        for(int x=0; x<len; x++) {
-            char aChar = theString.charAt(x);
-            switch(aChar) {
-                case '\\':outBuffer.append('\\'); outBuffer.append('\\');
-                break;
-                case '\t':outBuffer.append('\\'); outBuffer.append('t');
-                break;
-                case '\n':outBuffer.append('\\'); outBuffer.append('n');
-                break;
-                case '\r':outBuffer.append('\\'); outBuffer.append('r');
-                break;
-                case '\f':outBuffer.append('\\'); outBuffer.append('f');
-                break;
-                default:
-                    if ((aChar < 0x0020) || (aChar > 0x007e)) {
-                        outBuffer.append('\\');
-                        outBuffer.append('u');
-                        outBuffer.append(toHex((aChar >> 12) & 0xF));
-                        outBuffer.append(toHex((aChar >>  8) & 0xF));
-                        outBuffer.append(toHex((aChar >>  4) & 0xF));
-                        outBuffer.append(toHex( aChar        & 0xF));
-                    } else {
-                        if (specialSaveChars.indexOf(aChar) != -1) {
-                            outBuffer.append('\\');
-                        }
-                        outBuffer.append(aChar);
-                    }
-            }
-        }
-        return outBuffer.toString();
-    }
-
-    private static String inferPackageName(String inputPath, String outputPath) {
-        // Normalize file names
-        inputPath  = new File(inputPath).getPath();
-        outputPath = new File(outputPath).getPath();
-        // Split into components
-        String sep;
-        if (File.separatorChar == '\\') {
-            sep = "\\\\";
-        } else {
-            sep = File.separator;
-        }
-        String[] inputs  = inputPath.split(sep);
-        String[] outputs = outputPath.split(sep);
-        // Match common names, eliminating first "classes" entry from
-        // each if present
-        int inStart  = 0;
-        int inEnd    = inputs.length - 2;
-        int outEnd   = outputs.length - 2;
-        int i = inEnd;
-        int j = outEnd;
-        while (i >= 0 && j >= 0) {
-            if (!inputs[i].equals(outputs[j]) ||
-                    (inputs[i].equals("gensrc") && inputs[j].equals("gensrc"))) {
-                ++i;
-                ++j;
-                break;
-            }
-            --i;
-            --j;
-        }
-        String result;
-        if (i < 0 || j < 0 || i >= inEnd || j >= outEnd) {
-            result = "";
-        } else {
-            if (inputs[i].equals("classes") && outputs[j].equals("classes")) {
-                ++i;
-            }
-            inStart = i;
-            StringBuffer buf = new StringBuffer();
-            for (i = inStart; i <= inEnd; i++) {
-                buf.append(inputs[i]);
-                if (i < inEnd) {
-                    buf.append('.');
-                }
-            }
-            result = buf.toString();
-        }
-        return result;
-    }
-
-    private static final String FORMAT =
-            "{0}" +
-            "public final class {1} extends {2} '{'\n" +
-            "    protected final Object[][] getContents() '{'\n" +
-            "        return new Object[][] '{'\n" +
-            "{3}" +
-            "        };\n" +
-            "    }\n" +
-            "}\n";
-
-    // This comes from Properties
-    private static char toHex(int nibble) {
-        return hexDigit[(nibble & 0xF)];
-    }
-
-    // This comes from Properties
-    private static final char[] hexDigit = {
-        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
-    };
-
-    // Note: different from that in Properties
-    private static final String specialSaveChars = "\"";
-}
diff --git a/make/tools/CompileProperties/CompilePropertiesTask.java b/make/tools/CompileProperties/CompilePropertiesTask.java
deleted file mode 100644
index 8bf3303..0000000
--- a/make/tools/CompileProperties/CompilePropertiesTask.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2007, 2010, 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.
- */
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.MatchingTask;
-
-public class CompilePropertiesTask extends MatchingTask {
-    public void setSrcDir(File srcDir) {
-        this.srcDir = srcDir;
-    }
-
-    public void setDestDir(File destDir) {
-        this.destDir = destDir;
-    }
-
-    public void setSuperclass(String superclass) {
-        this.superclass = superclass;
-    }
-
-    @Override
-    public void execute() {
-        CompileProperties.Log log = new CompileProperties.Log() {
-            public void error(String msg, Exception e) {
-                log(msg, Project.MSG_ERR);
-            }
-            public void info(String msg) {
-                log(msg, Project.MSG_INFO);
-            }
-            public void verbose(String msg) {
-                log(msg, Project.MSG_VERBOSE);
-            }
-        };
-        List<String> mainOpts = new ArrayList<String>();
-        int count = 0;
-        DirectoryScanner s = getDirectoryScanner(srcDir);
-        for (String path: s.getIncludedFiles()) {
-            if (path.endsWith(".properties")) {
-                String destPath =
-                        path.substring(0, path.length() - ".properties".length()) +
-                        ".java";
-                File srcFile = new File(srcDir, path);
-                File destFile = new File(destDir, destPath);
-                // Arguably, the comparison in the next line should be ">", not ">="
-                // but that assumes the resolution of the last modified time is fine
-                // grained enough; in practice, it is better to use ">=".
-                if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified())
-                    continue;
-                destFile.getParentFile().mkdirs();
-                mainOpts.add("-compile");
-                mainOpts.add(srcFile.getPath());
-                mainOpts.add(destFile.getPath());
-                mainOpts.add(superclass);
-                count++;
-            }
-        }
-        if (mainOpts.size() > 0) {
-            log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO);
-            CompileProperties cp = new CompileProperties();
-            cp.setLog(log);
-            boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()]));
-            if (!ok)
-                throw new BuildException("CompileProperties failed.");
-        }
-    }
-
-    private File srcDir;
-    private File destDir;
-    private String superclass = "java.util.ListResourceBundle";
-}
diff --git a/make/tools/GenStubs/GenStubs.java b/make/tools/GenStubs/GenStubs.java
deleted file mode 100644
index b7caee2..0000000
--- a/make/tools/GenStubs/GenStubs.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright (c) 2009, 2010, 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.
- */
-
-import java.io.*;
-import java.util.*;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.taskdefs.MatchingTask;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Reference;
-
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.TypeTags;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
-import com.sun.tools.javac.tree.JCTree.JCIdent;
-import com.sun.tools.javac.tree.JCTree.JCImport;
-import com.sun.tools.javac.tree.JCTree.JCLiteral;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.tree.JCTree.JCModifiers;
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import com.sun.tools.javac.tree.Pretty;
-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.util.Context;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Name;
-import javax.tools.JavaFileManager;
-
-/**
- * Generate stub source files by removing implementation details from input files.
- *
- * This is a special purpose stub generator, specific to the needs of generating
- * stub files for JDK 7 API that are needed to compile langtools files that depend
- * on that API. The stub generator works by removing as much of the API source code
- * as possible without affecting the public signature, in order to reduce the
- * transitive closure of the API being referenced. The resulting stubs can be
- * put on the langtools sourcepath with -implicit:none to compile the langtools
- * files that depend on the JDK 7 API.
- *
- * Usage:
- *  genstubs -s <outdir> -sourcepath <path> <classnames>
- *
- * The specified class names are looked up on the sourcepath, and corresponding
- * stubs are written to the source output directory.
- *
- * Classes are parsed into javac ASTs, then processed with a javac TreeTranslator
- * to remove implementation details, and written out in the source output directory.
- * Documentation comments and annotations are removed. Method bodies are removed
- * and methods are marked native. Private and package-private field definitions
- * have their initializers replace with 0, 0.0, false, null as appropriate.
- *
- * An Ant task, Main$Ant is also provided. Files are specified with an implicit
- * fileset, using srcdir as a base directory. The set of files to be included
- * is specified with an includes attribute or nested <includes> set. However,
- * unlike a normal fileset, an empty includes attribute means "no files" instead
- * of "all files".  The Ant task also accepts "fork=true" and classpath attribute
- * or nested <classpath> element to run GenStubs in a separate VM with the specified
- * path. This is likely necessary if a JDK 7 parser is required to read the
- * JDK 7 input files.
- */
-
-public class GenStubs {
-    static class Fault extends Exception {
-        private static final long serialVersionUID = 0;
-        Fault(String message) {
-            super(message);
-        }
-        Fault(String message, Throwable cause) {
-            super(message);
-            initCause(cause);
-        }
-    }
-
-    public static void main(String[] args) {
-        boolean ok = new GenStubs().run(args);
-        if (!ok)
-            System.exit(1);
-    }
-
-    boolean run(String... args) {
-        File outdir = null;
-        String sourcepath = null;
-        List<String> classes = new ArrayList<String>();
-        for (ListIterator<String> iter = Arrays.asList(args).listIterator(); iter.hasNext(); ) {
-            String arg = iter.next();
-            if (arg.equals("-s") && iter.hasNext())
-                outdir = new File(iter.next());
-            else if (arg.equals("-sourcepath") && iter.hasNext())
-                sourcepath = iter.next();
-            else if (arg.startsWith("-"))
-                throw new IllegalArgumentException(arg);
-            else {
-                classes.add(arg);
-                while (iter.hasNext())
-                    classes.add(iter.next());
-            }
-        }
-
-        return run(sourcepath, outdir, classes);
-    }
-
-    boolean run(String sourcepath, File outdir, List<String> classes) {
-        //System.err.println("run: sourcepath:" + sourcepath + " outdir:" + outdir + " classes:" + classes);
-        if (sourcepath == null)
-            throw new IllegalArgumentException("sourcepath not set");
-        if (outdir == null)
-            throw new IllegalArgumentException("source output dir not set");
-
-        JavacTool tool = JavacTool.create();
-        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
-
-        try {
-            fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outdir));
-            fm.setLocation(StandardLocation.SOURCE_PATH, splitPath(sourcepath));
-            List<JavaFileObject> files = new ArrayList<JavaFileObject>();
-            for (String c: classes) {
-                JavaFileObject fo = fm.getJavaFileForInput(
-                        StandardLocation.SOURCE_PATH, c, JavaFileObject.Kind.SOURCE);
-                if (fo == null)
-                    error("class not found: " + c);
-                else
-                    files.add(fo);
-            }
-
-            JavacTask t = tool.getTask(null, fm, null, null, null, files);
-            Iterable<? extends CompilationUnitTree> trees = t.parse();
-            for (CompilationUnitTree tree: trees) {
-                makeStub(fm, tree);
-            }
-        } catch (IOException e) {
-            error("IO error " + e, e);
-        }
-
-        return (errors == 0);
-    }
-
-    void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException {
-        CompilationUnitTree tree2 = new StubMaker().translate(tree);
-        CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2);
-
-        String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile());
-        JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT,
-                className, JavaFileObject.Kind.SOURCE, null);
-        // System.err.println("Writing " + className + " to " + fo.getName());
-        Writer out = fo.openWriter();
-        try {
-            new Pretty(out, true).printExpr((JCTree) tree3);
-        } finally {
-            out.close();
-        }
-    }
-
-    List<File> splitPath(String path) {
-        List<File> list = new ArrayList<File>();
-        for (String p: path.split(File.pathSeparator)) {
-            if (p.length() > 0)
-                list.add(new File(p));
-        }
-        return list;
-    }
-
-    void error(String message) {
-        System.err.println(message);
-        errors++;
-    }
-
-    void error(String message, Throwable cause) {
-        error(message);
-    }
-
-    int errors;
-
-    class StubMaker extends TreeTranslator {
-        CompilationUnitTree translate(CompilationUnitTree tree) {
-            return super.translate((JCCompilationUnit) tree);
-        }
-
-        /**
-         * compilation units: remove javadoc comments
-         * -- required, in order to remove @deprecated tags, since we
-         * (separately) remove all annotations, including @Deprecated
-         */
-        public void visitTopLevel(JCCompilationUnit tree) {
-            super.visitTopLevel(tree);
-            tree.docComments = Collections.emptyMap();
-        }
-
-        /**
-         * methods: remove method bodies, make methods native
-         */
-        @Override
-        public void visitMethodDef(JCMethodDecl tree) {
-            tree.mods = translate(tree.mods);
-            tree.restype = translate(tree.restype);
-            tree.typarams = translateTypeParams(tree.typarams);
-            tree.params = translateVarDefs(tree.params);
-            tree.thrown = translate(tree.thrown);
-            if (tree.restype != null && tree.body != null) {
-                tree.mods.flags |= Flags.NATIVE;
-                tree.body = null;
-            }
-            result = tree;
-        }
-
-        /**
-         * modifiers: remove annotations
-         */
-        @Override
-        public void visitModifiers(JCModifiers tree) {
-            tree.annotations = com.sun.tools.javac.util.List.nil();
-            result = tree;
-        }
-
-        /**
-         * field definitions: replace initializers with 0, 0.0, false etc
-         * when possible -- i.e. leave public, protected initializers alone
-         */
-        @Override
-        public void visitVarDef(JCVariableDecl tree) {
-            tree.mods = translate(tree.mods);
-            tree.vartype = translate(tree.vartype);
-            if (tree.init != null) {
-                if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0)
-                    tree.init = translate(tree.init);
-                else {
-                    String t = tree.vartype.toString();
-                    if (t.equals("boolean"))
-                        tree.init = new JCLiteral(TypeTags.BOOLEAN, 0) { };
-                    else if (t.equals("byte"))
-                        tree.init = new JCLiteral(TypeTags.BYTE, 0) { };
-                    else if (t.equals("char"))
-                        tree.init = new JCLiteral(TypeTags.CHAR, 0) { };
-                    else if (t.equals("double"))
-                        tree.init = new JCLiteral(TypeTags.DOUBLE, 0.d) { };
-                    else if (t.equals("float"))
-                        tree.init = new JCLiteral(TypeTags.FLOAT, 0.f) { };
-                    else if (t.equals("int"))
-                        tree.init = new JCLiteral(TypeTags.INT, 0) { };
-                    else if (t.equals("long"))
-                        tree.init = new JCLiteral(TypeTags.LONG, 0) { };
-                    else if (t.equals("short"))
-                        tree.init = new JCLiteral(TypeTags.SHORT, 0) { };
-                    else
-                        tree.init = new JCLiteral(TypeTags.BOT, null) { };
-                }
-            }
-            result = tree;
-        }
-    }
-
-    class ImportCleaner extends TreeScanner {
-        private Set<Name> names = new HashSet<Name>();
-        private TreeMaker m;
-
-        ImportCleaner(JavaFileManager fm) {
-            // ImportCleaner itself doesn't require a filemanager, but instantiating
-            // a TreeMaker does, indirectly (via ClassReader, sigh)
-            Context c = new Context();
-            c.put(JavaFileManager.class, fm);
-            m = TreeMaker.instance(c);
-        }
-
-        CompilationUnitTree removeRedundantImports(CompilationUnitTree t) {
-            JCCompilationUnit tree = (JCCompilationUnit) t;
-            tree.accept(this);
-            ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
-            for (JCTree def: tree.defs) {
-                if (def.getTag() == JCTree.IMPORT) {
-                    JCImport imp = (JCImport) def;
-                    if (imp.qualid.getTag() == JCTree.SELECT) {
-                        JCFieldAccess qualid = (JCFieldAccess) imp.qualid;
-                        if (!qualid.name.toString().equals("*")
-                                && !names.contains(qualid.name)) {
-                            continue;
-                        }
-                    }
-                }
-                defs.add(def);
-            }
-            return m.TopLevel(tree.packageAnnotations, tree.pid, defs.toList());
-        }
-
-        @Override
-        public void visitImport(JCImport tree) { } // ignore names found in imports
-
-        @Override
-        public void visitIdent(JCIdent tree) {
-            names.add(tree.name);
-        }
-
-        @Override
-        public void visitSelect(JCFieldAccess tree) {
-            super.visitSelect(tree);
-            names.add(tree.name);
-        }
-    }
-
-    //---------- Ant Invocation ------------------------------------------------
-
-    public static class Ant extends MatchingTask {
-        private File srcDir;
-        private File destDir;
-        private boolean fork;
-        private Path classpath;
-        private String includes;
-
-        public void setSrcDir(File dir) {
-            this.srcDir = dir;
-        }
-
-        public void setDestDir(File dir) {
-            this.destDir = dir;
-        }
-
-        public void setFork(boolean v) {
-            this.fork = v;
-        }
-
-        public void setClasspath(Path cp) {
-            if (classpath == null)
-                classpath = cp;
-            else
-                classpath.append(cp);
-        }
-
-        public Path createClasspath() {
-            if (classpath == null) {
-                classpath = new Path(getProject());
-            }
-            return classpath.createPath();
-        }
-
-        public void setClasspathRef(Reference r) {
-            createClasspath().setRefid(r);
-        }
-
-        public void setIncludes(String includes) {
-            super.setIncludes(includes);
-            this.includes = includes;
-        }
-
-        @Override
-        public void execute() {
-            if (includes != null && includes.trim().isEmpty())
-                return;
-
-            DirectoryScanner s = getDirectoryScanner(srcDir);
-            String[] files = s.getIncludedFiles();
-//            System.err.println("Ant.execute: srcDir " + srcDir);
-//            System.err.println("Ant.execute: destDir " + destDir);
-//            System.err.println("Ant.execute: files " + Arrays.asList(files));
-
-            files = filter(srcDir, destDir, files);
-            if (files.length == 0)
-                return;
-            System.out.println("Generating " + files.length + " stub files to " + destDir);
-
-            List<String> classNames = new ArrayList<String>();
-            for (String file: files) {
-                classNames.add(file.replaceAll(".java$", "").replace('/', '.'));
-            }
-
-            if (!fork) {
-                GenStubs m = new GenStubs();
-                boolean ok = m.run(srcDir.getPath(), destDir, classNames);
-                if (!ok)
-                    throw new BuildException("genstubs failed");
-            } else {
-                List<String> cmd = new ArrayList<String>();
-                String java_home = System.getProperty("java.home");
-                cmd.add(new File(new File(java_home, "bin"), "java").getPath());
-                if (classpath != null)
-                    cmd.add("-Xbootclasspath/p:" + classpath);
-                cmd.add(GenStubs.class.getName());
-                cmd.add("-sourcepath");
-                cmd.add(srcDir.getPath());
-                cmd.add("-s");
-                cmd.add(destDir.getPath());
-                cmd.addAll(classNames);
-                //System.err.println("GenStubs exec " + cmd);
-                ProcessBuilder pb = new ProcessBuilder(cmd);
-                pb.redirectErrorStream(true);
-                try {
-                    Process p = pb.start();
-                    BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
-                    try {
-                        String line;
-                        while ((line = in.readLine()) != null)
-                            System.out.println(line);
-                    } finally {
-                        in.close();
-                    }
-                    int rc = p.waitFor();
-                    if (rc != 0)
-                        throw new BuildException("genstubs failed");
-                } catch (IOException e) {
-                    throw new BuildException("genstubs failed", e);
-                } catch (InterruptedException e) {
-                    throw new BuildException("genstubs failed", e);
-                }
-            }
-        }
-
-        String[] filter(File srcDir, File destDir, String[] files) {
-            List<String> results = new ArrayList<String>();
-            for (String f: files) {
-                long srcTime = new File(srcDir, f).lastModified();
-                long destTime = new File(destDir, f).lastModified();
-                if (srcTime > destTime)
-                    results.add(f);
-            }
-            return results.toArray(new String[results.size()]);
-        }
-    }
-}
diff --git a/make/tools/SelectTool/SelectToolTask.java b/make/tools/SelectTool/SelectToolTask.java
deleted file mode 100644
index b182b49..0000000
--- a/make/tools/SelectTool/SelectToolTask.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, 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.
- */
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import javax.swing.SwingUtilities;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-/**
- * Task to allow the user to control langtools tools built when using NetBeans.
- *
- * There are two primary modes.
- * 1) Property mode. In this mode, property names are provided to get values
- * that may be specified by the user, either directly in a GUI dialog, or
- * read from a properties file. If the GUI dialog is invoked, values may
- * optionally be set for future use.
- * 2) Setup mode. In this mode, no property names are provided, and the GUI
- * is invoked to allow the user to set or reset values for use in property mode.
- */
-public class SelectToolTask extends Task {
-    /**
-     * Set the location of the private properties file used to keep the retain
-     * user preferences for this repository.
-     */
-    public void setPropertyFile(File propertyFile) {
-        this.propertyFile = propertyFile;
-    }
-
-    /**
-     * Set the name of the property which will be set to the name of the
-     * selected tool, if any. If no tool is selected, the property will
-     * remain unset.
-     */
-    public void setToolProperty(String toolProperty) {
-        this.toolProperty = toolProperty;
-    }
-
-    /**
-     * Set the name of the property which will be set to the execution args of the
-     * selected tool, if any. The args default to an empty string.
-     */
-    public void setArgsProperty(String argsProperty) {
-        this.argsProperty = argsProperty;
-    }
-
-    /**
-     * Specify whether or not to pop up a dialog if the user has not specified
-     * a default value for a property.
-     */
-    public void setAskIfUnset(boolean askIfUnset) {
-        this.askIfUnset = askIfUnset;
-    }
-
-    @Override
-    public void execute() {
-        Project p = getProject();
-
-        Properties props = readProperties(propertyFile);
-        toolName = props.getProperty("tool.name");
-        if (toolName != null) {
-            toolArgs = props.getProperty(toolName + ".args", "");
-        }
-
-        if (toolProperty == null ||
-            askIfUnset && (toolName == null
-                || (argsProperty != null && toolArgs == null))) {
-            showGUI(props);
-        }
-
-        // finally, return required values, if any
-        if (toolProperty != null && !(toolName == null || toolName.equals(""))) {
-            p.setProperty(toolProperty, toolName);
-
-            if (argsProperty != null && toolArgs != null)
-                p.setProperty(argsProperty, toolArgs);
-        }
-    }
-
-    void showGUI(Properties fileProps) {
-        Properties guiProps = new Properties(fileProps);
-        JOptionPane p = createPane(guiProps);
-        p.createDialog("Select Tool").setVisible(true);
-
-        toolName = (String) toolChoice.getSelectedItem();
-        toolArgs = argsField.getText();
-
-        if (defaultCheck.isSelected()) {
-            if (toolName.equals("")) {
-                fileProps.remove("tool.name");
-            } else {
-                fileProps.put("tool.name", toolName);
-                fileProps.put(toolName + ".args", toolArgs);
-            }
-            writeProperties(propertyFile, fileProps);
-        }
-    }
-
-    JOptionPane createPane(final Properties props) {
-        JPanel body = new JPanel(new GridBagLayout());
-        GridBagConstraints lc = new GridBagConstraints();
-        lc.insets.right = 10;
-        lc.insets.bottom = 3;
-        GridBagConstraints fc = new GridBagConstraints();
-        fc.anchor = GridBagConstraints.WEST;
-        fc.gridx = 1;
-        fc.gridwidth = GridBagConstraints.REMAINDER;
-        fc.insets.bottom = 3;
-
-        JLabel toolLabel = new JLabel("Tool:");
-        body.add(toolLabel, lc);
-        String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" };
-        if (true || toolProperty == null) {
-            // include empty value in setup mode
-            List<String> l = new ArrayList<String>(Arrays.asList(toolChoices));
-            l.add(0, "");
-            toolChoices = l.toArray(new String[l.size()]);
-        }
-        toolChoice = new JComboBox(toolChoices);
-        if (toolName != null)
-            toolChoice.setSelectedItem(toolName);
-        toolChoice.addItemListener(new ItemListener() {
-            public void itemStateChanged(ItemEvent e) {
-                String tn = (String) e.getItem();
-                argsField.setText(getDefaultArgsForTool(props, tn));
-                if (toolProperty != null)
-                    okButton.setEnabled(!tn.equals(""));
-            }
-        });
-        body.add(toolChoice, fc);
-
-        argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40);
-        if (toolProperty == null || argsProperty != null) {
-            JLabel argsLabel = new JLabel("Args:");
-            body.add(argsLabel, lc);
-            body.add(argsField, fc);
-            argsField.addFocusListener(new FocusListener() {
-                public void focusGained(FocusEvent e) {
-                }
-                public void focusLost(FocusEvent e) {
-                    String toolName = (String) toolChoice.getSelectedItem();
-                    if (toolName.length() > 0)
-                        props.put(toolName + ".args", argsField.getText());
-                }
-            });
-        }
-
-        defaultCheck = new JCheckBox("Set as default");
-        if (toolProperty == null)
-            defaultCheck.setSelected(true);
-        else
-            body.add(defaultCheck, fc);
-
-        final JOptionPane p = new JOptionPane(body);
-        okButton = new JButton("OK");
-        okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
-        okButton.addActionListener(new ActionListener() {
-            public void actionPerformed(ActionEvent e) {
-                JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
-                d.setVisible(false);
-            }
-        });
-        p.setOptions(new Object[] { okButton });
-
-        return p;
-    }
-
-    Properties readProperties(File file) {
-        Properties p = new Properties();
-        if (file != null && file.exists()) {
-            Reader in = null;
-            try {
-                in = new BufferedReader(new FileReader(file));
-                p.load(in);
-                in.close();
-            } catch (IOException e) {
-                throw new BuildException("error reading property file", e);
-            } finally {
-                if (in != null) {
-                    try {
-                        in.close();
-                    } catch (IOException e) {
-                        throw new BuildException("cannot close property file", e);
-                    }
-                }
-            }
-        }
-        return p;
-    }
-
-    void writeProperties(File file, Properties p) {
-        if (file != null) {
-            Writer out = null;
-            try {
-                File dir = file.getParentFile();
-                if (dir != null && !dir.exists())
-                    dir.mkdirs();
-                out = new BufferedWriter(new FileWriter(file));
-                p.store(out, "langtools properties");
-                out.close();
-            } catch (IOException e) {
-                throw new BuildException("error writing property file", e);
-            } finally {
-                if (out != null) {
-                    try {
-                        out.close();
-                    } catch (IOException e) {
-                        throw new BuildException("cannot close property file", e);
-                    }
-                }
-            }
-        }
-    }
-
-    String getDefaultArgsForTool(Properties props, String tn) {
-        return (tn == null || tn.equals("")) ? "" : props.getProperty(tn + ".args", "");
-    }
-
-    // Ant task parameters
-    private boolean askIfUnset;
-    private String toolProperty;
-    private String argsProperty;
-    private File propertyFile;
-
-    // GUI components
-    private JComboBox toolChoice;
-    private JTextField argsField;
-    private JCheckBox defaultCheck;
-    private JButton okButton;
-
-    // Result values for the client
-    private String toolName;
-    private String toolArgs;
-}
diff --git a/make/tools/anttasks/CompilePropertiesTask.java b/make/tools/anttasks/CompilePropertiesTask.java
new file mode 100644
index 0000000..7541c9f
--- /dev/null
+++ b/make/tools/anttasks/CompilePropertiesTask.java
@@ -0,0 +1,101 @@
+/*
+ * 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.  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 anttasks;
+
+import compileproperties.CompileProperties;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+
+public class CompilePropertiesTask extends MatchingTask {
+    public void setSrcDir(File srcDir) {
+        this.srcDir = srcDir;
+    }
+
+    public void setDestDir(File destDir) {
+        this.destDir = destDir;
+    }
+
+    public void setSuperclass(String superclass) {
+        this.superclass = superclass;
+    }
+
+    @Override
+    public void execute() {
+        CompileProperties.Log log = new CompileProperties.Log() {
+            public void error(String msg, Exception e) {
+                log(msg, Project.MSG_ERR);
+            }
+            public void info(String msg) {
+                log(msg, Project.MSG_INFO);
+            }
+            public void verbose(String msg) {
+                log(msg, Project.MSG_VERBOSE);
+            }
+        };
+        List<String> mainOpts = new ArrayList<String>();
+        int count = 0;
+        DirectoryScanner s = getDirectoryScanner(srcDir);
+        for (String path: s.getIncludedFiles()) {
+            if (path.endsWith(".properties")) {
+                String destPath =
+                        path.substring(0, path.length() - ".properties".length()) +
+                        ".java";
+                File srcFile = new File(srcDir, path);
+                File destFile = new File(destDir, destPath);
+                // Arguably, the comparison in the next line should be ">", not ">="
+                // but that assumes the resolution of the last modified time is fine
+                // grained enough; in practice, it is better to use ">=".
+                if (destFile.exists() && destFile.lastModified() >= srcFile.lastModified())
+                    continue;
+                destFile.getParentFile().mkdirs();
+                mainOpts.add("-compile");
+                mainOpts.add(srcFile.getPath());
+                mainOpts.add(destFile.getPath());
+                mainOpts.add(superclass);
+                count++;
+            }
+        }
+        if (mainOpts.size() > 0) {
+            log("Generating " + count + " resource files to " + destDir, Project.MSG_INFO);
+            CompileProperties cp = new CompileProperties();
+            cp.setLog(log);
+            boolean ok = cp.run(mainOpts.toArray(new String[mainOpts.size()]));
+            if (!ok)
+                throw new BuildException("CompileProperties failed.");
+        }
+    }
+
+    private File srcDir;
+    private File destDir;
+    private String superclass = "java.util.ListResourceBundle";
+}
diff --git a/make/tools/anttasks/GenStubsTask.java b/make/tools/anttasks/GenStubsTask.java
new file mode 100644
index 0000000..66e4139
--- /dev/null
+++ b/make/tools/anttasks/GenStubsTask.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2009, 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 anttasks;
+
+import genstubs.GenStubs;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+
+/**
+ * Files are specified with an implicit fileset, using srcdir as a base directory.
+ * The set of files to be included is specified with an includes attribute or
+ * nested <includes> set. However, unlike a normal fileset, an empty includes attribute
+ * means "no files" instead of "all files".  The Ant task also accepts "fork=true" and
+ * classpath attribute or nested <classpath> element to run GenStubs in a separate VM
+ * with the specified path. This is likely necessary if a JDK 7 parser is required to read the
+ * JDK 7 input files.
+ */
+public class GenStubsTask extends MatchingTask {
+    private File srcDir;
+    private File destDir;
+    private boolean fork;
+    private Path classpath;
+    private String includes;
+
+    public void setSrcDir(File dir) {
+        this.srcDir = dir;
+    }
+
+    public void setDestDir(File dir) {
+        this.destDir = dir;
+    }
+
+    public void setFork(boolean v) {
+        this.fork = v;
+    }
+
+    public void setClasspath(Path cp) {
+        if (classpath == null)
+            classpath = cp;
+        else
+            classpath.append(cp);
+    }
+
+    public Path createClasspath() {
+        if (classpath == null) {
+            classpath = new Path(getProject());
+        }
+        return classpath.createPath();
+    }
+
+    public void setClasspathRef(Reference r) {
+        createClasspath().setRefid(r);
+    }
+
+    public void setIncludes(String includes) {
+        super.setIncludes(includes);
+        this.includes = includes;
+    }
+
+    @Override
+    public void execute() {
+        if (includes != null && includes.trim().isEmpty())
+            return;
+
+        DirectoryScanner s = getDirectoryScanner(srcDir);
+        String[] files = s.getIncludedFiles();
+//            System.err.println("Ant.execute: srcDir " + srcDir);
+//            System.err.println("Ant.execute: destDir " + destDir);
+//            System.err.println("Ant.execute: files " + Arrays.asList(files));
+
+        files = filter(srcDir, destDir, files);
+        if (files.length == 0)
+            return;
+        System.out.println("Generating " + files.length + " stub files to " + destDir);
+
+        List<String> classNames = new ArrayList<String>();
+        for (String file: files) {
+            classNames.add(file.replaceAll(".java$", "").replace('/', '.'));
+        }
+
+        if (!fork) {
+            GenStubs m = new GenStubs();
+            boolean ok = m.run(srcDir.getPath(), destDir, classNames);
+            if (!ok)
+                throw new BuildException("genstubs failed");
+        } else {
+            List<String> cmd = new ArrayList<String>();
+            String java_home = System.getProperty("java.home");
+            cmd.add(new File(new File(java_home, "bin"), "java").getPath());
+            if (classpath != null)
+                cmd.add("-Xbootclasspath/p:" + classpath);
+            cmd.add(GenStubs.class.getName());
+            cmd.add("-sourcepath");
+            cmd.add(srcDir.getPath());
+            cmd.add("-s");
+            cmd.add(destDir.getPath());
+            cmd.addAll(classNames);
+            //System.err.println("GenStubs exec " + cmd);
+            ProcessBuilder pb = new ProcessBuilder(cmd);
+            pb.redirectErrorStream(true);
+            try {
+                Process p = pb.start();
+                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                try {
+                    String line;
+                    while ((line = in.readLine()) != null)
+                        System.out.println(line);
+                } finally {
+                    in.close();
+                }
+                int rc = p.waitFor();
+                if (rc != 0)
+                    throw new BuildException("genstubs failed");
+            } catch (IOException e) {
+                throw new BuildException("genstubs failed", e);
+            } catch (InterruptedException e) {
+                throw new BuildException("genstubs failed", e);
+            }
+        }
+    }
+
+    String[] filter(File srcDir, File destDir, String[] files) {
+        List<String> results = new ArrayList<String>();
+        for (String f: files) {
+            long srcTime = new File(srcDir, f).lastModified();
+            long destTime = new File(destDir, f).lastModified();
+            if (srcTime > destTime)
+                results.add(f);
+        }
+        return results.toArray(new String[results.size()]);
+    }
+}
diff --git a/make/tools/anttasks/SelectToolTask.java b/make/tools/anttasks/SelectToolTask.java
new file mode 100644
index 0000000..fb2cf49
--- /dev/null
+++ b/make/tools/anttasks/SelectToolTask.java
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2008, 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 anttasks;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import javax.swing.SwingUtilities;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+
+/**
+ * Task to allow the user to control langtools tools built when using NetBeans.
+ *
+ * There are two primary modes.
+ * 1) Property mode. In this mode, property names are provided to get values
+ * that may be specified by the user, either directly in a GUI dialog, or
+ * read from a properties file. If the GUI dialog is invoked, values may
+ * optionally be set for future use.
+ * 2) Setup mode. In this mode, no property names are provided, and the GUI
+ * is invoked to allow the user to set or reset values for use in property mode.
+ */
+public class SelectToolTask extends Task {
+    /**
+     * Set the location of the private properties file used to keep the retain
+     * user preferences for this repository.
+     */
+    public void setPropertyFile(File propertyFile) {
+        this.propertyFile = propertyFile;
+    }
+
+    /**
+     * Set the name of the property which will be set to the name of the
+     * selected tool, if any. If no tool is selected, the property will
+     * remain unset.
+     */
+    public void setToolProperty(String toolProperty) {
+        this.toolProperty = toolProperty;
+    }
+
+    /**
+     * Set the name of the property which will be set to the execution args of the
+     * selected tool, if any. The args default to an empty string.
+     */
+    public void setArgsProperty(String argsProperty) {
+        this.argsProperty = argsProperty;
+    }
+
+    /**
+     * Specify whether or not to pop up a dialog if the user has not specified
+     * a default value for a property.
+     */
+    public void setAskIfUnset(boolean askIfUnset) {
+        this.askIfUnset = askIfUnset;
+    }
+
+    @Override
+    public void execute() {
+        Project p = getProject();
+
+        Properties props = readProperties(propertyFile);
+        toolName = props.getProperty("tool.name");
+        if (toolName != null) {
+            toolArgs = props.getProperty(toolName + ".args", "");
+        }
+
+        if (toolProperty == null ||
+            askIfUnset && (toolName == null
+                || (argsProperty != null && toolArgs == null))) {
+            showGUI(props);
+        }
+
+        // finally, return required values, if any
+        if (toolProperty != null && !(toolName == null || toolName.equals(""))) {
+            p.setProperty(toolProperty, toolName);
+
+            if (argsProperty != null && toolArgs != null)
+                p.setProperty(argsProperty, toolArgs);
+        }
+    }
+
+    void showGUI(Properties fileProps) {
+        Properties guiProps = new Properties(fileProps);
+        JOptionPane p = createPane(guiProps);
+        p.createDialog("Select Tool").setVisible(true);
+
+        toolName = (String) toolChoice.getSelectedItem();
+        toolArgs = argsField.getText();
+
+        if (defaultCheck.isSelected()) {
+            if (toolName.equals("")) {
+                fileProps.remove("tool.name");
+            } else {
+                fileProps.put("tool.name", toolName);
+                fileProps.put(toolName + ".args", toolArgs);
+            }
+            writeProperties(propertyFile, fileProps);
+        }
+    }
+
+    JOptionPane createPane(final Properties props) {
+        JPanel body = new JPanel(new GridBagLayout());
+        GridBagConstraints lc = new GridBagConstraints();
+        lc.insets.right = 10;
+        lc.insets.bottom = 3;
+        GridBagConstraints fc = new GridBagConstraints();
+        fc.anchor = GridBagConstraints.WEST;
+        fc.gridx = 1;
+        fc.gridwidth = GridBagConstraints.REMAINDER;
+        fc.insets.bottom = 3;
+
+        JLabel toolLabel = new JLabel("Tool:");
+        body.add(toolLabel, lc);
+        String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" };
+        if (true || toolProperty == null) {
+            // include empty value in setup mode
+            List<String> l = new ArrayList<String>(Arrays.asList(toolChoices));
+            l.add(0, "");
+            toolChoices = l.toArray(new String[l.size()]);
+        }
+        toolChoice = new JComboBox(toolChoices);
+        if (toolName != null)
+            toolChoice.setSelectedItem(toolName);
+        toolChoice.addItemListener(new ItemListener() {
+            public void itemStateChanged(ItemEvent e) {
+                String tn = (String) e.getItem();
+                argsField.setText(getDefaultArgsForTool(props, tn));
+                if (toolProperty != null)
+                    okButton.setEnabled(!tn.equals(""));
+            }
+        });
+        body.add(toolChoice, fc);
+
+        argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40);
+        if (toolProperty == null || argsProperty != null) {
+            JLabel argsLabel = new JLabel("Args:");
+            body.add(argsLabel, lc);
+            body.add(argsField, fc);
+            argsField.addFocusListener(new FocusListener() {
+                public void focusGained(FocusEvent e) {
+                }
+                public void focusLost(FocusEvent e) {
+                    String toolName = (String) toolChoice.getSelectedItem();
+                    if (toolName.length() > 0)
+                        props.put(toolName + ".args", argsField.getText());
+                }
+            });
+        }
+
+        defaultCheck = new JCheckBox("Set as default");
+        if (toolProperty == null)
+            defaultCheck.setSelected(true);
+        else
+            body.add(defaultCheck, fc);
+
+        final JOptionPane p = new JOptionPane(body);
+        okButton = new JButton("OK");
+        okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
+        okButton.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
+                d.setVisible(false);
+            }
+        });
+        p.setOptions(new Object[] { okButton });
+
+        return p;
+    }
+
+    Properties readProperties(File file) {
+        Properties p = new Properties();
+        if (file != null && file.exists()) {
+            Reader in = null;
+            try {
+                in = new BufferedReader(new FileReader(file));
+                p.load(in);
+                in.close();
+            } catch (IOException e) {
+                throw new BuildException("error reading property file", e);
+            } finally {
+                if (in != null) {
+                    try {
+                        in.close();
+                    } catch (IOException e) {
+                        throw new BuildException("cannot close property file", e);
+                    }
+                }
+            }
+        }
+        return p;
+    }
+
+    void writeProperties(File file, Properties p) {
+        if (file != null) {
+            Writer out = null;
+            try {
+                File dir = file.getParentFile();
+                if (dir != null && !dir.exists())
+                    dir.mkdirs();
+                out = new BufferedWriter(new FileWriter(file));
+                p.store(out, "langtools properties");
+                out.close();
+            } catch (IOException e) {
+                throw new BuildException("error writing property file", e);
+            } finally {
+                if (out != null) {
+                    try {
+                        out.close();
+                    } catch (IOException e) {
+                        throw new BuildException("cannot close property file", e);
+                    }
+                }
+            }
+        }
+    }
+
+    String getDefaultArgsForTool(Properties props, String tn) {
+        return (tn == null || tn.equals("")) ? "" : props.getProperty(tn + ".args", "");
+    }
+
+    // Ant task parameters
+    private boolean askIfUnset;
+    private String toolProperty;
+    private String argsProperty;
+    private File propertyFile;
+
+    // GUI components
+    private JComboBox toolChoice;
+    private JTextField argsField;
+    private JCheckBox defaultCheck;
+    private JButton okButton;
+
+    // Result values for the client
+    private String toolName;
+    private String toolArgs;
+}
diff --git a/make/tools/compileproperties/CompileProperties.java b/make/tools/compileproperties/CompileProperties.java
new file mode 100644
index 0000000..7ee8b88
--- /dev/null
+++ b/make/tools/compileproperties/CompileProperties.java
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2002, 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 compileproperties;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/** Translates a .properties file into a .java file containing the
+ *  definition of a java.util.Properties subclass which can then be
+ *  compiled with javac. <P>
+ *
+ *  Usage: java CompileProperties [path to .properties file] [path to .java file to be output] [super class]
+ *
+ *  Infers the package by looking at the common suffix of the two
+ *  inputs, eliminating "classes" from it.
+ *
+ * @author Scott Violet
+ * @author Kenneth Russell
+ */
+
+public class CompileProperties {
+
+    public static void main(String[] args) {
+        CompileProperties cp = new CompileProperties();
+        boolean ok = cp.run(args);
+        if ( !ok ) {
+            System.exit(1);
+        }
+    }
+
+    public static interface Log {
+        void info(String msg);
+        void verbose(String msg);
+        void error(String msg, Exception e);
+    }
+
+    private String propfiles[];
+    private String outfiles[] ;
+    private String supers[]   ;
+    private int compileCount = 0;
+    private boolean quiet = false;
+    public Log log;
+
+    public void setLog(Log log) {
+        this.log = log;
+    }
+
+    public boolean run(String[] args) {
+        if (log == null) {
+            log = new Log() {
+                public void error(String msg, Exception e) {
+                    System.err.println("ERROR: CompileProperties: " + msg);
+                    if ( e != null ) {
+                        System.err.println("EXCEPTION: " + e.toString());
+                        e.printStackTrace();
+                    }
+                }
+                public void info(String msg) {
+                    System.out.println(msg);
+                }
+                public void verbose(String msg) {
+                    if (!quiet)
+                        System.out.println(msg);
+                }
+            };
+        }
+
+        boolean ok = true;
+        /* Original usage */
+        if (args.length == 2 && args[0].charAt(0) != '-' ) {
+            ok = createFile(args[0], args[1], "java.util.ListResourceBundle");
+        } else if (args.length == 3) {
+            ok = createFile(args[0], args[1], args[2]);
+        } else if (args.length == 0) {
+            usage(log);
+            ok = false;
+        } else {
+            /* New batch usage */
+            ok = parseOptions(args);
+            if ( ok && compileCount == 0 ) {
+                log.error("options parsed but no files to compile", null);
+                ok = false;
+            }
+            /* Need at least one file. */
+            if ( !ok ) {
+                usage(log);
+            } else {
+                /* Process files */
+                for ( int i = 0; i < compileCount && ok ; i++ ) {
+                    ok = createFile(propfiles[i], outfiles[i], supers[i]);
+                }
+            }
+        }
+        return ok;
+    }
+
+    private boolean parseOptions(String args[]) {
+        boolean ok = true;
+        if ( compileCount > 0 ) {
+            String new_propfiles[] = new String[compileCount + args.length];
+            String new_outfiles[]  = new String[compileCount + args.length];
+            String new_supers[]    = new String[compileCount + args.length];
+            System.arraycopy(propfiles, 0, new_propfiles, 0, compileCount);
+            System.arraycopy(outfiles, 0, new_outfiles, 0, compileCount);
+            System.arraycopy(supers, 0, new_supers, 0, compileCount);
+            propfiles = new_propfiles;
+            outfiles  = new_outfiles;
+            supers    = new_supers;
+        } else {
+            propfiles = new String[args.length];
+            outfiles  = new String[args.length];
+            supers    = new String[args.length];
+        }
+
+        for ( int i = 0; i < args.length ; i++ ) {
+            if ( "-compile".equals(args[i]) && i+3 < args.length ) {
+                propfiles[compileCount] = args[++i];
+                outfiles[compileCount]  = args[++i];
+                supers[compileCount]    = args[++i];
+                compileCount++;
+            } else if ( "-optionsfile".equals(args[i]) && i+1 < args.length ) {
+                String filename = args[++i];
+                FileInputStream finput = null;
+                byte contents[] = null;
+                try {
+                    finput = new FileInputStream(filename);
+                    int byteCount = finput.available();
+                    if ( byteCount <= 0 ) {
+                        log.error("The -optionsfile file is empty", null);
+                        ok = false;
+                    } else {
+                        contents = new byte[byteCount];
+                        int bytesRead = finput.read(contents);
+                        if ( byteCount != bytesRead ) {
+                            log.error("Cannot read all of -optionsfile file", null);
+                            ok = false;
+                        }
+                    }
+                } catch ( IOException e ) {
+                    log.error("cannot open " + filename, e);
+                    ok = false;
+                }
+                if ( finput != null ) {
+                    try {
+                        finput.close();
+                    } catch ( IOException e ) {
+                        ok = false;
+                        log.error("cannot close " + filename, e);
+                    }
+                }
+                if ( ok = true && contents != null ) {
+                    String tokens[] = (new String(contents)).split("\\s+");
+                    if ( tokens.length > 0 ) {
+                        ok = parseOptions(tokens);
+                    }
+                }
+                if ( !ok ) {
+                    break;
+                }
+            } else if ( "-quiet".equals(args[i]) ) {
+                quiet = true;
+            } else {
+                log.error("argument error", null);
+                ok = false;
+            }
+        }
+        return ok;
+    }
+
+    private boolean createFile(String propertiesPath, String outputPath,
+            String superClass) {
+        boolean ok = true;
+        log.verbose("parsing: " + propertiesPath);
+        Properties p = new Properties();
+        try {
+            p.load(new FileInputStream(propertiesPath));
+        } catch ( FileNotFoundException e ) {
+            ok = false;
+            log.error("Cannot find file " + propertiesPath, e);
+        } catch ( IOException e ) {
+            ok = false;
+            log.error("IO error on file " + propertiesPath, e);
+        }
+        if ( ok ) {
+            String packageName = inferPackageName(propertiesPath, outputPath);
+            log.verbose("inferred package name: " + packageName);
+            List<String> sortedKeys = new ArrayList<String>();
+            for ( Object key : p.keySet() ) {
+                sortedKeys.add((String)key);
+            }
+            Collections.sort(sortedKeys);
+            Iterator<String> keys = sortedKeys.iterator();
+
+            StringBuffer data = new StringBuffer();
+
+            while (keys.hasNext()) {
+                String key = keys.next();
+                data.append("            { \"" + escape(key) + "\", \"" +
+                        escape((String)p.get(key)) + "\" },\n");
+            }
+
+            // Get class name from java filename, not the properties filename.
+            //   (zh_TW properties might be used to create zh_HK files)
+            File file = new File(outputPath);
+            String name = file.getName();
+            int dotIndex = name.lastIndexOf('.');
+            String className;
+            if (dotIndex == -1) {
+                className = name;
+            } else {
+                className = name.substring(0, dotIndex);
+            }
+
+            String packageString = "";
+            if (packageName != null && !packageName.equals("")) {
+                packageString = "package " + packageName + ";\n\n";
+            }
+
+            Writer writer = null;
+            try {
+                writer = new BufferedWriter(
+                        new OutputStreamWriter(new FileOutputStream(outputPath), "8859_1"));
+                MessageFormat format = new MessageFormat(FORMAT);
+                writer.write(format.format(new Object[] { packageString, className, superClass, data }));
+            } catch ( IOException e ) {
+                ok = false;
+                log.error("IO error writing to file " + outputPath, e);
+            }
+            if ( writer != null ) {
+                try {
+                    writer.flush();
+                } catch ( IOException e ) {
+                    ok = false;
+                    log.error("IO error flush " + outputPath, e);
+                }
+                try {
+                    writer.close();
+                } catch ( IOException e ) {
+                    ok = false;
+                    log.error("IO error close " + outputPath, e);
+                }
+            }
+            log.verbose("wrote: " + outputPath);
+        }
+        return ok;
+    }
+
+    private static void usage(Log log) {
+        log.info("usage:");
+        log.info("    java CompileProperties path_to_properties_file path_to_java_output_file [super_class]");
+        log.info("      -OR-");
+        log.info("    java CompileProperties {-compile path_to_properties_file path_to_java_output_file super_class} -or- -optionsfile filename");
+        log.info("");
+        log.info("Example:");
+        log.info("    java CompileProperties -compile test.properties test.java java.util.ListResourceBundle");
+        log.info("    java CompileProperties -optionsfile option_file");
+        log.info("option_file contains: -compile test.properties test.java java.util.ListResourceBundle");
+    }
+
+    private static String escape(String theString) {
+        // This is taken from Properties.saveConvert with changes for Java strings
+        int len = theString.length();
+        StringBuffer outBuffer = new StringBuffer(len*2);
+
+        for(int x=0; x<len; x++) {
+            char aChar = theString.charAt(x);
+            switch(aChar) {
+                case '\\':outBuffer.append('\\'); outBuffer.append('\\');
+                break;
+                case '\t':outBuffer.append('\\'); outBuffer.append('t');
+                break;
+                case '\n':outBuffer.append('\\'); outBuffer.append('n');
+                break;
+                case '\r':outBuffer.append('\\'); outBuffer.append('r');
+                break;
+                case '\f':outBuffer.append('\\'); outBuffer.append('f');
+                break;
+                default:
+                    if ((aChar < 0x0020) || (aChar > 0x007e)) {
+                        outBuffer.append('\\');
+                        outBuffer.append('u');
+                        outBuffer.append(toHex((aChar >> 12) & 0xF));
+                        outBuffer.append(toHex((aChar >>  8) & 0xF));
+                        outBuffer.append(toHex((aChar >>  4) & 0xF));
+                        outBuffer.append(toHex( aChar        & 0xF));
+                    } else {
+                        if (specialSaveChars.indexOf(aChar) != -1) {
+                            outBuffer.append('\\');
+                        }
+                        outBuffer.append(aChar);
+                    }
+            }
+        }
+        return outBuffer.toString();
+    }
+
+    private static String inferPackageName(String inputPath, String outputPath) {
+        // Normalize file names
+        inputPath  = new File(inputPath).getPath();
+        outputPath = new File(outputPath).getPath();
+        // Split into components
+        String sep;
+        if (File.separatorChar == '\\') {
+            sep = "\\\\";
+        } else {
+            sep = File.separator;
+        }
+        String[] inputs  = inputPath.split(sep);
+        String[] outputs = outputPath.split(sep);
+        // Match common names, eliminating first "classes" entry from
+        // each if present
+        int inStart  = 0;
+        int inEnd    = inputs.length - 2;
+        int outEnd   = outputs.length - 2;
+        int i = inEnd;
+        int j = outEnd;
+        while (i >= 0 && j >= 0) {
+            if (!inputs[i].equals(outputs[j]) ||
+                    (inputs[i].equals("gensrc") && inputs[j].equals("gensrc"))) {
+                ++i;
+                ++j;
+                break;
+            }
+            --i;
+            --j;
+        }
+        String result;
+        if (i < 0 || j < 0 || i >= inEnd || j >= outEnd) {
+            result = "";
+        } else {
+            if (inputs[i].equals("classes") && outputs[j].equals("classes")) {
+                ++i;
+            }
+            inStart = i;
+            StringBuffer buf = new StringBuffer();
+            for (i = inStart; i <= inEnd; i++) {
+                buf.append(inputs[i]);
+                if (i < inEnd) {
+                    buf.append('.');
+                }
+            }
+            result = buf.toString();
+        }
+        return result;
+    }
+
+    private static final String FORMAT =
+            "{0}" +
+            "public final class {1} extends {2} '{'\n" +
+            "    protected final Object[][] getContents() '{'\n" +
+            "        return new Object[][] '{'\n" +
+            "{3}" +
+            "        };\n" +
+            "    }\n" +
+            "}\n";
+
+    // This comes from Properties
+    private static char toHex(int nibble) {
+        return hexDigit[(nibble & 0xF)];
+    }
+
+    // This comes from Properties
+    private static final char[] hexDigit = {
+        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
+    };
+
+    // Note: different from that in Properties
+    private static final String specialSaveChars = "\"";
+}
diff --git a/make/tools/crules/AbstractCodingRulesAnalyzer.java b/make/tools/crules/AbstractCodingRulesAnalyzer.java
new file mode 100644
index 0000000..a4f3a3a
--- /dev/null
+++ b/make/tools/crules/AbstractCodingRulesAnalyzer.java
@@ -0,0 +1,117 @@
+/*
+ * 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 crules;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Plugin;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.BasicJavacTask;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+
+import static com.sun.source.util.TaskEvent.Kind;
+
+public abstract class AbstractCodingRulesAnalyzer implements Plugin {
+
+    protected Log log;
+    protected Trees trees;
+    protected TreeScanner treeVisitor;
+    protected Kind eventKind;
+    protected Messages messages;
+
+    public void init(JavacTask task, String... args) {
+        BasicJavacTask impl = (BasicJavacTask)task;
+        Context context = impl.getContext();
+        log = Log.instance(context);
+        trees = Trees.instance(task);
+        messages = new Messages();
+        task.addTaskListener(new PostAnalyzeTaskListener());
+    }
+
+    public class PostAnalyzeTaskListener implements TaskListener {
+
+        @Override
+        public void started(TaskEvent taskEvent) {}
+
+        @Override
+        public void finished(TaskEvent taskEvent) {
+            if (taskEvent.getKind().equals(eventKind)) {
+                TypeElement typeElem = taskEvent.getTypeElement();
+                Tree tree = trees.getTree(typeElem);
+                if (tree != null) {
+                    JavaFileObject prevSource = log.currentSourceFile();
+                    try {
+                        log.useSource(taskEvent.getCompilationUnit().getSourceFile());
+                        treeVisitor.scan((JCTree)tree);
+                    } finally {
+                        log.useSource(prevSource);
+                    }
+                }
+            }
+        }
+    }
+
+    class Messages {
+        ResourceBundle bundle;
+
+        Messages() {
+            String name = getClass().getPackage().getName() + ".resources.crules";
+            bundle = ResourceBundle.getBundle(name, Locale.ENGLISH);
+        }
+
+        public void error(JCTree tree, String code, Object... args) {
+            String msg = (code == null) ? (String) args[0] : localize(code, args);
+            log.error(tree, "proc.messager", msg.toString());
+        }
+
+        private String localize(String code, Object... args) {
+            String msg = bundle.getString(code);
+            if (msg == null) {
+                StringBuilder sb = new StringBuilder();
+                sb.append("message file broken: code=").append(code);
+                if (args.length > 0) {
+                    sb.append(" arguments={0}");
+                    for (int i = 1; i < args.length; i++) {
+                        sb.append(", {").append(i).append("}");
+                    }
+                }
+                msg = sb.toString();
+            }
+            return MessageFormat.format(msg, args);
+        }
+    }
+
+}
diff --git a/make/tools/crules/MutableFieldsAnalyzer.java b/make/tools/crules/MutableFieldsAnalyzer.java
new file mode 100644
index 0000000..0a7e6d1
--- /dev/null
+++ b/make/tools/crules/MutableFieldsAnalyzer.java
@@ -0,0 +1,118 @@
+/*
+ * 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 crules;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.tree.TreeScanner;
+
+import static com.sun.source.util.TaskEvent.Kind;
+import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+
+public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer {
+
+    public MutableFieldsAnalyzer() {
+        treeVisitor = new MutableFieldsVisitor();
+        eventKind = Kind.ANALYZE;
+    }
+
+    public String getName() {
+        return "mutable_fields_analyzer";
+    }
+
+    private boolean ignoreField(String className, String field) {
+        List<String> currentFieldsToIgnore =
+                classFieldsToIgnoreMap.get(className);
+        if (currentFieldsToIgnore != null) {
+            for (String fieldToIgnore : currentFieldsToIgnore) {
+                if (field.equals(fieldToIgnore)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    class MutableFieldsVisitor extends TreeScanner {
+
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            boolean isJavacPack = tree.sym.outermostClass().fullname.toString()
+                    .contains(packageToCheck);
+            if (isJavacPack &&
+                (tree.sym.flags() & SYNTHETIC) == 0 &&
+                tree.sym.owner.kind == Kinds.TYP) {
+                if (!ignoreField(tree.sym.owner.flatName().toString(),
+                        tree.getName().toString())) {
+                    boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
+                    boolean nonFinalStaticEnumField =
+                            (tree.sym.flags() & (ENUM | FINAL)) == 0;
+                    boolean nonFinalStaticField =
+                            (tree.sym.flags() & STATIC) != 0 &&
+                            (tree.sym.flags() & FINAL) == 0;
+                    if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
+                        messages.error(tree, "crules.err.var.must.be.final", tree);
+                    }
+                }
+            }
+            super.visitVarDef(tree);
+        }
+
+    }
+
+    private static final String packageToCheck = "com.sun.tools.javac";
+
+    private static final Map<String, List<String>> classFieldsToIgnoreMap =
+                new HashMap<String, List<String>>();
+
+    static {
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.util.JCDiagnostic",
+                    Arrays.asList("fragmentFormatter"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.util.JavacMessages",
+                    Arrays.asList("defaultBundle", "defaultMessages"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.file.ZipFileIndexCache",
+                    Arrays.asList("sharedInstance"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.main.JavaCompiler",
+                    Arrays.asList("versionRB"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.code.Type",
+                    Arrays.asList("moreInfo"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.util.SharedNameTable",
+                    Arrays.asList("freelist"));
+        classFieldsToIgnoreMap.
+                put("com.sun.tools.javac.util.Log",
+                    Arrays.asList("useRawMessages"));
+    }
+
+}
diff --git a/make/tools/crules/resources/crules.properties b/make/tools/crules/resources/crules.properties
new file mode 100644
index 0000000..9ae44b5
--- /dev/null
+++ b/make/tools/crules/resources/crules.properties
@@ -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.  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.
+#
+
+# 0: symbol
+crules.err.var.must.be.final=\
+    Static variable {0} must be final
diff --git a/make/tools/genstubs/GenStubs.java b/make/tools/genstubs/GenStubs.java
new file mode 100644
index 0000000..ffa95c9
--- /dev/null
+++ b/make/tools/genstubs/GenStubs.java
@@ -0,0 +1,336 @@
+/*
+ * 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.  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 genstubs;
+
+import java.io.*;
+import java.util.*;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+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;
+import com.sun.tools.javac.tree.JCTree.JCImport;
+import com.sun.tools.javac.tree.JCTree.JCLiteral;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCModifiers;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.Pretty;
+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.util.Context;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Name;
+import javax.tools.JavaFileManager;
+
+/**
+ * Generate stub source files by removing implementation details from input files.
+ *
+ * This is a special purpose stub generator, specific to the needs of generating
+ * stub files for JDK 7 API that are needed to compile langtools files that depend
+ * on that API. The stub generator works by removing as much of the API source code
+ * as possible without affecting the public signature, in order to reduce the
+ * transitive closure of the API being referenced. The resulting stubs can be
+ * put on the langtools sourcepath with -implicit:none to compile the langtools
+ * files that depend on the JDK 7 API.
+ *
+ * Usage:
+ *  genstubs -s <outdir> -sourcepath <path> <classnames>
+ *
+ * The specified class names are looked up on the sourcepath, and corresponding
+ * stubs are written to the source output directory.
+ *
+ * Classes are parsed into javac ASTs, then processed with a javac TreeTranslator
+ * to remove implementation details, and written out in the source output directory.
+ * Documentation comments and annotations are removed. Method bodies are removed
+ * and methods are marked native. Private and package-private field definitions
+ * have their initializers replace with 0, 0.0, false, null as appropriate.
+ */
+
+public class GenStubs {
+    static class Fault extends Exception {
+        private static final long serialVersionUID = 0;
+        Fault(String message) {
+            super(message);
+        }
+        Fault(String message, Throwable cause) {
+            super(message);
+            initCause(cause);
+        }
+    }
+
+    public static void main(String[] args) {
+        boolean ok = new GenStubs().run(args);
+        if (!ok)
+            System.exit(1);
+    }
+
+    public boolean run(String... args) {
+        File outdir = null;
+        String sourcepath = null;
+        List<String> classes = new ArrayList<String>();
+        for (ListIterator<String> iter = Arrays.asList(args).listIterator(); iter.hasNext(); ) {
+            String arg = iter.next();
+            if (arg.equals("-s") && iter.hasNext())
+                outdir = new File(iter.next());
+            else if (arg.equals("-sourcepath") && iter.hasNext())
+                sourcepath = iter.next();
+            else if (arg.startsWith("-"))
+                throw new IllegalArgumentException(arg);
+            else {
+                classes.add(arg);
+                while (iter.hasNext())
+                    classes.add(iter.next());
+            }
+        }
+
+        return run(sourcepath, outdir, classes);
+    }
+
+    public boolean run(String sourcepath, File outdir, List<String> classes) {
+        //System.err.println("run: sourcepath:" + sourcepath + " outdir:" + outdir + " classes:" + classes);
+        if (sourcepath == null)
+            throw new IllegalArgumentException("sourcepath not set");
+        if (outdir == null)
+            throw new IllegalArgumentException("source output dir not set");
+
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+
+        try {
+            fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(outdir));
+            fm.setLocation(StandardLocation.SOURCE_PATH, splitPath(sourcepath));
+            List<JavaFileObject> files = new ArrayList<JavaFileObject>();
+            for (String c: classes) {
+                JavaFileObject fo = fm.getJavaFileForInput(
+                        StandardLocation.SOURCE_PATH, c, JavaFileObject.Kind.SOURCE);
+                if (fo == null)
+                    error("class not found: " + c);
+                else
+                    files.add(fo);
+            }
+
+            JavacTask t = tool.getTask(null, fm, null, null, null, files);
+            Iterable<? extends CompilationUnitTree> trees = t.parse();
+            for (CompilationUnitTree tree: trees) {
+                makeStub(fm, tree);
+            }
+        } catch (IOException e) {
+            error("IO error " + e, e);
+        }
+
+        return (errors == 0);
+    }
+
+    void makeStub(StandardJavaFileManager fm, CompilationUnitTree tree) throws IOException {
+        CompilationUnitTree tree2 = new StubMaker().translate(tree);
+        CompilationUnitTree tree3 = new ImportCleaner(fm).removeRedundantImports(tree2);
+
+        String className = fm.inferBinaryName(StandardLocation.SOURCE_PATH, tree.getSourceFile());
+        JavaFileObject fo = fm.getJavaFileForOutput(StandardLocation.SOURCE_OUTPUT,
+                className, JavaFileObject.Kind.SOURCE, null);
+        // System.err.println("Writing " + className + " to " + fo.getName());
+        Writer out = fo.openWriter();
+        try {
+            new Pretty(out, true).printExpr((JCTree) tree3);
+        } finally {
+            out.close();
+        }
+    }
+
+    List<File> splitPath(String path) {
+        List<File> list = new ArrayList<File>();
+        for (String p: path.split(File.pathSeparator)) {
+            if (p.length() > 0)
+                list.add(new File(p));
+        }
+        return list;
+    }
+
+    void error(String message) {
+        System.err.println(message);
+        errors++;
+    }
+
+    void error(String message, Throwable cause) {
+        error(message);
+    }
+
+    int errors;
+
+    class StubMaker extends TreeTranslator {
+        CompilationUnitTree translate(CompilationUnitTree tree) {
+            return super.translate((JCCompilationUnit) tree);
+        }
+
+        /**
+         * compilation units: remove javadoc comments
+         * -- required, in order to remove @deprecated tags, since we
+         * (separately) remove all annotations, including @Deprecated
+         */
+        public void visitTopLevel(JCCompilationUnit tree) {
+            super.visitTopLevel(tree);
+            tree.docComments = null;
+        }
+
+        /**
+         * 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);
+            tree.typarams = translateTypeParams(tree.typarams);
+            tree.params = translateVarDefs(tree.params);
+            tree.thrown = translate(tree.thrown);
+            if (tree.body != null) {
+                if ((currClassMods & Flags.INTERFACE) != 0) {
+                    tree.mods.flags &= ~(Flags.DEFAULT | Flags.STATIC);
+                } else {
+                    tree.mods.flags |= Flags.NATIVE;
+                }
+                tree.body = null;
+            }
+            result = tree;
+        }
+
+        /**
+         * modifiers: remove annotations
+         */
+        @Override
+        public void visitModifiers(JCModifiers tree) {
+            tree.annotations = com.sun.tools.javac.util.List.nil();
+            result = tree;
+        }
+
+        /**
+         * field definitions: replace initializers with 0, 0.0, false etc
+         * when possible -- i.e. leave public, protected initializers alone
+         */
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            tree.mods = translate(tree.mods);
+            tree.vartype = translate(tree.vartype);
+            if (tree.init != null) {
+                if ((tree.mods.flags & (Flags.PUBLIC | Flags.PROTECTED)) != 0)
+                    tree.init = translate(tree.init);
+                else {
+                    String t = tree.vartype.toString();
+                    if (t.equals("boolean"))
+                        tree.init = new JCLiteral(TypeTag.BOOLEAN, 0) { };
+                    else if (t.equals("byte"))
+                        tree.init = new JCLiteral(TypeTag.BYTE, 0) { };
+                    else if (t.equals("char"))
+                        tree.init = new JCLiteral(TypeTag.CHAR, 0) { };
+                    else if (t.equals("double"))
+                        tree.init = new JCLiteral(TypeTag.DOUBLE, 0.d) { };
+                    else if (t.equals("float"))
+                        tree.init = new JCLiteral(TypeTag.FLOAT, 0.f) { };
+                    else if (t.equals("int"))
+                        tree.init = new JCLiteral(TypeTag.INT, 0) { };
+                    else if (t.equals("long"))
+                        tree.init = new JCLiteral(TypeTag.LONG, 0) { };
+                    else if (t.equals("short"))
+                        tree.init = new JCLiteral(TypeTag.SHORT, 0) { };
+                    else
+                        tree.init = new JCLiteral(TypeTag.BOT, null) { };
+                }
+            }
+            result = tree;
+        }
+    }
+
+    class ImportCleaner extends TreeScanner {
+        private Set<Name> names = new HashSet<Name>();
+        private TreeMaker m;
+
+        ImportCleaner(JavaFileManager fm) {
+            // ImportCleaner itself doesn't require a filemanager, but instantiating
+            // a TreeMaker does, indirectly (via ClassReader, sigh)
+            Context c = new Context();
+            c.put(JavaFileManager.class, fm);
+            m = TreeMaker.instance(c);
+        }
+
+        CompilationUnitTree removeRedundantImports(CompilationUnitTree t) {
+            JCCompilationUnit tree = (JCCompilationUnit) t;
+            tree.accept(this);
+            ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
+            for (JCTree def: tree.defs) {
+                if (def.getTag() == JCTree.Tag.IMPORT) {
+                    JCImport imp = (JCImport) def;
+                    if (imp.qualid.getTag() == JCTree.Tag.SELECT) {
+                        JCFieldAccess qualid = (JCFieldAccess) imp.qualid;
+                        if (!qualid.name.toString().equals("*")
+                                && !names.contains(qualid.name)) {
+                            continue;
+                        }
+                    }
+                }
+                defs.add(def);
+            }
+            return m.TopLevel(tree.packageAnnotations, tree.pid, defs.toList());
+        }
+
+        @Override
+        public void visitImport(JCImport tree) { } // ignore names found in imports
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            names.add(tree.name);
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            super.visitSelect(tree);
+            names.add(tree.name);
+        }
+    }
+}
diff --git a/makefiles/BuildLangtools.gmk b/makefiles/BuildLangtools.gmk
new file mode 100644
index 0000000..57d216b
--- /dev/null
+++ b/makefiles/BuildLangtools.gmk
@@ -0,0 +1,192 @@
+#
+# 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
+# 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.
+#
+
+# This must be the first rule
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+include JavaCompilation.gmk
+
+# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools
+# and the bootstrap javac, to be run by the bootdir jvm.
+$(eval $(call SetupJavaCompiler,BOOT_JAVAC,\
+	JAVAC:=$(JAVAC),\
+        SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+        SERVER_JVM:=$(SJAVAC_SERVER_JAVA),\
+        FLAGS:=-XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror))
+
+# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied.
+RESOURCE_SUFFIXES:=.gif .xml .css .js javax.tools.JavaCompilerTool
+
+# Now setup the compilation of the properties compilation tool. You can depend
+# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we
+# add src/share/classes to the sourcepath. This is necessary since the GenStubs
+# program needs to be linked and run towards the new javac sources.
+$(eval $(call SetupJavaCompilation,BUILD_TOOLS,\
+		SETUP:=BOOT_JAVAC,\
+		DISABLE_SJAVAC:=true,\
+                ADD_JAVAC_FLAGS:=-Xprefer:source,\
+		SRC:=$(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes,\
+		INCLUDES:=compileproperties genstubs,\
+		BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses))
+
+# The compileprops tools compiles a properties file into a resource bundle.
+TOOL_COMPILEPROPS_CMD:=$(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet
+# Lookup the properties that need to be compiled into resource bundles.
+PROPSOURCES:=$(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties")
+# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN"
+PROPPATHS:=$(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties,%,$(PROPSOURCES))
+# Generate the list of java files to be created.
+PROPJAVAS:=$(patsubst %,$(LANGTOOLS_OUTPUTDIR)/gensrc/%.java,$(PROPPATHS))
+# Generate the package dirs for the tobe generated java files.
+PROPDIRS:=$(dir $(PROPJAVAS))
+# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
+# suitable to be fed into the CompileProperties command.
+PROPCMDLINE:=$(subst _SPACE_,$(SPACE),$(join $(addprefix -compile_SPACE_,$(PROPSOURCES)), \
+		$(addsuffix _SPACE_java.util.ListResourceBundle,$(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/,$(addsuffix .java,$(PROPPATHS))))))
+
+# Now setup the rule for the generation of the resource bundles.
+$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d : $(PROPSOURCES) $(BUILD_TOOLS)
+	$(RM) -r $(@D)/*
+	$(MKDIR) -p $(@D) $(PROPDIRS)
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties
+	$(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties
+	$(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles
+	$(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \
+		-compile 	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \
+				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \
+				java.util.ListResourceBundle \
+		-compile 	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \
+				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \
+				java.util.ListResourceBundle \
+		-compile	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \
+				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \
+				java.util.ListResourceBundle \
+		-compile	$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \
+				$(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \
+				java.util.ListResourceBundle
+	$(ECHO) PROPS_ARE_CREATED=yes > $@
+
+# Trigger the generation of the resource bundles. After the resource bundles have
+# been compiled, then the makefile will restart and the newly created java files
+# will become part of the build further along in the makefile.
+-include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
+
+ifeq ($(PROPS_ARE_CREATED),yes)
+        # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac
+        # that can be compiled with an old javac. The intermediate javac is then used
+        # to compile javac again and to build the complete new jdk.
+        $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS,\
+		SETUP:=BOOT_JAVAC,\
+		DISABLE_SJAVAC:=true,\
+		SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
+		EXCLUDES:=com/sun/tools/javac/nio,\
+		COPY:=$(RESOURCE_SUFFIXES),\
+		BIN:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap))
+
+        $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC,$(BUILD_BOOTSTRAP_LANGTOOLS),\
+		SRCS:=$(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap,\
+		JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar,\
+		SUFFIXES:=.class $(RESOURCE_SUFFIXES)))
+
+        # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not 
+        # yet built. It is currently not needed but might be again in the future. The following
+        # exercises the functionality to verify that it works.
+        TOOL_GENSTUBS_CMD=$(JAVA) \
+             "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
+             -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \
+             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/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/function/Predicate.java")
+        # Rewrite the file names into class names because the GenStubs tool require this.
+        STUBCLASSES:=$(subst /,.,$(patsubst $(JDKS)/%.java,%,$(STUBSOURCES)))
+
+        # Now setup the build recipe for genstubs.
+        $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d : $(STUBSOURCES) $(BUILD_TOOLS) \
+				$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
+				$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d
+	       	$(MKDIR) -p $(@D)
+		$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
+	       	$(ECHO) $(LOG_INFO) Generating stubs from JDK sources.
+	       	($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED=yes > $@)
+		if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \
+			$(ECHO) $(LOG_INFO) No changes in the stubs!; \
+			$(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
+		else \
+			$(ECHO) $(LOG_INFO) Changes in stubs detected!; \
+			$(RM) -r $(@D); \
+			$(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
+		fi
+		$(ECHO) STUBS_ARE_CREATED=yes > $@
+
+        # Trigger a generation of the genstubs java source code and a restart
+        # of the makefile to make sure that the following build setup use the 
+        # newly created java files.
+        -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d
+
+	ifeq ($(STUBS_ARE_CREATED),yes)
+                # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar
+                # that generates code for the new jdk that is being built.
+                # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm.
+                $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE,\
+                  JVM:=$(JAVA),\
+                  JAVAC:="-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
+			 -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \
+			 com.sun.tools.javac.Main,\
+                  FLAGS:=-XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror,\
+                  SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
+                  SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
+
+                $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC,\
+			SETUP:=GENERATE_NEWBYTECODE,\
+			SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \
+			     $(LANGTOOLS_OUTPUTDIR)/genstubs,\
+			EXCLUDES:=java/util java/io java/nio,\
+			COPY:=$(RESOURCE_SUFFIXES),\
+			BIN:=$(LANGTOOLS_OUTPUTDIR)/classes))
+
+                $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC,$(BUILD_FULL_JAVAC),\
+			SETUP:=GENERATE_NEWBYTECODE,\
+			SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\
+			SUFFIXES:=.class $(RESOURCE_SUFFIXES),\
+			JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
+
+                $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\
+			SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
+			ZIP:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip))
+
+                all: 		$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \
+				$(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \
+	                 	$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
+
+        endif
+endif
diff --git a/makefiles/Makefile b/makefiles/Makefile
new file mode 100644
index 0000000..9539fe0
--- /dev/null
+++ b/makefiles/Makefile
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# Locate this Makefile
+ifeq ($(filter /%,$(lastword $(MAKEFILE_LIST))),)
+    makefile_path:=$(CURDIR)/$(lastword $(MAKEFILE_LIST))
+else
+    makefile_path:=$(lastword $(MAKEFILE_LIST))
+endif
+repo_dir:=$(patsubst %/makefiles/Makefile,%,$(makefile_path))
+
+# What is the name of this subsystem (langtools, corba, etc)?
+subsystem_name:=$(notdir $(repo_dir))
+
+# Try to locate top-level makefile
+top_level_makefile:=$(repo_dir)/../common/makefiles/Makefile
+ifneq ($(wildcard $(top_level_makefile)),)
+  $(info Will run $(subsystem_name) target on top-level Makefile)
+  $(info WARNING: This is a non-recommended way of building!)
+  $(info ===================================================)
+else
+  $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
+  $(error Build from top-level Makefile instead)
+endif
+
+all:
+	@$(MAKE) -f $(top_level_makefile) $(subsystem_name)
diff --git a/src/share/classes/com/sun/javadoc/AnnotatedType.java b/src/share/classes/com/sun/javadoc/AnnotatedType.java
new file mode 100644
index 0000000..c39260e
--- /dev/null
+++ b/src/share/classes/com/sun/javadoc/AnnotatedType.java
@@ -0,0 +1,45 @@
+/*
+ * 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.javadoc;
+
+
+/**
+ * Represents an annotated type.
+ * For example:
+ * <pre>
+ *      {@code @NonNull String}
+ *      {@code @Positive int}
+ * </pre>
+ *
+ * @author Mahmood Ali
+ * @since 1.8
+ */
+public interface AnnotatedType extends Type {
+
+    AnnotationDesc[] annotations();
+
+    Type underlyingType();
+}
diff --git a/src/share/classes/com/sun/javadoc/AnnotationDesc.java b/src/share/classes/com/sun/javadoc/AnnotationDesc.java
index 068763b..bf99121 100644
--- a/src/share/classes/com/sun/javadoc/AnnotationDesc.java
+++ b/src/share/classes/com/sun/javadoc/AnnotationDesc.java
@@ -52,6 +52,12 @@ public interface AnnotationDesc {
      */
     ElementValuePair[] elementValues();
 
+    /**
+     * Check for the synthesized bit on the annotation.
+     *
+     * @return true if the annotation is synthesized.
+     */
+    boolean isSynthesized();
 
     /**
      * Represents an association between an annotation type element
diff --git a/src/share/classes/com/sun/javadoc/ClassDoc.java b/src/share/classes/com/sun/javadoc/ClassDoc.java
index 8eda69b..bf05b41 100644
--- a/src/share/classes/com/sun/javadoc/ClassDoc.java
+++ b/src/share/classes/com/sun/javadoc/ClassDoc.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,6 +66,12 @@ public interface ClassDoc extends ProgramElementDoc, Type {
     boolean isExternalizable();
 
     /**
+     * Return true if this class can be used as a target type of a lambda expression
+     * or method reference.
+     */
+    boolean isFunctionalInterface();
+
+    /**
      * Return the serialization methods for this class or
      * interface.
      *
diff --git a/src/share/classes/com/sun/javadoc/Doc.java b/src/share/classes/com/sun/javadoc/Doc.java
index ae2e933..c258eeb 100644
--- a/src/share/classes/com/sun/javadoc/Doc.java
+++ b/src/share/classes/com/sun/javadoc/Doc.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@ public interface Doc extends Comparable<Object> {
 
     /**
      * Return comment as an array of tags. Includes inline tags
-     * (i.e. {&#64link <i>reference</i>} tags)  but not
+     * (i.e. {@link <i>reference</i>} tags)  but not
      * block tags.
      * Each section of plain text is represented as a {@link Tag}
      * of {@linkplain Tag#kind() kind} "Text".
@@ -90,7 +90,7 @@ public interface Doc extends Comparable<Object> {
     /**
      * Return the first sentence of the comment as an array of tags.
      * Includes inline tags
-     * (i.e. {&#64link <i>reference</i>} tags)  but not
+     * (i.e. {@link <i>reference</i>} tags)  but not
      * block tags.
      * Each section of plain text is represented as a {@link Tag}
      * of {@linkplain Tag#kind() kind} "Text".
diff --git a/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java b/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java
index 55fdeab..8792c9c 100644
--- a/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java
+++ b/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, 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
@@ -88,10 +88,18 @@ public interface ExecutableMemberDoc extends MemberDoc {
     Parameter[] parameters();
 
     /**
+     * Get the receiver type of this executable element.
+     *
+     * @return the receiver type of this executable element.
+     * @since 1.8
+     */
+    Type receiverType();
+
+    /**
      * Return the throws tags in this method.
      *
-     * @return an array of ThrowTag containing all <code>&#64exception</code>
-     * and <code>&#64throws</code> tags.
+     * @return an array of ThrowTag containing all <code>@exception</code>
+     * and <code>@throws</code> tags.
      */
     ThrowsTag[] throwsTags();
 
@@ -99,7 +107,7 @@ public interface ExecutableMemberDoc extends MemberDoc {
      * Return the param tags in this method, excluding the type
      * parameter tags.
      *
-     * @return an array of ParamTag containing all <code>&#64param</code> tags
+     * @return an array of ParamTag containing all <code>@param</code> tags
      * corresponding to the parameters of this method.
      */
     ParamTag[] paramTags();
@@ -107,7 +115,7 @@ public interface ExecutableMemberDoc extends MemberDoc {
     /**
      * Return the type parameter tags in this method.
      *
-     * @return an array of ParamTag containing all <code>&#64param</code> tags
+     * @return an array of ParamTag containing all <code>@param</code> tags
      * corresponding to the type parameters of this method.
      * @since 1.5
      */
diff --git a/src/share/classes/com/sun/javadoc/MethodDoc.java b/src/share/classes/com/sun/javadoc/MethodDoc.java
index 16b678e..83bc03f 100644
--- a/src/share/classes/com/sun/javadoc/MethodDoc.java
+++ b/src/share/classes/com/sun/javadoc/MethodDoc.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,11 @@ public interface MethodDoc extends ExecutableMemberDoc {
     boolean isAbstract();
 
     /**
+     * Return true if this method is default
+     */
+    boolean isDefault();
+
+    /**
      * Get return type.
      *
      * @return the return type of this method, null if it
diff --git a/src/share/classes/com/sun/javadoc/SerialFieldTag.java b/src/share/classes/com/sun/javadoc/SerialFieldTag.java
index ad32c1a..7f73936 100644
--- a/src/share/classes/com/sun/javadoc/SerialFieldTag.java
+++ b/src/share/classes/com/sun/javadoc/SerialFieldTag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@ package com.sun.javadoc;
 public interface SerialFieldTag extends Tag, Comparable<Object> {
 
     /**
-     * Return the serialziable field name.
+     * Return the serializable field name.
      */
     public String fieldName();
 
diff --git a/src/share/classes/com/sun/javadoc/Tag.java b/src/share/classes/com/sun/javadoc/Tag.java
index fdc54c4..1d8c590 100644
--- a/src/share/classes/com/sun/javadoc/Tag.java
+++ b/src/share/classes/com/sun/javadoc/Tag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, 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
@@ -54,36 +54,44 @@ public interface Tag {
      * <code>{@link}</code>, the curly brackets
      * are not part of the name, so in this example the name
      * would be simply <code>@link</code>.
+     *
+     * @return the name of this tag
      */
     String name();
 
     /**
      * Return the containing {@link Doc} of this Tag element.
+     *
+     * @return the containing {@link Doc} of this Tag element
      */
     Doc holder();
 
     /**
      * Return the kind of this tag.
-     * similar or synonymous tags.  For most tags,
+     * For most tags,
      * <code>kind() == name()</code>;
      * the following table lists those cases where there is more
      * than one tag of a given kind:
      * <p>
-     * <table border="1" cellpadding="4" cellspacing="0">
-     * <tr><th><tt> kind()  </th>  <th><tt> name()      </th></tr>
-     * <tr><td><tt> @throws </td>  <td><tt> @throws     </td></tr>
-     * <tr><td><tt> @throws </td>  <td><tt> @exception  </td></tr>
-     * <tr><td><tt> @see    </td>  <td><tt> @see        </td></tr>
-     * <tr><td><tt> @see    </td>  <td><tt> @link       </td></tr>
-     * <tr><td><tt> @see    </td>  <td><tt> @linkplain  </td></tr>
-     * <tr><td><tt> @serial </td>  <td><tt> @serial     </td></tr>
-     * <tr><td><tt> @serial </td>  <td><tt> @serialData </td></tr>
+     * <table border="1" cellpadding="4" cellspacing="0" summary="related tags">
+     * <tr><th>{@code kind()  }</th>  <th>{@code name()      }</th></tr>
+     * <tr><td>{@code @throws }</td>  <td>{@code @throws     }</td></tr>
+     * <tr><td>{@code @throws }</td>  <td>{@code @exception  }</td></tr>
+     * <tr><td>{@code @see    }</td>  <td>{@code @see        }</td></tr>
+     * <tr><td>{@code @see    }</td>  <td>{@code @link       }</td></tr>
+     * <tr><td>{@code @see    }</td>  <td>{@code @linkplain  }</td></tr>
+     * <tr><td>{@code @serial }</td>  <td>{@code @serial     }</td></tr>
+     * <tr><td>{@code @serial }</td>  <td>{@code @serialData }</td></tr>
      * </table>
+     *
+     * @return the kind of this tag.
      */
     String kind();
 
     /**
-     * Return the text of this tag, that is, portion beyond tag name.
+     * Return the text of this tag, that is, the portion beyond tag name.
+     *
+     * @return the text of this tag
      */
     String text();
 
@@ -127,7 +135,7 @@ public interface Tag {
     /**
      * Return the first sentence of the comment as an array of tags.
      * Includes inline tags
-     * (i.e. {&#64link <i>reference</i>} tags)  but not
+     * (i.e. {@link <i>reference</i>} tags)  but not
      * block tags.
      * Each section of plain text is represented as a {@link Tag}
      * of kind "Text".
diff --git a/src/share/classes/com/sun/javadoc/Type.java b/src/share/classes/com/sun/javadoc/Type.java
index c093fc9..77d9a73 100644
--- a/src/share/classes/com/sun/javadoc/Type.java
+++ b/src/share/classes/com/sun/javadoc/Type.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, 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
@@ -142,6 +142,16 @@ public interface Type {
     WildcardType asWildcardType();
 
     /**
+     * Returns this type as a <code>AnnotatedType</code> if it represents
+     * an annotated type.
+     *
+     * @return a <code>AnnotatedType</code> if the type if an annotated type,
+     *         or null if it is not
+     * @since 1.8
+     */
+    AnnotatedType asAnnotatedType();
+
+    /**
      * Return this type as an <code>AnnotationTypeDoc</code> if it represents
      * an annotation type.  Array dimensions are ignored.
      *
@@ -150,4 +160,13 @@ public interface Type {
      * @since 1.5
      */
     AnnotationTypeDoc asAnnotationTypeDoc();
+
+    /**
+     * If this type is an array type, return the element type of the
+     * array. Otherwise, return null.
+     *
+     * @return a <code>Type</code> representing the element type or null.
+     * @since 1.8
+     */
+    Type getElementType();
 }
diff --git a/src/share/classes/com/sun/javadoc/TypeVariable.java b/src/share/classes/com/sun/javadoc/TypeVariable.java
index c63421c..4212f20 100644
--- a/src/share/classes/com/sun/javadoc/TypeVariable.java
+++ b/src/share/classes/com/sun/javadoc/TypeVariable.java
@@ -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
@@ -55,4 +55,11 @@ public interface TypeVariable extends Type {
      *         which this type variable is declared.
      */
     ProgramElementDoc owner();
+
+    /**
+     * Get the annotations of this program element.
+     * Return an empty array if there are none.
+     */
+    public AnnotationDesc[] annotations();
+
 }
diff --git a/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java b/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java
deleted file mode 100644
index 27d5eaa..0000000
--- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-
-import java.io.IOException;
-import java.util.Collection;
-
-
-/**
- * An annotation processor, used to examine and process the
- * annotations of program elements.  An annotation processor may,
- * for example, create new source files and XML documents to be used
- * in conjunction with the original code.
- *
- * <p> An annotation processor is constructed by a
- * {@linkplain AnnotationProcessorFactory factory}, which provides it with an
- * {@linkplain AnnotationProcessorEnvironment environment} that
- * encapsulates the state it needs.
- * Messages regarding warnings and errors encountered during processing
- * should be directed to the environment's {@link Messager},
- * and new files may be created using the environment's {@link Filer}.
- *
- * <p> Each annotation processor is created to process annotations
- * of a particular annotation type or set of annotation types.
- * It may use its environment to find the program elements with
- * annotations of those types.  It may freely examine any other program
- * elements in the course of its processing.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.Processor}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationProcessor {
-
-    /**
-     * Process all program elements supported by this annotation processor.
-     */
-    void process();
-}
diff --git a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java b/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java
deleted file mode 100644
index 9eb13b1..0000000
--- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-
-import java.util.Collection;
-import java.util.Map;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * The environment encapsulating the state needed by an annotation processor.
- * An annotation processing tool makes this environment available
- * to all annotation processors.
- *
- * <p> When an annotation processing tool is invoked, it is given a
- * set of type declarations on which to operate.  These
- * are refered to as the <i>specified</i> types.
- * The type declarations said to be <i>included</i> in this invocation
- * consist of the specified types and any types nested within them.
- *
- * <p> {@link DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.ProcessingEnvironment}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationProcessorEnvironment {
-
-    /**
-     * Returns the options passed to the annotation processing tool.
-     * Options are returned in the form of a map from option name
-     * (such as <tt>"-encoding"</tt>) to option value.
-     * For an option with no value (such as <tt>"-help"</tt>), the
-     * corresponding value in the map is <tt>null</tt>.
-     *
-     * <p> Options beginning with <tt>"-A"</tt> are <i>processor-specific.</i>
-     * Such options are unrecognized by the tool, but intended to be used by
-     * some annotation processor.
-     *
-     * @return the options passed to the tool
-     */
-    Map<String,String> getOptions();
-
-    /**
-     * Returns the messager used to report errors, warnings, and other
-     * notices.
-     *
-     * @return the messager
-     */
-    Messager getMessager();
-
-    /**
-     * Returns the filer used to create new source, class, or auxiliary
-     * files.
-     *
-     * @return the filer
-     */
-    Filer getFiler();
-
-
-    /**
-     * Returns the declarations of the types specified when the
-     * annotation processing tool was invoked.
-     *
-     * @return the types specified when the tool was invoked, or an
-     * empty collection if there were none
-     */
-    Collection<TypeDeclaration> getSpecifiedTypeDeclarations();
-
-    /**
-     * Returns the declaration of a package given its fully qualified name.
-     *
-     * @param name  fully qualified package name, or "" for the unnamed package
-     * @return the declaration of the named package, or null if it cannot
-     * be found
-     */
-    PackageDeclaration getPackage(String name);
-
-    /**
-     * Returns the declaration of a type given its fully qualified name.
-     *
-     * @param name  fully qualified type name
-     * @return the declaration of the named type, or null if it cannot be
-     * found
-     */
-    TypeDeclaration getTypeDeclaration(String name);
-
-    /**
-     * A convenience method that returns the declarations of the types
-     * {@linkplain AnnotationProcessorEnvironment <i>included</i>}
-     * in this invocation of the annotation processing tool.
-     *
-     * @return the declarations of the types included in this invocation
-     * of the tool, or an empty collection if there are none
-     */
-    Collection<TypeDeclaration> getTypeDeclarations();
-
-    /**
-     * Returns the declarations annotated with the given annotation type.
-     * Only declarations of the types
-     * {@linkplain AnnotationProcessorEnvironment <i>included</i>}
-     * in this invocation of the annotation processing tool, or
-     * declarations of members, parameters, or type parameters
-     * declared within those, are returned.
-     *
-     * @param a  annotation type being requested
-     * @return the declarations annotated with the given annotation type,
-     * or an empty collection if there are none
-     */
-    Collection<Declaration> getDeclarationsAnnotatedWith(
-                                                AnnotationTypeDeclaration a);
-
-    /**
-     * Returns an implementation of some utility methods for
-     * operating on declarations.
-     *
-     * @return declaration utilities
-     */
-    Declarations getDeclarationUtils();
-
-    /**
-     * Returns an implementation of some utility methods for
-     * operating on types.
-     *
-     * @return type utilities
-     */
-    Types getTypeUtils();
-
-    /**
-     * Add a listener.  If the listener is currently registered to listen,
-     * adding it again will have no effect.
-     *
-     * @param listener The listener to add.
-     * @throws NullPointerException if the listener is null
-     */
-    void addListener(AnnotationProcessorListener listener);
-
-
-    /**
-     * Remove a listener.  If the listener is not currently listening,
-     * the method call does nothing.
-     *
-     * @param listener The listener to remove.
-     * @throws NullPointerException if the listener is null
-     */
-    void removeListener(AnnotationProcessorListener listener);
-}
diff --git a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java b/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java
deleted file mode 100644
index df5d83f..0000000
--- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-
-import java.util.Collection;
-import java.util.Set;
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-
-/**
- * A factory for creating annotation processors.
- * Each factory is responsible for creating processors for one or more
- * annotation types.
- * The factory is said to <i>support</i> these types.
- *
- * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
- * must provide a public no-argument constructor to be used by tools to
- * instantiate the factory.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.Processor}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationProcessorFactory {
-
-    /**
-     * Returns the options recognized by this factory or by any of the
-     * processors it may create.
-     * Only {@linkplain AnnotationProcessorEnvironment#getOptions()
-     * processor-specific} options are included, each of which begins
-     * with <tt>"-A"</tt>.  For example, if this factory recognizes
-     * options such as <tt>-Adebug -Aloglevel=3</tt>, it will
-     * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
-     *
-     * <p> A tool might use this information to determine if any
-     * options provided by a user are unrecognized by any processor,
-     * in which case it may wish to report an error.
-     *
-     * @return the options recognized by this factory or by any of the
-     * processors it may create, or an empty collection if none
-     */
-    Collection<String> supportedOptions();
-
-    /**
-     * Returns the names of the annotation types supported by this factory.
-     * An element of the result may be the canonical (fully qualified) name
-     * of a supported annotation type.  Alternately it may be of the form
-     * <tt>"<i>name</i>.*"</tt>
-     * representing the set of all annotation types
-     * with canonical names beginning with <tt>"<i>name</i>."</tt>
-     * Finally, <tt>"*"</tt> by itself represents the set of all
-     * annotation types.
-     *
-     * @return the names of the annotation types supported by this factory
-     */
-    Collection<String> supportedAnnotationTypes();
-
-    /**
-     * Returns an annotation processor for a set of annotation
-     * types. The set will be empty if the factory supports
-     * "<tt>*</tt>" and the specified type declarations have
-     * no annotations.  Note that the set of annotation types may be
-     * empty for other reasons, such as giving the factory an
-     * opportunity to register a listener.  An
-     * <tt>AnnotationProcessorFactory</tt> must gracefully handle an
-     * empty set of annotations; an appropriate response to an empty
-     * set will often be returning {@link AnnotationProcessors#NO_OP}.
-     *
-     * @param atds type declarations of the annotation types to be processed
-     * @param env  environment to use during processing
-     * @return an annotation processor for the given annotation types,
-     *          or <tt>null</tt> if the types are not supported or the
-     *          processor cannot be created
-     */
-    AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env);
-}
diff --git a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java b/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java
deleted file mode 100644
index 7c9ed0d..0000000
--- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-/**
- * Superinterface for all annotation processor event listeners.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  This interface has no
- * direct analog in the standardized API because the different round
- * model renders it unnecessary.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationProcessorListener extends java.util.EventListener {}
diff --git a/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java b/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java
deleted file mode 100644
index a0fb662..0000000
--- a/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-import com.sun.mirror.apt.*;
-import java.util.*;
-
-/**
- * Utilities to create specialized annotation processors.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  There is no direct analog
- * of the functionality of this class in the standardized API.
- *
- * @since 1.5
- * @author Joseph D. Darcy
- * @author Scott Seligman
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class AnnotationProcessors {
-    static class NoOpAP implements AnnotationProcessor {
-        NoOpAP() {}
-        public void process(){}
-    }
-
-    /**
-     * Combines multiple annotation processors into a simple composite
-     * processor.
-     * The composite processor functions by invoking each of its component
-     * processors in sequence.
-     */
-    static class CompositeAnnotationProcessor implements AnnotationProcessor {
-
-        private List<AnnotationProcessor> aps =
-            new LinkedList<AnnotationProcessor>();
-
-        /**
-         * Constructs a new composite annotation processor.
-         * @param aps  the component annotation processors
-         */
-        public CompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
-            this.aps.addAll(aps);
-        }
-
-        /**
-         * Constructs a new composite annotation processor.
-         * @param aps  the component annotation processors
-         */
-        public CompositeAnnotationProcessor(AnnotationProcessor... aps) {
-            for(AnnotationProcessor ap: aps)
-                this.aps.add(ap);
-        }
-
-        /**
-         * Invokes the <tt>process</tt> method of each component processor,
-         * in the order in which the processors were passed to the constructor.
-         */
-        public void process() {
-            for(AnnotationProcessor ap: aps)
-                ap.process();
-        }
-    }
-
-
-    /**
-     *  An annotation processor that does nothing and has no state.
-     *  May be used multiple times.
-     *
-     * @since 1.5
-     */
-    public final static AnnotationProcessor NO_OP = new NoOpAP();
-
-    /**
-     * Constructs a new composite annotation processor.  A composite
-     * annotation processor combines multiple annotation processors
-     * into one and functions by invoking each of its component
-     * processors' process methods in sequence.
-     *
-     * @param aps The processors to create a composite of
-     * @since 1.5
-     */
-    public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) {
-        return new CompositeAnnotationProcessor(aps);
-    }
-
-    /**
-     * Constructs a new composite annotation processor.  A composite
-     * annotation processor combines multiple annotation processors
-     * into one and functions by invoking each of its component
-     * processors' process methods in the sequence the processors are
-     * returned by the collection's iterator.
-     *
-     * @param aps A collection of processors to create a composite of
-     * @since 1.5
-     */
-    public static AnnotationProcessor getCompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) {
-        return new CompositeAnnotationProcessor(aps);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/apt/Filer.java b/src/share/classes/com/sun/mirror/apt/Filer.java
deleted file mode 100644
index a553c71..0000000
--- a/src/share/classes/com/sun/mirror/apt/Filer.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-
-import java.io.*;
-
-
-/**
- * This interface supports the creation of new files by an
- * annotation processor.
- * Files created in this way will be known to the annotation processing
- * tool implementing this interface, better enabling the tool to manage them.
- * Four kinds of files are distinguished:
- * source files, class files, other text files, and other binary files.
- * The latter two are collectively referred to as <i>auxiliary</i> files.
- *
- * <p> There are two distinguished locations (subtrees within the
- * file system) where newly created files are placed:
- * one for new source files, and one for new class files.
- * (These might be specified on a tool's command line, for example,
- * using flags such as <tt>-s</tt> and <tt>-d</tt>.)
- * Auxiliary files may be created in either location.
- *
- * <p> During each run of an annotation processing tool, a file
- * with a given pathname may be created only once.  If that file already
- * exists before the first attempt to create it, the old contents will
- * be deleted.  Any subsequent attempt to create the same file during
- * a run will fail.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.Filer}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface Filer {
-
-    /**
-     * Creates a new source file and returns a writer for it.
-     * The file's name and path (relative to the root of all newly created
-     * source files) is based on the type to be declared in that file.
-     * If more than one type is being declared, the name of the principal
-     * top-level type (the public one, for example) should be used.
-     *
-     * <p> The {@linkplain java.nio.charset.Charset charset} used to
-     * encode the file is determined by the implementation.
-     * An annotation processing tool may have an <tt>-encoding</tt>
-     * flag or the like for specifying this.  It will typically use
-     * the platform's default encoding if none is specified.
-     *
-     * @param name  canonical (fully qualified) name of the principal type
-     *          being declared in this file
-     * @return a writer for the new file
-     * @throws IOException if the file cannot be created
-     */
-    PrintWriter createSourceFile(String name) throws IOException;
-
-    /**
-     * Creates a new class file, and returns a stream for writing to it.
-     * The file's name and path (relative to the root of all newly created
-     * class files) is based on the name of the type being written.
-     *
-     * @param name canonical (fully qualified) name of the type being written
-     * @return a stream for writing to the new file
-     * @throws IOException if the file cannot be created
-     */
-    OutputStream createClassFile(String name) throws IOException;
-
-    /**
-     * Creates a new text file, and returns a writer for it.
-     * The file is located along with either the
-     * newly created source or newly created binary files.  It may be
-     * named relative to some package (as are source and binary files),
-     * and from there by an arbitrary pathname.  In a loose sense, the
-     * pathname of the new file will be the concatenation of
-     * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
-     *
-     * <p> A {@linkplain java.nio.charset.Charset charset} for
-     * encoding the file may be provided.  If none is given, the
-     * charset used to encode source files
-     * (see {@link #createSourceFile(String)}) will be used.
-     *
-     * @param loc location of the new file
-     * @param pkg package relative to which the file should be named,
-     *          or the empty string if none
-     * @param relPath final pathname components of the file
-     * @param charsetName the name of the charset to use, or null if none
-     *          is being explicitly specified
-     * @return a writer for the new file
-     * @throws IOException if the file cannot be created
-     */
-    PrintWriter createTextFile(Location loc,
-                               String pkg,
-                               File relPath,
-                               String charsetName) throws IOException;
-
-    /**
-     * Creates a new binary file, and returns a stream for writing to it.
-     * The file is located along with either the
-     * newly created source or newly created binary files.  It may be
-     * named relative to some package (as are source and binary files),
-     * and from there by an arbitrary pathname.  In a loose sense, the
-     * pathname of the new file will be the concatenation of
-     * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
-     *
-     * @param loc location of the new file
-     * @param pkg package relative to which the file should be named,
-     *          or the empty string if none
-     * @param relPath final pathname components of the file
-     * @return a stream for writing to the new file
-     * @throws IOException if the file cannot be created
-     */
-    OutputStream createBinaryFile(Location loc,
-                                  String pkg,
-                                  File relPath) throws IOException;
-
-
-    /**
-     * Locations (subtrees within the file system) where new files are created.
-     *
-     * @deprecated All components of this API have been superseded by
-     * the standardized annotation processing API.  The replacement
-     * for the functionality of this enum is {@link
-     * javax.tools.StandardLocation}.
-     */
-    @Deprecated
-    enum Location {
-        /** The location of new source files. */
-        SOURCE_TREE,
-        /** The location of new class files. */
-        CLASS_TREE
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/apt/Messager.java b/src/share/classes/com/sun/mirror/apt/Messager.java
deleted file mode 100644
index 0eb4ec8..0000000
--- a/src/share/classes/com/sun/mirror/apt/Messager.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * A <tt>Messager</tt> provides the way for
- * an annotation processor to report error messages, warnings, and
- * other notices.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.Messager}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface Messager {
-
-    /**
-     * Prints an error message.
-     * Equivalent to <tt>printError(null, msg)</tt>.
-     * @param msg  the message, or an empty string if none
-     */
-    void printError(String msg);
-
-    /**
-     * Prints an error message.
-     * @param pos  the position where the error occured, or null if it is
-     *                  unknown or not applicable
-     * @param msg  the message, or an empty string if none
-     */
-    void printError(SourcePosition pos, String msg);
-
-    /**
-     * Prints a warning message.
-     * Equivalent to <tt>printWarning(null, msg)</tt>.
-     * @param msg  the message, or an empty string if none
-     */
-    void printWarning(String msg);
-
-    /**
-     * Prints a warning message.
-     * @param pos  the position where the warning occured, or null if it is
-     *                  unknown or not applicable
-     * @param msg  the message, or an empty string if none
-     */
-    void printWarning(SourcePosition pos, String msg);
-
-    /**
-     * Prints a notice.
-     * Equivalent to <tt>printNotice(null, msg)</tt>.
-     * @param msg  the message, or an empty string if none
-     */
-    void printNotice(String msg);
-
-    /**
-     * Prints a notice.
-     * @param pos  the position where the noticed occured, or null if it is
-     *                  unknown or not applicable
-     * @param msg  the message, or an empty string if none
-     */
-    void printNotice(SourcePosition pos, String msg);
-}
diff --git a/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java b/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java
deleted file mode 100644
index 49614c5..0000000
--- a/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-/**
- * Event for the completion of a round of annotation processing.
- *
- * <p>While this class extends the serializable <tt>EventObject</tt>, it
- * cannot meaningfully be serialized because all of the annotation
- * processing tool's internal state would potentially be needed.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  This class has no direct
- * analog in the standardized API because the different round model
- * renders it unnecessary.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public abstract class RoundCompleteEvent extends java.util.EventObject {
-    private RoundState rs;
-
-    /**
-     * The current <tt>AnnotationProcessorEnvironment</tt> is regarded
-     * as the source of events.
-     *
-     * @param source The source of events
-     * @param rs     The state of the round
-     */
-    protected RoundCompleteEvent(AnnotationProcessorEnvironment source,
-                                 RoundState rs) {
-        super(source);
-        this.rs = rs;
-    }
-
-    /**
-     * Return round state.
-     */
-    public RoundState getRoundState() {
-        return rs;
-    }
-
-    /**
-     * Return source.
-     */
-    public AnnotationProcessorEnvironment getSource() {
-        return (AnnotationProcessorEnvironment)super.getSource();
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java b/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java
deleted file mode 100644
index adbac89..0000000
--- a/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-/**
- * Listener for the completion of a round of annotation processing.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  This interface has no
- * direct analog in the standardized API because the different round
- * model renders it unnecessary.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface RoundCompleteListener extends AnnotationProcessorListener {
-    /**
-     * Invoked after all processors for a round have run to completion.
-     *
-     * @param event An event for round completion
-     */
-    void roundComplete(RoundCompleteEvent event);
-}
diff --git a/src/share/classes/com/sun/mirror/apt/RoundState.java b/src/share/classes/com/sun/mirror/apt/RoundState.java
deleted file mode 100644
index bab4bcf..0000000
--- a/src/share/classes/com/sun/mirror/apt/RoundState.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.apt;
-
-/**
- * Represents the status of a completed round of annotation processing.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.annotation.processing.RoundEnvironment}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface RoundState {
-    /**
-     * Returns <tt>true</tt> if this was the last round of annotation
-     * processing; returns <tt>false</tt> if there will be a subsequent round.
-     */
-    boolean finalRound();
-
-    /**
-     * Returns <tt>true</tt> if an error was raised in this round of processing;
-     * returns <tt>false</tt> otherwise.
-     */
-    boolean errorRaised();
-
-    /**
-     * Returns <tt>true</tt> if new source files were created in this round of
-     * processing; returns <tt>false</tt> otherwise.
-     */
-    boolean sourceFilesCreated();
-
-    /**
-     * Returns <tt>true</tt> if new class files were created in this round of
-     * processing; returns <tt>false</tt> otherwise.
-     */
-    boolean classFilesCreated();
-}
diff --git a/src/share/classes/com/sun/mirror/apt/package-info.java b/src/share/classes/com/sun/mirror/apt/package-info.java
deleted file mode 100644
index eb6b3a4..0000000
--- a/src/share/classes/com/sun/mirror/apt/package-info.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-/**
- * Classes used to communicate information between {@linkplain
- * com.sun.mirror.apt.AnnotationProcessor annotation processors} and
- * an annotation processing tool.
- *
- * <p>The {@code apt} tool and its associated API have been superseded
- * by the standardized annotation processing API.  The replacement for
- * the functionality in this package is {@link
- * javax.annotation.processing}.
- *
- * @since 1.5
- */
-package com.sun.mirror.apt;
diff --git a/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java b/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java
deleted file mode 100644
index beecc53..0000000
--- a/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-import java.util.Map;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.util.SourcePosition;
-
-
-/**
- * Represents an annotation.  An annotation associates a value with
- * each element of an annotation type.
- *
- * <p> Annotations should not be compared using reference-equality
- * ("<tt>==</tt>").  There is no guarantee that any particular
- * annotation will always be represented by the same object.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.AnnotationMirror}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationMirror {
-
-    /**
-     * Returns the annotation type of this annotation.
-     *
-     * @return the annotation type of this annotation
-     */
-    AnnotationType getAnnotationType();
-
-    /**
-     * Returns the source position of the beginning of this annotation.
-     * Returns null if the position is unknown or not applicable.
-     *
-     * <p>This source position is intended for use in providing diagnostics,
-     * and indicates only approximately where an annotation begins.
-     *
-     * @return  the source position of the beginning of this annotation or
-     * null if the position is unknown or not applicable
-     */
-    SourcePosition getPosition();
-
-    /**
-     * Returns this annotation's elements and their values.
-     * This is returned in the form of a map that associates elements
-     * with their corresponding values.
-     * Only those elements and values explicitly present in the
-     * annotation are included, not those that are implicitly assuming
-     * their default values.
-     * The order of the map matches the order in which the
-     * elements appear in the annotation's source.
-     *
-     * @return this annotation's elements and their values,
-     * or an empty map if there are none
-     */
-    Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java b/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java
deleted file mode 100644
index 5630922..0000000
--- a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of an annotation type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.TypeElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationTypeDeclaration extends InterfaceDeclaration {
-
-    /**
-     * Returns the annotation type elements of this annotation type.
-     * These are the methods that are directly declared in the type's
-     * declaration.
-     *
-     * @return the annotation type elements of this annotation type,
-     * or an empty collection if there are none
-     */
-    Collection<AnnotationTypeElementDeclaration> getMethods();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java b/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java
deleted file mode 100644
index b591097..0000000
--- a/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-/**
- * Represents an element of an annotation type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.ExecutableElement}.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationTypeElementDeclaration extends MethodDeclaration {
-
-    /**
-     * Returns the default value of this element.
-     *
-     * @return the default value of this element, or null if this element
-     * has no default.
-     */
-    AnnotationValue getDefaultValue();
-
-    /**
-     * {@inheritDoc}
-     */
-    AnnotationTypeDeclaration getDeclaringType();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java b/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java
deleted file mode 100644
index a764a23..0000000
--- a/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-import com.sun.mirror.util.SourcePosition;
-
-/**
- * Represents a value of an annotation type element.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.AnnotationValue}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationValue {
-
-    /**
-     * Returns the value.
-     * The result has one of the following types:
-     * <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
-     *     <li> {@code String}
-     *     <li> {@code TypeMirror}
-     *     <li> {@code EnumConstantDeclaration}
-     *     <li> {@code AnnotationMirror}
-     *     <li> {@code Collection<AnnotationValue>}
-     *          (representing the elements, in order, if the value is an array)
-     * </ul>
-     *
-     * @return the value
-     */
-    Object getValue();
-
-    /**
-     * Returns the source position of the beginning of this annotation value.
-     * Returns null if the position is unknown or not applicable.
-     *
-     * <p>This source position is intended for use in providing diagnostics,
-     * and indicates only approximately where an annotation value begins.
-     *
-     * @return  the source position of the beginning of this annotation value or
-     * null if the position is unknown or not applicable
-     */
-    SourcePosition getPosition();
-
-    /**
-     * Returns a string representation of this value.
-     * This is returned in a form suitable for representing this value
-     * in the source code of an annotation.
-     *
-     * @return a string representation of this value
-     */
-    String toString();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java b/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java
deleted file mode 100644
index 7c9c9f2..0000000
--- a/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.ClassType;
-
-
-/**
- * Represents the declaration of a class.
- * For the declaration of an interface, see {@link InterfaceDeclaration}.
- * Provides access to information about the class, its members, and
- * its constructors.
- * Note that an {@linkplain EnumDeclaration enum} is a kind of class.
- *
- * <p> While a <tt>ClassDeclaration</tt> represents the <i>declaration</i>
- * of a class, a {@link ClassType} represents a class <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.TypeElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @see ClassType
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ClassDeclaration extends TypeDeclaration {
-
-    /**
-     * Returns the class type directly extended by this class.
-     * The only class with no superclass is <tt>java.lang.Object</tt>,
-     * for which this method returns null.
-     *
-     * @return the class type directly extended by this class, or null
-     * if there is none
-     */
-    ClassType getSuperclass();
-
-    /**
-     * Returns the constructors of this class.
-     * This includes the default constructor if this class has
-     * no constructors explicitly declared.
-     *
-     * @return the constructors of this class
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<ConstructorDeclaration> getConstructors();
-
-    /**
-     * {@inheritDoc}
-     */
-    Collection<MethodDeclaration> getMethods();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java b/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java
deleted file mode 100644
index c46e018..0000000
--- a/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-/**
- * Represents a constructor of a class or interface.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.ExecutableElement}.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ConstructorDeclaration extends ExecutableDeclaration {
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/Declaration.java b/src/share/classes/com/sun/mirror/declaration/Declaration.java
deleted file mode 100644
index 596a143..0000000
--- a/src/share/classes/com/sun/mirror/declaration/Declaration.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * Represents the declaration of a program element such as a package,
- * class, or method.  Each declaration represents a static, language-level
- * construct (and not, for example, a runtime construct of the virtual
- * machine), and typically corresponds one-to-one with a particular
- * fragment of source code.
- *
- * <p> Declarations should be compared using the {@link #equals(Object)}
- * method.  There is no guarantee that any particular declaration will
- * always be represented by the same object.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.Element}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @see Declarations
- * @see TypeMirror
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface Declaration {
-
-    /**
-     * Tests whether an object represents the same declaration as this.
-     *
-     * @param obj  the object to be compared with this declaration
-     * @return <tt>true</tt> if the specified object represents the same
-     *          declaration as this
-     */
-    boolean equals(Object obj);
-
-    /**
-     * Returns the text of the documentation ("javadoc") comment of
-     * this declaration.
-     *
-     * @return the documentation comment of this declaration, or <tt>null</tt>
-     *          if there is none
-     */
-    String getDocComment();
-
-    /**
-     * Returns the annotations that are directly present on this declaration.
-     *
-     * @return the annotations directly present on this declaration;
-     *          an empty collection if there are none
-     */
-    Collection<AnnotationMirror> getAnnotationMirrors();
-
-    /**
-     * Returns the annotation of this declaration having the specified
-     * type.  The annotation may be either inherited or directly
-     * present on this declaration.
-     *
-     * <p> The annotation returned by this method could contain an element
-     * whose value is of type <tt>Class</tt>.
-     * This value cannot be returned directly:  information necessary to
-     * locate and load a class (such as the class loader to use) is
-     * not available, and the class might not be loadable at all.
-     * Attempting to read a <tt>Class</tt> object by invoking the relevant
-     * method on the returned annotation
-     * will result in a {@link MirroredTypeException},
-     * from which the corresponding {@link TypeMirror} may be extracted.
-     * Similarly, attempting to read a <tt>Class[]</tt>-valued element
-     * will result in a {@link MirroredTypesException}.
-     *
-     * <blockquote>
-     * <i>Note:</i> This method is unlike
-     * others in this and related interfaces.  It operates on run-time
-     * reflective information -- representations of annotation types
-     * currently loaded into the VM -- rather than on the mirrored
-     * representations defined by and used throughout these
-     * interfaces.  It is intended for callers that are written to
-     * operate on a known, fixed set of annotation types.
-     * </blockquote>
-     *
-     * @param <A>  the annotation type
-     * @param annotationType  the <tt>Class</tt> object corresponding to
-     *          the annotation type
-     * @return the annotation of this declaration having the specified type
-     *
-     * @see #getAnnotationMirrors()
-     */
-    <A extends Annotation> A getAnnotation(Class<A> annotationType);
-
-    /**
-     * Returns the modifiers of this declaration, excluding annotations.
-     * Implicit modifiers, such as the <tt>public</tt> and <tt>static</tt>
-     * modifiers of interface members, are included.
-     *
-     * @return the modifiers of this declaration in undefined order;
-     *          an empty collection if there are none
-     */
-    Collection<Modifier> getModifiers();
-
-    /**
-     * Returns the simple (unqualified) name of this declaration.
-     * The name of a generic type does not include any reference
-     * to its formal type parameters.
-     * For example, the simple name of the interface declaration
-     * {@code java.util.Set<E>} is <tt>"Set"</tt>.
-     * If this declaration represents the empty package, an empty
-     * string is returned.
-     * If it represents a constructor, the simple name of its
-     * declaring class is returned.
-     *
-     * @return the simple name of this declaration
-     */
-    String getSimpleName();
-
-    /**
-     * Returns the source position of the beginning of this declaration.
-     * Returns <tt>null</tt> if the position is unknown or not applicable.
-     *
-     * <p> This source position is intended for use in providing
-     * diagnostics, and indicates only approximately where a declaration
-     * begins.
-     *
-     * @return the source position of the beginning of this declaration,
-     *          or null if the position is unknown or not applicable
-     */
-    SourcePosition getPosition();
-
-    /**
-     * Applies a visitor to this declaration.
-     *
-     * @param v the visitor operating on this declaration
-     */
-    void accept(DeclarationVisitor v);
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java b/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java
deleted file mode 100644
index 9f5c168..0000000
--- a/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-/**
- * Represents an enum constant declaration.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.VariableElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface EnumConstantDeclaration extends FieldDeclaration {
-    /**
-     * {@inheritDoc}
-     */
-    EnumDeclaration getDeclaringType();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java b/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java
deleted file mode 100644
index 19128f8..0000000
--- a/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of an enum type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.TypeElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface EnumDeclaration extends ClassDeclaration {
-
-    /**
-     * Returns the enum constants defined for this enum.
-     *
-     * @return the enum constants defined for this enum,
-     * or an empty collection if there are none
-     */
-    Collection<EnumConstantDeclaration> getEnumConstants();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java b/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java
deleted file mode 100644
index 2ec5179..0000000
--- a/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.ReferenceType;
-
-
-/**
- * Represents a method or constructor of a class or interface.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.ExecutableElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ExecutableDeclaration extends MemberDeclaration {
-
-    /**
-     * Returns <tt>true</tt> if this method or constructor accepts a variable
-     * number of arguments.
-     *
-     * @return <tt>true</tt> if this method or constructor accepts a variable
-     * number of arguments
-     */
-    boolean isVarArgs();
-
-    /**
-     * Returns the formal type parameters of this method or constructor.
-     * They are returned in declaration order.
-     *
-     * @return the formal type parameters of this method or constructor,
-     * or an empty collection if there are none
-     */
-    Collection<TypeParameterDeclaration> getFormalTypeParameters();
-
-    /**
-     * Returns the formal parameters of this method or constructor.
-     * They are returned in declaration order.
-     *
-     * @return the formal parameters of this method or constructor,
-     * or an empty collection if there are none
-     */
-    Collection<ParameterDeclaration> getParameters();
-
-    /**
-     * Returns the exceptions and other throwables listed in this
-     * method or constructor's <tt>throws</tt> clause.
-     *
-     * @return the exceptions and other throwables listed in the
-     * <tt>throws</tt> clause, or an empty collection if there are none
-     */
-    Collection<ReferenceType> getThrownTypes();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java b/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java
deleted file mode 100644
index f217ead..0000000
--- a/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-
-
-/**
- * Represents a field of a type declaration.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.VariableElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface FieldDeclaration extends MemberDeclaration {
-
-    /**
-     * Returns the type of this field.
-     *
-     * @return the type of this field
-     */
-    TypeMirror getType();
-
-    /**
-     * Returns the value of this field if this field is a compile-time
-     * constant.  Returns <tt>null</tt> otherwise.
-     * The value will be of a primitive type or <tt>String</tt>.
-     * If the value is of a primitive type, it is wrapped in the
-     * appropriate wrapper class (such as {@link Integer}).
-     *
-     * @return the value of this field if this field is a compile-time
-     * constant, or <tt>null</tt> otherwise
-     */
-    Object getConstantValue();
-
-    /**
-     * Returns the text of a <i>constant expression</i> representing the
-     * value of this field if this field is a compile-time constant.
-     * Returns <tt>null</tt> otherwise.
-     * The value will be of a primitive type or <tt>String</tt>.
-     * The text returned is in a form suitable for representing the value
-     * in source code.
-     *
-     * @return the text of a constant expression if this field is a
-     *          compile-time constant, or <tt>null</tt> otherwise
-     */
-    String getConstantExpression();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java b/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java
deleted file mode 100644
index 2d3d175..0000000
--- a/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import com.sun.mirror.type.InterfaceType;
-
-
-/**
- * Represents the declaration of an interface.
- * Provides access to information about the interface and its members.
- * Note that an {@linkplain AnnotationTypeDeclaration annotation type} is
- * a kind of interface.
- *
- * <p> While an <tt>InterfaceDeclaration</tt> represents the
- * <i>declaration</i> of an interface, an {@link InterfaceType}
- * represents an interface <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.TypeElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @see InterfaceType
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface InterfaceDeclaration extends TypeDeclaration {
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java b/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java
deleted file mode 100644
index ffabbb4..0000000
--- a/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-/**
- * Represents a declaration that may be a member or constructor of a declared
- * type.  This includes fields, constructors, methods, and (since they
- * may be nested) declared types themselves.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.Element}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface MemberDeclaration extends Declaration {
-
-    /**
-     * Returns the type declaration within which this member or constructor
-     * is declared.
-     * If this is the declaration of a top-level type (a non-nested class
-     * or interface), returns null.
-     *
-     * @return the type declaration within which this member or constructor
-     * is declared, or null if there is none
-     */
-    TypeDeclaration getDeclaringType();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java b/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java
deleted file mode 100644
index 61906d1..0000000
--- a/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.type.VoidType;
-
-
-/**
- * Represents a method of a class or interface.
- * Note that an
- * {@linkplain AnnotationTypeElementDeclaration annotation type element}
- * is a kind of method.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.ExecutableElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface MethodDeclaration extends ExecutableDeclaration {
-
-    /**
-     * Returns the formal return type of this method.
-     * Returns {@link VoidType} if this method does not return a value.
-     *
-     * @return the formal return type of this method
-     */
-    TypeMirror getReturnType();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/Modifier.java b/src/share/classes/com/sun/mirror/declaration/Modifier.java
deleted file mode 100644
index df25ceb..0000000
--- a/src/share/classes/com/sun/mirror/declaration/Modifier.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-/**
- * Represents a modifier on the declaration of a program element such
- * as a class, method, or field.
- *
- * <p> Not all modifiers are applicable to all kinds of declarations.
- * When two or more modifiers appear in the source code of a declaration,
- * then it is customary, though not required, that they appear in the same
- * order as the constants listed in the detail section below.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this enum is {@link javax.lang.model.element.Modifier}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public enum Modifier {
-
-    // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
-    // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
-
-    /** The modifier <tt>public</tt> */         PUBLIC,
-    /** The modifier <tt>protected</tt> */      PROTECTED,
-    /** The modifier <tt>private</tt> */        PRIVATE,
-    /** The modifier <tt>abstract</tt> */       ABSTRACT,
-    /** The modifier <tt>static</tt> */         STATIC,
-    /** The modifier <tt>final</tt> */          FINAL,
-    /** The modifier <tt>transient</tt> */      TRANSIENT,
-    /** The modifier <tt>volatile</tt> */       VOLATILE,
-    /** The modifier <tt>synchronized</tt> */   SYNCHRONIZED,
-    /** The modifier <tt>native</tt> */         NATIVE,
-    /** The modifier <tt>strictfp</tt> */       STRICTFP;
-
-
-    private String lowercase = null;    // modifier name in lowercase
-
-    /**
-     * Returns this modifier's name in lowercase.
-     */
-    public String toString() {
-        if (lowercase == null) {
-           lowercase = name().toLowerCase(java.util.Locale.US);
-        }
-        return lowercase;
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java b/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java
deleted file mode 100644
index 52bbdbf..0000000
--- a/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents the declaration of a package.  Provides access to information
- * about the package and its members.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.PackageElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface PackageDeclaration extends Declaration {
-
-    /**
-     * Returns the fully qualified name of this package.
-     * This is also known as the package's <i>canonical</i> name.
-     *
-     * @return the fully qualified name of this package, or the
-     * empty string if this is the unnamed package
-     */
-    String getQualifiedName();
-
-    /**
-     * Returns the declarations of the top-level classes in this package.
-     * Interfaces are not included, but enum types are.
-     *
-     * @return the declarations of the top-level classes in this package
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<ClassDeclaration> getClasses();
-
-    /**
-     * Returns the declarations of the top-level enum types in this package.
-     *
-     * @return the declarations of the top-level enum types in this package
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<EnumDeclaration> getEnums();
-
-    /**
-     * Returns the declarations of the top-level interfaces in this package.
-     * Annotation types are included.
-     *
-     * @return the declarations of the top-level interfaces in this package
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<InterfaceDeclaration> getInterfaces();
-
-    /**
-     * Returns the declarations of the top-level annotation types in this
-     * package.
-     *
-     * @return the declarations of the top-level annotation types in this
-     * package
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<AnnotationTypeDeclaration> getAnnotationTypes();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java b/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java
deleted file mode 100644
index 777bf8a..0000000
--- a/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import com.sun.mirror.type.TypeMirror;
-
-
-/**
- * Represents a formal parameter of a method or constructor.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.VariableElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ParameterDeclaration extends Declaration {
-
-    /**
-     * Returns the type of this parameter.
-     *
-     * @return the type of this parameter
-     */
-    TypeMirror getType();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java b/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java
deleted file mode 100644
index bce5569..0000000
--- a/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-
-
-/**
- * Represents the declaration of a class or interface.
- * Provides access to information about the type and its members.
- * Note that an {@linkplain EnumDeclaration enum} is a kind of class,
- * and an {@linkplain AnnotationTypeDeclaration annotation type} is
- * a kind of interface.
- *
- * <p> <a name="DECL_VS_TYPE"></a>
- * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a {@link DeclaredType} represents a class
- * or interface <i>type</i>, the latter being a use
- * (or <i>invocation</i>) of the former.
- * The distinction is most apparent with generic types,
- * for which a single declaration can define a whole
- * family of types.  For example, the declaration of
- * {@code java.util.Set} corresponds to the parameterized types
- * {@code java.util.Set<String>} and {@code java.util.Set<Number>}
- * (and many others), and to the raw type {@code java.util.Set}.
- *
- * <p> {@link com.sun.mirror.util.DeclarationFilter}
- * provides a simple way to select just the items of interest
- * when a method returns a collection of declarations.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.element.TypeElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @see DeclaredType
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface TypeDeclaration extends MemberDeclaration {
-
-    /**
-     * Returns the package within which this type is declared.
-     *
-     * @return the package within which this type is declared
-     */
-    PackageDeclaration getPackage();
-
-    /**
-     * Returns the fully qualified name of this class or interface
-     * declaration.  More precisely, it returns the <i>canonical</i>
-     * name.
-     * The name of a generic type does not include any reference
-     * to its formal type parameters.
-     * For example, the the fully qualified name of the interface declaration
-     * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>.
-     *
-     * @return the fully qualified name of this class or interface declaration
-     */
-    String getQualifiedName();
-
-    /**
-     * Returns the formal type parameters of this class or interface.
-     *
-     * @return the formal type parameters, or an empty collection
-     * if there are none
-     */
-    Collection<TypeParameterDeclaration> getFormalTypeParameters();
-
-    /**
-     * Returns the interface types directly implemented by this class
-     * or extended by this interface.
-     *
-     * @return the interface types directly implemented by this class
-     * or extended by this interface, or an empty collection if there are none
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<InterfaceType> getSuperinterfaces();
-
-    /**
-     * Returns the fields that are directly declared by this class or
-     * interface.  Includes enum constants.
-     *
-     * @return the fields that are directly declared,
-     * or an empty collection if there are none
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<FieldDeclaration> getFields();
-
-    /**
-     * Returns the methods that are directly declared by this class or
-     * interface.  Includes annotation type elements.  Excludes
-     * implicitly declared methods of an interface, such as
-     * <tt>toString</tt>, that correspond to the methods of
-     * <tt>java.lang.Object</tt>.
-     *
-     * @return the methods that are directly declared,
-     * or an empty collection if there are none
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<? extends MethodDeclaration> getMethods();
-
-    /**
-     * Returns the declarations of the nested classes and interfaces
-     * that are directly declared by this class or interface.
-     *
-     * @return the declarations of the nested classes and interfaces,
-     * or an empty collection if there are none
-     *
-     * @see com.sun.mirror.util.DeclarationFilter
-     */
-    Collection<TypeDeclaration> getNestedTypes();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java b/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java
deleted file mode 100644
index 24e005d..0000000
--- a/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.type.*;
-
-
-/**
- * Represents a formal type parameter of a generic type, method,
- * or constructor declaration.
- * A type parameter declares a {@link TypeVariable}.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.TypeParameterElement}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface TypeParameterDeclaration extends Declaration {
-
-    /**
-     * Returns the bounds of this type parameter.
-     * These are the types given by the <i>extends</i> clause.
-     * If there is no explicit <i>extends</i> clause, then
-     * <tt>java.lang.Object</tt> is considered to be the sole bound.
-     *
-     * @return the bounds of this type parameter
-     */
-    Collection<ReferenceType> getBounds();
-
-    /**
-     * Returns the type, method, or constructor declaration within which
-     * this type parameter is declared.
-     *
-     * @return the declaration within which this type parameter is declared
-     */
-    Declaration getOwner();
-}
diff --git a/src/share/classes/com/sun/mirror/declaration/package-info.java b/src/share/classes/com/sun/mirror/declaration/package-info.java
deleted file mode 100644
index 32e9757..0000000
--- a/src/share/classes/com/sun/mirror/declaration/package-info.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-/**
- * Interfaces used to model program element declarations.  A
- * declaration is represented by the appropriate subinterface of
- * {@link com.sun.mirror.declaration.Declaration}, and an annotation
- * is represented as an {@link
- * com.sun.mirror.declaration.AnnotationMirror}.
- *
- * <p>The {@code apt} tool and its associated API have been superseded
- * by the standardized annotation processing API.  The replacement for
- * the functionality in this package is {@link
- * javax.lang.model.element}.
- *
- * @since 1.5
- */
-package com.sun.mirror.declaration;
diff --git a/src/share/classes/com/sun/mirror/overview.html b/src/share/classes/com/sun/mirror/overview.html
deleted file mode 100644
index f04c317..0000000
--- a/src/share/classes/com/sun/mirror/overview.html
+++ /dev/null
@@ -1,111 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-
-Copyright (c) 2004, 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.
--->
-</head>
-
-<body bgcolor="white">
-
-The Mirror API is used to model the semantic structure of a program.
-It provides representations of the entities
-declared in a program, such as classes, methods, and fields.
-Constructs below the method level, such as 
-individual statements and expressions, are not represented.
-
-<p> Also included is support for writing
-{@linkplain com.sun.mirror.apt.AnnotationProcessor annotation processors}
-to examine and process the annotations
-of program elements.  An annotation processor may, as an example, create
-new source files and XML documents to be used in conjunction with the
-original code.
-
-
-<h4> Characteristics of the API </h4>
-
-A program is represented at the language level, rather than at the
-level of the virtual machine.  Nested classes, for example, are
-handled as first-class constructs, 
-rather than in the translated form understood by the VM.
-Both source code and compiled code (class files) may be modeled
-in this way.
-
-<p> Programs are modeled in their static, or build-time, form.
-This differs from the {@linkplain java.lang.reflect reflection} API,
-which provides run-time information about classes and objects.
-
-<p> The API does not provide direct support for generating new code.
-
-
-<h4> Declarations and Types </h4>
-  
-The mirror API represents program constructs principally through the
-{@link com.sun.mirror.declaration.Declaration} interface
-and its hierarchy of subinterfaces in the package {@link
-com.sun.mirror.declaration}.  A <tt>Declaration</tt> represents a
-program element such as a package, class, or method.
-The interface hierarchy is depicted
-<a href="com/sun/mirror/declaration/package-tree.html"> here</a>.
-
-<p> Types are represented by the {@link com.sun.mirror.type.TypeMirror}
-interface and its hierarchy of subinterfaces in the
-package {@link com.sun.mirror.type}.  Types include primitive types,
-class and interface types, array types, type variables, and wildcards.
-The interface hierarchy is depicted
-<a href="com/sun/mirror/type/package-tree.html"> here</a>.
-
-<p> The API makes a clear distinction between declarations and types.
-This is most significant for generic types, where a single declaration
-can define an infinite family of types.  For example, the declaration of
-<tt>java.util.Set</tt> defines the raw type <tt>java.util.Set</tt>,
-the parameterized type {@code java.util.Set<String>},
-and much more.  Only the declaration can be annotated, for example,
-and only a type can appear in a method signature.
-
-<p> A program being modeled may be incomplete, in that
-it may depend on an unknown class or interface type.
-This may be the result of a processing error such as a missing class file,
-or perhaps the missing type is to be created by an annotation processor.
-See {@link com.sun.mirror.type.DeclaredType} for information on
-how such unknown types are handled.
-
-
-<h4> Utilities and Tool Support </h4>
-
-The {@link com.sun.mirror.util} package provides
-utilities to assist in the processing of declarations and types.
-Included is support for using the visitor design pattern when
-operating on declaration and type objects.
-
-<p> The {@link com.sun.mirror.apt} package supports the writing
-of annotation processors.  It provides the mechanism for them to
-interact with an annotation processing tool.
-
-
- at since 1.5
-
-</body>
-</html>
diff --git a/src/share/classes/com/sun/mirror/type/AnnotationType.java b/src/share/classes/com/sun/mirror/type/AnnotationType.java
deleted file mode 100644
index 5649993..0000000
--- a/src/share/classes/com/sun/mirror/type/AnnotationType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-
-/**
- * Represents an annotation type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.DeclaredType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface AnnotationType extends InterfaceType {
-
-    /**
-     * {@inheritDoc}
-     */
-    AnnotationTypeDeclaration getDeclaration();
-}
diff --git a/src/share/classes/com/sun/mirror/type/ArrayType.java b/src/share/classes/com/sun/mirror/type/ArrayType.java
deleted file mode 100644
index 93327a4..0000000
--- a/src/share/classes/com/sun/mirror/type/ArrayType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-/**
- * Represents an array type.
- * A multidimensional array type is represented as an array type
- * whose component type is also an array type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.ArrayType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ArrayType extends ReferenceType {
-
-    /**
-     * Returns the component type of this array type.
-     *
-     * @return the component type of this array type
-     */
-    TypeMirror getComponentType();
-}
diff --git a/src/share/classes/com/sun/mirror/type/ClassType.java b/src/share/classes/com/sun/mirror/type/ClassType.java
deleted file mode 100644
index 084d37d..0000000
--- a/src/share/classes/com/sun/mirror/type/ClassType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents a class type.
- * Interface types are represented separately by {@link InterfaceType}.
- * Note that an {@linkplain EnumType enum} is a kind of class.
- *
- * <p> While a {@link ClassDeclaration} represents the <i>declaration</i>
- * of a class, a <tt>ClassType</tt> represents a class <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.DeclaredType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ClassType extends DeclaredType {
-
-    /**
-     * {@inheritDoc}
-     */
-    ClassDeclaration getDeclaration();
-
-    /**
-     * Returns the class type that is a direct supertype of this one.
-     * This is the superclass of this type's declaring class, with any
-     * type arguments substituted in.
-     * The only class with no superclass is <tt>java.lang.Object</tt>,
-     * for which this method returns <tt>null</tt>.
-     *
-     * <p> For example, the class type extended by
-     * {@code java.util.TreeSet<String>} is
-     * {@code java.util.AbstractSet<String>}.
-     *
-     * @return the class type that is a direct supertype of this one,
-     * or <tt>null</tt> if there is none
-     */
-    ClassType getSuperclass();
-}
diff --git a/src/share/classes/com/sun/mirror/type/DeclaredType.java b/src/share/classes/com/sun/mirror/type/DeclaredType.java
deleted file mode 100644
index fddd0dd..0000000
--- a/src/share/classes/com/sun/mirror/type/DeclaredType.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.TypeDeclaration;
-
-
-/**
- * Represents a declared type, either a class type or an interface type.
- * This includes parameterized types such as {@code java.util.Set<String>}
- * as well as raw types.
- *
- * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a <tt>DeclaredType</tt> represents a class
- * or interface <i>type</i>, the latter being a use of the former.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> A <tt>DeclaredType</tt> may represent a type
- * for which details (declaration, supertypes, <i>etc.</i>) are unknown.
- * This may be the result of a processing error, such as a missing class file,
- * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
- * Other method invocations on such an unknown type will not, in general,
- * return meaningful results.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.DeclaredType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface DeclaredType extends ReferenceType {
-
-    /**
-     * Returns the declaration of this type.
-     *
-     * <p> Returns null if this type's declaration is unknown.  This may
-     * be the result of a processing error, such as a missing class file.
-     *
-     * @return the declaration of this type, or null if unknown
-     */
-    TypeDeclaration getDeclaration();
-
-    /**
-     * Returns the type that contains this type as a member.
-     * Returns <tt>null</tt> if this is a top-level type.
-     *
-     * <p> For example, the containing type of {@code O.I<S>}
-     * is the type {@code O}, and the containing type of
-     * {@code O<T>.I<S>} is the type {@code O<T>}.
-     *
-     * @return the type that contains this type,
-     * or <tt>null</tt> if this is a top-level type
-     */
-    DeclaredType getContainingType();
-
-    /**
-     * Returns (in order) the actual type arguments of this type.
-     * For a generic type nested within another generic type
-     * (such as {@code Outer<String>.Inner<Number>}), only the type
-     * arguments of the innermost type are included.
-     *
-     * @return the actual type arguments of this type, or an empty collection
-     * if there are none
-     */
-    Collection<TypeMirror> getActualTypeArguments();
-
-    /**
-     * Returns the interface types that are direct supertypes of this type.
-     * These are the interface types implemented or extended
-     * by this type's declaration, with any type arguments
-     * substituted in.
-     *
-     * <p> For example, the interface type extended by
-     * {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
-     *
-     * @return the interface types that are direct supertypes of this type,
-     * or an empty collection if there are none
-     */
-    Collection<InterfaceType> getSuperinterfaces();
-}
diff --git a/src/share/classes/com/sun/mirror/type/EnumType.java b/src/share/classes/com/sun/mirror/type/EnumType.java
deleted file mode 100644
index 07a019f..0000000
--- a/src/share/classes/com/sun/mirror/type/EnumType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.EnumDeclaration;
-
-
-/**
- * Represents an enum type.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.DeclaredType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface EnumType extends ClassType {
-
-    /**
-     * {@inheritDoc}
-     */
-    EnumDeclaration getDeclaration();
-}
diff --git a/src/share/classes/com/sun/mirror/type/InterfaceType.java b/src/share/classes/com/sun/mirror/type/InterfaceType.java
deleted file mode 100644
index 55440d7..0000000
--- a/src/share/classes/com/sun/mirror/type/InterfaceType.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents an interface type.
- * Note that an {@linkplain AnnotationType annotation type} is
- * a kind of interface.
- *
- * <p> While an {@link InterfaceDeclaration} represents the
- * <i>declaration</i> of an interface, an <tt>InterfaceType</tt>
- * represents an interface <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.DeclaredType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface InterfaceType extends DeclaredType {
-
-    /**
-     * {@inheritDoc}
-     */
-    InterfaceDeclaration getDeclaration();
-}
diff --git a/src/share/classes/com/sun/mirror/type/MirroredTypeException.java b/src/share/classes/com/sun/mirror/type/MirroredTypeException.java
deleted file mode 100644
index c427950..0000000
--- a/src/share/classes/com/sun/mirror/type/MirroredTypeException.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import java.lang.annotation.Annotation;
-
-import com.sun.mirror.declaration.Declaration;
-
-
-/**
- * Thrown when an application attempts to access the {@link Class} object
- * corresponding to a {@link TypeMirror}.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this exception is {@link
- * javax.lang.model.type.MirroredTypeException}.
- *
- * @see MirroredTypesException
- * @see Declaration#getAnnotation(Class)
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class MirroredTypeException extends RuntimeException {
-
-    private static final long serialVersionUID = 1;
-
-    private transient TypeMirror type;          // cannot be serialized
-    private String name;                        // type's qualified "name"
-
-    /**
-     * Constructs a new MirroredTypeException for the specified type.
-     *
-     * @param type  the type being accessed
-     */
-    public MirroredTypeException(TypeMirror type) {
-        super("Attempt to access Class object for TypeMirror " + type);
-        this.type = type;
-        name = type.toString();
-    }
-
-    /**
-     * Returns the type mirror corresponding to the type being accessed.
-     * The type mirror may be unavailable if this exception has been
-     * serialized and then read back in.
-     *
-     * @return the type mirror, or <tt>null</tt> if unavailable
-     */
-    public TypeMirror getTypeMirror() {
-        return type;
-    }
-
-    /**
-     * Returns the fully qualified name of the type being accessed.
-     * More precisely, returns the canonical name of a class,
-     * interface, array, or primitive, and returns <tt>"void"</tt> for
-     * the pseudo-type representing the type of <tt>void</tt>.
-     *
-     * @return the fully qualified name of the type being accessed
-     */
-    public String getQualifiedName() {
-        return name;
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/type/MirroredTypesException.java b/src/share/classes/com/sun/mirror/type/MirroredTypesException.java
deleted file mode 100644
index c6064f7..0000000
--- a/src/share/classes/com/sun/mirror/type/MirroredTypesException.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.mirror.type;
-
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import com.sun.mirror.declaration.Declaration;
-
-
-/**
- * Thrown when an application attempts to access a sequence of {@link Class}
- * objects each corresponding to a {@link TypeMirror}.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this exception is {@link
- * javax.lang.model.type.MirroredTypesException}.
- *
- * @see MirroredTypeException
- * @see Declaration#getAnnotation(Class)
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class MirroredTypesException extends RuntimeException {
-
-    private static final long serialVersionUID = 1;
-
-    private transient Collection<TypeMirror> types;     // cannot be serialized
-    private Collection<String> names;           // types' qualified "names"
-
-    /**
-     * Constructs a new MirroredTypesException for the specified types.
-     *
-     * @param types  an ordered collection of the types being accessed
-     */
-    public MirroredTypesException(Collection<TypeMirror> types) {
-        super("Attempt to access Class objects for TypeMirrors " + types);
-        this.types = types;
-        names = new ArrayList<String>();
-        for (TypeMirror t : types) {
-            names.add(t.toString());
-        }
-    }
-
-    /**
-     * Returns the type mirrors corresponding to the types being accessed.
-     * The type mirrors may be unavailable if this exception has been
-     * serialized and then read back in.
-     *
-     * @return the type mirrors in order, or <tt>null</tt> if unavailable
-     */
-    public Collection<TypeMirror> getTypeMirrors() {
-        return (types != null)
-                ? Collections.unmodifiableCollection(types)
-                : null;
-    }
-
-    /**
-     * Returns the fully qualified names of the types being accessed.
-     * More precisely, returns the canonical names of each class,
-     * interface, array, or primitive, and <tt>"void"</tt> for
-     * the pseudo-type representing the type of <tt>void</tt>.
-     *
-     * @return the fully qualified names, in order, of the types being
-     *          accessed
-     */
-    public Collection<String> getQualifiedNames() {
-        return Collections.unmodifiableCollection(names);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/type/PrimitiveType.java b/src/share/classes/com/sun/mirror/type/PrimitiveType.java
deleted file mode 100644
index 9e0d868..0000000
--- a/src/share/classes/com/sun/mirror/type/PrimitiveType.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-/**
- * Represents a primitive type.  These include
- * <tt>boolean</tt>, <tt>byte</tt>, <tt>short</tt>, <tt>int</tt>,
- * <tt>long</tt>, <tt>char</tt>, <tt>float</tt>, and <tt>double</tt>.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.PrimitiveType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface PrimitiveType extends TypeMirror {
-
-    /**
-     * Returns the kind of primitive type that this object represents.
-     *
-     * @return the kind of primitive type that this object represents
-     */
-    Kind getKind();
-
-    /**
-     * An enumeration of the different kinds of primitive types.
-     *
-     * @deprecated All components of this API have been superseded by
-     * the standardized annotation processing API.  The replacement
-     * for the functionality of this enum is {@link
-     * javax.lang.model.type.TypeKind}.
-     */
-    @Deprecated
-    enum Kind {
-        /** The primitive type <tt>boolean</tt> */      BOOLEAN,
-        /** The primitive type <tt>byte</tt> */         BYTE,
-        /** The primitive type <tt>short</tt> */        SHORT,
-        /** The primitive type <tt>int</tt> */          INT,
-        /** The primitive type <tt>long</tt> */         LONG,
-        /** The primitive type <tt>char</tt> */         CHAR,
-        /** The primitive type <tt>float</tt> */        FLOAT,
-        /** The primitive type <tt>double</tt> */       DOUBLE
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/type/ReferenceType.java b/src/share/classes/com/sun/mirror/type/ReferenceType.java
deleted file mode 100644
index ba997ae..0000000
--- a/src/share/classes/com/sun/mirror/type/ReferenceType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-/**
- * Represents a reference type.
- * These include class and interface types, array types, and type variables.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.ReferenceType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface ReferenceType extends TypeMirror {
-}
diff --git a/src/share/classes/com/sun/mirror/type/TypeMirror.java b/src/share/classes/com/sun/mirror/type/TypeMirror.java
deleted file mode 100644
index 74db855..0000000
--- a/src/share/classes/com/sun/mirror/type/TypeMirror.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.util.Types;
-import com.sun.mirror.util.TypeVisitor;
-
-
-/**
- * Represents a type in the Java programming language.
- * Types include primitive types, class and interface types, array
- * types, and type variables.  Wildcard type arguments, and the
- * pseudo-type representing the type of <tt>void</tt>, are represented
- * by type mirrors as well.
- *
- * <p> Types may be compared using the utility methods in
- * {@link Types}.
- * There is no guarantee that any particular type will
- * always be represented by the same object.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.TypeMirror}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @see Declaration
- * @see Types
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface TypeMirror {
-
-    /**
-     * Returns a string representation of this type.
-     * Any names embedded in the expression are qualified.
-     *
-     * @return a string representation of this type
-     */
-    String toString();
-
-    /**
-     * Tests whether two types represent the same type.
-     *
-     * @param obj the object to be compared with this type
-     * @return <tt>true</tt> if the specified object represents the same
-     *          type as this.
-     */
-    boolean equals(Object obj);
-
-    /**
-     * Applies a visitor to this type.
-     *
-     * @param v the visitor operating on this type
-     */
-    void accept(TypeVisitor v);
-}
diff --git a/src/share/classes/com/sun/mirror/type/TypeVariable.java b/src/share/classes/com/sun/mirror/type/TypeVariable.java
deleted file mode 100644
index 33b9e8c..0000000
--- a/src/share/classes/com/sun/mirror/type/TypeVariable.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Represents a type variable.
- * A type variable is declared by a
- * {@linkplain TypeParameterDeclaration type parameter} of a
- * type, method, or constructor.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.TypeVariable}.
- *
- * @author Joe Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface TypeVariable extends ReferenceType {
-
-    /**
-     * Returns the type parameter that declared this type variable.
-     *
-     * @return the type parameter that declared this type variable
-     */
-    TypeParameterDeclaration getDeclaration();
-}
diff --git a/src/share/classes/com/sun/mirror/type/VoidType.java b/src/share/classes/com/sun/mirror/type/VoidType.java
deleted file mode 100644
index ed58e35..0000000
--- a/src/share/classes/com/sun/mirror/type/VoidType.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import com.sun.mirror.declaration.MethodDeclaration;
-
-
-/**
- * A pseudo-type representing the type of <tt>void</tt>.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is included in {@link
- * javax.lang.model.type.NoType}.
- *
- * @see MethodDeclaration#getReturnType()
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface VoidType extends TypeMirror {
-}
diff --git a/src/share/classes/com/sun/mirror/type/WildcardType.java b/src/share/classes/com/sun/mirror/type/WildcardType.java
deleted file mode 100644
index b0ed117..0000000
--- a/src/share/classes/com/sun/mirror/type/WildcardType.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.type;
-
-
-import java.util.Collection;
-
-
-/**
- * Represents a wildcard type argument.
- * Examples include:    <pre><tt>
- *   ?
- *   ? extends Number
- *   ? super T
- * </tt></pre>
- *
- * <p> A wildcard may have its upper bound explicitly set by an
- * <tt>extends</tt> clause, its lower bound explicitly set by a
- * <tt>super</tt> clause, or neither (but not both).
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.type.WildcardType}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface WildcardType extends TypeMirror {
-
-    /**
-     * Returns the upper bounds of this wildcard.
-     * If no upper bound is explicitly declared, then
-     * an empty collection is returned.
-     *
-     * @return the upper bounds of this wildcard
-     */
-    Collection<ReferenceType> getUpperBounds();
-
-    /**
-     * Returns the lower bounds of this wildcard.
-     * If no lower bound is explicitly declared, then
-     * an empty collection is returned.
-     *
-     * @return the lower bounds of this wildcard
-     */
-    Collection<ReferenceType> getLowerBounds();
-}
diff --git a/src/share/classes/com/sun/mirror/type/package-info.java b/src/share/classes/com/sun/mirror/type/package-info.java
deleted file mode 100644
index 578936f..0000000
--- a/src/share/classes/com/sun/mirror/type/package-info.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-/**
- * Interfaces used to model types.  A type is represented by the
- * appropriate subinterface of {@link com.sun.mirror.type.TypeMirror}.
- *
- * <p>The {@code apt} tool and its associated API have been
- * superseded by the standardized annotation processing API.  The
- * replacement for the functionality in this package is {@link
- * javax.lang.model.type}.
- *
- * @since 1.5
- */
-package com.sun.mirror.type;
diff --git a/src/share/classes/com/sun/mirror/util/DeclarationFilter.java b/src/share/classes/com/sun/mirror/util/DeclarationFilter.java
deleted file mode 100644
index 1cae606..0000000
--- a/src/share/classes/com/sun/mirror/util/DeclarationFilter.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.Modifier;
-
-import static com.sun.mirror.declaration.Modifier.*;
-
-
-/**
- * A filter for selecting just the items of interest
- * from a collection of declarations.
- * The filter is said to <i>select</i> or to <i>match</i> those declarations.
- * Filters can be created in several ways:
- * by the static methods described below,
- * by negating or composing existing filters,
- * or by subclasses that implement arbitrary matching rules.
- *
- * <p> A subclass can create an arbitrary filter simply by implementing
- * the {@link #matches(Declaration)} method.
- *
- * <p> Examples.
- * <p> Selecting the <tt>public</tt> declarations from a collection:
- * <blockquote><pre>
- *     result = FILTER_PUBLIC.filter(decls);            </pre></blockquote>
- * Selecting class declarations (including enums):
- * <blockquote><pre>
- *     classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
- *     result = classFilter.filter(decls);              </pre></blockquote>
- * Selecting class declarations but excluding enums:
- * <blockquote><pre>
- *     enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
- *     compoundFilter = classFilter.and(enumFilter.not());
- *     result = compoundFilter.filter(decls);           </pre></blockquote>
- * Selecting declarations named "Bob":
- * <blockquote><pre>
- *     nameFilter = new DeclarationFilter() {
- *                      public boolean matches(Declaration d) {
- *                          return d.getSimpleName().equals("Bob");
- *                      }
- *                  };
- *     result = nameFilter.filter(decls);               </pre></blockquote>
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this class is {@link
- * javax.lang.model.util.ElementFilter}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class DeclarationFilter {
-
-    // Predefined filters for convenience.
-
-    /**
-     * A filter that selects only <tt>public</tt> declarations.
-     */
-    public static final DeclarationFilter FILTER_PUBLIC =
-            new AccessFilter(PUBLIC);
-
-    /**
-     * A filter that selects only <tt>protected</tt> declarations.
-     */
-    public static final DeclarationFilter FILTER_PROTECTED =
-            new AccessFilter(PROTECTED);
-
-    /**
-     * A filter that selects only <tt>public</tt> or <tt>protected</tt>
-     * declarations.
-     */
-    public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED =
-            new AccessFilter(PUBLIC, PROTECTED);
-
-    /**
-     * A filter that selects only package-private (<i>default</i>)
-     * declarations.
-     */
-    public static final DeclarationFilter FILTER_PACKAGE =
-            new AccessFilter();
-
-    /**
-     * A filter that selects only <tt>private</tt> declarations.
-     */
-    public static final DeclarationFilter FILTER_PRIVATE =
-            new AccessFilter(PRIVATE);
-
-
-    /**
-     * Constructs an identity filter:  one that selects all declarations.
-     */
-    public DeclarationFilter() {
-    }
-
-
-
-    // Methods to create a filter.
-
-    /**
-     * Returns a filter that selects declarations containing all of a
-     * collection of modifiers.
-     *
-     * @param mods  the modifiers to match (non-null)
-     * @return a filter that matches declarations containing <tt>mods</tt>
-     */
-    public static DeclarationFilter getFilter(
-                                             final Collection<Modifier> mods) {
-        return new DeclarationFilter() {
-            public boolean matches(Declaration d) {
-                return d.getModifiers().containsAll(mods);
-            }
-        };
-    }
-
-    /**
-     * Returns a filter that selects declarations of a particular kind.
-     * For example, there may be a filter that selects only class
-     * declarations, or only fields.
-     * The filter will select declarations of the specified kind,
-     * and also any subtypes of that kind; for example, a field filter
-     * will also select enum constants.
-     *
-     * @param kind  the kind of declarations to select
-     * @return a filter that selects declarations of a particular kind
-     */
-    public static DeclarationFilter getFilter(
-                                     final Class<? extends Declaration> kind) {
-        return new DeclarationFilter() {
-            public boolean matches(Declaration d) {
-                return kind.isInstance(d);
-            }
-        };
-    }
-
-    /**
-     * Returns a filter that selects those declarations selected
-     * by both this filter and another.
-     *
-     * @param f  filter to be composed with this one
-     * @return a filter that selects those declarations selected by
-     *          both this filter and another
-     */
-    public DeclarationFilter and(DeclarationFilter f) {
-        final DeclarationFilter f1 = this;
-        final DeclarationFilter f2 = f;
-        return new DeclarationFilter() {
-            public boolean matches(Declaration d) {
-                return f1.matches(d) && f2.matches(d);
-            }
-        };
-    }
-
-    /**
-     * Returns a filter that selects those declarations selected
-     * by either this filter or another.
-     *
-     * @param f  filter to be composed with this one
-     * @return a filter that selects those declarations selected by
-     *          either this filter or another
-     */
-    public DeclarationFilter or(DeclarationFilter f) {
-        final DeclarationFilter f1 = this;
-        final DeclarationFilter f2 = f;
-        return new DeclarationFilter() {
-            public boolean matches(Declaration d) {
-                return f1.matches(d) || f2.matches(d);
-            }
-        };
-    }
-
-    /**
-     * Returns a filter that selects those declarations not selected
-     * by this filter.
-     *
-     * @return a filter that selects those declarations not selected
-     * by this filter
-     */
-    public DeclarationFilter not() {
-        return new DeclarationFilter() {
-            public boolean matches(Declaration d) {
-                return !DeclarationFilter.this.matches(d);
-            }
-        };
-    }
-
-
-
-    // Methods to apply a filter.
-
-    /**
-     * Tests whether this filter matches a given declaration.
-     * The default implementation always returns <tt>true</tt>;
-     * subclasses should override this.
-     *
-     * @param decl  the declaration to match
-     * @return <tt>true</tt> if this filter matches the given declaration
-     */
-    public boolean matches(Declaration decl) {
-        return true;
-    }
-
-    /**
-     * Returns the declarations matched by this filter.
-     * The result is a collection of the same type as the argument;
-     * the {@linkplain #filter(Collection, Class) two-parameter version}
-     * of <tt>filter</tt> offers control over the result type.
-     *
-     * @param <D>    type of the declarations being filtered
-     * @param decls  declarations being filtered
-     * @return the declarations matched by this filter
-     */
-    public <D extends Declaration> Collection<D> filter(Collection<D> decls) {
-        ArrayList<D> res = new ArrayList<D>(decls.size());
-        for (D d : decls) {
-            if (matches(d)) {
-                res.add(d);
-            }
-        }
-        return res;
-    }
-
-    /**
-     * Returns the declarations matched by this filter, with the result
-     * being restricted to declarations of a given kind.
-     * Similar to the simpler
-     * {@linkplain #filter(Collection) single-parameter version}
-     * of <tt>filter</tt>, but the result type is specified explicitly.
-     *
-     * @param <D>      type of the declarations being returned
-     * @param decls    declarations being filtered
-     * @param resType  type of the declarations being returned --
-     *                  the reflective view of <tt>D</tt>
-     * @return the declarations matched by this filter, restricted to those
-     *                  of the specified type
-     */
-    public <D extends Declaration> Collection<D>
-            filter(Collection<? extends Declaration> decls, Class<D> resType) {
-        ArrayList<D> res = new ArrayList<D>(decls.size());
-        for (Declaration d : decls) {
-            if (resType.isInstance(d) && matches(d)) {
-                res.add(resType.cast(d));
-            }
-        }
-        return res;
-    }
-
-
-
-    /*
-     * A filter based on access modifiers.
-     */
-    private static class AccessFilter extends DeclarationFilter {
-
-        // The first access modifier to filter on, or null if we're looking
-        // for declarations with no access modifiers.
-        private Modifier mod1 = null;
-
-        // The second access modifier to filter on, or null if none.
-        private Modifier mod2 = null;
-
-        // Returns a filter that matches declarations with no access
-        // modifiers.
-        AccessFilter() {
-        }
-
-        // Returns a filter that matches m.
-        AccessFilter(Modifier m) {
-            mod1 = m;
-        }
-
-        // Returns a filter that matches either m1 or m2.
-        AccessFilter(Modifier m1, Modifier m2) {
-            mod1 = m1;
-            mod2 = m2;
-        }
-
-        public boolean matches(Declaration d) {
-            Collection<Modifier> mods = d.getModifiers();
-            if (mod1 == null) { // looking for package private
-                return !(mods.contains(PUBLIC) ||
-                         mods.contains(PROTECTED) ||
-                         mods.contains(PRIVATE));
-            }
-            return mods.contains(mod1) &&
-                   (mod2 == null || mods.contains(mod2));
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/util/DeclarationScanner.java b/src/share/classes/com/sun/mirror/util/DeclarationScanner.java
deleted file mode 100644
index 170e964..0000000
--- a/src/share/classes/com/sun/mirror/util/DeclarationScanner.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-/**
- * A visitor for declarations that scans declarations contained within
- * the given declaration.  For example, when visiting a class, the
- * methods, fields, constructors, and nested types of the class are
- * also visited.
- *
- * <p> To control the processing done on a declaration, users of this
- * class pass in their own visitors for pre and post processing.  The
- * preprocessing visitor is called before the contained declarations
- * are scanned; the postprocessing visitor is called after the
- * contained declarations are scanned.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this class is {@link
- * javax.lang.model.util.ElementScanner6}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-class DeclarationScanner implements DeclarationVisitor {
-    protected DeclarationVisitor pre;
-    protected DeclarationVisitor post;
-
-    DeclarationScanner(DeclarationVisitor pre, DeclarationVisitor post) {
-        this.pre = pre;
-        this.post = post;
-    }
-
-    /**
-     * Visits a declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitDeclaration(Declaration d) {
-        d.accept(pre);
-        d.accept(post);
-    }
-
-    /**
-     * Visits a package declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitPackageDeclaration(PackageDeclaration d) {
-        d.accept(pre);
-
-        for(ClassDeclaration classDecl: d.getClasses()) {
-            classDecl.accept(this);
-        }
-
-        for(InterfaceDeclaration interfaceDecl: d.getInterfaces()) {
-            interfaceDecl.accept(this);
-        }
-
-        d.accept(post);
-    }
-
-    /**
-     * Visits a member or constructor declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitMemberDeclaration(MemberDeclaration d) {
-        visitDeclaration(d);
-    }
-
-    /**
-     * Visits a type declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitTypeDeclaration(TypeDeclaration d) {
-        d.accept(pre);
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
-            tpDecl.accept(this);
-        }
-
-        for(FieldDeclaration fieldDecl: d.getFields()) {
-            fieldDecl.accept(this);
-        }
-
-        for(MethodDeclaration methodDecl: d.getMethods()) {
-            methodDecl.accept(this);
-        }
-
-        for(TypeDeclaration typeDecl: d.getNestedTypes()) {
-            typeDecl.accept(this);
-        }
-
-        d.accept(post);
-    }
-
-    /**
-     * Visits a class declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitClassDeclaration(ClassDeclaration d) {
-        d.accept(pre);
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
-            tpDecl.accept(this);
-        }
-
-        for(FieldDeclaration fieldDecl: d.getFields()) {
-            fieldDecl.accept(this);
-        }
-
-        for(MethodDeclaration methodDecl: d.getMethods()) {
-            methodDecl.accept(this);
-        }
-
-        for(TypeDeclaration typeDecl: d.getNestedTypes()) {
-            typeDecl.accept(this);
-        }
-
-        for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
-            ctorDecl.accept(this);
-        }
-
-        d.accept(post);
-    }
-
-    /**
-     * Visits an enum declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitEnumDeclaration(EnumDeclaration d) {
-        visitClassDeclaration(d);
-    }
-
-    /**
-     * Visits an interface declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitInterfaceDeclaration(InterfaceDeclaration d) {
-        visitTypeDeclaration(d);
-    }
-
-    /**
-     * Visits an annotation type declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
-        visitInterfaceDeclaration(d);
-    }
-
-    /**
-     * Visits a field declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitFieldDeclaration(FieldDeclaration d) {
-        visitMemberDeclaration(d);
-    }
-
-    /**
-     * Visits an enum constant declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
-        visitFieldDeclaration(d);
-    }
-
-    /**
-     * Visits a method or constructor declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitExecutableDeclaration(ExecutableDeclaration d) {
-        d.accept(pre);
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
-            tpDecl.accept(this);
-        }
-
-        for(ParameterDeclaration pDecl: d.getParameters()) {
-            pDecl.accept(this);
-        }
-
-        d.accept(post);
-    }
-
-    /**
-     * Visits a constructor declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitConstructorDeclaration(ConstructorDeclaration d) {
-        visitExecutableDeclaration(d);
-    }
-
-    /**
-     * Visits a method declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitMethodDeclaration(MethodDeclaration d) {
-        visitExecutableDeclaration(d);
-    }
-
-    /**
-     * Visits an annotation type element declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeElementDeclaration(
-            AnnotationTypeElementDeclaration d) {
-        visitMethodDeclaration(d);
-    }
-
-    /**
-     * Visits a parameter declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitParameterDeclaration(ParameterDeclaration d) {
-        visitDeclaration(d);
-    }
-
-    /**
-     * Visits a type parameter declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
-        visitDeclaration(d);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java b/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java
deleted file mode 100644
index 287b2c4..0000000
--- a/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * A visitor for declarations, in the style of the standard visitor
- * design pattern.  Classes implementing this interface are used to
- * operate on a declaration when the kind of declaration is unknown at
- * compile time.  When a visitor is passed to a declaration's {@link
- * Declaration#accept accept} method, the most specific
- * <tt>visit<i>Xxx</i></tt> method applicable to that declaration is
- * invoked.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.ElementVisitor}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface DeclarationVisitor {
-
-    /**
-     * Visits a declaration.
-     * @param d the declaration to visit
-     */
-    public void visitDeclaration(Declaration d);
-
-    /**
-     * Visits a package declaration.
-     * @param d the declaration to visit
-     */
-    public void visitPackageDeclaration(PackageDeclaration d);
-
-    /**
-     * Visits a member or constructor declaration.
-     * @param d the declaration to visit
-     */
-    public void visitMemberDeclaration(MemberDeclaration d);
-
-    /**
-     * Visits a type declaration.
-     * @param d the declaration to visit
-     */
-    public void visitTypeDeclaration(TypeDeclaration d);
-
-    /**
-     * Visits a class declaration.
-     * @param d the declaration to visit
-     */
-    public void visitClassDeclaration(ClassDeclaration d);
-
-    /**
-     * Visits an enum declaration.
-     * @param d the declaration to visit
-     */
-    public void visitEnumDeclaration(EnumDeclaration d);
-
-    /**
-     * Visits an interface declaration.
-     * @param d the declaration to visit
-     */
-    public void visitInterfaceDeclaration(InterfaceDeclaration d);
-
-    /**
-     * Visits an annotation type declaration.
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d);
-
-    /**
-     * Visits a field declaration.
-     * @param d the declaration to visit
-     */
-    public void visitFieldDeclaration(FieldDeclaration d);
-
-    /**
-     * Visits an enum constant declaration.
-     * @param d the declaration to visit
-     */
-    public void visitEnumConstantDeclaration(EnumConstantDeclaration d);
-
-    /**
-     * Visits a method or constructor declaration.
-     * @param d the declaration to visit
-     */
-    public void visitExecutableDeclaration(ExecutableDeclaration d);
-
-    /**
-     * Visits a constructor declaration.
-     * @param d the declaration to visit
-     */
-    public void visitConstructorDeclaration(ConstructorDeclaration d);
-
-    /**
-     * Visits a method declaration.
-     * @param d the declaration to visit
-     */
-    public void visitMethodDeclaration(MethodDeclaration d);
-
-    /**
-     * Visits an annotation type element declaration.
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeElementDeclaration(
-                                     AnnotationTypeElementDeclaration d);
-
-    /**
-     * Visits a parameter declaration.
-     * @param d the declaration to visit
-     */
-    public void visitParameterDeclaration(ParameterDeclaration d);
-
-    /**
-     * Visits a type parameter declaration.
-     * @param d the declaration to visit
-     */
-    public void visitTypeParameterDeclaration(TypeParameterDeclaration d);
-}
diff --git a/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java b/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java
deleted file mode 100644
index b4072ea..0000000
--- a/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-/**
- * Utilities to create specialized <tt>DeclarationVisitor</tt> instances.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  There is no direct
- * replacement for the functionality of this class in the standardized
- * API due to that API's different visitor structure.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class DeclarationVisitors {
-    private DeclarationVisitors(){} // do not instantiate.
-
-    /**
-     * A visitor that has no side effects and keeps no state.
-     */
-    public static final DeclarationVisitor NO_OP = new SimpleDeclarationVisitor();
-
-    /**
-     * Return a <tt>DeclarationVisitor</tt> that will scan the
-     * declaration structure, visiting declarations contained in
-     * another declaration.  For example, when visiting a class, the
-     * fields, methods, constructors, etc. of the class are also
-     * visited.  The order in which the contained declarations are scanned is
-     * not specified.
-     *
-     * <p>The <tt>pre</tt> and <tt>post</tt>
-     * <tt>DeclarationVisitor</tt> parameters specify,
-     * respectively, the processing the scanner will do before or
-     * after visiting the contained declarations.  If only one of pre
-     * and post processing is needed, use {@link
-     * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the
-     * other parameter.
-     *
-     * @param pre visitor representing processing to do before
-     * visiting contained declarations.
-     *
-     * @param post visitor representing processing to do after
-     * visiting contained declarations.
-     */
-    public static DeclarationVisitor getDeclarationScanner(DeclarationVisitor pre,
-                                                           DeclarationVisitor post) {
-        return new DeclarationScanner(pre, post);
-    }
-
-    /**
-     * Return a <tt>DeclarationVisitor</tt> that will scan the
-     * declaration structure, visiting declarations contained in
-     * another declaration in source code order.  For example, when
-     * visiting a class, the fields, methods, constructors, etc. of
-     * the class are also visited.  The order in which the contained
-     * declarations are visited is as close to source code order as
-     * possible; declaration mirrors created from class files instead
-     * of source code will not have source position information.
-     *
-     * <p>The <tt>pre</tt> and <tt>post</tt>
-     * <tt>DeclarationVisitor</tt> parameters specify,
-     * respectively, the processing the scanner will do before or
-     * after visiting the contained declarations.  If only one of pre
-     * and post processing is needed, use {@link
-     * DeclarationVisitors#NO_OP DeclarationVisitors.NO_OP} for the other parameter.
-     *
-     * @param pre visitor representing processing to do before
-     * visiting contained declarations.
-     *
-     * @param post visitor representing processing to do after
-     * visiting contained declarations.
-     */
-    public static DeclarationVisitor getSourceOrderDeclarationScanner(DeclarationVisitor pre,
-                                                                      DeclarationVisitor post) {
-        return new SourceOrderDeclScanner(pre, post);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/util/Declarations.java b/src/share/classes/com/sun/mirror/util/Declarations.java
deleted file mode 100644
index 8908bd4..0000000
--- a/src/share/classes/com/sun/mirror/util/Declarations.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * Utility methods for operating on declarations.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.util.Elements}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface Declarations {
-
-    /**
-     * Tests whether one type, method, or field declaration hides another.
-     *
-     * @param sub the first member
-     * @param sup the second member
-     * @return <tt>true</tt> if and only if the first member hides
-     *          the second
-     */
-    boolean hides(MemberDeclaration sub, MemberDeclaration sup);
-
-    /**
-     * Tests whether one method overrides another.  When a
-     * non-abstract method overrides an abstract one, the
-     * former is also said to <i>implement</i> the latter.
-     *
-     * @param sub the first method
-     * @param sup the second method
-     * @return <tt>true</tt> if and only if the first method overrides
-     *          the second
-     */
-    boolean overrides(MethodDeclaration sub, MethodDeclaration sup);
-}
diff --git a/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java b/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java
deleted file mode 100644
index 93a61e4..0000000
--- a/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import com.sun.mirror.declaration.*;
-
-
-/**
- * A simple visitor for declarations.
- *
- * <p> The implementations of the methods of this class do nothing but
- * delegate up the declaration hierarchy.  A subclass should override the
- * methods that correspond to the kinds of declarations on which it
- * will operate.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this class is {@link
- * javax.lang.model.util.SimpleElementVisitor6}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class SimpleDeclarationVisitor implements DeclarationVisitor {
-
-    /**
-     * Creates a new <tt>SimpleDeclarationVisitor</tt>.
-     */
-    public SimpleDeclarationVisitor(){}
-
-    /**
-     * Visits a declaration.
-     * The implementation does nothing.
-     * @param d the declaration to visit
-     */
-    public void visitDeclaration(Declaration d) {
-    }
-
-    /**
-     * Visits a package declaration.
-     * The implementation simply invokes
-     * {@link #visitDeclaration visitDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitPackageDeclaration(PackageDeclaration d) {
-        visitDeclaration(d);
-    }
-
-    /**
-     * Visits a member or constructor declaration.
-     * The implementation simply invokes
-     * {@link #visitDeclaration visitDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitMemberDeclaration(MemberDeclaration d) {
-        visitDeclaration(d);
-    }
-
-    /**
-     * Visits a type declaration.
-     * The implementation simply invokes
-     * {@link #visitMemberDeclaration visitMemberDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitTypeDeclaration(TypeDeclaration d) {
-        visitMemberDeclaration(d);
-    }
-
-    /**
-     * Visits a class declaration.
-     * The implementation simply invokes
-     * {@link #visitTypeDeclaration visitTypeDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitClassDeclaration(ClassDeclaration d) {
-        visitTypeDeclaration(d);
-    }
-
-    /**
-     * Visits an enum declaration.
-     * The implementation simply invokes
-     * {@link #visitClassDeclaration visitClassDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitEnumDeclaration(EnumDeclaration d) {
-        visitClassDeclaration(d);
-    }
-
-    /**
-     * Visits an interface declaration.
-     * The implementation simply invokes
-     * {@link #visitTypeDeclaration visitTypeDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitInterfaceDeclaration(InterfaceDeclaration d) {
-        visitTypeDeclaration(d);
-    }
-
-    /**
-     * Visits an annotation type declaration.
-     * The implementation simply invokes
-     * {@link #visitInterfaceDeclaration visitInterfaceDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
-        visitInterfaceDeclaration(d);
-    }
-
-    /**
-     * Visits a field declaration.
-     * The implementation simply invokes
-     * {@link #visitMemberDeclaration visitMemberDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitFieldDeclaration(FieldDeclaration d) {
-        visitMemberDeclaration(d);
-    }
-
-    /**
-     * Visits an enum constant declaration.
-     * The implementation simply invokes
-     * {@link #visitFieldDeclaration visitFieldDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
-        visitFieldDeclaration(d);
-    }
-
-    /**
-     * Visits a method or constructor declaration.
-     * The implementation simply invokes
-     * {@link #visitMemberDeclaration visitMemberDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitExecutableDeclaration(ExecutableDeclaration d) {
-        visitMemberDeclaration(d);
-    }
-
-    /**
-     * Visits a constructor declaration.
-     * The implementation simply invokes
-     * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitConstructorDeclaration(ConstructorDeclaration d) {
-        visitExecutableDeclaration(d);
-    }
-
-    /**
-     * Visits a method declaration.
-     * The implementation simply invokes
-     * {@link #visitExecutableDeclaration visitExecutableDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitMethodDeclaration(MethodDeclaration d) {
-        visitExecutableDeclaration(d);
-    }
-
-    /**
-     * Visits an annotation type element declaration.
-     * The implementation simply invokes
-     * {@link #visitMethodDeclaration visitMethodDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitAnnotationTypeElementDeclaration(
-            AnnotationTypeElementDeclaration d) {
-        visitMethodDeclaration(d);
-    }
-
-    /**
-     * Visits a parameter declaration.
-     * The implementation simply invokes
-     * {@link #visitDeclaration visitDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitParameterDeclaration(ParameterDeclaration d) {
-        visitDeclaration(d);
-    }
-
-    /**
-     * Visits a type parameter declaration.
-     * The implementation simply invokes
-     * {@link #visitDeclaration visitDeclaration}.
-     * @param d the declaration to visit
-     */
-    public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {
-        visitDeclaration(d);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java b/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java
deleted file mode 100644
index 188024c..0000000
--- a/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import com.sun.mirror.type.*;
-
-
-/**
- * A simple visitor for types.
- *
- * <p> The implementations of the methods of this class do nothing but
- * delegate up the type hierarchy.  A subclass should override the
- * methods that correspond to the kinds of types on which it will
- * operate.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this class is {@link
- * javax.lang.model.util.SimpleTypeVisitor6}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public class SimpleTypeVisitor implements TypeVisitor {
-
-    /**
-     * Creates a new <tt>SimpleTypeVisitor</tt>.
-     */
-    public SimpleTypeVisitor() {}
-
-    /**
-     * Visits a type mirror.
-     * The implementation does nothing.
-     * @param t the type to visit
-     */
-    public void visitTypeMirror(TypeMirror t) {
-    }
-
-    /**
-     * Visits a primitive type.
-     * The implementation simply invokes
-     * {@link #visitTypeMirror visitTypeMirror}.
-     * @param t the type to visit
-     */
-    public void visitPrimitiveType(PrimitiveType t) {
-        visitTypeMirror(t);
-    }
-
-    /**
-     * Visits a void type.
-     * The implementation simply invokes
-     * {@link #visitTypeMirror visitTypeMirror}.
-     * @param t the type to visit
-     */
-    public void visitVoidType(VoidType t) {
-        visitTypeMirror(t);
-    }
-
-    /**
-     * Visits a reference type.
-     * The implementation simply invokes
-     * {@link #visitTypeMirror visitTypeMirror}.
-     * @param t the type to visit
-     */
-    public void visitReferenceType(ReferenceType t) {
-        visitTypeMirror(t);
-    }
-
-    /**
-     * Visits a declared type.
-     * The implementation simply invokes
-     * {@link #visitReferenceType visitReferenceType}.
-     * @param t the type to visit
-     */
-    public void visitDeclaredType(DeclaredType t) {
-        visitReferenceType(t);
-    }
-
-    /**
-     * Visits a class type.
-     * The implementation simply invokes
-     * {@link #visitDeclaredType visitDeclaredType}.
-     * @param t the type to visit
-     */
-    public void visitClassType(ClassType t) {
-        visitDeclaredType(t);
-    }
-
-    /**
-     * Visits an enum type.
-     * The implementation simply invokes
-     * {@link #visitClassType visitClassType}.
-     * @param t the type to visit
-     */
-    public void visitEnumType(EnumType t) {
-        visitClassType(t);
-    }
-
-    /**
-     * Visits an interface type.
-     * The implementation simply invokes
-     * {@link #visitDeclaredType visitDeclaredType}.
-     * @param t the type to visit
-     */
-    public void visitInterfaceType(InterfaceType t) {
-        visitDeclaredType(t);
-    }
-
-    /**
-     * Visits an annotation type.
-     * The implementation simply invokes
-     * {@link #visitInterfaceType visitInterfaceType}.
-     * @param t the type to visit
-     */
-    public void visitAnnotationType(AnnotationType t) {
-        visitInterfaceType(t);
-    }
-
-    /**
-     * Visits an array type.
-     * The implementation simply invokes
-     * {@link #visitReferenceType visitReferenceType}.
-     * @param t the type to visit
-     */
-    public void visitArrayType(ArrayType t) {
-        visitReferenceType(t);
-    }
-
-    /**
-     * Visits a type variable.
-     * The implementation simply invokes
-     * {@link #visitReferenceType visitReferenceType}.
-     * @param t the type to visit
-     */
-    public void visitTypeVariable(TypeVariable t) {
-        visitReferenceType(t);
-    }
-
-    /**
-     * Visits a wildcard.
-     * The implementation simply invokes
-     * {@link #visitTypeMirror visitTypeMirror}.
-     * @param t the type to visit
-     */
-    public void visitWildcardType(WildcardType t) {
-        visitTypeMirror(t);
-    }
-}
diff --git a/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java b/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java
deleted file mode 100644
index 243de93..0000000
--- a/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.mirror.util;
-
-import com.sun.mirror.declaration.*;
-
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * A visitor for declarations that scans declarations contained within
- * the given declaration in source code order.  For example, when
- * visiting a class, the methods, fields, constructors, and nested
- * types of the class are also visited.
- *
- * To control the processing done on a declaration, users of this
- * class pass in their own visitors for pre and post processing.  The
- * preprocessing visitor is called before the contained declarations
- * are scanned; the postprocessing visitor is called after the
- * contained declarations are scanned.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this class is {@link
- * javax.lang.model.util.SimpleElementVisitor6}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-class SourceOrderDeclScanner extends DeclarationScanner {
-    static class SourceOrderComparator implements java.util.Comparator<Declaration> {
-        SourceOrderComparator(){}
-
-
-        static boolean equals(Declaration d1, Declaration d2) {
-            return d1 == d2 || (d1 != null && d1.equals(d2));
-        }
-
-        private static class DeclPartialOrder extends com.sun.mirror.util.SimpleDeclarationVisitor {
-            private int value = 1000;
-            private static int staticAdjust(Declaration d) {
-                return d.getModifiers().contains(Modifier.STATIC)?0:1;
-            }
-
-            DeclPartialOrder() {}
-
-            public int getValue() { return value; }
-
-            @Override
-            public void visitTypeParameterDeclaration(TypeParameterDeclaration d) {value = 0;}
-
-            @Override
-            public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {value = 1;}
-
-            @Override
-            public void visitClassDeclaration(ClassDeclaration d) {value = 2 + staticAdjust(d);}
-
-            @Override
-            public void visitInterfaceDeclaration(InterfaceDeclaration d) {value = 4;}
-
-            @Override
-            public void visitEnumDeclaration(EnumDeclaration d) {value = 6;}
-
-            @Override
-            public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {value = 8;}
-
-            @Override
-            public void visitFieldDeclaration(FieldDeclaration d) {value = 10 + staticAdjust(d);}
-
-            @Override
-            public void visitConstructorDeclaration(ConstructorDeclaration d) {value = 12;}
-
-            @Override
-            public void visitMethodDeclaration(MethodDeclaration d) {value = 14 + staticAdjust(d);}
-        }
-        @SuppressWarnings("cast")
-        private int compareEqualPosition(Declaration d1, Declaration d2) {
-            assert
-                (d1.getPosition() == d2.getPosition()) || // Handles two null positions.
-                (d1.getPosition().file().compareTo(d2.getPosition().file()) == 0 &&
-                 d1.getPosition().line()   == d2.getPosition().line() &&
-                 d1.getPosition().column() == d2.getPosition().column());
-
-            DeclPartialOrder dpo1 = new DeclPartialOrder();
-            DeclPartialOrder dpo2 = new DeclPartialOrder();
-
-            d1.accept(dpo1);
-            d2.accept(dpo2);
-
-            int difference = dpo1.getValue() - dpo2.getValue();
-            if (difference != 0)
-                return difference;
-            else {
-                int result = d1.getSimpleName().compareTo(d2.getSimpleName());
-                if (result != 0)
-                    return result;
-                return (int)( Long.signum((long)System.identityHashCode(d1) -
-                                          (long)System.identityHashCode(d2)));
-            }
-        }
-
-        public int compare(Declaration d1, Declaration d2) {
-            if (equals(d1, d2))
-                return 0;
-
-            SourcePosition p1 = d1.getPosition();
-            SourcePosition p2 = d2.getPosition();
-
-            if (p1 == null && p2 != null)
-                return 1;
-            else if (p1 != null && p2 == null)
-                return -1;
-            else if(p1 == null && p2 == null)
-                return compareEqualPosition(d1, d2);
-            else {
-                assert p1 != null && p2 != null;
-                int fileComp = p1.file().compareTo(p2.file()) ;
-                if (fileComp == 0) {
-                    long diff = (long)p1.line() - (long)p2.line();
-                    if (diff == 0) {
-                        diff = Long.signum((long)p1.column() - (long)p2.column());
-                        if (diff != 0)
-                            return (int)diff;
-                        else {
-                            // declarations may be two
-                            // compiler-generated members with the
-                            // same source position
-                            return compareEqualPosition(d1, d2);
-                        }
-                    } else
-                        return (diff<0)? -1:1;
-                } else
-                    return fileComp;
-            }
-        }
-    }
-
-    final static java.util.Comparator<Declaration> comparator = new SourceOrderComparator();
-
-    SourceOrderDeclScanner(DeclarationVisitor pre, DeclarationVisitor post) {
-        super(pre, post);
-    }
-
-    /**
-     * Visits a type declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitTypeDeclaration(TypeDeclaration d) {
-        d.accept(pre);
-
-        SortedSet<Declaration> decls = new
-            TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
-            decls.add(tpDecl);
-        }
-
-        for(FieldDeclaration fieldDecl: d.getFields()) {
-            decls.add(fieldDecl);
-        }
-
-        for(MethodDeclaration methodDecl: d.getMethods()) {
-            decls.add(methodDecl);
-        }
-
-        for(TypeDeclaration typeDecl: d.getNestedTypes()) {
-            decls.add(typeDecl);
-        }
-
-        for(Declaration decl: decls )
-            decl.accept(this);
-
-        d.accept(post);
-    }
-
-    /**
-     * Visits a class declaration.
-     *
-     * @param d the declaration to visit
-     */
-    public void visitClassDeclaration(ClassDeclaration d) {
-        d.accept(pre);
-
-        SortedSet<Declaration> decls = new
-            TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters()) {
-            decls.add(tpDecl);
-        }
-
-        for(FieldDeclaration fieldDecl: d.getFields()) {
-            decls.add(fieldDecl);
-        }
-
-        for(MethodDeclaration methodDecl: d.getMethods()) {
-            decls.add(methodDecl);
-        }
-
-        for(TypeDeclaration typeDecl: d.getNestedTypes()) {
-            decls.add(typeDecl);
-        }
-
-        for(ConstructorDeclaration ctorDecl: d.getConstructors()) {
-            decls.add(ctorDecl);
-        }
-
-        for(Declaration decl: decls )
-            decl.accept(this);
-
-        d.accept(post);
-    }
-
-    public void visitExecutableDeclaration(ExecutableDeclaration d) {
-        d.accept(pre);
-
-        SortedSet<Declaration> decls = new
-            TreeSet<Declaration>(SourceOrderDeclScanner.comparator) ;
-
-        for(TypeParameterDeclaration tpDecl: d.getFormalTypeParameters())
-            decls.add(tpDecl);
-
-        for(ParameterDeclaration pDecl: d.getParameters())
-            decls.add(pDecl);
-
-        for(Declaration decl: decls )
-            decl.accept(this);
-
-        d.accept(post);
-    }
-
-}
diff --git a/src/share/classes/com/sun/mirror/util/SourcePosition.java b/src/share/classes/com/sun/mirror/util/SourcePosition.java
deleted file mode 100644
index 69d2a04..0000000
--- a/src/share/classes/com/sun/mirror/util/SourcePosition.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import java.io.File;
-
-
-/**
- * Represents a position in a source file.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  There is no direct
- * replacement for the functionality of this interface since the
- * standardized {@link javax.annotation.processing.Messager Messager}
- * API implicitly takes a source position argument via any element,
- * annotation mirror, or annotation value passed along with the
- * message.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface SourcePosition {
-
-    /**
-     * Returns the source file containing this position.
-     *
-     * @return the source file containing this position; never null
-     */
-    File file();
-
-    /**
-     * Returns the line number of this position.  Lines are numbered
-     * starting with 1.
-     *
-     * @return the line number of this position, or 0 if the line
-     * number is unknown or not applicable
-     */
-    int line();
-
-    /**
-     * Returns the column number of this position.  Columns are numbered
-     * starting with 1.
-     *
-     * @return the column number of this position, or 0 if the column
-     * number is unknown or not applicable
-     */
-    int column();
-}
diff --git a/src/share/classes/com/sun/mirror/util/TypeVisitor.java b/src/share/classes/com/sun/mirror/util/TypeVisitor.java
deleted file mode 100644
index 628ed1f..0000000
--- a/src/share/classes/com/sun/mirror/util/TypeVisitor.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import com.sun.mirror.type.*;
-
-
-/**
- * A visitor for types, in the style of the standard visitor design pattern.
- * This is used to operate on a type when the kind
- * of type is unknown at compile time.
- * When a visitor is passed to a type's
- * {@link TypeMirror#accept accept} method,
- * the most specific <tt>visit<i>Xxx</i></tt> method applicable to
- * that type is invoked.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.element.TypeVisitor}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface TypeVisitor {
-
-    /**
-     * Visits a type mirror.
-     *
-     * @param t the type to visit
-     */
-    public void visitTypeMirror(TypeMirror t);
-
-    /**
-     * Visits a primitive type.
-
-     * @param t the type to visit
-     */
-    public void visitPrimitiveType(PrimitiveType t);
-
-    /**
-     * Visits a void type.
-     *
-     * @param t the type to visit
-     */
-    public void visitVoidType(VoidType t);
-
-    /**
-     * Visits a reference type.
-     *
-     * @param t the type to visit
-     */
-    public void visitReferenceType(ReferenceType t);
-
-    /**
-     * Visits a declared type.
-     *
-     * @param t the type to visit
-     */
-    public void visitDeclaredType(DeclaredType t);
-
-    /**
-     * Visits a class type.
-     *
-     * @param t the type to visit
-     */
-    public void visitClassType(ClassType t);
-
-    /**
-     * Visits an enum type.
-     *
-     * @param t the type to visit
-     */
-    public void visitEnumType(EnumType t);
-
-    /**
-     * Visits an interface type.
-     *
-     * @param t the type to visit
-     */
-    public void visitInterfaceType(InterfaceType t);
-
-    /**
-     * Visits an annotation type.
-     *
-     * @param t the type to visit
-     */
-    public void visitAnnotationType(AnnotationType t);
-
-    /**
-     * Visits an array type.
-     *
-     * @param t the type to visit
-     */
-    public void visitArrayType(ArrayType t);
-
-    /**
-     * Visits a type variable.
-     *
-     * @param t the type to visit
-     */
-    public void visitTypeVariable(TypeVariable t);
-
-    /**
-     * Visits a wildcard.
-     *
-     * @param t the type to visit
-     */
-    public void visitWildcardType(WildcardType t);
-}
diff --git a/src/share/classes/com/sun/mirror/util/Types.java b/src/share/classes/com/sun/mirror/util/Types.java
deleted file mode 100644
index d7c51c0..0000000
--- a/src/share/classes/com/sun/mirror/util/Types.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2004, 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.mirror.util;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-
-
-/**
- * Utility methods for operating on types.
- *
- * @deprecated All components of this API have been superseded by the
- * standardized annotation processing API.  The replacement for the
- * functionality of this interface is {@link
- * javax.lang.model.util.Types}.
- *
- * @author Joseph D. Darcy
- * @author Scott Seligman
- * @since 1.5
- */
- at Deprecated
- at SuppressWarnings("deprecation")
-public interface Types {
-
-    /**
-     * Tests whether one type is a subtype of the another.
-     * Any type is considered to be a subtype of itself.
-     *
-     * @param t1  the first type
-     * @param t2  the second type
-     * @return <tt>true</tt> if and only if the first type is a subtype
-     *          of the second
-     */
-    boolean isSubtype(TypeMirror t1, TypeMirror t2);
-
-    /**
-     * Tests whether one type is assignable to another.
-     *
-     * @param t1  the first type
-     * @param t2  the second type
-     * @return <tt>true</tt> if and only if the first type is assignable
-     *          to the second
-     */
-    boolean isAssignable(TypeMirror t1, TypeMirror t2);
-
-    /**
-     * Returns the erasure of a type.
-     *
-     * @param t  the type to be erased
-     * @return the erasure of the given type
-     */
-    TypeMirror getErasure(TypeMirror t);
-
-    /**
-     * Returns a primitive type.
-     *
-     * @param kind  the kind of primitive type to return
-     * @return a primitive type
-     */
-    PrimitiveType getPrimitiveType(PrimitiveType.Kind kind);
-
-    /**
-     * Returns the pseudo-type representing the type of <tt>void</tt>.
-     *
-     * @return the pseudo-type representing the type of <tt>void</tt>
-     */
-    VoidType getVoidType();
-
-    /**
-     * Returns an array type with the specified component type.
-     *
-     * @param componentType  the component type
-     * @return an array type with the specified component type.
-     * @throws IllegalArgumentException if the component type is not valid for
-     *          an array
-     */
-    ArrayType getArrayType(TypeMirror componentType);
-
-    /**
-     * Returns the type variable declared by a type parameter.
-     *
-     * @param tparam  the type parameter
-     * @return the type variable declared by the type parameter
-     */
-    TypeVariable getTypeVariable(TypeParameterDeclaration tparam);
-
-    /**
-     * Returns a new wildcard.
-     * Either the wildcards's upper bounds or lower bounds may be
-     * specified, or neither, but not both.
-     *
-     * @param upperBounds  the upper bounds of this wildcard,
-     *          or an empty collection if none
-     * @param lowerBounds  the lower bounds of this wildcard,
-     *          or an empty collection if none
-     * @return a new wildcard
-     * @throws IllegalArgumentException if bounds are not valid
-     */
-    WildcardType getWildcardType(Collection<ReferenceType> upperBounds,
-                                 Collection<ReferenceType> lowerBounds);
-
-    /**
-     * Returns the type corresponding to a type declaration and
-     * actual type arguments.
-     * Given the declaration for <tt>String</tt>, for example, this
-     * method may be used to get the <tt>String</tt> type.  It may
-     * then be invoked a second time, with the declaration for <tt>Set</tt>,
-     * to make the parameterized type {@code Set<String>}.
-     *
-     * <p> The number of type arguments must either equal the
-     * number of the declaration's formal type parameters, or must be
-     * zero.  If zero, and if the declaration is generic,
-     * then the declaration's raw type is returned.
-     *
-     * <p> If a parameterized type is being returned, its declaration
-     * must not be contained within a generic outer class.
-     * The parameterized type {@code Outer<String>.Inner<Number>},
-     * for example, may be constructed by first using this
-     * method to get the type {@code Outer<String>}, and then invoking
-     * {@link #getDeclaredType(DeclaredType, TypeDeclaration, TypeMirror...)}.
-     *
-     * @param decl      the type declaration
-     * @param typeArgs  the actual type arguments
-     * @return the type corresponding to the type declaration and
-     *          actual type arguments
-     * @throws IllegalArgumentException if too many or too few
-     *          type arguments are given, or if an inappropriate type
-     *          argument or declaration is provided
-     */
-    DeclaredType getDeclaredType(TypeDeclaration decl,
-                                 TypeMirror... typeArgs);
-
-    /**
-     * Returns the type corresponding to a type declaration
-     * and actual arguments, given a
-     * {@linkplain DeclaredType#getContainingType() containing type}
-     * of which it is a member.
-     * The parameterized type {@code Outer<String>.Inner<Number>},
-     * for example, may be constructed by first using
-     * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)}
-     * to get the type {@code Outer<String>}, and then invoking
-     * this method.
-     *
-     * <p> If the containing type is a parameterized type,
-     * the number of type arguments must equal the
-     * number of the declaration's formal type parameters.
-     * If it is not parameterized or if it is <tt>null</tt>, this method is
-     * equivalent to <tt>getDeclaredType(decl, typeArgs)</tt>.
-     *
-     * @param containing  the containing type, or <tt>null</tt> if none
-     * @param decl        the type declaration
-     * @param typeArgs    the actual type arguments
-     * @return the type corresponding to the type declaration and
-     *          actual type arguments,
-     *          contained within the given type
-     * @throws IllegalArgumentException if too many or too few
-     *          type arguments are given, or if an inappropriate type
-     *          argument, declaration, or containing type is provided
-     */
-    DeclaredType getDeclaredType(DeclaredType containing,
-                                 TypeDeclaration decl,
-                                 TypeMirror... typeArgs);
-}
diff --git a/src/share/classes/com/sun/mirror/util/package-info.java b/src/share/classes/com/sun/mirror/util/package-info.java
deleted file mode 100644
index 7e4e3cb..0000000
--- a/src/share/classes/com/sun/mirror/util/package-info.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-/**
- * Utilities to assist in the processing of {@linkplain
- * com.sun.mirror.declaration declarations} and {@linkplain
- * com.sun.mirror.type types}.
- *
- * <p>The {@code apt} tool and its associated API have been superseded
- * by the standardized annotation processing API.  The replacement for
- * the functionality in this package is {@link javax.lang.model.util}.
- *
- * @since 1.5
- */
-package com.sun.mirror.util;
diff --git a/src/share/classes/com/sun/source/doctree/AttributeTree.java b/src/share/classes/com/sun/source/doctree/AttributeTree.java
new file mode 100644
index 0000000..aa757f6
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/AttributeTree.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for an attribute in an HTML element.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface AttributeTree extends DocTree {
+    @jdk.Supported
+    enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE };
+
+    Name getName();
+    ValueKind getValueKind();
+    List<? extends DocTree> getValue();
+}
diff --git a/src/share/classes/com/sun/source/doctree/AuthorTree.java b/src/share/classes/com/sun/source/doctree/AuthorTree.java
new file mode 100644
index 0000000..7391fd2
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/AuthorTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @author block tag.
+ *
+ * <p>
+ * @author name-text.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface AuthorTree extends BlockTagTree {
+    List<? extends DocTree> getName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/BlockTagTree.java b/src/share/classes/com/sun/source/doctree/BlockTagTree.java
new file mode 100644
index 0000000..0af9fc5
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/BlockTagTree.java
@@ -0,0 +1,37 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * block tags.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface BlockTagTree extends DocTree {
+    String getTagName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/CommentTree.java b/src/share/classes/com/sun/source/doctree/CommentTree.java
new file mode 100644
index 0000000..a4ad14f
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/CommentTree.java
@@ -0,0 +1,40 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * An embedded HTML comment.
+ *
+ * <p>
+ * {@literal <!-- text --> }
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface CommentTree extends DocTree {
+    String getBody();
+}
+
diff --git a/src/share/classes/com/sun/source/doctree/DeprecatedTree.java b/src/share/classes/com/sun/source/doctree/DeprecatedTree.java
new file mode 100644
index 0000000..974b9b5
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/DeprecatedTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @deprecated block tag.
+ *
+ * <p>
+ * @deprecated deprecated text.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DeprecatedTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
diff --git a/src/share/classes/com/sun/source/doctree/DocCommentTree.java b/src/share/classes/com/sun/source/doctree/DocCommentTree.java
new file mode 100644
index 0000000..903f76f
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/DocCommentTree.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * The top level representation of a documentation comment.
+ *
+ * <p>
+ * first-sentence body block-tags
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DocCommentTree extends DocTree {
+    List<? extends DocTree> getFirstSentence();
+    List<? extends DocTree> getBody();
+    List<? extends DocTree> getBlockTags();
+}
diff --git a/src/share/classes/com/sun/source/doctree/DocRootTree.java b/src/share/classes/com/sun/source/doctree/DocRootTree.java
new file mode 100644
index 0000000..7e01e54
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/DocRootTree.java
@@ -0,0 +1,37 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for an @docroot inline tag.
+ *
+ * <p>
+ * {@docroot}
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DocRootTree extends InlineTagTree { }
diff --git a/src/share/classes/com/sun/source/doctree/DocTree.java b/src/share/classes/com/sun/source/doctree/DocTree.java
new file mode 100644
index 0000000..4f1cc00
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/DocTree.java
@@ -0,0 +1,256 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * Common interface for all nodes in a documentation syntax tree.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DocTree {
+    @jdk.Supported
+    enum Kind {
+        /**
+         * Used for instances of {@link AttributeTree}
+         * representing an HTML attribute.
+         */
+        ATTRIBUTE,
+
+        /**
+         * Used for instances of {@link AuthorTree}
+         * representing an @author tag.
+         */
+        AUTHOR("author"),
+
+        /**
+         * Used for instances of {@link LiteralTree}
+         * representing an @code tag.
+         */
+        CODE("code"),
+
+        /**
+         * Used for instances of {@link CommentTree}
+         * representing an HTML comment.
+         */
+        COMMENT,
+
+        /**
+         * Used for instances of {@link DeprecatedTree}
+         * representing an @deprecated tag.
+         */
+        DEPRECATED("deprecated"),
+
+        /**
+         * Used for instances of {@link DocCommentTree}
+         * representing a complete doc comment.
+         */
+        DOC_COMMENT,
+
+        /**
+         * Used for instances of {@link DocRootTree}
+         * representing an @docRoot tag.
+         */
+        DOC_ROOT("docRoot"),
+
+        /**
+         * Used for instances of {@link EndElementTree}
+         * representing the end of an HTML element.
+         */
+        END_ELEMENT,
+
+        /**
+         * Used for instances of {@link EntityTree}
+         * representing an HTML entity.
+         */
+        ENTITY,
+
+        /**
+         * Used for instances of {@link ErroneousTree}
+         * representing some invalid text.
+         */
+        ERRONEOUS,
+
+        /**
+         * Used for instances of {@link ThrowsTree}
+         * representing an @exception tag.
+         */
+        EXCEPTION("exception"),
+
+        /**
+         * Used for instances of {@link IdentifierTree}
+         * representing an identifier.
+         */
+        IDENTIFIER,
+
+        /**
+         * Used for instances of {@link InheritDocTree}
+         * representing an @inheritDoc tag.
+         */
+        INHERIT_DOC("inheritDoc"),
+
+        /**
+         * Used for instances of {@link LinkTree}
+         * representing an @link tag.
+         */
+        LINK("link"),
+
+        /**
+         * Used for instances of {@link LinkTree}
+         * representing an @linkplain tag.
+         */
+        LINK_PLAIN("linkplain"),
+
+        /**
+         * Used for instances of {@link LiteralTree}
+         * representing an @literal tag.
+         */
+        LITERAL("literal"),
+
+        /**
+         * Used for instances of {@link ParamTree}
+         * representing an @param tag.
+         */
+        PARAM("param"),
+
+        /**
+         * Used for instances of {@link ReferenceTree}
+         * representing a reference to a element in the
+         * Java programming language.
+         */
+        REFERENCE,
+
+        /**
+         * Used for instances of {@link ReturnTree}
+         * representing an @return tag.
+         */
+        RETURN("return"),
+
+        /**
+         * Used for instances of {@link SeeTree}
+         * representing an @see tag.
+         */
+        SEE("see"),
+
+        /**
+         * Used for instances of {@link SerialTree}
+         * representing an @serial tag.
+         */
+        SERIAL("serial"),
+
+        /**
+         * Used for instances of {@link SerialDataTree}
+         * representing an @serialData tag.
+         */
+        SERIAL_DATA("serialData"),
+
+        /**
+         * Used for instances of {@link SerialFieldTree}
+         * representing an @serialField tag.
+         */
+        SERIAL_FIELD("serialField"),
+
+        /**
+         * Used for instances of {@link SinceTree}
+         * representing an @since tag.
+         */
+        SINCE("since"),
+
+        /**
+         * Used for instances of {@link EndElementTree}
+         * representing the start of an HTML element.
+         */
+        START_ELEMENT,
+
+        /**
+         * Used for instances of {@link TextTree}
+         * representing some documentation text.
+         */
+        TEXT,
+
+        /**
+         * Used for instances of {@link ThrowsTree}
+         * representing an @throws tag.
+         */
+        THROWS("throws"),
+
+        /**
+         * Used for instances of {@link UnknownBlockTagTree}
+         * representing an unknown block tag.
+         */
+        UNKNOWN_BLOCK_TAG,
+
+        /**
+         * Used for instances of {@link UnknownInlineTagTree}
+         * representing an unknown inline tag.
+         */
+        UNKNOWN_INLINE_TAG,
+
+        /**
+         * Used for instances of {@link ValueTree}
+         * representing an @value tag.
+         */
+        VALUE("value"),
+
+        /**
+         * Used for instances of {@link VersionTree}
+         * representing an @version tag.
+         */
+        VERSION("version"),
+
+        /**
+         * An implementation-reserved node. This is the not the node
+         * you are looking for.
+         */
+        OTHER;
+
+        public final String tagName;
+
+        Kind() {
+            tagName = null;
+        }
+
+        Kind(String tagName) {
+            this.tagName = tagName;
+        }
+    };
+
+    /**
+     * Gets the kind of this tree.
+     *
+     * @return the kind of this tree.
+     */
+    Kind getKind();
+
+    /**
+     * Accept method used to implement the visitor pattern.  The
+     * visitor pattern is used to implement operations on trees.
+     *
+     * @param <R> result type of this operation.
+     * @param <D> type of additional data.
+     */
+    <R, D> R accept(DocTreeVisitor<R,D> visitor, D data);
+}
diff --git a/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java
new file mode 100644
index 0000000..71b548e
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java
@@ -0,0 +1,88 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+
+/**
+ * A visitor of trees, in the style of the visitor design pattern.
+ * Classes implementing this interface are used to operate
+ * on a tree when the kind of tree is unknown at compile time.
+ * When a visitor is passed to an tree's {@link DocTree#accept
+ * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
+ * to that tree is invoked.
+ *
+ * <p> Classes implementing this interface may or may not throw a
+ * {@code NullPointerException} if the additional parameter {@code p}
+ * is {@code null}; see documentation of the implementing class for
+ * details.
+ *
+ * <p> <b>WARNING:</b> It is possible that methods will be added to
+ * this interface to accommodate new, currently unknown, doc comment
+ * structures added to future versions of the Java™ programming
+ * language.  Therefore, visitor classes directly implementing this
+ * interface may be source incompatible with future versions of the
+ * platform.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DocTreeVisitor<R,P> {
+    R visitAttribute(AttributeTree node, P p);
+    R visitAuthor(AuthorTree node, P p);
+    R visitComment(CommentTree node, P p);
+    R visitDeprecated(DeprecatedTree node, P p);
+    R visitDocComment(DocCommentTree node, P p);
+    R visitDocRoot(DocRootTree node, P p);
+    R visitEndElement(EndElementTree node, P p);
+    R visitEntity(EntityTree node, P p);
+    R visitErroneous(ErroneousTree node, P p);
+    R visitIdentifier(IdentifierTree node, P p);
+    R visitInheritDoc(InheritDocTree node, P p);
+    R visitLink(LinkTree node, P p);
+    R visitLiteral(LiteralTree node, P p);
+    R visitParam(ParamTree node, P p);
+    R visitReference(ReferenceTree node, P p);
+    R visitReturn(ReturnTree node, P p);
+    R visitSee(SeeTree node, P p);
+    R visitSerial(SerialTree node, P p);
+    R visitSerialData(SerialDataTree node, P p);
+    R visitSerialField(SerialFieldTree node, P p);
+    R visitSince(SinceTree node, P p);
+    R visitStartElement(StartElementTree node, P p);
+    R visitText(TextTree node, P p);
+    R visitThrows(ThrowsTree node, P p);
+    R visitUnknownBlockTag(UnknownBlockTagTree node, P p);
+    R visitUnknownInlineTag(UnknownInlineTagTree node, P p);
+    R visitValue(ValueTree node, P p);
+    R visitVersion(VersionTree node, P p);
+    R visitOther(DocTree node, P p);
+}
diff --git a/src/share/classes/com/sun/source/doctree/EndElementTree.java b/src/share/classes/com/sun/source/doctree/EndElementTree.java
new file mode 100644
index 0000000..ae01e34
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/EndElementTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the end of an HTML element.
+ *
+ * <p>
+ * </ name >
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface EndElementTree extends DocTree {
+    Name getName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/EntityTree.java b/src/share/classes/com/sun/source/doctree/EntityTree.java
new file mode 100644
index 0000000..fb86c6d
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/EntityTree.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+
+/**
+ * A tree node for an HTML entity.
+ *
+ * <p>
+ * & name ;
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface EntityTree extends DocTree {
+    Name getName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ErroneousTree.java b/src/share/classes/com/sun/source/doctree/ErroneousTree.java
new file mode 100644
index 0000000..0229294
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ErroneousTree.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+
+/**
+ * A tree node to stand in for a malformed text
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ErroneousTree extends TextTree {
+    /**
+     * Gets a diagnostic object giving details about
+     * the reason the body text is in error.
+     *
+     * @return a diagnostic
+     */
+    Diagnostic<JavaFileObject> getDiagnostic();
+}
diff --git a/src/share/classes/com/sun/source/doctree/IdentifierTree.java b/src/share/classes/com/sun/source/doctree/IdentifierTree.java
new file mode 100644
index 0000000..5257cbf
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/IdentifierTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import javax.lang.model.element.Name;
+
+/**
+ * An identifier in a documentation comment.
+ *
+ * <p>
+ * name
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface IdentifierTree extends DocTree {
+    Name getName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/InheritDocTree.java b/src/share/classes/com/sun/source/doctree/InheritDocTree.java
new file mode 100644
index 0000000..b853d6a
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/InheritDocTree.java
@@ -0,0 +1,38 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @inheritDoc inline tag.
+ *
+ * <p>
+ * {@inheritDoc}
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface InheritDocTree extends InlineTagTree { }
diff --git a/src/share/classes/com/sun/source/doctree/InlineTagTree.java b/src/share/classes/com/sun/source/doctree/InlineTagTree.java
new file mode 100644
index 0000000..411b04e
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/InlineTagTree.java
@@ -0,0 +1,37 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * inline tags.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface InlineTagTree extends DocTree {
+    String getTagName();
+}
diff --git a/src/share/classes/com/sun/source/doctree/LinkTree.java b/src/share/classes/com/sun/source/doctree/LinkTree.java
new file mode 100644
index 0000000..4c7c687
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/LinkTree.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @link or @linkplain inline tag.
+ *
+ * <p>
+ * {@link reference label} <br>
+ * {@linkplain reference label }
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface LinkTree extends InlineTagTree {
+    ReferenceTree getReference();
+    List<? extends DocTree> getLabel();
+}
diff --git a/src/share/classes/com/sun/source/doctree/LiteralTree.java b/src/share/classes/com/sun/source/doctree/LiteralTree.java
new file mode 100644
index 0000000..b2cd282
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/LiteralTree.java
@@ -0,0 +1,40 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ *
+ * A tree node for an @literal or @code inline tag.
+ *
+ * <p>
+ * {@literal text}
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface LiteralTree extends InlineTagTree {
+    TextTree getBody();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ParamTree.java b/src/share/classes/com/sun/source/doctree/ParamTree.java
new file mode 100644
index 0000000..f0090bb
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ParamTree.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @param block tag.
+ *
+ * <p>
+ * @param parameter-name description
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ParamTree extends BlockTagTree {
+    boolean isTypeParameter();
+    IdentifierTree getName();
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ReferenceTree.java b/src/share/classes/com/sun/source/doctree/ReferenceTree.java
new file mode 100644
index 0000000..0bbfcdc
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ReferenceTree.java
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node to a reference to a Java language element.
+ *
+ * <p>
+ * package.class#field
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ReferenceTree extends DocTree {
+    String getSignature();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ReturnTree.java b/src/share/classes/com/sun/source/doctree/ReturnTree.java
new file mode 100644
index 0000000..e948ca9
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ReturnTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @return block tag.
+ *
+ * <p>
+ * @return description
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ReturnTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/SeeTree.java b/src/share/classes/com/sun/source/doctree/SeeTree.java
new file mode 100644
index 0000000..8d09ff2
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/SeeTree.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @see block tag.
+ *
+ * <p>
+ * @see "string" <br>
+ * @see <a href="URL#value"> label </a> <br>
+ * @see reference
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface SeeTree extends BlockTagTree {
+    List<? extends DocTree> getReference();
+}
diff --git a/src/share/classes/com/sun/source/doctree/SerialDataTree.java b/src/share/classes/com/sun/source/doctree/SerialDataTree.java
new file mode 100644
index 0000000..2044f5d
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/SerialDataTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ * <p>
+ * @serialData data-description
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface SerialDataTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/SerialFieldTree.java b/src/share/classes/com/sun/source/doctree/SerialFieldTree.java
new file mode 100644
index 0000000..cae5ff9
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/SerialFieldTree.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serialData block tag.
+ *
+ * <p>
+ * @serialField field-name field-type field-description
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface SerialFieldTree extends BlockTagTree {
+    IdentifierTree getName();
+    ReferenceTree getType();
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/SerialTree.java b/src/share/classes/com/sun/source/doctree/SerialTree.java
new file mode 100644
index 0000000..c95ae9b
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/SerialTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @serial block tag.
+ *
+ * <p>
+ * @serial field-description | include | exclude
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface SerialTree extends BlockTagTree {
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/SinceTree.java b/src/share/classes/com/sun/source/doctree/SinceTree.java
new file mode 100644
index 0000000..f6600d0
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/SinceTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an @since block tag.
+ *
+ * <p>
+ * @since since-text
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface SinceTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
diff --git a/src/share/classes/com/sun/source/doctree/StartElementTree.java b/src/share/classes/com/sun/source/doctree/StartElementTree.java
new file mode 100644
index 0000000..e72e21d
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/StartElementTree.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for the start of an HTML element.
+ *
+ * <p>
+ * < name [attributes] [/]>
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface StartElementTree extends DocTree {
+    Name getName();
+    List<? extends DocTree> getAttributes();
+    boolean isSelfClosing();
+}
diff --git a/src/share/classes/com/sun/source/doctree/TextTree.java b/src/share/classes/com/sun/source/doctree/TextTree.java
new file mode 100644
index 0000000..40fcf37
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/TextTree.java
@@ -0,0 +1,36 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for plain text.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface TextTree extends DocTree {
+    String getBody();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ThrowsTree.java b/src/share/classes/com/sun/source/doctree/ThrowsTree.java
new file mode 100644
index 0000000..c86729c
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ThrowsTree.java
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @exception or @throws block tag.
+ * @exception is a synonym for @throws.
+ *
+ * <p>
+ * @exception class-name description <br>
+ * @throws class-name description
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ThrowsTree extends BlockTagTree {
+    ReferenceTree getExceptionName();
+    List<? extends DocTree> getDescription();
+}
diff --git a/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java b/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java
new file mode 100644
index 0000000..113691e
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ * <p>
+ * @name content
+ *
+ * @since 1.8
+ *
+ */
+ at jdk.Supported
+public interface UnknownBlockTagTree extends BlockTagTree {
+    List<? extends DocTree> getContent();
+}
diff --git a/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java b/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java
new file mode 100644
index 0000000..f9072ff
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ * A tree node for an unrecognized inline tag.
+ *
+ * <p>
+ * {@name content}
+ *
+ * @since 1.8
+ *
+ */
+ at jdk.Supported
+public interface UnknownInlineTagTree extends InlineTagTree {
+    List<? extends DocTree> getContent();
+}
diff --git a/src/share/classes/com/sun/source/doctree/ValueTree.java b/src/share/classes/com/sun/source/doctree/ValueTree.java
new file mode 100644
index 0000000..91f6373
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/ValueTree.java
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for an @value inline tag.
+ *
+ * <p>
+ * { @value reference }
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface ValueTree extends InlineTagTree {
+    ReferenceTree getReference();
+}
diff --git a/src/share/classes/com/sun/source/doctree/VersionTree.java b/src/share/classes/com/sun/source/doctree/VersionTree.java
new file mode 100644
index 0000000..d36ba1e
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/VersionTree.java
@@ -0,0 +1,42 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+import java.util.List;
+
+/**
+ *
+ * A tree node for an @version block tag.
+ *
+ * <p>
+ * @version version-text
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface VersionTree extends BlockTagTree {
+    List<? extends DocTree> getBody();
+}
diff --git a/src/share/classes/com/sun/source/doctree/package-info.java b/src/share/classes/com/sun/source/doctree/package-info.java
new file mode 100644
index 0000000..888fb79
--- /dev/null
+++ b/src/share/classes/com/sun/source/doctree/package-info.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Provides interfaces to represent documentation comments as abstract syntax
+ * trees (AST).
+ *
+ * @author Jonathan Gibbons
+ * @since 1.8
+ * @see <a href="http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags">http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#javadoctags</a>
+ */
+ at jdk.Supported
+package com.sun.source.doctree;
diff --git a/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java b/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java
new file mode 100644
index 0000000..f9f3014
--- /dev/null
+++ b/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for an annotated type
+ *
+ * For example:
+ * <pre>
+ *    {@code @}<em>annotationType String</em>
+ *    {@code @}<em>annotationType</em> ( <em>arguments</em> ) <em>Date</em>
+ * </pre>
+ *
+ * @see "JSR 308: Annotations on Java Types"
+ *
+ * @author Mahmood Ali
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface AnnotatedTypeTree extends ExpressionTree {
+    List<? extends AnnotationTree> getAnnotations();
+    ExpressionTree getUnderlyingType();
+}
diff --git a/src/share/classes/com/sun/source/tree/AnnotationTree.java b/src/share/classes/com/sun/source/tree/AnnotationTree.java
index 5a9074b..5a785ee 100644
--- a/src/share/classes/com/sun/source/tree/AnnotationTree.java
+++ b/src/share/classes/com/sun/source/tree/AnnotationTree.java
@@ -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
@@ -42,6 +42,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface AnnotationTree extends ExpressionTree {
     Tree getAnnotationType();
     List<? extends ExpressionTree> getArguments();
diff --git a/src/share/classes/com/sun/source/tree/ArrayAccessTree.java b/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
index 7e5fc2c..97696c6 100644
--- a/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
+++ b/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ArrayAccessTree extends ExpressionTree {
     ExpressionTree getExpression();
     ExpressionTree getIndex();
diff --git a/src/share/classes/com/sun/source/tree/ArrayTypeTree.java b/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
index 0c58a71..b6275be 100644
--- a/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
+++ b/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ArrayTypeTree extends Tree {
     Tree getType();
 }
diff --git a/src/share/classes/com/sun/source/tree/AssertTree.java b/src/share/classes/com/sun/source/tree/AssertTree.java
index fce758e..90ca3c5 100644
--- a/src/share/classes/com/sun/source/tree/AssertTree.java
+++ b/src/share/classes/com/sun/source/tree/AssertTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface AssertTree extends StatementTree {
     ExpressionTree getCondition();
     ExpressionTree getDetail();
diff --git a/src/share/classes/com/sun/source/tree/AssignmentTree.java b/src/share/classes/com/sun/source/tree/AssignmentTree.java
index 9c5480d..a2cc602 100644
--- a/src/share/classes/com/sun/source/tree/AssignmentTree.java
+++ b/src/share/classes/com/sun/source/tree/AssignmentTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface AssignmentTree extends ExpressionTree {
     ExpressionTree getVariable();
     ExpressionTree getExpression();
diff --git a/src/share/classes/com/sun/source/tree/BinaryTree.java b/src/share/classes/com/sun/source/tree/BinaryTree.java
index d24497a..9767c0e 100644
--- a/src/share/classes/com/sun/source/tree/BinaryTree.java
+++ b/src/share/classes/com/sun/source/tree/BinaryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface BinaryTree extends ExpressionTree {
     ExpressionTree getLeftOperand();
     ExpressionTree getRightOperand();
diff --git a/src/share/classes/com/sun/source/tree/BlockTree.java b/src/share/classes/com/sun/source/tree/BlockTree.java
index 330309a..278e257 100644
--- a/src/share/classes/com/sun/source/tree/BlockTree.java
+++ b/src/share/classes/com/sun/source/tree/BlockTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface BlockTree extends StatementTree {
     boolean isStatic();
     List<? extends StatementTree> getStatements();
diff --git a/src/share/classes/com/sun/source/tree/BreakTree.java b/src/share/classes/com/sun/source/tree/BreakTree.java
index e287a98..f07eda0 100644
--- a/src/share/classes/com/sun/source/tree/BreakTree.java
+++ b/src/share/classes/com/sun/source/tree/BreakTree.java
@@ -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
@@ -43,6 +43,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface BreakTree extends StatementTree {
     Name getLabel();
 }
diff --git a/src/share/classes/com/sun/source/tree/CaseTree.java b/src/share/classes/com/sun/source/tree/CaseTree.java
index a273c2f..5dc5b78 100644
--- a/src/share/classes/com/sun/source/tree/CaseTree.java
+++ b/src/share/classes/com/sun/source/tree/CaseTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface CaseTree extends Tree {
     /**
      * @return null if and only if this Case is {@code default:}
diff --git a/src/share/classes/com/sun/source/tree/CatchTree.java b/src/share/classes/com/sun/source/tree/CatchTree.java
index 9c34e86..6e68963 100644
--- a/src/share/classes/com/sun/source/tree/CatchTree.java
+++ b/src/share/classes/com/sun/source/tree/CatchTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface CatchTree extends Tree {
     VariableTree getParameter();
     BlockTree getBlock();
diff --git a/src/share/classes/com/sun/source/tree/ClassTree.java b/src/share/classes/com/sun/source/tree/ClassTree.java
index 81c7c2f..f675b27 100644
--- a/src/share/classes/com/sun/source/tree/ClassTree.java
+++ b/src/share/classes/com/sun/source/tree/ClassTree.java
@@ -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
@@ -48,6 +48,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ClassTree extends StatementTree {
     ModifiersTree getModifiers();
     Name getSimpleName();
diff --git a/src/share/classes/com/sun/source/tree/CompilationUnitTree.java b/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
index 66b585c..086b71f 100644
--- a/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
+++ b/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
@@ -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
@@ -27,7 +27,6 @@ package com.sun.source.tree;
 
 import java.util.List;
 import javax.tools.JavaFileObject;
-import com.sun.source.tree.LineMap;
 
 /**
  * Represents the abstract syntax tree for compilation units (source
@@ -38,6 +37,7 @@ import com.sun.source.tree.LineMap;
  * @author Peter von der Ahé
  * @since 1.6
  */
+ at jdk.Supported
 public interface CompilationUnitTree extends Tree {
     List<? extends AnnotationTree> getPackageAnnotations();
     ExpressionTree getPackageName();
diff --git a/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java b/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
index 86eb99c..9ca04da 100644
--- a/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
+++ b/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface CompoundAssignmentTree extends ExpressionTree {
     ExpressionTree getVariable();
     ExpressionTree getExpression();
diff --git a/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java b/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
index 4492611..b2ce400 100644
--- a/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
+++ b/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ConditionalExpressionTree extends ExpressionTree {
     ExpressionTree getCondition();
     ExpressionTree getTrueExpression();
diff --git a/src/share/classes/com/sun/source/tree/ContinueTree.java b/src/share/classes/com/sun/source/tree/ContinueTree.java
index 98db354..0634957 100644
--- a/src/share/classes/com/sun/source/tree/ContinueTree.java
+++ b/src/share/classes/com/sun/source/tree/ContinueTree.java
@@ -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
@@ -42,6 +42,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ContinueTree extends StatementTree {
     Name getLabel();
 }
diff --git a/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java b/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
index 4a6e20b..d6a1837 100644
--- a/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
+++ b/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface DoWhileLoopTree extends StatementTree {
     ExpressionTree getCondition();
     StatementTree getStatement();
diff --git a/src/share/classes/com/sun/source/tree/EmptyStatementTree.java b/src/share/classes/com/sun/source/tree/EmptyStatementTree.java
index baf13c1..1882685 100644
--- a/src/share/classes/com/sun/source/tree/EmptyStatementTree.java
+++ b/src/share/classes/com/sun/source/tree/EmptyStatementTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,4 +39,5 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface EmptyStatementTree extends StatementTree {}
diff --git a/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java b/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
index f550bfa..9f2051a 100644
--- a/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
+++ b/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
@@ -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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface EnhancedForLoopTree extends StatementTree {
     VariableTree getVariable();
     ExpressionTree getExpression();
diff --git a/src/share/classes/com/sun/source/tree/ErroneousTree.java b/src/share/classes/com/sun/source/tree/ErroneousTree.java
index d379117..8591cc3 100644
--- a/src/share/classes/com/sun/source/tree/ErroneousTree.java
+++ b/src/share/classes/com/sun/source/tree/ErroneousTree.java
@@ -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
@@ -34,6 +34,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ErroneousTree extends ExpressionTree {
     List<? extends Tree> getErrorTrees();
 }
diff --git a/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java b/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
index f3661c1..cc78a8b 100644
--- a/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
+++ b/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ExpressionStatementTree extends StatementTree {
     ExpressionTree getExpression();
 }
diff --git a/src/share/classes/com/sun/source/tree/ExpressionTree.java b/src/share/classes/com/sun/source/tree/ExpressionTree.java
index 1ef4349..d0e9b40 100644
--- a/src/share/classes/com/sun/source/tree/ExpressionTree.java
+++ b/src/share/classes/com/sun/source/tree/ExpressionTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -35,4 +35,5 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ExpressionTree extends Tree {}
diff --git a/src/share/classes/com/sun/source/tree/ForLoopTree.java b/src/share/classes/com/sun/source/tree/ForLoopTree.java
index 12e21b7..7adea33 100644
--- a/src/share/classes/com/sun/source/tree/ForLoopTree.java
+++ b/src/share/classes/com/sun/source/tree/ForLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -42,6 +42,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ForLoopTree extends StatementTree {
     List<? extends StatementTree> getInitializer();
     ExpressionTree getCondition();
diff --git a/src/share/classes/com/sun/source/tree/IdentifierTree.java b/src/share/classes/com/sun/source/tree/IdentifierTree.java
index 1d2d8ad..dc662c0 100644
--- a/src/share/classes/com/sun/source/tree/IdentifierTree.java
+++ b/src/share/classes/com/sun/source/tree/IdentifierTree.java
@@ -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
@@ -41,6 +41,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface IdentifierTree extends ExpressionTree {
     Name getName();
 }
diff --git a/src/share/classes/com/sun/source/tree/IfTree.java b/src/share/classes/com/sun/source/tree/IfTree.java
index f600946..ad88dd5 100644
--- a/src/share/classes/com/sun/source/tree/IfTree.java
+++ b/src/share/classes/com/sun/source/tree/IfTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface IfTree extends StatementTree {
     ExpressionTree getCondition();
     StatementTree getThenStatement();
diff --git a/src/share/classes/com/sun/source/tree/ImportTree.java b/src/share/classes/com/sun/source/tree/ImportTree.java
index 1fd027d..8eb61ac 100644
--- a/src/share/classes/com/sun/source/tree/ImportTree.java
+++ b/src/share/classes/com/sun/source/tree/ImportTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ImportTree extends Tree {
     boolean isStatic();
     /**
diff --git a/src/share/classes/com/sun/source/tree/InstanceOfTree.java b/src/share/classes/com/sun/source/tree/InstanceOfTree.java
index 20d95e7..a7d6325 100644
--- a/src/share/classes/com/sun/source/tree/InstanceOfTree.java
+++ b/src/share/classes/com/sun/source/tree/InstanceOfTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface InstanceOfTree extends ExpressionTree {
     ExpressionTree getExpression();
     Tree getType();
diff --git a/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java b/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java
new file mode 100644
index 0000000..7476564
--- /dev/null
+++ b/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java
@@ -0,0 +1,40 @@
+/*
+ * 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.  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.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for an intersection type in a cast expression.
+ *
+ * @author Maurizio Cimadamore
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface IntersectionTypeTree extends Tree {
+    List<? extends Tree> getBounds();
+}
diff --git a/src/share/classes/com/sun/source/tree/LabeledStatementTree.java b/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
index ba58dd4..644189f 100644
--- a/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
+++ b/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
@@ -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
@@ -41,6 +41,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface LabeledStatementTree extends StatementTree {
     Name getLabel();
     StatementTree getStatement();
diff --git a/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java b/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
new file mode 100644
index 0000000..ffd230d
--- /dev/null
+++ b/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
@@ -0,0 +1,58 @@
+/*
+ * 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
+ * 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.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a lambda expression.
+ *
+ * For example:
+ * <pre>{@code
+ *   ()->{}
+ *   (List<String> ls)->ls.size()
+ *   (x,y)-> { return x + y; }
+ * }</pre>
+ */
+ at jdk.Supported
+public interface LambdaExpressionTree extends ExpressionTree {
+
+    /**
+     * Lambda expressions come in two forms: (i) expression lambdas, whose body
+     * is an expression, and (ii) statement lambdas, whose body is a block
+     */
+    @jdk.Supported
+    public enum BodyKind {
+        /** enum constant for expression lambdas */
+        EXPRESSION,
+        /** enum constant for statement lambdas */
+        STATEMENT;
+    }
+
+    List<? extends VariableTree> getParameters();
+    Tree getBody();
+    BodyKind getBodyKind();
+}
diff --git a/src/share/classes/com/sun/source/tree/LineMap.java b/src/share/classes/com/sun/source/tree/LineMap.java
index 058d3bb..4c0c29b 100644
--- a/src/share/classes/com/sun/source/tree/LineMap.java
+++ b/src/share/classes/com/sun/source/tree/LineMap.java
@@ -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
@@ -31,6 +31,7 @@ package com.sun.source.tree;
  *
  * @since 1.6
  */
+ at jdk.Supported
 public interface LineMap {
     /**
      * Find the start position of a line.
@@ -38,8 +39,8 @@ public interface LineMap {
      * @param line line number (beginning at 1)
      * @return     position of first character in line
      * @throws  IndexOutOfBoundsException
-     *           if <tt>lineNumber < 1</tt>
-     *           if <tt>lineNumber > no. of lines</tt>
+     *           if {@code lineNumber < 1}
+     *           if {@code lineNumber > no. of lines}
      */
     long getStartPosition(long line);
 
diff --git a/src/share/classes/com/sun/source/tree/LiteralTree.java b/src/share/classes/com/sun/source/tree/LiteralTree.java
index a8be528..adc3937 100644
--- a/src/share/classes/com/sun/source/tree/LiteralTree.java
+++ b/src/share/classes/com/sun/source/tree/LiteralTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface LiteralTree extends ExpressionTree {
     Object getValue();
 }
diff --git a/src/share/classes/com/sun/source/tree/MemberReferenceTree.java b/src/share/classes/com/sun/source/tree/MemberReferenceTree.java
new file mode 100644
index 0000000..03b8a6a
--- /dev/null
+++ b/src/share/classes/com/sun/source/tree/MemberReferenceTree.java
@@ -0,0 +1,60 @@
+/*
+ * 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
+ * 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.tree;
+
+import java.util.List;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for a member reference expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> # <em>[ identifier | new ]</em>
+ * </pre>
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface MemberReferenceTree extends ExpressionTree {
+
+    /**
+     * There are two kinds of member references: (i) method references and
+     * (ii) constructor references
+     */
+    @jdk.Supported
+    public enum ReferenceMode {
+        /** enum constant for method references */
+        INVOKE,
+        /** enum constant for constructor references */
+        NEW
+    }
+    ReferenceMode getMode();
+    ExpressionTree getQualifierExpression();
+    Name getName();
+    List<? extends ExpressionTree> getTypeArguments();
+}
diff --git a/src/share/classes/com/sun/source/tree/MemberSelectTree.java b/src/share/classes/com/sun/source/tree/MemberSelectTree.java
index e5beec5..8b1b8e4 100644
--- a/src/share/classes/com/sun/source/tree/MemberSelectTree.java
+++ b/src/share/classes/com/sun/source/tree/MemberSelectTree.java
@@ -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
@@ -41,6 +41,7 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface MemberSelectTree extends ExpressionTree {
     ExpressionTree getExpression();
     Name getIdentifier();
diff --git a/src/share/classes/com/sun/source/tree/MethodInvocationTree.java b/src/share/classes/com/sun/source/tree/MethodInvocationTree.java
index 4728d99..2ccbeae 100644
--- a/src/share/classes/com/sun/source/tree/MethodInvocationTree.java
+++ b/src/share/classes/com/sun/source/tree/MethodInvocationTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface MethodInvocationTree extends ExpressionTree {
     List<? extends Tree> getTypeArguments();
     ExpressionTree getMethodSelect();
diff --git a/src/share/classes/com/sun/source/tree/MethodTree.java b/src/share/classes/com/sun/source/tree/MethodTree.java
index 8dfd0ba..8d9820b 100644
--- a/src/share/classes/com/sun/source/tree/MethodTree.java
+++ b/src/share/classes/com/sun/source/tree/MethodTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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,12 +46,14 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface MethodTree extends Tree {
     ModifiersTree getModifiers();
     Name getName();
     Tree getReturnType();
     List<? extends TypeParameterTree> getTypeParameters();
     List<? extends VariableTree> getParameters();
+    VariableTree getReceiverParameter();
     List<? extends ExpressionTree> getThrows();
     BlockTree getBody();
     Tree getDefaultValue(); // for annotation types
diff --git a/src/share/classes/com/sun/source/tree/ModifiersTree.java b/src/share/classes/com/sun/source/tree/ModifiersTree.java
index 3189651..3fae9c0 100644
--- a/src/share/classes/com/sun/source/tree/ModifiersTree.java
+++ b/src/share/classes/com/sun/source/tree/ModifiersTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@ import javax.lang.model.element.Modifier;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ModifiersTree extends Tree {
     Set<Modifier> getFlags();
     List<? extends AnnotationTree> getAnnotations();
diff --git a/src/share/classes/com/sun/source/tree/NewArrayTree.java b/src/share/classes/com/sun/source/tree/NewArrayTree.java
index cdd5cd5..b9f1bdd 100644
--- a/src/share/classes/com/sun/source/tree/NewArrayTree.java
+++ b/src/share/classes/com/sun/source/tree/NewArrayTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface NewArrayTree extends ExpressionTree {
     Tree getType();
     List<? extends ExpressionTree> getDimensions();
diff --git a/src/share/classes/com/sun/source/tree/NewClassTree.java b/src/share/classes/com/sun/source/tree/NewClassTree.java
index 06d713b..561d411 100644
--- a/src/share/classes/com/sun/source/tree/NewClassTree.java
+++ b/src/share/classes/com/sun/source/tree/NewClassTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -48,6 +48,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface NewClassTree extends ExpressionTree {
     ExpressionTree getEnclosingExpression();
     List<? extends Tree> getTypeArguments();
diff --git a/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java b/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java
index aef328d..c51aad5 100644
--- a/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java
+++ b/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ParameterizedTypeTree extends Tree {
     Tree getType();
     List<? extends Tree> getTypeArguments();
diff --git a/src/share/classes/com/sun/source/tree/ParenthesizedTree.java b/src/share/classes/com/sun/source/tree/ParenthesizedTree.java
index d68516f..2e0cd4d 100644
--- a/src/share/classes/com/sun/source/tree/ParenthesizedTree.java
+++ b/src/share/classes/com/sun/source/tree/ParenthesizedTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ParenthesizedTree extends ExpressionTree {
     ExpressionTree getExpression();
 }
diff --git a/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java b/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java
index f6cd566..0b98b59 100644
--- a/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java
+++ b/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ import javax.lang.model.type.TypeKind;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface PrimitiveTypeTree extends Tree {
     TypeKind getPrimitiveTypeKind();
 }
diff --git a/src/share/classes/com/sun/source/tree/ReturnTree.java b/src/share/classes/com/sun/source/tree/ReturnTree.java
index 62a51cb..b8d451b 100644
--- a/src/share/classes/com/sun/source/tree/ReturnTree.java
+++ b/src/share/classes/com/sun/source/tree/ReturnTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ReturnTree extends StatementTree {
     ExpressionTree getExpression();
 }
diff --git a/src/share/classes/com/sun/source/tree/Scope.java b/src/share/classes/com/sun/source/tree/Scope.java
index 441f337..17b79be 100644
--- a/src/share/classes/com/sun/source/tree/Scope.java
+++ b/src/share/classes/com/sun/source/tree/Scope.java
@@ -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
@@ -25,11 +25,9 @@
 
 package com.sun.source.tree;
 
-import com.sun.source.tree.Tree;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
-import javax.lang.model.type.DeclaredType;
 
 /**
  * Interface for determining locally available program elements, such as
@@ -50,6 +48,7 @@ import javax.lang.model.type.DeclaredType;
  *
  * @since 1.6
  */
+ at jdk.Supported
 public interface Scope {
     /**
      * Returns the enclosing scope.
diff --git a/src/share/classes/com/sun/source/tree/StatementTree.java b/src/share/classes/com/sun/source/tree/StatementTree.java
index 47dba7d..2bae01c 100644
--- a/src/share/classes/com/sun/source/tree/StatementTree.java
+++ b/src/share/classes/com/sun/source/tree/StatementTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -35,4 +35,5 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface StatementTree extends Tree {}
diff --git a/src/share/classes/com/sun/source/tree/SwitchTree.java b/src/share/classes/com/sun/source/tree/SwitchTree.java
index c5a87c4..3d8a11f 100644
--- a/src/share/classes/com/sun/source/tree/SwitchTree.java
+++ b/src/share/classes/com/sun/source/tree/SwitchTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -43,6 +43,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface SwitchTree extends StatementTree {
     ExpressionTree getExpression();
     List<? extends CaseTree> getCases();
diff --git a/src/share/classes/com/sun/source/tree/SynchronizedTree.java b/src/share/classes/com/sun/source/tree/SynchronizedTree.java
index fd7cb06..579e075 100644
--- a/src/share/classes/com/sun/source/tree/SynchronizedTree.java
+++ b/src/share/classes/com/sun/source/tree/SynchronizedTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -40,6 +40,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface SynchronizedTree extends StatementTree {
     ExpressionTree getExpression();
     BlockTree getBlock();
diff --git a/src/share/classes/com/sun/source/tree/ThrowTree.java b/src/share/classes/com/sun/source/tree/ThrowTree.java
index a91f63b..474b588 100644
--- a/src/share/classes/com/sun/source/tree/ThrowTree.java
+++ b/src/share/classes/com/sun/source/tree/ThrowTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface ThrowTree extends StatementTree {
     ExpressionTree getExpression();
 }
diff --git a/src/share/classes/com/sun/source/tree/Tree.java b/src/share/classes/com/sun/source/tree/Tree.java
index 5e26c18..306991d 100644
--- a/src/share/classes/com/sun/source/tree/Tree.java
+++ b/src/share/classes/com/sun/source/tree/Tree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -39,19 +39,30 @@ package com.sun.source.tree;
  *
  * @since 1.6
  */
+ at jdk.Supported
 public interface Tree {
 
     /**
      * Enumerates all kinds of trees.
      */
+    @jdk.Supported
     public enum Kind {
 
+        ANNOTATED_TYPE(AnnotatedTypeTree.class),
+
         /**
-         * Used for instances of {@link AnnotationTree}.
+         * Used for instances of {@link AnnotationTree}
+         * representing declaration annotations.
          */
         ANNOTATION(AnnotationTree.class),
 
         /**
+         * Used for instances of {@link AnnotationTree}
+         * representing type annotations.
+         */
+        TYPE_ANNOTATION(AnnotationTree.class),
+
+        /**
          * Used for instances of {@link ArrayAccessTree}.
          */
         ARRAY_ACCESS(ArrayAccessTree.class),
@@ -132,6 +143,11 @@ public interface Tree {
         MEMBER_SELECT(MemberSelectTree.class),
 
         /**
+         * Used for instances of {@link MemberReferenceTree}.
+         */
+        MEMBER_REFERENCE(MemberReferenceTree.class),
+
+        /**
          * Used for instances of {@link ForLoopTree}.
          */
         FOR_LOOP(ForLoopTree.class),
@@ -187,6 +203,11 @@ public interface Tree {
         NEW_CLASS(NewClassTree.class),
 
         /**
+         * Used for instances of {@link LambdaExpressionTree}.
+         */
+        LAMBDA_EXPRESSION(LambdaExpressionTree.class),
+
+        /**
          * Used for instances of {@link ParenthesizedTree}.
          */
         PARENTHESIZED(ParenthesizedTree.class),
@@ -237,6 +258,11 @@ public interface Tree {
         UNION_TYPE(UnionTypeTree.class),
 
         /**
+         * Used for instances of {@link IntersectionTypeTree}.
+         */
+        INTERSECTION_TYPE(IntersectionTypeTree.class),
+
+        /**
          * Used for instances of {@link TypeCastTree}.
          */
         TYPE_CAST(TypeCastTree.class),
@@ -600,7 +626,7 @@ public interface Tree {
      * visitor pattern is used to implement operations on trees.
      *
      * @param <R> result type of this operation.
-     * @param <D> type of additonal data.
+     * @param <D> type of additional data.
      */
     <R,D> R accept(TreeVisitor<R,D> visitor, D data);
 }
diff --git a/src/share/classes/com/sun/source/tree/TreeVisitor.java b/src/share/classes/com/sun/source/tree/TreeVisitor.java
index ffaf0c3..386e714 100644
--- a/src/share/classes/com/sun/source/tree/TreeVisitor.java
+++ b/src/share/classes/com/sun/source/tree/TreeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -56,7 +56,9 @@ package com.sun.source.tree;
  *
  * @since 1.6
  */
+ at jdk.Supported
 public interface TreeVisitor<R,P> {
+    R visitAnnotatedType(AnnotatedTypeTree node, P p);
     R visitAnnotation(AnnotationTree node, P p);
     R visitMethodInvocation(MethodInvocationTree node, P p);
     R visitAssert(AssertTree node, P p);
@@ -85,9 +87,11 @@ public interface TreeVisitor<R,P> {
     R visitModifiers(ModifiersTree node, P p);
     R visitNewArray(NewArrayTree node, P p);
     R visitNewClass(NewClassTree node, P p);
+    R visitLambdaExpression(LambdaExpressionTree node, P p);
     R visitParenthesized(ParenthesizedTree node, P p);
     R visitReturn(ReturnTree node, P p);
     R visitMemberSelect(MemberSelectTree node, P p);
+    R visitMemberReference(MemberReferenceTree node, P p);
     R visitEmptyStatement(EmptyStatementTree node, P p);
     R visitSwitch(SwitchTree node, P p);
     R visitSynchronized(SynchronizedTree node, P p);
@@ -96,6 +100,7 @@ public interface TreeVisitor<R,P> {
     R visitTry(TryTree node, P p);
     R visitParameterizedType(ParameterizedTypeTree node, P p);
     R visitUnionType(UnionTypeTree node, P p);
+    R visitIntersectionType(IntersectionTypeTree node, P p);
     R visitArrayType(ArrayTypeTree node, P p);
     R visitTypeCast(TypeCastTree node, P p);
     R visitPrimitiveType(PrimitiveTypeTree node, P p);
diff --git a/src/share/classes/com/sun/source/tree/TryTree.java b/src/share/classes/com/sun/source/tree/TryTree.java
index f2510bd..0b7b19e 100644
--- a/src/share/classes/com/sun/source/tree/TryTree.java
+++ b/src/share/classes/com/sun/source/tree/TryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -45,6 +45,7 @@ import java.util.List;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface TryTree extends StatementTree {
     BlockTree getBlock();
     List<? extends CatchTree> getCatches();
diff --git a/src/share/classes/com/sun/source/tree/TypeCastTree.java b/src/share/classes/com/sun/source/tree/TypeCastTree.java
index 43dc619..77ad546 100644
--- a/src/share/classes/com/sun/source/tree/TypeCastTree.java
+++ b/src/share/classes/com/sun/source/tree/TypeCastTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface TypeCastTree extends ExpressionTree {
     Tree getType();
     ExpressionTree getExpression();
diff --git a/src/share/classes/com/sun/source/tree/TypeParameterTree.java b/src/share/classes/com/sun/source/tree/TypeParameterTree.java
index 6a60338..293a38b 100644
--- a/src/share/classes/com/sun/source/tree/TypeParameterTree.java
+++ b/src/share/classes/com/sun/source/tree/TypeParameterTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -44,7 +44,9 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface TypeParameterTree extends Tree {
     Name getName();
     List<? extends Tree> getBounds();
+    List<? extends AnnotationTree> getAnnotations();
 }
diff --git a/src/share/classes/com/sun/source/tree/UnaryTree.java b/src/share/classes/com/sun/source/tree/UnaryTree.java
index 7b4d9e8..cb0da5e 100644
--- a/src/share/classes/com/sun/source/tree/UnaryTree.java
+++ b/src/share/classes/com/sun/source/tree/UnaryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -42,6 +42,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface UnaryTree extends ExpressionTree {
     ExpressionTree getExpression();
 }
diff --git a/src/share/classes/com/sun/source/tree/UnionTypeTree.java b/src/share/classes/com/sun/source/tree/UnionTypeTree.java
index 2a4b935..57b9892 100644
--- a/src/share/classes/com/sun/source/tree/UnionTypeTree.java
+++ b/src/share/classes/com/sun/source/tree/UnionTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -34,6 +34,7 @@ import java.util.List;
  *
  * @since 1.7
  */
+ at jdk.Supported
 public interface UnionTypeTree extends Tree {
     List<? extends Tree> getTypeAlternatives();
 }
diff --git a/src/share/classes/com/sun/source/tree/VariableTree.java b/src/share/classes/com/sun/source/tree/VariableTree.java
index ea73f23..86fce99 100644
--- a/src/share/classes/com/sun/source/tree/VariableTree.java
+++ b/src/share/classes/com/sun/source/tree/VariableTree.java
@@ -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
@@ -33,6 +33,7 @@ import javax.lang.model.element.Name;
  * 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
@@ -41,9 +42,11 @@ import javax.lang.model.element.Name;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface VariableTree extends StatementTree {
     ModifiersTree getModifiers();
     Name getName();
+    ExpressionTree getNameExpression();
     Tree getType();
     ExpressionTree getInitializer();
 }
diff --git a/src/share/classes/com/sun/source/tree/WhileLoopTree.java b/src/share/classes/com/sun/source/tree/WhileLoopTree.java
index fd4a832..e7c4351 100644
--- a/src/share/classes/com/sun/source/tree/WhileLoopTree.java
+++ b/src/share/classes/com/sun/source/tree/WhileLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -41,6 +41,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface WhileLoopTree extends StatementTree {
     ExpressionTree getCondition();
     StatementTree getStatement();
diff --git a/src/share/classes/com/sun/source/tree/WildcardTree.java b/src/share/classes/com/sun/source/tree/WildcardTree.java
index d3f62fd..d60f797 100644
--- a/src/share/classes/com/sun/source/tree/WildcardTree.java
+++ b/src/share/classes/com/sun/source/tree/WildcardTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -44,6 +44,7 @@ package com.sun.source.tree;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface WildcardTree extends Tree {
     Tree getBound();
 }
diff --git a/src/share/classes/com/sun/source/tree/package-info.java b/src/share/classes/com/sun/source/tree/package-info.java
index 7a20464..7df58d8 100644
--- a/src/share/classes/com/sun/source/tree/package-info.java
+++ b/src/share/classes/com/sun/source/tree/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -31,4 +31,5 @@
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 package com.sun.source.tree;
diff --git a/src/share/classes/com/sun/source/util/DocSourcePositions.java b/src/share/classes/com/sun/source/util/DocSourcePositions.java
new file mode 100644
index 0000000..d249da1
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/DocSourcePositions.java
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package com.sun.source.util;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.tree.CompilationUnitTree;
+
+/**
+ * Provides methods to obtain the position of a DocTree within a javadoc comment.
+ * A position is defined as a simple character offset from the start of a
+ * CompilationUnit where the first character is at offset 0.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface DocSourcePositions extends SourcePositions {
+
+    /**
+     * Gets the starting position of the tree within the comment within the file.  If tree is not found within
+     * file, or if the starting position is not available,
+     * return {@link javax.tools.Diagnostic#NOPOS}.
+     * The given tree should be under the given comment tree, and the given documentation
+     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
+     * for a tree under the given file.
+     * The returned position must be at the start of the yield of this tree, that
+     * is for any sub-tree of this tree, the following must hold:
+     *
+     * <p>
+     * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
+     * {@code tree.getStartPosition() == NOPOS} or <br>
+     * {@code subtree.getStartPosition() == NOPOS}
+     * </p>
+     *
+     * @param file CompilationUnit in which to find tree.
+     * @param comment the comment tree that encloses the tree for which the
+     *                position is being sought
+     * @param tree tree for which a position is sought.
+     * @return the start position of tree.
+     */
+    long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
+
+    /**
+     * Gets the ending position of the tree within the comment within the file.  If tree is not found within
+     * file, or if the ending position is not available,
+     * return {@link javax.tools.Diagnostic#NOPOS}.
+     * The given tree should be under the given comment tree, and the given documentation
+     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
+     * for a tree under the given file.
+     * The returned position must be at the end of the yield of this tree,
+     * that is for any sub-tree of this tree, the following must hold:
+     *
+     * <p>
+     * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
+     * {@code tree.getEndPosition() == NOPOS} or <br>
+     * {@code subtree.getEndPosition() == NOPOS}
+     * </p>
+     *
+     * In addition, the following must hold:
+     *
+     * <p>
+     * {@code tree.getStartPosition() <= tree.getEndPosition()}  or <br>
+     * {@code tree.getStartPosition() == NOPOS} or <br>
+     * {@code tree.getEndPosition() == NOPOS}
+     * </p>
+     *
+     * @param file CompilationUnit in which to find tree.
+     * @param comment the comment tree that encloses the tree for which the
+     *                position is being sought
+     * @param tree tree for which a position is sought.
+     * @return the start position of tree.
+     */
+    long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
+
+}
diff --git a/src/share/classes/com/sun/source/util/DocTreePath.java b/src/share/classes/com/sun/source/util/DocTreePath.java
new file mode 100644
index 0000000..0720630
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/DocTreePath.java
@@ -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
+ */
+ at 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;
+}
diff --git a/src/share/classes/com/sun/source/util/DocTreePathScanner.java b/src/share/classes/com/sun/source/util/DocTreePathScanner.java
new file mode 100644
index 0000000..326c155
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/DocTreePathScanner.java
@@ -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
+ */
+ at 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;
+}
diff --git a/src/share/classes/com/sun/source/util/DocTreeScanner.java b/src/share/classes/com/sun/source/util/DocTreeScanner.java
new file mode 100644
index 0000000..006f1a5
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/DocTreeScanner.java
@@ -0,0 +1,274 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import com.sun.source.doctree.*;
+
+
+/**
+ * A TreeVisitor that visits all the child tree nodes.
+ * To visit nodes of a particular type, just override the
+ * corresponding visitXYZ method.
+ * Inside your method, call super.visitXYZ to visit descendant
+ * nodes.
+ *
+ * <p>The default implementation of the visitXYZ methods will determine
+ * a result as follows:
+ * <ul>
+ * <li>If the node being visited has no children, the result will be null.
+ * <li>If the node being visited has one child, the result will be the
+ * result of calling {@code scan} on that child. The child may be a simple node
+ * or itself a list of nodes.
+ * <li> If the node being visited has more than one child, the result will
+ * be determined by calling {@code scan} each child in turn, and then combining the
+ * result of each scan after the first with the cumulative result
+ * so far, as determined by the {@link #reduce} method. Each child may be either
+ * a simple node of a list of nodes. The default behavior of the {@code reduce}
+ * method is such that the result of the visitXYZ method will be the result of
+ * the last child scanned.
+ * </ul>
+ *
+ * <p>Here is an example to count the number of erroneous nodes in a tree:
+ * <pre>
+ *   class CountErrors extends DocTreeScanner<Integer,Void> {
+ *      {@literal @}Override
+ *      public Integer visitErroneous(ErroneousTree node, Void p) {
+ *          return 1;
+ *      }
+ *      {@literal @}Override
+ *      public Integer reduce(Integer r1, Integer r2) {
+ *          return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
+ *      }
+ *   }
+ * </pre>
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public class DocTreeScanner<R,P> implements DocTreeVisitor<R,P> {
+
+    /**
+     * Scan a single node.
+     */
+    public R scan(DocTree node, P p) {
+        return (node == null) ? null : node.accept(this, p);
+    }
+
+    private R scanAndReduce(DocTree node, P p, R r) {
+        return reduce(scan(node, p), r);
+    }
+
+    /**
+     * Scan a list of nodes.
+     */
+    public R scan(Iterable<? extends DocTree> nodes, P p) {
+        R r = null;
+        if (nodes != null) {
+            boolean first = true;
+            for (DocTree node : nodes) {
+                r = (first ? scan(node, p) : scanAndReduce(node, p, r));
+                first = false;
+            }
+        }
+        return r;
+    }
+
+    private R scanAndReduce(Iterable<? extends DocTree> nodes, P p, R r) {
+        return reduce(scan(nodes, p), r);
+    }
+
+    /**
+     * Reduces two results into a combined result.
+     * The default implementation is to return the first parameter.
+     * The general contract of the method is that it may take any action whatsoever.
+     */
+    public R reduce(R r1, R r2) {
+        return r1;
+    }
+
+
+/* ***************************************************************************
+ * Visitor methods
+ ****************************************************************************/
+
+    @Override
+    public R visitAttribute(AttributeTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitAuthor(AuthorTree node, P p) {
+        return scan(node.getName(), p);
+    }
+
+    @Override
+    public R visitComment(CommentTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitDeprecated(DeprecatedTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitDocComment(DocCommentTree node, P p) {
+        R r = scan(node.getFirstSentence(), p);
+        r = scanAndReduce(node.getBody(), p, r);
+        r = scanAndReduce(node.getBlockTags(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitDocRoot(DocRootTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitEndElement(EndElementTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitEntity(EntityTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitErroneous(ErroneousTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitIdentifier(IdentifierTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitInheritDoc(InheritDocTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitLink(LinkTree node, P p) {
+        R r = scan(node.getReference(), p);
+        r = scanAndReduce(node.getLabel(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitLiteral(LiteralTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitParam(ParamTree node, P p) {
+        R r = scan(node.getName(), p);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitReference(ReferenceTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitReturn(ReturnTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSee(SeeTree node, P p) {
+        return scan(node.getReference(), p);
+    }
+
+    @Override
+    public R visitSerial(SerialTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSerialData(SerialDataTree node, P p) {
+        return scan(node.getDescription(), p);
+    }
+
+    @Override
+    public R visitSerialField(SerialFieldTree node, P p) {
+        R r = scan(node.getName(), p);
+        r = scanAndReduce(node.getType(), p, r);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitSince(SinceTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitStartElement(StartElementTree node, P p) {
+        return scan(node.getAttributes(), p);
+    }
+
+    @Override
+    public R visitText(TextTree node, P p) {
+        return null;
+    }
+
+    @Override
+    public R visitThrows(ThrowsTree node, P p) {
+        R r = scan(node.getExceptionName(), p);
+        r = scanAndReduce(node.getDescription(), p, r);
+        return r;
+    }
+
+    @Override
+    public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+        return scan(node.getContent(), p);
+    }
+
+    @Override
+    public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+        return scan(node.getContent(), p);
+    }
+
+    @Override
+    public R visitValue(ValueTree node, P p) {
+        return scan(node.getReference(), p);
+    }
+
+    @Override
+    public R visitVersion(VersionTree node, P p) {
+        return scan(node.getBody(), p);
+    }
+
+    @Override
+    public R visitOther(DocTree node, P p) {
+        return null;
+    }
+
+}
diff --git a/src/share/classes/com/sun/source/util/DocTrees.java b/src/share/classes/com/sun/source/util/DocTrees.java
new file mode 100644
index 0000000..affc5f3
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/DocTrees.java
@@ -0,0 +1,90 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.util;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.lang.model.element.Element;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ReferenceTree;
+import javax.tools.Diagnostic;
+
+/**
+ * Provides access to syntax trees for doc comments.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public abstract class DocTrees extends Trees {
+    /**
+     * Gets a DocTrees object for a given CompilationTask.
+     * @param task the compilation task for which to get the Trees object
+     * @throws IllegalArgumentException if the task does not support the Trees API.
+     */
+    public static DocTrees instance(CompilationTask task) {
+        return (DocTrees) Trees.instance(task);
+    }
+
+    /**
+     * Gets a DocTrees object for a given ProcessingEnvironment.
+     * @param env the processing environment for which to get the Trees object
+     * @throws IllegalArgumentException if the env does not support the Trees API.
+     */
+    public static DocTrees instance(ProcessingEnvironment env) {
+        if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment"))
+            throw new IllegalArgumentException();
+        return (DocTrees) getJavacTrees(ProcessingEnvironment.class, env);
+    }
+
+    /**
+     * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath.
+     * Returns null if no doc comment was found.
+     */
+    public abstract DocCommentTree getDocCommentTree(TreePath path);
+
+    /**
+     * Gets the language model element referred to by the leaf node of the given
+     * {@link DocTreePath}, or null if unknown.
+     */
+    public abstract Element getElement(DocTreePath path);
+
+    public abstract DocSourcePositions getSourcePositions();
+
+    /**
+     * Prints a message of the specified kind at the location of the
+     * tree within the provided compilation unit
+     *
+     * @param kind the kind of message
+     * @param msg  the message, or an empty string if none
+     * @param t    the tree to use as a position hint
+     * @param root the compilation unit that contains tree
+     */
+    public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.doctree.DocTree t,
+            com.sun.source.doctree.DocCommentTree c,
+            com.sun.source.tree.CompilationUnitTree root);
+}
diff --git a/src/share/classes/com/sun/source/util/JavacTask.java b/src/share/classes/com/sun/source/util/JavacTask.java
index 2f2038f..1edb420 100644
--- a/src/share/classes/com/sun/source/util/JavacTask.java
+++ b/src/share/classes/com/sun/source/util/JavacTask.java
@@ -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
@@ -25,9 +25,9 @@
 
 package com.sun.source.util;
 
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.Tree;
 import java.io.IOException;
+
+import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.Element;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
@@ -35,6 +35,11 @@ import javax.lang.model.util.Types;
 import javax.tools.JavaCompiler.CompilationTask;
 import javax.tools.JavaFileObject;
 
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 /**
  * Provides access to functionality specific to the JDK Java Compiler, javac.
  *
@@ -42,13 +47,46 @@ import javax.tools.JavaFileObject;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public abstract class JavacTask implements CompilationTask {
 
     /**
+     * Get the {@code JavacTask} for a {@code ProcessingEnvironment}.
+     * If the compiler is being invoked using a
+     * {@link javax.tools.JavaCompiler.CompilationTask CompilationTask},
+     * then that task will be returned.
+     * @param processingEnvironment the processing environment
+     * @return the {@code JavacTask} for a {@code ProcessingEnvironment}
+     * @since 1.8
+     */
+    public static JavacTask instance(ProcessingEnvironment processingEnvironment) {
+        if (!processingEnvironment.getClass().getName().equals(
+                "com.sun.tools.javac.processing.JavacProcessingEnvironment"))
+            throw new IllegalArgumentException();
+        try {
+            //Cannot refer to the implementation directly, needs to use reflection:
+            Method m = processingEnvironment.getClass().getMethod("getJavacTask");
+            
+            return (JavacTask) m.invoke(processingEnvironment);
+        } catch (NoSuchMethodException ex) {
+            throw new UnsupportedOperationException(ex);
+        } catch (SecurityException ex) {
+            throw new UnsupportedOperationException(ex);
+        } catch (IllegalAccessException ex) {
+            throw new UnsupportedOperationException(ex);
+        } catch (IllegalArgumentException ex) {
+            throw new UnsupportedOperationException(ex);
+        } catch (InvocationTargetException ex) {
+            throw new UnsupportedOperationException(ex);
+        }
+    }
+
+    /**
      * Parse the specified files returning a list of abstract syntax trees.
      *
      * @return a list of abstract syntax trees
      * @throws IOException if an unhandled I/O error occurred in the compiler.
+     * @throws IllegalStateException if the operation cannot be performed at this time.
      */
     public abstract Iterable<? extends CompilationUnitTree> parse()
         throws IOException;
@@ -58,6 +96,7 @@ public abstract class JavacTask implements CompilationTask {
      *
      * @return a list of elements that were analyzed
      * @throws IOException if an unhandled I/O error occurred in the compiler.
+     * @throws IllegalStateException if the operation cannot be performed at this time.
      */
     public abstract Iterable<? extends Element> analyze() throws IOException;
 
@@ -66,19 +105,54 @@ public abstract class JavacTask implements CompilationTask {
      *
      * @return a list of files that were generated
      * @throws IOException if an unhandled I/O error occurred in the compiler.
+     * @throws IllegalStateException if the operation cannot be performed at this time.
      */
     public abstract Iterable<? extends JavaFileObject> generate() throws IOException;
 
     /**
-     * The specified listener will receive events describing the progress of
-     * this compilation task.
+     * The specified listener will receive notification of events
+     * describing the progress of this compilation task.
+     *
+     * If another listener is receiving notifications as a result of a prior
+     * call of this method, then that listener will no longer receive notifications.
+     *
+     * Informally, this method is equivalent to calling {@code removeTaskListener} for
+     * any listener that has been previously set, followed by {@code addTaskListener}
+     * for the new listener.
+     *
+     * @throws IllegalStateException if the specified listener has already been added.
      */
     public abstract void setTaskListener(TaskListener taskListener);
 
     /**
+     * The specified listener will receive notification of events
+     * describing the progress of this compilation task.
+     *
+     * This method may be called at any time before or during the compilation.
+     *
+     * @throws IllegalStateException if the specified listener has already been added.
+     * @since 1.8
+     */
+    public abstract void addTaskListener(TaskListener taskListener);
+
+    /**
+     * The specified listener will no longer receive notification of events
+     * describing the progress of this compilation task.
+     *
+     * This method may be called at any time before or during the compilation.
+     *
+     * @since 1.8
+     */
+    public abstract void removeTaskListener(TaskListener taskListener);
+
+    /**
      * Get a type mirror of the tree node determined by the specified path.
+     * This method has been superceded by methods on
+     * {@link com.sun.source.util.Trees Trees}.
+     * @see com.sun.source.util.Trees#getTypeMirror
      */
     public abstract TypeMirror getTypeMirror(Iterable<? extends Tree> path);
+
     /**
      * Get a utility object for dealing with program elements.
      */
diff --git a/src/share/classes/com/sun/source/util/Plugin.java b/src/share/classes/com/sun/source/util/Plugin.java
new file mode 100644
index 0000000..06f7418
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/Plugin.java
@@ -0,0 +1,65 @@
+/*
+ * 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.source.util;
+
+import java.util.ServiceLoader;
+import javax.tools.StandardLocation;
+
+/**
+ * The interface for a javac plug-in.
+ *
+ * <p>The javac plug-in mechanism allows a user to specify one or more plug-ins
+ * on the javac command line, to be started soon after the compilation
+ * has begun. Plug-ins are identified by a user-friendly name. Each plug-in that
+ * is started will be passed an array of strings, which may be used to
+ * provide the plug-in with values for any desired options or other arguments.
+ *
+ * <p>Plug-ins are located via a {@link ServiceLoader},
+ * using the same class path as annotation processors (i.e.
+ * {@link StandardLocation#ANNOTATION_PROCESSOR_PATH ANNOTATION_PROCESSOR_PATH} or
+ * {@code -processorpath}).
+ *
+ * <p>It is expected that a typical plug-in will simply register a
+ * {@link TaskListener} to be informed of events during the execution
+ * of the compilation, and that the rest of the work will be done
+ * by the task listener.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public interface Plugin {
+    /**
+     * Get the user-friendly name of this plug-in.
+     * @return the user-friendly name of the plug-in
+     */
+    String getName();
+
+    /**
+     * Initialize the plug-in for a given compilation task.
+     * @param task The compilation task that has just been started
+     * @param args Arguments, if any, for the plug-in
+     */
+    void init(JavacTask task, String... args);
+}
diff --git a/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
new file mode 100644
index 0000000..25e8010
--- /dev/null
+++ b/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
@@ -0,0 +1,180 @@
+/*
+ * 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.source.util;
+
+import com.sun.source.doctree.*;
+
+/**
+ * A simple visitor for tree nodes.
+ *
+ * @since 1.8
+ */
+ at jdk.Supported
+public class SimpleDocTreeVisitor<R,P> implements DocTreeVisitor<R, P> {
+    protected final R DEFAULT_VALUE;
+
+    protected SimpleDocTreeVisitor() {
+        DEFAULT_VALUE = null;
+    }
+
+    protected SimpleDocTreeVisitor(R defaultValue) {
+        DEFAULT_VALUE = defaultValue;
+    }
+
+    protected R defaultAction(DocTree node, P p) {
+        return DEFAULT_VALUE;
+    }
+
+    public final R visit(DocTree node, P p) {
+        return (node == null) ? null : node.accept(this, p);
+    }
+
+    public final R visit(Iterable<? extends DocTree> nodes, P p) {
+        R r = null;
+        if (nodes != null) {
+            for (DocTree node : nodes)
+                r = visit(node, p);
+        }
+        return r;
+    }
+
+    public R visitAttribute(AttributeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitAuthor(AuthorTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitComment(CommentTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDeprecated(DeprecatedTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDocComment(DocCommentTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitDocRoot(DocRootTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitEndElement(EndElementTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitEntity(EntityTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitErroneous(ErroneousTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitIdentifier(IdentifierTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitInheritDoc(InheritDocTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitLink(LinkTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitLiteral(LiteralTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitParam(ParamTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitReference(ReferenceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitReturn(ReturnTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSee(SeeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerial(SerialTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerialData(SerialDataTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSerialField(SerialFieldTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitSince(SinceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitStartElement(StartElementTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitText(TextTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitThrows(ThrowsTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitValue(ValueTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitVersion(VersionTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+    public R visitOther(DocTree node, P p) {
+        return defaultAction(node, p);
+    }
+
+}
diff --git a/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
index fc406b4..d8bf052 100644
--- a/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
+++ b/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -33,6 +33,7 @@ import com.sun.source.tree.*;
  * @author Peter von der Ahé
  * @since 1.6
  */
+ at jdk.Supported
 public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
     protected final R DEFAULT_VALUE;
 
@@ -172,6 +173,10 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
         return defaultAction(node, p);
     }
 
+    public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitParenthesized(ParenthesizedTree node, P p) {
         return defaultAction(node, p);
     }
@@ -208,6 +213,10 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
         return defaultAction(node, p);
     }
 
+    public R visitMemberReference(MemberReferenceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitIdentifier(IdentifierTree node, P p) {
         return defaultAction(node, p);
     }
@@ -232,6 +241,10 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
         return defaultAction(node, p);
     }
 
+    public R visitIntersectionType(IntersectionTypeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitTypeParameter(TypeParameterTree node, P p) {
         return defaultAction(node, p);
     }
@@ -248,6 +261,10 @@ public class SimpleTreeVisitor <R,P> implements TreeVisitor<R,P> {
         return defaultAction(node, p);
     }
 
+    public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitErroneous(ErroneousTree node, P p) {
         return defaultAction(node, p);
     }
diff --git a/src/share/classes/com/sun/source/util/SourcePositions.java b/src/share/classes/com/sun/source/util/SourcePositions.java
index b3a9fea..4494d32 100644
--- a/src/share/classes/com/sun/source/util/SourcePositions.java
+++ b/src/share/classes/com/sun/source/util/SourcePositions.java
@@ -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
@@ -35,6 +35,7 @@ import com.sun.source.tree.*;
  * @author Peter von der Ahé
  * @since 1.6
  */
+ at jdk.Supported
 public interface SourcePositions {
 
     /**
@@ -58,7 +59,7 @@ public interface SourcePositions {
 
     /**
      * Gets the ending position of tree within file.  If tree is not found within
-     * file, or if the starting position is not available,
+     * file, or if the ending position is not available,
      * return {@link javax.tools.Diagnostic#NOPOS}.
      * The returned position must be at the end of the yield of this tree,
      * that is for any sub-tree of this tree, the following must hold:
diff --git a/src/share/classes/com/sun/source/util/TaskEvent.java b/src/share/classes/com/sun/source/util/TaskEvent.java
index 7f45149..d49a9d5 100644
--- a/src/share/classes/com/sun/source/util/TaskEvent.java
+++ b/src/share/classes/com/sun/source/util/TaskEvent.java
@@ -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
@@ -25,22 +25,25 @@
 
 package com.sun.source.util;
 
-import com.sun.source.tree.CompilationUnitTree;
 import javax.lang.model.element.TypeElement;
 import javax.tools.JavaFileObject;
 
+import com.sun.source.tree.CompilationUnitTree;
+
 /**
  * Provides details about work that has been done by the JDK Java Compiler, javac.
  *
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public final class TaskEvent
 {
     /**
      * Kind of task event.
      * @since 1.6
      */
+    @jdk.Supported
     public enum Kind {
         /**
          * For events related to the parsing of a file.
@@ -59,7 +62,7 @@ public final class TaskEvent
          **/
         GENERATE,
         /**
-         * For events relating to overall annotaion processing.
+         * For events relating to overall annotation processing.
          **/
         ANNOTATION_PROCESSING,
         /**
diff --git a/src/share/classes/com/sun/source/util/TaskListener.java b/src/share/classes/com/sun/source/util/TaskListener.java
index 602ccbf..3909975 100644
--- a/src/share/classes/com/sun/source/util/TaskListener.java
+++ b/src/share/classes/com/sun/source/util/TaskListener.java
@@ -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
@@ -32,6 +32,7 @@ package com.sun.source.util;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public interface TaskListener
 {
     public void started(TaskEvent e);
diff --git a/src/share/classes/com/sun/source/util/TreePath.java b/src/share/classes/com/sun/source/util/TreePath.java
index 103f624..1d23b08 100644
--- a/src/share/classes/com/sun/source/util/TreePath.java
+++ b/src/share/classes/com/sun/source/util/TreePath.java
@@ -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
@@ -25,9 +25,10 @@
 
 package com.sun.source.util;
 
-import com.sun.source.tree.*;
 import java.util.Iterator;
 
+import com.sun.source.tree.*;
+
 /**
  * A path of tree nodes, typically used to represent the sequence of ancestor
  * nodes of a tree node up to the top level CompilationUnitTree node.
@@ -35,6 +36,7 @@ import java.util.Iterator;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public class TreePath implements Iterable<Tree> {
     /**
      * Gets a tree path for a tree node within a compilation unit.
@@ -59,14 +61,20 @@ public class TreePath implements Iterable<Tree> {
                 this.path = path;
             }
         }
+
         class PathFinder extends TreePathScanner<TreePath,Tree> {
             public TreePath scan(Tree tree, Tree target) {
-                if (tree == target)
+                if (tree == target) {
                     throw new Result(new TreePath(getCurrentPath(), target));
+                }
                 return super.scan(tree, target);
             }
         }
 
+        if (path.getLeaf() == target) {
+            return path;
+        }
+
         try {
             new PathFinder().scan(path, target);
         } catch (Result result) {
@@ -117,18 +125,25 @@ public class TreePath implements Iterable<Tree> {
         return parent;
     }
 
+    /**
+     *  Iterates from leaves to root.
+     */
+    @Override
     public Iterator<Tree> iterator() {
         return new Iterator<Tree>() {
+            @Override
             public boolean hasNext() {
                 return next != null;
             }
 
+            @Override
             public Tree next() {
                 Tree t = next.leaf;
                 next = next.parent;
                 return t;
             }
 
+            @Override
             public void remove() {
                 throw new UnsupportedOperationException();
             }
diff --git a/src/share/classes/com/sun/source/util/TreePathScanner.java b/src/share/classes/com/sun/source/util/TreePathScanner.java
index 4df7d24..54f8a99 100644
--- a/src/share/classes/com/sun/source/util/TreePathScanner.java
+++ b/src/share/classes/com/sun/source/util/TreePathScanner.java
@@ -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
@@ -38,6 +38,7 @@ import com.sun.source.tree.*;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public class TreePathScanner<R, P> extends TreeScanner<R, P> {
 
     /**
diff --git a/src/share/classes/com/sun/source/util/TreeScanner.java b/src/share/classes/com/sun/source/util/TreeScanner.java
index 96b9998..5c5ffd1 100644
--- a/src/share/classes/com/sun/source/util/TreeScanner.java
+++ b/src/share/classes/com/sun/source/util/TreeScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -52,7 +52,7 @@ import com.sun.source.tree.*;
  *
  * <p>Here is an example to count the number of identifier nodes in a tree:
  * <pre>
- *   class CountIdentifiers extends TreeScanner<Integer,Void> {
+ *   class CountIdentifiers extends TreeScanner<Integer,Void> {
  *      {@literal @}Override
  *      public Integer visitIdentifier(IdentifierTree node, Void p) {
  *          return 1;
@@ -68,6 +68,7 @@ import com.sun.source.tree.*;
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 public class TreeScanner<R,P> implements TreeVisitor<R,P> {
 
     /** Scan a single node.
@@ -138,6 +139,7 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
         r = scanAndReduce(node.getReturnType(), p, r);
         r = scanAndReduce(node.getTypeParameters(), p, r);
         r = scanAndReduce(node.getParameters(), p, r);
+        r = scanAndReduce(node.getReceiverParameter(), p, r);
         r = scanAndReduce(node.getThrows(), p, r);
         r = scanAndReduce(node.getBody(), p, r);
         r = scanAndReduce(node.getDefaultValue(), p, r);
@@ -147,6 +149,7 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
     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;
     }
@@ -285,6 +288,12 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
         return r;
     }
 
+    public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+        R r = scan(node.getParameters(), p);
+        r = scanAndReduce(node.getBody(), p, r);
+        return r;
+    }
+
     public R visitParenthesized(ParenthesizedTree node, P p) {
         return scan(node.getExpression(), p);
     }
@@ -333,6 +342,12 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
         return scan(node.getExpression(), p);
     }
 
+    public R visitMemberReference(MemberReferenceTree node, P p) {
+        R r = scan(node.getQualifierExpression(), p);
+        r = scanAndReduce(node.getTypeArguments(), p, r);
+        return r;
+    }
+
     public R visitIdentifier(IdentifierTree node, P p) {
         return null;
     }
@@ -359,8 +374,13 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
         return scan(node.getTypeAlternatives(), p);
     }
 
+    public R visitIntersectionType(IntersectionTypeTree node, P p) {
+        return scan(node.getBounds(), p);
+    }
+
     public R visitTypeParameter(TypeParameterTree node, P p) {
-        R r = scan(node.getBounds(), p);
+        R r = scan(node.getAnnotations(), p);
+        r = scanAndReduce(node.getBounds(), p, r);
         return r;
     }
 
@@ -378,6 +398,12 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
         return r;
     }
 
+   public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+       R r = scan(node.getAnnotations(), p);
+       r = scanAndReduce(node.getUnderlyingType(), p, r);
+       return r;
+   }
+
     public R visitOther(Tree node, P p) {
         return null;
     }
diff --git a/src/share/classes/com/sun/source/util/Trees.java b/src/share/classes/com/sun/source/util/Trees.java
index a787061..439b684 100644
--- a/src/share/classes/com/sun/source/util/Trees.java
+++ b/src/share/classes/com/sun/source/util/Trees.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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.source.util;
 
 import java.lang.reflect.Method;
+
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
@@ -50,6 +51,7 @@ import com.sun.source.tree.Tree;
  *
  * @author Peter von der Ahé
  */
+ at jdk.Supported
 public abstract class Trees {
     /**
      * Gets a Trees object for a given CompilationTask.
@@ -57,7 +59,9 @@ public abstract class Trees {
      * @throws IllegalArgumentException if the task does not support the Trees API.
      */
     public static Trees instance(CompilationTask task) {
-        if (!task.getClass().getName().equals("com.sun.tools.javac.api.JavacTaskImpl"))
+        String taskClassName = task.getClass().getName();
+        if (!taskClassName.equals("com.sun.tools.javac.api.JavacTaskImpl")
+                && !taskClassName.equals("com.sun.tools.javac.api.BasicJavacTask"))
             throw new IllegalArgumentException();
         return getJavacTrees(CompilationTask.class, task);
     }
@@ -73,7 +77,7 @@ public abstract class Trees {
         return getJavacTrees(ProcessingEnvironment.class, env);
     }
 
-    private static Trees getJavacTrees(Class<?> argType, Object arg) {
+    static Trees getJavacTrees(Class<?> argType, Object arg) {
         try {
             ClassLoader cl = arg.getClass().getClassLoader();
             Class<?> c = Class.forName("com.sun.tools.javac.api.JavacTrees", false, cl);
@@ -168,6 +172,7 @@ public abstract class Trees {
     /**
      * Gets the doc comment, if any, for the Tree node identified by a given TreePath.
      * Returns null if no doc comment was found.
+     * @see DocTrees#getDocCommentTree(TreePath)
      */
     public abstract String getDocComment(TreePath path);
 
diff --git a/src/share/classes/com/sun/source/util/package-info.java b/src/share/classes/com/sun/source/util/package-info.java
index 852dbc2..7e9659b 100644
--- a/src/share/classes/com/sun/source/util/package-info.java
+++ b/src/share/classes/com/sun/source/util/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -30,4 +30,5 @@
  * @author Jonathan Gibbons
  * @since 1.6
  */
+ at jdk.Supported
 package com.sun.source.util;
diff --git a/src/share/classes/com/sun/tools/apt/Main.java b/src/share/classes/com/sun/tools/apt/Main.java
deleted file mode 100644
index 0a34498..0000000
--- a/src/share/classes/com/sun/tools/apt/Main.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt;
-
-import java.io.PrintWriter;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/**
- * The main program for the command-line tool apt.
- *
- * <p>Nothing described in this source file is 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.
- */
-public class Main {
-
-    static {
-        ClassLoader loader = Main.class.getClassLoader();
-        if (loader != null)
-            loader.setPackageAssertionStatus("com.sun.tools.apt", true);
-    }
-
-    /** Command line interface.  If args is <tt>null</tt>, a
-     * <tt>NullPointerException</tt> is thrown.
-     * @param args   The command line parameters.
-     */
-    public static void main(String... args) {
-        System.exit(process(args));
-    }
-
-    /** Programatic interface.  If args is <tt>null</tt>, a
-     * <tt>NullPointerException</tt> is thrown.
-     * Output is directed to <tt>System.err</tt>.
-     * @param args   The command line parameters.
-     */
-    public static int process(String... args) {
-        return processing(null, null, args);
-    }
-
-    /** Programmatic interface.  If any argument
-     * is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
-     * @param args   The command line parameters.
-     * @param out    Where the tool's output is directed.
-     */
-    public static int process(PrintWriter out, String... args) {
-        if (out == null)
-            throw new NullPointerException("Parameter out cannot be null.");
-        return processing(null, out, args);
-    }
-
-    /** Programmatic interface.  If <tt>factory</tt> or <tt>args</tt>
-     * is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
-     * The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
-     * command line parameters are ignored by this entry point.
-     * Output is directed to <tt>System.err</tt>.
-     *
-     * @param factory The annotation processor factory to use
-     * @param args    The command line parameters.
-     */
-    public static int process(AnnotationProcessorFactory factory, String... args) {
-        return process(factory, new PrintWriter(System.err, true), args);
-    }
-
-    /** Programmatic interface.  If any argument
-     * is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
-     * The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
-     * command line parameters are ignored by this entry point.
-     *
-     * @param factory The annotation processor factory to use
-     * @param args   The command line parameters.
-     * @param out    Where the tool's output is directed.
-     */
-    public static int process(AnnotationProcessorFactory factory, PrintWriter out,
-                              String... args) {
-        if (out == null)
-            throw new NullPointerException("Parameter out cannot be null.");
-        if (factory == null)
-            throw new NullPointerException("Parameter factory cannot be null");
-        return processing(factory, out, args);
-    }
-
-    private static int processing(AnnotationProcessorFactory factory,
-                                  PrintWriter out,
-                                  String... args) {
-        if (out == null)
-            out = new PrintWriter(System.err, true);
-        com.sun.tools.apt.main.Main compiler =
-            new com.sun.tools.apt.main.Main("apt", out);
-        return compiler.compile(args, factory);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java b/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java
deleted file mode 100644
index 396cc16..0000000
--- a/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, 2009, 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.apt.comp;
-
-public class AnnotationProcessingError extends Error {
-    private static final long serialVersionUID = 3279196183341719287L;
-    AnnotationProcessingError(Throwable cause) {
-        super(cause);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/comp/Apt.java b/src/share/classes/com/sun/tools/apt/comp/Apt.java
deleted file mode 100644
index 00f261a..0000000
--- a/src/share/classes/com/sun/tools/apt/comp/Apt.java
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.comp;
-
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.comp.*;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.tree.TreeScanner;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.apt.util.Bark;
-import com.sun.tools.javac.util.Position;
-
-import java.util.*;
-import java.util.regex.*;
-import java.lang.reflect.*;
-import java.lang.reflect.InvocationTargetException;
-import java.io.IOException;
-
-import com.sun.tools.apt.*;
-import com.sun.tools.apt.comp.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.apt.*;
-// import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.apt.AnnotationProcessors;
-
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.apt.mirror.apt.FilerImpl;
-import com.sun.tools.apt.mirror.apt.AnnotationProcessorEnvironmentImpl;
-
-
-import static com.sun.tools.apt.mirror.declaration.DeclarationMaker.isJavaIdentifier;
-
-/**
- * Apt compiler phase.
- *
- *  <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>
- */
- at SuppressWarnings("deprecation")
-public class Apt extends ListBuffer<Env<AttrContext>> {
-    java.util.Set<String> genSourceFileNames = new java.util.LinkedHashSet<String>();
-    public java.util.Set<String> getSourceFileNames() {
-        return genSourceFileNames;
-    }
-
-    /** List of names of generated class files.
-     */
-    java.util.Set<String> genClassFileNames  = new java.util.LinkedHashSet<String>();
-    public java.util.Set<String> getClassFileNames() {
-        return genClassFileNames;
-    }
-
-    /* AptEnvironment */
-    AptEnv aptenv;
-
-    private Context context;
-
-    /** The context key for the todo list. */
-
-    protected static final Context.Key<Apt> aptKey =
-        new Context.Key<Apt>();
-
-    /** Get the Apt instance for this context. */
-    public static Apt instance(Context context) {
-        Apt instance = context.get(aptKey);
-        if (instance == null)
-            instance = new Apt(context);
-        return instance;
-    }
-
-    /** Create a new apt list. */
-    protected Apt(Context context) {
-        this.context = context;
-
-        context.put(aptKey, this);
-        aptenv = AptEnv.instance(context);
-    }
-
-    /**
-     * Used to scan javac trees to build data structures needed for
-     * bootstrapping the apt environment.  In particular:
-     *
-     * <ul>
-     *
-     * <li> Generate list of canonical names of annotation types that
-     * appear in source files given on the command line
-     *
-     * <li> Collect list of javac symbols representing source files
-     * given on the command line
-     *
-     * </ul>
-     */
-    static class AptTreeScanner extends TreeScanner {
-
-        // Set of fully qualified names of annotation types present in
-        // examined source
-        private Set<String> annotationSet;
-
-        // Symbols to build bootstrapping declaration list
-        private Collection<ClassSymbol> specifiedDeclCollection;
-        private Collection<ClassSymbol> declCollection;
-
-        public Set<String> getAnnotationSet() {
-            return annotationSet;
-        }
-
-        public AptTreeScanner() {
-            annotationSet = new  LinkedHashSet<String>();
-            specifiedDeclCollection = new LinkedHashSet<ClassSymbol>();
-            declCollection = new LinkedHashSet<ClassSymbol>();
-        }
-
-        public void visitTopLevel(JCTree.JCCompilationUnit tree) {
-            super.visitTopLevel(tree);
-            // Print out contents -- what are we dealing with?
-
-            for(JCTree d: tree.defs) {
-                if (d instanceof JCTree.JCClassDecl)
-                    specifiedDeclCollection.add(((JCTree.JCClassDecl) d).sym);
-            }
-
-        }
-
-        public void visitBlock(JCTree.JCBlock tree) {
-            ; // Do nothing.
-        }
-
-
-        // should add nested classes to packages, etc.
-        public void visitClassDef(JCTree.JCClassDecl tree) {
-            if (tree.sym == null) {
-                // could be an anon class w/in an initializer
-                return;
-            }
-
-            super.visitClassDef(tree);
-
-            declCollection.add(tree.sym);
-        }
-
-        public void visitMethodDef(JCTree.JCMethodDecl tree) {
-            super.visitMethodDef(tree);
-        }
-
-        public void visitVarDef(JCTree.JCVariableDecl tree) {
-            super.visitVarDef(tree);
-        }
-
-        public void visitAnnotation(JCTree.JCAnnotation tree) {
-            super.visitAnnotation(tree);
-            annotationSet.add(tree.type.tsym.toString());
-        }
-    }
-
-    Set<String> computeAnnotationSet(Collection<ClassSymbol> classSymbols) {
-        Set<String> annotationSet = new HashSet<String>();
-
-        for(ClassSymbol classSymbol: classSymbols) {
-            computeAnnotationSet(classSymbol, annotationSet);
-        }
-        return annotationSet;
-    }
-
-    void computeAnnotationSet(Symbol symbol, Set<String> annotationSet) {
-        if (symbol != null ) {
-            if (symbol.getAnnotationMirrors() != null)
-                for(Attribute.Compound compound: symbol.getAnnotationMirrors())
-                    annotationSet.add(compound.type.tsym.toString()); // should fullName be used instead of toString?
-
-            if (symbol instanceof Symbol.MethodSymbol) // add parameter annotations
-                for(Symbol param: ((MethodSymbol) symbol).params())
-                    computeAnnotationSet(param, annotationSet);
-
-            if (symbol.members() != null) {
-                for(Scope.Entry e = symbol.members().elems; e != null; e = e.sibling)
-                    computeAnnotationSet(e.sym, annotationSet);
-            }
-        }
-    }
-
-    public void main(com.sun.tools.javac.util.List<JCTree.JCCompilationUnit> treeList,
-                     ListBuffer<ClassSymbol> classes,
-                     Map<String, String> origOptions,
-                     ClassLoader aptCL,
-                     AnnotationProcessorFactory providedFactory,
-                     java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories) {
-        Bark bark = Bark.instance(context);
-        java.io.PrintWriter out = bark.warnWriter;
-        Options options = Options.instance(context);
-
-        Collection<TypeDeclaration> spectypedecls =     new LinkedHashSet<TypeDeclaration>();
-        Collection<TypeDeclaration> typedecls =         new LinkedHashSet<TypeDeclaration>();
-        Set<String> unmatchedAnnotations =              new LinkedHashSet<String>();
-        Set<AnnotationTypeDeclaration> emptyATDS =      Collections.emptySet();
-        Set<Class<? extends AnnotationProcessorFactory> > currentRoundFactories =
-            new LinkedHashSet<Class<? extends AnnotationProcessorFactory> >();
-
-        // Determine what annotations are present on the input source
-        // files, create collections of specified type declarations,
-        // and type declarations.
-        AptTreeScanner ats = new AptTreeScanner();
-        for(JCTree t: treeList) {
-            t.accept(ats);
-        }
-
-        // Turn collection of ClassSymbols into Collection of apt decls
-        for (ClassSymbol cs : ats.specifiedDeclCollection) {
-            TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
-            spectypedecls.add(decl);
-        }
-
-        for (ClassSymbol cs : ats.declCollection) {
-            TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
-            typedecls.add(decl);
-        }
-
-        unmatchedAnnotations.addAll(ats.getAnnotationSet());
-
-        // Process input class files
-        for(ClassSymbol cs : classes) {
-            TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(cs);
-            // System.out.println("Adding a class to spectypedecls");
-            spectypedecls.add(decl);
-            typedecls.add(decl);
-            computeAnnotationSet(cs, unmatchedAnnotations);
-        }
-
-        if (options.get("-XListAnnotationTypes") != null) {
-            out.println("Set of annotations found:" +
-                        (new TreeSet<String>(unmatchedAnnotations)).toString());
-        }
-
-        AnnotationProcessorEnvironmentImpl trivAPE =
-            new AnnotationProcessorEnvironmentImpl(spectypedecls, typedecls, origOptions, context);
-
-        if (options.get("-XListDeclarations") != null) {
-            out.println("Set of Specified Declarations:" +
-                        spectypedecls);
-
-            out.println("Set of Included Declarations: " +
-                           typedecls);
-        }
-
-        if (options.get("-print") != null) {
-            if (spectypedecls.size() == 0 )
-                throw new UsageMessageNeededException();
-
-            // Run the printing processor
-            AnnotationProcessor proc = (new BootstrapAPF()).getProcessorFor(new HashSet<AnnotationTypeDeclaration>(),
-                                                                            trivAPE);
-            proc.process();
-        } else {
-            // Discovery process
-
-            // List of annotation processory factory instances
-            java.util.Iterator<AnnotationProcessorFactory> providers = null;
-            {
-                /*
-                 * If a factory is provided by the user, the
-                 * "-factory" and "-factorypath" options are not used.
-                 *
-                 * Otherwise, if the "-factory" option is used, search
-                 * the appropriate path for the named class.
-                 * Otherwise, use sun.misc.Service to implement the
-                 * default discovery policy.
-                 */
-
-                java.util.List<AnnotationProcessorFactory> list =
-                    new LinkedList<AnnotationProcessorFactory>();
-                String factoryName = options.get("-factory");
-
-                if (providedFactory != null) {
-                    list.add(providedFactory);
-                    providers = list.iterator();
-                } else if (factoryName != null) {
-                    try {
-                        AnnotationProcessorFactory factory =
-                            (AnnotationProcessorFactory) (aptCL.loadClass(factoryName).newInstance());
-                        list.add(factory);
-                    } catch (ClassNotFoundException cnfe) {
-                        bark.aptWarning("FactoryNotFound", factoryName);
-                    } catch (ClassCastException cce) {
-                        bark.aptWarning("FactoryWrongType", factoryName);
-                    } catch (Exception e ) {
-                        bark.aptWarning("FactoryCantInstantiate", factoryName);
-                    } catch(Throwable t) {
-                        throw new AnnotationProcessingError(t);
-                    }
-
-                    providers = list.iterator();
-                } else {
-                    @SuppressWarnings("unchecked")
-                    Iterator<AnnotationProcessorFactory> iter =
-                            sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL);
-                    providers = iter;
-
-                }
-            }
-
-            java.util.Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> factoryToAnnotation =
-                new LinkedHashMap<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>>();
-
-            if (!providers.hasNext() && productiveFactories.size() == 0) {
-                if (unmatchedAnnotations.size() > 0)
-                    bark.aptWarning("NoAnnotationProcessors");
-                if (spectypedecls.size() == 0)
-                    throw new UsageMessageNeededException();
-                return; // no processors; nothing else to do
-            } else {
-                // If there are no annotations, still give
-                // processors that match everything a chance to
-                // run.
-
-                if(unmatchedAnnotations.size() == 0)
-                    unmatchedAnnotations.add("");
-
-                Set<String> emptyStringSet = new HashSet<String>();
-                emptyStringSet.add("");
-                emptyStringSet = Collections.unmodifiableSet(emptyStringSet);
-
-                while (providers.hasNext() ) {
-                    Object provider = providers.next();
-                    try {
-                        Set<String> matchedStrings = new HashSet<String>();
-
-                        AnnotationProcessorFactory apf = (AnnotationProcessorFactory) provider;
-                        Collection<String> supportedTypes = apf.supportedAnnotationTypes();
-
-                        Collection<Pattern> supportedTypePatterns = new LinkedList<Pattern>();
-                        for(String s: supportedTypes)
-                            supportedTypePatterns.add(importStringToPattern(s));
-
-                        for(String s: unmatchedAnnotations) {
-                            for(Pattern p: supportedTypePatterns) {
-                                if (p.matcher(s).matches()) {
-                                    matchedStrings.add(s);
-                                    break;
-                                }
-                            }
-                        }
-
-                        unmatchedAnnotations.removeAll(matchedStrings);
-
-                        if (options.get("-XPrintFactoryInfo") != null) {
-                            out.println("Factory " + apf.getClass().getName() +
-                                        " matches " +
-                                        ((matchedStrings.size() == 0)?
-                                         "nothing.": matchedStrings));
-                        }
-
-                        if (matchedStrings.size() > 0) {
-                            // convert annotation names to annotation
-                            // type decls
-                            Set<AnnotationTypeDeclaration> atds = new HashSet<AnnotationTypeDeclaration>();
-
-                            // If a "*" processor is called on the
-                            // empty string, pass in an empty set of
-                            // annotation type declarations.
-                            if (!matchedStrings.equals(emptyStringSet)) {
-                                for(String s: matchedStrings) {
-                                    TypeDeclaration decl = aptenv.declMaker.getTypeDeclaration(s);
-                                    AnnotationTypeDeclaration annotdecl;
-                                    if (decl == null) {
-                                        bark.aptError("DeclarationCreation", s);
-                                    } else {
-                                        try {
-                                            annotdecl = (AnnotationTypeDeclaration)decl;
-                                            atds.add(annotdecl);
-
-                                        } catch (ClassCastException cce) {
-                                            bark.aptError("BadDeclaration", s);
-                                        }
-                                    }
-                                }
-                            }
-
-                            currentRoundFactories.add(apf.getClass());
-                            productiveFactories.add(apf.getClass());
-                            factoryToAnnotation.put(apf, atds);
-                        } else if (productiveFactories.contains(apf.getClass())) {
-                            // If a factory provided a processor in a
-                            // previous round but doesn't match any
-                            // annotations this round, call it with an
-                            // empty set of declarations.
-                            currentRoundFactories.add(apf.getClass());
-                            factoryToAnnotation.put(apf, emptyATDS );
-                        }
-
-                        if (unmatchedAnnotations.size() == 0)
-                            break;
-
-                    } catch (ClassCastException cce) {
-                        bark.aptWarning("BadFactory", cce);
-                    }
-                }
-
-                unmatchedAnnotations.remove("");
-            }
-
-            // If the set difference of productiveFactories and
-            // currentRoundFactories is non-empty, call the remaining
-            // productive factories with an empty set of declarations.
-            {
-                java.util.Set<Class<? extends AnnotationProcessorFactory> > neglectedFactories =
-                    new LinkedHashSet<Class<? extends AnnotationProcessorFactory>>(productiveFactories);
-                neglectedFactories.removeAll(currentRoundFactories);
-                for(Class<? extends AnnotationProcessorFactory> working : neglectedFactories) {
-                    try {
-                        AnnotationProcessorFactory factory = working.newInstance();
-                        factoryToAnnotation.put(factory, emptyATDS);
-                    } catch (Exception e ) {
-                        bark.aptWarning("FactoryCantInstantiate", working.getName());
-                    } catch(Throwable t) {
-                        throw new AnnotationProcessingError(t);
-                    }
-                }
-            }
-
-            if (unmatchedAnnotations.size() > 0)
-                bark.aptWarning("AnnotationsWithoutProcessors", unmatchedAnnotations);
-
-            Set<AnnotationProcessor> processors = new LinkedHashSet<AnnotationProcessor>();
-
-            // If there were no source files AND no factory matching "*",
-            // make sure the usage message is printed
-            if (spectypedecls.size() == 0 &&
-                factoryToAnnotation.keySet().size() == 0 )
-                throw new UsageMessageNeededException();
-
-            try {
-                for(Map.Entry<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> entry :
-                        factoryToAnnotation.entrySet()) {
-                    AnnotationProcessorFactory  apFactory = entry.getKey();
-                    AnnotationProcessor processor = apFactory.getProcessorFor(entry.getValue(),
-                                                                              trivAPE);
-                    if (processor != null)
-                        processors.add(processor);
-                    else
-                        bark.aptWarning("NullProcessor", apFactory.getClass().getName());
-                }
-            } catch(Throwable t) {
-                throw new AnnotationProcessingError(t);
-            }
-
-            LinkedList<AnnotationProcessor> temp = new LinkedList<AnnotationProcessor>();
-            temp.addAll(processors);
-
-            AnnotationProcessor proc = AnnotationProcessors.getCompositeAnnotationProcessor(temp);
-
-            try {
-                proc.process();
-            } catch (Throwable t) {
-                throw new AnnotationProcessingError(t);
-            }
-
-            // Invoke listener callback mechanism
-            trivAPE.roundComplete();
-
-            FilerImpl filerimpl = (FilerImpl)trivAPE.getFiler();
-            genSourceFileNames = filerimpl.getSourceFileNames();
-            genClassFileNames = filerimpl.getClassFileNames();
-            filerimpl.flush(); // Make sure new files are written out
-        }
-    }
-
-    /**
-     * Convert import-style string to regex matching that string.  If
-     * the string is a valid import-style string, return a regex that
-     * won't match anything.
-     */
-    Pattern importStringToPattern(String s) {
-        if (com.sun.tools.javac.processing.JavacProcessingEnvironment.isValidImportString(s)) {
-            return com.sun.tools.javac.processing.JavacProcessingEnvironment.validImportStringToPattern(s);
-        } else {
-            Bark bark = Bark.instance(context);
-            bark.aptWarning("MalformedSupportedString", s);
-            return com.sun.tools.javac.processing.JavacProcessingEnvironment.noMatches;
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java b/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java
deleted file mode 100644
index 5cb6cc1..0000000
--- a/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.comp;
-
-import java.util.*;
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
- at SuppressWarnings("deprecation")
-public class BootstrapAPF implements AnnotationProcessorFactory {
-
-    static final Collection<String> supportedOptions =
-        Collections.unmodifiableSet(new HashSet<String>());
-
-    static Collection<String> supportedAnnotations;
-    static {
-        Collection<String> c = new HashSet<String>();
-        c.add("*");
-        supportedAnnotations = Collections.unmodifiableCollection(c);
-    }
-
-    public BootstrapAPF(){}
-
-    public Collection<String> supportedOptions() {
-        return BootstrapAPF.supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new PrintAP(env);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/comp/PrintAP.java b/src/share/classes/com/sun/tools/apt/comp/PrintAP.java
deleted file mode 100644
index b5f663e..0000000
--- a/src/share/classes/com/sun/tools/apt/comp/PrintAP.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, 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.apt.comp;
-
-import com.sun.mirror.declaration.*;
-import static com.sun.mirror.declaration.Modifier.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.apt.*;
-
-import java.util.*;
-import com.sun.mirror.util.*;
-
-/**
- * Class used to implement "-print" option.
- */
- at SuppressWarnings("deprecation")
-public class PrintAP implements AnnotationProcessor {
-
-
-    static class PrintingVisitors {
-        int indentation = 0; // Indentation level;
-        AnnotationProcessorEnvironment env;
-        Messager out;
-        Declaration java_lang_Object;
-        Declaration java_lang_annotation_Annotation;
-
-        static Set<Modifier> EMPTY_ELIDES = Collections.emptySet();
-        static Set<Modifier> INTERFACE_ELIDES = EnumSet.of(ABSTRACT);
-        static Set<Modifier> ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT);
-        static Set<Modifier> INTERFACE_MEMBER_ELIDES = EnumSet.of(ABSTRACT, PUBLIC, STATIC, FINAL);
-
-        PrintingVisitors(AnnotationProcessorEnvironment env) {
-            this.env = env;
-            this.out = env.getMessager();
-            this.java_lang_Object = env.getTypeDeclaration("java.lang.Object");
-            this.java_lang_annotation_Annotation = env.getTypeDeclaration("java.lang.annotation.Annotation");
-        }
-
-
-        static String [] spaces = {
-            "",
-            "  ",
-            "    ",
-            "      ",
-            "        ",
-            "          ",
-            "            ",
-            "              ",
-            "                ",
-            "                  ",
-            "                    "
-        };
-
-
-        String indent(){
-            int indentation = this.indentation;
-            if (indentation < 0)
-                return "";
-            else if (indentation <= 10)
-                return spaces[indentation];
-            else {
-                StringBuilder sb = new StringBuilder();
-                while (indentation > 10) {
-                    sb.append(spaces[indentation]);
-                    indentation -= 10;
-                }
-                sb.append(spaces[indentation]);
-            return sb.toString();
-            }
-        }
-
-
-        class PrePrinting extends SimpleDeclarationVisitor {
-            Map<EnumDeclaration, Integer> enumCardinality  = new HashMap<EnumDeclaration, Integer>();
-            Map<EnumDeclaration, Integer> enumConstVisited = new HashMap<EnumDeclaration, Integer>();
-
-            PrePrinting(){}
-
-            public void visitClassDeclaration(ClassDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d, EMPTY_ELIDES);
-                System.out.print("class " + d.getSimpleName());
-                printFormalTypeParameters(d);
-
-                // Elide "extends Object"
-                ClassType Super = d.getSuperclass();
-                if (Super != null && !java_lang_Object.equals(Super.getDeclaration()) )
-                    System.out.print(" extends " + Super.toString());
-
-                printInterfaces(d);
-
-                System.out.println(" {");
-
-                PrintingVisitors.this.indentation++;
-            }
-
-            public void visitEnumDeclaration(EnumDeclaration d) {
-                enumCardinality.put(d, d.getEnumConstants().size());
-                enumConstVisited.put(d, 1);
-
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d, ENUM_ELIDES);
-
-                System.out.print("enum " + d.getSimpleName());
-                printFormalTypeParameters(d);
-                printInterfaces(d);
-
-                System.out.println(" {");
-
-                PrintingVisitors.this.indentation++;
-            }
-
-
-            public void visitInterfaceDeclaration(InterfaceDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d, INTERFACE_ELIDES);
-                System.out.print("interface " + d.getSimpleName());
-
-                printFormalTypeParameters(d);
-                printInterfaces(d);
-
-                System.out.println(" {");
-
-                PrintingVisitors.this.indentation++;
-            }
-
-            public void visitAnnotationTypeDeclaration(AnnotationTypeDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d, INTERFACE_ELIDES);
-                System.out.print("@interface " + d.getSimpleName());
-                printFormalTypeParameters(d);
-
-                printInterfaces(d);
-
-                System.out.println(" {");
-
-                PrintingVisitors.this.indentation++;
-            }
-
-            public void visitFieldDeclaration(FieldDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d,
-                               (d.getDeclaringType() instanceof InterfaceDeclaration)?
-                               INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES);
-                System.out.print(d.getType().toString() + " " +
-                                   d.getSimpleName() );
-                String constantExpr = d.getConstantExpression();
-                if (constantExpr != null) {
-                    System.out.print(" = " + constantExpr);
-                }
-                System.out.println(";" );
-            }
-
-            public void visitEnumConstantDeclaration(EnumConstantDeclaration d) {
-                EnumDeclaration ed = d.getDeclaringType();
-                int enumCard = enumCardinality.get(ed);
-                int enumVisit = enumConstVisited.get(ed);
-
-                System.out.println();
-                printDocComment(d);
-                System.out.print(PrintingVisitors.this.indent());
-                System.out.print(d.getSimpleName() );
-                System.out.println((enumVisit < enumCard )? ",":";" );
-
-                enumConstVisited.put(ed, enumVisit+1);
-            }
-
-            public void visitMethodDeclaration(MethodDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d,
-                               (d.getDeclaringType() instanceof InterfaceDeclaration)?
-                               INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES);
-                printFormalTypeParameters(d);
-                System.out.print(d.getReturnType().toString() + " ");
-                System.out.print(d.getSimpleName() + "(");
-                printParameters(d);
-                System.out.print(")");
-                printThrows(d);
-                System.out.println(";");
-            }
-
-            public void visitConstructorDeclaration(ConstructorDeclaration d) {
-                System.out.println();
-                printDocComment(d);
-                printModifiers(d, EMPTY_ELIDES);
-                printFormalTypeParameters(d);
-                System.out.print(d.getSimpleName() + "(");
-                printParameters(d);
-                System.out.print(")");
-                printThrows(d);
-                System.out.println(";");
-            }
-
-
-        }
-
-        class PostPrinting extends SimpleDeclarationVisitor {
-            PostPrinting(){}
-
-            public void visitTypeDeclaration(TypeDeclaration d) {
-                PrintingVisitors.this.indentation--;
-
-                System.out.print(PrintingVisitors.this.indent());
-                System.out.println("}");
-            }
-        }
-
-        private void printAnnotations(Collection<AnnotationMirror> annots) {
-
-            for(AnnotationMirror annot: annots) {
-                System.out.print(this.indent());
-                System.out.print(annot.toString());
-                System.out.println();
-            }
-        }
-
-        private void printAnnotationsInline(Collection<AnnotationMirror> annots) {
-
-            for(AnnotationMirror annot: annots) {
-                System.out.print(annot);
-                System.out.print(" ");
-            }
-        }
-
-
-        private void printParameters(ExecutableDeclaration ex) {
-
-            Collection<ParameterDeclaration> parameters = ex.getParameters();
-            int size = parameters.size();
-
-            switch (size) {
-            case 0:
-                break;
-
-            case 1:
-                for(ParameterDeclaration parameter: parameters) {
-                    printModifiers(parameter, EMPTY_ELIDES);
-
-                    if (ex.isVarArgs() ) {
-                        System.out.print(((ArrayType)parameter.getType()).getComponentType() );
-                        System.out.print("...");
-                    } else
-                        System.out.print(parameter.getType());
-                    System.out.print(" " + parameter.getSimpleName());
-                }
-                break;
-
-            default:
-                {
-                    int i = 1;
-                    for(ParameterDeclaration parameter: parameters) {
-                        if (i == 2)
-                            PrintingVisitors.this.indentation++;
-
-                        if (i > 1)
-                            System.out.print(PrintingVisitors.this.indent());
-
-                        printModifiers(parameter, EMPTY_ELIDES);
-
-                        if (i == size && ex.isVarArgs() ) {
-                            System.out.print(((ArrayType)parameter.getType()).getComponentType() );
-                            System.out.print("...");
-                        } else
-                            System.out.print(parameter.getType());
-                        System.out.print(" " + parameter.getSimpleName());
-
-                        if (i < size)
-                            System.out.println(",");
-
-                        i++;
-                    }
-
-                    if (parameters.size() >= 2)
-                        PrintingVisitors.this.indentation--;
-                }
-                break;
-            }
-        }
-
-        private void printDocComment(Declaration d) {
-            String docComment = d.getDocComment();
-
-            if (docComment != null) {
-                // Break comment into lines
-                java.util.StringTokenizer st = new StringTokenizer(docComment,
-                                                                  "\n\r");
-                System.out.print(PrintingVisitors.this.indent());
-                System.out.println("/**");
-
-                while(st.hasMoreTokens()) {
-                    System.out.print(PrintingVisitors.this.indent());
-                    System.out.print(" *");
-                    System.out.println(st.nextToken());
-                }
-
-                System.out.print(PrintingVisitors.this.indent());
-                System.out.println(" */");
-            }
-        }
-
-        private void printModifiers(Declaration d, Collection<Modifier> elides) {
-            printAnnotations(d.getAnnotationMirrors());
-
-            System.out.print(PrintingVisitors.this.indent());
-
-            for(Modifier m: adjustModifiers(d.getModifiers(), elides) ){
-                System.out.print(m.toString() + " ");
-            }
-        }
-
-        private void printModifiers(ParameterDeclaration d, Collection<Modifier> elides) {
-            printAnnotationsInline(d.getAnnotationMirrors());
-
-            for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) {
-                System.out.print(m.toString() + " ");
-            }
-        }
-
-        private Collection<Modifier> adjustModifiers(Collection<Modifier> mods,
-                                                     Collection<Modifier> elides) {
-            if (elides.isEmpty())
-                return mods;
-            else {
-                Collection<Modifier> newMods = new LinkedHashSet<Modifier>();
-                newMods.addAll(mods);
-                newMods.removeAll(elides);
-                return newMods;
-            }
-        }
-
-        private void printFormalTypeParameters(ExecutableDeclaration e) {
-            printFormalTypeParameterSet(e.getFormalTypeParameters(), true);
-        }
-
-        private void printFormalTypeParameters(TypeDeclaration d) {
-            printFormalTypeParameterSet(d.getFormalTypeParameters(), false);
-        }
-
-        private void printFormalTypeParameterSet(Collection<TypeParameterDeclaration> typeParams, boolean pad) {
-            if (typeParams.size() != 0) {
-                System.out.print("<");
-
-                boolean first = true;
-                for(TypeParameterDeclaration tpd: typeParams) {
-                    if (!first)
-                        System.out.print(", ");
-                    System.out.print(tpd.toString());
-                }
-
-                System.out.print(">");
-                if (pad)
-                    System.out.print(" ");
-
-            }
-        }
-
-        private void printInterfaceSet(Collection<InterfaceType> interfaces,
-                                       boolean classNotInterface) {
-            if (interfaces.size() != 0) {
-                System.out.print((classNotInterface?" implements" : " extends"));
-
-                boolean first = true;
-                for(InterfaceType interType: interfaces) {
-                    if (!first)
-                        System.out.print(",");
-                    System.out.print(" ");
-                    System.out.print(interType.toString());
-                    first = false;
-                }
-            }
-        }
-
-        private void printInterfaces(TypeDeclaration d) {
-            printInterfaceSet(d.getSuperinterfaces(), d instanceof ClassDeclaration);
-        }
-
-        private void printInterfaces(AnnotationTypeDeclaration d) {
-            Collection<InterfaceType> interfaces = new HashSet<InterfaceType>(d.getSuperinterfaces());
-
-            for(InterfaceType interType: interfaces) {
-                if (java_lang_annotation_Annotation.equals(interType.getDeclaration()) )
-                    interfaces.remove(interType);
-            }
-
-            printInterfaceSet(interfaces, d instanceof ClassDeclaration);
-        }
-
-        private void printThrows(ExecutableDeclaration d) {
-            Collection<ReferenceType> thrownTypes = d.getThrownTypes();
-            final int size = thrownTypes.size();
-            if (size != 0) {
-                System.out.print(" throws");
-
-                int i = 1;
-                for(ReferenceType thrownType: thrownTypes) {
-                    if (i == 1) {
-                        System.out.print(" ");
-                    }
-
-                    if (i == 2)
-                        PrintingVisitors.this.indentation++;
-
-                    if (i >= 2)
-                        System.out.print(PrintingVisitors.this.indent());
-
-                    System.out.print(thrownType.toString());
-
-
-                    if (i != size) {
-                        System.out.println(", ");
-                    }
-                    i++;
-                }
-
-                if (size >= 2)
-                    PrintingVisitors.this.indentation--;
-            }
-        }
-
-        DeclarationVisitor getPrintingVisitor() {
-            return DeclarationVisitors.getSourceOrderDeclarationScanner(new PrePrinting(),
-                                                                        new PostPrinting());
-        }
-    }
-
-    AnnotationProcessorEnvironment env;
-    PrintAP(AnnotationProcessorEnvironment env) {
-        this.env = env;
-    }
-
-
-    public void process() {
-        Collection<TypeDeclaration> typedecls = env.getSpecifiedTypeDeclarations();
-
-        for (TypeDeclaration td: typedecls)
-            td.accept((new PrintingVisitors(env)).getPrintingVisitor());
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java b/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java
deleted file mode 100644
index 9eb9f31..0000000
--- a/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2004, 2009, 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.apt.comp;
-
-
-public class UsageMessageNeededException extends RuntimeException {
-    private static final long serialVersionUID = -3265159608992825840L;
-}
diff --git a/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java b/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java
deleted file mode 100644
index 89658e2..0000000
--- a/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, 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.apt.main;
-
-import java.io.*;
-import java.util.Map;
-
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.jvm.*;
-
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
-import com.sun.tools.apt.comp.*;
-import com.sun.tools.apt.util.Bark;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.tools.javac.parser.DocCommentScanner;
-
-/**
- *  <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>
- */
- at SuppressWarnings("deprecation")
-public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
-    /** The context key for the compiler. */
-    protected static final Context.Key<AptJavaCompiler> compilerKey =
-        new Context.Key<AptJavaCompiler>();
-
-    /** Get the JavaCompiler instance for this context. */
-    public static AptJavaCompiler instance(Context context) {
-        AptJavaCompiler instance = context.get(compilerKey);
-        if (instance == null)
-            instance = new AptJavaCompiler(context);
-        return instance;
-    }
-
-
-    java.util.Set<String> genSourceFileNames;
-    java.util.Set<String> genClassFileNames;
-
-    public java.util.Set<String> getSourceFileNames() {
-        return genSourceFileNames;
-    }
-
-    /** List of names of generated class files.
-     */
-    public java.util.Set<String> getClassFileNames() {
-        return genClassFileNames;
-    }
-
-    java.util.Set<java.io.File> aggregateGenFiles = java.util.Collections.emptySet();
-
-    public java.util.Set<java.io.File> getAggregateGenFiles() {
-        return aggregateGenFiles;
-    }
-
-    /** The bark to be used for error reporting.
-     */
-    Bark bark;
-
-    /** The log to be used for error reporting.
-     */
-    Log log;
-
-    /** The annotation framework
-     */
-    Apt apt;
-
-    private static Context preRegister(Context context) {
-        Bark.preRegister(context);
-
-        if (context.get(JavaFileManager.class) == null)
-            JavacFileManager.preRegister(context);
-
-        return context;
-    }
-
-    /** Construct a new compiler from a shared context.
-     */
-    public AptJavaCompiler(Context context) {
-        super(preRegister(context));
-
-        context.put(compilerKey, this);
-        apt = Apt.instance(context);
-
-        ClassReader classReader = ClassReader.instance(context);
-        classReader.preferSource = true;
-
-        // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
-        // original identities, to remember the original intent.
-        log = Log.instance(context);
-        bark = Bark.instance(context);
-
-        Options options = Options.instance(context);
-        classOutput   = options.get("-retrofit")      == null;
-        nocompile     = options.get("-nocompile")     != null;
-        print         = options.get("-print")         != null;
-        classesAsDecls= options.get("-XclassesAsDecls") != null;
-
-        genSourceFileNames = new java.util.LinkedHashSet<String>();
-        genClassFileNames  = new java.util.LinkedHashSet<String>();
-
-        // this forces a copy of the line map to be kept in the tree,
-        // for use by com.sun.mirror.util.SourcePosition.
-        lineDebugInfo = true;
-    }
-
-    /* Switches:
-     */
-
-    /** Emit class files. This switch is always set, except for the first
-     *  phase of retrofitting, where signatures are parsed.
-     */
-    public boolean classOutput;
-
-    /** The internal printing annotation processor should be used.
-     */
-    public boolean print;
-
-    /** Compilation should not be done after annotation processing.
-     */
-    public boolean nocompile;
-
-    /** Are class files being treated as declarations
-     */
-    public boolean classesAsDecls;
-
-    /** Try to open input stream with given name.
-     *  Report an error if this fails.
-     *  @param filename   The file name of the input stream to be opened.
-     */
-    // PROVIDED FOR EXTREME BACKWARDS COMPATIBILITY
-    // There are some very obscure errors that can arise while translating
-    // the contents of a file from bytes to characters. In Tiger, these
-    // diagnostics were ignored. This method provides compatibility with
-    // that behavior. It would be better to honor those diagnostics, in which
-    // case, this method can be deleted.
-    @Override
-    public CharSequence readSource(JavaFileObject filename) {
-        try {
-            inputFiles.add(filename);
-            boolean prev = bark.setDiagnosticsIgnored(true);
-            try {
-                return filename.getCharContent(false);
-            }
-            finally {
-                bark.setDiagnosticsIgnored(prev);
-            }
-        } catch (IOException e) {
-            bark.error(Position.NOPOS, "cant.read.file", filename);
-            return null;
-        }
-    }
-
-    /** Parse contents of input stream.
-     *  @param filename     The name of the file from which input stream comes.
-     *  @param input        The input stream to be parsed.
-     */
-    // PROVIDED FOR BACKWARDS COMPATIBILITY
-    // In Tiger, diagnostics from the scanner and parser were ignored.
-    // This method provides compatibility with that behavior.
-    // It would be better to honor those diagnostics, in which
-    // case, this method can be deleted.
-    @Override
-    protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
-        boolean prev = bark.setDiagnosticsIgnored(true);
-        try {
-            return super.parse(filename, content);
-        }
-        finally {
-            bark.setDiagnosticsIgnored(prev);
-        }
-    }
-
-    @Override
-    protected boolean keepComments() {
-        return true;  // make doc comments available to mirror API impl.
-    }
-
-    /** Track when the JavaCompiler has been used to compile something. */
-    private boolean hasBeenUsed = false;
-
-    /** Main method: compile a list of files, return all compiled classes
-     *  @param filenames     The names of all files to be compiled.
-     */
-    public List<ClassSymbol> compile(List<String> filenames,
-                                     Map<String, String> origOptions,
-                                     ClassLoader aptCL,
-                                     AnnotationProcessorFactory providedFactory,
-                                     java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
-                                     java.util.Set<java.io.File> aggregateGenFiles)
-        throws Throwable {
-        // as a JavaCompiler can only be used once, throw an exception if
-        // it has been used before.
-        assert !hasBeenUsed : "attempt to reuse JavaCompiler";
-        hasBeenUsed = true;
-
-        this.aggregateGenFiles = aggregateGenFiles;
-
-        long msec = System.currentTimeMillis();
-
-        ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
-        try {
-            JavacFileManager fm = (JavacFileManager)fileManager;
-            //parse all files
-            ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
-            for (List<String> l = filenames; l.nonEmpty(); l = l.tail) {
-                if (classesAsDecls) {
-                    if (! l.head.endsWith(".java") ) { // process as class file
-                        ClassSymbol cs = reader.enterClass(names.fromString(l.head));
-                        try {
-                            cs.complete();
-                        } catch(Symbol.CompletionFailure cf) {
-                            bark.aptError("CantFindClass", l);
-                            continue;
-                        }
-
-                        classes.append(cs); // add to list of classes
-                        continue;
-                    }
-                }
-                JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next();
-                trees.append(parse(fo));
-            }
-
-            //enter symbols for all files
-            List<JCCompilationUnit> roots = trees.toList();
-
-            if (errorCount() == 0) {
-                boolean prev = bark.setDiagnosticsIgnored(true);
-                try {
-                    enter.main(roots);
-                }
-                finally {
-                    bark.setDiagnosticsIgnored(prev);
-                }
-            }
-
-            if (errorCount() == 0) {
-                apt.main(roots,
-                         classes,
-                         origOptions, aptCL,
-                         providedFactory,
-                         productiveFactories);
-                genSourceFileNames.addAll(apt.getSourceFileNames());
-                genClassFileNames.addAll(apt.getClassFileNames());
-            }
-
-        } catch (Abort ex) {
-        }
-
-        if (verbose)
-            log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
-
-        chk.reportDeferredDiagnostics();
-
-        printCount("error", errorCount());
-        printCount("warn", warningCount());
-
-        return classes.toList();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/main/CommandLine.java b/src/share/classes/com/sun/tools/apt/main/CommandLine.java
deleted file mode 100644
index 5306830..0000000
--- a/src/share/classes/com/sun/tools/apt/main/CommandLine.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.main;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.FileReader;
-import java.io.BufferedReader;
-import java.io.StreamTokenizer;
-import com.sun.tools.javac.util.ListBuffer;
-
-/**
- * Various utility methods for processing Java tool command line arguments.
- *
- *  <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 CommandLine {
-    /**
-     * Process Win32-style command files for the specified command line
-     * arguments and return the resulting arguments. A command file argument
-     * is of the form '@file' where 'file' is the name of the file whose
-     * contents are to be parsed for additional arguments. The contents of
-     * the command file are parsed using StreamTokenizer and the original
-     * '@file' argument replaced with the resulting tokens. Recursive command
-     * files are not supported. The '@' character itself can be quoted with
-     * the sequence '@@'.
-     */
-    public static String[] parse(String[] args)
-        throws IOException
-    {
-        ListBuffer<String> newArgs = new ListBuffer<String>();
-        for (int i = 0; i < args.length; i++) {
-            String arg = args[i];
-            if (arg.length() > 1 && arg.charAt(0) == '@') {
-                arg = arg.substring(1);
-                if (arg.charAt(0) == '@') {
-                    newArgs.append(arg);
-                } else {
-                    loadCmdFile(arg, newArgs);
-                }
-            } else {
-                newArgs.append(arg);
-            }
-        }
-        return newArgs.toList().toArray(new String[newArgs.length()]);
-    }
-
-    private static void loadCmdFile(String name, ListBuffer<String> args)
-        throws IOException
-    {
-        Reader r = new BufferedReader(new FileReader(name));
-        StreamTokenizer st = new StreamTokenizer(r);
-        st.resetSyntax();
-        st.wordChars(' ', 255);
-        st.whitespaceChars(0, ' ');
-        st.commentChar('#');
-        st.quoteChar('"');
-        st.quoteChar('\'');
-        while (st.nextToken() != StreamTokenizer.TT_EOF) {
-            args.append(st.sval);
-        }
-        r.close();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/main/Main.java b/src/share/classes/com/sun/tools/apt/main/Main.java
deleted file mode 100644
index 5c2cfcc..0000000
--- a/src/share/classes/com/sun/tools/apt/main/Main.java
+++ /dev/null
@@ -1,1281 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.main;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
-import java.util.StringTokenizer;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-
-import java.net.URLClassLoader;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import javax.tools.JavaFileManager;
-import javax.tools.StandardLocation;
-
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.util.*;
-
-import com.sun.tools.apt.comp.AnnotationProcessingError;
-import com.sun.tools.apt.comp.UsageMessageNeededException;
-import com.sun.tools.apt.util.Bark;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-
-import static com.sun.tools.javac.file.Paths.pathToURLs;
-
-/** This class provides a commandline interface to the apt build-time
- *  tool.
- *
- *  <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>
- */
- at SuppressWarnings("deprecation")
-public class Main {
-
-    /** For testing: enter any options you want to be set implicitly
-     *  here.
-     */
-    static String[] forcedOpts = {
-        // Preserve parameter names from class files if the class was
-        // compiled with debug enabled
-        "-XDsave-parameter-names"
-    };
-
-    /** The name of the compiler, for use in diagnostics.
-     */
-    String ownName;
-
-    /** The writer to use for diagnostic output.
-     */
-    PrintWriter out;
-
-
-    /** Instantiated factory to use in lieu of discovery process.
-     */
-    AnnotationProcessorFactory providedFactory = null;
-
-    /** Map representing original command-line arguments.
-     */
-    Map<String,String> origOptions = new HashMap<String, String>();
-
-    /** Classloader to use for finding factories.
-     */
-    ClassLoader aptCL = null;
-
-    /** Result codes.
-     */
-    static final int
-        EXIT_OK = 0,        // Compilation completed with no errors.
-        EXIT_ERROR = 1,     // Completed but reported errors.
-        EXIT_CMDERR = 2,    // Bad command-line arguments
-        EXIT_SYSERR = 3,    // System error or resource exhaustion.
-        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
-
-    /** This class represents an option recognized by the main program
-     */
-    private class Option {
-        /** Whether or not the option is used only aptOnly.
-         */
-        boolean aptOnly = false;
-
-        /** Option string.
-         */
-        String name;
-
-        /** Documentation key for arguments.
-         */
-        String argsNameKey;
-
-        /** Documentation key for description.
-         */
-        String descrKey;
-
-        /** Suffix option (-foo=bar or -foo:bar)
-         */
-        boolean hasSuffix;
-
-        Option(String name, String argsNameKey, String descrKey) {
-            this.name = name;
-            this.argsNameKey = argsNameKey;
-            this.descrKey = descrKey;
-            char lastChar = name.charAt(name.length()-1);
-            hasSuffix = lastChar == ':' || lastChar == '=';
-        }
-        Option(String name, String descrKey) {
-            this(name, null, descrKey);
-        }
-
-        public String toString() {
-            return name;
-        }
-
-        /** Does this option take a (separate) operand?
-         */
-        boolean hasArg() {
-            return argsNameKey != null && !hasSuffix;
-        }
-
-        /** Does argument string match option pattern?
-         *  @param arg        The command line argument string.
-         */
-        boolean matches(String arg) {
-            return hasSuffix ? arg.startsWith(name) : arg.equals(name);
-        }
-
-        /** For javac-only options, print nothing.
-         */
-        void help() {
-        }
-
-        String helpSynopsis() {
-            return name +
-                (argsNameKey == null ? "" :
-                 ((hasSuffix ? "" : " ") +
-                  getLocalizedString(argsNameKey)));
-        }
-
-        /** Print a line of documentation describing this option, if non-standard.
-         */
-        void xhelp() {}
-
-        /** Process the option (with arg). Return true if error detected.
-         */
-        boolean process(String option, String arg) {
-            options.put(option, arg);
-            return false;
-        }
-
-        /** Process the option (without arg). Return true if error detected.
-         */
-        boolean process(String option) {
-            if (hasSuffix)
-                return process(name, option.substring(name.length()));
-            else
-                return process(option, option);
-        }
-    };
-
-    private class SharedOption extends Option {
-        SharedOption(String name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-        }
-
-        SharedOption(String name, String descrKey) {
-            super(name, descrKey);
-        }
-
-        void help() {
-            String s = "  " + helpSynopsis();
-            out.print(s);
-            for (int j = s.length(); j < 29; j++) out.print(" ");
-            Bark.printLines(out, getLocalizedString(descrKey));
-        }
-
-    }
-
-    private class AptOption extends Option {
-        AptOption(String name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-            aptOnly = true;
-        }
-
-        AptOption(String name, String descrKey) {
-            super(name, descrKey);
-            aptOnly = true;
-        }
-
-        /** Print a line of documentation describing this option, if standard.
-         */
-        void help() {
-            String s = "  " + helpSynopsis();
-            out.print(s);
-            for (int j = s.length(); j < 29; j++) out.print(" ");
-            Bark.printLines(out, getLocalizedString(descrKey));
-        }
-
-    }
-
-    /** A nonstandard or extended (-X) option
-     */
-    private class XOption extends Option {
-        XOption(String name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-        }
-        XOption(String name, String descrKey) {
-            this(name, null, descrKey);
-        }
-        void help() {}
-        void xhelp() {}
-    };
-
-    /** A nonstandard or extended (-X) option
-     */
-    private class AptXOption extends Option {
-        AptXOption(String name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-            aptOnly = true;
-        }
-        AptXOption(String name, String descrKey) {
-            this(name, null, descrKey);
-        }
-        void xhelp() {
-            String s = "  " + helpSynopsis();
-            out.print(s);
-            for (int j = s.length(); j < 29; j++) out.print(" ");
-            Log.printLines(out, getLocalizedString(descrKey));
-        }
-    };
-
-    /** A hidden (implementor) option
-     */
-    private class HiddenOption extends Option {
-        HiddenOption(String name) {
-            super(name, null, null);
-        }
-        HiddenOption(String name, String argsNameKey) {
-            super(name, argsNameKey, null);
-        }
-        void help() {}
-        void xhelp() {}
-    };
-
-    private class AptHiddenOption extends HiddenOption {
-        AptHiddenOption(String name) {
-            super(name);
-            aptOnly = true;
-        }
-        AptHiddenOption(String name, String argsNameKey) {
-            super(name, argsNameKey);
-            aptOnly = true;
-        }
-    }
-
-    private Option[] recognizedOptions = {
-        new Option("-g",                                        "opt.g"),
-        new Option("-g:none",                                   "opt.g.none") {
-            boolean process(String option) {
-                options.put("-g:", "none");
-                return false;
-            }
-        },
-
-        new Option("-g:{lines,vars,source}",                    "opt.g.lines.vars.source") {
-            boolean matches(String s) {
-                return s.startsWith("-g:");
-            }
-            boolean process(String option) {
-                String suboptions = option.substring(3);
-                options.put("-g:", suboptions);
-                // enter all the -g suboptions as "-g:suboption"
-                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
-                    String tok = t.nextToken();
-                    String opt = "-g:" + tok;
-                    options.put(opt, opt);
-                }
-                return false;
-            }
-        },
-
-        new XOption("-Xlint",                                   "opt.Xlint"),
-        new XOption("-Xlint:{"
-                    + "all,"
-                    + "cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides,"
-                    + "-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides,"
-                    + "none}",
-                                                                "opt.Xlint.suboptlist") {
-            boolean matches(String s) {
-                return s.startsWith("-Xlint:");
-            }
-            boolean process(String option) {
-                String suboptions = option.substring(7);
-                options.put("-Xlint:", suboptions);
-                // enter all the -Xlint suboptions as "-Xlint:suboption"
-                for (StringTokenizer t = new StringTokenizer(suboptions, ","); t.hasMoreTokens(); ) {
-                    String tok = t.nextToken();
-                    String opt = "-Xlint:" + tok;
-                    options.put(opt, opt);
-                }
-                return false;
-            }
-        },
-
-        new Option("-nowarn",                                   "opt.nowarn"),
-        new Option("-verbose",                                  "opt.verbose"),
-
-        // -deprecation is retained for command-line backward compatibility
-        new Option("-deprecation",                              "opt.deprecation") {
-                boolean process(String option) {
-                    options.put("-Xlint:deprecation", option);
-                    return false;
-                }
-            },
-
-        new SharedOption("-classpath",     "opt.arg.path",      "opt.classpath"),
-        new SharedOption("-cp",            "opt.arg.path",      "opt.classpath") {
-            boolean process(String option, String arg) {
-                return super.process("-classpath", arg);
-            }
-        },
-        new Option("-sourcepath",          "opt.arg.path",      "opt.sourcepath"),
-        new Option("-bootclasspath",       "opt.arg.path",      "opt.bootclasspath") {
-            boolean process(String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process(option, arg);
-            }
-        },
-        new XOption("-Xbootclasspath/p:",  "opt.arg.path", "opt.Xbootclasspath.p"),
-        new XOption("-Xbootclasspath/a:",  "opt.arg.path", "opt.Xbootclasspath.a"),
-        new XOption("-Xbootclasspath:",    "opt.arg.path", "opt.bootclasspath") {
-            boolean process(String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process("-bootclasspath", arg);
-            }
-        },
-        new Option("-extdirs",             "opt.arg.dirs",      "opt.extdirs"),
-        new XOption("-Djava.ext.dirs=",    "opt.arg.dirs",      "opt.extdirs") {
-            boolean process(String option, String arg) {
-                return super.process("-extdirs", arg);
-            }
-        },
-        new Option("-endorseddirs",        "opt.arg.dirs",      "opt.endorseddirs"),
-        new XOption("-Djava.endorsed.dirs=","opt.arg.dirs",     "opt.endorseddirs") {
-            boolean process(String option, String arg) {
-                return super.process("-endorseddirs", arg);
-            }
-        },
-        new Option("-proc:{none, only}",                        "opt.proc.none.only") {
-            public boolean matches(String s) {
-                return s.equals("-proc:none") || s.equals("-proc:only");
-            }
-        },
-        new Option("-processor",        "opt.arg.class",        "opt.processor"),
-        new Option("-processorpath",    "opt.arg.path",         "opt.processorpath"),
-
-        new SharedOption("-d",          "opt.arg.path", "opt.d"),
-        new SharedOption("-s",          "opt.arg.path", "opt.s"),
-        new Option("-encoding",         "opt.arg.encoding",     "opt.encoding"),
-        new SharedOption("-source",             "opt.arg.release",      "opt.source") {
-            boolean process(String option, String operand) {
-                Source source = Source.lookup(operand);
-                if (source == null) {
-                    error("err.invalid.source", operand);
-                    return true;
-                } else if (source.compareTo(Source.JDK1_5) > 0) {
-                    error("err.unsupported.source.version", operand);
-                    return true;
-                }
-                return super.process(option, operand);
-            }
-        },
-        new Option("-target",           "opt.arg.release",      "opt.target") {
-            boolean process(String option, String operand) {
-                Target target = Target.lookup(operand);
-                if (target == null) {
-                    error("err.invalid.target", operand);
-                    return true;
-                } else if (target.compareTo(Target.JDK1_5) > 0) {
-                    error("err.unsupported.target.version", operand);
-                    return true;
-                }
-                return super.process(option, operand);
-            }
-        },
-        new AptOption("-version",               "opt.version") {
-            boolean process(String option) {
-                Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
-                return super.process(option);
-            }
-        },
-        new HiddenOption("-fullversion"),
-        new AptOption("-help",                                  "opt.help") {
-            boolean process(String option) {
-                Main.this.help();
-                return super.process(option);
-            }
-        },
-        new SharedOption("-X",                                  "opt.X") {
-            boolean process(String option) {
-                Main.this.xhelp();
-                return super.process(option);
-            }
-        },
-
-        // This option exists only for the purpose of documenting itself.
-        // It's actually implemented by the launcher.
-        new AptOption("-J",             "opt.arg.flag",         "opt.J") {
-            String helpSynopsis() {
-                hasSuffix = true;
-                return super.helpSynopsis();
-            }
-            boolean process(String option) {
-                throw new AssertionError
-                    ("the -J flag should be caught by the launcher.");
-            }
-        },
-
-
-        new SharedOption("-A",          "opt.proc.flag",        "opt.A") {
-                String helpSynopsis() {
-                    hasSuffix = true;
-                    return super.helpSynopsis();
-                }
-
-                boolean matches(String arg) {
-                    return arg.startsWith("-A");
-                }
-
-                boolean hasArg() {
-                    return false;
-                }
-
-                boolean process(String option) {
-                    return process(option, option);
-                }
-            },
-
-        new AptOption("-nocompile",     "opt.nocompile"),
-
-        new AptOption("-print",         "opt.print"),
-
-        new AptOption("-factorypath", "opt.arg.path", "opt.factorypath"),
-
-        new AptOption("-factory",     "opt.arg.class", "opt.factory"),
-
-        new AptXOption("-XListAnnotationTypes", "opt.XListAnnotationTypes"),
-
-        new AptXOption("-XListDeclarations",    "opt.XListDeclarations"),
-
-        new AptXOption("-XPrintAptRounds",      "opt.XPrintAptRounds"),
-
-        new AptXOption("-XPrintFactoryInfo",    "opt.XPrintFactoryInfo"),
-
-        /*
-         * Option to treat both classes and source files as
-         * declarations that can be given on the command line and
-         * processed as the result of an apt round.
-         */
-        new AptXOption("-XclassesAsDecls", "opt.XClassesAsDecls"),
-
-        // new Option("-moreinfo",                                      "opt.moreinfo") {
-        new HiddenOption("-moreinfo") {
-            boolean process(String option) {
-                Type.moreInfo = true;
-                return super.process(option);
-            }
-        },
-
-        // treat warnings as errors
-        new HiddenOption("-Werror"),
-
-        // use complex inference from context in the position of a method call argument
-        new HiddenOption("-complexinference"),
-
-        // prompt after each error
-        // new Option("-prompt",                                        "opt.prompt"),
-        new HiddenOption("-prompt"),
-
-        // dump stack on error
-        new HiddenOption("-doe"),
-
-        // display warnings for generic unchecked and unsafe operations
-        new HiddenOption("-warnunchecked") {
-            boolean process(String option) {
-                options.put("-Xlint:unchecked", option);
-                return false;
-            }
-        },
-
-        new HiddenOption("-Xswitchcheck") {
-            boolean process(String option) {
-                options.put("-Xlint:switchcheck", option);
-                return false;
-            }
-        },
-
-        // generate trace output for subtyping operations
-        new HiddenOption("-debugsubtyping"),
-
-        new XOption("-Xmaxerrs",        "opt.arg.number",       "opt.maxerrs"),
-        new XOption("-Xmaxwarns",       "opt.arg.number",       "opt.maxwarns"),
-        new XOption("-Xstdout",         "opt.arg.file",         "opt.Xstdout") {
-            boolean process(String option, String arg) {
-                try {
-                    out = new PrintWriter(new FileWriter(arg), true);
-                } catch (java.io.IOException e) {
-                    error("err.error.writing.file", arg, e);
-                    return true;
-                }
-                return super.process(option, arg);
-            }
-        },
-
-        new XOption("-Xprint",                                  "opt.print"),
-
-        new XOption("-XprintRounds",                            "opt.printRounds"),
-
-        new XOption("-XprintProcessorInfo",                     "opt.printProcessorInfo"),
-
-
-        /* -O is a no-op, accepted for backward compatibility. */
-        new HiddenOption("-O"),
-
-        /* -Xjcov produces tables to support the code coverage tool jcov. */
-        new HiddenOption("-Xjcov"),
-
-        /* This is a back door to the compiler's option table.
-         * -Dx=y sets the option x to the value y.
-         * -Dx sets the option x to the value x.
-         */
-        new HiddenOption("-XD") {
-            String s;
-            boolean matches(String s) {
-                this.s = s;
-                return s.startsWith(name);
-            }
-            boolean process(String option) {
-                s = s.substring(name.length());
-                int eq = s.indexOf('=');
-                String key = (eq < 0) ? s : s.substring(0, eq);
-                String value = (eq < 0) ? s : s.substring(eq+1);
-                options.put(key, value);
-                return false;
-            }
-        },
-
-        new HiddenOption("sourcefile") {
-                String s;
-                boolean matches(String s) {
-                    this.s = s;
-                    return s.endsWith(".java") ||
-                        (options.get("-XclassesAsDecls") != null);
-                }
-                boolean process(String option) {
-                    if (s.endsWith(".java")) {
-                        if (!sourceFileNames.contains(s))
-                            sourceFileNames.add(s);
-                    } else if (options.get("-XclassesAsDecls") != null) {
-                        classFileNames.add(s);
-                    }
-                    return false;
-                }
-            },
-    };
-
-    /**
-     * Construct a compiler instance.
-     */
-    public Main(String name) {
-        this(name, new PrintWriter(System.err, true));
-    }
-
-    /**
-     * Construct a compiler instance.
-     */
-    public Main(String name, PrintWriter out) {
-        this.ownName = name;
-        this.out = out;
-    }
-
-    /** A table of all options that's passed to the JavaCompiler constructor.  */
-    private Options options = null;
-
-    /** The list of source files to process
-     */
-    java.util.List<String> sourceFileNames = new java.util.LinkedList<String>();
-
-    /** The list of class files to process
-     */
-    java.util.List<String> classFileNames = new java.util.LinkedList<String>();
-
-    /** List of top level names of generated source files from most recent apt round.
-     */
-    java.util.Set<String> genSourceFileNames = new java.util.LinkedHashSet<String>();
-
-    /** List of names of generated class files from most recent apt round.
-     */
-    java.util.Set<String> genClassFileNames  = new java.util.LinkedHashSet<String>();
-
-    /**
-     * List of all the generated source file names across all apt rounds.
-     */
-    java.util.Set<String> aggregateGenSourceFileNames = new java.util.LinkedHashSet<String>();
-
-    /**
-     * List of all the generated class file names across all apt rounds.
-     */
-    java.util.Set<String> aggregateGenClassFileNames  = new java.util.LinkedHashSet<String>();
-
-    /**
-     * List of all the generated file names across all apt rounds.
-     */
-    java.util.Set<java.io.File> aggregateGenFiles = new java.util.LinkedHashSet<java.io.File>();
-
-    /**
-     * Set of all factories that have provided a processor on some apt round.
-     */
-    java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories  =
-        new java.util.LinkedHashSet<Class<? extends AnnotationProcessorFactory> >();
-
-
-
-    /** Print a string that explains usage.
-     */
-    void help() {
-        Bark.printLines(out, getLocalizedString("msg.usage.header", ownName));
-        for (int i=0; i < recognizedOptions.length; i++) {
-            recognizedOptions[i].help();
-        }
-        Bark.printLines(out, getLocalizedString("msg.usage.footer"));
-        out.println();
-    }
-
-    /** Print a string that explains usage for X options.
-     */
-    void xhelp() {
-        for (int i=0; i<recognizedOptions.length; i++) {
-            recognizedOptions[i].xhelp();
-        }
-        out.println();
-        Bark.printLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
-    }
-
-    /** Report a usage error.
-     */
-    void error(String key, Object... args) {
-        warning(key, args);
-        help();
-    }
-
-    /** Report a warning.
-     */
-    void warning(String key, Object... args) {
-        Bark.printLines(out, ownName + ": "
-                       + getLocalizedString(key, args));
-    }
-
-    /** Process command line arguments: store all command line options
-     *  in `options' table and return all source filenames.
-     *  @param args    The array of command line arguments.
-     */
-    protected java.util.List<String> processArgs(String[] flags) {
-        int ac = 0;
-        while (ac < flags.length) {
-            String flag = flags[ac];
-            ac++;
-
-            int j;
-            for (j=0; j < recognizedOptions.length; j++)
-                if (recognizedOptions[j].matches(flag))
-                    break;
-
-            if (j == recognizedOptions.length) {
-                error("err.invalid.flag", flag);
-                return null;
-            }
-
-            Option option = recognizedOptions[j];
-            if (option.hasArg()) {
-                if (ac == flags.length) {
-                    error("err.req.arg", flag);
-                    return null;
-                }
-                String operand = flags[ac];
-                ac++;
-                if (option.process(flag, operand))
-                    return null;
-            } else {
-                if (option.process(flag))
-                    return null;
-            }
-        }
-
-        String sourceString = options.get("-source");
-        Source source = (sourceString != null)
-            ? Source.lookup(sourceString)
-            : Source.JDK1_5; // JDK 5 is the latest supported source version
-        String targetString = options.get("-target");
-        Target target = (targetString != null)
-            ? Target.lookup(targetString)
-            : Target.JDK1_5; // JDK 5 is the latest supported source version
-        // We don't check source/target consistency for CLDC, as J2ME
-        // profiles are not aligned with J2SE targets; moreover, a
-        // single CLDC target may have many profiles.  In addition,
-        // this is needed for the continued functioning of the JSR14
-        // prototype.
-        if (Character.isDigit(target.name.charAt(0)) &&
-            target.compareTo(source.requiredTarget()) < 0) {
-            if (targetString != null) {
-                if (sourceString == null) {
-                    warning("warn.target.default.source.conflict",
-                            targetString,
-                            source.requiredTarget().name);
-                } else {
-                    warning("warn.source.target.conflict",
-                            sourceString,
-                            source.requiredTarget().name);
-                }
-                return null;
-            } else {
-                options.put("-target", source.requiredTarget().name);
-            }
-        }
-        return sourceFileNames;
-    }
-
-    /** Programmatic interface for main function.
-     * @param args    The command line parameters.
-     */
-    public int compile(String[] args, AnnotationProcessorFactory factory) {
-        int returnCode = 0;
-        providedFactory = factory;
-
-        Context context = new Context();
-        JavacFileManager.preRegister(context);
-        options = Options.instance(context);
-        Bark bark;
-
-        /*
-         * Process the command line options to create the intial
-         * options data.  This processing is at least partially reused
-         * by any recursive apt calls.
-         */
-
-        // For testing: assume all arguments in forcedOpts are
-        // prefixed to command line arguments.
-        processArgs(forcedOpts);
-
-        /*
-         * A run of apt only gets passed the most recently generated
-         * files; the initial run of apt gets passed the files from
-         * the command line.
-         */
-
-        java.util.List<String> origFilenames;
-        try {
-            // assign args the result of parse to capture results of
-            // '@file' expansion
-            origFilenames = processArgs((args=CommandLine.parse(args)));
-
-            if (options.get("suppress-tool-api-removal-message") == null) {
-                Bark.printLines(out, getLocalizedString("misc.Deprecation"));
-            }
-
-            if (origFilenames == null) {
-                return EXIT_CMDERR;
-            } else if (origFilenames.size() == 0) {
-                // it is allowed to compile nothing if just asking for help
-                if (options.get("-help") != null ||
-                    options.get("-X") != null)
-                    return EXIT_OK;
-            }
-        } catch (java.io.FileNotFoundException e) {
-            Bark.printLines(out, ownName + ": " +
-                           getLocalizedString("err.file.not.found",
-                                              e.getMessage()));
-            return EXIT_SYSERR;
-        } catch (IOException ex) {
-            ioMessage(ex);
-            return EXIT_SYSERR;
-        } catch (OutOfMemoryError ex) {
-            resourceMessage(ex);
-            return EXIT_SYSERR;
-        } catch (StackOverflowError ex) {
-            resourceMessage(ex);
-            return EXIT_SYSERR;
-        } catch (FatalError ex) {
-            feMessage(ex);
-            return EXIT_SYSERR;
-        } catch (sun.misc.ServiceConfigurationError sce) {
-            sceMessage(sce);
-            return EXIT_ABNORMAL;
-        } catch (Throwable ex) {
-            bugMessage(ex);
-            return EXIT_ABNORMAL;
-        }
-
-
-        boolean firstRound = true;
-        boolean needSourcePath = false;
-        boolean needClassPath  = false;
-        boolean classesAsDecls = options.get("-XclassesAsDecls") != null;
-
-        /*
-         * Create augumented classpath and sourcepath values.
-         *
-         * If any of the prior apt rounds generated any new source
-         * files, the n'th apt round (and any javac invocation) has the
-         * source destination path ("-s path") as the last element of
-         * the "-sourcepath" to the n'th call.
-         *
-         * If any of the prior apt rounds generated any new class files,
-         * the n'th apt round (and any javac invocation) has the class
-         * destination path ("-d path") as the last element of the
-         * "-classpath" to the n'th call.
-         */
-        String augmentedSourcePath = "";
-        String augmentedClassPath = "";
-        String baseClassPath = "";
-
-        try {
-            /*
-             * Record original options for future annotation processor
-             * invocations.
-             */
-            origOptions = new HashMap<String, String>(options.size());
-            for(String s: options.keySet()) {
-                String value;
-                if (s.equals(value = options.get(s)))
-                    origOptions.put(s, (String)null);
-                else
-                    origOptions.put(s, value);
-            }
-            origOptions = Collections.unmodifiableMap(origOptions);
-
-            JavacFileManager fm = (JavacFileManager) context.get(JavaFileManager.class);
-            {
-                // Note: it might be necessary to check for an empty
-                // component ("") of the source path or class path
-
-                String sourceDest = options.get("-s");
-                if (fm.hasLocation(StandardLocation.SOURCE_PATH)) {
-                    for(File f: fm.getLocation(StandardLocation.SOURCE_PATH))
-                        augmentedSourcePath += (f + File.pathSeparator);
-                    augmentedSourcePath += (sourceDest == null)?".":sourceDest;
-                } else {
-                    augmentedSourcePath = ".";
-
-                    if (sourceDest != null)
-                        augmentedSourcePath += (File.pathSeparator + sourceDest);
-                }
-
-                String classDest = options.get("-d");
-                if (fm.hasLocation(StandardLocation.CLASS_PATH)) {
-                    for(File f: fm.getLocation(StandardLocation.CLASS_PATH))
-                        baseClassPath += (f + File.pathSeparator);
-                    // put baseClassPath into map to handle any
-                    // value needed for the classloader
-                    options.put("-classpath", baseClassPath);
-
-                    augmentedClassPath = baseClassPath + ((classDest == null)?".":classDest);
-                } else {
-                    baseClassPath = ".";
-                    if (classDest != null)
-                        augmentedClassPath = baseClassPath + (File.pathSeparator + classDest);
-                }
-                assert options.get("-classpath") != null;
-            }
-
-            /*
-             * Create base and augmented class loaders
-             */
-            ClassLoader augmentedAptCL = null;
-            {
-            /*
-             * Use a url class loader to look for classes on the
-             * user-specified class path. Prepend computed bootclass
-             * path, which includes extdirs, to the URLClassLoader apt
-             * uses.
-             */
-                String aptclasspath = "";
-                String bcp = "";
-                Iterable<? extends File> bootclasspath = fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH);
-
-                if (bootclasspath != null) {
-                    for(File f: bootclasspath)
-                        bcp += (f + File.pathSeparator);
-                }
-
-                // If the factory path is set, use that path
-                if (providedFactory == null)
-                    aptclasspath = options.get("-factorypath");
-                if (aptclasspath == null)
-                    aptclasspath = options.get("-classpath");
-
-                assert aptclasspath != null;
-                aptclasspath = (bcp + aptclasspath);
-                aptCL = new URLClassLoader(pathToURLs(aptclasspath));
-
-                if (providedFactory == null &&
-                    options.get("-factorypath") != null) // same CL even if new class files written
-                    augmentedAptCL = aptCL;
-                else {
-                    // Create class loader in case new class files are
-                    // written
-                    augmentedAptCL = new URLClassLoader(pathToURLs(augmentedClassPath.
-                                                                   substring(baseClassPath.length())),
-                                                        aptCL);
-                }
-            }
-
-            int round = 0; // For -XPrintAptRounds
-            do {
-                round++;
-
-                Context newContext = new Context();
-                Options newOptions = Options.instance(newContext); // creates a new context
-                newOptions.putAll(options);
-
-                // populate with old options... don't bother reparsing command line, etc.
-
-                // if genSource files, must add destination to source path
-                if (genSourceFileNames.size() > 0 && !firstRound) {
-                    newOptions.put("-sourcepath", augmentedSourcePath);
-                    needSourcePath = true;
-                }
-                aggregateGenSourceFileNames.addAll(genSourceFileNames);
-                sourceFileNames.addAll(genSourceFileNames);
-                genSourceFileNames.clear();
-
-                // Don't really need to track this; just have to add -d
-                // "foo" to class path if any class files are generated
-                if (genClassFileNames.size() > 0) {
-                    newOptions.put("-classpath", augmentedClassPath);
-                    aptCL = augmentedAptCL;
-                    needClassPath = true;
-                }
-                aggregateGenClassFileNames.addAll(genClassFileNames);
-                classFileNames.addAll(genClassFileNames);
-                genClassFileNames.clear();
-
-                options = newOptions;
-
-                if (options.get("-XPrintAptRounds") != null) {
-                    out.println("apt Round : " + round);
-                    out.println("filenames: " + sourceFileNames);
-                    if (classesAsDecls)
-                        out.println("classnames: " + classFileNames);
-                    out.println("options: " + options);
-                }
-
-                returnCode = compile(args, newContext);
-                firstRound = false;
-
-                // Check for reported errors before continuing
-                bark = Bark.instance(newContext);
-            } while(((genSourceFileNames.size() != 0 ) ||
-                     (classesAsDecls && genClassFileNames.size() != 0)) &&
-                    bark.nerrors == 0);
-        } catch (UsageMessageNeededException umne) {
-            help();
-            return EXIT_CMDERR; // will cause usage message to be printed
-        }
-
-        /*
-         * Do not compile if a processor has reported an error or if
-         * there are no source files to process.  A more sophisticated
-         * test would also fail for syntax errors caught by javac.
-         */
-        if (options.get("-nocompile") == null &&
-            options.get("-print")     == null &&
-            bark.nerrors == 0 &&
-            (origFilenames.size() > 0 || aggregateGenSourceFileNames.size() > 0 )) {
-            /*
-             * Need to create new argument string for calling javac:
-             * 1. apt specific arguments (e.g. -factory) must be stripped out
-             * 2. proper settings for sourcepath and classpath must be used
-             * 3. generated class names must be added
-             * 4. class file names as declarations must be removed
-             */
-
-            int newArgsLength = args.length +
-                (needSourcePath?1:0) +
-                (needClassPath?1:0) +
-                aggregateGenSourceFileNames.size();
-
-            // Null out apt-specific options and don't copy over into
-            // newArgs. This loop should be a lot faster; the options
-            // array should be replaced with a better data structure
-            // which includes a map from strings to options.
-            //
-            // If treating classes as declarations, must strip out
-            // class names from the javac argument list
-            argLoop:
-            for(int i = 0; i < args.length; i++) {
-                int matchPosition = -1;
-
-                // "-A" by itself is recognized by apt but not javac
-                if (args[i] != null && args[i].equals("-A")) {
-                    newArgsLength--;
-                    args[i] = null;
-                    continue argLoop;
-                } else {
-                    optionLoop:
-                    for(int j = 0; j < recognizedOptions.length; j++) {
-                        if (args[i] != null && recognizedOptions[j].matches(args[i])) {
-                            matchPosition = j;
-                            break optionLoop;
-                        }
-                    }
-
-                    if (matchPosition != -1) {
-                        Option op = recognizedOptions[matchPosition];
-                        if (op.aptOnly) {
-                            newArgsLength--;
-                            args[i] = null;
-                            if (op.hasArg()) {
-                                newArgsLength--;
-                                args[i+1] = null;
-                            }
-                        } else {
-                            if (op.hasArg()) { // skip over next string
-                                i++;
-                                continue argLoop;
-                            }
-
-                            if ((options.get("-XclassesAsDecls") != null) &&
-                                (matchPosition == (recognizedOptions.length-1)) ){
-                                // Remove class file names from
-                                // consideration by javac.
-                                if (! args[i].endsWith(".java")) {
-                                    newArgsLength--;
-                                    args[i] = null;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            String newArgs[] = new String[newArgsLength];
-
-            int j = 0;
-            for(int i=0; i < args.length; i++) {
-                if (args[i] != null)
-                    newArgs[j++] = args[i];
-            }
-
-            if (needClassPath)
-                newArgs[j++] = "-XD-classpath=" + augmentedClassPath;
-
-            if (needSourcePath) {
-                newArgs[j++] = "-XD-sourcepath=" + augmentedSourcePath;
-
-                for(String s: aggregateGenSourceFileNames)
-                    newArgs[j++] = s;
-            }
-
-            returnCode = com.sun.tools.javac.Main.compile(newArgs);
-        }
-
-        return returnCode;
-    }
-
-    /** Programmatic interface for main function.
-     * @param args    The command line parameters.
-     */
-    int compile(String[] args, Context context) {
-        boolean assertionsEnabled = false;
-        assert assertionsEnabled = true;
-        if (!assertionsEnabled) {
-            // Bark.printLines(out, "fatal error: assertions must be enabled when running javac");
-            // return EXIT_ABNORMAL;
-        }
-        int exitCode = EXIT_OK;
-
-        AptJavaCompiler comp = null;
-        try {
-            context.put(Bark.outKey, out);
-
-            comp = AptJavaCompiler.instance(context);
-            if (comp == null)
-                return EXIT_SYSERR;
-
-            java.util.List<String> nameList = new java.util.LinkedList<String>();
-            nameList.addAll(sourceFileNames);
-            if (options.get("-XclassesAsDecls") != null)
-                nameList.addAll(classFileNames);
-
-            List<Symbol.ClassSymbol> cs
-                = comp.compile(List.from(nameList.toArray(new String[0])),
-                               origOptions,
-                               aptCL,
-                               providedFactory,
-                               productiveFactories,
-                               aggregateGenFiles);
-
-            /*
-             * If there aren't new source files, we shouldn't bother
-             *  running javac if there were errors.
-             *
-             * If there are new files, we should try running javac in
-             * case there were typing errors.
-             *
-             */
-
-            if (comp.errorCount() != 0 ||
-                options.get("-Werror") != null && comp.warningCount() != 0)
-                return EXIT_ERROR;
-        } catch (IOException ex) {
-            ioMessage(ex);
-            return EXIT_SYSERR;
-        } catch (OutOfMemoryError ex) {
-            resourceMessage(ex);
-            return EXIT_SYSERR;
-        } catch (StackOverflowError ex) {
-            resourceMessage(ex);
-            return EXIT_SYSERR;
-        } catch (FatalError ex) {
-            feMessage(ex);
-            return EXIT_SYSERR;
-        } catch (UsageMessageNeededException umne) {
-            help();
-            return EXIT_CMDERR; // will cause usage message to be printed
-        } catch (AnnotationProcessingError ex) {
-            apMessage(ex);
-            return EXIT_ABNORMAL;
-        } catch (sun.misc.ServiceConfigurationError sce) {
-            sceMessage(sce);
-            return EXIT_ABNORMAL;
-        } catch (Throwable ex) {
-            bugMessage(ex);
-            return EXIT_ABNORMAL;
-        } finally {
-            if (comp != null) {
-                comp.close();
-                genSourceFileNames.addAll(comp.getSourceFileNames());
-                genClassFileNames.addAll(comp.getClassFileNames());
-            }
-            sourceFileNames = new java.util.LinkedList<String>();
-            classFileNames  = new java.util.LinkedList<String>();
-        }
-        return exitCode;
-    }
-
-    /** Print a message reporting an internal error.
-     */
-    void bugMessage(Throwable ex) {
-        Bark.printLines(out, getLocalizedString("msg.bug",
-                                               AptJavaCompiler.version()));
-        ex.printStackTrace(out);
-    }
-
-    /** Print a message reporting an fatal error.
-     */
-    void apMessage(AnnotationProcessingError ex) {
-        Bark.printLines(out, getLocalizedString("misc.Problem"));
-        ex.getCause().printStackTrace(out);
-    }
-
-    /** Print a message about sun.misc.Service problem.
-     */
-    void sceMessage(sun.misc.ServiceConfigurationError ex) {
-        Bark.printLines(out, getLocalizedString("misc.SunMiscService"));
-        ex.printStackTrace(out);
-    }
-
-    /** Print a message reporting an fatal error.
-     */
-    void feMessage(Throwable ex) {
-        Bark.printLines(out, ex.toString());
-    }
-
-    /** Print a message reporting an input/output error.
-     */
-    void ioMessage(Throwable ex) {
-        Bark.printLines(out, getLocalizedString("msg.io"));
-        ex.printStackTrace(out);
-    }
-
-    /** Print a message reporting an out-of-resources error.
-     */
-    void resourceMessage(Throwable ex) {
-        Bark.printLines(out, getLocalizedString("msg.resource"));
-        ex.printStackTrace(out);
-    }
-
-    /* ************************************************************************
-     * Internationalization
-     *************************************************************************/
-
-    /** Find a localized string in the resource bundle.
-     *  @param key     The key for the localized string.
-     */
-    private static String getLocalizedString(String key, Object... args) {
-        return getText(key, args);
-    }
-
-    private static final String javacRB =
-        "com.sun.tools.javac.resources.javac";
-
-    private static final String aptRB =
-        "com.sun.tools.apt.resources.apt";
-
-    private static ResourceBundle messageRBjavac;
-    private static ResourceBundle messageRBapt;
-
-    /** Initialize ResourceBundle.
-     */
-    private static void initResource() {
-        try {
-            messageRBapt   = ResourceBundle.getBundle(aptRB);
-            messageRBjavac = ResourceBundle.getBundle(javacRB);
-        } catch (MissingResourceException e) {
-            Error x = new FatalError("Fatal Error: Resource for apt or javac is missing");
-            x.initCause(e);
-            throw x;
-        }
-    }
-
-    /** Get and format message string from resource.
-     */
-    private static String getText(String key, Object... _args) {
-        String[] args = new String[_args.length];
-        for (int i=0; i<_args.length; i++) {
-            args[i] = "" + _args[i];
-        }
-        if (messageRBapt == null || messageRBjavac == null )
-            initResource();
-        try {
-            return MessageFormat.format(messageRBapt.getString("apt." + key),
-                                        (Object[]) args);
-        } catch (MissingResourceException e) {
-            try {
-                return MessageFormat.format(messageRBjavac.getString("javac." + key),
-                                            (Object[]) args);
-            } catch (MissingResourceException f) {
-                String msg = "apt or javac message file broken: key={0} "
-                    + "arguments={1}, {2}";
-                return MessageFormat.format(msg, (Object[]) args);
-            }
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java b/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java
deleted file mode 100644
index 0786b61..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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.apt.mirror;
-
-
-import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
-import com.sun.tools.apt.mirror.type.TypeMaker;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.CompletionFailure;
-import com.sun.tools.javac.comp.Attr;
-import com.sun.tools.javac.comp.Enter;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Names;
-
-
-/**
- * The environment for a run of apt.
- */
- at SuppressWarnings("deprecation")
-public class AptEnv {
-
-    public Names names;                 // javac's name table
-    public Symtab symtab;               // javac's predefined symbols
-    public Types jctypes;               // javac's type utilities
-    public Enter enter;                 // javac's enter phase
-    public Attr attr;                   // javac's attr phase (to evaluate
-                                        //   constant initializers)
-    public TypeMaker typeMaker;         // apt's internal type utilities
-    public DeclarationMaker declMaker;  // apt's internal declaration utilities
-
-
-    private static final Context.Key<AptEnv> aptEnvKey =
-            new Context.Key<AptEnv>();
-
-    public static AptEnv instance(Context context) {
-        AptEnv instance = context.get(aptEnvKey);
-        if (instance == null) {
-            instance = new AptEnv(context);
-        }
-        return instance;
-    }
-
-    private AptEnv(Context context) {
-        context.put(aptEnvKey, this);
-
-        names = Names.instance(context);
-        symtab = Symtab.instance(context);
-        jctypes = Types.instance(context);
-        enter = Enter.instance(context);
-        attr = Attr.instance(context);
-        typeMaker = TypeMaker.instance(context);
-        declMaker = DeclarationMaker.instance(context);
-    }
-
-
-    /**
-     * Does a symbol have a given flag?  Forces symbol completion.
-     */
-    public static boolean hasFlag(Symbol sym, long flag) {
-        return (getFlags(sym) & flag) != 0;
-    }
-
-    /**
-     * Returns a symbol's flags.  Forces completion.
-     */
-    public static long getFlags(Symbol sym) {
-        complete(sym);
-        return sym.flags();
-    }
-
-    /**
-     * Completes a symbol, ignoring completion failures.
-     */
-    private static void complete(Symbol sym) {
-        while (true) {
-            try {
-                sym.complete();
-                return;
-            } catch (CompletionFailure e) {
-                // Should never see two in a row, but loop just to be sure.
-            }
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java b/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java
deleted file mode 100644
index 049ceba..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.apt;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-import com.sun.mirror.apt.*;
-import com.sun.tools.apt.mirror.apt.*;
-import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
-import com.sun.tools.apt.mirror.util.*;
-import com.sun.tools.apt.util.Bark;
-import com.sun.tools.javac.util.Context;
-
-import com.sun.tools.apt.mirror.apt.FilerImpl;
-import com.sun.tools.apt.mirror.apt.MessagerImpl;
-import com.sun.tools.apt.mirror.apt.RoundStateImpl;
-import com.sun.tools.apt.mirror.apt.RoundCompleteEventImpl;
-
-import com.sun.tools.javac.util.Context;
-
-import java.util.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Annotation Processor Environment implementation.
- */
- at SuppressWarnings("deprecation")
-public class AnnotationProcessorEnvironmentImpl implements AnnotationProcessorEnvironment {
-
-    Collection<TypeDeclaration> spectypedecls;
-    Collection<TypeDeclaration> typedecls;
-    Map<String, String> origOptions;
-    DeclarationMaker declMaker;
-    Declarations declUtils;
-    Types typeUtils;
-    Messager messager;
-    FilerImpl filer;
-    Bark bark;
-    Set<RoundCompleteListener> roundCompleteListeners;
-
-    public AnnotationProcessorEnvironmentImpl(Collection<TypeDeclaration> spectypedecls,
-                                              Collection<TypeDeclaration> typedecls,
-                                              Map<String, String> origOptions,
-                                              Context context) {
-        // Safer to copy collections before applying unmodifiable
-        // wrapper.
-        this.spectypedecls = Collections.unmodifiableCollection(spectypedecls);
-        this.typedecls = Collections.unmodifiableCollection(typedecls);
-        this.origOptions = Collections.unmodifiableMap(origOptions);
-
-        declMaker = DeclarationMaker.instance(context);
-        declUtils = DeclarationsImpl.instance(context);
-        typeUtils = TypesImpl.instance(context);
-        messager = MessagerImpl.instance(context);
-        filer = FilerImpl.instance(context);
-        bark = Bark.instance(context);
-        roundCompleteListeners = new LinkedHashSet<RoundCompleteListener>();
-    }
-
-    public Map<String,String> getOptions() {
-        return origOptions;
-    }
-
-    public Messager getMessager() {
-        return messager;
-    }
-
-    public Filer getFiler() {
-        return filer;
-    }
-
-    public Collection<TypeDeclaration> getSpecifiedTypeDeclarations() {
-        return spectypedecls;
-    }
-
-    public PackageDeclaration getPackage(String name) {
-        return declMaker.getPackageDeclaration(name);
-    }
-
-    public TypeDeclaration getTypeDeclaration(String name) {
-        return declMaker.getTypeDeclaration(name);
-    }
-
-    public Collection<TypeDeclaration> getTypeDeclarations() {
-        return typedecls;
-    }
-
-    public Collection<Declaration> getDeclarationsAnnotatedWith(
-                                                AnnotationTypeDeclaration a) {
-        /*
-         * create collection of Declarations annotated with a given
-         * annotation.
-         */
-
-        CollectingAP proc = new CollectingAP(this, a);
-        proc.process();
-        return proc.decls;
-    }
-
-    private static class CollectingAP implements AnnotationProcessor {
-        AnnotationProcessorEnvironment env;
-        Collection<Declaration> decls;
-        AnnotationTypeDeclaration atd;
-        CollectingAP(AnnotationProcessorEnvironment env,
-                     AnnotationTypeDeclaration atd) {
-            this.env = env;
-            this.atd = atd;
-            decls = new HashSet<Declaration>();
-        }
-
-        private class CollectingVisitor extends SimpleDeclarationVisitor {
-            public void visitDeclaration(Declaration d) {
-                for(AnnotationMirror am: d.getAnnotationMirrors()) {
-                    if (am.getAnnotationType().getDeclaration().equals(CollectingAP.this.atd))
-                        CollectingAP.this.decls.add(d);
-                }
-            }
-        }
-
-        public void process() {
-            for(TypeDeclaration d: env.getSpecifiedTypeDeclarations())
-                d.accept(getSourceOrderDeclarationScanner(new CollectingVisitor(),
-                                                          NO_OP));
-        }
-    }
-
-    public Declarations getDeclarationUtils() {
-        return declUtils;
-    }
-
-    public Types getTypeUtils() {
-        return typeUtils;
-    }
-
-    public void addListener(AnnotationProcessorListener listener) {
-        if (listener == null)
-            throw new NullPointerException();
-        else {
-            if (listener instanceof RoundCompleteListener)
-                roundCompleteListeners.add((RoundCompleteListener)listener);
-        }
-    }
-
-    public void removeListener(AnnotationProcessorListener listener) {
-        if (listener == null)
-            throw new NullPointerException();
-        else
-            roundCompleteListeners.remove(listener);
-    }
-
-    public void roundComplete() {
-        RoundState roundState  = new RoundStateImpl(bark.nerrors > 0,
-                                                    filer.getSourceFileNames().size() > 0,
-                                                    filer.getClassFileNames().size() > 0,
-                                                    origOptions);
-        RoundCompleteEvent roundCompleteEvent = new RoundCompleteEventImpl(this, roundState);
-
-        filer.roundOver();
-        for(RoundCompleteListener rcl: roundCompleteListeners)
-            rcl.roundComplete(roundCompleteEvent);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java b/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java
deleted file mode 100644
index 3a15cc4..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.mirror.apt;
-
-
-import java.io.*;
-import java.util.Collection;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.sun.mirror.apt.Filer;
-import com.sun.tools.apt.mirror.declaration.DeclarationMaker;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.Position;
-import com.sun.tools.apt.util.Bark;
-
-import static com.sun.mirror.apt.Filer.Location.*;
-
-
-/**
- * Implementation of Filer.
- */
- at SuppressWarnings("deprecation")
-public class FilerImpl implements Filer {
-    /*
-     * The Filer class must maintain a number of constraints.  First,
-     * multiple attempts to open the same path within the same
-     * invocation of apt results in an IOException being thrown.  For
-     * example, trying to open the same source file twice:
-     *
-     * createSourceFile("foo.Bar")
-     * ...
-     * createSourceFile("foo.Bar")
-     *
-     * is disallowed as is opening a text file that happens to have
-     * the same name as a source file:
-     *
-     * createSourceFile("foo.Bar")
-     * ...
-     * createTextFile(SOURCE_TREE, "foo", new File("Bar"), null)
-     *
-     * Additionally, creating a source file that corresponds to an
-     * already created class file (or vice versa) generates at least a
-     * warning.  This is an error if -XclassesAsDecls is being used
-     * since you can't create the same type twice.  However, if the
-     * Filer is used to create a text file named *.java that happens
-     * to correspond to an existing class file, a warning is *not*
-     * generated.  Similarly, a warning is not generated for a binary
-     * file named *.class and an existing source file.
-     *
-     * The reason for this difference is that source files and class
-     * files are registered with apt and can get passed on as
-     * declarations to the next round of processing.  Files that are
-     * just named *.java and *.class are not processed in that manner;
-     * although having extra source files and class files on the
-     * source path and class path can alter the behavior of the tool
-     * and any final compile.
-     */
-
-    private enum FileKind {
-        SOURCE {
-            void register(File file, String name, FilerImpl that) throws IOException {
-                // Check for corresponding class file
-                if (that.filesCreated.contains(new File(that.locations.get(CLASS_TREE),
-                                                        that.nameToPath(name, ".class")))) {
-
-                    that.bark.aptWarning("CorrespondingClassFile", name);
-                    if (that.opts.get("-XclassesAsDecls") != null)
-                        throw new IOException();
-                }
-                that.sourceFileNames.add(file.getPath());
-            }
-        },
-
-        CLASS  {
-            void register(File file, String name, FilerImpl that) throws IOException {
-                if (that.filesCreated.contains(new File(that.locations.get(SOURCE_TREE),
-                                                        that.nameToPath(name, ".java")))) {
-                    that.bark.aptWarning("CorrespondingSourceFile", name);
-                    if (that.opts.get("-XclassesAsDecls") != null)
-                        throw new IOException();
-                }
-                // Track the binary name instead of the filesystem location
-                that.classFileNames.add(name);
-            }
-        },
-
-        OTHER  {
-            // Nothing special to do
-            void register(File file, String name, FilerImpl that) throws IOException {}
-        };
-
-        abstract void register(File file, String name, FilerImpl that) throws IOException;
-    }
-
-    private final Options opts;
-    private final DeclarationMaker declMaker;
-    private final com.sun.tools.apt.main.AptJavaCompiler comp;
-
-    // Platform's default encoding
-    private final static String DEFAULT_ENCODING =
-            new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
-
-    private String encoding;    // name of charset used for source files
-
-    private final EnumMap<Location, File> locations;    // where new files go
-
-
-    private static final Context.Key<FilerImpl> filerKey =
-            new Context.Key<FilerImpl>();
-
-    // Set of files opened.
-    private Collection<Flushable> wc;
-
-    private Bark bark;
-
-    // All created files.
-    private final Set<File> filesCreated;
-
-    // Names of newly created source files
-    private HashSet<String> sourceFileNames = new HashSet<String>();
-
-    // Names of newly created class files
-    private HashSet<String> classFileNames  = new HashSet<String>();
-
-    private boolean roundOver;
-
-    public static FilerImpl instance(Context context) {
-        FilerImpl instance = context.get(filerKey);
-        if (instance == null) {
-            instance = new FilerImpl(context);
-        }
-        return instance;
-    }
-
-    // flush all output streams;
-    public void flush() {
-        for(Flushable opendedFile: wc) {
-            try {
-                opendedFile.flush();
-                if (opendedFile instanceof FileOutputStream) {
-                    try {
-                        ((FileOutputStream) opendedFile).getFD().sync() ;
-                    } catch (java.io.SyncFailedException sfe) {}
-                }
-            } catch (IOException e) { }
-        }
-    }
-
-    private FilerImpl(Context context) {
-        context.put(filerKey, this);
-        opts = Options.instance(context);
-        declMaker = DeclarationMaker.instance(context);
-        bark = Bark.instance(context);
-        comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
-        roundOver = false;
-        this.filesCreated = comp.getAggregateGenFiles();
-
-        // Encoding
-        encoding = opts.get("-encoding");
-        if (encoding == null) {
-            encoding = DEFAULT_ENCODING;
-        }
-
-        wc = new HashSet<Flushable>();
-
-        // Locations
-        locations = new EnumMap<Location, File>(Location.class);
-        String s = opts.get("-s");      // location for new source files
-        String d = opts.get("-d");      // location for new class files
-        locations.put(SOURCE_TREE, new File(s != null ? s : "."));
-        locations.put(CLASS_TREE,  new File(d != null ? d : "."));
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public PrintWriter createSourceFile(String name) throws IOException {
-        String pathname = nameToPath(name, ".java");
-        File file = new File(locations.get(SOURCE_TREE),
-                             pathname);
-        PrintWriter pw = getPrintWriter(file, encoding, name, FileKind.SOURCE);
-        return pw;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public OutputStream createClassFile(String name) throws IOException {
-        String pathname = nameToPath(name, ".class");
-        File file = new File(locations.get(CLASS_TREE),
-                             pathname);
-        OutputStream os = getOutputStream(file, name, FileKind.CLASS);
-        return os;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public PrintWriter createTextFile(Location loc,
-                                      String pkg,
-                                      File relPath,
-                                      String charsetName) throws IOException {
-        File file = (pkg.length() == 0)
-                        ? relPath
-                        : new File(nameToPath(pkg), relPath.getPath());
-        if (charsetName == null) {
-            charsetName = encoding;
-        }
-        return getPrintWriter(loc, file.getPath(), charsetName, null, FileKind.OTHER);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public OutputStream createBinaryFile(Location loc,
-                                         String pkg,
-                                         File relPath) throws IOException {
-        File file = (pkg.length() == 0)
-                        ? relPath
-                        : new File(nameToPath(pkg), relPath.getPath());
-        return getOutputStream(loc, file.getPath(), null, FileKind.OTHER);
-    }
-
-
-    /**
-     * Converts the canonical name of a top-level type or package to a
-     * pathname.  Suffix is ".java" or ".class" or "".
-     */
-    private String nameToPath(String name, String suffix) throws IOException {
-        if (!DeclarationMaker.isJavaIdentifier(name.replace('.', '_'))) {
-            bark.aptWarning("IllegalFileName", name);
-            throw new IOException();
-        }
-        return name.replace('.', File.separatorChar) + suffix;
-    }
-
-    private String nameToPath(String name) throws IOException {
-        return nameToPath(name, "");
-    }
-
-    /**
-     * Returns a writer for a text file given its location, its
-     * pathname relative to that location, and its encoding.
-     */
-    private PrintWriter getPrintWriter(Location loc, String pathname,
-                                       String encoding, String name, FileKind kind) throws IOException {
-        File file = new File(locations.get(loc), pathname);
-        return getPrintWriter(file, encoding, name, kind);
-    }
-
-    /**
-     * Returns a writer for a text file given its encoding.
-     */
-    private PrintWriter getPrintWriter(File file,
-                                       String encoding, String name, FileKind kind) throws IOException {
-        prepareFile(file, name, kind);
-        PrintWriter pw =
-            new PrintWriter(
-                    new BufferedWriter(
-                         new OutputStreamWriter(new FileOutputStream(file),
-                                                encoding)));
-        wc.add(pw);
-        return pw;
-    }
-
-    /**
-     * Returns an output stream for a binary file given its location
-     * and its pathname relative to that location.
-     */
-    private OutputStream getOutputStream(Location loc, String pathname, String name, FileKind kind)
-                                                        throws IOException {
-        File file = new File(locations.get(loc), pathname);
-        return getOutputStream(file, name, kind);
-    }
-
-    private OutputStream getOutputStream(File file, String name, FileKind kind) throws IOException {
-        prepareFile(file, name, kind);
-        OutputStream os = new FileOutputStream(file);
-        wc.add(os);
-        return os;
-
-    }
-
-    public Set<String> getSourceFileNames() {
-        return sourceFileNames;
-    }
-
-    public Set<String> getClassFileNames() {
-        return classFileNames;
-    }
-
-    public void roundOver() {
-        roundOver = true;
-    }
-
-    /**
-     * Checks that the file has not already been created during this
-     * invocation.  If not, creates intermediate directories, and
-     * deletes the file if it already exists.
-     */
-    private void prepareFile(File file, String name, FileKind kind) throws IOException {
-        if (roundOver) {
-            bark.aptWarning("NoNewFilesAfterRound", file.toString());
-            throw new IOException();
-        }
-
-        if (filesCreated.contains(file)) {
-            bark.aptWarning("FileReopening", file.toString());
-            throw new IOException();
-        } else {
-            if (file.exists()) {
-                file.delete();
-            } else {
-                File parent = file.getParentFile();
-                if (parent != null && !parent.exists()) {
-                    if(!parent.mkdirs()) {
-                        bark.aptWarning("BadParentDirectory", file.toString());
-                        throw new IOException();
-                    }
-                }
-            }
-
-            kind.register(file, name, this);
-            filesCreated.add(file);
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java b/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java
deleted file mode 100644
index b4dd25f..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.apt;
-
-import javax.tools.JavaFileObject;
-import com.sun.mirror.apt.Messager;
-import com.sun.tools.apt.mirror.util.SourcePositionImpl;
-import com.sun.mirror.util.SourcePosition;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Position;
-import com.sun.tools.apt.util.Bark;
-
-
-/**
- * Implementation of Messager.
- */
- at SuppressWarnings("deprecation")
-public class MessagerImpl implements Messager {
-    private final Bark bark;
-
-    private static final Context.Key<MessagerImpl> messagerKey =
-            new Context.Key<MessagerImpl>();
-
-    public static MessagerImpl instance(Context context) {
-        MessagerImpl instance = context.get(messagerKey);
-        if (instance == null) {
-            instance = new MessagerImpl(context);
-        }
-        return instance;
-    }
-
-    private MessagerImpl(Context context) {
-        context.put(messagerKey, this);
-        bark = Bark.instance(context);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printError(String msg) {
-        bark.aptError("Messager", msg);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printError(SourcePosition pos, String msg) {
-        if (pos instanceof SourcePositionImpl) {
-            SourcePositionImpl posImpl = (SourcePositionImpl) pos;
-            JavaFileObject prev = bark.useSource(posImpl.getSource());
-            bark.aptError(posImpl.getJavacPosition(), "Messager", msg);
-            bark.useSource(prev);
-        } else
-            printError(msg);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printWarning(String msg) {
-        bark.aptWarning("Messager", msg);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printWarning(SourcePosition pos, String msg) {
-        if (pos instanceof SourcePositionImpl) {
-            SourcePositionImpl posImpl = (SourcePositionImpl) pos;
-            JavaFileObject prev = bark.useSource(posImpl.getSource());
-            bark.aptWarning(posImpl.getJavacPosition(), "Messager", msg);
-            bark.useSource(prev);
-        } else
-            printWarning(msg);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printNotice(String msg) {
-        bark.aptNote("Messager", msg);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void printNotice(SourcePosition pos, String msg) {
-        if (pos instanceof SourcePositionImpl) {
-            SourcePositionImpl posImpl = (SourcePositionImpl) pos;
-            JavaFileObject prev = bark.useSource(posImpl.getSource());
-            bark.aptNote(posImpl.getJavacPosition(), "Messager", msg);
-            bark.useSource(prev);
-        } else
-            printNotice(msg);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java b/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java
deleted file mode 100644
index b35f277..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2004, 2009, 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.apt.mirror.apt;
-
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.RoundCompleteEvent;
-import com.sun.mirror.apt.RoundState;
-
- at SuppressWarnings("deprecation")
-public class RoundCompleteEventImpl extends RoundCompleteEvent {
-    private static final long serialVersionUID = 7067621446720784300L;
-
-    public RoundCompleteEventImpl(AnnotationProcessorEnvironment source,
-                                  RoundState rs) {
-        super(source, rs);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java b/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java
deleted file mode 100644
index 1b48504..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.apt;
-
-import com.sun.mirror.apt.RoundState;
-import java.util.Map;
-
- at SuppressWarnings("deprecation")
-public class RoundStateImpl implements RoundState {
-    private final boolean finalRound;
-    private final boolean errorRaised;
-    private final boolean sourceFilesCreated;
-    private final boolean classFilesCreated;
-
-    public RoundStateImpl(boolean errorRaised,
-                          boolean sourceFilesCreated,
-                          boolean classFilesCreated,
-                          Map<String,String> options) {
-        /*
-         * In the default mode of operation, this round is the final
-         * round if an error was raised OR there were no new source
-         * files generated.  If classes are being treated as
-         * declarations, this is the final round if an error was
-         * raised OR neither new source files nor new class files were
-         * generated.
-         */
-        this.finalRound =
-            errorRaised ||
-            (!sourceFilesCreated &&
-            !(classFilesCreated && options.keySet().contains("-XclassesAsDecls")) );
-        this.errorRaised = errorRaised;
-        this.sourceFilesCreated = sourceFilesCreated;
-        this.classFilesCreated = classFilesCreated;
-    }
-
-    public boolean finalRound() {
-        return finalRound;
-    }
-
-    public boolean errorRaised() {
-        return errorRaised;
-    }
-
-    public boolean sourceFilesCreated() {
-        return sourceFilesCreated;
-    }
-
-    public boolean classFilesCreated() {
-        return classFilesCreated;
-    }
-
-    public String toString() {
-        return
-            "[final round: " +  finalRound +
-            ", error raised: " +  errorRaised +
-            ", source files created: " + sourceFilesCreated +
-            ", class files created: " + classFilesCreated + "]";
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java
deleted file mode 100644
index 4526b90..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.AnnotationType;
-import com.sun.mirror.util.SourcePosition;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Attribute;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Pair;
-
-
-/**
- * Implementation of AnnotationMirror
- */
- at SuppressWarnings("deprecation")
-public class AnnotationMirrorImpl implements AnnotationMirror {
-
-    protected final AptEnv env;
-    protected final Attribute.Compound anno;
-    protected final Declaration decl;
-
-
-    AnnotationMirrorImpl(AptEnv env, Attribute.Compound anno, Declaration decl) {
-        this.env = env;
-        this.anno = anno;
-        this.decl = decl;
-    }
-
-
-    /**
-     * Returns a string representation of this annotation.
-     * String is of one of the forms:
-     *     @com.example.foo(name1=val1, name2=val2)
-     *     @com.example.foo(val)
-     *     @com.example.foo
-     * Omit parens for marker annotations, and omit "value=" when allowed.
-     */
-    public String toString() {
-        StringBuilder sb = new StringBuilder("@");
-        Constants.Formatter fmtr = Constants.getFormatter(sb);
-
-        fmtr.append(anno.type.tsym);
-
-        int len = anno.values.length();
-        if (len > 0) {          // omit parens for marker annotations
-            sb.append('(');
-            boolean first = true;
-            for (Pair<MethodSymbol, Attribute> val : anno.values) {
-                if (!first) {
-                    sb.append(", ");
-                }
-                first = false;
-
-                Name name = val.fst.name;
-                if (len > 1 || name != env.names.value) {
-                    fmtr.append(name);
-                    sb.append('=');
-                }
-                sb.append(new AnnotationValueImpl(env, val.snd, this));
-            }
-            sb.append(')');
-        }
-        return fmtr.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public AnnotationType getAnnotationType() {
-        return (AnnotationType) env.typeMaker.getType(anno.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Map<AnnotationTypeElementDeclaration, AnnotationValue>
-                                                        getElementValues() {
-        Map<AnnotationTypeElementDeclaration, AnnotationValue> res =
-            new LinkedHashMap<AnnotationTypeElementDeclaration,
-                                                   AnnotationValue>(); // whew!
-        for (Pair<MethodSymbol, Attribute> val : anno.values) {
-            res.put(getElement(val.fst),
-                    new AnnotationValueImpl(env, val.snd, this));
-        }
-        return res;
-    }
-
-    public SourcePosition getPosition() {
-        // Return position of the declaration on which this annotation
-        // appears.
-        return (decl == null) ? null : decl.getPosition();
-
-    }
-
-    public Declaration getDeclaration() {
-        return this.decl;
-    }
-
-    /**
-     * Returns the annotation type element for a symbol.
-     */
-    private AnnotationTypeElementDeclaration getElement(MethodSymbol m) {
-        return (AnnotationTypeElementDeclaration)
-                    env.declMaker.getExecutableDeclaration(m);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java
deleted file mode 100644
index 1849c9a..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.mirror.declaration;
-
-
-import java.lang.annotation.*;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.*;
-import sun.reflect.annotation.*;
-
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.type.MirroredTypeException;
-import com.sun.mirror.type.MirroredTypesException;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Pair;
-
-
-/**
- * A generator of dynamic proxy implementations of
- * java.lang.annotation.Annotation.
- *
- * <p> The "dynamic proxy return form" of an attribute element value is
- * the form used by sun.reflect.annotation.AnnotationInvocationHandler.
- */
- at SuppressWarnings("deprecation")
-class AnnotationProxyMaker {
-
-    private final AptEnv env;
-    private final Attribute.Compound attrs;
-    private final Class<? extends Annotation> annoType;
-
-
-    private AnnotationProxyMaker(AptEnv env,
-                                 Attribute.Compound attrs,
-                                 Class<? extends Annotation> annoType) {
-        this.env = env;
-        this.attrs = attrs;
-        this.annoType = annoType;
-    }
-
-
-    /**
-     * Returns a dynamic proxy for an annotation mirror.
-     */
-    public static <A extends Annotation> A generateAnnotation(
-            AptEnv env, Attribute.Compound attrs, Class<A> annoType) {
-        AnnotationProxyMaker apm = new AnnotationProxyMaker(env, attrs, annoType);
-        return annoType.cast(apm.generateAnnotation());
-    }
-
-
-    /**
-     * Returns a dynamic proxy for an annotation mirror.
-     */
-    private Annotation generateAnnotation() {
-        return AnnotationParser.annotationForMap(annoType,
-                                                 getAllReflectedValues());
-    }
-
-    /**
-     * Returns a map from element names to their values in "dynamic
-     * proxy return form".  Includes all elements, whether explicit or
-     * defaulted.
-     */
-    private Map<String, Object> getAllReflectedValues() {
-        Map<String, Object> res = new LinkedHashMap<String, Object>();
-
-        for (Map.Entry<MethodSymbol, Attribute> entry :
-                                                  getAllValues().entrySet()) {
-            MethodSymbol meth = entry.getKey();
-            Object value = generateValue(meth, entry.getValue());
-            if (value != null) {
-                res.put(meth.name.toString(), value);
-            } else {
-                // Ignore this element.  May lead to
-                // IncompleteAnnotationException somewhere down the line.
-            }
-        }
-        return res;
-    }
-
-    /**
-     * Returns a map from element symbols to their values.
-     * Includes all elements, whether explicit or defaulted.
-     */
-    private Map<MethodSymbol, Attribute> getAllValues() {
-        Map<MethodSymbol, Attribute> res =
-            new LinkedHashMap<MethodSymbol, Attribute>();
-
-        // First find the default values.
-        ClassSymbol sym = (ClassSymbol) attrs.type.tsym;
-        for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
-            if (e.sym.kind == Kinds.MTH) {
-                MethodSymbol m = (MethodSymbol) e.sym;
-                Attribute def = m.defaultValue;
-                if (def != null) {
-                    res.put(m, def);
-                }
-            }
-        }
-        // Next find the explicit values, possibly overriding defaults.
-        for (Pair<MethodSymbol, Attribute> p : attrs.values) {
-            res.put(p.fst, p.snd);
-        }
-        return res;
-    }
-
-    /**
-     * Converts an element value to its "dynamic proxy return form".
-     * Returns an exception proxy on some errors, but may return null if
-     * a useful exception cannot or should not be generated at this point.
-     */
-    private Object generateValue(MethodSymbol meth, Attribute attr) {
-        ValueVisitor vv = new ValueVisitor(meth);
-        return vv.getValue(attr);
-    }
-
-
-    private class ValueVisitor implements Attribute.Visitor {
-
-        private MethodSymbol meth;      // annotation element being visited
-        private Class<?> runtimeType;   // runtime type of annotation element
-        private Object value;           // value in "dynamic proxy return form"
-
-        ValueVisitor(MethodSymbol meth) {
-            this.meth = meth;
-        }
-
-        Object getValue(Attribute attr) {
-            Method method;              // runtime method of annotation element
-            try {
-                method = annoType.getMethod(meth.name.toString());
-            } catch (NoSuchMethodException e) {
-                return null;
-            }
-            runtimeType = method.getReturnType();
-            attr.accept(this);
-            if (!(value instanceof ExceptionProxy) &&
-                !AnnotationType.invocationHandlerReturnType(runtimeType)
-                                                        .isInstance(value)) {
-                typeMismatch(method, attr);
-            }
-            return value;
-        }
-
-
-        public void visitConstant(Attribute.Constant c) {
-            value = Constants.decodeConstant(c.value, c.type);
-        }
-
-        public void visitClass(Attribute.Class c) {
-            value = new MirroredTypeExceptionProxy(
-                                env.typeMaker.getType(c.type));
-        }
-
-        public void visitArray(Attribute.Array a) {
-            Type elemtype = env.jctypes.elemtype(a.type);
-
-            if (elemtype.tsym == env.symtab.classType.tsym) {   // Class[]
-                // Construct a proxy for a MirroredTypesException
-                ArrayList<TypeMirror> elems = new ArrayList<TypeMirror>();
-                for (int i = 0; i < a.values.length; i++) {
-                    Type elem = ((Attribute.Class) a.values[i]).type;
-                    elems.add(env.typeMaker.getType(elem));
-                }
-                value = new MirroredTypesExceptionProxy(elems);
-
-            } else {
-                int len = a.values.length;
-                Class<?> runtimeTypeSaved = runtimeType;
-                runtimeType = runtimeType.getComponentType();
-                try {
-                    Object res = Array.newInstance(runtimeType, len);
-                    for (int i = 0; i < len; i++) {
-                        a.values[i].accept(this);
-                        if (value == null || value instanceof ExceptionProxy) {
-                            return;
-                        }
-                        try {
-                            Array.set(res, i, value);
-                        } catch (IllegalArgumentException e) {
-                            value = null;       // indicates a type mismatch
-                            return;
-                        }
-                    }
-                    value = res;
-                } finally {
-                    runtimeType = runtimeTypeSaved;
-                }
-            }
-        }
-
-        @SuppressWarnings({"unchecked", "rawtypes"})
-        public void visitEnum(Attribute.Enum e) {
-            if (runtimeType.isEnum()) {
-                String constName = e.value.toString();
-                try {
-                    value = Enum.valueOf((Class)runtimeType, constName);
-                } catch (IllegalArgumentException ex) {
-                    value = new EnumConstantNotPresentExceptionProxy(
-                                                        (Class<Enum<?>>)runtimeType, constName);
-                }
-            } else {
-                value = null;   // indicates a type mismatch
-            }
-        }
-
-        public void visitCompound(Attribute.Compound c) {
-            try {
-                Class<? extends Annotation> nested =
-                    runtimeType.asSubclass(Annotation.class);
-                value = generateAnnotation(env, c, nested);
-            } catch (ClassCastException ex) {
-                value = null;   // indicates a type mismatch
-            }
-        }
-
-        public void visitError(Attribute.Error e) {
-            value = null;       // indicates a type mismatch
-        }
-
-
-        /**
-         * Sets "value" to an ExceptionProxy indicating a type mismatch.
-         */
-        private void typeMismatch(Method method, final Attribute attr) {
-            class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
-                private static final long serialVersionUID = 8473323277815075163L;
-                transient final Method method;
-                AnnotationTypeMismatchExceptionProxy(Method method) {
-                    this.method = method;
-                }
-                public String toString() {
-                    return "<error>";   // eg:  @Anno(value=<error>)
-                }
-                protected RuntimeException generateException() {
-                    return new AnnotationTypeMismatchException(method,
-                                attr.type.toString());
-                }
-            }
-            value = new AnnotationTypeMismatchExceptionProxy(method);
-        }
-    }
-
-
-    /**
-     * ExceptionProxy for MirroredTypeException.
-     * The toString, hashCode, and equals methods foward to the underlying
-     * type.
-     */
-    private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
-        private static final long serialVersionUID = 6662035281599933545L;
-
-        private MirroredTypeException ex;
-
-        MirroredTypeExceptionProxy(TypeMirror t) {
-            // It would be safer if we could construct the exception in
-            // generateException(), but there would be no way to do
-            // that properly following deserialization.
-            ex = new MirroredTypeException(t);
-        }
-
-        public String toString() {
-            return ex.getQualifiedName();
-        }
-
-        public int hashCode() {
-            TypeMirror t = ex.getTypeMirror();
-            return (t != null)
-                    ? t.hashCode()
-                    : ex.getQualifiedName().hashCode();
-        }
-
-        public boolean equals(Object obj) {
-            TypeMirror t = ex.getTypeMirror();
-            return t != null &&
-                   obj instanceof MirroredTypeExceptionProxy &&
-                   t.equals(
-                        ((MirroredTypeExceptionProxy) obj).ex.getTypeMirror());
-        }
-
-        protected RuntimeException generateException() {
-            return (RuntimeException) ex.fillInStackTrace();
-        }
-    }
-
-
-    /**
-     * ExceptionProxy for MirroredTypesException.
-     * The toString, hashCode, and equals methods foward to the underlying
-     * types.
-     */
-    private static final class MirroredTypesExceptionProxy extends ExceptionProxy {
-        private static final long serialVersionUID = -6670822532616693951L;
-
-        private MirroredTypesException ex;
-
-        MirroredTypesExceptionProxy(Collection<TypeMirror> ts) {
-            // It would be safer if we could construct the exception in
-            // generateException(), but there would be no way to do
-            // that properly following deserialization.
-            ex = new MirroredTypesException(ts);
-        }
-
-        public String toString() {
-            return ex.getQualifiedNames().toString();
-        }
-
-        public int hashCode() {
-            Collection<TypeMirror> ts = ex.getTypeMirrors();
-            return (ts != null)
-                    ? ts.hashCode()
-                    : ex.getQualifiedNames().hashCode();
-        }
-
-        public boolean equals(Object obj) {
-            Collection<TypeMirror> ts = ex.getTypeMirrors();
-            return ts != null &&
-                   obj instanceof MirroredTypesExceptionProxy &&
-                   ts.equals(
-                      ((MirroredTypesExceptionProxy) obj).ex.getTypeMirrors());
-        }
-
-        protected RuntimeException generateException() {
-            return (RuntimeException) ex.fillInStackTrace();
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java
deleted file mode 100644
index 544c1ad..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of AnnotationTypeDeclaration
- */
- at SuppressWarnings("deprecation")
-public class AnnotationTypeDeclarationImpl extends InterfaceDeclarationImpl
-                                           implements AnnotationTypeDeclaration
-{
-    AnnotationTypeDeclarationImpl(AptEnv env, ClassSymbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<AnnotationTypeElementDeclaration> getMethods() {
-        return identityFilter.filter(super.getMethods(),
-                                     AnnotationTypeElementDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitAnnotationTypeDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java
deleted file mode 100644
index 717e6ac..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-
-
-/**
- * Implementation of AnnotationTypeElementDeclaration
- */
- at SuppressWarnings("deprecation")
-public class AnnotationTypeElementDeclarationImpl extends MethodDeclarationImpl
-                                  implements AnnotationTypeElementDeclaration {
-
-    AnnotationTypeElementDeclarationImpl(AptEnv env, MethodSymbol sym) {
-        super(env, sym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public AnnotationTypeDeclaration getDeclaringType() {
-        return (AnnotationTypeDeclaration) super.getDeclaringType();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public AnnotationValue getDefaultValue() {
-        return (sym.defaultValue == null)
-               ? null
-               : new AnnotationValueImpl(env, sym.defaultValue, null);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitAnnotationTypeElementDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java
deleted file mode 100644
index a27d675..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.SourcePosition;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Attribute;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.TypeTags;
-
-
-/**
- * Implementation of AnnotationValue
- */
- at SuppressWarnings("deprecation")
-public class AnnotationValueImpl implements AnnotationValue {
-
-    protected final AptEnv env;
-    protected final Attribute attr;
-    protected final AnnotationMirrorImpl annotation;
-
-    AnnotationValueImpl(AptEnv env, Attribute attr, AnnotationMirrorImpl annotation) {
-        this.env = env;
-        this.attr = attr;
-        this.annotation = annotation;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        Constants.Formatter fmtr = Constants.getFormatter(sb);
-
-        fmtr.append(getValue());
-        return fmtr.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object getValue() {
-        ValueVisitor vv = new ValueVisitor();
-        attr.accept(vv);
-        return vv.value;
-    }
-
-
-    public SourcePosition getPosition() {
-        // Imprecise implementation; just return position of enclosing
-        // annotation.
-        return (annotation == null) ? null : annotation.getPosition();
-    }
-
-    private class ValueVisitor implements Attribute.Visitor {
-
-        public Object value;
-
-        public void visitConstant(Attribute.Constant c) {
-            value = Constants.decodeConstant(c.value, c.type);
-        }
-
-        public void visitClass(Attribute.Class c) {
-            value = env.typeMaker.getType(
-                        env.jctypes.erasure(c.type));
-        }
-
-        public void visitEnum(Attribute.Enum e) {
-            value = env.declMaker.getFieldDeclaration(e.value);
-        }
-
-        public void visitCompound(Attribute.Compound c) {
-            value = new AnnotationMirrorImpl(env, c,
-                                             (annotation == null) ?
-                                             null :
-                                             annotation.getDeclaration());
-        }
-
-        public void visitArray(Attribute.Array a) {
-            ArrayList<AnnotationValue> vals =
-                new ArrayList<AnnotationValue>(a.values.length);
-            for (Attribute elem : a.values) {
-                vals.add(new AnnotationValueImpl(env, elem, annotation));
-            }
-            value = vals;
-        }
-
-        public void visitError(Attribute.Error e) {
-            value = "<error>";  // javac will already have logged an error msg
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java
deleted file mode 100644
index 88032b6..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Inherited;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.ClassType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of ClassDeclaration
- */
- at SuppressWarnings("deprecation")
-public class ClassDeclarationImpl extends TypeDeclarationImpl
-                                  implements ClassDeclaration {
-
-    ClassDeclarationImpl(AptEnv env, ClassSymbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     * Overridden here to handle @Inherited.
-     */
-    public <A extends Annotation> A getAnnotation(Class<A> annoType) {
-
-        boolean inherited = annoType.isAnnotationPresent(Inherited.class);
-        for (Type t = sym.type;
-             t.tsym != env.symtab.objectType.tsym && !t.isErroneous();
-             t = env.jctypes.supertype(t)) {
-
-            A result = getAnnotation(annoType, t.tsym);
-            if (result != null || !inherited) {
-                return result;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public ClassType getSuperclass() {
-        //  java.lang.Object has no superclass
-        if (sym == env.symtab.objectType.tsym) {
-            return null;
-        }
-        Type t = env.jctypes.supertype(sym.type);
-        return (ClassType) env.typeMaker.getType(t);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ConstructorDeclaration> getConstructors() {
-        ArrayList<ConstructorDeclaration> res =
-            new ArrayList<ConstructorDeclaration>();
-        for (Symbol s : getMembers(true)) {
-            if (s.isConstructor()) {
-                MethodSymbol m = (MethodSymbol) s;
-                res.add((ConstructorDeclaration)
-                        env.declMaker.getExecutableDeclaration(m));
-            }
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<MethodDeclaration> getMethods() {
-        return identityFilter.filter(super.getMethods(),
-                                     MethodDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitClassDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java
deleted file mode 100644
index 0aa13da..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.tools.apt.mirror.type.TypeMirrorImpl;
-import com.sun.tools.javac.code.Type;
-
-import static com.sun.tools.javac.code.TypeTags.*;
-
-
-/**
- * Utility class for operating on constant expressions.
- */
- at SuppressWarnings("deprecation")
-class Constants {
-
-    /**
-     * Converts a constant in javac's internal representation (in which
-     * boolean, char, byte, short, and int are each represented by an Integer)
-     * into standard representation.  Other values (including null) are
-     * returned unchanged.
-     */
-    static Object decodeConstant(Object value, Type type) {
-        if (value instanceof Integer) {
-            int i = ((Integer) value).intValue();
-            switch (type.tag) {
-            case BOOLEAN:  return Boolean.valueOf(i != 0);
-            case CHAR:     return Character.valueOf((char) i);
-            case BYTE:     return Byte.valueOf((byte) i);
-            case SHORT:    return Short.valueOf((short) i);
-            }
-        }
-        return value;
-    }
-
-    /**
-     * Returns a formatter for generating the text of constant
-     * expressions.  Equivalent to
-     * <tt>getFormatter(new StringBuilder())</tt>.
-     */
-    static Formatter getFormatter() {
-        return new Formatter(new StringBuilder());
-    }
-
-    /**
-     * Returns a formatter for generating the text of constant
-     * expressions.  Also generates the text of constant
-     * "pseudo-expressions" for annotations and array-valued
-     * annotation elements.
-     *
-     * @param buf  where the expression is written
-     */
-    static Formatter getFormatter(StringBuilder buf) {
-        return new Formatter(buf);
-    }
-
-
-    /**
-     * Utility class used to generate the text of constant
-     * expressions.  Also generates the text of constant
-     * "pseudo-expressions" for annotations and array-valued
-     * annotation elements.
-     */
-    static class Formatter {
-
-        private StringBuilder buf;      // where the output goes
-
-        private Formatter(StringBuilder buf) {
-            this.buf = buf;
-        }
-
-
-        public String toString() {
-            return buf.toString();
-        }
-
-        /**
-         * Appends a constant whose type is not statically known
-         * by dispatching to the appropriate overloaded append method.
-         */
-        void append(Object val) {
-            if (val instanceof String) {
-                append((String) val);
-            } else if (val instanceof Character) {
-                append((Character) val);
-            } else if (val instanceof Boolean) {
-                append((Boolean) val);
-            } else if (val instanceof Byte) {
-                append((Byte) val);
-            } else if (val instanceof Short) {
-                append((Short) val);
-            } else if (val instanceof Integer) {
-                append((Integer) val);
-            } else if (val instanceof Long) {
-                append((Long) val);
-            } else if (val instanceof Float) {
-                append((Float) val);
-            } else if (val instanceof Double) {
-                append((Double) val);
-            } else if (val instanceof TypeMirror) {
-                append((TypeMirrorImpl) val);
-            } else if (val instanceof EnumConstantDeclaration) {
-                append((EnumConstantDeclarationImpl) val);
-            } else if (val instanceof AnnotationMirror) {
-                append((AnnotationMirrorImpl) val);
-            } else if (val instanceof Collection<?>) {
-                append((Collection<?>) val);
-            } else {
-                appendUnquoted(val.toString());
-            }
-        }
-
-        /**
-         * Appends a string, escaped (as needed) and quoted.
-         */
-        void append(String val) {
-            buf.append('"');
-            appendUnquoted(val);
-            buf.append('"');
-        }
-
-        /**
-         * Appends a Character, escaped (as needed) and quoted.
-         */
-        void append(Character val) {
-            buf.append('\'');
-            appendUnquoted(val.charValue());
-            buf.append('\'');
-        }
-
-        void append(Boolean val) {
-            buf.append(val);
-        }
-
-        void append(Byte val) {
-            buf.append(String.format("0x%02x", val));
-        }
-
-        void append(Short val) {
-            buf.append(val);
-        }
-
-        void append(Integer val) {
-            buf.append(val);
-        }
-
-        void append(Long val) {
-            buf.append(val).append('L');
-        }
-
-        void append(Float val) {
-            if (val.isNaN()) {
-                buf.append("0.0f/0.0f");
-            } else if (val.isInfinite()) {
-                if (val.floatValue() < 0) {
-                    buf.append('-');
-                }
-                buf.append("1.0f/0.0f");
-            } else {
-                buf.append(val).append('f');
-            }
-        }
-
-        void append(Double val) {
-            if (val.isNaN()) {
-                buf.append("0.0/0.0");
-            } else if (val.isInfinite()) {
-                if (val.doubleValue() < 0) {
-                    buf.append('-');
-                }
-                buf.append("1.0/0.0");
-            } else {
-                buf.append(val);
-            }
-        }
-
-        /**
-         * Appends the class literal corresponding to a type.  Should
-         * only be invoked for types that have an associated literal.
-         * e.g:  "java.lang.String.class"
-         *       "boolean.class"
-         *       "int[].class"
-         */
-        void append(TypeMirrorImpl t) {
-            appendUnquoted(t.type.toString());
-            buf.append(".class");
-        }
-
-        /**
-         * Appends the fully qualified name of an enum constant.
-         * e.g:  "java.math.RoundingMode.UP"
-         */
-        void append(EnumConstantDeclarationImpl e) {
-            appendUnquoted(e.sym.enclClass() + "." + e);
-        }
-
-        /**
-         * Appends the text of an annotation pseudo-expression.
-         * e.g:  "@pkg.Format(linesep='\n')"
-         */
-        void append(AnnotationMirrorImpl anno) {
-            appendUnquoted(anno.toString());
-        }
-
-        /**
-         * Appends the elements of a collection, enclosed within braces
-         * and separated by ", ".  Useful for array-valued annotation
-         * elements.
-         */
-        void append(Collection<?> vals) {
-            buf.append('{');
-            boolean first = true;
-            for (Object val : vals) {
-                if (first) {
-                    first = false;
-                } else {
-                    buf.append(", ");
-                }
-                append(((AnnotationValue) val).getValue());
-            }
-            buf.append('}');
-        }
-
-
-        /**
-         * For each char of a string, append using appendUnquoted(char).
-         */
-        private void appendUnquoted(String s) {
-            for (char c : s.toCharArray()) {
-                appendUnquoted(c);
-            }
-        }
-
-        /**
-         * Appends a char (unquoted), using escapes for those that are not
-         * printable ASCII.  We don't know what is actually printable in
-         * the locale in which this result will be used, so ASCII is our
-         * best guess as to the least common denominator.
-         */
-        private void appendUnquoted(char c) {
-            switch (c) {
-            case '\b': buf.append("\\b");  break;
-            case '\t': buf.append("\\t");  break;
-            case '\n': buf.append("\\n");  break;
-            case '\f': buf.append("\\f");  break;
-            case '\r': buf.append("\\r");  break;
-            case '\"': buf.append("\\\""); break;
-            case '\'': buf.append("\\\'"); break;
-            case '\\': buf.append("\\\\"); break;
-            default:
-                if (isPrintableAscii(c)) {
-                    buf.append(c);
-                } else {
-                    buf.append(String.format("\\u%04x", (int) c));
-                }
-            }
-        }
-
-        /**
-         * Is c a printable ASCII character?
-         */
-        private static boolean isPrintableAscii(char c) {
-            return c >= ' ' && c <= '~';
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java
deleted file mode 100644
index be59686..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-
-
-/**
- * Implementation of ConstructorDeclaration
- */
- at SuppressWarnings("deprecation")
-public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl
-                                        implements ConstructorDeclaration {
-
-    ConstructorDeclarationImpl(AptEnv env, MethodSymbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     * Returns the simple name of the declaring class.
-     */
-    public String getSimpleName() {
-        return sym.enclClass().name.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitConstructorDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java
deleted file mode 100644
index 69ff36e..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.mirror.declaration;
-
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.Collection;
-import java.util.EnumSet;
-import javax.tools.JavaFileObject;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.apt.mirror.util.SourcePositionImpl;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.comp.AttrContext;
-import com.sun.tools.javac.comp.Env;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Position;
-
-import static com.sun.mirror.declaration.Modifier.*;
-import static com.sun.tools.javac.code.Kinds.*;
-
-
-/**
- * Implementation of Declaration
- */
- at SuppressWarnings("deprecation")
-public abstract class DeclarationImpl implements Declaration {
-
-    protected final AptEnv env;
-    public final Symbol sym;
-
-    protected static final DeclarationFilter identityFilter =
-            new DeclarationFilter();
-
-
-    /**
-     * "sym" should be completed before this constructor is called.
-     */
-    protected DeclarationImpl(AptEnv env, Symbol sym) {
-        this.env = env;
-        this.sym = sym;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     * <p> ParameterDeclarationImpl overrides this implementation.
-     */
-    public boolean equals(Object obj) {
-        if (obj instanceof DeclarationImpl) {
-            DeclarationImpl that = (DeclarationImpl) obj;
-            return sym == that.sym && env == that.env;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     * <p> ParameterDeclarationImpl overrides this implementation.
-     */
-    public int hashCode() {
-        return sym.hashCode() + env.hashCode();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getDocComment() {
-        // Our doc comment is contained in a map in our toplevel,
-        // indexed by our tree.  Find our enter environment, which gives
-        // us our toplevel.  It also gives us a tree that contains our
-        // tree:  walk it to find our tree.  This is painful.
-        Env<AttrContext> enterEnv = getEnterEnv();
-        if (enterEnv == null)
-            return null;
-        JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree);
-        return enterEnv.toplevel.docComments.get(tree);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<AnnotationMirror> getAnnotationMirrors() {
-        Collection<AnnotationMirror> res =
-            new ArrayList<AnnotationMirror>();
-        for (Attribute.Compound a : sym.getAnnotationMirrors()) {
-            res.add(env.declMaker.getAnnotationMirror(a, this));
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     * Overridden by ClassDeclarationImpl to handle @Inherited.
-     */
-    public <A extends Annotation> A getAnnotation(Class<A> annoType) {
-        return getAnnotation(annoType, sym);
-    }
-
-    protected <A extends Annotation> A getAnnotation(Class<A> annoType,
-                                                     Symbol annotated) {
-        if (!annoType.isAnnotation()) {
-            throw new IllegalArgumentException(
-                                "Not an annotation type: " + annoType);
-        }
-        String name = annoType.getName();
-        for (Attribute.Compound attr : annotated.getAnnotationMirrors()) {
-            if (name.equals(attr.type.tsym.flatName().toString())) {
-                return AnnotationProxyMaker.generateAnnotation(env, attr,
-                                                               annoType);
-            }
-        }
-        return null;
-    }
-
-    // Cache for modifiers.
-    private EnumSet<Modifier> modifiers = null;
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<Modifier> getModifiers() {
-        if (modifiers == null) {
-            modifiers = EnumSet.noneOf(Modifier.class);
-            long flags = AptEnv.getFlags(sym);
-
-            if (0 != (flags & Flags.PUBLIC))       modifiers.add(PUBLIC);
-            if (0 != (flags & Flags.PROTECTED))    modifiers.add(PROTECTED);
-            if (0 != (flags & Flags.PRIVATE))      modifiers.add(PRIVATE);
-            if (0 != (flags & Flags.ABSTRACT))     modifiers.add(ABSTRACT);
-            if (0 != (flags & Flags.STATIC))       modifiers.add(STATIC);
-            if (0 != (flags & Flags.FINAL))        modifiers.add(FINAL);
-            if (0 != (flags & Flags.TRANSIENT))    modifiers.add(TRANSIENT);
-            if (0 != (flags & Flags.VOLATILE))     modifiers.add(VOLATILE);
-            if (0 != (flags & Flags.SYNCHRONIZED)) modifiers.add(SYNCHRONIZED);
-            if (0 != (flags & Flags.NATIVE))       modifiers.add(NATIVE);
-            if (0 != (flags & Flags.STRICTFP))     modifiers.add(STRICTFP);
-        }
-        return modifiers;
-    }
-
-    /**
-     * {@inheritDoc}
-     * Overridden in some subclasses.
-     */
-    public String getSimpleName() {
-        return sym.name.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public SourcePosition getPosition() {
-        // Find the toplevel.  From there use a tree-walking utility
-        // that finds the tree for our symbol, and with it the position.
-        Env<AttrContext> enterEnv = getEnterEnv();
-        if (enterEnv == null)
-            return null;
-        JCTree.JCCompilationUnit toplevel = enterEnv.toplevel;
-        JavaFileObject sourcefile = toplevel.sourcefile;
-        if (sourcefile == null)
-            return null;
-        int pos = TreeInfo.positionFor(sym, toplevel);
-
-        return new SourcePositionImpl(sourcefile, pos, toplevel.lineMap);
-    }
-
-    /**
-     * Applies a visitor to this declaration.
-     *
-     * @param v the visitor operating on this declaration
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitDeclaration(this);
-    }
-
-
-    private Collection<Symbol> members = null;  // cache for getMembers()
-
-    /**
-     * Returns the symbols of type or package members (and constructors)
-     * that are not synthetic or otherwise unwanted.
-     * Caches the result if "cache" is true.
-     */
-    protected Collection<Symbol> getMembers(boolean cache) {
-        if (members != null) {
-            return members;
-        }
-        LinkedList<Symbol> res = new LinkedList<Symbol>();
-        for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
-            if (e.sym != null && !unwanted(e.sym)) {
-                res.addFirst(e.sym);
-            }
-        }
-        return cache ? (members = res) : res;
-    }
-
-    /**
-     * Tests whether this is a symbol that should never be seen by clients,
-     * such as a synthetic class.
-     * Note that a class synthesized by the compiler may not be flagged as
-     * synthetic:  see bugid 4959932.
-     */
-    private static boolean unwanted(Symbol s) {
-        return AptEnv.hasFlag(s, Flags.SYNTHETIC) ||
-               (s.kind == TYP &&
-                !DeclarationMaker.isJavaIdentifier(s.name.toString()));
-    }
-
-    /**
-     * Returns this declaration's enter environment, or null if it
-     * has none.
-     */
-    private Env<AttrContext> getEnterEnv() {
-        // Get enclosing class of sym, or sym itself if it is a class
-        // or package.
-        TypeSymbol ts = (sym.kind != PCK)
-                        ? sym.enclClass()
-                        : (PackageSymbol) sym;
-        return (ts != null)
-                ? env.enter.getEnv(ts)
-                : null;
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java
deleted file mode 100644
index 8e9f617..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, 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.apt.mirror.declaration;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.sun.mirror.declaration.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.main.JavaCompiler;
-
-/**
- * Utilities for constructing and caching declarations.
- */
- at SuppressWarnings("deprecation")
-public class DeclarationMaker {
-
-    private AptEnv env;
-    private Context context;
-    private JavaCompiler javacompiler;
-    private static final Context.Key<DeclarationMaker> declarationMakerKey =
-            new Context.Key<DeclarationMaker>();
-
-    public static DeclarationMaker instance(Context context) {
-        DeclarationMaker instance = context.get(declarationMakerKey);
-        if (instance == null) {
-            instance = new DeclarationMaker(context);
-        }
-        return instance;
-    }
-
-    private DeclarationMaker(Context context) {
-        context.put(declarationMakerKey, this);
-        env = AptEnv.instance(context);
-        this.context = context;
-        this.javacompiler = JavaCompiler.instance(context);
-    }
-
-
-
-    // Cache of package declarations
-    private Map<PackageSymbol, PackageDeclaration> packageDecls =
-            new HashMap<PackageSymbol, PackageDeclaration>();
-
-    /**
-     * Returns the package declaration for a package symbol.
-     */
-    public PackageDeclaration getPackageDeclaration(PackageSymbol p) {
-        PackageDeclaration res = packageDecls.get(p);
-        if (res == null) {
-            res = new PackageDeclarationImpl(env, p);
-            packageDecls.put(p, res);
-        }
-        return res;
-    }
-
-    /**
-     * Returns the package declaration for the package with the given name.
-     * Name is fully-qualified, or "" for the unnamed package.
-     * Returns null if package declaration not found.
-     */
-    public PackageDeclaration getPackageDeclaration(String name) {
-        PackageSymbol p = null;
-        if (name.equals("") )
-            p = env.symtab.unnamedPackage;
-        else {
-            if (!isJavaName(name))
-                return null;
-            Symbol s = nameToSymbol(name, false);
-            if (s instanceof PackageSymbol) {
-                p = (PackageSymbol) s;
-                if (!p.exists())
-                    return null;
-            } else
-                return null;
-        }
-        return getPackageDeclaration(p);
-    }
-
-    // Cache of type declarations
-    private Map<ClassSymbol, TypeDeclaration> typeDecls =
-            new HashMap<ClassSymbol, TypeDeclaration>();
-
-    /**
-     * Returns the type declaration for a class symbol.
-     * Forces completion, and returns null on error.
-     */
-    public TypeDeclaration getTypeDeclaration(ClassSymbol c) {
-        long flags = AptEnv.getFlags(c);        // forces symbol completion
-        if (c.kind == Kinds.ERR) {
-            return null;
-        }
-        TypeDeclaration res = typeDecls.get(c);
-        if (res == null) {
-            if ((flags & Flags.ANNOTATION) != 0) {
-                res = new AnnotationTypeDeclarationImpl(env, c);
-            } else if ((flags & Flags.INTERFACE) != 0) {
-                res = new InterfaceDeclarationImpl(env, c);
-            } else if ((flags & Flags.ENUM) != 0) {
-                res = new EnumDeclarationImpl(env, c);
-            } else {
-                res = new ClassDeclarationImpl(env, c);
-            }
-            typeDecls.put(c, res);
-        }
-        return res;
-    }
-
-    /**
-     * Returns the type declaration for the type with the given canonical name.
-     * Returns null if type declaration not found.
-     */
-    public TypeDeclaration getTypeDeclaration(String name) {
-        if (!isJavaName(name))
-            return null;
-        Symbol s = nameToSymbol(name, true);
-        if (s instanceof ClassSymbol) {
-            ClassSymbol c = (ClassSymbol) s;
-            return getTypeDeclaration(c);
-        } else
-            return null;
-    }
-
-    /**
-     * Returns a symbol given the type's or packages's canonical name,
-     * or null if the name isn't found.
-     */
-    private Symbol nameToSymbol(String name, boolean classCache) {
-        Symbol s = null;
-        Name nameName = env.names.fromString(name);
-        if (classCache)
-            s = env.symtab.classes.get(nameName);
-        else
-            s = env.symtab.packages.get(nameName);
-
-        if (s != null && s.exists())
-            return s;
-
-        s = javacompiler.resolveIdent(name);
-        if (s.kind == Kinds.ERR  )
-            return null;
-
-        if (s.kind == Kinds.PCK)
-            s.complete();
-
-        return s;
-    }
-
-    // Cache of method and constructor declarations
-    private Map<MethodSymbol, ExecutableDeclaration> executableDecls =
-            new HashMap<MethodSymbol, ExecutableDeclaration>();
-
-    /**
-     * Returns the method or constructor declaration for a method symbol.
-     */
-    ExecutableDeclaration getExecutableDeclaration(MethodSymbol m) {
-        ExecutableDeclaration res = executableDecls.get(m);
-        if (res == null) {
-            if (m.isConstructor()) {
-                res = new ConstructorDeclarationImpl(env, m);
-            } else if (isAnnotationTypeElement(m)) {
-                res = new AnnotationTypeElementDeclarationImpl(env, m);
-            } else {
-                res = new MethodDeclarationImpl(env, m);
-            }
-            executableDecls.put(m, res);
-        }
-        return res;
-    }
-
-    // Cache of field declarations
-    private Map<VarSymbol, FieldDeclaration> fieldDecls =
-            new HashMap<VarSymbol, FieldDeclaration>();
-
-    /**
-     * Returns the field declaration for a var symbol.
-     */
-    FieldDeclaration getFieldDeclaration(VarSymbol v) {
-        FieldDeclaration res = fieldDecls.get(v);
-        if (res == null) {
-            if (hasFlag(v, Flags.ENUM)) {
-                res = new EnumConstantDeclarationImpl(env, v);
-            } else {
-                res = new FieldDeclarationImpl(env, v);
-            }
-            fieldDecls.put(v, res);
-        }
-        return res;
-    }
-
-    /**
-     * Returns a parameter declaration.
-     */
-    ParameterDeclaration getParameterDeclaration(VarSymbol v) {
-        return new ParameterDeclarationImpl(env, v);
-    }
-
-    /**
-     * Returns a type parameter declaration.
-     */
-    public TypeParameterDeclaration getTypeParameterDeclaration(TypeSymbol t) {
-        return new TypeParameterDeclarationImpl(env, t);
-    }
-
-    /**
-     * Returns an annotation.
-     */
-    AnnotationMirror getAnnotationMirror(Attribute.Compound a, Declaration decl) {
-        return new AnnotationMirrorImpl(env, a, decl);
-    }
-
-
-    /**
-     * Is a string a valid Java identifier?
-     */
-    public static boolean isJavaIdentifier(String id) {
-        return javax.lang.model.SourceVersion.isIdentifier(id);
-    }
-
-    public static boolean isJavaName(String name) {
-        for(String id: name.split("\\.")) {
-            if (! isJavaIdentifier(id))
-                return false;
-        }
-        return true;
-    }
-
-    /**
-     * Is a method an annotation type element?
-     * It is if it's declared in an annotation type.
-     */
-    private static boolean isAnnotationTypeElement(MethodSymbol m) {
-        return hasFlag(m.enclClass(), Flags.ANNOTATION);
-    }
-
-    /**
-     * Does a symbol have a given flag?
-     */
-    private static boolean hasFlag(Symbol s, long flag) {
-        return AptEnv.hasFlag(s, flag);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java
deleted file mode 100644
index 2e6b936..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-
-
-/**
- * Implementation of EnumConstantDeclaration
- */
- at SuppressWarnings("deprecation")
-public class EnumConstantDeclarationImpl extends FieldDeclarationImpl
-                                         implements EnumConstantDeclaration {
-
-    EnumConstantDeclarationImpl(AptEnv env, VarSymbol sym) {
-        super(env, sym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public EnumDeclaration getDeclaringType() {
-        return (EnumDeclaration) super.getDeclaringType();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitEnumConstantDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java
deleted file mode 100644
index e5cce78..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of EnumDeclaration
- */
- at SuppressWarnings("deprecation")
-public class EnumDeclarationImpl extends ClassDeclarationImpl
-                                 implements EnumDeclaration {
-
-    EnumDeclarationImpl(AptEnv env, ClassSymbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<EnumConstantDeclaration> getEnumConstants() {
-        return identityFilter.filter(getFields(),
-                                     EnumConstantDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitEnumDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java
deleted file mode 100644
index 5ff1c13..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of ExecutableDeclaration
- */
- at SuppressWarnings("deprecation")
-public abstract class ExecutableDeclarationImpl extends MemberDeclarationImpl
-                                             implements ExecutableDeclaration {
-    public MethodSymbol sym;
-
-    protected ExecutableDeclarationImpl(AptEnv env, MethodSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns type parameters (if any), method name, and signature
-     * (value parameter types).
-     */
-    public String toString() {
-        return sym.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isVarArgs() {
-        return AptEnv.hasFlag(sym, Flags.VARARGS);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ParameterDeclaration> getParameters() {
-        Collection<ParameterDeclaration> res =
-            new ArrayList<ParameterDeclaration>();
-        for (VarSymbol param : sym.params())
-            res.add(env.declMaker.getParameterDeclaration(param));
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ReferenceType> getThrownTypes() {
-        ArrayList<ReferenceType> res = new ArrayList<ReferenceType>();
-        for (Type t : sym.type.getThrownTypes()) {
-            res.add((ReferenceType) env.typeMaker.getType(t));
-        }
-        return res;
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java
deleted file mode 100644
index 5122693..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.TypeTags;
-
-
-/**
- * Implementation of FieldDeclaration
- */
- at SuppressWarnings("deprecation")
-class FieldDeclarationImpl extends MemberDeclarationImpl
-                                  implements FieldDeclaration {
-
-    protected VarSymbol sym;
-
-    FieldDeclarationImpl(AptEnv env, VarSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns the field's name.
-     */
-    public String toString() {
-        return getSimpleName();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeMirror getType() {
-        return env.typeMaker.getType(sym.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Object getConstantValue() {
-        Object val = sym.getConstValue();
-        // val may be null, indicating that this is not a constant.
-
-        return Constants.decodeConstant(val, sym.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getConstantExpression() {
-        Object val = getConstantValue();
-        if (val == null) {
-            return null;
-        }
-        Constants.Formatter fmtr = Constants.getFormatter();
-        fmtr.append(val);
-        return fmtr.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitFieldDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java
deleted file mode 100644
index 5aa2211..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of InterfaceDeclaration
- */
- at SuppressWarnings("deprecation")
-public class InterfaceDeclarationImpl extends TypeDeclarationImpl
-                                      implements InterfaceDeclaration {
-
-    InterfaceDeclarationImpl(AptEnv env, ClassSymbol sym) {
-        super(env, sym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitInterfaceDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java
deleted file mode 100644
index 7a24fd7..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of MemberDeclaration
- */
- at SuppressWarnings("deprecation")
-public abstract class MemberDeclarationImpl extends DeclarationImpl
-                                            implements MemberDeclaration {
-
-    protected MemberDeclarationImpl(AptEnv env, Symbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeDeclaration getDeclaringType() {
-        ClassSymbol c = getDeclaringClassSymbol();
-        return (c == null)
-            ? null
-            : env.declMaker.getTypeDeclaration(c);
-    }
-
-    /**
-     * {@inheritDoc}
-     * For methods, constructors, and types.
-     */
-    public Collection<TypeParameterDeclaration> getFormalTypeParameters() {
-        ArrayList<TypeParameterDeclaration> res =
-            new ArrayList<TypeParameterDeclaration>();
-        for (Type t : sym.type.getTypeArguments()) {
-            res.add(env.declMaker.getTypeParameterDeclaration(t.tsym));
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitMemberDeclaration(this);
-    }
-
-
-    /**
-     * Returns the ClassSymbol of the declaring type,
-     * or null if this is a top-level type.
-     */
-    private ClassSymbol getDeclaringClassSymbol() {
-        return sym.owner.enclClass();
-    }
-
-    /**
-     * Returns the formal type parameters of a type, member or constructor
-     * as an angle-bracketed string.  Each parameter consists of the simple
-     * type variable name and any bounds (with no implicit "extends Object"
-     * clause added).  Type names are qualified.
-     * Returns "" if there are no type parameters.
-     */
-    protected static String typeParamsToString(AptEnv env, Symbol sym) {
-        if (sym.type.getTypeArguments().isEmpty()) {
-            return "";
-        }
-        StringBuilder s = new StringBuilder();
-        for (Type t : sym.type.getTypeArguments()) {
-            Type.TypeVar tv = (Type.TypeVar) t;
-            s.append(s.length() == 0 ? "<" : ", ")
-             .append(TypeParameterDeclarationImpl.toString(env, tv));
-        }
-        s.append(">");
-        return s.toString();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java
deleted file mode 100644
index a4c7dcd..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.declaration;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-
-
-/**
- * Implementation of MethodDeclaration
- */
- at SuppressWarnings("deprecation")
-public class MethodDeclarationImpl extends ExecutableDeclarationImpl
-                                   implements MethodDeclaration {
-
-    MethodDeclarationImpl(AptEnv env, MethodSymbol sym) {
-        super(env, sym);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeMirror getReturnType() {
-        return env.typeMaker.getType(sym.type.getReturnType());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitMethodDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java
deleted file mode 100644
index 0b839f2..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, 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.apt.mirror.declaration;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of PackageDeclaration.
- */
- at SuppressWarnings("deprecation")
-public class PackageDeclarationImpl extends DeclarationImpl
-                                    implements PackageDeclaration {
-
-    private PackageSymbol sym;
-
-
-    public PackageDeclarationImpl(AptEnv env, PackageSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns the qualified name.
-     */
-    public String toString() {
-        return getQualifiedName();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getQualifiedName() {
-        return sym.getQualifiedName().toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ClassDeclaration> getClasses() {
-        return identityFilter.filter(getAllTypes(),
-                                     ClassDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<EnumDeclaration> getEnums() {
-        return identityFilter.filter(getAllTypes(),
-                                     EnumDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<InterfaceDeclaration> getInterfaces() {
-        return identityFilter.filter(getAllTypes(),
-                                     InterfaceDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
-        return identityFilter.filter(getAllTypes(),
-                                     AnnotationTypeDeclaration.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitPackageDeclaration(this);
-    }
-
-
-    // Cache of all top-level type declarations in this package.
-    private Collection<TypeDeclaration> allTypes = null;
-
-    /**
-     * Caches and returns all top-level type declarations in this package.
-     * Omits synthetic types.
-     */
-    private Collection<TypeDeclaration> getAllTypes() {
-        if (allTypes != null) {
-            return allTypes;
-        }
-        allTypes = new ArrayList<TypeDeclaration>();
-        for (Symbol s : getMembers(false)) {
-            allTypes.add(env.declMaker.getTypeDeclaration((ClassSymbol) s));
-        }
-        return allTypes;
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java
deleted file mode 100644
index 1d53920..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.TypeMirror;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-
-
-/**
- * Implementation of ParameterDeclaration
- */
- at SuppressWarnings("deprecation")
-public class ParameterDeclarationImpl extends DeclarationImpl
-                                      implements ParameterDeclaration
-{
-    protected VarSymbol sym;
-
-
-    ParameterDeclarationImpl(AptEnv env, VarSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns the simple name of the parameter.
-     */
-    public String toString() {
-        return getType() + " " + sym.name;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(Object obj) {
-        // Neither ParameterDeclarationImpl objects nor their symbols
-        // are cached by the current implementation, so check symbol
-        // owners and names.
-
-        if (obj instanceof ParameterDeclarationImpl) {
-            ParameterDeclarationImpl that = (ParameterDeclarationImpl) obj;
-            return sym.owner == that.sym.owner &&
-                   sym.name == that.sym.name &&
-                   env == that.env;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int hashCode() {
-        return sym.owner.hashCode() + sym.name.hashCode() + env.hashCode();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeMirror getType() {
-        return env.typeMaker.getType(sym.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitParameterDeclaration(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java
deleted file mode 100644
index 6f926aa..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.Name;
-
-/**
- * Implementation of TypeDeclaration
- */
- at SuppressWarnings("deprecation")
-public class TypeDeclarationImpl extends MemberDeclarationImpl
-                                 implements TypeDeclaration {
-
-    public ClassSymbol sym;
-
-
-    /**
-     * "sym" should be completed before this constructor is called.
-     */
-     protected TypeDeclarationImpl(AptEnv env, ClassSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns the type's name, with any type parameters (including those
-     * of outer classes).  Type names are qualified.
-     */
-    public String toString() {
-        return toString(env, sym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public PackageDeclaration getPackage() {
-        return env.declMaker.getPackageDeclaration(sym.packge());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public String getQualifiedName() {
-        return sym.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<InterfaceType> getSuperinterfaces() {
-        return env.typeMaker.getTypes(env.jctypes.interfaces(sym.type),
-                                      InterfaceType.class);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<FieldDeclaration> getFields() {
-        ArrayList<FieldDeclaration> res = new ArrayList<FieldDeclaration>();
-        for (Symbol s : getMembers(true)) {
-            if (s.kind == Kinds.VAR) {
-                res.add(env.declMaker.getFieldDeclaration((VarSymbol) s));
-            }
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<? extends MethodDeclaration> getMethods() {
-        ArrayList<MethodDeclaration> res = new ArrayList<MethodDeclaration>();
-        for (Symbol s : getMembers(true)) {
-            if (s.kind == Kinds.MTH && !s.isConstructor() &&
-                !env.names.clinit.equals(s.name) ) { // screen out static initializers
-                MethodSymbol m = (MethodSymbol) s;
-                res.add((MethodDeclaration)
-                        env.declMaker.getExecutableDeclaration(m));
-            }
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<TypeDeclaration> getNestedTypes() {
-        ArrayList<TypeDeclaration> res = new ArrayList<TypeDeclaration>();
-        for (Symbol s : getMembers(true)) {
-            if (s.kind == Kinds.TYP) {
-                res.add(env.declMaker.getTypeDeclaration((ClassSymbol) s));
-            }
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitTypeDeclaration(this);
-    }
-
-
-    /**
-     * Returns a type's name, with any type parameters (including those
-     * of outer classes).  Type names are qualified.
-     */
-    static String toString(AptEnv env, ClassSymbol c) {
-        StringBuilder sb = new StringBuilder();
-        if (c.isInner()) {
-            // c is an inner class, so include type params of outer.
-            ClassSymbol enclosing = c.owner.enclClass();
-            sb.append(toString(env, enclosing))
-              .append('.')
-              .append(c.name);
-        } else {
-            sb.append(c);
-        }
-        sb.append(typeParamsToString(env, c));
-        return sb.toString();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java b/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java
deleted file mode 100644
index 30563fa..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.declaration;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.ReferenceType;
-import com.sun.mirror.util.DeclarationVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of TypeParameterDeclaration
- */
- at SuppressWarnings("deprecation")
-public class TypeParameterDeclarationImpl extends DeclarationImpl
-                                          implements TypeParameterDeclaration
-{
-    protected TypeSymbol sym;
-
-
-    TypeParameterDeclarationImpl(AptEnv env, TypeSymbol sym) {
-        super(env, sym);
-        this.sym = sym;
-    }
-
-
-    /**
-     * Returns the type parameter's name along with any "extends" clause.
-     * Class names are qualified.  No implicit "extends Object" is added.
-     */
-    public String toString() {
-        return toString(env, (Type.TypeVar) sym.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ReferenceType> getBounds() {
-        ArrayList<ReferenceType> res = new ArrayList<ReferenceType>();
-        for (Type t : env.jctypes.getBounds((Type.TypeVar) sym.type)) {
-            res.add((ReferenceType) env.typeMaker.getType(t));
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Declaration getOwner() {
-        Symbol owner = sym.owner;
-        return ((owner.kind & Kinds.TYP) != 0)
-               ? env.declMaker.getTypeDeclaration((ClassSymbol) owner)
-               : env.declMaker.getExecutableDeclaration((MethodSymbol) owner);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(DeclarationVisitor v) {
-        v.visitTypeParameterDeclaration(this);
-    }
-
-
-    /**
-     * Returns the type parameter's name along with any "extends" clause.
-     * See {@link #toString()} for details.
-     */
-    static String toString(AptEnv env, Type.TypeVar tv) {
-        StringBuilder s = new StringBuilder();
-        s.append(tv);
-        boolean first = true;
-        for (Type bound : getExtendsBounds(env, tv)) {
-            s.append(first ? " extends " : " & ");
-            s.append(env.typeMaker.typeToString(bound));
-            first = false;
-        }
-        return s.toString();
-    }
-
-    /**
-     * Returns the bounds of a type variable, eliding java.lang.Object
-     * if it appears alone.
-     */
-    private static Iterable<Type> getExtendsBounds(AptEnv env,
-                                                   Type.TypeVar tv) {
-        return (tv.getUpperBound().tsym == env.symtab.objectType.tsym)
-               ? com.sun.tools.javac.util.List.<Type>nil()
-               : env.jctypes.getBounds(tv);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java
deleted file mode 100644
index b31998b..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of AnnotationType
- */
- at SuppressWarnings("deprecation")
-public class AnnotationTypeImpl extends InterfaceTypeImpl
-                                implements AnnotationType {
-
-    AnnotationTypeImpl(AptEnv env, Type.ClassType type) {
-        super(env, type);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public AnnotationTypeDeclaration getDeclaration() {
-        return (AnnotationTypeDeclaration) super.getDeclaration();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitAnnotationType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java
deleted file mode 100644
index 8c4223a..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of ArrayType
- */
- at SuppressWarnings("deprecation")
-public class ArrayTypeImpl extends TypeMirrorImpl implements ArrayType {
-
-    protected Type.ArrayType type;
-
-
-    ArrayTypeImpl(AptEnv env, Type.ArrayType type) {
-        super(env, type);
-        this.type = type;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeMirror getComponentType() {
-        return env.typeMaker.getType(type.elemtype);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitArrayType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java
deleted file mode 100644
index 6813a73..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of ClassType
- */
- at SuppressWarnings("deprecation")
-public class ClassTypeImpl extends DeclaredTypeImpl implements ClassType {
-
-    ClassTypeImpl(AptEnv env, Type.ClassType type) {
-        super(env, type);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ClassDeclaration getDeclaration() {
-        return (ClassDeclaration) super.getDeclaration();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public ClassType getSuperclass() {
-        //  java.lang.Object has no superclass
-        if (type.tsym == env.symtab.objectType.tsym) {
-            return null;
-        }
-        Type sup = env.jctypes.supertype(type);
-        return (ClassType) env.typeMaker.getType(sup);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitClassType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java
deleted file mode 100644
index 7e0eb34..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.type;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.TypeDeclaration;
-import com.sun.mirror.type.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-
-
-/**
- * Implementation of DeclaredType
- */
- at SuppressWarnings("deprecation")
-abstract class DeclaredTypeImpl extends TypeMirrorImpl
-                                implements DeclaredType {
-
-    protected Type.ClassType type;
-
-
-    protected DeclaredTypeImpl(AptEnv env, Type.ClassType type) {
-        super(env, type);
-        this.type = type;
-    }
-
-
-    /**
-     * Returns a string representation of this declared type.
-     * This includes the type's name and any actual type arguments.
-     * Type names are qualified.
-     */
-    public String toString() {
-        return toString(env, type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeDeclaration getDeclaration() {
-        return env.declMaker.getTypeDeclaration((ClassSymbol) type.tsym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public DeclaredType getContainingType() {
-        if (type.getEnclosingType().tag == TypeTags.CLASS) {
-            // This is the type of an inner class.
-            return (DeclaredType) env.typeMaker.getType(type.getEnclosingType());
-        }
-        ClassSymbol enclosing = type.tsym.owner.enclClass();
-        if (enclosing != null) {
-            // Nested but not inner.  Return the raw type of the enclosing
-            // class or interface.
-            // See java.lang.reflect.ParameterizedType.getOwnerType().
-            return (DeclaredType) env.typeMaker.getType(
-                                        env.jctypes.erasure(enclosing.type));
-        }
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<TypeMirror> getActualTypeArguments() {
-        return env.typeMaker.getTypes(type.getTypeArguments());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<InterfaceType> getSuperinterfaces() {
-        return env.typeMaker.getTypes(env.jctypes.interfaces(type),
-                                      InterfaceType.class);
-    }
-
-
-    /**
-     * Returns a string representation of this declared type.
-     * See {@link #toString()} for details.
-     */
-    static String toString(AptEnv env, Type.ClassType c) {
-        return c.toString();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java
deleted file mode 100644
index 0eec936..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of EnumType
- */
- at SuppressWarnings("deprecation")
-public class EnumTypeImpl extends ClassTypeImpl implements EnumType {
-
-    EnumTypeImpl(AptEnv env, Type.ClassType type) {
-        super(env, type);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public EnumDeclaration getDeclaration() {
-        return (EnumDeclaration) super.getDeclaration();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitEnumType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java
deleted file mode 100644
index 3d9cd50..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of InterfaceType
- */
- at SuppressWarnings("deprecation")
-public class InterfaceTypeImpl extends DeclaredTypeImpl
-                               implements InterfaceType {
-
-    InterfaceTypeImpl(AptEnv env, Type.ClassType type) {
-        super(env, type);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public InterfaceDeclaration getDeclaration() {
-        return (InterfaceDeclaration) super.getDeclaration();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitInterfaceType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java
deleted file mode 100644
index 973227f..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-
-import com.sun.mirror.type.PrimitiveType;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Type;
-
-import static com.sun.mirror.type.PrimitiveType.Kind.*;
-
-
-/**
- * Implementation of PrimitiveType.
- */
- at SuppressWarnings("deprecation")
-class PrimitiveTypeImpl extends TypeMirrorImpl implements PrimitiveType {
-
-    private final Kind kind;    // the kind of primitive
-
-
-    PrimitiveTypeImpl(AptEnv env, Kind kind) {
-        super(env, getType(env, kind));
-        this.kind = kind;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Kind getKind() {
-        return kind;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitPrimitiveType(this);
-    }
-
-
-    /**
-     * Returns the javac type corresponding to a kind of primitive type.
-     */
-    private static Type getType(AptEnv env, Kind kind) {
-        switch (kind) {
-        case BOOLEAN:   return env.symtab.booleanType;
-        case BYTE:      return env.symtab.byteType;
-        case SHORT:     return env.symtab.shortType;
-        case INT:       return env.symtab.intType;
-        case LONG:      return env.symtab.longType;
-        case CHAR:      return env.symtab.charType;
-        case FLOAT:     return env.symtab.floatType;
-        case DOUBLE:    return env.symtab.doubleType;
-        default:        throw new AssertionError();
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java b/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java
deleted file mode 100644
index 3fbd391..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.type.*;
-import com.sun.mirror.type.PrimitiveType.Kind;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.util.Context;
-
-import static com.sun.tools.javac.code.TypeTags.*;
-
-
-/**
- * Utilities for constructing type objects.
- */
- at SuppressWarnings("deprecation")
-public class TypeMaker {
-
-    private final AptEnv env;
-    private final VoidType voidType;
-    private PrimitiveType[] primTypes = new PrimitiveType[VOID];
-                                                // VOID is past all prim types
-
-
-    private static final Context.Key<TypeMaker> typeMakerKey =
-            new Context.Key<TypeMaker>();
-
-    public static TypeMaker instance(Context context) {
-        TypeMaker instance = context.get(typeMakerKey);
-        if (instance == null) {
-            instance = new TypeMaker(context);
-        }
-        return instance;
-    }
-
-    private TypeMaker(Context context) {
-        context.put(typeMakerKey, this);
-        env = AptEnv.instance(context);
-
-        voidType = new VoidTypeImpl(env);
-        primTypes[BOOLEAN] = new PrimitiveTypeImpl(env, Kind.BOOLEAN);
-        primTypes[BYTE]    = new PrimitiveTypeImpl(env, Kind.BYTE);
-        primTypes[SHORT]   = new PrimitiveTypeImpl(env, Kind.SHORT);
-        primTypes[INT]     = new PrimitiveTypeImpl(env, Kind.INT);
-        primTypes[LONG]    = new PrimitiveTypeImpl(env, Kind.LONG);
-        primTypes[CHAR]    = new PrimitiveTypeImpl(env, Kind.CHAR);
-        primTypes[FLOAT]   = new PrimitiveTypeImpl(env, Kind.FLOAT);
-        primTypes[DOUBLE]  = new PrimitiveTypeImpl(env, Kind.DOUBLE);
-    }
-
-
-    /**
-     * Returns the TypeMirror corresponding to a javac Type object.
-     */
-    public TypeMirror getType(Type t) {
-        if (t.isPrimitive()) {
-            return primTypes[t.tag];
-        }
-        switch (t.tag) {
-        case ERROR:     // fall through
-        case CLASS:     return getDeclaredType((Type.ClassType) t);
-        case WILDCARD:  return new WildcardTypeImpl(env, (Type.WildcardType) t);
-        case TYPEVAR:   return new TypeVariableImpl(env, (Type.TypeVar) t);
-        case ARRAY:     return new ArrayTypeImpl(env, (Type.ArrayType) t);
-        case VOID:      return voidType;
-        default:        throw new AssertionError();
-        }
-    }
-
-    /**
-     * Returns the declared type corresponding to a given ClassType.
-     */
-    public DeclaredType getDeclaredType(Type.ClassType t) {
-        return
-            hasFlag(t.tsym, Flags.ANNOTATION) ? new AnnotationTypeImpl(env, t) :
-            hasFlag(t.tsym, Flags.INTERFACE)  ? new InterfaceTypeImpl(env, t) :
-            hasFlag(t.tsym, Flags.ENUM)       ? new EnumTypeImpl(env, t) :
-                                                new ClassTypeImpl(env, t);
-    }
-
-    /**
-     * Returns a collection of types corresponding to a list of javac Type
-     * objects.
-     */
-    public Collection<TypeMirror> getTypes(Iterable<Type> types) {
-        return getTypes(types, TypeMirror.class);
-    }
-
-    /**
-     * Returns a collection of types corresponding to a list of javac Type
-     * objects.  The element type of the result is specified explicitly.
-     */
-    public <T extends TypeMirror> Collection<T> getTypes(Iterable<Type> types,
-                                                         Class<T> resType) {
-        ArrayList<T> res = new ArrayList<T>();
-        for (Type t : types) {
-            TypeMirror mir = getType(t);
-            if (resType.isInstance(mir)) {
-                res.add(resType.cast(mir));
-            }
-        }
-        return res;
-    }
-
-    /**
-     * Returns the string representation of a type.
-     * Bounds of type variables are not included; bounds of wildcard types are.
-     * Type names are qualified.
-     */
-    public String typeToString(Type t) {
-        switch (t.tag) {
-        case ARRAY:
-            return typeToString(env.jctypes.elemtype(t)) + "[]";
-        case CLASS:
-            Type.ClassType c = (Type.ClassType) t;
-            return DeclaredTypeImpl.toString(env, c);
-        case WILDCARD:
-            Type.WildcardType a = (Type.WildcardType) t;
-            return WildcardTypeImpl.toString(env, a);
-        default:
-            return t.tsym.toString();
-        }
-    }
-
-
-    /**
-     * Does a symbol have a given flag?
-     */
-    private static boolean hasFlag(Symbol s, long flag) {
-        return AptEnv.hasFlag(s, flag);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java
deleted file mode 100644
index 0e9e23d..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.apt.mirror.type;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-
-
-/**
- * Implementation of TypeMirror
- */
- at SuppressWarnings("deprecation")
-public abstract class TypeMirrorImpl implements TypeMirror {
-
-    protected final AptEnv env;
-    public final Type type;
-
-
-    protected TypeMirrorImpl(AptEnv env, Type type) {
-        this.env = env;
-        this.type = type;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public String toString() {
-        return type.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean equals(Object obj) {
-        if (obj instanceof TypeMirrorImpl) {
-            TypeMirrorImpl that = (TypeMirrorImpl) obj;
-            return env.jctypes.isSameType(this.type, that.type);
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int hashCode() {
-        return Types.hashCode(type);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java
deleted file mode 100644
index 53a9dc0..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2004, 2009, 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.apt.mirror.type;
-
-
-import java.util.Collection;
-import java.util.ArrayList;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.Symbol.TypeSymbol;
-import com.sun.tools.javac.code.Type;
-
-
-/**
- * Implementation of TypeVariable
- */
- at SuppressWarnings("deprecation")
-public class TypeVariableImpl extends TypeMirrorImpl implements TypeVariable {
-
-    protected Type.TypeVar type;
-
-
-    TypeVariableImpl(AptEnv env, Type.TypeVar type) {
-        super(env, type);
-        this.type = type;
-    }
-
-
-    /**
-     * Returns the simple name of this type variable.  Bounds are
-     * not included.
-     */
-    public String toString() {
-        return type.tsym.name.toString();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeParameterDeclaration getDeclaration() {
-        TypeSymbol sym = type.tsym;
-        return env.declMaker.getTypeParameterDeclaration(sym);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitTypeVariable(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java
deleted file mode 100644
index 7150f5f..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import com.sun.mirror.type.VoidType;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-
-
-/**
- * Implementation of VoidType.
- */
- at SuppressWarnings("deprecation")
-class VoidTypeImpl extends TypeMirrorImpl implements VoidType {
-
-    VoidTypeImpl(AptEnv env) {
-        super(env, env.symtab.voidType);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitVoidType(this);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java b/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java
deleted file mode 100644
index fb2d386..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.type;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.TypeVisitor;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-
-
-/**
- * Implementation of WildcardType
- */
- at SuppressWarnings("deprecation")
-public class WildcardTypeImpl extends TypeMirrorImpl implements WildcardType {
-
-    protected Type.WildcardType type;
-
-    WildcardTypeImpl(AptEnv env, Type.WildcardType type) {
-        super(env, type);
-        this.type = type;
-    }
-
-
-    /**
-     * Returns the string form of a wildcard type, consisting of "?"
-     * and any "extends" or "super" clause.
-     * Delimiting brackets are not included.  Class names are qualified.
-     */
-    public String toString() {
-        return toString(env, type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ReferenceType> getUpperBounds() {
-        return type.isSuperBound()
-                ? Collections.<ReferenceType>emptyList()
-                : typeToCollection(type.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Collection<ReferenceType> getLowerBounds() {
-        return type.isExtendsBound()
-                ? Collections.<ReferenceType>emptyList()
-                : typeToCollection(type.type);
-    }
-
-    /**
-     * Gets the ReferenceType for a javac Type object, and returns
-     * it in a singleton collection.  If type is null, returns an empty
-     * collection.
-     */
-    private Collection<ReferenceType> typeToCollection(Type type) {
-        ArrayList<ReferenceType> res = new ArrayList<ReferenceType>(1);
-        if (type != null) {
-            res.add((ReferenceType) env.typeMaker.getType(type));
-        }
-        return res;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void accept(TypeVisitor v) {
-        v.visitWildcardType(this);
-    }
-
-
-    /**
-     * Returns the string form of a wildcard type, consisting of "?"
-     * and any "extends" or "super" clause.
-     * See {@link #toString()} for details.
-     */
-    static String toString(AptEnv env, Type.WildcardType wildThing) {
-        return wildThing.toString();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java b/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java
deleted file mode 100644
index 02f59ff..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2004, 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.apt.mirror.util;
-
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.Declarations;
-import com.sun.tools.apt.mirror.declaration.DeclarationImpl;
-import com.sun.tools.apt.mirror.declaration.MethodDeclarationImpl;
-import com.sun.tools.apt.mirror.util.DeclarationsImpl;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.Context;
-
-import static com.sun.tools.javac.code.Kinds.*;
-
-
-/**
- * Implementation of Declarations utility methods for annotation processors
- */
- at SuppressWarnings("deprecation")
-public class DeclarationsImpl implements Declarations {
-
-    private final AptEnv env;
-
-
-    private static final Context.Key<Declarations> declarationsKey =
-            new Context.Key<Declarations>();
-
-    public static Declarations instance(Context context) {
-        Declarations instance = context.get(declarationsKey);
-        if (instance == null) {
-            instance = new DeclarationsImpl(context);
-        }
-        return instance;
-    }
-
-    private DeclarationsImpl(Context context) {
-        context.put(declarationsKey, this);
-        env = AptEnv.instance(context);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     * See sections 8.3 and 8.4.6 of
-     * <cite>The Java™ Language Specification</cite>
-     */
-    public boolean hides(MemberDeclaration sub, MemberDeclaration sup) {
-        Symbol hider = ((DeclarationImpl) sub).sym;
-        Symbol hidee = ((DeclarationImpl) sup).sym;
-
-        // Fields only hide fields; methods only methods; types only types.
-        // Names must match.  Nothing hides itself (just try it).
-        if (hider == hidee ||
-                hider.kind != hidee.kind ||
-                hider.name != hidee.name) {
-            return false;
-        }
-
-        // Only static methods can hide other methods.
-        // Methods only hide methods with matching signatures.
-        if (hider.kind == MTH) {
-            if ((hider.flags() & Flags.STATIC) == 0 ||
-                        !env.jctypes.isSubSignature(hider.type, hidee.type)) {
-                return false;
-            }
-        }
-
-        // Hider must be in a subclass of hidee's class.
-        // Note that if M1 hides M2, and M2 hides M3, and M3 is accessible
-        // in M1's class, then M1 and M2 both hide M3.
-        ClassSymbol hiderClass = hider.owner.enclClass();
-        ClassSymbol hideeClass = hidee.owner.enclClass();
-        if (hiderClass == null || hideeClass == null ||
-                !hiderClass.isSubClass(hideeClass, env.jctypes)) {
-            return false;
-        }
-
-        // Hidee must be accessible in hider's class.
-        // The method isInheritedIn is poorly named:  it checks only access.
-        return hidee.isInheritedIn(hiderClass, env.jctypes);
-    }
-
-    /**
-     * {@inheritDoc}
-     * See section 8.4.6.1 of
-     * <cite>The Java™ Language Specification</cite>
-     */
-    public boolean overrides(MethodDeclaration sub, MethodDeclaration sup) {
-        MethodSymbol overrider = ((MethodDeclarationImpl) sub).sym;
-        MethodSymbol overridee = ((MethodDeclarationImpl) sup).sym;
-        ClassSymbol origin = (ClassSymbol) overrider.owner;
-
-        return overrider.name == overridee.name &&
-
-               // not reflexive as per JLS
-               overrider != overridee &&
-
-               // we don't care if overridee is static, though that wouldn't
-               // compile
-               !overrider.isStatic() &&
-
-               // overrider, whose declaring type is the origin, must be
-               // in a subtype of overridee's type
-               env.jctypes.asSuper(origin.type, overridee.owner) != null &&
-
-               // check access and signatures; don't check return types
-               overrider.overrides(overridee, origin, env.jctypes, false);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java b/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java
deleted file mode 100644
index cfa673d..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.util;
-
-
-import java.io.File;
-import javax.tools.JavaFileObject;
-
-import com.sun.mirror.util.SourcePosition;
-import com.sun.tools.javac.util.Position;
-
-
-/**
- * Implementation of SourcePosition
- */
- at SuppressWarnings("deprecation")
-public class SourcePositionImpl implements SourcePosition {
-
-    private JavaFileObject sourcefile;
-    private int pos;            // file position, in javac's internal format
-    private Position.LineMap linemap;
-
-
-    public SourcePositionImpl(JavaFileObject sourcefile, int pos, Position.LineMap linemap) {
-        this.sourcefile = sourcefile;
-        this.pos = pos;
-        this.linemap = linemap;
-        assert sourcefile != null;
-        assert linemap != null;
-    }
-
-    public int getJavacPosition() {
-        return pos;
-    }
-
-    public JavaFileObject getSource() {
-        return sourcefile;
-    }
-
-    /**
-     * Returns a string representation of this position in the
-     * form "sourcefile:line", or "sourcefile" if no line number is available.
-     */
-    public String toString() {
-        int ln = line();
-        return (ln == Position.NOPOS)
-                ? sourcefile.getName()
-                : sourcefile.getName() + ":" + ln;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public File file() {
-        return new File(sourcefile.toUri());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int line() {
-        return linemap.getLineNumber(pos);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int column() {
-        return linemap.getColumnNumber(pos);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java b/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java
deleted file mode 100644
index 821b3ed..0000000
--- a/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 2004, 2005, 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.apt.mirror.util;
-
-
-import java.util.Collection;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.Types;
-import com.sun.tools.apt.mirror.AptEnv;
-import com.sun.tools.apt.mirror.declaration.*;
-import com.sun.tools.apt.mirror.type.TypeMirrorImpl;
-import com.sun.tools.javac.code.BoundKind;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.ListBuffer;
-
-
-/**
- * Implementation of Types utility methods for annotation processors
- */
- at SuppressWarnings("deprecation")
-public class TypesImpl implements Types {
-
-    private final AptEnv env;
-
-
-    private static final Context.Key<Types> typesKey =
-            new Context.Key<Types>();
-
-    public static Types instance(Context context) {
-        Types instance = context.get(typesKey);
-        if (instance == null) {
-            instance = new TypesImpl(context);
-        }
-        return instance;
-    }
-
-    private TypesImpl(Context context) {
-        context.put(typesKey, this);
-        env = AptEnv.instance(context);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isSubtype(TypeMirror t1, TypeMirror t2) {
-        return env.jctypes.isSubtype(((TypeMirrorImpl) t1).type,
-                                     ((TypeMirrorImpl) t2).type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean isAssignable(TypeMirror t1, TypeMirror t2) {
-        return env.jctypes.isAssignable(((TypeMirrorImpl) t1).type,
-                                        ((TypeMirrorImpl) t2).type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeMirror getErasure(TypeMirror t) {
-        return env.typeMaker.getType(
-                env.jctypes.erasure(((TypeMirrorImpl) t).type));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public PrimitiveType getPrimitiveType(PrimitiveType.Kind kind) {
-        Type prim = null;
-        switch (kind) {
-        case BOOLEAN:   prim = env.symtab.booleanType;  break;
-        case BYTE:      prim = env.symtab.byteType;     break;
-        case SHORT:     prim = env.symtab.shortType;    break;
-        case INT:       prim = env.symtab.intType;      break;
-        case LONG:      prim = env.symtab.longType;     break;
-        case CHAR:      prim = env.symtab.charType;     break;
-        case FLOAT:     prim = env.symtab.floatType;    break;
-        case DOUBLE:    prim = env.symtab.doubleType;   break;
-        default:        assert false;
-        }
-        return (PrimitiveType) env.typeMaker.getType(prim);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public VoidType getVoidType() {
-        return (VoidType) env.typeMaker.getType(env.symtab.voidType);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public ArrayType getArrayType(TypeMirror componentType) {
-        if (componentType instanceof VoidType) {
-            throw new IllegalArgumentException("void");
-        }
-        return (ArrayType) env.typeMaker.getType(
-                new Type.ArrayType(((TypeMirrorImpl) componentType).type,
-                                   env.symtab.arrayClass));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public TypeVariable getTypeVariable(TypeParameterDeclaration tparam) {
-        return (TypeVariable) env.typeMaker.getType(
-                                ((DeclarationImpl) tparam).sym.type);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public WildcardType getWildcardType(Collection<ReferenceType> upperBounds,
-                                        Collection<ReferenceType> lowerBounds) {
-        BoundKind kind;
-        Type bound;
-        int uppers  = upperBounds.size();
-        int downers = lowerBounds.size();
-
-        if (uppers + downers > 1) {
-            throw new IllegalArgumentException("Multiple bounds not allowed");
-
-        } else if (uppers + downers == 0) {
-            kind = BoundKind.UNBOUND;
-            bound = env.symtab.objectType;
-
-        } else if (uppers == 1) {
-            assert downers == 0;
-            kind = BoundKind.EXTENDS;
-            bound = ((TypeMirrorImpl) upperBounds.iterator().next()).type;
-
-        } else {
-            assert uppers == 0 && downers == 1;
-            kind = BoundKind.SUPER;
-            bound = ((TypeMirrorImpl) lowerBounds.iterator().next()).type;
-        }
-
-        if (bound instanceof Type.WildcardType)
-            throw new IllegalArgumentException(bound.toString());
-
-        return (WildcardType) env.typeMaker.getType(
-                new Type.WildcardType(bound, kind, env.symtab.boundClass));
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public DeclaredType getDeclaredType(TypeDeclaration decl,
-                                        TypeMirror... typeArgs) {
-        ClassSymbol sym = ((TypeDeclarationImpl) decl).sym;
-
-        if (typeArgs.length == 0)
-            return (DeclaredType) env.typeMaker.getType(
-                                        env.jctypes.erasure(sym.type));
-        if (sym.type.getEnclosingType().isParameterized())
-            throw new IllegalArgumentException(decl.toString());
-
-        return getDeclaredType(sym.type.getEnclosingType(), sym, typeArgs);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public DeclaredType getDeclaredType(DeclaredType containing,
-                                        TypeDeclaration decl,
-                                        TypeMirror... typeArgs) {
-        if (containing == null)
-            return getDeclaredType(decl, typeArgs);
-
-        ClassSymbol sym = ((TypeDeclarationImpl) decl).sym;
-        Type outer = ((TypeMirrorImpl) containing).type;
-
-        if (outer.tsym != sym.owner.enclClass())
-            throw new IllegalArgumentException(containing.toString());
-        if (!outer.isParameterized())
-            return getDeclaredType(decl, typeArgs);
-
-        return getDeclaredType(outer, sym, typeArgs);
-    }
-
-    private DeclaredType getDeclaredType(Type outer,
-                                         ClassSymbol sym,
-                                         TypeMirror... typeArgs) {
-        if (typeArgs.length != sym.type.getTypeArguments().length())
-            throw new IllegalArgumentException(
-                                "Incorrect number of type arguments");
-
-        ListBuffer<Type> targs = new ListBuffer<Type>();
-        for (TypeMirror t : typeArgs) {
-            if (!(t instanceof ReferenceType || t instanceof WildcardType))
-                throw new IllegalArgumentException(t.toString());
-            targs.append(((TypeMirrorImpl) t).type);
-        }
-        //### Need a way to check that type args match formals.
-
-        return (DeclaredType) env.typeMaker.getType(
-                new Type.ClassType(outer, targs.toList(), sym));
-    }
-}
diff --git a/src/share/classes/com/sun/tools/apt/resources/apt.properties b/src/share/classes/com/sun/tools/apt/resources/apt.properties
deleted file mode 100644
index 8ec7be9..0000000
--- a/src/share/classes/com/sun/tools/apt/resources/apt.properties
+++ /dev/null
@@ -1,184 +0,0 @@
-#
-# Copyright (c) 2004, 2006, 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.
-#
-
-apt.msg.usage.header=\
-Usage: {0} <apt and javac options> <source files>\n\
-where apt options include:
-
-apt.msg.usage.footer=\
-See javac -help for information on javac options.
-
-apt.msg.usage.nonstandard.footer=\
-These options are non-standard and subject to change without notice, \nas is the format of their output.
-
-apt.msg.bug=\
-An exception has occurred in apt ({0}). \
-Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  \
-after checking the Bug Parade for duplicates. \
-Include your program and the following diagnostic in your report.  Thank you.
-
-## apt options
-
-apt.opt.A=\
-    Options to pass to annotation processors
-apt.opt.arg.class=\
-    <class>
-apt.opt.arg.directory=\
-    Specify where to place processor and javac generated class files
-apt.opt.classpath=\
-    Specify where to find user class files and annotation processor factories
-apt.opt.d=\
-    Specify where to place processor and javac generated class files
-apt.opt.factory=\
-    Name of AnnotationProcessorFactory to use; bypasses default discovery process
-apt.opt.factorypath=\
-    Specify where to find annotation processor factories
-apt.opt.s=\
-    Specify where to place processor generated source files
-apt.opt.help=\
-    Print a synopsis of standard options; use javac -help for more options
-apt.opt.print=\
-    Print out textual representation of specified types
-apt.opt.nocompile=\
-    Do not compile source files to class files
-apt.opt.proc.flag=\
-    [key[=value]]
-apt.opt.version=\
-    Version information
-apt.opt.XListAnnotationTypes=\
-    List found annotation types
-apt.opt.XListDeclarations=\
-    List specified and included declarations
-apt.opt.XPrintAptRounds=\
-    Print information about initial and recursive apt rounds
-apt.opt.XPrintFactoryInfo=\
-    Print information about which annotations a factory is asked to process
-apt.opt.XClassesAsDecls=\
-    Treat both class and source files as declarations to process
-
-##
-## errors
-##
-
-## All errors which do not refer to a particular line in the source code are
-## preceded by this string.
-
-apt.err.error=\
-    error:\u0020
-
-apt.err.unsupported.source.version=\
-    Source release {0} is not supported; use release 5 or earlier
-
-apt.err.unsupported.target.version=\
-    Target release {0} is not supported; use release 5 or earlier
-
-apt.err.BadDeclaration=\
-    Bad declaration created for annotation type {0}
-
-apt.err.CantFindClass=\
-    Could not find class file for {0}
-
-apt.err.DeclarationCreation=\
-    Could not create declaration for annotation type {0}
-
-# Print an error from the Messager
-apt.err.Messager=\
-    {0}
-
-##
-## miscellaneous strings
-##
-
-apt.misc.Deprecation=\
-    \nwarning:\u0020The apt tool and its associated API are planned to be\n\
-    removed in the next major JDK release.  These features have been\n\
-    superseded by javac and the standardized annotation processing API,\n\
-    javax.annotation.processing and javax.lang.model.  Users are\n\
-    recommended to migrate to the annotation processing features of\n\
-    javac; see the javac man page for more information.\n
-
-apt.misc.Problem=\
-    Problem encountered during annotation processing; \nsee stacktrace below for more information.
-
-apt.misc.SunMiscService=\
-    Error finding annotation processor factories; \ncheck META-INF/services information.
-
-# Print a notice from the Messager
-apt.note.Messager=\
-    {0}
-
-##
-## warnings
-##
-
-## All warning messages are preceded by the following string.
-apt.warn.warning=\
-    warning:\u0020
-
-apt.warn.AnnotationsWithoutProcessors=\
-    Annotation types without processors: {0}
-
-apt.warn.BadFactory=\
-    Bad annotation processor factory: {0} 
-
-apt.warn.BadParentDirectory=\
-    Failed to create some parent directory of {0} 
-
-apt.warn.FactoryCantInstantiate=\
-    Could not instantiate an instance of factory ''{0}''.
-
-apt.warn.FactoryWrongType=\
-    Specified factory, ''{0}'', is not an AnnotationProcessorFactory.
-
-apt.warn.FactoryNotFound=\
-    Specified AnnotationProcessorFactory, ''{0}'', not found on search path.
-
-apt.warn.FileReopening=\
-    Attempt to create ''{0}'' multiple times
-
-apt.warn.IllegalFileName=\
-    Cannot create file for illegal name ''{0}''.
-
-apt.warn.MalformedSupportedString=\
-    Malformed string for annotation support, ''{0}'', returned by factory.
-
-apt.warn.NoNewFilesAfterRound=\
-    Cannot create file ''{0}'' after a round has ended.
-
-# Print a warning from the Messager
-apt.warn.Messager=\
-    {0}
-
-apt.warn.NoAnnotationProcessors=\
-    No annotation processors found but annotations present.
-
-apt.warn.NullProcessor=\
-    Factory {0} returned null for an annotation processor.
-
-apt.warn.CorrespondingClassFile=\
-    A class file corresponding to source file ''{0}'' has already been created.
-
-apt.warn.CorrespondingSourceFile=\
-    A source file corresponding to class file ''{0}'' has already been created.
diff --git a/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties b/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties
deleted file mode 100644
index 48400e5..0000000
--- a/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# Copyright (c) 2004, 2006, 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.
-#
-
-apt.msg.usage.header=\u4F7F\u7528\u65B9\u6CD5: {0} <apt and javac options> <source files>\n\u6B21\u306Eapt\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059:
-
-apt.msg.usage.footer=javac\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306F\u3001javac -help\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-
-apt.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u3001\u8868\u793A\u5F62\u5F0F\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\n\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002
-
-apt.msg.bug=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u306B\u540C\u3058\u30D0\u30B0\u304C\u767B\u9332\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u3092\u3054\u78BA\u8A8D\u306E\u4E0A\u3001Java Developer Connection(http://java.sun.com/webapps/bugreport)\u3067\u30D0\u30B0\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306 [...]
-
-## apt options
-
-apt.opt.A=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306B\u6E21\u3055\u308C\u308B\u30AA\u30D7\u30B7\u30E7\u30F3
-apt.opt.arg.class=<class>
-apt.opt.arg.directory=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B
-apt.opt.classpath=\u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304A\u3088\u3073\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B
-apt.opt.d=\u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B
-apt.opt.factory=\u4F7F\u7528\u3059\u308BAnnotationProcessorFactory\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9
-apt.opt.factorypath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B
-apt.opt.s=\u30D7\u30ED\u30BB\u30C3\u30B5\u304C\u751F\u6210\u3057\u305F\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B
-apt.opt.help=\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u6982\u8981\u3092\u51FA\u529B\u3059\u308B\u3002\u8A73\u7D30\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u3064\u3044\u3066\u306Fjavac -help\u3092\u53C2\u7167
-apt.opt.print=\u6307\u5B9A\u3057\u305F\u578B\u306E\u30C6\u30AD\u30B9\u30C8\u8868\u793A\u3092\u51FA\u529B\u3059\u308B
-apt.opt.nocompile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u306A\u3044
-apt.opt.proc.flag=[key[=value]]
-apt.opt.version=\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831
-apt.opt.XListAnnotationTypes=\u898B\u3064\u304B\u3063\u305F\u6CE8\u91C8\u578B\u3092\u30EA\u30B9\u30C8\u3059\u308B
-apt.opt.XListDeclarations=\u6307\u5B9A\u3055\u308C\u305F\u5BA3\u8A00\u304A\u3088\u3073\u30A4\u30F3\u30AF\u30EB\u30FC\u30C9\u3055\u308C\u305F\u5BA3\u8A00\u3092\u30EA\u30B9\u30C8\u3059\u308B
-apt.opt.XPrintAptRounds=\u521D\u671F\u304A\u3088\u3073\u518D\u5E30apt\u5F80\u5FA9\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B
-apt.opt.XPrintFactoryInfo=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u51E6\u7406\u3092\u4F9D\u983C\u3055\u308C\u308B\u6CE8\u91C8\u306B\u3064\u3044\u3066\u306E\u60C5\u5831\u3092\u5370\u5237\u3059\u308B
-apt.opt.XClassesAsDecls=\u30AF\u30E9\u30B9\u3068\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u4E21\u65B9\u3068\u3082\u51E6\u7406\u3059\u308B\u5BA3\u8A00\u3068\u3057\u3066\u51E6\u7406
-
-##
-## errors
-##
-
-## All errors which do not refer to a particular line in the source code are
-## preceded by this string.
-
-apt.err.error=\u30A8\u30E9\u30FC:\u0020
-
-apt.err.unsupported.source.version=\u30BD\u30FC\u30B9\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044
-
-apt.err.unsupported.target.version=\u30BF\u30FC\u30B2\u30C3\u30C8\u30FB\u30EA\u30EA\u30FC\u30B9{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30EA\u30EA\u30FC\u30B95\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044
-
-apt.err.BadDeclaration=\u6CE8\u91C8\u578B{0}\u7528\u306B\u4F5C\u6210\u3055\u308C\u305F\u7121\u52B9\u306A\u5BA3\u8A00\u3067\u3059
-
-apt.err.CantFindClass={0}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
-
-apt.err.DeclarationCreation=\u6CE8\u91C8\u578B{0}\u7528\u306B\u5BA3\u8A00\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F
-
-# Print an error from the Messager
-apt.err.Messager={0}
-
-##
-## miscellaneous strings
-##
-
-apt.misc.Deprecation=\n\u8B66\u544A: apt\u30C4\u30FC\u30EB\u3068\u30C4\u30FC\u30EB\u306B\u95A2\u9023\u4ED8\u3051\u3089\u308C\u305FAPI\u306F\u3001\u6B21\u56DE\u306EJDK\n\u30E1\u30B8\u30E3\u30FC\u30FB\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u4E88\u5B9A\u3067\u3059\u3002\u3053\u308C\u3089\u306E\u6A5F\u80FD\u306Fjavac\u304A\u3088\u3073\n\u6A19\u6E96\u5316\u3055\u308C\u305F\u6CE8\u91C8\u51E6\u7406API\u306Ejavax.annotation.processing\u304A\u3088\u3073javax.lang.model\n\u306 [...]
-
-apt.misc.Problem=\u6CE8\u91C8\u51E6\u7406\u4E2D\u306B\u554F\u984C\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u3001\u4E0B\u8A18\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-
-apt.misc.SunMiscService=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u306E\u691C\u7D22\u30A8\u30E9\u30FC\u3067\u3059\u3002\nMETA-INF/services\u5185\u306E\u60C5\u5831\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-
-# Print a notice from the Messager
-apt.note.Messager={0}
-
-##
-## warnings
-##
-
-## All warning messages are preceded by the following string.
-apt.warn.warning=\u8B66\u544A:
-
-apt.warn.AnnotationsWithoutProcessors=\u30D7\u30ED\u30BB\u30C3\u30B5\u306A\u3057\u306E\u6CE8\u91C8\u578B\u3067\u3059: {0}
-
-apt.warn.BadFactory=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u7121\u52B9\u3067\u3059: {0} 
-
-apt.warn.BadParentDirectory={0}\u306E\u3044\u304F\u3064\u304B\u306E\u89AA\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F 
-
-apt.warn.FactoryCantInstantiate=\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002
-
-apt.warn.FactoryWrongType=\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30AF\u30C8\u30EA''{0}''\u306FAnnotationProcessorFactory\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002
-
-apt.warn.FactoryNotFound=\u6307\u5B9A\u3057\u305FAnnotationProcessorFactory ''{0}''\u306F\u691C\u7D22\u30D1\u30B9\u3067\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002
-
-apt.warn.FileReopening=''{0}''\u3092\u8907\u6570\u56DE\u4F5C\u6210\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059
-
-apt.warn.IllegalFileName=\u7121\u52B9\u306A\u540D\u524D''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002
-
-apt.warn.MalformedSupportedString=\u30D5\u30A1\u30AF\u30C8\u30EA\u304C\u8FD4\u3057\u305F\u6CE8\u91C8\u30B5\u30DD\u30FC\u30C8''{0}''\u306E\u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059\u3002
-
-apt.warn.NoNewFilesAfterRound=\u5F80\u5FA9\u306E\u7D42\u4E86\u5F8C\u306B\u30D5\u30A1\u30A4\u30EB''{0}''\u3092\u4F5C\u6210\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002
-
-# Print a warning from the Messager
-apt.warn.Messager={0}
-
-apt.warn.NoAnnotationProcessors=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u304C\u3001\u6CE8\u91C8\u306F\u5B58\u5728\u3057\u307E\u3059\u3002
-
-apt.warn.NullProcessor=\u30D5\u30A1\u30AF\u30C8\u30EA{0}\u304C\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306Bnull\u3092\u8FD4\u3057\u307E\u3057\u305F\u3002
-
-apt.warn.CorrespondingClassFile=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002
-
-apt.warn.CorrespondingSourceFile=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB''{0}''\u306B\u5BFE\u5FDC\u3059\u308B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002
diff --git a/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties b/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties
deleted file mode 100644
index 20b0b49..0000000
--- a/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# Copyright (c) 2004, 2006, 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.
-#
-
-apt.msg.usage.header=\u7528\u6CD5: {0} <apt and javac options> <source files>\n\u5176\u4E2D, apt \u9009\u9879\u5305\u62EC:
-
-apt.msg.usage.footer=\u6709\u5173 javac \u9009\u9879\u7684\u4FE1\u606F, \u8BF7\u53C2\u9605 javac -help\u3002
-
-apt.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u53CA\u5176\u8F93\u51FA\u683C\u5F0F\u90FD\u4E0D\u662F\u6807\u51C6\u7684, \n\u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002
-
-apt.msg.bug=apt ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002 \u5982\u679C\u5728 Bug Parade \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728 Java Developer Connection (http://java.sun.com/webapps/bugreport) \u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002
-
-## apt options
-
-apt.opt.A=\u4F20\u9012\u7ED9\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u7684\u9009\u9879
-apt.opt.arg.class=<\u7C7B>
-apt.opt.arg.directory=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E
-apt.opt.classpath=\u6307\u5B9A\u67E5\u627E\u7528\u6237\u7C7B\u6587\u4EF6\u548C\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E
-apt.opt.d=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E
-apt.opt.factory=\u8981\u4F7F\u7528\u7684 AnnotationProcessorFactory \u7684\u540D\u79F0; \u7ED5\u8FC7\u9ED8\u8BA4\u7684\u641C\u7D22\u8FDB\u7A0B
-apt.opt.factorypath=\u6307\u5B9A\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u7684\u4F4D\u7F6E
-apt.opt.s=\u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u751F\u6210\u7684\u6E90\u6587\u4EF6\u7684\u4F4D\u7F6E
-apt.opt.help=\u8F93\u51FA\u6807\u51C6\u9009\u9879\u7684\u63D0\u8981; \u4F7F\u7528 javac -help \u53EF\u4EE5\u5F97\u5230\u66F4\u591A\u9009\u9879
-apt.opt.print=\u8F93\u51FA\u6307\u5B9A\u7C7B\u578B\u7684\u6587\u672C\u8868\u793A
-apt.opt.nocompile=\u8BF7\u52FF\u5C06\u6E90\u6587\u4EF6\u7F16\u8BD1\u4E3A\u7C7B\u6587\u4EF6
-apt.opt.proc.flag=[\u5173\u952E\u5B57[=\u503C]]
-apt.opt.version=\u7248\u672C\u4FE1\u606F
-apt.opt.XListAnnotationTypes=\u5217\u51FA\u627E\u5230\u7684\u6CE8\u91CA\u7C7B\u578B
-apt.opt.XListDeclarations=\u5217\u51FA\u6307\u5B9A\u548C\u5305\u542B\u7684\u58F0\u660E
-apt.opt.XPrintAptRounds=\u8F93\u51FA\u6709\u5173\u521D\u59CB\u548C\u9012\u5F52 apt \u5FAA\u73AF\u7684\u4FE1\u606F
-apt.opt.XPrintFactoryInfo=\u8F93\u51FA\u6709\u5173\u8BF7\u6C42\u5DE5\u5382\u5904\u7406\u54EA\u4E9B\u6CE8\u91CA\u7684\u4FE1\u606F
-apt.opt.XClassesAsDecls=\u5C06\u7C7B\u6587\u4EF6\u548C\u6E90\u6587\u4EF6\u90FD\u89C6\u4E3A\u8981\u5904\u7406\u7684\u58F0\u660E
-
-##
-## errors
-##
-
-## All errors which do not refer to a particular line in the source code are
-## preceded by this string.
-
-apt.err.error=\u9519\u8BEF:\u0020
-
-apt.err.unsupported.source.version=\u4E0D\u652F\u6301\u6E90\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248
-
-apt.err.unsupported.target.version=\u4E0D\u652F\u6301\u76EE\u6807\u53D1\u884C\u7248 {0}; \u8BF7\u4F7F\u7528\u53D1\u884C\u7248 5 \u6216\u65E9\u671F\u53D1\u884C\u7248
-
-apt.err.BadDeclaration=\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u7684\u58F0\u660E\u51FA\u73B0\u9519\u8BEF
-
-apt.err.CantFindClass=\u627E\u4E0D\u5230{0}\u7684\u7C7B\u6587\u4EF6
-
-apt.err.DeclarationCreation=\u65E0\u6CD5\u4E3A\u6CE8\u91CA\u7C7B\u578B{0}\u521B\u5EFA\u58F0\u660E
-
-# Print an error from the Messager
-apt.err.Messager={0}
-
-##
-## miscellaneous strings
-##
-
-apt.misc.Deprecation=\n\u8B66\u544A:\u0020\u5DF2\u8BA1\u5212\u5728\u4E0B\u4E00\u4E2A JDK \u4E3B\u53D1\u884C\u7248\u4E2D\n\u5220\u9664 apt \u5DE5\u5177\u53CA\u5176\u5173\u8054\u7684 API\u3002\u8FD9\u4E9B\u529F\u80FD\n\u5DF2\u88AB javac \u548C\u6807\u51C6\u6CE8\u91CA\u5904\u7406 API,\njavax.annotation.processing \u548C javax.lang.model \u53D6\u4EE3\u3002\u5EFA\u8BAE\u7528\u6237\n\u79FB\u690D\u5230 javac \u7684\u6CE8\u91CA\u5904\u7406\u529F\u80FD;\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8B [...]
-
-apt.misc.Problem=\u6CE8\u91CA\u5904\u7406\u8FC7\u7A0B\u4E2D\u9047\u5230\u95EE\u9898; \n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4E0B\u9762\u7684\u5806\u6808\u8DDF\u8E2A\u3002
-
-apt.misc.SunMiscService=\u67E5\u627E\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u65F6\u51FA\u9519; \n\u8BF7\u67E5\u770B META-INF/\u670D\u52A1\u4FE1\u606F\u3002
-
-# Print a notice from the Messager
-apt.note.Messager={0}
-
-##
-## warnings
-##
-
-## All warning messages are preceded by the following string.
-apt.warn.warning=\u8B66\u544A:\u0020
-
-apt.warn.AnnotationsWithoutProcessors=\u4E0D\u5E26\u5904\u7406\u7A0B\u5E8F\u7684\u6CE8\u91CA\u7C7B\u578B: {0}
-
-apt.warn.BadFactory=\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F\u5DE5\u5382\u51FA\u73B0\u9519\u8BEF: {0} 
-
-apt.warn.BadParentDirectory=\u65E0\u6CD5\u521B\u5EFA{0}\u7684\u67D0\u4E9B\u7236\u76EE\u5F55 
-
-apt.warn.FactoryCantInstantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u5DE5\u5382 ''{0}'' \u7684\u5B9E\u4F8B\u3002
-
-apt.warn.FactoryWrongType=\u6307\u5B9A\u7684\u5DE5\u5382 ''{0}'' \u4E0D\u662F AnnotationProcessorFactory\u3002
-
-apt.warn.FactoryNotFound=\u5728\u641C\u7D22\u8DEF\u5F84\u4E2D\u627E\u4E0D\u5230\u6307\u5B9A\u7684 AnnotationProcessorFactory ''{0}''\u3002
-
-apt.warn.FileReopening=\u5C1D\u8BD5\u591A\u6B21\u521B\u5EFA ''{0}''
-
-apt.warn.IllegalFileName=\u65E0\u6CD5\u521B\u5EFA\u5E26\u6709\u975E\u6CD5\u540D\u79F0 ''{0}'' \u7684\u6587\u4EF6\u3002
-
-apt.warn.MalformedSupportedString=\u5DE5\u5382\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\u7684\u6CE8\u91CA\u652F\u6301\u5B57\u7B26\u4E32 ''{0}''\u3002
-
-apt.warn.NoNewFilesAfterRound=\u5FAA\u73AF\u7ED3\u675F\u540E\u65E0\u6CD5\u521B\u5EFA\u6587\u4EF6 ''{0}''\u3002
-
-# Print a warning from the Messager
-apt.warn.Messager={0}
-
-apt.warn.NoAnnotationProcessors=\u627E\u4E0D\u5230\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u4F46\u5B58\u5728\u6CE8\u91CA\u3002
-
-apt.warn.NullProcessor=\u5BF9\u4E8E\u67D0\u4E2A\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F, \u5DE5\u5382{0}\u8FD4\u56DE\u7684\u503C\u4E3A\u7A7A\u503C\u3002
-
-apt.warn.CorrespondingClassFile=\u5DF2\u521B\u5EFA\u4E0E\u6E90\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u7C7B\u6587\u4EF6\u3002
-
-apt.warn.CorrespondingSourceFile=\u5DF2\u521B\u5EFA\u4E0E\u7C7B\u6587\u4EF6 ''{0}'' \u76F8\u5BF9\u5E94\u7684\u6E90\u6587\u4EF6\u3002
diff --git a/src/share/classes/com/sun/tools/apt/util/Bark.java b/src/share/classes/com/sun/tools/apt/util/Bark.java
deleted file mode 100644
index a6c0c23..0000000
--- a/src/share/classes/com/sun/tools/apt/util/Bark.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2004, 2011, 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.apt.util;
-
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.JCDiagnostic;
-import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.JavacMessages;
-import com.sun.tools.javac.util.Position;
-
-/** A subtype of Log for use in APT.
- *
- *  <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 Bark extends Log {
-    /** The context key for the bark. */
-    protected static final Context.Key<Bark> barkKey =
-        new Context.Key<Bark>();
-
-    /**
-     * Preregisters factories to create and use a Bark object for use as
-     * both a Log and a Bark.
-     */
-    public static void preRegister(Context context) {
-        context.put(barkKey, new Context.Factory<Bark>() {
-            public Bark make(Context c) {
-                return new Bark(c);
-            }
-        });
-        context.put(Log.logKey, new Context.Factory<Log>() {
-            public Log make(Context c) {
-                return Bark.instance(c);
-            }
-        });
-    }
-
-    /** Get the Bark instance for this context. */
-    public static Bark instance(Context context) {
-        Bark instance = context.get(barkKey);
-        if (instance == null)
-            instance = new Bark(context);
-        return instance;
-    }
-
-    /** Specifies whether or not to ignore any diagnostics that are reported.
-     */
-    private boolean ignoreDiagnostics;
-
-    /**
-     * Factory for APT-specific diagnostics.
-     */
-    private JCDiagnostic.Factory aptDiags;
-
-
-    /**
-     * Creates a Bark.
-     */
-    protected Bark(Context context) {
-        super(context); // will register this object in context with Log.logKey
-        context.put(barkKey, this);
-
-        // register additional resource bundle for APT messages.
-        JavacMessages aptMessages = JavacMessages.instance(context);
-        aptMessages.add("com.sun.tools.apt.resources.apt");
-        aptDiags = new JCDiagnostic.Factory(aptMessages, "apt");
-
-        multipleErrors = true;
-    }
-
-    /**
-     * Sets a flag indicating whether or not to ignore all diagnostics.
-     * When ignored, they are not reported to the output writers, not are they
-     * counted in the various counters.
-     * @param b If true, subsequent diagnostics will be ignored.
-     * @return the previous state of the flag
-     */
-    public boolean setDiagnosticsIgnored(boolean b) {
-        boolean prev = ignoreDiagnostics;
-        ignoreDiagnostics = b;
-        return prev;
-    }
-
-    /**
-     * Report a diagnostic if they are not currently being ignored.
-     */
-    @Override
-    public void report(JCDiagnostic diagnostic) {
-        if (ignoreDiagnostics)
-            return;
-
-        super.report(diagnostic);
-    }
-
-    /** Report an error.
-     *  @param key    The key for the localized error message.
-     *  @param args   Fields of the error message.
-     */
-    public void aptError(String key, Object... args) {
-        aptError(Position.NOPOS, key, args);
-    }
-
-    /** Report an error, unless another error was already reported at same
-     *  source position.
-     *  @param pos    The source position at which to report the error.
-     *  @param key    The key for the localized error message.
-     *  @param args   Fields of the error message.
-     */
-    public void aptError(int pos, String key, Object ... args) {
-        report(aptDiags.error(source, new SimpleDiagnosticPosition(pos), key, args));
-    }
-
-    /** Report a warning, unless suppressed by the  -nowarn option or the
-     *  maximum number of warnings has been reached.
-     *  @param key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void aptWarning(String key, Object... args) {
-        aptWarning(Position.NOPOS, key, args);
-    }
-
-    /** Report a warning, unless suppressed by the  -nowarn option or the
-     *  maximum number of warnings has been reached.
-     *  @param pos    The source position at which to report the warning.
-     *  @param key    The key for the localized warning message.
-     *  @param args   Fields of the warning message.
-     */
-    public void aptWarning(int pos, String key, Object ... args) {
-        report(aptDiags.warning(source, new SimpleDiagnosticPosition(pos), key, args));
-    }
-
-    /** Report a note, unless suppressed by the  -nowarn option.
-     *  @param key    The key for the localized note message.
-     *  @param args   Fields of the note message.
-     */
-    public void aptNote(String key, Object... args) {
-        aptNote(Position.NOPOS, key, args);
-    }
-
-    /** Report a note, unless suppressed by the  -nowarn option.
-     *  @param pos    The source position at which to report the note.
-     *  @param key    The key for the localized note message.
-     *  @param args   Fields of the note message.
-     */
-    public void aptNote(int pos, String key, Object ... args) {
-        report(aptDiags.note(source, new SimpleDiagnosticPosition(pos), key, args));
-    }
-}
diff --git a/src/share/classes/com/sun/tools/classfile/AccessFlags.java b/src/share/classes/com/sun/tools/classfile/AccessFlags.java
index bb8faf3..f927b3b 100644
--- a/src/share/classes/com/sun/tools/classfile/AccessFlags.java
+++ b/src/share/classes/com/sun/tools/classfile/AccessFlags.java
@@ -56,7 +56,7 @@ public class AccessFlags {
     public static final int ACC_SYNTHETIC     = 0x1000; // class, inner, field, method
     public static final int ACC_ANNOTATION    = 0x2000; // class, inner
     public static final int ACC_ENUM          = 0x4000; // class, inner, field
-    public static final int ACC_MODULE        = 0x8000; // class, inner, field, method
+    public static final int ACC_MANDATED      = 0x8000; // class, inner, field, method
 
     public static enum Kind { Class, InnerClass, Field, Method};
 
@@ -81,12 +81,12 @@ public class AccessFlags {
     }
 
     private static final int[] classModifiers = {
-        ACC_PUBLIC, ACC_FINAL, ACC_ABSTRACT, ACC_MODULE
+        ACC_PUBLIC, ACC_FINAL, ACC_ABSTRACT
     };
 
     private static final int[] classFlags = {
         ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, ACC_ABSTRACT,
-        ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE
+        ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM
     };
 
     public Set<String> getClassModifiers() {
@@ -100,12 +100,12 @@ public class AccessFlags {
 
     private static final int[] innerClassModifiers = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
-        ACC_ABSTRACT, ACC_MODULE
+        ACC_ABSTRACT
     };
 
     private static final int[] innerClassFlags = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SUPER,
-        ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE
+        ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM
     };
 
     public Set<String> getInnerClassModifiers() {
@@ -119,12 +119,12 @@ public class AccessFlags {
 
     private static final int[] fieldModifiers = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
-        ACC_VOLATILE, ACC_TRANSIENT, ACC_MODULE
+        ACC_VOLATILE, ACC_TRANSIENT
     };
 
     private static final int[] fieldFlags = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
-        ACC_VOLATILE, ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM, ACC_MODULE
+        ACC_VOLATILE, ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM
     };
 
     public Set<String> getFieldModifiers() {
@@ -137,13 +137,13 @@ public class AccessFlags {
 
     private static final int[] methodModifiers = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
-        ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_MODULE
+        ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT
     };
 
     private static final int[] methodFlags = {
         ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
         ACC_SYNCHRONIZED, ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT,
-        ACC_STRICT, ACC_SYNTHETIC, ACC_MODULE
+        ACC_STRICT, ACC_SYNTHETIC
     };
 
     public Set<String> getMethodModifiers() {
@@ -208,8 +208,8 @@ public class AccessFlags {
                 return "abstract";
             case ACC_STRICT:
                 return "strictfp";
-            case ACC_MODULE:
-                return "module";
+            case ACC_MANDATED:
+                return "mandated";
             default:
                 return null;
         }
@@ -247,8 +247,8 @@ public class AccessFlags {
             return "ACC_ANNOTATION";
         case ACC_ENUM:
             return "ACC_ENUM";
-        case ACC_MODULE:
-            return "ACC_MODULE";
+        case ACC_MANDATED:
+            return "ACC_MANDATED";
         default:
             return null;
         }
diff --git a/src/share/classes/com/sun/tools/classfile/Attribute.java b/src/share/classes/com/sun/tools/classfile/Attribute.java
index 6c95e6f..dc4fc9d 100644
--- a/src/share/classes/com/sun/tools/classfile/Attribute.java
+++ b/src/share/classes/com/sun/tools/classfile/Attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -51,10 +51,13 @@ public abstract class Attribute {
     public static final String LineNumberTable          = "LineNumberTable";
     public static final String LocalVariableTable       = "LocalVariableTable";
     public static final String LocalVariableTypeTable   = "LocalVariableTypeTable";
+    public static final String MethodParameters         = "MethodParameters";
     public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
     public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
     public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
     public static final String RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations";
+    public static final String RuntimeVisibleTypeAnnotations = "RuntimeVisibleTypeAnnotations";
+    public static final String RuntimeInvisibleTypeAnnotations = "RuntimeInvisibleTypeAnnotations";
     public static final String Signature                = "Signature";
     public static final String SourceDebugExtension     = "SourceDebugExtension";
     public static final String SourceFile               = "SourceFile";
@@ -74,10 +77,12 @@ public abstract class Attribute {
 
         public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
                 throws IOException {
-            if (standardAttributes == null)
+            if (standardAttributes == null) {
                 init();
+            }
 
             ConstantPool cp = cr.getConstantPool();
+            String reasonForDefaultAttr;
             try {
                 String name = cp.getUTF8Value(name_index);
                 Class<? extends Attribute> attrClass = standardAttributes.get(name);
@@ -87,14 +92,18 @@ public abstract class Attribute {
                         Constructor<? extends Attribute> constr = attrClass.getDeclaredConstructor(constrArgTypes);
                         return constr.newInstance(new Object[] { cr, name_index, data.length });
                     } catch (Throwable t) {
+                        reasonForDefaultAttr = t.toString();
                         // fall through and use DefaultAttribute
                         // t.printStackTrace();
                     }
+                } else {
+                    reasonForDefaultAttr = "unknown attribute";
                 }
             } catch (ConstantPoolException e) {
+                reasonForDefaultAttr = e.toString();
                 // fall through and use DefaultAttribute
             }
-            return new DefaultAttribute(cr, name_index, data);
+            return new DefaultAttribute(cr, name_index, data, reasonForDefaultAttr);
         }
 
         protected void init() {
@@ -113,11 +122,14 @@ public abstract class Attribute {
             standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
 
             if (!compat) { // old javap does not recognize recent attributes
+                standardAttributes.put(MethodParameters, MethodParameters_attribute.class);
                 standardAttributes.put(CompilationID, CompilationID_attribute.class);
                 standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
                 standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
                 standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
                 standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
+                standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
+                standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
                 standardAttributes.put(Signature,     Signature_attribute.class);
                 standardAttributes.put(SourceID, SourceID_attribute.class);
             }
@@ -171,10 +183,13 @@ public abstract class Attribute {
         R visitLineNumberTable(LineNumberTable_attribute attr, P p);
         R visitLocalVariableTable(LocalVariableTable_attribute attr, P p);
         R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p);
+        R visitMethodParameters(MethodParameters_attribute attr, P p);
         R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
         R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
         R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
         R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p);
+        R visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, P p);
+        R visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, P p);
         R visitSignature(Signature_attribute attr, P p);
         R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p);
         R visitSourceFile(SourceFile_attribute attr, P p);
diff --git a/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java b/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java
index 3804333..69d0347 100644
--- a/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java
+++ b/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,8 @@ package com.sun.tools.classfile;
 import java.io.IOException;
 
 /**
- * See JVMS <TBD>
- * http://cr.openjdk.java.net/~jrose/pres/indy-javadoc-mlvm/
+ * See JVMS 4.7.21
+ * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.21
  *
  *  <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.
diff --git a/src/share/classes/com/sun/tools/classfile/ClassFile.java b/src/share/classes/com/sun/tools/classfile/ClassFile.java
index 9a68f61..52aefca 100644
--- a/src/share/classes/com/sun/tools/classfile/ClassFile.java
+++ b/src/share/classes/com/sun/tools/classfile/ClassFile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 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
@@ -26,9 +26,10 @@
 package com.sun.tools.classfile;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 import static com.sun.tools.classfile.AccessFlags.*;
 
@@ -43,23 +44,26 @@ import static com.sun.tools.classfile.AccessFlags.*;
 public class ClassFile {
     public static ClassFile read(File file)
             throws IOException, ConstantPoolException {
-        return read(file, new Attribute.Factory());
+        return read(file.toPath(), new Attribute.Factory());
     }
 
-    public static ClassFile read(File file, Attribute.Factory attributeFactory)
+    public static ClassFile read(Path input)
+            throws IOException, ConstantPoolException {
+        return read(input, new Attribute.Factory());
+    }
+
+    public static ClassFile read(Path input, Attribute.Factory attributeFactory)
             throws IOException, ConstantPoolException {
-        FileInputStream in = new FileInputStream(file);
-        try {
+        try (InputStream in = Files.newInputStream(input)) {
             return new ClassFile(in, attributeFactory);
-        } finally {
-            try {
-                in.close();
-            } catch (IOException e) {
-                // ignore
-            }
         }
     }
 
+    public static ClassFile read(File file, Attribute.Factory attributeFactory)
+            throws IOException, ConstantPoolException {
+        return read(file.toPath(), attributeFactory);
+    }
+
     public static ClassFile read(InputStream in)
             throws IOException, ConstantPoolException {
         return new ClassFile(in, new Attribute.Factory());
diff --git a/src/share/classes/com/sun/tools/classfile/ClassTranslator.java b/src/share/classes/com/sun/tools/classfile/ClassTranslator.java
index f40a8d5..6a5bd8c 100644
--- a/src/share/classes/com/sun/tools/classfile/ClassTranslator.java
+++ b/src/share/classes/com/sun/tools/classfile/ClassTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -25,6 +25,8 @@
 
 package com.sun.tools.classfile;
 
+import java.util.Map;
+
 import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info;
 import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info;
 import com.sun.tools.classfile.ConstantPool.CONSTANT_Fieldref_info;
@@ -40,7 +42,6 @@ import com.sun.tools.classfile.ConstantPool.CONSTANT_NameAndType_info;
 import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info;
 import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info;
 import com.sun.tools.classfile.ConstantPool.CPInfo;
-import java.util.Map;
 
 /**
  * Rewrites a class file using a map of translations.
diff --git a/src/share/classes/com/sun/tools/classfile/ClassWriter.java b/src/share/classes/com/sun/tools/classfile/ClassWriter.java
index 87128a6..17c21c8 100644
--- a/src/share/classes/com/sun/tools/classfile/ClassWriter.java
+++ b/src/share/classes/com/sun/tools/classfile/ClassWriter.java
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2008, 2011, 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
@@ -479,6 +479,15 @@ public class ClassWriter {
             out.writeShort(entry.index);
         }
 
+        public Void visitMethodParameters(MethodParameters_attribute attr, ClassOutputStream out) {
+            out.writeByte(attr.method_parameter_table.length);
+            for (MethodParameters_attribute.Entry e : attr.method_parameter_table) {
+                out.writeShort(e.name_index);
+                out.writeShort(e.flags);
+            }
+            return null;
+        }
+
         public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) {
             annotationWriter.write(attr.annotations, out);
             return null;
@@ -489,6 +498,16 @@ public class ClassWriter {
             return null;
         }
 
+        public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, ClassOutputStream out) {
+            annotationWriter.write(attr.annotations, out);
+            return null;
+        }
+
+        public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, ClassOutputStream out) {
+            annotationWriter.write(attr.annotations, out);
+            return null;
+        }
+
         public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) {
             out.writeByte(attr.parameter_annotations.length);
             for (Annotation[] annos: attr.parameter_annotations)
@@ -648,6 +667,12 @@ public class ClassWriter {
                 write(anno, out);
         }
 
+        public void write(TypeAnnotation[] annos, ClassOutputStream out) {
+            out.writeShort(annos.length);
+            for (TypeAnnotation anno: annos)
+                write(anno, out);
+        }
+
         public void write(Annotation anno, ClassOutputStream out) {
             out.writeShort(anno.type_index);
             out.writeShort(anno.element_value_pairs.length);
@@ -655,6 +680,11 @@ public class ClassWriter {
                 write(p, out);
         }
 
+        public void write(TypeAnnotation anno, ClassOutputStream out) {
+            write(anno.position, out);
+            write(anno.annotation, out);
+        }
+
         public void write(element_value_pair pair, ClassOutputStream out) {
             out.writeShort(pair.element_name_index);
             write(pair.value, out);
@@ -693,5 +723,89 @@ public class ClassWriter {
             return null;
         }
 
+        // TODO: Move this to TypeAnnotation to be closer with similar logic?
+        private void write(TypeAnnotation.Position p, ClassOutputStream out) {
+            out.writeByte(p.type.targetTypeValue());
+            switch (p.type) {
+            // instanceof
+            case INSTANCEOF:
+            // new expression
+            case NEW:
+            // constructor/method reference receiver
+            case CONSTRUCTOR_REFERENCE:
+            case METHOD_REFERENCE:
+                out.writeShort(p.offset);
+                break;
+            // local variable
+            case LOCAL_VARIABLE:
+            // resource variable
+            case RESOURCE_VARIABLE:
+                int table_length = p.lvarOffset.length;
+                out.writeShort(table_length);
+                for (int i = 0; i < table_length; ++i) {
+                    out.writeShort(1);  // for table length
+                    out.writeShort(p.lvarOffset[i]);
+                    out.writeShort(p.lvarLength[i]);
+                    out.writeShort(p.lvarIndex[i]);
+                }
+                break;
+            // exception parameter
+            case EXCEPTION_PARAMETER:
+                out.writeShort(p.exception_index);
+                break;
+            // method receiver
+            case METHOD_RECEIVER:
+                // Do nothing
+                break;
+            // type parameters
+            case CLASS_TYPE_PARAMETER:
+            case METHOD_TYPE_PARAMETER:
+                out.writeByte(p.parameter_index);
+                break;
+            // type parameters bounds
+            case CLASS_TYPE_PARAMETER_BOUND:
+            case METHOD_TYPE_PARAMETER_BOUND:
+                out.writeByte(p.parameter_index);
+                out.writeByte(p.bound_index);
+                break;
+            // class extends or implements clause
+            case CLASS_EXTENDS:
+                out.writeShort(p.type_index);
+                break;
+            // throws
+            case THROWS:
+                out.writeShort(p.type_index);
+                break;
+            // method parameter
+            case METHOD_FORMAL_PARAMETER:
+                out.writeByte(p.parameter_index);
+                break;
+            // type cast
+            case CAST:
+            // method/constructor/reference type argument
+            case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+            case METHOD_INVOCATION_TYPE_ARGUMENT:
+            case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+            case METHOD_REFERENCE_TYPE_ARGUMENT:
+                out.writeShort(p.offset);
+                out.writeByte(p.type_index);
+                break;
+            // We don't need to worry about these
+            case METHOD_RETURN:
+            case FIELD:
+                break;
+            case UNKNOWN:
+                throw new AssertionError("ClassWriter: UNKNOWN target type should never occur!");
+            default:
+                throw new AssertionError("ClassWriter: Unknown target type for position: " + p);
+            }
+
+            { // Append location data for generics/arrays.
+                // TODO: check for overrun?
+                out.writeByte((byte)p.location.size());
+                for (int i : TypeAnnotation.Position.getBinaryFromTypePath(p.location))
+                    out.writeByte((byte)i);
+            }
+        }
     }
 }
diff --git a/src/share/classes/com/sun/tools/classfile/Code_attribute.java b/src/share/classes/com/sun/tools/classfile/Code_attribute.java
index af34c2a..5d7c814 100644
--- a/src/share/classes/com/sun/tools/classfile/Code_attribute.java
+++ b/src/share/classes/com/sun/tools/classfile/Code_attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2009, 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
@@ -38,7 +38,7 @@ import java.util.NoSuchElementException;
  *  deletion without notice.</b>
  */
 public class Code_attribute extends Attribute {
-    public class InvalidIndex extends AttributeException {
+    public static class InvalidIndex extends AttributeException {
         private static final long serialVersionUID = -8904527774589382802L;
         InvalidIndex(int index) {
             this.index = index;
@@ -143,7 +143,7 @@ public class Code_attribute extends Attribute {
     public final Exception_data[] exception_table;
     public final Attributes attributes;
 
-    public class Exception_data {
+    public static class Exception_data {
         Exception_data(ClassReader cr) throws IOException {
             start_pc = cr.readUnsignedShort();
             end_pc = cr.readUnsignedShort();
diff --git a/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java b/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java
index fba1700..16fdeb9 100644
--- a/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java
+++ b/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 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
@@ -33,13 +33,24 @@ package com.sun.tools.classfile;
  */
 public class DefaultAttribute extends Attribute {
     DefaultAttribute(ClassReader cr, int name_index, byte[] data) {
+        this(cr, name_index, data, null);
+    }
+
+    DefaultAttribute(ClassReader cr, int name_index, byte[] data, String reason) {
         super(name_index, data.length);
         info = data;
+        this.reason = reason;
     }
 
     public DefaultAttribute(ConstantPool constant_pool, int name_index, byte[] info) {
+        this(constant_pool, name_index, info, null);
+    }
+
+    public DefaultAttribute(ConstantPool constant_pool, int name_index,
+            byte[] info, String reason) {
         super(name_index, info.length);
         this.info = info;
+        this.reason = reason;
     }
 
     public <R, P> R accept(Visitor<R, P> visitor, P p) {
@@ -47,4 +58,7 @@ public class DefaultAttribute extends Attribute {
     }
 
     public final byte[] info;
+    /** Why did we need to generate a DefaultAttribute
+     */
+    public final String reason;
 }
diff --git a/src/share/classes/com/sun/tools/classfile/Dependencies.java b/src/share/classes/com/sun/tools/classfile/Dependencies.java
index cffa778..336a687 100644
--- a/src/share/classes/com/sun/tools/classfile/Dependencies.java
+++ b/src/share/classes/com/sun/tools/classfile/Dependencies.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -33,8 +33,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import com.sun.tools.classfile.Dependency.Finder;
 import com.sun.tools.classfile.Dependency.Filter;
+import com.sun.tools.classfile.Dependency.Finder;
 import com.sun.tools.classfile.Dependency.Location;
 import com.sun.tools.classfile.Type.ArrayType;
 import com.sun.tools.classfile.Type.ClassSigType;
@@ -43,7 +43,6 @@ import com.sun.tools.classfile.Type.MethodType;
 import com.sun.tools.classfile.Type.SimpleType;
 import com.sun.tools.classfile.Type.TypeParamType;
 import com.sun.tools.classfile.Type.WildcardType;
-
 import static com.sun.tools.classfile.ConstantPool.*;
 
 /**
@@ -99,7 +98,7 @@ public class Dependencies {
          * Get the ClassFile object for a specified class.
          * @param className the name of the class to be returned.
          * @return the ClassFile for the given class
-         * @throws Dependencies#ClassFileNotFoundException if the classfile cannot be
+         * @throws Dependencies.ClassFileNotFoundException if the classfile cannot be
          *   found
          */
         public ClassFile getClassFile(String className)
@@ -143,6 +142,15 @@ public class Dependencies {
     }
 
     /**
+     * Get a finder to do class dependency analysis.
+     *
+     * @return a Class dependency finder
+     */
+    public static Finder getClassDependencyFinder() {
+        return new ClassDependencyFinder();
+    }
+
+    /**
      * Get the finder used to locate the dependencies for a class.
      * @return the finder
      */
@@ -247,8 +255,6 @@ public class Dependencies {
         return results;
     }
 
-
-
     /**
      * Find the dependencies of a class, using the current
      * {@link Dependencies#getFinder finder} and
@@ -307,38 +313,44 @@ public class Dependencies {
      * A location identifying a class.
      */
     static class SimpleLocation implements Location {
-        public SimpleLocation(String className) {
-            this.className = className;
+        public SimpleLocation(String name) {
+            this.name = name;
+            this.className = name.replace('/', '.');
+        }
+
+        public String getName() {
+            return name;
         }
 
-        /**
-         * Get the name of the class being depended on. This name will be used to
-         * locate the class file for transitive dependency analysis.
-         * @return the name of the class being depended on
-         */
         public String getClassName() {
             return className;
         }
 
+        public String getPackageName() {
+            int i = name.lastIndexOf('/');
+            return (i > 0) ? name.substring(0, i).replace('/', '.') : "";
+        }
+
         @Override
         public boolean equals(Object other) {
             if (this == other)
                 return true;
             if (!(other instanceof SimpleLocation))
                 return false;
-            return (className.equals(((SimpleLocation) other).className));
+            return (name.equals(((SimpleLocation) other).name));
         }
 
         @Override
         public int hashCode() {
-            return className.hashCode();
+            return name.hashCode();
         }
 
         @Override
         public String toString() {
-            return className;
+            return name;
         }
 
+        private String name;
         private String className;
     }
 
@@ -432,9 +444,7 @@ public class Dependencies {
         }
 
         public boolean accepts(Dependency dependency) {
-            String cn = dependency.getTarget().getClassName();
-            int lastSep = cn.lastIndexOf("/");
-            String pn = (lastSep == -1 ? "" : cn.substring(0, lastSep));
+            String pn = dependency.getTarget().getPackageName();
             if (packageNames.contains(pn))
                 return true;
 
@@ -452,8 +462,6 @@ public class Dependencies {
         private final boolean matchSubpackages;
     }
 
-
-
     /**
      * This class identifies class names directly or indirectly in the constant pool.
      */
@@ -463,6 +471,26 @@ public class Dependencies {
             for (CPInfo cpInfo: classfile.constant_pool.entries()) {
                 v.scan(cpInfo);
             }
+            try {
+                v.addClass(classfile.super_class);
+                v.addClasses(classfile.interfaces);
+                v.scan(classfile.attributes);
+
+                for (Field f : classfile.fields) {
+                    v.scan(f.descriptor, f.attributes);
+                }
+                for (Method m : classfile.methods) {
+                    v.scan(m.descriptor, m.attributes);
+                    Exceptions_attribute e =
+                        (Exceptions_attribute)m.attributes.get(Attribute.Exceptions);
+                    if (e != null) {
+                        v.addClasses(e.exception_index_table);
+                    }
+                }
+            } catch (ConstantPoolException e) {
+                throw new ClassFileError(e);
+            }
+
             return v.deps;
         }
     }
@@ -559,9 +587,7 @@ public class Dependencies {
             void scan(Descriptor d, Attributes attrs) {
                 try {
                     scan(new Signature(d.index).getType(constant_pool));
-                    Signature_attribute sa = (Signature_attribute) attrs.get(Attribute.Signature);
-                    if (sa != null)
-                        scan(new Signature(sa.signature_index).getType(constant_pool));
+                    scan(attrs);
                 } catch (ConstantPoolException e) {
                     throw new ClassFileError(e);
                 }
@@ -575,6 +601,43 @@ public class Dependencies {
                 t.accept(this, null);
             }
 
+            void scan(Attributes attrs) {
+                try {
+                    Signature_attribute sa = (Signature_attribute)attrs.get(Attribute.Signature);
+                    if (sa != null)
+                        scan(sa.getParsedSignature().getType(constant_pool));
+
+                    scan((RuntimeVisibleAnnotations_attribute)
+                            attrs.get(Attribute.RuntimeVisibleAnnotations));
+                    scan((RuntimeVisibleParameterAnnotations_attribute)
+                            attrs.get(Attribute.RuntimeVisibleParameterAnnotations));
+                } catch (ConstantPoolException e) {
+                    throw new ClassFileError(e);
+                }
+            }
+
+            private void scan(RuntimeAnnotations_attribute attr) throws ConstantPoolException {
+                if (attr == null) {
+                    return;
+                }
+                for (int i = 0; i < attr.annotations.length; i++) {
+                    int index = attr.annotations[i].type_index;
+                    scan(new Signature(index).getType(constant_pool));
+                }
+            }
+
+            private void scan(RuntimeParameterAnnotations_attribute attr) throws ConstantPoolException {
+                if (attr == null) {
+                    return;
+                }
+                for (int param = 0; param < attr.parameter_annotations.length; param++) {
+                    for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
+                        int index = attr.parameter_annotations[param][i].type_index;
+                        scan(new Signature(index).getType(constant_pool));
+                    }
+                }
+            }
+
             void addClass(int index) throws ConstantPoolException {
                 if (index != 0) {
                     String name = constant_pool.getClassInfo(index).getBaseName();
@@ -699,6 +762,7 @@ public class Dependencies {
                 findDependencies(type.paramTypes);
                 findDependencies(type.returnType);
                 findDependencies(type.throwsTypes);
+                findDependencies(type.typeParamTypes);
                 return null;
             }
 
@@ -710,7 +774,7 @@ public class Dependencies {
 
             public Void visitClassType(ClassType type, Void p) {
                 findDependencies(type.outerType);
-                addDependency(type.name);
+                addDependency(type.getBinaryName());
                 findDependencies(type.typeArgs);
                 return null;
             }
diff --git a/src/share/classes/com/sun/tools/classfile/Dependency.java b/src/share/classes/com/sun/tools/classfile/Dependency.java
index 5f42e81..96c9427 100644
--- a/src/share/classes/com/sun/tools/classfile/Dependency.java
+++ b/src/share/classes/com/sun/tools/classfile/Dependency.java
@@ -71,7 +71,19 @@ public interface Dependency {
          * dependency analysis.
          * @return the name of the class containing the location.
          */
+        String getName();
+
+        /**
+         * Get the fully-qualified name of the class containing the location.
+         * @return the fully-qualified name of the class containing the location.
+         */
         String getClassName();
+
+        /**
+         * Get the package name of the class containing the location.
+         * @return the package name of the class containing the location.
+         */
+        String getPackageName();
     }
 
 
diff --git a/src/share/classes/com/sun/tools/classfile/Descriptor.java b/src/share/classes/com/sun/tools/classfile/Descriptor.java
index 28db331..0e340e0 100644
--- a/src/share/classes/com/sun/tools/classfile/Descriptor.java
+++ b/src/share/classes/com/sun/tools/classfile/Descriptor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2009, 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
@@ -37,7 +37,7 @@ import java.io.IOException;
  *  deletion without notice.</b>
  */
 public class Descriptor {
-    public class InvalidDescriptor extends DescriptorException {
+    public static class InvalidDescriptor extends DescriptorException {
         private static final long serialVersionUID = 1L;
         InvalidDescriptor(String desc) {
             this.desc = desc;
@@ -114,7 +114,7 @@ public class Descriptor {
     private String parse(String desc, int start, int end)
             throws InvalidDescriptor {
         int p = start;
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         int dims = 0;
         count = 0;
 
diff --git a/src/share/classes/com/sun/tools/classfile/Instruction.java b/src/share/classes/com/sun/tools/classfile/Instruction.java
index a2d36f5..855cc78 100644
--- a/src/share/classes/com/sun/tools/classfile/Instruction.java
+++ b/src/share/classes/com/sun/tools/classfile/Instruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -71,11 +71,16 @@ public class Instruction {
         SHORT(3),
         /** Wide opcode is not followed by any operands. */
         WIDE_NO_OPERANDS(2),
+        /** Wide opcode is followed by a 2-byte index into the local variables array. */
+        WIDE_LOCAL(4),
         /** Wide opcode is followed by a 2-byte index into the constant pool. */
         WIDE_CPREF_W(4),
         /** Wide opcode is followed by a 2-byte index into the constant pool,
          *  and a signed short value. */
         WIDE_CPREF_W_SHORT(6),
+        /** Wide opcode is followed by a 2-byte reference to a local variable,
+         *  and a signed short value. */
+        WIDE_LOCAL_SHORT(6),
         /** Opcode was not recognized. */
         UNKNOWN(1);
 
@@ -101,9 +106,9 @@ public class Instruction {
         R visitConstantPoolRef(Instruction instr, int index, P p);
         /** See {@link Kind#CPREF_W_UBYTE}, {@link Kind#CPREF_W_UBYTE_ZERO}, {@link Kind#WIDE_CPREF_W_SHORT}. */
         R visitConstantPoolRefAndValue(Instruction instr, int index, int value, P p);
-        /** See {@link Kind#LOCAL}. */
+        /** See {@link Kind#LOCAL}, {@link Kind#WIDE_LOCAL}. */
         R visitLocal(Instruction instr, int index, P p);
-        /** See {@link Kind#LOCAL_UBYTE}. */
+        /** See {@link Kind#LOCAL_BYTE}. */
         R visitLocalAndValue(Instruction instr, int index, int value, P p);
         /** See {@link Kind#DYNAMIC}. */
         R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, P p);
@@ -315,6 +320,9 @@ public class Instruction {
             case WIDE_NO_OPERANDS:
                 return visitor.visitNoOperands(this, p);
 
+            case WIDE_LOCAL:
+                return visitor.visitLocal(this, getUnsignedShort(2), p);
+
             case WIDE_CPREF_W:
                 return visitor.visitConstantPoolRef(this, getUnsignedShort(2), p);
 
@@ -322,6 +330,10 @@ public class Instruction {
                 return visitor.visitConstantPoolRefAndValue(
                         this, getUnsignedShort(2), getUnsignedByte(4), p);
 
+            case WIDE_LOCAL_SHORT:
+                return visitor.visitLocalAndValue(
+                        this, getUnsignedShort(2), getShort(4), p);
+
             case UNKNOWN:
                 return visitor.visitUnknown(this, p);
 
diff --git a/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java b/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java
new file mode 100644
index 0000000..bf060cf
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JVMS, section 4.8.13.
+ *
+ *  <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 MethodParameters_attribute extends Attribute {
+
+    public final int method_parameter_table_length;
+    public final Entry[] method_parameter_table;
+
+    MethodParameters_attribute(ClassReader cr,
+                              int name_index,
+                              int length)
+        throws IOException {
+        super(name_index, length);
+
+        method_parameter_table_length = cr.readUnsignedByte();
+        method_parameter_table = new Entry[method_parameter_table_length];
+        for (int i = 0; i < method_parameter_table_length; i++)
+            method_parameter_table[i] = new Entry(cr);
+    }
+
+    public MethodParameters_attribute(ConstantPool constant_pool,
+                                      Entry[] method_parameter_table)
+        throws ConstantPoolException {
+        this(constant_pool.getUTF8Index(Attribute.MethodParameters),
+             method_parameter_table);
+    }
+
+    public MethodParameters_attribute(int name_index,
+                                      Entry[] method_parameter_table) {
+        super(name_index, 1 + method_parameter_table.length * Entry.length());
+        this.method_parameter_table_length = method_parameter_table.length;
+        this.method_parameter_table = method_parameter_table;
+    }
+
+    public <R, D> R accept(Visitor<R, D> visitor, D data) {
+        return visitor.visitMethodParameters(this, data);
+    }
+
+    public static class Entry {
+        Entry(ClassReader cr) throws IOException {
+            name_index = cr.readUnsignedShort();
+            flags = cr.readUnsignedShort();
+        }
+
+        public static int length() {
+            return 6;
+        }
+
+        public final int name_index;
+        public final int flags;
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/classfile/Opcode.java b/src/share/classes/com/sun/tools/classfile/Opcode.java
index 9f27645..f22bec8 100644
--- a/src/share/classes/com/sun/tools/classfile/Opcode.java
+++ b/src/share/classes/com/sun/tools/classfile/Opcode.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -246,18 +246,18 @@ public enum Opcode {
     // impdep 0xff: Picojava priv
 
     // wide opcodes
-    ILOAD_W(0xc415, WIDE_CPREF_W),
-    LLOAD_W(0xc416, WIDE_CPREF_W),
-    FLOAD_W(0xc417, WIDE_CPREF_W),
-    DLOAD_W(0xc418, WIDE_CPREF_W),
-    ALOAD_W(0xc419, WIDE_CPREF_W),
-    ISTORE_W(0xc436, WIDE_CPREF_W),
-    LSTORE_W(0xc437, WIDE_CPREF_W),
-    FSTORE_W(0xc438, WIDE_CPREF_W),
-    DSTORE_W(0xc439, WIDE_CPREF_W),
-    ASTORE_W(0xc43a, WIDE_CPREF_W),
-    IINC_W(0xc484, WIDE_CPREF_W_SHORT),
-    RET_W(0xc4a9, WIDE_CPREF_W),
+    ILOAD_W(0xc415, WIDE_LOCAL),
+    LLOAD_W(0xc416, WIDE_LOCAL),
+    FLOAD_W(0xc417, WIDE_LOCAL),
+    DLOAD_W(0xc418, WIDE_LOCAL),
+    ALOAD_W(0xc419, WIDE_LOCAL),
+    ISTORE_W(0xc436, WIDE_LOCAL),
+    LSTORE_W(0xc437, WIDE_LOCAL),
+    FSTORE_W(0xc438, WIDE_LOCAL),
+    DSTORE_W(0xc439, WIDE_LOCAL),
+    ASTORE_W(0xc43a, WIDE_LOCAL),
+    IINC_W(0xc484, WIDE_LOCAL_SHORT),
+    RET_W(0xc4a9, WIDE_LOCAL),
 
     // PicoJava nonpriv instructions
     LOAD_UBYTE(PICOJAVA, 0xfe00),
@@ -448,10 +448,10 @@ public enum Opcode {
 
     }
 
-    private static Opcode[] stdOpcodes = new Opcode[256];
-    private static Opcode[] wideOpcodes = new Opcode[256];
-    private static Opcode[] nonPrivOpcodes = new Opcode[256];
-    private static Opcode[] privOpcodes = new Opcode[256];
+    private static final Opcode[] stdOpcodes = new Opcode[256];
+    private static final Opcode[] wideOpcodes = new Opcode[256];
+    private static final Opcode[] nonPrivOpcodes = new Opcode[256];
+    private static final Opcode[] privOpcodes = new Opcode[256];
     static {
         for (Opcode o: values())
             getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o;
diff --git a/src/share/classes/com/sun/tools/classfile/ReferenceFinder.java b/src/share/classes/com/sun/tools/classfile/ReferenceFinder.java
new file mode 100644
index 0000000..1cc819c
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/ReferenceFinder.java
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.classfile;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import com.sun.tools.classfile.Instruction.TypeKind;
+import static com.sun.tools.classfile.ConstantPool.*;
+
+/**
+ * A utility class to find where in a ClassFile references
+ * a {@link CONSTANT_Methodref_info method},
+ * a {@link CONSTANT_InterfaceMethodref_info interface method,
+ * or a {@link CONSTANT_Fieldref_info field}.
+ */
+public final class ReferenceFinder {
+    /**
+     * Filter for ReferenceFinder of what constant pool entries for reference lookup.
+     */
+    public interface Filter {
+        /**
+         * Decides if the given CPRefInfo entry should be accepted or filtered.
+         *
+         * @param cpool  ConstantPool of the ClassFile being parsed
+         * @param cpref  constant pool entry representing a reference to
+         *               a fields method, and interface method.
+         * @return {@code true} if accepted; otherwise {@code false}
+         */
+        boolean accept(ConstantPool cpool, CPRefInfo cpref);
+    }
+
+    /**
+     * Visitor of individual method of a ClassFile that references the
+     * accepted field, method, or interface method references.
+     */
+    public interface Visitor {
+        /**
+         * Invoked for a method containing one or more accepted CPRefInfo entries
+         *
+         * @param cf      ClassFile
+         * @param method  Method that does the references the accepted references
+         * @param refs    Accepted constant pool method/field reference
+         */
+        void visit(ClassFile cf, Method method, List<CPRefInfo> refConstantPool);
+    }
+
+    private final Filter filter;
+    private final Visitor visitor;
+
+    /**
+     * Constructor.
+     */
+    public ReferenceFinder(Filter filter, Visitor visitor) {
+        this.filter = Objects.requireNonNull(filter);
+        this.visitor = Objects.requireNonNull(visitor);
+    }
+
+    /**
+     * Parses a given ClassFile and invoke the visitor if there is any reference
+     * to the constant pool entries referencing field, method, or
+     * interface method that are accepted. This method will return
+     * {@code true} if there is one or more accepted constant pool entries
+     * to lookup; otherwise, it will return {@code false}.
+     *
+     * @param  cf  ClassFile
+     * @return {@code true} if the given class file is processed to lookup
+     *         references
+     * @throws ConstantPoolException if an error of the constant pool
+     */
+    public boolean parse(ClassFile cf) throws ConstantPoolException {
+        List<Integer> cprefs = new ArrayList<Integer>();
+        int index = 1;
+        for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) {
+            if (cpInfo.accept(cpVisitor, cf.constant_pool)) {
+                cprefs.add(index);
+            }
+            index += cpInfo.size();
+        }
+
+        if (cprefs.isEmpty()) {
+            return false;
+        }
+
+        for (Method m : cf.methods) {
+            Set<Integer> ids = new HashSet<Integer>();
+            Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code);
+            if (c_attr != null) {
+                for (Instruction instr : c_attr.getInstructions()) {
+                    int idx = instr.accept(codeVisitor, cprefs);
+                    if (idx > 0) {
+                        ids.add(idx);
+                    }
+                }
+            }
+            if (ids.size() > 0) {
+                List<CPRefInfo> refInfos = new ArrayList<CPRefInfo>(ids.size());
+                for (int id : ids) {
+                    refInfos.add(CPRefInfo.class.cast(cf.constant_pool.get(id)));
+                }
+                visitor.visit(cf, m, refInfos);
+            }
+        }
+        return true;
+    }
+
+    private ConstantPool.Visitor<Boolean,ConstantPool> cpVisitor =
+            new ConstantPool.Visitor<Boolean,ConstantPool>()
+    {
+        public Boolean visitClass(CONSTANT_Class_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ConstantPool cpool) {
+            return filter.accept(cpool, info);
+        }
+
+        public Boolean visitMethodref(CONSTANT_Methodref_info info, ConstantPool cpool) {
+            return filter.accept(cpool, info);
+        }
+
+        public Boolean visitFieldref(CONSTANT_Fieldref_info info, ConstantPool cpool) {
+            return filter.accept(cpool, info);
+        }
+
+        public Boolean visitDouble(CONSTANT_Double_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitFloat(CONSTANT_Float_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitInteger(CONSTANT_Integer_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitLong(CONSTANT_Long_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitNameAndType(CONSTANT_NameAndType_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitMethodType(CONSTANT_MethodType_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitString(CONSTANT_String_info info, ConstantPool cpool) {
+            return false;
+        }
+
+        public Boolean visitUtf8(CONSTANT_Utf8_info info, ConstantPool cpool) {
+            return false;
+        }
+    };
+
+    private Instruction.KindVisitor<Integer, List<Integer>> codeVisitor =
+            new Instruction.KindVisitor<Integer, List<Integer>>()
+    {
+        public Integer visitNoOperands(Instruction instr, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitArrayType(Instruction instr, TypeKind kind, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitBranch(Instruction instr, int offset, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitConstantPoolRef(Instruction instr, int index, List<Integer> p) {
+            return p.contains(index) ? index : 0;
+        }
+
+        public Integer visitConstantPoolRefAndValue(Instruction instr, int index, int value, List<Integer> p) {
+            return p.contains(index) ? index : 0;
+        }
+
+        public Integer visitLocal(Instruction instr, int index, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitLocalAndValue(Instruction instr, int index, int value, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitValue(Instruction instr, int value, List<Integer> p) {
+            return 0;
+        }
+
+        public Integer visitUnknown(Instruction instr, List<Integer> p) {
+            return 0;
+        }
+    };
+}
+
diff --git a/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java b/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java
new file mode 100644
index 0000000..672bb55
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java
@@ -0,0 +1,56 @@
+/*
+ * 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
+ * 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.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, Section 3.
+ *
+ *  <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 RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
+    RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(cr, name_index, length);
+    }
+
+    public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, TypeAnnotation[] annotations)
+            throws ConstantPoolException {
+        this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations);
+    }
+
+    public RuntimeInvisibleTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) {
+        super(name_index, annotations);
+    }
+
+    public <R, P> R accept(Visitor<R, P> visitor, P p) {
+        return visitor.visitRuntimeInvisibleTypeAnnotations(this, p);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java b/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java
new file mode 100644
index 0000000..162e076
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java
@@ -0,0 +1,61 @@
+/*
+ * 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
+ * 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.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, Section 3.
+ *
+ *  <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 abstract class RuntimeTypeAnnotations_attribute extends Attribute {
+    protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(name_index, length);
+        int num_annotations = cr.readUnsignedShort();
+        annotations = new TypeAnnotation[num_annotations];
+        for (int i = 0; i < annotations.length; i++)
+            annotations[i] = new TypeAnnotation(cr);
+    }
+
+    protected RuntimeTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) {
+        super(name_index, length(annotations));
+        this.annotations = annotations;
+    }
+
+    private static int length(TypeAnnotation[] annos) {
+        int n = 2;
+        for (TypeAnnotation anno: annos)
+            n += anno.length();
+        return n;
+    }
+
+    public final TypeAnnotation[] annotations;
+}
diff --git a/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java b/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java
new file mode 100644
index 0000000..851c1f7
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java
@@ -0,0 +1,56 @@
+/*
+ * 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
+ * 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.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, Section 3.
+ *
+ *  <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 RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
+    RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(cr, name_index, length);
+    }
+
+    public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, TypeAnnotation[] annotations)
+            throws ConstantPoolException {
+        this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations);
+    }
+
+    public RuntimeVisibleTypeAnnotations_attribute(int name_index, TypeAnnotation[] annotations) {
+        super(name_index, annotations);
+    }
+
+    public <R, P> R accept(Visitor<R, P> visitor, P p) {
+        return visitor.visitRuntimeVisibleTypeAnnotations(this, p);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java b/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java
index ba1f2aa..6744500 100644
--- a/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java
+++ b/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 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
@@ -28,6 +28,7 @@ package com.sun.tools.classfile;
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
 import java.io.IOException;
+import java.nio.charset.Charset;
 
 /**
  * See JVMS, section 4.8.15.
@@ -38,6 +39,8 @@ import java.io.IOException;
  *  deletion without notice.</b>
  */
 public class SourceDebugExtension_attribute extends Attribute {
+    private static final Charset UTF8 = Charset.forName("UTF-8");
+
     SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException {
         super(name_index, length);
         debug_extension = new byte[attribute_length];
@@ -55,12 +58,7 @@ public class SourceDebugExtension_attribute extends Attribute {
     }
 
     public String getValue() {
-        DataInputStream d  = new DataInputStream(new ByteArrayInputStream(debug_extension));
-        try {
-            return d.readUTF();
-        } catch (IOException e) {
-            return null;
-        }
+        return new String(debug_extension, UTF8);
     }
 
     public <R, D> R accept(Visitor<R, D> visitor, D data) {
diff --git a/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java b/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java
new file mode 100644
index 0000000..1369069
--- /dev/null
+++ b/src/share/classes/com/sun/tools/classfile/TypeAnnotation.java
@@ -0,0 +1,657 @@
+/*
+ * 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.  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.classfile;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.sun.tools.classfile.TypeAnnotation.Position.TypePathEntry;
+
+/**
+ * See JSR 308 specification, Section 3.
+ *
+ *  <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 TypeAnnotation {
+    TypeAnnotation(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
+        constant_pool = cr.getConstantPool();
+        position = read_position(cr);
+        annotation = new Annotation(cr);
+    }
+
+    public TypeAnnotation(ConstantPool constant_pool,
+            Annotation annotation, Position position) {
+        this.constant_pool = constant_pool;
+        this.position = position;
+        this.annotation = annotation;
+    }
+
+    public int length() {
+        int n = annotation.length();
+        n += position_length(position);
+        return n;
+    }
+
+    @Override
+    public String toString() {
+        try {
+            return "@" + constant_pool.getUTF8Value(annotation.type_index).toString().substring(1) +
+                    " pos: " + position.toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return e.toString();
+        }
+    }
+
+    public final ConstantPool constant_pool;
+    public final Position position;
+    public final Annotation annotation;
+
+    private static Position read_position(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
+        // Copied from ClassReader
+        int tag = cr.readUnsignedByte(); // TargetType tag is a byte
+        if (!TargetType.isValidTargetTypeValue(tag))
+            throw new Annotation.InvalidAnnotation("TypeAnnotation: Invalid type annotation target type value: " + String.format("0x%02X", tag));
+
+        TargetType type = TargetType.fromTargetTypeValue(tag);
+
+        Position position = new Position();
+        position.type = type;
+
+        switch (type) {
+        // instanceof
+        case INSTANCEOF:
+        // new expression
+        case NEW:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
+            position.offset = cr.readUnsignedShort();
+            break;
+        // local variable
+        case LOCAL_VARIABLE:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            int table_length = cr.readUnsignedShort();
+            position.lvarOffset = new int[table_length];
+            position.lvarLength = new int[table_length];
+            position.lvarIndex = new int[table_length];
+            for (int i = 0; i < table_length; ++i) {
+                position.lvarOffset[i] = cr.readUnsignedShort();
+                position.lvarLength[i] = cr.readUnsignedShort();
+                position.lvarIndex[i] = cr.readUnsignedShort();
+            }
+            break;
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            position.exception_index = cr.readUnsignedShort();
+            break;
+        // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameter
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            position.parameter_index = cr.readUnsignedByte();
+            break;
+        // type parameter bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND:
+            position.parameter_index = cr.readUnsignedByte();
+            position.bound_index = cr.readUnsignedByte();
+            break;
+        // class extends or implements clause
+        case CLASS_EXTENDS:
+            int in = cr.readUnsignedShort();
+            if (in == 0xFFFF)
+                in = -1;
+            position.type_index = in;
+            break;
+        // throws
+        case THROWS:
+            position.type_index = cr.readUnsignedShort();
+            break;
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
+            position.parameter_index = cr.readUnsignedByte();
+            break;
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
+            position.offset = cr.readUnsignedShort();
+            position.type_index = cr.readUnsignedByte();
+            break;
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
+            break;
+        case UNKNOWN:
+            throw new AssertionError("TypeAnnotation: UNKNOWN target type should never occur!");
+        default:
+            throw new AssertionError("TypeAnnotation: Unknown target type: " + type);
+        }
+
+        { // Write type path
+            int len = cr.readUnsignedByte();
+            List<Integer> loc = new ArrayList<Integer>(len);
+            for (int i = 0; i < len * TypePathEntry.bytesPerEntry; ++i)
+                loc.add(cr.readUnsignedByte());
+            position.location = Position.getTypePathFromBinary(loc);
+        }
+        return position;
+    }
+
+    private static int position_length(Position pos) {
+        int n = 0;
+        n += 1; // TargetType tag is a byte
+        switch (pos.type) {
+        // instanceof
+        case INSTANCEOF:
+        // new expression
+        case NEW:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
+            n += 2; // offset
+            break;
+        // local variable
+        case LOCAL_VARIABLE:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            n += 2; // table_length;
+            int table_length = pos.lvarOffset.length;
+            n += 2 * table_length; // offset
+            n += 2 * table_length; // length
+            n += 2 * table_length; // index
+            break;
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            n += 2; // exception_index
+            break;
+        // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameter
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            n += 1; // parameter_index
+            break;
+        // type parameter bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND:
+            n += 1; // parameter_index
+            n += 1; // bound_index
+            break;
+        // class extends or implements clause
+        case CLASS_EXTENDS:
+            n += 2; // type_index
+            break;
+        // throws
+        case THROWS:
+            n += 2; // type_index
+            break;
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
+            n += 1; // parameter_index
+            break;
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
+            n += 2; // offset
+            n += 1; // type index
+            break;
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
+            break;
+        case UNKNOWN:
+            throw new AssertionError("TypeAnnotation: UNKNOWN target type should never occur!");
+        default:
+            throw new AssertionError("TypeAnnotation: Unknown target type: " + pos.type);
+        }
+
+        {
+            n += 1; // length
+            n += TypePathEntry.bytesPerEntry * pos.location.size(); // bytes for actual array
+        }
+
+        return n;
+    }
+
+    // Code duplicated from com.sun.tools.javac.code.TypeAnnotationPosition
+    public static class Position {
+        public enum TypePathEntryKind {
+            ARRAY(0),
+            INNER_TYPE(1),
+            WILDCARD(2),
+            TYPE_ARGUMENT(3);
+
+            public final int tag;
+
+            private TypePathEntryKind(int tag) {
+                this.tag = tag;
+            }
+        }
+
+        public static class TypePathEntry {
+            /** The fixed number of bytes per TypePathEntry. */
+            public static final int bytesPerEntry = 2;
+
+            public final TypePathEntryKind tag;
+            public final int arg;
+
+            public static final TypePathEntry ARRAY = new TypePathEntry(TypePathEntryKind.ARRAY);
+            public static final TypePathEntry INNER_TYPE = new TypePathEntry(TypePathEntryKind.INNER_TYPE);
+            public static final TypePathEntry WILDCARD = new TypePathEntry(TypePathEntryKind.WILDCARD);
+
+            private TypePathEntry(TypePathEntryKind tag) {
+                if (!(tag == TypePathEntryKind.ARRAY ||
+                        tag == TypePathEntryKind.INNER_TYPE ||
+                        tag == TypePathEntryKind.WILDCARD)) {
+                    throw new AssertionError("Invalid TypePathEntryKind: " + tag);
+                }
+                this.tag = tag;
+                this.arg = 0;
+            }
+
+            public TypePathEntry(TypePathEntryKind tag, int arg) {
+                if (tag != TypePathEntryKind.TYPE_ARGUMENT) {
+                    throw new AssertionError("Invalid TypePathEntryKind: " + tag);
+                }
+                this.tag = tag;
+                this.arg = arg;
+            }
+
+            public static TypePathEntry fromBinary(int tag, int arg) {
+                if (arg != 0 && tag != TypePathEntryKind.TYPE_ARGUMENT.tag) {
+                    throw new AssertionError("Invalid TypePathEntry tag/arg: " + tag + "/" + arg);
+                }
+                switch (tag) {
+                case 0:
+                    return ARRAY;
+                case 1:
+                    return INNER_TYPE;
+                case 2:
+                    return WILDCARD;
+                case 3:
+                    return new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg);
+                default:
+                    throw new AssertionError("Invalid TypePathEntryKind tag: " + tag);
+                }
+            }
+
+            @Override
+            public String toString() {
+                return tag.toString() +
+                        (tag == TypePathEntryKind.TYPE_ARGUMENT ? ("(" + arg + ")") : "");
+            }
+
+            @Override
+            public boolean equals(Object other) {
+                if (! (other instanceof TypePathEntry)) {
+                    return false;
+                }
+                TypePathEntry tpe = (TypePathEntry) other;
+                return this.tag == tpe.tag && this.arg == tpe.arg;
+            }
+
+            @Override
+            public int hashCode() {
+                return this.tag.hashCode() * 17 + this.arg;
+            }
+        }
+
+        public TargetType type = TargetType.UNKNOWN;
+
+        // For generic/array types.
+        // TODO: or should we use null? Noone will use this object.
+        public List<TypePathEntry> location = new ArrayList<TypePathEntry>(0);
+
+        // Tree position.
+        public int pos = -1;
+
+        // For typecasts, type tests, new (and locals, as start_pc).
+        public boolean isValidOffset = false;
+        public int offset = -1;
+
+        // For locals. arrays same length
+        public int[] lvarOffset = null;
+        public int[] lvarLength = null;
+        public int[] lvarIndex = null;
+
+        // For type parameter bound
+        public int bound_index = Integer.MIN_VALUE;
+
+        // For type parameter and method parameter
+        public int parameter_index = Integer.MIN_VALUE;
+
+        // For class extends, implements, and throws clauses
+        public int type_index = Integer.MIN_VALUE;
+
+        // For exception parameters, index into exception table
+        public int exception_index = Integer.MIN_VALUE;
+
+        public Position() {}
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append('[');
+            sb.append(type);
+
+            switch (type) {
+            // instanceof
+            case INSTANCEOF:
+            // new expression
+            case NEW:
+            // constructor/method reference receiver
+            case CONSTRUCTOR_REFERENCE:
+            case METHOD_REFERENCE:
+                sb.append(", offset = ");
+                sb.append(offset);
+                break;
+            // local variable
+            case LOCAL_VARIABLE:
+            // resource variable
+            case RESOURCE_VARIABLE:
+                if (lvarOffset == null) {
+                    sb.append(", lvarOffset is null!");
+                    break;
+                }
+                sb.append(", {");
+                for (int i = 0; i < lvarOffset.length; ++i) {
+                    if (i != 0) sb.append("; ");
+                    sb.append("start_pc = ");
+                    sb.append(lvarOffset[i]);
+                    sb.append(", length = ");
+                    sb.append(lvarLength[i]);
+                    sb.append(", index = ");
+                    sb.append(lvarIndex[i]);
+                }
+                sb.append("}");
+                break;
+            // method receiver
+            case METHOD_RECEIVER:
+                // Do nothing
+                break;
+            // type parameter
+            case CLASS_TYPE_PARAMETER:
+            case METHOD_TYPE_PARAMETER:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                break;
+            // type parameter bound
+            case CLASS_TYPE_PARAMETER_BOUND:
+            case METHOD_TYPE_PARAMETER_BOUND:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                sb.append(", bound_index = ");
+                sb.append(bound_index);
+                break;
+            // class extends or implements clause
+            case CLASS_EXTENDS:
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            // throws
+            case THROWS:
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            // exception parameter
+            case EXCEPTION_PARAMETER:
+                sb.append(", exception_index = ");
+                sb.append(exception_index);
+                break;
+            // method parameter
+            case METHOD_FORMAL_PARAMETER:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                break;
+            // type cast
+            case CAST:
+            // method/constructor/reference type argument
+            case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+            case METHOD_INVOCATION_TYPE_ARGUMENT:
+            case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+            case METHOD_REFERENCE_TYPE_ARGUMENT:
+                sb.append(", offset = ");
+                sb.append(offset);
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            // We don't need to worry about these
+            case METHOD_RETURN:
+            case FIELD:
+                break;
+            case UNKNOWN:
+                sb.append(", position UNKNOWN!");
+                break;
+            default:
+                throw new AssertionError("Unknown target type: " + type);
+            }
+
+            // Append location data for generics/arrays.
+            if (!location.isEmpty()) {
+                sb.append(", location = (");
+                sb.append(location);
+                sb.append(")");
+            }
+
+            sb.append(", pos = ");
+            sb.append(pos);
+
+            sb.append(']');
+            return sb.toString();
+        }
+
+        /**
+         * Indicates whether the target tree of the annotation has been optimized
+         * away from classfile or not.
+         * @return true if the target has not been optimized away
+         */
+        public boolean emitToClassfile() {
+            return !type.isLocal() || isValidOffset;
+        }
+
+        /**
+         * Decode the binary representation for a type path and set
+         * the {@code location} field.
+         *
+         * @param list The bytecode representation of the type path.
+         */
+        public static List<TypePathEntry> getTypePathFromBinary(List<Integer> list) {
+            List<TypePathEntry> loc = new ArrayList<TypePathEntry>(list.size() / TypePathEntry.bytesPerEntry);
+            int idx = 0;
+            while (idx < list.size()) {
+                if (idx + 1 == list.size()) {
+                    throw new AssertionError("Could not decode type path: " + list);
+                }
+                loc.add(TypePathEntry.fromBinary(list.get(idx), list.get(idx + 1)));
+                idx += 2;
+            }
+            return loc;
+        }
+
+        public static List<Integer> getBinaryFromTypePath(List<TypePathEntry> locs) {
+            List<Integer> loc = new ArrayList<Integer>(locs.size() * TypePathEntry.bytesPerEntry);
+            for (TypePathEntry tpe : locs) {
+                loc.add(tpe.tag.tag);
+                loc.add(tpe.arg);
+            }
+            return loc;
+        }
+    }
+
+    // Code duplicated from com.sun.tools.javac.code.TargetType
+    // The IsLocal flag could be removed here.
+    public enum TargetType {
+        /** For annotations on a class type parameter declaration. */
+        CLASS_TYPE_PARAMETER(0x00),
+
+        /** For annotations on a method type parameter declaration. */
+        METHOD_TYPE_PARAMETER(0x01),
+
+        /** For annotations on the type of an "extends" or "implements" clause. */
+        CLASS_EXTENDS(0x10),
+
+        /** For annotations on a bound of a type parameter of a class. */
+        CLASS_TYPE_PARAMETER_BOUND(0x11),
+
+        /** For annotations on a bound of a type parameter of a method. */
+        METHOD_TYPE_PARAMETER_BOUND(0x12),
+
+        /** For annotations on a field. */
+        FIELD(0x13),
+
+        /** For annotations on a method return type. */
+        METHOD_RETURN(0x14),
+
+        /** For annotations on the method receiver. */
+        METHOD_RECEIVER(0x15),
+
+        /** For annotations on a method parameter. */
+        METHOD_FORMAL_PARAMETER(0x16),
+
+        /** For annotations on a throws clause in a method declaration. */
+        THROWS(0x17),
+
+        /** For annotations on a local variable. */
+        LOCAL_VARIABLE(0x40, true),
+
+        /** For annotations on a resource variable. */
+        RESOURCE_VARIABLE(0x41, true),
+
+        /** For annotations on an exception parameter. */
+        EXCEPTION_PARAMETER(0x42, true),
+
+        /** For annotations on a type test. */
+        INSTANCEOF(0x43, true),
+
+        /** For annotations on an object creation expression. */
+        NEW(0x44, true),
+
+        /** For annotations on a constructor reference receiver. */
+        CONSTRUCTOR_REFERENCE(0x45, true),
+
+        /** For annotations on a method reference receiver. */
+        METHOD_REFERENCE(0x46, true),
+
+        /** For annotations on a typecast. */
+        CAST(0x47, true),
+
+        /** For annotations on a type argument of an object creation expression. */
+        CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(0x48, true),
+
+        /** For annotations on a type argument of a method call. */
+        METHOD_INVOCATION_TYPE_ARGUMENT(0x49, true),
+
+        /** For annotations on a type argument of a constructor reference. */
+        CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
+
+        /** For annotations on a type argument of a method reference. */
+        METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true),
+
+        /** For annotations with an unknown target. */
+        UNKNOWN(0xFF);
+
+        private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
+
+        private final int targetTypeValue;
+        private final boolean isLocal;
+
+        private TargetType(int targetTypeValue) {
+            this(targetTypeValue, false);
+        }
+
+        private TargetType(int targetTypeValue, boolean isLocal) {
+            if (targetTypeValue < 0
+                    || targetTypeValue > 255)
+                    throw new AssertionError("Attribute type value needs to be an unsigned byte: " + String.format("0x%02X", targetTypeValue));
+            this.targetTypeValue = targetTypeValue;
+            this.isLocal = isLocal;
+        }
+
+        /**
+         * Returns whether or not this TargetType represents an annotation whose
+         * target is exclusively a tree in a method body
+         *
+         * Note: wildcard bound targets could target a local tree and a class
+         * member declaration signature tree
+         */
+        public boolean isLocal() {
+            return isLocal;
+        }
+
+        public int targetTypeValue() {
+            return this.targetTypeValue;
+        }
+
+        private static final TargetType[] targets;
+
+        static {
+            targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
+            TargetType[] alltargets = values();
+            for (TargetType target : alltargets) {
+                if (target.targetTypeValue != UNKNOWN.targetTypeValue)
+                    targets[target.targetTypeValue] = target;
+            }
+            for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
+                if (targets[i] == null)
+                    targets[i] = UNKNOWN;
+            }
+        }
+
+        public static boolean isValidTargetTypeValue(int tag) {
+            if (tag == UNKNOWN.targetTypeValue)
+                return true;
+            return (tag >= 0 && tag < targets.length);
+        }
+
+        public static TargetType fromTargetTypeValue(int tag) {
+            if (tag == UNKNOWN.targetTypeValue)
+                return UNKNOWN;
+
+            if (tag < 0 || tag >= targets.length)
+                throw new AssertionError("Unknown TargetType: " + tag);
+            return targets[tag];
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
index 191b392..0468a8e 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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
@@ -33,6 +33,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Print method and constructor info.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -40,7 +45,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
 
     public AbstractExecutableMemberWriter(SubWriterHolderWriter writer,
-                                     ClassDoc classdoc) {
+            ClassDoc classdoc) {
         super(writer, classdoc);
     }
 
@@ -55,17 +60,24 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      * @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) {
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
-            LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
-        String typeParameters = writer.getTypeParameterLinks(linkInfo);
-        if (linkInfo.displayLength > 0) {
-            Content linkContent = new RawHtml(typeParameters);
-            htmltree.addContent(linkContent);
+    protected void addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
+        Content typeParameters = getTypeParameters(member);
+        if (!typeParameters.isEmpty()) {
+            htmltree.addContent(typeParameters);
             htmltree.addContent(writer.getSpace());
-            writer.displayLength += linkInfo.displayLength + 1;
         }
-        return linkInfo.displayLength;
+    }
+
+    /**
+     * 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.Kind.MEMBER_TYPE_PARAMS, member);
+        return writer.getTypeParameterLinks(linkInfo);
     }
 
     /**
@@ -73,7 +85,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      */
     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());
     }
 
@@ -81,35 +93,34 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      * Add the summary link for the member.
      *
      * @param context the id of the context where the link will be printed
-     * @param classDoc the classDoc that we should link to
+     * @param cd the classDoc that we should link to
      * @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);
     }
 
     /**
      * Add the inherited summary link for the member.
      *
-     * @param classDoc the classDoc that we should link to
+     * @param cd the classDoc that we should link to
      * @param member the member being linked to
      * @param linksTree the content tree to which the link will be added
      */
     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));
     }
 
     /**
@@ -121,11 +132,11 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      * @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(
-                    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) {
@@ -135,13 +146,34 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
     }
 
     /**
+     * Add the receiver annotations information.
+     *
+     * @param member the member to write receiver annotations for.
+     * @param rcvrType the receiver type.
+     * @param descList list of annotation description.
+     * @param tree the content tree to which the information will be added.
+     */
+    protected void addReceiverAnnotations(ExecutableMemberDoc member, Type rcvrType,
+            AnnotationDesc[] descList, Content tree) {
+        writer.addReceiverAnnotationInfo(member, descList, tree);
+        tree.addContent(writer.getSpace());
+        tree.addContent(rcvrType.typeName());
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.Kind.CLASS_SIGNATURE, rcvrType);
+        tree.addContent(writer.getTypeParameterLinks(linkInfo));
+        tree.addContent(writer.getSpace());
+        tree.addContent("this");
+    }
+
+
+    /**
      * Add all the parameters for the executable member.
      *
      * @param member the member to write parameters for.
-     * @param tree the content tree to which the parameters information will be added.
+     * @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);
     }
 
     /**
@@ -149,19 +181,25 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      *
      * @param member the member to write parameters for.
      * @param includeAnnotations true if annotation information needs to be added.
-     * @param tree the content tree to which the parameters information will be added.
+     * @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();
+            if (descList.length > 0) {
+                addReceiverAnnotations(member, rcvrType, descList, htmltree);
+                sep = "," + DocletConstants.NL + indent;
+            }
         }
         int paramstart;
         for (paramstart = 0; paramstart < params.length; paramstart++) {
+            htmltree.addContent(sep);
             Parameter param = params[paramstart];
             if (!param.name().startsWith("this$")) {
                 if (includeAnnotations) {
@@ -204,53 +242,30 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      * @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) {
-            LinkInfoImpl memberTypeParam = new LinkInfoImpl(
-                    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);
+        if (exceptions.length > 0) {
+            LinkInfoImpl memberTypeParam = new LinkInfoImpl(configuration,
+                    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(
-                    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(
-                        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(
-                    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++) {
@@ -276,7 +291,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
      * @return the 1.4.x style anchor for the ExecutableMemberDoc.
      */
     protected String getErasureAnchor(ExecutableMemberDoc emd) {
-        StringBuffer buf = new StringBuffer(emd.name() + "(");
+        StringBuilder buf = new StringBuilder(emd.name() + "(");
         Parameter[] params = emd.parameters();
         boolean foundTypeVariable = false;
         for (int i = 0; i < params.length; i++) {
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
index 0284f8a..87a5bce 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -29,9 +29,9 @@ import java.io.*;
 import java.util.*;
 
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate Index for all the Member Names with Indexing in
@@ -39,6 +39,11 @@ import com.sun.tools.doclets.internal.toolkit.*;
  * {@link SplitIndexWriter}. It uses the functionality from
  * {@link HtmlDocletWriter} to generate the Index Contents.
  *
+ *  <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>
+ *
  * @see    IndexBuilder
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -51,32 +56,18 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
     protected IndexBuilder indexbuilder;
 
     /**
-     * This constructor will be used by {@link SplitIndexWriter}. Initialises
+     * This constructor will be used by {@link SplitIndexWriter}. Initializes
      * path to this file and relative path from this file.
      *
+     * @param configuration  The current configuration
      * @param path       Path to the file which is getting generated.
-     * @param filename   Name of the file which is getting genrated.
-     * @param relpath    Relative path from this file to the current directory.
      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
      */
     protected AbstractIndexWriter(ConfigurationImpl configuration,
-                                  String path, String filename,
-                                  String relpath, IndexBuilder indexbuilder)
-                                  throws IOException {
-        super(configuration, path, filename, relpath);
-        this.indexbuilder = indexbuilder;
-    }
-
-    /**
-     * This Constructor will be used by {@link SingleIndexWriter}.
-     *
-     * @param filename   Name of the file which is getting genrated.
-     * @param indexbuilder Unicode based Index form {@link IndexBuilder}
-     */
-    protected AbstractIndexWriter(ConfigurationImpl configuration,
-                                  String filename, IndexBuilder indexbuilder)
+                                  DocPath path,
+                                  IndexBuilder indexbuilder)
                                   throws IOException {
-        super(configuration, filename);
+        super(configuration, path);
         this.indexbuilder = indexbuilder;
     }
 
@@ -148,8 +139,8 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
      * @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(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);
@@ -160,7 +151,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
     }
 
     /**
-     * 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
@@ -169,8 +160,9 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
     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()))
+                ));
     }
 
     /**
@@ -183,11 +175,8 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
         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);
@@ -261,7 +250,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter {
                         getResource("doclet.Method_in", classdesc));
             }
         }
-        addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
+        addPreQualifiedClassLink(LinkInfoImpl.Kind.INDEX, containing,
                 false, contentTree);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
index 27ca14f..8ca5691 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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,17 +25,23 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import java.util.*;
 import java.lang.reflect.Modifier;
+import java.util.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * The base class for member writers.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Jamie Ho (Re-write)
@@ -43,15 +49,20 @@ import com.sun.tools.doclets.internal.toolkit.taglets.*;
  */
 public abstract class AbstractMemberWriter {
 
-    protected boolean printedSummaryHeader = false;
+    protected final ConfigurationImpl configuration;
     protected final SubWriterHolderWriter writer;
     protected final ClassDoc classdoc;
+    protected Map<String,Integer> typeMap = new LinkedHashMap<String,Integer>();
+    protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class);
+    private int methodTypesOr = 0;
     public final boolean nodepr;
 
-    public AbstractMemberWriter(SubWriterHolderWriter writer,
-                             ClassDoc classdoc) {
+    protected boolean printedSummaryHeader = false;
+
+    public AbstractMemberWriter(SubWriterHolderWriter writer, ClassDoc classdoc) {
+        this.configuration = writer.configuration;
         this.writer = writer;
-        this.nodepr = configuration().nodeprecated;
+        this.nodepr = configuration.nodeprecated;
         this.classdoc = classdoc;
     }
 
@@ -80,7 +91,7 @@ public abstract class AbstractMemberWriter {
      *
      * @return a string for the table caption
      */
-    public abstract String getCaption();
+    public abstract Content getCaption();
 
     /**
      * Get the summary table header for the member.
@@ -132,7 +143,7 @@ public abstract class AbstractMemberWriter {
      */
     protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member,
             Content tdSummary) {
-        addSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member, tdSummary);
+        addSummaryLink(LinkInfoImpl.Kind.MEMBER, cd, member, tdSummary);
     }
 
     /**
@@ -143,7 +154,7 @@ public abstract class AbstractMemberWriter {
      * @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);
 
     /**
@@ -181,32 +192,14 @@ public abstract class AbstractMemberWriter {
      */
     protected abstract void addNavDetailLink(boolean link, Content liNav);
 
-    /***  ***/
-
-    protected void print(String str) {
-        writer.print(str);
-        writer.displayLength += str.length();
-    }
-
-    protected void print(char ch) {
-        writer.print(ch);
-        writer.displayLength++;
-    }
-
-    protected void strong(String str) {
-        writer.strong(str);
-        writer.displayLength += str.length();
-    }
-
     /**
-     * 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();
     }
 
     /**
@@ -245,7 +238,14 @@ public abstract class AbstractMemberWriter {
         if ((member.isField() || member.isMethod()) &&
             writer instanceof ClassWriterImpl &&
             ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
-            mod = Util.replaceText(mod, "public", "").trim();
+            // This check for isDefault() and the default modifier needs to be
+            // added for it to appear on the method details section. Once the
+            // default modifier is added to the Modifier list on DocEnv and once
+            // it is updated to use the javax.lang.model.element.Modifier, we
+            // will need to remove this.
+            mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ?
+                    Util.replaceText(mod, "public", "default").trim() :
+                    Util.replaceText(mod, "public", "").trim();
         }
         if(mod.length() > 0) {
             htmltree.addContent(mod);
@@ -257,8 +257,8 @@ public abstract class AbstractMemberWriter {
         if (len <= 0) {
             return "";
         }
-        StringBuffer sb = new StringBuffer(len);
-        for(int i = 0; i < len; i++) {
+        StringBuilder sb = new StringBuilder(len);
+        for (int i = 0; i < len; i++) {
             sb.append(' ');
     }
         return sb.toString();
@@ -285,42 +285,28 @@ public abstract class AbstractMemberWriter {
         } 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(
-                        writer.getLink(new LinkInfoImpl(
-                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+                code.addContent(
+                        writer.getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
             } else {
-                code.addContent(new RawHtml(
-                        writer.getLink(new LinkInfoImpl(
-                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+                code.addContent(
+                        writer.getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type)));
             }
 
         }
         tdSummaryType.addContent(code);
     }
 
-    private void printModifier(ProgramElementDoc member) {
-        if (member.isProtected()) {
-            print("protected ");
-        } else if (member.isPrivate()) {
-            print("private ");
-        } else if (!member.isPublic()) { // Package private
-            writer.printText("doclet.Package_private");
-            print(" ");
-        }
-        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
-            print("abstract ");
-        }
-        if (member.isStatic()) {
-            print("static");
-        }
-    }
-
     /**
      * Add the modifier for the member.
      *
@@ -333,11 +319,22 @@ public abstract class AbstractMemberWriter {
         } else if (member.isPrivate()) {
             code.addContent("private ");
         } else if (!member.isPublic()) { // Package private
-            code.addContent(configuration().getText("doclet.Package_private"));
+            code.addContent(configuration.getText("doclet.Package_private"));
             code.addContent(" ");
         }
-        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
-            code.addContent("abstract ");
+        if (member.isMethod()) {
+            if (!(member.containingClass().isInterface()) &&
+                    ((MethodDoc)member).isAbstract()) {
+                code.addContent("abstract ");
+            }
+            // This check for isDefault() and the default modifier needs to be
+            // added for it to appear on the "Modifier and Type" column in the
+            // method summary section. Once the default modifier is added
+            // to the Modifier list on DocEnv and once it is updated to use the
+            // javax.lang.model.element.Modifier, we will need to remove this.
+            if (((MethodDoc)member).isDefault()) {
+                code.addContent("default ");
+            }
         }
         if (member.isStatic()) {
             code.addContent("static ");
@@ -351,10 +348,10 @@ public abstract class AbstractMemberWriter {
      * @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);
         }
@@ -364,7 +361,7 @@ public abstract class AbstractMemberWriter {
      * Add the comment for the given member.
      *
      * @param member the member being documented.
-     * @param contentTree the content tree to which the comment will be added.
+     * @param htmltree the content tree to which the comment will be added.
      */
     protected void addComment(ProgramElementDoc member, Content htmltree) {
         if (member.inlineTags().length > 0) {
@@ -383,7 +380,7 @@ public abstract class AbstractMemberWriter {
      * @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;
     }
@@ -417,7 +414,7 @@ public abstract class AbstractMemberWriter {
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprmembers.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                writer.getTableCaption(configuration().getText(headingKey)));
+                writer.getTableCaption(configuration.getResource(headingKey)));
             table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprmembers.size(); i++) {
@@ -449,7 +446,7 @@ public abstract class AbstractMemberWriter {
      * @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;
         }
@@ -488,7 +485,7 @@ public abstract class AbstractMemberWriter {
                     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);
@@ -535,8 +532,8 @@ public abstract class AbstractMemberWriter {
     }
 
     protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
-        if (configuration().serialwarn) {
-            ConfigurationImpl.getInstance().getDocletSpecificMsg().warning(pos, key, a1, a2);
+        if (configuration.serialwarn) {
+            configuration.getDocletSpecificMsg().warning(pos, key, a1, a2);
         }
     }
 
@@ -544,21 +541,17 @@ public abstract class AbstractMemberWriter {
         return nodepr? Util.excludeDeprecatedMembers(members): members;
     }
 
-    public ConfigurationImpl configuration() {
-        return writer.configuration;
-    }
-
     /**
      * Add the member summary for the given class.
      *
      * @param classDoc the class that is being documented
      * @param member the member being documented
      * @param firstSentenceTags the first sentence tags to be added to the summary
-     * @param tableTree the content tree to which the documentation will be added
-     * @param counter the counter for determing style for the table row
+     * @param tableContents the list of contents to which the documentation will be added
+     * @param counter the counter for determining id and style for the table row
      */
     public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
-            Tag[] firstSentenceTags, Content tableTree, int counter) {
+            Tag[] firstSentenceTags, List<Content> tableContents, int counter) {
         HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
         tdSummaryType.addStyle(HtmlStyle.colFirst);
         writer.addSummaryType(this, member, tdSummaryType);
@@ -568,11 +561,52 @@ public abstract class AbstractMemberWriter {
         writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
         HtmlTree tr = HtmlTree.TR(tdSummaryType);
         tr.addContent(tdSummary);
+        if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
+            int methodType = (member.isStatic()) ? MethodTypes.STATIC.value() :
+                    MethodTypes.INSTANCE.value();
+            if (member.containingClass().isInterface()) {
+                methodType = (((MethodDoc) member).isAbstract())
+                        ? methodType | MethodTypes.ABSTRACT.value()
+                        : methodType | MethodTypes.DEFAULT.value();
+            } else {
+                methodType = (((MethodDoc) member).isAbstract())
+                        ? methodType | MethodTypes.ABSTRACT.value()
+                        : methodType | MethodTypes.CONCRETE.value();
+            }
+            if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) {
+                methodType = methodType | MethodTypes.DEPRECATED.value();
+            }
+            methodTypesOr = methodTypesOr | methodType;
+            String tableId = "i" + counter;
+            typeMap.put(tableId, methodType);
+            tr.addAttr(HtmlAttr.ID, tableId);
+        }
         if (counter%2 == 0)
             tr.addStyle(HtmlStyle.altColor);
         else
             tr.addStyle(HtmlStyle.rowColor);
-        tableTree.addContent(tr);
+        tableContents.add(tr);
+    }
+
+    /**
+     * Generate the method types set and return true if the method summary table
+     * needs to show tabs.
+     *
+     * @return true if the table should show tabs
+     */
+    public boolean showTabs() {
+        int value;
+        for (MethodTypes type : EnumSet.allOf(MethodTypes.class)) {
+            value = type.value();
+            if ((value & methodTypesOr) == value) {
+                methodTypes.add(type);
+            }
+        }
+        boolean showTabs = methodTypes.size() > 1;
+        if (showTabs) {
+            methodTypes.add(MethodTypes.ALL);
+        }
+        return showTabs;
     }
 
     /**
@@ -625,10 +659,11 @@ public abstract class AbstractMemberWriter {
      * Get the summary table tree for the given class.
      *
      * @param classDoc the class for which the summary table is generated
+     * @param tableContents list of contents to be displayed in the summary table
      * @return a content tree for the summary table
      */
-    public Content getSummaryTableTree(ClassDoc classDoc) {
-        return writer.getSummaryTableTree(this, classDoc);
+    public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) {
+        return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
index ef407df..95cd4a4 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -27,15 +27,22 @@ 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.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocPath;
 
 /**
  * Abstract class to generate the overview files in
  * Frame and Non-Frame format. This will be sub-classed by to
  * generate overview-frame.html as well as overview-summary.html.
  *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
@@ -47,14 +54,14 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
     protected PackageDoc[] packages;
 
     /**
-     * Constructor. Also initialises the packages variable.
+     * Constructor. Also initializes the packages variable.
      *
+     * @param configuration  The current configuration
      * @param filename Name of the package index file to be generated.
      */
     public AbstractPackageIndexWriter(ConfigurationImpl configuration,
-                                      String filename) throws IOException {
+                                      DocPath filename) throws IOException {
         super(configuration, filename);
-        this.relativepathNoSlash = ".";
         packages = configuration.packages;
     }
 
@@ -143,7 +150,20 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
             String tableSummary, Content body) {
         if (packages.length > 0) {
             Arrays.sort(packages);
-            addAllClassesLink(body);
+            HtmlTree div = new HtmlTree(HtmlTag.DIV);
+            div.addStyle(HtmlStyle.indexHeader);
+            addAllClassesLink(div);
+            if (configuration.showProfiles) {
+                addAllProfilesLink(div);
+            }
+            body.addContent(div);
+            if (configuration.showProfiles) {
+                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);
         }
     }
@@ -175,10 +195,29 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
     }
 
     /**
-     * Do nothing. This will be overridden in PackageIndexFrameWriter.
+     * Do nothing. This will be overridden.
+     *
+     * @param div the document tree to which the all classes link will be added
+     */
+    protected void addAllClassesLink(Content div) {
+    }
+
+    /**
+     * Do nothing. This will be overridden.
+     *
+     * @param div the document tree to which the all profiles link will be added
+     */
+    protected void addAllProfilesLink(Content div) {
+    }
+
+    /**
+     * Do nothing. This will be overridden.
      *
-     * @param body the document tree to which the all classes link will be added
+     * @param profileSummary the profile summary heading
+     * @param profilesTableSummary the profiles table summary information
+     * @param body the content tree to which the profiles list will be added
      */
-    protected void addAllClassesLink(Content body) {
+    protected void addProfilesList(Content profileSummary, Content profilesTableSummary,
+            Content body) {
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractProfileIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractProfileIndexWriter.java
new file mode 100644
index 0000000..c0f7ccf
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractProfileIndexWriter.java
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+
+import com.sun.tools.javac.sym.Profiles;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocPath;
+
+/**
+ * Abstract class to generate the profile overview files in
+ * Frame and Non-Frame format. This will be sub-classed to
+ * generate profile-overview-frame.html as well as profile-overview-summary.html.
+ *
+ *  <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 Bhavesh Patel
+ */
+public abstract class AbstractProfileIndexWriter extends HtmlDocletWriter {
+
+    /**
+     * Profiles to be documented.
+     */
+    protected Profiles profiles;
+
+    /**
+     * Constructor. Also initializes the profiles variable.
+     *
+     * @param configuration  The current configuration
+     * @param filename Name of the profile index file to be generated.
+     */
+    public AbstractProfileIndexWriter(ConfigurationImpl configuration,
+                                      DocPath filename) throws IOException {
+        super(configuration, filename);
+        profiles = configuration.profiles;
+    }
+
+    /**
+     * Adds the navigation bar header to the documentation tree.
+     *
+     * @param body the document tree to which the navigation bar header will be added
+     */
+    protected abstract void addNavigationBarHeader(Content body);
+
+    /**
+     * Adds the navigation bar footer to the documentation tree.
+     *
+     * @param body the document tree to which the navigation bar footer will be added
+     */
+    protected abstract void addNavigationBarFooter(Content body);
+
+    /**
+     * Adds the overview header to the documentation tree.
+     *
+     * @param body the document tree to which the overview header will be added
+     */
+    protected abstract void addOverviewHeader(Content body);
+
+    /**
+     * Adds the profiles list to the documentation tree.
+     *
+     * @param profiles profiles object
+     * @param text caption for the table
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the profiles list will be added
+     */
+    protected abstract void addProfilesList(Profiles profiles, String text,
+            String tableSummary, Content body);
+
+    /**
+     * Adds the profile packages list to the documentation tree.
+     *
+     * @param profiles profiles object
+     * @param text caption for the table
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the profiles list will be added
+     * @param profileName the name for the profile being documented
+     */
+    protected abstract void addProfilePackagesList(Profiles profiles, String text,
+            String tableSummary, Content body, String profileName);
+
+    /**
+     * Generate and prints the contents in the profile index file. Call appropriate
+     * methods from the sub-class in order to generate Frame or Non
+     * Frame format.
+     *
+     * @param title the title of the window.
+     * @param includeScript boolean set true if windowtitle script is to be included
+     */
+    protected void buildProfileIndexFile(String title, boolean includeScript) throws IOException {
+        String windowOverview = configuration.getText(title);
+        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        addNavigationBarHeader(body);
+        addOverviewHeader(body);
+        addIndex(body);
+        addOverview(body);
+        addNavigationBarFooter(body);
+        printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
+                configuration.doctitle), includeScript, body);
+    }
+
+    /**
+     * Generate and prints the contents in the profile packages index file. Call appropriate
+     * methods from the sub-class in order to generate Frame or Non
+     * Frame format.
+     *
+     * @param title the title of the window.
+     * @param includeScript boolean set true if windowtitle script is to be included
+     * @param profileName the name of the profile being documented
+     */
+    protected void buildProfilePackagesIndexFile(String title,
+            boolean includeScript, String profileName) throws IOException {
+        String windowOverview = configuration.getText(title);
+        Content body = getBody(includeScript, getWindowTitle(windowOverview));
+        addNavigationBarHeader(body);
+        addOverviewHeader(body);
+        addProfilePackagesIndex(body, profileName);
+        addOverview(body);
+        addNavigationBarFooter(body);
+        printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
+                configuration.doctitle), includeScript, body);
+    }
+
+    /**
+     * Default to no overview, override to add overview.
+     *
+     * @param body the document tree to which the overview will be added
+     */
+    protected void addOverview(Content body) throws IOException {
+    }
+
+    /**
+     * Adds the frame or non-frame profile index to the documentation tree.
+     *
+     * @param body the document tree to which the index will be added
+     */
+    protected void addIndex(Content body) {
+        addIndexContents(profiles, "doclet.Profile_Summary",
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Profile_Summary"),
+                configuration.getText("doclet.profiles")), body);
+    }
+
+    /**
+     * Adds the frame or non-frame profile packages index to the documentation tree.
+     *
+     * @param body the document tree to which the index will be added
+     * @param profileName  the name of the profile being documented
+     */
+    protected void addProfilePackagesIndex(Content body, String profileName) {
+        addProfilePackagesIndexContents(profiles, "doclet.Profile_Summary",
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Profile_Summary"),
+                configuration.getText("doclet.profiles")), body, profileName);
+    }
+
+    /**
+     * Adds profile index contents. Call appropriate methods from
+     * the sub-classes. Adds it to the body HtmlTree
+     *
+     * @param profiles profiles to be documented
+     * @param text string which will be used as the heading
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the index contents will be added
+     */
+    protected void addIndexContents(Profiles profiles, String text,
+            String tableSummary, Content body) {
+        if (profiles.getProfileCount() > 0) {
+            HtmlTree div = new HtmlTree(HtmlTag.DIV);
+            div.addStyle(HtmlStyle.indexHeader);
+            addAllClassesLink(div);
+            addAllPackagesLink(div);
+            body.addContent(div);
+            addProfilesList(profiles, text, tableSummary, body);
+        }
+    }
+
+    /**
+     * Adds profile packages index contents. Call appropriate methods from
+     * the sub-classes. Adds it to the body HtmlTree
+     *
+     * @param profiles profiles to be documented
+     * @param text string which will be used as the heading
+     * @param tableSummary summary for the table
+     * @param body the document tree to which the index contents will be added
+     * @param profileName the name of the profile being documented
+     */
+    protected void addProfilePackagesIndexContents(Profiles profiles, String text,
+            String tableSummary, Content body, String profileName) {
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.indexHeader);
+        addAllClassesLink(div);
+        addAllPackagesLink(div);
+        addAllProfilesLink(div);
+        body.addContent(div);
+        addProfilePackagesList(profiles, text, tableSummary, body, profileName);
+    }
+
+    /**
+     * Adds the doctitle to the documentation tree, if it is specified on the command line.
+     *
+     * @param body the document tree to which the title will be added
+     */
+    protected void addConfigurationTitle(Content body) {
+        if (configuration.doctitle.length() > 0) {
+            Content title = new RawHtml(configuration.doctitle);
+            Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
+                    HtmlStyle.title, title);
+            Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+            body.addContent(div);
+        }
+    }
+
+    /**
+     * Returns highlighted "Overview", in the navigation bar as this is the
+     * overview page.
+     *
+     * @return a Content object to be added to the documentation tree
+     */
+    protected Content getNavLinkContents() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
+        return li;
+    }
+
+    /**
+     * Do nothing. This will be overridden in ProfileIndexFrameWriter.
+     *
+     * @param div the document tree to which the all classes link will be added
+     */
+    protected void addAllClassesLink(Content div) {
+    }
+
+    /**
+     * Do nothing. This will be overridden in ProfileIndexFrameWriter.
+     *
+     * @param div the document tree to which the all packages link will be added
+     */
+    protected void addAllPackagesLink(Content div) {
+    }
+
+    /**
+     * Do nothing. This will be overridden in ProfilePackageIndexFrameWriter.
+     *
+     * @param div the document tree to which the all profiles link will be added
+     */
+    protected void addAllProfilesLink(Content div) {
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
index 2b1b352..8cc0b61 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -27,10 +27,11 @@ package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.formats.html.markup.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Abstract class to print the class hierarchy page for all the Classes. This
@@ -38,6 +39,11 @@ import com.sun.javadoc.*;
  * generate the Package Tree and global Tree(for all the classes and packages)
  * pages.
  *
+ *  <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 Atul M Dambalkar
  */
 public abstract class AbstractTreeWriter extends HtmlDocletWriter {
@@ -50,46 +56,23 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
     private static final String LI_CIRCLE  = "circle";
 
     /**
-     * Constructor initilises classtree variable. This constructor will be used
+     * Constructor initializes classtree variable. This constructor will be used
      * while generating global tree file "overview-tree.html".
      *
+     * @param configuration  The current configuration
      * @param filename   File to be generated.
      * @param classtree  Tree built by {@link ClassTree}.
      * @throws IOException
      * @throws DocletAbortException
      */
     protected AbstractTreeWriter(ConfigurationImpl configuration,
-                                 String filename, ClassTree classtree)
+                                 DocPath filename, ClassTree classtree)
                                  throws IOException {
         super(configuration, filename);
         this.classtree = classtree;
     }
 
     /**
-     * Create appropriate directory for the package and also initilise the
-     * relative path from this generated file to the current or
-     * the destination directory. This constructor will be used while
-     * generating "package tree" file.
-     *
-     * @param path Directories in this path will be created if they are not
-     * already there.
-     * @param filename Name of the package tree file to be generated.
-     * @param classtree The tree built using {@link ClassTree}.
-     * for the package pkg.
-     * @param pkg PackageDoc for which tree file will be generated.
-     * @throws IOException
-     * @throws DocletAbortException
-     */
-    protected AbstractTreeWriter(ConfigurationImpl configuration,
-                                 String path, String filename,
-                                 ClassTree classtree, PackageDoc pkg)
-                                 throws IOException {
-        super(configuration,
-              path, filename, DirectoryManager.getRelativePath(pkg.name()));
-        this.classtree = classtree;
-    }
-
-    /**
      * Add each level of the class tree. For each sub-class or
      * sub-interface indents the next level information.
      * Recurses itself to add subclasses info.
@@ -155,7 +138,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
             for (int i = 0; i < interfaces.length; i++) {
                 if (parent != interfaces[i]) {
                     if (! (interfaces[i].isPublic() ||
-                            Util.isLinkable(interfaces[i], configuration()))) {
+                            Util.isLinkable(interfaces[i], configuration))) {
                         continue;
                     }
                     if (counter == 0) {
@@ -169,7 +152,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
                     } else {
                         contentTree.addContent(", ");
                     }
-                    addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
+                    addPreQualifiedClassLink(LinkInfoImpl.Kind.TREE,
                             interfaces[i], contentTree);
                     counter++;
                 }
@@ -187,7 +170,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
      * @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);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
index b68af04..0d6846a 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -29,9 +29,9 @@ import java.io.*;
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the file with list of all the classes in this run. This page will be
@@ -39,6 +39,11 @@ import com.sun.tools.doclets.formats.html.markup.*;
  * the left-hand top frame. The name of the generated file is
  * "allclasses-frame.html".
  *
+ *  <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 Atul M Dambalkar
  * @author Doug Kramer
  * @author Bhavesh Patel (Modified)
@@ -46,16 +51,6 @@ import com.sun.tools.doclets.formats.html.markup.*;
 public class AllClassesFrameWriter extends HtmlDocletWriter {
 
     /**
-     * The name of the output file with frames
-     */
-    public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
-
-    /**
-     * The name of the output file without frames
-     */
-    public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
-
-    /**
      * Index of all the classes.
      */
     protected IndexBuilder indexbuilder;
@@ -66,13 +61,16 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
     final HtmlTree BR = new HtmlTree(HtmlTag.BR);
 
     /**
-     * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
+     * Construct AllClassesFrameWriter object. Also initializes the indexbuilder
      * variable in this class.
+     * @param configuration  The current configuration
+     * @param filename       Path to the file which is getting generated.
+     * @param indexbuilder   Unicode based Index from {@link IndexBuilder}
      * @throws IOException
      * @throws DocletAbortException
      */
     public AllClassesFrameWriter(ConfigurationImpl configuration,
-                                 String filename, IndexBuilder indexbuilder)
+                                 DocPath filename, IndexBuilder indexbuilder)
                               throws IOException {
         super(configuration, filename);
         this.indexbuilder = indexbuilder;
@@ -89,13 +87,13 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
     public static void generate(ConfigurationImpl configuration,
                                 IndexBuilder indexbuilder) {
         AllClassesFrameWriter allclassgen;
-        String filename = OUTPUT_FILE_NAME_FRAMES;
+        DocPath filename = DocPaths.ALLCLASSES_FRAME;
         try {
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
             allclassgen.buildAllClassesFile(true);
             allclassgen.close();
-            filename = OUTPUT_FILE_NAME_NOFRAMES;
+            filename = DocPaths.ALLCLASSES_NOFRAME;
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
             allclassgen.buildAllClassesFile(false);
@@ -158,13 +156,13 @@ public class AllClassesFrameWriter extends HtmlDocletWriter {
             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(
-                        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(cd, label)));
+                linkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.DEFAULT, cd).label(label));
             }
             Content li = HtmlTree.LI(linkContent);
             content.addContent(li);
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
index 77f2327..ff8fc10 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
@@ -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
@@ -34,6 +34,11 @@ import com.sun.tools.doclets.internal.toolkit.*;
 /**
  * Writes annotation type optional member documentation in HTML format.
  *
+ *  <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
  * @author Bhavesh Patel (Modified)
  */
@@ -98,16 +103,16 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
-                configuration().getText("doclet.annotation_type_optional_members"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
+                configuration.getText("doclet.annotation_type_optional_members"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Annotation_Type_Optional_Members");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Annotation_Type_Optional_Members");
     }
 
     /**
@@ -116,9 +121,9 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Annotation_Type_Optional_Member"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Annotation_Type_Optional_Member"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -136,7 +141,7 @@ public class AnnotationTypeOptionalMemberWriterImpl extends
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", "annotation_type_optional_element_summary",
+            return writer.getHyperLink("annotation_type_optional_element_summary",
                     writer.getResource("doclet.navAnnotationTypeOptionalMember"));
         } else {
             return writer.getResource("doclet.navAnnotationTypeOptionalMember");
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
index f2418e5..6583b89 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
@@ -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
@@ -34,6 +34,11 @@ import com.sun.tools.doclets.internal.toolkit.*;
 /**
  * Writes annotation type required member documentation in HTML format.
  *
+ *  <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
  * @author Bhavesh Patel (Modified)
  */
@@ -47,7 +52,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
      * @param annotationType the AnnotationType that holds this member.
      */
     public AnnotationTypeRequiredMemberWriterImpl(SubWriterHolderWriter writer,
-        AnnotationTypeDoc annotationType) {
+            AnnotationTypeDoc annotationType) {
         super(writer, annotationType);
     }
 
@@ -100,12 +105,12 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(member, pre);
         addModifiers(member, pre);
-        Content link = new RawHtml(
-                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                getType(member))));
+        Content link =
+                writer.getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.MEMBER, getType(member)));
         pre.addContent(link);
         pre.addContent(writer.getSpace());
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content memberName = new StringContent(member.name());
             writer.addSrcLink(member, memberName, pre);
         } else {
@@ -170,16 +175,16 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
-                configuration().getText("doclet.annotation_type_required_members"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Type_Required_Member_Summary"),
+                configuration.getText("doclet.annotation_type_required_members"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Annotation_Type_Required_Members");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Annotation_Type_Required_Members");
     }
 
     /**
@@ -188,9 +193,9 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Annotation_Type_Required_Member"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Annotation_Type_Required_Member"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -218,10 +223,10 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
     /**
      * {@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);
     }
@@ -246,7 +251,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((MemberDoc)member).qualifiedName());
     }
 
@@ -255,7 +260,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", "annotation_type_required_element_summary",
+            return writer.getHyperLink("annotation_type_required_element_summary",
                     writer.getResource("doclet.navAnnotationTypeRequiredMember"));
         } else {
             return writer.getResource("doclet.navAnnotationTypeRequiredMember");
@@ -267,7 +272,7 @@ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
+            liNav.addContent(writer.getHyperLink("annotation_type_element_detail",
                     writer.getResource("doclet.navAnnotationTypeMember")));
         } else {
             liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
index 83886de..df4b5ea 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
@@ -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
@@ -25,14 +25,22 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.IOException;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
-import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate the Class Information Page.
+ *
+ *  <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>
+ *
  * @see com.sun.javadoc.ClassDoc
  * @see java.util.Collections
  * @see java.util.List
@@ -57,13 +65,10 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
      * @param prevType the previous class that was documented.
      * @param nextType the next class being documented.
      */
-    public AnnotationTypeWriterImpl (AnnotationTypeDoc annotationType,
-            Type prevType, Type nextType)
-    throws Exception {
-        super(ConfigurationImpl.getInstance(),
-              DirectoryManager.getDirectoryPath(annotationType.containingPackage()),
-              annotationType.name() + ".html",
-              DirectoryManager.getRelativePath(annotationType.containingPackage().name()));
+    public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
+            AnnotationTypeDoc annotationType, Type prevType, Type nextType)
+            throws Exception {
+        super(configuration, DocPath.forClass(annotationType));
         this.annotationType = annotationType;
         configuration.currentcd = annotationType.asClassDoc();
         this.prev = prevType;
@@ -76,7 +81,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content linkContent = getHyperLink("package-summary.html", "",
+        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
                 packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
@@ -98,7 +103,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
      * @return a content tree for the class use link
      */
     protected Content getNavLinkClassUse() {
-        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
+        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -111,9 +116,9 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
-                    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
@@ -129,9 +134,9 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
-                    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
@@ -157,12 +162,12 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
             div.addContent(pkgNameDiv);
         }
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                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;
@@ -187,7 +192,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
     /**
      * {@inheritDoc}
      */
-    public void printDocument(Content contentTree) {
+    public void printDocument(Content contentTree) throws IOException {
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
                 true, contentTree);
     }
@@ -214,11 +219,11 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
         Content pre = new HtmlTree(HtmlTag.PRE);
         addAnnotationInfo(annotationType, pre);
         pre.addContent(modifiers);
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.Kind.CLASS_SIGNATURE, annotationType);
         Content annotationName = new StringContent(annotationType.name());
-        Content parameterLinks = new RawHtml(getTypeParameterLinks(linkInfo));
-        if (configuration().linksource) {
+        Content parameterLinks = getTypeParameterLinks(linkInfo);
+        if (configuration.linksource) {
             addSrcLink(annotationType, annotationName, pre);
             pre.addContent(parameterLinks);
         } else {
@@ -281,8 +286,8 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
      * {@inheritDoc}
      */
     protected Content getNavLinkTree() {
-        Content treeLinkContent = getHyperLink("package-tree.html",
-                "", treeLabel, "", "");
+        Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
+                treeLabel, "", "");
         Content li = HtmlTree.LI(treeLinkContent);
         return li;
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
index d0cea94..90da398 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
@@ -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
@@ -27,14 +27,20 @@ package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate class usage information.
  *
+ *  <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 Robert G. Field
  * @author Bhavesh Patel (Modified)
  */
@@ -76,7 +82,6 @@ public class ClassUseWriter extends SubWriterHolderWriter {
     final String methodUseTableSummary;
     final String constructorUseTableSummary;
 
-
     /**
      * Constructor.
      *
@@ -85,10 +90,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      * @throws DocletAbortException
      */
     public ClassUseWriter(ConfigurationImpl configuration,
-                          ClassUseMapper mapper, String path,
-                          String filename, String relpath,
+                          ClassUseMapper mapper, DocPath filename,
                           ClassDoc classdoc) throws IOException {
-        super(configuration, path, filename, relpath);
+        super(configuration, filename);
         this.classdoc = classdoc;
         if (mapper.classToPackageAnnotations.containsKey(classdoc.qualifiedName()))
                 pkgToPackageAnnotations = new HashSet<PackageDoc>(mapper.classToPackageAnnotations.get(classdoc.qualifiedName()));
@@ -193,23 +197,19 @@ public class ClassUseWriter extends SubWriterHolderWriter {
     public static void generate(ConfigurationImpl configuration,
                                 ClassUseMapper mapper, ClassDoc classdoc) {
         ClassUseWriter clsgen;
-        String path = DirectoryManager.getDirectoryPath(classdoc.
-                                                            containingPackage());
-        path += "class-use" + DirectoryManager.URL_FILE_SEPARATOR;
-        String filename = classdoc.name() + ".html";
-        String pkgname = classdoc.containingPackage().name();
-        pkgname += (pkgname.length() > 0)? ".class-use": "class-use";
-        String relpath = DirectoryManager.getRelativePath(pkgname);
+        DocPath path = DocPath.forPackage(classdoc)
+                .resolve(DocPaths.CLASS_USE)
+                .resolve(DocPath.forName(classdoc));
         try {
             clsgen = new ClassUseWriter(configuration,
-                                        mapper, path, filename,
-                                        relpath, classdoc);
+                                        mapper, path,
+                                        classdoc);
             clsgen.generateClassUseFile();
             clsgen.close();
         } catch (IOException exc) {
             configuration.standardmessage.
                 error("doclet.exception_encountered",
-                      exc.toString(), filename);
+                      exc.toString(), path.getPath());
             throw new DocletAbortException();
         }
     }
@@ -256,10 +256,10 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.getResource(
                 "doclet.ClassUse_Packages.that.use.0",
-                getLink(new LinkInfoImpl(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();
@@ -287,14 +287,14 @@ public class ClassUseWriter extends SubWriterHolderWriter {
     protected void addPackageAnnotationList(Content contentTree) throws IOException {
         if ((!classdoc.isAnnotationType()) ||
                 pkgToPackageAnnotations == null ||
-                pkgToPackageAnnotations.size() == 0) {
+                pkgToPackageAnnotations.isEmpty()) {
             return;
         }
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.getResource(
                 "doclet.ClassUse_PackageAnnotation",
-                getLink(new LinkInfoImpl(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 = pkgToPackageAnnotations.iterator();
@@ -331,11 +331,10 @@ public class ClassUseWriter extends SubWriterHolderWriter {
         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(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);
@@ -353,7 +352,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      */
     protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
         Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
-                getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
+                getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg))));
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
@@ -368,71 +367,71 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      * @param contentTree the content tree to which the class use information will be added
      */
     protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
-        String classLink = getLink(new LinkInfoImpl(
-            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 @@ public class ClassUseWriter extends SubWriterHolderWriter {
         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);
@@ -464,8 +466,8 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content linkContent = getHyperLink("../package-summary.html", "",
-                packageLabel);
+        Content linkContent =
+                getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -476,9 +478,9 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      * @return a content tree for the class page link
      */
     protected Content getNavLinkClass() {
-        Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
-                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;
     }
@@ -500,8 +502,8 @@ public class ClassUseWriter extends SubWriterHolderWriter {
      */
     protected Content getNavLinkTree() {
         Content linkContent = classdoc.containingPackage().isIncluded() ?
-            getHyperLink("../package-tree.html", "", treeLabel) :
-            getHyperLink(relativePath + "overview-tree.html", "", treeLabel);
+            getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel) :
+            getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
index cc8411e..47e9346 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -28,14 +28,22 @@ package com.sun.tools.doclets.formats.html;
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import java.io.IOException;
 
 /**
  * Generate the Class Information Page.
+ *
+ *  <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>
+ *
  * @see com.sun.javadoc.ClassDoc
  * @see java.util.Collections
  * @see java.util.List
@@ -49,27 +57,25 @@ import com.sun.tools.doclets.formats.html.markup.*;
 public class ClassWriterImpl extends SubWriterHolderWriter
         implements ClassWriter {
 
-    protected ClassDoc classDoc;
+    protected final ClassDoc classDoc;
 
-    protected ClassTree classtree;
+    protected final ClassTree classtree;
 
-    protected ClassDoc prev;
+    protected final ClassDoc prev;
 
-    protected ClassDoc next;
+    protected final ClassDoc next;
 
     /**
+     * @param configuration the configuration data for the doclet
      * @param classDoc the class being documented.
      * @param prevClass the previous class that was documented.
      * @param nextClass the next class being documented.
      * @param classTree the class tree for the given class.
      */
-    public ClassWriterImpl (ClassDoc classDoc,
+    public ClassWriterImpl (ConfigurationImpl configuration, ClassDoc classDoc,
             ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
-    throws Exception {
-        super(ConfigurationImpl.getInstance(),
-              DirectoryManager.getDirectoryPath(classDoc.containingPackage()),
-              classDoc.name() + ".html",
-              DirectoryManager.getRelativePath(classDoc.containingPackage().name()));
+            throws IOException {
+        super(configuration, DocPath.forClass(classDoc));
         this.classDoc = classDoc;
         configuration.currentcd = classDoc;
         this.classtree = classTree;
@@ -83,7 +89,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content linkContent = getHyperLink("package-summary.html", "",
+        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
                 packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
@@ -105,7 +111,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
      * @return a content tree for the class use link
      */
     protected Content getNavLinkClassUse() {
-        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
+        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -118,9 +124,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
     public Content getNavLinkPrevious() {
         Content li;
         if (prev != null) {
-            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
-                    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
@@ -136,9 +142,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
     public Content getNavLinkNext() {
         Content li;
         if (next != null) {
-            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
-                    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
@@ -159,19 +165,33 @@ public class ClassWriterImpl extends SubWriterHolderWriter
         bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.addStyle(HtmlStyle.header);
+        if (configuration.showProfiles) {
+            String sep = "";
+            int profile = configuration.profiles.getProfile(getTypeNameForProfile(classDoc));
+            if (profile > 0) {
+                Content profNameContent = new StringContent();
+                for (int i = profile; i < configuration.profiles.getProfileCount(); i++) {
+                    profNameContent.addContent(sep);
+                    profNameContent.addContent(Profile.lookup(i).name);
+                    sep = ", ";
+                }
+                Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profNameContent);
+                div.addContent(profileNameDiv);
+            }
+        }
         if (pkgname.length() > 0) {
             Content pkgNameContent = new StringContent(pkgname);
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, pkgNameContent);
             div.addContent(pkgNameDiv);
         }
-        LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER,
-                classDoc, false);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.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;
@@ -196,7 +216,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
     /**
      * {@inheritDoc}
      */
-    public void printDocument(Content contentTree) {
+    public void printDocument(Content contentTree) throws IOException {
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
                 true, contentTree);
     }
@@ -224,13 +244,13 @@ public class ClassWriterImpl extends SubWriterHolderWriter
         Content pre = new HtmlTree(HtmlTag.PRE);
         addAnnotationInfo(classDoc, pre);
         pre.addContent(modifiers);
-        LinkInfoImpl linkInfo = new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
+        LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                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));
-        if (configuration().linksource) {
+        Content parameterLinks = getTypeParameterLinks(linkInfo);
+        if (configuration.linksource) {
             addSrcLink(classDoc, className, pre);
             pre.addContent(parameterLinks);
         } else {
@@ -240,13 +260,13 @@ public class ClassWriterImpl extends SubWriterHolderWriter
         }
         if (!isInterface) {
             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
-                    configuration());
+                    configuration);
             if (superclass != null) {
                 pre.addContent(DocletConstants.NL);
                 pre.addContent("extends ");
-                Content link = new RawHtml(getLink(new LinkInfoImpl(
-                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
-                        superclass)));
+                Content link = getLink(new LinkInfoImpl(configuration,
+                        LinkInfoImpl.Kind.CLASS_SIGNATURE_PARENT_NAME,
+                        superclass));
                 pre.addContent(link);
             }
         }
@@ -256,7 +276,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
             for (int i = 0; i < implIntfacs.length; i++) {
                 ClassDoc classDoc = implIntfacs[i].asClassDoc();
                 if (! (classDoc.isPublic() ||
-                        Util.isLinkable(classDoc, configuration()))) {
+                        Util.isLinkable(classDoc, configuration))) {
                     continue;
                 }
                 if (counter == 0) {
@@ -265,9 +285,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                 } else {
                     pre.addContent(", ");
                 }
-                Content link = new RawHtml(getLink(new LinkInfoImpl(
-                        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++;
             }
@@ -311,7 +331,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
         do {
             sup = Util.getFirstVisibleSuperClass(
                     type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
-                    configuration());
+                    configuration);
             if (sup != null) {
                 HtmlTree ul = new HtmlTree(HtmlTag.UL);
                 ul.addStyle(HtmlStyle.inheritance);
@@ -340,22 +360,21 @@ public class ClassWriterImpl extends SubWriterHolderWriter
     private Content getTreeForClassHelper(Type type) {
         Content li = new HtmlTree(HtmlTag.LI);
         if (type.equals(classDoc)) {
-            String typeParameters = getTypeParameterLinks(
-                    new LinkInfoImpl(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(
-                    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;
@@ -376,9 +395,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter
      */
     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);
         }
@@ -399,7 +417,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                         "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);
             }
@@ -417,7 +435,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                         "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);
             }
@@ -441,7 +459,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                     "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);
         }
@@ -459,7 +477,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                     "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);
         }
@@ -477,7 +495,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                     "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);
         }
@@ -500,8 +518,22 @@ public class ClassWriterImpl extends SubWriterHolderWriter
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             Content dd = new HtmlTree(HtmlTag.DD);
-            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
-                    false))));
+            dd.addContent(getLink(new LinkInfoImpl(configuration,
+                    LinkInfoImpl.Kind.CLASS, outerClass)));
+            dl.addContent(dd);
+            classInfoTree.addContent(dl);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addFunctionalInterfaceInfo (Content classInfoTree) {
+        if (classDoc.isFunctionalInterface()) {
+            Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
+            Content dl = HtmlTree.DL(dt);
+            Content dd = new HtmlTree(HtmlTag.DD);
+            dd.addContent(getResource("doclet.Functional_Interface_Message"));
             dl.addContent(dd);
             classInfoTree.addContent(dl);
         }
@@ -535,7 +567,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter
      * @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++) {
@@ -544,12 +576,12 @@ public class ClassWriterImpl extends SubWriterHolderWriter
                 dd.addContent(separator);
             }
             if (typeList[i] instanceof ClassDoc) {
-                Content link = new RawHtml(getLink(
-                        new LinkInfoImpl(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(context, (Type)(typeList[i]))));
+                Content link = getLink(
+                        new LinkInfoImpl(configuration, context, (Type)(typeList[i])));
                 dd.addContent(link);
             }
         }
@@ -560,8 +592,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter
      * {@inheritDoc}
      */
     protected Content getNavLinkTree() {
-        Content treeLinkContent = getHyperLink("package-tree.html",
-                "", treeLabel, "", "");
+        Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
+                treeLabel, "", "");
         Content li = HtmlTree.LI(treeLinkContent);
         return li;
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
index 7985d93..5d84c80 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
@@ -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
@@ -25,13 +25,19 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
+import java.net.*;
+import java.util.*;
+
+import javax.tools.JavaFileManager;
 
 import com.sun.javadoc.*;
-import java.util.*;
-import java.io.*;
-import java.net.*;
+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;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.RootDocImpl;
 
 /**
  * Configure the output based on the command line options.
@@ -46,6 +52,11 @@ import java.net.*;
  * use "-helpfile" option when already "-nohelp" option is used.
  * </p>
  *
+ *  <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 Robert Field.
  * @author Atul Dambalkar.
  * @author Jamie Ho
@@ -53,8 +64,6 @@ import java.net.*;
  */
 public class ConfigurationImpl extends Configuration {
 
-    private static ConfigurationImpl instance = new ConfigurationImpl();
-
     /**
      * The build date.  Note: For now, we will use
      * a version number instead of a date.
@@ -62,11 +71,6 @@ public class ConfigurationImpl extends Configuration {
     public static final String BUILD_DATE = System.getProperty("java.version");
 
     /**
-     * The name of the constant values file.
-     */
-    public static final String CONSTANTS_FILE_NAME = "constant-values.html";
-
-    /**
      * Argument for command line option "-header".
      */
     public String header = "";
@@ -171,6 +175,11 @@ public class ConfigurationImpl extends Configuration {
     public boolean createoverview = false;
 
     /**
+     * Collected set of doclint options
+     */
+    public Set<String> doclintOpts = new LinkedHashSet<String>();
+
+    /**
      * Unique Resource Handler for this package.
      */
     public final MessageRetriever standardmessage;
@@ -179,39 +188,26 @@ public class ConfigurationImpl extends Configuration {
      * First file to appear in the right-hand frame in the generated
      * documentation.
      */
-    public String topFile = "";
+    public DocPath topFile = DocPath.empty;
 
     /**
      * The classdoc for the class file getting generated.
      */
-    public ClassDoc currentcd = null;  // Set this classdoc in the
-    // ClassWriter.
+    public ClassDoc currentcd = null;  // Set this classdoc in the ClassWriter.
 
     /**
-     * Constructor. Initialises resource for the
-     * {@link com.sun.tools.doclets.MessageRetriever}.
+     * Constructor. Initializes resource for the
+     * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
      */
-    private ConfigurationImpl() {
+    public ConfigurationImpl() {
         standardmessage = new MessageRetriever(this,
             "com.sun.tools.doclets.formats.html.resources.standard");
     }
 
     /**
-     * Reset to a fresh new ConfigurationImpl, to allow multiple invocations
-     * of javadoc within a single VM. It would be better not to be using
-     * static fields at all, but .... (sigh).
-     */
-    public static void reset() {
-        instance = new ConfigurationImpl();
-    }
-
-    public static ConfigurationImpl getInstance() {
-        return instance;
-    }
-
-    /**
      * Return the build date for the doclet.
      */
+    @Override
     public String getDocletSpecificBuildDate() {
         return BUILD_DATE;
     }
@@ -222,6 +218,7 @@ public class ConfigurationImpl extends Configuration {
      *
      * @param options The array of option names and values.
      */
+    @Override
     public void setSpecificDocletOptions(String[][] options) {
         for (int oi = 0; oi < options.length; ++oi) {
             String[] os = options[oi];
@@ -266,6 +263,10 @@ public class ConfigurationImpl extends Configuration {
                 nooverview = true;
             } else if (opt.equals("-overview")) {
                 overview = true;
+            } else if (opt.equals("-xdoclint")) {
+                doclintOpts.add(null);
+            } else if (opt.startsWith("-xdoclint:")) {
+                doclintOpts.add(opt.substring(opt.indexOf(":") + 1));
             }
         }
         if (root.specifiedClasses().length > 0) {
@@ -281,6 +282,10 @@ public class ConfigurationImpl extends Configuration {
         }
         setCreateOverview();
         setTopFile(root);
+
+        if (root instanceof RootDocImpl) {
+            ((RootDocImpl) root).initDocLint(doclintOpts);
+        }
     }
 
     /**
@@ -314,11 +319,24 @@ public class ConfigurationImpl extends Configuration {
             option.equals("-serialwarn") ||
             option.equals("-use") ||
             option.equals("-nonavbar") ||
-            option.equals("-nooverview")) {
+            option.equals("-nooverview") ||
+            option.equals("-xdoclint") ||
+            option.startsWith("-xdoclint:")) {
             return 1;
         } else if (option.equals("-help")) {
+            // Uugh: first, this should not be hidden inside optionLength,
+            // and second, we should not be writing directly to stdout.
+            // But we have no access to a DocErrorReporter, which would
+            // allow use of reporter.printNotice
             System.out.println(getText("doclet.usage"));
             return 1;
+        } else if (option.equals("-x")) {
+            // Uugh: first, this should not be hidden inside optionLength,
+            // and second, we should not be writing directly to stdout.
+            // But we have no access to a DocErrorReporter, which would
+            // allow use of reporter.printNotice
+            System.out.println(getText("doclet.X.usage"));
+            return 1;
         } else if (option.equals("-footer") ||
                    option.equals("-header") ||
                    option.equals("-packagesheader") ||
@@ -340,6 +358,7 @@ public class ConfigurationImpl extends Configuration {
     /**
      * {@inheritDoc}
      */
+    @Override
     public boolean validOptions(String options[][],
             DocErrorReporter reporter) {
         boolean helpfile = false;
@@ -367,7 +386,7 @@ public class ConfigurationImpl extends Configuration {
                         "-helpfile"));
                     return false;
                 }
-                File help = new File(os[1]);
+                DocFile help = DocFile.createFileForInput(this, os[1]);
                 if (!help.exists()) {
                     reporter.printError(getText("doclet.File_not_found", os[1]));
                     return false;
@@ -420,6 +439,16 @@ public class ConfigurationImpl extends Configuration {
                     return false;
                 }
                 noindex = true;
+            } else if (opt.startsWith("-xdoclint:")) {
+                if (opt.contains("/")) {
+                    reporter.printError(getText("doclet.Option_doclint_no_qualifiers"));
+                    return false;
+                }
+                if (!DocLint.isValidOption(
+                        opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) {
+                    reporter.printError(getText("doclet.Option_doclint_invalid_arg"));
+                    return false;
+                }
             }
         }
         return true;
@@ -428,6 +457,7 @@ public class ConfigurationImpl extends Configuration {
     /**
      * {@inheritDoc}
      */
+    @Override
     public MessageRetriever getDocletSpecificMsg() {
         return standardmessage;
     }
@@ -447,18 +477,17 @@ public class ConfigurationImpl extends Configuration {
             return;
         }
         if (createoverview) {
-            topFile = "overview-summary.html";
+            topFile = DocPaths.OVERVIEW_SUMMARY;
         } else {
             if (packages.length == 1 && packages[0].name().equals("")) {
                 if (root.classes().length > 0) {
                     ClassDoc[] classarr = root.classes();
                     Arrays.sort(classarr);
                     ClassDoc cd = getValidClass(classarr);
-                    topFile = DirectoryManager.getPathToClass(cd);
+                    topFile = DocPath.forClass(cd);
                 }
             } else {
-                topFile = DirectoryManager.getPathToPackage(packages[0],
-                                                            "package-summary.html");
+                topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY);
             }
         }
     }
@@ -498,6 +527,7 @@ public class ConfigurationImpl extends Configuration {
     /**
      * {@inheritDoc}
      */
+    @Override
     public WriterFactory getWriterFactory() {
         return new WriterFactoryImpl(this);
     }
@@ -505,6 +535,7 @@ public class ConfigurationImpl extends Configuration {
     /**
      * {@inheritDoc}
      */
+    @Override
     public Comparator<ProgramElementDoc> getMemberComparator() {
         return null;
     }
@@ -512,10 +543,40 @@ public class ConfigurationImpl extends Configuration {
     /**
      * {@inheritDoc}
      */
+    @Override
     public Locale getLocale() {
-        if (root instanceof com.sun.tools.javadoc.RootDocImpl)
-            return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale();
+        if (root instanceof RootDocImpl)
+            return ((RootDocImpl)root).getLocale();
         else
             return Locale.getDefault();
     }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JavaFileManager getFileManager() {
+        if (fileManager == null) {
+            if (root instanceof RootDocImpl)
+                fileManager = ((RootDocImpl) root).getFileManager();
+            else
+                fileManager = new JavacFileManager(new Context(), false, null);
+        }
+        return fileManager;
+    }
+
+    private JavaFileManager fileManager;
+
+    @Override
+    public boolean showMessage(SourcePosition pos, String key) {
+        if (root instanceof RootDocImpl) {
+            return pos == null || ((RootDocImpl) root).showTagMessages();
+        }
+        return true;
+    }
+
+    @Override
+    public Content newContent() {
+        return new ContentBuilder();
+    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
index 4d38ad9..02dfdb3 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, 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,14 +27,20 @@ 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.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Write the Constants Summary Page in HTML format.
  *
+ *  <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
  * @author Bhavesh Patel (Modified)
  * @since 1.4
@@ -63,7 +69,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
      */
     public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
             throws IOException {
-        super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
+        super(configuration, DocPaths.CONSTANT_VALUES);
         this.configuration = configuration;
         constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
                 configuration.getText("doclet.Constants_Summary"));
@@ -101,13 +107,13 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
         //add link to summary
         Content link;
         if (packageName.length() == 0) {
-            link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
-                    "", defaultPackageLabel, "", "");
+            link = getHyperLink(DocLink.fragment(DocletConstants.UNNAMED_PACKAGE_ANCHOR),
+                    defaultPackageLabel, "", "");
         } else {
             Content packageNameContent = getPackageLabel(parsedPackageName);
             packageNameContent.addContent(".*");
-            link = getHyperLink("#" + parsedPackageName,
-                    "", packageNameContent, "", "");
+            link = getHyperLink(DocLink.fragment(parsedPackageName),
+                    packageNameContent, "", "");
             printedPackageHeaders.add(parsedPackageName);
         }
         contentListTree.addContent(HtmlTree.LI(link));
@@ -178,13 +184,17 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
      */
     public Content getConstantMembersHeader(ClassDoc cd) {
         //generate links backward only to public classes.
-        String classlink = (cd.isPublic() || cd.isProtected())?
-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
-                false)) :
-            cd.qualifiedName();
+        Content classlink = (cd.isPublic() || cd.isProtected()) ?
+            getLink(new LinkInfoImpl(configuration,
+                    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);
         }
@@ -196,7 +206,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
      * @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"));
@@ -254,8 +264,8 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
             code.addContent(modifier);
             code.addContent(getSpace());
         }
-        Content type = new RawHtml(getLink(new LinkInfoImpl(
-                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;
@@ -268,8 +278,8 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
      * @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);
     }
@@ -297,7 +307,7 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
     /**
      * {@inheritDoc}
      */
-    public void printDocument(Content contentTree) {
+    public void printDocument(Content contentTree) throws IOException {
         printHtmlDocument(null, true, contentTree);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
index 6db2b0d..4967370 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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
@@ -36,6 +36,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes constructor documentation.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -55,7 +60,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
             ClassDoc classDoc) {
         super(writer, classDoc);
         VisibleMemberMap visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.CONSTRUCTORS, configuration().nodeprecated);
+            VisibleMemberMap.CONSTRUCTORS, configuration);
         List<ProgramElementDoc> constructors = new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
         for (int i = 0; i < constructors.size(); i++) {
             if ((constructors.get(i)).isProtected() ||
@@ -121,18 +126,18 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
      * {@inheritDoc}
      */
     public Content getSignature(ConstructorDoc constructor) {
-        writer.displayLength = 0;
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(constructor, pre);
         addModifiers(constructor, pre);
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content constructorName = new StringContent(constructor.name());
             writer.addSrcLink(constructor, constructorName, pre);
         } else {
             addName(constructor.name(), pre);
         }
-        addParameters(constructor, pre);
-        addExceptions(constructor, pre);
+        int indent = pre.charCount();
+        addParameters(constructor, pre, indent);
+        addExceptions(constructor, pre, indent);
         return pre;
     }
 
@@ -212,16 +217,16 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Constructor_Summary"),
-                configuration().getText("doclet.constructors"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Constructor_Summary"),
+                configuration.getText("doclet.constructors"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Constructors");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Constructors");
     }
 
     /**
@@ -231,17 +236,17 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
         String[] header;
         if (foundNonPubConstructor) {
             header = new String[] {
-                configuration().getText("doclet.Modifier"),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Constructor"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.Modifier"),
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Constructor"),
+                        configuration.getText("doclet.Description"))
             };
         }
         else {
             header = new String[] {
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Constructor"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Constructor"),
+                        configuration.getText("doclet.Description"))
             };
         }
         return header;
@@ -275,7 +280,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", "constructor_summary",
+            return writer.getHyperLink("constructor_summary",
                     writer.getResource("doclet.navConstructor"));
         } else {
             return writer.getResource("doclet.navConstructor");
@@ -287,7 +292,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "constructor_detail",
+            liNav.addContent(writer.getHyperLink("constructor_detail",
                     writer.getResource("doclet.navConstructor")));
         } else {
             liNav.addContent(writer.getResource("doclet.navConstructor"));
@@ -308,7 +313,7 @@ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
                 code.addContent(writer.getSpace());
             } else {
                 code.addContent(
-                        configuration().getText("doclet.Package_private"));
+                        configuration.getText("doclet.Package_private"));
             }
             tdSummaryType.addContent(code);
         }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
index ed9805b..bb98945 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,20 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
+
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate File to list all the deprecated classes and class members with the
  * appropriate links.
  *
+ *  <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>
+ *
  * @see java.util.List
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -90,7 +95,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
      * @param filename the file to be generated.
      */
     public DeprecatedListWriter(ConfigurationImpl configuration,
-                                String filename) throws IOException {
+                                DocPath filename) throws IOException {
         super(configuration, filename);
         this.configuration = configuration;
         NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
@@ -111,7 +116,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
      * @param configuration the current configuration of the doclet.
      */
     public static void generate(ConfigurationImpl configuration) {
-        String filename = "deprecated-list.html";
+        DocPath filename = DocPaths.DEPRECATED_LIST;
         try {
             DeprecatedListWriter depr =
                    new DeprecatedListWriter(configuration, filename);
@@ -175,7 +180,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
     private void addIndexLink(DeprecatedAPIListBuilder builder,
             int type, Content contentTree) {
         if (builder.hasDocumentation(type)) {
-            Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
+            Content li = HtmlTree.LI(getHyperLink(ANCHORS[type],
                     getResource(HEADING_KEYS[type])));
             contentTree.addContent(li);
         }
@@ -208,7 +213,7 @@ public class DeprecatedListWriter extends SubWriterHolderWriter {
      *
      * @param builder the deprecated list builder
      * @param type the type of list being documented
-     * @param contentTree the content tree to which the anchor will be added
+     * @param htmlTree the content tree to which the anchor will be added
      */
     private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
         if (builder.hasDocumentation(type)) {
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
index f567aae..9643e87 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
@@ -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
@@ -35,6 +35,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes enum constant documentation in HTML format.
  *
+ *  <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
  * @author Bhavesh Patel (Modified)
  */
@@ -96,11 +101,11 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(enumConstant, pre);
         addModifiers(enumConstant, pre);
-        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                enumConstant.type())));
+        Content enumConstantLink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER, enumConstant.type()));
         pre.addContent(enumConstantLink);
         pre.addContent(" ");
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content enumConstantName = new StringContent(enumConstant.name());
             writer.addSrcLink(enumConstant, enumConstantName, pre);
         } else {
@@ -169,16 +174,16 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Enum_Constant_Summary"),
-                configuration().getText("doclet.enum_constants"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Enum_Constant_Summary"),
+                configuration.getText("doclet.enum_constants"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Enum_Constants");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Enum_Constants");
     }
 
     /**
@@ -186,9 +191,9 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
      */
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Enum_Constant"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Enum_Constant"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -215,10 +220,10 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
     /**
      * {@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);
     }
@@ -249,7 +254,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
@@ -258,10 +263,10 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", (cd == null)?
+            return writer.getHyperLink((cd == null)?
                 "enum_constant_summary":
                 "enum_constants_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navEnum"));
         } else {
             return writer.getResource("doclet.navEnum");
@@ -273,7 +278,7 @@ public class EnumConstantWriterImpl extends AbstractMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "enum_constant_detail",
+            liNav.addContent(writer.getHyperLink("enum_constant_detail",
                     writer.getResource("doclet.navEnum")));
         } else {
             liNav.addContent(writer.getResource("doclet.navEnum"));
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
index ed442aa..4f1dbbd 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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
@@ -35,6 +35,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes field documentation in HTML format.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Jamie Ho (rewrite)
@@ -97,11 +102,11 @@ public class FieldWriterImpl extends AbstractMemberWriter
         Content pre = new HtmlTree(HtmlTag.PRE);
         writer.addAnnotationInfo(field, pre);
         addModifiers(field, pre);
-        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                field.type())));
+        Content fieldlink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER, field.type()));
         pre.addContent(fieldlink);
         pre.addContent(" ");
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content fieldName = new StringContent(field.name());
             writer.addSrcLink(field, fieldName, pre);
         } else {
@@ -124,15 +129,15 @@ public class FieldWriterImpl extends AbstractMemberWriter
         ClassDoc holder = field.containingClass();
         if (field.inlineTags().length > 0) {
             if (holder.equals(classdoc) ||
-                    (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+                    (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
                 writer.addInlineComment(field, fieldDocTree);
             } else {
-                Content link = new RawHtml(
-                        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);
@@ -190,16 +195,16 @@ public class FieldWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Field_Summary"),
-                configuration().getText("doclet.fields"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Field_Summary"),
+                configuration.getText("doclet.fields"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Fields");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Fields");
     }
 
     /**
@@ -208,9 +213,9 @@ public class FieldWriterImpl extends AbstractMemberWriter
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Field"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Field"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -227,18 +232,18 @@ public class FieldWriterImpl extends AbstractMemberWriter
      */
     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
         inheritedTree.addContent(writer.getMarkerAnchor(
-                "fields_inherited_from_class_" + configuration().getClassName(cd)));
+                "fields_inherited_from_class_" + configuration.getClassName(cd)));
     }
 
     /**
      * {@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"));
+            configuration.getText("doclet.Fields_Inherited_From_Class") :
+            configuration.getText("doclet.Fields_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -249,10 +254,10 @@ public class FieldWriterImpl extends AbstractMemberWriter
     /**
      * {@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);
     }
@@ -262,9 +267,9 @@ public class FieldWriterImpl extends AbstractMemberWriter
      */
     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));
     }
 
     /**
@@ -279,7 +284,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((FieldDoc)member).qualifiedName());
     }
 
@@ -288,10 +293,10 @@ public class FieldWriterImpl extends AbstractMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", (cd == null)?
+            return writer.getHyperLink((cd == null)?
                 "field_summary":
                 "fields_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navField"));
         } else {
             return writer.getResource("doclet.navField");
@@ -303,7 +308,7 @@ public class FieldWriterImpl extends AbstractMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "field_detail",
+            liNav.addContent(writer.getHyperLink("field_detail",
                     writer.getResource("doclet.navField")));
         } else {
             liNav.addContent(writer.getResource("doclet.navField"));
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
index 1d7ac27..3d483cd 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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,9 +26,10 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate the documentation in the Html "frame" format in the browser. The
@@ -40,6 +41,11 @@ import com.sun.tools.doclets.formats.html.markup.*;
  * right-hand frame will have overview or package summary or class file. Also
  * take care of browsers which do not support Html frames.
  *
+ *  <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 Atul M Dambalkar
  */
 public class FrameOutputWriter extends HtmlDocletWriter {
@@ -57,9 +63,9 @@ public class FrameOutputWriter extends HtmlDocletWriter {
      * @param filename File to be generated.
      */
     public FrameOutputWriter(ConfigurationImpl configuration,
-                             String filename) throws IOException {
+                             DocPath filename) throws IOException {
         super(configuration, filename);
-    noOfPackages = configuration.packages.length;
+        noOfPackages = configuration.packages.length;
     }
 
     /**
@@ -71,9 +77,9 @@ public class FrameOutputWriter extends HtmlDocletWriter {
      */
     public static void generate(ConfigurationImpl configuration) {
         FrameOutputWriter framegen;
-        String filename = "";
+        DocPath filename = DocPath.empty;
         try {
-            filename = "index.html";
+            filename = DocPaths.INDEX;
             framegen = new FrameOutputWriter(configuration, filename);
             framegen.generateFrameFile();
             framegen.close();
@@ -86,10 +92,10 @@ public class FrameOutputWriter extends HtmlDocletWriter {
     }
 
     /**
-     * Generate the contants in the "index.html" file. Print the frame details
+     * Generate the constants in the "index.html" file. Print the frame details
      * as well as warning if browser is not supporting the Html frames.
      */
-    protected void generateFrameFile() {
+    protected void generateFrameFile() throws IOException {
         Content frameset = getFrameDetails();
         if (configuration.windowtitle.length() > 0) {
             printFramesetDocument(configuration.windowtitle, configuration.notimestamp,
@@ -115,7 +121,7 @@ public class FrameOutputWriter extends HtmlDocletWriter {
                 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);
@@ -149,8 +155,8 @@ public class FrameOutputWriter extends HtmlDocletWriter {
      * @param contentTree the content tree to which the information will be added
      */
     private void addAllPackagesFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
-                configuration.getText("doclet.All_Packages"));
+        HtmlTree frame = HtmlTree.FRAME(DocPaths.OVERVIEW_FRAME.getPath(),
+                "packageListFrame", configuration.getText("doclet.All_Packages"));
         contentTree.addContent(frame);
     }
 
@@ -160,8 +166,8 @@ public class FrameOutputWriter extends HtmlDocletWriter {
      * @param contentTree the content tree to which the information will be added
      */
     private void addAllClassesFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
-                configuration.getText("doclet.All_classes_and_interfaces"));
+        HtmlTree frame = HtmlTree.FRAME(DocPaths.ALLCLASSES_FRAME.getPath(),
+                "packageFrame", configuration.getText("doclet.All_classes_and_interfaces"));
         contentTree.addContent(frame);
     }
 
@@ -171,7 +177,7 @@ public class FrameOutputWriter extends HtmlDocletWriter {
      * @param contentTree the content tree to which the information will be added
      */
     private void addClassFrameTag(Content contentTree) {
-        HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
+        HtmlTree frame = HtmlTree.FRAME(configuration.topFile.getPath(), "classFrame",
                 configuration.getText("doclet.Package_class_and_interface_descriptions"),
                 SCROLL_YES);
         contentTree.addContent(frame);
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
index 7f15c84..2884d3b 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
@@ -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
@@ -26,14 +26,20 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate the Help File for the generated API documentation. The help file
  * contents are helpful for browsing the generated documentation.
  *
+ *  <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 Atul M Dambalkar
  */
 public class HelpWriter extends HtmlDocletWriter {
@@ -43,7 +49,7 @@ public class HelpWriter extends HtmlDocletWriter {
      * @param filename File to be generated.
      */
     public HelpWriter(ConfigurationImpl configuration,
-                      String filename) throws IOException {
+                      DocPath filename) throws IOException {
         super(configuration, filename);
     }
 
@@ -56,9 +62,9 @@ public class HelpWriter extends HtmlDocletWriter {
      */
     public static void generate(ConfigurationImpl configuration) {
         HelpWriter helpgen;
-        String filename = "";
+        DocPath filename = DocPath.empty;
         try {
-            filename = "help-doc.html";
+            filename = DocPaths.HELP_DOC;
             helpgen = new HelpWriter(configuration, filename);
             helpgen.generateHelpFile();
             helpgen.close();
@@ -73,7 +79,7 @@ public class HelpWriter extends HtmlDocletWriter {
     /**
      * Generate the help file contents.
      */
-    protected void generateHelpFile() {
+    protected void generateHelpFile() throws IOException {
         String title = configuration.getText("doclet.Window_Help_title");
         Content body = getBody(true, getWindowTitle(title));
         addTop(body);
@@ -107,7 +113,7 @@ public class HelpWriter extends HtmlDocletWriter {
                 getResource("doclet.Overview"));
             Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
             Content line3 = getResource("doclet.Help_line_3",
-                    getHyperLinkString("overview-summary.html",
+                    getHyperLink(DocPaths.OVERVIEW_SUMMARY,
                     configuration.getText("doclet.Overview")));
             Content overviewPara = HtmlTree.P(line3);
             liOverview.addContent(overviewPara);
@@ -228,8 +234,9 @@ public class HelpWriter extends HtmlDocletWriter {
                     getResource("doclet.Help_line_16"));
             Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
             Content line17 = getResource("doclet.Help_line_17_with_tree_link",
-                    getHyperLinkString("overview-tree.html",
-                    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);
@@ -246,19 +253,19 @@ public class HelpWriter extends HtmlDocletWriter {
                     getResource("doclet.Deprecated_API"));
             Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
             Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
-                    getHyperLinkString("deprecated-list.html",
+                    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("index-files/index-1.html",
+                indexlink = getHyperLink(DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1)),
                         configuration.getText("doclet.Index"));
             } else {
-                indexlink = getHyperLinkString("index-all.html",
+                indexlink = getHyperLink(DocPaths.INDEX_ALL,
                         configuration.getText("doclet.Index"));
             }
             Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
@@ -287,7 +294,7 @@ public class HelpWriter extends HtmlDocletWriter {
                 getResource("doclet.All_Classes"));
         Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
         Content line27 = getResource("doclet.Help_line_27",
-                getHyperLinkString("allclasses-noframe.html",
+                getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
                 configuration.getText("doclet.All_Classes")));
         Content allclassesPara = HtmlTree.P(line27);
         liAllClasses.addContent(allclassesPara);
@@ -303,7 +310,7 @@ public class HelpWriter extends HtmlDocletWriter {
                 getResource("doclet.Constants_Summary"));
         Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
         Content line29 = getResource("doclet.Help_line_29",
-                getHyperLinkString("constant-values.html",
+                getHyperLink(DocPaths.CONSTANT_VALUES,
                 configuration.getText("doclet.Constants_Summary")));
         Content constPara = HtmlTree.P(line29);
         liConst.addContent(constPara);
@@ -319,6 +326,7 @@ public class HelpWriter extends HtmlDocletWriter {
      *
      * @return a content tree for the help label
      */
+    @Override
     protected Content getNavLinkHelp() {
         Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
         return li;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
index 89af9ab..7395503 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -24,31 +24,41 @@
  */
 package com.sun.tools.doclets.formats.html;
 
+import java.io.*;
+import java.util.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.sym.Profiles;
+import com.sun.tools.javac.jvm.Profile;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
-import com.sun.javadoc.*;
-import java.util.*;
-import java.io.*;
-
 /**
  * The class with "start" method, calls individual Writers.
  *
+ *  <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 Atul M Dambalkar
  * @author Robert Field
  * @author Jamie Ho
  *
  */
 public class HtmlDoclet extends AbstractDoclet {
+    // An instance will be created by validOptions, and used by start.
+    private static HtmlDoclet docletToStart = null;
+
     public HtmlDoclet() {
-        configuration = (ConfigurationImpl) configuration();
+        configuration = new ConfigurationImpl();
     }
 
     /**
      * The global configuration information for this run.
      */
-    public ConfigurationImpl configuration;
+    public final ConfigurationImpl configuration;
 
     /**
      * The "start" method as required by Javadoc.
@@ -58,12 +68,16 @@ public class HtmlDoclet extends AbstractDoclet {
      * @return true if the doclet ran without encountering any errors.
      */
     public static boolean start(RootDoc root) {
-        try {
-            HtmlDoclet doclet = new HtmlDoclet();
-            return doclet.start(doclet, root);
-        } finally {
-            ConfigurationImpl.reset();
+        // In typical use, options will have been set up by calling validOptions,
+        // which will create an HtmlDoclet for use here.
+        HtmlDoclet doclet;
+        if (docletToStart != null) {
+            doclet = docletToStart;
+            docletToStart = null;
+        } else {
+            doclet = new HtmlDoclet();
         }
+        return doclet.start(doclet, root);
     }
 
     /**
@@ -72,7 +86,7 @@ public class HtmlDoclet extends AbstractDoclet {
      * configuration.
      */
     public Configuration configuration() {
-        return ConfigurationImpl.getInstance();
+        return configuration;
     }
 
     /**
@@ -89,31 +103,24 @@ public class HtmlDoclet extends AbstractDoclet {
             throws Exception {
         super.generateOtherFiles(root, classtree);
         if (configuration.linksource) {
-            if (configuration.destDirName.length() > 0) {
-                SourceToHTMLConverter.convertRoot(configuration,
-                    root, configuration.destDirName + File.separator
-                    + DocletConstants.SOURCE_OUTPUT_DIR_NAME);
-            } else {
-                SourceToHTMLConverter.convertRoot(configuration,
-                    root, DocletConstants.SOURCE_OUTPUT_DIR_NAME);
-            }
+            SourceToHTMLConverter.convertRoot(configuration,
+                root, DocPaths.SOURCE_OUTPUT);
         }
 
-        if (configuration.topFile.length() == 0) {
+        if (configuration.topFile.isEmpty()) {
             configuration.standardmessage.
                 error("doclet.No_Non_Deprecated_Classes_To_Document");
             return;
         }
         boolean nodeprecated = configuration.nodeprecated;
-        String configdestdir = configuration.destDirName;
-        String confighelpfile = configuration.helpfile;
-        String configstylefile = configuration.stylesheetfile;
-        performCopy(configdestdir, confighelpfile);
-        performCopy(configdestdir, configstylefile);
-        Util.copyResourceFile(configuration, "background.gif", false);
-        Util.copyResourceFile(configuration, "tab.gif", false);
-        Util.copyResourceFile(configuration, "titlebar.gif", false);
-        Util.copyResourceFile(configuration, "titlebar_end.gif", false);
+        performCopy(configuration.helpfile);
+        performCopy(configuration.stylesheetfile);
+        copyResourceFile("background.gif");
+        copyResourceFile("tab.gif");
+        copyResourceFile("titlebar.gif");
+        copyResourceFile("titlebar_end.gif");
+        copyResourceFile("activetitlebar.gif");
+        copyResourceFile("activetitlebar_end.gif");
         // do early to reduce memory footprint
         if (configuration.classuse) {
             ClassUseWriter.generate(configuration, classtree);
@@ -149,11 +156,13 @@ public class HtmlDoclet extends AbstractDoclet {
         }
         // If a stylesheet file is not specified, copy the default stylesheet
         // and replace newline with platform-specific newline.
+        DocFile f;
         if (configuration.stylesheetfile.length() == 0) {
-            Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
-                    (configdestdir.isEmpty()) ?
-                        System.getProperty("user.dir") : configdestdir, false, true);
+            f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
+            f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
         }
+        f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
+        f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
     }
 
     /**
@@ -195,6 +204,44 @@ public class HtmlDoclet extends AbstractDoclet {
     /**
      * {@inheritDoc}
      */
+    protected void generateProfileFiles() throws Exception {
+        if (configuration.showProfiles) {
+            ProfileIndexFrameWriter.generate(configuration);
+            Profile prevProfile = null, nextProfile;
+            for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
+                ProfilePackageIndexFrameWriter.generate(configuration, Profile.lookup(i).name);
+                PackageDoc[] packages = configuration.profilePackages.get(
+                        Profile.lookup(i).name);
+                PackageDoc prev = null, next;
+                for (int j = 0; j < packages.length; j++) {
+                    // if -nodeprecated option is set and the package is marked as
+                    // deprecated, do not generate the profilename-package-summary.html
+                    // and profilename-package-frame.html pages for that package.
+                    if (!(configuration.nodeprecated && Util.isDeprecated(packages[j]))) {
+                        ProfilePackageFrameWriter.generate(configuration, packages[j], i);
+                        next = (j + 1 < packages.length
+                                && packages[j + 1].name().length() > 0) ? packages[j + 1] : null;
+                        AbstractBuilder profilePackageSummaryBuilder =
+                                configuration.getBuilderFactory().getProfilePackageSummaryBuilder(
+                                packages[j], prev, next, Profile.lookup(i));
+                        profilePackageSummaryBuilder.build();
+                        prev = packages[j];
+                    }
+                }
+                nextProfile = (i + 1 < configuration.profiles.getProfileCount()) ?
+                        Profile.lookup(i + 1) : null;
+                AbstractBuilder profileSummaryBuilder =
+                        configuration.getBuilderFactory().getProfileSummaryBuilder(
+                        Profile.lookup(i), prevProfile, nextProfile);
+                profileSummaryBuilder.build();
+                prevProfile = Profile.lookup(i);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     protected void generatePackageFiles(ClassTree classtree) throws Exception {
         PackageDoc[] packages = configuration.packages;
         if (packages.length > 1) {
@@ -225,6 +272,9 @@ public class HtmlDoclet extends AbstractDoclet {
         }
     }
 
+    public static final ConfigurationImpl sharedInstanceForOptions =
+            new ConfigurationImpl();
+
     /**
      * Check for doclet added options here.
      *
@@ -233,7 +283,7 @@ public class HtmlDoclet extends AbstractDoclet {
      */
     public static int optionLength(String option) {
         // Construct temporary configuration for check
-        return (ConfigurationImpl.getInstance()).optionLength(option);
+        return sharedInstanceForOptions.optionLength(option);
     }
 
     /**
@@ -249,33 +299,37 @@ public class HtmlDoclet extends AbstractDoclet {
      */
     public static boolean validOptions(String options[][],
             DocErrorReporter reporter) {
-        // Construct temporary configuration for check
-        return (ConfigurationImpl.getInstance()).validOptions(options, reporter);
+        docletToStart = new HtmlDoclet();
+        return docletToStart.configuration.validOptions(options, reporter);
+    }
+
+    /**
+     * Copy a file in the resources directory to the destination directory.
+     * @param resource   The name of the resource file to copy
+     */
+    private void copyResourceFile(String resource) {
+        DocPath p = DocPaths.RESOURCES.resolve(resource);
+        DocFile f = DocFile.createFileForOutput(configuration, p);
+        f.copyResource(p, false, false);
     }
 
-    private void performCopy(String configdestdir, String filename) {
+    private void performCopy(String filename) {
+        if (filename.isEmpty())
+            return;
+
         try {
-            String destdir = (configdestdir.length() > 0) ?
-                configdestdir + File.separatorChar: "";
-            if (filename.length() > 0) {
-                File helpstylefile = new File(filename);
-                String parent = helpstylefile.getParent();
-                String helpstylefilename = (parent == null)?
-                    filename:
-                    filename.substring(parent.length() + 1);
-                File desthelpfile = new File(destdir + helpstylefilename);
-                if (!desthelpfile.getCanonicalPath().equals(
-                        helpstylefile.getCanonicalPath())) {
-                    configuration.message.
-                        notice((SourcePosition) null,
-                            "doclet.Copying_File_0_To_File_1",
-                            helpstylefile.toString(), desthelpfile.toString());
-                    Util.copyFile(desthelpfile, helpstylefile);
-                }
-            }
+            DocFile fromfile = DocFile.createFileForInput(configuration, filename);
+            DocPath path = DocPath.create(fromfile.getName());
+            DocFile toFile = DocFile.createFileForOutput(configuration, path);
+            if (toFile.isSameFile(fromfile))
+                return;
+
+            configuration.message.notice((SourcePosition) null,
+                    "doclet.Copying_File_0_To_File_1",
+                    fromfile.toString(), path.getPath());
+            toFile.copyFile(fromfile);
         } catch (IOException exc) {
-            configuration.message.
-                error((SourcePosition) null,
+            configuration.message.error((SourcePosition) null,
                     "doclet.perform_copy_exception_encountered",
                     exc.toString());
             throw new DocletAbortException();
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
index 2cc8114..ba62e7c 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
@@ -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
@@ -32,14 +32,19 @@ import java.util.*;
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for the Html Format Code Generation specific to JavaDoc.
  * This Class contains methods related to the Html Code Generation which
  * are used extensively while generating the entire documentation.
  *
+ *  <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.2
  * @author Atul M Dambalkar
  * @author Robert Field
@@ -50,42 +55,29 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     /**
      * Relative path from the file getting generated to the destination
      * directory. For example, if the file getting generated is
-     * "java/lang/Object.html", then the relative path string is "../../".
+     * "java/lang/Object.html", then the path to the root is "../..".
      * This string can be empty if the file getting generated is in
      * the destination directory.
      */
-    public String relativePath = "";
+    public final DocPath pathToRoot;
 
     /**
-     * Same as relativepath, but normalized to never be empty or
-     * end with a slash.
-     */
-    public String relativepathNoSlash = "";
-
-    /**
-     * Platform-dependent directory path from the current or the
+     * Platform-independent path from the current or the
      * destination directory to the file getting generated.
      * Used when creating the file.
-     * For example, if the file getting generated is
-     * "java/lang/Object.html", then the path string is "java/lang".
      */
-    public String path = "";
+    public final DocPath path;
 
     /**
      * Name of the file getting generated. If the file getting generated is
      * "java/lang/Object.html", then the filename is "Object.html".
      */
-    public String filename = "";
-
-    /**
-     * The display length used for indentation while generating the class page.
-     */
-    public int displayLength = 0;
+    public final DocPath filename;
 
     /**
      * The global configuration information for this run.
      */
-    public ConfigurationImpl configuration;
+    public final ConfigurationImpl configuration;
 
     /**
      * To check whether annotation heading is printed or not.
@@ -93,35 +85,27 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     protected boolean printedAnnotationHeading = false;
 
     /**
-     * Constructor to construct the HtmlStandardWriter object.
-     *
-     * @param filename File to be generated.
+     * To check whether the repeated annotations is documented or not.
      */
-    public HtmlDocletWriter(ConfigurationImpl configuration,
-                              String filename) throws IOException {
-        super(configuration, filename);
-        this.configuration = configuration;
-        this.filename = filename;
-    }
+    private boolean isAnnotationDocumented = false;
+
+    /**
+     * To check whether the container annotations is documented or not.
+     */
+    private boolean isContainerDocumented = false;
 
     /**
      * Constructor to construct the HtmlStandardWriter object.
      *
-     * @param path         Platform-dependent {@link #path} used when
-     *                     creating file.
-     * @param filename     Name of file to be generated.
-     * @param relativePath Value for the variable {@link #relativePath}.
+     * @param path File to be generated.
      */
-    public HtmlDocletWriter(ConfigurationImpl configuration,
-                              String path, String filename,
-                              String relativePath) throws IOException {
-        super(configuration, path, filename);
+    public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path)
+            throws IOException {
+        super(configuration, path);
         this.configuration = configuration;
         this.path = path;
-        this.relativePath = relativePath;
-        this.relativepathNoSlash =
-            DirectoryManager.getPathNoTrailingSlash(this.relativePath);
-        this.filename = filename;
+        this.pathToRoot = path.parent().invert();
+        this.filename = path.basename();
     }
 
     /**
@@ -160,8 +144,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         int previndex = 0;
         while (true) {
             if (configuration.docrootparent.length() > 0) {
+                final String docroot_parent = "{@docroot}/..";
                 // Search for lowercase version of {@docRoot}/..
-                index = lowerHtml.indexOf("{@docroot}/..", previndex);
+                index = lowerHtml.indexOf(docroot_parent, previndex);
                 // If next {@docRoot}/.. pattern not found, append rest of htmlstr and exit loop
                 if (index < 0) {
                     buf.append(htmlstr.substring(previndex));
@@ -169,17 +154,18 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 }
                 // If next {@docroot}/.. pattern found, append htmlstr up to start of tag
                 buf.append(htmlstr.substring(previndex, index));
-                previndex = index + 13;  // length for {@docroot}/.. string
+                previndex = index + docroot_parent.length();
                 // Insert docrootparent absolute path where {@docRoot}/.. was located
 
                 buf.append(configuration.docrootparent);
                 // Append slash if next character is not a slash
                 if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
-                    buf.append(DirectoryManager.URL_FILE_SEPARATOR);
+                    buf.append('/');
                 }
             } else {
+                final String docroot = "{@docroot}";
                 // Search for lowercase version of {@docRoot}
-                index = lowerHtml.indexOf("{@docroot}", previndex);
+                index = lowerHtml.indexOf(docroot, previndex);
                 // If next {@docRoot} tag not found, append rest of htmlstr and exit loop
                 if (index < 0) {
                     buf.append(htmlstr.substring(previndex));
@@ -187,13 +173,12 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 }
                 // If next {@docroot} tag found, append htmlstr up to start of tag
                 buf.append(htmlstr.substring(previndex, index));
-                previndex = index + 10;  // length for {@docroot} string
+                previndex = index + docroot.length();
                 // Insert relative path where {@docRoot} was located
-                buf.append(relativepathNoSlash);
+                buf.append(pathToRoot.isEmpty() ? "." : pathToRoot.getPath());
                 // Append slash if next character is not a slash
-                if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() &&
-                        htmlstr.charAt(previndex) != '/') {
-                    buf.append(DirectoryManager.URL_FILE_SEPARATOR);
+                if (previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') {
+                    buf.append('/');
                 }
             }
         }
@@ -201,33 +186,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print Html Hyper Link, with target frame.  This
-     * link will only appear if page is not in a frame.
-     *
-     * @param link String name of the file.
-     * @param where Position in the file
-     * @param target Name of the target frame.
-     * @param label Tag for the link.
-     * @param strong Whether the label should be strong or not?
-     */
-    public void printNoFramesTargetHyperLink(String link, String where,
-                                               String target, String label,
-                                               boolean strong) {
-        script();
-        println("  <!--");
-        println("  if(window==top) {");
-        println("    document.writeln('"
-            + getHyperLinkString(link, where, label, strong, "", "", target) + "');");
-        println("  }");
-        println("  //-->");
-        scriptEnd();
-        noScript();
-        println("  " + getHyperLinkString(link, where, label, strong, "", "", target));
-        noScriptEnd();
-        println(DocletConstants.NL);
-    }
-
-    /**
      * Get the script to show or hide the All classes link.
      *
      * @param id id of the element to show or hide
@@ -288,15 +246,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         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);
     }
 
@@ -308,11 +262,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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();
     }
 
     /**
@@ -324,14 +278,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         return new TagletWriterImpl(this, isFirstSentence);
     }
 
-    protected void printTagsInfoHeader() {
-        dl();
-    }
-
-    protected void printTagsInfoFooter() {
-        dlEnd();
-    }
-
     /**
      * Get Package link, with target frame.
      *
@@ -342,67 +288,107 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      */
     public Content getTargetPackageLink(PackageDoc pd, String target,
             Content label) {
-        return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
-    }
-
-    /**
-     * Print the html file header. Also print Html page title and stylesheet
-     * default properties.
-     *
-     * @param title         String window title to go in the <TITLE> tag
-     * @param metakeywords  Array of String keywords for META tag.  Each element
-     *                      of the array is assigned to a separate META tag.
-     *                      Pass in null for no array.
-     * @param includeScript boolean true if printing windowtitle script.
-     *             False for files that appear in the left-hand frames.
-     */
-    public void printHtmlHeader(String title, String[] metakeywords,
-            boolean includeScript) {
-        println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " +
-                    "Transitional//EN\" " +
-                    "\"http://www.w3.org/TR/html4/loose.dtd\">");
-        println("<!--NewPage-->");
-        html();
-        head();
-        if (! configuration.notimestamp) {
-            print("<!-- Generated by javadoc (build " + ConfigurationImpl.BUILD_DATE + ") on ");
-            print(today());
-            println(" -->");
-        }
-        if (configuration.charset.length() > 0) {
-            println("<META http-equiv=\"Content-Type\" content=\"text/html; "
-                        + "charset=" + configuration.charset + "\">");
-        }
-        if ( configuration.windowtitle.length() > 0 ) {
-            title += " (" + configuration.windowtitle  + ")";
-        }
-        title(title);
-        println(title);
-        titleEnd();
-        println("");
-        if (! configuration.notimestamp) {
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                println("<META NAME=\"date\" "
-                                    + "CONTENT=\"" + dateFormat.format(new Date()) + "\">");
-        }
-        if ( metakeywords != null ) {
-            for ( int i=0; i < metakeywords.length; i++ ) {
-                println("<META NAME=\"keywords\" "
-                            + "CONTENT=\"" + metakeywords[i] + "\">");
+        return getHyperLink(pathString(pd, DocPaths.PACKAGE_SUMMARY), label, "", target);
+    }
+
+    /**
+     * Get Profile Package link, with target frame.
+     *
+     * @param pd the packageDoc object
+     * @param target name of the target frame
+     * @param label tag for the link
+     * @param profileName the name of the profile being documented
+     * @return a content for the target profile packages link
+     */
+    public Content getTargetProfilePackageLink(PackageDoc pd, String target,
+            Content label, String profileName) {
+        return getHyperLink(pathString(pd, DocPaths.profilePackageSummary(profileName)),
+                label, "", target);
+    }
+
+    /**
+     * Get Profile link, with target frame.
+     *
+     * @param target name of the target frame
+     * @param label tag for the link
+     * @param profileName the name of the profile being documented
+     * @return a content for the target profile link
+     */
+    public Content getTargetProfileLink(String target, Content label,
+            String profileName) {
+        return getHyperLink(pathToRoot.resolve(
+                DocPaths.profileSummary(profileName)), label, "", target);
+    }
+
+    /**
+     * Get the type name for profile search.
+     *
+     * @param cd the classDoc object for which the type name conversion is needed
+     * @return a type name string for the type
+     */
+    public String getTypeNameForProfile(ClassDoc cd) {
+        StringBuilder typeName =
+                new StringBuilder((cd.containingPackage()).name().replace(".", "/"));
+        typeName.append("/")
+                .append(cd.name().replace(".", "$"));
+        return typeName.toString();
+    }
+
+    /**
+     * Check if a type belongs to a profile.
+     *
+     * @param cd the classDoc object that needs to be checked
+     * @param profileValue the profile in which the type needs to be checked
+     * @return true if the type is in the profile
+     */
+    public boolean isTypeInProfile(ClassDoc cd, int profileValue) {
+        return (configuration.profiles.getProfile(getTypeNameForProfile(cd)) <= profileValue);
+    }
+
+    public void addClassesSummary(ClassDoc[] classes, String label,
+            String tableSummary, String[] tableHeader, Content summaryContentTree,
+            int profileValue) {
+        if(classes.length > 0) {
+            Arrays.sort(classes);
+            Content caption = getTableCaption(new RawHtml(label));
+            Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
+                    tableSummary, caption);
+            table.addContent(getSummaryTableHeader(tableHeader, "col"));
+            Content tbody = new HtmlTree(HtmlTag.TBODY);
+            for (int i = 0; i < classes.length; i++) {
+                if (!isTypeInProfile(classes[i], profileValue)) {
+                    continue;
+                }
+                if (!Util.isCoreClass(classes[i]) ||
+                    !configuration.isGeneratedDoc(classes[i])) {
+                    continue;
+                }
+                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)
+                    tr.addStyle(HtmlStyle.altColor);
+                else
+                    tr.addStyle(HtmlStyle.rowColor);
+                HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
+                tdClassDescription.addStyle(HtmlStyle.colLast);
+                if (Util.isDeprecated(classes[i])) {
+                    tdClassDescription.addContent(deprecatedLabel);
+                    if (classes[i].tags("deprecated").length > 0) {
+                        addSummaryDeprecatedComment(classes[i],
+                            classes[i].tags("deprecated")[0], tdClassDescription);
+                    }
+                }
+                else
+                    addSummaryComment(classes[i], tdClassDescription);
+                tr.addContent(tdClassDescription);
+                tbody.addContent(tr);
             }
+            table.addContent(tbody);
+            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+            summaryContentTree.addContent(li);
         }
-        println("");
-        printStyleSheetProperties();
-        println("");
-        // Don't print windowtitle script for overview-frame, allclasses-frame
-        // and package-frame
-        if (includeScript) {
-            printWinTitleScript(title);
-        }
-        println("");
-        headEnd();
-        println("");
-        body("white", includeScript);
     }
 
     /**
@@ -416,13 +402,12 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @param body the body htmltree to be included in the document
      */
     public void printHtmlDocument(String[] metakeywords, boolean includeScript,
-            Content body) {
-        Content htmlDocType = DocType.Transitional();
+            Content body) throws IOException {
+        Content htmlDocType = DocType.TRANSITIONAL;
         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
         Content head = new HtmlTree(HtmlTag.HEAD);
         if (!configuration.notimestamp) {
-            Content headComment = new Comment("Generated by javadoc (version " +
-                    ConfigurationImpl.BUILD_DATE + ") on " + today());
+            Content headComment = new Comment(getGeneratedByString());
             head.addContent(headComment);
         }
         if (configuration.charset.length() > 0) {
@@ -443,11 +428,12 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             }
         }
         head.addContent(getStyleSheetProperties());
+        head.addContent(getScriptProperties());
         Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
                 head, body);
         Content htmlDocument = new HtmlDocument(htmlDocType,
                 htmlComment, htmlTree);
-        print(htmlDocument.toString());
+        write(htmlDocument);
     }
 
     /**
@@ -464,26 +450,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print user specified header and the footer.
-     *
-     * @param header if true print the user provided header else print the
-     * user provided footer.
-     */
-    public void printUserHeaderFooter(boolean header) {
-        em();
-        if (header) {
-            print(replaceDocRootDir(configuration.header));
-        } else {
-            if (configuration.footer.length() != 0) {
-                print(replaceDocRootDir(configuration.footer));
-            } else {
-                print(replaceDocRootDir(configuration.header));
-            }
-        }
-        emEnd();
-    }
-
-    /**
      * Get user specified header and the footer.
      *
      * @param header if true print the user provided header else print the
@@ -506,14 +472,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the user specified top.
-     */
-    public void printTop() {
-        print(replaceDocRootDir(configuration.top));
-        hr();
-    }
-
-    /**
      * Adds the user specified top.
      *
      * @param body the content tree to which user specified top will be added
@@ -524,14 +482,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the user specified bottom.
-     */
-    public void printBottom() {
-        hr();
-        print(replaceDocRootDir(configuration.bottom));
-    }
-
-    /**
      * Adds the user specified bottom.
      *
      * @param body the content tree to which user specified bottom will be added
@@ -544,128 +494,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the navigation bar for the Html page at the top and and the bottom.
-     *
-     * @param header If true print navigation bar at the top of the page else
-     * print the nevigation bar at the bottom.
-     */
-    protected void navLinks(boolean header) {
-        println("");
-        if (!configuration.nonavbar) {
-            if (header) {
-                println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->");
-                anchor("navbar_top");
-                println();
-                print(getHyperLinkString("", "skip-navbar_top", "", false, "",
-                    configuration.getText("doclet.Skip_navigation_links"), ""));
-            } else {
-                println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
-                anchor("navbar_bottom");
-                println();
-                print(getHyperLinkString("", "skip-navbar_bottom", "", false, "",
-                    configuration.getText("doclet.Skip_navigation_links"), ""));
-            }
-            table(0, "100%", 1, 0);
-            tr();
-            tdColspanBgcolorStyle(2, "#EEEEFF", "NavBarCell1");
-            println("");
-            if (header) {
-                anchor("navbar_top_firstrow");
-            } else {
-                anchor("navbar_bottom_firstrow");
-            }
-            table(0, 0, 3);
-            print("  ");
-            trAlignVAlign("center", "top");
-
-            if (configuration.createoverview) {
-                navLinkContents();
-            }
-
-            if (configuration.packages.length == 1) {
-                navLinkPackage(configuration.packages[0]);
-            } else if (configuration.packages.length > 1) {
-                navLinkPackage();
-            }
-
-            navLinkClass();
-
-            if(configuration.classuse) {
-                navLinkClassUse();
-            }
-            if(configuration.createtree) {
-                navLinkTree();
-            }
-            if(!(configuration.nodeprecated ||
-                     configuration.nodeprecatedlist)) {
-                navLinkDeprecated();
-            }
-            if(configuration.createindex) {
-                navLinkIndex();
-            }
-            if (!configuration.nohelp) {
-                navLinkHelp();
-            }
-            print("  ");
-            trEnd();
-            tableEnd();
-            tdEnd();
-
-            tdAlignVAlignRowspan("right", "top", 3);
-
-            printUserHeaderFooter(header);
-            tdEnd();
-            trEnd();
-            println("");
-
-            tr();
-            tdBgcolorStyle("white", "NavBarCell2");
-            font("-2");
-            space();
-            navLinkPrevious();
-            space();
-            println("");
-            space();
-            navLinkNext();
-            fontEnd();
-            tdEnd();
-
-            tdBgcolorStyle("white", "NavBarCell2");
-            font("-2");
-            print("  ");
-            navShowLists();
-            print("  ");
-            space();
-            println("");
-            space();
-            navHideLists(filename);
-            print("  ");
-            space();
-            println("");
-            space();
-            navLinkClassIndex();
-            fontEnd();
-            tdEnd();
-
-            trEnd();
-
-            printSummaryDetailLinks();
-
-            tableEnd();
-            if (header) {
-                aName("skip-navbar_top");
-                aEnd();
-                println(DocletConstants.NL + "<!-- ========= END OF TOP NAVBAR ========= -->");
-            } else {
-                aName("skip-navbar_bottom");
-                aEnd();
-                println(DocletConstants.NL + "<!-- ======== END OF BOTTOM NAVBAR ======= -->");
-            }
-            println("");
-        }
-    }
-
-    /**
      * Adds the navigation bar for the Html page at the top and and the bottom.
      *
      * @param header If true print navigation bar at the top of the page else
@@ -681,9 +509,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 allClassesId += "navbar_top";
                 Content a = getMarkerAnchor("navbar_top");
                 navDiv.addContent(a);
-                Content skipLinkContent = getHyperLink("",
-                        "skip-navbar_top", HtmlTree.EMPTY, configuration.getText(
-                        "doclet.Skip_navigation_links"), "");
+                Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_top"),
+                        HtmlTree.EMPTY,
+                        configuration.getText("doclet.Skip_navigation_links"),
+                        "");
                 navDiv.addContent(skipLinkContent);
             } else {
                 body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
@@ -691,9 +520,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 allClassesId += "navbar_bottom";
                 Content a = getMarkerAnchor("navbar_bottom");
                 navDiv.addContent(a);
-                Content skipLinkContent = getHyperLink("",
-                        "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText(
-                        "doclet.Skip_navigation_links"), "");
+                Content skipLinkContent = getHyperLink(DocLink.fragment("skip-navbar_bottom"),
+                        HtmlTree.EMPTY,
+                        configuration.getText("doclet.Skip_navigation_links"),
+                        "");
                 navDiv.addContent(skipLinkContent);
             }
             if (header) {
@@ -758,14 +588,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the word "NEXT" to indicate that no link is available.  Override
-     * this method to customize next link.
-     */
-    protected void navLinkNext() {
-        navLinkNext(null);
-    }
-
-    /**
      * Get the word "NEXT" to indicate that no link is available.  Override
      * this method to customize next link.
      *
@@ -776,14 +598,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the word "PREV" to indicate that no link is available.  Override
-     * this method to customize prev link.
-     */
-    protected void navLinkPrevious() {
-        navLinkPrevious(null);
-    }
-
-    /**
      * Get the word "PREV" to indicate that no link is available.  Override
      * this method to customize prev link.
      *
@@ -796,78 +610,22 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     /**
      * Do nothing. This is the default method.
      */
-    protected void printSummaryDetailLinks() {
-    }
-
-    /**
-     * Do nothing. This is the default method.
-     */
     protected void addSummaryDetailLinks(Content navDiv) {
     }
 
     /**
-     * Print link to the "overview-summary.html" page.
-     */
-    protected void navLinkContents() {
-        navCellStart();
-        printHyperLink(relativePath + "overview-summary.html", "",
-                       configuration.getText("doclet.Overview"), true, "NavBarFont1");
-        navCellEnd();
-    }
-
-    /**
      * Get link to the "overview-summary.html" page.
      *
      * @return a content tree for the link
      */
     protected Content getNavLinkContents() {
-        Content linkContent = getHyperLink(relativePath +
-                "overview-summary.html", "", overviewLabel, "", "");
+        Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY),
+                overviewLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
 
     /**
-     * Description for a cell in the navigation bar.
-     */
-    protected void navCellStart() {
-        print("  ");
-        tdBgcolorStyle("#EEEEFF", "NavBarCell1");
-        print("    ");
-    }
-
-    /**
-     * Description for a cell in the navigation bar, but with reverse
-     * high-light effect.
-     */
-    protected void navCellRevStart() {
-        print("  ");
-        tdBgcolorStyle("#FFFFFF", "NavBarCell1Rev");
-        print(" ");
-        space();
-    }
-
-    /**
-     * Closing tag for navigation bar cell.
-     */
-    protected void navCellEnd() {
-        space();
-        tdEnd();
-    }
-
-    /**
-     * Print link to the "package-summary.html" page for the package passed.
-     *
-     * @param pkg Package to which link will be generated.
-     */
-    protected void navLinkPackage(PackageDoc pkg) {
-        navCellStart();
-        printPackageLink(pkg, configuration.getText("doclet.Package"), true,
-            "NavBarFont1");
-        navCellEnd();
-    }
-
-    /**
      * Get link to the "package-summary.html" page for the package passed.
      *
      * @param pkg Package to which link will be generated
@@ -881,18 +639,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the word "Package" in the navigation bar cell, to indicate that
-     * link is not available here.
-     */
-    protected void navLinkPackage() {
-        navCellStart();
-        fontStyle("NavBarFont1");
-        printText("doclet.Package");
-        fontEnd();
-        navCellEnd();
-    }
-
-    /**
      * Get the word "Package" , to indicate that link is not available here.
      *
      * @return a content tree for the link
@@ -903,18 +649,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print the word "Use" in the navigation bar cell, to indicate that link
-     * is not available.
-     */
-    protected void navLinkClassUse() {
-        navCellStart();
-        fontStyle("NavBarFont1");
-        printText("doclet.navClassUse");
-        fontEnd();
-        navCellEnd();
-    }
-
-    /**
      * Get the word "Use", to indicate that link is not available.
      *
      * @return a content tree for the link
@@ -925,29 +659,15 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print link for previous file.
-     *
-     * @param prev File name for the prev link.
-     */
-    public void navLinkPrevious(String prev) {
-        String tag = configuration.getText("doclet.Prev");
-        if (prev != null) {
-            printHyperLink(prev, "", tag, true) ;
-        } else {
-            print(tag);
-        }
-    }
-
-    /**
      * Get link for previous file.
      *
      * @param prev File name for the prev link
      * @return a content tree for the link
      */
-    public Content getNavLinkPrevious(String prev) {
+    public Content getNavLinkPrevious(DocPath prev) {
         Content li;
         if (prev != null) {
-            li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
+            li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", ""));
         }
         else
             li = HtmlTree.LI(prevLabel);
@@ -955,31 +675,16 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print link for next file.  If next is null, just print the label
-     * without linking it anywhere.
-     *
-     * @param next File name for the next link.
-     */
-    public void navLinkNext(String next) {
-        String tag = configuration.getText("doclet.Next");
-        if (next != null) {
-            printHyperLink(next, "", tag, true);
-        } else {
-            print(tag);
-        }
-    }
-
-    /**
      * Get link for next file.  If next is null, just print the label
      * without linking it anywhere.
      *
      * @param next File name for the next link
      * @return a content tree for the link
      */
-    public Content getNavLinkNext(String next) {
+    public Content getNavLinkNext(DocPath next) {
         Content li;
         if (next != null) {
-            li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
+            li = HtmlTree.LI(getHyperLink(next, nextLabel, "", ""));
         }
         else
             li = HtmlTree.LI(nextLabel);
@@ -987,52 +692,25 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print "FRAMES" link, to switch to the frame version of the output.
-     *
-     * @param link File to be linked, "index.html".
-     */
-    protected void navShowLists(String link) {
-        print(getHyperLinkString(link + "?" + path + filename, "",
-            configuration.getText("doclet.FRAMES"), true, "", "", "_top"));
-    }
-
-    /**
      * Get "FRAMES" link, to switch to the frame version of the output.
      *
      * @param link File to be linked, "index.html"
      * @return a content tree for the link
      */
-    protected Content getNavShowLists(String link) {
-        Content framesContent = getHyperLink(link + "?" + path +
-                filename, "", framesLabel, "", "_top");
+    protected Content getNavShowLists(DocPath link) {
+        DocLink dl = new DocLink(link, path.getPath(), null);
+        Content framesContent = getHyperLink(dl, framesLabel, "", "_top");
         Content li = HtmlTree.LI(framesContent);
         return li;
     }
 
     /**
-     * Print "FRAMES" link, to switch to the frame version of the output.
-     */
-    protected void navShowLists() {
-        navShowLists(relativePath + "index.html");
-    }
-
-    /**
      * Get "FRAMES" link, to switch to the frame version of the output.
      *
      * @return a content tree for the link
      */
     protected Content getNavShowLists() {
-        return getNavShowLists(relativePath + "index.html");
-    }
-
-    /**
-     * Print "NO FRAMES" link, to switch to the non-frame version of the output.
-     *
-     * @param link File to be linked.
-     */
-    protected void navHideLists(String link) {
-        print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"),
-            true, "", "", "_top"));
+        return getNavShowLists(pathToRoot.resolve(DocPaths.INDEX));
     }
 
     /**
@@ -1041,32 +719,13 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @param link File to be linked
      * @return a content tree for the link
      */
-    protected Content getNavHideLists(String link) {
-        Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
+    protected Content getNavHideLists(DocPath link) {
+        Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top");
         Content li = HtmlTree.LI(noFramesContent);
         return li;
     }
 
     /**
-     * Print "Tree" link in the navigation bar. If there is only one package
-     * specified on the command line, then the "Tree" link will be to the
-     * only "package-tree.html" file otherwise it will be to the
-     * "overview-tree.html" file.
-     */
-    protected void navLinkTree() {
-        navCellStart();
-        PackageDoc[] packages = configuration.root.specifiedPackages();
-        if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
-            printHyperLink(pathString(packages[0], "package-tree.html"), "",
-                           configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        } else {
-            printHyperLink(relativePath + "overview-tree.html", "",
-                           configuration.getText("doclet.Tree"), true, "NavBarFont1");
-        }
-        navCellEnd();
-    }
-
-    /**
      * Get "Tree" link in the navigation bar. If there is only one package
      * specified on the command line, then the "Tree" link will be to the
      * only "package-tree.html" file otherwise it will be to the
@@ -1079,11 +738,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         PackageDoc[] packages = configuration.root.specifiedPackages();
         if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
             treeLinkContent = getHyperLink(pathString(packages[0],
-                    "package-tree.html"), "", treeLabel,
+                    DocPaths.PACKAGE_TREE), treeLabel,
                     "", "");
         } else {
-            treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
-                    "", treeLabel, "", "");
+            treeLinkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
+                    treeLabel, "", "");
         }
         Content li = HtmlTree.LI(treeLinkContent);
         return li;
@@ -1096,25 +755,13 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @return a content tree for the link
      */
     protected Content getNavLinkMainTree(String label) {
-        Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
+        Content mainTreeContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE),
                 new StringContent(label));
         Content li = HtmlTree.LI(mainTreeContent);
         return li;
     }
 
     /**
-     * Print the word "Class" in the navigation bar cell, to indicate that
-     * class link is not available.
-     */
-    protected void navLinkClass() {
-        navCellStart();
-        fontStyle("NavBarFont1");
-        printText("doclet.Class");
-        fontEnd();
-        navCellEnd();
-    }
-
-    /**
      * Get the word "Class", to indicate that class link is not available.
      *
      * @return a content tree for the link
@@ -1125,39 +772,18 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Print "Deprecated" API link in the navigation bar.
-     */
-    protected void navLinkDeprecated() {
-        navCellStart();
-        printHyperLink(relativePath + "deprecated-list.html", "",
-                       configuration.getText("doclet.navDeprecated"), true, "NavBarFont1");
-        navCellEnd();
-    }
-
-    /**
      * Get "Deprecated" API link in the navigation bar.
      *
      * @return a content tree for the link
      */
     protected Content getNavLinkDeprecated() {
-        Content linkContent = getHyperLink(relativePath +
-                "deprecated-list.html", "", deprecatedLabel, "", "");
+        Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
+                deprecatedLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
 
     /**
-     * Print link for generated index. If the user has used "-splitindex"
-     * command line option, then link to file "index-files/index-1.html" is
-     * generated otherwise link to file "index-all.html" is generated.
-     */
-    protected void navLinkClassIndex() {
-        printNoFramesTargetHyperLink(relativePath +
-                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES,
-            "", "", configuration.getText("doclet.All_Classes"), true);
-    }
-
-    /**
      * Get link for generated index. If the user has used "-splitindex"
      * command line option, then link to file "index-files/index-1.html" is
      * generated otherwise link to file "index-all.html" is generated.
@@ -1165,26 +791,12 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @return a content tree for the link
      */
     protected Content getNavLinkClassIndex() {
-        Content allClassesContent = getHyperLink(relativePath +
-                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
+        Content allClassesContent = getHyperLink(pathToRoot.resolve(
+                DocPaths.ALLCLASSES_NOFRAME),
                 allclassesLabel, "", "");
         Content li = HtmlTree.LI(allClassesContent);
         return li;
     }
-    /**
-     * Print link for generated class index.
-     */
-    protected void navLinkIndex() {
-        navCellStart();
-        printHyperLink(relativePath +
-                           (configuration.splitindex?
-                                DirectoryManager.getPath("index-files") +
-                                fileseparator: "") +
-                           (configuration.splitindex?
-                                "index-1.html" : "index-all.html"), "",
-                       configuration.getText("doclet.Index"), true, "NavBarFont1");
-        navCellEnd();
-    }
 
     /**
      * Get link for generated class index.
@@ -1192,36 +804,16 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @return a content tree for the link
      */
     protected Content getNavLinkIndex() {
-        Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
-            DirectoryManager.getPath("index-files") + fileseparator: "") +
-            (configuration.splitindex?"index-1.html" : "index-all.html"), "",
+        Content linkContent = getHyperLink(pathToRoot.resolve(
+                (configuration.splitindex
+                    ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
+                    : DocPaths.INDEX_ALL)),
             indexLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
 
     /**
-     * Print help file link. If user has provided a help file, then generate a
-     * link to the user given file, which is already copied to current or
-     * destination directory.
-     */
-    protected void navLinkHelp() {
-        String helpfilenm = configuration.helpfile;
-        if (helpfilenm.equals("")) {
-            helpfilenm = "help-doc.html";
-        } else {
-            int lastsep;
-            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
-                helpfilenm = helpfilenm.substring(lastsep + 1);
-            }
-        }
-        navCellStart();
-        printHyperLink(relativePath + helpfilenm, "",
-                       configuration.getText("doclet.Help"), true, "NavBarFont1");
-        navCellEnd();
-    }
-
-    /**
      * Get help file link. If user has provided a help file, then generate a
      * link to the user given file, which is already copied to current or
      * destination directory.
@@ -1229,103 +821,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @return a content tree for the link
      */
     protected Content getNavLinkHelp() {
-        String helpfilenm = configuration.helpfile;
-        if (helpfilenm.equals("")) {
-            helpfilenm = "help-doc.html";
+        String helpfile = configuration.helpfile;
+        DocPath helpfilenm;
+        if (helpfile.isEmpty()) {
+            helpfilenm = DocPaths.HELP_DOC;
         } else {
-            int lastsep;
-            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
-                helpfilenm = helpfilenm.substring(lastsep + 1);
-            }
+            DocFile file = DocFile.createFileForInput(configuration, helpfile);
+            helpfilenm = DocPath.create(file.getName());
         }
-        Content linkContent = getHyperLink(relativePath + helpfilenm, "",
+        Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm),
                 helpLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
 
     /**
-     * Print the word "Detail" in the navigation bar. No link is available.
-     */
-    protected void navDetail() {
-        printText("doclet.Detail");
-    }
-
-    /**
-     * Print the word "Summary" in the navigation bar. No link is available.
-     */
-    protected void navSummary() {
-        printText("doclet.Summary");
-    }
-
-    /**
-     * Print the Html table tag for the index summary tables. The table tag
-     * printed is
-     * <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
-     */
-    public void tableIndexSummary() {
-        table(1, "100%", 3, 0);
-    }
-
-    /**
-     * Print the Html table tag for the index summary tables.
-     *
-     * @param summary the summary for the table tag summary attribute.
-     */
-    public void tableIndexSummary(String summary) {
-        table(1, "100%", 3, 0, summary);
-    }
-
-    /**
-     * Same as {@link #tableIndexSummary()}.
-     */
-    public void tableIndexDetail() {
-        table(1, "100%", 3, 0);
-    }
-
-    /**
-     * Print Html tag for table elements. The tag printed is
-     * <TD ALIGN="right" VALIGN="top" WIDTH="1%">.
-     */
-    public void tdIndex() {
-        print("<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\">");
-    }
-
-    /**
-     * Print table caption.
-     */
-    public void tableCaptionStart() {
-        captionStyle("TableCaption");
-    }
-
-    /**
-     * Print table sub-caption.
-     */
-    public void tableSubCaptionStart() {
-        captionStyle("TableSubCaption");
-    }
-
-    /**
-     * Print table caption end tags.
-     */
-    public void tableCaptionEnd() {
-        captionEnd();
-    }
-
-    /**
-     * Print summary table header.
-     */
-    public void summaryTableHeader(String[] header, String scope) {
-        tr();
-        for ( int i=0; i < header.length; i++ ) {
-            thScopeNoWrap("TableHeader", scope);
-            print(header[i]);
-            thEnd();
-        }
-        trEnd();
-    }
-
-    /**
      * Get summary table header.
      *
      * @param header the header for the table
@@ -1359,8 +869,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
@@ -1408,7 +917,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     /**
      * Returns a package name label.
      *
-     * @param parsedName the package name
+     * @param packageName the package name
      * @return the package name content
      */
     public Content getPackageLabel(String packageName) {
@@ -1428,7 +937,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             String tableSummary, String[] tableHeader, Content contentTree) {
         if (deprPkgs.size() > 0) {
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration().getText(headingKey)));
+                    getTableCaption(configuration.getResource(headingKey)));
             table.addContent(getSummaryTableHeader(tableHeader, "col"));
             Content tbody = new HtmlTree(HtmlTag.TBODY);
             for (int i = 0; i < deprPkgs.size(); i++) {
@@ -1446,224 +955,34 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 }
                 tbody.addContent(tr);
             }
-            table.addContent(tbody);
-            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
-            Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
-            contentTree.addContent(ul);
-        }
-    }
-
-    /**
-     * Prine table header information about color, column span and the font.
-     *
-     * @param color Background color.
-     * @param span  Column span.
-     */
-    public void tableHeaderStart(String color, int span) {
-        trBgcolorStyle(color, "TableHeadingColor");
-        thAlignColspan("left", span);
-        font("+2");
-    }
-
-    /**
-     * Print table header for the inherited members summary tables. Print the
-     * background color information.
-     *
-     * @param color Background color.
-     */
-    public void tableInheritedHeaderStart(String color) {
-        trBgcolorStyle(color, "TableSubHeadingColor");
-        thAlign("left");
-    }
-
-    /**
-     * Print "Use" table header. Print the background color and the column span.
-     *
-     * @param color Background color.
-     */
-    public void tableUseInfoHeaderStart(String color) {
-        trBgcolorStyle(color, "TableSubHeadingColor");
-        thAlignColspan("left", 2);
-    }
-
-    /**
-     * Print table header with the background color with default column span 2.
-     *
-     * @param color Background color.
-     */
-    public void tableHeaderStart(String color) {
-        tableHeaderStart(color, 2);
-    }
-
-    /**
-     * Print table header with the column span, with the default color #CCCCFF.
-     *
-     * @param span Column span.
-     */
-    public void tableHeaderStart(int span) {
-        tableHeaderStart("#CCCCFF", span);
-    }
-
-    /**
-     * Print table header with default column span 2 and default color #CCCCFF.
-     */
-    public void tableHeaderStart() {
-        tableHeaderStart(2);
-    }
-
-    /**
-     * Print table header end tags for font, column and row.
-     */
-    public void tableHeaderEnd() {
-        fontEnd();
-        thEnd();
-        trEnd();
-    }
-
-    /**
-     * Print table header end tags in inherited tables for column and row.
-     */
-    public void tableInheritedHeaderEnd() {
-        thEnd();
-        trEnd();
-    }
-
-    /**
-     * Print the summary table row cell attribute width.
-     *
-     * @param width Width of the table cell.
-     */
-    public void summaryRow(int width) {
-        if (width != 0) {
-            tdWidth(width + "%");
-        } else {
-            td();
-        }
-    }
-
-    /**
-     * Print the summary table row cell end tag.
-     */
-    public void summaryRowEnd() {
-        tdEnd();
-    }
-
-    /**
-     * Print the heading in Html <H2> format.
-     *
-     * @param str The Header string.
-     */
-    public void printIndexHeading(String str) {
-        h2();
-        print(str);
-        h2End();
-    }
-
-    /**
-     * Print Html tag <FRAMESET=arg>.
-     *
-     * @param arg Argument for the tag.
-     */
-    public void frameSet(String arg) {
-        println("<FRAMESET " + arg + ">");
-    }
-
-    /**
-     * Print Html closing tag </FRAMESET>.
-     */
-    public void frameSetEnd() {
-        println("</FRAMESET>");
-    }
-
-    /**
-     * Print Html tag <FRAME=arg>.
-     *
-     * @param arg Argument for the tag.
-     */
-    public void frame(String arg) {
-        println("<FRAME " + arg + ">");
-    }
-
-    /**
-     * Print Html closing tag </FRAME>.
-     */
-    public void frameEnd() {
-        println("</FRAME>");
-    }
-
-    /**
-     * Return path to the class page for a classdoc. For example, the class
-     * name is "java.lang.Object" and if the current file getting generated is
-     * "java/io/File.html", then the path string to the class, returned is
-     * "../../java/lang.Object.html".
-     *
-     * @param cd Class to which the path is requested.
-     */
-    protected String pathToClass(ClassDoc cd) {
-        return pathString(cd.containingPackage(), cd.name() + ".html");
-    }
-
-    /**
-     * Return the path to the class page for a classdoc. Works same as
-     * {@link #pathToClass(ClassDoc)}.
-     *
-     * @param cd   Class to which the path is requested.
-     * @param name Name of the file(doesn't include path).
-     */
-    protected String pathString(ClassDoc cd, String name) {
-        return pathString(cd.containingPackage(), name);
-    }
-
-    /**
-     * Return path to the given file name in the given package. So if the name
-     * passed is "Object.html" and the name of the package is "java.lang", and
-     * if the relative path is "../.." then returned string will be
-     * "../../java/lang/Object.html"
-     *
-     * @param pd Package in which the file name is assumed to be.
-     * @param name File name, to which path string is.
-     */
-    protected String pathString(PackageDoc pd, String name) {
-        StringBuffer buf = new StringBuffer(relativePath);
-        buf.append(DirectoryManager.getPathToPackage(pd, name));
-        return buf.toString();
-    }
-
-    /**
-     * Print 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.
-     */
-    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
-        print(getPackageLinkString(pkg, label, isStrong));
+            table.addContent(tbody);
+            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
+            Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
+            contentTree.addContent(ul);
+        }
     }
 
     /**
-     * Print the link to the given package.
+     * Return the path to the class page for a classdoc.
      *
-     * @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.
+     * @param cd   Class to which the path is requested.
+     * @param name Name of the file(doesn't include path).
      */
-    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
-            String style) {
-        print(getPackageLinkString(pkg, label, isStrong, style));
+    protected DocPath pathString(ClassDoc cd, DocPath name) {
+        return pathString(cd.containingPackage(), name);
     }
 
     /**
-     * Return the link to the given package.
+     * Return path to the given file name in the given package. So if the name
+     * passed is "Object.html" and the name of the package is "java.lang", and
+     * if the relative path is "../.." then returned string will be
+     * "../../java/lang/Object.html"
      *
-     * @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.
+     * @param pd Package in which the file name is assumed to be.
+     * @param name File name, to which path string is.
      */
-    public String getPackageLinkString(PackageDoc pkg, String label,
-                                 boolean isStrong) {
-        return getPackageLinkString(pkg, label, isStrong, "");
+    protected DocPath pathString(PackageDoc pd, DocPath name) {
+        return pathToRoot.resolve(DocPath.forPackage(pd).resolve(name));
     }
 
     /**
@@ -1671,33 +990,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      *
      * @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, "package-summary.html"),
-                                "", label, isStrong, style);
-        } else {
-            String 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));
     }
 
     /**
@@ -1719,36 +1015,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             }
         }
         if (included || pkg == null) {
-            return getHyperLink(pathString(pkg, "package-summary.html"),
-                                "", label);
+            return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
+                    label);
         } else {
-            String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
+            DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
             if (crossPkgLink != null) {
-                return getHyperLink(crossPkgLink, "", label);
+                return getHyperLink(crossPkgLink, label);
             } else {
                 return label;
             }
         }
     }
 
-    public String italicsClassName(ClassDoc cd, boolean qual) {
-        String name = (qual)? cd.qualifiedName(): cd.name();
-        return (cd.isInterface())?  italicsText(name): name;
-    }
-
-    public void printSrcLink(ProgramElementDoc d, String label) {
-        if (d == null) {
-            return;
-        }
-        ClassDoc cd = d.containingClass();
-        if (cd == null) {
-            //d must be a class doc since in has no containing class.
-            cd = (ClassDoc) d;
-        }
-        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
-            + DirectoryManager.getDirectoryPath(cd.containingPackage())
-            + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(d);
-        printHyperLink(href, "", label, true);
+    public Content italicsClassName(ClassDoc cd, boolean qual) {
+        Content name = new StringContent((qual)? cd.qualifiedName(): cd.name());
+        return (cd.isInterface())?  HtmlTree.I(name): name;
     }
 
     /**
@@ -1767,10 +1048,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             //d must be a class doc since in has no containing class.
             cd = (ClassDoc) doc;
         }
-        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
-                + DirectoryManager.getDirectoryPath(cd.containingPackage())
-                + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
-        Content linkContent = getHyperLink(href, "", label, "", "");
+        DocPath href = pathToRoot
+                .resolve(DocPaths.SOURCE_OUTPUT)
+                .resolve(DocPath.forClass(cd));
+        Content linkContent = getHyperLink(href.fragment(SourceToHTMLConverter.getAnchorName(doc)), label, "", "");
         htmltree.addContent(linkContent);
     }
 
@@ -1781,11 +1062,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      *
      * @return the link for the given class.
      */
-    public String getLink(LinkInfoImpl linkInfo) {
+    public Content getLink(LinkInfoImpl linkInfo) {
         LinkFactoryImpl factory = new LinkFactoryImpl(this);
-        String link = ((LinkOutputImpl) factory.getLinkOutput(linkInfo)).toString();
-        displayLength += linkInfo.displayLength;
-        return link;
+        return factory.getLink(linkInfo);
     }
 
     /**
@@ -1794,17 +1073,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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 ((LinkOutputImpl)
-            factory.getTypeParameterLinks(linkInfo, false)).toString();
-    }
-
-    /**
-     * Print the link to the given class.
-     */
-    public void printLink(LinkInfoImpl linkInfo) {
-        print(getLink(linkInfo));
+        return factory.getTypeParameterLinks(linkInfo, false);
     }
 
     /*************************************************************
@@ -1821,16 +1092,18 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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 = "",
-            packageName = qualifiedClassName == null ? "" : qualifiedClassName;
+        String className = "";
+        String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
         int periodIndex;
-        while((periodIndex = packageName.lastIndexOf('.')) != -1) {
+        while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
             className = packageName.substring(periodIndex + 1, packageName.length()) +
                 (className.length() > 0 ? "." + className : "");
-            String defaultLabel = code ? getCode() + className + getCodeEnd() : 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
@@ -1838,11 +1111,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 //the -link option.  There are ways to determine if an external package
                 //exists, but no way to determine if the external class exists.  We just
                 //have to assume that it does.
-                return getHyperLinkString(
-                    configuration.extern.getExternalLink(packageName, relativePath,
-                                className + ".html?is-external=true"),
-                    refMemName == null ? "" : refMemName,
-                    label == null || label.length() == 0 ? defaultLabel : label,
+                DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
+                                className + ".html", refMemName);
+                return getHyperLink(link,
+                    (label == null) || label.isEmpty() ? defaultLabel : label,
                     strong, style,
                     configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
                     "");
@@ -1858,9 +1130,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         return configuration.extern.isExternal(cd);
     }
 
-    public String getCrossPackageLink(String pkgName) {
-        return configuration.extern.getExternalLink(pkgName, relativePath,
-            "package-summary.html?is-external=true");
+    public DocLink getCrossPackageLink(String pkgName) {
+        return configuration.extern.getExternalLink(pkgName, pathToRoot,
+            DocPaths.PACKAGE_SUMMARY.getPath());
     }
 
     /**
@@ -1870,9 +1142,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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(context, cd,
-                configuration.getClassName(cd), "")));
+    public Content getQualifiedClassLink(LinkInfoImpl.Kind context, ClassDoc cd) {
+        return getLink(new LinkInfoImpl(configuration, context, cd)
+                .label(configuration.getClassName(cd)));
     }
 
     /**
@@ -1882,27 +1154,28 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
     }
 
     /**
      * Retrieve the class link with the package portion of the label in
-     * plain text.  If the qualifier is excluded, it willnot be included in the
+     * plain text.  If the qualifier is excluded, it will not be included in the
      * link label.
      *
      * @param cd the class to link to.
      * @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(context, cd, cd.name(), isStrong));
+        classlink.addContent(getLink(new LinkInfoImpl(configuration,
+                context, cd).label(cd.name()).strong(isStrong)));
         return classlink;
     }
 
@@ -1916,14 +1189,14 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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(
-                context, cd, cd.name(), isStrong))));
+        contentTree.addContent(getLink(new LinkInfoImpl(configuration,
+                context, cd).label(cd.name()).strong(isStrong)));
     }
 
     /**
@@ -1934,34 +1207,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
     }
 
-    public void printText(String key) {
-        print(configuration.getText(key));
-    }
-
-    public void printText(String key, String a1) {
-        print(configuration.getText(key, a1));
-    }
-
-    public void printText(String key, String a1, String a2) {
-        print(configuration.getText(key, a1, a2));
-    }
-
-    public void strongText(String key) {
-        strong(configuration.getText(key));
-    }
-
-    public void strongText(String key, String a1) {
-        strong(configuration.getText(key, a1));
-    }
-
-    public void strongText(String key, String a1, String a2) {
-        strong(configuration.getText(key, a1, a2));
-    }
-
     /**
      * Get the link for the given member.
      *
@@ -1970,41 +1219,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
-    }
-
-    /**
-     * Print the link for the given member.
-     *
-     * @param context the id of the context where the link will be printed.
-     * @param classDoc the classDoc that we should link to.  This is not
-     *                 necessarily equal to doc.containingClass().  We may be
-     *                 inheriting comments.
-     * @param doc the member being linked to.
-     * @param label the label for the link.
-     * @param strong true if the link should be strong.
-     */
-    public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc,
-            String label, boolean strong) {
-        printDocLink(context, classDoc, doc, label, strong, false);
-    }
-
-    /**
-     * Print the link for the given member.
-     *
-     * @param context the id of the context where the link will be printed.
-     * @param classDoc the classDoc that we should link to.  This is not
-     *                 necessarily equal to doc.containingClass().  We may be
-     *                 inheriting comments.
-     * @param doc the member being linked to.
-     * @param label the label for the link.
-     * @param strong true if the link should be strong.
-     * @param isProperty true if the doc parameter is a JavaFX property.
-     */
-    public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc,
-            String label, boolean strong, boolean isProperty) {
-        print(getDocLink(context, classDoc, doc, label, strong, isProperty));
+    public Content getDocLink(LinkInfoImpl.Kind context, MemberDoc doc, String label) {
+        return getDocLink(context, doc.containingClass(), doc,
+                new StringContent(label));
     }
 
     /**
@@ -2016,8 +1233,8 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
     }
 
@@ -2033,12 +1250,16 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
     }
 
-        /**
+   /**
      * Return the link for the given member.
      *
      * @param context the id of the context where the link will be printed.
@@ -2051,18 +1272,28 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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()))) {
+            Util.isLinkable(classDoc, configuration))) {
             return label;
         } else if (doc instanceof ExecutableMemberDoc) {
             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return getLink(new LinkInfoImpl(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(context, classDoc,
-                doc.name(), label, strong));
+            return getLink(new LinkInfoImpl(configuration, context, classDoc)
+                .label(label).where(doc.name()).strong(strong));
         } else {
             return label;
         }
@@ -2079,27 +1310,23 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
+            Util.isLinkable(classDoc, configuration))) {
+            return label;
         } else if (doc instanceof ExecutableMemberDoc) {
-            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
-            return new RawHtml(getLink(new LinkInfoImpl(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(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;
         }
     }
 
-    public void anchor(ExecutableMemberDoc emd) {
-        anchor(getAnchor(emd));
-    }
-
     public String getAnchor(ExecutableMemberDoc emd) {
         return getAnchor(emd, false);
     }
@@ -2124,78 +1351,75 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         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();
         }
-        StringBuffer result = new StringBuffer();
-        boolean isplaintext = tagName.toLowerCase().equals("@linkplain");
-        String label = see.label();
-        label = (label.length() > 0)?
-            ((isplaintext) ? label :
-                 getCode() + label + getCodeEnd()):"";
+
         String seetext = replaceDocRootDir(see.text());
 
         //Check if @see is an href or "string"
         if (seetext.startsWith("<") || seetext.startsWith("\"")) {
-            result.append(seetext);
-            return result.toString();
+            return new RawHtml(seetext);
         }
 
+        boolean plain = tagName.equalsIgnoreCase("@linkplain");
+        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 = (isplaintext) ? seetext : getCode() + seetext + getCodeEnd();
+        Content text = plainOrCode(plain, new RawHtml(seetext));
 
         ClassDoc refClass = see.referencedClass();
         String refClassName = see.referencedClassName();
         MemberDoc refMem = see.referencedMember();
         String refMemName = see.referencedMemberName();
+
         if (refClass == null) {
             //@see is not referencing an included class
             PackageDoc refPackage = see.referencedPackage();
             if (refPackage != null && refPackage.isIncluded()) {
                 //@see is referencing an included package
-                String packageName = isplaintext ? refPackage.name() :
-                    getCode() + refPackage.name() + getCodeEnd();
-                result.append(getPackageLinkString(refPackage,
-                    label.length() == 0 ? packageName : label, false));
+                if (label.isEmpty())
+                    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, packageCrossLink = getCrossPackageLink(refClassName);
+                Content classCrossLink;
+                DocLink packageCrossLink = getCrossPackageLink(refClassName);
                 if (packageCrossLink != null) {
                     //Package cross link found
-                    result.append(getHyperLinkString(packageCrossLink, "",
-                        (label.length() == 0)? text : label, false));
+                    return getHyperLink(packageCrossLink,
+                        (label.isEmpty() ? text : label));
                 } else if ((classCrossLink = getCrossClassLink(refClassName,
-                        refMemName, label, false, "", ! isplaintext)) != null) {
-                    //Class cross link found (possiblly to a member in the class)
-                    result.append(classCrossLink);
+                        refMemName, label, false, "", !plain)) != null) {
+                    //Class cross link found (possibly to a member in the class)
+                    return classCrossLink;
                 } else {
                     //No cross link found so print warning
                     configuration.getDocletSpecificMsg().warning(see.position(), "doclet.see.class_or_package_not_found",
                             tagName, seetext);
-                    result.append((label.length() == 0)? text: label);
+                    return (label.isEmpty() ? text: label);
                 }
             }
         } else if (refMemName == null) {
             // Must be a class reference since refClass is not null and refMemName is null.
-            if (label.length() == 0) {
-                label = (isplaintext) ? refClass.name() : getCode() + refClass.name() + getCodeEnd();
-                result.append(getLink(new LinkInfoImpl(refClass, label)));
-            } else {
-                result.append(getLink(new LinkInfoImpl(refClass, label)));
+            if (label.isEmpty()) {
+                label = plainOrCode(plain, new StringContent(refClass.name()));
             }
+            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.
-            result.append((label.length() == 0)? text: label);
+            return (label.isEmpty() ? text: label);
         } else {
             // Must be a member reference since refClass is not null and refMemName is not null.
             // refMem is not null, so this @see tag must be referencing a valid member.
             ClassDoc containing = refMem.containingClass();
             if (see.text().trim().startsWith("#") &&
                 ! (containing.isPublic() ||
-                Util.isLinkable(containing, configuration()))) {
+                Util.isLinkable(containing, configuration))) {
                 // Since the link is relative and the holder is not even being
                 // documented, this must be an inherited link.  Redirect it.
                 // The current class either overrides the referenced member or
@@ -2220,24 +1444,16 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                     refMemName += ((ExecutableMemberDoc)refMem).signature();
                 }
             }
-            if (Configuration.getJavafxJavadoc()) {
-                int index;
-                if ((index = refMemName.indexOf("<")) != -1 ) {
-                    refMemName = refMemName.substring(0, index) + ")";
-                }
-            }
 
-            text = (isplaintext) ?
-                refMemName : getCode() + Util.escapeHtmlChars(refMemName) + getCodeEnd();
+            text = plainOrCode(plain, new StringContent(refMemName));
 
-            result.append(getDocLink(LinkInfoImpl.CONTEXT_SEE_TAG, containing,
-                refMem, (label.length() == 0)? text: label, false));
+            return getDocLink(LinkInfoImpl.Kind.SEE_TAG, containing,
+                refMem, (label.isEmpty() ? text: label), false);
         }
-        return result.toString();
     }
 
-    public void printInlineComment(Doc doc, Tag tag) {
-        printCommentTags(doc, tag.inlineTags(), false, false);
+    private Content plainOrCode(boolean plain, Content body) {
+        return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
     }
 
     /**
@@ -2248,11 +1464,7 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @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);
-    }
-
-    public void printInlineDeprecatedComment(Doc doc, Tag tag) {
-        printCommentTags(doc, tag.inlineTags(), true, false);
+        addCommentTags(doc, tag, tag.inlineTags(), false, false, htmltree);
     }
 
     /**
@@ -2266,10 +1478,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         addCommentTags(doc, tag.inlineTags(), true, false, htmltree);
     }
 
-    public void printSummaryComment(Doc doc) {
-        printSummaryComment(doc, doc.firstSentenceTags());
-    }
-
     /**
      * Adds the summary content.
      *
@@ -2280,10 +1488,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
     }
 
-    public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) {
-        printCommentTags(doc, firstSentenceTags, false, true);
-    }
-
     /**
      * Adds the summary content.
      *
@@ -2295,23 +1499,10 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         addCommentTags(doc, firstSentenceTags, false, true, htmltree);
     }
 
-    public void printSummaryDeprecatedComment(Doc doc) {
-        printCommentTags(doc, doc.firstSentenceTags(), true, true);
-    }
-
-    public void printSummaryDeprecatedComment(Doc doc, Tag tag) {
-        printCommentTags(doc, tag.firstSentenceTags(), true, true);
-    }
-
     public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
         addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree);
     }
 
-    public void printInlineComment(Doc doc) {
-        printCommentTags(doc, doc.inlineTags(), false, false);
-        p();
-    }
-
     /**
      * Adds the inline comment.
      *
@@ -2322,43 +1513,37 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
     }
 
-    public void printInlineDeprecatedComment(Doc doc) {
-        printCommentTags(doc, doc.inlineTags(), true, false);
-    }
-
-    private void printCommentTags(Doc doc, Tag[] tags, boolean depr, boolean first) {
-        if(configuration.nocomment){
-            return;
-        }
-        if (depr) {
-            italic();
-        }
-        String result = commentTagsToString(null, doc, tags, first);
-        print(result);
-        if (depr) {
-            italicEnd();
-        }
-        if (tags.length == 0) {
-            space();
-        }
+    /**
+     * Adds the comment tags.
+     *
+     * @param doc the doc for which the comment tags will be generated
+     * @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[] 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 sentenge tags should be added
+     * @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[] tags, boolean depr,
+    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);
@@ -2385,9 +1570,9 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      *               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);
@@ -2395,14 +1580,15 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             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") &&
@@ -2434,17 +1620,11 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                 if (isFirstSentence) {
                     text = removeNonInlineHtmlTags(text);
                 }
-                StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
-                StringBuffer textBuff = new StringBuffer();
-                while (lines.hasMoreTokens()) {
-                    StringBuilder line = new StringBuilder(lines.nextToken());
-                    Util.replaceTabs(configuration.sourcetab, line);
-                    textBuff.append(line.toString());
-                }
-                result.append(textBuff);
+                text = Util.replaceTabs(configuration, text);
+                result.addContent(new RawHtml(text));
             }
         }
-        return result.toString();
+        return result;
     }
 
     /**
@@ -2460,21 +1640,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
 
     /**
      * Suppose a piece of documentation has a relative link.  When you copy
-     * that documetation to another place such as the index or class-use page,
+     * that documentation to another place such as the index or class-use page,
      * that relative link will no longer work.  We should redirect those links
      * so that they will work again.
      * <p>
      * Here is the algorithm used to fix the link:
      * <p>
-     * <relative link> => docRoot + <relative path to file> + <relative link>
+     * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
      * <p>
      * For example, suppose com.sun.javadoc.RootDoc has this link:
-     * <a href="package-summary.html">The package Page</a>
+     * {@literal <a href="package-summary.html">The package Page</a> }
      * <p>
      * If this link appeared in the index, we would redirect
      * the link like this:
      *
-     * <a href="./com/sun/javadoc/package-summary.html">The package Page</a>
+     * {@literal <a href="./com/sun/javadoc/package-summary.html">The package Page</a>}
      *
      * @param doc the Doc object whose documentation is being written.
      * @param text the text being written.
@@ -2486,25 +1666,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
             return text;
         }
 
-        String redirectPathFromRoot;
+        DocPath redirectPathFromRoot;
         if (doc instanceof ClassDoc) {
-            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((ClassDoc) doc).containingPackage());
+            redirectPathFromRoot = DocPath.forPackage(((ClassDoc) doc).containingPackage());
         } else if (doc instanceof MemberDoc) {
-            redirectPathFromRoot = DirectoryManager.getDirectoryPath(((MemberDoc) doc).containingPackage());
+            redirectPathFromRoot = DocPath.forPackage(((MemberDoc) doc).containingPackage());
         } else if (doc instanceof PackageDoc) {
-            redirectPathFromRoot = DirectoryManager.getDirectoryPath((PackageDoc) doc);
+            redirectPathFromRoot = DocPath.forPackage((PackageDoc) doc);
         } else {
             return text;
         }
 
-        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
-            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
-        }
-
         //Redirect all relative links.
         int end, begin = text.toLowerCase().indexOf("<a");
         if(begin >= 0){
-            StringBuffer textBuff = new StringBuffer(text);
+            StringBuilder textBuff = new StringBuilder(text);
 
             while(begin >=0){
                 if (textBuff.length() > begin + 2 && ! Character.isWhitespace(textBuff.charAt(begin+2))) {
@@ -2526,22 +1702,21 @@ public class HtmlDocletWriter extends HtmlDocWriter {
                     //might be missing '>' character because the href has an inline tag.
                     break;
                 }
-                if(textBuff.substring(begin, end).indexOf("\"") != -1){
+                if (textBuff.substring(begin, end).indexOf("\"") != -1){
                     begin = textBuff.indexOf("\"", begin) + 1;
                     end = textBuff.indexOf("\"", begin +1);
-                    if(begin == 0 || end == -1){
+                    if (begin == 0 || end == -1){
                         //Link is missing a quote.
                         break;
                     }
                 }
                 String relativeLink = textBuff.substring(begin, end);
-                if(!(relativeLink.toLowerCase().startsWith("mailto:") ||
-                     relativeLink.toLowerCase().startsWith("http:") ||
-                     relativeLink.toLowerCase().startsWith("https:") ||
-                     relativeLink.toLowerCase().startsWith("file:"))){
-                     relativeLink = "{@"+(new DocRootTaglet()).getName() + "}"
-                        + redirectPathFromRoot
-                        + relativeLink;
+                if (!(relativeLink.toLowerCase().startsWith("mailto:") ||
+                        relativeLink.toLowerCase().startsWith("http:") ||
+                        relativeLink.toLowerCase().startsWith("https:") ||
+                        relativeLink.toLowerCase().startsWith("file:"))) {
+                    relativeLink = "{@"+(new DocRootTaglet()).getName() + "}/"
+                        + redirectPathFromRoot.resolve(relativeLink).getPath();
                     textBuff.replace(begin, end, relativeLink);
                 }
                 begin = textBuff.toString().toLowerCase().indexOf("<a", begin + 1);
@@ -2551,76 +1726,55 @@ public class HtmlDocletWriter extends HtmlDocWriter {
         return text;
     }
 
-    public String removeNonInlineHtmlTags(String text) {
-        if (text.indexOf('<') < 0) {
-            return text;
+    static final Set<String> blockTags = new HashSet<String>();
+    static {
+        for (HtmlTag t: HtmlTag.values()) {
+            if (t.blockType == HtmlTag.BlockType.BLOCK)
+                blockTags.add(t.value);
         }
-        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], "");
-        }
-        return text;
     }
 
-    public String replace(String text, String tobe, String by) {
-        while (true) {
-            int startindex = text.indexOf(tobe);
-            if (startindex < 0) {
-                return text;
+    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;
+        }
+
+        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 endindex = startindex + tobe.length();
-            StringBuilder replaced = new StringBuilder();
-            if (startindex > 0) {
-                replaced.append(text.substring(0, startindex));
+            int tagPos = currPos;
+            while (isHtmlTagLetterOrDigit(ch)) {
+                if (++currPos == len)
+                    break main;
+                ch = text.charAt(currPos);
             }
-            replaced.append(by);
-            if (text.length() > endindex) {
-                replaced.append(text.substring(endindex));
+            if (ch == '>' && blockTags.contains(text.substring(tagPos, currPos).toLowerCase())) {
+                result.append(text, startPos, lessThanPos);
+                startPos = currPos + 1;
             }
-            text = replaced.toString();
+            lessThanPos = text.indexOf('<', currPos);
         }
+        result.append(text.substring(startPos));
+
+        return result.toString();
     }
 
-    public void printStyleSheetProperties() {
-        String filename = configuration.stylesheetfile;
-        if (filename.length() > 0) {
-            File stylefile = new File(filename);
-            String parent = stylefile.getParent();
-            filename = (parent == null)?
-                filename:
-                filename.substring(parent.length() + 1);
-        } else {
-            filename = "stylesheet.css";
-        }
-        filename = relativePath + filename;
-        link("REL =\"stylesheet\" TYPE=\"text/css\" HREF=\"" +
-                 filename + "\" " + "TITLE=\"Style\"");
+    private static boolean isHtmlTagLetterOrDigit(char ch) {
+        return ('a' <= ch && ch <= 'z') ||
+                ('A' <= ch && ch <= 'Z') ||
+                ('1' <= ch && ch <= '6');
     }
 
     /**
@@ -2629,22 +1783,32 @@ public class HtmlDocletWriter extends HtmlDocWriter {
      * @return an HtmlTree for the lINK tag which provides the stylesheet location
      */
     public HtmlTree getStyleSheetProperties() {
-        String filename = configuration.stylesheetfile;
-        if (filename.length() > 0) {
-            File stylefile = new File(filename);
-            String parent = stylefile.getParent();
-            filename = (parent == null)?
-                filename:
-                filename.substring(parent.length() + 1);
+        String stylesheetfile = configuration.stylesheetfile;
+        DocPath stylesheet;
+        if (stylesheetfile.isEmpty()) {
+            stylesheet = DocPaths.STYLESHEET;
         } else {
-            filename = "stylesheet.css";
+            DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
+            stylesheet = DocPath.create(file.getName());
         }
-        filename = relativePath + filename;
-        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
+        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
+                pathToRoot.resolve(stylesheet).getPath(),
+                "Style");
         return link;
     }
 
     /**
+     * Returns a link to the JavaScript file.
+     *
+     * @return an HtmlTree for the Script tag which provides the JavaScript location
+     */
+    public HtmlTree getScriptProperties() {
+        HtmlTree script = HtmlTree.SCRIPT("text/javascript",
+                pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
+        return script;
+    }
+
+    /**
      * According to
      * <cite>The Java™ Language Specification</cite>,
      * all the outer classes and static nested classes are core classes.
@@ -2654,15 +1818,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Write the annotatation types for the given packageDoc.
-     *
-     * @param packageDoc the package to write annotations for.
-     */
-    public void writeAnnotationInfo(PackageDoc packageDoc) {
-        writeAnnotationInfo(packageDoc, packageDoc.annotations());
-    }
-
-    /**
      * Adds the annotatation types for the given packageDoc.
      *
      * @param packageDoc the package to write annotations for.
@@ -2674,18 +1829,22 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Write the annotatation types for the given doc.
+     * Add the annotation types of the executable receiver.
      *
-     * @param doc the doc to write annotations for.
+     * @param method the executable to write the receiver annotations for.
+     * @param descList list of annotation description.
+     * @param htmltree the documentation tree to which the annotation info will be
+     *        added
      */
-    public void writeAnnotationInfo(ProgramElementDoc doc) {
-        writeAnnotationInfo(doc, doc.annotations());
+    public void addReceiverAnnotationInfo(ExecutableMemberDoc method, AnnotationDesc[] descList,
+            Content htmltree) {
+        addAnnotationInfo(0, method, descList, false, htmltree);
     }
 
     /**
      * Adds the annotatation types for the given doc.
      *
-     * @param packageDoc the package to write annotations for
+     * @param doc the package to write annotations for
      * @param htmltree the content tree to which the annotation types will be added
      */
     public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) {
@@ -2693,17 +1852,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Write the annotatation types for the given doc and parameter.
-     *
-     * @param indent the number of spaced to indent the parameters.
-     * @param doc the doc to write annotations for.
-     * @param param the parameter to write annotations for.
-     */
-    public boolean writeAnnotationInfo(int indent, Doc doc, Parameter param) {
-        return writeAnnotationInfo(indent, doc, param.annotations(), false);
-    }
-
-    /**
      * Add the annotatation types for the given doc and parameter.
      *
      * @param indent the number of spaces to indent the parameters.
@@ -2717,16 +1865,6 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Write the annotatation types for the given doc.
-     *
-     * @param doc the doc to write annotations for.
-     * @param descList the array of {@link AnnotationDesc}.
-     */
-    private void writeAnnotationInfo(Doc doc, AnnotationDesc[] descList) {
-        writeAnnotationInfo(0, doc, descList, true);
-    }
-
-    /**
      * Adds the annotatation types for the given doc.
      *
      * @param doc the doc to write annotations for.
@@ -2740,142 +1878,249 @@ public class HtmlDocletWriter extends HtmlDocWriter {
     }
 
     /**
-     * Write 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.
      * @param descList the array of {@link AnnotationDesc}.
+     * @param htmltree the documentation tree to which the annotation info will be
+     *        added
      */
-    private boolean writeAnnotationInfo(int indent, Doc doc, AnnotationDesc[] descList, boolean lineBreak) {
-        List<String> annotations = getAnnotations(indent, descList, lineBreak);
-        if (annotations.size() == 0) {
+    private boolean addAnnotationInfo(int indent, Doc doc,
+            AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
+        List<Content> annotations = getAnnotations(indent, descList, lineBreak);
+        String sep ="";
+        if (annotations.isEmpty()) {
             return false;
         }
-        fontNoNewLine("-1");
-        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
-            print(iter.next());
+        for (Content annotation: annotations) {
+            htmltree.addContent(sep);
+            htmltree.addContent(annotation);
+            sep = " ";
         }
-        fontEnd();
         return true;
     }
 
-    /**
-     * Adds the annotatation types for the given doc.
+   /**
+     * Return the string representations of 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.
      * @param descList the array of {@link AnnotationDesc}.
-     * @param htmltree the documentation tree to which the annotation info will be
-     *        added
+     * @param linkBreak if true, add new line between each member value.
+     * @return an array of strings representing the annotations being
+     *         documented.
      */
-    private boolean addAnnotationInfo(int indent, Doc doc,
-            AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
-        List<String> annotations = getAnnotations(indent, descList, lineBreak);
-        if (annotations.size() == 0) {
-            return false;
-        }
-        Content annotationContent;
-        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
-            annotationContent = new RawHtml(iter.next());
-            htmltree.addContent(annotationContent);
-        }
-        return true;
+    private List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
+        return getAnnotations(indent, descList, linkBreak, true);
     }
 
-   /**
+    /**
      * Return the string representations of the annotation types for
      * the given doc.
      *
+     * A {@code null} {@code elementType} indicates that all the
+     * annotations should be returned without any filtering.
+     *
      * @param indent the number of extra spaces to indent the annotations.
      * @param descList the array of {@link AnnotationDesc}.
      * @param linkBreak if true, add new line between each member value.
+     * @param elementType the type of targeted element (used for filtering
+     *        type annotations from declaration annotations)
      * @return an array of strings representing the annotations being
      *         documented.
      */
-    private List<String> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak) {
-        List<String> results = new ArrayList<String>();
-        StringBuffer annotation;
+    public List<Content> getAnnotations(int indent, AnnotationDesc[] descList, boolean linkBreak,
+            boolean isJava5DeclarationLocation) {
+        List<Content> results = new ArrayList<Content>();
+        ContentBuilder annotation;
         for (int i = 0; i < descList.length; i++) {
             AnnotationTypeDoc annotationDoc = descList[i].annotationType();
-            if (! Util.isDocumentedAnnotation(annotationDoc)){
+            // If an annotation is not documented, do not add it to the list. If
+            // the annotation is of a repeatable type, and if it is not documented
+            // and also if its container annotation is not documented, do not add it
+            // to the list. If an annotation of a repeatable type is not documented
+            // but its container is documented, it will be added to the list.
+            if (! Util.isDocumentedAnnotation(annotationDoc) &&
+                    (!isAnnotationDocumented && !isContainerDocumented)) {
                 continue;
             }
-            annotation = new StringBuffer();
-            LinkInfoImpl linkInfo = new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_ANNOTATION, annotationDoc);
-            linkInfo.label = "@" + annotationDoc.name();
-            annotation.append(getLink(linkInfo));
+            /* TODO: check logic here to correctly handle declaration
+             * and type annotations.
+            if  (Util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) {
+                continue;
+            }*/
+            annotation = new ContentBuilder();
+            isAnnotationDocumented = false;
+            LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                LinkInfoImpl.Kind.ANNOTATION, annotationDoc);
             AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues();
-            if (pairs.length > 0) {
-                annotation.append('(');
+            // If the annotation is synthesized, do not print the container.
+            if (descList[i].isSynthesized()) {
                 for (int j = 0; j < pairs.length; j++) {
-                    if (j > 0) {
-                        annotation.append(",");
-                        if (linkBreak) {
-                            annotation.append(DocletConstants.NL);
-                            int spaces = annotationDoc.name().length() + 2;
-                            for (int k = 0; k < (spaces + indent); k++) {
-                                annotation.append(' ');
-                            }
-                        }
-                    }
-                    annotation.append(getDocLink(LinkInfoImpl.CONTEXT_ANNOTATION,
-                        pairs[j].element(), pairs[j].element().name(), false));
-                    annotation.append('=');
                     AnnotationValue annotationValue = pairs[j].value();
                     List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
                     if (annotationValue.value() instanceof AnnotationValue[]) {
                         AnnotationValue[] annotationArray =
-                            (AnnotationValue[]) annotationValue.value();
-                        for (int k = 0; k < annotationArray.length; k++) {
-                            annotationTypeValues.add(annotationArray[k]);
-                        }
+                                (AnnotationValue[]) annotationValue.value();
+                        annotationTypeValues.addAll(Arrays.asList(annotationArray));
                     } else {
                         annotationTypeValues.add(annotationValue);
                     }
-                    annotation.append(annotationTypeValues.size() == 1 ? "" : "{");
-                    for (Iterator<AnnotationValue> iter = annotationTypeValues.iterator(); iter.hasNext(); ) {
-                        annotation.append(annotationValueToString(iter.next()));
-                        annotation.append(iter.hasNext() ? "," : "");
+                    String sep = "";
+                    for (AnnotationValue av : annotationTypeValues) {
+                        annotation.addContent(sep);
+                        annotation.addContent(annotationValueToContent(av));
+                        sep = " ";
                     }
-                    annotation.append(annotationTypeValues.size() == 1 ? "" : "}");
                 }
-                annotation.append(")");
             }
-            annotation.append(linkBreak ? DocletConstants.NL : "");
-            results.add(annotation.toString());
+            else if (isAnnotationArray(pairs)) {
+                // If the container has 1 or more value defined and if the
+                // repeatable type annotation is not documented, do not print
+                // the container.
+                if (pairs.length == 1 && isAnnotationDocumented) {
+                    AnnotationValue[] annotationArray =
+                            (AnnotationValue[]) (pairs[0].value()).value();
+                    List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
+                    annotationTypeValues.addAll(Arrays.asList(annotationArray));
+                    String sep = "";
+                    for (AnnotationValue av : annotationTypeValues) {
+                        annotation.addContent(sep);
+                        annotation.addContent(annotationValueToContent(av));
+                        sep = " ";
+                    }
+                }
+                // If the container has 1 or more value defined and if the
+                // repeatable type annotation is not documented, print the container.
+                else {
+                    addAnnotations(annotationDoc, linkInfo, annotation, pairs,
+                        indent, false);
+                }
+            }
+            else {
+                addAnnotations(annotationDoc, linkInfo, annotation, pairs,
+                        indent, linkBreak);
+            }
+            annotation.addContent(linkBreak ? DocletConstants.NL : "");
+            results.add(annotation);
         }
         return results;
     }
 
-    private String annotationValueToString(AnnotationValue annotationValue) {
+    /**
+     * Add annotation to the annotation string.
+     *
+     * @param annotationDoc the annotation being documented
+     * @param linkInfo the information about the link
+     * @param annotation the annotation string to which the annotation will be added
+     * @param pairs annotation type element and value pairs
+     * @param indent the number of extra spaces to indent the annotations.
+     * @param linkBreak if true, add new line between each member value
+     */
+    private void addAnnotations(AnnotationTypeDoc annotationDoc, LinkInfoImpl linkInfo,
+            ContentBuilder annotation, AnnotationDesc.ElementValuePair[] pairs,
+            int indent, boolean linkBreak) {
+        linkInfo.label = new StringContent("@" + annotationDoc.name());
+        annotation.addContent(getLink(linkInfo));
+        if (pairs.length > 0) {
+            annotation.addContent("(");
+            for (int j = 0; j < pairs.length; j++) {
+                if (j > 0) {
+                    annotation.addContent(",");
+                    if (linkBreak) {
+                        annotation.addContent(DocletConstants.NL);
+                        int spaces = annotationDoc.name().length() + 2;
+                        for (int k = 0; k < (spaces + indent); k++) {
+                            annotation.addContent(" ");
+                        }
+                    }
+                }
+                annotation.addContent(getDocLink(LinkInfoImpl.Kind.ANNOTATION,
+                        pairs[j].element(), pairs[j].element().name(), false));
+                annotation.addContent("=");
+                AnnotationValue annotationValue = pairs[j].value();
+                List<AnnotationValue> annotationTypeValues = new ArrayList<AnnotationValue>();
+                if (annotationValue.value() instanceof AnnotationValue[]) {
+                    AnnotationValue[] annotationArray =
+                            (AnnotationValue[]) annotationValue.value();
+                    annotationTypeValues.addAll(Arrays.asList(annotationArray));
+                } else {
+                    annotationTypeValues.add(annotationValue);
+                }
+                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "{");
+                String sep = "";
+                for (AnnotationValue av : annotationTypeValues) {
+                    annotation.addContent(sep);
+                    annotation.addContent(annotationValueToContent(av));
+                    sep = ",";
+                }
+                annotation.addContent(annotationTypeValues.size() == 1 ? "" : "}");
+                isContainerDocumented = false;
+            }
+            annotation.addContent(")");
+        }
+    }
+
+    /**
+     * Check if the annotation contains an array of annotation as a value. This
+     * check is to verify if a repeatable type annotation is present or not.
+     *
+     * @param pairs annotation type element and value pairs
+     *
+     * @return true if the annotation contains an array of annotation as a value.
+     */
+    private boolean isAnnotationArray(AnnotationDesc.ElementValuePair[] pairs) {
+        AnnotationValue annotationValue;
+        for (int j = 0; j < pairs.length; j++) {
+            annotationValue = pairs[j].value();
+            if (annotationValue.value() instanceof AnnotationValue[]) {
+                AnnotationValue[] annotationArray =
+                        (AnnotationValue[]) annotationValue.value();
+                if (annotationArray.length > 1) {
+                    if (annotationArray[0].value() instanceof AnnotationDesc) {
+                        AnnotationTypeDoc annotationDoc =
+                                ((AnnotationDesc) annotationArray[0].value()).annotationType();
+                        isContainerDocumented = true;
+                        if (Util.isDocumentedAnnotation(annotationDoc)) {
+                            isAnnotationDocumented = true;
+                        }
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    private Content annotationValueToContent(AnnotationValue annotationValue) {
         if (annotationValue.value() instanceof Type) {
             Type type = (Type) annotationValue.value();
             if (type.asClassDoc() != null) {
-                LinkInfoImpl linkInfo = new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_ANNOTATION, type);
-                    linkInfo.label = (type.asClassDoc().isIncluded() ?
-                        type.typeName() :
-                        type.qualifiedTypeName()) + type.dimension() + ".class";
+                LinkInfoImpl linkInfo = new LinkInfoImpl(configuration,
+                    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);
-            StringBuffer buf = new StringBuffer();
-            for (Iterator<String> iter = list.iterator(); iter.hasNext(); ) {
-                buf.append(iter.next());
+            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());
          }
     }
 
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
index 8f32789..8918889 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, 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
@@ -28,20 +28,25 @@ package com.sun.tools.doclets.formats.html;
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate serialized form for serializable fields.
  * Documentation denoted by the tags <code>serial</code> and
  * <code>serialField</code> is processed.
  *
+ *  <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 Joe Fialli
  * @author Bhavesh Patel (Modified)
  */
 public class HtmlSerialFieldWriter extends FieldWriterImpl
-    implements SerializedFormWriter.SerialFieldWriter {
+        implements SerializedFormWriter.SerialFieldWriter {
     ProgramElementDoc[] members = null;
 
     private boolean printedOverallAnchor = false;
@@ -55,18 +60,6 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
         return Arrays.asList(cd.serializableFields());
     }
 
-    protected void printTypeLinkNoDimension(Type type) {
-        ClassDoc cd = type.asClassDoc();
-        //Linking to package private classes in serialized for causes
-        //broken links.  Don't link to them.
-        if (type.isPrimitive() || cd.isPackagePrivate()) {
-            print(type.typeName());
-        } else {
-            writer.printLink(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_SERIAL_MEMBER, type));
-        }
-    }
-
     /**
      * Return the header for serializable fields section.
      *
@@ -121,10 +114,10 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
     /**
      * Add the member header.
      *
-     * @param fieldsType the class document to be listed
-     * @param fieldTypeStr the string for the filed type to be documented
+     * @param fieldType the class document to be listed
+     * @param fieldTypeStr the string for the field type to be documented
      * @param fieldDimensions the dimensions of the field string to be added
-     * @param firldName name of the field to be added
+     * @param fieldName name of the field to be added
      * @param contentTree the content tree to which the member header will be added
      */
     public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr,
@@ -136,8 +129,8 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
         if (fieldType == null) {
             pre.addContent(fieldTypeStr);
         } else {
-            Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
-                    LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
+            Content fieldContent = writer.getLink(new LinkInfoImpl(
+                    configuration, LinkInfoImpl.Kind.SERIAL_MEMBER, fieldType));
             pre.addContent(fieldContent);
         }
         pre.addContent(fieldDimensions + " ");
@@ -193,17 +186,13 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
      * @param contentTree the tree to which the member tags info will be added
      */
     public void addMemberTags(FieldDoc field, Content contentTree) {
-        TagletOutputImpl output = new TagletOutputImpl("");
-        TagletWriter.genTagOuput(configuration().tagletManager, field,
-                configuration().tagletManager.getCustomTags(field),
-                writer.getTagletWriterInstance(false), output);
-        String outputString = output.toString().trim();
+        Content tagContent = new ContentBuilder();
+        TagletWriter.genTagOuput(configuration.tagletManager, field,
+                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?
     }
 
     /**
@@ -215,7 +204,7 @@ public class HtmlSerialFieldWriter extends FieldWriterImpl
      * @return true if overview details need to be printed
      */
     public boolean shouldPrintOverview(FieldDoc field) {
-        if (!configuration().nocomment) {
+        if (!configuration.nocomment) {
             if(!field.commentText().isEmpty() ||
                     writer.hasSerializationOverviewTags(field))
                 return true;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
index 6ce0120..4e5da21 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -26,14 +26,19 @@
 package com.sun.tools.doclets.formats.html;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate serialized form for Serializable/Externalizable methods.
  * Documentation denoted by the <code>serialData</code> tag is processed.
  *
+ *  <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 Joe Fialli
  * @author Bhavesh Patel (Modified)
  */
@@ -141,19 +146,15 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
      * @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 =
-            ConfigurationImpl.getInstance().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) {
@@ -161,14 +162,4 @@ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
                 method.containingClass().qualifiedName(), method.name());
         }
     }
-
-    protected void printTypeLinkNoDimension(Type type) {
-        ClassDoc cd = type.asClassDoc();
-        if (type.isPrimitive() || cd.isPackagePrivate()) {
-            print(type.typeName());
-        } else {
-            writer.printLink(new LinkInfoImpl(
-                LinkInfoImpl.CONTEXT_SERIAL_MEMBER,type));
-        }
-    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
index 3e4b968..abad36d 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
@@ -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
@@ -25,14 +25,24 @@
 
 package com.sun.tools.doclets.formats.html;
 
-import com.sun.tools.doclets.internal.toolkit.util.links.*;
+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.*;
 
 /**
  * A factory that returns a link given the information about it.
  *
+ *  <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
  */
@@ -47,16 +57,16 @@ public class LinkFactoryImpl extends LinkFactory {
     /**
      * {@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.
@@ -66,60 +76,94 @@ public class LinkFactoryImpl extends LinkFactory {
                     classLinkInfo.type != null &&
                     !classDoc.qualifiedTypeName().equals(classLinkInfo.type.qualifiedTypeName())) :
             "";
-        StringBuffer label = new StringBuffer(
-            classLinkInfo.getClassLinkLabel(m_writer.configuration));
-        classLinkInfo.displayLength += label.length();
-        Configuration configuration = ConfigurationImpl.getInstance();
-        LinkOutputImpl linkOutput = new LinkOutputImpl();
+        Content label = classLinkInfo.getClassLinkLabel(m_writer.configuration);
+        Configuration configuration = m_writer.configuration;
+        Content link = new ContentBuilder();
         if (classDoc.isIncluded()) {
             if (configuration.isGeneratedDoc(classDoc)) {
-                String filename = pathString(classLinkInfo);
+                DocPath filename = getPath(classLinkInfo);
                 if (linkInfo.linkToSelf ||
-                                !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
-                        linkOutput.append(m_writer.getHyperLinkString(filename,
-                            classLinkInfo.where, label.toString(),
+                                !(DocPath.forName(classDoc)).equals(m_writer.filename)) {
+                        link.addContent(m_writer.getHyperLink(
+                                filename.fragment(classLinkInfo.where),
+                            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(linkInfo.getContext(),
-            typeParam);
+        LinkInfoImpl typeLinkInfo = new LinkInfoImpl(m_writer.configuration,
+                ((LinkInfoImpl) linkInfo).getContext(), typeParam);
         typeLinkInfo.excludeTypeBounds = linkInfo.excludeTypeBounds;
         typeLinkInfo.excludeTypeParameterLinks = linkInfo.excludeTypeParameterLinks;
         typeLinkInfo.linkToSelf = linkInfo.linkToSelf;
-        LinkOutput output = getLinkOutput(typeLinkInfo);
-        ((LinkInfoImpl) linkInfo).displayLength += typeLinkInfo.displayLength;
-        return output;
+        typeLinkInfo.isJava5DeclarationLocation = false;
+        return getLink(typeLinkInfo);
+    }
+
+    protected Content getTypeAnnotationLink(LinkInfo linkInfo,
+            AnnotationDesc annotation) {
+        throw new RuntimeException("Not implemented yet!");
+    }
+
+    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 links;
+        }
+
+        if (annotations.length == 0)
+            return links;
+
+        List<Content> annos = m_writer.getAnnotations(0, annotations, false, linkInfo.isJava5DeclarationLocation);
+
+        boolean isFirst = true;
+        for (Content anno : annos) {
+            if (!isFirst) {
+                links.addContent(" ");
+            }
+            links.addContent(anno);
+            isFirst = false;
+        }
+        if (!annos.isEmpty()) {
+            links.addContent(" ");
+        }
+
+        return links;
     }
 
     /**
@@ -129,10 +173,10 @@ public class LinkFactoryImpl extends LinkFactory {
      * @return the tool tip for the appropriate class.
      */
     private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) {
-        Configuration configuration = ConfigurationImpl.getInstance();
+        Configuration configuration = m_writer.configuration;
         if (isTypeLink) {
             return configuration.getText("doclet.Href_Type_Param_Title",
-            classDoc.name());
+                classDoc.name());
         } else if (classDoc.isInterface()){
             return configuration.getText("doclet.Href_Interface_Title",
                 Util.getPackageName(classDoc.containingPackage()));
@@ -155,18 +199,13 @@ public class LinkFactoryImpl extends LinkFactory {
      * "../../java/lang/Object.html"
      *
      * @param linkInfo the information about the link.
-     * @param fileName the file name, to which path string is.
      */
-    private String pathString(LinkInfoImpl linkInfo) {
-        if (linkInfo.context == LinkInfoImpl.PACKAGE_FRAME) {
+    private DocPath getPath(LinkInfoImpl linkInfo) {
+        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 linkInfo.classDoc.name() + ".html";
+            return DocPath.forName(linkInfo.classDoc);
         }
-        StringBuffer buf = new StringBuffer(m_writer.relativePath);
-        buf.append(DirectoryManager.getPathToPackage(
-            linkInfo.classDoc.containingPackage(),
-            linkInfo.classDoc.name() + ".html"));
-        return buf.toString();
+        return m_writer.pathToRoot.resolve(DocPath.forClass(linkInfo.classDoc));
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
index c9a176c..7e3b604 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
@@ -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
@@ -27,175 +27,195 @@
 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.*;
 
+/**
+ *  <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 LinkInfoImpl extends LinkInfo {
 
-    /**
-     * Indicate that the link appears in a class list.
-     */
-    public static final int ALL_CLASSES_FRAME = 1;
-
-    /**
-     * Indicate that the link appears in a class documentation.
-     */
-    public static final int CONTEXT_CLASS = 2;
-
-    /**
-     * Indicate that the link appears in member documentation.
-     */
-    public static final int CONTEXT_MEMBER = 3;
-
-    /**
-     * Indicate that the link appears in class use documentation.
-     */
-    public static final int CONTEXT_CLASS_USE = 4;
-
-    /**
-     * Indicate that the link appears in index documentation.
-     */
-    public static final int CONTEXT_INDEX = 5;
-
-    /**
-     * Indicate that the link appears in constant value summary.
-     */
-    public static final int CONTEXT_CONSTANT_SUMMARY = 6;
-
-    /**
-     * Indicate that the link appears in serialized form documentation.
-     */
-    public static final int CONTEXT_SERIALIZED_FORM = 7;
-
-    /**
-     * Indicate that the link appears in serial member documentation.
-     */
-    public static final int CONTEXT_SERIAL_MEMBER = 8;
-
-    /**
-     * Indicate that the link appears in package documentation.
-     */
-    public static final int CONTEXT_PACKAGE = 9;
-
-    /**
-     * Indicate that the link appears in see tag documentation.
-     */
-    public static final int CONTEXT_SEE_TAG = 10;
-
-    /**
-     * Indicate that the link appears in value tag documentation.
-     */
-    public static final int CONTEXT_VALUE_TAG = 11;
-
-    /**
-     * Indicate that the link appears in tree documentation.
-     */
-    public static final int CONTEXT_TREE = 12;
-
-    /**
-     * Indicate that the link appears in a class list.
-     */
-    public static final int PACKAGE_FRAME = 13;
-
-    /**
-     * The header in the class documentation.
-     */
-    public static final int CONTEXT_CLASS_HEADER = 14;
-
-    /**
-     * The signature in the class documentation.
-     */
-    public static final int CONTEXT_CLASS_SIGNATURE = 15;
-
-    /**
-     * The return type of a method.
-     */
-    public static final int CONTEXT_RETURN_TYPE = 16;
-
-    /**
-     * The return type of a method in a member summary.
-     */
-    public static final int CONTEXT_SUMMARY_RETURN_TYPE = 17;
-
-    /**
-     * The type of a method/constructor parameter.
-     */
-    public static final int CONTEXT_EXECUTABLE_MEMBER_PARAM = 18;
-
-    /**
-     * Super interface links.
-     */
-    public static final int CONTEXT_SUPER_INTERFACES = 19;
-
-    /**
-     * Implemented interface links.
-     */
-    public static final int CONTEXT_IMPLEMENTED_INTERFACES = 20;
-
-    /**
-     * Implemented class links.
-     */
-    public static final int CONTEXT_IMPLEMENTED_CLASSES = 21;
-
-    /**
-     * Subinterface links.
-     */
-    public static final int CONTEXT_SUBINTERFACES = 22;
-
-    /**
-     * Subclasses links.
-     */
-    public static final int CONTEXT_SUBCLASSES = 23;
-
-    /**
-     * The signature in the class documentation (implements/extends portion).
-     */
-    public static final int CONTEXT_CLASS_SIGNATURE_PARENT_NAME = 24;
-
-    /**
-     * The header for method documentation copied from parent.
-     */
-    public static final int CONTEXT_METHOD_DOC_COPY = 26;
-
-    /**
-     * Method "specified by" link.
-     */
-    public static final int CONTEXT_METHOD_SPECIFIED_BY = 27;
-
-    /**
-     * Method "overrides" link.
-     */
-    public static final int CONTEXT_METHOD_OVERRIDES = 28;
-
-    /**
-     * Annotation link.
-     */
-    public static final int CONTEXT_ANNOTATION = 29;
-
-    /**
-     * The header for field documentation copied from parent.
-     */
-    public static final int CONTEXT_FIELD_DOC_COPY = 30;
-
-    /**
-     * The parent nodes int the class tree.
-     */
-    public static final int CONTEXT_CLASS_TREE_PARENT = 31;
-
-    /**
-     * The type parameters of a method or constructor.
-     */
-    public static final int CONTEXT_MEMBER_TYPE_PARAMS = 32;
+    public enum Kind {
+        DEFAULT,
+
+        /**
+         * Indicate that the link appears in a class list.
+         */
+        ALL_CLASSES_FRAME,
+
+        /**
+         * Indicate that the link appears in a class documentation.
+         */
+        CLASS,
+
+        /**
+         * Indicate that the link appears in member documentation.
+         */
+        MEMBER,
+
+        /**
+         * Indicate that the link appears in class use documentation.
+         */
+        CLASS_USE,
+
+        /**
+         * Indicate that the link appears in index documentation.
+         */
+        INDEX,
+
+        /**
+         * Indicate that the link appears in constant value summary.
+         */
+        CONSTANT_SUMMARY,
+
+        /**
+         * Indicate that the link appears in serialized form documentation.
+         */
+        SERIALIZED_FORM,
+
+        /**
+         * Indicate that the link appears in serial member documentation.
+         */
+        SERIAL_MEMBER,
+
+        /**
+         * Indicate that the link appears in package documentation.
+         */
+        PACKAGE,
+
+        /**
+         * Indicate that the link appears in see tag documentation.
+         */
+        SEE_TAG,
+
+        /**
+         * Indicate that the link appears in value tag documentation.
+         */
+        VALUE_TAG,
+
+        /**
+         * Indicate that the link appears in tree documentation.
+         */
+        TREE,
+
+        /**
+         * Indicate that the link appears in a class list.
+         */
+        PACKAGE_FRAME,
+
+        /**
+         * The header in the class documentation.
+         */
+        CLASS_HEADER,
+
+        /**
+         * 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.
+         */
+        SUMMARY_RETURN_TYPE,
+
+        /**
+         * The type of a method/constructor parameter.
+         */
+        EXECUTABLE_MEMBER_PARAM,
+
+        /**
+         * Super interface links.
+         */
+        SUPER_INTERFACES,
+
+        /**
+         * Implemented interface links.
+         */
+        IMPLEMENTED_INTERFACES,
+
+        /**
+         * Implemented class links.
+         */
+        IMPLEMENTED_CLASSES,
+
+        /**
+         * Subinterface links.
+         */
+        SUBINTERFACES,
+
+        /**
+         * Subclasses links.
+         */
+        SUBCLASSES,
+
+        /**
+         * The signature in the class documentation (implements/extends portion).
+         */
+        CLASS_SIGNATURE_PARENT_NAME,
+
+        /**
+         * The header for method documentation copied from parent.
+         */
+        METHOD_DOC_COPY,
+
+        /**
+         * Method "specified by" link.
+         */
+        METHOD_SPECIFIED_BY,
+
+        /**
+         * Method "overrides" link.
+         */
+        METHOD_OVERRIDES,
+
+        /**
+         * Annotation link.
+         */
+        ANNOTATION,
+
+        /**
+         * The header for field documentation copied from parent.
+         */
+        FIELD_DOC_COPY,
+
+        /**
+         * The parent nodes in the class tree.
+         */
+        CLASS_TREE_PARENT,
+
+        /**
+         * The type parameters of a method or constructor.
+         */
+        MEMBER_TYPE_PARAMS,
+
+        /**
+         * Indicate that the link appears in class use documentation.
+         */
+        CLASS_USE_HEADER,
+
+        /**
+         * The header for property documentation copied from parent.
+         */
+        PROPERTY_DOC_COPY
+    }
 
-    /**
-     * Indicate that the link appears in class use documentation.
-     */
-    public static final int CONTEXT_CLASS_USE_HEADER = 33;
+    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 #.
@@ -205,166 +225,127 @@ public class LinkInfoImpl extends LinkInfo {
     /**
      * String style of text defined in style sheet.
      */
-    public String styleName ="";
+    public String styleName = "";
 
     /**
-     * The valueof the target.
+     * The value of the target.
      */
     public String target = "";
 
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param label      the label for the link.
-     * @param target     the value of the target attribute.
+     * @param context               the context of the link.
+     * @param executableMemberDoc   the member to link to.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String label,
-            String target){
-        this.classDoc = classDoc;
-        this.label = label;
-        this.target = target;
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, ExecutableMemberDoc executableMemberDoc) {
+        this.configuration = configuration;
+        this.executableMemberDoc = executableMemberDoc;
         setContext(context);
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @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 (int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong, String styleName){
-        this.classDoc = classDoc;
-        this.where = where;
-        this.label = label;
-        this.isStrong = isStrong;
-        this.styleName = styleName;
-        setContext(context);
+    protected Content newContent() {
+        return new ContentBuilder();
     }
 
     /**
      * Construct a LinkInfo object.
      *
+     * @param configuration the configuration data for the doclet
      * @param context    the context of the link.
      * @param classDoc   the class to link to.
-     * @param where      the value of the marker #.
-     * @param label      the label for the link.
-     * @param isStrong       true if the link should be strong.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
-            boolean isStrong){
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, ClassDoc classDoc) {
+        this.configuration = configuration;
         this.classDoc = classDoc;
-        this.where = where;
-        this.label = label;
-        this.isStrong = isStrong;
         setContext(context);
     }
 
     /**
      * Construct a LinkInfo object.
      *
-     * @param classDoc   the class to link to.
-     * @param label      the label for the link.
+     * @param configuration the configuration data for the doclet
+     * @param context    the context of the link.
+     * @param type       the class to link to.
      */
-    public LinkInfoImpl (ClassDoc classDoc, String label){
-        this.classDoc = classDoc;
-        this.label = label;
+    public LinkInfoImpl(ConfigurationImpl configuration,
+            Kind context, Type type) {
+        this.configuration = configuration;
+        this.type = type;
         setContext(context);
     }
 
+
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param context               the context of the link.
-     * @param executableMemberDoc   the member to link to.
-     * @param isStrong                true if the link should be strong.
+     * Set the label for the link.
+     * @param label plain-text label for the link
      */
-    public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
-            boolean isStrong){
-        this.executableMemberDoc = executableMemberDoc;
-        this.isStrong = isStrong;
-        setContext(context);
+    public LinkInfoImpl label(String label) {
+        this.label = new StringContent(label);
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param context    the context of the link.
-     * @param classDoc   the class to link to.
-     * @param isStrong       true if the link should be strong.
+     * Set the label for the link.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isStrong){
-        this.classDoc = classDoc;
-        this.isStrong = isStrong;
-        setContext(context);
+    public LinkInfoImpl label(Content label) {
+        this.label = label;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @param context    the context of the link.
-     * @param type       the class to link to.
+     * Set whether or not the link should be strong.
      */
-    public LinkInfoImpl (int context, Type type){
-        this.type = type;
-        setContext(context);
+    public LinkInfoImpl strong(boolean strong) {
+        this.isStrong = strong;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @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 style to be used for the link.
+     * @param styleName  String style of text defined in style sheet.
      */
-    public LinkInfoImpl (int context, Type type, boolean isVarArg){
-        this.type = type;
-        this.isVarArg = isVarArg;
-        setContext(context);
+    public LinkInfoImpl styleName(String styleName) {
+        this.styleName = styleName;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @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 target to be used for the link.
+     * @param styleName  String style of text defined in style sheet.
      */
-    public LinkInfoImpl (int context, Type type, String label,
-            boolean isStrong){
-        this.type = type;
-        this.label = label;
-        this.isStrong = isStrong;
-        setContext(context);
+    public LinkInfoImpl target(String target) {
+        this.target = target;
+        return this;
     }
 
     /**
-     * Construct a LinkInfo object.
-     *
-     * @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 whether or not this is a link to a varargs parameter.
      */
-    public LinkInfoImpl (int context, ClassDoc classDoc, String label,
-            boolean isStrong){
-        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;
     }
 
@@ -376,60 +357,63 @@ public class LinkInfoImpl extends LinkInfo {
      *
      * @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_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 CONTEXT_EXECUTABLE_MEMBER_PARAM:
+            case RETURN_TYPE:
+            case SUMMARY_RETURN_TYPE:
+                excludeTypeBounds = true;
+                break;
+            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;
         }
     }
@@ -442,6 +426,6 @@ public class LinkInfoImpl extends LinkInfo {
      * desired place.
      */
     public boolean isLinkable() {
-        return Util.isLinkable(classDoc, ConfigurationImpl.getInstance());
+        return Util.isLinkable(classDoc, configuration);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkOutputImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkOutputImpl.java
index 788fd68..7cd2f6f 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/LinkOutputImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/LinkOutputImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -30,6 +30,11 @@ import com.sun.tools.doclets.internal.toolkit.util.links.*;
 /**
  * Stores output of a link.
  *
+ *  <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
  */
@@ -38,13 +43,13 @@ public class LinkOutputImpl implements LinkOutput {
     /**
      * The output of the link.
      */
-    public StringBuffer output;
+    public StringBuilder output;
 
     /**
      * Construct a new LinkOutputImpl.
      */
     public LinkOutputImpl() {
-        output = new StringBuffer();
+        output = new StringBuilder();
     }
 
     /**
@@ -58,6 +63,13 @@ public class LinkOutputImpl implements LinkOutput {
     /**
      * {@inheritDoc}
      */
+    public void insert(int offset, Object o) {
+        output.insert(offset, o.toString());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public String toString() {
         return output.toString();
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
index 8759155..235c913 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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
@@ -35,6 +35,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes method documentation in HTML format.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Jamie Ho (rewrite)
@@ -112,20 +117,20 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
      * @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);
         addTypeParameters(method, pre);
         addReturnType(method, pre);
-        if (configuration().linksource) {
+        if (configuration.linksource) {
             Content methodName = new StringContent(method.name());
             writer.addSrcLink(method, methodName, pre);
         } 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;
     }
 
@@ -144,15 +149,15 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
         if (method.inlineTags().length > 0) {
             if (holder.asClassDoc().equals(classdoc) ||
                     (! (holderClassDoc.isPublic() ||
-                    Util.isLinkable(holderClassDoc, configuration())))) {
+                    Util.isLinkable(holderClassDoc, configuration)))) {
                 writer.addInlineComment(method, methodDocTree);
             } else {
-                Content link = new RawHtml(
-                        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);
@@ -210,16 +215,16 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Method_Summary"),
-                configuration().getText("doclet.methods"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Method_Summary"),
+                configuration.getText("doclet.methods"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Methods");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Methods");
     }
 
     /**
@@ -228,9 +233,9 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
             writer.getModifierTypeHeader(),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Method"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Method"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -248,18 +253,18 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
         inheritedTree.addContent(writer.getMarkerAnchor(
                 "methods_inherited_from_class_" +
-                configuration().getClassName(cd)));
+                configuration.getClassName(cd)));
     }
 
     /**
      * {@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"));
+            configuration.getText("doclet.Methods_Inherited_From_Class") :
+            configuration.getText("doclet.Methods_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -280,12 +285,12 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
      */
     protected static void addOverridden(HtmlDocletWriter writer,
             Type overriddenType, MethodDoc method, Content dl) {
-        if(writer.configuration.nocomment){
+        if (writer.configuration.nocomment) {
             return;
         }
         ClassDoc holderClassDoc = overriddenType.asClassDoc();
         if (! (holderClassDoc.isPublic() ||
-            Util.isLinkable(holderClassDoc, writer.configuration()))) {
+            Util.isLinkable(holderClassDoc, writer.configuration))) {
             //This is an implementation detail that should not be documented.
             return;
         }
@@ -295,25 +300,25 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
             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()){
+            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(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(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());
@@ -356,14 +361,14 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
         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(
-                    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());
@@ -383,8 +388,8 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
     protected void addReturnType(MethodDoc method, Content htmltree) {
         Type type = method.returnType();
         if (type != null) {
-            Content linkContent = new RawHtml(writer.getLink(
-                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
+            Content linkContent = writer.getLink(
+                    new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
             htmltree.addContent(linkContent);
             htmltree.addContent(writer.getSpace());
         }
@@ -395,10 +400,10 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", (cd == null)?
+            return writer.getHyperLink((cd == null)?
                 "method_summary":
                 "methods_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navMethod"));
         } else {
             return writer.getResource("doclet.navMethod");
@@ -410,7 +415,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "method_detail",
+            liNav.addContent(writer.getHyperLink("method_detail",
                     writer.getResource("doclet.navMethod")));
         } else {
             liNav.addContent(writer.getResource("doclet.navMethod"));
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
index dda91ce..487d9ff 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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.*;
@@ -36,6 +35,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes nested class documentation in HTML format.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Jamie Ho (rewrite)
@@ -88,16 +92,16 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Nested_Class_Summary"),
-                configuration().getText("doclet.nested_classes"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Nested_Class_Summary"),
+                configuration.getText("doclet.nested_classes"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Nested_Classes");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Nested_Classes");
     }
 
     /**
@@ -108,17 +112,17 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
         if (member.isInterface()) {
             header = new String[] {
                 writer.getModifierTypeHeader(),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Interface"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Interface"),
+                        configuration.getText("doclet.Description"))
             };
         }
         else {
             header = new String[] {
                 writer.getModifierTypeHeader(),
-                configuration().getText("doclet.0_and_1",
-                        configuration().getText("doclet.Class"),
-                        configuration().getText("doclet.Description"))
+                configuration.getText("doclet.0_and_1",
+                        configuration.getText("doclet.Class"),
+                        configuration.getText("doclet.Description"))
             };
         }
         return header;
@@ -143,11 +147,11 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
      * {@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"));
+            configuration.getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
+            configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -158,10 +162,10 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
     /**
      * {@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(context, (ClassDoc)member, false))));
+        Content strong = HtmlTree.STRONG(
+                writer.getLink(new LinkInfoImpl(configuration, context, (ClassDoc)member)));
         Content code = HtmlTree.CODE(strong);
         tdSummary.addContent(code);
     }
@@ -171,9 +175,9 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
-                (ClassDoc)member, false))));
+        linksTree.addContent(
+                writer.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER,
+                (ClassDoc)member)));
     }
 
     /**
@@ -189,7 +193,7 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getQualifiedClassLink(LinkInfoImpl.Kind.MEMBER,
                 (ClassDoc)member);
     }
 
@@ -198,9 +202,8 @@ public class NestedClassWriterImpl extends AbstractMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", (cd == null) ? "nested_class_summary":
-                "nested_classes_inherited_from_class_" +
-                cd.qualifiedName(),
+            return writer.getHyperLink((cd == null) ? "nested_class_summary":
+                "nested_classes_inherited_from_class_" + cd.qualifiedName(),
                 writer.getResource("doclet.navNested"));
         } else {
             return writer.getResource("doclet.navNested");
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
index dc456c8..cdd8837 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
@@ -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
@@ -27,17 +27,22 @@ package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.formats.html.markup.*;
-import com.sun.tools.doclets.internal.toolkit.builders.PackageSummaryBuilder;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class to generate file for each package contents in the left-hand bottom
  * frame. This will list all the Class Kinds in the package. A click on any
  * class-kind will update the right-hand frame with the clicked class-kind page.
  *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
@@ -55,17 +60,12 @@ public class PackageFrameWriter extends HtmlDocletWriter {
     private Set<ClassDoc> documentedClasses;
 
     /**
-     * The name of the output file.
-     */
-    public static final String OUTPUT_FILE_NAME = "package-frame.html";
-
-    /**
      * Constructor to construct PackageFrameWriter object and to generate
      * "package-frame.html" file in the respective package directory.
      * For example for package "java.lang" this will generate file
      * "package-frame.html" file in the "java/lang" directory. It will also
      * create "java/lang" directory in the current or the destination directory
-     * if it doesen't exist.
+     * if it doesn't exist.
      *
      * @param configuration the configuration of the doclet.
      * @param packageDoc PackageDoc under consideration.
@@ -73,7 +73,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
     public PackageFrameWriter(ConfigurationImpl configuration,
                               PackageDoc packageDoc)
                               throws IOException {
-        super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME, DirectoryManager.getRelativePath(packageDoc));
+        super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_FRAME));
         this.packageDoc = packageDoc;
         if (configuration.root.specifiedPackages().length == 0) {
             documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes()));
@@ -94,7 +94,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
             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);
@@ -108,7 +108,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
         } catch (IOException exc) {
             configuration.standardmessage.error(
                     "doclet.exception_encountered",
-                    exc.toString(), OUTPUT_FILE_NAME);
+                    exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
             throw new DocletAbortException();
         }
     }
@@ -121,7 +121,7 @@ public class PackageFrameWriter extends HtmlDocletWriter {
      * @param contentTree the content tree to which the listing will be added
      */
     protected void addClassListing(Content contentTree) {
-        Configuration config = configuration();
+        Configuration config = configuration;
         if (packageDoc.isIncluded()) {
             addClassKindListing(packageDoc.interfaces(),
                 getResource("doclet.Interfaces"), contentTree);
@@ -161,12 +161,12 @@ public class PackageFrameWriter extends HtmlDocletWriter {
      */
     protected void addClassKindListing(ClassDoc[] arr, Content labelContent,
             Content contentTree) {
-        arr = PackageSummaryBuilder.filterOutPrivateClasses(arr);
+        arr = Util.filterOutPrivateClasses(arr, configuration.javafx);
         if(arr.length > 0) {
             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 @@ public class PackageFrameWriter extends HtmlDocletWriter {
                     contentTree.addContent(heading);
                     printedHeader = true;
                 }
-                Content link = new RawHtml (getLink(new LinkInfoImpl(
-                        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);
             }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
index 3ac4b98..fad1bd3 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, 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
@@ -26,16 +26,22 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the package index for the left-hand frame in the generated output.
  * A click on the package name in this frame will update the page in the bottom
  * left hand frame with the listing of contents of the clicked package.
  *
+ *  <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 Atul M Dambalkar
  */
 public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
@@ -46,7 +52,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
      * @param filename Name of the package index file to be generated.
      */
     public PackageIndexFrameWriter(ConfigurationImpl configuration,
-                                   String filename) throws IOException {
+                                   DocPath filename) throws IOException {
         super(configuration, filename);
     }
 
@@ -56,7 +62,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
      */
     public static void generate(ConfigurationImpl configuration) {
         PackageIndexFrameWriter packgen;
-        String filename = "overview-frame.html";
+        DocPath filename = DocPaths.OVERVIEW_FRAME;
         try {
             packgen = new PackageIndexFrameWriter(configuration, filename);
             packgen.buildPackageIndexFile("doclet.Window_Overview", false);
@@ -78,7 +84,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
                 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.
@@ -103,12 +109,12 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
         if (pd.name().length() > 0) {
             packageLabel = getPackageLabel(pd.name());
             packageLinkContent = getHyperLink(pathString(pd,
-                    "package-frame.html"), "", packageLabel, "",
+                     DocPaths.PACKAGE_FRAME), packageLabel, "",
                     "packageFrame");
         } else {
-            packageLabel = new RawHtml("<unnamed package>");
-            packageLinkContent = getHyperLink("package-frame.html",
-                    "", packageLabel, "", "packageFrame");
+            packageLabel = new StringContent("<unnamed package>");
+            packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
+                    packageLabel, "", "packageFrame");
         }
         Content li = HtmlTree.LI(packageLinkContent);
         return li;
@@ -139,13 +145,26 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter {
      * Adds "All Classes" link for the top of the left-hand frame page to the
      * documentation tree.
      *
-     * @param body the Content object to which the all classes link should be added
+     * @param div the Content object to which the all classes link should be added
      */
-    protected void addAllClassesLink(Content body) {
-        Content linkContent = getHyperLink("allclasses-frame.html", "",
+    protected void addAllClassesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
                 allclassesLabel, "", "packageFrame");
-        Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
-        body.addContent(div);
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * Adds "All Profiles" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all profiles link should be added
+     */
+    protected void addAllProfilesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME,
+                allprofilesLabel, "", "packageListFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
index 7b9be91..e11ed98 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -27,15 +27,22 @@ package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Generate the package index page "overview-summary.html" for the right-hand
  * frame. A click on the package name on this page will update the same frame
- * with the "pacakge-summary.html" file for the clicked package.
+ * with the "package-summary.html" file for the clicked package.
+ *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -67,7 +74,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
      * @see Group
      */
     public PackageIndexWriter(ConfigurationImpl configuration,
-                              String filename)
+                              DocPath filename)
                        throws IOException {
         super(configuration, filename);
         this.root = configuration.root;
@@ -82,7 +89,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
      */
     public static void generate(ConfigurationImpl configuration) {
         PackageIndexWriter packgen;
-        String filename = "overview-summary.html";
+        DocPath filename = DocPaths.OVERVIEW_SUMMARY;
         try {
             packgen = new PackageIndexWriter(configuration, filename);
             packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
@@ -116,10 +123,25 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
     /**
      * {@inheritDoc}
      */
+    protected void addProfilesList(Content profileSummary, String profilesTableSummary,
+            Content body) {
+        Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, profilesTableSummary,
+                getTableCaption(profileSummary));
+        table.addContent(getSummaryTableHeader(profileTableHeader, "col"));
+        Content tbody = new HtmlTree(HtmlTag.TBODY);
+        addProfilesList(tbody);
+        table.addContent(tbody);
+        Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
+        body.addContent(div);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     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);
@@ -129,6 +151,31 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
     }
 
     /**
+     * Adds list of profiles in the index table. Generate link to each profile.
+     *
+     * @param tbody the documentation tree to which the list will be added
+     */
+    protected void addProfilesList(Content tbody) {
+        for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
+            String profileName = Profile.lookup(i).name;
+            Content profileLinkContent = getTargetProfileLink("classFrame",
+                    new StringContent(profileName), profileName);
+            Content tdProfile = HtmlTree.TD(HtmlStyle.colFirst, profileLinkContent);
+            HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
+            tdSummary.addStyle(HtmlStyle.colLast);
+            tdSummary.addContent(getSpace());
+            HtmlTree tr = HtmlTree.TR(tdProfile);
+            tr.addContent(tdSummary);
+            if (i % 2 == 0) {
+                tr.addStyle(HtmlStyle.altColor);
+            } else {
+                tr.addStyle(HtmlStyle.rowColor);
+            }
+            tbody.addContent(tr);
+        }
+    }
+
+    /**
      * Adds list of packages in the index table. Generate link to each package.
      *
      * @param packages Packages to which link is to be generated
@@ -172,7 +219,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
             Content see = seeLabel;
             see.addContent(" ");
             Content descPara = HtmlTree.P(see);
-            Content descLink = getHyperLink("", "overview_description",
+            Content descLink = getHyperLink(DocLink.fragment("overview_description"),
                 descriptionLabel, "", "");
             descPara.addContent(descLink);
             div.addContent(descPara);
@@ -190,10 +237,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
     protected void addOverviewComment(Content htmltree) {
         if (root.inlineTags().length > 0) {
             htmltree.addContent(getMarkerAnchor("overview_description"));
-            HtmlTree div = new HtmlTree(HtmlTag.DIV);
-            div.addStyle(HtmlStyle.subTitle);
-            addInlineComment(root, div);
-            htmltree.addContent(div);
+            addInlineComment(root, htmltree);
         }
     }
 
@@ -205,7 +249,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
      */
     protected void addOverview(Content body) throws IOException {
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
-        div.addStyle(HtmlStyle.footer);
+        div.addStyle(HtmlStyle.contentContainer);
         addOverviewComment(div);
         addTagsInfo(root, div);
         body.addContent(div);
@@ -228,7 +272,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter {
      * Adds the lower navigation bar and the bottom text
      * (from the -bottom option) at the bottom of page.
      *
-     * @param the documentation tree to which the navigation bar footer will be added
+     * @param body the documentation tree to which the navigation bar footer will be added
      */
     protected void addNavigationBarFooter(Content body) {
         addNavLinks(false, body);
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
index 7996655..d9510f2 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -28,14 +28,19 @@ package com.sun.tools.doclets.formats.html;
 import java.io.*;
 
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class to generate Tree page for a package. The name of the file generated is
  * "package-tree.html" and it is generated in the respective package directory.
  *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
@@ -62,15 +67,14 @@ public class PackageTreeWriter extends AbstractTreeWriter {
      * @throws DocletAbortException
      */
     public PackageTreeWriter(ConfigurationImpl configuration,
-                             String path, String filename,
+                             DocPath path,
                              PackageDoc packagedoc,
                              PackageDoc prev, PackageDoc next)
                       throws IOException {
-        super(configuration, path, filename,
+        super(configuration, path,
               new ClassTree(
                 configuration.classDocCatalog.allClasses(packagedoc),
-                configuration),
-              packagedoc);
+                configuration));
         this.packagedoc = packagedoc;
         this.prev = prev;
         this.next = next;
@@ -91,17 +95,16 @@ public class PackageTreeWriter extends AbstractTreeWriter {
                                 PackageDoc pkg, PackageDoc prev,
                                 PackageDoc next, boolean noDeprecated) {
         PackageTreeWriter packgen;
-        String path = DirectoryManager.getDirectoryPath(pkg);
-        String filename = "package-tree.html";
+        DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE);
         try {
-            packgen = new PackageTreeWriter(configuration, path, filename, pkg,
+            packgen = new PackageTreeWriter(configuration, path, pkg,
                 prev, next);
             packgen.generatePackageTreeFile();
             packgen.close();
         } catch (IOException exc) {
             configuration.standardmessage.error(
                         "doclet.exception_encountered",
-                        exc.toString(), filename);
+                        exc.toString(), path.getPath());
             throw new DocletAbortException();
         }
     }
@@ -170,9 +173,8 @@ public class PackageTreeWriter extends AbstractTreeWriter {
         if (prev == null) {
             return getNavLinkPrevious(null);
         } else {
-            String path = DirectoryManager.getRelativePath(packagedoc.name(),
-                    prev.name());
-            return getNavLinkPrevious(path + "package-tree.html");
+            DocPath path = DocPath.relativePath(packagedoc, prev);
+            return getNavLinkPrevious(path.resolve(DocPaths.PACKAGE_TREE));
         }
     }
 
@@ -185,9 +187,8 @@ public class PackageTreeWriter extends AbstractTreeWriter {
         if (next == null) {
             return getNavLinkNext(null);
         } else {
-            String path = DirectoryManager.getRelativePath(packagedoc.name(),
-                    next.name());
-            return getNavLinkNext(path + "package-tree.html");
+            DocPath path = DocPath.relativePath(packagedoc, next);
+            return getNavLinkNext(path.resolve(DocPaths.PACKAGE_TREE));
         }
     }
 
@@ -197,7 +198,7 @@ public class PackageTreeWriter extends AbstractTreeWriter {
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content linkContent = getHyperLink("package-summary.html", "",
+        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
                 packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
index 579aee2..3e2668f 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, 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
@@ -27,14 +27,20 @@ package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate package usage information.
  *
+ *  <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 Robert G. Field
  * @author Bhavesh Patel (Modified)
  */
@@ -51,11 +57,9 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      * @throws DocletAbortException
      */
     public PackageUseWriter(ConfigurationImpl configuration,
-                            ClassUseMapper mapper, String filename,
+                            ClassUseMapper mapper, DocPath filename,
                             PackageDoc pkgdoc) throws IOException {
-        super(configuration, DirectoryManager.getDirectoryPath(pkgdoc),
-              filename,
-              DirectoryManager.getRelativePath(pkgdoc.name()));
+        super(configuration, DocPath.forPackage(pkgdoc).resolve(filename));
         this.pkgdoc = pkgdoc;
 
         // by examining all classes in this package, find what packages
@@ -92,7 +96,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
     public static void generate(ConfigurationImpl configuration,
                                 ClassUseMapper mapper, PackageDoc pkgdoc) {
         PackageUseWriter pkgusegen;
-        String filename = "package-use.html";
+        DocPath filename = DocPaths.PACKAGE_USE;
         try {
             pkgusegen = new PackageUseWriter(configuration,
                                              mapper, filename, pkgdoc);
@@ -148,9 +152,9 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      */
     protected void addPackageList(Content contentTree) throws IOException {
         Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
-                getTableCaption(configuration().getText(
+                getTableCaption(configuration.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();
@@ -193,10 +197,10 @@ public class PackageUseWriter extends SubWriterHolderWriter {
             String tableSummary = configuration.getText("doclet.Use_Table_Summary",
                     configuration.getText("doclet.classes"));
             Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
-                    getTableCaption(configuration().getText(
+                    getTableCaption(configuration.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 =
@@ -226,10 +230,10 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      */
     protected void addClassRow(ClassDoc usedClass, String packageName,
             Content contentTree) {
-        String path = pathString(usedClass,
-                "class-use/" + usedClass.name() + ".html");
+        DocPath dp = pathString(usedClass,
+                DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass)));
         Content td = HtmlTree.TD(HtmlStyle.colOne,
-                getHyperLink(path, packageName, new StringContent(usedClass.name())));
+                getHyperLink(dp.fragment(packageName), new StringContent(usedClass.name())));
         addIndexComment(usedClass, td);
         contentTree.addContent(td);
     }
@@ -242,8 +246,8 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      */
     protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
         Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
-                getHyperLink("", Util.getPackageName(pkg),
-                new RawHtml(Util.getPackageName(pkg))));
+                getHyperLink(Util.getPackageName(pkg),
+                new StringContent(Util.getPackageName(pkg))));
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
@@ -268,7 +272,10 @@ public class PackageUseWriter extends SubWriterHolderWriter {
         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);
@@ -282,7 +289,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content linkContent = getHyperLink("package-summary.html", "",
+        Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
                 packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
@@ -304,7 +311,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
      * @return a content tree for the tree link
      */
     protected Content getNavLinkTree() {
-        Content linkContent = getHyperLink("package-tree.html", "",
+        Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE,
                 treeLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
index bc35318..16be6c3 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -27,16 +27,22 @@ 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.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Class to generate file for each package contents in the right-hand
  * frame. This will list all the Class Kinds in the package. A click on any
  * class-kind will update the frame with the clicked class-kind page.
  *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
@@ -59,17 +65,12 @@ public class PackageWriterImpl extends HtmlDocletWriter
     protected PackageDoc packageDoc;
 
     /**
-     * The name of the output file.
-     */
-    private static final String OUTPUT_FILE_NAME = "package-summary.html";
-
-    /**
      * Constructor to construct PackageWriter object and to generate
      * "package-summary.html" file in the respective package directory.
      * For example for package "java.lang" this will generate file
      * "package-summary.html" file in the "java/lang" directory. It will also
      * create "java/lang" directory in the current or the destination directory
-     * if it doesen't exist.
+     * if it doesn't exist.
      *
      * @param configuration the configuration of the doclet.
      * @param packageDoc    PackageDoc under consideration.
@@ -77,25 +78,15 @@ public class PackageWriterImpl extends HtmlDocletWriter
      * @param next            Next package in the sorted array.
      */
     public PackageWriterImpl(ConfigurationImpl configuration,
-        PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
-    throws IOException {
-        super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
-             DirectoryManager.getRelativePath(packageDoc.name()));
+            PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
+            throws IOException {
+        super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_SUMMARY));
         this.prev = prev;
         this.next = next;
         this.packageDoc = packageDoc;
     }
 
     /**
-     * Return the name of the output file.
-     *
-     * @return the name of the output file.
-     */
-    public String getOutputFileName() {
-        return OUTPUT_FILE_NAME;
-    }
-
-    /**
      * {@inheritDoc}
      */
     public Content getPackageHeader(String heading) {
@@ -111,7 +102,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
         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);
@@ -121,7 +112,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
             addSummaryComment(packageDoc, docSummaryDiv);
             div.addContent(docSummaryDiv);
             Content space = getSpace();
-            Content descLink = getHyperLink("", "package_description",
+            Content descLink = getHyperLink(DocLink.fragment("package_description"),
                     descriptionLabel, "", "");
             Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
             div.addContent(descPara);
@@ -177,7 +168,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
             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"));
@@ -187,8 +178,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
                     !configuration.isGeneratedDoc(classes[i])) {
                     continue;
                 }
-                Content classContent = new RawHtml(getLink(new LinkInfoImpl(
-                        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)
@@ -248,7 +239,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
     /**
      * {@inheritDoc}
      */
-    public void printDocument(Content contentTree) {
+    public void printDocument(Content contentTree) throws IOException {
         printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
                 true, contentTree);
     }
@@ -259,7 +250,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
      * @return a content tree for the class use link
      */
     protected Content getNavLinkClassUse() {
-        Content useLink = getHyperLink("package-use.html", "",
+        Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
                 useLabel, "", "");
         Content li = HtmlTree.LI(useLink);
         return li;
@@ -275,9 +266,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
         if (prev == null) {
             li = HtmlTree.LI(prevpackageLabel);
         } else {
-            String path = DirectoryManager.getRelativePath(packageDoc.name(),
-                                                           prev.name());
-            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
+            DocPath path = DocPath.relativePath(packageDoc, prev);
+            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
                 prevpackageLabel, "", ""));
         }
         return li;
@@ -293,9 +283,8 @@ public class PackageWriterImpl extends HtmlDocletWriter
         if (next == null) {
             li = HtmlTree.LI(nextpackageLabel);
         } else {
-            String path = DirectoryManager.getRelativePath(packageDoc.name(),
-                                                           next.name());
-            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
+            DocPath path = DocPath.relativePath(packageDoc, next);
+            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
                 nextpackageLabel, "", ""));
         }
         return li;
@@ -308,7 +297,7 @@ public class PackageWriterImpl extends HtmlDocletWriter
      * @return a content tree for the tree link
      */
     protected Content getNavLinkTree() {
-        Content useLink = getHyperLink("package-tree.html", "",
+        Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
                 treeLabel, "", "");
         Content li = HtmlTree.LI(useLink);
         return li;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java
new file mode 100644
index 0000000..4689eca
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java
@@ -0,0 +1,173 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+
+import com.sun.tools.javac.sym.Profiles;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+import com.sun.tools.javac.jvm.Profile;
+
+/**
+ * Generate the profile index for the left-hand frame in the generated output.
+ * A click on the profile name in this frame will update the page in the top
+ * left hand frame with the listing of packages of the clicked profile.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter {
+
+    /**
+     * Construct the ProfileIndexFrameWriter object.
+     *
+     * @param configuration the configuration object
+     * @param filename Name of the profile index file to be generated.
+     */
+    public ProfileIndexFrameWriter(ConfigurationImpl configuration,
+                                   DocPath filename) throws IOException {
+        super(configuration, filename);
+    }
+
+    /**
+     * Generate the profile index file named "profile-overview-frame.html".
+     * @throws DocletAbortException
+     * @param configuration the configuration object
+     */
+    public static void generate(ConfigurationImpl configuration) {
+        ProfileIndexFrameWriter profilegen;
+        DocPath filename = DocPaths.PROFILE_OVERVIEW_FRAME;
+        try {
+            profilegen = new ProfileIndexFrameWriter(configuration, filename);
+            profilegen.buildProfileIndexFile("doclet.Window_Overview", false);
+            profilegen.close();
+        } catch (IOException exc) {
+            configuration.standardmessage.error(
+                        "doclet.exception_encountered",
+                        exc.toString(), filename);
+            throw new DocletAbortException();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addProfilesList(Profiles profiles, String text,
+            String tableSummary, Content body) {
+        Content heading = HtmlTree.HEADING(HtmlConstants.PROFILE_HEADING, true,
+                profilesLabel);
+        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.setTitle(profilesLabel);
+        for (int i = 1; i < profiles.getProfileCount(); i++) {
+            ul.addContent(getProfile(i));
+        }
+        div.addContent(ul);
+        body.addContent(div);
+    }
+
+    /**
+     * Gets each profile name as a separate link.
+     *
+     * @param profile the profile being documented
+     * @return content for the profile link
+     */
+    protected Content getProfile(int profile) {
+        Content profileLinkContent;
+        Content profileLabel;
+        String profileName = (Profile.lookup(profile)).name;
+        profileLabel = new StringContent(profileName);
+        profileLinkContent = getHyperLink(DocPaths.profileFrame(profileName), profileLabel, "",
+                    "packageListFrame");
+        Content li = HtmlTree.LI(profileLinkContent);
+        return li;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavigationBarHeader(Content body) {
+        Content headerContent;
+        if (configuration.packagesheader.length() > 0) {
+            headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+        } else {
+            headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+        }
+        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.bar, headerContent);
+        body.addContent(heading);
+    }
+
+    /**
+     * Do nothing as there is no overview information in this page.
+     */
+    protected void addOverviewHeader(Content body) {
+    }
+
+    /**
+     * Adds "All Classes" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all classes link should be added
+     */
+    protected void addAllClassesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
+                allclassesLabel, "", "packageFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * Adds "All Packages" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all packages link should be added
+     */
+    protected void addAllPackagesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
+                allpackagesLabel, "", "packageListFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavigationBarFooter(Content body) {
+        Content p = HtmlTree.P(getSpace());
+        body.addContent(p);
+    }
+
+    protected void addProfilePackagesList(Profiles profiles, String text,
+            String tableSummary, Content body, String profileName) {
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java
new file mode 100644
index 0000000..ef8c0fb
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Class to generate file for each package contents of a profile in the left-hand bottom
+ * frame. This will list all the Class Kinds in the package for a profile. A click on any
+ * class-kind will update the right-hand frame with the clicked class-kind page.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfilePackageFrameWriter extends HtmlDocletWriter {
+
+    /**
+     * The package being documented.
+     */
+    private PackageDoc packageDoc;
+
+    /**
+     * Constructor to construct ProfilePackageFrameWriter object and to generate
+     * "profilename-package-frame.html" file in the respective package directory.
+     * For example for profile compact1 and package "java.lang" this will generate file
+     * "compact1-package-frame.html" file in the "java/lang" directory. It will also
+     * create "java/lang" directory in the current or the destination directory
+     * if it doesn't exist.
+     *
+     * @param configuration the configuration of the doclet.
+     * @param packageDoc PackageDoc under consideration.
+     * @param profileName the name of the profile being documented
+     */
+    public ProfilePackageFrameWriter(ConfigurationImpl configuration,
+            PackageDoc packageDoc, String profileName)
+            throws IOException {
+        super(configuration, DocPath.forPackage(packageDoc).resolve(
+                DocPaths.profilePackageFrame(profileName)));
+        this.packageDoc = packageDoc;
+    }
+
+    /**
+     * Generate a profile package summary page for the left-hand bottom frame. Construct
+     * the ProfilePackageFrameWriter object and then uses it generate the file.
+     *
+     * @param configuration the current configuration of the doclet.
+     * @param packageDoc The package for which "profilename-package-frame.html" is to be generated.
+     * @param profileValue the value of the profile being documented
+     */
+    public static void generate(ConfigurationImpl configuration,
+            PackageDoc packageDoc, int profileValue) {
+        ProfilePackageFrameWriter profpackgen;
+        try {
+            String profileName = Profile.lookup(profileValue).name;
+            profpackgen = new ProfilePackageFrameWriter(configuration, packageDoc,
+                    profileName);
+            StringBuilder winTitle = new StringBuilder(profileName);
+            String sep = " - ";
+            winTitle.append(sep);
+            String pkgName = Util.getPackageName(packageDoc);
+            winTitle.append(pkgName);
+            Content body = profpackgen.getBody(false,
+                    profpackgen.getWindowTitle(winTitle.toString()));
+            Content profName = new StringContent(profileName);
+            Content sepContent = new StringContent(sep);
+            Content pkgNameContent = new RawHtml(pkgName);
+            Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
+                    profpackgen.getTargetProfileLink("classFrame", profName, profileName));
+            heading.addContent(sepContent);
+            heading.addContent(profpackgen.getTargetProfilePackageLink(packageDoc,
+                    "classFrame", pkgNameContent, profileName));
+            body.addContent(heading);
+            HtmlTree div = new HtmlTree(HtmlTag.DIV);
+            div.addStyle(HtmlStyle.indexContainer);
+            profpackgen.addClassListing(div, profileValue);
+            body.addContent(div);
+            profpackgen.printHtmlDocument(
+                    configuration.metakeywords.getMetaKeywords(packageDoc), false, body);
+            profpackgen.close();
+        } catch (IOException exc) {
+            configuration.standardmessage.error(
+                    "doclet.exception_encountered",
+                    exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
+            throw new DocletAbortException();
+        }
+    }
+
+    /**
+     * Add class listing for all the classes in this package. Divide class
+     * listing as per the class kind and generate separate listing for
+     * Classes, Interfaces, Exceptions and Errors.
+     *
+     * @param contentTree the content tree to which the listing will be added
+     * @param profileValue the value of the profile being documented
+     */
+    protected void addClassListing(Content contentTree, int profileValue) {
+        if (packageDoc.isIncluded()) {
+            addClassKindListing(packageDoc.interfaces(),
+                getResource("doclet.Interfaces"), contentTree, profileValue);
+            addClassKindListing(packageDoc.ordinaryClasses(),
+                getResource("doclet.Classes"), contentTree, profileValue);
+            addClassKindListing(packageDoc.enums(),
+                getResource("doclet.Enums"), contentTree, profileValue);
+            addClassKindListing(packageDoc.exceptions(),
+                getResource("doclet.Exceptions"), contentTree, profileValue);
+            addClassKindListing(packageDoc.errors(),
+                getResource("doclet.Errors"), contentTree, profileValue);
+            addClassKindListing(packageDoc.annotationTypes(),
+                getResource("doclet.AnnotationTypes"), contentTree, profileValue);
+        }
+    }
+
+    /**
+     * Add specific class kind listing. Also add label to the listing.
+     *
+     * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error
+     * @param labelContent content tree of the label to be added
+     * @param contentTree the content tree to which the class kind listing will be added
+     * @param profileValue the value of the profile being documented
+     */
+    protected void addClassKindListing(ClassDoc[] arr, Content labelContent,
+            Content contentTree, int profileValue) {
+        if(arr.length > 0) {
+            Arrays.sort(arr);
+            boolean printedHeader = false;
+            HtmlTree ul = new HtmlTree(HtmlTag.UL);
+            ul.setTitle(labelContent);
+            for (int i = 0; i < arr.length; i++) {
+                if (!isTypeInProfile(arr[i], profileValue)) {
+                    continue;
+                }
+                if (!Util.isCoreClass(arr[i]) || !
+                        configuration.isGeneratedDoc(arr[i])) {
+                    continue;
+                }
+                if (!printedHeader) {
+                    Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                            true, labelContent);
+                    contentTree.addContent(heading);
+                    printedHeader = true;
+                }
+                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);
+            }
+            contentTree.addContent(ul);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java
new file mode 100644
index 0000000..6764f5f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.sym.Profiles;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Generate the profile package index for the left-hand frame in the generated output.
+ * A click on the package name in this frame will update the page in the bottom
+ * left hand frame with the listing of contents of the clicked profile package.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter {
+
+    /**
+     * Construct the ProfilePackageIndexFrameWriter object.
+     *
+     * @param configuration the configuration object
+     * @param filename Name of the package index file to be generated.
+     */
+    public ProfilePackageIndexFrameWriter(ConfigurationImpl configuration,
+                                   DocPath filename) throws IOException {
+        super(configuration, filename);
+    }
+
+    /**
+     * Generate the profile package index file.
+     * @throws DocletAbortException
+     * @param configuration the configuration object
+     * @param profileName the name of the profile being documented
+     */
+    public static void generate(ConfigurationImpl configuration, String profileName) {
+        ProfilePackageIndexFrameWriter profpackgen;
+        DocPath filename = DocPaths.profileFrame(profileName);
+        try {
+            profpackgen = new ProfilePackageIndexFrameWriter(configuration, filename);
+            profpackgen.buildProfilePackagesIndexFile("doclet.Window_Overview", false, profileName);
+            profpackgen.close();
+        } catch (IOException exc) {
+            configuration.standardmessage.error(
+                        "doclet.exception_encountered",
+                        exc.toString(), filename);
+            throw new DocletAbortException();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addProfilePackagesList(Profiles profiles, String text,
+            String tableSummary, Content body, String profileName) {
+        Content profNameContent = new StringContent(profileName);
+        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
+                getTargetProfileLink("classFrame", profNameContent, profileName));
+        heading.addContent(getSpace());
+        heading.addContent(packagesLabel);
+        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.setTitle(packagesLabel);
+        PackageDoc[] packages = configuration.profilePackages.get(profileName);
+        for (int i = 0; i < packages.length; i++) {
+            if ((!(configuration.nodeprecated && Util.isDeprecated(packages[i])))) {
+                ul.addContent(getPackage(packages[i], profileName));
+            }
+        }
+        div.addContent(ul);
+        body.addContent(div);
+    }
+
+    /**
+     * Gets each package name as a separate link.
+     *
+     * @param pd PackageDoc
+     * @param profileName the name of the profile being documented
+     * @return content for the package link
+     */
+    protected Content getPackage(PackageDoc pd, String profileName) {
+        Content packageLinkContent;
+        Content pkgLabel;
+        if (pd.name().length() > 0) {
+            pkgLabel = getPackageLabel(pd.name());
+            packageLinkContent = getHyperLink(pathString(pd,
+                     DocPaths.profilePackageFrame(profileName)), pkgLabel, "",
+                    "packageFrame");
+        } else {
+            pkgLabel = new StringContent("<unnamed package>");
+            packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
+                    pkgLabel, "", "packageFrame");
+        }
+        Content li = HtmlTree.LI(packageLinkContent);
+        return li;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavigationBarHeader(Content body) {
+        Content headerContent;
+        if (configuration.packagesheader.length() > 0) {
+            headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+        } else {
+            headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+        }
+        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.bar, headerContent);
+        body.addContent(heading);
+    }
+
+    /**
+     * Do nothing as there is no overview information in this page.
+     */
+    protected void addOverviewHeader(Content body) {
+    }
+
+    protected void addProfilesList(Profiles profiles, String text,
+            String tableSummary, Content body) {
+    }
+
+    /**
+     * Adds "All Classes" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all classes link should be added
+     */
+    protected void addAllClassesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
+                allclassesLabel, "", "packageFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * Adds "All Packages" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all packages link should be added
+     */
+    protected void addAllPackagesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
+                allpackagesLabel, "", "packageListFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * Adds "All Profiles" link for the top of the left-hand frame page to the
+     * documentation tree.
+     *
+     * @param div the Content object to which the all profiles link should be added
+     */
+    protected void addAllProfilesLink(Content div) {
+        Content linkContent = getHyperLink(DocPaths.PROFILE_OVERVIEW_FRAME,
+                allprofilesLabel, "", "packageListFrame");
+        Content span = HtmlTree.SPAN(linkContent);
+        div.addContent(span);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void addNavigationBarFooter(Content body) {
+        Content p = HtmlTree.P(getSpace());
+        body.addContent(p);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java
new file mode 100644
index 0000000..1de03f4
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java
@@ -0,0 +1,296 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Class to generate file for each profile package contents in the right-hand
+ * frame. This will list all the Class Kinds in the package. A click on any
+ * class-kind will update the frame with the clicked class-kind page.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfilePackageWriterImpl extends HtmlDocletWriter
+    implements ProfilePackageSummaryWriter {
+
+    /**
+     * The prev package name in the alpha-order list.
+     */
+    protected PackageDoc prev;
+
+    /**
+     * The next package name in the alpha-order list.
+     */
+    protected PackageDoc next;
+
+    /**
+     * The profile package being documented.
+     */
+    protected PackageDoc packageDoc;
+
+    /**
+     * The name of the profile being documented.
+     */
+    protected String profileName;
+
+    /**
+     * The value of the profile being documented.
+     */
+    protected int profileValue;
+
+    /**
+     * Constructor to construct ProfilePackageWriter object and to generate
+     * "profilename-package-summary.html" file in the respective package directory.
+     * For example for profile compact1 and package "java.lang" this will generate file
+     * "compact1-package-summary.html" file in the "java/lang" directory. It will also
+     * create "java/lang" directory in the current or the destination directory
+     * if it doesn't exist.
+     *
+     * @param configuration the configuration of the doclet.
+     * @param packageDoc    PackageDoc under consideration.
+     * @param prev          Previous package in the sorted array.
+     * @param next          Next package in the sorted array.
+     * @param profile       The profile being documented.
+     */
+    public ProfilePackageWriterImpl(ConfigurationImpl configuration,
+            PackageDoc packageDoc, PackageDoc prev, PackageDoc next,
+            Profile profile) throws IOException {
+        super(configuration, DocPath.forPackage(packageDoc).resolve(
+                DocPaths.profilePackageSummary(profile.name)));
+        this.prev = prev;
+        this.next = next;
+        this.packageDoc = packageDoc;
+        this.profileName = profile.name;
+        this.profileValue = profile.value;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getPackageHeader(String heading) {
+        String pkgName = packageDoc.name();
+        Content bodyTree = getBody(true, getWindowTitle(pkgName));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.header);
+        Content profileContent = new StringContent(profileName);
+        Content profileNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, profileContent);
+        div.addContent(profileNameDiv);
+        Content annotationContent = new HtmlTree(HtmlTag.P);
+        addAnnotationInfo(packageDoc, annotationContent);
+        div.addContent(annotationContent);
+        Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.title, packageLabel);
+        tHeading.addContent(getSpace());
+        Content packageHead = new RawHtml(heading);
+        tHeading.addContent(packageHead);
+        div.addContent(tHeading);
+        addDeprecationInfo(div);
+        if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
+            HtmlTree docSummaryDiv = new HtmlTree(HtmlTag.DIV);
+            docSummaryDiv.addStyle(HtmlStyle.docSummary);
+            addSummaryComment(packageDoc, docSummaryDiv);
+            div.addContent(docSummaryDiv);
+            Content space = getSpace();
+            Content descLink = getHyperLink(DocLink.fragment("package_description"),
+                    descriptionLabel, "", "");
+            Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
+            div.addContent(descPara);
+        }
+        bodyTree.addContent(div);
+        return bodyTree;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getContentHeader() {
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.contentContainer);
+        return div;
+    }
+
+    /**
+     * Add the package deprecation information to the documentation tree.
+     *
+     * @param div the content tree to which the deprecation information will be added
+     */
+    public void addDeprecationInfo(Content div) {
+        Tag[] deprs = packageDoc.tags("deprecated");
+        if (Util.isDeprecated(packageDoc)) {
+            HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
+            deprDiv.addStyle(HtmlStyle.deprecatedContent);
+            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
+            deprDiv.addContent(deprPhrase);
+            if (deprs.length > 0) {
+                Tag[] commentTags = deprs[0].inlineTags();
+                if (commentTags.length > 0) {
+                    addInlineDeprecatedComment(packageDoc, deprs[0], deprDiv);
+                }
+            }
+            div.addContent(deprDiv);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addClassesSummary(ClassDoc[] classes, String label,
+            String tableSummary, String[] tableHeader, Content packageSummaryContentTree) {
+        addClassesSummary(classes, label, tableSummary, tableHeader,
+                packageSummaryContentTree, profileValue);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getSummaryHeader() {
+        HtmlTree ul = new HtmlTree(HtmlTag.UL);
+        ul.addStyle(HtmlStyle.blockList);
+        return ul;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPackageDescription(Content packageContentTree) {
+        if (packageDoc.inlineTags().length > 0) {
+            packageContentTree.addContent(getMarkerAnchor("package_description"));
+            Content h2Content = new StringContent(
+                    configuration.getText("doclet.Package_Description",
+                    packageDoc.name()));
+            packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING,
+                    true, h2Content));
+            addInlineComment(packageDoc, packageContentTree);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPackageTags(Content packageContentTree) {
+        addTagsInfo(packageDoc, packageContentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addPackageFooter(Content contentTree) {
+        addNavLinks(false, contentTree);
+        addBottom(contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void printDocument(Content contentTree) throws IOException {
+        printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
+                true, contentTree);
+    }
+
+    /**
+     * Get "Use" link for this package in the navigation bar.
+     *
+     * @return a content tree for the class use link
+     */
+    protected Content getNavLinkClassUse() {
+        Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
+                useLabel, "", "");
+        Content li = HtmlTree.LI(useLink);
+        return li;
+    }
+
+    /**
+     * Get "PREV PACKAGE" link in the navigation bar.
+     *
+     * @return a content tree for the previous link
+     */
+    public Content getNavLinkPrevious() {
+        Content li;
+        if (prev == null) {
+            li = HtmlTree.LI(prevpackageLabel);
+        } else {
+            DocPath path = DocPath.relativePath(packageDoc, prev);
+            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)),
+                prevpackageLabel, "", ""));
+        }
+        return li;
+    }
+
+    /**
+     * Get "NEXT PACKAGE" link in the navigation bar.
+     *
+     * @return a content tree for the next link
+     */
+    public Content getNavLinkNext() {
+        Content li;
+        if (next == null) {
+            li = HtmlTree.LI(nextpackageLabel);
+        } else {
+            DocPath path = DocPath.relativePath(packageDoc, next);
+            li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.profilePackageSummary(profileName)),
+                nextpackageLabel, "", ""));
+        }
+        return li;
+    }
+
+    /**
+     * Get "Tree" link in the navigation bar. This will be link to the package
+     * tree file.
+     *
+     * @return a content tree for the tree link
+     */
+    protected Content getNavLinkTree() {
+        Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
+                treeLabel, "", "");
+        Content li = HtmlTree.LI(useLink);
+        return li;
+    }
+
+    /**
+     * Highlight "Package" in the navigation bar, as this is the package page.
+     *
+     * @return a content tree for the package link
+     */
+    protected Content getNavLinkPackage() {
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
+        return li;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java
new file mode 100644
index 0000000..5dae2e9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.formats.html;
+
+import java.io.*;
+import java.util.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.formats.html.markup.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Class to generate file for each profile contents in the right-hand
+ * frame. This will list all the packages and Class Kinds in the profile. A click on any
+ * class-kind will update the frame with the clicked class-kind page. A click on any
+ * package will update the frame with the clicked profile package page.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfileWriterImpl extends HtmlDocletWriter
+    implements ProfileSummaryWriter {
+
+    /**
+     * The prev profile name in the alpha-order list.
+     */
+    protected Profile prevProfile;
+
+    /**
+     * The next profile name in the alpha-order list.
+     */
+    protected Profile nextProfile;
+
+    /**
+     * The profile being documented.
+     */
+    protected Profile profile;
+
+    /**
+     * Constructor to construct ProfileWriter object and to generate
+     * "profileName-summary.html" file.
+     *
+     * @param configuration the configuration of the doclet.
+     * @param profile       Profile under consideration.
+     * @param prevProfile   Previous profile in the sorted array.
+     * @param nextProfile   Next profile in the sorted array.
+     */
+    public ProfileWriterImpl(ConfigurationImpl configuration,
+            Profile profile, Profile prevProfile, Profile nextProfile)
+            throws IOException {
+        super(configuration, DocPaths.profileSummary(profile.name));
+        this.prevProfile = prevProfile;
+        this.nextProfile = nextProfile;
+        this.profile = profile;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getProfileHeader(String heading) {
+        String profileName = profile.name;
+        Content bodyTree = getBody(true, getWindowTitle(profileName));
+        addTop(bodyTree);
+        addNavLinks(true, bodyTree);
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.header);
+        Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
+                HtmlStyle.title, profileLabel);
+        tHeading.addContent(getSpace());
+        Content profileHead = new RawHtml(heading);
+        tHeading.addContent(profileHead);
+        div.addContent(tHeading);
+        bodyTree.addContent(div);
+        return bodyTree;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getContentHeader() {
+        HtmlTree div = new HtmlTree(HtmlTag.DIV);
+        div.addStyle(HtmlStyle.contentContainer);
+        return div;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getSummaryHeader() {
+        HtmlTree li = new HtmlTree(HtmlTag.LI);
+        li.addStyle(HtmlStyle.blockList);
+        return li;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getSummaryTree(Content summaryContentTree) {
+        HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree);
+        HtmlTree div = HtmlTree.DIV(HtmlStyle.summary, ul);
+        return div;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getPackageSummaryHeader(PackageDoc pkg) {
+        Content pkgName = getTargetProfilePackageLink(pkg,
+                    "classFrame", new StringContent(pkg.name()), profile.name);
+        Content heading = HtmlTree.HEADING(HtmlTag.H3, pkgName);
+        HtmlTree li = HtmlTree.LI(HtmlStyle.blockList, heading);
+        return li;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getPackageSummaryTree(Content packageSummaryContentTree) {
+        HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, packageSummaryContentTree);
+        return ul;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addClassesSummary(ClassDoc[] classes, String label,
+            String tableSummary, String[] tableHeader, Content packageSummaryContentTree) {
+        addClassesSummary(classes, label, tableSummary, tableHeader,
+                packageSummaryContentTree, profile.value);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addProfileFooter(Content contentTree) {
+        addNavLinks(false, contentTree);
+        addBottom(contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void printDocument(Content contentTree) throws IOException {
+        printHtmlDocument(configuration.metakeywords.getMetaKeywords(profile),
+                true, contentTree);
+    }
+
+    /**
+     * Get "PREV PROFILE" link in the navigation bar.
+     *
+     * @return a content tree for the previous link
+     */
+    public Content getNavLinkPrevious() {
+        Content li;
+        if (prevProfile == null) {
+            li = HtmlTree.LI(prevprofileLabel);
+        } else {
+            li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
+                    prevProfile.name)), prevprofileLabel, "", ""));
+        }
+        return li;
+    }
+
+    /**
+     * Get "NEXT PROFILE" link in the navigation bar.
+     *
+     * @return a content tree for the next link
+     */
+    public Content getNavLinkNext() {
+        Content li;
+        if (nextProfile == null) {
+            li = HtmlTree.LI(nextprofileLabel);
+        } else {
+            li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.profileSummary(
+                    nextProfile.name)), nextprofileLabel, "", ""));
+        }
+        return li;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
index f0b5e02..9018b77 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java
@@ -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
@@ -35,6 +35,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * Writes property documentation in HTML format.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Jamie Ho (rewrite)
@@ -61,67 +66,81 @@ public class PropertyWriterImpl extends AbstractMemberWriter
     /**
      * {@inheritDoc}
      */
-    public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
+    public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
             Content memberDetailsTree) {
         memberDetailsTree.addContent(HtmlConstants.START_OF_PROPERTY_DETAILS);
-        Content fieldDetailsTree = writer.getMemberTreeHeader();
-        fieldDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
+        Content propertyDetailsTree = writer.getMemberTreeHeader();
+        propertyDetailsTree.addContent(writer.getMarkerAnchor("property_detail"));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
                 writer.propertyDetailsLabel);
-        fieldDetailsTree.addContent(heading);
-        return fieldDetailsTree;
+        propertyDetailsTree.addContent(heading);
+        return propertyDetailsTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getFieldDocTreeHeader(MethodDoc field,
-            Content fieldDetailsTree) {
-        fieldDetailsTree.addContent(
-                writer.getMarkerAnchor(field.name()));
-        Content fieldDocTree = writer.getMemberTreeHeader();
+    public Content getPropertyDocTreeHeader(MethodDoc property,
+            Content propertyDetailsTree) {
+        propertyDetailsTree.addContent(
+                writer.getMarkerAnchor(property.name()));
+        Content propertyDocTree = writer.getMemberTreeHeader();
         Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
-        heading.addContent(field.name().substring(0, field.name().lastIndexOf("Property")));
-        fieldDocTree.addContent(heading);
-        return fieldDocTree;
+        heading.addContent(property.name().substring(0, property.name().lastIndexOf("Property")));
+        propertyDocTree.addContent(heading);
+        return propertyDocTree;
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getSignature(MethodDoc field) {
-        return new Comment("property signature");
+    public Content getSignature(MethodDoc property) {
+        Content pre = new HtmlTree(HtmlTag.PRE);
+        writer.addAnnotationInfo(property, pre);
+        addModifiers(property, pre);
+        Content propertylink = writer.getLink(new LinkInfoImpl(
+                configuration, LinkInfoImpl.Kind.MEMBER,
+                property.returnType()));
+        pre.addContent(propertylink);
+        pre.addContent(" ");
+        if (configuration.linksource) {
+            Content propertyName = new StringContent(property.name());
+            writer.addSrcLink(property, propertyName, pre);
+        } else {
+            addName(property.name(), pre);
+        }
+        return pre;
     }
 
     /**
      * {@inheritDoc}
      */
-    public void addDeprecated(MethodDoc field, Content fieldDocTree) {
+    public void addDeprecated(MethodDoc property, Content propertyDocTree) {
     }
 
     /**
      * {@inheritDoc}
      */
-    public void addComments(MethodDoc field, Content fieldDocTree) {
-        ClassDoc holder = field.containingClass();
-        if (field.inlineTags().length > 0) {
+    public void addComments(MethodDoc property, Content propertyDocTree) {
+        ClassDoc holder = property.containingClass();
+        if (property.inlineTags().length > 0) {
             if (holder.equals(classdoc) ||
-                    (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
-                writer.addInlineComment(field, fieldDocTree);
+                    (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) {
+                writer.addInlineComment(property, propertyDocTree);
             } else {
-                Content link = new RawHtml(
-                        writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
-                        holder, field,
+                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);
                 strong.addContent(writer.getSpace());
                 strong.addContent(codeLink);
-                fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
-                writer.addInlineComment(field, fieldDocTree);
+                propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
+                writer.addInlineComment(property, propertyDocTree);
             }
         }
     }
@@ -129,23 +148,23 @@ public class PropertyWriterImpl extends AbstractMemberWriter
     /**
      * {@inheritDoc}
      */
-    public void addTags(MethodDoc field, Content fieldDocTree) {
-        writer.addTagsInfo(field, fieldDocTree);
+    public void addTags(MethodDoc property, Content propertyDocTree) {
+        writer.addTagsInfo(property, propertyDocTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getFieldDetails(Content fieldDetailsTree) {
-        return getMemberTree(fieldDetailsTree);
+    public Content getPropertyDetails(Content propertyDetailsTree) {
+        return getMemberTree(propertyDetailsTree);
     }
 
     /**
      * {@inheritDoc}
      */
-    public Content getFieldDoc(Content fieldDocTree,
+    public Content getPropertyDoc(Content propertyDocTree,
             boolean isLastContent) {
-        return getMemberTree(fieldDocTree, isLastContent);
+        return getMemberTree(propertyDocTree, isLastContent);
     }
 
     /**
@@ -172,16 +191,16 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration().getText("doclet.Member_Table_Summary",
-                configuration().getText("doclet.Property_Summary"),
-                configuration().getText("doclet.properties"));
+        return configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Property_Summary"),
+                configuration.getText("doclet.properties"));
     }
 
     /**
      * {@inheritDoc}
      */
-    public String getCaption() {
-        return configuration().getText("doclet.Properties");
+    public Content getCaption() {
+        return configuration.getResource("doclet.Properties");
     }
 
     /**
@@ -189,10 +208,10 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      */
     public String[] getSummaryTableHeader(ProgramElementDoc member) {
         String[] header = new String[] {
-            configuration().getText("doclet.Type"),
-            configuration().getText("doclet.0_and_1",
-                    configuration().getText("doclet.Property"),
-                    configuration().getText("doclet.Description"))
+            configuration.getText("doclet.Type"),
+            configuration.getText("doclet.0_and_1",
+                    configuration.getText("doclet.Property"),
+                    configuration.getText("doclet.Description"))
         };
         return header;
     }
@@ -209,18 +228,18 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      */
     public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
         inheritedTree.addContent(writer.getMarkerAnchor(
-                "properties_inherited_from_class_" + configuration().getClassName(cd)));
+                "properties_inherited_from_class_" + configuration.getClassName(cd)));
     }
 
     /**
      * {@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"));
+            configuration.getText("doclet.Properties_Inherited_From_Class") :
+            configuration.getText("doclet.Properties_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
         labelHeading.addContent(writer.getSpace());
@@ -231,15 +250,15 @@ public class PropertyWriterImpl extends AbstractMemberWriter
     /**
      * {@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);
@@ -250,27 +269,27 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      */
     protected void addInheritedSummaryLink(ClassDoc cd,
             ProgramElementDoc member, Content linksTree) {
-        linksTree.addContent(new RawHtml(
-                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
-                ((member.name().lastIndexOf("Property") != -1) && Configuration.getJavafxJavadoc())
+        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));
     }
 
     /**
      * {@inheritDoc}
      */
     protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
-        MethodDoc method = (MethodDoc)member;
-        addModifierAndType(method, method.returnType(), tdSummaryType);
+        MethodDoc property = (MethodDoc)member;
+        addModifierAndType(property, property.returnType(), tdSummaryType);
     }
 
     /**
      * {@inheritDoc}
      */
     protected Content getDeprecatedLink(ProgramElementDoc member) {
-        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+        return writer.getDocLink(LinkInfoImpl.Kind.MEMBER,
                 (MemberDoc) member, ((MethodDoc)member).qualifiedName());
     }
 
@@ -279,10 +298,10 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      */
     protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
         if (link) {
-            return writer.getHyperLink("", (cd == null)?
+            return writer.getHyperLink((cd == null)?
                 "property_summary":
                 "properties_inherited_from_class_" +
-                configuration().getClassName(cd),
+                configuration.getClassName(cd),
                 writer.getResource("doclet.navProperty"));
         } else {
             return writer.getResource("doclet.navProperty");
@@ -294,7 +313,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter
      */
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
-            liNav.addContent(writer.getHyperLink("", "property_detail",
+            liNav.addContent(writer.getHyperLink("property_detail",
                     writer.getResource("doclet.navProperty")));
         } else {
             liNav.addContent(writer.getResource("doclet.navProperty"));
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
index 6d39f0a..23ef780 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, 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
@@ -29,40 +29,30 @@ import java.io.*;
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocPaths;
+import com.sun.tools.doclets.internal.toolkit.util.DocletAbortException;
 
 /**
  * Generate the Serialized Form Information Page.
  *
+ *  <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 Atul M Dambalkar
  */
 public class SerializedFormWriterImpl extends SubWriterHolderWriter
-    implements com.sun.tools.doclets.internal.toolkit.SerializedFormWriter {
-
-    private static final String FILE_NAME = "serialized-form.html";
+    implements SerializedFormWriter {
 
     /**
+     * @param configuration the configuration data for the doclet
      * @throws IOException
      * @throws DocletAbortException
      */
-    public SerializedFormWriterImpl() throws IOException {
-        super(ConfigurationImpl.getInstance(), FILE_NAME);
-    }
-
-    /**
-     * Writes the given header.
-     *
-     * @param header the header to write.
-     */
-    public void writeHeader(String header) {
-        printHtmlHeader(header, null, true);
-        printTop();
-        navLinks(true);
-        hr();
-        center();
-        h1();
-        print(header);
-        h1End();
-        centerEnd();
+    public SerializedFormWriterImpl(ConfigurationImpl configuration)
+            throws IOException {
+        super(configuration, DocPaths.SERIALIZED_FORM);
     }
 
     /**
@@ -137,28 +127,28 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
      * @return a content tree for the class header
      */
     public Content getClassHeader(ClassDoc classDoc) {
-        String classLink = (classDoc.isPublic() || classDoc.isProtected())?
-            getLink(new LinkInfoImpl(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(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
-                classDoc.superclassType())) :
+                getLink(new LinkInfoImpl(configuration,
+                        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;
     }
 
@@ -225,20 +215,10 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
     /**
      * {@inheritDoc}
      */
-    public void printDocument(Content serializedTree) {
+    public void printDocument(Content serializedTree) throws IOException {
         printHtmlDocument(null, true, serializedTree);
     }
 
-    private void tableHeader() {
-        tableIndexSummary();
-        trBgcolorStyle("#CCCCFF", "TableSubHeadingColor");
-    }
-
-    private void tableFooter() {
-        fontEnd();
-        thEnd(); trEnd(); tableEnd();
-    }
-
     /**
      * Return an instance of a SerialFieldWriter.
      *
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
index 6bbcae6..924557c 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,21 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
+
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate only one index file for all the Member Names with Indexing in
  * Unicode Order. The name of the generated file is "index-all.html" and it is
  * generated in current or the destination directory.
  *
+ *  <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>
+ *
  * @see java.lang.Character
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -49,11 +55,9 @@ public class SingleIndexWriter extends AbstractIndexWriter {
      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
      */
     public SingleIndexWriter(ConfigurationImpl configuration,
-                             String filename,
+                             DocPath filename,
                              IndexBuilder indexbuilder) throws IOException {
         super(configuration, filename, indexbuilder);
-        relativepathNoSlash = ".";
-        relativePath = "./";
     }
 
     /**
@@ -65,7 +69,7 @@ public class SingleIndexWriter extends AbstractIndexWriter {
     public static void generate(ConfigurationImpl configuration,
                                 IndexBuilder indexbuilder) {
         SingleIndexWriter indexgen;
-        String filename = "index-all.html";
+        DocPath filename = DocPaths.INDEX_ALL;
         try {
             indexgen = new SingleIndexWriter(configuration,
                                              filename, indexbuilder);
@@ -111,7 +115,7 @@ public class SingleIndexWriter extends AbstractIndexWriter {
         for (int i = 0; i < indexbuilder.elements().length; i++) {
             String unicode = (indexbuilder.elements())[i].toString();
             contentTree.addContent(
-                    getHyperLink("#_" + unicode + "_", new StringContent(unicode)));
+                    getHyperLink("_" + unicode + "_", new StringContent(unicode)));
             contentTree.addContent(getSpace());
         }
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
index 5fd7f88..9d528a9 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, 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,18 +26,21 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
+
 import javax.tools.FileObject;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * Converts Java Source Code to HTML.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -55,18 +58,26 @@ public class SourceToHTMLConverter {
     /**
      * 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;
+
+    private final RootDoc rootDoc;
+
+    private DocPath outputdir;
 
     /**
      * Relative path from the documentation root to the file that is being
      * generated.
      */
-    private static String relativePath = "";
+    private DocPath relativePath = DocPath.empty;
 
-    /**
-     * Source is converted to HTML using static methods below.
-     */
-    private SourceToHTMLConverter() {}
+    private SourceToHTMLConverter(ConfigurationImpl configuration, RootDoc rd,
+            DocPath outputdir) {
+        this.configuration  = configuration;
+        this.rootDoc = rd;
+        this.outputdir = outputdir;
+    }
 
     /**
      * Convert the Classes in the given RootDoc to an HTML.
@@ -76,42 +87,42 @@ public class SourceToHTMLConverter {
      * @param outputdir the name of the directory to output to.
      */
     public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
-            String outputdir) {
-        if (rd == null || outputdir == null) {
+            DocPath outputdir) {
+        new SourceToHTMLConverter(configuration, rd, outputdir).generate();
+    }
+
+    void generate() {
+        if (rootDoc == null || outputdir == null) {
             return;
         }
-        PackageDoc[] pds = rd.specifiedPackages();
+        PackageDoc[] pds = rootDoc.specifiedPackages();
         for (int i = 0; i < pds.length; i++) {
             // If -nodeprecated option is set and the package is marked as deprecated,
             // do not convert the package files to HTML.
             if (!(configuration.nodeprecated && Util.isDeprecated(pds[i])))
-                convertPackage(configuration, pds[i], outputdir);
+                convertPackage(pds[i], outputdir);
         }
-        ClassDoc[] cds = rd.specifiedClasses();
+        ClassDoc[] cds = rootDoc.specifiedClasses();
         for (int i = 0; i < cds.length; i++) {
             // If -nodeprecated option is set and the class is marked as deprecated
             // or the containing package is deprecated, do not convert the
             // package files to HTML.
             if (!(configuration.nodeprecated &&
                     (Util.isDeprecated(cds[i]) || Util.isDeprecated(cds[i].containingPackage()))))
-                convertClass(configuration, cds[i],
-                        getPackageOutputDir(outputdir, cds[i].containingPackage()));
+                convertClass(cds[i], outputdir);
         }
     }
 
     /**
      * Convert the Classes in the given Package to an HTML.
      *
-     * @param configuration the configuration.
      * @param pd the Package to convert.
      * @param outputdir the name of the directory to output to.
      */
-    public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
-            String outputdir) {
-        if (pd == null || outputdir == null) {
+    public void convertPackage(PackageDoc pd, DocPath outputdir) {
+        if (pd == null) {
             return;
         }
-        String classOutputdir = getPackageOutputDir(outputdir, pd);
         ClassDoc[] cds = pd.allClasses();
         for (int i = 0; i < cds.length; i++) {
             // If -nodeprecated option is set and the class is marked as deprecated,
@@ -119,32 +130,18 @@ public class SourceToHTMLConverter {
             // containing package deprecation since it is already check in
             // the calling method above.
             if (!(configuration.nodeprecated && Util.isDeprecated(cds[i])))
-                convertClass(configuration, cds[i], classOutputdir);
+                convertClass(cds[i], outputdir);
         }
     }
 
     /**
-     * Return the directory write output to for the given package.
-     *
-     * @param outputDir the directory to output to.
-     * @param pd the Package to generate output for.
-     * @return the package output directory as a String.
-     */
-    private static String getPackageOutputDir(String outputDir, PackageDoc pd) {
-        return outputDir + File.separator +
-            DirectoryManager.getDirectoryPath(pd) + File.separator;
-    }
-
-    /**
      * Convert the given Class to an HTML.
      *
-     * @param configuration the configuration.
      * @param cd the class to convert.
      * @param outputdir the name of the directory to output to.
      */
-    public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
-            String outputdir) {
-        if (cd == null || outputdir == null) {
+    public void convertClass(ClassDoc cd, DocPath outputdir) {
+        if (cd == null) {
             return;
         }
         try {
@@ -167,14 +164,15 @@ public class SourceToHTMLConverter {
             LineNumberReader reader = new LineNumberReader(r);
             int lineno = 1;
             String line;
-            relativePath = DirectoryManager.getRelativePath(DocletConstants.SOURCE_OUTPUT_DIR_NAME) +
-                    DirectoryManager.getRelativePath(cd.containingPackage());
+            relativePath = DocPaths.SOURCE_OUTPUT
+                    .resolve(DocPath.forPackage(cd))
+                    .invert();
             Content body = getHeader();
             Content pre = new HtmlTree(HtmlTag.PRE);
             try {
                 while ((line = reader.readLine()) != null) {
                     addLineNo(pre, lineno);
-                    addLine(pre, line, configuration.sourcetab, lineno);
+                    addLine(pre, line, lineno);
                     lineno++;
                 }
             } finally {
@@ -183,8 +181,8 @@ public class SourceToHTMLConverter {
             addBlankLines(pre);
             Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
             body.addContent(div);
-            writeToFile(body, outputdir, cd.name(), configuration);
-        } catch (Exception e){
+            writeToFile(body, outputdir.resolve(DocPath.forClass(cd)));
+        } catch (IOException e) {
             e.printStackTrace();
         }
     }
@@ -193,50 +191,44 @@ public class SourceToHTMLConverter {
      * Write the output to the file.
      *
      * @param body the documentation content to be written to the file.
-     * @param outputDir the directory to output to.
-     * @param className the name of the class that I am converting to HTML.
-     * @param configuration the Doclet configuration to pass notices to.
+     * @param path the path for the file.
      */
-    private static void writeToFile(Content body, String outputDir,
-            String className, ConfigurationImpl configuration) throws IOException {
-        Content htmlDocType = DocType.Transitional();
+    private void writeToFile(Content body, DocPath path) throws IOException {
+        Content htmlDocType = DocType.TRANSITIONAL;
         Content head = new HtmlTree(HtmlTag.HEAD);
         head.addContent(HtmlTree.TITLE(new StringContent(
                 configuration.getText("doclet.Window_Source_title"))));
-        head.addContent(getStyleSheetProperties(configuration));
+        head.addContent(getStyleSheetProperties());
         Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
                 head, body);
         Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
-        File dir = new File(outputDir);
-        dir.mkdirs();
-        File newFile = new File(dir, className + ".html");
-        configuration.message.notice("doclet.Generating_0", newFile.getPath());
-        FileOutputStream fout = new FileOutputStream(newFile);
-        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fout));
-        bw.write(htmlDocument.toString());
-        bw.close();
-        fout.close();
+        configuration.message.notice("doclet.Generating_0", path.getPath());
+        DocFile df = DocFile.createFileForOutput(configuration, path);
+        Writer w = df.openWriter();
+        try {
+            htmlDocument.write(w, true);
+        } finally {
+            w.close();
+        }
+
     }
 
     /**
      * Returns a link to the stylesheet file.
      *
-     * @param configuration the doclet configuration for the current run of javadoc
      * @return an HtmlTree for the lINK tag which provides the stylesheet location
      */
-    public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
+    public HtmlTree getStyleSheetProperties() {
         String filename = configuration.stylesheetfile;
+        DocPath stylesheet;
         if (filename.length() > 0) {
-            File stylefile = new File(filename);
-            String parent = stylefile.getParent();
-            filename = (parent == null)?
-                filename:
-                filename.substring(parent.length() + 1);
+            DocFile file = DocFile.createFileForInput(configuration, filename);
+            stylesheet = DocPath.create(file.getName());
         } else {
-            filename = "stylesheet.css";
+            stylesheet = DocPaths.STYLESHEET;
         }
-        filename = relativePath + filename;
-        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
+        DocPath p = relativePath.resolve(stylesheet);
+        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", p.getPath(), "Style");
         return link;
     }
 
@@ -273,15 +265,11 @@ public class SourceToHTMLConverter {
      *
      * @param pre the content tree to which the line will be added.
      * @param line the string to format.
-     * @param tabLength the number of spaces for each tab.
      * @param currentLineNo the current number.
      */
-    private static void addLine(Content pre, String line, int tabLength,
-            int currentLineNo) {
+    private void addLine(Content pre, String line, int currentLineNo) {
         if (line != null) {
-            StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
-            Util.replaceTabs(tabLength, lineBuffer);
-            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);
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
index 9d60873..69f273e 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,21 @@
 package com.sun.tools.doclets.formats.html;
 
 import java.io.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
+
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate Separate Index Files for all the member names with Indexing in
  * Unicode Order. This will create "index-files" directory in the current or
  * destination directory and will generate separate file for each unicode index.
  *
+ *  <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>
+ *
  * @see java.lang.Character
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
@@ -56,15 +62,13 @@ public class SplitIndexWriter extends AbstractIndexWriter {
      * from this file.
      *
      * @param path       Path to the file which is getting generated.
-     * @param filename   Name of the file which is getting genrated.
-     * @param relpath    Relative path from this file to the current directory.
      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
      */
     public SplitIndexWriter(ConfigurationImpl configuration,
-                            String path, String filename,
-                            String relpath, IndexBuilder indexbuilder,
+                            DocPath path,
+                            IndexBuilder indexbuilder,
                             int prev, int next) throws IOException {
-        super(configuration, path, filename, relpath, indexbuilder);
+        super(configuration, path, indexbuilder);
         this.prev = prev;
         this.next = next;
     }
@@ -79,17 +83,16 @@ public class SplitIndexWriter extends AbstractIndexWriter {
     public static void generate(ConfigurationImpl configuration,
                                 IndexBuilder indexbuilder) {
         SplitIndexWriter indexgen;
-        String filename = "";
-        String path = DirectoryManager.getPath("index-files");
-        String relpath = DirectoryManager.getRelativePath("index-files");
+        DocPath filename = DocPath.empty;
+        DocPath path = DocPaths.INDEX_FILES;
         try {
             for (int i = 0; i < indexbuilder.elements().length; i++) {
                 int j = i + 1;
                 int prev = (j == 1)? -1: i;
                 int next = (j == indexbuilder.elements().length)? -1: j + 1;
-                filename = "index-" + j +".html";
+                filename = DocPaths.indexN(j);
                 indexgen = new SplitIndexWriter(configuration,
-                                                path, filename, relpath,
+                                                path.resolve(filename),
                                                 indexbuilder, prev, next);
                 indexgen.generateIndexFile((Character)indexbuilder.
                                                                  elements()[i]);
@@ -98,7 +101,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
         } catch (IOException exc) {
             configuration.standardmessage.error(
                         "doclet.exception_encountered",
-                        exc.toString(), filename);
+                        exc.toString(), filename.getPath());
             throw new DocletAbortException();
         }
     }
@@ -136,7 +139,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
         Object[] unicodeChars = indexbuilder.elements();
         for (int i = 0; i < unicodeChars.length; i++) {
             int j = i + 1;
-            contentTree.addContent(getHyperLink("index-" + j + ".html",
+            contentTree.addContent(getHyperLink(DocPaths.indexN(j),
                     new StringContent(unicodeChars[i].toString())));
             contentTree.addContent(getSpace());
         }
@@ -153,7 +156,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
             return HtmlTree.LI(prevletterLabel);
         }
         else {
-            Content prevLink = getHyperLink("index-" + prev + ".html", "",
+            Content prevLink = getHyperLink(DocPaths.indexN(prev),
                     prevletterLabel);
             return HtmlTree.LI(prevLink);
         }
@@ -170,7 +173,7 @@ public class SplitIndexWriter extends AbstractIndexWriter {
             return HtmlTree.LI(nextletterLabel);
         }
         else {
-            Content nextLink = getHyperLink("index-" + next + ".html","",
+            Content nextLink = getHyperLink(DocPaths.indexN(next),
                     nextletterLabel);
             return HtmlTree.LI(nextLink);
         }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
index 6790b73..94bde2e 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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,10 +26,12 @@
 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.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
  * This abstract class exists to provide functionality needed in the
@@ -39,6 +41,11 @@ import com.sun.tools.doclets.formats.html.markup.*;
  * can not be used effectively to change formatting.  The concrete
  * class subclass of this class can be subclassed to change formatting.
  *
+ *  <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>
+ *
  * @see AbstractMemberWriter
  * @see ClassWriterImpl
  *
@@ -48,30 +55,11 @@ import com.sun.tools.doclets.formats.html.markup.*;
  */
 public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
 
-    public SubWriterHolderWriter(ConfigurationImpl configuration,
-                                 String filename) throws IOException {
+    public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
+            throws IOException {
         super(configuration, filename);
     }
 
-
-    public SubWriterHolderWriter(ConfigurationImpl configuration,
-                                 String path, String filename, String relpath)
-                                 throws IOException {
-        super(configuration, path, filename, relpath);
-    }
-
-    public void printTypeSummaryHeader() {
-        tdIndex();
-        font("-1");
-        code();
-    }
-
-    public void printTypeSummaryFooter() {
-        codeEnd();
-        fontEnd();
-        tdEnd();
-    }
-
     /**
      * Add the summary header.
      *
@@ -90,21 +78,66 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
      *
      * @param mw the writer for the member being documented
      * @param cd the classdoc to be documented
+     * @param tableContents list of summary table contents
+     * @param showTabs true if the table needs to show tabs
      * @return the content tree for the summary table
      */
-    public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
+    public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd,
+            List<Content> tableContents, boolean showTabs) {
+        Content caption;
+        if (showTabs) {
+            caption = getTableCaption(mw.methodTypes);
+            generateMethodTypesScript(mw.typeMap, mw.methodTypes);
+        }
+        else {
+            caption = getTableCaption(mw.getCaption());
+        }
         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
-                mw.getTableSummary(), getTableCaption(mw.getCaption()));
+                mw.getTableSummary(), caption);
         table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
+        for (int i = 0; i < tableContents.size(); i++) {
+            table.addContent(tableContents.get(i));
+        }
         return table;
     }
 
-    public void printTableHeadingBackground(String str) {
-        tableIndexDetail();
-        tableHeaderStart("#CCCCFF", 1);
-        strong(str);
-        tableHeaderEnd();
-        tableEnd();
+    /**
+     * Get the summary table caption.
+     *
+     * @param methodTypes set comprising of method types to show as table caption
+     * @return the caption for the summary table
+     */
+    public Content getTableCaption(Set<MethodTypes> methodTypes) {
+        Content tabbedCaption = new HtmlTree(HtmlTag.CAPTION);
+        for (MethodTypes type : methodTypes) {
+            Content captionSpan;
+            Content span;
+            if (type.isDefaultTab()) {
+                captionSpan = HtmlTree.SPAN(new StringContent(type.text()));
+                span = HtmlTree.SPAN(type.tabId(),
+                        HtmlStyle.activeTableTab, captionSpan);
+            } else {
+                captionSpan = HtmlTree.SPAN(getMethodTypeLinks(type));
+                span = HtmlTree.SPAN(type.tabId(),
+                        HtmlStyle.tableTab, captionSpan);
+            }
+            Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
+            span.addContent(tabSpan);
+            tabbedCaption.addContent(span);
+        }
+        return tabbedCaption;
+    }
+
+    /**
+     * Get the method type links for the table caption.
+     *
+     * @param methodType the method type to be displayed as link
+     * @return the content tree for the method type link
+     */
+    public Content getMethodTypeLinks(MethodTypes methodType) {
+        String jsShow = "javascript:show(" + methodType.value() +");";
+        HtmlTree link = HtmlTree.A(jsShow, new StringContent(methodType.text()));
+        return link;
     }
 
     /**
@@ -120,19 +153,6 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
         mw.addInheritedSummaryLabel(cd, inheritedTree);
     }
 
-    public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
-        tableEnd();
-        space();
-    }
-
-    public void printInheritedSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
-        codeEnd();
-        summaryRowEnd();
-        trEnd();
-        tableEnd();
-        space();
-    }
-
     /**
      * Add the index comment.
      *
@@ -143,24 +163,6 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
         addIndexComment(member, member.firstSentenceTags(), contentTree);
     }
 
-    protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
-        Tag[] deprs = member.tags("deprecated");
-        if (Util.isDeprecated((ProgramElementDoc) member)) {
-            strongText("doclet.Deprecated");
-            space();
-            if (deprs.length > 0) {
-                printInlineDeprecatedComment(member, deprs[0]);
-            }
-            return;
-        } else {
-            ClassDoc cd = ((ProgramElementDoc)member).containingClass();
-            if (cd != null && Util.isDeprecated(cd)) {
-                strongText("doclet.Deprecated"); space();
-            }
-        }
-        printSummaryComment(member, firstSentenceTags);
-    }
-
     /**
      * Add the index comment.
      *
@@ -217,18 +219,6 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
         addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
     }
 
-    public void printSummaryLinkComment(AbstractMemberWriter mw,
-                                        ProgramElementDoc member,
-                                        Tag[] firstSentenceTags) {
-        codeEnd();
-        println();
-        br();
-        printNbsps();
-        printIndexComment(member, firstSentenceTags);
-        summaryRowEnd();
-        trEnd();
-    }
-
     /**
      * Add the summary link comment.
      *
@@ -259,13 +249,6 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
         mw.addInheritedSummaryLink(cd, member, linksTree);
     }
 
-    public void printMemberHeader() {
-        hr();
-    }
-
-    public void printMemberFooter() {
-    }
-
     /**
      * Get the document content header tree
      *
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
deleted file mode 100644
index 9fb3bcd..0000000
--- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2003, 2009, 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.
- *
- * @since 1.5
- * @author Jamie Ho
- */
-
-public class TagletOutputImpl implements TagletOutput {
-
-    private StringBuffer output;
-
-    public TagletOutputImpl(String o) {
-        setOutput(o);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOutput (Object o) {
-        output = new StringBuffer(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());
-    }
-}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
index f0b4978..1939d68 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
@@ -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
@@ -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.*;
@@ -34,6 +39,11 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 /**
  * The taglet writer that writes HTML.
  *
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -41,47 +51,60 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
 
 public class TagletWriterImpl extends TagletWriter {
 
-    private HtmlDocletWriter htmlWriter;
+    private final HtmlDocletWriter htmlWriter;
+    private final ConfigurationImpl configuration;
 
     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
+        super(isFirstSentence);
         this.htmlWriter = htmlWriter;
-        this.isFirstSentence = isFirstSentence;
+        configuration = htmlWriter.configuration;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Content getOutputInstance() {
+        return new ContentBuilder();
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getOutputInstance() {
-        return new TagletOutputImpl("");
+    protected Content codeTagOutput(Tag tag) {
+        Content result = HtmlTree.CODE(new StringContent(tag.text()));
+        return result;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getDocRootOutput() {
-        if (htmlWriter.configuration.docrootparent.length() > 0)
-            return new TagletOutputImpl(htmlWriter.configuration.docrootparent);
+    public Content getDocRootOutput() {
+        String path;
+        if (configuration.docrootparent.length() > 0)
+            path = configuration.docrootparent;
+        else if (htmlWriter.pathToRoot.isEmpty())
+            path = ".";
         else
-            return new TagletOutputImpl(htmlWriter.relativepathNoSlash);
+            path = htmlWriter.pathToRoot.getPath();
+        return new StringContent(path);
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput deprecatedTagOutput(Doc doc) {
-        StringBuffer output = new StringBuffer();
+    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\">" +
-                    ConfigurationImpl.getInstance().
-                        getText("doclet.Deprecated") + "</span> ");
+                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)
                         );
                     }
                 }
@@ -89,217 +112,243 @@ public class TagletWriterImpl extends TagletWriter {
         } else {
             MemberDoc member = (MemberDoc) doc;
             if (Util.isDeprecated((ProgramElementDoc) doc)) {
-                output.append("<span class=\"strong\">" +
-                    ConfigurationImpl.getInstance().
-                            getText("doclet.Deprecated") + "</span> ");
+                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\">" +
-                    ConfigurationImpl.getInstance().
-                            getText("doclet.Deprecated") + "</span> ");
+                    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;
     }
 
     /**
      * {@inheritDoc}
      */
     public MessageRetriever getMsgRetriever() {
-        return htmlWriter.configuration.message;
+        return configuration.message;
     }
 
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getParamHeader(String header) {
-        StringBuffer result = new StringBuffer();
-        result.append("<dt>");
-        result.append("<span class=\"strong\">" +  header + "</span></dt>");
-        return new TagletOutputImpl(result.toString());
+    public Content getParamHeader(String header) {
+        HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.strong,
+                new StringContent(header)));
+        return result;
     }
 
     /**
      * {@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 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 TagletOutput returnTagOutput(Tag returnTag) {
-        TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<dt>" +
-            "<span class=\"strong\">" + htmlWriter.configuration.getText("doclet.Returns") +
-            "</span>" + "</dt>" + "<dd>" +
-            htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
-            false) + "</dd>");
+    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 TagletOutput seeTagOutput(Doc holder, SeeTag[] seeTags) {
-        String result = "";
+    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 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);
-            result += htmlWriter.getHyperLinkString(htmlWriter.relativePath +
-                ConfigurationImpl.CONSTANTS_FILE_NAME
-                + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
-                + "." + ((FieldDoc) holder).name(),
-                htmlWriter.configuration.getText("doclet.Constants_Summary"));
+            appendSeparatorIfNotEmpty(body);
+            DocPath constantsPath =
+                    htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES);
+            String whichConstant =
+                    ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name();
+            DocLink link = constantsPath.fragment(whichConstant);
+            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);
-                result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html",
-                        ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+                appendSeparatorIfNotEmpty(body);
+                DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM);
+                DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName());
+                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\">" +
-                    htmlWriter.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>";
+    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) {
-                result += ", ";
+                body.addContent(", ");
             }
-            result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
+            body.addContent(htmlWriter.commentTagsToContent(
+                    simpleTags[i], null, simpleTags[i].inlineTags(), false));
         }
-        result += "</dd>" + DocletConstants.NL;
-        return new TagletOutputImpl(result);
+        result.addContent(HtmlTree.DD(body));
+        return 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 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 TagletOutput getThrowsHeader() {
-        return new TagletOutputImpl(DocletConstants.NL + "<dt>" + "<span class=\"strong\">" +
-            htmlWriter.configuration().getText("doclet.Throws") + "</span></dt>");
+    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(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(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);
     }
 
     /**
      * {@inheritDoc}
      */
     public Configuration configuration() {
-        return htmlWriter.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("");
+        return configuration;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
index e116fe4..f51a834 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -28,9 +28,9 @@ package com.sun.tools.doclets.formats.html;
 import java.io.*;
 
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Generate Class Hierarchy page for all the Classes in this run.  Use
@@ -38,6 +38,11 @@ import com.sun.tools.doclets.internal.toolkit.*;
  * the generated file is "overview-tree.html" and it is generated in the
  * current or the destination directory.
  *
+ *  <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 Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
@@ -62,7 +67,7 @@ public class TreeWriter extends AbstractTreeWriter {
      * @param classtree the tree being built.
      */
     public TreeWriter(ConfigurationImpl configuration,
-            String filename, ClassTree classtree)
+            DocPath filename, ClassTree classtree)
     throws IOException {
         super(configuration, filename, classtree);
         packages = configuration.packages;
@@ -79,7 +84,7 @@ public class TreeWriter extends AbstractTreeWriter {
     public static void generate(ConfigurationImpl configuration,
                                 ClassTree classtree) {
         TreeWriter treegen;
-        String filename = "overview-tree.html";
+        DocPath filename = DocPaths.OVERVIEW_TREE;
         try {
             treegen = new TreeWriter(configuration, filename, classtree);
             treegen.generateTreeFile();
@@ -139,9 +144,9 @@ public class TreeWriter extends AbstractTreeWriter {
                         (configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
                     continue;
                 }
-                String link = pathString(packages[i], "package-tree.html");
+                DocPath link = pathString(packages[i], DocPaths.PACKAGE_TREE);
                 Content li = HtmlTree.LI(getHyperLink(
-                        link, "", new StringContent(packages[i].name())));
+                        link, new StringContent(packages[i].name())));
                 if (i < packages.length - 1) {
                     li.addContent(", ");
                 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
index ddbb719..b8a1775 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/WriterFactoryImpl.java
@@ -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,19 +25,27 @@
 
 package com.sun.tools.doclets.formats.html;
 
+import java.io.IOException;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 
 /**
  * The factory that returns HTML writers.
  *
+ *  <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 class WriterFactoryImpl implements WriterFactory {
 
-    private ConfigurationImpl configuration;
+    private final ConfigurationImpl configuration;
 
     public WriterFactoryImpl(ConfigurationImpl configuration) {
         this.configuration = configuration;
@@ -55,17 +63,35 @@ public class WriterFactoryImpl implements WriterFactory {
      */
     public PackageSummaryWriter getPackageSummaryWriter(PackageDoc packageDoc,
         PackageDoc prevPkg, PackageDoc nextPkg) throws Exception {
-        return new PackageWriterImpl(ConfigurationImpl.getInstance(), packageDoc,
+        return new PackageWriterImpl(configuration, packageDoc,
             prevPkg, nextPkg);
     }
 
     /**
      * {@inheritDoc}
      */
+    public ProfileSummaryWriter getProfileSummaryWriter(Profile profile,
+        Profile prevProfile, Profile nextProfile) throws Exception {
+        return new ProfileWriterImpl(configuration, profile,
+            prevProfile, nextProfile);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ProfilePackageSummaryWriter getProfilePackageSummaryWriter(PackageDoc packageDoc,
+        PackageDoc prevPkg, PackageDoc nextPkg, Profile profile) throws Exception {
+        return new ProfilePackageWriterImpl(configuration, packageDoc,
+            prevPkg, nextPkg, profile);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public ClassWriter getClassWriter(ClassDoc classDoc, ClassDoc prevClass,
-            ClassDoc nextClass, ClassTree classTree)
-            throws Exception {
-        return new ClassWriterImpl(classDoc, prevClass, nextClass, classTree);
+            ClassDoc nextClass, ClassTree classTree) throws IOException {
+        return new ClassWriterImpl(configuration, classDoc,
+                prevClass, nextClass, classTree);
     }
 
     /**
@@ -74,7 +100,8 @@ public class WriterFactoryImpl implements WriterFactory {
     public AnnotationTypeWriter getAnnotationTypeWriter(
         AnnotationTypeDoc annotationType, Type prevType, Type nextType)
     throws Exception {
-        return new AnnotationTypeWriterImpl(annotationType, prevType, nextType);
+        return new AnnotationTypeWriterImpl(configuration,
+                annotationType, prevType, nextType);
     }
 
     /**
@@ -101,7 +128,7 @@ public class WriterFactoryImpl implements WriterFactory {
     /**
      * {@inheritDoc}
      */
-    public EnumConstantWriter getEnumConstantWriter(ClassWriter classWriter)
+    public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter)
             throws Exception {
         return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -110,7 +137,7 @@ public class WriterFactoryImpl implements WriterFactory {
     /**
      * {@inheritDoc}
      */
-    public FieldWriter getFieldWriter(ClassWriter classWriter)
+    public FieldWriterImpl getFieldWriter(ClassWriter classWriter)
             throws Exception {
         return new FieldWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -119,7 +146,7 @@ public class WriterFactoryImpl implements WriterFactory {
     /**
      * {@inheritDoc}
      */
-    public PropertyWriter getPropertyWriter(ClassWriter classWriter)
+    public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter)
             throws Exception {
         return new PropertyWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -128,7 +155,7 @@ public class WriterFactoryImpl implements WriterFactory {
     /**
      * {@inheritDoc}
      */
-    public  MethodWriter getMethodWriter(ClassWriter classWriter)
+    public MethodWriterImpl getMethodWriter(ClassWriter classWriter)
             throws Exception {
         return new MethodWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -137,7 +164,7 @@ public class WriterFactoryImpl implements WriterFactory {
     /**
      * {@inheritDoc}
      */
-    public ConstructorWriter getConstructorWriter(ClassWriter classWriter)
+    public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter)
             throws Exception {
         return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter,
             classWriter.getClassDoc());
@@ -147,22 +174,22 @@ public class WriterFactoryImpl implements WriterFactory {
      * {@inheritDoc}
      */
     public MemberSummaryWriter getMemberSummaryWriter(
-        ClassWriter classWriter, int memberType)
-    throws Exception {
+            ClassWriter classWriter, int memberType)
+            throws Exception {
         switch (memberType) {
             case VisibleMemberMap.CONSTRUCTORS:
-                return (ConstructorWriterImpl) getConstructorWriter(classWriter);
+                return getConstructorWriter(classWriter);
             case VisibleMemberMap.ENUM_CONSTANTS:
-                return (EnumConstantWriterImpl) getEnumConstantWriter(classWriter);
+                return getEnumConstantWriter(classWriter);
             case VisibleMemberMap.FIELDS:
-                return (FieldWriterImpl) getFieldWriter(classWriter);
+                return getFieldWriter(classWriter);
             case VisibleMemberMap.PROPERTIES:
-                return (PropertyWriterImpl) getPropertyWriter(classWriter);
+                return getPropertyWriter(classWriter);
             case VisibleMemberMap.INNERCLASSES:
                 return new NestedClassWriterImpl((SubWriterHolderWriter)
                     classWriter, classWriter.getClassDoc());
             case VisibleMemberMap.METHODS:
-                return (MethodWriterImpl) getMethodWriter(classWriter);
+                return getMethodWriter(classWriter);
             default:
                 return null;
         }
@@ -190,6 +217,6 @@ public class WriterFactoryImpl implements WriterFactory {
      * {@inheritDoc}
      */
     public SerializedFormWriter getSerializedFormWriter() throws Exception {
-        return new SerializedFormWriterImpl();
+        return new SerializedFormWriterImpl(configuration);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
index 86fea13..533c9b7 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,15 +25,23 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating a comment for HTML pages of javadoc 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 Bhavesh Patel
  */
-public class Comment extends Content{
+public class Comment extends Content {
 
     private String commentText;
 
@@ -80,11 +88,13 @@ public class Comment extends Content{
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
-        if (!endsWithNewLine(contentBuilder))
-            contentBuilder.append(DocletConstants.NL);
-        contentBuilder.append("<!-- ");
-        contentBuilder.append(commentText);
-        contentBuilder.append(" -->" + DocletConstants.NL);
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        if (!atNewline)
+            out.write(DocletConstants.NL);
+        out.write("<!-- ");
+        out.write(commentText);
+        out.write(" -->" + DocletConstants.NL);
+        return true;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java
new file mode 100644
index 0000000..a586627
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/ContentBuilder.java
@@ -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>();
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
index 03265d2..0e586b4 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,21 +25,31 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating document type for HTML pages of javadoc 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 Bhavesh Patel
  */
-public class DocType extends Content{
+public class DocType extends Content {
 
     private String docType;
 
-    private static DocType transitional;
+    public static final DocType TRANSITIONAL =
+            new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
 
-    private static DocType frameset;
+    public static final DocType FRAMESET =
+            new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
 
     /**
      * Constructor to construct a DocType object.
@@ -51,28 +61,6 @@ public class DocType extends Content{
                 "//EN\" \"" + dtd + "\">" + DocletConstants.NL;
     }
 
-     /**
-     * Construct and return a HTML 4.01 transitional DocType content
-     *
-     * @return a content tree for transitional DocType
-     */
-    public static DocType Transitional() {
-        if (transitional == null)
-            transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
-        return transitional;
-    }
-
-    /**
-     * Construct and return a HTML 4.01 frameset DocType content
-     *
-     * @return a content tree for frameset DocType
-     */
-    public static DocType Frameset() {
-        if (frameset == null)
-            frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
-        return frameset;
-    }
-
     /**
      * This method is not supported by the class.
      *
@@ -107,7 +95,9 @@ public class DocType extends Content{
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
-        contentBuilder.append(docType);
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        out.write(docType);
+        return true; // guaranteed by constructor
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java
index 9689553..62b0f60 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -28,6 +28,11 @@ package com.sun.tools.doclets.formats.html.markup;
 /**
  * Enum representing HTML tag attributes.
  *
+ *  <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 Bhavesh Patel
  */
 public enum HtmlAttr {
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java
index 9b1f9d6..7c32503 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java
@@ -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
@@ -30,6 +30,11 @@ import com.sun.tools.doclets.internal.toolkit.Content;
 /**
  * Stores constants for Html Doclet.
  *
+ *  <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 Bhavesh Patel
  */
 public class HtmlConstants {
@@ -175,6 +180,11 @@ public class HtmlConstants {
     public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
 
     /**
+     * Html tag for the profile name heading.
+     */
+    public static final HtmlTag PROFILE_HEADING = HtmlTag.H2;
+
+    /**
      * Html tag for the member summary heading.
      */
     public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3;
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
index 979c72b..c0048f9 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, 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
@@ -29,7 +29,11 @@ import java.io.*;
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.formats.html.ConfigurationImpl;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.DocFile;
+import com.sun.tools.doclets.internal.toolkit.util.DocLink;
+import com.sun.tools.doclets.internal.toolkit.util.DocPath;
 
 
 /**
@@ -38,6 +42,11 @@ import com.sun.tools.doclets.internal.toolkit.*;
  * are used by the Sub-Classes in the package com.sun.tools.doclets.standard
  * and com.sun.tools.doclets.oneone.
  *
+ *  <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.2
  * @author Atul M Dambalkar
  * @author Robert Field
@@ -50,25 +59,11 @@ public abstract class HtmlDocWriter extends HtmlWriter {
      *
      * @param filename String file name.
      */
-    public HtmlDocWriter(Configuration configuration,
-                         String filename) throws IOException {
-        super(configuration,
-              null, configuration.destDirName + filename,
-              configuration.docencoding);
-        // use File to normalize file separators
-        configuration.message.notice("doclet.Generating_0",
-            new File(configuration.destDirName, filename));
-    }
-
-    public HtmlDocWriter(Configuration configuration,
-                         String path, String filename) throws IOException {
-        super(configuration,
-              configuration.destDirName + path, filename,
-              configuration.docencoding);
-        // use File to normalize file separators
+    public HtmlDocWriter(Configuration configuration, DocPath filename)
+            throws IOException {
+        super(configuration, filename);
         configuration.message.notice("doclet.Generating_0",
-            new File(configuration.destDirName,
-                    ((path.length() > 0)? path + File.separator: "") + filename));
+            DocFile.createFileForOutput(configuration, filename).getPath());
     }
 
     /**
@@ -76,161 +71,84 @@ public abstract class HtmlDocWriter extends HtmlWriter {
      */
     public abstract Configuration configuration();
 
-    /**
-     * Print Html Hyper Link.
-     *
-     * @param link String name of the file.
-     * @param where Position of the link in the file. Character '#' is not
-     * needed.
-     * @param label Tag for the link.
-     * @param strong  Boolean that sets label to strong.
-     */
-    public void printHyperLink(String link, String where,
-                               String label, boolean strong) {
-        print(getHyperLinkString(link, where, label, strong, "", "", ""));
+    public Content getHyperLink(DocPath link, String label) {
+        return getHyperLink(link, new StringContent(label), false, "", "", "");
     }
 
     /**
-     * Print Html Hyper Link.
-     *
-     * @param link String name of the file.
-     * @param where Position of the link in the file. Character '#' is not
-     * needed.
-     * @param label Tag for the link.
-     */
-    public void printHyperLink(String link, String where, String label) {
-        printHyperLink(link, where, label, false);
-    }
-
-    /**
-     * Print Html Hyper Link.
+     * Get Html Hyper Link string.
      *
-     * @param link       String name of the file.
      * @param where      Position of the link in the file. Character '#' is not
-     * needed.
+     *                   needed.
      * @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 a content tree for the hyper link
      */
-    public void printHyperLink(String link, String where,
-                               String label, boolean strong,
-                               String stylename) {
-        print(getHyperLinkString(link, where, label, strong, stylename, "", ""));
+    public Content getHyperLink(String where,
+                               Content label) {
+        return getHyperLink(DocLink.fragment(where), label, "", "");
     }
 
     /**
-     * Return Html Hyper Link string.
+     * Get Html hyperlink.
      *
-     * @param link       String name of the file.
-     * @param where      Position of the link in the file. Character '#' is not
-     * needed.
+     * @param link       path of the file.
      * @param label      Tag for the link.
-     * @param strong       Boolean that sets label to strong.
-     * @return String    Hyper Link.
+     * @return a content tree for the hyper link
      */
-    public String getHyperLinkString(String link, String where,
-                               String label, boolean strong) {
-        return getHyperLinkString(link, where, label, strong, "", "", "");
+    public Content getHyperLink(DocPath link, Content label) {
+        return getHyperLink(link, label, "", "");
     }
 
-    /**
-     * Get Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param where      Position of the link in the file. Character '#' is not
-     *                   needed.
-     * @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(String link, String where,
-                               String label, boolean strong,
-                               String stylename) {
-        return getHyperLinkString(link, where, label, strong, stylename, "", "");
+    public Content getHyperLink(DocLink link, Content label) {
+        return getHyperLink(link, label, "", "");
     }
 
-    /**
-     * Get Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param where      Position of the link in the file. Character '#' is not
-     *                   needed.
-     * @param label      Tag for the link.
-     * @return a content tree for the hyper link
-     */
-    public Content getHyperLink(String link, String where,
-                               Content label) {
-        return getHyperLink(link, where, label, "", "");
+    public Content getHyperLink(DocPath link,
+                               Content label, boolean strong,
+                               String stylename, String title, String target) {
+        return getHyperLink(new DocLink(link), label, strong,
+                stylename, title, target);
     }
 
-    /**
-     * Get Html Hyper Link string.
-     *
-     * @param link       String name of the file.
-     * @param where      Position of the link in the file. Character '#' is not
-     *                   needed.
-     * @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 link's content for accessibility.
-     * @param target     Target frame.
-     * @return String    Hyper Link.
-     */
-    public String getHyperLinkString(String link, String where,
-                               String label, boolean strong,
+    public Content getHyperLink(DocLink link,
+                               Content label, boolean strong,
                                String stylename, String title, String target) {
-        StringBuffer retlink = new StringBuffer();
-        retlink.append("<a href=\"");
-        retlink.append(link);
-        if (where != null && where.length() != 0) {
-            retlink.append("#");
-            retlink.append(where);
-        }
-        retlink.append("\"");
-        if (title != null && title.length() != 0) {
-            retlink.append(" title=\"" + title + "\"");
-        }
-        if (target != null && target.length() != 0) {
-            retlink.append(" target=\"" + target + "\"");
+        Content body = label;
+        if (strong) {
+            body = HtmlTree.SPAN(HtmlStyle.strong, body);
         }
-        retlink.append(">");
         if (stylename != null && stylename.length() != 0) {
-            retlink.append("<FONT CLASS=\"");
-            retlink.append(stylename);
-            retlink.append("\">");
-        }
-        if (strong) {
-            retlink.append("<span class=\"strong\">");
+            HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
+            t.addAttr(HtmlAttr.CLASS, stylename);
+            body = t;
         }
-        retlink.append(label);
-        if (strong) {
-            retlink.append("</span>");
+        HtmlTree l = HtmlTree.A(link.toString(), body);
+        if (title != null && title.length() != 0) {
+            l.addAttr(HtmlAttr.TITLE, title);
         }
-        if (stylename != null && stylename.length() != 0) {
-            retlink.append("</FONT>");
+        if (target != null && target.length() != 0) {
+            l.addAttr(HtmlAttr.TARGET, target);
         }
-        retlink.append("</a>");
-        return retlink.toString();
+        return l;
     }
 
     /**
      * Get Html Hyper Link.
      *
      * @param link       String name of the file.
-     * @param where      Position of the link in the file. Character '#' is not
-     *                   needed.
      * @param label      Tag for the link.
      * @param title      String that describes the link's content for accessibility.
      * @param target     Target frame.
      * @return a content tree for the hyper link.
      */
-    public Content getHyperLink(String link, String where,
+    public Content getHyperLink(DocPath link,
             Content label, String title, String target) {
-        if (where != null && where.length() != 0) {
-            link += "#" + where;
-        }
-        HtmlTree anchor = HtmlTree.A(link, label);
+        return getHyperLink(new DocLink(link), label, title, target);
+    }
+
+    public Content getHyperLink(DocLink link,
+            Content label, String title, String target) {
+        HtmlTree anchor = HtmlTree.A(link.toString(), label);
         if (title != null && title.length() != 0) {
             anchor.addAttr(HtmlAttr.TITLE, title);
         }
@@ -241,37 +159,6 @@ public abstract class HtmlDocWriter extends HtmlWriter {
     }
 
     /**
-     * Get a hyperlink to a file.
-     *
-     * @param link String name of the file
-     * @param label Label for the link
-     * @return a content for the hyperlink to the file
-     */
-    public Content getHyperLink(String link, Content label) {
-        return getHyperLink(link, "", label);
-    }
-
-    /**
-     * 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(String link, String label) {
-        return getHyperLinkString(link, "", label, false);
-    }
-
-    /**
-     * Print the name of the package, this class is in.
-     *
-     * @param cd    ClassDoc.
-     */
-    public void printPkgName(ClassDoc cd) {
-        print(getPkgName(cd));
-    }
-
-    /**
      * Get the name of the package, this class is in.
      *
      * @param cd    ClassDoc.
@@ -285,27 +172,6 @@ public abstract class HtmlDocWriter extends HtmlWriter {
         return "";
     }
 
-    /**
-     * Keep track of member details list. Print the definition list start tag
-     * if it is not printed yet.
-     */
-    public void printMemberDetailsListStartTag () {
-        if (!getMemberDetailsListPrinted()) {
-            dl();
-            memberDetailsListPrinted = true;
-        }
-    }
-
-    /**
-     * Print the definition list end tag if the list start tag was printed.
-     */
-    public void printMemberDetailsListEndTag () {
-        if (getMemberDetailsListPrinted()) {
-            dlEnd();
-            memberDetailsListPrinted = false;
-        }
-    }
-
     public boolean getMemberDetailsListPrinted() {
         return memberDetailsListPrinted;
     }
@@ -319,12 +185,12 @@ public abstract class HtmlDocWriter extends HtmlWriter {
      * @param frameset the frameset to be added to the HTML document
      */
     public void printFramesetDocument(String title, boolean noTimeStamp,
-            Content frameset) {
-        Content htmlDocType = DocType.Frameset();
+            Content frameset) throws IOException {
+        Content htmlDocType = DocType.FRAMESET;
         Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
         Content head = new HtmlTree(HtmlTag.HEAD);
         if (! noTimeStamp) {
-            Content headComment = new Comment("Generated by javadoc on " + today());
+            Content headComment = new Comment(getGeneratedByString());
             head.addContent(headComment);
         }
         if (configuration.charset.length() > 0) {
@@ -339,63 +205,12 @@ public abstract class HtmlDocWriter extends HtmlWriter {
                 head, frameset);
         Content htmlDocument = new HtmlDocument(htmlDocType,
                 htmlComment, htmlTree);
-        print(htmlDocument.toString());
-    }
-
-    /**
-     * 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;
-    }
-
-    /**
-     * Print the closing </body> and </html> tags.
-     */
-    public void printBodyHtmlEnd() {
-        println();
-        bodyEnd();
-        htmlEnd();
+        write(htmlDocument);
     }
 
-    /**
-     * Calls {@link #printBodyHtmlEnd()} method.
-     */
-    public void printFooter() {
-        printBodyHtmlEnd();
-    }
-
-    /**
-     * Print closing </html> tag.
-     */
-    public void printFrameFooter() {
-        htmlEnd();
-    }
-
-    /**
-     * Print ten non-breaking spaces("&nbsp;").
-     */
-    public void printNbsps() {
-        print("          ");
-    }
-
-    /**
-     * Get the day and date information for today, depending upon user option.
-     *
-     * @return String Today.
-     * @see java.util.Calendar
-     * @see java.util.GregorianCalendar
-     * @see java.util.TimeZone
-     */
-    public String today() {
+    protected String getGeneratedByString() {
         Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
-        return calendar.getTime().toString();
+        Date today = calendar.getTime();
+        return "Generated by javadoc ("+ ConfigurationImpl.BUILD_DATE + ") on " + today;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java
index 458c174..b62fe75 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,13 +25,21 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
 import java.util.*;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating an HTML document for javadoc 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 Bhavesh Patel
  */
 public class HtmlDocument extends Content {
@@ -69,7 +77,7 @@ public class HtmlDocument extends Content {
      *
      * @param htmlContent html content to be added
      */
-    public void addContent(Content htmlContent) {
+    public final void addContent(Content htmlContent) {
         if (htmlContent.isValid())
             docContent.add(htmlContent);
     }
@@ -96,8 +104,9 @@ public class HtmlDocument extends Content {
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
+    public boolean write(Writer out,  boolean atNewline) throws IOException {
         for (Content c : docContent)
-            c.write(contentBuilder);
+            atNewline = c.write(out, atNewline);
+        return atNewline;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
index 8d53c46..a1719bb 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -28,10 +28,16 @@ package com.sun.tools.doclets.formats.html.markup;
 /**
  * Enum representing HTML styles. The name map to values in the CSS file.
  *
+ *  <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 Bhavesh Patel
  */
 public enum HtmlStyle {
     aboutLanguage,
+    activeTableTab,
     altColor,
     bar,
     block,
@@ -70,6 +76,7 @@ public enum HtmlStyle {
     summary,
     deprecatedContent,
     tabEnd,
+    tableTab,
     title,
     topNav;
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
index 6a58bb0..fe9f554 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
@@ -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
@@ -28,6 +28,11 @@ package com.sun.tools.doclets.formats.html.markup;
 /**
  * Enum representing HTML tags.
  *
+ *  <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 Bhavesh Patel
  */
 public enum HtmlTag {
@@ -39,6 +44,7 @@ public enum HtmlTag {
     CENTER,
     CODE(BlockType.INLINE, EndTag.END),
     DD,
+    DIR,
     DIV,
     DL,
     DT,
@@ -58,6 +64,7 @@ public enum HtmlTag {
     I(BlockType.INLINE, EndTag.END),
     IMG(BlockType.INLINE, EndTag.NOEND),
     LI,
+    LISTING,
     LINK(BlockType.OTHER, EndTag.NOEND),
     MENU,
     META(BlockType.OTHER, EndTag.NOEND),
@@ -70,6 +77,7 @@ public enum HtmlTag {
     SMALL(BlockType.INLINE, EndTag.END),
     SPAN(BlockType.INLINE, EndTag.END),
     STRONG(BlockType.INLINE, EndTag.END),
+    SUB(BlockType.INLINE, EndTag.END),
     TABLE,
     TBODY,
     TD,
@@ -79,14 +87,14 @@ public enum HtmlTag {
     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;
@@ -95,7 +103,7 @@ public enum HtmlTag {
     /**
      * Enum representing HTML end tag requirement.
      */
-    protected static enum EndTag {
+    public static enum EndTag {
         END,
         NOEND;
     }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
index ba6d623..e6c101a 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -25,13 +25,21 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
 import java.util.*;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating HTML tree for javadoc 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 Bhavesh Patel
  */
 public class HtmlTree extends Content {
@@ -70,8 +78,12 @@ public class HtmlTree extends Content {
      */
     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));
     }
 
     /**
@@ -115,6 +127,42 @@ public class HtmlTree extends Content {
             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("<");  break;
+                            case '>': sb.append(">");  break;
+                            case '&': sb.append("&"); break;
+                            default:  sb.append(ch);      break;
+                        }
+                    }
+                    return sb.toString();
+            }
+        }
+        return s;
+    }
+
     /**
      * Generates an HTML anchor tag.
      *
@@ -124,7 +172,7 @@ public class HtmlTree extends Content {
      */
     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;
     }
 
@@ -309,7 +357,7 @@ public class HtmlTree extends Content {
             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;
@@ -423,9 +471,9 @@ public class HtmlTree extends Content {
     /**
      * Generates a META tag with the http-equiv, content and charset attributes.
      *
-     * @param http-equiv http equiv attribute for the META tag
+     * @param httpEquiv http equiv attribute for the META tag
      * @param content type of content
-     * @param charset character set used
+     * @param charSet character set used
      * @return an HtmlTree object for the META tag
      */
     public static HtmlTree META(String httpEquiv, String content, String charSet) {
@@ -486,6 +534,20 @@ public class HtmlTree extends Content {
     }
 
     /**
+     * Generates a SCRIPT tag with the type and src attributes.
+     *
+     * @param type type of link
+     * @param src the path for the script
+     * @return an HtmlTree object for the SCRIPT tag
+     */
+    public static HtmlTree SCRIPT(String type, String src) {
+        HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
+        htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
+        htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
+        return htmltree;
+    }
+
+    /**
      * Generates a SMALL tag with some content.
      *
      * @param body content for the tag
@@ -532,6 +594,23 @@ public class HtmlTree extends Content {
     }
 
     /**
+     * Generates a SPAN tag with id and style class attributes. It also encloses
+     * a content.
+     *
+     * @param id the id for the tag
+     * @param styleClass stylesheet class for the tag
+     * @param body content for the tag
+     * @return an HtmlTree object for the SPAN tag
+     */
+    public static HtmlTree SPAN(String id, HtmlStyle styleClass, Content body) {
+        HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
+        htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
+        if (styleClass != null)
+            htmltree.addStyle(styleClass);
+        return htmltree;
+    }
+
+    /**
      * Generates a Table tag with border, width and summary attributes and
      * some content.
      *
@@ -734,6 +813,9 @@ public class HtmlTree extends Content {
                 return (hasAttr(HtmlAttr.HREF) && !hasContent());
             case META :
                 return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
+            case SCRIPT :
+                return ((hasAttr(HtmlAttr.TYPE) && hasAttr(HtmlAttr.SRC) && !hasContent()) ||
+                        (hasAttr(HtmlAttr.TYPE) && hasContent()));
             default :
                 return hasContent();
         }
@@ -751,35 +833,59 @@ public class HtmlTree extends Content {
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
-        if (!isInline() && !endsWithNewLine(contentBuilder))
-            contentBuilder.append(DocletConstants.NL);
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        if (!isInline() && !atNewline)
+            out.write(DocletConstants.NL);
         String tagString = htmlTag.toString();
-        contentBuilder.append("<");
-        contentBuilder.append(tagString);
+        out.write("<");
+        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);
-            contentBuilder.append(" ");
-            contentBuilder.append(key.toString());
+            out.write(" ");
+            out.write(key.toString());
             if (!value.isEmpty()) {
-                contentBuilder.append("=\"");
-                contentBuilder.append(value);
-                contentBuilder.append("\"");
+                out.write("=\"");
+                out.write(value);
+                out.write("\"");
             }
         }
-        contentBuilder.append(">");
+        out.write(">");
+        boolean nl = false;
         for (Content c : content)
-            c.write(contentBuilder);
+            nl = c.write(out, nl);
         if (htmlTag.endTagRequired()) {
-            contentBuilder.append("</");
-            contentBuilder.append(tagString);
-            contentBuilder.append(">");
+            out.write("</");
+            out.write(tagString);
+            out.write(">");
+        }
+        if (!isInline()) {
+            out.write(DocletConstants.NL);
+            return true;
+        } else {
+            return false;
         }
-        if (!isInline())
-            contentBuilder.append(DocletConstants.NL);
+    }
+
+    /**
+     * 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();
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
index d807885..5369733 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
@@ -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,25 +26,28 @@
 package com.sun.tools.doclets.formats.html.markup;
 
 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.*;
 
 /**
  * Class for the Html format code generation.
- * Initilizes PrintWriter with FileWriter, to enable print
+ * Initializes PrintWriter with FileWriter, to enable print
  * related methods to generate the code to the named File through FileWriter.
  *
+ *  <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.2
  * @author Atul M Dambalkar
  * @author Bhavesh Patel (Modified)
  */
-public class HtmlWriter extends PrintWriter {
-
-    /**
-     * Name of the file, to which this writer is writing to.
-     */
-    protected final String htmlFilename;
+public class HtmlWriter {
 
     /**
      * The window title of this file
@@ -52,12 +55,6 @@ public class HtmlWriter extends PrintWriter {
     protected String winTitle;
 
     /**
-     * URL file separator string("/").
-     */
-    public static final String fileseparator =
-         DirectoryManager.URL_FILE_SEPARATOR;
-
-    /**
      * The configuration
      */
     protected Configuration configuration;
@@ -68,6 +65,11 @@ public class HtmlWriter extends PrintWriter {
     protected boolean memberDetailsListPrinted;
 
     /**
+     * Header for table displaying profiles and description..
+     */
+    protected final String[] profileTableHeader;
+
+    /**
      * Header for tables displaying packages and description..
      */
     protected final String[] packageTableHeader;
@@ -88,6 +90,8 @@ public class HtmlWriter extends PrintWriter {
 
     public final Content packageLabel;
 
+    public final Content profileLabel;
+
     public final Content useLabel;
 
     public final Content prevLabel;
@@ -116,6 +120,10 @@ public class HtmlWriter extends PrintWriter {
 
     public final Content allclassesLabel;
 
+    public final Content allpackagesLabel;
+
+    public final Content allprofilesLabel;
+
     public final Content indexLabel;
 
     public final Content helpLabel;
@@ -128,8 +136,14 @@ public class HtmlWriter extends PrintWriter {
 
     public final Content nextpackageLabel;
 
+    public final Content prevprofileLabel;
+
+    public final Content nextprofileLabel;
+
     public final Content packagesLabel;
 
+    public final Content profilesLabel;
+
     public final Content methodDetailsLabel;
 
     public final Content annotationTypeDetailsLabel;
@@ -150,26 +164,29 @@ public class HtmlWriter extends PrintWriter {
 
     public final Content descfrmInterfaceLabel;
 
+    private final Writer writer;
+
+    private Content script;
+
     /**
      * Constructor.
      *
      * @param path The directory path to be created for this file
      *             or null if none to be created.
-     * @param filename File Name to which the PrintWriter will
-     *                 do the Output.
-     * @param docencoding Encoding to be used for this file.
      * @exception IOException Exception raised by the FileWriter is passed on
      * to next level.
-     * @exception UnSupportedEncodingException Exception raised by the
+     * @exception UnsupportedEncodingException Exception raised by the
      * OutputStreamWriter is passed on to next level.
      */
-    public HtmlWriter(Configuration configuration,
-                      String path, String filename, String docencoding)
-                      throws IOException, UnsupportedEncodingException {
-        super(Util.genWriter(configuration, path, filename, docencoding));
+    public HtmlWriter(Configuration configuration, DocPath path)
+            throws IOException, UnsupportedEncodingException {
+        writer = DocFile.createFileForOutput(configuration, path).openWriter();
         this.configuration = configuration;
-        htmlFilename = filename;
         this.memberDetailsListPrinted = false;
+        profileTableHeader = new String[] {
+            configuration.getText("doclet.Profile"),
+            configuration.getText("doclet.Description")
+        };
         packageTableHeader = new String[] {
             configuration.getText("doclet.Package"),
             configuration.getText("doclet.Description")
@@ -180,9 +197,9 @@ public class HtmlWriter extends PrintWriter {
                 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");
         prevLabel = getResource("doclet.Prev");
         nextLabel = getResource("doclet.Next");
@@ -197,13 +214,18 @@ public class HtmlWriter extends PrintWriter {
         deprecatedLabel = getResource("doclet.navDeprecated");
         deprecatedPhrase = getResource("doclet.Deprecated");
         allclassesLabel = getResource("doclet.All_Classes");
+        allpackagesLabel = getResource("doclet.All_Packages");
+        allprofilesLabel = getResource("doclet.All_Profiles");
         indexLabel = getResource("doclet.Index");
         helpLabel = getResource("doclet.Help");
         seeLabel = getResource("doclet.See");
         descriptionLabel = getResource("doclet.Description");
         prevpackageLabel = getResource("doclet.Prev_Package");
         nextpackageLabel = getResource("doclet.Next_Package");
+        prevprofileLabel = getResource("doclet.Prev_Profile");
+        nextprofileLabel = getResource("doclet.Next_Profile");
         packagesLabel = getResource("doclet.Packages");
+        profilesLabel = getResource("doclet.Profiles");
         methodDetailsLabel = getResource("doclet.Method_Detail");
         annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
         fieldDetailsLabel = getResource("doclet.Field_Detail");
@@ -216,6 +238,14 @@ public class HtmlWriter extends PrintWriter {
         descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
     }
 
+    public void write(Content c) throws IOException {
+        c.write(writer, true);
+    }
+
+    public void close() throws IOException {
+        writer.close();
+    }
+
     /**
      * Get the configuration string as a content.
      *
@@ -223,62 +253,30 @@ public class HtmlWriter extends PrintWriter {
      * @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));
-    }
-
-    /**
-     * Print <HTML> tag. Add a newline character at the end.
-     */
-    public void html() {
-        println("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">");
-    }
-
-    /**
-     * Print </HTML> tag. Add a newline character at the end.
-     */
-    public void htmlEnd() {
-        println("</HTML>");
-    }
-
-    /**
-     * Print the script code to be embeded before the  </HEAD> tag.
-     */
-    protected void printWinTitleScript(String winTitle){
-        if(winTitle != null && winTitle.length() > 0) {
-            script();
-            println("function windowTitle()");
-            println("{");
-            println("    if (location.href.indexOf('is-external=true') == -1) {");
-            println("        parent.document.title=\"" + winTitle + "\";");
-            println("    }");
-            println("}");
-            scriptEnd();
-            noScript();
-            noScriptEnd();
-        }
+    public Content getResource(String key, Object o0, Object o1) {
+        return configuration.getResource(key, o0, o1);
     }
 
     /**
@@ -306,14 +304,49 @@ public class HtmlWriter extends PrintWriter {
      *
      * @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 +
+                "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
                 "        targetPage = \"undefined\";" + DocletConstants.NL +
+                "    function validURL(url) {" + DocletConstants.NL +
+                "        var pos = url.indexOf(\".html\");" + DocletConstants.NL +
+                "        if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
+                "            return false;" + DocletConstants.NL +
+                "        var allowNumber = false;" + DocletConstants.NL +
+                "        var allowSep = false;" + DocletConstants.NL +
+                "        var seenDot = false;" + DocletConstants.NL +
+                "        for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
+                "            var ch = url.charAt(i);" + DocletConstants.NL +
+                "            if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
+                "                    'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
+                "                    ch == '$' ||" + DocletConstants.NL +
+                "                    ch == '_') {" + DocletConstants.NL +
+                "                allowNumber = true;" + DocletConstants.NL +
+                "                allowSep = true;" + DocletConstants.NL +
+                "            } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
+                "                    || ch == '-') {" + DocletConstants.NL +
+                "                if (!allowNumber)" + DocletConstants.NL +
+                "                     return false;" + DocletConstants.NL +
+                "            } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
+                "                if (!allowSep)" + DocletConstants.NL +
+                "                    return false;" + DocletConstants.NL +
+                "                allowNumber = false;" + DocletConstants.NL +
+                "                allowSep = false;" + DocletConstants.NL +
+                "                if (ch == '.')" + DocletConstants.NL +
+                "                     seenDot = true;" + DocletConstants.NL +
+                "                if (ch == '/' && seenDot)" + DocletConstants.NL +
+                "                     return false;" + DocletConstants.NL +
+                "            } else {" + DocletConstants.NL +
+                "                return false;"+ DocletConstants.NL +
+                "            }" + DocletConstants.NL +
+                "        }" + DocletConstants.NL +
+                "        return true;" + DocletConstants.NL +
+                "    }" + DocletConstants.NL +
                 "    function loadFrames() {" + DocletConstants.NL +
                 "        if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
                 "             top.classFrame.location = top.targetPage;" + DocletConstants.NL +
@@ -324,64 +357,6 @@ public class HtmlWriter extends PrintWriter {
     }
 
     /**
-     * Print the Javascript <SCRIPT> start tag with its type
-     * attribute.
-     */
-    public void script() {
-        println("<SCRIPT type=\"text/javascript\">");
-    }
-
-    /**
-     * Print the Javascript </SCRIPT> end tag.
-     */
-    public void scriptEnd() {
-        println("</SCRIPT>");
-    }
-
-    /**
-     * Print the Javascript <NOSCRIPT> start tag.
-     */
-    public void noScript() {
-        println("<NOSCRIPT>");
-    }
-
-    /**
-     * Print the Javascript </NOSCRIPT> end tag.
-     */
-    public void noScriptEnd() {
-        println("</NOSCRIPT>");
-    }
-
-    /**
-     * Return the Javascript call to be embedded in the <BODY> tag.
-     * Return nothing if winTitle is empty.
-     * @return the Javascript call to be embedded in the <BODY> tag.
-     */
-    protected String getWindowTitleOnload(){
-        if(winTitle != null && winTitle.length() > 0) {
-            return " onload=\"windowTitle();\"";
-        } else {
-            return "";
-        }
-    }
-
-    /**
-     * Print <BODY BGCOLOR="bgcolor">, including JavaScript
-     * "onload" call to load windowtitle script.  This script shows the name
-     * of the document in the window title bar when frames are on.
-     *
-     * @param bgcolor Background color.
-     * @param includeScript  boolean set true if printing windowtitle script
-     */
-    public void body(String bgcolor, boolean includeScript) {
-        print("<BODY BGCOLOR=\"" + bgcolor + "\"");
-        if (includeScript) {
-            print(getWindowTitleOnload());
-        }
-        println(">");
-    }
-
-    /**
      * Returns an HtmlTree for the BODY tag.
      *
      * @param includeScript  set true if printing windowtitle script
@@ -395,7 +370,8 @@ public class HtmlWriter extends PrintWriter {
         // Don't print windowtitle script for overview-frame, allclasses-frame
         // and package-frame
         if (includeScript) {
-            body.addContent(getWinTitleScript());
+            this.script = getWinTitleScript();
+            body.addContent(script);
             Content noScript = HtmlTree.NOSCRIPT(
                     HtmlTree.DIV(getResource("doclet.No_Script_Message")));
             body.addContent(noScript);
@@ -404,28 +380,50 @@ public class HtmlWriter extends PrintWriter {
     }
 
     /**
-     * Print </BODY> tag. Add a newline character at the end.
-     */
-    public void bodyEnd() {
-        println("</BODY>");
-    }
-
-    /**
-     * Print <TITLE> tag. Add a newline character at the end.
+     * Generated javascript variables for the document.
+     *
+     * @param typeMap map comprising of method and type relationship
+     * @param methodTypes set comprising of all methods types for this class
      */
-    public void title() {
-        println("<TITLE>");
+    public void generateMethodTypesScript(Map<String,Integer> typeMap,
+            Set<MethodTypes> methodTypes) {
+        String sep = "";
+        StringBuilder vars = new StringBuilder("var methods = {");
+        for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
+            vars.append(sep);
+            sep = ",";
+            vars.append("\"");
+            vars.append(entry.getKey());
+            vars.append("\":");
+            vars.append(entry.getValue());
+        }
+        vars.append("};").append(DocletConstants.NL);
+        sep = "";
+        vars.append("var tabs = {");
+        for (MethodTypes entry : methodTypes) {
+            vars.append(sep);
+            sep = ",";
+            vars.append(entry.value()).append(":");
+            vars.append("[").append("\"").append(entry.tabId());
+            vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]");
+        }
+        vars.append("};").append(DocletConstants.NL);
+        addStyles(HtmlStyle.altColor, vars);
+        addStyles(HtmlStyle.rowColor, vars);
+        addStyles(HtmlStyle.tableTab, vars);
+        addStyles(HtmlStyle.activeTableTab, vars);
+        script.addContent(new RawHtml(vars.toString()));
     }
 
     /**
-     * Print <TITLE> tag. Add a newline character at the end.
+     * Adds javascript style variables to the document.
      *
-     * @param winTitle The title of this document.
+     * @param style style to be added as a javascript variable
+     * @param vars variable string to which the style variable will be added
      */
-    public void title(String winTitle) {
-        // Set window title string which is later printed
-        this.winTitle = winTitle;
-        title();
+    public void addStyles(HtmlStyle style, StringBuilder vars) {
+        vars.append("var ").append(style).append(" = \"").append(style)
+                .append("\";").append(DocletConstants.NL);
     }
 
     /**
@@ -438,994 +436,21 @@ public class HtmlWriter extends PrintWriter {
         return title;
     }
 
-    /**
-     * Print </TITLE> tag. Add a newline character at the end.
-     */
-    public void titleEnd() {
-        println("</TITLE>");
-    }
-
-    /**
-     * Print <UL> tag. Add a newline character at the end.
-     */
-    public void ul() {
-        println("<UL>");
-    }
-
-    /**
-     * Print </UL> tag. Add a newline character at the end.
-     */
-    public void ulEnd() {
-        println("</UL>");
-    }
-
-    /**
-     * Print <LI> tag.
-     */
-    public void li() {
-        print("<LI>");
-    }
-
-    /**
-     * Print <LI TYPE="type"> tag.
-     *
-     * @param type Type string.
-     */
-    public void li(String type) {
-        print("<LI TYPE=\"" + type + "\">");
-    }
-
-    /**
-     * Print <H1> tag. Add a newline character at the end.
-     */
-    public void h1() {
-        println("<H1>");
-    }
-
-    /**
-     * Print </H1> tag. Add a newline character at the end.
-     */
-    public void h1End() {
-        println("</H1>");
-    }
-
-    /**
-     * Print text with <H1> tag. Also adds </H1> tag. Add a newline character
-     * at the end of the text.
-     *
-     * @param text Text to be printed with <H1> format.
-     */
-    public void h1(String text) {
-        h1();
-        println(text);
-        h1End();
-    }
-
-    /**
-     * Print <H2> tag. Add a newline character at the end.
-     */
-    public void h2() {
-        println("<H2>");
-    }
-
-    /**
-     * Print text with <H2> tag. Also adds </H2> tag. Add a newline character
-     *  at the end of the text.
-     *
-     * @param text Text to be printed with <H2> format.
-     */
-    public void h2(String text) {
-        h2();
-        println(text);
-        h2End();
-    }
-
-    /**
-     * Print </H2> tag. Add a newline character at the end.
-     */
-    public void h2End() {
-        println("</H2>");
-    }
-
-    /**
-     * Print <H3> tag. Add a newline character at the end.
-     */
-    public void h3() {
-        println("<H3>");
-    }
-
-    /**
-     * Print text with <H3> tag. Also adds </H3> tag. Add a newline character
-     *  at the end of the text.
-     *
-     * @param text Text to be printed with <H3> format.
-     */
-    public void h3(String text) {
-        h3();
-        println(text);
-        h3End();
-    }
-
-    /**
-     * Print </H3> tag. Add a newline character at the end.
-     */
-    public void h3End() {
-        println("</H3>");
-    }
-
-    /**
-     * Print <H4> tag. Add a newline character at the end.
-     */
-    public void h4() {
-        println("<H4>");
-    }
-
-    /**
-     * Print </H4> tag. Add a newline character at the end.
-     */
-    public void h4End() {
-        println("</H4>");
-    }
-
-    /**
-     * Print text with <H4> tag. Also adds </H4> tag. Add a newline character
-     * at the end of the text.
-     *
-     * @param text Text to be printed with <H4> format.
-     */
-    public void h4(String text) {
-        h4();
-        println(text);
-        h4End();
-    }
-
-    /**
-     * Print <H5> tag. Add a newline character at the end.
-     */
-    public void h5() {
-        println("<H5>");
-    }
-
-    /**
-     * Print </H5> tag. Add a newline character at the end.
-     */
-    public void h5End() {
-        println("</H5>");
-    }
-
-    /**
-     * Print HTML <IMG SRC="imggif" WIDTH="width" HEIGHT="height" ALT="imgname>
-     * tag. It prepends the "images" directory name to the "imggif". This
-     * method is used for oneone format generation. Add a newline character
-     * at the end.
-     *
-     * @param imggif   Image GIF file.
-     * @param imgname  Image name.
-     * @param width    Width of the image.
-     * @param height   Height of the image.
-     */
-    public void img(String imggif, String imgname, int width, int height) {
-        println("<IMG SRC=\"images/" + imggif + ".gif\""
-              + " WIDTH=\"" + width + "\" HEIGHT=\"" + height
-              + "\" ALT=\"" + imgname + "\">");
-    }
-
-    /**
-     * Print <MENU> tag. Add a newline character at the end.
-     */
-    public void menu() {
-        println("<MENU>");
-    }
-
-    /**
-     * Print </MENU> tag. Add a newline character at the end.
-     */
-    public void menuEnd() {
-        println("</MENU>");
-    }
-
-    /**
-     * Print <PRE> tag. Add a newline character at the end.
-     */
-    public void pre() {
-        println("<PRE>");
-    }
-
-    /**
-     * Print <PRE> tag without adding new line character at th eend.
-     */
-    public void preNoNewLine() {
-        print("<PRE>");
-    }
-
-    /**
-     * Print </PRE> tag. Add a newline character at the end.
-     */
-    public void preEnd() {
-        println("</PRE>");
-    }
-
-    /**
-     * Print <HR> tag. Add a newline character at the end.
-     */
-    public void hr() {
-        println("<HR>");
-    }
-
-    /**
-     * Print <HR SIZE="size" WIDTH="widthpercent%"> tag. Add a newline
-     * character at the end.
-     *
-     * @param size           Size of the ruler.
-     * @param widthPercent   Percentage Width of the ruler
-     */
-    public void hr(int size, int widthPercent) {
-        println("<HR SIZE=\"" + size + "\" WIDTH=\"" + widthPercent + "%\">");
-    }
-
-    /**
-     * Print <HR SIZE="size" NOSHADE> tag. Add a newline character at the end.
-     *
-     * @param size           Size of the ruler.
-     * @param noshade        noshade string.
-     */
-    public void hr(int size, String noshade) {
-        println("<HR SIZE=\"" + size + "\" NOSHADE>");
-    }
-
-    /**
-     * Get the "<STRONG>" string.
-     *
-     * @return String Return String "<STRONG>";
-     */
-    public String getStrong() {
-        return "<STRONG>";
-    }
-
-    /**
-     * Get the "</STRONG>" string.
-     *
-     * @return String Return String "</STRONG>";
-     */
-    public String getStrongEnd() {
-        return "</STRONG>";
-    }
-
-    /**
-     * Print <STRONG> tag.
-     */
-    public void strong() {
-        print("<STRONG>");
-    }
-
-    /**
-     * Print </STRONG> tag.
-     */
-    public void strongEnd() {
-        print("</STRONG>");
-    }
-
-    /**
-     * Print text passed, in strong format using <STRONG> and </STRONG> tags.
-     *
-     * @param text String to be printed in between <STRONG> and </STRONG> tags.
-     */
-    public void strong(String text) {
-        strong();
-        print(text);
-        strongEnd();
-    }
-
-    /**
-     * Print text passed, in Italics using <I> and </I> tags.
-     *
-     * @param text String to be printed in between <I> and </I> tags.
-     */
-    public void italics(String text) {
-        print("<I>");
-        print(text);
-        println("</I>");
-    }
-
-    /**
-     * Return, text passed, with Italics <i> and </i> tags, surrounding it.
-     * So if the text passed is "Hi", then string returned will be "<i>Hi</i>".
-     *
-     * @param text String to be printed in between <I> and </I> tags.
-     */
-    public String italicsText(String text) {
-        return "<i>" + text + "</i>";
-    }
-
     public String codeText(String text) {
         return "<code>" + text + "</code>";
     }
 
     /**
-     * Print "&nbsp;", non-breaking space.
-     */
-    public void space() {
-        print(" ");
-    }
-
-    /**
      * Return "&nbsp;", non-breaking space.
      */
     public Content getSpace() {
         return RawHtml.nbsp;
     }
 
-    /**
-     * Print <DL> tag. Add a newline character at the end.
-     */
-    public void dl() {
-        println("<DL>");
-    }
-
-    /**
-     * Print </DL> tag. Add a newline character at the end.
-     */
-    public void dlEnd() {
-        println("</DL>");
-    }
-
-    /**
-     * Print <DT> tag.
-     */
-    public void dt() {
-        print("<DT>");
-    }
-
-    /**
-     * Print </DT> tag.
-     */
-    public void dtEnd() {
-        print("</DT>");
-    }
-
-    /**
-     * Print <DD> tag.
-     */
-    public void dd() {
-        print("<DD>");
-    }
-
-    /**
-     * Print </DD> tag. Add a newline character at the end.
-     */
-    public void ddEnd() {
-        println("</DD>");
-    }
-
-    /**
-     * Print <SUP> tag. Add a newline character at the end.
-     */
-    public void sup() {
-        println("<SUP>");
-    }
-
-    /**
-     * Print </SUP> tag. Add a newline character at the end.
-     */
-    public void supEnd() {
-        println("</SUP>");
-    }
-
-    /**
-     * Print <FONT SIZE="size"> tag. Add a newline character at the end.
-     *
-     * @param size String size.
-     */
-    public void font(String size) {
-        println("<FONT SIZE=\"" + size + "\">");
-    }
-
-    /**
-     * Print <FONT SIZE="size"> tag.
-     *
-     * @param size String size.
-     */
-    public void fontNoNewLine(String size) {
-        print("<FONT SIZE=\"" + size + "\">");
-    }
-
-    /**
-     * Print <FONT CLASS="stylename"> tag. Add a newline character at the end.
-     *
-     * @param stylename String stylename.
-     */
-    public void fontStyle(String stylename) {
-        print("<FONT CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print <FONT SIZE="size" CLASS="stylename"> tag. Add a newline character
-     * at the end.
-     *
-     * @param size String size.
-     * @param stylename String stylename.
-     */
-    public void fontSizeStyle(String size, String stylename) {
-        println("<FONT size=\"" + size + "\" CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print </FONT> tag.
-     */
-    public void fontEnd() {
-        print("</FONT>");
-    }
-
-    /**
-     * Get the "<FONT COLOR="color">" string.
-     *
-     * @param color String color.
-     * @return String Return String "<FONT COLOR="color">".
-     */
-    public String getFontColor(String color) {
-        return "<FONT COLOR=\"" + color + "\">";
-    }
-
-    /**
-     * Get the "</FONT>" string.
-     *
-     * @return String Return String "</FONT>";
-     */
-    public String getFontEnd() {
-        return "</FONT>";
-    }
-
-    /**
-     * Print <CENTER> tag. Add a newline character at the end.
-     */
-    public void center() {
-        println("<CENTER>");
-    }
-
-    /**
-     * Print </CENTER> tag. Add a newline character at the end.
-     */
-    public void centerEnd() {
-        println("</CENTER>");
-    }
-
-    /**
-     * Print anchor <A NAME="name"> tag.
-     *
-     * @param name Name String.
-     */
-    public void aName(String name) {
-        print("<A NAME=\"" + name + "\">");
-    }
-
-    /**
-     * Print </A> tag.
-     */
-    public void aEnd() {
-        print("</A>");
-    }
-
-    /**
-     * Print <I> tag.
-     */
-    public void italic() {
-        print("<I>");
-    }
-
-    /**
-     * Print </I> tag.
-     */
-    public void italicEnd() {
-        print("</I>");
-    }
-
-    /**
-     * Print contents within anchor <A NAME="name"> tags.
-     *
-     * @param name String name.
-     * @param content String contents.
-     */
-    public void anchor(String name, String content) {
-        aName(name);
-        print(content);
-        aEnd();
-    }
-
-    /**
-     * Print anchor <A NAME="name"> and </A>tags. Print comment string
-     * "<!-- -->" within those tags.
-     *
-     * @param name String name.
-     */
-    public void anchor(String name) {
-        anchor(name, "<!-- -->");
-    }
-
-    /**
-     * Print newline and then print <P> tag. Add a newline character at the
-     * end.
-     */
-    public void p() {
-        println();
-        println("<P>");
-    }
-
-    /**
-     * Print newline and then print </P> tag. Add a newline character at the
-     * end.
-     */
-    public void pEnd() {
-        println();
-        println("</P>");
-    }
-
-    /**
-     * Print newline and then print <BR> tag. Add a newline character at the
-     * end.
-     */
-    public void br() {
-        println();
-        println("<BR>");
-    }
-
-    /**
-     * Print <ADDRESS> tag. Add a newline character at the end.
-     */
-    public void address() {
-        println("<ADDRESS>");
-    }
-
-    /**
-     * Print </ADDRESS> tag. Add a newline character at the end.
-     */
-    public void addressEnd() {
-        println("</ADDRESS>");
-    }
-
-    /**
-     * Print <HEAD> tag. Add a newline character at the end.
-     */
-    public void head() {
-        println("<HEAD>");
-    }
-
-    /**
-     * Print </HEAD> tag. Add a newline character at the end.
-     */
-    public void headEnd() {
-        println("</HEAD>");
-    }
-
-    /**
-     * Print <CODE> tag.
-     */
-    public void code() {
-        print("<CODE>");
-    }
-
-    /**
-     * Print </CODE> tag.
-     */
-    public void codeEnd() {
-        print("</CODE>");
-    }
-
-    /**
-     * Print <EM> tag. Add a newline character at the end.
-     */
-    public void em() {
-        println("<EM>");
-    }
-
-    /**
-     * Print </EM> tag. Add a newline character at the end.
-     */
-    public void emEnd() {
-        println("</EM>");
-    }
-
-    /**
-     * Print HTML <TABLE BORDER="border" WIDTH="width"
-     * CELLPADDING="cellpadding" CELLSPACING="cellspacing"> tag.
-     *
-     * @param border       Border size.
-     * @param width        Width of the table.
-     * @param cellpadding  Cellpadding for the table cells.
-     * @param cellspacing  Cellspacing for the table cells.
-     */
-    public void table(int border, String width, int cellpadding,
-                      int cellspacing) {
-        println(DocletConstants.NL +
-                "<TABLE BORDER=\"" + border +
-                "\" WIDTH=\"" + width +
-                "\" CELLPADDING=\"" + cellpadding +
-                "\" CELLSPACING=\"" + cellspacing +
-                "\" SUMMARY=\"\">");
-    }
-
-    /**
-     * Print HTML <TABLE BORDER="border" WIDTH="width"
-     * CELLPADDING="cellpadding" CELLSPACING="cellspacing" SUMMARY="summary"> tag.
-     *
-     * @param border       Border size.
-     * @param width        Width of the table.
-     * @param cellpadding  Cellpadding for the table cells.
-     * @param cellspacing  Cellspacing for the table cells.
-     * @param summary      Table summary.
-     */
-    public void table(int border, String width, int cellpadding,
-                      int cellspacing, String summary) {
-        println(DocletConstants.NL +
-                "<TABLE BORDER=\"" + border +
-                "\" WIDTH=\"" + width +
-                "\" CELLPADDING=\"" + cellpadding +
-                "\" CELLSPACING=\"" + cellspacing +
-                "\" SUMMARY=\"" + summary + "\">");
-    }
-
-    /**
-     * Print HTML <TABLE BORDER="border" CELLPADDING="cellpadding"
-     * CELLSPACING="cellspacing"> tag.
-     *
-     * @param border       Border size.
-     * @param cellpadding  Cellpadding for the table cells.
-     * @param cellspacing  Cellspacing for the table cells.
-     */
-    public void table(int border, int cellpadding, int cellspacing) {
-        println(DocletConstants.NL +
-                "<TABLE BORDER=\"" + border +
-                "\" CELLPADDING=\"" + cellpadding +
-                "\" CELLSPACING=\"" + cellspacing +
-                "\" SUMMARY=\"\">");
-    }
-
-    /**
-     * Print HTML <TABLE BORDER="border" CELLPADDING="cellpadding"
-     * CELLSPACING="cellspacing" SUMMARY="summary"> tag.
-     *
-     * @param border       Border size.
-     * @param cellpadding  Cellpadding for the table cells.
-     * @param cellspacing  Cellspacing for the table cells.
-     * @param summary      Table summary.
-     */
-    public void table(int border, int cellpadding, int cellspacing, String summary) {
-        println(DocletConstants.NL +
-                "<TABLE BORDER=\"" + border +
-                "\" CELLPADDING=\"" + cellpadding +
-                "\" CELLSPACING=\"" + cellspacing +
-                "\" SUMMARY=\"" + summary + "\">");
-    }
-
-    /**
-     * Print HTML <TABLE BORDER="border" WIDTH="width">
-     *
-     * @param border       Border size.
-     * @param width        Width of the table.
-     */
-    public void table(int border, String width) {
-        println(DocletConstants.NL +
-                "<TABLE BORDER=\"" + border +
-                "\" WIDTH=\"" + width +
-                "\" SUMMARY=\"\">");
-    }
-
-    /**
-     * Print the HTML table tag with border size 0 and width 100%.
-     */
-    public void table() {
-        table(0, "100%");
-    }
-
-    /**
-     * Print </TABLE> tag. Add a newline character at the end.
-     */
-    public void tableEnd() {
-        println("</TABLE>");
-    }
-
-    /**
-     * Print <TR> tag. Add a newline character at the end.
-     */
-    public void tr() {
-        println("<TR>");
-    }
-
-    /**
-     * Print </TR> tag. Add a newline character at the end.
-     */
-    public void trEnd() {
-        println("</TR>");
-    }
-
-    /**
-     * Print <TD> tag.
-     */
-    public void td() {
-        print("<TD>");
-    }
-
-    /**
-     * Print <TD NOWRAP> tag.
-     */
-    public void tdNowrap() {
-        print("<TD NOWRAP>");
-    }
-
-    /**
-     * Print <TD WIDTH="width"> tag.
-     *
-     * @param width String width.
-     */
-    public void tdWidth(String width) {
-        print("<TD WIDTH=\"" + width + "\">");
-    }
-
-    /**
-     * Print </TD> tag. Add a newline character at the end.
-     */
-    public void tdEnd() {
-        println("</TD>");
-    }
-
-    /**
-     * Print <LINK str> tag.
-     *
-     * @param str String.
-     */
-    public void link(String str) {
-        println("<LINK " + str + ">");
-    }
-
-    /**
-     * Print "<!-- " comment start string.
-     */
-    public void commentStart() {
-         print("<!-- ");
-    }
-
-    /**
-     * Print "-->" comment end string. Add a newline character at the end.
-     */
-    public void commentEnd() {
-         println("-->");
-    }
-
-    /**
-     * Print <CAPTION CLASS="stylename"> tag. Adds a newline character
-     * at the end.
-     *
-     * @param stylename style to be applied.
-     */
-    public void captionStyle(String stylename) {
-        println("<CAPTION CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print </CAPTION> tag. Add a newline character at the end.
-     */
-    public void captionEnd() {
-        println("</CAPTION>");
-    }
-
-    /**
-     * Print <TR BGCOLOR="color" CLASS="stylename"> tag. Adds a newline character
-     * at the end.
-     *
-     * @param color String color.
-     * @param stylename String stylename.
-     */
-    public void trBgcolorStyle(String color, String stylename) {
-        println("<TR BGCOLOR=\"" + color + "\" CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print <TR BGCOLOR="color"> tag. Adds a newline character at the end.
-     *
-     * @param color String color.
-     */
-    public void trBgcolor(String color) {
-        println("<TR BGCOLOR=\"" + color + "\">");
-    }
-
-    /**
-     * Print <TR ALIGN="align" VALIGN="valign"> tag. Adds a newline character
-     * at the end.
-     *
-     * @param align String align.
-     * @param valign String valign.
-     */
-    public void trAlignVAlign(String align, String valign) {
-        println("<TR ALIGN=\"" + align + "\" VALIGN=\"" + valign + "\">");
-    }
-
-    /**
-     * Print <TH ALIGN="align"> tag.
-     *
-     * @param align the align attribute.
-     */
-    public void thAlign(String align) {
-        print("<TH ALIGN=\"" + align + "\">");
-    }
-
-    /**
-     * Print <TH CLASS="stylename" SCOPE="scope" NOWRAP> tag.
-     *
-     * @param stylename style to be applied.
-     * @param scope the scope attribute.
-     */
-    public void thScopeNoWrap(String stylename, String scope) {
-        print("<TH CLASS=\"" + stylename + "\" SCOPE=\"" + scope + "\" NOWRAP>");
-    }
-
-    /*
-     * Returns a header for Modifier and Type column of a table.
+    /*
+     * Returns a header for Modifier and Type column of a table.
      */
     public String getModifierTypeHeader() {
         return modifierTypeHeader;
     }
-
-    /**
-     * Print <TH align="align" COLSPAN=i> tag.
-     *
-     * @param align the align attribute.
-     * @param i integer.
-     */
-    public void thAlignColspan(String align, int i) {
-        print("<TH ALIGN=\"" + align + "\" COLSPAN=\"" + i + "\">");
-    }
-
-    /**
-     * Print <TH align="align" NOWRAP> tag.
-     *
-     * @param align the align attribute.
-     */
-    public void thAlignNowrap(String align) {
-        print("<TH ALIGN=\"" + align + "\" NOWRAP>");
-    }
-
-    /**
-     * Print </TH> tag. Add a newline character at the end.
-     */
-    public void thEnd() {
-        println("</TH>");
-    }
-
-    /**
-     * Print <TD COLSPAN=i> tag.
-     *
-     * @param i integer.
-     */
-    public void tdColspan(int i) {
-        print("<TD COLSPAN=" + i + ">");
-    }
-
-    /**
-     * Print <TD BGCOLOR="color" CLASS="stylename"> tag.
-     *
-     * @param color String color.
-     * @param stylename String stylename.
-     */
-    public void tdBgcolorStyle(String color, String stylename) {
-        print("<TD BGCOLOR=\"" + color + "\" CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print <TD COLSPAN=i BGCOLOR="color" CLASS="stylename"> tag.
-     *
-     * @param i integer.
-     * @param color String color.
-     * @param stylename String stylename.
-     */
-    public void tdColspanBgcolorStyle(int i, String color, String stylename) {
-        print("<TD COLSPAN=" + i + " BGCOLOR=\"" + color + "\" CLASS=\"" +
-              stylename + "\">");
-    }
-
-    /**
-     * Print <TD ALIGN="align"> tag. Adds a newline character
-     * at the end.
-     *
-     * @param align String align.
-     */
-    public void tdAlign(String align) {
-        print("<TD ALIGN=\"" + align + "\">");
-    }
-
-    /**
-     * Print <TD ALIGN="align" CLASS="stylename"> tag.
-     *
-     * @param align        String align.
-     * @param stylename    String stylename.
-     */
-    public void tdVAlignClass(String align, String stylename) {
-        print("<TD VALIGN=\"" + align + "\" CLASS=\"" + stylename + "\">");
-    }
-
-    /**
-     * Print <TD VALIGN="valign"> tag.
-     *
-     * @param valign String valign.
-     */
-    public void tdVAlign(String valign) {
-        print("<TD VALIGN=\"" + valign + "\">");
-    }
-
-    /**
-     * Print <TD ALIGN="align" VALIGN="valign"> tag.
-     *
-     * @param align   String align.
-     * @param valign  String valign.
-     */
-    public void tdAlignVAlign(String align, String valign) {
-        print("<TD ALIGN=\"" + align + "\" VALIGN=\"" + valign + "\">");
-    }
-
-    /**
-     * Print <TD ALIGN="align" ROWSPAN=rowspan> tag.
-     *
-     * @param align    String align.
-     * @param rowspan  integer rowspan.
-     */
-    public void tdAlignRowspan(String align, int rowspan) {
-        print("<TD ALIGN=\"" + align + "\" ROWSPAN=" + rowspan + ">");
-    }
-
-    /**
-     * Print <TD ALIGN="align" VALIGN="valign" ROWSPAN=rowspan> tag.
-     *
-     * @param align    String align.
-     * @param valign  String valign.
-     * @param rowspan  integer rowspan.
-     */
-    public void tdAlignVAlignRowspan(String align, String valign,
-                                     int rowspan) {
-        print("<TD ALIGN=\"" + align + "\" VALIGN=\"" + valign
-                + "\" ROWSPAN=" + rowspan + ">");
-    }
-
-    /**
-     * Print <BLOCKQUOTE> tag. Add a newline character at the end.
-     */
-    public void blockquote() {
-        println("<BLOCKQUOTE>");
-    }
-
-    /**
-     * Print </BLOCKQUOTE> tag. Add a newline character at the end.
-     */
-    public void blockquoteEnd() {
-        println("</BLOCKQUOTE>");
-    }
-
-    /**
-     * Get the "<code>" string.
-     *
-     * @return String Return String "<code>";
-     */
-    public String getCode() {
-        return "<code>";
-    }
-
-    /**
-     * Get the "</code>" string.
-     *
-     * @return String Return String "</code>";
-     */
-    public String getCodeEnd() {
-        return "</code>";
-    }
-
-    /**
-     * Print <NOFRAMES> tag. Add a newline character at the end.
-     */
-    public void noFrames() {
-        println("<NOFRAMES>");
-    }
-
-    /**
-     * Print </NOFRAMES> tag. Add a newline character at the end.
-     */
-    public void noFramesEnd() {
-        println("</NOFRAMES>");
-    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java
index 56c2396..6b4fc6e 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java
@@ -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
@@ -25,15 +25,23 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating raw HTML content to be added to HTML pages of javadoc 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 Bhavesh Patel
  */
-public class RawHtml extends Content{
+public class RawHtml extends Content {
 
     private String rawHtmlContent;
 
@@ -82,7 +90,71 @@ public class RawHtml extends Content{
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
-        contentBuilder.append(rawHtmlContent);
+    @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}
+     */
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        out.write(rawHtmlContent);
+        return rawHtmlContent.endsWith(DocletConstants.NL);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java
index 2bf4437..21d67c0 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java
@@ -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
@@ -25,15 +25,23 @@
 
 package com.sun.tools.doclets.formats.html.markup;
 
+import java.io.IOException;
+import java.io.Writer;
+
 import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Class for generating string content for HTML tags of javadoc 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 Bhavesh Patel
  */
-public class StringContent extends Content{
+public class StringContent extends Content {
 
     private StringBuilder stringContent;
 
@@ -50,8 +58,8 @@ public class StringContent extends Content{
      * @param initialContent initial content for the object
      */
     public StringContent(String initialContent) {
-        stringContent = new StringBuilder(
-                Util.escapeHtmlChars(nullCheck(initialContent)));
+        stringContent = new StringBuilder();
+        appendChars(initialContent);
     }
 
     /**
@@ -73,7 +81,7 @@ public class StringContent extends Content{
      * @param strContent string content to be added
      */
     public void addContent(String strContent) {
-        stringContent.append(Util.escapeHtmlChars(nullCheck(strContent)));
+        appendChars(strContent);
     }
 
     /**
@@ -83,6 +91,10 @@ public class StringContent extends Content{
         return (stringContent.length() == 0);
     }
 
+    public int charCount() {
+        return RawHtml.charCount(stringContent.toString());
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -93,7 +105,22 @@ public class StringContent extends Content{
     /**
      * {@inheritDoc}
      */
-    public void write(StringBuilder contentBuilder) {
-        contentBuilder.append(stringContent);
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        String s = stringContent.toString();
+        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("<");  break;
+                case '>': stringContent.append(">");  break;
+                case '&': stringContent.append("&"); break;
+                default:  stringContent.append(ch);      break;
+            }
+        }
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
index a1d29e1..9951877 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
@@ -4,7 +4,9 @@ doclet.Overview=Overview
 doclet.Window_Overview=Overview List
 doclet.Window_Overview_Summary=Overview
 doclet.Package=Package
+doclet.Profile=Profile
 doclet.All_Packages=All Packages
+doclet.All_Profiles=All Profiles
 doclet.Tree=Tree
 doclet.Class_Hierarchy=Class Hierarchy
 doclet.Window_Class_Hierarchy=Class Hierarchy
@@ -17,6 +19,8 @@ doclet.Prev_Class=Prev Class
 doclet.Next_Class=Next Class
 doclet.Prev_Package=Prev Package
 doclet.Next_Package=Next Package
+doclet.Prev_Profile=Prev Profile
+doclet.Next_Profile=Next Profile
 doclet.Prev_Letter=Prev Letter
 doclet.Next_Letter=Next Letter
 doclet.Href_Class_Title=class in {0}
@@ -43,32 +47,21 @@ doclet.Help=Help
 doclet.Skip_navigation_links=Skip navigation links
 doclet.Navigation=Navigation
 doclet.New_Page=NewPage
-doclet.None=None
-doclet.Factory_Method_Detail=Static Factory Method Detail
 doclet.navDeprecated=Deprecated
-doclet.Deprecated_List=Deprecated List
 doclet.Window_Deprecated_List=Deprecated List
-doclet.Note_0_is_deprecated=Note: {0} is deprecated.
 doclet.Overrides=Overrides:
 doclet.in_class=in class
-doclet.0_Fields_and_Methods="{0}" Fields and Methods
-doclet.Index_of_Fields_and_Methods=Index of Fields and Methods
 doclet.Static_variable_in=Static variable in {0}
 doclet.Variable_in=Variable in {0}
 doclet.Constructor_for=Constructor for {0}
 doclet.Static_method_in=Static method in {0}
 doclet.Method_in=Method in {0}
-doclet.throws=throws
 doclet.package=package
 doclet.MalformedURL=Malformed URL: {0}
 doclet.File_error=Error reading file: {0}
 doclet.URL_error=Error fetching URL: {0}
-doclet.No_Package_Comment_File=For Package {0} Package.Comment file not found
-doclet.No_Source_For_Class=Source information for class {0} not available.
 doclet.see.class_or_package_not_found=Tag {0}: reference not found: {1}
 doclet.see.class_or_package_not_accessible=Tag {0}: reference not accessible: {1}
-doclet.see.malformed_tag=Tag {0}: Malformed: {1}
-doclet.Inherited_API_Summary=Inherited API Summary
 doclet.Deprecated_API=Deprecated API
 doclet.Deprecated_Packages=Deprecated Packages
 doclet.Deprecated_Classes=Deprecated Classes
@@ -94,10 +87,7 @@ doclet.deprecated_constructors=deprecated constructors
 doclet.deprecated_methods=deprecated methods
 doclet.deprecated_enum_constants=deprecated enum constants
 doclet.deprecated_annotation_type_members=deprecated annotation type elements
-doclet.Frame_Output=Frame Output
-doclet.Docs_generated_by_Javadoc=Documentation generated by Javadoc.
 doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)
-doclet.Blank=Blank
 doclet.Other_Packages=Other Packages
 doclet.Package_Description=Package {0} Description
 doclet.Description=Description
@@ -106,33 +96,25 @@ doclet.in_interface=in interface
 doclet.Subclasses=Direct Known Subclasses:
 doclet.Subinterfaces=All Known Subinterfaces:
 doclet.Implementing_Classes=All Known Implementing Classes:
+doclet.Functional_Interface=Functional Interface:
+doclet.Functional_Interface_Message=This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
 doclet.also=also
-doclet.Option=Option
-doclet.Or=Or
 doclet.Frames=Frames
 doclet.No_Frames=No Frames
 doclet.Package_Hierarchies=Package Hierarchies:
 doclet.Hierarchy_For_Package=Hierarchy For Package {0}
-doclet.Source_Code=Source Code:
 doclet.Hierarchy_For_All_Packages=Hierarchy For All Packages
-doclet.Cannot_handle_no_packages=Cannot handle no packages.
 doclet.Frame_Alert=Frame Alert
-doclet.Overview-Member-Frame=Overview Member Frame
 doclet.Frame_Warning_Message=This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to {0}.
 doclet.No_Script_Message=JavaScript is disabled on your browser.
 doclet.Non_Frame_Version=Non-frame version
-doclet.Frame_Version=Frame version
-doclet.Following_From_Class=Following copied from class: {0}
-doclet.Following_From_Interface=Following copied from interface: {0}
 doclet.Description_From_Interface=Description copied from interface:
 doclet.Description_From_Class=Description copied from class:
-doclet.Standard_doclet_invoked=Standard doclet invoked...
 doclet.No_Non_Deprecated_Classes_To_Document=No non-deprecated classes found to document.
 doclet.Interfaces_Italic=Interfaces (italic)
 doclet.Enclosing_Class=Enclosing class:
 doclet.Enclosing_Interface=Enclosing interface:
 doclet.Window_Source_title=Source code
-doclet.Help_title=API Help
 doclet.Window_Help_title=API Help
 doclet.Help_line_1=How This API Document Is Organized
 doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
@@ -150,7 +132,7 @@ doclet.Help_line_13=Each summary entry contains the first sentence from the deta
 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 t [...]
 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.
@@ -170,19 +152,6 @@ doclet.Help_enum_line_3=Enum description
 doclet.Help_annotation_type_line_1=Each annotation type has its own separate page with the following sections:
 doclet.Help_annotation_type_line_2=Annotation Type declaration
 doclet.Help_annotation_type_line_3=Annotation Type description
-doclet.Style_line_1=Javadoc style sheet
-doclet.Style_line_2=Define colors, fonts and other style attributes here to override the defaults
-doclet.Style_line_3=Page background color
-doclet.Style_Headings=Headings
-doclet.Style_line_4=Table colors
-doclet.Style_line_5=Dark mauve
-doclet.Style_line_6=Light mauve
-doclet.Style_line_7=White
-doclet.Style_line_8=Font used in left-hand frame lists
-doclet.Style_line_9=Example of smaller, sans-serif font in frames
-doclet.Style_line_10=Navigation bar fonts and colors
-doclet.Style_line_11=Dark Blue
-doclet.Style_line_12=Table caption style
 doclet.ClassUse_Packages.that.use.0=Packages that use {0}
 doclet.ClassUse_Uses.of.0.in.1=Uses of {0} in {1}
 doclet.ClassUse_Classes.in.0.used.by.1=Classes in {0} used by {1}
@@ -191,9 +160,7 @@ doclet.ClassUse_Annotation=Classes in {1} with annotations of type {0}
 doclet.ClassUse_TypeParameter=Classes in {1} with type parameters of type {0}
 doclet.ClassUse_MethodTypeParameter=Methods in {1} with type parameters of type {0}
 doclet.ClassUse_FieldTypeParameter=Fields in {1} with type parameters of type {0}
-doclet.ClassUse_PropertyTypeParameter=Properties in {1} with type parameters of type {0}
 doclet.ClassUse_FieldAnnotations=Fields in {1} with annotations of type {0}
-doclet.ClassUse_PropertyAnnotations=Properties in {1} with annotations of type {0}
 doclet.ClassUse_MethodAnnotations=Methods in {1} with annotations of type {0}
 doclet.ClassUse_MethodParameterAnnotations=Method parameters in {1} with annotations of type {0}
 doclet.ClassUse_MethodReturnTypeParameter=Methods in {1} that return types with arguments of type {0}
@@ -212,55 +179,57 @@ doclet.ClassUse_ConstructorArgsTypeParameters=Constructor parameters in {1} with
 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.link_option_twice=Extern URL link option (link or linkoffline) used twice.
 doclet.Error_in_packagelist=Error in using -group option: {0} {1}
 doclet.Groupname_already_used=In -group option, groupname already used: {0}
 doclet.Same_package_name_used=Package name format used twice: {0}
-doclet.Serialization.Excluded_Class=Non-transient field {1} uses excluded class {0}.
-doclet.Serialization.Nonexcluded_Class=Non-transient field {1} uses hidden, non-included class {0}.
 doclet.exception_encountered=Exception encountered while processing {1}\n{0}
 doclet.usage=Provided by Standard doclet:\n\
-  -d <directory>                    Destination directory for output files\n\
-  -use                              Create class and package usage pages\n\
-  -version                          Include @version paragraphs\n\
-  -author                           Include @author paragraphs\n\
-  -docfilessubdirs                  Recursively copy doc-file subdirectories\n\
-  -splitindex                       Split index into one file per letter\n\
-  -windowtitle <text>               Browser window title for the documenation\n\
-  -doctitle <html-code>             Include title for the overview page\n\
-  -header <html-code>               Include header text for each page\n\
-  -footer <html-code>               Include footer text for each page\n\
-  -top    <html-code>               Include top text for each page\n\
-  -bottom <html-code>               Include bottom text for each page\n\
-  -link <url>                       Create links to javadoc output at <url>\n\
-  -linkoffline <url> <url2>         Link to docs at <url> using package list at <url2>\n\
-  -excludedocfilessubdir <name1>:.. Exclude any doc-files subdirectories with given name.\n\
-  -group <name> <p1>:<p2>..         Group specified packages together in overview page\n\
-  -nocomment                        Supress description and tags, generate only declarations.\n\
-  -nodeprecated                     Do not include @deprecated information\n\
-  -noqualifier <name1>:<name2>:...  Exclude the list of qualifiers from the output.\n\
-  -nosince                          Do not include @since information\n\
-  -notimestamp                      Do not include hidden time stamp\n\
-  -nodeprecatedlist                 Do not generate deprecated list\n\
-  -notree                           Do not generate class hierarchy\n\
-  -noindex                          Do not generate index\n\
-  -nohelp                           Do not generate help link\n\
-  -nonavbar                         Do not generate navigation bar\n\
-  -serialwarn                       Generate warning about @serial tag\n\
-  -tag <name>:<locations>:<header>  Specify single argument custom tags\n\
-  -taglet                           The fully qualified name of Taglet to register\n\
-  -tagletpath                       The path to Taglets\n\
-  -Xdocrootparent <url>             Replaces all appearances of @docRoot followed by /.. in doc comments with <url>\n\
-  -charset <charset>                Charset for cross-platform viewing of generated documentation.\n\
-  -helpfile <file>                  Include file that help link links to\n\
-  -linksource                       Generate source in HTML\n\
-  -sourcetab <tab length>           Specify the number of spaces each tab takes up in the source\n\
-  -keywords                         Include HTML meta tags with package, class and member info\n\
-  -stylesheetfile <path>            File to change style of the generated documentation\n\
-  -docencoding <name>               Output encoding name
-
-
+\  -d <directory>                   Destination directory for output files\n\
+\  -use                             Create class and package usage pages\n\
+\  -version                         Include @version paragraphs\n\
+\  -author                          Include @author paragraphs\n\
+\  -docfilessubdirs                 Recursively copy doc-file subdirectories\n\
+\  -splitindex                      Split index into one file per letter\n\
+\  -windowtitle <text>              Browser window title for the documentation\n\
+\  -doctitle <html-code>            Include title for the overview page\n\
+\  -header <html-code>              Include header text for each page\n\
+\  -footer <html-code>              Include footer text for each page\n\
+\  -top    <html-code>              Include top text for each page\n\
+\  -bottom <html-code>              Include bottom text for each page\n\
+\  -link <url>                      Create links to javadoc output at <url>\n\
+\  -linkoffline <url> <url2>        Link to docs at <url> using package list at <url2>\n\
+\  -excludedocfilessubdir <name1>:.. Exclude any doc-files subdirectories with given name.\n\
+\  -group <name> <p1>:<p2>..        Group specified packages together in overview page\n\
+\  -nocomment                       Suppress description and tags, generate only declarations.\n\
+\  -nodeprecated                    Do not include @deprecated information\n\
+\  -noqualifier <name1>:<name2>:... Exclude the list of qualifiers from the output.\n\
+\  -nosince                         Do not include @since information\n\
+\  -notimestamp                     Do not include hidden time stamp\n\
+\  -nodeprecatedlist                Do not generate deprecated list\n\
+\  -notree                          Do not generate class hierarchy\n\
+\  -noindex                         Do not generate index\n\
+\  -nohelp                          Do not generate help link\n\
+\  -nonavbar                        Do not generate navigation bar\n\
+\  -serialwarn                      Generate warning about @serial tag\n\
+\  -tag <name>:<locations>:<header> Specify single argument custom tags\n\
+\  -taglet                          The fully qualified name of Taglet to register\n\
+\  -tagletpath                      The path to Taglets\n\
+\  -charset <charset>               Charset for cross-platform viewing of generated documentation.\n\
+\  -helpfile <file>                 Include file that help link links to\n\
+\  -linksource                      Generate source in HTML\n\
+\  -sourcetab <tab length>          Specify the number of spaces each tab takes up in the source\n\
+\  -keywords                        Include HTML meta tags with package, class and member info\n\
+\  -stylesheetfile <path>           File to change style of the generated documentation\n\
+\  -docencoding <name>              Specify the character encoding for the output
 
 
+# L10N: do not localize these words: all none accessibility html missing reference syntax
+doclet.X.usage=Provided by standard doclet:\n\
+\  -Xdocrootparent <url>            Replaces all appearances of @docRoot followed\n\
+\                                   by /.. in doc comments with <url>\n\
+\  -Xdoclint                        Enable recommended checks for problems in javadoc comments\n\
+\  -Xdoclint:(all|none|[-]<group>) \n\
+\        Enable or disable specific checks for problems in javadoc comments,\n\
+\        where <group> is one of accessibility, html, missing, reference, or syntax.\n
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
index f887dcd..373b533 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
@@ -4,7 +4,9 @@ doclet.Overview=\u6982\u8981
 doclet.Window_Overview=\u6982\u8981\u30EA\u30B9\u30C8
 doclet.Window_Overview_Summary=\u6982\u8981
 doclet.Package=\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.Profile=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
 doclet.All_Packages=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.All_Profiles=\u3059\u3079\u3066\u306E\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
 doclet.Tree=\u968E\u5C64\u30C4\u30EA\u30FC
 doclet.Class_Hierarchy=\u30AF\u30E9\u30B9\u968E\u5C64
 doclet.Window_Class_Hierarchy=\u30AF\u30E9\u30B9\u968E\u5C64
@@ -17,6 +19,8 @@ doclet.Prev_Class=\u524D\u306E\u30AF\u30E9\u30B9
 doclet.Next_Class=\u6B21\u306E\u30AF\u30E9\u30B9
 doclet.Prev_Package=\u524D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.Next_Package=\u6B21\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.Prev_Profile=\u524D\u306E\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
+doclet.Next_Profile=\u6B21\u306E\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
 doclet.Prev_Letter=\u524D\u306E\u6587\u5B57
 doclet.Next_Letter=\u6B21\u306E\u6587\u5B57
 doclet.Href_Class_Title={0}\u5185\u306E\u30AF\u30E9\u30B9
@@ -33,7 +37,7 @@ doclet.navAnnotationTypeRequiredMember=\u5FC5\u9808
 doclet.navAnnotationTypeMember=\u8981\u7D20
 doclet.navField=\u30D5\u30A3\u30FC\u30EB\u30C9
 doclet.navProperty=\u30D7\u30ED\u30D1\u30C6\u30A3
-doclet.navEnum=\u5217\u6319\u5B9A\u6570
+doclet.navEnum=\u5217\u6319\u578B\u5B9A\u6570
 doclet.navConstructor=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
 doclet.navMethod=\u30E1\u30BD\u30C3\u30C9
 doclet.Index=\u7D22\u5F15
@@ -43,61 +47,47 @@ doclet.Help=\u30D8\u30EB\u30D7
 doclet.Skip_navigation_links=\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30EA\u30F3\u30AF\u3092\u30B9\u30AD\u30C3\u30D7
 doclet.Navigation=\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3
 doclet.New_Page=NewPage
-doclet.None=\u306A\u3057
-doclet.Factory_Method_Detail=static\u30D5\u30A1\u30AF\u30C8\u30EA\u30FB\u30E1\u30BD\u30C3\u30C9\u306E\u8A73\u7D30
 doclet.navDeprecated=\u975E\u63A8\u5968
-doclet.Deprecated_List=\u975E\u63A8\u5968API\u306E\u30EA\u30B9\u30C8
-doclet.Window_Deprecated_List=\u975E\u63A8\u5968API\u306E\u30EA\u30B9\u30C8
-doclet.Note_0_is_deprecated=\u6CE8\u610F: {0}\u306F\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
+doclet.Window_Deprecated_List=\u975E\u63A8\u5968\u306E\u30EA\u30B9\u30C8
 doclet.Overrides=\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9:
 doclet.in_class=\u30AF\u30E9\u30B9\u5185
-doclet.0_Fields_and_Methods="{0}"\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u30E1\u30BD\u30C3\u30C9
-doclet.Index_of_Fields_and_Methods=\u30D5\u30A3\u30FC\u30EB\u30C9\u3068\u30E1\u30BD\u30C3\u30C9\u306E\u7D22\u5F15
 doclet.Static_variable_in={0}\u306Estatic\u5909\u6570
 doclet.Variable_in={0}\u306E\u5909\u6570
 doclet.Constructor_for={0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
 doclet.Static_method_in={0}\u306Estatic\u30E1\u30BD\u30C3\u30C9
 doclet.Method_in={0}\u306E\u30E1\u30BD\u30C3\u30C9
-doclet.throws=\u30B9\u30ED\u30FC
 doclet.package=\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.MalformedURL=\u4E0D\u6B63\u306AURL: {0}
 doclet.File_error=\u30D5\u30A1\u30A4\u30EB\u8AAD\u8FBC\u307F\u30A8\u30E9\u30FC: {0}
 doclet.URL_error=URL\u53D6\u51FA\u3057\u30A8\u30E9\u30FC: {0}
-doclet.No_Package_Comment_File=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306EPackage.Comment\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
-doclet.No_Source_For_Class=\u30AF\u30E9\u30B9{0}\u306E\u30BD\u30FC\u30B9\u60C5\u5831\u304C\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002
 doclet.see.class_or_package_not_found=\u30BF\u30B0{0}: \u53C2\u7167\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {1}
 doclet.see.class_or_package_not_accessible=\u30BF\u30B0{0}: \u53C2\u7167\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093: {1}
-doclet.see.malformed_tag={0}\u30BF\u30B0: \u4E0D\u6B63\u306A{1}\u30BF\u30B0
-doclet.Inherited_API_Summary=\u7D99\u627F\u3055\u308C\u305FAPI\u306E\u6982\u8981
-doclet.Deprecated_API=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044API
-doclet.Deprecated_Packages=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D1\u30C3\u30B1\u30FC\u30B8
-doclet.Deprecated_Classes=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30AF\u30E9\u30B9
-doclet.Deprecated_Enums=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B
-doclet.Deprecated_Interfaces=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
-doclet.Deprecated_Exceptions=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u4F8B\u5916
-doclet.Deprecated_Annotation_Types=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B
-doclet.Deprecated_Errors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A8\u30E9\u30FC
-doclet.Deprecated_Fields=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D5\u30A3\u30FC\u30EB\u30C9
-doclet.Deprecated_Constructors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
-doclet.Deprecated_Methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9
-doclet.Deprecated_Enum_Constants=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B\u5B9A\u6570
-doclet.Deprecated_Annotation_Type_Members=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B\u306E\u8981\u7D20
-doclet.deprecated_packages=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D1\u30C3\u30B1\u30FC\u30B8
-doclet.deprecated_classes=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30AF\u30E9\u30B9
-doclet.deprecated_enums=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B
-doclet.deprecated_interfaces=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
-doclet.deprecated_exceptions=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u4F8B\u5916
-doclet.deprecated_annotation_types=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B
-doclet.deprecated_errors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30A8\u30E9\u30FC
-doclet.deprecated_fields=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30D5\u30A3\u30FC\u30EB\u30C9
-doclet.deprecated_constructors=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
-doclet.deprecated_methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9
-doclet.deprecated_enum_constants=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u5217\u6319\u578B\u5B9A\u6570
-doclet.deprecated_annotation_type_members=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u6CE8\u91C8\u578B\u306E\u8981\u7D20
-doclet.Frame_Output=\u30D5\u30EC\u30FC\u30E0\u51FA\u529B
-doclet.Docs_generated_by_Javadoc=\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306Fjavadoc\u3067\u751F\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002
+doclet.Deprecated_API=\u975E\u63A8\u5968\u306EAPI
+doclet.Deprecated_Packages=\u975E\u63A8\u5968\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.Deprecated_Classes=\u975E\u63A8\u5968\u306E\u30AF\u30E9\u30B9
+doclet.Deprecated_Enums=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B
+doclet.Deprecated_Interfaces=\u975E\u63A8\u5968\u306E\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
+doclet.Deprecated_Exceptions=\u975E\u63A8\u5968\u306E\u4F8B\u5916
+doclet.Deprecated_Annotation_Types=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B
+doclet.Deprecated_Errors=\u975E\u63A8\u5968\u306E\u30A8\u30E9\u30FC
+doclet.Deprecated_Fields=\u975E\u63A8\u5968\u306E\u30D5\u30A3\u30FC\u30EB\u30C9
+doclet.Deprecated_Constructors=\u975E\u63A8\u5968\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
+doclet.Deprecated_Methods=\u975E\u63A8\u5968\u306E\u30E1\u30BD\u30C3\u30C9
+doclet.Deprecated_Enum_Constants=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B\u5B9A\u6570
+doclet.Deprecated_Annotation_Type_Members=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B\u306E\u8981\u7D20
+doclet.deprecated_packages=\u975E\u63A8\u5968\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.deprecated_classes=\u975E\u63A8\u5968\u306E\u30AF\u30E9\u30B9
+doclet.deprecated_enums=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B
+doclet.deprecated_interfaces=\u975E\u63A8\u5968\u306E\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
+doclet.deprecated_exceptions=\u975E\u63A8\u5968\u306E\u4F8B\u5916
+doclet.deprecated_annotation_types=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B
+doclet.deprecated_errors=\u975E\u63A8\u5968\u306E\u30A8\u30E9\u30FC
+doclet.deprecated_fields=\u975E\u63A8\u5968\u306E\u30D5\u30A3\u30FC\u30EB\u30C9
+doclet.deprecated_constructors=\u975E\u63A8\u5968\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
+doclet.deprecated_methods=\u975E\u63A8\u5968\u306E\u30E1\u30BD\u30C3\u30C9
+doclet.deprecated_enum_constants=\u975E\u63A8\u5968\u306E\u5217\u6319\u578B\u5B9A\u6570
+doclet.deprecated_annotation_type_members=\u975E\u63A8\u5968\u306E\u6CE8\u91C8\u578B\u306E\u8981\u7D20
 doclet.Generated_Docs_Untitled=\u751F\u6210\u3055\u308C\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8(\u30BF\u30A4\u30C8\u30EB\u306A\u3057)
-doclet.Blank=\u30D6\u30E9\u30F3\u30AF
 doclet.Other_Packages=\u305D\u306E\u4ED6\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.Package_Description=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u8AAC\u660E
 doclet.Description=\u8AAC\u660E
@@ -106,33 +96,25 @@ doclet.in_interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u5185
 doclet.Subclasses=\u76F4\u7CFB\u306E\u65E2\u77E5\u306E\u30B5\u30D6\u30AF\u30E9\u30B9:
 doclet.Subinterfaces=\u65E2\u77E5\u306E\u30B5\u30D6\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8:
 doclet.Implementing_Classes=\u65E2\u77E5\u306E\u5B9F\u88C5\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8:
+doclet.Functional_Interface=\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
+doclet.Functional_Interface_Message=\u3053\u308C\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306A\u306E\u3067\u3001\u30E9\u30E0\u30C0\u5F0F\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u5272\u5F53\u3066\u30BF\u30FC\u30B2\u30C3\u30C8\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002 
 doclet.also=\u540C\u69D8\u306B
-doclet.Option=\u30AA\u30D7\u30B7\u30E7\u30F3
-doclet.Or=\u307E\u305F\u306F
 doclet.Frames=\u30D5\u30EC\u30FC\u30E0
 doclet.No_Frames=\u30D5\u30EC\u30FC\u30E0\u306A\u3057
 doclet.Package_Hierarchies=\u30D1\u30C3\u30B1\u30FC\u30B8\u968E\u5C64:
 doclet.Hierarchy_For_Package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u968E\u5C64
-doclet.Source_Code=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9:
 doclet.Hierarchy_For_All_Packages=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64
-doclet.Cannot_handle_no_packages=\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u51E6\u7406\u3067\u304D\u307E\u305B\u3093\u3002
 doclet.Frame_Alert=\u30D5\u30EC\u30FC\u30E0\u95A2\u9023\u306E\u30A2\u30E9\u30FC\u30C8
-doclet.Overview-Member-Frame=\u6982\u8981\u30E1\u30F3\u30D0\u30FC\u30FB\u30D5\u30EC\u30FC\u30E0
 doclet.Frame_Warning_Message=\u3053\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306F\u30D5\u30EC\u30FC\u30E0\u6A5F\u80FD\u3092\u4F7F\u7528\u3057\u3066\u8868\u793A\u3059\u308B\u3088\u3046\u306B\u4F5C\u6210\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30D5\u30EC\u30FC\u30E0\u3092\u8868\u793A\u3067\u304D\u306A\u3044Web\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u306E\u5834\u5408\u306B\u3053\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002{0}\u306B\u30EA\u30F3\u30AF\ [...]
 doclet.No_Script_Message=\u30D6\u30E9\u30A6\u30B6\u306EJavaScript\u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u3002
 doclet.Non_Frame_Version=\u30D5\u30EC\u30FC\u30E0\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u306A\u3044\u30D0\u30FC\u30B8\u30E7\u30F3
-doclet.Frame_Version=\u30D5\u30EC\u30FC\u30E0\u3042\u308A\u306E\u30D0\u30FC\u30B8\u30E7\u30F3
-doclet.Following_From_Class=\u30AF\u30E9\u30B9{0}\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u30BF\u30B0:
-doclet.Following_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9{0}\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u30BF\u30B0:
 doclet.Description_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u8AAC\u660E:
 doclet.Description_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u30B3\u30D4\u30FC\u3055\u308C\u305F\u8AAC\u660E:
-doclet.Standard_doclet_invoked=\u6A19\u6E96\u306Edoclet\u304C\u8D77\u52D5\u3055\u308C\u307E\u3057\u305F...
-doclet.No_Non_Deprecated_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308B\u975E\u63A8\u5968\u4EE5\u5916\u306E\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
+doclet.No_Non_Deprecated_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308B\u975E\u63A8\u5968\u3067\u306A\u3044\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
 doclet.Interfaces_Italic=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9(\u30A4\u30BF\u30EA\u30C3\u30AF)
 doclet.Enclosing_Class=\u542B\u307E\u308C\u3066\u3044\u308B\u30AF\u30E9\u30B9:
 doclet.Enclosing_Interface=\u542B\u307E\u308C\u3066\u3044\u308B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9:
 doclet.Window_Source_title=\u30BD\u30FC\u30B9\u30FB\u30B3\u30FC\u30C9
-doclet.Help_title=API\u30D8\u30EB\u30D7
 doclet.Window_Help_title=API\u30D8\u30EB\u30D7
 doclet.Help_line_1=API\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u69CB\u6210
 doclet.Help_line_2=\u3053\u306EAPI(Application Programming Interface)\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u306F\u3001\u6B21\u306B\u8AAC\u660E\u3059\u308B\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306B\u3042\u308B\u9805\u76EE\u306B\u5BFE\u5FDC\u3059\u308B\u30DA\u30FC\u30B8\u304C\u542B\u307E\u308C\u307E\u3059\u3002
@@ -150,10 +132,10 @@ doclet.Help_line_13=\u5404\u6982\u8981\u30A8\u30F3\u30C8\u30EA\u306B\u306F\u3001
 doclet.Help_line_14=\u4F7F\u7528
 doclet.Help_line_15=\u5404\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3055\u308C\u305F\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u306F\u305D\u308C\u305E\u308C\u300C\u4F7F\u7528\u300D\u30DA\u30FC\u30B8\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u30DA\u30FC\u30B8\u306B\u306F\u3001\u3069\u306E\u3088\u3046\u306A\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u3001\u30E1\u30BD\u30C3\u30C9\u3001\u30B3\u30 [...]
 doclet.Help_line_16=\u968E\u5C64\u30C4\u30EA\u30FC(\u30AF\u30E9\u30B9\u968E\u5C64)
-doclet.Help_line_17_with_tree_link=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F{0}\u30DA\u30FC\u30B8\u304C\u3042\u308A\u3001\u3055\u3089\u306B\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64\u304C\u3042\u308A\u307E\u3059\u3002\u5404\u968E\u5C64\u30DA\u30FC\u30B8\u306F\u3001\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8\u3068\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8\u3092\u542B\u307F\u307E\u3059\u3002\u30AF\u30E9\u30B9\u306F <code>java.lang [...]
+doclet.Help_line_17_with_tree_link=\u3059\u3079\u3066\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u306F{0}\u30DA\u30FC\u30B8\u304C\u3042\u308A\u3001\u3055\u3089\u306B\u5404\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64\u304C\u3042\u308A\u307E\u3059\u3002\u5404\u968E\u5C64\u30DA\u30FC\u30B8\u306F\u3001\u30AF\u30E9\u30B9\u306E\u30EA\u30B9\u30C8\u3068\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u30EA\u30B9\u30C8\u3092\u542B\u307F\u307E\u3059\u3002\u30AF\u30E9\u30B9\u306F{1}\u3092\u958B\ [...]
 doclet.Help_line_18=\u6982\u8981\u30DA\u30FC\u30B8\u3092\u8868\u793A\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u300C\u968E\u5C64\u30C4\u30EA\u30FC\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u3068\u3001\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u968E\u5C64\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002
 doclet.Help_line_19=\u7279\u5B9A\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u8868\u793A\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u300C\u968E\u5C64\u30C4\u30EA\u30FC\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u3068\u3001\u8A72\u5F53\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u307F\u306E\u968E\u5C64\u304C\u8868\u793A\u3055\u308C\u307E\u3059\u3002
-doclet.Help_line_20_with_deprecated_api_link={0}\u30DA\u30FC\u30B8\u306F\u3001\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u3059\u3079\u3066\u306EAPI\u306E\u30EA\u30B9\u30C8\u3092\u8868\u793A\u3057\u307E\u3059\u3002\u975E\u63A8\u5968API\u3068\u306F\u3001\u6A5F\u80FD\u6539\u826F\u306A\u3069\u306E\u7406\u7531\u304B\u3089\u4F7F\u7528\u3092\u304A\u85A6\u3081\u3067\u304D\u306A\u304F\u306A\u3063\u305FAPI\u306E\u3053\u3068\u3067\u3001\u901A\u5E38\u306F\u305D\u308C\u306B\u4EE3\u308F\u308BAPI [...]
+doclet.Help_line_20_with_deprecated_api_link={0}\u30DA\u30FC\u30B8\u306F\u3001\u975E\u63A8\u5968\u306EAPI\u3092\u3059\u3079\u3066\u30EA\u30B9\u30C8\u3057\u307E\u3059\u3002\u975E\u63A8\u5968\u306EAPI\u3068\u306F\u3001\u6A5F\u80FD\u6539\u826F\u306A\u3069\u306E\u7406\u7531\u304B\u3089\u4F7F\u7528\u3092\u304A\u85A6\u3081\u3067\u304D\u306A\u304F\u306A\u3063\u305FAPI\u306E\u3053\u3068\u3067\u3001\u901A\u5E38\u306F\u305D\u308C\u306B\u4EE3\u308F\u308BAPI\u304C\u63D0\u4F9B\u3055\u308C\u307E\u3059 [...]
 doclet.Help_line_21=\u7D22\u5F15
 doclet.Help_line_22={0}\u306B\u306F\u3001\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3001\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u3001\u30E1\u30BD\u30C3\u30C9\u304A\u3088\u3073\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8\u9806\u306E\u30EA\u30B9\u30C8\u304C\u542B\u307E\u308C\u307E\u3059\u3002
 doclet.Help_line_23=\u524D/\u6B21
@@ -170,19 +152,6 @@ doclet.Help_enum_line_3=\u5217\u6319\u578B\u306E\u8AAC\u660E
 doclet.Help_annotation_type_line_1=\u5404\u6CE8\u91C8\u578B\u306B\u306F\u3001\u305D\u308C\u81EA\u8EAB\u306E\u500B\u5225\u306E\u30DA\u30FC\u30B8\u3068\u6B21\u306E\u30BB\u30AF\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059:
 doclet.Help_annotation_type_line_2=\u6CE8\u91C8\u578B\u306E\u5BA3\u8A00
 doclet.Help_annotation_type_line_3=\u6CE8\u91C8\u578B\u306E\u8AAC\u660E
-doclet.Style_line_1=javadoc\u30B9\u30BF\u30A4\u30EB\u30FB\u30B7\u30FC\u30C8
-doclet.Style_line_2=\u8272\u3084\u30D5\u30A9\u30F3\u30C8\u306A\u3069\u306E\u30B9\u30BF\u30A4\u30EB\u5C5E\u6027\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\u306B\u306F\u3001\u3053\u3053\u3067\u5B9A\u7FA9\u3057\u307E\u3059
-doclet.Style_line_3=\u30DA\u30FC\u30B8\u306E\u30D0\u30C3\u30AF\u30B0\u30E9\u30A6\u30F3\u30C9\u306E\u8272
-doclet.Style_Headings=\u898B\u51FA\u3057
-doclet.Style_line_4=\u8868\u306E\u8272
-doclet.Style_line_5=\u6FC3\u3044\u85E4\u8272
-doclet.Style_line_6=\u8584\u3044\u85E4\u8272
-doclet.Style_line_7=\u767D
-doclet.Style_line_8=\u5DE6\u5074\u306E\u30D5\u30EC\u30FC\u30E0\u306E\u30EA\u30B9\u30C8\u306B\u4F7F\u7528\u3059\u308B\u30D5\u30A9\u30F3\u30C8
-doclet.Style_line_9=\u30D5\u30EC\u30FC\u30E0\u306B\u304A\u3051\u308B\u3001\u3088\u308A\u5C0F\u3055\u3044sans-serif\u30D5\u30A9\u30F3\u30C8\u306E\u4F8B
-doclet.Style_line_10=\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u306E\u30D5\u30A9\u30F3\u30C8\u3068\u8272
-doclet.Style_line_11=\u6FC3\u3044\u9752
-doclet.Style_line_12=\u8868\u306E\u30AD\u30E3\u30D7\u30B7\u30E7\u30F3\u30FB\u30B9\u30BF\u30A4\u30EB
 doclet.ClassUse_Packages.that.use.0={0}\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.ClassUse_Uses.of.0.in.1={1}\u3067\u306E{0}\u306E\u4F7F\u7528
 doclet.ClassUse_Classes.in.0.used.by.1={1}\u306B\u3088\u308A\u4F7F\u7528\u3055\u308C\u308B{0}\u306E\u30AF\u30E9\u30B9
@@ -191,9 +160,7 @@ doclet.ClassUse_Annotation={0}\u578B\u306E\u6CE8\u91C8\u3092\u6301\u3064{1}\u306
 doclet.ClassUse_TypeParameter={0}\u578B\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064{1}\u306E\u30AF\u30E9\u30B9
 doclet.ClassUse_MethodTypeParameter={0}\u578B\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064{1}\u306E\u30E1\u30BD\u30C3\u30C9
 doclet.ClassUse_FieldTypeParameter={0}\u578B\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064{1}\u306E\u30D5\u30A3\u30FC\u30EB\u30C9
-doclet.ClassUse_PropertyTypeParameter={0}\u578B\u306E\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064{1}\u306E\u30D7\u30ED\u30D1\u30C6\u30A3
 doclet.ClassUse_FieldAnnotations={0}\u578B\u306E\u6CE8\u91C8\u3092\u6301\u3064{1}\u306E\u30D5\u30A3\u30FC\u30EB\u30C9
-doclet.ClassUse_PropertyAnnotations={0}\u578B\u306E\u6CE8\u91C8\u3092\u6301\u3064{1}\u306E\u30D7\u30ED\u30D1\u30C6\u30A3
 doclet.ClassUse_MethodAnnotations={0}\u578B\u306E\u6CE8\u91C8\u3092\u6301\u3064{1}\u306E\u30E1\u30BD\u30C3\u30C9
 doclet.ClassUse_MethodParameterAnnotations={0}\u578B\u306E\u6CE8\u91C8\u3092\u6301\u3064{1}\u306E\u30E1\u30BD\u30C3\u30C9\u30FB\u30D1\u30E9\u30E1\u30FC\u30BF
 doclet.ClassUse_MethodReturnTypeParameter={0}\u578B\u306E\u5F15\u6570\u3092\u6301\u3064\u578B\u3092\u8FD4\u3059{1}\u306E\u30E1\u30BD\u30C3\u30C9
@@ -212,16 +179,14 @@ doclet.ClassUse_ConstructorArgsTypeParameters={0}\u578B\u306E\u578B\u5F15\u6570\
 doclet.ClassUse_ConstructorThrows={0}\u3092\u30B9\u30ED\u30FC\u3059\u308B{1}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
 doclet.ClassUse_No.usage.of.0={0}\u306F\u3069\u3053\u304B\u3089\u3082\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u305B\u3093
 doclet.Window_ClassUse_Header={0} {1}\u306E\u4F7F\u7528
-doclet.ClassUse_Title={0}<br>{1}\u306E\u4F7F\u7528
+doclet.ClassUse_Title={0}\u306E\u4F7F\u7528
 doclet.navClassUse=\u4F7F\u7528
-doclet.link_option_twice=\u5916\u90E8URL\u30EA\u30F3\u30AF\u30FB\u30AA\u30D7\u30B7\u30E7\u30F3(link\u307E\u305F\u306Flinkoffline)\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u3002
 doclet.Error_in_packagelist=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u4F7F\u7528\u65B9\u6CD5\u306E\u30A8\u30E9\u30FC: {0} {1}
 doclet.Groupname_already_used=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u304A\u3044\u3066\u3001\u3059\u3067\u306B\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0}
 doclet.Same_package_name_used=\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u5F62\u5F0F\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0}
-doclet.Serialization.Excluded_Class=\u5E38\u99D0\u30D5\u30A3\u30FC\u30EB\u30C9{1}\u306F\u3001\u9664\u5916\u3055\u308C\u305F\u30AF\u30E9\u30B9{0}\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
-doclet.Serialization.Nonexcluded_Class=\u5E38\u99D0\u30D5\u30A3\u30FC\u30EB\u30C9{1}\u306F\u3001\u975E\u8868\u793A\u306E\u3001\u542B\u307E\u308C\u306A\u3044\u30AF\u30E9\u30B9{0}\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
 doclet.exception_encountered={1}\u306E\u51E6\u7406\u4E2D\u306B\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n{0}
-doclet.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n-d <directory>                    \u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\n-use                              \u30AF\u30E9\u30B9\u3068\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4F7F\u7528\u30DA\u30FC\u30B8\u3092\u4F5C\u6210\u3059\u308B\n-version                          @version\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-autho [...]
+doclet.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n-d <directory>                    \u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\n-use                              \u30AF\u30E9\u30B9\u3068\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4F7F\u7528\u30DA\u30FC\u30B8\u3092\u4F5C\u6210\u3059\u308B\n-version                          @version\u30D1\u30E9\u30B0\u30E9\u30D5\u3092\u542B\u3081\u308B\n-autho [...]
+<url>             \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30B3\u30E1\u30F3\u30C8\u5185\u306E at docRoot(\u3053\u306E\u5F8C\u306B\u306F/..\u304C\u7D9A\u304F)\u306E\u3059\u3079\u3066\u306E\u51FA\u73FE\u7B87\u6240\u3092<url>\u3067\u7F6E\u63DB\u3059\u308B\n-charset <charset>                \u751F\u6210\u3055\u308C\u308B\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30AF\u30ED\u30B9\u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u3067\u306E\u6587\u5B57\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3 [...]
 
 
 
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties
index 9260d65..61fd72c 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_zh_CN.properties
@@ -4,7 +4,9 @@ doclet.Overview=\u6982\u89C8
 doclet.Window_Overview=\u6982\u89C8\u5217\u8868
 doclet.Window_Overview_Summary=\u6982\u89C8
 doclet.Package=\u7A0B\u5E8F\u5305
+doclet.Profile=\u914D\u7F6E\u6587\u4EF6
 doclet.All_Packages=\u6240\u6709\u7A0B\u5E8F\u5305
+doclet.All_Profiles=\u6240\u6709\u914D\u7F6E\u6587\u4EF6
 doclet.Tree=\u6811
 doclet.Class_Hierarchy=\u7C7B\u5206\u5C42\u7ED3\u6784
 doclet.Window_Class_Hierarchy=\u7C7B\u5206\u5C42\u7ED3\u6784
@@ -17,6 +19,8 @@ doclet.Prev_Class=\u4E0A\u4E00\u4E2A\u7C7B
 doclet.Next_Class=\u4E0B\u4E00\u4E2A\u7C7B
 doclet.Prev_Package=\u4E0A\u4E00\u4E2A\u7A0B\u5E8F\u5305
 doclet.Next_Package=\u4E0B\u4E00\u4E2A\u7A0B\u5E8F\u5305
+doclet.Prev_Profile=\u4E0A\u4E00\u914D\u7F6E\u6587\u4EF6
+doclet.Next_Profile=\u4E0B\u4E00\u914D\u7F6E\u6587\u4EF6
 doclet.Prev_Letter=\u4E0A\u4E00\u4E2A\u5B57\u6BCD
 doclet.Next_Letter=\u4E0B\u4E00\u4E2A\u5B57\u6BCD
 doclet.Href_Class_Title={0}\u4E2D\u7684\u7C7B
@@ -43,32 +47,21 @@ doclet.Help=\u5E2E\u52A9
 doclet.Skip_navigation_links=\u8DF3\u8FC7\u5BFC\u822A\u94FE\u63A5
 doclet.Navigation=\u5BFC\u822A
 doclet.New_Page=NewPage
-doclet.None=\u65E0
-doclet.Factory_Method_Detail=\u9759\u6001\u5DE5\u5382\u65B9\u6CD5\u8BE6\u7EC6\u8D44\u6599
 doclet.navDeprecated=\u5DF2\u8FC7\u65F6
-doclet.Deprecated_List=\u5DF2\u8FC7\u65F6\u7684\u5217\u8868
 doclet.Window_Deprecated_List=\u5DF2\u8FC7\u65F6\u7684\u5217\u8868
-doclet.Note_0_is_deprecated=\u6CE8: {0}\u5DF2\u8FC7\u65F6\u3002
 doclet.Overrides=\u8986\u76D6:
 doclet.in_class=\u5728\u7C7B\u4E2D
-doclet.0_Fields_and_Methods="{0}" \u5B57\u6BB5\u548C\u65B9\u6CD5
-doclet.Index_of_Fields_and_Methods=\u5B57\u6BB5\u548C\u65B9\u6CD5\u7684\u7D22\u5F15
 doclet.Static_variable_in={0}\u4E2D\u7684\u9759\u6001\u53D8\u91CF
 doclet.Variable_in={0}\u4E2D\u7684\u53D8\u91CF
 doclet.Constructor_for={0}\u7684\u6784\u9020\u5668
 doclet.Static_method_in={0}\u4E2D\u7684\u9759\u6001\u65B9\u6CD5
 doclet.Method_in={0}\u4E2D\u7684\u65B9\u6CD5
-doclet.throws=\u629B\u51FA
 doclet.package=\u7A0B\u5E8F\u5305
 doclet.MalformedURL=\u683C\u5F0F\u9519\u8BEF\u7684 URL: {0}
 doclet.File_error=\u8BFB\u53D6\u6587\u4EF6\u65F6\u51FA\u9519: {0}
 doclet.URL_error=\u83B7\u53D6 URL \u65F6\u51FA\u9519: {0}
-doclet.No_Package_Comment_File=\u5BF9\u4E8E\u7A0B\u5E8F\u5305{0}, \u627E\u4E0D\u5230 Package.Comment \u6587\u4EF6
-doclet.No_Source_For_Class=\u7C7B{0}\u7684\u6E90\u4FE1\u606F\u4E0D\u53EF\u7528\u3002
 doclet.see.class_or_package_not_found=\u6807\u8BB0{0}: \u627E\u4E0D\u5230\u5F15\u7528: {1}
 doclet.see.class_or_package_not_accessible=\u6807\u8BB0{0}: \u65E0\u6CD5\u8BBF\u95EE\u5F15\u7528: {1}
-doclet.see.malformed_tag=\u6807\u8BB0{0}: \u683C\u5F0F\u9519\u8BEF: {1}
-doclet.Inherited_API_Summary=\u7EE7\u627F\u7684 API \u6982\u8981
 doclet.Deprecated_API=\u5DF2\u8FC7\u65F6\u7684 API
 doclet.Deprecated_Packages=\u5DF2\u8FC7\u65F6\u7A0B\u5E8F\u5305
 doclet.Deprecated_Classes=\u5DF2\u8FC7\u65F6\u7684\u7C7B
@@ -94,10 +87,7 @@ doclet.deprecated_constructors=\u5DF2\u8FC7\u65F6\u7684\u6784\u9020\u5668
 doclet.deprecated_methods=\u5DF2\u8FC7\u65F6\u7684\u65B9\u6CD5
 doclet.deprecated_enum_constants=\u5DF2\u8FC7\u65F6\u7684\u679A\u4E3E\u5E38\u91CF
 doclet.deprecated_annotation_type_members=\u5DF2\u8FC7\u65F6\u7684\u6CE8\u91CA\u7C7B\u578B\u5143\u7D20
-doclet.Frame_Output=\u6846\u67B6\u8F93\u51FA
-doclet.Docs_generated_by_Javadoc=\u7531 Javadoc \u751F\u6210\u7684\u6587\u6863\u3002
 doclet.Generated_Docs_Untitled=\u751F\u6210\u7684\u6587\u6863 (\u65E0\u6807\u9898)
-doclet.Blank=\u7A7A\u767D
 doclet.Other_Packages=\u5176\u4ED6\u7A0B\u5E8F\u5305
 doclet.Package_Description=\u7A0B\u5E8F\u5305{0}\u7684\u8BF4\u660E
 doclet.Description=\u8BF4\u660E
@@ -106,33 +96,25 @@ doclet.in_interface=\u5728\u63A5\u53E3\u4E2D
 doclet.Subclasses=\u76F4\u63A5\u5DF2\u77E5\u5B50\u7C7B:
 doclet.Subinterfaces=\u6240\u6709\u5DF2\u77E5\u5B50\u63A5\u53E3:
 doclet.Implementing_Classes=\u6240\u6709\u5DF2\u77E5\u5B9E\u73B0\u7C7B:
+doclet.Functional_Interface=\u51FD\u6570\u63A5\u53E3:
+doclet.Functional_Interface_Message=\u8FD9\u662F\u4E00\u4E2A\u51FD\u6570\u63A5\u53E3, \u56E0\u6B64\u53EF\u7528\u4F5C lambda \u8868\u8FBE\u5F0F\u6216\u65B9\u6CD5\u5F15\u7528\u7684\u8D4B\u503C\u76EE\u6807\u3002
 doclet.also=\u5E76
-doclet.Option=\u9009\u9879
-doclet.Or=\u6216
 doclet.Frames=\u6846\u67B6
 doclet.No_Frames=\u65E0\u6846\u67B6
 doclet.Package_Hierarchies=\u7A0B\u5E8F\u5305\u5206\u5C42\u7ED3\u6784:
 doclet.Hierarchy_For_Package=\u7A0B\u5E8F\u5305{0}\u7684\u5206\u5C42\u7ED3\u6784
-doclet.Source_Code=\u6E90\u4EE3\u7801:
 doclet.Hierarchy_For_All_Packages=\u6240\u6709\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784
-doclet.Cannot_handle_no_packages=\u65E0\u6CD5\u5904\u7406\u6CA1\u6709\u7A0B\u5E8F\u5305\u7684\u60C5\u51B5\u3002
 doclet.Frame_Alert=\u6846\u67B6\u9884\u8B66
-doclet.Overview-Member-Frame=\u6210\u5458\u6846\u67B6\u6982\u89C8
 doclet.Frame_Warning_Message=\u8BF7\u4F7F\u7528\u6846\u67B6\u529F\u80FD\u67E5\u770B\u6B64\u6587\u6863\u3002\u5982\u679C\u770B\u5230\u6B64\u6D88\u606F, \u5219\u8868\u660E\u60A8\u4F7F\u7528\u7684\u662F\u4E0D\u652F\u6301\u6846\u67B6\u7684 Web \u5BA2\u6237\u673A\u3002\u94FE\u63A5\u5230{0}\u3002
 doclet.No_Script_Message=\u60A8\u7684\u6D4F\u89C8\u5668\u5DF2\u7981\u7528 JavaScript\u3002
 doclet.Non_Frame_Version=\u975E\u6846\u67B6\u7248\u672C
-doclet.Frame_Version=\u6846\u67B6\u7248\u672C
-doclet.Following_From_Class=\u4EE5\u4E0B\u5185\u5BB9\u662F\u4ECE\u7C7B{0}\u590D\u5236\u7684
-doclet.Following_From_Interface=\u4EE5\u4E0B\u5185\u5BB9\u662F\u4ECE\u63A5\u53E3{0}\u590D\u5236\u7684
 doclet.Description_From_Interface=\u4ECE\u63A5\u53E3\u590D\u5236\u7684\u8BF4\u660E:
 doclet.Description_From_Class=\u4ECE\u7C7B\u590D\u5236\u7684\u8BF4\u660E:
-doclet.Standard_doclet_invoked=\u5DF2\u8C03\u7528\u7684\u6807\u51C6 doclet...
 doclet.No_Non_Deprecated_Classes_To_Document=\u627E\u4E0D\u5230\u53EF\u4EE5\u6587\u6863\u5316\u7684\u672A\u8FC7\u65F6\u7684\u7C7B\u3002
 doclet.Interfaces_Italic=\u63A5\u53E3 (\u659C\u4F53)
 doclet.Enclosing_Class=\u5C01\u95ED\u7C7B:
 doclet.Enclosing_Interface=\u5C01\u95ED\u63A5\u53E3:
 doclet.Window_Source_title=\u6E90\u4EE3\u7801
-doclet.Help_title=API \u5E2E\u52A9
 doclet.Window_Help_title=API \u5E2E\u52A9
 doclet.Help_line_1=\u6B64 API \u6587\u6863\u7684\u7EC4\u7EC7\u65B9\u5F0F
 doclet.Help_line_2=\u6B64 API (\u5E94\u7528\u7A0B\u5E8F\u7F16\u7A0B\u63A5\u53E3) \u6587\u6863\u5305\u542B\u5BF9\u5E94\u4E8E\u5BFC\u822A\u680F\u4E2D\u7684\u9879\u76EE\u7684\u9875\u9762, \u5982\u4E0B\u6240\u8FF0\u3002
@@ -150,7 +132,7 @@ doclet.Help_line_13=\u6BCF\u4E2A\u6982\u8981\u6761\u76EE\u90FD\u5305\u542B\u8BE5
 doclet.Help_line_14=\u4F7F\u7528
 doclet.Help_line_15=\u6BCF\u4E2A\u5DF2\u6587\u6863\u5316\u7684\u7A0B\u5E8F\u5305, \u7C7B\u548C\u63A5\u53E3\u90FD\u6709\u5404\u81EA\u7684\u201C\u4F7F\u7528\u201D\u9875\u9762\u3002\u6B64\u9875\u9762\u4ECB\u7ECD\u4E86\u4F7F\u7528\u7ED9\u5B9A\u7C7B\u6216\u7A0B\u5E8F\u5305\u7684\u4EFB\u4F55\u90E8\u5206\u7684\u7A0B\u5E8F\u5305, \u7C7B, \u65B9\u6CD5, \u6784\u9020\u5668\u548C\u5B57\u6BB5\u3002\u5BF9\u4E8E\u7ED9\u5B9A\u7684\u7C7B\u6216\u63A5\u53E3 A, \u5176\u201C\u4F7F\u7528\u201D\u9875\u9762\u53 [...]
 doclet.Help_line_16=\u6811 (\u7C7B\u5206\u5C42\u7ED3\u6784)
-doclet.Help_line_17_with_tree_link=\u5BF9\u4E8E\u6240\u6709\u7A0B\u5E8F\u5305, \u6709\u4E00\u4E2A {0} \u9875\u9762, \u4EE5\u53CA\u6BCF\u4E2A\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784\u3002\u6BCF\u4E2A\u5206\u5C42\u7ED3\u6784\u9875\u9762\u90FD\u5305\u542B\u7C7B\u7684\u5217\u8868\u548C\u63A5\u53E3\u7684\u5217\u8868\u3002\u4ECE <code>java.lang.Object</code> \u5F00\u59CB, \u6309\u7EE7\u627F\u7ED3\u6784\u5BF9\u7C7B\u8FDB\u884C\u6392\u5217\u3002\u63A5\u53E3\u4E0D\u4ECE <code>java.lang.Ob [...]
+doclet.Help_line_17_with_tree_link=\u5BF9\u4E8E\u6240\u6709\u7A0B\u5E8F\u5305, \u6709\u4E00\u4E2A{0}\u9875\u9762, \u4EE5\u53CA\u6BCF\u4E2A\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784\u3002\u6BCF\u4E2A\u5206\u5C42\u7ED3\u6784\u9875\u9762\u90FD\u5305\u542B\u7C7B\u7684\u5217\u8868\u548C\u63A5\u53E3\u7684\u5217\u8868\u3002\u4ECE{1}\u5F00\u59CB, \u6309\u7EE7\u627F\u7ED3\u6784\u5BF9\u7C7B\u8FDB\u884C\u6392\u5217\u3002\u63A5\u53E3\u4E0D\u4ECE{1}\u7EE7\u627F\u3002
 doclet.Help_line_18=\u67E5\u770B\u201C\u6982\u89C8\u201D\u9875\u9762\u65F6, \u5355\u51FB "\u6811" \u5C06\u663E\u793A\u6240\u6709\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784\u3002
 doclet.Help_line_19=\u67E5\u770B\u7279\u5B9A\u7A0B\u5E8F\u5305, \u7C7B\u6216\u63A5\u53E3\u9875\u9762\u65F6, \u5355\u51FB "\u6811" \u5C06\u4EC5\u663E\u793A\u8BE5\u7A0B\u5E8F\u5305\u7684\u5206\u5C42\u7ED3\u6784\u3002
 doclet.Help_line_20_with_deprecated_api_link={0} \u9875\u9762\u5217\u51FA\u4E86\u6240\u6709\u5DF2\u8FC7\u65F6\u7684 API\u3002\u4E00\u822C\u7531\u4E8E\u8FDB\u884C\u4E86\u6539\u8FDB\u5E76\u4E14\u901A\u5E38\u63D0\u4F9B\u4E86\u66FF\u4EE3\u7684 API, \u6240\u4EE5\u5EFA\u8BAE\u4E0D\u8981\u4F7F\u7528\u5DF2\u8FC7\u65F6\u7684 API\u3002\u5728\u5C06\u6765\u7684\u5B9E\u73B0\u8FC7\u7A0B\u4E2D, \u53EF\u80FD\u4F1A\u5220\u9664\u5DF2\u8FC7\u65F6\u7684 API\u3002
@@ -170,19 +152,6 @@ doclet.Help_enum_line_3=\u679A\u4E3E\u8BF4\u660E
 doclet.Help_annotation_type_line_1=\u6BCF\u4E2A\u6CE8\u91CA\u7C7B\u578B\u90FD\u6709\u5404\u81EA\u7684\u9875\u9762, \u5176\u4E2D\u5305\u542B\u4EE5\u4E0B\u90E8\u5206:
 doclet.Help_annotation_type_line_2=\u6CE8\u91CA\u7C7B\u578B\u58F0\u660E
 doclet.Help_annotation_type_line_3=\u6CE8\u91CA\u7C7B\u578B\u8BF4\u660E
-doclet.Style_line_1=Javadoc \u6837\u5F0F\u8868
-doclet.Style_line_2=\u5728\u6B64\u5904\u5B9A\u4E49\u989C\u8272, \u5B57\u4F53\u548C\u5176\u4ED6\u6837\u5F0F\u5C5E\u6027\u4EE5\u8986\u76D6\u9ED8\u8BA4\u503C
-doclet.Style_line_3=\u9875\u9762\u80CC\u666F\u989C\u8272
-doclet.Style_Headings=\u6807\u9898
-doclet.Style_line_4=\u8868\u683C\u989C\u8272
-doclet.Style_line_5=\u6DF1\u7D2B\u8272
-doclet.Style_line_6=\u6DE1\u7D2B\u8272
-doclet.Style_line_7=\u767D\u8272
-doclet.Style_line_8=\u5DE6\u4FA7\u7684\u6846\u67B6\u5217\u8868\u4E2D\u4F7F\u7528\u7684\u5B57\u4F53
-doclet.Style_line_9=\u6846\u67B6\u4E2D\u5C0F\u53F7 sans-serif \u5B57\u4F53\u7684\u793A\u4F8B
-doclet.Style_line_10=\u5BFC\u822A\u680F\u5B57\u4F53\u548C\u989C\u8272
-doclet.Style_line_11=\u6DF1\u84DD\u8272
-doclet.Style_line_12=\u8868\u6807\u9898\u6837\u5F0F
 doclet.ClassUse_Packages.that.use.0=\u4F7F\u7528{0}\u7684\u7A0B\u5E8F\u5305
 doclet.ClassUse_Uses.of.0.in.1={1}\u4E2D{0}\u7684\u4F7F\u7528
 doclet.ClassUse_Classes.in.0.used.by.1={1}\u4F7F\u7528\u7684{0}\u4E2D\u7684\u7C7B
@@ -191,9 +160,7 @@ doclet.ClassUse_Annotation=\u6CE8\u91CA\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u768
 doclet.ClassUse_TypeParameter=\u7C7B\u578B\u53C2\u6570\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u7C7B
 doclet.ClassUse_MethodTypeParameter=\u7C7B\u578B\u53C2\u6570\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u65B9\u6CD5
 doclet.ClassUse_FieldTypeParameter=\u7C7B\u578B\u53C2\u6570\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u5B57\u6BB5
-doclet.ClassUse_PropertyTypeParameter=\u7C7B\u578B\u53C2\u6570\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u5C5E\u6027
 doclet.ClassUse_FieldAnnotations=\u6CE8\u91CA\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u5B57\u6BB5
-doclet.ClassUse_PropertyAnnotations=\u6CE8\u91CA\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u5C5E\u6027
 doclet.ClassUse_MethodAnnotations=\u6CE8\u91CA\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u65B9\u6CD5
 doclet.ClassUse_MethodParameterAnnotations=\u6CE8\u91CA\u7C7B\u578B\u4E3A{0}\u7684{1}\u4E2D\u7684\u65B9\u6CD5\u53C2\u6570
 doclet.ClassUse_MethodReturnTypeParameter=\u8FD4\u56DE\u53D8\u91CF\u7C7B\u578B\u4E3A{0}\u7684\u7C7B\u578B\u7684{1}\u4E2D\u7684\u65B9\u6CD5
@@ -212,14 +179,11 @@ doclet.ClassUse_ConstructorArgsTypeParameters=\u7C7B\u578B\u53D8\u91CF\u7C7B\u57
 doclet.ClassUse_ConstructorThrows=\u629B\u51FA{0}\u7684{1}\u4E2D\u7684\u6784\u9020\u5668
 doclet.ClassUse_No.usage.of.0=\u6CA1\u6709{0}\u7684\u7528\u6CD5
 doclet.Window_ClassUse_Header={0} {1}\u7684\u4F7F\u7528
-doclet.ClassUse_Title={0} {1}<br>\u7684\u4F7F\u7528
+doclet.ClassUse_Title={0}\u7684\u4F7F\u7528
 doclet.navClassUse=\u4F7F\u7528
-doclet.link_option_twice=\u5916\u90E8 URL \u94FE\u63A5\u9009\u9879 (link \u6216 linkoffline) \u4F7F\u7528\u4E86\u4E24\u6B21\u3002
 doclet.Error_in_packagelist=\u4F7F\u7528 -group \u9009\u9879\u65F6\u51FA\u9519: {0} {1}
 doclet.Groupname_already_used=\u5728 -group \u9009\u9879\u4E2D, groupname \u5DF2\u4F7F\u7528: {0}
 doclet.Same_package_name_used=\u7A0B\u5E8F\u5305\u540D\u79F0\u5F62\u5F0F\u4F7F\u7528\u4E86\u4E24\u6B21: {0}
-doclet.Serialization.Excluded_Class=\u975E\u77AC\u6001\u5B57\u6BB5{1}\u4F7F\u7528\u4E86\u6392\u9664\u7684\u7C7B{0}\u3002
-doclet.Serialization.Nonexcluded_Class=\u975E\u77AC\u6001\u5B57\u6BB5{1}\u4F7F\u7528\u4E86\u9690\u85CF\u7684, \u672A\u5305\u542B\u7684\u7C7B{0}\u3002
 doclet.exception_encountered=\u5904\u7406{1}\u65F6\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\n{0}
 doclet.usage=\u901A\u8FC7\u6807\u51C6 doclet \u63D0\u4F9B:\n-d <directory>                    \u8F93\u51FA\u6587\u4EF6\u7684\u76EE\u6807\u76EE\u5F55\n-use                              \u521B\u5EFA\u7C7B\u548C\u7A0B\u5E8F\u5305\u7528\u6CD5\u9875\u9762\n-version                          \u5305\u542B @version \u6BB5\n-author                           \u5305\u542B @author \u6BB5\n-docfilessubdirs                  \u9012\u5F52\u590D\u5236\u6587\u6863\u6587\u4EF6\u5B50\u76EE\u5F55\n-splitindex [...]
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
index 39f3af8..40c4a98 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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,18 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
+import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.builders.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
-import java.util.*;
-import java.io.*;
 
 /**
  * An abstract implementation of a Doclet.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API.
+ *  <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
  */
@@ -50,8 +49,8 @@ public abstract class AbstractDoclet {
     /**
      * The only doclet that may use this toolkit is {@value}
      */
-    private static final String TOOLKIT_DOCLET_NAME = new
-        com.sun.tools.doclets.formats.html.HtmlDoclet().getClass().getName();
+    private static final String TOOLKIT_DOCLET_NAME =
+        com.sun.tools.doclets.formats.html.HtmlDoclet.class.getName();
 
     /**
      * Verify that the only doclet that is using this toolkit is
@@ -81,6 +80,9 @@ public abstract class AbstractDoclet {
         }
         try {
             doclet.startGeneration(root);
+        } catch (Configuration.Fault f) {
+            root.printError(f.getMessage());
+            return false;
         } catch (Exception exc) {
             exc.printStackTrace();
             return false;
@@ -105,13 +107,13 @@ public abstract class AbstractDoclet {
 
     /**
      * Start the generation of files. Call generate methods in the individual
-     * writers, which will in turn genrate the documentation files. Call the
+     * writers, which will in turn generate the documentation files. Call the
      * TreeWriter generation first to ensure the Class Hierarchy is built
      * first and then can be used in the later generation.
      *
      * @see com.sun.javadoc.RootDoc
      */
-    private void startGeneration(RootDoc root) throws Exception {
+    private void startGeneration(RootDoc root) throws Configuration.Fault, Exception {
         if (root.classes().length == 0) {
             configuration.message.
                 error("doclet.No_Public_Classes_To_Document");
@@ -123,20 +125,11 @@ public abstract class AbstractDoclet {
         ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated);
 
         generateClassFiles(root, classtree);
-        if (configuration.sourcepath != null && configuration.sourcepath.length() > 0) {
-            StringTokenizer pathTokens = new StringTokenizer(configuration.sourcepath,
-                String.valueOf(File.pathSeparatorChar));
-            boolean first = true;
-            while(pathTokens.hasMoreTokens()){
-                Util.copyDocFiles(configuration,
-                    pathTokens.nextToken() + File.separator,
-                    DocletConstants.DOC_FILES_DIR_NAME, first);
-                first = false;
-            }
-        }
+        Util.copyDocFiles(configuration, DocPaths.DOC_FILES);
 
         PackageListWriter.generate(configuration);
         generatePackageFiles(classtree);
+        generateProfileFiles();
 
         generateOtherFiles(root, classtree);
         configuration.tagletManager.printReport();
@@ -157,6 +150,12 @@ public abstract class AbstractDoclet {
     }
 
     /**
+     * Generate the profile documentation.
+     *
+     */
+    protected abstract void generateProfileFiles() throws Exception;
+
+    /**
      * Generate the package documentation.
      *
      * @param classtree the data structure representing the class tree.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
index 64f4b34..18ada19 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -30,9 +30,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing annotation type optional member output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
index fb83c2a..28a18f9 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,11 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing annotation type required member output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
index 9ef63b5..b65740e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,9 +32,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing annotation type output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API.
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -152,7 +153,7 @@ public interface AnnotationTypeWriter {
      *
      * @param contentTree content tree that will be printed as a document
      */
-    public void printDocument(Content contentTree);
+    public void printDocument(Content contentTree) throws IOException;
 
     /**
      * Close the writer.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
index c5bfb13..c0a991e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,9 +32,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing class output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -116,6 +117,13 @@ public interface ClassWriter {
     public void addInterfaceUsageInfo(Content classInfoTree);
 
     /**
+     * If this is an functional interface, display appropriate message.
+     *
+     * @param classInfoTree content tree to which the documentation will be added
+     */
+    public void addFunctionalInterfaceInfo(Content classInfoTree);
+
+    /**
      * If this is an inner class or interface, add the enclosing class or
      * interface.
      *
@@ -179,7 +187,7 @@ public interface ClassWriter {
      *
      * @param contentTree content tree that will be printed as a document
      */
-    public void printDocument(Content contentTree);
+    public void printDocument(Content contentTree) throws IOException;
 
     /**
      * Close the writer.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
index e140e93..633e941 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
@@ -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,12 +25,18 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
+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;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory;
-import com.sun.javadoc.*;
-import java.util.*;
-import java.io.*;
+import javax.tools.JavaFileManager;
 
 /**
  * Configure the output based on the options. Doclets should sub-class
@@ -38,9 +44,10 @@ import java.io.*;
  * all user options which are supported by the 1.1 doclet and the standard
  * doclet.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Robert Field.
  * @author Atul Dambalkar.
@@ -49,6 +56,21 @@ import java.io.*;
 public abstract class Configuration {
 
     /**
+     * Exception used to report a problem during setOptions.
+     */
+    public static class Fault extends Exception {
+        private static final long serialVersionUID = 0;
+
+        Fault(String msg) {
+            super(msg);
+        }
+
+        Fault(String msg, Exception cause) {
+            super(msg, cause);
+        }
+    }
+
+    /**
      * The factory for builders.
      */
     protected BuilderFactory builderFactory;
@@ -75,14 +97,16 @@ public abstract class Configuration {
 
     /**
      * This is true if option "-serialwarn" is used. Defualt value is false to
-     * supress excessive warnings about serial tag.
+     * suppress excessive warnings about serial tag.
      */
     public boolean serialwarn = false;
 
     /**
      * The specified amount of space between tab stops.
      */
-    public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+    public int sourcetab;
+
+    public String tabSpaces;
 
     /**
      * True if we should generate browsable sources.
@@ -169,6 +193,12 @@ public abstract class Configuration {
     public boolean showauthor = false;
 
     /**
+     * Generate documentation for JavaFX getters and setters automatically
+     * by copying it from the appropriate property definition.
+     */
+    public boolean javafx = false;
+
+    /**
      * Generate version specific information for the all the classes
      * if @version tag is used in the doc comment and if -version option is
      * used. <code>showversion</code> is set to true if -version option is
@@ -183,6 +213,17 @@ public abstract class Configuration {
     public String sourcepath = "";
 
     /**
+     * Argument for command line option "-Xprofilespath".
+     */
+    public String profilespath = "";
+
+    /**
+     * Generate profiles documentation if profilespath is set and valid profiles
+     * are present.
+     */
+    public boolean showProfiles = false;
+
+    /**
      * Don't generate deprecated API information at all, if -nodeprecated
      * option is used. <code>nodepracted</code> is set to true if
      * -nodeprecated option is used. Default is generate deprected API
@@ -221,19 +262,6 @@ public abstract class Configuration {
     public final Extern extern = new Extern(this);
 
     /**
-     * Returns true if the user wants to generate JavaFX documentation.
-     */
-    public static boolean getJavafxJavadoc() {
-        return Boolean.getBoolean("javafx.javadoc");
-    }
-
-    /**
-     * Location of doclet properties file.
-     */
-    public static final String DOCLETS_RESOURCE
-            = "com.sun.tools.doclets.internal.toolkit.resources.doclets";
-
-    /**
      * Return the build date for the doclet.
      */
     public abstract String getDocletSpecificBuildDate();
@@ -246,7 +274,7 @@ public abstract class Configuration {
      * @param options The array of option names and values.
      * @throws DocletAbortException
      */
-    public abstract void setSpecificDocletOptions(String[][] options);
+    public abstract void setSpecificDocletOptions(String[][] options) throws Fault;
 
     /**
      * Return the doclet specific {@link MessageRetriever}
@@ -255,6 +283,16 @@ public abstract class Configuration {
     public abstract MessageRetriever getDocletSpecificMsg();
 
     /**
+     * A profiles object used to access profiles across various pages.
+     */
+    public Profiles profiles;
+
+    /**
+     * An map of the profiles to packages.
+     */
+    public Map<String,PackageDoc[]> profilePackages;
+
+    /**
      * An array of the packages specified on the command-line merged
      * with the array of packages that contain the classes specified on the
      * command-line.  The array is sorted.
@@ -266,9 +304,11 @@ public abstract class Configuration {
      */
     public Configuration() {
         message =
-            new MessageRetriever(this, DOCLETS_RESOURCE);
+            new MessageRetriever(this,
+            "com.sun.tools.doclets.internal.toolkit.resources.doclets");
         excludedDocFileDirs = new HashSet<String>();
         excludedQualifiers = new HashSet<String>();
+        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
     }
 
     /**
@@ -300,6 +340,7 @@ public abstract class Configuration {
         option = option.toLowerCase();
         if (option.equals("-author") ||
             option.equals("-docfilessubdirs") ||
+            option.equals("-javafx") ||
             option.equals("-keywords") ||
             option.equals("-linksource") ||
             option.equals("-nocomment") ||
@@ -321,7 +362,8 @@ public abstract class Configuration {
                    option.equals("-sourcepath") ||
                    option.equals("-tag") ||
                    option.equals("-taglet") ||
-                   option.equals("-tagletpath")) {
+                   option.equals("-tagletpath") ||
+                   option.equals("-xprofilespath")) {
             return 2;
         } else if (option.equals("-group") ||
                    option.equals("-linkoffline")) {
@@ -340,6 +382,38 @@ public abstract class Configuration {
     public abstract boolean validOptions(String options[][],
         DocErrorReporter reporter);
 
+    private void initProfiles() throws IOException {
+        profiles = Profiles.read(new File(profilespath));
+        // Generate profiles documentation only is profilespath is set and if
+        // profiles is not null and profiles count is 1 or more.
+        showProfiles = (!profilespath.isEmpty() && profiles != null &&
+                profiles.getProfileCount() > 0);
+    }
+
+    private void initProfilePackages() throws IOException {
+        profilePackages = new HashMap<String,PackageDoc[]>();
+        ArrayList<PackageDoc> results;
+        Map<String,PackageDoc> packageIndex = new HashMap<String,PackageDoc>();
+        for (int i = 0; i < packages.length; i++) {
+            PackageDoc pkg = packages[i];
+            packageIndex.put(pkg.name(), pkg);
+        }
+        for (int i = 1; i < profiles.getProfileCount(); i++) {
+            Set<String> profPkgs = profiles.getPackages(i);
+            results = new ArrayList<PackageDoc>();
+            for (String packageName : profPkgs) {
+                packageName = packageName.replace("/", ".");
+                PackageDoc profPkg = packageIndex.get(packageName);
+                if (profPkg != null) {
+                    results.add(profPkg);
+                }
+            }
+            Collections.sort(results);
+            PackageDoc[] profilePkgs = results.toArray(new PackageDoc[]{});
+            profilePackages.put(Profile.lookup(i).name, profilePkgs);
+        }
+    }
+
     private void initPackageArray() {
         Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages()));
         ClassDoc[] classes = root.specifiedClasses();
@@ -356,15 +430,26 @@ public abstract class Configuration {
      *
      * @param options the two dimensional array of options.
      */
-    public void setOptions(String[][] options) {
+    public void setOptions(String[][] options) throws Fault {
         LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>();
+
+        // Some options, specifically -link and -linkoffline, require that
+        // the output directory has already been created: so do that first.
         for (int oi = 0; oi < options.length; ++oi) {
             String[] os = options[oi];
             String opt = os[0].toLowerCase();
             if (opt.equals("-d")) {
                 destDirName = addTrailingFileSep(os[1]);
                 docFileDestDirName = destDirName;
-            } else if (opt.equals("-docfilessubdirs")) {
+                ensureOutputDirExists();
+                break;
+            }
+        }
+
+        for (int oi = 0; oi < options.length; ++oi) {
+            String[] os = options[oi];
+            String opt = os[0].toLowerCase();
+            if (opt.equals("-docfilessubdirs")) {
                 copydocfilesubdirs = true;
             } else if (opt.equals("-docencoding")) {
                 docencoding = os[1];
@@ -372,6 +457,8 @@ public abstract class Configuration {
                 encoding = os[1];
             } else if (opt.equals("-author")) {
                 showauthor = true;
+            } else  if (opt.equals("-javafx")) {
+                javafx = true;
             } else if (opt.equals("-nosince")) {
                 nosince = true;
             } else if (opt.equals("-version")) {
@@ -380,7 +467,7 @@ public abstract class Configuration {
                 nodeprecated = true;
             } else if (opt.equals("-sourcepath")) {
                 sourcepath = os[1];
-            } else if (opt.equals("-classpath") &&
+            } else if ((opt.equals("-classpath") || opt.equals("-cp")) &&
                        sourcepath.length() == 0) {
                 sourcepath = os[1];
             } else if (opt.equals("-excludedocfilessubdir")) {
@@ -392,7 +479,7 @@ public abstract class Configuration {
             } else if (opt.equals("-sourcetab")) {
                 linksource = true;
                 try {
-                    sourcetab = Integer.parseInt(os[1]);
+                    setTabWidth(Integer.parseInt(os[1]));
                 } catch (NumberFormatException e) {
                     //Set to -1 so that warning will be printed
                     //to indicate what is valid argument.
@@ -400,7 +487,7 @@ public abstract class Configuration {
                 }
                 if (sourcetab <= 0) {
                     message.warning("doclet.sourcetab_warning");
-                    sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
+                    setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
                 }
             } else if (opt.equals("-notimestamp")) {
                 notimestamp = true;
@@ -410,6 +497,8 @@ public abstract class Configuration {
                 customTagStrs.add(os);
             } else if (opt.equals("-tagletpath")) {
                 tagletpath = os[1];
+            }  else if (opt.equals("-xprofilespath")) {
+                profilespath = os[1];
             } else if (opt.equals("-keywords")) {
                 keywords = true;
             } else if (opt.equals("-serialwarn")) {
@@ -418,11 +507,11 @@ public abstract class Configuration {
                 group.checkPackageGroups(os[1], os[2]);
             } else if (opt.equals("-link")) {
                 String url = os[1];
-                extern.url(url, url, root, false);
+                extern.link(url, url, root, false);
             } else if (opt.equals("-linkoffline")) {
                 String url = os[1];
                 String pkglisturl = os[2];
-                extern.url(url, pkglisturl, root, true);
+                extern.link(url, pkglisturl, root, true);
             }
         }
         if (sourcepath.length() == 0) {
@@ -442,32 +531,57 @@ public abstract class Configuration {
      *
      * @throws DocletAbortException
      */
-    public void setOptions() {
+    public void setOptions() throws Fault {
         initPackageArray();
         setOptions(root.options());
+        if (!profilespath.isEmpty()) {
+            try {
+                initProfiles();
+                initProfilePackages();
+            } catch (Exception e) {
+                throw new DocletAbortException();
+            }
+        }
         setSpecificDocletOptions(root.options());
     }
 
+    private void ensureOutputDirExists() throws Fault {
+        DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
+        if (!destDir.exists()) {
+            //Create the output directory (in case it doesn't exist yet)
+            root.printNotice(getText("doclet.dest_dir_create", destDirName));
+            destDir.mkdirs();
+        } else if (!destDir.isDirectory()) {
+            throw new Fault(getText(
+                "doclet.destination_directory_not_directory_0",
+                destDir.getPath()));
+        } else if (!destDir.canWrite()) {
+            throw new Fault(getText(
+                "doclet.destination_directory_not_writable_0",
+                destDir.getPath()));
+        }
+    }
+
 
     /**
      * Initialize the taglet manager.  The strings to initialize the simple custom tags should
      * be in the following format:  "[tag name]:[location str]:[heading]".
-     * @param customTagStrs the set two dimentional arrays of strings.  These arrays contain
+     * @param customTagStrs the set two dimensional arrays of strings.  These arrays contain
      * either -tag or -taglet arguments.
      */
     private void initTagletManager(Set<String[]> customTagStrs) {
         tagletManager = tagletManager == null ?
-            new TagletManager(nosince, showversion, showauthor, message) :
+            new TagletManager(nosince, showversion, showauthor, javafx, message) :
             tagletManager;
         String[] args;
         for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) {
             args = it.next();
             if (args[0].equals("-taglet")) {
-                tagletManager.addCustomTag(args[1], tagletpath);
+                tagletManager.addCustomTag(args[1], getFileManager(), tagletpath);
                 continue;
             }
-            String[] tokens = Util.tokenize(args[1],
-                TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3);
+            String[] tokens = tokenize(args[1],
+                TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
             if (tokens.length == 1) {
                 String tagName = args[1];
                 if (tagletManager.isKnownCustomTag(tagName)) {
@@ -475,7 +589,7 @@ public abstract class Configuration {
                     tagletManager.addNewSimpleCustomTag(tagName, null, "");
                 } else {
                     //Create a simple tag with the heading that has the same name as the tag.
-                    StringBuffer heading = new StringBuffer(tagName + ":");
+                    StringBuilder heading = new StringBuilder(tagName + ":");
                     heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0)));
                     tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a");
                 }
@@ -490,6 +604,47 @@ public abstract class Configuration {
         }
     }
 
+    /**
+     * Given a string, return an array of tokens.  The separator can be escaped
+     * with the '\' character.  The '\' character may also be escaped by the
+     * '\' character.
+     *
+     * @param s         the string to tokenize.
+     * @param separator the separator char.
+     * @param maxTokens the maximum number of tokens returned.  If the
+     *                  max is reached, the remaining part of s is appended
+     *                  to the end of the last token.
+     *
+     * @return an array of tokens.
+     */
+    private String[] tokenize(String s, char separator, int maxTokens) {
+        List<String> tokens = new ArrayList<String>();
+        StringBuilder  token = new StringBuilder ();
+        boolean prevIsEscapeChar = false;
+        for (int i = 0; i < s.length(); i += Character.charCount(i)) {
+            int currentChar = s.codePointAt(i);
+            if (prevIsEscapeChar) {
+                // Case 1:  escaped character
+                token.appendCodePoint(currentChar);
+                prevIsEscapeChar = false;
+            } else if (currentChar == separator && tokens.size() < maxTokens-1) {
+                // Case 2:  separator
+                tokens.add(token.toString());
+                token = new StringBuilder();
+            } else if (currentChar == '\\') {
+                // Case 3:  escape character
+                prevIsEscapeChar = true;
+            } else {
+                // Case 4:  regular character
+                token.appendCodePoint(currentChar);
+            }
+        }
+        if (token.length() > 0) {
+            tokens.add(token.toString());
+        }
+        return tokens.toArray(new String[] {});
+    }
+
     private void addToSet(Set<String> s, String str){
         StringTokenizer st = new StringTokenizer(str, ":");
         String current;
@@ -500,17 +655,18 @@ public abstract class Configuration {
     }
 
     /**
-     * Add a traliling file separator, if not found or strip off extra trailing
-     * file separators if any.
+     * Add a trailing file separator, if not found. Remove superfluous
+     * file separators if any. Preserve the front double file separator for
+     * UNC paths.
      *
      * @param path Path under consideration.
      * @return String Properly constructed path string.
      */
-    String addTrailingFileSep(String path) {
+    public static String addTrailingFileSep(String path) {
         String fs = System.getProperty("file.separator");
         String dblfs = fs + fs;
         int indexDblfs;
-        while ((indexDblfs = path.indexOf(dblfs)) >= 0) {
+        while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
             path = path.substring(0, indexDblfs) +
                 path.substring(indexDblfs + fs.length());
         }
@@ -539,26 +695,7 @@ public abstract class Configuration {
         for (int oi = 0; oi < options.length; oi++) {
             String[] os = options[oi];
             String opt = os[0].toLowerCase();
-            if (opt.equals("-d")) {
-                String destdirname = addTrailingFileSep(os[1]);
-                File destDir = new File(destdirname);
-                if (!destDir.exists()) {
-                    //Create the output directory (in case it doesn't exist yet)
-                    reporter.printNotice(getText("doclet.dest_dir_create",
-                        destdirname));
-                    (new File(destdirname)).mkdirs();
-                } else if (!destDir.isDirectory()) {
-                    reporter.printError(getText(
-                        "doclet.destination_directory_not_directory_0",
-                        destDir.getPath()));
-                    return false;
-                } else if (!destDir.canWrite()) {
-                    reporter.printError(getText(
-                        "doclet.destination_directory_not_writable_0",
-                        destDir.getPath()));
-                    return false;
-                }
-            } else if (opt.equals("-docencoding")) {
+            if (opt.equals("-docencoding")) {
                 docencodingfound = true;
                 if (!checkOutputFileEncoding(os[1], reporter)) {
                     return false;
@@ -690,6 +827,82 @@ public abstract class Configuration {
         }
     }
 
+    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
@@ -717,10 +930,10 @@ public abstract class Configuration {
      * @return the input steam to the builder XML.
      * @throws FileNotFoundException when the given XML file cannot be found.
      */
-    public InputStream getBuilderXML() throws FileNotFoundException {
+    public InputStream getBuilderXML() throws IOException {
         return builderXMLPath == null ?
             Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
-            new FileInputStream(new File(builderXMLPath));
+            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
     }
 
     /**
@@ -729,10 +942,22 @@ public abstract class Configuration {
     public abstract Locale getLocale();
 
     /**
+     * Return the current file manager.
+     */
+    public abstract JavaFileManager getFileManager();
+
+    /**
      * Return the comparator that will be used to sort member documentation.
      * To no do any sorting, return null.
      *
      * @return the {@link java.util.Comparator} used to sort members.
      */
     public abstract Comparator<ProgramElementDoc> getMemberComparator();
+
+    private void setTabWidth(int n) {
+        sourcetab = n;
+        tabSpaces = String.format("%" + n + "s", "");
+    }
+
+    public abstract boolean showMessage(SourcePosition pos, String key);
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
index a2eab1b..1318a13 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,16 +25,18 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
-import java.util.*;
 import java.io.*;
+import java.util.*;
+
 import com.sun.javadoc.*;
 
 /**
  * The interface for writing constants summary output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -137,6 +139,6 @@ public interface ConstantsSummaryWriter {
      *
      * @param contentTree content tree which should be printed
      */
-    public abstract void printDocument(Content contentTree);
+    public abstract void printDocument(Content contentTree) throws IOException;
 
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
index 8ad4824..f784b4a 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing constructor output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
index a7bdf96..fff0195 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -25,11 +25,20 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * A class to create content for javadoc output pages.
  *
+ *  <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 Bhavesh Patel
  */
 public abstract class Content {
@@ -39,10 +48,16 @@ public abstract class Content {
      *
      * @return string representation of the content
      */
+    @Override
     public String toString() {
-        StringBuilder contentBuilder = new StringBuilder();
-        write(contentBuilder);
-        return contentBuilder.toString();
+        StringWriter out = new StringWriter();
+        try {
+            write(out, true);
+        } catch (IOException e) {
+            // cannot happen from StringWriter
+            throw new DocletAbortException();
+        }
+        return out.toString();
     }
 
     /**
@@ -60,10 +75,10 @@ public abstract class Content {
     public abstract void addContent(String stringContent);
 
     /**
-     * Writes content to a StringBuilder.
+     * Writes content to a writer.
      *
      */
-    public abstract void write(StringBuilder contentBuilder);
+    public abstract boolean write(Writer writer, boolean atNewline) throws IOException ;
 
     /**
      * Returns true if the content is empty.
@@ -82,6 +97,15 @@ public abstract class Content {
     }
 
     /**
+     * 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
@@ -91,32 +115,4 @@ public abstract class Content {
         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;
-    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
index 8b14267..987c52f 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing enum constant output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -56,7 +57,7 @@ public interface EnumConstantWriter {
      * Get the enum constants documentation tree header.
      *
      * @param enumConstant the enum constant being documented
-     * @param enumConstantDetailsTree the content tree representing enum constant details
+     * @param enumConstantsDetailsTree the content tree representing enum constant details
      * @return content tree for the enum constant documentation header
      */
     public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
index c17ac26..554f199 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing field output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
index 76baf59..79ec354 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,9 +32,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing member summary output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -57,9 +58,11 @@ public interface MemberSummaryWriter {
      * Get the summary table for the given class.
      *
      * @param classDoc the class the summary table belongs to
+     * @param tableContents list of contents that will be added to the summary table
      * @return a content tree for the member summary table
      */
-    public Content getSummaryTableTree(ClassDoc classDoc);
+    public Content getSummaryTableTree(ClassDoc classDoc,
+            List<Content> tableContents);
 
     /**
      * Add the member summary for the given class and member.
@@ -67,11 +70,11 @@ public interface MemberSummaryWriter {
      * @param classDoc the class the summary belongs to
      * @param member the member that is documented
      * @param firstSentenceTags the tags for the sentence being documented
-     * @param tableTree the content treeto which the information will be added
-     * @param counter the counter for determing style for the table row
+     * @param tableContents list of contents to which the summary will be added
+     * @param counter the counter for determining id and style for the table row
      */
     public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
-        Tag[] firstSentenceTags, Content tableTree, int counter);
+            Tag[] firstSentenceTags, List<Content> tableContents, int counter);
 
     /**
      * Get the inherited member summary header for the given class.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
index 1864bf9..ce4b90e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing method output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
index a5a023a..4aea909 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -30,9 +30,10 @@ import java.io.*;
 /**
  * The interface for writing class output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
index eb8bf7b..e6ce1ff 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,15 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
-import com.sun.javadoc.*;
 import java.io.*;
 
+import com.sun.javadoc.*;
+
 /**
  * The interface for writing package summary output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -43,13 +45,6 @@ import java.io.*;
 public interface PackageSummaryWriter {
 
     /**
-     * Return the name of the output file.
-     *
-     * @return the name of the output file.
-     */
-    public abstract String getOutputFileName();
-
-    /**
      * Get the header for the summary.
      *
      * @param heading Package name.
@@ -113,7 +108,7 @@ public interface PackageSummaryWriter {
      *
      * @param contentTree the content tree that will be printed
      */
-    public abstract void printDocument(Content contentTree);
+    public abstract void printDocument(Content contentTree) throws IOException;
 
     /**
      * Close the writer.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfilePackageSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfilePackageSummaryWriter.java
new file mode 100644
index 0000000..55c9762
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfilePackageSummaryWriter.java
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+
+/**
+ * The interface for writing profile package summary 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 Bhavesh Patel
+ */
+
+public interface ProfilePackageSummaryWriter {
+
+    /**
+     * Get the header for the summary.
+     *
+     * @param heading Package name.
+     * @return the header to be added to the content tree
+     */
+    public abstract Content getPackageHeader(String heading);
+
+    /**
+     * Get the header for the content.
+     *
+     * @return a content tree for the content header
+     */
+    public abstract Content getContentHeader();
+
+    /**
+     * Get the header for the package summary.
+     *
+     * @return a content tree with the package summary header
+     */
+    public abstract Content getSummaryHeader();
+
+    /**
+     * Adds the table of classes to the documentation tree.
+     *
+     * @param classes the array of classes to document.
+     * @param label the label for this table.
+     * @param tableSummary the summary string for the table
+     * @param tableHeader array of table headers
+     * @param summaryContentTree the content tree to which the summaries will be added
+     */
+    public abstract void addClassesSummary(ClassDoc[] classes, String label,
+            String tableSummary, String[] tableHeader, Content summaryContentTree);
+
+    /**
+     * Adds the package description from the "packages.html" file to the documentation
+     * tree.
+     *
+     * @param packageContentTree the content tree to which the package description
+     *                           will be added
+     */
+    public abstract void addPackageDescription(Content packageContentTree);
+
+    /**
+     * Adds the tag information from the "packages.html" file to the documentation
+     * tree.
+     *
+     * @param packageContentTree the content tree to which the package tags will
+     *                           be added
+     */
+    public abstract void addPackageTags(Content packageContentTree);
+
+    /**
+     * Adds the footer to the documentation tree.
+     *
+     * @param contentTree the tree to which the footer will be added
+     */
+    public abstract void addPackageFooter(Content contentTree);
+
+    /**
+     * Print the package summary document.
+     *
+     * @param contentTree the content tree that will be printed
+     */
+    public abstract void printDocument(Content contentTree) throws IOException;
+
+    /**
+     * Close the writer.
+     */
+    public abstract void close() throws IOException;
+
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfileSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfileSummaryWriter.java
new file mode 100644
index 0000000..d3a8682
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ProfileSummaryWriter.java
@@ -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.  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;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+
+/**
+ * The interface for writing profile summary 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 Bhavesh Patel
+ */
+
+public interface ProfileSummaryWriter {
+
+    /**
+     * Get the header for the summary.
+     *
+     * @param heading profile name.
+     * @return the header to be added to the content tree
+     */
+    public abstract Content getProfileHeader(String heading);
+
+    /**
+     * Get the header for the profile content.
+     *
+     * @return a content tree for the profile content header
+     */
+    public abstract Content getContentHeader();
+
+    /**
+     * Get the header for the summary header.
+     *
+     * @return a content tree with the summary header
+     */
+    public abstract Content getSummaryHeader();
+
+    /**
+     * Get the header for the summary tree.
+     *
+     * @param summaryContentTree the content tree.
+     * @return a content tree with the summary tree
+     */
+    public abstract Content getSummaryTree(Content summaryContentTree);
+
+    /**
+     * Get the header for the package summary header.
+     *
+     * @return a content tree with the package summary header
+     */
+    public abstract Content getPackageSummaryHeader(PackageDoc pkg);
+
+    /**
+     * Get the header for the package summary tree.
+     *
+     * @return a content tree with the package summary
+     */
+    public abstract Content getPackageSummaryTree(Content packageSummaryContentTree);
+
+    /**
+     * Adds the table of classes to the documentation tree.
+     *
+     * @param classes the array of classes to document.
+     * @param label the label for this table.
+     * @param tableSummary the summary string for the table
+     * @param tableHeader array of table headers
+     * @param packageSummaryContentTree the content tree to which the summaries will be added
+     */
+    public abstract void addClassesSummary(ClassDoc[] classes, String label,
+            String tableSummary, String[] tableHeader, Content packageSummaryContentTree);
+
+    /**
+     * Adds the footer to the documentation tree.
+     *
+     * @param contentTree the tree to which the footer will be added
+     */
+    public abstract void addProfileFooter(Content contentTree);
+
+    /**
+     * Print the profile summary document.
+     *
+     * @param contentTree the content tree that will be printed
+     */
+    public abstract void printDocument(Content contentTree) throws IOException;
+
+    /**
+     * Close the writer.
+     */
+    public abstract void close() throws IOException;
+
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java
index c7c8d1f..971af7c 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PropertyWriter.java
@@ -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,87 +29,88 @@ import java.io.*;
 import com.sun.javadoc.*;
 
 /**
- * The interface for writing field output.
+ * The interface for writing property output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
- * @since 1.5
+ * @since 1.7
  */
 
 public interface PropertyWriter {
 
     /**
-     * Get the field details tree header.
+     * Get the property details tree header.
      *
      * @param classDoc the class being documented
      * @param memberDetailsTree the content tree representing member details
-     * @return content tree for the field details header
+     * @return content tree for the property details header
      */
-    public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
+    public Content getPropertyDetailsTreeHeader(ClassDoc classDoc,
             Content memberDetailsTree);
 
     /**
-     * Get the field documentation tree header.
+     * Get the property documentation tree header.
      *
-     * @param field the constructor being documented
-     * @param fieldDetailsTree the content tree representing field details
-     * @return content tree for the field documentation header
+     * @param property the property being documented
+     * @param propertyDetailsTree the content tree representing property details
+     * @return content tree for the property documentation header
      */
-    public Content getFieldDocTreeHeader(MethodDoc field,
-            Content fieldDetailsTree);
+    public Content getPropertyDocTreeHeader(MethodDoc property,
+            Content propertyDetailsTree);
 
     /**
-     * Get the signature for the given field.
+     * Get the signature for the given property.
      *
-     * @param field the field being documented
-     * @return content tree for the field signature
+     * @param property the property being documented
+     * @return content tree for the property signature
      */
-    public Content getSignature(MethodDoc field);
+    public Content getSignature(MethodDoc property);
 
     /**
-     * Add the deprecated output for the given field.
+     * Add the deprecated output for the given property.
      *
-     * @param field the field being documented
-     * @param fieldDocTree content tree to which the deprecated information will be added
+     * @param property the property being documented
+     * @param propertyDocTree content tree to which the deprecated information will be added
      */
-    public void addDeprecated(MethodDoc field, Content fieldDocTree);
+    public void addDeprecated(MethodDoc property, Content propertyDocTree);
 
     /**
-     * Add the comments for the given field.
+     * Add the comments for the given property.
      *
-     * @param field the field being documented
-     * @param fieldDocTree the content tree to which the comments will be added
+     * @param property the property being documented
+     * @param propertyDocTree the content tree to which the comments will be added
      */
-    public void addComments(MethodDoc field, Content fieldDocTree);
+    public void addComments(MethodDoc property, Content propertyDocTree);
 
     /**
-     * Add the tags for the given field.
+     * Add the tags for the given property.
      *
-     * @param field the field being documented
-     * @param fieldDocTree the content tree to which the tags will be added
+     * @param property the property being documented
+     * @param propertyDocTree the content tree to which the tags will be added
      */
-    public void addTags(MethodDoc field, Content fieldDocTree);
+    public void addTags(MethodDoc property, Content propertyDocTree);
 
     /**
-     * Get the field details tree.
+     * Get the property details tree.
      *
      * @param memberDetailsTree the content tree representing member details
-     * @return content tree for the field details
+     * @return content tree for the property details
      */
-    public Content getFieldDetails(Content memberDetailsTree);
+    public Content getPropertyDetails(Content memberDetailsTree);
 
     /**
-     * Get the field documentation.
+     * Get the property documentation.
      *
-     * @param fieldDocTree the content tree representing field documentation
+     * @param propertyDocTree the content tree representing property documentation
      * @param isLastContent true if the content to be added is the last content
-     * @return content tree for the field documentation
+     * @return content tree for the property documentation
      */
-    public Content getFieldDoc(Content fieldDocTree, boolean isLastContent);
+    public Content getPropertyDoc(Content propertyDocTree, boolean isLastContent);
 
     /**
      * Close the writer.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
index 84454ac..89add8a 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -32,9 +32,10 @@ import com.sun.javadoc.*;
 /**
  * The interface for writing serialized form output.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
@@ -150,7 +151,7 @@ public interface SerializedFormWriter {
      *
      * @param serializedTree the content tree that will be printed
      */
-    public abstract void printDocument(Content serializedTree);
+    public abstract void printDocument(Content serializedTree) throws IOException;
 
     /**
      * Write the serialized form for a given field.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java
index 0af9241..1fa4c2f 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/WriterFactory.java
@@ -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,15 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * The interface for a factory creates writers.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -64,6 +66,33 @@ public interface WriterFactory {
     throws Exception;
 
     /**
+     * Return the writer for the profile summary.
+     *
+     * @param profile the profile being documented.
+     * @param prevProfile the previous profile that was documented.
+     * @param nextProfile the next profile being documented.
+     * @return the writer for the profile summary.  Return null if this
+     * writer is not supported by the doclet.
+     */
+    public abstract ProfileSummaryWriter getProfileSummaryWriter(Profile
+        profile, Profile prevProfile, Profile nextProfile)
+    throws Exception;
+
+    /**
+     * Return the writer for the profile package summary.
+     *
+     * @param packageDoc the profile package being documented.
+     * @param prevPkg the previous profile package that was documented.
+     * @param nextPkg the next profile package being documented.
+     * @param profile the profile being documented.
+     * @return the writer for the profile package summary.  Return null if this
+     * writer is not supported by the doclet.
+     */
+    public abstract ProfilePackageSummaryWriter getProfilePackageSummaryWriter(
+            PackageDoc packageDoc, PackageDoc prevPkg, PackageDoc nextPkg,
+            Profile profile) throws Exception;
+
+    /**
      * Return the writer for a class.
      *
      * @param classDoc the class being documented.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
index c016775..56676ec 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,12 +25,13 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
 
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
 /**
  * The superclass for all builders.  A builder is a class that provides
  * the structure and content of API documentation.  A builder is completely
@@ -41,27 +42,56 @@ import java.util.*;
  * do is implement the ConstantsSummaryWriter interface and pass it to the
  * builder using a WriterFactory.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 abstract class AbstractBuilder {
+    public static class Context {
+        /**
+         * The configuration used in this run of the doclet.
+         */
+        final Configuration configuration;
+
+        /**
+         * Keep track of which packages we have seen for
+         * efficiency purposes.  We don't want to copy the
+         * doc files multiple times for a single package.
+         */
+        final Set<String> containingPackagesSeen;
+
+        /**
+         * Shared parser for the builder XML file
+         */
+        final LayoutParser layoutParser;
+
+        Context(Configuration configuration,
+                Set<String> containingPackagesSeen,
+                LayoutParser layoutParser) {
+            this.configuration = configuration;
+            this.containingPackagesSeen = containingPackagesSeen;
+            this.layoutParser = layoutParser;
+        }
+    }
 
     /**
      * The configuration used in this run of the doclet.
      */
-    protected Configuration configuration;
+    protected final Configuration configuration;
 
     /**
      * Keep track of which packages we have seen for
      * efficiency purposes.  We don't want to copy the
      * doc files multiple times for a single package.
      */
-    protected static Set<String> containingPackagesSeen;
+    protected final Set<String> containingPackagesSeen;
+
+    protected final LayoutParser layoutParser;
 
     /**
      * True if we want to print debug output.
@@ -73,8 +103,10 @@ public abstract class AbstractBuilder {
      * @param configuration the configuration used in this run
      *        of the doclet.
      */
-    public AbstractBuilder(Configuration configuration) {
-        this.configuration = configuration;
+    public AbstractBuilder(Context c) {
+        this.configuration = c.configuration;
+        this.containingPackagesSeen = c.containingPackagesSeen;
+        this.layoutParser = c.layoutParser;
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
index 6a4be60..5313f4f 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,18 +25,20 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
+import java.util.Set;
+
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.util.*;
 
 /**
  * The superclass for all member builders.  Member builders are only executed
  * within Class Builders.  They essentially build sub-components.  For example,
  * method documentation is a sub-component of class documentation.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
@@ -48,8 +50,8 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder {
      * @param configuration the configuration used in this run
      *        of the doclet.
      */
-    public AbstractMemberBuilder(Configuration configuration) {
-        super(configuration);
+    public AbstractMemberBuilder(Context context) {
+        super(context);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
index a92ea56..4de5402 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
@@ -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
@@ -27,16 +27,18 @@ package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.io.*;
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds the summary for a given annotation type.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -52,12 +54,12 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
     /**
      * The annotation type being documented.
      */
-    private AnnotationTypeDoc annotationTypeDoc;
+    private final AnnotationTypeDoc annotationTypeDoc;
 
     /**
      * The doclet specific writer.
      */
-    private AnnotationTypeWriter writer;
+    private final AnnotationTypeWriter writer;
 
     /**
      * The content tree for the annotation documentation.
@@ -67,38 +69,37 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context           the build context.
+     * @param annotationTypeDoc the class being documented.
+     * @param writer            the doclet specific writer.
      */
-    private AnnotationTypeBuilder(Configuration configuration) {
-        super(configuration);
+    private AnnotationTypeBuilder(Context context,
+            AnnotationTypeDoc annotationTypeDoc,
+            AnnotationTypeWriter writer) {
+        super(context);
+        this.annotationTypeDoc = annotationTypeDoc;
+        this.writer = writer;
     }
 
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration     the current configuration of the doclet.
+     * @param context           the build context.
      * @param annotationTypeDoc the class being documented.
      * @param writer            the doclet specific writer.
      */
-    public static AnnotationTypeBuilder getInstance(Configuration configuration,
-        AnnotationTypeDoc annotationTypeDoc, AnnotationTypeWriter writer)
-    throws Exception {
-        AnnotationTypeBuilder builder = new AnnotationTypeBuilder(configuration);
-        builder.configuration = configuration;
-        builder.annotationTypeDoc = annotationTypeDoc;
-        builder.writer = writer;
-        if(containingPackagesSeen == null) {
-            containingPackagesSeen = new HashSet<String>();
-        }
-        return builder;
+    public static AnnotationTypeBuilder getInstance(Context context,
+            AnnotationTypeDoc annotationTypeDoc,
+            AnnotationTypeWriter writer)
+            throws Exception {
+        return new AnnotationTypeBuilder(context, annotationTypeDoc, writer);
     }
 
     /**
      * {@inheritDoc}
      */
     public void build() throws IOException {
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
@@ -115,9 +116,9 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
       * @param contentTree the content tree to which the documentation will be added
       */
      public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception {
-        contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
+         contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
                 " " + annotationTypeDoc.name());
-        Content annotationContentTree = writer.getAnnotationContentHeader();
+         Content annotationContentTree = writer.getAnnotationContentHeader();
          buildChildren(node, annotationContentTree);
          contentTree.addContent(annotationContentTree);
          writer.addFooter(contentTree);
@@ -138,12 +139,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
             //Only copy doc files dir if the containing package is not
             //documented AND if we have not documented a class from the same
             //package already. Otherwise, we are making duplicate copies.
-            Util.copyDocFiles(configuration,
-                Util.getPackageSourcePath(configuration,
-                    annotationTypeDoc.containingPackage()) +
-                DirectoryManager.getDirectoryPath(
-                    annotationTypeDoc.containingPackage())
-                    + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true);
+            Util.copyDocFiles(configuration, containingPackage);
             containingPackagesSeen.add(containingPackage.name());
         }
      }
@@ -177,7 +173,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder {
      * @param annotationInfoTree the content tree to which the documentation will be added
      */
     public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
-        StringBuffer modifiers = new StringBuffer(
+        StringBuilder modifiers = new StringBuilder(
                 annotationTypeDoc.modifiers() + " ");
         writer.addAnnotationTypeSignature(Util.replaceText(
                 modifiers.toString(), "interface", "@interface"), annotationInfoTree);
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
index b0abbc3..9c28e9e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,60 +25,53 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
-import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for optional annotation type members.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
  * @since 1.5
  */
 public class AnnotationTypeOptionalMemberBuilder extends
-    AnnotationTypeRequiredMemberBuilder {
+        AnnotationTypeRequiredMemberBuilder {
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
-        super(configuration);
+    private AnnotationTypeOptionalMemberBuilder(Context context,
+            ClassDoc classDoc,
+            AnnotationTypeOptionalMemberWriter writer) {
+        super(context, classDoc, writer,
+                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
     }
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the doclet.
-     * @param classDoc the class whoses members are being documented.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
      * @param writer the doclet specific writer.
      */
     public static AnnotationTypeOptionalMemberBuilder getInstance(
-            Configuration configuration, ClassDoc classDoc,
+            Context context, ClassDoc classDoc,
             AnnotationTypeOptionalMemberWriter writer) {
-        AnnotationTypeOptionalMemberBuilder builder =
-            new AnnotationTypeOptionalMemberBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
-        builder.members = new ArrayList<ProgramElementDoc>(
-            builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(builder.members,
-                configuration.getMemberComparator());
-        }
-        return builder;
+        return new AnnotationTypeOptionalMemberBuilder(context,
+                classDoc, writer);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
index ec9c4f2..84ded90 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
@@ -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
@@ -26,16 +26,18 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for required annotation type members.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -72,37 +74,40 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
     /**
      * Construct a new AnnotationTypeRequiredMemberBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
+     * @param writer the doclet specific writer.
      */
-    protected AnnotationTypeRequiredMemberBuilder(Configuration configuration) {
-        super(configuration);
+    protected AnnotationTypeRequiredMemberBuilder(Context context,
+            ClassDoc classDoc,
+            AnnotationTypeRequiredMemberWriter writer,
+            int memberType) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        this.visibleMemberMap = new VisibleMemberMap(classDoc, memberType,
+            configuration);
+        this.members = new ArrayList<ProgramElementDoc>(
+            this.visibleMemberMap.getMembersFor(classDoc));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(this.members, configuration.getMemberComparator());
+        }
     }
 
 
     /**
      * Construct a new AnnotationTypeMemberBuilder.
      *
-     * @param configuration the current configuration of the doclet.
-     * @param classDoc the class whoses members are being documented.
+     * @param context  the build context.
+     * @param classDoc the class whose members are being documented.
      * @param writer the doclet specific writer.
      */
     public static AnnotationTypeRequiredMemberBuilder getInstance(
-            Configuration configuration, ClassDoc classDoc,
+            Context context, ClassDoc classDoc,
             AnnotationTypeRequiredMemberWriter writer) {
-        AnnotationTypeRequiredMemberBuilder builder =
-            new AnnotationTypeRequiredMemberBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, configuration.nodeprecated);
-        builder.members = new ArrayList<ProgramElementDoc>(
-            builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(builder.members,
-                configuration.getMemberComparator());
-        }
-        return builder;
+        return new AnnotationTypeRequiredMemberBuilder(context, classDoc,
+                    writer,
+                    VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
index 6c1f4e4..7152f2b 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/BuilderFactory.java
@@ -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,16 +25,21 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
+import java.util.HashSet;
+import java.util.Set;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 
 /**
  * The factory for constructing builders.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -45,12 +50,14 @@ public class BuilderFactory {
     /**
      * The current configuration of the doclet.
      */
-    private Configuration configuration;
+    private final Configuration configuration;
 
     /**
      * The factory to retrieve the required writers from.
      */
-    private WriterFactory writerFactory;
+    private final WriterFactory writerFactory;
+
+    private final AbstractBuilder.Context context;
 
     /**
      * Construct a builder factory using the given configuration.
@@ -60,6 +67,10 @@ public class BuilderFactory {
     public BuilderFactory (Configuration configuration) {
         this.configuration = configuration;
         this.writerFactory = configuration.getWriterFactory();
+
+        Set<String> containingPackagesSeen = new HashSet<String>();
+        context = new AbstractBuilder.Context(configuration, containingPackagesSeen,
+                LayoutParser.getInstance(configuration));
     }
 
     /**
@@ -67,7 +78,7 @@ public class BuilderFactory {
      * @return the builder that builds the constant summary.
      */
     public AbstractBuilder getConstantsSummaryBuider() throws Exception {
-        return ConstantsSummaryBuilder.getInstance(configuration,
+        return ConstantsSummaryBuilder.getInstance(context,
             writerFactory.getConstantsSummaryWriter());
     }
 
@@ -81,11 +92,41 @@ public class BuilderFactory {
      */
     public AbstractBuilder getPackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
             PackageDoc nextPkg) throws Exception {
-        return PackageSummaryBuilder.getInstance(configuration, pkg,
+        return PackageSummaryBuilder.getInstance(context, pkg,
             writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg));
     }
 
     /**
+     * Return the builder that builds the profile summary.
+     *
+     * @param profile the profile being documented.
+     * @param prevProfile the previous profile being documented.
+     * @param nextProfile the next profile being documented.
+     * @return the builder that builds the profile summary.
+     */
+    public AbstractBuilder getProfileSummaryBuilder(Profile profile, Profile prevProfile,
+            Profile nextProfile) throws Exception {
+        return ProfileSummaryBuilder.getInstance(context, profile,
+            writerFactory.getProfileSummaryWriter(profile, prevProfile, nextProfile));
+    }
+
+    /**
+     * Return the builder that builds the profile package summary.
+     *
+     * @param pkg the profile package being documented.
+     * @param prevPkg the previous profile package being documented.
+     * @param nextPkg the next profile package being documented.
+     * @param profile the profile being documented.
+     * @return the builder that builds the profile package summary.
+     */
+    public AbstractBuilder getProfilePackageSummaryBuilder(PackageDoc pkg, PackageDoc prevPkg,
+            PackageDoc nextPkg, Profile profile) throws Exception {
+        return ProfilePackageSummaryBuilder.getInstance(context, pkg,
+            writerFactory.getProfilePackageSummaryWriter(pkg, prevPkg, nextPkg,
+                profile), profile);
+    }
+
+    /**
      * Return the builder for the class.
      *
      * @param classDoc the class being documented.
@@ -96,9 +137,9 @@ public class BuilderFactory {
      * writer is not supported by the doclet.
      */
     public AbstractBuilder getClassBuilder(ClassDoc classDoc,
-        ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
+            ClassDoc prevClass, ClassDoc nextClass, ClassTree classTree)
             throws Exception {
-        return ClassBuilder.getInstance(configuration, classDoc,
+        return ClassBuilder.getInstance(context, classDoc,
             writerFactory.getClassWriter(classDoc, prevClass, nextClass,
                 classTree));
     }
@@ -116,9 +157,8 @@ public class BuilderFactory {
         AnnotationTypeDoc annotationType,
         Type prevType, Type nextType)
             throws Exception {
-        return AnnotationTypeBuilder.getInstance(configuration, annotationType,
-            writerFactory.getAnnotationTypeWriter(annotationType, prevType,
-            nextType));
+        return AnnotationTypeBuilder.getInstance(context, annotationType,
+            writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType));
     }
 
     /**
@@ -128,7 +168,7 @@ public class BuilderFactory {
      */
     public AbstractBuilder getMethodBuilder(ClassWriter classWriter)
            throws Exception {
-        return MethodBuilder.getInstance(configuration,
+        return MethodBuilder.getInstance(context,
             classWriter.getClassDoc(),
             writerFactory.getMethodWriter(classWriter));
     }
@@ -143,7 +183,7 @@ public class BuilderFactory {
     public AbstractBuilder getAnnotationTypeOptionalMemberBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return AnnotationTypeOptionalMemberBuilder.getInstance(configuration,
+        return AnnotationTypeOptionalMemberBuilder.getInstance(context,
             annotationTypeWriter.getAnnotationTypeDoc(),
             writerFactory.getAnnotationTypeOptionalMemberWriter(
                 annotationTypeWriter));
@@ -159,7 +199,7 @@ public class BuilderFactory {
     public AbstractBuilder getAnnotationTypeRequiredMemberBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return AnnotationTypeRequiredMemberBuilder.getInstance(configuration,
+        return AnnotationTypeRequiredMemberBuilder.getInstance(context,
             annotationTypeWriter.getAnnotationTypeDoc(),
             writerFactory.getAnnotationTypeRequiredMemberWriter(
                 annotationTypeWriter));
@@ -172,7 +212,7 @@ public class BuilderFactory {
      */
     public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter)
             throws Exception {
-        return EnumConstantBuilder.getInstance(configuration, classWriter.getClassDoc(),
+        return EnumConstantBuilder.getInstance(context, classWriter.getClassDoc(),
             writerFactory.getEnumConstantWriter(classWriter));
     }
 
@@ -183,7 +223,7 @@ public class BuilderFactory {
      */
     public AbstractBuilder getFieldBuilder(ClassWriter classWriter)
             throws Exception {
-        return FieldBuilder.getInstance(configuration, classWriter.getClassDoc(),
+        return FieldBuilder.getInstance(context, classWriter.getClassDoc(),
             writerFactory.getFieldWriter(classWriter));
     }
 
@@ -195,7 +235,7 @@ public class BuilderFactory {
     public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception {
         final PropertyWriter propertyWriter =
                 writerFactory.getPropertyWriter(classWriter);
-        return PropertyBuilder.getInstance(configuration,
+        return PropertyBuilder.getInstance(context,
                                            classWriter.getClassDoc(),
                                            propertyWriter);
     }
@@ -207,9 +247,9 @@ public class BuilderFactory {
      */
     public AbstractBuilder getConstructorBuilder(ClassWriter classWriter)
             throws Exception {
-        return ConstructorBuilder.getInstance(configuration,
-            classWriter.getClassDoc(), writerFactory.getConstructorWriter(
-            classWriter));
+        return ConstructorBuilder.getInstance(context,
+            classWriter.getClassDoc(),
+            writerFactory.getConstructorWriter(classWriter));
     }
 
     /**
@@ -219,7 +259,7 @@ public class BuilderFactory {
      */
     public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter)
             throws Exception {
-        return MemberSummaryBuilder.getInstance(classWriter, configuration);
+        return MemberSummaryBuilder.getInstance(classWriter, context);
     }
 
     /**
@@ -232,8 +272,7 @@ public class BuilderFactory {
     public AbstractBuilder getMemberSummaryBuilder(
             AnnotationTypeWriter annotationTypeWriter)
     throws Exception {
-        return MemberSummaryBuilder.getInstance(annotationTypeWriter,
-            configuration);
+        return MemberSummaryBuilder.getInstance(annotationTypeWriter, context);
     }
 
     /**
@@ -243,6 +282,6 @@ public class BuilderFactory {
      */
     public AbstractBuilder getSerializedFormBuilder()
             throws Exception {
-        return SerializedFormBuilder.getInstance(configuration);
+        return SerializedFormBuilder.getInstance(context);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
index 05f66ce..719aace 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
@@ -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
@@ -27,16 +27,18 @@ package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.io.*;
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds the summary for a given class.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -52,22 +54,22 @@ public class ClassBuilder extends AbstractBuilder {
     /**
      * The class being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The doclet specific writer.
      */
-    private ClassWriter writer;
+    private final ClassWriter writer;
 
     /**
      * Keep track of whether or not this classdoc is an interface.
      */
-    private boolean isInterface = false;
+    private final boolean isInterface;
 
     /**
      * Keep track of whether or not this classdoc is an enum.
      */
-    private boolean isEnum = false;
+    private final boolean isEnum;
 
     /**
      * The content tree for the class documentation.
@@ -77,44 +79,45 @@ public class ClassBuilder extends AbstractBuilder {
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context
+     * @param classDoc the class being documented.
+     * @param writer the doclet specific writer.
      */
-    private ClassBuilder(Configuration configuration) {
-        super(configuration);
+    private ClassBuilder(Context context,
+            ClassDoc classDoc, ClassWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        if (classDoc.isInterface()) {
+            isInterface = true;
+            isEnum = false;
+        } else if (classDoc.isEnum()) {
+            isInterface = false;
+            isEnum = true;
+            Util.setEnumDocumentation(configuration, classDoc);
+        } else {
+            isInterface = false;
+            isEnum = false;
+        }
     }
 
     /**
      * Construct a new ClassBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context
      * @param classDoc the class being documented.
      * @param writer the doclet specific writer.
      */
-    public static ClassBuilder getInstance(Configuration configuration,
-        ClassDoc classDoc, ClassWriter writer)
-    throws Exception {
-        ClassBuilder builder = new ClassBuilder(configuration);
-        builder.configuration = configuration;
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        if (classDoc.isInterface()) {
-            builder.isInterface = true;
-        } else if (classDoc.isEnum()) {
-            builder.isEnum = true;
-            Util.setEnumDocumentation(configuration, classDoc);
-        }
-        if(containingPackagesSeen == null) {
-            containingPackagesSeen = new HashSet<String>();
-        }
-        return builder;
+    public static ClassBuilder getInstance(Context context,
+            ClassDoc classDoc, ClassWriter writer) {
+        return new ClassBuilder(context, classDoc, writer);
     }
 
     /**
      * {@inheritDoc}
      */
     public void build() throws IOException {
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
@@ -125,7 +128,7 @@ public class ClassBuilder extends AbstractBuilder {
     }
 
      /**
-      * Handles the <ClassDoc> tag.
+      * Handles the {@literal <ClassDoc>} tag.
       *
       * @param node the XML element that specifies which components to document
       * @param contentTree the content tree to which the documentation will be added
@@ -233,6 +236,16 @@ public class ClassBuilder extends AbstractBuilder {
     }
 
     /**
+     * If this is an functional interface, display appropriate message.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param classInfoTree the content tree to which the documentation will be added
+     */
+    public void buildFunctionalInterfaceInfo(XMLNode node, Content classInfoTree) {
+        writer.addFunctionalInterfaceInfo(classInfoTree);
+    }
+
+    /**
      * If this class is deprecated, build the appropriate information.
      *
      * @param node the XML element that specifies which components to document
@@ -264,11 +277,7 @@ public class ClassBuilder extends AbstractBuilder {
             //Only copy doc files dir if the containing package is not
             //documented AND if we have not documented a class from the same
             //package already. Otherwise, we are making duplicate copies.
-            Util.copyDocFiles(configuration,
-                    Util.getPackageSourcePath(configuration,
-                    classDoc.containingPackage()) +
-                    DirectoryManager.getDirectoryPath(classDoc.containingPackage())
-                    + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true);
+            Util.copyDocFiles(configuration, containingPackage);
             containingPackagesSeen.add(containingPackage.name());
         }
      }
@@ -280,18 +289,19 @@ public class ClassBuilder extends AbstractBuilder {
      * @param classInfoTree the content tree to which the documentation will be added
      */
     public void buildClassSignature(XMLNode node, Content classInfoTree) {
-        StringBuffer modifiers = new StringBuffer(classDoc.modifiers() + " ");
+        StringBuilder modifiers = new StringBuilder(classDoc.modifiers());
+        modifiers.append(modifiers.length() == 0 ? "" : " ");
         if (isEnum) {
             modifiers.append("enum ");
             int index;
             if ((index = modifiers.indexOf("abstract")) >= 0) {
-                modifiers.delete(index, index + (new String("abstract")).length());
-                modifiers = new StringBuffer(
+                modifiers.delete(index, index + "abstract".length());
+                modifiers = new StringBuilder(
                         Util.replaceText(modifiers.toString(), "  ", " "));
             }
             if ((index = modifiers.indexOf("final")) >= 0) {
-                modifiers.delete(index, index + (new String("final")).length());
-                modifiers = new StringBuffer(
+                modifiers.delete(index, index + "final".length());
+                modifiers = new StringBuilder(
                         Util.replaceText(modifiers.toString(), "  ", " "));
             }
         //} else if (classDoc.isAnnotationType()) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
index bded1e8..c13d485 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
@@ -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
@@ -27,16 +27,18 @@ package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds the Constants Summary Page.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -58,12 +60,12 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
     /**
      * The writer used to write the results.
      */
-    protected ConstantsSummaryWriter writer;
+    protected final ConstantsSummaryWriter writer;
 
     /**
      * The set of ClassDocs that have constant fields.
      */
-    protected Set<ClassDoc> classDocsWithConstFields;
+    protected final Set<ClassDoc> classDocsWithConstFields;
 
     /**
      * The set of printed package headers.
@@ -88,27 +90,25 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
     /**
      * Construct a new ConstantsSummaryBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context       the build context.
+     * @param writer        the writer for the summary.
      */
-    private ConstantsSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    private ConstantsSummaryBuilder(Context context,
+            ConstantsSummaryWriter writer) {
+        super(context);
+        this.writer = writer;
+        this.classDocsWithConstFields = new HashSet<ClassDoc>();
     }
 
     /**
      * Construct a ConstantsSummaryBuilder.
      *
-     * @param configuration the configuration used in this run
-     *                      of the doclet.
+     * @param context       the build context.
      * @param writer        the writer for the summary.
      */
-    public static ConstantsSummaryBuilder getInstance(
-        Configuration configuration, ConstantsSummaryWriter writer) {
-        ConstantsSummaryBuilder builder = new ConstantsSummaryBuilder(
-            configuration);
-        builder.writer = writer;
-        builder.classDocsWithConstFields = new HashSet<ClassDoc>();
-        return builder;
+    public static ConstantsSummaryBuilder getInstance(Context context,
+            ConstantsSummaryWriter writer) {
+        return new ConstantsSummaryBuilder(context, writer);
     }
 
     /**
@@ -119,7 +119,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
             //Doclet does not support this output.
             return;
         }
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
@@ -265,7 +265,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
      */
     private boolean hasConstantField (ClassDoc classDoc) {
         VisibleMemberMap visibleMemberMapFields = new VisibleMemberMap(classDoc,
-            VisibleMemberMap.FIELDS, configuration.nodeprecated);
+            VisibleMemberMap.FIELDS, configuration);
         List<?> fields = visibleMemberMapFields.getLeafClassMembers(configuration);
         for (Iterator<?> iter = fields.iterator(); iter.hasNext(); ) {
             FieldDoc field = (FieldDoc) iter.next();
@@ -323,9 +323,9 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
         public ConstantFieldBuilder(ClassDoc classdoc) {
             this.classdoc = classdoc;
             visibleMemberMapFields = new VisibleMemberMap(classdoc,
-                VisibleMemberMap.FIELDS, configuration.nodeprecated);
+                VisibleMemberMap.FIELDS, configuration);
             visibleMemberMapEnumConst = new VisibleMemberMap(classdoc,
-                VisibleMemberMap.ENUM_CONSTANTS, configuration.nodeprecated);
+                VisibleMemberMap.ENUM_CONSTANTS, configuration);
         }
 
         /**
@@ -345,7 +345,6 @@ public class ConstantsSummaryBuilder extends AbstractBuilder {
 
         /**
          * Return the list of visible constant fields for the given classdoc.
-         * @param cd the classdoc to examine.
          * @return the list of visible constant fields for the given classdoc.
          */
         protected List<FieldDoc> members() {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
index 68efe8c..c744678 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
@@ -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
@@ -26,16 +26,18 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for a constructor.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -57,66 +59,64 @@ public class ConstructorBuilder extends AbstractMemberBuilder {
     /**
      * The class whose constructors are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible constructors for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the constructor documentation.
      */
-    private ConstructorWriter writer;
+    private final ConstructorWriter writer;
 
     /**
      * The constructors being documented.
      */
-    private List<ProgramElementDoc> constructors;
+    private final List<ProgramElementDoc> constructors;
 
     /**
      * Construct a new ConstructorBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
-     */
-    private ConstructorBuilder(Configuration configuration) {
-        super(configuration);
-    }
-
-    /**
-     * Construct a new ConstructorBuilder.
-     *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static ConstructorBuilder getInstance(
-            Configuration configuration,
+    private ConstructorBuilder(Context context,
             ClassDoc classDoc,
             ConstructorWriter writer) {
-        ConstructorBuilder builder = new ConstructorBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
                 new VisibleMemberMap(
                 classDoc,
                 VisibleMemberMap.CONSTRUCTORS,
-                configuration.nodeprecated);
-        builder.constructors =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
-        for (int i = 0; i < builder.constructors.size(); i++) {
-            if (builder.constructors.get(i).isProtected()
-                    || builder.constructors.get(i).isPrivate()) {
+                configuration);
+        constructors =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
+        for (int i = 0; i < constructors.size(); i++) {
+            if (constructors.get(i).isProtected()
+                    || constructors.get(i).isPrivate()) {
                 writer.setFoundNonPubConstructor(true);
             }
         }
         if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.constructors,
-                    configuration.getMemberComparator());
+            Collections.sort(constructors,configuration.getMemberComparator());
         }
-        return builder;
+    }
+
+    /**
+     * Construct a new ConstructorBuilder.
+     *
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
+     */
+    public static ConstructorBuilder getInstance(Context context,
+            ClassDoc classDoc, ConstructorWriter writer) {
+        return new ConstructorBuilder(context, classDoc, writer);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
index 868297b..32127fa 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
@@ -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
@@ -26,16 +26,18 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for a enum constants.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -46,22 +48,22 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
     /**
      * The class whose enum constants are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible enum constantss for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the enum constants documentation.
      */
-    private EnumConstantWriter writer;
+    private final EnumConstantWriter writer;
 
     /**
      * The list of enum constants being documented.
      */
-    private List<ProgramElementDoc> enumConstants;
+    private final List<ProgramElementDoc> enumConstants;
 
     /**
      * The index of the current enum constant that is being documented at this point
@@ -72,40 +74,37 @@ public class EnumConstantBuilder extends AbstractMemberBuilder {
     /**
      * Construct a new EnumConstantsBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
      */
-    private EnumConstantBuilder(Configuration configuration) {
-        super(configuration);
+    private EnumConstantBuilder(Context context,
+            ClassDoc classDoc, EnumConstantWriter writer) {
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
+                new VisibleMemberMap(
+                classDoc,
+                VisibleMemberMap.ENUM_CONSTANTS,
+                configuration);
+        enumConstants =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
+        if (configuration.getMemberComparator() != null) {
+            Collections.sort(enumConstants, configuration.getMemberComparator());
+        }
     }
 
     /**
      * Construct a new EnumConstantsBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static EnumConstantBuilder getInstance(
-            Configuration configuration,
-            ClassDoc classDoc,
-            EnumConstantWriter writer) {
-        EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
-                classDoc,
-                VisibleMemberMap.ENUM_CONSTANTS,
-                configuration.nodeprecated);
-        builder.enumConstants =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
-        if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.enumConstants,
-                    configuration.getMemberComparator());
-        }
-        return builder;
+    public static EnumConstantBuilder getInstance(Context context,
+            ClassDoc classDoc, EnumConstantWriter writer) {
+        return new EnumConstantBuilder(context, classDoc, writer);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
index 0416ba9..98bde47 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
@@ -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
@@ -26,16 +26,18 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for a field.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -46,22 +48,22 @@ public class FieldBuilder extends AbstractMemberBuilder {
     /**
      * The class whose fields are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible fields for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the field documentation.
      */
-    private FieldWriter writer;
+    private final FieldWriter writer;
 
     /**
      * The list of fields being documented.
      */
-    private List<ProgramElementDoc> fields;
+    private final List<ProgramElementDoc> fields;
 
     /**
      * The index of the current field that is being documented at this point
@@ -72,41 +74,40 @@ public class FieldBuilder extends AbstractMemberBuilder {
     /**
      * Construct a new FieldBuilder.
      *
-     * @param configuration the current configuration of the
-     *                      doclet.
-     */
-    private FieldBuilder(Configuration configuration) {
-        super(configuration);
-    }
-
-    /**
-     * Construct a new FieldBuilder.
-     *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static FieldBuilder getInstance(
-            Configuration configuration,
+    private FieldBuilder(Context context,
             ClassDoc classDoc,
             FieldWriter writer) {
-        FieldBuilder builder = new FieldBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
                 new VisibleMemberMap(
                 classDoc,
                 VisibleMemberMap.FIELDS,
-                configuration.nodeprecated);
-        builder.fields =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
+                configuration);
+        fields =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
                 configuration));
         if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.fields,
-                    configuration.getMemberComparator());
+            Collections.sort(fields, configuration.getMemberComparator());
         }
-        return builder;
+    }
+
+    /**
+     * Construct a new FieldBuilder.
+     *
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
+     */
+    public static FieldBuilder getInstance(Context context,
+            ClassDoc classDoc,
+            FieldWriter writer) {
+        return new FieldBuilder(context, classDoc, writer);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
index 3445d96..6c9b306 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -24,18 +24,26 @@
  */
 package com.sun.tools.doclets.internal.toolkit.builders;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import java.io.*;
 import java.util.*;
+
+import javax.xml.parsers.*;
+
 import org.xml.sax.*;
 import org.xml.sax.helpers.DefaultHandler;
-import javax.xml.parsers.*;
+
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Parse the XML that specified the order of operation for the builders.  This
  * Parser uses SAX parsing.
  *
+ *  <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
  * @see SAXParser
@@ -47,14 +55,10 @@ public class LayoutParser extends DefaultHandler {
      */
     private Map<String,XMLNode> xmlElementsMap;
     private XMLNode currentNode;
-    private Configuration configuration;
-    private static LayoutParser instance;
+    private final Configuration configuration;
     private String currentRoot;
     private boolean isParsing;
 
-    /**
-     * This class is a singleton.
-     */
     private LayoutParser(Configuration configuration) {
         xmlElementsMap = new HashMap<String,XMLNode>();
         this.configuration = configuration;
@@ -67,10 +71,7 @@ public class LayoutParser extends DefaultHandler {
      * @return an instance of the BuilderXML.
      */
     public static LayoutParser getInstance(Configuration configuration) {
-        if (instance == null) {
-            instance = new LayoutParser(configuration);
-        }
-        return instance;
+        return new LayoutParser(configuration);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
index 2aed216..8edb5dd 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
@@ -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,17 +26,19 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.text.MessageFormat;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
 /**
  * Builds the member summary.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -52,7 +54,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
     /**
      * The visible members for the given class.
      */
-    private VisibleMemberMap[] visibleMemberMaps;
+    private final VisibleMemberMap[] visibleMemberMaps;
 
     /**
      * The member summary writers for the given class.
@@ -62,10 +64,27 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
     /**
      * The type being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
-    private MemberSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    /**
+     * Construct a new MemberSummaryBuilder.
+     *
+     * @param classWriter   the writer for the class whose members are being
+     *                      summarized.
+     * @param context       the build context.
+     */
+    private MemberSummaryBuilder(Context context, ClassDoc classDoc) {
+        super(context);
+        this.classDoc = classDoc;
+        visibleMemberMaps =
+                new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
+        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+            visibleMemberMaps[i] =
+                    new VisibleMemberMap(
+                    classDoc,
+                    i,
+                    configuration);
+        }
     }
 
     /**
@@ -73,14 +92,22 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
      *
      * @param classWriter   the writer for the class whose members are being
      *                      summarized.
-     * @param configuration the current configuration of the doclet.
+     * @param context       the build context.
      */
     public static MemberSummaryBuilder getInstance(
-            ClassWriter classWriter, Configuration configuration)
+            ClassWriter classWriter, Context context)
             throws Exception {
-        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
-        builder.classDoc = classWriter.getClassDoc();
-        builder.init(classWriter);
+        MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+                classWriter.getClassDoc());
+        builder.memberSummaryWriters =
+                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+        WriterFactory wf = context.configuration.getWriterFactory();
+        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+                builder.memberSummaryWriters[i] =
+                    builder.visibleMemberMaps[i].noVisibleMembers() ?
+                        null :
+                        wf.getMemberSummaryWriter(classWriter, i);
+        }
         return builder;
     }
 
@@ -92,42 +119,21 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
      * @param configuration the current configuration of the doclet.
      */
     public static MemberSummaryBuilder getInstance(
-            AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
+            AnnotationTypeWriter annotationTypeWriter, Context context)
             throws Exception {
-        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
-        builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
-        builder.init(annotationTypeWriter);
-        return builder;
-    }
-
-    private void init(Object writer) throws Exception {
-        visibleMemberMaps =
-                new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
-        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
-            visibleMemberMaps[i] =
-                    new VisibleMemberMap(
-                    classDoc,
-                    i,
-                    configuration.nodeprecated);
-        }
-        memberSummaryWriters =
+        MemberSummaryBuilder builder = new MemberSummaryBuilder(context,
+                annotationTypeWriter.getAnnotationTypeDoc());
+        builder.memberSummaryWriters =
                 new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+        WriterFactory wf = context.configuration.getWriterFactory();
         for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
-            if (classDoc.isAnnotationType()) {
-                memberSummaryWriters[i] =
-                    visibleMemberMaps[i].noVisibleMembers()?
+                builder.memberSummaryWriters[i] =
+                    builder.visibleMemberMaps[i].noVisibleMembers()?
                         null :
-                        configuration.getWriterFactory().getMemberSummaryWriter(
-                        (AnnotationTypeWriter) writer, i);
-            } else {
-                memberSummaryWriters[i] =
-                    visibleMemberMaps[i].noVisibleMembers()?
-                        null :
-                        configuration.getWriterFactory().getMemberSummaryWriter(
-                        (ClassWriter) writer, i);
-            }
+                        wf.getMemberSummaryWriter(
+                        annotationTypeWriter, i);
         }
-
+        return builder;
     }
 
     /**
@@ -166,7 +172,6 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
      * This information can be used for doclet specific documentation
      * generation.
      *
-     * @param classDoc the {@link ClassDoc} we want to check.
      * @param type the type of members to return.
      * @return a list of methods that will be documented.
      * @see VisibleMemberMap
@@ -315,7 +320,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
                 configuration));
         if (members.size() > 0) {
             Collections.sort(members);
-            Content tableTree = writer.getSummaryTableTree(classDoc);
+            List<Content> tableContents = new LinkedList<Content>();
             for (int i = 0; i < members.size(); i++) {
                 ProgramElementDoc member = members.get(i);
                 final ProgramElementDoc propertyDoc =
@@ -329,14 +334,15 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
                     //necessary.
                     DocFinder.Output inheritedDoc =
                             DocFinder.search(new DocFinder.Input((MethodDoc) member));
-                    if (inheritedDoc.holder != null &&
-                            inheritedDoc.holder.firstSentenceTags().length > 0) {
+                    if (inheritedDoc.holder != null
+                            && inheritedDoc.holder.firstSentenceTags().length > 0) {
                         firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
                     }
                 }
-                writer.addMemberSummary(classDoc, member, firstSentenceTags, tableTree, i);
+                writer.addMemberSummary(classDoc, member, firstSentenceTags,
+                        tableContents, i);
             }
-            summaryTreeList.add(tableTree);
+            summaryTreeList.add(writer.getSummaryTableTree(classDoc, tableContents));
         }
     }
 
@@ -363,13 +369,13 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
             if (isSetter) {
                 commentTextBuilder.append(
                         MessageFormat.format(
-                                Util.RESOURCE_BUNDLE.getString("doclet.PropertySetterWithName"),
+                                configuration.getText("doclet.PropertySetterWithName"),
                                 Util.propertyNameFromMethodName(member.name())));
             }
             if (isGetter) {
                 commentTextBuilder.append(
                         MessageFormat.format(
-                                Util.RESOURCE_BUNDLE.getString("doclet.PropertyGetterWithName"),
+                                configuration.getText("doclet.PropertyGetterWithName"),
                                 Util.propertyNameFromMethodName(member.name())));
             }
             if (propertyDoc.commentText() != null
@@ -379,15 +385,21 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder {
         }
         commentTextBuilder.append(propertyDoc.commentText());
 
-        Tag[] tags = propertyDoc.tags("@defaultValue");
-        if (tags != null) {
-            for (Tag tag: tags) {
-                commentTextBuilder.append("\n")
-                                  .append(tag.name())
-                                  .append(" ")
-                                  .append(tag.text());
+        // copy certain tags
+        List<Tag> allTags = new LinkedList<Tag>();
+        String[] tagNames = {"@defaultValue", "@since"};
+        for (String tagName: tagNames) {
+            Tag[] tags = propertyDoc.tags(tagName);
+            if (tags != null) {
+                allTags.addAll(Arrays.asList(tags));
             }
         }
+        for (Tag tag: allTags) {
+            commentTextBuilder.append("\n")
+                                .append(tag.name())
+                                .append(" ")
+                                .append(tag.text());
+        }
 
         //add @see tags
         if (!isGetter && !isSetter) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
index 0a28d89..2300879 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
@@ -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
@@ -26,16 +26,18 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.tools.doclets.internal.toolkit.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds documentation for a method.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -52,57 +54,61 @@ public class MethodBuilder extends AbstractMemberBuilder {
     /**
      * The class whose methods are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
      * The visible methods for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
      * The writer to output the method documentation.
      */
-    private MethodWriter writer;
+    private final MethodWriter writer;
 
     /**
      * The methods being documented.
      */
     private List<ProgramElementDoc> methods;
 
-    private MethodBuilder(Configuration configuration) {
-        super(configuration);
-    }
 
     /**
      * Construct a new MethodBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context       the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
-     *
-     * @return an instance of a MethodBuilder.
      */
-    public static MethodBuilder getInstance(
-            Configuration configuration,
+    private MethodBuilder(Context context,
             ClassDoc classDoc,
             MethodWriter writer) {
-        MethodBuilder builder = new MethodBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
-                new VisibleMemberMap(
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap = new VisibleMemberMap(
                 classDoc,
                 VisibleMemberMap.METHODS,
-                configuration.nodeprecated);
-        builder.methods =
-                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
+                configuration);
+        methods =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getLeafClassMembers(
                 configuration));
         if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.methods,
-                    configuration.getMemberComparator());
+            Collections.sort(methods, configuration.getMemberComparator());
         }
-        return builder;
+    }
+
+    /**
+     * Construct a new MethodBuilder.
+     *
+     * @param context       the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
+     *
+     * @return an instance of a MethodBuilder.
+     */
+    public static MethodBuilder getInstance(Context context,
+            ClassDoc classDoc, MethodWriter writer) {
+        return new MethodBuilder(context, classDoc, writer);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
index b4c2b30..b6e8fec 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
@@ -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,20 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.builders;
 
+import java.io.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * Builds the summary for a given package.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -53,40 +52,47 @@ public class PackageSummaryBuilder extends AbstractBuilder {
     /**
      * The package being documented.
      */
-    private PackageDoc packageDoc;
+    private final PackageDoc packageDoc;
 
     /**
      * The doclet specific writer that will output the result.
      */
-    private PackageSummaryWriter packageWriter;
+    private final PackageSummaryWriter packageWriter;
 
     /**
      * The content that will be added to the package summary documentation tree.
      */
     private Content contentTree;
 
-    private PackageSummaryBuilder(Configuration configuration) {
-        super(configuration);
+    /**
+     * Construct a new PackageSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param pkg the package being documented.
+     * @param packageWriter the doclet specific writer that will output the
+     *        result.
+     */
+    private PackageSummaryBuilder(Context context,
+            PackageDoc pkg,
+            PackageSummaryWriter packageWriter) {
+        super(context);
+        this.packageDoc = pkg;
+        this.packageWriter = packageWriter;
     }
 
     /**
      * Construct a new PackageSummaryBuilder.
-     * @param configuration the current configuration of the doclet.
+     *
+     * @param context  the build context.
      * @param pkg the package being documented.
      * @param packageWriter the doclet specific writer that will output the
      *        result.
      *
      * @return an instance of a PackageSummaryBuilder.
      */
-    public static PackageSummaryBuilder getInstance(
-        Configuration configuration,
-        PackageDoc pkg,
-        PackageSummaryWriter packageWriter) {
-        PackageSummaryBuilder builder =
-                new PackageSummaryBuilder(configuration);
-        builder.packageDoc = pkg;
-        builder.packageWriter = packageWriter;
-        return builder;
+    public static PackageSummaryBuilder getInstance(Context context,
+            PackageDoc pkg, PackageSummaryWriter packageWriter) {
+        return new PackageSummaryBuilder(context, pkg, packageWriter);
     }
 
     /**
@@ -97,7 +103,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
             //Doclet does not support this output.
             return;
         }
-        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+        build(layoutParser.parseXML(ROOT), contentTree);
     }
 
     /**
@@ -114,19 +120,12 @@ public class PackageSummaryBuilder extends AbstractBuilder {
      * @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);
         packageWriter.close();
-        Util.copyDocFiles(
-                configuration,
-                Util.getPackageSourcePath(configuration, packageDoc),
-                DirectoryManager.getDirectoryPath(packageDoc)
-                        + File.separator
-                        + DocletConstants.DOC_FILES_DIR_NAME,
-                true);
+        Util.copyDocFiles(configuration, packageDoc);
     }
 
     /**
@@ -176,7 +175,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.interfaces()
                         : configuration.classDocCatalog.interfaces(
                                 Util.getPackageName(packageDoc));
-        interfaces = filterOutPrivateClasses(interfaces);
+        interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx);
         if (interfaces.length > 0) {
             packageWriter.addClassesSummary(
                     interfaces,
@@ -206,7 +205,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.ordinaryClasses()
                         : configuration.classDocCatalog.ordinaryClasses(
                                 Util.getPackageName(packageDoc));
-        classes = filterOutPrivateClasses(classes);
+        classes = Util.filterOutPrivateClasses(classes, configuration.javafx);
         if (classes.length > 0) {
             packageWriter.addClassesSummary(
                     classes,
@@ -236,7 +235,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.enums()
                         : configuration.classDocCatalog.enums(
                                 Util.getPackageName(packageDoc));
-        enums = filterOutPrivateClasses(enums);
+        enums = Util.filterOutPrivateClasses(enums, configuration.javafx);
         if (enums.length > 0) {
             packageWriter.addClassesSummary(
                     enums,
@@ -266,7 +265,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.exceptions()
                         : configuration.classDocCatalog.exceptions(
                                 Util.getPackageName(packageDoc));
-        exceptions = filterOutPrivateClasses(exceptions);
+        exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx);
         if (exceptions.length > 0) {
             packageWriter.addClassesSummary(
                     exceptions,
@@ -296,7 +295,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.errors()
                         : configuration.classDocCatalog.errors(
                                 Util.getPackageName(packageDoc));
-        errors = filterOutPrivateClasses(errors);
+        errors = Util.filterOutPrivateClasses(errors, configuration.javafx);
         if (errors.length > 0) {
             packageWriter.addClassesSummary(
                     errors,
@@ -326,7 +325,7 @@ public class PackageSummaryBuilder extends AbstractBuilder {
                         ? packageDoc.annotationTypes()
                         : configuration.classDocCatalog.annotationTypes(
                                 Util.getPackageName(packageDoc));
-        annotationTypes = filterOutPrivateClasses(annotationTypes);
+        annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx);
         if (annotationTypes.length > 0) {
             packageWriter.addClassesSummary(
                     annotationTypes,
@@ -362,25 +361,4 @@ public class PackageSummaryBuilder extends AbstractBuilder {
         }
         packageWriter.addPackageTags(packageContentTree);
     }
-
-    static public ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes) {
-        if (!Configuration.getJavafxJavadoc()) {
-            return classes;
-        }
-        final List<ClassDoc> filteredOutClasses =
-                new ArrayList<ClassDoc>(classes.length);
-        for (ClassDoc classDoc : classes) {
-            if (classDoc.isPrivate() || classDoc.isPackagePrivate()) {
-                continue;
-            }
-            Tag[] aspTags = classDoc.tags("treatAsPrivate");
-            if (aspTags != null && aspTags.length > 0) {
-                continue;
-            }
-            filteredOutClasses.add(classDoc);
-        }
-
-        return filteredOutClasses.toArray(new ClassDoc[0]);
-    }
-
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java
new file mode 100644
index 0000000..98ae55d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java
@@ -0,0 +1,374 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.builders;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Builds the summary for a given profile package.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfilePackageSummaryBuilder extends AbstractBuilder {
+    /**
+     * The root element of the profile package summary XML is {@value}.
+     */
+    public static final String ROOT = "PackageDoc";
+
+    /**
+     * The profile package being documented.
+     */
+    private final PackageDoc packageDoc;
+
+    /**
+     * The name of the profile being documented.
+     */
+    private final String profileName;
+
+    /**
+     * The value of the profile being documented.
+     */
+    private final int profileValue;
+
+    /**
+     * The doclet specific writer that will output the result.
+     */
+    private final ProfilePackageSummaryWriter profilePackageWriter;
+
+    /**
+     * The content that will be added to the profile package summary documentation tree.
+     */
+    private Content contentTree;
+
+    /**
+     * Construct a new ProfilePackageSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param pkg the profile package being documented.
+     * @param profilePackageWriter the doclet specific writer that will output the
+     *        result.
+     * @param profile the profile being documented.
+     */
+    private ProfilePackageSummaryBuilder(Context context,
+            PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
+            Profile profile) {
+        super(context);
+        this.packageDoc = pkg;
+        this.profilePackageWriter = profilePackageWriter;
+        this.profileName = profile.name;
+        this.profileValue = profile.value;
+    }
+
+    /**
+     * Construct a new ProfilePackageSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param pkg the profile package being documented.
+     * @param profilePackageWriter the doclet specific writer that will output the
+     *        result.
+     * @param profile the profile being documented.
+     *
+     * @return an instance of a ProfilePackageSummaryBuilder.
+     */
+    public static ProfilePackageSummaryBuilder getInstance(Context context,
+            PackageDoc pkg, ProfilePackageSummaryWriter profilePackageWriter,
+            Profile profile) {
+        return new ProfilePackageSummaryBuilder(context, pkg, profilePackageWriter,
+                profile);
+    }
+
+    /**
+     * Build the profile package summary.
+     */
+    public void build() throws IOException {
+        if (profilePackageWriter == null) {
+            //Doclet does not support this output.
+            return;
+        }
+        build(layoutParser.parseXML(ROOT), contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return ROOT;
+    }
+
+    /**
+     * Build the profile package documentation.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param contentTree the content tree to which the documentation will be added
+     */
+    public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
+        contentTree = profilePackageWriter.getPackageHeader(
+                Util.getPackageName(packageDoc));
+        buildChildren(node, contentTree);
+        profilePackageWriter.addPackageFooter(contentTree);
+        profilePackageWriter.printDocument(contentTree);
+        profilePackageWriter.close();
+        Util.copyDocFiles(configuration, packageDoc);
+    }
+
+    /**
+     * Build the content for the profile package doc.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param contentTree the content tree to which the package contents
+     *                    will be added
+     */
+    public void buildContent(XMLNode node, Content contentTree) {
+        Content packageContentTree = profilePackageWriter.getContentHeader();
+        buildChildren(node, packageContentTree);
+        contentTree.addContent(packageContentTree);
+    }
+
+    /**
+     * Build the profile package summary.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageContentTree the package content tree to which the summaries will
+     *                           be added
+     */
+    public void buildSummary(XMLNode node, Content packageContentTree) {
+        Content summaryContentTree = profilePackageWriter.getSummaryHeader();
+        buildChildren(node, summaryContentTree);
+        packageContentTree.addContent(summaryContentTree);
+    }
+
+    /**
+     * Build the summary for the interfaces in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the interface summary
+     *                           will be added
+     */
+    public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
+        String interfaceTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Interface_Summary"),
+                configuration.getText("doclet.interfaces"));
+        String[] interfaceTableHeader = new String[] {
+            configuration.getText("doclet.Interface"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] interfaces =
+                packageDoc.isIncluded()
+                        ? packageDoc.interfaces()
+                        : configuration.classDocCatalog.interfaces(
+                                Util.getPackageName(packageDoc));
+        if (interfaces.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    interfaces,
+                    configuration.getText("doclet.Interface_Summary"),
+                    interfaceTableSummary, interfaceTableHeader, summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the classes in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the class summary will
+     *                           be added
+     */
+    public void buildClassSummary(XMLNode node, Content summaryContentTree) {
+        String classTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Class_Summary"),
+                configuration.getText("doclet.classes"));
+        String[] classTableHeader = new String[] {
+            configuration.getText("doclet.Class"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] classes =
+                packageDoc.isIncluded()
+                        ? packageDoc.ordinaryClasses()
+                        : configuration.classDocCatalog.ordinaryClasses(
+                                Util.getPackageName(packageDoc));
+        if (classes.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    classes,
+                    configuration.getText("doclet.Class_Summary"),
+                    classTableSummary, classTableHeader, summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the enums in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the enum summary will
+     *                           be added
+     */
+    public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
+        String enumTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Enum_Summary"),
+                configuration.getText("doclet.enums"));
+        String[] enumTableHeader = new String[] {
+            configuration.getText("doclet.Enum"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] enums =
+                packageDoc.isIncluded()
+                        ? packageDoc.enums()
+                        : configuration.classDocCatalog.enums(
+                                Util.getPackageName(packageDoc));
+        if (enums.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    enums,
+                    configuration.getText("doclet.Enum_Summary"),
+                    enumTableSummary, enumTableHeader, summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the exceptions in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the exception summary will
+     *                           be added
+     */
+    public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
+        String exceptionTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Exception_Summary"),
+                configuration.getText("doclet.exceptions"));
+        String[] exceptionTableHeader = new String[] {
+            configuration.getText("doclet.Exception"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] exceptions =
+                packageDoc.isIncluded()
+                        ? packageDoc.exceptions()
+                        : configuration.classDocCatalog.exceptions(
+                                Util.getPackageName(packageDoc));
+        if (exceptions.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    exceptions,
+                    configuration.getText("doclet.Exception_Summary"),
+                    exceptionTableSummary, exceptionTableHeader, summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the errors in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the error summary will
+     *                           be added
+     */
+    public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
+        String errorTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Error_Summary"),
+                configuration.getText("doclet.errors"));
+        String[] errorTableHeader = new String[] {
+            configuration.getText("doclet.Error"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] errors =
+                packageDoc.isIncluded()
+                        ? packageDoc.errors()
+                        : configuration.classDocCatalog.errors(
+                                Util.getPackageName(packageDoc));
+        if (errors.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    errors,
+                    configuration.getText("doclet.Error_Summary"),
+                    errorTableSummary, errorTableHeader, summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the annotation type in this package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the summary tree to which the annotation type
+     *                           summary will be added
+     */
+    public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
+        String annotationtypeTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Types_Summary"),
+                configuration.getText("doclet.annotationtypes"));
+        String[] annotationtypeTableHeader = new String[] {
+            configuration.getText("doclet.AnnotationType"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] annotationTypes =
+                packageDoc.isIncluded()
+                        ? packageDoc.annotationTypes()
+                        : configuration.classDocCatalog.annotationTypes(
+                                Util.getPackageName(packageDoc));
+        if (annotationTypes.length > 0) {
+            profilePackageWriter.addClassesSummary(
+                    annotationTypes,
+                    configuration.getText("doclet.Annotation_Types_Summary"),
+                    annotationtypeTableSummary, annotationtypeTableHeader,
+                    summaryContentTree);
+        }
+    }
+
+    /**
+     * Build the description of the summary.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageContentTree the tree to which the package description will
+     *                           be added
+     */
+    public void buildPackageDescription(XMLNode node, Content packageContentTree) {
+        if (configuration.nocomment) {
+            return;
+        }
+        profilePackageWriter.addPackageDescription(packageContentTree);
+    }
+
+    /**
+     * Build the tags of the summary.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageContentTree the tree to which the package tags will be added
+     */
+    public void buildPackageTags(XMLNode node, Content packageContentTree) {
+        if (configuration.nocomment) {
+            return;
+        }
+        profilePackageWriter.addPackageTags(packageContentTree);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java
new file mode 100644
index 0000000..57cf323
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java
@@ -0,0 +1,328 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.builders;
+
+import java.io.*;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
+/**
+ * Builds the summary for a given profile.
+ *
+ *  <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 Bhavesh Patel
+ */
+public class ProfileSummaryBuilder extends AbstractBuilder {
+    /**
+     * The root element of the profile summary XML is {@value}.
+     */
+    public static final String ROOT = "ProfileDoc";
+
+    /**
+     * The profile being documented.
+     */
+    private final Profile profile;
+
+    /**
+     * The doclet specific writer that will output the result.
+     */
+    private final ProfileSummaryWriter profileWriter;
+
+    /**
+     * The content that will be added to the profile summary documentation tree.
+     */
+    private Content contentTree;
+
+    /**
+     * The profile package being documented.
+     */
+    private PackageDoc pkg;
+
+    /**
+     * Construct a new ProfileSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param profile the profile being documented.
+     * @param profileWriter the doclet specific writer that will output the
+     *        result.
+     */
+    private ProfileSummaryBuilder(Context context,
+            Profile profile, ProfileSummaryWriter profileWriter) {
+        super(context);
+        this.profile = profile;
+        this.profileWriter = profileWriter;
+    }
+
+    /**
+     * Construct a new ProfileSummaryBuilder.
+     *
+     * @param context  the build context.
+     * @param profile the profile being documented.
+     * @param profileWriter the doclet specific writer that will output the
+     *        result.
+     *
+     * @return an instance of a ProfileSummaryBuilder.
+     */
+    public static ProfileSummaryBuilder getInstance(Context context,
+            Profile profile, ProfileSummaryWriter profileWriter) {
+        return new ProfileSummaryBuilder(context, profile, profileWriter);
+    }
+
+    /**
+     * Build the profile summary.
+     */
+    public void build() throws IOException {
+        if (profileWriter == null) {
+            //Doclet does not support this output.
+            return;
+        }
+        build(layoutParser.parseXML(ROOT), contentTree);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return ROOT;
+    }
+
+    /**
+     * Build the profile documentation.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param contentTree the content tree to which the documentation will be added
+     */
+    public void buildProfileDoc(XMLNode node, Content contentTree) throws Exception {
+        contentTree = profileWriter.getProfileHeader(profile.name);
+        buildChildren(node, contentTree);
+        profileWriter.addProfileFooter(contentTree);
+        profileWriter.printDocument(contentTree);
+        profileWriter.close();
+        Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name));
+    }
+
+    /**
+     * Build the content for the profile doc.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param contentTree the content tree to which the profile contents
+     *                    will be added
+     */
+    public void buildContent(XMLNode node, Content contentTree) {
+        Content profileContentTree = profileWriter.getContentHeader();
+        buildChildren(node, profileContentTree);
+        contentTree.addContent(profileContentTree);
+    }
+
+    /**
+     * Build the profile summary.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param profileContentTree the profile content tree to which the summaries will
+     *                           be added
+     */
+    public void buildSummary(XMLNode node, Content profileContentTree) {
+        Content summaryContentTree = profileWriter.getSummaryHeader();
+        buildChildren(node, summaryContentTree);
+        profileContentTree.addContent(profileWriter.getSummaryTree(summaryContentTree));
+    }
+
+    /**
+     * Build the profile package summary.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param summaryContentTree the content tree to which the summaries will
+     *                           be added
+     */
+    public void buildPackageSummary(XMLNode node, Content summaryContentTree) {
+        PackageDoc[] packages = configuration.profilePackages.get(profile.name);
+        for (int i = 0; i < packages.length; i++) {
+            this.pkg = packages[i];
+            Content packageSummaryContentTree = profileWriter.getPackageSummaryHeader(this.pkg);
+            buildChildren(node, packageSummaryContentTree);
+            summaryContentTree.addContent(profileWriter.getPackageSummaryTree(
+                    packageSummaryContentTree));
+        }
+    }
+
+    /**
+     * Build the summary for the interfaces in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the interface summary
+     *                           will be added
+     */
+    public void buildInterfaceSummary(XMLNode node, Content packageSummaryContentTree) {
+        String interfaceTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Interface_Summary"),
+                configuration.getText("doclet.interfaces"));
+        String[] interfaceTableHeader = new String[] {
+            configuration.getText("doclet.Interface"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] interfaces = pkg.interfaces();
+        if (interfaces.length > 0) {
+            profileWriter.addClassesSummary(
+                    interfaces,
+                    configuration.getText("doclet.Interface_Summary"),
+                    interfaceTableSummary, interfaceTableHeader, packageSummaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the classes in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the class summary will
+     *                           be added
+     */
+    public void buildClassSummary(XMLNode node, Content packageSummaryContentTree) {
+        String classTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Class_Summary"),
+                configuration.getText("doclet.classes"));
+        String[] classTableHeader = new String[] {
+            configuration.getText("doclet.Class"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] classes = pkg.ordinaryClasses();
+        if (classes.length > 0) {
+            profileWriter.addClassesSummary(
+                    classes,
+                    configuration.getText("doclet.Class_Summary"),
+                    classTableSummary, classTableHeader, packageSummaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the enums in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the enum summary will
+     *                           be added
+     */
+    public void buildEnumSummary(XMLNode node, Content packageSummaryContentTree) {
+        String enumTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Enum_Summary"),
+                configuration.getText("doclet.enums"));
+        String[] enumTableHeader = new String[] {
+            configuration.getText("doclet.Enum"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] enums = pkg.enums();
+        if (enums.length > 0) {
+            profileWriter.addClassesSummary(
+                    enums,
+                    configuration.getText("doclet.Enum_Summary"),
+                    enumTableSummary, enumTableHeader, packageSummaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the exceptions in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the exception summary will
+     *                           be added
+     */
+    public void buildExceptionSummary(XMLNode node, Content packageSummaryContentTree) {
+        String exceptionTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Exception_Summary"),
+                configuration.getText("doclet.exceptions"));
+        String[] exceptionTableHeader = new String[] {
+            configuration.getText("doclet.Exception"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] exceptions = pkg.exceptions();
+        if (exceptions.length > 0) {
+            profileWriter.addClassesSummary(
+                    exceptions,
+                    configuration.getText("doclet.Exception_Summary"),
+                    exceptionTableSummary, exceptionTableHeader, packageSummaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the errors in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the error summary will
+     *                           be added
+     */
+    public void buildErrorSummary(XMLNode node, Content packageSummaryContentTree) {
+        String errorTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Error_Summary"),
+                configuration.getText("doclet.errors"));
+        String[] errorTableHeader = new String[] {
+            configuration.getText("doclet.Error"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] errors = pkg.errors();
+        if (errors.length > 0) {
+            profileWriter.addClassesSummary(
+                    errors,
+                    configuration.getText("doclet.Error_Summary"),
+                    errorTableSummary, errorTableHeader, packageSummaryContentTree);
+        }
+    }
+
+    /**
+     * Build the summary for the annotation type in the package.
+     *
+     * @param node the XML element that specifies which components to document
+     * @param packageSummaryContentTree the tree to which the annotation type
+     *                           summary will be added
+     */
+    public void buildAnnotationTypeSummary(XMLNode node, Content packageSummaryContentTree) {
+        String annotationtypeTableSummary =
+                configuration.getText("doclet.Member_Table_Summary",
+                configuration.getText("doclet.Annotation_Types_Summary"),
+                configuration.getText("doclet.annotationtypes"));
+        String[] annotationtypeTableHeader = new String[] {
+            configuration.getText("doclet.AnnotationType"),
+            configuration.getText("doclet.Description")
+        };
+        ClassDoc[] annotationTypes = pkg.annotationTypes();
+        if (annotationTypes.length > 0) {
+            profileWriter.addClassesSummary(
+                    annotationTypes,
+                    configuration.getText("doclet.Annotation_Types_Summary"),
+                    annotationtypeTableSummary, annotationtypeTableHeader,
+                    packageSummaryContentTree);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java
index 476e18f..6430da6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PropertyBuilder.java
@@ -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,86 +26,87 @@
 package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.util.*;
+
 import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.javadoc.*;
 
 /**
- * Builds documentation for a field.
+ * Builds documentation for a property.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
- * @since 1.5
+ * @since 1.7
  */
 public class PropertyBuilder extends AbstractMemberBuilder {
 
     /**
-     * The class whose fields are being documented.
+     * The class whose properties are being documented.
      */
-    private ClassDoc classDoc;
+    private final ClassDoc classDoc;
 
     /**
-     * The visible fields for the given class.
+     * The visible properties for the given class.
      */
-    private VisibleMemberMap visibleMemberMap;
+    private final VisibleMemberMap visibleMemberMap;
 
     /**
-     * The writer to output the field documentation.
+     * The writer to output the property documentation.
      */
-    private PropertyWriter writer;
+    private final PropertyWriter writer;
 
     /**
-     * The list of fields being documented.
+     * The list of properties being documented.
      */
-    private List<ProgramElementDoc> fields;
+    private final List<ProgramElementDoc> properties;
 
     /**
-     * The index of the current field that is being documented at this point
+     * The index of the current property that is being documented at this point
      * in time.
      */
-    private int currentFieldIndex;
-
-    /**
-     * Construct a new FieldBuilder.
-     *
-     * @param configuration the current configuration of the
-     *                      doclet.
-     */
-    private PropertyBuilder(Configuration configuration) {
-        super(configuration);
-    }
+    private int currentPropertyIndex;
 
     /**
-     * Construct a new FieldBuilder.
+     * Construct a new PropertyBuilder.
      *
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      * @param classDoc the class whoses members are being documented.
      * @param writer the doclet specific writer.
      */
-    public static PropertyBuilder getInstance(
-            Configuration configuration,
+    private PropertyBuilder(Context context,
             ClassDoc classDoc,
             PropertyWriter writer) {
-        PropertyBuilder builder = new PropertyBuilder(configuration);
-        builder.classDoc = classDoc;
-        builder.writer = writer;
-        builder.visibleMemberMap =
+        super(context);
+        this.classDoc = classDoc;
+        this.writer = writer;
+        visibleMemberMap =
                 new VisibleMemberMap(
                 classDoc,
                 VisibleMemberMap.PROPERTIES,
-                configuration.nodeprecated);
-        builder.fields = new ArrayList<ProgramElementDoc>(
-                              builder.visibleMemberMap.getMembersFor(classDoc));
+                configuration);
+        properties =
+                new ArrayList<ProgramElementDoc>(visibleMemberMap.getMembersFor(classDoc));
         if (configuration.getMemberComparator() != null) {
-            Collections.sort(
-                    builder.fields,
-                    configuration.getMemberComparator());
+            Collections.sort(properties, configuration.getMemberComparator());
         }
-        return builder;
+    }
+
+    /**
+     * Construct a new PropertyBuilder.
+     *
+     * @param context  the build context.
+     * @param classDoc the class whoses members are being documented.
+     * @param writer the doclet specific writer.
+     */
+    public static PropertyBuilder getInstance(Context context,
+            ClassDoc classDoc,
+            PropertyWriter writer) {
+        return new PropertyBuilder(context, classDoc, writer);
     }
 
     /**
@@ -116,21 +117,21 @@ public class PropertyBuilder extends AbstractMemberBuilder {
     }
 
     /**
-     * Returns a list of fields that will be documented for the given class.
+     * Returns a list of properties that will be documented for the given class.
      * This information can be used for doclet specific documentation
      * generation.
      *
      * @param classDoc the {@link ClassDoc} we want to check.
-     * @return a list of fields that will be documented.
+     * @return a list of properties that will be documented.
      */
     public List<ProgramElementDoc> members(ClassDoc classDoc) {
         return visibleMemberMap.getMembersFor(classDoc);
     }
 
     /**
-     * Returns the visible member map for the fields of this class.
+     * Returns the visible member map for the properties of this class.
      *
-     * @return the visible member map for the fields of this class.
+     * @return the visible member map for the properties of this class.
      */
     public VisibleMemberMap getVisibleMemberMap() {
         return visibleMemberMap;
@@ -140,11 +141,11 @@ public class PropertyBuilder extends AbstractMemberBuilder {
      * summaryOrder.size()
      */
     public boolean hasMembersToDocument() {
-        return fields.size() > 0;
+        return properties.size() > 0;
     }
 
     /**
-     * Build the field documentation.
+     * Build the property documentation.
      *
      * @param node the XML element that specifies which components to document
      * @param memberDetailsTree the content tree to which the documentation will be added
@@ -153,21 +154,21 @@ public class PropertyBuilder extends AbstractMemberBuilder {
         if (writer == null) {
             return;
         }
-        int size = fields.size();
+        int size = properties.size();
         if (size > 0) {
-            Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(
+            Content propertyDetailsTree = writer.getPropertyDetailsTreeHeader(
                     classDoc, memberDetailsTree);
-            for (currentFieldIndex = 0; currentFieldIndex < size;
-                    currentFieldIndex++) {
-                Content fieldDocTree = writer.getFieldDocTreeHeader(
-                        (MethodDoc) fields.get(currentFieldIndex),
-                        fieldDetailsTree);
-                buildChildren(node, fieldDocTree);
-                fieldDetailsTree.addContent(writer.getFieldDoc(
-                        fieldDocTree, (currentFieldIndex == size - 1)));
+            for (currentPropertyIndex = 0; currentPropertyIndex < size;
+                    currentPropertyIndex++) {
+                Content propertyDocTree = writer.getPropertyDocTreeHeader(
+                        (MethodDoc) properties.get(currentPropertyIndex),
+                        propertyDetailsTree);
+                buildChildren(node, propertyDocTree);
+                propertyDetailsTree.addContent(writer.getPropertyDoc(
+                        propertyDocTree, (currentPropertyIndex == size - 1)));
             }
             memberDetailsTree.addContent(
-                    writer.getFieldDetails(fieldDetailsTree));
+                    writer.getPropertyDetails(propertyDetailsTree));
         }
     }
 
@@ -175,34 +176,34 @@ public class PropertyBuilder extends AbstractMemberBuilder {
      * Build the signature.
      *
      * @param node the XML element that specifies which components to document
-     * @param fieldDocTree the content tree to which the documentation will be added
+     * @param propertyDocTree the content tree to which the documentation will be added
      */
-    public void buildSignature(XMLNode node, Content fieldDocTree) {
-        fieldDocTree.addContent(
-                writer.getSignature((MethodDoc) fields.get(currentFieldIndex)));
+    public void buildSignature(XMLNode node, Content propertyDocTree) {
+        propertyDocTree.addContent(
+                writer.getSignature((MethodDoc) properties.get(currentPropertyIndex)));
     }
 
     /**
      * Build the deprecation information.
      *
      * @param node the XML element that specifies which components to document
-     * @param fieldDocTree the content tree to which the documentation will be added
+     * @param propertyDocTree the content tree to which the documentation will be added
      */
-    public void buildDeprecationInfo(XMLNode node, Content fieldDocTree) {
+    public void buildDeprecationInfo(XMLNode node, Content propertyDocTree) {
         writer.addDeprecated(
-                (MethodDoc) fields.get(currentFieldIndex), fieldDocTree);
+                (MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
     }
 
     /**
-     * Build the comments for the field.  Do nothing if
+     * Build the comments for the property.  Do nothing if
      * {@link Configuration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
-     * @param fieldDocTree the content tree to which the documentation will be added
+     * @param propertyDocTree the content tree to which the documentation will be added
      */
-    public void buildPropertyComments(XMLNode node, Content fieldDocTree) {
+    public void buildPropertyComments(XMLNode node, Content propertyDocTree) {
         if (!configuration.nocomment) {
-            writer.addComments((MethodDoc) fields.get(currentFieldIndex), fieldDocTree);
+            writer.addComments((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
         }
     }
 
@@ -210,16 +211,16 @@ public class PropertyBuilder extends AbstractMemberBuilder {
      * Build the tag information.
      *
      * @param node the XML element that specifies which components to document
-     * @param fieldDocTree the content tree to which the documentation will be added
+     * @param propertyDocTree the content tree to which the documentation will be added
      */
-    public void buildTagInfo(XMLNode node, Content fieldDocTree) {
-        writer.addTags((MethodDoc) fields.get(currentFieldIndex), fieldDocTree);
+    public void buildTagInfo(XMLNode node, Content propertyDocTree) {
+        writer.addTags((MethodDoc) properties.get(currentPropertyIndex), propertyDocTree);
     }
 
     /**
-     * Return the field writer for this builder.
+     * Return the property writer for this builder.
      *
-     * @return the field writer for this builder.
+     * @return the property writer for this builder.
      */
     public PropertyWriter getWriter() {
         return writer;
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
index 013120b..da424f6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -27,16 +27,18 @@ package com.sun.tools.doclets.internal.toolkit.builders;
 
 import java.io.*;
 import java.util.*;
+
 import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.internal.toolkit.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * Builds the serialized form.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Bhavesh Patel (Modified)
@@ -91,17 +93,21 @@ public class SerializedFormBuilder extends AbstractBuilder {
      */
     private Content contentTree;
 
-    private SerializedFormBuilder(Configuration configuration) {
-        super(configuration);
+
+    /**
+     * Construct a new SerializedFormBuilder.
+     * @param context  the build context.
+     */
+    private SerializedFormBuilder(Context context) {
+        super(context);
     }
 
     /**
      * Construct a new SerializedFormBuilder.
-     * @param configuration the current configuration of the doclet.
+     * @param context  the build context.
      */
-    public static SerializedFormBuilder getInstance(Configuration configuration) {
-        SerializedFormBuilder builder = new SerializedFormBuilder(configuration);
-        return builder;
+    public static SerializedFormBuilder getInstance(Context context) {
+        return new SerializedFormBuilder(context);
     }
 
     /**
@@ -121,7 +127,7 @@ public class SerializedFormBuilder extends AbstractBuilder {
         } catch (Exception e) {
             throw new DocletAbortException();
         }
-        build(LayoutParser.getInstance(configuration).parseXML(NAME), contentTree);
+        build(layoutParser.parseXML(NAME), contentTree);
         writer.close();
     }
 
@@ -472,6 +478,8 @@ public class SerializedFormBuilder extends AbstractBuilder {
         Arrays.sort(tags);
         int tagsLength = tags.length;
         for (int i = 0; i < tagsLength; i++) {
+            if (tags[i].fieldName() == null || tags[i].fieldType() == null) // ignore malformed @serialField tags
+                continue;
             Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
                     (i == tagsLength - 1));
             fieldWriter.addMemberHeader(tags[i].fieldTypeDoc(),
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
index 4b414da..ae335b9 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -32,6 +32,11 @@ import java.util.Map;
 
 /**
  * Simple class to represent the attribute and elements of an XML node.
+ *
+ *  <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 XMLNode {
     XMLNode(XMLNode parent, String qname) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif
new file mode 100644
index 0000000..7b6e08f
Binary files /dev/null and b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar.gif differ
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif
new file mode 100644
index 0000000..feabf0b
Binary files /dev/null and b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/activetitlebar_end.gif differ
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
index c0fb804..aabaaff 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='utf-8'?>
 
 <!--
- 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,6 +28,21 @@
 
 <Doclet>
 
+    <ProfileDoc>
+        <Content>
+            <Summary>
+                <PackageSummary>
+                    <InterfaceSummary/>
+                    <ClassSummary/>
+                    <EnumSummary/>
+                    <ExceptionSummary/>
+                    <ErrorSummary/>
+                    <AnnotationTypeSummary/>
+                </PackageSummary>
+            </Summary>
+        </Content>
+    </ProfileDoc>
+
     <PackageDoc>
         <Content>
             <Summary>
@@ -85,6 +100,7 @@
             <SubInterfacesInfo/>
             <InterfaceUsageInfo/>
             <NestedClassInfo/>
+            <FunctionalInterfaceInfo/>
             <DeprecationInfo/>
             <ClassSignature/>
             <ClassDescription/>
@@ -109,6 +125,7 @@
             </EnumConstantsDetails>
             <PropertyDetails>
                 <PropertyDoc>
+                    <Signature/>
                     <PropertyComments/>
                     <TagInfo/>
                 </PropertyDoc>
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
index 761e91c..a663d38 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
@@ -6,12 +6,13 @@ doclet.Serializable_no_customization=No readObject or writeObject method declare
 doclet.Serialized_Form=Serialized Form
 doclet.Serialized_Form_methods=Serialization Methods
 doclet.Serialized_Form_fields=Serialized Fields
-doclet.Serialized_Form_properties=Serialized Properties
 doclet.Serialized_Form_class=Serialization Overview
 doclet.Class_0_implements_serializable=Class {0} implements Serializable
 doclet.Class_0_extends_implements_serializable=Class {0} extends {1} implements Serializable
 doclet.Option_conflict=Option {0} conflicts with {1}
 doclet.Option_reuse=Option reused: {0}
+doclet.Option_doclint_no_qualifiers=Access qualifiers not permitted for -Xdoclint arguments
+doclet.Option_doclint_invalid_arg=Invalid argument for -Xdoclint option
 doclet.exception_encountered= {0} encountered \n\
 \twhile attempting to create file: {1}
 doclet.perform_copy_exception_encountered= {0} encountered while \n\
@@ -22,16 +23,15 @@ doclet.Copying_File_0_To_Dir_1=Copying file {0} to directory {1}...
 doclet.Copying_File_0_To_File_1=Copying file {0} to file {1}...
 doclet.No_Public_Classes_To_Document=No public or protected classes found to document.
 doclet.Unable_to_create_directory_0=Unable to create directory {0}
-doclet.destination_directory_not_found_0=Destination directory not found {0}
 doclet.destination_directory_not_directory_0=Destination directory is not a directory {0}
 doclet.destination_directory_not_writable_0=Destination directory not writable {0}
-doclet.Error_creating_tmp_file=Error creating temporary file, using default platform encoding.
 doclet.Encoding_not_supported=Encoding not supported: {0}
 doclet.Building_Tree=Building tree for all the packages and classes...
 doclet.Building_Index=Building index for all the packages and classes...
 doclet.Building_Index_For_All_Classes=Building index for all classes...
 doclet.sourcetab_warning=The argument for -sourcetab must be an integer greater than 0.
 doclet.Packages=Packages
+doclet.Profiles=Profiles
 doclet.Other_Packages=Other Packages
 doclet.Notice_taglet_registered=Registered Taglet {0} ...
 doclet.Notice_taglet_unseen=Note: Custom tags that were not seen: {0}
@@ -69,6 +69,7 @@ doclet.malformed_html_link_tag=<a> tag is malformed:\n"{0}"
 doclet.tag_misuse=Tag {0} cannot be used in {1} documentation.  It can only be used in the following types of documentation: {2}.
 doclet.javafx_tag_misuse=Tags @propertyGetter, @propertySetter and @propertyDescription can only be used in JavaFX properties getters and setters.
 doclet.Package_Summary=Package Summary
+doclet.Profile_Summary=Profile Summary
 doclet.Interface_Summary=Interface Summary
 doclet.Annotation_Types_Summary=Annotation Types Summary
 doclet.Enum_Summary=Enum Summary
@@ -83,7 +84,6 @@ doclet.Property_Summary=Property Summary
 doclet.Enum_Constant_Summary=Enum Constant Summary
 doclet.Constructor_Summary=Constructor Summary
 doclet.Method_Summary=Method Summary
-doclet.Factory_Method_Summary=Static Factory Method Summary
 doclet.Interfaces=Interfaces
 doclet.Enums=Enums
 doclet.AnnotationTypes=Annotation Types
@@ -92,12 +92,12 @@ doclet.Errors=Errors
 doclet.Classes=Classes
 doclet.Packages=Packages
 doclet.packages=packages
+doclet.profiles=profiles
 doclet.All_Classes=All Classes
 doclet.All_Superinterfaces=All Superinterfaces:
 doclet.All_Implemented_Interfaces=All Implemented Interfaces:
 doclet.All_classes_and_interfaces=All classes and interfaces (except non-static nested types)
 doclet.Package_class_and_interface_descriptions=Package, class and interface descriptions
-doclet.Members=Members
 doclet.Interface=Interface
 doclet.Class=Class
 doclet.AnnotationType=Annotation Type
@@ -116,10 +116,7 @@ doclet.errors=errors
 doclet.Exception=Exception
 doclet.exception=exception
 doclet.exceptions=exceptions
-doclet.extended_by=extended by
-doclet.extends=extends
 doclet.Package_private=(package private)
-doclet.implements=implementsdoclet.Same_package_name_used=Package name format used twice: {0}
 doclet.Nested_Classes_Interfaces_Inherited_From_Class=Nested classes/interfaces inherited from class
 doclet.Nested_Classes_Interface_Inherited_From_Interface=Nested classes/interfaces inherited from interface
 doclet.Methods_Inherited_From_Class=Methods inherited from class
@@ -128,8 +125,6 @@ doclet.Fields_Inherited_From_Class=Fields inherited from class
 doclet.Fields_Inherited_From_Interface=Fields inherited from interface
 doclet.Properties_Inherited_From_Class=Properties inherited from class
 doclet.Properties_Inherited_From_Interface=Properties inherited from interface
-doclet.Serializable=Serializable
-doclet.Externalizable=Externalizable
 doclet.Annotation_Type_Member_Detail=Element Detail
 doclet.Enum_Constant_Detail=Enum Constant Detail
 doclet.Constants_Summary=Constant Field Values
@@ -138,7 +133,6 @@ doclet.Property_Detail=Property Detail
 doclet.Method_Detail=Method Detail
 doclet.Constructor_Detail=Constructor Detail
 doclet.Deprecated=Deprecated.
-doclet.Deprecated_class=This class is deprecated.
 doclet.Groupname_already_used=In -group option, groupname already used: {0}
 doclet.value_tag_invalid_reference={0} (referenced by @value tag) is an unknown reference.
 doclet.value_tag_invalid_constant=@value tag (which references {0}) can only be used in constants.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
index 83c4b66..82509fc 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
@@ -6,12 +6,13 @@ doclet.Serializable_no_customization=readObject\u307E\u305F\u306FwriteObject\u30
 doclet.Serialized_Form=\u76F4\u5217\u5316\u3055\u308C\u305F\u5F62\u5F0F
 doclet.Serialized_Form_methods=\u76F4\u5217\u5316\u30E1\u30BD\u30C3\u30C9
 doclet.Serialized_Form_fields=\u76F4\u5217\u5316\u3055\u308C\u305F\u30D5\u30A3\u30FC\u30EB\u30C9
-doclet.Serialized_Form_properties=\u76F4\u5217\u5316\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3
 doclet.Serialized_Form_class=\u76F4\u5217\u5316\u306E\u6982\u8981
 doclet.Class_0_implements_serializable=Class {0} implements Serializable
 doclet.Class_0_extends_implements_serializable=Class {0} extends {1} implements Serializable
 doclet.Option_conflict=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u304C{1}\u3068\u77DB\u76FE\u3057\u307E\u3059
 doclet.Option_reuse=\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u518D\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0}
+doclet.Option_doclint_no_qualifiers=\u30A2\u30AF\u30BB\u30B9\u4FEE\u98FE\u5B50\u306F-Xdoclint\u306E\u5F15\u6570\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+doclet.Option_doclint_invalid_arg=-Xdoclint\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059
 doclet.exception_encountered= {0}\u3092\u691C\u51FA\n\t\u30D5\u30A1\u30A4\u30EB\u306E\u4F5C\u6210\u4E2D: {1}
 doclet.perform_copy_exception_encountered= \u30B3\u30D4\u30FC\u5B9F\u884C\u4E2D\u306B{0}\u3092\n\u691C\u51FA\u3057\u307E\u3057\u305F\u3002
 doclet.File_not_found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}
@@ -20,16 +21,15 @@ doclet.Copying_File_0_To_Dir_1=\u30D5\u30A1\u30A4\u30EB{0}\u3092\u30C7\u30A3\u30
 doclet.Copying_File_0_To_File_1=\u30D5\u30A1\u30A4\u30EB{0}\u3092\u30D5\u30A1\u30A4\u30EB{1}\u306B\u30B3\u30D4\u30FC\u4E2D...
 doclet.No_Public_Classes_To_Document=\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5316\u3059\u308Bpublic\u307E\u305F\u306Fprotected\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
 doclet.Unable_to_create_directory_0=\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093
-doclet.destination_directory_not_found_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
 doclet.destination_directory_not_directory_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u306F\u3042\u308A\u307E\u305B\u3093
 doclet.destination_directory_not_writable_0=\u8EE2\u9001\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u66F8\u8FBC\u307F\u53EF\u80FD\u3067\u306F\u3042\u308A\u307E\u305B\u3093
-doclet.Error_creating_tmp_file=\u30D7\u30E9\u30C3\u30C8\u30D5\u30A9\u30FC\u30E0\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u4F7F\u7528\u3057\u3066\u4E00\u6642\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3057\u3066\u3044\u308B\u3068\u304D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002
 doclet.Encoding_not_supported=\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093
 doclet.Building_Tree=\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u30AF\u30E9\u30B9\u306E\u968E\u5C64\u30C4\u30EA\u30FC\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059...
 doclet.Building_Index=\u5168\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u30AF\u30E9\u30B9\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059...
 doclet.Building_Index_For_All_Classes=\u5168\u30AF\u30E9\u30B9\u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059...
 doclet.sourcetab_warning=-sourcetab\u306E\u5F15\u6570\u306F0\u3088\u308A\u5927\u304D\u3044\u6574\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002
 doclet.Packages=\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.Profiles=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
 doclet.Other_Packages=\u305D\u306E\u4ED6\u306E\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.Notice_taglet_registered=\u767B\u9332\u3055\u308C\u305F\u30BF\u30B0\u30EC\u30C3\u30C8{0} ...
 doclet.Notice_taglet_unseen=\u6CE8\u610F: \u975E\u8868\u793A\u306E\u30AB\u30B9\u30BF\u30E0\u30FB\u30BF\u30B0: {0}
@@ -67,6 +67,7 @@ doclet.malformed_html_link_tag=<a> \u30BF\u30B0\u306E\u5F62\u5F0F\u304C\u4E0D\u6
 doclet.tag_misuse={0}\u30BF\u30B0\u306F{1}\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3002\u4F7F\u7528\u3067\u304D\u308B\u306E\u306F\u6B21\u306E\u30BF\u30A4\u30D7\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u306E\u307F\u3067\u3059: {2}\u3002
 doclet.javafx_tag_misuse=\u30BF\u30B0 at propertyGetter\u3001 at propertySetter\u304A\u3088\u3073 at propertyDescription\u306F\u3001JavaFX\u306E\u30D7\u30ED\u30D1\u30C6\u30A3getter\u3068setter\u306E\u307F\u3067\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
 doclet.Package_Summary=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6982\u8981
+doclet.Profile_Summary=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u30FB\u30B5\u30DE\u30EA\u30FC
 doclet.Interface_Summary=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u6982\u8981
 doclet.Annotation_Types_Summary=\u6CE8\u91C8\u578B\u306E\u6982\u8981
 doclet.Enum_Summary=\u5217\u6319\u578B\u306E\u6982\u8981
@@ -81,7 +82,6 @@ doclet.Property_Summary=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u6982\u8981
 doclet.Enum_Constant_Summary=\u5217\u6319\u578B\u5B9A\u6570\u306E\u6982\u8981
 doclet.Constructor_Summary=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u6982\u8981
 doclet.Method_Summary=\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981
-doclet.Factory_Method_Summary=static\u30D5\u30A1\u30AF\u30C8\u30EA\u30FB\u30E1\u30BD\u30C3\u30C9\u306E\u6982\u8981
 doclet.Interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.Enums=\u5217\u6319\u578B
 doclet.AnnotationTypes=\u6CE8\u91C8\u578B
@@ -90,20 +90,20 @@ doclet.Errors=\u30A8\u30E9\u30FC
 doclet.Classes=\u30AF\u30E9\u30B9
 doclet.Packages=\u30D1\u30C3\u30B1\u30FC\u30B8
 doclet.packages=\u30D1\u30C3\u30B1\u30FC\u30B8
+doclet.profiles=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB
 doclet.All_Classes=\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9
 doclet.All_Superinterfaces=\u3059\u3079\u3066\u306E\u30B9\u30FC\u30D1\u30FC\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9:
 doclet.All_Implemented_Interfaces=\u3059\u3079\u3066\u306E\u5B9F\u88C5\u3055\u308C\u305F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9:
 doclet.All_classes_and_interfaces=\u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9(\u975Estatic\u306E\u30CD\u30B9\u30C8\u3055\u308C\u305F\u578B\u3092\u9664\u304F)
 doclet.Package_class_and_interface_descriptions=\u30D1\u30C3\u30B1\u30FC\u30B8\u3001\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306E\u8AAC\u660E
-doclet.Members=\u30E1\u30F3\u30D0\u30FC
 doclet.Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.Class=\u30AF\u30E9\u30B9
 doclet.AnnotationType=\u6CE8\u91C8\u578B
 doclet.annotationtype=\u6CE8\u91C8\u578B
 doclet.annotationtypes=\u6CE8\u91C8\u578B
 doclet.Enum=\u5217\u6319\u578B
-doclet.enum=\u5217\u6319
-doclet.enums=\u5217\u6319
+doclet.enum=\u5217\u6319\u578B
+doclet.enums=\u5217\u6319\u578B
 doclet.interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.interfaces=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.class=\u30AF\u30E9\u30B9
@@ -114,10 +114,7 @@ doclet.errors=\u30A8\u30E9\u30FC
 doclet.Exception=\u4F8B\u5916
 doclet.exception=\u4F8B\u5916
 doclet.exceptions=\u4F8B\u5916
-doclet.extended_by=\u4E0A\u4F4D\u3092\u62E1\u5F35
-doclet.extends=extends
 doclet.Package_private=(package private)
-doclet.implements=implementsdoclet.Same_package_name_used=\u30D1\u30C3\u30B1\u30FC\u30B8\u540D\u5F62\u5F0F\u304C2\u56DE\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0}
 doclet.Nested_Classes_Interfaces_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9/\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.Nested_Classes_Interface_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9/\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
 doclet.Methods_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9
@@ -126,8 +123,6 @@ doclet.Fields_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3
 doclet.Fields_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30D5\u30A3\u30FC\u30EB\u30C9
 doclet.Properties_Inherited_From_Class=\u30AF\u30E9\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3
 doclet.Properties_Inherited_From_Interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u7D99\u627F\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3
-doclet.Serializable=\u76F4\u5217\u5316\u53EF\u80FD
-doclet.Externalizable=\u5916\u90E8\u5316\u53EF\u80FD
 doclet.Annotation_Type_Member_Detail=\u8981\u7D20\u306E\u8A73\u7D30
 doclet.Enum_Constant_Detail=\u5217\u6319\u578B\u5B9A\u6570\u306E\u8A73\u7D30
 doclet.Constants_Summary=\u5B9A\u6570\u30D5\u30A3\u30FC\u30EB\u30C9\u5024
@@ -135,8 +130,7 @@ doclet.Field_Detail=\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u8A73\u7D30
 doclet.Property_Detail=\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8A73\u7D30
 doclet.Method_Detail=\u30E1\u30BD\u30C3\u30C9\u306E\u8A73\u7D30
 doclet.Constructor_Detail=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u8A73\u7D30
-doclet.Deprecated=\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
-doclet.Deprecated_class=\u3053\u306E\u30AF\u30E9\u30B9\u306F\u63A8\u5968\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
+doclet.Deprecated=\u975E\u63A8\u5968\u3067\u3059\u3002
 doclet.Groupname_already_used=-group\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u304A\u3044\u3066\u3001\u3059\u3067\u306B\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059: {0}
 doclet.value_tag_invalid_reference={0}(@value\u30BF\u30B0\u306B\u3088\u308A\u53C2\u7167\u3055\u308C\u3066\u3044\u308B)\u306F\u4E0D\u660E\u306A\u53C2\u7167\u3067\u3059\u3002
 doclet.value_tag_invalid_constant=@value\u30BF\u30B0({0}\u3092\u53C2\u7167\u3057\u3066\u3044\u308B)\u306F\u5B9A\u6570\u5185\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
@@ -158,7 +152,7 @@ doclet.Annotation_Type_Optional_Members=\u4EFB\u610F\u8981\u7D20
 doclet.annotation_type_required_members=\u5FC5\u9808\u8981\u7D20
 doclet.Annotation_Type_Required_Members=\u5FC5\u9808\u8981\u7D20
 doclet.enum_constants=\u5217\u6319\u578B\u5B9A\u6570
-doclet.Enum_Constants=\u5217\u6319\u5B9A\u6570
+doclet.Enum_Constants=\u5217\u6319\u578B\u5B9A\u6570
 doclet.nested_classes=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9
 doclet.Nested_Classes=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9
 doclet.subclasses=\u30B5\u30D6\u30AF\u30E9\u30B9
@@ -182,4 +176,4 @@ doclet.0_and_1={0}\u3068{1}
 #Documentation for Enums
 doclet.enum_values_doc=\n\u3053\u306E\u5217\u6319\u578B\u306E\u5B9A\u6570\u3092\u542B\u3080\u914D\u5217\u3092\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B\u9806\u5E8F\u3067\u8FD4\u3057\u307E\u3059\u3002\n\u3053\u306E\u30E1\u30BD\u30C3\u30C9\u306F\u6B21\u306E\u3088\u3046\u306B\u3057\u3066\u5B9A\u6570\u3092\u53CD\u5FA9\u3059\u308B\u305F\u3081\u306B\n\u4F7F\u7528\u3067\u304D\u307E\u3059:\n<pre>\nfor({0} c: {0}.values())\n  System.out.println(c);\n</pre>\n at return\u3053\u306E\u5217\u6319\u5 [...]
 
-doclet.enum_valueof_doc=\n\u6307\u5B9A\u3057\u305F\u540D\u524D\u3092\u6301\u3064\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u8FD4\u3057\u307E\u3059\u3002\n\u6587\u5B57\u5217\u306F\u3001\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u5BA3\u8A00\u3059\u308B\u306E\u306B\u4F7F\u7528\u3057\u305F\u8B58\u5225\u5B50\u3068\u53B3\u5BC6\u306B\n\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n(\u4F59\u5206\u306A\u7A7A\u767D\u6587\u5 [...]
+doclet.enum_valueof_doc=\n\u6307\u5B9A\u3057\u305F\u540D\u524D\u3092\u6301\u3064\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u8FD4\u3057\u307E\u3059\u3002\n\u6587\u5B57\u5217\u306F\u3001\u3053\u306E\u578B\u306E\u5217\u6319\u578B\u5B9A\u6570\u3092\u5BA3\u8A00\u3059\u308B\u306E\u306B\u4F7F\u7528\u3057\u305F\u8B58\u5225\u5B50\u3068<i>\u6B63\u78BA\u306B</i>\n\u4E00\u81F4\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\n(\u4F59\u5206\u306A\u7A7A\u767D\u [...]
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
index 9371b26..6026824 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
@@ -6,12 +6,13 @@ doclet.Serializable_no_customization=\u672A\u58F0\u660E readObject \u6216 writeO
 doclet.Serialized_Form=\u5E8F\u5217\u5316\u8868\u683C
 doclet.Serialized_Form_methods=\u5E8F\u5217\u5316\u65B9\u6CD5
 doclet.Serialized_Form_fields=\u5E8F\u5217\u5316\u5B57\u6BB5
-doclet.Serialized_Form_properties=\u5E8F\u5217\u5316\u5C5E\u6027
 doclet.Serialized_Form_class=\u5E8F\u5217\u5316\u6982\u89C8
 doclet.Class_0_implements_serializable=\u7C7B{0}\u5B9E\u73B0\u53EF\u5E8F\u5217\u5316
 doclet.Class_0_extends_implements_serializable=\u7C7B{0}\u6269\u5C55{1}\u5B9E\u73B0\u53EF\u5E8F\u5217\u5316
 doclet.Option_conflict=\u9009\u9879{0}\u4E0E{1}\u51B2\u7A81
 doclet.Option_reuse=\u91CD\u590D\u4F7F\u7528\u7684\u9009\u9879: {0}
+doclet.Option_doclint_no_qualifiers=-Xdoclint \u53C2\u6570\u4E0D\u5141\u8BB8\u4F7F\u7528\u8BBF\u95EE\u9650\u5B9A\u7B26
+doclet.Option_doclint_invalid_arg=-Xdoclint \u9009\u9879\u7684\u53C2\u6570\u65E0\u6548
 doclet.exception_encountered= \u5C1D\u8BD5\u521B\u5EFA\u6587\u4EF6{1}\u65F6 \n\t\u9047\u5230{0}
 doclet.perform_copy_exception_encountered= \u6267\u884C\u590D\u5236\u65F6 \n\u9047\u5230{0}\u3002
 doclet.File_not_found=\u627E\u4E0D\u5230\u6587\u4EF6: {0}
@@ -20,16 +21,15 @@ doclet.Copying_File_0_To_Dir_1=\u6B63\u5728\u5C06\u6587\u4EF6{0}\u590D\u5236\u52
 doclet.Copying_File_0_To_File_1=\u6B63\u5728\u5C06\u6587\u4EF6{0}\u590D\u5236\u5230\u6587\u4EF6{1}...
 doclet.No_Public_Classes_To_Document=\u627E\u4E0D\u5230\u53EF\u4EE5\u6587\u6863\u5316\u7684\u516C\u5171\u6216\u53D7\u4FDD\u62A4\u7684\u7C7B\u3002
 doclet.Unable_to_create_directory_0=\u65E0\u6CD5\u521B\u5EFA\u76EE\u5F55 {0}
-doclet.destination_directory_not_found_0=\u627E\u4E0D\u5230\u76EE\u6807\u76EE\u5F55 {0}
 doclet.destination_directory_not_directory_0=\u76EE\u6807\u76EE\u5F55\u4E0D\u662F\u76EE\u5F55 {0}
 doclet.destination_directory_not_writable_0=\u76EE\u6807\u76EE\u5F55\u4E0D\u53EF\u5199\u5165 {0}
-doclet.Error_creating_tmp_file=\u4F7F\u7528\u9ED8\u8BA4\u5E73\u53F0\u7F16\u7801\u521B\u5EFA\u4E34\u65F6\u6587\u4EF6\u65F6\u51FA\u9519\u3002
 doclet.Encoding_not_supported=\u4E0D\u652F\u6301\u7F16\u7801: {0}
 doclet.Building_Tree=\u6B63\u5728\u6784\u5EFA\u6240\u6709\u7A0B\u5E8F\u5305\u548C\u7C7B\u7684\u6811...
 doclet.Building_Index=\u6B63\u5728\u6784\u5EFA\u6240\u6709\u7A0B\u5E8F\u5305\u548C\u7C7B\u7684\u7D22\u5F15...
 doclet.Building_Index_For_All_Classes=\u6B63\u5728\u6784\u5EFA\u6240\u6709\u7C7B\u7684\u7D22\u5F15...
 doclet.sourcetab_warning=-sourcetab \u7684\u53C2\u6570\u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6574\u6570\u3002
 doclet.Packages=\u7A0B\u5E8F\u5305
+doclet.Profiles=\u914D\u7F6E\u6587\u4EF6
 doclet.Other_Packages=\u5176\u4ED6\u7A0B\u5E8F\u5305
 doclet.Notice_taglet_registered=\u6CE8\u518C\u7684 Taglet {0}...
 doclet.Notice_taglet_unseen=\u6CE8: \u627E\u4E0D\u5230\u7684\u5B9A\u5236\u6807\u8BB0: {0}
@@ -67,6 +67,7 @@ doclet.malformed_html_link_tag=<a> \u6807\u8BB0\u683C\u5F0F\u9519\u8BEF: \n"{0}"
 doclet.tag_misuse=\u4E0D\u80FD\u5728{1}\u6587\u6863\u4E2D\u4F7F\u7528\u6807\u8BB0{0}\u3002\u53EA\u80FD\u5728\u4EE5\u4E0B\u7C7B\u578B\u7684\u6587\u6863\u4E2D\u4F7F\u7528\u8BE5\u6807\u8BB0: {2}\u3002
 doclet.javafx_tag_misuse=\u6807\u8BB0 @propertyGetter, @propertySetter \u548C @propertyDescription \u53EA\u80FD\u5728 JavaFX \u5C5E\u6027 getter \u548C setter \u4E2D\u4F7F\u7528\u3002
 doclet.Package_Summary=\u7A0B\u5E8F\u5305\u6982\u8981
+doclet.Profile_Summary=\u6982\u8981\u4FE1\u606F\u6982\u8981
 doclet.Interface_Summary=\u63A5\u53E3\u6982\u8981
 doclet.Annotation_Types_Summary=\u6CE8\u91CA\u7C7B\u578B\u6982\u8981
 doclet.Enum_Summary=\u679A\u4E3E\u6982\u8981
@@ -81,7 +82,6 @@ doclet.Property_Summary=\u5C5E\u6027\u6982\u8981
 doclet.Enum_Constant_Summary=\u679A\u4E3E\u5E38\u91CF\u6982\u8981
 doclet.Constructor_Summary=\u6784\u9020\u5668\u6982\u8981
 doclet.Method_Summary=\u65B9\u6CD5\u6982\u8981
-doclet.Factory_Method_Summary=\u9759\u6001\u5DE5\u5382\u65B9\u6CD5\u6982\u8981
 doclet.Interfaces=\u63A5\u53E3
 doclet.Enums=\u679A\u4E3E
 doclet.AnnotationTypes=\u6CE8\u91CA\u7C7B\u578B
@@ -90,12 +90,12 @@ doclet.Errors=\u9519\u8BEF
 doclet.Classes=\u7C7B
 doclet.Packages=\u7A0B\u5E8F\u5305
 doclet.packages=\u7A0B\u5E8F\u5305
+doclet.profiles=\u914D\u7F6E\u6587\u4EF6
 doclet.All_Classes=\u6240\u6709\u7C7B
 doclet.All_Superinterfaces=\u6240\u6709\u8D85\u7EA7\u63A5\u53E3:
 doclet.All_Implemented_Interfaces=\u6240\u6709\u5DF2\u5B9E\u73B0\u7684\u63A5\u53E3:
 doclet.All_classes_and_interfaces=\u6240\u6709\u7C7B\u548C\u63A5\u53E3 (\u9664\u4E86\u975E\u9759\u6001\u5D4C\u5957\u7C7B\u578B)
 doclet.Package_class_and_interface_descriptions=\u7A0B\u5E8F\u5305, \u7C7B\u548C\u63A5\u53E3\u8BF4\u660E
-doclet.Members=\u6210\u5458
 doclet.Interface=\u63A5\u53E3
 doclet.Class=\u7C7B
 doclet.AnnotationType=\u6CE8\u91CA\u7C7B\u578B
@@ -114,10 +114,7 @@ doclet.errors=\u9519\u8BEF
 doclet.Exception=\u5F02\u5E38\u9519\u8BEF
 doclet.exception=\u5F02\u5E38\u9519\u8BEF
 doclet.exceptions=\u5F02\u5E38\u9519\u8BEF
-doclet.extended_by=\u6269\u5C55\u8005
-doclet.extends=\u6269\u5C55
 doclet.Package_private=(\u4E13\u7528\u7A0B\u5E8F\u5305)
-doclet.implements=implementsdoclet.Same_package_name_used=\u7A0B\u5E8F\u5305\u540D\u79F0\u5F62\u5F0F\u4F7F\u7528\u4E86\u4E24\u6B21: {0}
 doclet.Nested_Classes_Interfaces_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u5D4C\u5957\u7C7B/\u63A5\u53E3
 doclet.Nested_Classes_Interface_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u5D4C\u5957\u7C7B/\u63A5\u53E3
 doclet.Methods_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u65B9\u6CD5
@@ -126,8 +123,6 @@ doclet.Fields_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u5B57\u6BB5
 doclet.Fields_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u5B57\u6BB5
 doclet.Properties_Inherited_From_Class=\u4ECE\u7C7B\u7EE7\u627F\u7684\u5C5E\u6027
 doclet.Properties_Inherited_From_Interface=\u4ECE\u63A5\u53E3\u7EE7\u627F\u7684\u5C5E\u6027
-doclet.Serializable=\u53EF\u5E8F\u5217\u5316
-doclet.Externalizable=\u53EF\u5916\u90E8\u5316
 doclet.Annotation_Type_Member_Detail=\u5143\u7D20\u8BE6\u7EC6\u8D44\u6599
 doclet.Enum_Constant_Detail=\u679A\u4E3E\u5E38\u91CF\u8BE6\u7EC6\u8D44\u6599
 doclet.Constants_Summary=\u5E38\u91CF\u5B57\u6BB5\u503C
@@ -136,7 +131,6 @@ doclet.Property_Detail=\u5C5E\u6027\u8BE6\u7EC6\u4FE1\u606F
 doclet.Method_Detail=\u65B9\u6CD5\u8BE6\u7EC6\u8D44\u6599
 doclet.Constructor_Detail=\u6784\u9020\u5668\u8BE6\u7EC6\u8D44\u6599
 doclet.Deprecated=\u5DF2\u8FC7\u65F6\u3002
-doclet.Deprecated_class=\u8BE5\u7C7B\u5DF2\u8FC7\u65F6\u3002
 doclet.Groupname_already_used=\u5728 -group \u9009\u9879\u4E2D, groupname \u5DF2\u4F7F\u7528: {0}
 doclet.value_tag_invalid_reference={0} (\u7531 @value \u6807\u8BB0\u5F15\u7528) \u4E3A\u672A\u77E5\u5F15\u7528\u3002
 doclet.value_tag_invalid_constant=@value \u6807\u8BB0 (\u5F15\u7528{0}) \u53EA\u80FD\u5728\u5E38\u91CF\u4E2D\u4F7F\u7528\u3002
@@ -180,6 +174,6 @@ doclet.Value=\u503C
 doclet.0_and_1={0}\u548C{1}
 
 #Documentation for Enums
-doclet.enum_values_doc=\n\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5E38\u91CF\u7684\u6570\u7EC4\u3002\u8BE5\u65B9\u6CD5\u53EF\u7528\u4E8E\u8FED\u4EE3\n\u5E38\u91CF, \u5982\u4E0B\u6240\u793A:\n<pre>\nfor ({0} c : {0}.values())\n    System.out.println(c);\n</pre>\n@\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5 [...]
+doclet.enum_values_doc=\n\u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u4E9B\u5E38\u91CF\u7684\u6570\u7EC4\u3002\u8BE5\u65B9\u6CD5\u53EF\u7528\u4E8E\u8FED\u4EE3\n\u5E38\u91CF, \u5982\u4E0B\u6240\u793A:\n<pre>\nfor ({0} c : {0}.values())\n    System.out.println(c);\n</pre>\n at return \u6309\u7167\u58F0\u660E\u8BE5\u679A\u4E3E\u7C7B\u578B\u7684\u5E38\u91CF\u7684\u987A\u5E8F, \u8FD4\u56DE\n\u5305\u542B\u8FD9\u [...]
 
-doclet.enum_valueof_doc=\n\u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u3002\n\u5B57\u7B26\u4E32\u5FC5\u987B\u4E0E\u7528\u4E8E\u58F0\u660E\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u7684\n\u6807\u8BC6\u7B26<i>\u5B8C\u5168</i>\u5339\u914D\u3002(\u4E0D\u5141\u8BB8\u6709\u591A\u4F59\n\u7684\u7A7A\u683C\u5B57\u7B26\u3002)\n\n at param name \u8981\u8FD4\u56DE\u7684\u679A\u4E3E\u5E38\u91CF\u7684\u540D\u79F0\u3002\n@\u8FD4\u56DE\u5E26 [...]
+doclet.enum_valueof_doc=\n\u8FD4\u56DE\u5E26\u6709\u6307\u5B9A\u540D\u79F0\u7684\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u3002\n\u5B57\u7B26\u4E32\u5FC5\u987B\u4E0E\u7528\u4E8E\u58F0\u660E\u8BE5\u7C7B\u578B\u7684\u679A\u4E3E\u5E38\u91CF\u7684\n\u6807\u8BC6\u7B26<i>\u5B8C\u5168</i>\u5339\u914D\u3002(\u4E0D\u5141\u8BB8\u6709\u591A\u4F59\n\u7684\u7A7A\u683C\u5B57\u7B26\u3002)\n\n at param name \u8981\u8FD4\u56DE\u7684\u679A\u4E3E\u5E38\u91CF\u7684\u540D\u79F0\u3002\n at return \u8FD4\u56D [...]
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js
new file mode 100644
index 0000000..b346356
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/script.js
@@ -0,0 +1,30 @@
+function show(type)
+{
+    count = 0;
+    for (var key in methods) {
+        var row = document.getElementById(key);
+        if ((methods[key] &  type) != 0) {
+            row.style.display = '';
+            row.className = (count++ % 2) ? rowColor : altColor;
+        }
+        else
+            row.style.display = 'none';
+    }
+    updateTabs(type);
+}
+
+function updateTabs(type)
+{
+    for (var value in tabs) {
+        var sNode = document.getElementById(tabs[value][0]);
+        var spanNode = sNode.firstChild;
+        if (value == type) {
+            sNode.className = activeTableTab;
+            spanNode.innerHTML = tabs[value][1];
+        }
+        else {
+            sNode.className = tableTab;
+            spanNode.innerHTML = "<a href=\"javascript:show("+ value + ");\">" + tabs[value][1] + "</a>";
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
index 0aeaa97..6634d8a 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
@@ -191,6 +191,9 @@ Page header and footer styles
     margin:10px;
     position:relative;
 }
+.indexHeader span{
+    margin-right:15px;
+}
 .indexHeader h1 {
     font-size:1.3em;
 }
@@ -368,6 +371,7 @@ Table styles
     overflow:hidden;
     padding:0px;
     margin:0px;
+    white-space:pre;
 }
 caption a:link, caption a:hover, caption a:active, caption a:visited {
     color:#FFFFFF;
@@ -381,6 +385,31 @@ caption a:link, caption a:hover, caption a:active, caption a:visited {
     background-image:url(resources/titlebar.gif);
     height:18px;
 }
+.contentContainer ul.blockList li.blockList caption span.activeTableTab span {
+    white-space:nowrap;
+    padding-top:8px;
+    padding-left:8px;
+    display:block;
+    float:left;
+    background-image:url(resources/activetitlebar.gif);
+    height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab span {
+    white-space:nowrap;
+    padding-top:8px;
+    padding-left:8px;
+    display:block;
+    float:left;
+    background-image:url(resources/titlebar.gif);
+    height:18px;
+}
+.contentContainer ul.blockList li.blockList caption span.tableTab, .contentContainer ul.blockList li.blockList caption span.activeTableTab {
+    padding-top:0px;
+    padding-left:0px;
+    background-image:none;
+    float:none;
+    display:inline;
+}
 .overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd {
     width:10px;
     background-image:url(resources/titlebar_end.gif);
@@ -389,6 +418,24 @@ caption a:link, caption a:hover, caption a:active, caption a:visited {
     position:relative;
     float:left;
 }
+.contentContainer ul.blockList li.blockList .activeTableTab .tabEnd {
+    width:10px;
+    margin-right:5px;
+    background-image:url(resources/activetitlebar_end.gif);
+    background-repeat:no-repeat;
+    background-position:top right;
+    position:relative;
+    float:left;
+}
+.contentContainer ul.blockList li.blockList .tableTab .tabEnd {
+    width:10px;
+    margin-right:5px;
+    background-image:url(resources/titlebar_end.gif);
+    background-repeat:no-repeat;
+    background-position:top right;
+    position:relative;
+    float:left;
+}
 ul.blockList ul.blockList li.blockList table {
     margin:0 0 12px 0px;
     width:100%;
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseExecutableMemberTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseExecutableMemberTaglet.java
index a3b53f3..ce15461 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseExecutableMemberTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseExecutableMemberTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -29,9 +29,10 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
  * An abstract class for that implements the {@link Taglet} interface
  * for tags in <code>ExecutableMembers</code>.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API.
+ *  <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.4
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseInlineTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseInlineTaglet.java
index 2dff841..24383b8 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseInlineTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseInlineTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -28,9 +28,10 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
 /**
  * An abstract inline taglet that outputs HTML.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java
index f28b859..e93c902 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BasePropertyTaglet.java
@@ -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,14 +26,16 @@
 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
  * serves as a base for JavaFX property getter and setter taglets.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 abstract class BasePropertyTaglet extends BaseTaglet {
@@ -58,15 +60,8 @@ public abstract class BasePropertyTaglet extends BaseTaglet {
      * @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));
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java
index c0c6bff..01ba3ec 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/BaseTaglet.java
@@ -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
@@ -25,15 +25,16 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An abstract class for that implements the {@link Taglet} interface.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -130,7 +131,7 @@ public abstract class BaseTaglet implements Taglet {
      * {@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 @@ public abstract class BaseTaglet implements Taglet {
      * {@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() + ".");
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java
index 444771b..5dc5001 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/CodeTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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 @@ 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;
 
 /**
  * An inline Taglet used to denote literal code fragments.
@@ -40,27 +40,32 @@ import com.sun.tools.doclets.Taglet;
  * displays as:
  * <blockquote>  The type {@code List<P>}  </blockquote>
  *
+ *  <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 Scott Seligman
  * @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);
+    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java
index b2035b3..258fe72 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DeprecatedTaglet.java
@@ -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
@@ -26,13 +26,15 @@
 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.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
@@ -47,7 +49,7 @@ public class DeprecatedTaglet extends BaseTaglet{
     /**
      * {@inheritDoc}
      */
-    public TagletOutput getTagletOutput(Doc holder, TagletWriter writer) {
+    public Content getTagletOutput(Doc holder, TagletWriter writer) {
         return writer.deprecatedTagOutput(holder);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java
index f895b67..1a64127 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/DocRootTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,15 +26,17 @@
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 
 /**
  * An inline Taglet representing {@docRoot}.  This taglet is
  * used to get the relative path to the document's root output
  * directory.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  * @author Doug Kramer
@@ -59,7 +61,7 @@ public class DocRootTaglet extends BaseInlineTaglet {
      * @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();
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java
deleted file mode 100644
index aa5a976..0000000
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ExpertTaglet.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2006, 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;
-
-import java.util.Map;
-import com.sun.tools.doclets.Taglet;
-import com.sun.javadoc.Tag;
-
-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>";
-
-    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();
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
index 554756b..357a083 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2005, 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.Configuration;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
@@ -33,9 +35,10 @@ import com.sun.tools.doclets.internal.toolkit.util.*;
  * be used with a method.  It is used to inherit documentation from overriden
  * and implemented methods.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -58,8 +61,8 @@ public class InheritDocTaglet extends BaseInlineTaglet {
 
     /**
      * 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;
@@ -67,8 +70,8 @@ public class InheritDocTaglet extends BaseInlineTaglet {
 
     /**
      * 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;
@@ -76,8 +79,8 @@ public class InheritDocTaglet extends BaseInlineTaglet {
 
     /**
      * 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;
@@ -85,54 +88,66 @@ public class InheritDocTaglet extends BaseInlineTaglet {
 
     /**
      * 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;
     }
 
     /**
      * Given a <code>MethodDoc</code> item, a <code>Tag</code> in the
-     * <code>MethodDoc</code> item and a String, replace all occurances
+     * <code>MethodDoc</code> item and a String, replace all occurrences
      * of @inheritDoc with documentation from it's superclass or superinterface.
      *
      * @param writer the writer that is writing the output.
-     * @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 : writer.configuration().tagletManager.getTaglet(holderTag.name());
+            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.
-                writer.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) {
-            writer.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;
     }
@@ -143,14 +158,14 @@ public class InheritDocTaglet extends BaseInlineTaglet {
      * 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);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritableTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritableTaglet.java
index 20a265d..89518e8 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritableTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritableTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,6 +31,11 @@ import com.sun.tools.doclets.internal.toolkit.util.DocFinder;
  * A taglet should implement this interface if it supports the inheritDoc
  * tag or is automatically inherited if it is missing.
  *
+ *  <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
  */
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java
index b8cfa6f..2691c2b 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LegacyTaglet.java
@@ -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,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
@@ -36,9 +38,10 @@ import com.sun.javadoc.*;
  * This taglet is able to wrap most most legacy taglets because
  * the standard doclet is the only known doclet to use legacy taglets.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
@@ -114,20 +117,20 @@ public class LegacyTaglet implements Taglet {
     /**
      * {@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;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java
index 7a465e3..8f3d6e6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/LiteralTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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;
 
 
 /**
@@ -38,64 +39,32 @@ import com.sun.tools.doclets.Taglet;
  * displays as:
  * <blockquote>  {@literal a<B>c}  </blockquote>
  *
+ *  <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 Scott Seligman
  * @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) {
-           StringBuffer buf = new StringBuffer();
-           for (int i = 0; i < text.length(); i++) {
-               char c = text.charAt(i);
-               switch (c) {
-                   case '<':
-                          buf.append("<");
-                          break;
-                   case '>':
-                          buf.append(">");
-                          break;
-                   case '&':
-                          buf.append("&");
-                          break;
-                   default:
-                          buf.append(c);
-               }
-           }
-           return buf.toString();
+    public Content getTagletOutput(Tag tag, TagletWriter writer) {
+        return writer.literalTagOutput(tag);
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java
index 449bc1f..557d89c 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, 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,16 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
+import java.util.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.util.*;
 
 /**
  * A taglet that represents the @param tag.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -99,14 +102,14 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
             }
         }
         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();
@@ -163,12 +166,12 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
      * @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 {
@@ -182,19 +185,19 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
      * Given an array of <code>ParamTag</code>s,return its string representation.
      * Try to inherit the param tags that are missing.
      *
-     * @param doc               the doc that holds the param tags.
+     * @param holder            the doc that holds the param tags.
      * @param writer            the TagletWriter that will write this tag.
      * @param formalParameters  The array of parmeters (from type or executable
      *                          member) to check.
      *
      * @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)
             );
@@ -202,7 +205,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
         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;
@@ -212,10 +215,10 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
      * 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++) {
@@ -229,7 +232,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
                         String.valueOf(i), ! isNonTypeParams));
                 if (inheritedDoc.inlineTags != null &&
                         inheritedDoc.inlineTags.length > 0) {
-                    result.appendOutput(
+                    result.addContent(
                         processParamTag(isNonTypeParams, writer,
                             (ParamTag) inheritedDoc.holderTag,
                             isNonTypeParams ?
@@ -255,16 +258,16 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
      *        been documented.
      * @param rankMap a {@link java.util.Map} which holds ordering
      *                    information about the parameters.
-     * @param nameMap a {@link java.util.Map} which holds a mapping
+     * @param rankMap a {@link java.util.Map} which holds a mapping
      *                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];
@@ -285,7 +288,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
                            "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);
             }
@@ -293,7 +296,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
         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.
@@ -305,16 +308,16 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet {
      * @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;
     }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java
index 9a93cf8..d41229e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertyGetterTaglet.java
@@ -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,9 +29,10 @@ package com.sun.tools.doclets.internal.toolkit.taglets;
  * A taglet that adds the initial line of documentation to the JavaFX
  * property getters.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 PropertyGetterTaglet extends BasePropertyTaglet {
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java
index a0ba02f..6da9af6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/PropertySetterTaglet.java
@@ -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,15 +25,14 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
-import com.sun.javadoc.*;
-
 /**
  * A taglet that adds the initial line of documentation to the JavaFX
  * property setters.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 PropertySetterTaglet extends BasePropertyTaglet {
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java
index f5e90c8..1e9e18f 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,15 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * A taglet that represents the @return tag.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -49,9 +51,9 @@ public class ReturnTaglet extends BaseExecutableMemberTaglet
      * {@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();
@@ -72,7 +74,7 @@ public class ReturnTaglet extends BaseExecutableMemberTaglet
     /**
      * {@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);
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java
index bca2707..de88897 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,15 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
+import com.sun.tools.doclets.internal.toolkit.util.*;
 
 /**
  * A taglet that represents the @see tag.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -48,9 +50,9 @@ public class SeeTaglet extends BaseTaglet implements InheritableTaglet {
      * {@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();
@@ -60,7 +62,7 @@ public class SeeTaglet extends BaseTaglet implements InheritableTaglet {
     /**
      * {@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 =
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java
index 3051503..e201eb6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SimpleTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,18 +26,21 @@
 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.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
  */
 
-public class SimpleTaglet extends BaseTaglet {
+public class SimpleTaglet extends BaseTaglet implements InheritableTaglet {
 
     /**
      * The marker in the location string for excluded tags.
@@ -198,17 +201,28 @@ public class SimpleTaglet extends BaseTaglet {
         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;
         }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java
index 1e2664a..e10e21a 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/Taglet.java
@@ -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 @@ public interface Taglet {
 
     /**
      * 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 @@ public interface Taglet {
      * @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();
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
index 7f0599d..b6af474 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
@@ -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,20 +25,24 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
-
 import java.io.*;
 import java.lang.reflect.*;
 import java.net.*;
 import java.util.*;
 
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.util.*;
+
 /**
  * Manages the<code>Taglet</code>s used by doclets.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -47,16 +51,16 @@ import java.util.*;
 public class TagletManager {
 
     /**
-     * The default seperator for the simple tag option.
+     * The default separator for the simple tag option.
      */
-    public static final char SIMPLE_TAGLET_OPT_SEPERATOR = ':';
+    public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
 
     /**
-     * The alternate seperator for simple tag options.  Use this
-     * with you want the default seperator to be in the name of the
+     * The alternate separator for simple tag options.  Use this
+     * when you want the default separator to be in the name of the
      * custom tag.
      */
-    public static final String ALT_SIMPLE_TAGLET_OPT_SEPERATOR = "-";
+    public static final String ALT_SIMPLE_TAGLET_OPT_SEPARATOR = "-";
 
     /**
      * The map of custom tags.
@@ -153,6 +157,12 @@ public class TagletManager {
     private boolean showauthor;
 
     /**
+     * True if we want to use JavaFX-related tags (@propertyGetter,
+     * @propertySetter, @propertyDescription, @defaultValue, @treatAsPrivate).
+     */
+    private boolean javafx;
+
+    /**
      * Construct a new <code>TagletManager</code>.
      * @param nosince true if we do not want to use @since tags.
      * @param showversion true if we want to use @version tags.
@@ -160,7 +170,8 @@ public class TagletManager {
      * @param message the message retriever to print warnings.
      */
     public TagletManager(boolean nosince, boolean showversion,
-                         boolean showauthor, MessageRetriever message){
+                         boolean showauthor, boolean javafx,
+                         MessageRetriever message) {
         overridenStandardTags = new HashSet<String>();
         potentiallyConflictingTags = new HashSet<String>();
         standardTags = new HashSet<String>();
@@ -170,8 +181,9 @@ public class TagletManager {
         this.nosince = nosince;
         this.showversion = showversion;
         this.showauthor = showauthor;
+        this.javafx = javafx;
         this.message = message;
-        initStandardTags();
+        initStandardTaglets();
         initStandardTagsLowercase();
     }
 
@@ -199,18 +211,24 @@ public class TagletManager {
      * @param classname  the name of the class representing the custom tag.
      * @param tagletPath  the path to the class representing the custom tag.
      */
-    public void addCustomTag(String classname, String tagletPath) {
+    public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
         try {
             Class<?> customTagClass = null;
             // construct class loader
             String cpString = null;   // make sure env.class.path defaults to dot
 
-            // do prepends to get correct ordering
-            cpString = appendPath(System.getProperty("env.class.path"), cpString);
-            cpString = appendPath(System.getProperty("java.class.path"), cpString);
-            cpString = appendPath(tagletPath, cpString);
-            URLClassLoader appClassLoader = new URLClassLoader(pathToURLs(cpString));
-            customTagClass = appClassLoader.loadClass(classname);
+            ClassLoader tagClassLoader;
+            if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.TAGLET_PATH)) {
+                tagClassLoader = fileManager.getClassLoader(DocumentationTool.Location.TAGLET_PATH);
+            } else {
+                // do prepends to get correct ordering
+                cpString = appendPath(System.getProperty("env.class.path"), cpString);
+                cpString = appendPath(System.getProperty("java.class.path"), cpString);
+                cpString = appendPath(tagletPath, cpString);
+                tagClassLoader = new URLClassLoader(pathToURLs(cpString));
+            }
+
+            customTagClass = tagClassLoader.loadClass(classname);
             Method meth = customTagClass.getMethod("register",
                                                    new Class<?>[] {java.util.Map.class});
             Object[] list = customTags.values().toArray();
@@ -252,51 +270,17 @@ public class TagletManager {
      * @param path the search path string
      * @return the resulting array of directory and JAR file URLs
      */
-    private static URL[] pathToURLs(String path) {
-        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
-        URL[] urls = new URL[st.countTokens()];
-        int count = 0;
-        while (st.hasMoreTokens()) {
-            URL url = fileToURL(new File(st.nextToken()));
-            if (url != null) {
-                urls[count++] = url;
+    private URL[] pathToURLs(String path) {
+        Set<URL> urls = new LinkedHashSet<URL>();
+        for (String s: path.split(File.pathSeparator)) {
+            if (s.isEmpty()) continue;
+            try {
+                urls.add(new File(s).getAbsoluteFile().toURI().toURL());
+            } catch (MalformedURLException e) {
+                message.error("doclet.MalformedURL", s);
             }
         }
-        if (urls.length != count) {
-            URL[] tmp = new URL[count];
-            System.arraycopy(urls, 0, tmp, 0, count);
-            urls = tmp;
-        }
-        return urls;
-    }
-
-    /**
-     * Returns the directory or JAR file URL corresponding to the specified
-     * local file name.
-     *
-     * @param file the File object
-     * @return the resulting directory or JAR file URL, or null if unknown
-     */
-    private static URL fileToURL(File file) {
-        String name;
-        try {
-            name = file.getCanonicalPath();
-        } catch (IOException e) {
-            name = file.getAbsolutePath();
-        }
-        name = name.replace(File.separatorChar, '/');
-        if (!name.startsWith("/")) {
-            name = "/" + name;
-        }
-        // If the file does not exist, then assume that it's a directory
-        if (!file.isFile()) {
-            name = name + "/";
-        }
-        try {
-            return new URL("file", "", name);
-        } catch (MalformedURLException e) {
-            throw new IllegalArgumentException("file");
-        }
+        return urls.toArray(new URL[urls.size()]);
     }
 
 
@@ -452,7 +436,7 @@ public class TagletManager {
             //This known tag is excluded.
             return;
         }
-        StringBuffer combined_locations = new StringBuffer();
+        StringBuilder combined_locations = new StringBuilder();
         for (int i = 0; i < locations.length; i++) {
             if (i > 0) {
                 combined_locations.append(", ");
@@ -469,9 +453,9 @@ public class TagletManager {
      * @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;
     }
@@ -482,9 +466,9 @@ public class TagletManager {
      * @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;
     }
@@ -495,9 +479,9 @@ public class TagletManager {
      * @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;
     }
@@ -508,9 +492,9 @@ public class TagletManager {
      * @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;
     }
@@ -521,9 +505,9 @@ public class TagletManager {
      * @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;
     }
@@ -532,19 +516,19 @@ public class TagletManager {
      * @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;
     }
@@ -555,9 +539,9 @@ public class TagletManager {
      * @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;
     }
@@ -568,9 +552,9 @@ public class TagletManager {
      * @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;
     }
@@ -581,9 +565,9 @@ public class TagletManager {
      * @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;
     }
@@ -591,7 +575,7 @@ public class TagletManager {
     /**
      * 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());
@@ -646,79 +630,72 @@ public class TagletManager {
     /**
      * Initialize standard Javadoc tags for ordering purposes.
      */
-    private void initStandardTags() {
+    private void initStandardTaglets() {
+        if (javafx) {
+            initJavaFXTaglets();
+        }
+
         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 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("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);
-        customTags.put((temp = new SimpleTaglet("treatAsPrivate", null ,
-                SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE)).getName(), temp);
-        customTags.put((temp = new LegacyTaglet(new ExpertTaglet())).getName(), temp);
-
-        //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("propertyGetter");
-        standardTags.add("propertySetter");
-        standardTags.add("propertyDescription");
-        standardTags.add("defaultValue");
-        standardTags.add("see");
+        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. 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");
-        standardTags.add("treatAsPrivate");
-        standardTags.add("expert");
+    }
+
+    /**
+     * Initialize JavaFX-related tags.
+     */
+    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));
+    }
+
+    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);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java
deleted file mode 100644
index e0dabc2..0000000
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletOutput.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- *
- * @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();
-}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
index f8a22e9..9f77cc8 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletWriter.java
@@ -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,13 +25,18 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
+import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import com.sun.javadoc.*;
 
 /**
  * The interface for the taglet writer.
  *
+ *  <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
  */
@@ -41,18 +46,30 @@ public abstract class TagletWriter {
     /**
      * True if we only want to write the first sentence.
      */
-    protected boolean isFirstSentence = false;
+    protected final boolean isFirstSentence;
+
+    protected TagletWriter(boolean isFirstSentence) {
+        this.isFirstSentence = isFirstSentence;
+    }
 
     /**
-     * @return an instance of the output object.
+     * @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.
@@ -60,7 +77,15 @@ public abstract class TagletWriter {
      * @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.
@@ -75,7 +100,7 @@ public abstract class TagletWriter {
      * @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.
@@ -84,16 +109,25 @@ public abstract class TagletWriter {
      * @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.
@@ -101,7 +135,7 @@ public abstract class TagletWriter {
      * @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.
@@ -109,7 +143,7 @@ public abstract class TagletWriter {
      * @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);
 
     /**
@@ -118,14 +152,14 @@ public abstract class TagletWriter {
      * @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.
@@ -133,7 +167,7 @@ public abstract class TagletWriter {
      * @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.
@@ -141,7 +175,7 @@ public abstract class TagletWriter {
      * @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.
@@ -152,7 +186,7 @@ public abstract class TagletWriter {
      *                    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);
 
     /**
@@ -166,10 +200,10 @@ public abstract class TagletWriter {
      * @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) {
@@ -194,7 +228,7 @@ public abstract class TagletWriter {
             }
             if (currentOutput != null) {
                 tagletManager.seenCustomTag(taglets[i].getName());
-                output.appendOutput(currentOutput);
+                output.addContent(currentOutput);
             }
         }
     }
@@ -208,16 +242,16 @@ public abstract class TagletWriter {
      * @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);
@@ -236,9 +270,9 @@ public abstract class TagletWriter {
      * @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
@@ -249,9 +283,9 @@ public abstract class TagletWriter {
      * @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
@@ -264,18 +298,13 @@ public abstract class TagletWriter {
      * @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();
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java
index d25618a..dfe1fbb 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, 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,16 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
+import java.util.*;
+
 import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.Content;
 import com.sun.tools.doclets.internal.toolkit.util.*;
-import java.util.*;
 
 /**
  * A taglet that represents the @throws tag.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -58,15 +61,15 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
                 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();
@@ -81,10 +84,10 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
     /**
      * 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 &&
@@ -93,9 +96,9 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
                 ! 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());
             }
         }
@@ -106,10 +109,10 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
      * 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++) {
@@ -123,7 +126,7 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
                 }
                 declaredExceptionTags.addAll(inheritedDoc.tagList);
             }
-            result.appendOutput(throwsTagsOutput(
+            result.addContent(throwsTagsOutput(
                 declaredExceptionTags.toArray(new ThrowsTag[] {}),
                 writer, alreadyDocumented, false));
         }
@@ -133,18 +136,18 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
     /**
      * {@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;
     }
@@ -158,11 +161,11 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
      * @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];
@@ -172,9 +175,9 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet
                     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());
             }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java
index e07bc15..f4d58c8 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ValueTaglet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,12 @@
 
 package com.sun.tools.doclets.internal.toolkit.taglets;
 
+import java.util.*;
+
 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.*;
-import java.util.*;
 
 /**
  * An inline Taglet representing the value tag. This tag should only be used with
@@ -39,9 +41,10 @@ import java.util.*;
  * is retrieved for the field that the inline tag appears on.  The name is specifed
  * in the following format:  [fully qualified class name]#[constant field name].
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -107,7 +110,7 @@ public class ValueTaglet extends BaseInlineTaglet {
      * @param config the current configuration of the doclet.
      * @param tag the value tag.
      * @param name the name of the field to search for.  The name should be in
-     * <qualified class name>#<field name> format. If the class name is omitted,
+     * {@code <qualified class name>#<field name>} format. If the class name is omitted,
      * it is assumed that the field is in the current class.
      *
      * @return the corresponding FieldDoc. If the name is null or empty string,
@@ -158,7 +161,7 @@ public class ValueTaglet extends BaseInlineTaglet {
     /**
      * {@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) {
@@ -167,7 +170,7 @@ public class ValueTaglet extends BaseInlineTaglet {
                 "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.
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java
index 529d4fc..9e83edf 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -36,9 +36,10 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
  * those classes so that we can retrieve all of the classes from a particular
  * package later.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.4
@@ -184,7 +185,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration;
       /**
        * Return all of the classes specified on the command-line that
        * belong to the given package.
-       * @param packageDoc the package to return the classes for.
+       * @param pkgDoc the package to return the classes for.
        */
       public ClassDoc[] allClasses(PackageDoc pkgDoc) {
           return pkgDoc.isIncluded() ?
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java
index 0d9efcf..5936339 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java
@@ -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
@@ -25,17 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * Build Class Hierarchy for all the Classes. This class builds the Class
  * Tree and the Interface Tree separately.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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>
  *
  * @see java.util.HashMap
  * @see java.util.List
@@ -131,12 +133,8 @@ public class ClassTree {
                 continue;
             }
 
-            if (classes[i].tags("treatAsPrivate").length > 0) {
-                continue;
-            }
-
-            if (Configuration.getJavafxJavadoc()
-                    && (classes[i].isPackagePrivate() || classes[i].isPrivate())) {
+            if (configuration.javafx
+                    && classes[i].tags("treatAsPrivate").length > 0) {
                 continue;
             }
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
index 017ed72..a7eb4f6 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,17 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.javadoc.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+
 /**
  * Map all class uses for a given class.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.2
  * @author Robert G. Field
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java
index d74c08e..5c88214 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -30,9 +30,10 @@ import com.sun.javadoc.*;
 /**
  * Find a commented method.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 CommentedMethodFinder extends MethodFinder {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java
index 5c64a8f..8f8a096 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.javadoc.*;
 import java.util.*;
+
+import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
 
 /**
  * Build list of all the deprecated packages, classes, constructors, fields and methods.
  *
+ *  <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 Atul M Dambalkar
  */
 public class DeprecatedAPIListBuilder {
@@ -145,7 +151,7 @@ public class DeprecatedAPIListBuilder {
     /**
      * Return the list of deprecated Doc objects of a given type.
      *
-     * @param the constant representing the type of list being returned.
+     * @param type the constant representing the type of list being returned.
      */
     public List<Doc> getList(int type) {
         return deprecatedLists.get(type);
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
deleted file mode 100644
index fd50d8f..0000000
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.internal.toolkit.util;
-
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
-import java.io.*;
-
-
-/**
- * Handle the directory creations and the path string generations.
- * All static - never instaniated.
- *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
- *
- * @since 1.2
- * @author Atul M Dambalkar
- */
-public class DirectoryManager {
-
-    /**
-     * The file separator string, "/", used in the formation of the URL path.
-     */
-    public static final String URL_FILE_SEPARATOR = "/";
-
-    /**
-     * Never instaniated.
-     */
-    private DirectoryManager() {
-    }
-
-    /**
-     * Given a PackageDoc, return its URL path string.
-     *
-     * @param pd PackageDoc
-     * @see #getPath(String)
-     */
-    public static String createPathString(PackageDoc pd) {
-        if (pd == null) {
-            return "";
-        }
-        return getPath(pd.name());
-    }
-
-    /**
-     * Given a ClassDoc, return its URL path string.
-     *
-     * @param cd ClassDoc
-     * @see #getPath(String)
-     */
-    public static String createPathString(ClassDoc cd) {
-        if (cd == null) {
-            return "";
-        }
-        PackageDoc pd = cd.containingPackage();
-        return (pd == null)? "": getPath(pd.name());
-    }
-
-    /**
-     * Given a PackageDoc, return the corresponding directory name
-     * with the platform-dependent file separator between subdirectory names.
-     * For example, if name of the package is "java.lang" , then it
-     * returns "java/lang" on Unix and "java\lang" on Windows.
-     * If name of the package contains no dot, then the value
-     * will be returned unchanged.  Because package names cannot
-     * end in a dot, the return value will never end with a slash.
-     * <p>
-     * Also see getPath for the URL separator version of this method
-     * that takes a string instead of a PackageDoc.
-     *
-     * @param  pd    the PackageDoc
-     * @return       the platform-dependent directory path for the package
-     */
-    public static String getDirectoryPath(PackageDoc pd) {
-        return pd == null || pd.name().length() == 0 ? "" : getDirectoryPath(pd.name());
-    }
-
-    /**
-     * Given a package name, return the corresponding directory name
-     * with the platform-dependent file separator between subdirectory names.
-     * For example, if name of the package is "java.lang" , then it
-     * returns "java/lang" on Unix and "java\lang" on Windows.
-     * If name of the package contains no dot, then the value
-     * will be returned unchanged.  Because package names cannot
-     * end in a dot, the return value will never end with a slash.
-     * <p>
-     * Also see getPath for the URL separator version of this method
-     * that takes a string instead of a PackageDoc.
-     *
-     * @param  packageName    the name of the package
-     * @return       the platform-dependent directory path for the package
-     */
-    public static String getDirectoryPath(String packageName) {
-        if (packageName == null || packageName.length() == 0) {
-            return "";
-        }
-        StringBuffer pathstr = new StringBuffer();
-        for (int i = 0; i < packageName.length(); i++) {
-            char ch = packageName.charAt(i);
-            if (ch == '.') {
-                pathstr.append(URL_FILE_SEPARATOR);
-            } else {
-                pathstr.append(ch);
-            }
-        }
-        if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) {
-            pathstr.append(URL_FILE_SEPARATOR);
-        }
-        return pathstr.toString();
-    }
-
-    /**
-     * Given a package name (a string), return the path string,
-     * with the URL separator "/" separating the subdirectory names.
-     * If name of the package contains no dot, then the value
-     * will be returned unchanged.  Because package names cannot
-     * end in a dot, the return value will never end with a slash.
-     * <p>
-     * For example if the string is "com.sun.javadoc" then the URL
-     * path string will be "com/sun/javadoc".
-     *
-     * @param name   the package name as a String
-     * @return       the String URL path
-     */
-    public static String getPath(String name) {
-        if (name == null || name.length() == 0) {
-            return "";
-        }
-        StringBuffer pathstr = new StringBuffer();
-        for (int i = 0; i < name.length(); i++) {
-            char ch = name.charAt(i);
-            if (ch == '.') {
-                pathstr.append(URL_FILE_SEPARATOR);
-            } else {
-                pathstr.append(ch);
-            }
-        }
-        return pathstr.toString();
-    }
-
-    /**
-     * Given two package names as strings, return the relative path
-     * from the package directory corresponding to the first string
-     * to the package directory corresponding to the second string,
-     * with the URL file separator "/" separating subdirectory names.
-     * <p>
-     * For example, if the parameter "from" is "java.lang"
-     * and parameter "to" is "java.applet", return string
-     * "../../java/applet".
-     *
-     * @param from   the package name from which path is calculated
-     * @param to     the package name to which path is calculated
-     * @return       relative path between "from" and "to" with URL
-     *               separators
-     * @see          #getRelativePath(String)
-     * @see          #getPath(String)
-     */
-    public static String getRelativePath(String from, String to) {
-        StringBuffer pathstr = new StringBuffer();
-        pathstr.append(getRelativePath(from));
-        pathstr.append(getPath(to));
-        pathstr.append(URL_FILE_SEPARATOR);
-        return pathstr.toString();
-    }
-
-    /**
-     * Given a package name as a string, return relative path string
-     * from the corresponding package directory to the root of
-     * the documentation, using the URL separator "/" between
-     * subdirectory names.
-     * <p>
-     * For example, if the string "from" is "java.lang",
-     * return "../../"
-     *
-     * @param from    the package
-     * @return        String relative path from "from".
-     * @see           #getRelativePath(String, String)
-     */
-    public static String getRelativePath(PackageDoc from) {
-        return from == null || from.name().length() == 0 ? "" : getRelativePath(from.name());
-    }
-
-    /**
-     * Given a package name as a string, return relative path string
-     * from the corresponding package directory to the root of
-     * the documentation, using the URL separator "/" between
-     * subdirectory names.
-     * <p>
-     * For example, if the string "from" is "java.lang",
-     * return "../../"
-     *
-     * @param from    the package name
-     * @return        String relative path from "from".
-     * @see           #getRelativePath(String, String)
-     */
-    public static String getRelativePath(String from) {
-        if (from == null || from.length() == 0) {
-            return "";
-        }
-        StringBuffer pathstr = new StringBuffer();
-        for (int i = 0; i < from.length(); i++) {
-            char ch = from.charAt(i);
-            if (ch == '.') {
-                pathstr.append(".." + URL_FILE_SEPARATOR);
-            }
-        }
-        pathstr.append(".." + URL_FILE_SEPARATOR);
-        return pathstr.toString();
-    }
-
-    /**
-     * Given a relative or absolute path that might be empty,
-     * convert it to a path that does not end with a
-     * URL separator "/".  Used for converting
-     * HtmlStandardWriter.relativepath when replacing {@docRoot}.
-     *
-     * @param path   the path to convert.  An empty path represents
-     *               the current directory.
-     */
-    public static String getPathNoTrailingSlash(String path) {
-        if ( path.equals("") ) {
-            return ".";
-        }
-        if ( path.equals("/") ) {
-            return "/.";
-        }
-        if ( path.endsWith("/") ) {
-            // Remove trailing slash
-            path = path.substring(0, path.length() -1);
-        }
-        return path;
-    }
-
-    /**
-     * Given a path string create all the directories in the path. For example,
-     * if the path string is "java/applet", the method will create directory
-     * "java" and then "java/applet" if they don't exist. The file separator
-     * string "/" is platform dependent system property.
-     *
-     * @param path Directory path string.
-     */
-    public static void createDirectory(Configuration configuration,
-                                       String path) {
-        if (path == null || path.length() == 0) {
-            return;
-        }
-        File dir = new File(path);
-        if (dir.exists()) {
-            return;
-        } else {
-            if (dir.mkdirs()) {
-                return;
-            } else {
-                configuration.message.error(
-                       "doclet.Unable_to_create_directory_0", path);
-                throw new DocletAbortException();
-            }
-        }
-    }
-
-    /**
-     * Given a package name and a file name, return the full path to that file.
-     * For example, if PackageDoc passed is for "java.lang" and the filename
-     * passed is "package-summary.html", then the string returned is
-     * "java/lang/package-summary.html".
-     *
-     * @param pd         PackageDoc.
-     * @param filename   File name to be appended to the path of the package.
-     */
-    public static String getPathToPackage(PackageDoc pd, String filename) {
-        StringBuffer buf = new StringBuffer();
-        String pathstr = createPathString(pd);
-        if (pathstr.length() > 0) {
-            buf.append(pathstr);
-            buf.append(URL_FILE_SEPARATOR);
-        }
-        buf.append(filename);
-        return buf.toString();
-    }
-
-    /**
-     * Given a class name return the full path to the class file.
-     * For example, if ClassDoc passed is for "java.lang.Object" then the
-     * string returned is "java/lang/Object.html".
-     *
-     * @param cd   ClassDoc.
-     */
-    public static String getPathToClass(ClassDoc cd) {
-        return getPathToPackage(cd.containingPackage(), cd.name() + ".html");
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
new file mode 100644
index 0000000..f55d99a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFile.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Abstraction for handling files, which may be specified directly
+ * (e.g. via a path on the command line) or relative to a Location.
+ *
+ *  <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 8
+ */
+public abstract class DocFile {
+
+    /** Create a DocFile for a directory. */
+    public static DocFile createFileForDirectory(Configuration configuration, String file) {
+        return DocFileFactory.getFactory(configuration).createFileForDirectory(file);
+    }
+
+    /** Create a DocFile for a file that will be opened for reading. */
+    public static DocFile createFileForInput(Configuration configuration, String file) {
+        return DocFileFactory.getFactory(configuration).createFileForInput(file);
+    }
+
+    /** Create a DocFile for a file that will be opened for writing. */
+    public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
+        return DocFileFactory.getFactory(configuration).createFileForOutput(path);
+    }
+
+    private final Configuration configuration;
+
+    /**
+     * The location for this file. Maybe null if the file was created without
+     * a location or path.
+     */
+    protected final Location location;
+
+    /**
+     * The path relative to the (output) location. Maybe null if the file was
+     * created without a location or path.
+     */
+    protected final DocPath path;
+
+    /**
+     * List the directories and files found in subdirectories along the
+     * elements of the given location.
+     * @param configuration the doclet configuration
+     * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported.
+     * @param path the subdirectory of the directories of the location for which to
+     *  list files
+     */
+    public static Iterable<DocFile> list(Configuration configuration, Location location, DocPath path) {
+        return DocFileFactory.getFactory(configuration).list(location, path);
+    }
+
+    /** Create a DocFile without a location or path */
+    protected DocFile(Configuration configuration) {
+        this.configuration = configuration;
+        this.location = null;
+        this.path = null;
+    }
+
+    /** Create a DocFile for a given location and relative path. */
+    protected DocFile(Configuration configuration, Location location, DocPath path) {
+        this.configuration = configuration;
+        this.location = location;
+        this.path = path;
+    }
+
+    /** Open an input stream for the file. */
+    public abstract InputStream openInputStream() throws IOException;
+
+    /**
+     * Open an output stream for the file.
+     * The file must have been created with a location of
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT}
+     * and a corresponding relative path.
+     */
+    public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException;
+
+    /**
+     * Open an writer for the file, using the encoding (if any) given in the
+     * doclet configuration.
+     * The file must have been created with a location of
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+     */
+    public abstract Writer openWriter() throws IOException, UnsupportedEncodingException;
+
+    /**
+     * Copy the contents of another file directly to this file.
+     */
+    public void copyFile(DocFile fromFile) throws IOException {
+        InputStream input = fromFile.openInputStream();
+        OutputStream output = openOutputStream();
+        try {
+            byte[] bytearr = new byte[1024];
+            int len;
+            while ((len = input.read(bytearr)) != -1) {
+                output.write(bytearr, 0, len);
+            }
+        } catch (FileNotFoundException exc) {
+        } catch (SecurityException exc) {
+        } finally {
+            input.close();
+            output.close();
+        }
+    }
+
+    /**
+     * Copy the contents of a resource file to this file.
+     * @param resource the path of the resource, relative to the package of this class
+     * @param overwrite whether or not to overwrite the file if it already exists
+     * @param replaceNewLine if false, the file is copied as a binary file;
+     *     if true, the file is written line by line, using the platform line
+     *     separator
+     */
+    public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) {
+        if (exists() && !overwrite)
+            return;
+
+        try {
+            InputStream in = Configuration.class.getResourceAsStream(resource.getPath());
+            if (in == null)
+                return;
+
+            OutputStream out = openOutputStream();
+            try {
+                if (!replaceNewLine) {
+                    byte[] buf = new byte[2048];
+                    int n;
+                    while((n = in.read(buf))>0) out.write(buf,0,n);
+                } else {
+                    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+                    BufferedWriter writer;
+                    if (configuration.docencoding == null) {
+                        writer = new BufferedWriter(new OutputStreamWriter(out));
+                    } else {
+                        writer = new BufferedWriter(new OutputStreamWriter(out,
+                                configuration.docencoding));
+                    }
+                    try {
+                        String line;
+                        while ((line = reader.readLine()) != null) {
+                            writer.write(line);
+                            writer.write(DocletConstants.NL);
+                        }
+                    } finally {
+                        reader.close();
+                        writer.close();
+                    }
+                }
+            } finally {
+                in.close();
+                out.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace(System.err);
+            throw new DocletAbortException();
+        }
+    }
+
+    /** Return true if the file can be read. */
+    public abstract boolean canRead();
+
+    /** Return true if the file can be written. */
+    public abstract boolean canWrite();
+
+    /** Return true if the file exists. */
+    public abstract boolean exists();
+
+    /** Return the base name (last component) of the file name. */
+    public abstract String getName();
+
+    /** Return the file system path for this file. */
+    public abstract String getPath();
+
+    /** Return true if file has an absolute path name. */
+    public abstract boolean isAbsolute();
+
+    /** Return true if file identifies a directory. */
+    public abstract boolean isDirectory();
+
+    /** Return true if file identifies a file. */
+    public abstract boolean isFile();
+
+    /** Return true if this file is the same as another. */
+    public abstract boolean isSameFile(DocFile other);
+
+    /** If the file is a directory, list its contents. */
+    public abstract Iterable<DocFile> list() throws IOException;
+
+    /** Create the file as a directory, including any parent directories. */
+    public abstract boolean mkdirs();
+
+    /**
+     * Derive a new file by resolving a relative path against this file.
+     * The new file will inherit the configuration and location of this file
+     * If this file has a path set, the new file will have a corresponding
+     * new path.
+     */
+    public abstract DocFile resolve(DocPath p);
+
+    /**
+     * Derive a new file by resolving a relative path against this file.
+     * The new file will inherit the configuration and location of this file
+     * If this file has a path set, the new file will have a corresponding
+     * new path.
+     */
+    public abstract DocFile resolve(String p);
+
+    /**
+     * Resolve a relative file against the given output location.
+     * @param locn Currently, only
+     * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+     */
+    public abstract DocFile resolveAgainst(Location locn);
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java
new file mode 100644
index 0000000..57db795
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Factory for DocFile objects.
+ *
+ *  <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.8
+ */
+abstract class DocFileFactory {
+    private static final Map<Configuration, DocFileFactory> factories =
+            new WeakHashMap<Configuration, DocFileFactory>();
+
+    /**
+     * Get the appropriate factory, based on the file manager given in the
+     * configuration.
+     */
+    static synchronized DocFileFactory getFactory(Configuration configuration) {
+        DocFileFactory f = factories.get(configuration);
+        if (f == null) {
+            JavaFileManager fm = configuration.getFileManager();
+            if (fm instanceof StandardJavaFileManager)
+                f = new StandardDocFileFactory(configuration);
+            else {
+                try {
+                    Class<?> pathFileManagerClass =
+                            Class.forName("com.sun.tools.javac.nio.PathFileManager");
+                    if (pathFileManagerClass.isAssignableFrom(fm.getClass()))
+                        f = new PathDocFileFactory(configuration);
+                } catch (Throwable t) {
+                    throw new IllegalStateException(t);
+                }
+            }
+            factories.put(configuration, f);
+        }
+        return f;
+    }
+
+    protected Configuration configuration;
+
+    protected DocFileFactory(Configuration configuration) {
+        this.configuration = configuration;
+    }
+
+    /** Create a DocFile for a directory. */
+    abstract DocFile createFileForDirectory(String file);
+
+    /** Create a DocFile for a file that will be opened for reading. */
+    abstract DocFile createFileForInput(String file);
+
+    /** Create a DocFile for a file that will be opened for writing. */
+    abstract DocFile createFileForOutput(DocPath path);
+
+    /**
+     * List the directories and files found in subdirectories along the
+     * elements of the given location.
+     * @param location currently, only {@link StandardLocation#SOURCE_PATH} is supported.
+     * @param path the subdirectory of the directories of the location for which to
+     *  list files
+     */
+    abstract Iterable<DocFile> list(Location location, DocPath path);
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java
index b23e5db..d68b09d 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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,13 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
+import java.util.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import java.util.*;
 
 /**
  * Search for the requested documentation.  Inherit documentation if necessary.
  *
+ *  <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
  */
@@ -42,9 +48,9 @@ public class DocFinder {
      */
     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.
@@ -78,54 +84,55 @@ public class DocFinder {
          */
         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;
 
         }
@@ -158,8 +165,8 @@ public class DocFinder {
 
         /**
          * 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.
@@ -168,9 +175,9 @@ public class DocFinder {
     }
 
     /**
-     * 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.
@@ -180,14 +187,14 @@ public class DocFinder {
     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);
         }
@@ -198,25 +205,38 @@ public class DocFinder {
         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;
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocLink.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocLink.java
new file mode 100644
index 0000000..48ff3d4
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocLink.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Abstraction for simple relative URIs, consisting of a path,
+ * an optional query, and an optional fragment. DocLink objects can
+ * be created by the constructors below or from a DocPath using the
+ * convenience methods, {@link DocPath#fragment fragment} and
+ * {@link DocPath#query query}.
+ *
+ *  <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 DocLink {
+    final String path;
+    final String query;
+    final String fragment;
+
+    /** Create a DocLink representing the URI {@code #fragment}. */
+    public static DocLink fragment(String fragment) {
+        return new DocLink((String) null, (String) null, fragment);
+    }
+
+    /** Create a DocLink representing the URI {@code path}. */
+    public DocLink(DocPath path) {
+        this(path.getPath(), null, null);
+    }
+
+    /**
+     * Create a DocLink representing the URI {@code path?query#fragment}.
+     * query and fragment may be null.
+     */
+    public DocLink(DocPath path, String query, String fragment) {
+        this(path.getPath(), query, fragment);
+    }
+
+    /**
+     * Create a DocLink representing the URI {@code path?query#fragment}.
+     * Any of the component parts may be null.
+     */
+    public DocLink(String path, String query, String fragment) {
+        this.path = path;
+        this.query = query;
+        this.fragment = fragment;
+    }
+
+    /**
+     * Return the link in the form "path?query#fragment", omitting any empty
+     * components.
+     */
+    @Override
+    public String toString() {
+        // common fast path
+        if (path != null && isEmpty(query) && isEmpty(fragment))
+            return path;
+
+        StringBuilder sb = new StringBuilder();
+        if (path != null)
+            sb.append(path);
+        if (!isEmpty(query))
+            sb.append("?").append(query);
+        if (!isEmpty(fragment))
+            sb.append("#").append(fragment);
+        return sb.toString();
+    }
+
+    private static boolean isEmpty(String s) {
+        return (s == null) || s.isEmpty();
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
new file mode 100644
index 0000000..055d449
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPath.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.PackageDoc;
+
+/**
+ * Abstraction for immutable relative paths.
+ * Paths always use '/' as a separator, and never begin or end with '/'.
+ *
+ *  <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 DocPath {
+    private final String path;
+
+    /** The empty path. */
+    public static final DocPath empty = new DocPath("");
+
+    /** The empty path. */
+    public static final DocPath parent = new DocPath("..");
+
+    /**
+     * Create a path from a string.
+     */
+    public static DocPath create(String p) {
+        return (p == null) || p.isEmpty() ? empty : new DocPath(p);
+    }
+
+    /**
+     * Return the path for a class.
+     * For example, if the class is java.lang.Object,
+     * the path is java/lang/Object.html.
+     */
+    public static DocPath forClass(ClassDoc cd) {
+        return (cd == null) ? empty :
+                forPackage(cd.containingPackage()).resolve(forName(cd));
+    }
+
+    /**
+     * Return the path for the simple name of the class.
+     * For example, if the class is java.lang.Object,
+     * the path is Object.html.
+     */
+    public static DocPath forName(ClassDoc cd) {
+        return (cd == null) ? empty : new DocPath(cd.name() + ".html");
+    }
+
+    /**
+     * Return the path for the package of a class.
+     * For example, if the class is java.lang.Object,
+     * the path is java/lang.
+     */
+    public static DocPath forPackage(ClassDoc cd) {
+        return (cd == null) ? empty : forPackage(cd.containingPackage());
+    }
+
+    /**
+     * Return the path for a package.
+     * For example, if the package is java.lang,
+     * the path is java/lang.
+     */
+    public static DocPath forPackage(PackageDoc pd) {
+        return (pd == null) ? empty : DocPath.create(pd.name().replace('.', '/'));
+    }
+
+    /**
+     * Return the inverse path for a package.
+     * For example, if the package is java.lang,
+     * the inverse path is ../...
+     */
+    public static DocPath forRoot(PackageDoc pd) {
+        String name = (pd == null) ? "" : pd.name();
+        if (name.isEmpty())
+            return empty;
+        return new DocPath(name.replace('.', '/').replaceAll("[^/]+", ".."));
+    }
+
+    /**
+     * Return the relative path from one package to another.
+     */
+    public static DocPath relativePath(PackageDoc from, PackageDoc to) {
+        return forRoot(from).resolve(forPackage(to));
+    }
+
+    protected DocPath(String p) {
+        path = (p.endsWith("/") ? p.substring(0, p.length() - 1) : p);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean equals(Object other) {
+        return (other instanceof DocPath) && path.equals(((DocPath)other).path);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int hashCode() {
+        return path.hashCode();
+    }
+
+    public DocPath basename() {
+        int sep = path.lastIndexOf("/");
+        return (sep == -1) ? this : new DocPath(path.substring(sep + 1));
+    }
+
+    public DocPath parent() {
+        int sep = path.lastIndexOf("/");
+        return (sep == -1) ? empty : new DocPath(path.substring(0, sep));
+    }
+
+    /**
+     * Return the path formed by appending the specified string to the current path.
+     */
+    public DocPath resolve(String p) {
+        if (p == null || p.isEmpty())
+            return this;
+        if (path.isEmpty())
+            return new DocPath(p);
+        return new DocPath(path + "/" + p);
+    }
+
+    /**
+     * Return the path by appending the specified path to the current path.
+     */
+    public DocPath resolve(DocPath p) {
+        if (p == null || p.isEmpty())
+            return this;
+        if (path.isEmpty())
+            return p;
+        return new DocPath(path + "/" + p.getPath());
+    }
+
+    /**
+     * Return the inverse path for this path.
+     * For example, if the path is a/b/c, the inverse path is ../../..
+     */
+    public DocPath invert() {
+        return new DocPath(path.replaceAll("[^/]+", ".."));
+    }
+
+    /**
+     * Return true if this path is empty.
+     */
+    public boolean isEmpty() {
+        return path.isEmpty();
+    }
+
+    public DocLink fragment(String fragment) {
+        return new DocLink(path, null, fragment);
+    }
+
+    public DocLink query(String query) {
+        return new DocLink(path, query, null);
+    }
+
+    /**
+     * Return this path as a string.
+     */
+    // This is provided instead of using toString() to help catch
+    // unintended use of toString() in string concatenation sequences.
+    public String getPath() {
+        return path;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
new file mode 100644
index 0000000..563f9b5
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocPaths.java
@@ -0,0 +1,141 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Standard DocPath objects.
+ *
+ *  <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 8
+ */
+public class DocPaths {
+
+    /** The name of the file for all classes, using frames. */
+    public static final DocPath ALLCLASSES_FRAME = DocPath.create("allclasses-frame.html");
+
+    /** The name of the file for all classes, without using frames. */
+    public static final DocPath ALLCLASSES_NOFRAME = DocPath.create("allclasses-noframe.html");
+
+    /** The name of the sub-directory for storing class usage info. */
+    public static final DocPath CLASS_USE = DocPath.create("class-use");
+
+    /** The name of the file for constant values. */
+    public static final DocPath CONSTANT_VALUES = DocPath.create("constant-values.html");
+
+    /** The name of the fie for deprecated elements. */
+    public static final DocPath DEPRECATED_LIST = DocPath.create("deprecated-list.html");
+
+    /** The name of the subdirectory for user-provided additional documentation files. */
+    public static final DocPath DOC_FILES = DocPath.create("doc-files");
+
+    /** The name of the file for help info. */
+    public static final DocPath HELP_DOC = DocPath.create("help-doc.html");
+
+    /** The name of the main index file. */
+    public static final DocPath INDEX = DocPath.create("index.html");
+
+    /** The name of the single index file for all classes. */
+    public static final DocPath INDEX_ALL = DocPath.create("index-all.html");
+
+    /** The name of the directory for the split index files. */
+    public static final DocPath INDEX_FILES = DocPath.create("index-files");
+
+    /** Generate the name of one of the files in the split index. */
+    public static final DocPath indexN(int n) {
+        return DocPath.create("index-" + n + ".html");
+    }
+
+    /** The name of the default javascript file. */
+    public static final DocPath JAVASCRIPT = DocPath.create("script.js");
+
+    /** The name of the file for the overview frame. */
+    public static final DocPath OVERVIEW_FRAME = DocPath.create("overview-frame.html");
+
+    /** The name of the file for the overview summary. */
+    public static final DocPath OVERVIEW_SUMMARY = DocPath.create("overview-summary.html");
+
+    /** The name of the file for the overview tree. */
+    public static final DocPath OVERVIEW_TREE = DocPath.create("overview-tree.html");
+
+    /** The name of the file for the package frame. */
+    public static final DocPath PACKAGE_FRAME = DocPath.create("package-frame.html");
+
+    /** The name of the file for the profile frame. */
+     public static final DocPath profileFrame(String profileName) {
+        return DocPath.create(profileName + "-frame.html");
+    }
+
+    /** The name of the file for the profile package frame. */
+     public static final DocPath profilePackageFrame(String profileName) {
+        return DocPath.create(profileName + "-package-frame.html");
+    }
+
+    /** The name of the file for the profile package summary. */
+     public static final DocPath profilePackageSummary(String profileName) {
+        return DocPath.create(profileName + "-package-summary.html");
+    }
+
+    /** The name of the file for the profile summary. */
+     public static final DocPath profileSummary(String profileName) {
+        return DocPath.create(profileName + "-summary.html");
+    }
+
+    /** The name of the file for the package list. */
+    public static final DocPath PACKAGE_LIST = DocPath.create("package-list");
+
+    /** The name of the file for the package summary. */
+    public static final DocPath PACKAGE_SUMMARY = DocPath.create("package-summary.html");
+
+    /** The name of the file for the package tree. */
+    public static final DocPath PACKAGE_TREE = DocPath.create("package-tree.html");
+
+    /** The name of the file for the package usage info. */
+    public static final DocPath PACKAGE_USE = DocPath.create("package-use.html");
+
+    /** The name of the file for the overview frame. */
+    public static final DocPath PROFILE_OVERVIEW_FRAME = DocPath.create("profile-overview-frame.html");
+
+    /** The name of the directory in which resources are generated.
+     *  Also the name of the sub-package from which resources are read.
+     */
+    public static final DocPath RESOURCES = DocPath.create("resources");
+
+    /** The name of the file for the serialized form info. */
+    public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
+
+    /** The name of the directory in which HTML versions of the source code
+     *  are generated.
+     */
+    public static final DocPath SOURCE_OUTPUT = DocPath.create("src-html");
+
+    /** The name of the default stylesheet. */
+    public static final DocPath STYLESHEET = DocPath.create("stylesheet.css");
+
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java
index c93d5bc..6261cae 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletAbortException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -25,6 +25,12 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
+/**
+ *  <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 DocletAbortException extends RuntimeException {
     private static final long serialVersionUID = -9131058909576418984L;
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
index f962080..c76b2ed 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocletConstants.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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,9 +29,10 @@ package com.sun.tools.doclets.internal.toolkit.util;
  * Stores all constants for a Doclet.  Extend this class if you have doclet
  * specific constants to add.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
@@ -39,47 +40,27 @@ package com.sun.tools.doclets.internal.toolkit.util;
 public class DocletConstants {
 
     /**
-     * The default package name.
-     */
-    public static final String DEFAULT_PACKAGE_NAME = "<Unnamed>";
-
-    /**
-     * The default package file name.
-     */
-    public static final String DEFAULT_PACKAGE_FILE_NAME = "default";
-
-    /**
-     * The anchor for the default package.
-     */
-    public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package";
-
-    /**
-     * The name of the doc files directory.
-     */
-    public static final String DOC_FILES_DIR_NAME = "doc-files";
-
-    /**
      * The default amount of space between tab stops.
      */
     public static final int DEFAULT_TAB_STOP_LENGTH = 8;
 
     /**
-     * The name of the directory where we will copy resource files to.
+     * The line separator for the current operating system.
      */
-    public static final String RESOURE_DIR_NAME = "resources";
+    public static final String NL = System.getProperty("line.separator");
 
     /**
-     * The source output directory name
+     * The default package name.
      */
-    public static final String SOURCE_OUTPUT_DIR_NAME = "src-html/";
+    public static final String DEFAULT_PACKAGE_NAME = "<Unnamed>";
 
     /**
-     * The name of the package list file.
+     * The default package file name.
      */
-    public static final String PACKAGE_LIST_FILE_NAME = "package-list";
+    public static final String DEFAULT_PACKAGE_FILE_NAME = "default";
 
     /**
-     * The line seperator for the current operating system.
+     * The anchor for the default package.
      */
-    public static final String NL = System.getProperty("line.separator");
+    public static final String UNNAMED_PACKAGE_ANCHOR = "unnamed_package";
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
index 32a4a0d..0306f7b 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,15 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-
-import com.sun.javadoc.*;
-import java.util.Map;
-import java.util.HashMap;
 import java.io.*;
 import java.net.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.tools.DocumentationTool;
+
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
 
 /**
  * Process and manage "-link" and "-linkoffline" to external packages. The
@@ -40,9 +42,10 @@ import java.net.*;
  * documented) file in the current or the destination directory, while
  * generating the documentation.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  * @author Robert Field
@@ -91,7 +94,7 @@ public class Extern {
          * If the same package name is found in the map, then the first mapped
          * Item object or offline location will be retained.
          *
-         * @param packagename Package name found in the "package-list" file.
+         * @param packageName Package name found in the "package-list" file.
          * @param path        URL or Directory path from where the "package-list"
          * file is picked.
          * @param relative    True if path is URL, false if directory path.
@@ -137,21 +140,25 @@ public class Extern {
      *
      * @param pkgName The package name.
      * @param relativepath    The relative path.
-     * @param link    The link to convert.
+     * @param filename    The link to convert.
      * @return if external return converted link else return null
      */
-    public String getExternalLink(String pkgName,
-                                  String relativepath, String link) {
+    public DocLink getExternalLink(String pkgName,
+                                  DocPath relativepath, String filename) {
+        return getExternalLink(pkgName, relativepath, filename, null);
+    }
+
+    public DocLink getExternalLink(String pkgName,
+                                  DocPath relativepath, String filename, String memberName) {
         Item fnd = findPackageItem(pkgName);
-        if (fnd != null) {
-            String externlink = fnd.path + link;
-            if (fnd.relative) {  // it's a relative path.
-                return relativepath + externlink;
-            } else {
-                return externlink;
-            }
-        }
-        return null;
+        if (fnd == null)
+            return null;
+
+        DocPath p = fnd.relative ?
+                relativepath.resolve(fnd.path).resolve(filename) :
+                DocPath.create(fnd.path).resolve(filename);
+
+        return new DocLink(p, "is-external=true", memberName);
     }
 
     /**
@@ -162,24 +169,45 @@ public class Extern {
      * @param pkglisturl This can be another URL for "package-list" or ordinary
      *                   file.
      * @param reporter   The <code>DocErrorReporter</code> used to report errors.
-     * @param linkoffline True if -linkoffline isused and false if -link is used.
+     * @param linkoffline True if -linkoffline is used and false if -link is used.
      */
-    public boolean url(String url, String pkglisturl,
+    public boolean link(String url, String pkglisturl,
                               DocErrorReporter reporter, boolean linkoffline) {
         this.linkoffline = linkoffline;
-        String errMsg = composeExternPackageList(url, pkglisturl);
-        if (errMsg != null) {
-            reporter.printWarning(errMsg);
-            return false;
-        } else {
+        try {
+            url = adjustEndFileSeparator(url);
+            if (isUrl(pkglisturl)) {
+                readPackageListFromURL(url, toURL(pkglisturl));
+            } else {
+                readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl));
+            }
             return true;
+        } catch (Fault f) {
+            reporter.printWarning(f.getMessage());
+            return false;
+        }
+    }
+
+    private URL toURL(String url) throws Fault {
+        try {
+            return new URL(url);
+        } catch (MalformedURLException e) {
+            throw new Fault(configuration.getText("doclet.MalformedURL", url), e);
+        }
+    }
+
+    private class Fault extends Exception {
+        private static final long serialVersionUID = 0;
+
+        Fault(String msg, Exception cause) {
+            super(msg, cause);
         }
     }
 
     /**
      * Get the Extern Item object associated with this package name.
      *
-     * @param pkgname Package name.
+     * @param pkgName Package name.
      */
     private Item findPackageItem(String pkgName) {
         if (packageToItemMap == null) {
@@ -189,31 +217,10 @@ public class Extern {
     }
 
     /**
-     * Adjusts the end file separator if it is missing from the URL or the
-     * directory path and depending upon the URL or file path, fetch or
-     * read the "package-list" file.
-     *
-     * @param urlOrDirPath        URL or the directory path.
-     * @param pkgListUrlOrDirPath URL or directory path for the "package-list" file or the "package-list"
-     * file itself.
-     */
-    private String composeExternPackageList(String urlOrDirPath, String pkgListUrlOrDirPath) {
-        urlOrDirPath = adjustEndFileSeparator(urlOrDirPath);
-        pkgListUrlOrDirPath = adjustEndFileSeparator(pkgListUrlOrDirPath);
-        return isUrl(pkgListUrlOrDirPath) ?
-            fetchURLComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath) :
-            readFileComposeExternPackageList(urlOrDirPath, pkgListUrlOrDirPath);
-    }
-
-    /**
      * If the URL or Directory path is missing end file separator, add that.
      */
     private String adjustEndFileSeparator(String url) {
-        String filesep = "/";
-        if (!url.endsWith(filesep)) {
-            url += filesep;
-        }
-        return url;
+        return url.endsWith("/") ? url : url + '/';
     }
 
     /**
@@ -222,17 +229,18 @@ public class Extern {
      * @param urlpath        Path to the packages.
      * @param pkglisturlpath URL or the path to the "package-list" file.
      */
-    private String fetchURLComposeExternPackageList(String urlpath,
-                                                   String pkglisturlpath) {
-        String link = pkglisturlpath + "package-list";
+    private void readPackageListFromURL(String urlpath, URL pkglisturlpath)
+            throws Fault {
         try {
-            readPackageList((new URL(link)).openStream(), urlpath, false);
+            URL link = pkglisturlpath.toURI().resolve(DocPaths.PACKAGE_LIST.getPath()).toURL();
+            readPackageList(link.openStream(), urlpath, false);
+        } catch (URISyntaxException exc) {
+            throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc);
         } catch (MalformedURLException exc) {
-            return configuration.getText("doclet.MalformedURL", link);
+            throw new Fault(configuration.getText("doclet.MalformedURL", pkglisturlpath.toString()), exc);
         } catch (IOException exc) {
-            return configuration.getText("doclet.URL_error", link);
+            throw new Fault(configuration.getText("doclet.URL_error", pkglisturlpath.toString()), exc);
         }
-        return null;
     }
 
     /**
@@ -241,27 +249,24 @@ public class Extern {
      * @param path URL or directory path to the packages.
      * @param pkgListPath Path to the local "package-list" file.
      */
-    private String readFileComposeExternPackageList(String path,
-                                                   String pkgListPath) {
-
-        String link = pkgListPath + "package-list";
-        if (! ((new File(pkgListPath)).isAbsolute() || linkoffline)){
-            link = configuration.destDirName + link;
+    private void readPackageListFromFile(String path, DocFile pkgListPath)
+            throws Fault {
+        DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
+        if (! (file.isAbsolute() || linkoffline)){
+            file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
         }
         try {
-            File file = new File(link);
             if (file.exists() && file.canRead()) {
-                readPackageList(new FileInputStream(file), path,
-                    ! ((new File(path)).isAbsolute() || isUrl(path)));
+                boolean pathIsRelative =
+                        !DocFile.createFileForInput(configuration, path).isAbsolute()
+                        && !isUrl(path);
+                readPackageList(file.openInputStream(), path, pathIsRelative);
             } else {
-                return configuration.getText("doclet.File_error", link);
+                throw new Fault(configuration.getText("doclet.File_error", file.getPath()), null);
             }
-        } catch (FileNotFoundException exc) {
-            return configuration.getText("doclet.File_error", link);
         } catch (IOException exc) {
-            return configuration.getText("doclet.File_error", link);
+           throw new Fault(configuration.getText("doclet.File_error", file.getPath()), exc);
         }
-        return null;
     }
 
     /**
@@ -276,7 +281,7 @@ public class Extern {
                                 boolean relative)
                          throws IOException {
         BufferedReader in = new BufferedReader(new InputStreamReader(input));
-        StringBuffer strbuf = new StringBuffer();
+        StringBuilder strbuf = new StringBuilder();
         try {
             int c;
             while ((c = in.read()) >= 0) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java
index 5893f30..be5284e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Group.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,11 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * Process and manage grouping of packages, as specified by "-group" option on
  * the command line.
@@ -48,9 +49,10 @@ import java.util.*;
  * will put the package java.lang in the group "Lang" and not in group "Core".
  * </p>
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  */
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java
index 3783442..c2bfc13 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -25,17 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
+import java.util.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
-import java.util.*;
 
 /**
  * For a given class method, build an array of interface methods which it
  * implements.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  */
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java
index c066b03..8976b55 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java
@@ -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
@@ -25,19 +25,21 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * Build the mapping of each Unicode character with it's member lists
  * containing members names starting with it. Also build a list for all the
  * Unicode characters which start a member name. Member name is
  * classkind or field or method or constructor name.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.2
  * @see java.lang.Character
@@ -61,6 +63,11 @@ public class IndexBuilder {
      */
     private boolean classesOnly;
 
+    /**
+     * Indicates javafx mode.
+     */
+    private boolean javafx;
+
     // make ProgramElementDoc[] when new toArray is available
     protected final Object[] elements;
 
@@ -113,6 +120,7 @@ public class IndexBuilder {
         }
         this.noDeprecated = noDeprecated;
         this.classesOnly = classesOnly;
+        this.javafx = configuration.javafx;
         buildIndexMap(configuration.root);
         Set<Character> set = indexmap.keySet();
         elements =  set.toArray();
@@ -207,23 +215,10 @@ public class IndexBuilder {
      * Should this doc element be added to the index map?
      */
     protected boolean shouldAddToIndexMap(Doc element) {
-        if (Configuration.getJavafxJavadoc()) {
+        if (javafx) {
             if (element.tags("treatAsPrivate").length > 0) {
                 return false;
             }
-            if (element instanceof ProgramElementDoc) {
-                ProgramElementDoc elementCasted = (ProgramElementDoc) element;
-                if (elementCasted.isPackagePrivate() || elementCasted.isPrivate()) {
-                    return false;
-                }
-            }
-
-            if (element instanceof ClassDoc) {
-                ClassDoc elementCasted = (ClassDoc) element;
-                if (elementCasted.isPackagePrivate() || elementCasted.isPrivate()) {
-                    return false;
-                }
-            }
         }
 
         if (element instanceof PackageDoc)
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
index 7e264c8..75129c2 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MessageRetriever.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2009, 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
@@ -24,18 +24,20 @@
  */
 package com.sun.tools.doclets.internal.toolkit.util;
 
+import java.text.MessageFormat;
+import java.util.*;
+
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.Configuration;
-import java.util.*;
-import java.text.MessageFormat;
 
 
 /**
  * Retrieve and format messages stored in a resource.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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.2
  * @author Atul M Dambalkar
@@ -58,9 +60,9 @@ public class MessageRetriever {
     private ResourceBundle messageRB;
 
     /**
-     * Initilize the ResourceBundle with the given resource.
+     * Initialize the ResourceBundle with the given resource.
      *
-     * @param rb the esource bundle to read.
+     * @param rb the resource bundle to read.
      */
     public MessageRetriever(ResourceBundle rb) {
         this.configuration = null;
@@ -69,7 +71,7 @@ public class MessageRetriever {
     }
 
     /**
-     * Initilize the ResourceBundle with the given resource.
+     * Initialize the ResourceBundle with the given resource.
      *
      * @param configuration the configuration
      * @param resourcelocation Resource.
@@ -187,7 +189,8 @@ public class MessageRetriever {
      * @param args arguments to be replaced in the message.
      */
     public void warning(SourcePosition pos, String key, Object... args) {
-        printWarning(pos, getText(key, args));
+        if (configuration.showMessage(pos, key))
+            printWarning(pos, getText(key, args));
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java
index e9fd61e..18358ec 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, 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
@@ -25,19 +25,22 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * Provides methods for creating an array of class, method and
  * field names to be included as meta keywords in the HTML header
  * of class pages.  These keywords improve search results
  * on browsers that look for keywords.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Doug Kramer
  */
@@ -103,6 +106,20 @@ public class MetaKeywords {
     }
 
     /**
+     * Get the profile keywords.
+     *
+     * @param profile the profile being documented
+     */
+    public String[] getMetaKeywords(Profile profile) {
+        if( configuration.keywords ) {
+            String profileName = profile.name;
+            return new String[] { profileName + " " + "profile" };
+        } else {
+            return new String[] {};
+        }
+    }
+
+    /**
      * Get the overview keywords.
      */
     public String[] getOverviewMetaKeywords(String title, String docTitle) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java
index a19e8c1..68e0827 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -33,9 +33,10 @@ import com.sun.javadoc.*;
  * superclasses and interfaces(subsequently super-interfaces also)
  * recursively.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API.
+ *  <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 abstract class MethodFinder {
 
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
new file mode 100644
index 0000000..7b31ad8
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+/**
+ * Enum representing method types.
+ *
+ * @author Bhavesh Patel
+ */
+public enum MethodTypes {
+    ALL(0xffff, "All Methods", "t0", true),
+    STATIC(0x1, "Static Methods", "t1", false),
+    INSTANCE(0x2, "Instance Methods", "t2", false),
+    ABSTRACT(0x4, "Abstract Methods", "t3", false),
+    CONCRETE(0x8, "Concrete Methods", "t4", false),
+    DEFAULT(0x10, "Default Methods", "t5", false),
+    DEPRECATED(0x20, "Deprecated Methods", "t6", false);
+
+    private final int value;
+    private final String text;
+    private final String tabId;
+    private final boolean isDefaultTab;
+
+    MethodTypes(int v, String t, String id, boolean dt) {
+        this.value = v;
+        this.text = t;
+        this.tabId = id;
+        this.isDefaultTab = dt;
+    }
+
+    public int value() {
+        return value;
+    }
+
+    public String text() {
+        return text;
+    }
+
+    public String tabId() {
+        return tabId;
+    }
+
+    public boolean isDefaultTab() {
+        return isDefaultTab;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
index a32f048..0d1b63e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,19 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.tools.doclets.internal.toolkit.*;
-import com.sun.javadoc.*;
 import java.io.*;
 import java.util.*;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * Write out the package index.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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>
  *
  * @see com.sun.javadoc.PackageDoc
  * @author Atul M Dambalkar
@@ -50,8 +52,7 @@ public class PackageListWriter extends PrintWriter {
      * @param configuration the current configuration of the doclet.
      */
     public PackageListWriter(Configuration configuration) throws IOException {
-        super(Util.genWriter(configuration, configuration.destDirName,
-            DocletConstants.PACKAGE_LIST_FILE_NAME, configuration.docencoding));
+        super(DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST).openWriter());
         this.configuration = configuration;
     }
 
@@ -69,7 +70,7 @@ public class PackageListWriter extends PrintWriter {
             packgen.close();
         } catch (IOException exc) {
             configuration.message.error("doclet.exception_encountered",
-                exc.toString(), DocletConstants.PACKAGE_LIST_FILE_NAME);
+                exc.toString(), DocPaths.PACKAGE_LIST);
             throw new DocletAbortException();
         }
     }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java
new file mode 100644
index 0000000..d2ee2d6
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.doclets.internal.toolkit.util;
+
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.nio.PathFileManager;
+
+
+/**
+ * Implementation of DocFileFactory using a {@link PathFileManager}.
+ *
+ *  <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.8
+ */
+class PathDocFileFactory extends DocFileFactory {
+    private final PathFileManager fileManager;
+    private final Path destDir;
+
+    public PathDocFileFactory(Configuration configuration) {
+        super(configuration);
+        fileManager = (PathFileManager) configuration.getFileManager();
+
+        if (!configuration.destDirName.isEmpty()
+                || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+            try {
+                String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+                Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
+                fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+            } catch (IOException e) {
+                throw new DocletAbortException();
+            }
+        }
+
+        destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        if (fileManager.hasLocation(location)) {
+            for (Path f: fileManager.getLocation(location)) {
+                if (Files.isDirectory(f)) {
+                    f = f.resolve(path.getPath());
+                    if (Files.exists(f))
+                        files.add(new StandardDocFile(f));
+                }
+            }
+        }
+        return files;
+    }
+
+    class StandardDocFile extends DocFile {
+        private Path file;
+
+        /** Create a StandardDocFile for a given file. */
+        private StandardDocFile(Path file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a StandardDocFile for a given location and relative path. */
+        private StandardDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            this.file = destDir.resolve(path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws IOException {
+            JavaFileObject fo = getJavaFileObjectForInput(file);
+            return new BufferedInputStream(fo.openInputStream());
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            return new BufferedOutputStream(out);
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(out));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return Files.isReadable(file);
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return Files.isWritable(file);
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return Files.exists(file);
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getFileName().toString();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.toString();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return Files.isDirectory(file);
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return Files.isRegularFile(file);
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof StandardDocFile))
+                return false;
+
+            try {
+                return Files.isSameFile(file, ((StandardDocFile) other).file);
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() throws IOException {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (Path f: Files.newDirectoryStream(file)) {
+                files.add(new StandardDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            try {
+                Files.createDirectories(file);
+                return true;
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new StandardDocFile(file.resolve(p));
+            } else {
+                return new StandardDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new StandardDocFile(destDir.resolve(file));
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("PathDocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+        private JavaFileObject getJavaFileObjectForInput(Path file) {
+            return fileManager.getJavaFileObjects(file).iterator().next();
+        }
+
+        private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+            // break the path into a package-part and the rest, by finding
+            // the position of the last '/' before an invalid character for a
+            // package name, such as the "." before an extension or the "-"
+            // in filenames like package-summary.html, doc-files or src-html.
+            String p = path.getPath();
+            int lastSep = -1;
+            for (int i = 0; i < p.length(); i++) {
+                char ch = p.charAt(i);
+                if (ch == '/') {
+                    lastSep = i;
+                } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+                        || !Character.isJavaIdentifierPart(ch)) {
+                    break;
+                }
+            }
+            String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+            String rest = p.substring(lastSep + 1);
+            return fileManager.getFileForOutput(location, pkg, rest, null);
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java
new file mode 100644
index 0000000..e9711f5
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SimpleDocFileFactory.java
@@ -0,0 +1,292 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * Implementation of DocFileFactory that just uses java.io.File API,
+ * and does not use a JavaFileManager..
+ *
+ *  <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.8
+ */
+class SimpleDocFileFactory extends DocFileFactory {
+
+    public SimpleDocFileFactory(Configuration configuration) {
+        super(configuration);
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new SimpleDocFile(new File(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new SimpleDocFile(new File(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new SimpleDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        for (String s : configuration.sourcepath.split(File.pathSeparator)) {
+            if (s.isEmpty())
+                continue;
+            File f = new File(s);
+            if (f.isDirectory()) {
+                f = new File(f, path.getPath());
+                if (f.exists())
+                    files.add(new SimpleDocFile(f));
+            }
+        }
+        return files;
+    }
+
+    class SimpleDocFile extends DocFile {
+        private File file;
+
+        /** Create a DocFile for a given file. */
+        private SimpleDocFile(File file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a DocFile for a given location and relative path. */
+        private SimpleDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            String destDirName = configuration.destDirName;
+            this.file = destDirName.isEmpty() ? new File(path.getPath())
+                    : new File(destDirName, path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws FileNotFoundException {
+            return new BufferedInputStream(new FileInputStream(file));
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            createDirectoryForFile(file);
+            return new BufferedOutputStream(new FileOutputStream(file));
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            createDirectoryForFile(file);
+            FileOutputStream fos = new FileOutputStream(file);
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(fos));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(fos, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return file.canRead();
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return file.canRead();
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return file.exists();
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getName();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.getPath();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return file.isDirectory();
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return file.isFile();
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof SimpleDocFile))
+                return false;
+
+            try {
+                return file.exists()
+                        && file.getCanonicalFile().equals(((SimpleDocFile)other).file.getCanonicalFile());
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (File f: file.listFiles()) {
+                files.add(new SimpleDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            return file.mkdirs();
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new SimpleDocFile(new File(file, p));
+            } else {
+                return new SimpleDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new SimpleDocFile(
+                    new File(configuration.destDirName, file.getPath()));
+        }
+
+        /**
+         * Given a path string create all the directories in the path. For example,
+         * if the path string is "java/applet", the method will create directory
+         * "java" and then "java/applet" if they don't exist. The file separator
+         * string "/" is platform dependent system property.
+         *
+         * @param path Directory path string.
+         */
+        private void createDirectoryForFile(File file) {
+            File dir = file.getParentFile();
+            if (dir == null || dir.exists() || dir.mkdirs())
+                return;
+
+            configuration.message.error(
+                   "doclet.Unable_to_create_directory_0", dir.getPath());
+            throw new DocletAbortException();
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("DocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java
deleted file mode 100644
index 64c9d7e..0000000
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourcePath.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.doclets.internal.toolkit.util;
-
-import java.io.File;
-
-/**
- * This class is used to represent a source path which can contain only
- * directories no zip files. If a zip file is specified in the command line it
- * will not get reflected in the SourcePath.
- *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
- *
- * @author Atul M Dambalkar
- */
-public
-    class SourcePath {
-    private final char dirSeparator = File.pathSeparatorChar;
-
-    /**
-     * The original class path string
-     */
-    private String pathstr;
-
-    /**
-     * List of source path entries. Each entry is a directory.
-     */
-    private File[] sourcePath;
-
-
-    /**
-     * Build a source path from the specified path string on the command line.
-     */
-    public SourcePath(String pathstr) {
-        init(pathstr);
-    }
-
-    /**
-     * Build a default source path from the path strings specified by
-     * the properties env.class.path.
-     */
-    public SourcePath() {
-        init(System.getProperty("env.class.path"));
-    }
-
-    /**
-     * Initialize the SourcePath File array, which will contain only the
-     * directory names from the given path string.
-     *
-     * @param pathstr Path String.
-     */
-    private void init(String pathstr) {
-        if (pathstr == null ||  pathstr.length() == 0) {
-            pathstr = ".";
-        }
-
-        int noOfFileSep = 0;
-        int index = 0;
-        this.pathstr = pathstr; // Save original class path string
-
-        // Count the number of path separators
-        while ((index = pathstr.indexOf(dirSeparator, index)) != -1) {
-            noOfFileSep++;
-            index++;
-        }
-        // Build the source path
-        File[] tempPath = new File[noOfFileSep + 1];
-        int tempPathIndex = 0;
-        int len = pathstr.length();
-        int sepPos = 0;
-        for (index = 0; index < len; index = sepPos + 1) {
-            sepPos = pathstr.indexOf(dirSeparator, index);
-            if (sepPos < 0) {
-                sepPos = len;
-            }
-            File file = new File(pathstr.substring(index, sepPos));
-            if (file.isDirectory()) {
-                tempPath[tempPathIndex++] = file;
-            } // if it is really a file, ignore it.
-        }
-        sourcePath = new File[tempPathIndex];
-        System.arraycopy((Object)tempPath, 0, (Object)sourcePath,
-                         0, tempPathIndex);
-    }
-
-    /**
-     * Find the specified directory in the source path.
-     *
-     * @param name Name of the directory to be searched for in the source path.
-     * @return File Return the directory if found else return null.
-     */
-    public File getDirectory(String name) {
-        for (int i = 0; i < sourcePath.length; i++) {
-            File directoryNeeded = new File(sourcePath[i], name);
-            if (directoryNeeded.isDirectory()) {
-                return directoryNeeded;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Return original source path string.
-     */
-    public String toString() {
-        return pathstr;
-    }
-}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java
new file mode 100644
index 0000000..1f7d20c
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/StandardDocFileFactory.java
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclets.internal.toolkit.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.doclets.internal.toolkit.Configuration;
+import com.sun.tools.javac.util.Assert;
+
+/**
+ * Implementation of DocFileFactory using a {@link StandardJavaFileManager}.
+ *
+ *  <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.8
+ */
+class StandardDocFileFactory extends DocFileFactory {
+    private final StandardJavaFileManager fileManager;
+    private File destDir;
+
+    public StandardDocFileFactory(Configuration configuration) {
+        super(configuration);
+        fileManager = (StandardJavaFileManager) configuration.getFileManager();
+    }
+
+    private File getDestDir() {
+        if (destDir == null) {
+            if (!configuration.destDirName.isEmpty()
+                    || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
+                try {
+                    String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
+                    File dir = new File(dirName);
+                    fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
+                } catch (IOException e) {
+                    throw new DocletAbortException();
+                }
+            }
+
+            destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
+        }
+        return destDir;
+    }
+
+    public DocFile createFileForDirectory(String file) {
+        return new StandardDocFile(new File(file));
+    }
+
+    public DocFile createFileForInput(String file) {
+        return new StandardDocFile(new File(file));
+    }
+
+    public DocFile createFileForOutput(DocPath path) {
+        return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
+    }
+
+    @Override
+    Iterable<DocFile> list(Location location, DocPath path) {
+        if (location != StandardLocation.SOURCE_PATH)
+            throw new IllegalArgumentException();
+
+        Set<DocFile> files = new LinkedHashSet<DocFile>();
+        Location l = fileManager.hasLocation(StandardLocation.SOURCE_PATH)
+                ? StandardLocation.SOURCE_PATH : StandardLocation.CLASS_PATH;
+        for (File f: fileManager.getLocation(l)) {
+            if (f.isDirectory()) {
+                f = new File(f, path.getPath());
+                if (f.exists())
+                    files.add(new StandardDocFile(f));
+            }
+        }
+        return files;
+    }
+
+    private static File newFile(File dir, String path) {
+        return (dir == null) ? new File(path) : new File(dir, path);
+    }
+
+    class StandardDocFile extends DocFile {
+        private File file;
+
+
+        /** Create a StandardDocFile for a given file. */
+        private StandardDocFile(File file) {
+            super(configuration);
+            this.file = file;
+        }
+
+        /** Create a StandardDocFile for a given location and relative path. */
+        private StandardDocFile(Location location, DocPath path) {
+            super(configuration, location, path);
+            Assert.check(location == DocumentationTool.Location.DOCUMENTATION_OUTPUT);
+            this.file = newFile(getDestDir(), path.getPath());
+        }
+
+        /** Open an input stream for the file. */
+        public InputStream openInputStream() throws IOException {
+            JavaFileObject fo = getJavaFileObjectForInput(file);
+            return new BufferedInputStream(fo.openInputStream());
+        }
+
+        /**
+         * Open an output stream for the file.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            return new BufferedOutputStream(out);
+        }
+
+        /**
+         * Open an writer for the file, using the encoding (if any) given in the
+         * doclet configuration.
+         * The file must have been created with a location of
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
+         */
+        public Writer openWriter() throws IOException, UnsupportedEncodingException {
+            if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalStateException();
+
+            OutputStream out = getFileObjectForOutput(path).openOutputStream();
+            if (configuration.docencoding == null) {
+                return new BufferedWriter(new OutputStreamWriter(out));
+            } else {
+                return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
+            }
+        }
+
+        /** Return true if the file can be read. */
+        public boolean canRead() {
+            return file.canRead();
+        }
+
+        /** Return true if the file can be written. */
+        public boolean canWrite() {
+            return file.canWrite();
+        }
+
+        /** Return true if the file exists. */
+        public boolean exists() {
+            return file.exists();
+        }
+
+        /** Return the base name (last component) of the file name. */
+        public String getName() {
+            return file.getName();
+        }
+
+        /** Return the file system path for this file. */
+        public String getPath() {
+            return file.getPath();
+        }
+
+        /** Return true is file has an absolute path name. */
+        public boolean isAbsolute() {
+            return file.isAbsolute();
+        }
+
+        /** Return true is file identifies a directory. */
+        public boolean isDirectory() {
+            return file.isDirectory();
+        }
+
+        /** Return true is file identifies a file. */
+        public boolean isFile() {
+            return file.isFile();
+        }
+
+        /** Return true if this file is the same as another. */
+        public boolean isSameFile(DocFile other) {
+            if (!(other instanceof StandardDocFile))
+                return false;
+
+            try {
+                return file.exists()
+                        && file.getCanonicalFile().equals(((StandardDocFile) other).file.getCanonicalFile());
+            } catch (IOException e) {
+                return false;
+            }
+        }
+
+        /** If the file is a directory, list its contents. */
+        public Iterable<DocFile> list() {
+            List<DocFile> files = new ArrayList<DocFile>();
+            for (File f: file.listFiles()) {
+                files.add(new StandardDocFile(f));
+            }
+            return files;
+        }
+
+        /** Create the file as a directory, including any parent directories. */
+        public boolean mkdirs() {
+            return file.mkdirs();
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(DocPath p) {
+            return resolve(p.getPath());
+        }
+
+        /**
+         * Derive a new file by resolving a relative path against this file.
+         * The new file will inherit the configuration and location of this file
+         * If this file has a path set, the new file will have a corresponding
+         * new path.
+         */
+        public DocFile resolve(String p) {
+            if (location == null && path == null) {
+                return new StandardDocFile(new File(file, p));
+            } else {
+                return new StandardDocFile(location, path.resolve(p));
+            }
+        }
+
+        /**
+         * Resolve a relative file against the given output location.
+         * @param locn Currently, only
+         * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported.
+         */
+        public DocFile resolveAgainst(Location locn) {
+            if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
+                throw new IllegalArgumentException();
+            return new StandardDocFile(newFile(getDestDir(), file.getPath()));
+        }
+
+        /** Return a string to identify the contents of this object,
+         * for debugging purposes.
+         */
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append("StandardDocFile[");
+            if (location != null)
+                sb.append("locn:").append(location).append(",");
+            if (path != null)
+                sb.append("path:").append(path.getPath()).append(",");
+            sb.append("file:").append(file);
+            sb.append("]");
+            return sb.toString();
+        }
+
+        private JavaFileObject getJavaFileObjectForInput(File file) {
+            return fileManager.getJavaFileObjects(file).iterator().next();
+        }
+
+        private FileObject getFileObjectForOutput(DocPath path) throws IOException {
+            // break the path into a package-part and the rest, by finding
+            // the position of the last '/' before an invalid character for a
+            // package name, such as the "." before an extension or the "-"
+            // in filenames like package-summary.html, doc-files or src-html.
+            String p = path.getPath();
+            int lastSep = -1;
+            for (int i = 0; i < p.length(); i++) {
+                char ch = p.charAt(i);
+                if (ch == '/') {
+                    lastSep = i;
+                } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
+                        || !Character.isJavaIdentifierPart(ch)) {
+                    break;
+                }
+            }
+            String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
+            String rest = p.substring(lastSep + 1);
+            return fileManager.getFileForOutput(location, pkg, rest, null);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java
index e4c7fbc..2854b49 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -30,9 +30,10 @@ import com.sun.javadoc.*;
 /**
  * Find a tagged method.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  */
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TextTag.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TextTag.java
index a9e2aa0..074718f 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TextTag.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TextTag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -30,9 +30,10 @@ import com.sun.javadoc.*;
  * A tag that holds nothing but plain text.  This is useful for passing
  * text to methods that only accept inline tags as a parameter.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
index 8386ff4..acdae45 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
@@ -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
@@ -26,17 +26,21 @@
 package com.sun.tools.doclets.internal.toolkit.util;
 
 import java.io.*;
+import java.lang.annotation.ElementType;
 import java.util.*;
 
 import com.sun.javadoc.*;
+import com.sun.javadoc.AnnotationDesc.ElementValuePair;
 import com.sun.tools.doclets.internal.toolkit.*;
+import javax.tools.StandardLocation;
 
 /**
  * Utilities Class for Doclets.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  * @author Jamie Ho
@@ -44,24 +48,6 @@ import com.sun.tools.doclets.internal.toolkit.*;
 public class Util {
 
     /**
-     * A mapping between characters and their
-     * corresponding HTML escape character.
-     */
-    public static final String[][] HTML_ESCAPE_CHARS =
-    {{"&", "&"}, {"<", "<"}, {">", ">"}};
-
-    /**
-     * Name of the resource directory.
-     */
-    public static final String RESOURCESDIR = "resources";
-
-    /**
-     * Resource bundle corresponding to the doclets.properties file.
-     */
-    public static final ResourceBundle RESOURCE_BUNDLE =
-                    ResourceBundle.getBundle(Configuration.DOCLETS_RESOURCE);
-
-    /**
      * Return array of class members whose documentation is to be generated.
      * If the member is deprecated do not include such a member in the
      * returned array.
@@ -202,32 +188,6 @@ public class Util {
     }
 
     /**
-     * Copy source file to destination file.
-     *
-     * @throws SecurityException
-     * @throws IOException
-     */
-    public static void copyFile(File destfile, File srcfile)
-        throws IOException {
-        byte[] bytearr = new byte[512];
-        int len = 0;
-        FileInputStream input = new FileInputStream(srcfile);
-        File destDir = destfile.getParentFile();
-        destDir.mkdirs();
-        FileOutputStream output = new FileOutputStream(destfile);
-        try {
-            while ((len = input.read(bytearr)) != -1) {
-                output.write(bytearr, 0, len);
-                }
-        } catch (FileNotFoundException exc) {
-        } catch (SecurityException exc) {
-            } finally {
-            input.close();
-            output.close();
-            }
-        }
-
-    /**
      * Copy the given directory contents from the source package directory
      * to the generated documentation directory. For example for a package
      * java.lang this method find out the source location of the package using
@@ -240,180 +200,50 @@ public class Util {
      * @param dir The original directory name to copy from.
      * @param overwrite Overwrite files if true.
      */
-    public static void copyDocFiles(Configuration configuration,
-            String path, String dir, boolean overwrite) {
-        if (checkCopyDocFilesErrors(configuration, path, dir)) {
-            return;
-        }
-        String destname = configuration.docFileDestDirName;
-        File srcdir = new File(path + dir);
-        if (destname.length() > 0 && !destname.endsWith(
-               DirectoryManager.URL_FILE_SEPARATOR)) {
-            destname += DirectoryManager.URL_FILE_SEPARATOR;
-        }
-        String dest = destname + dir;
-        try {
-            File destdir = new File(dest);
-            DirectoryManager.createDirectory(configuration, dest);
-            String[] files = srcdir.list();
-            for (int i = 0; i < files.length; i++) {
-                File srcfile = new File(srcdir, files[i]);
-                File destfile = new File(destdir, files[i]);
-                if (srcfile.isFile()) {
-                    if(destfile.exists() && ! overwrite) {
-                        configuration.message.warning((SourcePosition) null,
-                                "doclet.Copy_Overwrite_warning",
-                                srcfile.toString(), destdir.toString());
-                    } else {
-                        configuration.message.notice(
-                            "doclet.Copying_File_0_To_Dir_1",
-                            srcfile.toString(), destdir.toString());
-                        Util.copyFile(destfile, srcfile);
-                    }
-                } else if(srcfile.isDirectory()) {
-                    if(configuration.copydocfilesubdirs
-                        && ! configuration.shouldExcludeDocFileDir(
-                          srcfile.getName())){
-                        copyDocFiles(configuration, path, dir +
-                                    DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(),
-                                overwrite);
-                    }
-                }
-            }
-        } catch (SecurityException exc) {
-            throw new DocletAbortException();
-        } catch (IOException exc) {
-            throw new DocletAbortException();
-        }
-    }
-
-    /**
-     * Given the parameters for copying doc-files, check for errors.
-     *
-     * @param configuration The configuration of the current doclet.
-     * @param path The relative path to the directory to be copied.
-     * @param dirName The original directory name to copy from.
-     */
-    private static boolean checkCopyDocFilesErrors (Configuration configuration,
-            String path, String dirName) {
-        if ((configuration.sourcepath == null || configuration.sourcepath.length() == 0) &&
-               (configuration.destDirName == null || configuration.destDirName.length() == 0)) {
-            //The destination path and source path are definitely equal.
-            return true;
-        }
-        File sourcePath, destPath = new File(configuration.destDirName);
-        StringTokenizer pathTokens = new StringTokenizer(
-            configuration.sourcepath == null ? "" : configuration.sourcepath,
-            File.pathSeparator);
-        //Check if the destination path is equal to the source path.  If yes,
-        //do not copy doc-file directories.
-        while(pathTokens.hasMoreTokens()){
-            sourcePath = new File(pathTokens.nextToken());
-            if(destPath.equals(sourcePath)){
-                return true;
-            }
-        }
-        //Make sure the doc-file being copied exists.
-        File srcdir = new File(path + dirName);
-        if (! srcdir.exists()) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Copy a file in the resources directory to the destination
-     * directory (if it is not there already).  If
-     * <code>overwrite</code> is true and the destination file
-     * already exists, overwrite it.
-     *
-     * @param configuration  Holds the destination directory and error message
-     * @param resourcefile   The name of the resource file to copy
-     * @param overwrite      A flag to indicate whether the file in the
-     *                       destination directory will be overwritten if
-     *                       it already exists.
-     */
-    public static void copyResourceFile(Configuration configuration,
-            String resourcefile, boolean overwrite) {
-        String destresourcesdir = configuration.destDirName + RESOURCESDIR;
-        copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir,
-                overwrite, false);
+    public static void copyDocFiles(Configuration configuration, PackageDoc pd) {
+        copyDocFiles(configuration, DocPath.forPackage(pd).resolve(DocPaths.DOC_FILES));
     }
 
-    /**
-     * Copy a file from a source directory to a destination directory
-     * (if it is not there already). If <code>overwrite</code> is true and
-     * the destination file already exists, overwrite it.
-     *
-     * @param configuration Holds the error message
-     * @param file The name of the file to copy
-     * @param source The source directory
-     * @param destination The destination directory where the file needs to be copied
-     * @param overwrite A flag to indicate whether the file in the
-     *                  destination directory will be overwritten if
-     *                  it already exists.
-     * @param replaceNewLine true if the newline needs to be replaced with platform-
-     *                  specific newline.
-     */
-    public static void copyFile(Configuration configuration, String file, String source,
-            String destination, boolean overwrite, boolean replaceNewLine) {
-        DirectoryManager.createDirectory(configuration, destination);
-        File destfile = new File(destination, file);
-        if(destfile.exists() && (! overwrite)) return;
+    public static void copyDocFiles(Configuration configuration, DocPath dir) {
         try {
-            InputStream in = Configuration.class.getResourceAsStream(
-                    source + DirectoryManager.URL_FILE_SEPARATOR + file);
-            if(in==null) return;
-            OutputStream out = new FileOutputStream(destfile);
-            try {
-                if (!replaceNewLine) {
-                    byte[] buf = new byte[2048];
-                    int n;
-                    while((n = in.read(buf))>0) out.write(buf,0,n);
-                } else {
-                    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-                    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
-                    try {
-                        String line;
-                        while ((line = reader.readLine()) != null) {
-                            writer.write(line);
-                            writer.write(DocletConstants.NL);
+            boolean first = true;
+            for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) {
+                if (!f.isDirectory()) {
+                    continue;
+                }
+                DocFile srcdir = f;
+                DocFile destdir = DocFile.createFileForOutput(configuration, dir);
+                if (srcdir.isSameFile(destdir)) {
+                    continue;
+                }
+
+                for (DocFile srcfile: srcdir.list()) {
+                    DocFile destfile = destdir.resolve(srcfile.getName());
+                    if (srcfile.isFile()) {
+                        if (destfile.exists() && !first) {
+                            configuration.message.warning((SourcePosition) null,
+                                    "doclet.Copy_Overwrite_warning",
+                                    srcfile.getPath(), destdir.getPath());
+                        } else {
+                            configuration.message.notice(
+                                    "doclet.Copying_File_0_To_Dir_1",
+                                    srcfile.getPath(), destdir.getPath());
+                            destfile.copyFile(srcfile);
+                        }
+                    } else if (srcfile.isDirectory()) {
+                        if (configuration.copydocfilesubdirs
+                                && !configuration.shouldExcludeDocFileDir(srcfile.getName())) {
+                            copyDocFiles(configuration, dir.resolve(srcfile.getName()));
                         }
-                    } finally {
-                        reader.close();
-                        writer.close();
                     }
                 }
-            } finally {
-                in.close();
-                out.close();
+
+                first = false;
             }
-        } catch (IOException ie) {
-            ie.printStackTrace(System.err);
+        } catch (SecurityException exc) {
+            throw new DocletAbortException();
+        } catch (IOException exc) {
             throw new DocletAbortException();
-        }
-    }
-
-    /**
-     * Given a PackageDoc, return the source path for that package.
-     * @param configuration The Configuration for the current Doclet.
-     * @param pkgDoc The package to seach the path for.
-     * @return A string representing the path to the given package.
-     */
-    public static String getPackageSourcePath(Configuration configuration,
-            PackageDoc pkgDoc){
-        try{
-            String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
-            String completePath = new SourcePath(configuration.sourcepath).
-                getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
-            //Make sure that both paths are using the same separators.
-            completePath = Util.replaceText(completePath, File.separator,
-                    DirectoryManager.URL_FILE_SEPARATOR);
-            pkgPath = Util.replaceText(pkgPath, File.separator,
-                    DirectoryManager.URL_FILE_SEPARATOR);
-            return completePath.substring(0, completePath.lastIndexOf(pkgPath));
-        } catch (Exception e){
-            return "";
         }
     }
 
@@ -476,9 +306,7 @@ public class Util {
         //Try walking the tree.
         addAllInterfaceTypes(results,
             superType,
-            superType instanceof ClassDoc ?
-                ((ClassDoc) superType).interfaceTypes() :
-                ((ParameterizedType) superType).interfaceTypes(),
+            interfaceTypesOf(superType),
             false, configuration);
         List<Type> resultsList = new ArrayList<Type>(results.values());
         if (sort) {
@@ -487,6 +315,14 @@ public class Util {
         return resultsList;
     }
 
+    private static Type[] interfaceTypesOf(Type type) {
+        if (type instanceof AnnotatedType)
+            type = ((AnnotatedType)type).underlyingType();
+        return type instanceof ClassDoc ?
+                ((ClassDoc)type).interfaceTypes() :
+                ((ParameterizedType)type).interfaceTypes();
+    }
+
     public static List<Type> getAllInterfaces(Type type, Configuration configuration) {
         return getAllInterfaces(type, configuration, true);
     }
@@ -497,9 +333,7 @@ public class Util {
         if (superType == null)
             return;
         addAllInterfaceTypes(results, superType,
-                superType instanceof ClassDoc ?
-                ((ClassDoc) superType).interfaceTypes() :
-                ((ParameterizedType) superType).interfaceTypes(),
+                interfaceTypesOf(superType),
                 raw, configuration);
     }
 
@@ -509,9 +343,7 @@ public class Util {
         if (superType == null)
             return;
         addAllInterfaceTypes(results, superType,
-                superType instanceof ClassDoc ?
-                ((ClassDoc) superType).interfaceTypes() :
-                ((ParameterizedType) superType).interfaceTypes(),
+                interfaceTypesOf(superType),
                 false, configuration);
     }
 
@@ -535,6 +367,9 @@ public class Util {
                 results.put(superInterface.asClassDoc(), superInterface);
             }
         }
+        if (type instanceof AnnotatedType)
+            type = ((AnnotatedType)type).underlyingType();
+
         if (type instanceof ParameterizedType)
             findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
         else if (((ClassDoc) type).typeParameters().length == 0)
@@ -551,7 +386,7 @@ public class Util {
     }
 
     /**
-     * Given a package, return it's name.
+     * Given a package, return its name.
      * @param packageDoc the package to check.
      * @return the name of the given package.
      */
@@ -561,7 +396,7 @@ public class Util {
     }
 
     /**
-     * Given a package, return it's file name without the extension.
+     * Given a package, return its file name without the extension.
      * @param packageDoc the package to check.
      * @return the file name of the given package.
      */
@@ -571,7 +406,7 @@ public class Util {
     }
 
     /**
-     * Given a string, replace all occurraces of 'newStr' with 'oldStr'.
+     * Given a string, replace all occurrences of 'newStr' with 'oldStr'.
      * @param originalStr the string to modify.
      * @param oldStr the string to replace.
      * @param newStr the string to insert in place of the old string.
@@ -585,77 +420,6 @@ public class Util {
     }
 
     /**
-     * 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.
-     *
-     * @see #HTML_ESCAPE_CHARS
-     */
-    public static String escapeHtmlChars(String s) {
-        String result = s;
-        for (int i = 0; i < HTML_ESCAPE_CHARS.length; i++) {
-            result = Util.replaceText(result,
-                    HTML_ESCAPE_CHARS[i][0], HTML_ESCAPE_CHARS[i][1]);
-        }
-        return result;
-    }
-
-    /**
-     * 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();
-    }
-
-    /**
-     * Create the directory path for the file to be generated, construct
-     * FileOutputStream and OutputStreamWriter depending upon docencoding.
-     *
-     * @param path The directory path to be created for this file.
-     * @param filename File Name to which the PrintWriter will do the Output.
-     * @param docencoding Encoding to be used for this file.
-     * @exception IOException Exception raised by the FileWriter is passed on
-     * to next level.
-     * @exception UnsupportedEncodingException Exception raised by the
-     * OutputStreamWriter is passed on to next level.
-     * @return Writer Writer for the file getting generated.
-     * @see java.io.FileOutputStream
-     * @see java.io.OutputStreamWriter
-     */
-    public static Writer genWriter(Configuration configuration,
-            String path, String filename,
-            String docencoding)
-        throws IOException, UnsupportedEncodingException {
-        FileOutputStream fos;
-        if (path != null) {
-            DirectoryManager.createDirectory(configuration, path);
-            fos = new FileOutputStream(((path.length() > 0)?
-                                                  path + File.separator: "") + filename);
-        } else {
-            fos = new FileOutputStream(filename);
-        }
-        if (docencoding == null) {
-            return new OutputStreamWriter(fos);
-        } else {
-            return new OutputStreamWriter(fos, docencoding);
-        }
-    }
-
-    /**
      * Given an annotation, return true if it should be documented and false
      * otherwise.
      *
@@ -674,45 +438,55 @@ public class Util {
         return false;
     }
 
+    private static boolean isDeclarationTarget(AnnotationDesc targetAnno) {
+        // The error recovery steps here are analogous to TypeAnnotations
+        ElementValuePair[] elems = targetAnno.elementValues();
+        if (elems == null
+            || elems.length != 1
+            || !"value".equals(elems[0].element().name())
+            || !(elems[0].value().value() instanceof AnnotationValue[]))
+            return true;    // error recovery
+
+        AnnotationValue[] values = (AnnotationValue[])elems[0].value().value();
+        for (int i = 0; i < values.length; i++) {
+            Object value = values[i].value();
+            if (!(value instanceof FieldDoc))
+                return true; // error recovery
+
+            FieldDoc eValue = (FieldDoc)value;
+            if (Util.isJava5DeclarationElementType(eValue)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     /**
-     * Given a string, return an array of tokens.  The separator can be escaped
-     * with the '\' character.  The '\' character may also be escaped by the
-     * '\' character.
+     * Returns true if the {@code annotationDoc} is to be treated
+     * as a declaration annotation, when targeting the
+     * {@code elemType} element type.
      *
-     * @param s         the string to tokenize.
-     * @param separator the separator char.
-     * @param maxTokens the maxmimum number of tokens returned.  If the
-     *                  max is reached, the remaining part of s is appended
-     *                  to the end of the last token.
-     *
-     * @return an array of tokens.
+     * @param annotationDoc the annotationDoc to check
+     * @param elemType  the targeted elemType
+     * @return true if annotationDoc is a declaration annotation
      */
-    public static String[] tokenize(String s, char separator, int maxTokens) {
-        List<String> tokens = new ArrayList<String>();
-        StringBuilder  token = new StringBuilder ();
-        boolean prevIsEscapeChar = false;
-        for (int i = 0; i < s.length(); i += Character.charCount(i)) {
-            int currentChar = s.codePointAt(i);
-            if (prevIsEscapeChar) {
-                // Case 1:  escaped character
-                token.appendCodePoint(currentChar);
-                prevIsEscapeChar = false;
-            } else if (currentChar == separator && tokens.size() < maxTokens-1) {
-                // Case 2:  separator
-                tokens.add(token.toString());
-                token = new StringBuilder();
-            } else if (currentChar == '\\') {
-                // Case 3:  escape character
-                prevIsEscapeChar = true;
-            } else {
-                // Case 4:  regular character
-                token.appendCodePoint(currentChar);
+    public static boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc,
+            boolean isJava5DeclarationLocation) {
+        if (!isJava5DeclarationLocation)
+            return false;
+        AnnotationDesc[] annotationDescList = annotationDoc.annotations();
+        // Annotations with no target are treated as declaration as well
+        if (annotationDescList.length==0)
+            return true;
+        for (int i = 0; i < annotationDescList.length; i++) {
+            if (annotationDescList[i].annotationType().qualifiedName().equals(
+                    java.lang.annotation.Target.class.getName())) {
+                if (isDeclarationTarget(annotationDescList[i]))
+                    return true;
             }
         }
-        if (token.length() > 0) {
-            tokens.add(token.toString());
-        }
-        return tokens.toArray(new String[] {});
+        return false;
     }
 
     /**
@@ -795,7 +569,7 @@ public class Util {
      *
      * @param cd the ClassDoc to check.
      * @param lowerCaseOnly true if you want the name returned in lower case.
-     *                      If false, the first letter of the name is capatilized.
+     *                      If false, the first letter of the name is capitalized.
      * @return
      */
     public static String getTypeName(Configuration config,
@@ -819,22 +593,43 @@ public class Util {
     }
 
     /**
-     * Given a string, replace all tabs with the appropriate
-     * number of spaces.
-     * @param tabLength the length of each tab.
-     * @param s the String to scan.
-     */
-    public static void replaceTabs(int tabLength, StringBuilder s) {
-        if (whitespace == null || whitespace.length() < tabLength)
-            whitespace = String.format("%" + tabLength + "s", " ");
-        int index = 0;
-        while ((index = s.indexOf("\t", index)) != -1) {
-            int spaceCount = tabLength - index % tabLength;
-            s.replace(index, index+1, whitespace.substring(0, spaceCount));
-            index += spaceCount;
+     * 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 text the text for which the tabs should be expanded
+     * @return the text with all tabs expanded
+     */
+    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();
     }
-    private static String whitespace;
 
     /**
      * The documentation for values() and valueOf() in Enums are set by the
@@ -903,5 +698,56 @@ public class Util {
         }
         return propertyName.substring(0, 1).toLowerCase()
                 + propertyName.substring(1);
-   }
+    }
+
+    /**
+     * In case of JavaFX mode on, filters out classes that are private,
+     * package private or having the @treatAsPrivate annotation. Those are not
+     * documented in JavaFX mode.
+     *
+     * @param classes array of classes to be filtered.
+     * @param javafx set to true if in JavaFX mode.
+     * @return list of filtered classes.
+     */
+    public static ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes,
+                                                     boolean javafx) {
+        if (!javafx) {
+            return classes;
+        }
+        final List<ClassDoc> filteredOutClasses =
+                new ArrayList<ClassDoc>(classes.length);
+        for (ClassDoc classDoc : classes) {
+            if (classDoc.isPrivate() || classDoc.isPackagePrivate()) {
+                continue;
+            }
+            Tag[] aspTags = classDoc.tags("treatAsPrivate");
+            if (aspTags != null && aspTags.length > 0) {
+                continue;
+            }
+            filteredOutClasses.add(classDoc);
+        }
+
+        return filteredOutClasses.toArray(new ClassDoc[0]);
+    }
+
+    /**
+     * Test whether the given FieldDoc is one of the declaration annotation ElementTypes
+     * defined in Java 5.
+     * Instead of testing for one of the new enum constants added in Java 8, test for
+     * the old constants. This prevents bootstrapping problems.
+     *
+     * @param elt The FieldDoc to test
+     * @return true, iff the given ElementType is one of the constants defined in Java 5
+     * @since 1.8
+     */
+    public static boolean isJava5DeclarationElementType(FieldDoc elt) {
+        return elt.name().contentEquals(ElementType.ANNOTATION_TYPE.name()) ||
+                elt.name().contentEquals(ElementType.CONSTRUCTOR.name()) ||
+                elt.name().contentEquals(ElementType.FIELD.name()) ||
+                elt.name().contentEquals(ElementType.LOCAL_VARIABLE.name()) ||
+                elt.name().contentEquals(ElementType.METHOD.name()) ||
+                elt.name().contentEquals(ElementType.PACKAGE.name()) ||
+                elt.name().contentEquals(ElementType.PARAMETER.name()) ||
+                elt.name().contentEquals(ElementType.TYPE.name());
+    }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
index fce42b5..6c98704 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
@@ -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
@@ -25,11 +25,12 @@
 
 package com.sun.tools.doclets.internal.toolkit.util;
 
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.internal.toolkit.*;
 import java.util.*;
 import java.util.regex.Pattern;
 
+import com.sun.javadoc.*;
+import com.sun.tools.doclets.internal.toolkit.*;
+
 /**
  * A data structure that encapsulates the visible members of a particular
  * type for a given class tree.  To use this data structor, you must specify
@@ -37,9 +38,10 @@ import java.util.regex.Pattern;
  * or method) and the leaf of the class tree.  The data structure will map
  * all visible members in the leaf and classes above the leaf in the tree.
  *
- * This code is not part of an API.
- * It is implementation that is subject to change.
- * Do not use it as an API
+ *  <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 Atul M Dambalkar
  * @author Jamie Ho (rewrite)
@@ -93,9 +95,9 @@ public class VisibleMemberMap {
     private final int kind;
 
     /**
-     * Deprected members should be excluded or not?
+     * The configuration this VisibleMemberMap was created with.
      */
-    private final boolean nodepr;
+    private final Configuration configuration;
 
     private static final Map<ClassDoc, ProgramElementDoc[]> propertiesCache =
             new HashMap<ClassDoc, ProgramElementDoc[]>();
@@ -106,17 +108,21 @@ public class VisibleMemberMap {
 
     /**
      * Construct a VisibleMemberMap of the given type for the given
-     * class.  If nodepr is true, exclude the deprecated members from
-     * the map.
+     * class.
      *
      * @param classdoc the class whose members are being mapped.
      * @param kind the kind of member that is being mapped.
-     * @param nodepr if true, exclude the deprecated members from the map.
+     * @param configuration the configuration to use to construct this
+     * VisibleMemberMap. If the field configuration.nodeprecated is true the
+     * deprecated members are excluded from the map. If the field
+     * configuration.javafx is true the JavaFX features are used.
      */
-    public VisibleMemberMap(ClassDoc classdoc, int kind, boolean nodepr) {
+    public VisibleMemberMap(ClassDoc classdoc,
+                            int kind,
+                            Configuration configuration) {
         this.classdoc = classdoc;
-        this.nodepr = nodepr;
         this.kind = kind;
+        this.configuration = configuration;
         new ClassMembers(classdoc, STARTLEVEL).build();
     }
 
@@ -161,7 +167,7 @@ public class VisibleMemberMap {
      * Return the package private members inherited by the class.  Only return
      * if parent is package private and not documented.
      *
-     * @param configuation the current configuration of the doclet.
+     * @param configuration the current configuration of the doclet.
      * @return the package private members inherited by the class.
      */
     private List<ProgramElementDoc> getInheritedPackagePrivateMethods(Configuration configuration) {
@@ -184,7 +190,7 @@ public class VisibleMemberMap {
      * end of the list members that are inherited by inaccessible parents. We
      * document these members in the child because the parent is not documented.
      *
-     * @param configuation the current configuration of the doclet.
+     * @param configuration the current configuration of the doclet.
      */
     public List<ProgramElementDoc> getLeafClassMembers(Configuration configuration) {
         List<ProgramElementDoc> result = getMembersFor(classdoc);
@@ -366,10 +372,10 @@ public class VisibleMemberMap {
             List<ProgramElementDoc> incllist = new ArrayList<ProgramElementDoc>();
             for (int i = 0; i < cdmembers.size(); i++) {
                 ProgramElementDoc pgmelem = cdmembers.get(i);
-                if (!found(members, pgmelem)
-                    && memberIsVisible(pgmelem)
-                    && !isOverridden(pgmelem, level)
-                    && !isTreatedAsPrivate(pgmelem)) {
+                if (!found(members, pgmelem) &&
+                    memberIsVisible(pgmelem) &&
+                    !isOverridden(pgmelem, level) &&
+                    !isTreatedAsPrivate(pgmelem)) {
                         incllist.add(pgmelem);
                 }
             }
@@ -381,14 +387,10 @@ public class VisibleMemberMap {
         }
 
         private boolean isTreatedAsPrivate(ProgramElementDoc pgmelem) {
-            if (!Configuration.getJavafxJavadoc()) {
+            if (!configuration.javafx) {
                 return false;
             }
 
-            if (pgmelem.isPrivate() || pgmelem.isPackagePrivate()) {
-                return true;
-            }
-
             Tag[] aspTags = pgmelem.tags("@treatAsPrivate");
             boolean result = (aspTags != null) && (aspTags.length > 0);
             return result;
@@ -463,7 +465,8 @@ public class VisibleMemberMap {
                 default:
                     members = new ProgramElementDoc[0];
             }
-            if (nodepr) {
+            // Deprected members should be excluded or not?
+            if (configuration.nodeprecated) {
                 return Util.excludeDeprecatedMembersAsList(members);
             }
             return Arrays.asList(members);
@@ -528,7 +531,7 @@ public class VisibleMemberMap {
 
         private ProgramElementDoc[] properties(final ClassDoc cd, final boolean filter) {
             final MethodDoc[] allMethods = cd.methods(filter);
-            final FieldDoc[] allFields = cd.fields();
+            final FieldDoc[] allFields = cd.fields(false);
 
             if (propertiesCache.containsKey(cd)) {
                 return propertiesCache.get(cd);
@@ -565,6 +568,7 @@ public class VisibleMemberMap {
                     || field.getRawCommentText().length() == 0) {
                 addToPropertiesMap(setter, propertyMethod);
                 addToPropertiesMap(getter, propertyMethod);
+                addToPropertiesMap(propertyMethod, propertyMethod);
             } else {
                 addToPropertiesMap(getter, field);
                 addToPropertiesMap(setter, field);
@@ -578,7 +582,13 @@ public class VisibleMemberMap {
                 return;
             }
             final String methodRawCommentText = propertyMethod.getRawCommentText();
-            if (null == methodRawCommentText || 0 == methodRawCommentText.length()) {
+
+            /* The second condition is required for the property buckets. In
+             * this case the comment is at the property method (not at the field)
+             * and it needs to be listed in the map.
+             */
+            if ((null == methodRawCommentText || 0 == methodRawCommentText.length())
+                    || propertyMethod.equals(commentSource)) {
                 classPropertiesMap.put(propertyMethod, commentSource);
             }
         }
@@ -592,17 +602,17 @@ public class VisibleMemberMap {
             final String fieldNameUppercased =
                     "" + Character.toUpperCase(fieldName.charAt(0))
                                             + fieldName.substring(1);
-            final String getterName;
+            final String getterNamePattern;
             final String fieldTypeName = propertyMethod.returnType().toString();
             if ("boolean".equals(fieldTypeName)
                     || fieldTypeName.endsWith("BooleanProperty")) {
-                getterName = "is" + fieldNameUppercased;
+                getterNamePattern = "(is|get)" + fieldNameUppercased;
             } else {
-                getterName = "get" + fieldNameUppercased;
+                getterNamePattern = "get" + fieldNameUppercased;
             }
 
             for (MethodDoc methodDoc : methods) {
-                if (getterName.equals(methodDoc.name())) {
+                if (Pattern.matches(getterNamePattern, methodDoc.name())) {
                     if (0 == methodDoc.parameters().length
                             && (methodDoc.isPublic() || methodDoc.isProtected())) {
                         return methodDoc;
@@ -668,17 +678,18 @@ public class VisibleMemberMap {
 
         private void checkOnPropertiesTags(MethodDoc[] members) {
             for (MethodDoc methodDoc: members) {
-                for (Tag tag: methodDoc.tags()) {
-                    String tagName = tag.name();
-                    if (tagName.equals("@propertySetter")
-                            || tagName.equals("@propertyGetter")
-                            || tagName.equals("@propertyDescription")) {
-                        if (!isPropertyGetterOrSetter(members, methodDoc)) {
-                            System.out.println(methodDoc.containingClass().qualifiedName()
-                                    +  ": "
-                                    + Util.RESOURCE_BUNDLE.getString("doclet.javafx_tag_misuse"));
+                if (methodDoc.isIncluded()) {
+                    for (Tag tag: methodDoc.tags()) {
+                        String tagName = tag.name();
+                        if (tagName.equals("@propertySetter")
+                                || tagName.equals("@propertyGetter")
+                                || tagName.equals("@propertyDescription")) {
+                            if (!isPropertyGetterOrSetter(members, methodDoc)) {
+                                configuration.message.warning(tag.position(),
+                                        "doclet.javafx_tag_misuse");
+                            }
+                            break;
                         }
-                        break;
                     }
                 }
             }
@@ -725,11 +736,7 @@ public class VisibleMemberMap {
      * @return true if this map has no visible members.
      */
     public boolean noVisibleMembers() {
-        if (Configuration.getJavafxJavadoc()) {
-            return false;
-        } else {
-            return noVisibleMembers;
-        }
+        return noVisibleMembers;
     }
 
     private ClassMember getClassMember(MethodDoc member) {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java
index 37855ae..6ecea31 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, 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,21 +26,27 @@
 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.
  *
+ *  <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 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.
@@ -48,57 +54,59 @@ public abstract class LinkFactory {
      * @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) {
+                link.addContent(getTypeAnnotationLinks(linkInfo));
+                linkInfo.type = type.asAnnotatedType().underlyingType();
+                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) {
+                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) {
@@ -107,15 +115,15 @@ public abstract class LinkFactory {
                         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));
                     }
                 }
             }
@@ -124,23 +132,37 @@ public abstract class LinkFactory {
                 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 {
-                linkInfo.displayLength += type.dimension().length();
-                linkOutput.append(type.dimension());
+                while (type != null && type.dimension().length() > 0) {
+                    if (type.asAnnotatedType() != null) {
+                        linkInfo.type = type;
+                        link.addContent(" ");
+                        link.addContent(getTypeAnnotationLinks(linkInfo));
+                        link.addContent("[]");
+                        type = type.asAnnotatedType().underlyingType().getElementType();
+                    } else {
+                        link.addContent("[]");
+                        type = type.getElementType();
+                    }
+                }
+                linkInfo.type = type;
+                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;
         }
@@ -159,7 +181,7 @@ public abstract class LinkFactory {
      *
      * @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.
@@ -167,16 +189,19 @@ public abstract class LinkFactory {
      * @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 Content getTypeAnnotationLink(LinkInfo linkInfo,
+            AnnotationDesc annotation);
+
     /**
      * Return the links to the type parameters.
      *
      * @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);
     }
 
@@ -188,8 +213,8 @@ public abstract class LinkFactory {
      *                     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();
@@ -200,44 +225,37 @@ public abstract class LinkFactory {
             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;
     }
 
-    /**
-     * Return &lt;, which is used in type parameters.  Override this
-     * if your doclet uses something different.
-     *
-     * @return return &lt;, which is used in type parameters.
-     */
-    protected String getLessThanString() {
-        return "<";
-    }
+    public Content getTypeAnnotationLinks(LinkInfo linkInfo) {
+        Content links = newContent();
+        if (linkInfo.type.asAnnotatedType() == null)
+            return links;
+        AnnotationDesc[] annotations = linkInfo.type.asAnnotatedType().annotations();
+        for (int i = 0; i < annotations.length; i++) {
+            if (i > 0) {
+                links.addContent(" ");
+            }
+            links.addContent(getTypeAnnotationLink(linkInfo, annotations[i]));
+        }
 
-    /**
-     * Return &gt;, which is used in type parameters.  Override this
-     * if your doclet uses something different.
-     *
-     * @return return &gt;, which is used in type parameters.
-     */
-    protected String getGreaterThanString() {
-        return ">";
+        links.addContent(" ");
+        return links;
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
index 4e3517d..842dd61 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, 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
@@ -27,10 +27,16 @@ package com.sun.tools.doclets.internal.toolkit.util.links;
 
 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.
  *
+ *  <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
  */
@@ -64,9 +70,15 @@ public abstract class LinkInfo {
     public boolean isTypeBound = false;
 
     /**
+     * Whether the document element is in a Java 5 declaration
+     * location or not.
+     */
+    public boolean isJava5DeclarationLocation = true;
+
+    /**
      * The label for the link.
      */
-    public String label;
+    public Content label;
 
     /**
      * True if the link should be strong.
@@ -79,7 +91,7 @@ public abstract class LinkInfo {
     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;
 
@@ -105,24 +117,11 @@ public abstract class LinkInfo {
     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
@@ -139,13 +138,17 @@ public abstract class LinkInfo {
      * @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;
         }
     }
 }
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkOutput.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkOutput.java
index 156a009..d917ee8 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkOutput.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkOutput.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -28,6 +28,11 @@ package com.sun.tools.doclets.internal.toolkit.util.links;
 /**
  * Stores output of a link.
  *
+ *  <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
  */
@@ -39,4 +44,12 @@ public interface LinkOutput {
      * @param o the object to append.
      */
     public void append(Object o);
+
+    /**
+     * Insert the given object into the output sequence.
+     *
+     * @param offset the offset.
+     * @param o the object to be inserted.
+     */
+    public void insert(int offset, Object o);
 }
diff --git a/src/share/classes/com/sun/tools/doclets/package.html b/src/share/classes/com/sun/tools/doclets/package.html
index edd8761..bc5abe1 100644
--- a/src/share/classes/com/sun/tools/doclets/package.html
+++ b/src/share/classes/com/sun/tools/doclets/package.html
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ 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
@@ -29,6 +29,6 @@
 </head>
 <body bgcolor="white">
         As of JDK version 1.5, replaced by 
-        {@link com.sun.tools.doclets.internal.toolkit.util}.
+        {@code com.sun.tools.doclets.internal.toolkit.util}.
     </body>
 </html>
diff --git a/src/share/classes/com/sun/tools/doclint/Checker.java b/src/share/classes/com/sun/tools/doclint/Checker.java
new file mode 100644
index 0000000..d7b1859
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/Checker.java
@@ -0,0 +1,850 @@
+/*
+ * 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.  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.doclint;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Deque;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Name;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic.Kind;
+
+import com.sun.source.doctree.AttributeTree;
+import com.sun.source.doctree.AuthorTree;
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocRootTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.EndElementTree;
+import com.sun.source.doctree.EntityTree;
+import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.doctree.IdentifierTree;
+import com.sun.source.doctree.InheritDocTree;
+import com.sun.source.doctree.LinkTree;
+import com.sun.source.doctree.LiteralTree;
+import com.sun.source.doctree.ParamTree;
+import com.sun.source.doctree.ReferenceTree;
+import com.sun.source.doctree.ReturnTree;
+import com.sun.source.doctree.SerialDataTree;
+import com.sun.source.doctree.SerialFieldTree;
+import com.sun.source.doctree.SinceTree;
+import com.sun.source.doctree.StartElementTree;
+import com.sun.source.doctree.TextTree;
+import com.sun.source.doctree.ThrowsTree;
+import com.sun.source.doctree.ValueTree;
+import com.sun.source.doctree.VersionTree;
+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;
+import static com.sun.tools.doclint.Messages.Group.*;
+
+
+/**
+ * Validate a doc comment.
+ *
+ * <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></p>
+ */
+public class Checker extends DocTreePathScanner<Void, Void> {
+    final Env env;
+
+    Set<Element> foundParams = new HashSet<Element>();
+    Set<TypeMirror> foundThrows = new HashSet<TypeMirror>();
+    Set<String> foundAnchors = new HashSet<String>();
+    boolean foundInheritDoc = false;
+    boolean foundReturn = false;
+
+    public enum Flag {
+        TABLE_HAS_CAPTION,
+        HAS_ELEMENT,
+        HAS_INLINE_TAG,
+        HAS_TEXT,
+        REPORTED_BAD_INLINE
+    }
+
+    static class TagStackItem {
+        final DocTree tree; // typically, but not always, StartElementTree
+        final HtmlTag tag;
+        final Set<HtmlTag.Attr> attrs;
+        final Set<Flag> flags;
+        TagStackItem(DocTree tree, HtmlTag tag) {
+            this.tree = tree;
+            this.tag = tag;
+            attrs = EnumSet.noneOf(HtmlTag.Attr.class);
+            flags = EnumSet.noneOf(Flag.class);
+        }
+        @Override
+        public String toString() {
+            return String.valueOf(tag);
+        }
+    }
+
+    private Deque<TagStackItem> tagStack; // TODO: maybe want to record starting tree as well
+    private HtmlTag currHeaderTag;
+
+    private final int implicitHeaderLevel;
+
+    // <editor-fold defaultstate="collapsed" desc="Top level">
+
+    Checker(Env env) {
+        env.getClass();
+        this.env = env;
+        tagStack = new LinkedList<TagStackItem>();
+        implicitHeaderLevel = env.implicitHeaderLevel;
+    }
+
+    public Void scan(DocCommentTree tree, TreePath p) {
+        env.setCurrent(p, tree);
+
+        boolean isOverridingMethod = !env.currOverriddenMethods.isEmpty();
+
+        if (tree == null) {
+            if (!isSynthetic() && !isOverridingMethod)
+                reportMissing("dc.missing.comment");
+            return null;
+        }
+
+        tagStack.clear();
+        currHeaderTag = null;
+
+        foundParams.clear();
+        foundThrows.clear();
+        foundInheritDoc = false;
+        foundReturn = false;
+
+        scan(new DocTreePath(p, tree), null);
+
+        if (!isOverridingMethod) {
+            switch (env.currElement.getKind()) {
+                case METHOD:
+                case CONSTRUCTOR: {
+                    ExecutableElement ee = (ExecutableElement) env.currElement;
+                    checkParamsDocumented(ee.getTypeParameters());
+                    checkParamsDocumented(ee.getParameters());
+                    switch (ee.getReturnType().getKind()) {
+                        case VOID:
+                        case NONE:
+                            break;
+                        default:
+                            if (!foundReturn
+                                    && !foundInheritDoc
+                                    && !env.types.isSameType(ee.getReturnType(), env.java_lang_Void)) {
+                                reportMissing("dc.missing.return");
+                            }
+                    }
+                    checkThrowsDocumented(ee.getThrownTypes());
+                }
+            }
+        }
+
+        return null;
+    }
+
+    private void reportMissing(String code, Object... args) {
+        env.messages.report(MISSING, Kind.WARNING, env.currPath.getLeaf(), code, args);
+    }
+
+    @Override
+    public Void visitDocComment(DocCommentTree tree, Void ignore) {
+        super.visitDocComment(tree, ignore);
+        for (TagStackItem tsi: tagStack) {
+            if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
+                    && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
+                StartElementTree t = (StartElementTree) tsi.tree;
+                env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
+            }
+        }
+        return null;
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Text and entities.">
+
+    @Override
+    public Void visitText(TextTree tree, Void ignore) {
+        if (hasNonWhitespace(tree)) {
+            checkAllowsText(tree);
+            markEnclosingTag(Flag.HAS_TEXT);
+        }
+        return null;
+    }
+
+    @Override
+    public Void visitEntity(EntityTree tree, Void ignore) {
+        checkAllowsText(tree);
+        markEnclosingTag(Flag.HAS_TEXT);
+        String name = tree.getName().toString();
+        if (name.startsWith("#")) {
+            int v = name.toLowerCase().startsWith("#x")
+                    ? Integer.parseInt(name.substring(2), 16)
+                    : Integer.parseInt(name.substring(1), 10);
+            if (!Entity.isValid(v)) {
+                env.messages.error(HTML, tree, "dc.entity.invalid", name);
+            }
+        } else if (!Entity.isValid(name)) {
+            env.messages.error(HTML, tree, "dc.entity.invalid", name);
+        }
+        return null;
+    }
+
+    void checkAllowsText(DocTree tree) {
+        TagStackItem top = tagStack.peek();
+        if (top != null
+                && top.tree.getKind() == DocTree.Kind.START_ELEMENT
+                && !top.tag.acceptsText()) {
+            if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
+                env.messages.error(HTML, tree, "dc.text.not.allowed",
+                        ((StartElementTree) top.tree).getName());
+            }
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="HTML elements">
+
+    @Override
+    public Void visitStartElement(StartElementTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_ELEMENT);
+        final Name treeName = tree.getName();
+        final HtmlTag t = HtmlTag.get(treeName);
+        if (t == null) {
+            env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
+        } else {
+            boolean done = false;
+            for (TagStackItem tsi: tagStack) {
+                if (tsi.tag.accepts(t)) {
+                    while (tagStack.peek() != tsi) tagStack.pop();
+                    done = true;
+                    break;
+                } else if (tsi.tag.endKind != HtmlTag.EndKind.OPTIONAL) {
+                    done = true;
+                    break;
+                }
+            }
+            if (!done && HtmlTag.BODY.accepts(t)) {
+                tagStack.clear();
+            }
+
+            checkStructure(tree, t);
+
+            // tag specific checks
+            switch (t) {
+                // check for out of sequence headers, such as <h1>...</h1>  <h3>...</h3>
+                case H1: case H2: case H3: case H4: case H5: case H6:
+                    checkHeader(tree, t);
+                    break;
+            }
+
+            if (t.flags.contains(HtmlTag.Flag.NO_NEST)) {
+                for (TagStackItem i: tagStack) {
+                    if (t == i.tag) {
+                        env.messages.warning(HTML, tree, "dc.tag.nested.not.allowed", treeName);
+                        break;
+                    }
+                }
+            }
+        }
+
+        // check for self closing tags, such as <a id="name"/>
+        if (tree.isSelfClosing()) {
+            env.messages.error(HTML, tree, "dc.tag.self.closing", treeName);
+        }
+
+        try {
+            TagStackItem parent = tagStack.peek();
+            TagStackItem top = new TagStackItem(tree, t);
+            tagStack.push(top);
+
+            super.visitStartElement(tree, ignore);
+
+            // handle attributes that may or may not have been found in start element
+            if (t != null) {
+                switch (t) {
+                    case CAPTION:
+                        if (parent != null && parent.tag == HtmlTag.TABLE)
+                            parent.flags.add(Flag.TABLE_HAS_CAPTION);
+                        break;
+
+                    case IMG:
+                        if (!top.attrs.contains(HtmlTag.Attr.ALT))
+                            env.messages.error(ACCESSIBILITY, tree, "dc.no.alt.attr.for.image");
+                        break;
+                }
+            }
+
+            return null;
+        } finally {
+
+            if (t == null || t.endKind == HtmlTag.EndKind.NONE)
+                tagStack.pop();
+        }
+    }
+
+    private void checkStructure(StartElementTree tree, HtmlTag t) {
+        Name treeName = tree.getName();
+        TagStackItem top = tagStack.peek();
+        switch (t.blockType) {
+            case BLOCK:
+                if (top == null || top.tag.accepts(t))
+                    return;
+
+                switch (top.tree.getKind()) {
+                    case START_ELEMENT: {
+                        if (top.tag.blockType == HtmlTag.BlockType.INLINE) {
+                            Name name = ((StartElementTree) top.tree).getName();
+                            env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.element",
+                                    treeName, name);
+                            return;
+                        }
+                    }
+                    break;
+
+                    case LINK:
+                    case LINK_PLAIN: {
+                        String name = top.tree.getKind().tagName;
+                        env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.tag",
+                                treeName, name);
+                        return;
+                    }
+                }
+                break;
+
+            case INLINE:
+                if (top == null || top.tag.accepts(t))
+                    return;
+                break;
+
+            case LIST_ITEM:
+            case TABLE_ITEM:
+                if (top != null) {
+                    // reset this flag so subsequent bad inline content gets reported
+                    top.flags.remove(Flag.REPORTED_BAD_INLINE);
+                    if (top.tag.accepts(t))
+                        return;
+                }
+                break;
+
+            case OTHER:
+                env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName);
+                return;
+        }
+
+        env.messages.error(HTML, tree, "dc.tag.not.allowed.here", treeName);
+    }
+
+    private void checkHeader(StartElementTree tree, HtmlTag tag) {
+        // verify the new tag
+        if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
+            if (currHeaderTag == null) {
+                env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
+            } else {
+                env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
+                    tag, currHeaderTag);
+            }
+        }
+
+        currHeaderTag = tag;
+    }
+
+    private int getHeaderLevel(HtmlTag tag) {
+        if (tag == null)
+            return implicitHeaderLevel;
+        switch (tag) {
+            case H1: return 1;
+            case H2: return 2;
+            case H3: return 3;
+            case H4: return 4;
+            case H5: return 5;
+            case H6: return 6;
+            default: throw new IllegalArgumentException();
+        }
+    }
+
+    @Override
+    public Void visitEndElement(EndElementTree tree, Void ignore) {
+        final Name treeName = tree.getName();
+        final HtmlTag t = HtmlTag.get(treeName);
+        if (t == null) {
+            env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
+        } else if (t.endKind == HtmlTag.EndKind.NONE) {
+            env.messages.error(HTML, tree, "dc.tag.end.not.permitted", treeName);
+        } else {
+            boolean done = false;
+            while (!tagStack.isEmpty()) {
+                TagStackItem top = tagStack.peek();
+                if (t == top.tag) {
+                    switch (t) {
+                        case TABLE:
+                            if (!top.attrs.contains(HtmlTag.Attr.SUMMARY)
+                                    && !top.flags.contains(Flag.TABLE_HAS_CAPTION)) {
+                                env.messages.error(ACCESSIBILITY, tree,
+                                        "dc.no.summary.or.caption.for.table");
+                            }
+                    }
+                    if (t.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
+                            && !top.flags.contains(Flag.HAS_TEXT)
+                            && !top.flags.contains(Flag.HAS_ELEMENT)
+                            && !top.flags.contains(Flag.HAS_INLINE_TAG)) {
+                        env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
+                    }
+                    tagStack.pop();
+                    done = true;
+                    break;
+                } else if (top.tag == null || top.tag.endKind != HtmlTag.EndKind.REQUIRED) {
+                    tagStack.pop();
+                } else {
+                    boolean found = false;
+                    for (TagStackItem si: tagStack) {
+                        if (si.tag == t) {
+                            found = true;
+                            break;
+                        }
+                    }
+                    if (found && top.tree.getKind() == DocTree.Kind.START_ELEMENT) {
+                        env.messages.error(HTML, top.tree, "dc.tag.start.unmatched",
+                                ((StartElementTree) top.tree).getName());
+                        tagStack.pop();
+                    } else {
+                        env.messages.error(HTML, tree, "dc.tag.end.unexpected", treeName);
+                        done = true;
+                        break;
+                    }
+                }
+            }
+
+            if (!done && tagStack.isEmpty()) {
+                env.messages.error(HTML, tree, "dc.tag.end.unexpected", treeName);
+            }
+        }
+
+        return super.visitEndElement(tree, ignore);
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="HTML attributes">
+
+    @Override @SuppressWarnings("fallthrough")
+    public Void visitAttribute(AttributeTree tree, Void ignore) {
+        HtmlTag currTag = tagStack.peek().tag;
+        if (currTag != null) {
+            Name name = tree.getName();
+            HtmlTag.Attr attr = currTag.getAttr(name);
+            if (attr != null) {
+                boolean first = tagStack.peek().attrs.add(attr);
+                if (!first)
+                    env.messages.error(HTML, tree, "dc.attr.repeated", name);
+            }
+            AttrKind k = currTag.getAttrKind(name);
+            switch (k) {
+                case OK:
+                    break;
+
+                case INVALID:
+                    env.messages.error(HTML, tree, "dc.attr.unknown", name);
+                    break;
+
+                case OBSOLETE:
+                    env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete", name);
+                    break;
+
+                case USE_CSS:
+                    env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete.use.css", name);
+                    break;
+            }
+
+            if (attr != null) {
+                switch (attr) {
+                    case NAME:
+                        if (currTag != HtmlTag.A) {
+                            break;
+                        }
+                        // fallthrough
+                    case ID:
+                        String value = getAttrValue(tree);
+                        if (value == null) {
+                            env.messages.error(HTML, tree, "dc.anchor.value.missing");
+                        } else {
+                            if (!validName.matcher(value).matches()) {
+                                env.messages.error(HTML, tree, "dc.invalid.anchor", value);
+                            }
+                            if (!foundAnchors.add(value)) {
+                                env.messages.error(HTML, tree, "dc.anchor.already.defined", value);
+                            }
+                        }
+                        break;
+
+                    case HREF:
+                        if (currTag == HtmlTag.A) {
+                            String v = getAttrValue(tree);
+                            if (v == null || v.isEmpty()) {
+                                env.messages.error(HTML, tree, "dc.attr.lacks.value");
+                            } else {
+                                Matcher m = docRoot.matcher(v);
+                                if (m.matches()) {
+                                    String rest = m.group(2);
+                                    if (!rest.isEmpty())
+                                        checkURI(tree, rest);
+                                } else {
+                                    checkURI(tree, v);
+                                }
+                            }
+                        }
+                        break;
+
+                    case VALUE:
+                        if (currTag == HtmlTag.LI) {
+                            String v = getAttrValue(tree);
+                            if (v == null || v.isEmpty()) {
+                                env.messages.error(HTML, tree, "dc.attr.lacks.value");
+                            } else if (!validNumber.matcher(v).matches()) {
+                                env.messages.error(HTML, tree, "dc.attr.not.number");
+                            }
+                        }
+                        break;
+                }
+            }
+        }
+
+        // TODO: basic check on value
+
+        return super.visitAttribute(tree, ignore);
+    }
+
+    // http://www.w3.org/TR/html401/types.html#type-name
+    private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*");
+
+    private static final Pattern validNumber = Pattern.compile("-?[0-9]+");
+
+    // pattern to remove leading {@docRoot}/?
+    private static final Pattern docRoot = Pattern.compile("(?i)(\\{@docRoot *\\}/?)?(.*)");
+
+    private String getAttrValue(AttributeTree tree) {
+        if (tree.getValue() == null)
+            return null;
+
+        StringWriter sw = new StringWriter();
+        try {
+            new DocPretty(sw).print(tree.getValue());
+        } catch (IOException e) {
+            // cannot happen
+        }
+        // ignore potential use of entities for now
+        return sw.toString();
+    }
+
+    private void checkURI(AttributeTree tree, String uri) {
+        try {
+            URI u = new URI(uri);
+        } catch (URISyntaxException e) {
+            env.messages.error(HTML, tree, "dc.invalid.uri", uri);
+        }
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="javadoc tags">
+
+    @Override
+    public Void visitAuthor(AuthorTree tree, Void ignore) {
+        warnIfEmpty(tree, tree.getName());
+        return super.visitAuthor(tree, ignore);
+    }
+
+    @Override
+    public Void visitDocRoot(DocRootTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_INLINE_TAG);
+        return super.visitDocRoot(tree, ignore);
+    }
+
+    @Override
+    public Void visitInheritDoc(InheritDocTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_INLINE_TAG);
+        // TODO: verify on overridden method
+        foundInheritDoc = true;
+        return super.visitInheritDoc(tree, ignore);
+    }
+
+    @Override
+    public Void visitLink(LinkTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_INLINE_TAG);
+        // simulate inline context on tag stack
+        HtmlTag t = (tree.getKind() == DocTree.Kind.LINK)
+                ? HtmlTag.CODE : HtmlTag.SPAN;
+        tagStack.push(new TagStackItem(tree, t));
+        try {
+            return super.visitLink(tree, ignore);
+        } finally {
+            tagStack.pop();
+        }
+    }
+
+    @Override
+    public Void visitLiteral(LiteralTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_INLINE_TAG);
+        if (tree.getKind() == DocTree.Kind.CODE) {
+            for (TagStackItem tsi: tagStack) {
+                if (tsi.tag == HtmlTag.CODE) {
+                    env.messages.warning(HTML, tree, "dc.tag.code.within.code");
+                    break;
+                }
+            }
+        }
+        return super.visitLiteral(tree, ignore);
+    }
+
+    @Override
+    @SuppressWarnings("fallthrough")
+    public Void visitParam(ParamTree tree, Void ignore) {
+        boolean typaram = tree.isTypeParameter();
+        IdentifierTree nameTree = tree.getName();
+        Element paramElement = nameTree != null ? env.trees.getElement(new DocTreePath(getCurrentPath(), nameTree)) : null;
+
+        if (paramElement == null) {
+            switch (env.currElement.getKind()) {
+                case CLASS: case INTERFACE: {
+                    if (!typaram) {
+                        env.messages.error(REFERENCE, tree, "dc.invalid.param");
+                        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;
+            }
+        } else {
+            foundParams.add(paramElement);
+        }
+
+        warnIfEmpty(tree, tree.getDescription());
+        return super.visitParam(tree, ignore);
+    }
+
+    private void checkParamsDocumented(List<? extends Element> list) {
+        if (foundInheritDoc)
+            return;
+
+        for (Element e: list) {
+            if (!foundParams.contains(e)) {
+                CharSequence paramName = (e.getKind() == ElementKind.TYPE_PARAMETER)
+                        ? "<" + e.getSimpleName() + ">"
+                        : e.getSimpleName();
+                reportMissing("dc.missing.param", paramName);
+            }
+        }
+    }
+
+    @Override
+    public Void visitReference(ReferenceTree tree, Void ignore) {
+        Element e = env.trees.getElement(getCurrentPath());
+        if (e == null)
+            env.messages.error(REFERENCE, tree, "dc.ref.not.found");
+        return super.visitReference(tree, ignore);
+    }
+
+    @Override
+    public Void visitReturn(ReturnTree tree, Void ignore) {
+        Element e = env.trees.getElement(env.currPath);
+        if (e.getKind() != ElementKind.METHOD
+                || ((ExecutableElement) e).getReturnType().getKind() == TypeKind.VOID)
+            env.messages.error(REFERENCE, tree, "dc.invalid.return");
+        foundReturn = true;
+        warnIfEmpty(tree, tree.getDescription());
+        return super.visitReturn(tree, ignore);
+    }
+
+    @Override
+    public Void visitSerialData(SerialDataTree tree, Void ignore) {
+        warnIfEmpty(tree, tree.getDescription());
+        return super.visitSerialData(tree, ignore);
+    }
+
+    @Override
+    public Void visitSerialField(SerialFieldTree tree, Void ignore) {
+        warnIfEmpty(tree, tree.getDescription());
+        return super.visitSerialField(tree, ignore);
+    }
+
+    @Override
+    public Void visitSince(SinceTree tree, Void ignore) {
+        warnIfEmpty(tree, tree.getBody());
+        return super.visitSince(tree, ignore);
+    }
+
+    @Override
+    public Void visitThrows(ThrowsTree tree, Void ignore) {
+        ReferenceTree exName = tree.getExceptionName();
+        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
+                && env.types.isAssignable(ex.asType(), env.java_lang_Throwable)) {
+            switch (env.currElement.getKind()) {
+                case CONSTRUCTOR:
+                case METHOD:
+                    if (isCheckedException(ex.asType())) {
+                        ExecutableElement ee = (ExecutableElement) env.currElement;
+                        checkThrowsDeclared(exName, ex.asType(), ee.getThrownTypes());
+                    }
+                    break;
+                default:
+                    env.messages.error(REFERENCE, tree, "dc.invalid.throws");
+            }
+        } else {
+            env.messages.error(REFERENCE, tree, "dc.invalid.throws");
+        }
+        warnIfEmpty(tree, tree.getDescription());
+        return scan(tree.getDescription(), ignore);
+    }
+
+    private void checkThrowsDeclared(ReferenceTree tree, TypeMirror t, List<? extends TypeMirror> list) {
+        boolean found = false;
+        for (TypeMirror tl : list) {
+            if (env.types.isAssignable(t, tl)) {
+                foundThrows.add(tl);
+                found = true;
+            }
+        }
+        if (!found)
+            env.messages.error(REFERENCE, tree, "dc.exception.not.thrown", t);
+    }
+
+    private void checkThrowsDocumented(List<? extends TypeMirror> list) {
+        if (foundInheritDoc)
+            return;
+
+        for (TypeMirror tl: list) {
+            if (isCheckedException(tl) && !foundThrows.contains(tl))
+                reportMissing("dc.missing.throws", tl);
+        }
+    }
+
+    @Override
+    public Void visitValue(ValueTree tree, Void ignore) {
+        markEnclosingTag(Flag.HAS_INLINE_TAG);
+        return super.visitValue(tree, ignore);
+    }
+
+    @Override
+    public Void visitVersion(VersionTree tree, Void ignore) {
+        warnIfEmpty(tree, tree.getBody());
+        return super.visitVersion(tree, ignore);
+    }
+
+    @Override
+    public Void visitErroneous(ErroneousTree tree, Void ignore) {
+        env.messages.error(SYNTAX, tree, null, tree.getDiagnostic().getMessage(null));
+        return null;
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Utility methods">
+
+    private boolean isCheckedException(TypeMirror t) {
+        return !(env.types.isAssignable(t, env.java_lang_Error)
+                || env.types.isAssignable(t, env.java_lang_RuntimeException));
+    }
+
+    private boolean isSynthetic() {
+        switch (env.currElement.getKind()) {
+            case CONSTRUCTOR:
+                // A synthetic default constructor has the same pos as the
+                // enclosing class
+                TreePath p = env.currPath;
+                return env.getPos(p) == env.getPos(p.getParentPath());
+        }
+        return false;
+    }
+
+    void markEnclosingTag(Flag flag) {
+        TagStackItem top = tagStack.peek();
+        if (top != null)
+            top.flags.add(flag);
+    }
+
+    String toString(TreePath p) {
+        StringBuilder sb = new StringBuilder("TreePath[");
+        toString(p, sb);
+        sb.append("]");
+        return sb.toString();
+    }
+
+    void toString(TreePath p, StringBuilder sb) {
+        TreePath parent = p.getParentPath();
+        if (parent != null) {
+            toString(parent, sb);
+            sb.append(",");
+        }
+       sb.append(p.getLeaf().getKind()).append(":").append(env.getPos(p)).append(":S").append(env.getStartPos(p));
+    }
+
+    void warnIfEmpty(DocTree tree, List<? extends DocTree> list) {
+        for (DocTree d: list) {
+            switch (d.getKind()) {
+                case TEXT:
+                    if (hasNonWhitespace((TextTree) d))
+                        return;
+                    break;
+                default:
+                    return;
+            }
+        }
+        env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName);
+    }
+
+    boolean hasNonWhitespace(TextTree tree) {
+        String s = tree.getBody();
+        for (int i = 0; i < s.length(); i++) {
+            if (!Character.isWhitespace(s.charAt(i)))
+                return true;
+        }
+        return false;
+    }
+
+    // </editor-fold>
+
+}
diff --git a/src/share/classes/com/sun/tools/doclint/DocLint.java b/src/share/classes/com/sun/tools/doclint/DocLint.java
new file mode 100644
index 0000000..0e5be61
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/DocLint.java
@@ -0,0 +1,360 @@
+/*
+ * 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.  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.doclint;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import javax.lang.model.element.Name;
+import javax.tools.StandardLocation;
+
+import com.sun.source.doctree.DocCommentTree;
+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.JavacTask;
+import com.sun.source.util.Plugin;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * Multi-function entry point for the doc check utility.
+ *
+ * This class can be invoked in the following ways:
+ * <ul>
+ * <li>From the command line
+ * <li>From javac, as a plugin
+ * <li>Directly, via a simple API
+ * </ul>
+ *
+ * <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></p>
+ */
+public class DocLint implements Plugin {
+
+    public static final String XMSGS_OPTION = "-Xmsgs";
+    public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
+    private static final String STATS = "-stats";
+    public static final String XIMPLICIT_HEADERS = "-XimplicitHeaders:";
+
+    // <editor-fold defaultstate="collapsed" desc="Command-line entry point">
+    public static void main(String... args) {
+        DocLint dl = new DocLint();
+        try {
+            dl.run(args);
+        } catch (BadArgs e) {
+            System.err.println(e.getMessage());
+            System.exit(1);
+        } catch (IOException e) {
+            System.err.println(dl.localize("dc.main.ioerror", e.getLocalizedMessage()));
+            System.exit(2);
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Simple API">
+
+    public class BadArgs extends Exception {
+        private static final long serialVersionUID = 0;
+        BadArgs(String code, Object... args) {
+            super(localize(code, args));
+            this.code = code;
+            this.args = args;
+        }
+
+        final String code;
+        final Object[] args;
+    }
+
+    /**
+     * Simple API entry point.
+     */
+    public void run(String... args) throws BadArgs, IOException {
+        PrintWriter out = new PrintWriter(System.out);
+        try {
+            run(out, args);
+        } finally {
+            out.flush();
+        }
+    }
+
+    public void run(PrintWriter out, String... args) throws BadArgs, IOException {
+        env = new Env();
+        processArgs(args);
+
+        if (needHelp)
+            showHelp(out);
+
+        if (javacFiles.isEmpty()) {
+            if (!needHelp)
+                out.println(localize("dc.main.no.files.given"));
+        }
+
+        JavacTool tool = JavacTool.create();
+
+        JavacFileManager fm = new JavacFileManager(new Context(), false, null);
+        fm.setSymbolFileEnabled(false);
+        fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, javacBootClassPath);
+        fm.setLocation(StandardLocation.CLASS_PATH, javacClassPath);
+        fm.setLocation(StandardLocation.SOURCE_PATH, javacSourcePath);
+
+        JavacTask task = tool.getTask(out, fm, null, javacOpts, null,
+                fm.getJavaFileObjectsFromFiles(javacFiles));
+        Iterable<? extends CompilationUnitTree> units = task.parse();
+        ((JavacTaskImpl) task).enter();
+
+        env.init(task);
+        checker = new Checker(env);
+
+        DeclScanner ds = new DeclScanner() {
+            @Override
+            void visitDecl(Tree tree, Name name) {
+                TreePath p = getCurrentPath();
+                DocCommentTree dc = env.trees.getDocCommentTree(p);
+
+                checker.scan(dc, p);
+            }
+        };
+
+        ds.scan(units, null);
+
+        reportStats(out);
+
+        Context ctx = ((JavacTaskImpl) task).getContext();
+        JavaCompiler c = JavaCompiler.instance(ctx);
+        c.printCount("error", c.errorCount());
+        c.printCount("warn", c.warningCount());
+    }
+
+    void processArgs(String... args) throws BadArgs {
+        javacOpts = new ArrayList<String>();
+        javacFiles = new ArrayList<File>();
+
+        if (args.length == 0)
+            needHelp = true;
+
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.matches("-Xmax(errs|warns)") && i + 1 < args.length) {
+                if (args[++i].matches("[0-9]+")) {
+                    javacOpts.add(arg);
+                    javacOpts.add(args[i]);
+                } else {
+                    throw new BadArgs("dc.bad.value.for.option", arg, args[i]);
+                }
+            } else if (arg.equals(STATS)) {
+                env.messages.setStatsEnabled(true);
+            } else if (arg.equals("-bootclasspath") && i + 1 < args.length) {
+                javacBootClassPath = splitPath(args[++i]);
+            } else if (arg.equals("-classpath") && i + 1 < args.length) {
+                javacClassPath = splitPath(args[++i]);
+            } else if (arg.equals("-cp") && i + 1 < args.length) {
+                javacClassPath = splitPath(args[++i]);
+            } else if (arg.equals("-sourcepath") && i + 1 < args.length) {
+                javacSourcePath = splitPath(args[++i]);
+            } else if (arg.equals(XMSGS_OPTION)) {
+                env.messages.setOptions(null);
+            } else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
+                env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
+            } else if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")
+                    || arg.equals("-?") || arg.equals("-usage")) {
+                needHelp = true;
+            } else if (arg.startsWith("-")) {
+                throw new BadArgs("dc.bad.option", arg);
+            } else {
+                while (i < args.length)
+                    javacFiles.add(new File(args[i++]));
+            }
+        }
+    }
+
+    void showHelp(PrintWriter out) {
+        String msg = localize("dc.main.usage");
+        for (String line: msg.split("\n"))
+            out.println(line);
+    }
+
+    List<File> splitPath(String path) {
+        List<File> files = new ArrayList<File>();
+        for (String f: path.split(File.pathSeparator)) {
+            if (f.length() > 0)
+                files.add(new File(f));
+        }
+        return files;
+    }
+
+    List<File> javacBootClassPath;
+    List<File> javacClassPath;
+    List<File> javacSourcePath;
+    List<String> javacOpts;
+    List<File> javacFiles;
+    boolean needHelp = false;
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="javac Plugin">
+
+    @Override
+    public String getName() {
+        return "doclint";
+    }
+
+    @Override
+    public void init(JavacTask task, String... args) {
+        init(task, args, true);
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Embedding API">
+
+    public void init(JavacTask task, String[] args, boolean addTaskListener) {
+        env = new Env();
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.equals(XMSGS_OPTION)) {
+                env.messages.setOptions(null);
+            } else if (arg.startsWith(XMSGS_CUSTOM_PREFIX)) {
+                env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
+            } else if (arg.matches(XIMPLICIT_HEADERS + "[1-6]")) {
+                char ch = arg.charAt(arg.length() - 1);
+                env.setImplicitHeaders(Character.digit(ch, 10));
+            } else
+                throw new IllegalArgumentException(arg);
+        }
+        env.init(task);
+
+        checker = new Checker(env);
+
+        if (addTaskListener) {
+            final DeclScanner ds = new DeclScanner() {
+                @Override
+                void visitDecl(Tree tree, Name name) {
+                    TreePath p = getCurrentPath();
+                    DocCommentTree dc = env.trees.getDocCommentTree(p);
+
+                    checker.scan(dc, p);
+                }
+            };
+
+            TaskListener tl = new TaskListener() {
+                @Override
+                public void started(TaskEvent e) {
+                    return;
+                }
+
+                @Override
+                public void finished(TaskEvent e) {
+                    switch (e.getKind()) {
+                        case ENTER:
+                            ds.scan(e.getCompilationUnit(), null);
+                    }
+                }
+            };
+
+            task.addTaskListener(tl);
+        }
+    }
+
+    public void scan(TreePath p) {
+        DocCommentTree dc = env.trees.getDocCommentTree(p);
+        checker.scan(dc, p);
+    }
+
+    public void reportStats(PrintWriter out) {
+        env.messages.reportStats(out);
+    }
+
+    // </editor-fold>
+
+    Env env;
+    Checker checker;
+
+    public static boolean isValidOption(String opt) {
+        if (opt.equals(XMSGS_OPTION))
+           return true;
+        if (opt.startsWith(XMSGS_CUSTOM_PREFIX))
+           return Messages.Options.isValidOptions(opt.substring(XMSGS_CUSTOM_PREFIX.length()));
+        return false;
+    }
+
+    private String localize(String code, Object... args) {
+        Messages m = (env != null) ? env.messages : new Messages(null);
+        return m.localize(code, args);
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="DeclScanner">
+
+    static abstract class DeclScanner extends TreePathScanner<Void, Void> {
+        abstract void visitDecl(Tree tree, Name name);
+
+        @Override
+        public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+            if (tree.getPackageName() != null) {
+                visitDecl(tree, null);
+            }
+            return super.visitCompilationUnit(tree, ignore);
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            visitDecl(tree, tree.getSimpleName());
+            return super.visitClass(tree, ignore);
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            visitDecl(tree, tree.getName());
+            //return super.visitMethod(tree, ignore);
+            return null;
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            visitDecl(tree, tree.getName());
+            return super.visitVariable(tree, ignore);
+        }
+    }
+
+    // </editor-fold>
+
+}
diff --git a/src/share/classes/com/sun/tools/doclint/Entity.java b/src/share/classes/com/sun/tools/doclint/Entity.java
new file mode 100644
index 0000000..0d6d762
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/Entity.java
@@ -0,0 +1,326 @@
+/*
+ * 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.  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.doclint;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Table of entities defined in HTML 4.01.
+ *
+ * <p> Derived from
+ * <a href="http://www.w3.org/TR/html4/sgml/entities.html">Character entity references in HTML 4</a>.
+ *
+ * The name of the member follows the name of the entity,
+ * except when it clashes with a keyword, in which case
+ * it is prefixed by '_'.
+ *
+ * <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></p>
+ */
+public enum Entity {
+    nbsp(160),
+    iexcl(161),
+    cent(162),
+    pound(163),
+    curren(164),
+    yen(165),
+    brvbar(166),
+    sect(167),
+    uml(168),
+    copy(169),
+    ordf(170),
+    laquo(171),
+    not(172),
+    shy(173),
+    reg(174),
+    macr(175),
+    deg(176),
+    plusmn(177),
+    sup2(178),
+    sup3(179),
+    acute(180),
+    micro(181),
+    para(182),
+    middot(183),
+    cedil(184),
+    sup1(185),
+    ordm(186),
+    raquo(187),
+    frac14(188),
+    frac12(189),
+    frac34(190),
+    iquest(191),
+    Agrave(192),
+    Aacute(193),
+    Acirc(194),
+    Atilde(195),
+    Auml(196),
+    Aring(197),
+    AElig(198),
+    Ccedil(199),
+    Egrave(200),
+    Eacute(201),
+    Ecirc(202),
+    Euml(203),
+    Igrave(204),
+    Iacute(205),
+    Icirc(206),
+    Iuml(207),
+    ETH(208),
+    Ntilde(209),
+    Ograve(210),
+    Oacute(211),
+    Ocirc(212),
+    Otilde(213),
+    Ouml(214),
+    times(215),
+    Oslash(216),
+    Ugrave(217),
+    Uacute(218),
+    Ucirc(219),
+    Uuml(220),
+    Yacute(221),
+    THORN(222),
+    szlig(223),
+    agrave(224),
+    aacute(225),
+    acirc(226),
+    atilde(227),
+    auml(228),
+    aring(229),
+    aelig(230),
+    ccedil(231),
+    egrave(232),
+    eacute(233),
+    ecirc(234),
+    euml(235),
+    igrave(236),
+    iacute(237),
+    icirc(238),
+    iuml(239),
+    eth(240),
+    ntilde(241),
+    ograve(242),
+    oacute(243),
+    ocirc(244),
+    otilde(245),
+    ouml(246),
+    divide(247),
+    oslash(248),
+    ugrave(249),
+    uacute(250),
+    ucirc(251),
+    uuml(252),
+    yacute(253),
+    thorn(254),
+    yuml(255),
+    fnof(402),
+    Alpha(913),
+    Beta(914),
+    Gamma(915),
+    Delta(916),
+    Epsilon(917),
+    Zeta(918),
+    Eta(919),
+    Theta(920),
+    Iota(921),
+    Kappa(922),
+    Lambda(923),
+    Mu(924),
+    Nu(925),
+    Xi(926),
+    Omicron(927),
+    Pi(928),
+    Rho(929),
+    Sigma(931),
+    Tau(932),
+    Upsilon(933),
+    Phi(934),
+    Chi(935),
+    Psi(936),
+    Omega(937),
+    alpha(945),
+    beta(946),
+    gamma(947),
+    delta(948),
+    epsilon(949),
+    zeta(950),
+    eta(951),
+    theta(952),
+    iota(953),
+    kappa(954),
+    lambda(955),
+    mu(956),
+    nu(957),
+    xi(958),
+    omicron(959),
+    pi(960),
+    rho(961),
+    sigmaf(962),
+    sigma(963),
+    tau(964),
+    upsilon(965),
+    phi(966),
+    chi(967),
+    psi(968),
+    omega(969),
+    thetasym(977),
+    upsih(978),
+    piv(982),
+    bull(8226),
+    hellip(8230),
+    prime(8242),
+    Prime(8243),
+    oline(8254),
+    frasl(8260),
+    weierp(8472),
+    image(8465),
+    real(8476),
+    trade(8482),
+    alefsym(8501),
+    larr(8592),
+    uarr(8593),
+    rarr(8594),
+    darr(8595),
+    harr(8596),
+    crarr(8629),
+    lArr(8656),
+    uArr(8657),
+    rArr(8658),
+    dArr(8659),
+    hArr(8660),
+    forall(8704),
+    part(8706),
+    exist(8707),
+    empty(8709),
+    nabla(8711),
+    isin(8712),
+    notin(8713),
+    ni(8715),
+    prod(8719),
+    sum(8721),
+    minus(8722),
+    lowast(8727),
+    radic(8730),
+    prop(8733),
+    infin(8734),
+    ang(8736),
+    and(8743),
+    or(8744),
+    cap(8745),
+    cup(8746),
+    _int(8747),
+    there4(8756),
+    sim(8764),
+    cong(8773),
+    asymp(8776),
+    ne(8800),
+    equiv(8801),
+    le(8804),
+    ge(8805),
+    sub(8834),
+    sup(8835),
+    nsub(8836),
+    sube(8838),
+    supe(8839),
+    oplus(8853),
+    otimes(8855),
+    perp(8869),
+    sdot(8901),
+    lceil(8968),
+    rceil(8969),
+    lfloor(8970),
+    rfloor(8971),
+    lang(9001),
+    rang(9002),
+    loz(9674),
+    spades(9824),
+    clubs(9827),
+    hearts(9829),
+    diams(9830),
+    quot(34),
+    amp(38),
+    lt(60),
+    gt(62),
+    OElig(338),
+    oelig(339),
+    Scaron(352),
+    scaron(353),
+    Yuml(376),
+    circ(710),
+    tilde(732),
+    ensp(8194),
+    emsp(8195),
+    thinsp(8201),
+    zwnj(8204),
+    zwj(8205),
+    lrm(8206),
+    rlm(8207),
+    ndash(8211),
+    mdash(8212),
+    lsquo(8216),
+    rsquo(8217),
+    sbquo(8218),
+    ldquo(8220),
+    rdquo(8221),
+    bdquo(8222),
+    dagger(8224),
+    Dagger(8225),
+    permil(8240),
+    lsaquo(8249),
+    rsaquo(8250),
+    euro(8364);
+
+    int code;
+
+    private Entity(int code) {
+        this.code = code;
+    }
+
+    static boolean isValid(String name) {
+        return names.containsKey(name);
+    }
+
+    static boolean isValid(int code) {
+        // allow numeric codes for standard ANSI characters
+        return codes.containsKey(code) || ( 32 <= code && code < 2127);
+    }
+
+    private static final Map<String,Entity> names = new HashMap<String,Entity>();
+    private static final Map<Integer,Entity> codes = new HashMap<Integer,Entity>();
+    static {
+        for (Entity e: values()) {
+            String name = e.name();
+            int code = e.code;
+            if (name.startsWith("_")) name = name.substring(1);
+            names.put(name, e);
+            codes.put(code, e);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclint/Env.java b/src/share/classes/com/sun/tools/doclint/Env.java
new file mode 100644
index 0000000..0af19be
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/Env.java
@@ -0,0 +1,173 @@
+/*
+ * 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.  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.doclint;
+
+
+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;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.tree.JCTree;
+
+/**
+ * Utility container for current execution environment,
+ * providing the current declaration and its doc comment.
+ *
+ * <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></p>
+ */
+public class Env {
+    /**
+     * Access kinds for declarations.
+     */
+    public enum AccessKind {
+        PRIVATE,
+        PACKAGE,
+        PROTECTED,
+        PUBLIC;
+
+        static boolean accepts(String opt) {
+            for (AccessKind g: values())
+                if (opt.equals(g.name().toLowerCase())) return true;
+            return false;
+        }
+
+        static AccessKind of(Set<Modifier> mods) {
+            if (mods.contains(Modifier.PUBLIC))
+                return AccessKind.PUBLIC;
+            else if (mods.contains(Modifier.PROTECTED))
+                return AccessKind.PROTECTED;
+            else if (mods.contains(Modifier.PRIVATE))
+                return AccessKind.PRIVATE;
+            else
+                return AccessKind.PACKAGE;
+        }
+    };
+
+    /** Message handler. */
+    final Messages messages;
+
+    int implicitHeaderLevel = 0;
+
+    // Utility classes
+    DocTrees trees;
+    Elements elements;
+    Types types;
+
+    // Types used when analysing doc comments.
+    TypeMirror java_lang_Error;
+    TypeMirror java_lang_RuntimeException;
+    TypeMirror java_lang_Throwable;
+    TypeMirror java_lang_Void;
+
+    /** The path for the declaration containing the comment currently being analyzed. */
+    TreePath currPath;
+    /** The element for the declaration containing the comment currently being analyzed. */
+    Element currElement;
+    /** The comment current being analyzed. */
+    DocCommentTree currDocComment;
+    /**
+     * The access kind of the declaration containing the comment currently being analyzed.
+     * This is the minimum (most restrictive) access kind of the declaration itself
+     * and that of its containers. For example, a public method in a private class is
+     * noted as private.
+     */
+    AccessKind currAccess;
+    /** The set of methods, if any, that the current declaration overrides. */
+    Set<? extends ExecutableElement> currOverriddenMethods;
+
+    Env() {
+        messages = new Messages(this);
+    }
+
+    void init(JavacTask task) {
+        init(DocTrees.instance(task), task.getElements(), task.getTypes());
+    }
+
+    void init(DocTrees trees, Elements elements, Types types) {
+        this.trees = trees;
+        this.elements = elements;
+        this.types = types;
+        java_lang_Error = elements.getTypeElement("java.lang.Error").asType();
+        java_lang_RuntimeException = elements.getTypeElement("java.lang.RuntimeException").asType();
+        java_lang_Throwable = elements.getTypeElement("java.lang.Throwable").asType();
+        java_lang_Void = elements.getTypeElement("java.lang.Void").asType();
+    }
+
+    void setImplicitHeaders(int n) {
+        implicitHeaderLevel = n;
+    }
+
+    /** Set the current declaration and its doc comment. */
+    void setCurrent(TreePath path, DocCommentTree comment) {
+        currPath = path;
+        currDocComment = comment;
+        currElement = trees.getElement(currPath);
+        currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);
+
+        AccessKind ak = AccessKind.PUBLIC;
+        for (TreePath p = path; p != null; p = p.getParentPath()) {
+            Element e = trees.getElement(p);
+            if (e != null && e.getKind() != ElementKind.PACKAGE) {
+                ak = min(ak, AccessKind.of(e.getModifiers()));
+            }
+        }
+        currAccess = ak;
+    }
+
+    AccessKind getAccessKind() {
+        return currAccess;
+    }
+
+    long getPos(TreePath p) {
+        return ((JCTree) p.getLeaf()).pos;
+    }
+
+    long getStartPos(TreePath p) {
+        SourcePositions sp = trees.getSourcePositions();
+        return sp.getStartPosition(p.getCompilationUnit(), p.getLeaf());
+    }
+
+    private <T extends Comparable<T>> T min(T item1, T item2) {
+        return (item1 == null) ? item2
+                : (item2 == null) ? item1
+                : item1.compareTo(item2) <= 0 ? item1 : item2;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclint/HtmlTag.java b/src/share/classes/com/sun/tools/doclint/HtmlTag.java
new file mode 100644
index 0000000..0475314
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/HtmlTag.java
@@ -0,0 +1,455 @@
+/*
+ * 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.  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.doclint;
+
+import java.util.Set;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.lang.model.element.Name;
+
+import static com.sun.tools.doclint.HtmlTag.Attr.*;
+
+/**
+ * Enum representing HTML tags.
+ *
+ * The intent of this class is to embody the semantics of W3C HTML 4.01
+ * to the extent supported/used by javadoc.
+ *
+ * This is derivative of com.sun.tools.doclets.formats.html.markup.HtmlTag.
+ * Eventually, these two should be merged back together, and possibly made
+ * public.
+ *
+ * @see <a href="http://www.w3.org/TR/REC-html40/">HTML 4.01 Specification</a>
+ * @author Bhavesh Patel
+ * @author Jonathan Gibbons (revised)
+ */
+public enum HtmlTag {
+    A(BlockType.INLINE, EndKind.REQUIRED,
+            attrs(AttrKind.OK, HREF, TARGET, NAME)),
+
+    B(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    BIG(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT)),
+
+    BLOCKQUOTE(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
+
+    BODY(BlockType.OTHER, EndKind.REQUIRED),
+
+    BR(BlockType.INLINE, EndKind.NONE,
+            attrs(AttrKind.USE_CSS, CLEAR)),
+
+    CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+            EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
+
+    CENTER(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
+
+    CITE(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    CODE(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    DD(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
+
+    DIV(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
+
+    DL(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.USE_CSS, COMPACT)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == DT) || (t == DD);
+        }
+    },
+
+    DT(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+            EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
+
+    EM(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.NO_NEST)),
+
+    FONT(BlockType.INLINE, EndKind.REQUIRED, // tag itself is deprecated
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.USE_CSS, SIZE, COLOR, FACE)),
+
+    FRAME(BlockType.OTHER, EndKind.NONE),
+
+    FRAMESET(BlockType.OTHER, EndKind.REQUIRED),
+
+    H1(BlockType.BLOCK, EndKind.REQUIRED),
+    H2(BlockType.BLOCK, EndKind.REQUIRED),
+    H3(BlockType.BLOCK, EndKind.REQUIRED),
+    H4(BlockType.BLOCK, EndKind.REQUIRED),
+    H5(BlockType.BLOCK, EndKind.REQUIRED),
+    H6(BlockType.BLOCK, EndKind.REQUIRED),
+
+    HEAD(BlockType.OTHER, EndKind.REQUIRED),
+
+    HR(BlockType.BLOCK, EndKind.NONE),
+
+    HTML(BlockType.OTHER, EndKind.REQUIRED),
+
+    I(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    IMG(BlockType.INLINE, EndKind.NONE,
+            attrs(AttrKind.OK, SRC, ALT, HEIGHT, WIDTH),
+            attrs(AttrKind.OBSOLETE, NAME),
+            attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)),
+
+    LI(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
+            attrs(AttrKind.OK, VALUE)),
+
+    LINK(BlockType.OTHER, EndKind.NONE),
+
+    MENU(BlockType.BLOCK, EndKind.REQUIRED) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == LI);
+        }
+    },
+
+    META(BlockType.OTHER, EndKind.NONE),
+
+    NOFRAMES(BlockType.OTHER, EndKind.REQUIRED),
+
+    NOSCRIPT(BlockType.BLOCK, EndKind.REQUIRED),
+
+    OL(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.USE_CSS, START, TYPE)){
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == LI);
+        }
+    },
+
+    P(BlockType.BLOCK, EndKind.OPTIONAL,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.USE_CSS, ALIGN)),
+
+    PRE(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            switch (t) {
+                case IMG: case BIG: case SMALL: case SUB: case SUP:
+                    return false;
+                default:
+                    return (t.blockType == BlockType.INLINE);
+            }
+        }
+    },
+
+    SCRIPT(BlockType.OTHER, EndKind.REQUIRED),
+
+    SMALL(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT)),
+
+    SPAN(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT)),
+
+    STRONG(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT)),
+
+    SUB(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    SUP(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    TABLE(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
+                CELLPADDING, CELLSPACING),
+            attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            switch (t) {
+                case CAPTION:
+                case THEAD: case TBODY: case TFOOT:
+                case TR: // HTML 3.2
+                    return true;
+                default:
+                    return false;
+            }
+        }
+    },
+
+    TBODY(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == TR);
+        }
+    },
+
+    TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
+            attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
+                ALIGN, CHAR, CHAROFF, VALIGN),
+            attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
+
+    TFOOT(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+            attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == TR);
+        }
+    },
+
+    TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
+            EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
+            attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
+                ALIGN, CHAR, CHAROFF, VALIGN),
+            attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
+
+    THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+            attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == TR);
+        }
+    },
+
+    TITLE(BlockType.OTHER, EndKind.REQUIRED),
+
+    TR(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
+            attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN),
+            attrs(AttrKind.USE_CSS, BGCOLOR)) {
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == TH) || (t == TD);
+        }
+    },
+
+    TT(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    U(BlockType.INLINE, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
+
+    UL(BlockType.BLOCK, EndKind.REQUIRED,
+            EnumSet.of(Flag.EXPECT_CONTENT),
+            attrs(AttrKind.USE_CSS, COMPACT, TYPE)){
+        @Override
+        public boolean accepts(HtmlTag t) {
+            return (t == LI);
+        }
+    },
+
+    VAR(BlockType.INLINE, EndKind.REQUIRED);
+
+    /**
+     * Enum representing the type of HTML element.
+     */
+    public static enum BlockType {
+        BLOCK,
+        INLINE,
+        LIST_ITEM,
+        TABLE_ITEM,
+        OTHER;
+    }
+
+    /**
+     * Enum representing HTML end tag requirement.
+     */
+    public static enum EndKind {
+        NONE,
+        OPTIONAL,
+        REQUIRED;
+    }
+
+    public static enum Flag {
+        ACCEPTS_BLOCK,
+        ACCEPTS_INLINE,
+        EXPECT_CONTENT,
+        NO_NEST
+    }
+
+    public static enum Attr {
+        ABBR,
+        ALIGN,
+        ALT,
+        AXIS,
+        BGCOLOR,
+        BORDER,
+        CELLSPACING,
+        CELLPADDING,
+        CHAR,
+        CHAROFF,
+        CLEAR,
+        CLASS,
+        COLOR,
+        COLSPAN,
+        COMPACT,
+        FACE,
+        FRAME,
+        HEADERS,
+        HEIGHT,
+        HREF,
+        HSPACE,
+        ID,
+        NAME,
+        NOWRAP,
+        REVERSED,
+        ROWSPAN,
+        RULES,
+        SCOPE,
+        SIZE,
+        SPACE,
+        SRC,
+        START,
+        STYLE,
+        SUMMARY,
+        TARGET,
+        TYPE,
+        VALIGN,
+        VALUE,
+        VSPACE,
+        WIDTH;
+
+        public String getText() {
+            return name().toLowerCase();
+        }
+
+        static final Map<String,Attr> index = new HashMap<String,Attr>();
+        static {
+            for (Attr t: values()) {
+                index.put(t.getText(), t);
+            }
+        }
+    }
+
+    public static enum AttrKind {
+        INVALID,
+        OBSOLETE,
+        USE_CSS,
+        OK
+    }
+
+    // This class exists to avoid warnings from using parameterized vararg type
+    // Map<Attr,AttrKind> in signature of HtmlTag constructor.
+    private static class AttrMap extends EnumMap<Attr,AttrKind>  {
+        private static final long serialVersionUID = 0;
+        AttrMap() {
+            super(Attr.class);
+        }
+    }
+
+
+    public final BlockType blockType;
+    public final EndKind endKind;
+    public final Set<Flag> flags;
+    private final Map<Attr,AttrKind> attrs;
+
+    HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
+        this(blockType, endKind, Collections.<Flag>emptySet(), attrMaps);
+    }
+
+    HtmlTag(BlockType blockType, EndKind endKind, Set<Flag> flags, AttrMap... attrMaps) {
+        this.blockType = blockType;
+        this.endKind = endKind;
+        this.flags = flags;
+        this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
+        for (Map<Attr,AttrKind> m: attrMaps)
+            this.attrs.putAll(m);
+        attrs.put(Attr.CLASS, AttrKind.OK);
+        attrs.put(Attr.ID, AttrKind.OK);
+        attrs.put(Attr.STYLE, AttrKind.OK);
+    }
+
+    public boolean accepts(HtmlTag t) {
+        if (flags.contains(Flag.ACCEPTS_BLOCK) && flags.contains(Flag.ACCEPTS_INLINE)) {
+            return (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
+        } else if (flags.contains(Flag.ACCEPTS_BLOCK)) {
+            return (t.blockType == BlockType.BLOCK);
+        } else if (flags.contains(Flag.ACCEPTS_INLINE)) {
+            return (t.blockType == BlockType.INLINE);
+        } else
+            switch (blockType) {
+                case BLOCK:
+                case INLINE:
+                    return (t.blockType == BlockType.INLINE);
+                case OTHER:
+                    // OTHER tags are invalid in doc comments, and will be
+                    // reported separately, so silently accept/ignore any content
+                    return true;
+                default:
+                    // any combination which could otherwise arrive here
+                    // ought to have been handled in an overriding method
+                    throw new AssertionError(this + ":" + t);
+            }
+    }
+
+    public boolean acceptsText() {
+        // generally, anywhere we can put text we can also put inline tag
+        // so check if a typical inline tag is allowed
+        return accepts(B);
+    }
+
+    public String getText() {
+        return name().toLowerCase();
+    }
+
+    public Attr getAttr(Name attrName) {
+        return Attr.index.get(attrName.toString().toLowerCase());
+    }
+
+    public AttrKind getAttrKind(Name attrName) {
+        AttrKind k = attrs.get(getAttr(attrName)); // null-safe
+        return (k == null) ? AttrKind.INVALID : k;
+    }
+
+    private static AttrMap attrs(AttrKind k, Attr... attrs) {
+        AttrMap map = new AttrMap();
+        for (Attr a: attrs) map.put(a, k);
+        return map;
+    }
+
+    private static final Map<String,HtmlTag> index = new HashMap<String,HtmlTag>();
+    static {
+        for (HtmlTag t: values()) {
+            index.put(t.getText(), t);
+        }
+    }
+
+    static HtmlTag get(Name tagName) {
+        return index.get(tagName.toString().toLowerCase());
+    }
+}
diff --git a/src/share/classes/com/sun/tools/doclint/Messages.java b/src/share/classes/com/sun/tools/doclint/Messages.java
new file mode 100644
index 0000000..cfa397d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/Messages.java
@@ -0,0 +1,348 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.doclint;
+
+import java.io.PrintWriter;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import javax.tools.Diagnostic;
+
+import com.sun.source.doctree.DocTree;
+import com.sun.source.tree.Tree;
+import com.sun.tools.doclint.Env.AccessKind;
+
+/**
+ * Message reporting for DocLint.
+ *
+ * Options are used to filter out messages based on group and access level.
+ * Support can be enabled for accumulating statistics of different kinds of
+ * messages.
+ *
+ * <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></p>
+ */
+public class Messages {
+    /**
+     * Groups used to categorize messages, so that messages in each group
+     * can be enabled or disabled via options.
+     */
+    public enum Group {
+        ACCESSIBILITY,
+        HTML,
+        MISSING,
+        SYNTAX,
+        REFERENCE;
+
+        String optName() { return name().toLowerCase(); }
+        String notOptName() { return "-" + optName(); }
+
+        static boolean accepts(String opt) {
+            for (Group g: values())
+                if (opt.equals(g.optName())) return true;
+            return false;
+        }
+    };
+
+    private final Options options;
+    private final Stats stats;
+
+    ResourceBundle bundle;
+    Env env;
+
+    Messages(Env env) {
+        this.env = env;
+        String name = getClass().getPackage().getName() + ".resources.doclint";
+        bundle = ResourceBundle.getBundle(name, Locale.ENGLISH);
+
+        stats = new Stats(bundle);
+        options = new Options(stats);
+    }
+
+    void error(Group group, DocTree tree, String code, Object... args) {
+        report(group, Diagnostic.Kind.ERROR, tree, code, args);
+    }
+
+    void warning(Group group, DocTree tree, String code, Object... args) {
+        report(group, Diagnostic.Kind.WARNING, tree, code, args);
+    }
+
+    void setOptions(String opts) {
+        options.setOptions(opts);
+    }
+
+    void setStatsEnabled(boolean b) {
+        stats.setEnabled(b);
+    }
+
+    void reportStats(PrintWriter out) {
+        stats.report(out);
+    }
+
+    protected void report(Group group, Diagnostic.Kind dkind, DocTree tree, String code, Object... args) {
+        if (options.isEnabled(group, env.currAccess)) {
+            String msg = (code == null) ? (String) args[0] : localize(code, args);
+            env.trees.printMessage(dkind, msg, tree,
+                    env.currDocComment, env.currPath.getCompilationUnit());
+
+            stats.record(group, dkind, code);
+        }
+    }
+
+    protected void report(Group group, Diagnostic.Kind dkind, Tree tree, String code, Object... args) {
+        if (options.isEnabled(group, env.currAccess)) {
+            String msg = localize(code, args);
+            env.trees.printMessage(dkind, msg, tree, env.currPath.getCompilationUnit());
+
+            stats.record(group, dkind, code);
+        }
+    }
+
+    String localize(String code, Object... args) {
+        String msg = bundle.getString(code);
+        if (msg == null) {
+            StringBuilder sb = new StringBuilder();
+            sb.append("message file broken: code=").append(code);
+            if (args.length > 0) {
+                sb.append(" arguments={0}");
+                for (int i = 1; i < args.length; i++) {
+                    sb.append(", {").append(i).append("}");
+                }
+            }
+            msg = sb.toString();
+        }
+        return MessageFormat.format(msg, args);
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="Options">
+
+    /**
+     * Handler for (sub)options specific to message handling.
+     */
+    static class Options {
+        Map<String, Env.AccessKind> map = new HashMap<String, Env.AccessKind>();
+        private final Stats stats;
+
+        static boolean isValidOptions(String opts) {
+            for (String opt: opts.split(",")) {
+                if (!isValidOption(opt.trim().toLowerCase()))
+                    return false;
+            }
+            return true;
+        }
+
+        private static boolean isValidOption(String opt) {
+            if (opt.equals("none") || opt.equals(Stats.OPT))
+                return true;
+
+            int begin = opt.startsWith("-") ? 1 : 0;
+            int sep = opt.indexOf("/");
+            String grp = opt.substring(begin, (sep != -1) ? sep : opt.length());
+            return ((begin == 0 && grp.equals("all")) || Group.accepts(grp))
+                    && ((sep == -1) || AccessKind.accepts(opt.substring(sep + 1)));
+        }
+
+        Options(Stats stats) {
+            this.stats = stats;
+        }
+
+        /** Determine if a message group is enabled for a particular access level. */
+        boolean isEnabled(Group g, Env.AccessKind access) {
+            if (map.isEmpty())
+                map.put("all", Env.AccessKind.PROTECTED);
+
+            Env.AccessKind ak = map.get(g.optName());
+            if (ak != null && access.compareTo(ak) >= 0)
+                return true;
+
+            ak = map.get(ALL);
+            if (ak != null && access.compareTo(ak) >= 0) {
+                ak = map.get(g.notOptName());
+                if (ak == null || access.compareTo(ak) > 0) // note >, not >=
+                    return true;
+            }
+
+            return false;
+        }
+
+        void setOptions(String opts) {
+            if (opts == null)
+                setOption(ALL, Env.AccessKind.PRIVATE);
+            else {
+                for (String opt: opts.split(","))
+                    setOption(opt.trim().toLowerCase());
+            }
+        }
+
+        private void setOption(String arg) throws IllegalArgumentException {
+            if (arg.equals(Stats.OPT)) {
+                stats.setEnabled(true);
+                return;
+            }
+
+            int sep = arg.indexOf("/");
+            if (sep > 0) {
+                Env.AccessKind ak = Env.AccessKind.valueOf(arg.substring(sep + 1).toUpperCase());
+                setOption(arg.substring(0, sep), ak);
+            } else {
+                setOption(arg, null);
+            }
+        }
+
+        private void setOption(String opt, Env.AccessKind ak) {
+            map.put(opt, (ak != null) ? ak
+                    : opt.startsWith("-") ? Env.AccessKind.PUBLIC : Env.AccessKind.PRIVATE);
+        }
+
+        private static final String ALL = "all";
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Statistics">
+
+    /**
+     * Optionally record statistics of different kinds of message.
+     */
+    static class Stats {
+        public static final String OPT = "stats";
+        public static final String NO_CODE = "";
+        final ResourceBundle bundle;
+
+        // tables only initialized if enabled
+        int[] groupCounts;
+        int[] dkindCounts;
+        Map<String, Integer> codeCounts;
+
+        Stats(ResourceBundle bundle) {
+            this.bundle = bundle;
+        }
+
+        void setEnabled(boolean b) {
+            if (b) {
+                groupCounts = new int[Messages.Group.values().length];
+                dkindCounts = new int[Diagnostic.Kind.values().length];
+                codeCounts = new HashMap<String, Integer>();
+            } else {
+                groupCounts = null;
+                dkindCounts = null;
+                codeCounts = null;
+            }
+        }
+
+        void record(Messages.Group g, Diagnostic.Kind dkind, String code) {
+            if (codeCounts == null) {
+                return;
+            }
+            groupCounts[g.ordinal()]++;
+            dkindCounts[dkind.ordinal()]++;
+            if (code == null) {
+                code = NO_CODE;
+            }
+            Integer i = codeCounts.get(code);
+            codeCounts.put(code, (i == null) ? 1 : i + 1);
+        }
+
+        void report(PrintWriter out) {
+            if (codeCounts == null) {
+                return;
+            }
+            out.println("By group...");
+            Table groupTable = new Table();
+            for (Messages.Group g : Messages.Group.values()) {
+                groupTable.put(g.optName(), groupCounts[g.ordinal()]);
+            }
+            groupTable.print(out);
+            out.println();
+            out.println("By diagnostic kind...");
+            Table dkindTable = new Table();
+            for (Diagnostic.Kind k : Diagnostic.Kind.values()) {
+                dkindTable.put(k.toString().toLowerCase(), dkindCounts[k.ordinal()]);
+            }
+            dkindTable.print(out);
+            out.println();
+            out.println("By message kind...");
+            Table codeTable = new Table();
+            for (Map.Entry<String, Integer> e : codeCounts.entrySet()) {
+                String code = e.getKey();
+                String msg;
+                try {
+                    msg = code.equals(NO_CODE) ? "OTHER" : bundle.getString(code);
+                } catch (MissingResourceException ex) {
+                    msg = code;
+                }
+                codeTable.put(msg, e.getValue());
+            }
+            codeTable.print(out);
+        }
+
+        /**
+         * A table of (int, String) sorted by decreasing int.
+         */
+        private static class Table {
+
+            private static final Comparator<Integer> DECREASING = new Comparator<Integer>() {
+
+                public int compare(Integer o1, Integer o2) {
+                    return o2.compareTo(o1);
+                }
+            };
+            private final TreeMap<Integer, Set<String>> map = new TreeMap<Integer, Set<String>>(DECREASING);
+
+            void put(String label, int n) {
+                if (n == 0) {
+                    return;
+                }
+                Set<String> labels = map.get(n);
+                if (labels == null) {
+                    map.put(n, labels = new TreeSet<String>());
+                }
+                labels.add(label);
+            }
+
+            void print(PrintWriter out) {
+                for (Map.Entry<Integer, Set<String>> e : map.entrySet()) {
+                    int count = e.getKey();
+                    Set<String> labels = e.getValue();
+                    for (String label : labels) {
+                        out.println(String.format("%6d: %s", count, label));
+                    }
+                }
+            }
+        }
+    }
+    // </editor-fold>
+}
diff --git a/src/share/classes/com/sun/tools/doclint/resources/doclint.properties b/src/share/classes/com/sun/tools/doclint/resources/doclint.properties
new file mode 100644
index 0000000..8905235
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/resources/doclint.properties
@@ -0,0 +1,116 @@
+#
+# 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.  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.
+#
+
+dc.anchor.already.defined = anchor already defined: {0}
+dc.anchor.value.missing = no value given for anchor
+dc.attr.lacks.value = attribute lacks value
+dc.attr.not.number = attribute value is not a number
+dc.attr.obsolete = attribute obsolete: {0}
+dc.attr.obsolete.use.css = attribute obsolete, use CSS instead: {0}
+dc.attr.repeated = repeated attribute: {0}
+dc.attr.unknown = unknown attribute: {0}
+dc.bad.option = bad option: {0}
+dc.bad.value.for.option = bad value for option: {0} {1}
+dc.empty = no description for @{0}
+dc.entity.invalid = invalid entity &{0};
+dc.exception.not.thrown = exception not thrown: {0}
+dc.invalid.anchor = invalid name for anchor: "{0}"
+dc.invalid.param = invalid use of @param
+dc.invalid.return = invalid use of @return
+dc.invalid.throws = invalid use of @throws
+dc.invalid.uri = invalid uri: "{0}"
+dc.missing.comment = no comment
+dc.missing.param = no @param for {0}
+dc.missing.return = no @return
+dc.missing.throws = no @throws for {0}
+dc.no.alt.attr.for.image = no "alt" attribute for image
+dc.no.summary.or.caption.for.table=no summary or caption for table
+dc.param.name.not.found = @param name not found
+dc.ref.not.found = reference not found
+dc.tag.code.within.code = '{@code'} within <code>
+dc.tag.empty = empty <{0}> tag
+dc.tag.end.not.permitted = invalid end tag: </{0}>
+dc.tag.end.unexpected = unexpected end tag: </{0}>
+dc.tag.header.sequence.1 = header used out of sequence: <{0}>
+dc.tag.header.sequence.2 = header used out of sequence: <{0}>
+dc.tag.nested.not.allowed=nested tag not allowed: <{0}>
+dc.tag.not.allowed.here = tag not allowed here: <{0}>
+dc.tag.not.allowed = element not allowed in documentation comments: <{0}>
+dc.tag.not.allowed.inline.element = block element not allowed within inline element <{1}>: {0}
+dc.tag.not.allowed.inline.tag = block element not allowed within @{1}: {0}
+dc.tag.not.allowed.inline.other = block element not allowed here: {0}
+dc.tag.not.closed= element not closed: {0}
+dc.tag.p.in.pre= unexpected use of <p> inside <pre> element
+dc.tag.self.closing = self-closing element not allowed
+dc.tag.start.unmatched = end tag missing: </{0}>
+dc.tag.unknown = unknown tag: {0}
+dc.text.not.allowed = text not allowed in <{0}> element
+
+dc.main.ioerror=IO error: {0}
+dc.main.no.files.given=No files given
+dc.main.usage=\
+Usage:\n\
+\    doclint [options] source-files...\n\
+\n\
+Options:\n\
+\  -Xmsgs  \n\
+\    Same as -Xmsgs:all\n\
+\  -Xmsgs:values\n\
+\    Specify categories of issues to be checked, where ''values''\n\
+\    is a comma-separated list of any of the following:\n\
+\      reference      show places where comments contain incorrect\n\
+\                     references to Java source code elements\n\
+\      syntax         show basic syntax errors within comments\n\
+\      html           show issues with HTML tags and attributes\n\
+\      accessibility  show issues for accessibility\n\
+\      missing        show issues with missing documentation\n\
+\      all            all of the above\n\
+\    Precede a value with ''-'' to negate it\n\
+\    Categories may be qualified by one of:\n\
+\      /public /protected /package /private\n\
+\    For positive categories (not beginning with ''-'')\n\
+\    the qualifier applies to that access level and above.\n\
+\    For negative categories (beginning with ''-'')\n\
+\    the qualifier applies to that access level and below.\n\
+\    If a qualifier is missing, the category applies to\n\
+\    all access levels.\n\
+\    For example, -Xmsgs:all,-syntax/private\n\
+\    This will enable all messages, except syntax errors\n\
+\    in the doc comments of private methods.\n\
+\    If no -Xmsgs options are provided, the default is\n\
+\    equivalent to -Xmsgs:all/protected, meaning that\n\
+\    all messages are reported for protected and public\n\
+\    declarations only. \n\
+\  -stats\n\
+\    Report statistics on the reported issues.\n\
+\  -h -help --help -usage -?\n\
+\    Show this message.\n\
+\n\
+The following javac options are also supported\n\
+\  -bootclasspath, -classpath, -cp, -sourcepath, -Xmaxerrs, -Xmaxwarns\n\
+\n\
+To run doclint on part of a project, put the compiled classes for your\n\
+project on the classpath (or bootclasspath), then specify the source files\n\
+to be checked on the command line.
diff --git a/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties b/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties
new file mode 100644
index 0000000..10282be
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/resources/doclint_ja.properties
@@ -0,0 +1,68 @@
+#
+# 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.  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.
+#
+
+dc.anchor.already.defined = \u30A2\u30F3\u30AB\u30FC\u304C\u3059\u3067\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059: {0}
+dc.anchor.value.missing = \u30A2\u30F3\u30AB\u30FC\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+dc.attr.lacks.value = \u5C5E\u6027\u306B\u5024\u304C\u3042\u308A\u307E\u305B\u3093
+dc.attr.obsolete = \u5C5E\u6027\u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059: {0}
+dc.attr.obsolete.use.css = \u5C5E\u6027\u306F\u5EC3\u6B62\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u304B\u308F\u308A\u306BCSS\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044: {0}
+dc.attr.repeated = \u7E70\u308A\u8FD4\u3055\u308C\u305F\u5C5E\u6027: {0}
+dc.attr.unknown = \u4E0D\u660E\u306A\u5C5E\u6027: {0}
+dc.bad.option = \u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}
+dc.bad.value.for.option = \u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5024\u304C\u4E0D\u6B63\u3067\u3059: {0} {1}
+dc.empty = @{0}\u306E\u8AAC\u660E\u304C\u3042\u308A\u307E\u305B\u3093
+dc.entity.invalid = \u7121\u52B9\u306A\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3&{0};
+dc.exception.not.thrown = \u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {0}
+dc.invalid.anchor = \u30A2\u30F3\u30AB\u30FC\u306E\u540D\u524D\u304C\u7121\u52B9\u3067\u3059: "{0}"
+dc.invalid.param = \u7121\u52B9\u306A at param\u306E\u4F7F\u7528
+dc.invalid.return = \u7121\u52B9\u306A at return\u306E\u4F7F\u7528
+dc.invalid.throws = \u7121\u52B9\u306A at throws\u306E\u4F7F\u7528
+dc.invalid.uri = \u7121\u52B9\u306AURI: "{0}"
+dc.missing.comment = \u30B3\u30E1\u30F3\u30C8\u306A\u3057
+dc.missing.param = {0}\u306E at param\u304C\u3042\u308A\u307E\u305B\u3093
+dc.missing.return = @return\u304C\u3042\u308A\u307E\u305B\u3093
+dc.missing.throws = {0}\u306E at throws\u304C\u3042\u308A\u307E\u305B\u3093
+dc.no.alt.attr.for.image = \u30A4\u30E1\u30FC\u30B8\u306E"alt"\u5C5E\u6027\u304C\u3042\u308A\u307E\u305B\u3093
+dc.no.summary.or.caption.for.table=\u8868\u306E\u8981\u7D04\u307E\u305F\u306F\u30AD\u30E3\u30D7\u30B7\u30E7\u30F3\u304C\u3042\u308A\u307E\u305B\u3093
+dc.param.name.not.found = @param\u540D\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+dc.ref.not.found = \u53C2\u7167\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+dc.tag.code.within.code = <code>\u5185\u306E'{@code'}
+dc.tag.empty = \u7A7A\u306E<{0}>\u30BF\u30B0
+dc.tag.end.not.permitted = \u7121\u52B9\u306A\u7D42\u4E86\u30BF\u30B0: </{0}>
+dc.tag.end.unexpected = \u4E88\u671F\u3057\u306A\u3044\u7D42\u4E86\u30BF\u30B0: </{0}>
+dc.tag.header.sequence.1 = \u30D8\u30C3\u30C0\u30FC\u306E\u6307\u5B9A\u9806\u5E8F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: <{0}>
+dc.tag.header.sequence.2 = \u30D8\u30C3\u30C0\u30FC\u306E\u6307\u5B9A\u9806\u5E8F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: <{0}>
+dc.tag.nested.not.allowed=\u30CD\u30B9\u30C8\u3057\u305F\u30BF\u30B0\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: <{0}>
+dc.tag.not.allowed.here = \u3053\u3053\u3067\u306F\u30BF\u30B0\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: <{0}>
+dc.tag.not.allowed = \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u30FB\u30B3\u30E1\u30F3\u30C8\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u8981\u7D20\u3067\u3059: <{0}>
+dc.tag.not.allowed.inline.element = \u30A4\u30F3\u30E9\u30A4\u30F3\u8981\u7D20<{1}>\u5185\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3067\u3059: {0}
+dc.tag.not.allowed.inline.tag = @{1}\u5185\u3067\u4F7F\u7528\u3067\u304D\u306A\u3044\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3067\u3059: {0}
+dc.tag.not.allowed.inline.other = \u3053\u3053\u3067\u306F\u30D6\u30ED\u30C3\u30AF\u8981\u7D20\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093: {0}
+dc.tag.not.closed= \u8981\u7D20\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093: {0}
+dc.tag.p.in.pre= <pre>\u8981\u7D20\u5185\u3067\u4E88\u671F\u3057\u306A\u3044<p>\u304C\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059
+dc.tag.self.closing = \u81EA\u5DF1\u7D42\u4E86\u8981\u7D20\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+dc.tag.start.unmatched = \u7D42\u4E86\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093: </{0}>
+dc.tag.unknown = \u4E0D\u660E\u306A\u30BF\u30B0: {0}
+dc.text.not.allowed = <{0}>\u8981\u7D20\u3067\u306F\u30C6\u30AD\u30B9\u30C8\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
diff --git a/src/share/classes/com/sun/tools/doclint/resources/doclint_zh_CN.properties b/src/share/classes/com/sun/tools/doclint/resources/doclint_zh_CN.properties
new file mode 100644
index 0000000..b3a9c70
--- /dev/null
+++ b/src/share/classes/com/sun/tools/doclint/resources/doclint_zh_CN.properties
@@ -0,0 +1,68 @@
+#
+# 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.  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.
+#
+
+dc.anchor.already.defined = \u951A\u5B9A\u70B9\u5DF2\u5B9A\u4E49: {0}
+dc.anchor.value.missing = \u6CA1\u6709\u4E3A\u951A\u5B9A\u70B9\u6307\u5B9A\u503C
+dc.attr.lacks.value = \u5C5E\u6027\u7F3A\u5C11\u503C
+dc.attr.obsolete = \u5C5E\u6027\u5DF2\u8FC7\u65F6: {0}
+dc.attr.obsolete.use.css = \u5C5E\u6027\u5DF2\u8FC7\u65F6, \u8BF7\u6539\u7528 CSS: {0}
+dc.attr.repeated = \u5C5E\u6027\u91CD\u590D: {0}
+dc.attr.unknown = \u672A\u77E5\u5C5E\u6027: {0}
+dc.bad.option = \u9009\u9879\u9519\u8BEF: {0}
+dc.bad.value.for.option = \u9009\u9879\u7684\u503C\u9519\u8BEF: {0} {1}
+dc.empty = @{0} \u6CA1\u6709\u8BF4\u660E
+dc.entity.invalid = \u5B9E\u4F53 &{0}; \u65E0\u6548
+dc.exception.not.thrown = \u672A\u629B\u51FA\u5F02\u5E38\u9519\u8BEF: {0}
+dc.invalid.anchor = \u951A\u5B9A\u70B9\u7684\u540D\u79F0\u65E0\u6548: "{0}"
+dc.invalid.param = @param \u7684\u7528\u6CD5\u65E0\u6548
+dc.invalid.return = @return \u7684\u7528\u6CD5\u65E0\u6548
+dc.invalid.throws = @throws \u7684\u7528\u6CD5\u65E0\u6548
+dc.invalid.uri = URI \u65E0\u6548: "{0}"
+dc.missing.comment = \u6CA1\u6709\u6CE8\u91CA
+dc.missing.param = {0}\u6CA1\u6709 @param
+dc.missing.return = \u6CA1\u6709 @return
+dc.missing.throws = {0}\u6CA1\u6709 @throws
+dc.no.alt.attr.for.image = \u56FE\u50CF\u6CA1\u6709 "alt" \u5C5E\u6027
+dc.no.summary.or.caption.for.table=\u8868\u6CA1\u6709\u6982\u8981\u6216\u6807\u9898
+dc.param.name.not.found = \u627E\u4E0D\u5230 @param \u540D\u79F0
+dc.ref.not.found = \u627E\u4E0D\u5230\u5F15\u7528
+dc.tag.code.within.code = '{@code'} \u5728 <code> \u4E2D
+dc.tag.empty = <{0}> \u6807\u8BB0\u4E3A\u7A7A
+dc.tag.end.not.permitted = \u65E0\u6548\u7684\u7ED3\u675F\u6807\u8BB0: </{0}>
+dc.tag.end.unexpected = \u610F\u5916\u7684\u7ED3\u675F\u6807\u8BB0: </{0}>
+dc.tag.header.sequence.1 = \u4F7F\u7528\u7684\u6807\u9898\u8D85\u51FA\u5E8F\u5217: <{0}>
+dc.tag.header.sequence.2 = \u4F7F\u7528\u7684\u6807\u9898\u8D85\u51FA\u5E8F\u5217: <{0}>
+dc.tag.nested.not.allowed=\u4E0D\u5141\u8BB8\u4F7F\u7528\u5D4C\u5957\u6807\u8BB0: <{0}>
+dc.tag.not.allowed.here = \u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u6807\u8BB0: <{0}>
+dc.tag.not.allowed = \u6587\u6863\u6CE8\u91CA\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5143\u7D20: <{0}>
+dc.tag.not.allowed.inline.element = \u5185\u5D4C\u5143\u7D20 <{1}> \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}
+dc.tag.not.allowed.inline.tag = @{1} \u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}
+dc.tag.not.allowed.inline.other = \u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u5757\u5143\u7D20: {0}
+dc.tag.not.closed= \u5143\u7D20\u672A\u5173\u95ED: {0}
+dc.tag.p.in.pre= <pre> \u5143\u7D20\u5185\u90E8\u610F\u5916\u5730\u4F7F\u7528\u4E86 <p>
+dc.tag.self.closing = \u4E0D\u5141\u8BB8\u4F7F\u7528\u81EA\u5173\u95ED\u5143\u7D20
+dc.tag.start.unmatched = \u7F3A\u5C11\u7ED3\u675F\u6807\u8BB0: </{0}>
+dc.tag.unknown = \u672A\u77E5\u6807\u8BB0: {0}
+dc.text.not.allowed = <{0}> \u5143\u7D20\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u6587\u672C
diff --git a/src/share/classes/com/sun/tools/javac/Launcher.java b/src/share/classes/com/sun/tools/javac/Launcher.java
deleted file mode 100644
index 8c17804..0000000
--- a/src/share/classes/com/sun/tools/javac/Launcher.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2006, 2010, 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;
-
-import java.io.File;
-import java.util.prefs.Preferences;
-import javax.swing.JFileChooser;
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-
-/**
- * <b>Unsupported</b> entry point for starting javac from an IDE.
- *
- * <p><b>Note:</b> this class is not available in the JDK.  It is not
- * compiled by default and will not be in tools.jar.  It is designed
- * to be useful when editing the compiler sources in an IDE (as part
- * of a <em>project</em>).  Simply ensure that this class is added to
- * the project and make it the main class of the project.</p>
- *
- * <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></p>
- *
- * @author Peter von der Ahé
- * @since 1.6
- */
-class Launcher {
-    public static void main(String... args) {
-        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
-        JFileChooser fileChooser;
-        Preferences prefs = Preferences.userNodeForPackage(Launcher.class);
-        if (args.length > 0)
-            fileChooser = new JFileChooser(args[0]);
-        else {
-            String fileName = prefs.get("recent.file", null);
-            fileChooser = new JFileChooser();
-            if (fileName != null) {
-                fileChooser = new JFileChooser();
-                fileChooser.setSelectedFile(new File(fileName));
-            }
-        }
-        if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
-            String fileName = fileChooser.getSelectedFile().getPath();
-            prefs.put("recent.file", fileName);
-            javac.run(System.in, null, null, "-d", "/tmp", fileName);
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/Main.java b/src/share/classes/com/sun/tools/javac/Main.java
index e569c1b..eb3acca 100644
--- a/src/share/classes/com/sun/tools/javac/Main.java
+++ b/src/share/classes/com/sun/tools/javac/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -41,6 +41,7 @@ import java.lang.reflect.*;
  * risk.  This code and its internal interfaces are subject to change
  * or deletion without notice.
  */
+ at jdk.Supported
 public class Main {
 
     /** Unsupported command line interface.
@@ -73,7 +74,7 @@ public class Main {
     public static int compile(String[] args) {
         com.sun.tools.javac.main.Main compiler =
             new com.sun.tools.javac.main.Main("javac");
-        return compiler.compile(args);
+        return compiler.compile(args).exitCode;
     }
 
 
@@ -91,6 +92,6 @@ public class Main {
     public static int compile(String[] args, PrintWriter out) {
         com.sun.tools.javac.main.Main compiler =
             new com.sun.tools.javac.main.Main("javac", out);
-        return compiler.compile(args);
+        return compiler.compile(args).exitCode;
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/Server.java b/src/share/classes/com/sun/tools/javac/Server.java
deleted file mode 100644
index fcb2127..0000000
--- a/src/share/classes/com/sun/tools/javac/Server.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2005, 2008, 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;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.logging.Logger;
-import javax.tools.*;
-
-/**
- * Java Compiler Server.  Can be used to speed up a set of (small)
- * compilation tasks by caching jar files between compilations.
- *
- * <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></p>
- *
- * @author Peter von der Ahé
- * @since 1.6
- */
-class Server implements Runnable {
-    private final BufferedReader in;
-    private final OutputStream out;
-    private final boolean isSocket;
-    private static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-    private static Logger logger = Logger.getLogger("com.sun.tools.javac");
-    static class CwdFileManager extends ForwardingJavaFileManager<JavaFileManager> {
-        String cwd;
-        CwdFileManager(JavaFileManager fileManager) {
-            super(fileManager);
-        }
-        String getAbsoluteName(String name) {
-            if (new File(name).isAbsolute()) {
-                return name;
-            } else {
-                return new File(cwd,name).getPath();
-            }
-        }
-//      public JavaFileObject getFileForInput(String name)
-//          throws IOException
-//      {
-//          return super.getFileForInput(getAbsoluteName(name));
-//      }
-    }
-    // static CwdFileManager fm = new CwdFileManager(tool.getStandardFileManager());
-    static StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
-    static {
-        // Use the same file manager for all compilations.  This will
-        // cache jar files in the standard file manager.  Use
-        // tool.getStandardFileManager().close() to release.
-        // FIXME tool.setFileManager(fm);
-        logger.setLevel(java.util.logging.Level.SEVERE);
-    }
-    private Server(BufferedReader in, OutputStream out, boolean isSocket) {
-        this.in = in;
-        this.out = out;
-        this.isSocket = isSocket;
-    }
-    private Server(BufferedReader in, OutputStream out) {
-        this(in, out, false);
-    }
-    private Server(Socket socket) throws IOException, UnsupportedEncodingException {
-        this(new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8")),
-             socket.getOutputStream(),
-             true);
-    }
-    public void run() {
-        List<String> args = new ArrayList<String>();
-        int res = -1;
-        try {
-            String line = null;
-            try {
-                line = in.readLine();
-            } catch (IOException e) {
-                System.err.println(e.getLocalizedMessage());
-                System.exit(0);
-                line = null;
-            }
-            // fm.cwd=null;
-            String cwd = null;
-            while (line != null) {
-                if (line.startsWith("PWD:")) {
-                    cwd = line.substring(4);
-                } else if (line.equals("END")) {
-                    break;
-                } else if (!"-XDstdout".equals(line)) {
-                    args.add(line);
-                }
-                try {
-                    line = in.readLine();
-                } catch (IOException e) {
-                    System.err.println(e.getLocalizedMessage());
-                    System.exit(0);
-                    line = null;
-                }
-            }
-            Iterable<File> path = cwd == null ? null : Arrays.<File>asList(new File(cwd));
-            // try { in.close(); } catch (IOException e) {}
-            long msec = System.currentTimeMillis();
-            try {
-                synchronized (tool) {
-                    for (StandardLocation location : StandardLocation.values())
-                        fm.setLocation(location, path);
-                    res = compile(out, fm, args);
-                    // FIXME res = tool.run((InputStream)null, null, out, args.toArray(new String[args.size()]));
-                }
-            } catch (Throwable ex) {
-                logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
-                PrintWriter p = new PrintWriter(out, true);
-                ex.printStackTrace(p);
-                p.flush();
-            }
-            if (res >= 3) {
-                logger.severe(String.format("problem: %s", args));
-            } else {
-                logger.info(String.format("success: %s", args));
-            }
-            // res = compile(args.toArray(new String[args.size()]), out);
-            msec -= System.currentTimeMillis();
-            logger.info(String.format("Real time: %sms", -msec));
-        } finally {
-            if (!isSocket) {
-                try { in.close(); } catch (IOException e) {}
-            }
-            try {
-                out.write(String.format("EXIT: %s%n", res).getBytes());
-            } catch (IOException ex) {
-                logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
-            }
-            try {
-                out.flush();
-                out.close();
-            } catch (IOException ex) {
-                logger.log(java.util.logging.Level.SEVERE, args.toString(), ex);
-            }
-            logger.info(String.format("EXIT: %s", res));
-        }
-    }
-    public static void main(String... args) throws FileNotFoundException {
-        if (args.length == 2) {
-            for (;;) {
-                throw new UnsupportedOperationException("TODO");
-//              BufferedReader in = new BufferedReader(new FileReader(args[0]));
-//              PrintWriter out = new PrintWriter(args[1]);
-//              new Server(in, out).run();
-//              System.out.flush();
-//              System.err.flush();
-            }
-        } else {
-            ExecutorService pool = Executors.newCachedThreadPool();
-            try
-                {
-                ServerSocket socket = new ServerSocket(0xcafe, -1, null);
-                for (;;) {
-                    pool.execute(new Server(socket.accept()));
-                }
-            }
-            catch (IOException e) {
-                System.err.format("Error: %s%n", e.getLocalizedMessage());
-                pool.shutdown();
-            }
-        }
-    }
-
-    private int compile(OutputStream out, StandardJavaFileManager fm, List<String> args) {
-        // FIXME parse args and use getTask
-        // System.err.println("Running " + args);
-        return tool.run(null, null, out, args.toArray(new String[args.size()]));
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java b/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java
new file mode 100644
index 0000000..e44bca3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.api;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Locale;
+
+import javax.annotation.processing.Processor;
+import javax.lang.model.element.Element;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
+import javax.tools.JavaFileObject;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * Provides basic functionality for implementations of JavacTask.
+ *
+ * <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></p>
+ */
+public class BasicJavacTask extends JavacTask {
+    protected Context context;
+    private TaskListener taskListener;
+
+    public static JavacTask instance(Context context) {
+        JavacTask instance = context.get(JavacTask.class);
+        if (instance == null)
+            instance = new BasicJavacTask(context, true);
+        return instance;
+    }
+
+    public BasicJavacTask(Context c, boolean register) {
+        context = c;
+        if (register)
+            context.put(JavacTask.class, this);
+    }
+
+    @Override
+    public Iterable<? extends CompilationUnitTree> parse() throws IOException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public Iterable<? extends Element> analyze() throws IOException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public Iterable<? extends JavaFileObject> generate() throws IOException {
+        throw new IllegalStateException();
+    }
+
+    @Override
+    public void setTaskListener(TaskListener tl) {
+        MultiTaskListener mtl = MultiTaskListener.instance(context);
+        if (taskListener != null)
+            mtl.remove(taskListener);
+        if (tl != null)
+            mtl.add(tl);
+        taskListener = tl;
+    }
+
+    @Override
+    public void addTaskListener(TaskListener taskListener) {
+        MultiTaskListener mtl = MultiTaskListener.instance(context);
+        mtl.add(taskListener);
+    }
+
+    @Override
+    public void removeTaskListener(TaskListener taskListener) {
+        MultiTaskListener mtl = MultiTaskListener.instance(context);
+        mtl.remove(taskListener);
+    }
+
+    public Collection<TaskListener> getTaskListeners() {
+        MultiTaskListener mtl = MultiTaskListener.instance(context);
+        return mtl.getTaskListeners();
+    }
+
+    @Override
+    public TypeMirror getTypeMirror(Iterable<? extends Tree> path) {
+        // TODO: Should complete attribution if necessary
+        Tree last = null;
+        for (Tree node : path)
+            last = node;
+        return ((JCTree)last).type;
+    }
+
+    @Override
+    public Elements getElements() {
+        return JavacElements.instance(context);
+    }
+
+    @Override
+    public Types getTypes() {
+        return JavacTypes.instance(context);
+    }
+
+    public void setProcessors(Iterable<? extends Processor> processors) {
+        throw new IllegalStateException();
+    }
+
+    public void setLocale(Locale locale) {
+        throw new IllegalStateException();
+    }
+
+    public Boolean call() {
+        throw new IllegalStateException();
+    }
+
+    /**
+     * For internal use only.  This method will be
+     * removed without warning.
+     */
+    public Context getContext() {
+        return context;
+    }
+
+    /**
+     * For internal use only.  This method will be
+     * removed without warning.
+     */
+    public void updateContext(Context newContext) {
+        context = newContext;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java b/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
index 0793439..8817ada 100644
--- a/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
+++ b/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,13 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -41,25 +46,21 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
+import javax.lang.model.element.Modifier;
 import javax.lang.model.element.NestingKind;
 import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
 import javax.tools.FileObject;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileManager.Location;
 import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
 
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import javax.lang.model.element.Modifier;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaFileObject.Kind;
 
 /**
  *  Wrap objects to enable unchecked exceptions to be caught and handled.
@@ -148,7 +149,7 @@ public class ClientCodeWrapper {
             return fo;
     }
 
-    <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
+    public <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
         if (isTrusted(dl))
             return dl;
         return new WrappedDiagnosticListener<T>(dl);
@@ -160,6 +161,20 @@ public class ClientCodeWrapper {
         return new WrappedTaskListener(tl);
     }
 
+    TaskListener unwrap(TaskListener l) {
+        if (l instanceof WrappedTaskListener)
+            return ((WrappedTaskListener) l).clientTaskListener;
+        else
+            return l;
+    }
+
+    Collection<TaskListener> unwrap(Collection<? extends TaskListener> listeners) {
+        Collection<TaskListener> c = new ArrayList<TaskListener>(listeners.size());
+        for (TaskListener l: listeners)
+            c.add(unwrap(l));
+        return c;
+    }
+
     @SuppressWarnings("unchecked")
     private <T> Diagnostic<T> unwrap(final Diagnostic<T> diagnostic) {
         if (diagnostic instanceof JCDiagnostic) {
@@ -183,6 +198,10 @@ public class ClientCodeWrapper {
         return trusted;
     }
 
+    private String wrappedToString(Class<?> wrapperClass, Object wrapped) {
+        return wrapperClass.getSimpleName() + "[" + wrapped + "]";
+    }
+
     // <editor-fold defaultstate="collapsed" desc="Wrapper classes">
 
     // FIXME: all these classes should be converted to use multi-catch when
@@ -363,6 +382,11 @@ public class ClientCodeWrapper {
                 throw new ClientCodeException(e);
             }
         }
+
+        @Override
+        public String toString() {
+            return wrappedToString(getClass(), clientJavaFileManager);
+        }
     }
 
     protected class WrappedFileObject implements FileObject {
@@ -488,6 +512,11 @@ public class ClientCodeWrapper {
                 throw new ClientCodeException(e);
             }
         }
+
+        @Override
+        public String toString() {
+            return wrappedToString(getClass(), clientFileObject);
+        }
     }
 
     protected class WrappedJavaFileObject extends WrappedFileObject implements JavaFileObject {
@@ -546,6 +575,11 @@ public class ClientCodeWrapper {
                 throw new ClientCodeException(e);
             }
         }
+
+        @Override
+        public String toString() {
+            return wrappedToString(getClass(), clientFileObject);
+        }
     }
 
     protected class WrappedDiagnosticListener<T /*super JavaFileObject*/> implements DiagnosticListener<T> {
@@ -567,6 +601,11 @@ public class ClientCodeWrapper {
                 throw new ClientCodeException(e);
             }
         }
+
+        @Override
+        public String toString() {
+            return wrappedToString(getClass(), clientDiagnosticListener);
+        }
     }
 
     public class DiagnosticSourceUnwrapper implements Diagnostic<JavaFileObject> {
@@ -612,6 +651,7 @@ public class ClientCodeWrapper {
             return d.getMessage(locale);
         }
 
+        @Override
         public String toString() {
             return d.toString();
         }
@@ -649,6 +689,11 @@ public class ClientCodeWrapper {
                 throw new ClientCodeException(e);
             }
         }
+
+        @Override
+        public String toString() {
+            return wrappedToString(getClass(), clientTaskListener);
+        }
     }
 
     // </editor-fold>
diff --git a/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java b/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
index 18aafee..fab0ada 100644
--- a/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
+++ b/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -138,7 +138,7 @@ public interface DiagnosticFormatter<D extends Diagnostic<?>> {
         /**
          * Configure the set of diagnostic parts that should be displayed
          * by the formatter.
-         * @param options options to set
+         * @param visibleParts the parts to be set
          */
         public void setVisible(Set<DiagnosticPart> visibleParts);
 
diff --git a/src/share/classes/com/sun/tools/javac/api/JavacScope.java b/src/share/classes/com/sun/tools/javac/api/JavacScope.java
index 054f1dd..f20af8d 100644
--- a/src/share/classes/com/sun/tools/javac/api/JavacScope.java
+++ b/src/share/classes/com/sun/tools/javac/api/JavacScope.java
@@ -50,7 +50,7 @@ public class JavacScope implements com.sun.source.tree.Scope {
     protected final Env<AttrContext> env;
 
     /** Creates a new instance of JavacScope */
-    JavacScope(Env<AttrContext> env) {
+    protected JavacScope(Env<AttrContext> env) {
         env.getClass(); // null-check
         this.env = env;
     }
diff --git a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index 22db521..adc2e1e 100644
--- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -44,6 +44,7 @@ import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.main.*;
+import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.model.*;
 import com.sun.tools.javac.parser.JavacParser;
 import com.sun.tools.javac.parser.Parser;
@@ -52,7 +53,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.util.List;
-import com.sun.tools.javac.main.JavaCompiler;
 
 /**
  * Provides access to functionality specific to the JDK Java Compiler, javac.
@@ -65,29 +65,26 @@ import com.sun.tools.javac.main.JavaCompiler;
  * @author Peter von der Ahé
  * @author Jonathan Gibbons
  */
-public class JavacTaskImpl extends JavacTask {
-    private ClientCodeWrapper ccw;
+public class JavacTaskImpl extends BasicJavacTask {
     private Main compilerMain;
     private JavaCompiler compiler;
     private Locale locale;
     private String[] args;
     private String[] classNames;
-    private Context context;
     private List<JavaFileObject> fileObjects;
     private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
     private ListBuffer<Env<AttrContext>> genList;
-    private TaskListener taskListener;
-    private AtomicBoolean used = new AtomicBoolean();
+    private final AtomicBoolean used = new AtomicBoolean();
     private Iterable<? extends Processor> processors;
-    
-    private Integer result = null;
+
+    private Main.Result result = null;
 
     JavacTaskImpl(Main compilerMain,
                 String[] args,
                 String[] classNames,
                 Context context,
                 List<JavaFileObject> fileObjects) {
-        this.ccw = ClientCodeWrapper.instance(context);
+        super(null, false);
         this.compilerMain = compilerMain;
         this.args = args;
         this.classNames = classNames;
@@ -101,18 +98,19 @@ public class JavacTaskImpl extends JavacTask {
     }
 
     JavacTaskImpl(Main compilerMain,
-                Iterable<String> flags,
+                Iterable<String> args,
                 Context context,
                 Iterable<String> classes,
                 Iterable<? extends JavaFileObject> fileObjects) {
-        this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects));
+        this(compilerMain, toArray(args), toArray(classes), context, toList(fileObjects));
     }
 
     JavacTaskImpl(Context context) {
+        super(null, false);
         this.context = context;
         setLocale(Locale.getDefault());
     }
-
+    
     static private String[] toArray(Iterable<String> iter) {
         ListBuffer<String> result = new ListBuffer<String>();
         if (iter != null)
@@ -130,19 +128,23 @@ public class JavacTaskImpl extends JavacTask {
         return result.toList();
     }
 
-    public Boolean call() {
+    public Main.Result doCall() {
         if (!used.getAndSet(true)) {
             initContext();
             notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
             compilerMain.setAPIMode(true);
             result = compilerMain.compile(args, classNames, context, fileObjects, processors);
             cleanup();
-            return result == 0;
+            return result;
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
         }
     }
 
+    public Boolean call() {
+        return doCall().isOK();
+    }
+
     public void setProcessors(Iterable<? extends Processor> processors) {
         processors.getClass(); // null check
         // not mt-safe
@@ -167,10 +169,11 @@ public class JavacTaskImpl extends JavacTask {
                 throw new IllegalStateException();
         } else {
             initContext();
+            compilerMain.log = Log.instance(context);
             compilerMain.setOptions(Options.instance(context));
             compilerMain.filenames = new LinkedHashSet<File>();
             Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames);
-            if (!filenames.isEmpty())
+            if (filenames != null && !filenames.isEmpty())
                 throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
             compiler = JavaCompiler.instance(context);
             // NOTE: this value will be updated after annotation processing
@@ -199,11 +202,7 @@ public class JavacTaskImpl extends JavacTask {
     }
 
     private void initContext() {
-        context.put(JavacTaskImpl.class, this);
-        if (context.get(TaskListener.class) != null)
-            context.put(TaskListener.class, (TaskListener)null);
-        if (taskListener != null)
-            context.put(TaskListener.class, ccw.wrap(taskListener));
+        context.put(JavacTask.class, this);
         //initialize compiler's default locale
         context.put(Locale.class, locale);
     }
@@ -233,10 +232,6 @@ public class JavacTaskImpl extends JavacTask {
         return fm.getRegularFile(file);
     }
 
-    public void setTaskListener(TaskListener taskListener) {
-        this.taskListener = taskListener;
-    }
-
     public Iterable<? extends CompilationUnitTree> parse (JavaFileObject... files) throws IOException {
         prepareCompiler();
         java.util.List<CompilationUnitTree> trees = new java.util.LinkedList<CompilationUnitTree> ();
@@ -326,8 +321,11 @@ public class JavacTaskImpl extends JavacTask {
     public Iterable<? extends TypeElement> enter(Iterable<? extends CompilationUnitTree> trees)
         throws IOException
     {
-        prepareCompiler();
+        if (trees == null && notYetEntered != null && notYetEntered.isEmpty())
+            return List.nil();
 
+        prepareCompiler();
+        
         ListBuffer<JCCompilationUnit> roots = null;
 
         if (trees == null) {
@@ -365,6 +363,9 @@ public class JavacTaskImpl extends JavacTask {
         if (roots == null)
             return List.nil();
 
+        if (!compiler.skipAnnotationProcessing && compiler.processAnnotations && compiler.deferredDiagnosticHandler == null)
+            compiler.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(compiler.log);
+
         try {
             List<JCCompilationUnit> units = compiler.enterTrees(roots.toList());
 
@@ -385,7 +386,7 @@ public class JavacTaskImpl extends JavacTask {
                         elements.append(unit.packge.package_info);
                 } else {
                     for (JCTree node : unit.defs) {
-                        if (node.getTag() == JCTree.CLASSDEF) {
+                        if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                             JCClassDecl cdef = (JCClassDecl) node;
                             if (cdef.sym != null) // maybe null if errors in anno processing
                                 elements.append(cdef.sym);
@@ -428,7 +429,7 @@ public class JavacTaskImpl extends JavacTask {
         final java.util.List<TypeElement> res = new java.util.ArrayList<TypeElement>();
         if (((JCCompilationUnit)tree).packge != null) {
             for (JCTree t : ((JCCompilationUnit)tree).defs) {
-                if (t.getTag() == JCTree.CLASSDEF) {
+                if (t.hasTag(JCTree.Tag.CLASSDEF)) {
                     ClassSymbol sym = ((JCClassDecl)t).sym;
                     if (sym != null)
                         res.add(sym);
@@ -485,12 +486,12 @@ public class JavacTaskImpl extends JavacTask {
         private void handleFlowResults(Queue<Env<AttrContext>> queue, ListBuffer<Element> elems) {
             for (Env<AttrContext> env: queue) {
                 switch (env.tree.getTag()) {
-                    case JCTree.CLASSDEF:
+                    case CLASSDEF:
                         JCClassDecl cdef = (JCClassDecl) env.tree;
                         if (cdef.sym != null)
                             elems.append(cdef.sym);
                         break;
-                    case JCTree.TOPLEVEL:
+                    case TOPLEVEL:
                         JCCompilationUnit unit = (JCCompilationUnit) env.tree;
                         if (unit.packge != null)
                             elems.append(unit.packge);
@@ -634,38 +635,21 @@ public class JavacTaskImpl extends JavacTask {
      * For internal use only.  This method will be
      * removed without warning.
      */
-    public Context getContext() {
-        return context;
-    }
-
-    /**
-     * For internal use only.  This method will be
-     * removed without warning.
-     */
-    public void updateContext(Context newContext) {
-        context = newContext;
-    }
-
-    /**
-     * For internal use only.  This method will be
-     * removed without warning.
-     */
     public Type parseType(String expr, TypeElement scope) {
         if (expr == null || expr.equals(""))
             throw new IllegalArgumentException();
         compiler = JavaCompiler.instance(context);
         JavaFileObject prev = compiler.log.useSource(null);
-        boolean old = compiler.log.suppressErrorsAndWarnings;
-        compiler.log.suppressErrorsAndWarnings = true;
         ParserFactory parserFactory = ParserFactory.instance(context);
         Attr attr = Attr.instance(context);
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(compiler.log);
         try {
             CharBuffer buf = CharBuffer.wrap((expr+"\u0000").toCharArray(), 0, expr.length());
-            Parser parser = parserFactory.newParser(buf, false, false, false, true);
+            Parser parser = parserFactory.newParser(buf, false, false, false);
             JCTree tree = parser.parseType();
             return attr.attribType(tree, (Symbol.TypeSymbol)scope);
         } finally {
-            compiler.log.suppressErrorsAndWarnings = old;
+            compiler.log.popDiagnosticHandler(discardHandler);
             compiler.log.useSource(prev);
         }
     }
@@ -675,16 +659,14 @@ public class JavacTaskImpl extends JavacTask {
             throw new IllegalArgumentException();
         compiler = JavaCompiler.instance(context);
         JavaFileObject prev = compiler.log.useSource(null);
-        boolean old = compiler.log.suppressErrorsAndWarnings;
-        compiler.log.suppressErrorsAndWarnings = true;
         ParserFactory parserFactory = ParserFactory.instance(context);
-        Attr attr = Attr.instance(context);
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(compiler.log);
         try {
             CharBuffer buf = CharBuffer.wrap((expr+"\u0000").toCharArray(), 0, expr.length());
-            Parser parser = parserFactory.newParser(buf, false, false, false, true);
+            Parser parser = parserFactory.newParser(buf, false, false, false);
             return parser.parseType();
         } finally {
-            compiler.log.suppressErrorsAndWarnings = old;
+            compiler.log.popDiagnosticHandler(discardHandler);
             compiler.log.useSource(prev);
         }
     }
@@ -693,21 +675,21 @@ public class JavacTaskImpl extends JavacTask {
         return (JCStatement) doParse(ParseKind.STATEMENT, stmt, pos, errors);
     }
 
-    private JCTree doParse(ParseKind kind, CharSequence source, SourcePositions[] pos, DiagnosticListener<? super JavaFileObject> errors) {
+    private JCTree doParse(ParseKind kind, CharSequence source, SourcePositions[] pos, final DiagnosticListener<? super JavaFileObject> errors) {
         if (source == null || (pos != null && pos.length != 1))
             throw new IllegalArgumentException();
         compiler = JavaCompiler.instance(context);
         JavaFileObject prev = compiler.log.useSource(null);
-        boolean old = compiler.log.suppressErrorsAndWarnings;
-        DiagnosticListener<? super JavaFileObject> oldListener = compiler.log.getDiagnosticListener();
-        int oldErrors = compiler.log.nerrors;
-        int oldWarnings = compiler.log.nwarnings;
-        compiler.log.suppressErrorsAndWarnings = false;
-        compiler.log.setDiagnosticListener(errors);
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(compiler.log) {
+            @Override
+            public void report(JCDiagnostic diag) {
+                errors.report(diag);
+            }            
+        };
         ParserFactory parserFactory = ParserFactory.instance(context);
         try {
             CharBuffer buf = CharBuffer.wrap((source+"\u0000").toCharArray(), 0, source.length());
-            Parser parser = parserFactory.newParser(buf, false, true, false, true);
+            Parser parser = parserFactory.newParser(buf, false, true, false);
             if (parser instanceof JavacParser) {
                 if (pos != null)
                     pos[0] = new ParserSourcePositions((JavacParser)parser);
@@ -717,18 +699,15 @@ public class JavacTaskImpl extends JavacTask {
                     case VARIABLE_INIT: return ((JavacParser)parser).variableInitializer();
                     case STATIC_BLOCK:
                         List<JCTree> trees = ((JavacParser)parser).classOrInterfaceBodyDeclaration(null, false);
-                        return trees.head != null && trees.head.getTag() == JCTree.BLOCK ? (JCBlock) trees.head : null;
+                        return trees.head != null && trees.head.hasTag(JCTree.Tag.BLOCK) ? (JCBlock) trees.head : null;
                     default: throw new UnsupportedOperationException(kind.name());
                 }
                 
             }
             return null;
         } finally {
-            compiler.log.suppressErrorsAndWarnings = old;
-            compiler.log.setDiagnosticListener(oldListener);
+            compiler.log.popDiagnosticHandler(discardHandler);
             compiler.log.useSource(prev);
-            compiler.log.nerrors = oldErrors;
-            compiler.log.nwarnings = oldWarnings;
         }
     }
 
@@ -774,14 +753,16 @@ public class JavacTaskImpl extends JavacTask {
         Log log = Log.instance(context);
         Attr attr = Attr.instance(context);
         JavaFileObject prev = log.useSource(null);
-        boolean old = log.suppressErrorsAndWarnings;
-        log.suppressErrorsAndWarnings = true;
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
+        Enter enter = Enter.instance(context);
+        enter.shadowTypeEnvs(true);
         try {
             if (tree instanceof JCExpression)
                 return attr.attribExpr(tree, env, Type.noType);
             return attr.attribStat(tree, env);
         } finally {
-            log.suppressErrorsAndWarnings = old;
+            enter.shadowTypeEnvs(false);
+            log.popDiagnosticHandler(discardHandler);
             log.useSource(prev);
         }
     }
@@ -790,13 +771,15 @@ public class JavacTaskImpl extends JavacTask {
         Log log = Log.instance(context);
         Attr attr = Attr.instance(context);
         JavaFileObject prev = log.useSource(null);
-        boolean old = log.suppressErrorsAndWarnings;
-        log.suppressErrorsAndWarnings = true;
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
+        Enter enter = Enter.instance(context);
+        enter.shadowTypeEnvs(true);
         try {
             Env<AttrContext> ret = tree instanceof JCExpression ? attr.attribExprToTree(tree, env, to) : attr.attribStatToTree(tree, env, to);
             return new JavacScope(ret);
         } finally {
-            log.suppressErrorsAndWarnings = old;
+            enter.shadowTypeEnvs(false);
+            log.popDiagnosticHandler(discardHandler);
             log.useSource(prev);
         }
     }
diff --git a/src/share/classes/com/sun/tools/javac/api/JavacTool.java b/src/share/classes/com/sun/tools/javac/api/JavacTool.java
index 8b015d2..d1ef902 100644
--- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,15 @@
 
 package com.sun.tools.javac.api;
 
-import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Locale;
 import java.util.Set;
 import javax.lang.model.SourceVersion;
@@ -44,16 +41,15 @@ import javax.tools.*;
 
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.main.JavacOption.OptionKind;
-import com.sun.tools.javac.main.JavacOption;
 import com.sun.tools.javac.main.Main;
-import com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper;
-import com.sun.tools.javac.main.RecognizedOptions;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.Pair;
 
 /**
  * TODO: describe com.sun.tools.javac.api.Tool
@@ -66,24 +62,11 @@ import com.sun.tools.javac.util.Pair;
  * @author Peter von der Ah\u00e9
  */
 public final class JavacTool implements JavaCompiler {
-    private final List<Pair<String,String>> options
-        = new ArrayList<Pair<String,String>>();
-    private final Context dummyContext = new Context();
-
-    private final PrintWriter silent = new PrintWriter(new OutputStream(){
-        public void write(int b) {}
-    });
-
-    private final Main sharedCompiler = new Main("javac", silent);
-    {
-        sharedCompiler.setOptions(Options.instance(dummyContext));
-    }
-
     /**
-     * Constructor used by service provider mechanism.  The correct way to
-     * obtain an instance of this class is using create or the service provider
-     * mechanism.
-     * @see javax.tools.JavaCompilerTool
+     * Constructor used by service provider mechanism.  The recommended way to
+     * obtain an instance of this class is by using {@link #create} or the
+     * service provider mechanism.
+     * @see javax.tools.JavaCompiler
      * @see javax.tools.ToolProvider
      * @see #create
      */
@@ -98,49 +81,6 @@ public final class JavacTool implements JavaCompiler {
         return new JavacTool();
     }
 
-    private String argsToString(Object... args) {
-        String newArgs = null;
-        if (args.length > 0) {
-            StringBuilder sb = new StringBuilder();
-            String separator = "";
-            for (Object arg : args) {
-                sb.append(separator).append(arg.toString());
-                separator = File.pathSeparator;
-            }
-            newArgs = sb.toString();
-        }
-        return newArgs;
-    }
-
-    private void setOption1(String name, OptionKind kind, Object... args) {
-        String arg = argsToString(args);
-        JavacOption option = sharedCompiler.getOption(name);
-        if (option == null || !match(kind, option.getKind()))
-            throw new IllegalArgumentException(name);
-        if ((args.length != 0) != option.hasArg())
-            throw new IllegalArgumentException(name);
-        if (option.hasArg()) {
-            if (option.process(null, name, arg)) // FIXME
-                throw new IllegalArgumentException(name);
-        } else {
-            if (option.process(null, name)) // FIXME
-                throw new IllegalArgumentException(name);
-        }
-        options.add(new Pair<String,String>(name,arg));
-    }
-
-    public void setOption(String name, Object... args) {
-        setOption1(name, OptionKind.NORMAL, args);
-    }
-
-    public void setExtendedOption(String name, Object... args)  {
-        setOption1(name, OptionKind.EXTENDED, args);
-    }
-
-    private static boolean match(OptionKind clientKind, OptionKind optionKind) {
-        return (clientKind == (optionKind == OptionKind.HIDDEN ? OptionKind.EXTENDED : optionKind));
-    }
-
     public JavacFileManager getStandardFileManager(
         DiagnosticListener<? super JavaFileObject> diagnosticListener,
         Locale locale,
@@ -156,15 +96,28 @@ public final class JavacTool implements JavaCompiler {
         return new JavacFileManager(context, true, charset);
     }
 
+    @Override
     public JavacTask getTask(Writer out,
                              JavaFileManager fileManager,
                              DiagnosticListener<? super JavaFileObject> diagnosticListener,
                              Iterable<String> options,
                              Iterable<String> classes,
-                             Iterable<? extends JavaFileObject> compilationUnits)
+                             Iterable<? extends JavaFileObject> compilationUnits) {
+        Context context = new Context();
+        return getTask(out, fileManager, diagnosticListener,
+                options, classes, compilationUnits,
+                context);
+    }
+
+    public JavacTask getTask(Writer out,
+                             JavaFileManager fileManager,
+                             DiagnosticListener<? super JavaFileObject> diagnosticListener,
+                             Iterable<String> options,
+                             Iterable<String> classes,
+                             Iterable<? extends JavaFileObject> compilationUnits,
+                             Context context)
     {
         try {
-            Context context = new Context();
             ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
 
             final String kindMsg = "All compilation units must be of SOURCE kind";
@@ -195,7 +148,9 @@ public final class JavacTool implements JavaCompiler {
             if (fileManager == null)
                 fileManager = getStandardFileManager(diagnosticListener, null, null);
             fileManager = ccw.wrap(fileManager);
+
             context.put(JavaFileManager.class, fileManager);
+
             processOptions(context, fileManager, options);
             Main compiler = new Main("javacTask", context.get(Log.outKey));
             return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
@@ -204,17 +159,35 @@ public final class JavacTool implements JavaCompiler {
         }
     }
 
-    private static void processOptions(Context context,
+    public static void processOptions(Context context,
                                        JavaFileManager fileManager,
                                        Iterable<String> options)
     {
         if (options == null)
             return;
 
-        Options optionTable = Options.instance(context);
+        final Options optionTable = Options.instance(context);
+        Log log = Log.instance(context);
+
+        Option[] recognizedOptions =
+                Option.getJavacToolOptions().toArray(new Option[0]);
+        OptionHelper optionHelper = new GrumpyHelper(log) {
+            @Override
+            public String get(Option option) {
+                return optionTable.get(option.getText());
+            }
+
+            @Override
+            public void put(String name, String value) {
+                optionTable.put(name, value);
+            }
+
+            @Override
+            public void remove(String name) {
+                optionTable.remove(name);
+            }
+        };
 
-        JavacOption[] recognizedOptions =
-            RecognizedOptions.getJavacToolOptions(new GrumpyHelper());
         Iterator<String> flags = options.iterator();
         while (flags.hasNext()) {
             String flag = flags.next();
@@ -227,29 +200,31 @@ public final class JavacTool implements JavaCompiler {
                 if (fileManager.handleOption(flag, flags)) {
                     continue;
                 } else {
-                    String msg = Main.getLocalizedString("err.invalid.flag", flag);
+                    String msg = log.localize(PrefixKind.JAVAC, "err.invalid.flag", flag);
                     throw new IllegalArgumentException(msg);
                 }
             }
 
-            JavacOption option = recognizedOptions[j];
+            Option option = recognizedOptions[j];
             if (option.hasArg()) {
                 if (!flags.hasNext()) {
-                    String msg = Main.getLocalizedString("err.req.arg", flag);
+                    String msg = log.localize(PrefixKind.JAVAC, "err.req.arg", flag);
                     throw new IllegalArgumentException(msg);
                 }
                 String operand = flags.next();
-                if (option.process(optionTable, flag, operand))
+                if (option.process(optionHelper, flag, operand))
                     // should not happen as the GrumpyHelper will throw exceptions
                     // in case of errors
                     throw new IllegalArgumentException(flag + " " + operand);
             } else {
-                if (option.process(optionTable, flag))
+                if (option.process(optionHelper, flag))
                     // should not happen as the GrumpyHelper will throw exceptions
                     // in case of errors
                     throw new IllegalArgumentException(flag);
             }
         }
+
+        optionTable.notifyListeners();
     }
 
     public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
@@ -266,9 +241,8 @@ public final class JavacTool implements JavaCompiler {
     }
 
     public int isSupportedOption(String option) {
-        JavacOption[] recognizedOptions =
-            RecognizedOptions.getJavacToolOptions(new GrumpyHelper());
-        for (JavacOption o : recognizedOptions) {
+        Set<Option> recognizedOptions = Option.getJavacToolOptions();
+        for (Option o : recognizedOptions) {
             if (o.matches(option))
                 return o.hasArg() ? 1 : 0;
         }
diff --git a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
index d66809e..8779e14 100644
--- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -26,11 +26,14 @@
 package com.sun.tools.javac.api;
 
 import java.io.IOException;
-import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
+
 import javax.annotation.processing.ProcessingEnvironment;
 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;
@@ -40,36 +43,73 @@ import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
 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.SourcePositions;
+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;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.Type.ErrorType;
 import com.sun.tools.javac.code.Type.UnionClassType;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.TypeTag;
+import com.sun.tools.javac.code.Types.TypeRelation;
 import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.comp.MemberEnter;
 import com.sun.tools.javac.comp.Resolve;
+import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCBlockTag;
+import com.sun.tools.javac.tree.DCTree.DCComment;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCEndElement;
+import com.sun.tools.javac.tree.DCTree.DCEndPosTree;
+import com.sun.tools.javac.tree.DCTree.DCEntity;
+import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DCTree.DCIdentifier;
+import com.sun.tools.javac.tree.DCTree.DCInlineTag;
+import com.sun.tools.javac.tree.DCTree.DCParam;
+import com.sun.tools.javac.tree.DCTree.DCReference;
+import com.sun.tools.javac.tree.DCTree.DCText;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.TreeCopier;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeMaker;
+import com.sun.tools.javac.util.Abort;
+import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Pair;
+import com.sun.tools.javac.util.Position;
+import static com.sun.tools.javac.code.TypeTag.*;
 
 /**
  * Provides an implementation of Trees.
@@ -81,7 +121,7 @@ import com.sun.tools.javac.util.Pair;
  *
  * @author Peter von der Ahé
  */
-public class JavacTrees extends Trees {
+public class JavacTrees extends DocTrees {
 
     // in a world of a single context per compilation, these would all be final
     private Resolve resolve;
@@ -92,13 +132,17 @@ public class JavacTrees extends Trees {
     private TreeMaker treeMaker;
     private JavacElements elements;
     private JavacTaskImpl javacTaskImpl;
+    private Names names;
+    private Types types;
 
+    // called reflectively from Trees.instance(CompilationTask task)
     public static JavacTrees instance(JavaCompiler.CompilationTask task) {
-        if (!(task instanceof JavacTaskImpl))
+        if (!(task instanceof BasicJavacTask))
             throw new IllegalArgumentException();
-        return instance(((JavacTaskImpl)task).getContext());
+        return instance(((BasicJavacTask)task).getContext());
     }
 
+    // called reflectively from Trees.instance(ProcessingEnvironment env)
     public static JavacTrees instance(ProcessingEnvironment env) {
         if (!(env instanceof JavacProcessingEnvironment))
             throw new IllegalArgumentException();
@@ -122,6 +166,8 @@ public class JavacTrees extends Trees {
     }
 
     private void init(Context context) {
+        //Need ensure ClassReader is initialized before Symtab:
+        ClassReader.instance(context);
         attr = Attr.instance(context);
         enter = Enter.instance(context);
         elements = JavacElements.instance(context);
@@ -129,22 +175,121 @@ public class JavacTrees extends Trees {
         resolve = Resolve.instance(context);
         treeMaker = TreeMaker.instance(context);
         memberEnter = MemberEnter.instance(context);
-        javacTaskImpl = context.get(JavacTaskImpl.class);
+        names = Names.instance(context);
+        types = Types.instance(context);
+
+        JavacTask t = context.get(JavacTask.class);
+        if (t instanceof JavacTaskImpl)
+            javacTaskImpl = (JavacTaskImpl) t;
     }
 
-    public SourcePositions getSourcePositions() {
-        return new SourcePositions() {
+    public DocSourcePositions getSourcePositions() {
+        return new DocSourcePositions() {
                 public long getStartPosition(CompilationUnitTree file, Tree tree) {
                     return TreeInfo.getStartPos((JCTree) tree);
                 }
 
                 public long getEndPosition(CompilationUnitTree file, Tree tree) {
-                    Map<JCTree,Integer> endPositions = ((JCCompilationUnit) file).endPositions;
-                    return TreeInfo.getEndPos((JCTree) tree, endPositions);
+                    EndPosTable endPosTable = ((JCCompilationUnit) file).endPositions;
+                    return TreeInfo.getEndPos((JCTree) tree, endPosTable);
+                }
+
+                public long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) {
+                    return ((DCTree) tree).getSourcePosition((DCDocComment) comment);
+                }
+                @SuppressWarnings("fallthrough")
+                public long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree) {
+                    DCDocComment dcComment = (DCDocComment) comment;
+                    if (tree instanceof DCEndPosTree) {
+                        int endPos = ((DCEndPosTree) tree).getEndPos(dcComment);
+
+                        if (endPos != Position.NOPOS) {
+                            return endPos;
+                        }
+                    }
+                    int correction = 0;
+                    switch (tree.getKind()) {
+                        case TEXT:
+                            DCText text = (DCText) tree;
+
+                            return dcComment.comment.getSourcePos(text.pos + text.text.length());
+                        case ERRONEOUS:
+                            DCErroneous err = (DCErroneous) tree;
+
+                            return dcComment.comment.getSourcePos(err.pos + err.body.length());
+                        case IDENTIFIER:
+                            DCIdentifier ident = (DCIdentifier) tree;
+
+                            return dcComment.comment.getSourcePos(ident.pos + (ident.name != names.error ? ident.name.length() : 0));
+                        case PARAM:
+                            DCParam param = (DCParam) tree;
+
+                            if (param.isTypeParameter && param.getDescription().isEmpty()) {
+                                correction = 1;
+                            }
+                        case AUTHOR: case DEPRECATED: case RETURN: case SEE:
+                        case SERIAL: case SERIAL_DATA: case SERIAL_FIELD: case SINCE:
+                        case THROWS: case UNKNOWN_BLOCK_TAG: case VERSION: {
+                            DocTree last = getLastChild(tree);
+
+                            if (last != null) {
+                                return getEndPosition(file, comment, last) + correction;
+                            }
+
+                            DCBlockTag block = (DCBlockTag) tree;
+
+                            return dcComment.comment.getSourcePos(block.pos + block.getTagName().length() + 1);
+                        }
+                        case UNKNOWN_INLINE_TAG: {
+                            DocTree last = getLastChild(tree);
+
+                            if (last != null) {
+                                return getEndPosition(file, comment, last) + correction;
+                            }
+
+                            DCInlineTag inline = (DCInlineTag) tree;
+
+                            return dcComment.comment.getSourcePos(inline.pos + inline.getTagName().length() + 1);
+                        }                            
+                        case END_ELEMENT: {
+                            DCEndElement endEl = (DCEndElement) tree;
+                            return dcComment.comment.getSourcePos(endEl.pos + (endEl.name != names.error ? endEl.name.length() : 0) + 3);
+                        }
+                        case ENTITY: {
+                            DCEntity endEl = (DCEntity) tree;
+                            return dcComment.comment.getSourcePos(endEl.pos + (endEl.name != names.error ? endEl.name.length() : 0) + 2);
+                        }
+                        case COMMENT: {
+                            DCComment endEl = (DCComment) tree;
+                            return dcComment.comment.getSourcePos(endEl.pos + endEl.body.length());
+                        }
+                        default:
+                            DocTree last = getLastChild(tree);
+
+                            if (last != null) {
+                                return getEndPosition(file, comment, last);
+                            }
+                            break;
+                    }
+
+                    return Position.NOPOS;
                 }
             };
     }
 
+    private DocTree getLastChild(DocTree tree) {
+        final DocTree[] last = new DocTree[] {null};
+
+        tree.accept(new DocTreeScanner<Void, Void>() {
+            @Override public Void scan(DocTree node, Void p) {
+                if (node != null) last[0] = node;
+                return null;
+            }
+        }, null);
+
+        return last[0];
+    }
+
     public JCClassDecl getTree(TypeElement element) {
         return (JCClassDecl) getTree((Element) element);
     }
@@ -187,20 +332,22 @@ public class JavacTrees extends Trees {
         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 && TreeInfo.isDeclaration(tree)) {
-            for (TreePath p = path; p != null; p = p.getParentPath()) {
-                JCTree t = (JCTree) p.getLeaf();
-                if (t.getTag() == JCTree.CLASSDEF) {
-                    JCClassDecl ct = (JCClassDecl) t;
-                    if (ct.sym != null) {
-                        if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
-                            attr.attribClass(ct.pos(), ct.sym);
-                            sym = TreeInfo.symbolFor(tree);
+        if (sym == null) {
+            if (TreeInfo.isDeclaration(tree)) {
+                for (TreePath p = path; p != null; p = p.getParentPath()) {
+                    JCTree t = (JCTree) p.getLeaf();
+                    if (t.hasTag(JCTree.Tag.CLASSDEF)) {
+                        JCClassDecl ct = (JCClassDecl) t;
+                        if (ct.sym != null) {
+                            if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
+                                attr.attribClass(ct.pos(), ct.sym);
+                                sym = TreeInfo.symbolFor(tree);
+                            }
+                            break;
                         }
-                        break;
                     }
                 }
             }
@@ -208,6 +355,366 @@ public class JavacTrees extends Trees {
         return sym;
     }
 
+    @Override
+    public Element getElement(DocTreePath path) {
+        DocTree forTree = path.getLeaf();
+        if (forTree instanceof DCReference) {
+            return ensureDocReferenceAttributed(path.getTreePath(), ((DCReference) forTree));
+        }
+        if (forTree instanceof DCIdentifier) {
+            if (path.getParentPath().getLeaf() instanceof DCParam) {
+                return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
+            }
+        }
+        return null;
+    }
+
+    public Symbol ensureDocReferenceAttributed(TreePath path, DCReference ref) {
+        if (!ref.attributed) {
+            ref.attributed = true;
+            ref.sym = attributeDocReference(path, ref);
+        }
+        return ref.sym;
+    }
+    
+    private Symbol attributeDocReference(TreePath path, DCReference ref) {
+        Env<AttrContext> env = getAttrContext(path);
+
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
+                new Log.DeferredDiagnosticHandler(log);
+        try {
+            final ClassSymbol tsym;
+            final Name memberName;
+            if (ref.qualifierExpression == null) {
+                tsym = env.enclClass.sym;
+                memberName = ref.memberName;
+            } else {
+                // See if the qualifierExpression is a type or package name.
+                // javac does not provide the exact method required, so
+                // we first check if qualifierExpression identifies a type,
+                // and if not, then we check to see if it identifies a package.
+                Type t = attr.attribType(ref.qualifierExpression, env);
+                if (t.isErroneous()) {
+                    if (ref.memberName == null) {
+                        // Attr/Resolve assume packages exist and create symbols as needed
+                        // so use getPackageElement to restrict search to existing packages
+                        PackageSymbol pck = elements.getPackageElement(ref.qualifierExpression.toString());
+                        if (pck != null) {
+                            return pck;
+                        } else if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) {
+                            // fixup:  allow "identifier" instead of "#identifier"
+                            // for compatibility with javadoc
+                            tsym = env.enclClass.sym;
+                            memberName = ((JCIdent) ref.qualifierExpression).name;
+                        } else
+                            return null;
+                    } else {
+                        return null;
+                    }
+                } else {
+                    tsym = (ClassSymbol) t.tsym;
+                    memberName = ref.memberName;
+                }
+            }
+
+            if (memberName == null)
+                return tsym;
+
+            final List<Type> paramTypes;
+            if (ref.paramTypes == null)
+                paramTypes = null;
+            else {
+                ListBuffer<Type> lb = new ListBuffer<Type>();
+                for (List<JCTree> l = ref.paramTypes; l.nonEmpty(); l = l.tail) {
+                    JCTree tree = l.head;
+                    Type t = attr.attribType(tree, env);
+                    lb.add(t);
+                }
+                paramTypes = lb.toList();
+            }
+
+            Symbol msym = (memberName == tsym.name)
+                    ? findConstructor(tsym, paramTypes)
+                    : findMethod(tsym, memberName, paramTypes);
+            if (paramTypes != null) {
+                // explicit (possibly empty) arg list given, so cannot be a field
+                return msym;
+            }
+
+            VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName);
+            // prefer a field over a method with no parameters
+            if (vsym != null &&
+                    (msym == null ||
+                        types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) {
+                return vsym;
+            } else {
+                return msym;
+            }
+        } catch (Abort e) { // may be thrown by Check.completionError in case of bad class file
+            return null;
+        } finally {
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
+        }
+    }
+
+    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>());
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#searchField */
+    private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set<ClassSymbol> searched) {
+        if (searched.contains(tsym)) {
+            return null;
+        }
+        searched.add(tsym);
+
+        for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(fieldName);
+                e.scope != null; e = e.next()) {
+            if (e.sym.kind == Kinds.VAR) {
+                return (VarSymbol)e.sym;
+            }
+        }
+
+        //### If we found a VarSymbol above, but which did not pass
+        //### the modifier filter, we should return failure here!
+
+        ClassSymbol encl = tsym.owner.enclClass();
+        if (encl != null) {
+            VarSymbol vsym = searchField(encl, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        // search superclass
+        Type superclass = tsym.getSuperclass();
+        if (superclass.tsym != null) {
+            VarSymbol vsym = searchField((ClassSymbol) superclass.tsym, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        // search interfaces
+        List<Type> intfs = tsym.getInterfaces();
+        for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
+            Type intf = l.head;
+            if (intf.isErroneous()) continue;
+            VarSymbol vsym = searchField((ClassSymbol) intf.tsym, fieldName, searched);
+            if (vsym != null) {
+                return vsym;
+            }
+        }
+
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */
+    MethodSymbol findConstructor(ClassSymbol tsym, List<Type> paramTypes) {
+        for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init);
+                e.scope != null; e = e.next()) {
+            if (e.sym.kind == Kinds.MTH) {
+                if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+                    return (MethodSymbol) e.sym;
+                }
+            }
+        }
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */
+    private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List<Type> paramTypes) {
+        return searchMethod(tsym, methodName, paramTypes, new HashSet<ClassSymbol>());
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */
+    private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
+                                       List<Type> paramTypes, Set<ClassSymbol> searched) {
+        //### Note that this search is not necessarily what the compiler would do!
+
+        // do not match constructors
+        if (methodName == names.init)
+            return null;
+
+        if (searched.contains(tsym))
+            return null;
+        searched.add(tsym);
+
+        // search current class
+        com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName);
+
+        //### Using modifier filter here isn't really correct,
+        //### but emulates the old behavior.  Instead, we should
+        //### apply the normal rules of visibility and inheritance.
+
+        if (paramTypes == null) {
+            // If no parameters specified, we are allowed to return
+            // any method with a matching name.  In practice, the old
+            // code returned the first method, which is now the last!
+            // In order to provide textually identical results, we
+            // attempt to emulate the old behavior.
+            MethodSymbol lastFound = null;
+            for (; e.scope != null; e = e.next()) {
+                if (e.sym.kind == Kinds.MTH) {
+                    if (e.sym.name == methodName) {
+                        lastFound = (MethodSymbol)e.sym;
+                    }
+                }
+            }
+            if (lastFound != null) {
+                return lastFound;
+            }
+        } else {
+            for (; e.scope != null; e = e.next()) {
+                if (e.sym != null &&
+                    e.sym.kind == Kinds.MTH) {
+                    if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
+                        return (MethodSymbol) e.sym;
+                    }
+                }
+            }
+        }
+
+        //### If we found a MethodSymbol above, but which did not pass
+        //### the modifier filter, we should return failure here!
+
+        // search superclass
+        Type superclass = tsym.getSuperclass();
+        if (superclass.tsym != null) {
+            MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        // search interfaces
+        List<Type> intfs = tsym.getInterfaces();
+        for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
+            Type intf = l.head;
+            if (intf.isErroneous()) continue;
+            MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        // search enclosing class
+        ClassSymbol encl = tsym.owner.enclClass();
+        if (encl != null) {
+            MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched);
+            if (msym != null) {
+                return msym;
+            }
+        }
+
+        return null;
+    }
+
+    /** @see com.sun.tools.javadoc.ClassDocImpl */
+    private boolean hasParameterTypes(MethodSymbol method, List<Type> paramTypes) {
+        if (paramTypes == null)
+            return true;
+
+        if (method.params().size() != paramTypes.size())
+            return false;
+
+        List<Type> methodParamTypes = types.erasureRecursive(method.asType()).getParameterTypes();
+
+        return (Type.isErroneous(paramTypes))
+            ? fuzzyMatch(paramTypes, methodParamTypes)
+            : types.isSameTypes(paramTypes, methodParamTypes);
+    }
+
+    boolean fuzzyMatch(List<Type> paramTypes, List<Type> methodParamTypes) {
+        List<Type> l1 = paramTypes;
+        List<Type> l2 = methodParamTypes;
+        while (l1.nonEmpty()) {
+            if (!fuzzyMatch(l1.head, l2.head))
+                return false;
+            l1 = l1.tail;
+            l2 = l2.tail;
+        }
+        return true;
+    }
+
+    boolean fuzzyMatch(Type paramType, Type methodParamType) {
+        Boolean b = fuzzyMatcher.visit(paramType, methodParamType);
+        return (b == Boolean.TRUE);
+    }
+
+    TypeRelation fuzzyMatcher = new TypeRelation() {
+        @Override
+        public Boolean visitType(Type t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            switch (t.getTag()) {
+            case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
+            case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE:
+                return t.hasTag(s.getTag());
+            default:
+                throw new AssertionError("fuzzyMatcher " + t.getTag());
+            }
+        }
+
+        @Override
+        public Boolean visitArrayType(ArrayType t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            return s.hasTag(ARRAY)
+                && visit(t.elemtype, types.elemtype(s));
+        }
+
+        @Override
+        public Boolean visitClassType(ClassType t, Type s) {
+            if (t == s)
+                return true;
+
+            if (s.isPartial())
+                return visit(s, t);
+
+            return t.tsym == s.tsym;
+        }
+
+        @Override
+        public Boolean visitErrorType(ErrorType t, Type s) {
+            return s.hasTag(CLASS)
+                    && t.tsym.name == ((ClassType) s).tsym.name;
+        }
+    };
+
     public TypeMirror getTypeMirror(TreePath path) {
         Tree t = path.getLeaf();
         return ((JCTree)t).type;
@@ -219,10 +726,23 @@ public class JavacTrees extends Trees {
 
     public String getDocComment(TreePath path) {
         CompilationUnitTree t = path.getCompilationUnit();
-        if (t instanceof JCTree.JCCompilationUnit) {
+        Tree leaf = path.getLeaf();
+        if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
             JCCompilationUnit cu = (JCCompilationUnit) t;
             if (cu.docComments != null) {
-                return cu.docComments.get(path.getLeaf());
+                return cu.docComments.getCommentText((JCTree) leaf);
+            }
+        }
+        return null;
+    }
+
+    public DocCommentTree getDocCommentTree(final TreePath path) {
+        CompilationUnitTree t = path.getCompilationUnit();
+        Tree leaf = path.getLeaf();
+        if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
+            JCCompilationUnit cu = (JCCompilationUnit) t;
+            if (cu.docComments != null) {
+                return cu.docComments.getCommentTree((JCTree) leaf);
             }
         }
         return null;
@@ -230,6 +750,9 @@ public class JavacTrees extends Trees {
 
     public boolean isAccessible(Scope scope, TypeElement type) {
         if (scope instanceof JavacScope && type instanceof ClassSymbol) {
+            if ((((ClassSymbol)type).flags_field & Flags.NOT_IN_PROFILE) != 0) {
+                return false;
+            }
             Env<AttrContext> env = ((JavacScope) scope).env;
             return resolve.isAccessible(env, (ClassSymbol)type, true);
         } else
@@ -240,6 +763,9 @@ public class JavacTrees extends Trees {
         if (scope instanceof JavacScope
                 && member instanceof Symbol
                 && type instanceof com.sun.tools.javac.code.Type) {
+            if ((((com.sun.tools.javac.code.Type)type).tsym.flags_field & Flags.NOT_IN_PROFILE) != 0) {
+                return false;
+            }
             Env<AttrContext> env = ((JavacScope) scope).env;
             return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true);
         } else
@@ -250,9 +776,10 @@ public class JavacTrees extends Trees {
         if (!(path.getLeaf() instanceof JCTree))  // implicit null-check
             throw new IllegalArgumentException();
 
-        // if we're being invoked via from a JSR199 client, we need to make sure
-        // all the classes have been entered; if we're being invoked from JSR269,
-        // then the classes will already have been entered.
+        // if we're being invoked from a Tree API client via parse/enter/analyze,
+        // we need to make sure all the classes have been entered;
+        // if we're being invoked from JSR 199 or JSR 269, then the classes
+        // will already have been entered.
         if (javacTaskImpl != null) {
             try {
                 javacTaskImpl.enter(null);
@@ -307,21 +834,38 @@ public class JavacTrees extends Trees {
                     break;
                 case BLOCK: {
 //                    System.err.println("BLOCK: ");
-                    if (method != null)
-                        env = memberEnter.getMethodEnv(method, env);
-                    JCTree body = copier.copy((JCTree)tree, (JCTree) path.getLeaf());
-                    env = attribStatToTree(body, env, copier.leafCopy);
-                    clazz = null;
+                    if (method != null) {
+                        try {
+                            Assert.check(method.body == tree);
+                            method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf());
+                            e = memberEnter.getMethodEnv(method, env);
+                            if (e == null)
+                                return env;
+                            env = e;
+                            env = attribStatToTree(method.body, env, copier.leafCopy);
+                        } finally {
+                            method.body = (JCBlock) tree;
+                        }
+                    } else {
+                        JCBlock body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf());
+                        env = attribStatToTree(body, env, copier.leafCopy);
+                    }
                     return env;
                 }
                 default:
 //                    System.err.println("DEFAULT: " + tree.getKind());
                     if (clazz != null) {
-                        env = memberEnter.getBaseEnv(clazz, env);
+                        e = memberEnter.getBaseEnv(clazz, env);
+                        if (e == null)
+                            return env;
+                        env = e;
                         clazz = null;
                     }
                     if (field != null && field.getInitializer() == tree) {
-                        env = memberEnter.getInitEnv(field, env);
+                        e = memberEnter.getInitEnv(field, env);
+                        if (e == null)
+                            return env;
+                        env = e;
                         JCExpression expr = copier.copy((JCExpression)tree, (JCTree) path.getLeaf());
                         env = attribExprToTree(expr, env, copier.leafCopy);
                     }
@@ -333,36 +877,30 @@ public class JavacTrees extends Trees {
 
     private Env<AttrContext> attribStatToTree(JCTree stat, Env<AttrContext>env, JCTree tree) {
         JavaFileObject prev = log.useSource(null);
-        boolean old = log.suppressErrorsAndWarnings;
-        log.suppressErrorsAndWarnings = true;
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
         enter.shadowTypeEnvs(true);
         try {
             return attr.attribStatToTree(stat, env, tree);
         } finally {
             enter.shadowTypeEnvs(false);
-            log.suppressErrorsAndWarnings = old;
+            log.popDiagnosticHandler(discardHandler);
             log.useSource(prev);
         }
     }
 
     private Env<AttrContext> attribExprToTree(JCExpression expr, Env<AttrContext>env, JCTree tree) {
         JavaFileObject prev = log.useSource(null);
-        boolean old = log.suppressErrorsAndWarnings;
-        log.suppressErrorsAndWarnings = true;
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
         enter.shadowTypeEnvs(true);
         try {
             return attr.attribExprToTree(expr, env, tree);
         } finally {
             enter.shadowTypeEnvs(false);
-            log.suppressErrorsAndWarnings = old;
+            log.popDiagnosticHandler(discardHandler);
             log.useSource(prev);
         }
     }
 
-    protected Copier createCopier(TreeMaker make) {
-        return new Copier(make);
-    }
-    
     /**
      * Makes a copy of a tree, noting the value resulting from copying a particular leaf.
      **/
@@ -382,6 +920,10 @@ public class JavacTrees extends Trees {
         }
     }
 
+    protected Copier createCopier(TreeMaker maker) {
+        return new Copier(maker);
+    }
+
     /**
      * Gets the original type from the ErrorType object.
      * @param errorType The errorType for which we want to get the original type.
@@ -408,14 +950,27 @@ public class JavacTrees extends Trees {
     public void printMessage(Diagnostic.Kind kind, CharSequence msg,
             com.sun.source.tree.Tree t,
             com.sun.source.tree.CompilationUnitTree root) {
+        printMessage(kind, msg, ((JCTree) t).pos(), root);
+    }
+
+    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.doctree.DocTree t,
+            com.sun.source.doctree.DocCommentTree c,
+            com.sun.source.tree.CompilationUnitTree root) {
+        printMessage(kind, msg, ((DCTree) t).pos((DCDocComment) c), root);
+    }
+
+    private void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            JCDiagnostic.DiagnosticPosition pos,
+            com.sun.source.tree.CompilationUnitTree root) {
         JavaFileObject oldSource = null;
         JavaFileObject newSource = null;
-        JCDiagnostic.DiagnosticPosition pos = null;
 
         newSource = root.getSourceFile();
-        if (newSource != null) {
+        if (newSource == null) {
+            pos = null;
+        } else {
             oldSource = log.useSource(newSource);
-            pos = ((JCTree) t).pos();
         }
 
         try {
diff --git a/src/share/classes/com/sun/tools/javac/api/MultiTaskListener.java b/src/share/classes/com/sun/tools/javac/api/MultiTaskListener.java
new file mode 100644
index 0000000..f1c21f9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/api/MultiTaskListener.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.api;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * TODO.
+ *
+ * <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 MultiTaskListener implements TaskListener {
+    /** The context key for the MultiTaskListener. */
+    public static final Context.Key<MultiTaskListener> taskListenerKey =
+        new Context.Key<MultiTaskListener>();
+
+    /** Get the MultiTaskListener instance for this context. */
+    public static MultiTaskListener instance(Context context) {
+        MultiTaskListener instance = context.get(taskListenerKey);
+        if (instance == null)
+            instance = new MultiTaskListener(context);
+        return instance;
+    }
+
+    protected MultiTaskListener(Context context) {
+        context.put(taskListenerKey, this);
+        ccw = ClientCodeWrapper.instance(context);
+    }
+
+    /**
+     * The current set of registered listeners.
+     * This is a mutable reference to an immutable array.
+     */
+    TaskListener[] listeners = { };
+
+    ClientCodeWrapper ccw;
+
+    public Collection<TaskListener> getTaskListeners() {
+        return Arrays.asList(listeners);
+    }
+
+    public boolean isEmpty() {
+        return (listeners.length == 0);
+    }
+
+    public void add(TaskListener listener) {
+        for (TaskListener l: listeners) {
+            if (ccw.unwrap(l) == listener)
+                throw new IllegalStateException();
+        }
+        listeners = Arrays.copyOf(listeners, listeners.length + 1);
+        listeners[listeners.length - 1] = ccw.wrap(listener);
+    }
+
+    public void remove(TaskListener listener) {
+        for (int i = 0; i < listeners.length; i++) {
+            if (ccw.unwrap(listeners[i]) == listener) {
+                TaskListener[] newListeners = new TaskListener[listeners.length - 1];
+                System.arraycopy(listeners, 0, newListeners, 0, i);
+                System.arraycopy(listeners, i + 1, newListeners, i, newListeners.length - i);
+                listeners = newListeners;
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void started(TaskEvent e) {
+        // guard against listeners being updated by a listener
+        TaskListener[] ll = this.listeners;
+        for (TaskListener l: ll)
+            l.started(e);
+    }
+
+    @Override
+    public void finished(TaskEvent e) {
+        // guard against listeners being updated by a listener
+        TaskListener[] ll = this.listeners;
+        for (TaskListener l: ll)
+            l.finished(e);
+    }
+
+    @Override
+    public String toString() {
+        return Arrays.toString(listeners);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java b/src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java
index 41d9874..2472834 100644
--- a/src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java
+++ b/src/share/classes/com/sun/tools/javac/api/WrappingJavaFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -31,8 +31,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
-import javax.tools.JavaFileObject.Kind;
+
 import javax.tools.*;
+import javax.tools.JavaFileObject.Kind;
 
 /**
  * Wraps all calls to a given file manager.  Subclasses of this class
diff --git a/src/share/classes/com/sun/tools/javac/code/Annotations.java b/src/share/classes/com/sun/tools/javac/code/Annotations.java
new file mode 100644
index 0000000..5be0865
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/code/Annotations.java
@@ -0,0 +1,451 @@
+/*
+ * 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.  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.code;
+
+import java.util.Map;
+
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.comp.Annotate;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Pair;
+import static com.sun.tools.javac.code.Kinds.PCK;
+
+/**
+ * Container for all annotations (attributes in javac) on a Symbol.
+ *
+ * This class is explicitly mutable. Its contents will change when attributes
+ * are annotated onto the Symbol. However this class depends on the facts that
+ * List (in javac) is immutable.
+ *
+ * An instance of this class can be in one of three states:
+ *
+ * NOT_STARTED indicates that the Symbol this instance belongs to has not been
+ * annotated (yet). Specifically if the declaration is not annotated this
+ * instance will never move past NOT_STARTED. You can never go back to
+ * NOT_STARTED.
+ *
+ * IN_PROGRESS annotations have been found on the declaration. Will be processed
+ * later. You can reset to IN_PROGRESS. While IN_PROGRESS you can set the list
+ * of attributes (and this moves out of the IN_PROGRESS state).
+ *
+ * "unnamed" this Annotations contains some attributes, possibly the final set.
+ * While in this state you can only prepend or append to the attributes not set
+ * it directly. You can also move back to the IN_PROGRESS state using reset().
+ *
+ * <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 Annotations {
+
+    private static final List<Attribute.Compound> DECL_NOT_STARTED = List.of(null);
+    private static final List<Attribute.Compound> DECL_IN_PROGRESS = List.of(null);
+
+    /*
+     * This field should never be null
+     */
+    private List<Attribute.Compound> attributes = DECL_NOT_STARTED;
+
+    /*
+     * 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;
+
+    public Annotations(Symbol sym) {
+        this.sym = sym;
+    }
+
+    public List<Attribute.Compound> getDeclarationAttributes() {
+        return filterDeclSentinels(attributes);
+    }
+
+    public List<Attribute.TypeCompound> getTypeAttributes() {
+        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) {
+            throw new NullPointerException();
+        }
+        attributes = a;
+    }
+
+    public void setTypeAttributes(List<Attribute.TypeCompound> a) {
+        if (a == null) {
+            throw new NullPointerException();
+        }
+        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) {
+        Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK));
+        this.setDeclarationAttributes(getAttributesForCompletion(ctx));
+    }
+
+    public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) {
+        this.appendUniqueTypes(getAttributesForCompletion(ctx));
+    }
+
+    private <T extends Attribute.Compound> List<T> getAttributesForCompletion(
+            final Annotate.AnnotateRepeatedContext<T> ctx) {
+
+        Map<Symbol.TypeSymbol, ListBuffer<T>> annotated = ctx.annotated;
+        boolean atLeastOneRepeated = false;
+        List<T> buf = List.<T>nil();
+        for (ListBuffer<T> lb : annotated.values()) {
+            if (lb.size() == 1) {
+                buf = buf.prepend(lb.first());
+            } else { // repeated
+                // This will break when other subtypes of Attributs.Compound
+                // are introduced, because PlaceHolder is a subtype of TypeCompound.
+                T res;
+                @SuppressWarnings("unchecked")
+                T ph = (T) new Placeholder<T>(ctx, lb.toList(), sym);
+                res = ph;
+                buf = buf.prepend(res);
+                atLeastOneRepeated = true;
+            }
+        }
+
+        if (atLeastOneRepeated) {
+            // The Symbol s is now annotated with a combination of
+            // finished non-repeating annotations and placeholders for
+            // repeating annotations.
+            //
+            // We need to do this in two passes because when creating
+            // a container for a repeating annotation we must
+            // guarantee that the @Repeatable on the
+            // contained annotation is fully annotated
+            //
+            // The way we force this order is to do all repeating
+            // annotations in a pass after all non-repeating are
+            // finished. This will work because @Repeatable
+            // is non-repeating and therefore will be annotated in the
+            // fist pass.
+
+            // Queue a pass that will replace Attribute.Placeholders
+            // with Attribute.Compound (made from synthesized containers).
+            ctx.annotateRepeated(new Annotate.Annotator() {
+                @Override
+                public String toString() {
+                    return "repeated annotation pass of: " + sym + " in: " + sym.owner;
+                }
+
+                @Override
+                public void enterAnnotation() {
+                    complete(ctx);
+                }
+            });
+        }
+        // Add non-repeating attributes
+        return buf.reverse();
+    }
+
+    public Annotations reset() {
+        attributes = DECL_IN_PROGRESS;
+        return this;
+    }
+
+    public boolean isEmpty() {
+        return !isStarted()
+                || pendingCompletion()
+                || attributes.isEmpty();
+    }
+
+    public boolean isTypesEmpty() {
+        return type_attributes.isEmpty();
+    }
+
+    public boolean pendingCompletion() {
+        return attributes == DECL_IN_PROGRESS;
+    }
+
+    public Annotations append(List<Attribute.Compound> l) {
+        attributes = filterDeclSentinels(attributes);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.appendList(l);
+        }
+        return this;
+    }
+
+    public Annotations appendUniqueTypes(List<Attribute.TypeCompound> l) {
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (type_attributes.isEmpty()) {
+            type_attributes = l;
+        } else {
+            // TODO: in case we expect a large number of annotations, this
+            // might be inefficient.
+            for (Attribute.TypeCompound tc : l) {
+                if (!type_attributes.contains(tc))
+                    type_attributes = type_attributes.append(tc);
+            }
+        }
+        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);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.prependList(l);
+        }
+        return this;
+    }
+
+    private List<Attribute.Compound> filterDeclSentinels(List<Attribute.Compound> a) {
+        return (a == DECL_IN_PROGRESS || a == DECL_NOT_STARTED)
+                ? List.<Attribute.Compound>nil()
+                : a;
+    }
+
+    private boolean isStarted() {
+        return attributes != DECL_NOT_STARTED;
+    }
+
+    private List<Attribute.Compound> getPlaceholders() {
+        List<Attribute.Compound> res = List.<Attribute.Compound>nil();
+        for (Attribute.Compound a : filterDeclSentinels(attributes)) {
+            if (a instanceof Placeholder) {
+                res = res.prepend(a);
+            }
+        }
+        return res.reverse();
+    }
+
+    private List<Attribute.TypeCompound> getTypePlaceholders() {
+        List<Attribute.TypeCompound> res = List.<Attribute.TypeCompound>nil();
+        for (Attribute.TypeCompound a : type_attributes) {
+            if (a instanceof Placeholder) {
+                res = res.prepend(a);
+            }
+        }
+        return res.reverse();
+    }
+
+    /*
+     * Replace Placeholders for repeating annotations with their containers
+     */
+    private <T extends Attribute.Compound> void complete(Annotate.AnnotateRepeatedContext<T> ctx) {
+        Log log = ctx.log;
+        Env<AttrContext> env = ctx.env;
+        JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
+        try {
+            // TODO: can we reduce duplication in the following branches?
+            if (ctx.isTypeCompound) {
+                Assert.check(!isTypesEmpty());
+
+                if (isTypesEmpty()) {
+                    return;
+                }
+
+                List<Attribute.TypeCompound> result = List.nil();
+                for (Attribute.TypeCompound a : getTypeAttributes()) {
+                    if (a instanceof Placeholder) {
+                        @SuppressWarnings("unchecked")
+                        Placeholder<Attribute.TypeCompound> ph = (Placeholder<Attribute.TypeCompound>) a;
+                        Attribute.TypeCompound replacement = replaceOne(ph, ph.getRepeatedContext());
+
+                        if (null != replacement) {
+                            result = result.prepend(replacement);
+                        }
+                    } else {
+                        result = result.prepend(a);
+                    }
+                }
+
+                type_attributes = result.reverse();
+
+                Assert.check(Annotations.this.getTypePlaceholders().isEmpty());
+            } else {
+                Assert.check(!pendingCompletion());
+
+                if (isEmpty()) {
+                    return;
+                }
+
+                List<Attribute.Compound> result = List.nil();
+                for (Attribute.Compound a : getDeclarationAttributes()) {
+                    if (a instanceof Placeholder) {
+                        @SuppressWarnings("unchecked")
+                        Attribute.Compound replacement = replaceOne((Placeholder<T>) a, ctx);
+
+                        if (null != replacement) {
+                            result = result.prepend(replacement);
+                        }
+                    } else {
+                        result = result.prepend(a);
+                    }
+                }
+
+                attributes = result.reverse();
+
+                Assert.check(Annotations.this.getPlaceholders().isEmpty());
+            }
+        } finally {
+            log.useSource(oldSource);
+        }
+    }
+
+    private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
+        Log log = ctx.log;
+
+        // Process repeated annotations
+        T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);
+
+        if (validRepeated != null) {
+            // Check that the container isn't manually
+            // present along with repeated instances of
+            // its contained annotation.
+            ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
+            if (manualContainer != null) {
+                log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
+                        manualContainer.first().type.tsym);
+            }
+        }
+
+        // A null return will delete the Placeholder
+        return validRepeated;
+    }
+
+    private static class Placeholder<T extends Attribute.Compound> extends Attribute.TypeCompound {
+
+        private final Annotate.AnnotateRepeatedContext<T> ctx;
+        private final List<T> placeholderFor;
+        private final Symbol on;
+
+        public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
+            super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
+                    ctx.isTypeCompound ?
+                            ((Attribute.TypeCompound)placeholderFor.head).position :
+                                null);
+            this.ctx = ctx;
+            this.placeholderFor = placeholderFor;
+            this.on = on;
+        }
+
+        @Override
+        public String toString() {
+            return "<placeholder: " + placeholderFor + " on: " + on + ">";
+        }
+
+        public List<T> getPlaceholderFor() {
+            return placeholderFor;
+        }
+
+        public Annotate.AnnotateRepeatedContext<T> getRepeatedContext() {
+            return ctx;
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/code/Attribute.java b/src/share/classes/com/sun/tools/javac/code/Attribute.java
index 37bb6ee..bb29eea 100644
--- a/src/share/classes/com/sun/tools/javac/code/Attribute.java
+++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java
@@ -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
@@ -34,8 +34,6 @@ import javax.lang.model.type.DeclaredType;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.util.*;
 
-import static com.sun.tools.javac.code.TypeTags.*;
-
 /** An annotation value.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -62,6 +60,9 @@ public abstract class Attribute implements AnnotationValue {
         throw new UnsupportedOperationException();
     }
 
+    public boolean isSynthesized() {
+        return false;
+    }
 
     /** The value for an annotation element of primitive type or String. */
     public static class Constant extends Attribute {
@@ -82,7 +83,7 @@ public abstract class Attribute implements AnnotationValue {
                 return v.visitString((String) value, p);
             if (value instanceof Integer) {
                 int i = (Integer) value;
-                switch (type.tag) {
+                switch (type.getTag()) {
                 case BOOLEAN:   return v.visitBoolean(i != 0, p);
                 case CHAR:      return v.visitChar((char) i, p);
                 case BYTE:      return v.visitByte((byte) i, p);
@@ -90,7 +91,7 @@ public abstract class Attribute implements AnnotationValue {
                 case INT:       return v.visitInt(i, p);
                 }
             }
-            switch (type.tag) {
+            switch (type.getTag()) {
             case LONG:          return v.visitLong((Long) value, p);
             case FLOAT:         return v.visitFloat((Float) value, p);
             case DOUBLE:        return v.visitDouble((Double) value, p);
@@ -103,11 +104,11 @@ public abstract class Attribute implements AnnotationValue {
      *  represented as a ClassSymbol.
      */
     public static class Class extends Attribute {
-        public final Type type;
+        public final Type classType;
         public void accept(Visitor v) { v.visitClass(this); }
         public Class(Types types, Type type) {
             super(makeClassType(types, type));
-            this.type = type;
+            this.classType = type;
         }
         static Type makeClassType(Types types, Type type) {
             Type arg = type.isPrimitive()
@@ -118,13 +119,13 @@ public abstract class Attribute implements AnnotationValue {
                                       types.syms.classType.tsym);
         }
         public String toString() {
-            return type + ".class";
+            return classType + ".class";
         }
         public Type getValue() {
-            return type;
+            return classType;
         }
         public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
-            return v.visitType(type, p);
+            return v.visitType(classType, p);
         }
     }
 
@@ -138,6 +139,18 @@ public abstract class Attribute implements AnnotationValue {
          *  access this attribute.
          */
         public final List<Pair<MethodSymbol,Attribute>> values;
+
+        private boolean synthesized = false;
+
+        @Override
+        public boolean isSynthesized() {
+            return synthesized;
+        }
+
+        public void setSynthesized(boolean synthesized) {
+            this.synthesized = synthesized;
+        }
+
         public Compound(Type type,
                         List<Pair<MethodSymbol,Attribute>> values) {
             super(type);
@@ -204,6 +217,57 @@ public abstract class Attribute implements AnnotationValue {
         }
     }
 
+    public static class TypeCompound extends Compound {
+        public TypeAnnotationPosition position;
+        public TypeCompound(Compound compound,
+                TypeAnnotationPosition position) {
+            this(compound.type, compound.values, position);
+        }
+        public TypeCompound(Type type,
+                List<Pair<MethodSymbol, Attribute>> values,
+                TypeAnnotationPosition position) {
+            super(type, values);
+            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.
      */
     public static class Array extends Attribute {
@@ -212,6 +276,12 @@ public abstract class Attribute implements AnnotationValue {
             super(type);
             this.values = values;
         }
+
+        public Array(Type type, List<Attribute> values) {
+            super(type);
+            this.values = values.toArray(new Attribute[values.size()]);
+        }
+
         public void accept(Visitor v) { v.visitArray(this); }
         public String toString() {
             StringBuilder buf = new StringBuilder();
diff --git a/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java b/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java
index 5034b79..de01a60 100644
--- a/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java
+++ b/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,8 @@ import java.util.Map;
 
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.ListBuffer;
 
 /**
  *
diff --git a/src/share/classes/com/sun/tools/javac/code/Flags.java b/src/share/classes/com/sun/tools/javac/code/Flags.java
index d35c977..9d4f6ba 100644
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,12 +25,15 @@
 
 package com.sun.tools.javac.code;
 
-import java.util.EnumSet;
 import java.util.Collections;
+import java.util.EnumSet;
 import java.util.Map;
 import java.util.Set;
+
 import javax.lang.model.element.Modifier;
 
+import com.sun.tools.javac.util.Assert;
+
 /** Access flags and other modifiers for Java classes and members.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -45,51 +48,29 @@ public class Flags {
     public static String toString(long flags) {
         StringBuilder buf = new StringBuilder();
         String sep = "";
-        for (Flag s : asFlagSet(flags)) {
+        for (Flag flag : asFlagSet(flags)) {
             buf.append(sep);
-            buf.append(s);
+            buf.append(flag);
             sep = " ";
         }
         return buf.toString();
     }
 
-    public static EnumSet<Flag> asFlagSet(long mask) {
-        EnumSet<Flag> flags = EnumSet.noneOf(Flag.class);
-        if ((mask&PUBLIC) != 0) flags.add(Flag.PUBLIC);
-        if ((mask&PRIVATE) != 0) flags.add(Flag.PRIVATE);
-        if ((mask&PROTECTED) != 0) flags.add(Flag.PROTECTED);
-        if ((mask&STATIC) != 0) flags.add(Flag.STATIC);
-        if ((mask&FINAL) != 0) flags.add(Flag.FINAL);
-        if ((mask&SYNCHRONIZED) != 0) flags.add(Flag.SYNCHRONIZED);
-        if ((mask&VOLATILE) != 0) flags.add(Flag.VOLATILE);
-        if ((mask&TRANSIENT) != 0) flags.add(Flag.TRANSIENT);
-        if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
-        if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
-        if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
-        if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
-        if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
-        if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
-        if ((mask&DEPRECATED) != 0) flags.add(Flag.DEPRECATED);
-        if ((mask&HASINIT) != 0) flags.add(Flag.HASINIT);
-        if ((mask&ENUM) != 0) flags.add(Flag.ENUM);
-        if ((mask&IPROXY) != 0) flags.add(Flag.IPROXY);
-        if ((mask&NOOUTERTHIS) != 0) flags.add(Flag.NOOUTERTHIS);
-        if ((mask&EXISTS) != 0) flags.add(Flag.EXISTS);
-        if ((mask&COMPOUND) != 0) flags.add(Flag.COMPOUND);
-        if ((mask&CLASS_SEEN) != 0) flags.add(Flag.CLASS_SEEN);
-        if ((mask&SOURCE_SEEN) != 0) flags.add(Flag.SOURCE_SEEN);
-        if ((mask&LOCKED) != 0) flags.add(Flag.LOCKED);
-        if ((mask&UNATTRIBUTED) != 0) flags.add(Flag.UNATTRIBUTED);
-        if ((mask&ANONCONSTR) != 0) flags.add(Flag.ANONCONSTR);
-        if ((mask&ACYCLIC) != 0) flags.add(Flag.ACYCLIC);
-        if ((mask&PARAMETER) != 0) flags.add(Flag.PARAMETER);
-        if ((mask&VARARGS) != 0) flags.add(Flag.VARARGS);
-        return flags;
+    public static EnumSet<Flag> asFlagSet(long flags) {
+        EnumSet<Flag> flagSet = EnumSet.noneOf(Flag.class);
+        for (Flag flag : Flag.values()) {
+            if ((flags & flag.value) != 0) {
+                flagSet.add(flag);
+                flags &= ~flag.value;
+            }
+        }
+        Assert.check(flags == 0, "Flags parameter contains unknown flags " + flags);
+        return flagSet;
     }
 
     /* Standard Java flags.
      */
-    public static final int PUBLIC       = 1<<0;
+    public static final int PUBLIC       = 1;
     public static final int PRIVATE      = 1<<1;
     public static final int PROTECTED    = 1<<2;
     public static final int STATIC       = 1<<3;
@@ -112,6 +93,9 @@ public class Flags {
      *  classfile v49.0. */
     public static final int ENUM         = 1<<14;
 
+    /** Added in SE8, represents constructs implicitly declared in source. */
+    public static final int MANDATED     = 1<<15;
+
     public static final int StandardFlags = 0x0fff;
     public static final int ModifierFlags = StandardFlags & ~INTERFACE;
 
@@ -148,9 +132,9 @@ public class Flags {
 
     /** Flag is set for nested classes that do not access instance members
      *  or `this' of an outer class and therefore don't need to be passed
-     *  a this$n reference.  This flag is currently set only for anonymous
+     *  a this$n reference.  This value is currently set only for anonymous
      *  classes in superclass constructor calls and only for pre 1.4 targets.
-     *  todo: use this flag for optimizing away this$n parameters in
+     *  todo: use this value for optimizing away this$n parameters in
      *  other cases.
      */
     public static final int NOOUTERTHIS  = 1<<22;
@@ -221,7 +205,7 @@ public class Flags {
 
     /** Flag that marks a hypothetical method that need not really be
      *  generated in the binary, but is present in the symbol table to
-     *  simplify checking for erasure clashes.
+     *  simplify checking for erasure clashes - also used for 292 poly sig methods.
      */
     public static final long HYPOTHETICAL   = 1L<<37;
 
@@ -231,32 +215,57 @@ public class Flags {
     public static final long PROPRIETARY = 1L<<38;
 
     /**
-     * Flag that marks a a multi-catch parameter
+     * Flag that marks a multi-catch parameter.
      */
     public static final long UNION = 1L<<39;
 
     /**
-     * Flag that marks a signature-polymorphic invoke method.
-     * (These occur inside java.lang.invoke.MethodHandle.)
+     * Flag that marks a special kind of bridge method (the ones that
+     * come from restricted supertype bounds).
+     */
+    public static final long OVERRIDE_BRIDGE = 1L<<40;
+
+    /**
+     * Flag that marks an 'effectively final' local variable.
+     */
+    public static final long EFFECTIVELY_FINAL = 1L<<41;
+
+    /**
+     * Flag that marks non-override equivalent methods with the same signature.
+     */
+    public static final long CLASH = 1L<<42;
+
+    /**
+     * Flag that marks either a default method or an interface containing default methods.
+     */
+    public static final long DEFAULT = 1L<<43;
+
+    /**
+     * Flag that marks class as auxiliary, ie a non-public class following
+     * the public class in a source file, that could block implicit compilation.
+     */
+    public static final long AUXILIARY = 1L<<44;
+
+    /**
+     * Flag that marks that a symbol is not available in the current profile
      */
-    public static final long POLYMORPHIC_SIGNATURE = 1L<<40;
-    
+    public static final long NOT_IN_PROFILE = 1L<<45;
+
     /**
-     * Flag that marks a special kind of bridge methods (the ones that
-     * come from restricted supertype bounds)
+     * Flag that indicates that an override error has been detected by Check.
      */
-    public static final long OVERRIDE_BRIDGE = 1L<<41;
+    public static final long BAD_OVERRIDE = 1L<<45;
 
     /**
-     * Flag that marks an 'effectively final' local variable
+     * Flag that indicates a signature polymorphic method (292).
      */
-    public static final long EFFECTIVELY_FINAL = 1L<<42;
+    public static final long SIGNATURE_POLYMORPHIC = 1L<<46;
 
     /**
-     * Flag that marks non-override equivalent methods with the same signature
+     * Flag that marks inference variables used in a 'throws' clause
      */
-    public static final long CLASH = 1L<<43;
-    
+    public static final long THROWS = 1L<<47;
+
     public static final long FROMCLASS = 1L<<61;
     public static final long APT_CLEANED = 1L<<62;
 
@@ -275,7 +284,10 @@ public class Flags {
         MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
                                 SYNCHRONIZED | FINAL | STRICTFP;
     public static final long
-        LocalVarFlags         = FINAL | PARAMETER;
+        ExtendedStandardFlags       = (long)StandardFlags | DEFAULT,
+        InterfaceMethodMask         = ABSTRACT | STATIC | PUBLIC | STRICTFP | DEFAULT,
+        LocalVarFlags               = FINAL | PARAMETER;
+
 
     public static Set<Modifier> asModifierSet(long flags) {
         Set<Modifier> modifiers = modifierSets.get(flags);
@@ -293,6 +305,7 @@ public class Flags {
                                           modifiers.add(Modifier.SYNCHRONIZED);
             if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
             if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
+            if (0 != (flags & DEFAULT))   modifiers.add(Modifier.DEFAULT);
             modifiers = Collections.unmodifiableSet(modifiers);
             modifierSets.put(flags, modifiers);
         }
@@ -300,7 +313,7 @@ public class Flags {
     }
 
     // Cache of modifier sets.
-    private static Map<Long, Set<Modifier>> modifierSets =
+    private static final Map<Long, Set<Modifier>> modifierSets =
         new java.util.concurrent.ConcurrentHashMap<Long, Set<Modifier>>(64);
 
     public static boolean isStatic(Symbol symbol) {
@@ -315,47 +328,67 @@ public class Flags {
         return symbol.getConstValue() != null;
     }
 
-    public enum Flag {
 
-        PUBLIC("public"),
-        PRIVATE("private"),
-        PROTECTED("protected"),
-        STATIC("static"),
-        FINAL("final"),
-        SYNCHRONIZED("synchronized"),
-        VOLATILE("volatile"),
-        TRANSIENT("transient"),
-        NATIVE("native"),
-        INTERFACE("interface"),
-        ABSTRACT("abstract"),
-        STRICTFP("strictfp"),
-        BRIDGE("bridge"),
-        SYNTHETIC("synthetic"),
-        DEPRECATED("deprecated"),
-        HASINIT("hasinit"),
-        ENUM("enum"),
-        IPROXY("iproxy"),
-        NOOUTERTHIS("noouterthis"),
-        EXISTS("exists"),
-        COMPOUND("compound"),
-        CLASS_SEEN("class_seen"),
-        SOURCE_SEEN("source_seen"),
-        LOCKED("locked"),
-        UNATTRIBUTED("unattributed"),
-        ANONCONSTR("anonconstr"),
-        ACYCLIC("acyclic"),
-        PARAMETER("parameter"),
-        VARARGS("varargs"),
-        PACKAGE("package");
-
-        String name;
-
-        Flag(String name) {
-            this.name = name;
+    public enum Flag {
+        PUBLIC(Flags.PUBLIC),
+        PRIVATE(Flags.PRIVATE),
+        PROTECTED(Flags.PROTECTED),
+        STATIC(Flags.STATIC),
+        FINAL(Flags.FINAL),
+        SYNCHRONIZED(Flags.SYNCHRONIZED),
+        VOLATILE(Flags.VOLATILE),
+        TRANSIENT(Flags.TRANSIENT),
+        NATIVE(Flags.NATIVE),
+        INTERFACE(Flags.INTERFACE),
+        ABSTRACT(Flags.ABSTRACT),
+        DEFAULT(Flags.DEFAULT),
+        STRICTFP(Flags.STRICTFP),
+        BRIDGE(Flags.BRIDGE),
+        SYNTHETIC(Flags.SYNTHETIC),
+        ANNOTATION(Flags.ANNOTATION),
+        DEPRECATED(Flags.DEPRECATED),
+        HASINIT(Flags.HASINIT),
+        BLOCK(Flags.BLOCK),
+        ENUM(Flags.ENUM),
+        MANDATED(Flags.MANDATED),
+        IPROXY(Flags.IPROXY),
+        NOOUTERTHIS(Flags.NOOUTERTHIS),
+        EXISTS(Flags.EXISTS),
+        COMPOUND(Flags.COMPOUND),
+        CLASS_SEEN(Flags.CLASS_SEEN),
+        SOURCE_SEEN(Flags.SOURCE_SEEN),
+        LOCKED(Flags.LOCKED),
+        UNATTRIBUTED(Flags.UNATTRIBUTED),
+        ANONCONSTR(Flags.ANONCONSTR),
+        ACYCLIC(Flags.ACYCLIC),
+        PARAMETER(Flags.PARAMETER),
+        VARARGS(Flags.VARARGS),
+        ACYCLIC_ANN(Flags.ACYCLIC_ANN),
+        GENERATEDCONSTR(Flags.GENERATEDCONSTR),
+        HYPOTHETICAL(Flags.HYPOTHETICAL),
+        PROPRIETARY(Flags.PROPRIETARY),
+        UNION(Flags.UNION),
+        OVERRIDE_BRIDGE(Flags.OVERRIDE_BRIDGE),
+        EFFECTIVELY_FINAL(Flags.EFFECTIVELY_FINAL),
+        CLASH(Flags.CLASH),
+        AUXILIARY(Flags.AUXILIARY),
+        NOT_IN_PROFILE(Flags.NOT_IN_PROFILE),
+        BAD_OVERRIDE(Flags.BAD_OVERRIDE),
+        SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC),
+        THROWS(Flags.THROWS);
+
+        Flag(long flag) {
+            this.value = flag;
+            this.lowercaseName = name().toLowerCase();
         }
 
+        @Override
         public String toString() {
-            return name;
+            return lowercaseName;
         }
+
+        final long value;
+        final String lowercaseName;
     }
+
 }
diff --git a/src/share/classes/com/sun/tools/javac/code/Kinds.java b/src/share/classes/com/sun/tools/javac/code/Kinds.java
index 7bd4e32..1ec0a5b 100644
--- a/src/share/classes/com/sun/tools/javac/code/Kinds.java
+++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -28,11 +28,13 @@ package com.sun.tools.javac.code;
 import java.util.EnumSet;
 import java.util.Locale;
 
+import com.sun.source.tree.MemberReferenceTree;
 import com.sun.tools.javac.api.Formattable;
 import com.sun.tools.javac.api.Messages;
-
-import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.PACKAGE;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
 
 /** Internal symbol kinds, which distinguish between elements of
  *  different subclasses of Symbol. Symbol kinds are organized so they can be
@@ -71,9 +73,13 @@ public class Kinds {
      */
     public final static int MTH = 1 << 4;
 
+    /** Poly kind, for deferred types.
+     */
+    public final static int POLY = 1 << 5;
+
     /** The error kind, which includes all other kinds.
      */
-    public final static int ERR = (1 << 5) - 1;
+    public final static int ERR = (1 << 6) - 1;
 
     /** The set of all kinds.
      */
@@ -81,15 +87,16 @@ public class Kinds {
 
     /** Kinds for erroneous symbols that complement the above
      */
-    public static final int ERRONEOUS = 1 << 6;
+    public static final int ERRONEOUS = 1 << 7;
     public static final int AMBIGUOUS    = ERRONEOUS+1; // ambiguous reference
     public static final int HIDDEN       = ERRONEOUS+2; // hidden method or field
     public static final int STATICERR    = ERRONEOUS+3; // nonstatic member from static context
-    public static final int ABSENT_VAR   = ERRONEOUS+4; // missing variable
-    public static final int WRONG_MTHS   = ERRONEOUS+5; // methods with wrong arguments
-    public static final int WRONG_MTH    = ERRONEOUS+6; // one method with wrong arguments
-    public static final int ABSENT_MTH   = ERRONEOUS+7; // missing method
-    public static final int ABSENT_TYP   = ERRONEOUS+8; // missing type
+    public static final int MISSING_ENCL = ERRONEOUS+4; // missing enclosing class
+    public static final int ABSENT_VAR   = ERRONEOUS+5; // missing variable
+    public static final int WRONG_MTHS   = ERRONEOUS+6; // methods with wrong arguments
+    public static final int WRONG_MTH    = ERRONEOUS+7; // one method with wrong arguments
+    public static final int ABSENT_MTH   = ERRONEOUS+8; // missing method
+    public static final int ABSENT_TYP   = ERRONEOUS+9; // missing type
 
     public enum KindName implements Formattable {
         ANNOTATION("kindname.annotation"),
@@ -108,7 +115,7 @@ public class Kinds {
         PACKAGE("kindname.package"),
         ERROR("kindname.error");
 
-        private String name;
+        private final String name;
 
         KindName(String name) {
             this.name = name;
@@ -142,6 +149,14 @@ public class Kinds {
         }
     }
 
+    public static KindName kindName(MemberReferenceTree.ReferenceMode mode) {
+        switch (mode) {
+            case INVOKE: return KindName.METHOD;
+            case NEW: return KindName.CONSTRUCTOR;
+            default : throw new AssertionError("Unexpected mode: "+ mode);
+        }
+    }
+
     /** A KindName representing a given symbol
      */
     public static KindName kindName(Symbol sym) {
@@ -205,10 +220,10 @@ public class Kinds {
     /** A KindName representing the kind of a given class/interface type.
      */
     public static KindName typeKindName(Type t) {
-        if (t.tag == TYPEVAR ||
-            t.tag == CLASS && (t.tsym.flags() & COMPOUND) != 0)
+        if (t.hasTag(TYPEVAR) ||
+            t.hasTag(CLASS) && (t.tsym.flags() & COMPOUND) != 0)
             return KindName.BOUND;
-        else if (t.tag == PACKAGE)
+        else if (t.hasTag(PACKAGE))
             return KindName.PACKAGE;
         else if ((t.tsym.flags_field & ANNOTATION) != 0)
             return KindName.ANNOTATION;
diff --git a/src/share/classes/com/sun/tools/javac/code/Lint.java b/src/share/classes/com/sun/tools/javac/code/Lint.java
index 3f3c477..019ee37 100644
--- a/src/share/classes/com/sun/tools/javac/code/Lint.java
+++ b/src/share/classes/com/sun/tools/javac/code/Lint.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -26,13 +26,13 @@
 package com.sun.tools.javac.code;
 
 import java.util.EnumSet;
-import java.util.HashMap;
 import java.util.Map;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Options;
 import com.sun.tools.javac.util.Pair;
+
 import static com.sun.tools.javac.code.Flags.*;
 
 
@@ -68,19 +68,11 @@ public class Lint
 
     /**
      * Returns the result of combining the values in this object with
-     * the given annotations.
+     * the metadata on the given symbol.
      */
-    public Lint augment(List<Attribute.Compound> attrs) {
-        return augmentor.augment(this, attrs);
-    }
-
-    /**
-     * Returns the result of combining the values in this object with
-     * the given annotations and flags.
-     */
-    public Lint augment(List<Attribute.Compound> attrs, long flags) {
-        Lint l = augmentor.augment(this, attrs);
-        if ((flags & DEPRECATED) != 0) {
+    public Lint augment(Symbol sym) {
+        Lint l = augmentor.augment(this, sym.getDeclarationAttributes());
+        if (sym.isDeprecated()) {
             if (l == this)
                 l = new Lint(this);
             l.values.remove(LintCategory.DEPRECATION);
@@ -95,7 +87,8 @@ public class Lint
     private final EnumSet<LintCategory> values;
     private final EnumSet<LintCategory> suppressedValues;
 
-    private static Map<String, LintCategory> map = new HashMap<String,LintCategory>();
+    private static final Map<String, LintCategory> map =
+            new java.util.concurrent.ConcurrentHashMap<String, LintCategory>(20);
 
 
     protected Lint(Context context) {
@@ -138,6 +131,13 @@ public class Lint
      */
     public enum LintCategory {
         /**
+         * Warn when code refers to a auxiliary class that is hidden in a source file (ie source file name is
+         * different from the class name, and the type is not properly nested) and the referring code
+         * is not located in the same source file.
+         */
+        AUXILIARYCLASS("auxiliaryclass"),
+
+        /**
          * Warn about use of unnecessary casts.
          */
         CAST("cast"),
diff --git a/src/share/classes/com/sun/tools/javac/code/Printer.java b/src/share/classes/com/sun/tools/javac/code/Printer.java
index 59aa924..be0b503 100644
--- a/src/share/classes/com/sun/tools/javac/code/Printer.java
+++ b/src/share/classes/com/sun/tools/javac/code/Printer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, 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
@@ -27,15 +27,20 @@ package com.sun.tools.javac.code;
 
 import java.util.Locale;
 
+import javax.lang.model.type.TypeKind;
+
 import com.sun.tools.javac.api.Messages;
-import com.sun.tools.javac.code.Type.*;
+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;
 import com.sun.tools.javac.util.ListBuffer;
 
-import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
 
 /**
  * A combined type/symbol visitor for generating non-trivial localized string
@@ -51,6 +56,8 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
     List<Type> seenCaptured = List.nil();
     static final int PRIME = 997;  // largest prime less than 1000
 
+    protected Printer() { }
+
     /**
      * This method should be overriden in order to provide proper i18n support.
      *
@@ -121,9 +128,9 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
     }
 
     /**
-     * Get a localized string represenation for a given type.
+     * Get a localized string representation for a given type.
      *
-     * @param ts type to be displayed
+     * @param t type to be displayed
      * @param locale the locale in which the string is to be rendered
      * @return localized string representation
      */
@@ -132,9 +139,9 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
     }
 
     /**
-     * Get a localized string represenation for a given symbol.
+     * Get a localized string representation for a given symbol.
      *
-     * @param ts symbol to be displayed
+     * @param s symbol to be displayed
      * @param locale the locale in which the string is to be rendered
      * @return localized string representation
      */
@@ -176,15 +183,41 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
 
     @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
     public String visitClassType(ClassType t, Locale locale) {
-        StringBuffer buf = new StringBuffer();
-        if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
+        StringBuilder buf = new StringBuilder();
+        if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == Kinds.TYP) {
             buf.append(visit(t.getEnclosingType(), locale));
-            buf.append(".");
+            buf.append('.');
             buf.append(className(t, false, locale));
         } else {
             buf.append(className(t, true, locale));
@@ -192,7 +225,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
         if (t.getTypeArguments().nonEmpty()) {
             buf.append('<');
             buf.append(visitTypes(t.getTypeArguments(), locale));
-            buf.append(">");
+            buf.append('>');
         }
         return buf.toString();
     }
@@ -209,7 +242,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
 
     @Override
     public String visitWildcardType(WildcardType t, Locale locale) {
-        StringBuffer s = new StringBuffer();
+        StringBuilder s = new StringBuilder();
         s.append(t.kind);
         if (t.kind != UNBOUND) {
             s.append(visit(t.type, locale));
@@ -227,6 +260,29 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
         return visitType(t, locale);
     }
 
+    @Override
+    public String visitAnnotatedType(AnnotatedType t, Locale locale) {
+        if (t.typeAnnotations != null &&
+                t.typeAnnotations.nonEmpty()) {
+            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);
+        }
+    }
+
     public String visitType(Type t, Locale locale) {
         String s = (t.tsym == null || t.tsym.name == null)
                 ? localize(locale, "compiler.misc.type.none")
@@ -236,7 +292,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
 
     /**
      * 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
@@ -247,9 +303,9 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
     protected String className(ClassType t, boolean longform, Locale locale) {
         Symbol sym = t.tsym;
         if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) {
-            StringBuffer s = new StringBuffer(visit(t.supertype_field, locale));
+            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();
@@ -258,7 +314,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
             ClassType norm = (ClassType) t.tsym.type;
             if (norm == null) {
                 s = localize(locale, "compiler.misc.anonymous.class", (Object) null);
-            } else if (norm.interfaces_field.nonEmpty()) {
+            } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
                 s = localize(locale, "compiler.misc.anonymous.class",
                         visit(norm.interfaces_field.head, locale));
             } else {
@@ -286,14 +342,19 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
         if (!varArgs) {
             return visitTypes(args, locale);
         } else {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             while (args.tail.nonEmpty()) {
                 buf.append(visit(args.head, locale));
                 args = args.tail;
                 buf.append(',');
             }
-            if (args.head.tag == ARRAY) {
-                buf.append(visit(((ArrayType) args.head).elemtype, locale));
+            if (args.head.unannotatedType().getKind() == TypeKind.ARRAY) {
+                buf.append(visit(((ArrayType) args.head.unannotatedType()).elemtype, locale));
+                if (args.head.getAnnotationMirrors().nonEmpty()) {
+                    buf.append(' ');
+                    buf.append(args.head.getAnnotationMirrors());
+                    buf.append(' ');
+                }
                 buf.append("...");
             } else {
                 buf.append(visit(args.head, locale));
@@ -318,7 +379,7 @@ public abstract class Printer implements Type.Visitor<String, Locale>, Symbol.Vi
                     ? s.owner.name.toString()
                     : s.name.toString();
             if (s.type != null) {
-                if (s.type.tag == FORALL) {
+                if (s.type.hasTag(FORALL)) {
                     ms = "<" + visitTypes(s.type.getTypeArguments(), locale) + ">" + ms;
                 }
                 ms += "(" + printMethodArgs(
diff --git a/src/share/classes/com/sun/tools/javac/code/Scope.java b/src/share/classes/com/sun/tools/javac/code/Scope.java
index a5100f6..86b5352 100644
--- a/src/share/classes/com/sun/tools/javac/code/Scope.java
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,9 +25,10 @@
 
 package com.sun.tools.javac.code;
 
-import com.sun.tools.javac.util.*;
 import java.util.Iterator;
 
+import com.sun.tools.javac.util.*;
+
 /** A scope represents an area of visibility in a Java program. The
  *  Scope class is a container for symbols which provides
  *  efficient access to symbols given their names. Scopes are implemented
@@ -315,6 +316,7 @@ public class Scope {
     public Entry lookup(Name name) {
         return lookup(name, noFilter);
     }
+
     public Entry lookup(Name name, Filter<Symbol> sf) {
         Entry e = table[getIndex(name)];
         if (e == null || e == sentinel)
@@ -360,6 +362,10 @@ public class Scope {
         }
     }
 
+    public boolean anyMatch(Filter<Symbol> sf) {
+        return getElements(sf).iterator().hasNext();
+    }
+
     public Iterable<Symbol> getElements() {
         return getElements(noFilter);
     }
diff --git a/src/share/classes/com/sun/tools/javac/code/Source.java b/src/share/classes/com/sun/tools/javac/code/Source.java
index bee0ed8..fffa266 100644
--- a/src/share/classes/com/sun/tools/javac/code/Source.java
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, 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
@@ -26,13 +26,13 @@
 package com.sun.tools.javac.code;
 
 import java.util.*;
+
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
-import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.jvm.Target;
-
-import static com.sun.tools.javac.main.OptionName.*;
+import com.sun.tools.javac.util.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** The source language version accepted.
  *
@@ -64,8 +64,11 @@ public enum Source {
     /** 1.6 reports encoding problems as errors instead of warnings. */
     JDK1_6("1.6"),
 
-    /** 1.7 covers the to be determined language features that will be added in JDK 7. */
-    JDK1_7("1.7");
+    /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
+    JDK1_7("1.7"),
+
+    /** 1.8 covers the to be determined language features that will be added in JDK 8. */
+    JDK1_8("1.8");
 
     private static final Context.Key<Source> sourceKey
         = new Context.Key<Source>();
@@ -84,7 +87,7 @@ public enum Source {
 
     public final String name;
 
-    private static Map<String,Source> tab = new HashMap<String,Source>();
+    private static final Map<String,Source> tab = new HashMap<String,Source>();
     static {
         for (Source s : values()) {
             tab.put(s.name, s);
@@ -92,19 +95,21 @@ public enum Source {
         tab.put("5", JDK1_5); // Make 5 an alias for 1.5
         tab.put("6", JDK1_6); // Make 6 an alias for 1.6
         tab.put("7", JDK1_7); // Make 7 an alias for 1.7
+        tab.put("8", JDK1_8); // Make 8 an alias for 1.8
     }
 
     private Source(String name) {
         this.name = name;
     }
 
-    public static final Source DEFAULT = JDK1_7;
+    public static final Source DEFAULT = JDK1_8;
 
     public static Source lookup(String name) {
         return tab.get(name);
     }
 
     public Target requiredTarget() {
+        if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
         if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
         if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6;
         if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5;
@@ -171,9 +176,6 @@ public enum Source {
     public boolean allowTryWithResources() {
         return compareTo(JDK1_7) >= 0;
     }
-    public boolean allowTypeAnnotations() {
-        return compareTo(JDK1_7) >= 0;
-    }
     public boolean allowBinaryLiterals() {
         return compareTo(JDK1_7) >= 0;
     }
@@ -189,6 +191,42 @@ public enum Source {
     public boolean allowObjectToPrimitiveCast() {
         return compareTo(JDK1_7) >= 0;
     }
+    public boolean allowPoly() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowLambda() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowMethodReferences() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowDefaultMethods() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowStaticInterfaceMethods() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowStrictMethodClashCheck() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowEffectivelyFinalInInnerClasses() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowTypeAnnotations() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowRepeatedAnnotations() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowIntersectionTypesInCast() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowGraphInference() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowStructuralMostSpecific() {
+        return compareTo(JDK1_8) >= 0;
+    }
     public static SourceVersion toSourceVersion(Source source) {
         switch(source) {
         case JDK1_2:
@@ -203,6 +241,8 @@ public enum Source {
             return RELEASE_6;
         case JDK1_7:
             return RELEASE_7;
+        case JDK1_8:
+            return RELEASE_8;
         default:
             return null;
         }
diff --git a/src/share/classes/com/sun/tools/javac/code/Symbol.java b/src/share/classes/com/sun/tools/javac/code/Symbol.java
index cd5550d..93fdfcb 100644
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -27,23 +27,28 @@ package com.sun.tools.javac.code;
 
 import java.util.Set;
 import java.util.concurrent.Callable;
+
 import javax.lang.model.element.*;
+import javax.lang.model.util.ElementScanner6;
 import javax.tools.JavaFileObject;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.comp.Annotate;
 import com.sun.tools.javac.comp.Attr;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.model.*;
 import com.sun.tools.javac.tree.JCTree;
-import javax.lang.model.util.ElementScanner6;
-
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Name;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.ERROR;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
+import static com.sun.tools.javac.code.TypeTag.UNKNOWN;
 
 /** Root class for Java symbols. It contains subclasses
  *  for specific sorts of symbols, such as variables, methods and operators,
@@ -73,25 +78,6 @@ public abstract class Symbol implements Element {
      */
     public long flags() { return flags_field; }
 
-    /** The attributes of this symbol.
-     */
-    public List<Attribute.Compound> attributes_field;
-
-    /** An accessor method for the attributes of this symbol.
-     *  Attributes of class symbols should be accessed through the accessor
-     *  method to make sure that the class symbol is loaded.
-     */
-    public List<Attribute.Compound> getAnnotationMirrors() {
-        return Assert.checkNonNull(attributes_field);
-    }
-
-    /** Fetch a particular annotation from a symbol. */
-    public Attribute.Compound attribute(Symbol anno) {
-        for (Attribute.Compound a : getAnnotationMirrors())
-            if (a.type.tsym == anno) return a;
-        return null;
-    }
-
     /** The name of this symbol in Utf8 representation.
      */
     public Name name;
@@ -112,6 +98,146 @@ public abstract class Symbol implements Element {
      */
     public Type erasure_field;
 
+    // <editor-fold defaultstate="collapsed" desc="annotations">
+
+    /** The attributes of this symbol are contained in this
+     * Annotations. The Annotations instance is NOT immutable.
+     */
+    protected Annotations annotations;
+
+    /** An accessor method for the attributes of this symbol.
+     *  Attributes of class symbols should be accessed through the accessor
+     *  method to make sure that the class symbol is loaded.
+     */
+    public List<Attribute.Compound> getRawAttributes() {
+        return (annotations == null)
+                ? List.<Attribute.Compound>nil()
+                : annotations.getDeclarationAttributes();
+    }
+
+    /** An accessor method for the type attributes of this symbol.
+     *  Attributes of class symbols should be accessed through the accessor
+     *  method to make sure that the class symbol is loaded.
+     */
+    public List<Attribute.TypeCompound> getRawTypeAttributes() {
+        return (annotations == null)
+                ? List.<Attribute.TypeCompound>nil()
+                : annotations.getTypeAttributes();
+    }
+
+    /** Fetch a particular annotation from a symbol. */
+    public Attribute.Compound attribute(Symbol anno) {
+        for (Attribute.Compound a : getRawAttributes()) {
+            if (a.type.tsym == anno) return a;
+        }
+        return null;
+    }
+
+    public boolean annotationsPendingCompletion() {
+        return annotations == null ? false : annotations.pendingCompletion();
+    }
+
+    public void appendAttributes(List<Attribute.Compound> l) {
+        if (l.nonEmpty()) {
+            initedAnnos().append(l);
+        }
+    }
+
+    public void appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        if (l.nonEmpty()) {
+            initedAnnos().appendClassInitTypeAttributes(l);
+        }
+    }
+
+    public void appendInitTypeAttributes(List<Attribute.TypeCompound> l) {
+        if (l.nonEmpty()) {
+            initedAnnos().appendInitTypeAttributes(l);
+        }
+    }
+
+    public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) {
+        initedAnnos().appendTypeAttributesWithCompletion(ctx);
+    }
+
+    public void appendUniqueTypeAttributes(List<Attribute.TypeCompound> l) {
+        if (l.nonEmpty()) {
+            initedAnnos().appendUniqueTypes(l);
+        }
+    }
+
+    public List<Attribute.TypeCompound> getClassInitTypeAttributes() {
+        return (annotations == null)
+                ? List.<Attribute.TypeCompound>nil()
+                : annotations.getClassInitTypeAttributes();
+    }
+
+    public List<Attribute.TypeCompound> getInitTypeAttributes() {
+        return (annotations == null)
+                ? List.<Attribute.TypeCompound>nil()
+                : annotations.getInitTypeAttributes();
+    }
+
+    public List<Attribute.Compound> getDeclarationAttributes() {
+        return (annotations == null)
+                ? List.<Attribute.Compound>nil()
+                : annotations.getDeclarationAttributes();
+    }
+
+    public boolean hasAnnotations() {
+        return (annotations != null && !annotations.isEmpty());
+    }
+
+    public boolean hasTypeAnnotations() {
+        return (annotations != null && !annotations.isTypesEmpty());
+    }
+
+    public void prependAttributes(List<Attribute.Compound> l) {
+        if (l.nonEmpty()) {
+            initedAnnos().prepend(l);
+        }
+    }
+
+    public void resetAnnotations() {
+        initedAnnos().reset();
+    }
+
+    public void setAttributes(Symbol other) {
+        if (annotations != null || other.annotations != null) {
+            initedAnnos().setAttributes(other.annotations);
+        }
+    }
+
+    public void setDeclarationAttributes(List<Attribute.Compound> a) {
+        if (annotations != null || a.nonEmpty()) {
+            initedAnnos().setDeclarationAttributes(a);
+        }
+    }
+
+    public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) {
+        initedAnnos().setDeclarationAttributesWithCompletion(ctx);
+    }
+
+    public void setTypeAttributes(List<Attribute.TypeCompound> a) {
+        if (annotations != null || a.nonEmpty()) {
+            if (annotations == null)
+                annotations = new Annotations(this);
+            annotations.setTypeAttributes(a);
+        }
+    }
+
+    private Annotations initedAnnos() {
+        if (annotations == null)
+            annotations = new Annotations(this);
+        return annotations;
+    }
+
+    /** This method is intended for debugging only. */
+    public Annotations getAnnotations() {
+        return annotations;
+    }
+
+    // </editor-fold>
+
     /** Construct a symbol with given kind, flags, name, type and owner.
      */
     public Symbol(int kind, long flags, Name name, Type type, Symbol owner) {
@@ -121,7 +247,6 @@ public abstract class Symbol implements Element {
         this.owner = owner;
         this.completer = null;
         this.erasure_field = null;
-        this.attributes_field = List.nil();
         this.name = name;
     }
 
@@ -161,13 +286,17 @@ public abstract class Symbol implements Element {
         if (owner.name == null || owner.name.isEmpty()) {
             return location();
         }
-        if (owner.type.tag == CLASS) {
+        if (owner.type.hasTag(CLASS)) {
             Type ownertype = types.asOuterSuper(site, owner);
             if (ownertype != null) return ownertype.tsym;
         }
         return owner;
     }
 
+    public Symbol baseSymbol() {
+        return this;
+    }
+
     /** The symbol's erased type.
      */
     public Type erasure(Types types) {
@@ -193,6 +322,10 @@ public abstract class Symbol implements Element {
         }
     }
 
+    public boolean isDeprecated() {
+        return (flags_field & DEPRECATED) != 0;
+    }
+
     public boolean isStatic() {
         return
             (flags() & STATIC) != 0 ||
@@ -203,14 +336,12 @@ public abstract class Symbol implements Element {
         return (flags() & INTERFACE) != 0;
     }
 
-    /** Recognize if this symbol was marked @PolymorphicSignature in the source. */
-    public boolean isPolymorphicSignatureGeneric() {
-        return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == POLYMORPHIC_SIGNATURE;
+    public boolean isPrivate() {
+        return (flags_field & Flags.AccessFlags) == PRIVATE;
     }
 
-    /** Recognize if this symbol was split from a @PolymorphicSignature symbol in the source. */
-    public boolean isPolymorphicSignatureInstance() {
-        return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == (POLYMORPHIC_SIGNATURE | HYPOTHETICAL);
+    public boolean isEnum() {
+        return (flags() & ENUM) != 0;
     }
 
     /** Is this symbol declared (directly or indirectly) local
@@ -225,7 +356,7 @@ public abstract class Symbol implements Element {
     }
 
     /** Has this symbol an empty name? This includes anonymous
-     *  inner classses.
+     *  inner classes.
      */
     public boolean isAnonymous() {
         return name.isEmpty();
@@ -262,7 +393,7 @@ public abstract class Symbol implements Element {
     /** A class is an inner class if it it has an enclosing instance class.
      */
     public boolean isInner() {
-        return type.getEnclosingType() != null && type.getEnclosingType().tag == CLASS;
+        return type.getEnclosingType() != null && type.getEnclosingType().hasTag(CLASS);
     }
 
     /** An inner class has an outer instance if it is not an interface
@@ -275,7 +406,7 @@ public abstract class Symbol implements Element {
      */
     public boolean hasOuterInstance() {
         return type.getEnclosingType() != null &&
-            type.getEnclosingType().tag == CLASS && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
+            type.getEnclosingType().hasTag(CLASS) && (flags() & (INTERFACE | NOOUTERTHIS)) == 0;
     }
 
     /** The closest enclosing class of this symbol's declaration.
@@ -283,7 +414,7 @@ public abstract class Symbol implements Element {
     public ClassSymbol enclClass() {
         Symbol c = this;
         while (c != null &&
-               ((c.kind & TYP) == 0 || (c.type.tag != CLASS && c.type.tag != ERROR))) {
+               ((c.kind & TYP) == 0 || !(c.type.hasTag(CLASS) || c.type.hasTag(ERROR)))) {
             c = c.owner;
         }
         return (ClassSymbol)c;
@@ -352,7 +483,7 @@ public abstract class Symbol implements Element {
                 e = e.next();
             }
             Type superType = types.supertype(clazz.type);
-            if (superType.tag != TypeTags.CLASS) return false;
+            if (!superType.hasTag(CLASS)) return false;
             clazz = (ClassSymbol)superType.tsym;
         }
     }
@@ -379,7 +510,7 @@ public abstract class Symbol implements Element {
             for (Symbol sup = clazz;
                  sup != null && sup != this.owner;
                  sup = types.supertype(sup.type).tsym) {
-                while (sup.type.tag == TYPEVAR)
+                while (sup.type.hasTag(TYPEVAR))
                     sup = sup.type.getUpperBound().tsym;
                 if (sup.type.isErroneous())
                     return true; // error recovery
@@ -450,11 +581,25 @@ public abstract class Symbol implements Element {
     }
 
     /**
+     * This is the implementation for {@code
+     * javax.lang.model.element.Element.getAnnotationMirrors()}.
+     */
+    @Override
+    public List<Attribute.Compound> getAnnotationMirrors() {
+        return getRawAttributes();
+    }
+
+    /**
      * @deprecated this method should never be used by javac internally.
      */
     @Deprecated
     public <A extends java.lang.annotation.Annotation> A getAnnotation(Class<A> annoType) {
-        return JavacElements.getAnnotation(this, annoType);
+        return JavacAnnoConstructs.getAnnotation(this, annoType);
+    }
+
+    // This method is part of the javax.lang.model API, do not use this in javac code.
+    public <A extends java.lang.annotation.Annotation> A[] getAnnotationsByType(Class<A> annoType) {
+        return JavacAnnoConstructs.getAnnotations(this, annoType);
     }
 
     // TODO: getEnclosedElements should return a javac List, fix in FilteredMemberList
@@ -462,23 +607,25 @@ public abstract class Symbol implements Element {
         return List.nil();
     }
 
-    public List<TypeSymbol> getTypeParameters() {
-        ListBuffer<TypeSymbol> l = ListBuffer.lb();
+    public List<TypeVariableSymbol> getTypeParameters() {
+        ListBuffer<TypeVariableSymbol> l = ListBuffer.lb();
         for (Type t : type.getTypeArguments()) {
-            l.append(t.tsym);
+            Assert.check(t.tsym.getKind() == ElementKind.TYPE_PARAMETER);
+            l.append((TypeVariableSymbol)t.tsym);
         }
         return l.toList();
     }
 
-    public static class DelegatedSymbol extends Symbol {
-        protected Symbol other;
-        public DelegatedSymbol(Symbol other) {
+    public static class DelegatedSymbol<T extends Symbol> extends Symbol {
+        protected T other;
+        public DelegatedSymbol(T other) {
             super(other.kind, other.flags_field, other.name, other.type, other.owner);
             this.other = other;
         }
         public String toString() { return other.toString(); }
         public Symbol location() { return other.location(); }
         public Symbol location(Type site, Types types) { return other.location(site, types); }
+        public Symbol baseSymbol() { return other; }
         public Type erasure(Types types) { return other.erasure(types); }
         public Type externalType(Types types) { return other.externalType(types); }
         public boolean isLocal() { return other.isLocal(); }
@@ -505,28 +652,25 @@ public abstract class Symbol implements Element {
         public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
             return v.visitSymbol(other, p);
         }
+
+        public T getUnderlyingSymbol() {
+            return other;
+        }
     }
 
-    /** A class for type symbols. Type variables are represented by instances
-     *  of this class, classes and packages by instances of subclasses.
+    /** A base class for Symbols representing types.
      */
-    public static class TypeSymbol
-            extends Symbol implements TypeParameterElement {
-        // Implements TypeParameterElement because type parameters don't
-        // have their own TypeSymbol subclass.
-        // TODO: type parameters should have their own TypeSymbol subclass
-
-        public TypeSymbol(long flags, Name name, Type type, Symbol owner) {
-            super(TYP, flags, name, type, owner);
+    public static abstract class TypeSymbol extends Symbol {
+        public TypeSymbol(int kind, long flags, Name name, Type type, Symbol owner) {
+            super(kind, flags, name, type, owner);
         }
-
         /** form a fully qualified name from a name and an owner
          */
         static public Name formFullName(Name name, Symbol owner) {
             if (owner == null) return name;
             if (((owner.kind != ERR)) &&
                 ((owner.kind & (VAR | MTH)) != 0
-                 || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+                 || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
                  )) return name;
             Name prefix = owner.getQualifiedName();
             if (prefix == null || prefix == prefix.table.names.empty)
@@ -541,7 +685,7 @@ public abstract class Symbol implements Element {
             if (owner == null) return name;
             if (((owner.kind != ERR)) &&
                 ((owner.kind & (VAR | MTH)) != 0
-                 || (owner.kind == TYP && owner.type.tag == TYPEVAR)
+                 || (owner.kind == TYP && owner.type.hasTag(TYPEVAR))
                  )) return name;
             char sep = (owner.kind & TYP) != 0 ? '$' : '.';
             Name prefix = owner.flatName();
@@ -559,27 +703,23 @@ public abstract class Symbol implements Element {
         public final boolean precedes(TypeSymbol that, Types types) {
             if (this == that)
                 return false;
-            if (this.type.tag == that.type.tag) {
-                if (this.type.tag == CLASS) {
+            if (type.hasTag(that.type.getTag())) {
+                if (type.hasTag(CLASS)) {
                     return
                         types.rank(that.type) < types.rank(this.type) ||
                         types.rank(that.type) == types.rank(this.type) &&
                         that.getQualifiedName().compareTo(this.getQualifiedName()) < 0;
-                } else if (this.type.tag == TYPEVAR) {
+                } else if (type.hasTag(TYPEVAR)) {
                     return types.isSubtype(this.type, that.type);
                 }
             }
-            return this.type.tag == TYPEVAR;
-        }
-
-        // For type params; overridden in subclasses.
-        public ElementKind getKind() {
-            return ElementKind.TYPE_PARAMETER;
+            return type.hasTag(TYPEVAR);
         }
 
+        @Override
         public java.util.List<Symbol> getEnclosedElements() {
             List<Symbol> list = List.nil();
-            if (kind == NIL || (kind == TYP && type.tag == TYPEVAR || type.tag == UNKNOWN)) {
+            if (kind == NIL || (kind == TYP && type.hasTag(TYPEVAR) || type.hasTag(UNKNOWN))) {
                 return list;
             }
             for (Scope.Entry e = members().elems; e != null; e = e.sibling) {
@@ -591,21 +731,29 @@ public abstract class Symbol implements Element {
             return list;
         }
 
-        // For type params.
-        // Perhaps not needed if getEnclosingElement can be spec'ed
-        // to do the same thing.
-        // TODO: getGenericElement() might not be needed
-        public Symbol getGenericElement() {
-            return owner;
+        @Override
+        public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
+            return v.visitTypeSymbol(this, p);
         }
+    }
 
-        public <R, P> R accept(ElementVisitor<R, P> v, P p) {
-            Assert.check(type.tag == TYPEVAR); // else override will be invoked
-            return v.visitTypeParameter(this, p);
+    /**
+     * Type variables are represented by instances of this class.
+     */
+    public static class TypeVariableSymbol
+            extends TypeSymbol implements TypeParameterElement {
+
+        public TypeVariableSymbol(long flags, Name name, Type type, Symbol owner) {
+            super(TYP, flags, name, type, owner);
         }
 
-        public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
-            return v.visitTypeSymbol(this, p);
+        public ElementKind getKind() {
+            return ElementKind.TYPE_PARAMETER;
+        }
+
+        @Override
+        public Symbol getGenericElement() {
+            return owner;
         }
 
         public List<Type> getBounds() {
@@ -624,6 +772,29 @@ public abstract class Symbol implements Element {
                 return ct.interfaces_field;
             }
         }
+
+        @Override
+        public List<Attribute.Compound> getAnnotationMirrors() {
+            return onlyTypeVariableAnnotations(owner.getRawTypeAttributes());
+        }
+
+        private List<Attribute.Compound> onlyTypeVariableAnnotations(
+                List<Attribute.TypeCompound> candidates) {
+            // Declaration annotations on TypeParameters are stored in type attributes
+            List<Attribute.Compound> res = List.nil();
+            for (Attribute.TypeCompound a : candidates) {
+                if (a.position.type == TargetType.CLASS_TYPE_PARAMETER ||
+                    a.position.type == TargetType.METHOD_TYPE_PARAMETER)
+                    res = res.prepend(a);
+            }
+
+            return res = res.reverse();
+        }
+
+        @Override
+        public <R, P> R accept(ElementVisitor<R, P> v, P p) {
+            return v.visitTypeParameter(this, p);
+        }
     }
 
     /** A class for package symbols
@@ -636,8 +807,7 @@ public abstract class Symbol implements Element {
         public ClassSymbol package_info; // see bug 6443073
 
         public PackageSymbol(Name name, Type type, Symbol owner) {
-            super(0, name, type, owner);
-            this.kind = PCK;
+            super(PCK, 0, name, type, owner);
             this.members_field = null;
             this.fullname = formFullName(name, owner);
         }
@@ -669,14 +839,22 @@ public abstract class Symbol implements Element {
             return flags_field;
         }
 
-        public List<Attribute.Compound> getAnnotationMirrors() {
+        @Override
+        public List<Attribute.Compound> getRawAttributes() {
             if (completer != null) complete();
             if (package_info != null && package_info.completer != null) {
                 package_info.complete();
-                if (attributes_field.isEmpty())
-                    attributes_field = package_info.attributes_field;
+                mergeAttributes();
+            }
+            return super.getRawAttributes();
+        }
+
+        private void mergeAttributes() {
+            if (annotations == null &&
+                package_info.annotations != null) {
+                annotations = new Annotations(this);
+                annotations.setAttributes(package_info.annotations);
             }
-            return Assert.checkNonNull(attributes_field);
         }
 
         /** A package "exists" if a type or package that exists has
@@ -742,7 +920,7 @@ public abstract class Symbol implements Element {
         public Pool pool;
 
         public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
-            super(flags, name, type, owner);
+            super(TYP, flags, name, type, owner);
             this.members_field = null;
             this.fullname = formFullName(name, owner);
             this.flatname = formFlatName(name, owner);
@@ -780,11 +958,18 @@ public abstract class Symbol implements Element {
             return members_field;
         }
 
-        public List<Attribute.Compound> getAnnotationMirrors() {
+        @Override
+        public List<Attribute.Compound> getRawAttributes() {
             try {
                 if (completer != null) complete();
             } catch (CompletionFailure cf) {}
-            return Assert.checkNonNull(attributes_field);
+            return super.getRawAttributes();
+        }
+
+        @Override
+        public List<Attribute.TypeCompound> getRawTypeAttributes() {
+            if (completer != null) complete();
+            return super.getRawTypeAttributes();
         }
 
         public Type erasure(Types types) {
@@ -811,17 +996,19 @@ public abstract class Symbol implements Element {
         }
 
         public boolean isSubClass(Symbol base, Types types) {
-            if (this == base) {
-                return true;
-            } else if ((base.flags() & INTERFACE) != 0) {
-                for (Type t = type; t.tag == CLASS; t = types.supertype(t))
-                    for (List<Type> is = types.interfaces(t);
-                         is.nonEmpty();
-                         is = is.tail)
-                        if (is.head.tsym.isSubClass(base, types)) return true;
-            } else {
-                for (Type t = type; t.tag == CLASS; t = types.supertype(t))
-                    if (t.tsym == base) return true;
+            if (base != null) {
+                if (this == base) {
+                    return true;
+                } else if ((base.flags() & INTERFACE) != 0) {
+                    for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
+                        for (List<Type> is = types.interfaces(t);
+                             is.nonEmpty();
+                             is = is.tail)
+                            if (is.head.tsym.isSubClass(base, types)) return true;
+                } else {
+                    for (Type t = type; t.hasTag(CLASS); t = types.supertype(t))
+                        if (t.tsym == base) return true;
+                }
             }
             return false;
         }
@@ -899,11 +1086,12 @@ public abstract class Symbol implements Element {
         }
 
         /**
-         * @deprecated this method should never be used by javac internally.
+         * Since this method works in terms of the runtime representation
+         * of annotations, it should never be used by javac internally.
          */
-        @Override @Deprecated
+        @Override
         public <A extends java.lang.annotation.Annotation> A getAnnotation(Class<A> annoType) {
-            return JavacElements.getAnnotation(this, annoType);
+            return JavacAnnoConstructs.getAnnotation(this, annoType);
         }
 
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
@@ -935,23 +1123,21 @@ public abstract class Symbol implements Element {
          */
         public int adr = -1;
 
-        public final VarSymbol originalVar;
-
         /** Construct a variable symbol, given its flags, name, type and owner.
          */
         public VarSymbol(long flags, Name name, Type type, Symbol owner) {
-            this(flags, name, type, owner, null);
-        }
-
-        private VarSymbol(long flags, Name name, Type type, Symbol owner, VarSymbol originalVar) {
             super(VAR, flags, name, type, owner);
-            this.originalVar = originalVar;
         }
 
         /** Clone this symbol with new owner.
          */
         public VarSymbol clone(Symbol newOwner) {
-            VarSymbol v = new VarSymbol(flags_field, name, type, newOwner, originalVar != null ? originalVar : this);
+            VarSymbol v = new VarSymbol(flags_field, name, type, newOwner) {
+                @Override
+                public Symbol baseSymbol() {
+                    return VarSymbol.this;
+                }
+            };
             v.pos = pos;
             v.adr = adr;
             v.data = data;
@@ -1115,6 +1301,9 @@ public abstract class Symbol implements Element {
         /** The code of the method. */
         public Code code = null;
 
+        /** The extra (synthetic/mandated) parameters of the method. */
+        public List<VarSymbol> extraParams = List.nil();
+
         /** The parameters of the method. */
         public List<VarSymbol> params = null;
 
@@ -1127,28 +1316,32 @@ public abstract class Symbol implements Element {
          */
         public Attribute defaultValue = null;
 
-        public final MethodSymbol originalMethod;
-
         /** Construct a method symbol, given its flags, name, type and owner.
          */
         public MethodSymbol(long flags, Name name, Type type, Symbol owner) {
-            this(flags, name, type, owner, null);
-        }
-
-        private MethodSymbol(long flags, Name name, Type type, Symbol owner, MethodSymbol originalMethod) {
             super(MTH, flags, name, type, owner);
-            if (owner.type.tag == TYPEVAR) Assert.error(owner + "." + name);
-            this.originalMethod = originalMethod;
+            if (owner.type.hasTag(TYPEVAR)) Assert.error(owner + "." + name);
         }
 
         /** Clone this symbol with new owner.
          */
         public MethodSymbol clone(Symbol newOwner) {
-            MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner, originalMethod != null ? originalMethod : this);
+            MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner) {
+                @Override
+                public Symbol baseSymbol() {
+                    return MethodSymbol.this;
+                }
+            };
             m.code = code;
             return m;
         }
 
+        @Override
+        public Set<Modifier> getModifiers() {
+            long flags = flags();
+            return Flags.asModifierSet((flags & DEFAULT) != 0 ? flags & ~ABSTRACT : flags);
+        }
+
         /** The Java source which this symbol represents.
          */
         public String toString() {
@@ -1159,7 +1352,7 @@ public abstract class Symbol implements Element {
                     ? owner.name.toString()
                     : name.toString();
                 if (type != null) {
-                    if (type.tag == FORALL)
+                    if (type.hasTag(FORALL))
                         s = "<" + ((ForAll)type).getTypeArguments() + ">" + s;
                     s += "(" + type.argtypes((flags() & VARARGS) != 0) + ")";
                 }
@@ -1167,6 +1360,10 @@ public abstract class Symbol implements Element {
             }
         }
 
+        public boolean isDynamic() {
+            return false;
+        }
+
         /** find a symbol that this (proxy method) symbol implements.
          *  @param    c       The class whose members are searched for
          *                    implementations
@@ -1229,7 +1426,7 @@ public abstract class Symbol implements Element {
          *  @param origin   The class of which the implementation is a member.
          */
         public MethodSymbol binaryImplementation(ClassSymbol origin, Types types) {
-            for (TypeSymbol c = origin; c != null && c.type.tag != TypeTags.ERROR; c = types.supertype(c.type).tsym) {
+            for (TypeSymbol c = origin; c != null && !c.type.hasTag(ERROR); c = types.supertype(c.type).tsym) {
                 for (Scope.Entry e = c.members().lookup(name);
                      e.scope != null;
                      e = e.next()) {
@@ -1271,9 +1468,9 @@ public abstract class Symbol implements Element {
 
             // check for an inherited implementation
             if ((flags() & ABSTRACT) != 0 ||
-                (other.flags() & ABSTRACT) == 0 ||
-                !other.isOverridableIn(origin) ||
-                !this.isMemberOf(origin, types))
+                    ((other.flags() & ABSTRACT) == 0 && (other.flags() & DEFAULT) == 0) ||
+                    !other.isOverridableIn(origin) ||
+                    !this.isMemberOf(origin, types))
                 return false;
 
             // assert types.asSuper(origin.type, other.owner) != null;
@@ -1281,7 +1478,7 @@ public abstract class Symbol implements Element {
             Type ot = types.memberType(origin.type, other);
             return
                 types.isSubSignature(mt, ot) &&
-                (!checkResult || types.resultSubtype(mt, ot, Warner.noWarnings));
+                (!checkResult || types.resultSubtype(mt, ot, types.noWarnings));
         }
 
         private boolean isOverridableIn(TypeSymbol origin) {
@@ -1290,7 +1487,8 @@ public abstract class Symbol implements Element {
             case Flags.PRIVATE:
                 return false;
             case Flags.PUBLIC:
-                return true;
+                return !this.owner.isInterface() ||
+                        (flags_field & STATIC) == 0;
             case Flags.PROTECTED:
                 return (origin.flags() & INTERFACE) == 0;
             case 0:
@@ -1304,6 +1502,18 @@ public abstract class Symbol implements Element {
             }
         }
 
+        @Override
+        public boolean isInheritedIn(Symbol clazz, Types types) {
+            switch ((int)(flags_field & Flags.AccessFlags)) {
+                case PUBLIC:
+                    return !this.owner.isInterface() ||
+                            clazz == owner ||
+                            (flags_field & STATIC) == 0;
+                default:
+                    return super.isInheritedIn(clazz, types);
+            }
+        }
+
         /** The implementation of this (abstract) symbol in class origin;
          *  null if none exists. Synthetic methods are not considered
          *  as possible implementations.
@@ -1312,7 +1522,7 @@ public abstract class Symbol implements Element {
             return implementation(origin, types, checkResult, implementation_filter);
         }
         // where
-            private static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
+            public static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
                 public boolean accepts(Symbol s) {
                     return s.kind == Kinds.MTH &&
                             (s.flags() & SYNTHETIC) == 0;
@@ -1335,6 +1545,7 @@ public abstract class Symbol implements Element {
         public List<VarSymbol> params() {
             owner.complete();
             if (params == null) {
+                Assert.checkNonNull(type, "Invalid element: " + this.name);
                 // If ClassReader.saveParameterNames has been set true, then
                 // savedParameterNames will be set to a list of names that
                 // matches the types in type.getParameterTypes().  If any names
@@ -1345,8 +1556,9 @@ public abstract class Symbol implements Element {
                 List<Name> paramNames = savedParameterNames;
                 savedParameterNames = null;
                 // discard the provided names if the list of names is the wrong size.
-                if (paramNames == null || paramNames.size() != type.getParameterTypes().size())
+                if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
                     paramNames = List.nil();
+                }
                 ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
                 List<Name> remaining = paramNames;
                 // assert: remaining and paramNames are both empty or both
@@ -1420,6 +1632,10 @@ public abstract class Symbol implements Element {
             return (flags() & VARARGS) != 0;
         }
 
+        public boolean isDefault() {
+            return (flags() & DEFAULT) != 0;
+        }
+
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
             return v.visitExecutable(this, p);
         }
@@ -1428,6 +1644,10 @@ public abstract class Symbol implements Element {
             return v.visitMethodSymbol(this, p);
         }
 
+        public Type getReceiverType() {
+            return asType().getReceiverType();
+        }
+
         public Type getReturnType() {
             return asType().getReturnType();
         }
@@ -1437,6 +1657,27 @@ public abstract class Symbol implements Element {
         }
     }
 
+    /** A class for invokedynamic method calls.
+     */
+    public static class DynamicMethodSymbol extends MethodSymbol {
+
+        public Object[] staticArgs;
+        public Symbol bsm;
+        public int bsmKind;
+
+        public DynamicMethodSymbol(Name name, Symbol owner, int bsmKind, MethodSymbol bsm, Type type, Object[] staticArgs) {
+            super(0, name, type, owner);
+            this.bsm = bsm;
+            this.bsmKind = bsmKind;
+            this.staticArgs = staticArgs;
+        }
+
+        @Override
+        public boolean isDynamic() {
+            return true;
+        }
+    }
+
     /** A class for predefined operators.
      */
     public static class OperatorSymbol extends MethodSymbol {
diff --git a/src/share/classes/com/sun/tools/javac/code/Symtab.java b/src/share/classes/com/sun/tools/javac/code/Symtab.java
index 0cf6f23..9f8d21f 100644
--- a/src/share/classes/com/sun/tools/javac/code/Symtab.java
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,17 +26,17 @@
 package com.sun.tools.javac.code;
 
 import java.util.*;
-import javax.lang.model.type.TypeVisitor;
+
 import javax.lang.model.element.ElementVisitor;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.*;
-
-import static com.sun.tools.javac.jvm.ByteCodes.*;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.jvm.ByteCodes.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 
 /** A class that defines all predefined constants and operators
  *  as well as special classes such as java.lang.Object, which need
@@ -64,16 +64,16 @@ public class Symtab {
 
     /** Builtin types.
      */
-    public final Type byteType = new Type(TypeTags.BYTE, null);
-    public final Type charType = new Type(TypeTags.CHAR, null);
-    public final Type shortType = new Type(TypeTags.SHORT, null);
-    public final Type intType = new Type(TypeTags.INT, null);
-    public final Type longType = new Type(TypeTags.LONG, null);
-    public final Type floatType = new Type(TypeTags.FLOAT, null);
-    public final Type doubleType = new Type(TypeTags.DOUBLE, null);
-    public final Type booleanType = new Type(TypeTags.BOOLEAN, null);
+    public final JCPrimitiveType byteType = new JCPrimitiveType(BYTE, null);
+    public final JCPrimitiveType charType = new JCPrimitiveType(CHAR, null);
+    public final JCPrimitiveType shortType = new JCPrimitiveType(SHORT, null);
+    public final JCPrimitiveType intType = new JCPrimitiveType(INT, null);
+    public final JCPrimitiveType longType = new JCPrimitiveType(LONG, null);
+    public final JCPrimitiveType floatType = new JCPrimitiveType(FLOAT, null);
+    public final JCPrimitiveType doubleType = new JCPrimitiveType(DOUBLE, null);
+    public final JCPrimitiveType booleanType = new JCPrimitiveType(BOOLEAN, null);
     public final Type botType = new BottomType();
-    public final JCNoType voidType = new JCNoType(TypeTags.VOID);
+    public final JCVoidType voidType = new JCVoidType();
 
     private final Names names;
     private final ClassReader reader;
@@ -125,10 +125,11 @@ public class Symtab {
     public final Type stringBuilderType;
     public final Type cloneableType;
     public final Type serializableType;
-    public final Type transientMethodHandleType; // transient - 292
+    public final Type serializedLambdaType;
     public final Type methodHandleType;
-    public final Type transientPolymorphicSignatureType; // transient - 292
-    public final Type polymorphicSignatureType;
+    public final Type methodHandleLookupType;
+    public final Type methodTypeType;
+    public final Type nativeHeaderType;
     public final Type throwableType;
     public final Type errorType;
     public final Type interruptedExceptionType;
@@ -145,6 +146,7 @@ public class Symtab {
     public final Type listType;
     public final Type collectionsType;
     public final Type comparableType;
+    public final Type comparatorType;
     public final Type arraysType;
     public final Type iterableType;
     public final Type iteratorType;
@@ -154,10 +156,16 @@ public class Symtab {
     public final Type deprecatedType;
     public final Type suppressWarningsType;
     public final Type inheritedType;
+    public final Type profileType;
     public final Type proprietaryType;
     public final Type systemType;
     public final Type autoCloseableType;
     public final Type trustMeType;
+    public final Type lambdaMetafactory;
+    public final Type repeatableType;
+    public final Type documentedType;
+    public final Type elementTypeType;
+    public final Type functionalInterfaceType;
 
     /** The symbol representing the length field of an array.
      */
@@ -174,11 +182,15 @@ public class Symtab {
 
     /** The predefined type that belongs to a tag.
      */
-    public final Type[] typeOfTag = new Type[TypeTags.TypeTagCount];
+    public final Type[] typeOfTag = new Type[TypeTag.getTypeTagCount()];
 
     /** The name of the class that belongs to a basix type tag.
      */
-    public final Name[] boxedName = new Name[TypeTags.TypeTagCount];
+    public final Name[] boxedName = new Name[TypeTag.getTypeTagCount()];
+
+    /** A set containing all operator names.
+     */
+    public final Set<Name> operatorNames = new HashSet<Name>();
 
     /** A hashtable containing the encountered top-level and member classes,
      *  indexed by flat names. The table does not contain local classes.
@@ -195,7 +207,7 @@ public class Symtab {
 
     public void initType(Type type, ClassSymbol c) {
         type.tsym = c;
-        typeOfTag[type.tag] = type;
+        typeOfTag[type.getTag().ordinal()] = type;
     }
 
     public void initType(Type type, String name) {
@@ -207,7 +219,7 @@ public class Symtab {
 
     public void initType(Type type, String name, String bname) {
         initType(type, name);
-            boxedName[type.tag] = names.fromString("java.lang." + bname);
+            boxedName[type.getTag().ordinal()] = names.fromString("java.lang." + bname);
     }
 
     /** The class symbol that owns all predefined symbols.
@@ -241,7 +253,7 @@ public class Symtab {
                             int opcode) {
         predefClass.members().enter(
             new OperatorSymbol(
-                names.fromString(name),
+                makeOperatorName(name),
                 new MethodType(List.of(left, right), res,
                                List.<Type>nil(), methodClass),
                 opcode,
@@ -249,7 +261,8 @@ public class Symtab {
     }
 
     /** Enter a binary operation, as above but with two opcodes,
-     *  which get encoded as (opcode1 << ByteCodeTags.preShift) + opcode2.
+     *  which get encoded as
+     *  {@code (opcode1 << ByteCodeTags.preShift) + opcode2 }.
      *  @param opcode1     First opcode.
      *  @param opcode2     Second opcode.
      */
@@ -271,7 +284,7 @@ public class Symtab {
                                      Type res,
                                      int opcode) {
         OperatorSymbol sym =
-            new OperatorSymbol(names.fromString(name),
+            new OperatorSymbol(makeOperatorName(name),
                                new MethodType(List.of(arg),
                                               res,
                                               List.<Type>nil(),
@@ -282,8 +295,18 @@ public class Symtab {
         return sym;
     }
 
+    /**
+     * Create a new operator name from corresponding String representation
+     * and add the name to the set of known operator names.
+     */
+    private Name makeOperatorName(String name) {
+        Name opName = names.fromString(name);
+        operatorNames.add(opName);
+        return opName;
+    }
+
     /** Enter a class into symbol table.
-     *  @param    The name of the class.
+     *  @param s The name of the class.
      */
     private Type enterClass(String s) {
         return reader.enterClass(names.fromString(s)).type;
@@ -306,7 +329,7 @@ public class Symtab {
     }
 
     public void synthesizeBoxTypeIfMissing(final Type type) {
-        ClassSymbol sym = reader.enterClass(boxedName[type.tag]);
+        ClassSymbol sym = reader.enterClass(boxedName[type.getTag().ordinal()]);
         final Completer completer = sym.completer;
         if (completer != null) {
             sym.completer = new Completer() {
@@ -338,6 +361,22 @@ public class Symtab {
 
     }
 
+    // Enter a synthetic class that is used to mark classes in ct.sym.
+    // This class does not have a class file.
+    private Type enterSyntheticAnnotation(String name) {
+        ClassType type = (ClassType)enterClass(name);
+        ClassSymbol sym = (ClassSymbol)type.tsym;
+        sym.completer = null;
+        sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
+        sym.erasure_field = type;
+        sym.members_field = new Scope(sym);
+        type.typarams_field = List.nil();
+        type.allparams_field = List.nil();
+        type.supertype_field = annotationType;
+        type.interfaces_field = List.nil();
+        return type;
+    }
+
     /** Constructor; enters all predefined identifiers and operators
      *  into symbol table.
      */
@@ -348,12 +387,7 @@ public class Symtab {
         target = Target.instance(context);
 
         // Create the unknown type
-        unknownType = new Type(TypeTags.UNKNOWN, null) {
-            @Override
-            public <R, P> R accept(TypeVisitor<R, P> v, P p) {
-                return v.visitUnknown(this, p);
-            }
-        };
+        unknownType = new UnknownType();
 
         // create the basic builtin symbols
         rootPackage = new PackageSymbol(names.empty, null);
@@ -363,7 +397,7 @@ public class Symtab {
                     return messages.getLocalizedString("compiler.misc.unnamed.package");
                 }
             };
-        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
+        noSymbol = new TypeSymbol(Kinds.NIL, 0, names.empty, Type.noType, rootPackage) {
             public <R, P> R accept(ElementVisitor<R, P> v, P p) {
                 return v.visitUnknown(this, p);
             }
@@ -371,7 +405,6 @@ public class Symtab {
                 return false;
             }
         };
-        noSymbol.kind = Kinds.NIL;
 
         // create the error symbols
         errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
@@ -439,10 +472,10 @@ public class Symtab {
         cloneableType = enterClass("java.lang.Cloneable");
         throwableType = enterClass("java.lang.Throwable");
         serializableType = enterClass("java.io.Serializable");
-        transientMethodHandleType = enterClass("java.dyn.MethodHandle"); // transient - 292
+        serializedLambdaType = enterClass("java.lang.invoke.SerializedLambda");
         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
-        transientPolymorphicSignatureType = enterClass("java.dyn.MethodHandle$PolymorphicSignature"); // transient - 292
-        polymorphicSignatureType = enterClass("java.lang.invoke.MethodHandle$PolymorphicSignature");
+        methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
+        methodTypeType = enterClass("java.lang.invoke.MethodType");
         errorType = enterClass("java.lang.Error");
         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
         interruptedExceptionType = enterClass("java.lang.InterruptedException");
@@ -465,6 +498,7 @@ public class Symtab {
         listType = enterClass("java.util.List");
         collectionsType = enterClass("java.util.Collections");
         comparableType = enterClass("java.lang.Comparable");
+        comparatorType = enterClass("java.util.Comparator");
         arraysType = enterClass("java.util.Arrays");
         iterableType = target.hasIterable()
             ? enterClass("java.lang.Iterable")
@@ -476,6 +510,9 @@ public class Symtab {
         deprecatedType = enterClass("java.lang.Deprecated");
         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
         inheritedType = enterClass("java.lang.annotation.Inherited");
+        repeatableType = enterClass("java.lang.annotation.Repeatable");
+        documentedType = enterClass("java.lang.annotation.Documented");
+        elementTypeType = enterClass("java.lang.annotation.ElementType");
         systemType = enterClass("java.lang.System");
         autoCloseableType = enterClass("java.lang.AutoCloseable");
         autoCloseableClose = new MethodSymbol(PUBLIC,
@@ -484,12 +521,15 @@ public class Symtab {
                                             List.of(exceptionType), methodClass),
                              autoCloseableType.tsym);
         trustMeType = enterClass("java.lang.SafeVarargs");
+        nativeHeaderType = enterClass("java.lang.annotation.Native");
+        lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
+        functionalInterfaceType = enterClass("java.lang.FunctionalInterface");
 
         synthesizeEmptyInterfaceIfMissing(autoCloseableType);
         synthesizeEmptyInterfaceIfMissing(cloneableType);
         synthesizeEmptyInterfaceIfMissing(serializableType);
-        synthesizeEmptyInterfaceIfMissing(transientPolymorphicSignatureType); // transient - 292
-        synthesizeEmptyInterfaceIfMissing(polymorphicSignatureType);
+        synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
+        synthesizeEmptyInterfaceIfMissing(serializedLambdaType);
         synthesizeBoxTypeIfMissing(doubleType);
         synthesizeBoxTypeIfMissing(floatType);
         synthesizeBoxTypeIfMissing(voidType);
@@ -497,17 +537,13 @@ public class Symtab {
         // Enter a synthetic class that is used to mark internal
         // proprietary classes in ct.sym.  This class does not have a
         // class file.
-        ClassType proprietaryType = (ClassType)enterClass("sun.Proprietary+Annotation");
-        this.proprietaryType = proprietaryType;
-        ClassSymbol proprietarySymbol = (ClassSymbol)proprietaryType.tsym;
-        proprietarySymbol.completer = null;
-        proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
-        proprietarySymbol.erasure_field = proprietaryType;
-        proprietarySymbol.members_field = new Scope(proprietarySymbol);
-        proprietaryType.typarams_field = List.nil();
-        proprietaryType.allparams_field = List.nil();
-        proprietaryType.supertype_field = annotationType;
-        proprietaryType.interfaces_field = List.nil();
+        proprietaryType = enterSyntheticAnnotation("sun.Proprietary+Annotation");
+
+        // Enter a synthetic class that is used to provide profile info for
+        // classes in ct.sym.  This class does not have a class file.
+        profileType = enterSyntheticAnnotation("jdk.Profile+Annotation");
+        MethodSymbol m = new MethodSymbol(PUBLIC | ABSTRACT, names.value, intType, profileType.tsym);
+        profileType.tsym.members().enter(m);
 
         // Enter a class for arrays.
         // The class implements java.lang.Cloneable and java.io.Serializable.
@@ -531,15 +567,18 @@ public class Symtab {
         arrayClass.members().enter(arrayCloneMethod);
 
         // Enter operators.
-        enterUnop("+", doubleType, doubleType, nop);
-        enterUnop("+", floatType, floatType, nop);
-        enterUnop("+", longType, longType, nop);
-        enterUnop("+", intType, intType, nop);
-
-        enterUnop("-", doubleType, doubleType, dneg);
-        enterUnop("-", floatType, floatType, fneg);
-        enterUnop("-", longType, longType, lneg);
-        enterUnop("-", intType, intType, ineg);
+        /*  Internally we use +++, --- for unary +, - to reduce +, - operators
+         *  overloading
+         */
+        enterUnop("+++", doubleType, doubleType, nop);
+        enterUnop("+++", floatType, floatType, nop);
+        enterUnop("+++", longType, longType, nop);
+        enterUnop("+++", intType, intType, nop);
+
+        enterUnop("---", doubleType, doubleType, dneg);
+        enterUnop("---", floatType, floatType, fneg);
+        enterUnop("---", longType, longType, lneg);
+        enterUnop("---", intType, intType, ineg);
 
         enterUnop("~", longType, longType, lxor);
         enterUnop("~", intType, intType, ixor);
diff --git a/src/share/classes/com/sun/tools/javac/code/TargetType.java b/src/share/classes/com/sun/tools/javac/code/TargetType.java
index 6c24287..0876749 100644
--- a/src/share/classes/com/sun/tools/javac/code/TargetType.java
+++ b/src/share/classes/com/sun/tools/javac/code/TargetType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 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
@@ -25,10 +25,7 @@
 
 package com.sun.tools.javac.code;
 
-import static com.sun.tools.javac.code.TargetType.TargetAttribute.*;
-
-import java.util.EnumSet;
-import java.util.Set;
+import com.sun.tools.javac.util.Assert;
 
 /**
  * Describes the type of program element an extended annotation (or extended
@@ -44,178 +41,92 @@ import java.util.Set;
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
+// Code duplicated in com.sun.tools.classfile.TypeAnnotation.TargetType
 public enum TargetType {
+    /** For annotations on a class type parameter declaration. */
+    CLASS_TYPE_PARAMETER(0x00),
 
-    //
-    // Some target types are commented out, because Java doesn't permit such
-    // targets.  They are included here to confirm that their omission is
-    // intentional omission not an accidental omission.
-    //
-
-    /** For annotations on typecasts. */
-    TYPECAST(0x00, IsLocal),
+    /** For annotations on a method type parameter declaration. */
+    METHOD_TYPE_PARAMETER(0x01),
 
-    /** For annotations on a type argument or nested array of a typecast. */
-    TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation, IsLocal),
+    /** For annotations on the type of an "extends" or "implements" clause. */
+    CLASS_EXTENDS(0x10),
 
-    /** For annotations on type tests. */
-    INSTANCEOF(0x02, IsLocal),
+    /** For annotations on a bound of a type parameter of a class. */
+    CLASS_TYPE_PARAMETER_BOUND(0x11),
 
-    /** For annotations on a type argument or nested array of a type test. */
-    INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation, IsLocal),
+    /** For annotations on a bound of a type parameter of a method. */
+    METHOD_TYPE_PARAMETER_BOUND(0x12),
 
-    /** For annotations on object creation expressions. */
-    NEW(0x04, IsLocal),
-
-    /**
-     * For annotations on a type argument or nested array of an object creation
-     * expression.
-     */
-    NEW_GENERIC_OR_ARRAY(0x05, HasLocation, IsLocal),
+    /** For annotations on a field. */
+    FIELD(0x13),
 
+    /** For annotations on a method return type. */
+    METHOD_RETURN(0x14),
 
     /** For annotations on the method receiver. */
-    METHOD_RECEIVER(0x06),
-
-    // invalid location
-    //@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
-
-    /** For annotations on local variables. */
-    LOCAL_VARIABLE(0x08, IsLocal),
-
-    /** For annotations on a type argument or nested array of a local. */
-    LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation, IsLocal),
-
-    // handled by regular annotations
-    //@Deprecated METHOD_RETURN(0x0A),
-
-    /**
-     * For annotations on a type argument or nested array of a method return
-     * type.
-     */
-    METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
-
-    // handled by regular annotations
-    //@Deprecated METHOD_PARAMETER(0x0C),
-
-    /** For annotations on a type argument or nested array of a method parameter. */
-    METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
+    METHOD_RECEIVER(0x15),
 
-    // handled by regular annotations
-    //@Deprecated FIELD(0x0E),
-
-    /** For annotations on a type argument or nested array of a field. */
-    FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
-
-    /** For annotations on a bound of a type parameter of a class. */
-    CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
+    /** For annotations on a method parameter. */
+    METHOD_FORMAL_PARAMETER(0x16),
 
-    /**
-     * For annotations on a type argument or nested array of a bound of a type
-     * parameter of a class.
-     */
-    CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
-
-    /** For annotations on a bound of a type parameter of a method. */
-    METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
-
-    /**
-     * For annotations on a type argument or nested array of a bound of a type
-     * parameter of a method.
-     */
-    METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
+    /** For annotations on a throws clause in a method declaration. */
+    THROWS(0x17),
 
-    /** For annotations on the type of an "extends" or "implements" clause. */
-    CLASS_EXTENDS(0x14),
+    /** For annotations on a local variable. */
+    LOCAL_VARIABLE(0x40, true),
 
-    /** For annotations on the inner type of an "extends" or "implements" clause. */
-    CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
+    /** For annotations on a resource variable. */
+    RESOURCE_VARIABLE(0x41, true),
 
-    /** For annotations on a throws clause in a method declaration. */
-    THROWS(0x16),
+    /** For annotations on an exception parameter. */
+    EXCEPTION_PARAMETER(0x42, true),
 
-    // invalid location
-    //@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
+    /** For annotations on a type test. */
+    INSTANCEOF(0x43, true),
 
-    /** For annotations in type arguments of object creation expressions. */
-    NEW_TYPE_ARGUMENT(0x18, IsLocal),
-    NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation, IsLocal),
+    /** For annotations on an object creation expression. */
+    NEW(0x44, true),
 
-    METHOD_TYPE_ARGUMENT(0x1A, IsLocal),
-    METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation, IsLocal),
+    /** For annotations on a constructor reference receiver. */
+    CONSTRUCTOR_REFERENCE(0x45, true),
 
-    WILDCARD_BOUND(0x1C, HasBound),
-    WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
+    /** For annotations on a method reference receiver. */
+    METHOD_REFERENCE(0x46, true),
 
-    CLASS_LITERAL(0x1E, IsLocal),
-    CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation, IsLocal),
+    /** For annotations on a typecast. */
+    CAST(0x47, true),
 
-    METHOD_TYPE_PARAMETER(0x20, HasParameter),
+    /** For annotations on a type argument of an object creation expression. */
+    CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT(0x48, true),
 
-    // invalid location
-    //@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
+    /** For annotations on a type argument of a method call. */
+    METHOD_INVOCATION_TYPE_ARGUMENT(0x49, true),
 
-    CLASS_TYPE_PARAMETER(0x22, HasParameter),
+    /** For annotations on a type argument of a constructor reference. */
+    CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT(0x4A, true),
 
-    // invalid location
-    //@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
+    /** For annotations on a type argument of a method reference. */
+    METHOD_REFERENCE_TYPE_ARGUMENT(0x4B, true),
 
     /** For annotations with an unknown target. */
-    UNKNOWN(-1);
+    UNKNOWN(0xFF);
 
-    static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
+    private static final int MAXIMUM_TARGET_TYPE_VALUE = 0x4B;
 
     private final int targetTypeValue;
-    private Set<TargetAttribute> flags;
-
-    TargetType(int targetTypeValue, TargetAttribute... attributes) {
-        if (targetTypeValue < Byte.MIN_VALUE
-                || targetTypeValue > Byte.MAX_VALUE)
-                throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
-        this.targetTypeValue = (byte)targetTypeValue;
-        flags = EnumSet.noneOf(TargetAttribute.class);
-        for (TargetAttribute attr : attributes)
-            flags.add(attr);
-    }
+    private final boolean isLocal;
 
-    /**
-     * Returns whether or not this TargetType represents an annotation whose
-     * target is an inner type of a generic or array type.
-     *
-     * @return true if this TargetType represents an annotation on an inner
-     *         type, false otherwise
-     */
-    public boolean hasLocation() {
-        return flags.contains(HasLocation);
+    private TargetType(int targetTypeValue) {
+        this(targetTypeValue, false);
     }
 
-    public TargetType getGenericComplement() {
-        if (hasLocation())
-            return this;
-        else
-            return fromTargetTypeValue(targetTypeValue() + 1);
-    }
-
-    /**
-     * Returns whether or not this TargetType represents an annotation whose
-     * target has a parameter index.
-     *
-     * @return true if this TargetType has a parameter index,
-     *         false otherwise
-     */
-    public boolean hasParameter() {
-        return flags.contains(HasParameter);
-    }
-
-    /**
-     * Returns whether or not this TargetType represents an annotation whose
-     * target is a type parameter bound.
-     *
-     * @return true if this TargetType represents an type parameter bound
-     *         annotation, false otherwise
-     */
-    public boolean hasBound() {
-        return flags.contains(HasBound);
+    private TargetType(int targetTypeValue, boolean isLocal) {
+        if (targetTypeValue < 0
+                || targetTypeValue > 255)
+                Assert.error("Attribute type value needs to be an unsigned byte: " + String.format("0x%02X", targetTypeValue));
+        this.targetTypeValue = targetTypeValue;
+        this.isLocal = isLocal;
     }
 
     /**
@@ -226,52 +137,41 @@ public enum TargetType {
      * member declaration signature tree
      */
     public boolean isLocal() {
-        return flags.contains(IsLocal);
+        return isLocal;
     }
 
     public int targetTypeValue() {
         return this.targetTypeValue;
     }
 
-    private static TargetType[] targets = null;
+    private static final TargetType[] targets;
 
-    private static TargetType[] buildTargets() {
-        TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
+    static {
+        targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
         TargetType[] alltargets = values();
         for (TargetType target : alltargets) {
-            if (target.targetTypeValue >= 0)
+            if (target.targetTypeValue != UNKNOWN.targetTypeValue)
                 targets[target.targetTypeValue] = target;
         }
         for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
             if (targets[i] == null)
                 targets[i] = UNKNOWN;
         }
-        return targets;
     }
 
     public static boolean isValidTargetTypeValue(int tag) {
-        if (targets == null)
-            targets = buildTargets();
-
-        if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+        if (tag == UNKNOWN.targetTypeValue)
             return true;
 
         return (tag >= 0 && tag < targets.length);
     }
 
     public static TargetType fromTargetTypeValue(int tag) {
-        if (targets == null)
-            targets = buildTargets();
-
-        if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+        if (tag == UNKNOWN.targetTypeValue)
             return UNKNOWN;
 
         if (tag < 0 || tag >= targets.length)
-            throw new IllegalArgumentException("Unknown TargetType: " + tag);
+            Assert.error("Unknown TargetType: " + tag);
         return targets[tag];
     }
-
-    static enum TargetAttribute {
-        HasLocation, HasParameter, HasBound, IsLocal;
-    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/code/Type.java b/src/share/classes/com/sun/tools/javac/code/Type.java
index 737a2cf..66f03a6 100644
--- a/src/share/classes/com/sun/tools/javac/code/Type.java
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,17 +25,22 @@
 
 package com.sun.tools.javac.code;
 
+import java.lang.annotation.Annotation;
 import java.util.Collections;
-
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.code.Symbol.*;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.Map;
+import java.util.Set;
 
 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.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.BoundKind.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 
 /** This class represents Java types. The class itself defines the behavior of
  *  the following types:
@@ -54,7 +59,7 @@ import static com.sun.tools.javac.code.TypeTags.*;
  *  package types (tag: PACKAGE, class: PackageType),
  *  type variables (tag: TYPEVAR, class: TypeVar),
  *  type arguments (tag: WILDCARD, class: WildcardType),
- *  polymorphic types (tag: FORALL, class: ForAll),
+ *  generic method types (tag: FORALL, class: ForAll),
  *  the error type (tag: ERROR, class: ErrorType).
  *  </pre>
  *
@@ -63,27 +68,65 @@ import static com.sun.tools.javac.code.TypeTags.*;
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  *
- *  @see TypeTags
+ *  @see TypeTag
  */
-public class Type implements PrimitiveType {
+public abstract class Type implements TypeMirror {
 
     /** Constant type: no type at all. */
-    public static final JCNoType noType = new JCNoType(NONE);
+    public static final JCNoType noType = new JCNoType();
+
+    /** Constant type: special type to be used during recovery of deferred expressions. */
+    public static final JCNoType recoveryType = new JCNoType();
+
+    /** Constant type: special type to be used for marking stuck trees. */
+    public static final JCNoType stuckType = new JCNoType();
 
     /** If this switch is turned on, the names of type variables
      *  and anonymous classes are printed with hashcodes appended.
      */
     public static boolean moreInfo = false;
 
-    /** The tag of this type.
-     *
-     *  @see TypeTags
+    /** The defining class / interface / package / type variable.
      */
-    public int tag;
+    public TypeSymbol tsym;
 
-    /** The defining class / interface / package / type variable
+    /**
+     * Checks if the current type tag is equal to the given tag.
+     * @return true if tag is equal to the current type tag.
      */
-    public TypeSymbol tsym;
+    public boolean hasTag(TypeTag tag) {
+        return tag == getTag();
+    }
+
+    /**
+     * Returns the current type tag.
+     * @return the value of the current type tag.
+     */
+    public abstract TypeTag getTag();
+
+    public boolean isNumeric() {
+        return false;
+    }
+
+    public boolean isPrimitive() {
+        return false;
+    }
+
+    public boolean isPrimitiveOrVoid() {
+        return false;
+    }
+
+    public boolean isReference() {
+        return false;
+    }
+
+    public boolean isNullOrReference() {
+        return false;
+    }
+
+    public boolean isPartial() {
+        return false;
+    }
 
     /**
      * The constant value of this type, null if this type does not
@@ -95,17 +138,29 @@ public class Type implements PrimitiveType {
         return null;
     }
 
+    /** Is this a constant type whose value is false?
+     */
+    public boolean isFalse() {
+        return false;
+    }
+
+    /** Is this a constant type whose value is true?
+     */
+    public boolean isTrue() {
+        return false;
+    }
+
     /**
      * Get the representation of this type used for modelling purposes.
      * By default, this is itself. For ErrorType, a different value
-     * may be provided,
+     * may be provided.
      */
     public Type getModelType() {
         return this;
     }
 
     public static List<Type> getModelTypes(List<Type> ts) {
-        ListBuffer<Type> lb = new ListBuffer<Type>();
+        ListBuffer<Type> lb = new ListBuffer<>();
         for (Type t: ts)
             lb.append(t.getModelType());
         return lb.toList();
@@ -115,8 +170,7 @@ public class Type implements PrimitiveType {
 
     /** Define a type given its tag and type symbol
      */
-    public Type(int tag, TypeSymbol tsym) {
-        this.tag = tag;
+    public Type(TypeSymbol tsym) {
         this.tsym = tsym;
     }
 
@@ -155,18 +209,7 @@ public class Type implements PrimitiveType {
      *  and with given constant value
      */
     public Type constType(Object constValue) {
-        final Object value = constValue;
-        Assert.check(tag <= BOOLEAN);
-        return new Type(tag, tsym) {
-                @Override
-                public Object constValue() {
-                    return value;
-                }
-                @Override
-                public Type baseType() {
-                    return tsym.type;
-                }
-            };
+        throw new AssertionError();
     }
 
     /**
@@ -177,6 +220,35 @@ public class Type implements PrimitiveType {
         return this;
     }
 
+    public boolean isAnnotated() {
+        return false;
+    }
+
+    /**
+     * If this is an annotated type, return the underlying type.
+     * Otherwise, return the type itself.
+     */
+    public Type unannotatedType() {
+        return this;
+    }
+
+    @Override
+    public List<? extends Attribute.TypeCompound> getAnnotationMirrors() {
+        return List.nil();
+    }
+
+    @Override
+    public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+        return null;
+    }
+
+    @Override
+    public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
+        @SuppressWarnings("unchecked")
+        A[] tmp = (A[]) java.lang.reflect.Array.newInstance(annotationType, 0);
+        return tmp;
+    }
+
     /** Return the base types of a list of types.
      */
     public static List<Type> baseTypes(List<Type> ts) {
@@ -195,7 +267,9 @@ public class Type implements PrimitiveType {
         String s = (tsym == null || tsym.name == null)
             ? "<none>"
             : tsym.name.toString();
-        if (moreInfo && tag == TYPEVAR) s = s + hashCode();
+        if (moreInfo && hasTag(TYPEVAR)) {
+            s = s + hashCode();
+        }
         return s;
     }
 
@@ -221,12 +295,7 @@ public class Type implements PrimitiveType {
      */
     public String stringValue() {
         Object cv = Assert.checkNonNull(constValue());
-        if (tag == BOOLEAN)
-            return ((Integer) cv).intValue() == 0 ? "false" : "true";
-        else if (tag == CHAR)
-            return String.valueOf((char) ((Integer) cv).intValue());
-        else
-            return cv.toString();
+        return cv.toString();
     }
 
     /**
@@ -234,32 +303,16 @@ public class Type implements PrimitiveType {
      * never complete classes. Where isSameType would complete a
      * class, equals assumes that the two types are different.
      */
+    @Override
     public boolean equals(Object t) {
         return super.equals(t);
     }
 
+    @Override
     public int hashCode() {
         return super.hashCode();
     }
 
-    /** Is this a constant type whose value is false?
-     */
-    public boolean isFalse() {
-        return
-            tag == BOOLEAN &&
-            constValue() != null &&
-            ((Integer)constValue()).intValue() == 0;
-    }
-
-    /** Is this a constant type whose value is true?
-     */
-    public boolean isTrue() {
-        return
-            tag == BOOLEAN &&
-            constValue() != null &&
-            ((Integer)constValue()).intValue() != 0;
-    }
-
     public String argtypes(boolean varargs) {
         List<Type> args = getParameterTypes();
         if (!varargs) return args.toString();
@@ -269,8 +322,11 @@ public class Type implements PrimitiveType {
             args = args.tail;
             buf.append(',');
         }
-        if (args.head.tag == ARRAY) {
-            buf.append(((ArrayType)args.head).elemtype);
+        if (args.head.unannotatedType().hasTag(ARRAY)) {
+            buf.append(((ArrayType)args.head.unannotatedType()).elemtype);
+            if (args.head.getAnnotationMirrors().nonEmpty()) {
+                buf.append(args.head.getAnnotationMirrors());
+            }
             buf.append("...");
         } else {
             buf.append(args.head);
@@ -281,9 +337,10 @@ public class Type implements PrimitiveType {
     /** Access methods.
      */
     public List<Type>        getTypeArguments()  { return List.nil(); }
-    public Type              getEnclosingType() { return null; }
+    public Type              getEnclosingType()  { return null; }
     public List<Type>        getParameterTypes() { return List.nil(); }
     public Type              getReturnType()     { return null; }
+    public Type              getReceiverType()   { return null; }
     public List<Type>        getThrownTypes()    { return List.nil(); }
     public Type              getUpperBound()     { return null; }
     public Type              getLowerBound()     { return null; }
@@ -346,10 +403,6 @@ public class Type implements PrimitiveType {
         return (tsym.flags() & FINAL) != 0;
     }
 
-    public boolean isPrimitive() {
-        return tag < VOID;
-    }
-
     /**
      * Does this type contain occurrences of type t?
      */
@@ -406,28 +459,122 @@ public class Type implements PrimitiveType {
         return tsym;
     }
 
+    @Override
     public TypeKind getKind() {
-        switch (tag) {
-        case BYTE:      return TypeKind.BYTE;
-        case CHAR:      return TypeKind.CHAR;
-        case SHORT:     return TypeKind.SHORT;
-        case INT:       return TypeKind.INT;
-        case LONG:      return TypeKind.LONG;
-        case FLOAT:     return TypeKind.FLOAT;
-        case DOUBLE:    return TypeKind.DOUBLE;
-        case BOOLEAN:   return TypeKind.BOOLEAN;
-        case VOID:      return TypeKind.VOID;
-        case BOT:       return TypeKind.NULL;
-        case NONE:      return TypeKind.NONE;
-        default:        return TypeKind.OTHER;
-        }
+        return TypeKind.OTHER;
     }
 
+    @Override
     public <R, P> R accept(TypeVisitor<R, P> v, P p) {
-        if (isPrimitive())
+        throw new AssertionError();
+    }
+
+    public static class JCPrimitiveType extends Type
+            implements javax.lang.model.type.PrimitiveType {
+
+        TypeTag tag;
+
+        public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) {
+            super(tsym);
+            this.tag = tag;
+            Assert.check(tag.isPrimitive);
+        }
+
+        @Override
+        public boolean isNumeric() {
+            return tag != BOOLEAN;
+        }
+
+        @Override
+        public boolean isPrimitive() {
+            return true;
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return tag;
+        }
+
+        @Override
+        public boolean isPrimitiveOrVoid() {
+            return true;
+        }
+
+        /** Define a constant type, of the same kind as this type
+         *  and with given constant value
+         */
+        @Override
+        public Type constType(Object constValue) {
+            final Object value = constValue;
+            return new JCPrimitiveType(tag, tsym) {
+                    @Override
+                    public Object constValue() {
+                        return value;
+                    }
+                    @Override
+                    public Type baseType() {
+                        return tsym.type;
+                    }
+                };
+        }
+
+        /**
+         * The constant value of this type, converted to String
+         */
+        @Override
+        public String stringValue() {
+            Object cv = Assert.checkNonNull(constValue());
+            if (tag == BOOLEAN) {
+                return ((Integer) cv).intValue() == 0 ? "false" : "true";
+            }
+            else if (tag == CHAR) {
+                return String.valueOf((char) ((Integer) cv).intValue());
+            }
+            else {
+                return cv.toString();
+            }
+        }
+
+        /** Is this a constant type whose value is false?
+         */
+        @Override
+        public boolean isFalse() {
+            return
+                tag == BOOLEAN &&
+                constValue() != null &&
+                ((Integer)constValue()).intValue() == 0;
+        }
+
+        /** Is this a constant type whose value is true?
+         */
+        @Override
+        public boolean isTrue() {
+            return
+                tag == BOOLEAN &&
+                constValue() != null &&
+                ((Integer)constValue()).intValue() != 0;
+        }
+
+        @Override
+        public <R, P> R accept(TypeVisitor<R, P> v, P p) {
             return v.visitPrimitive(this, p);
-        else
+        }
+
+        @Override
+        public TypeKind getKind() {
+            switch (tag) {
+                case BYTE:      return TypeKind.BYTE;
+                case CHAR:      return TypeKind.CHAR;
+                case SHORT:     return TypeKind.SHORT;
+                case INT:       return TypeKind.INT;
+                case LONG:      return TypeKind.LONG;
+                case FLOAT:     return TypeKind.FLOAT;
+                case DOUBLE:    return TypeKind.DOUBLE;
+                case BOOLEAN:   return TypeKind.BOOLEAN;
+            }
             throw new AssertionError();
+        }
+
     }
 
     public static class WildcardType extends Type
@@ -443,7 +590,7 @@ public class Type implements PrimitiveType {
         }
 
         public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) {
-            super(WILDCARD, tsym);
+            super(tsym);
             this.type = Assert.checkNonNull(type);
             this.kind = kind;
         }
@@ -456,6 +603,12 @@ public class Type implements PrimitiveType {
             this.bound = bound;
         }
 
+        @Override
+        public TypeTag getTag() {
+            return WILDCARD;
+        }
+
+        @Override
         public boolean contains(Type t) {
             return kind != UNBOUND && type.contains(t);
         }
@@ -472,6 +625,17 @@ public class Type implements PrimitiveType {
             return kind == UNBOUND;
         }
 
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
+        @Override
         public Type withTypeVar(Type t) {
             //-System.err.println(this+".withTypeVar("+t+");");//DEBUG
             if (bound == t)
@@ -534,7 +698,7 @@ public class Type implements PrimitiveType {
 
         /** The enclosing type of this type. If this is the type of an inner
          *  class, outer_field refers to the type of its enclosing
-         *  instance class, in all other cases it referes to noType.
+         *  instance class, in all other cases it refers to noType.
          */
         private Type outer_field;
 
@@ -561,7 +725,7 @@ public class Type implements PrimitiveType {
         public List<Type> all_interfaces_field;
 
         public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
-            super(CLASS, tsym);
+            super(tsym);
             this.outer_field = outer;
             this.typarams_field = typarams;
             this.allparams_field = null;
@@ -579,6 +743,11 @@ public class Type implements PrimitiveType {
         }
 
         @Override
+        public TypeTag getTag() {
+            return CLASS;
+        }
+
+        @Override
         public <R,S> R accept(Type.Visitor<R,S> v, S s) {
             return v.visitClassType(this, s);
         }
@@ -601,7 +770,7 @@ public class Type implements PrimitiveType {
          */
         public String toString() {
             StringBuilder buf = new StringBuilder();
-            if (getEnclosingType() != null && getEnclosingType().tag == CLASS && tsym.owner.kind == TYP) {
+            if (getEnclosingType() != null && getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) {
                 buf.append(getEnclosingType().toString());
                 buf.append(".");
                 buf.append(className(tsym, false));
@@ -626,7 +795,7 @@ public class Type implements PrimitiveType {
                     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()) {
@@ -684,7 +853,7 @@ public class Type implements PrimitiveType {
             return
                 getEnclosingType().isErroneous() ||
                 isErroneous(getTypeArguments()) ||
-                this != tsym.type && tsym.type.isErroneous();
+                this != tsym.type.unannotatedType() && tsym.type.isErroneous();
         }
 
         public boolean isParameterized() {
@@ -692,13 +861,23 @@ public class Type implements PrimitiveType {
             // optimization, was: allparams().nonEmpty();
         }
 
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
         /** A cache for the rank. */
         int rank_field = -1;
 
         /** A class type is raw if it misses some
          *  of its type parameter sections.
          *  After validation, this is equivalent to:
-         *  allparams.isEmpty() && tsym.type.allparams.nonEmpty();
+         *  {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); }
          */
         public boolean isRaw() {
             return
@@ -781,17 +960,70 @@ public class Type implements PrimitiveType {
         }
     }
 
+    // a clone of a ClassType that knows about the bounds of an intersection type.
+    public static class IntersectionClassType extends ClassType implements IntersectionType {
+
+        public boolean allInterfaces;
+
+        public enum IntersectionKind {
+            EXPLICIT,
+            IMPLICT;
+        }
+
+        public IntersectionKind intersectionKind;
+
+        public IntersectionClassType(List<Type> bounds, ClassSymbol csym, boolean allInterfaces) {
+            super(Type.noType, List.<Type>nil(), csym);
+            this.allInterfaces = allInterfaces;
+            Assert.check((csym.flags() & COMPOUND) != 0);
+            supertype_field = bounds.head;
+            interfaces_field = bounds.tail;
+            Assert.check(supertype_field.tsym.completer != null ||
+                    !supertype_field.isInterface(), supertype_field);
+        }
+
+        public java.util.List<? extends TypeMirror> getBounds() {
+            return Collections.unmodifiableList(getComponents());
+        }
+
+        public List<Type> getComponents() {
+            return interfaces_field.prepend(supertype_field);
+        }
+
+        public List<Type> getExplicitComponents() {
+            return allInterfaces ?
+                    interfaces_field :
+                    getComponents();
+        }
+
+        @Override
+        public TypeKind getKind() {
+            return TypeKind.INTERSECTION;
+        }
+
+        @Override
+        public <R, P> R accept(TypeVisitor<R, P> v, P p) {
+            return intersectionKind == IntersectionKind.EXPLICIT ?
+                v.visitIntersection(this, p) :
+                v.visitDeclared(this, p);
+        }
+    }
+
     public static class ArrayType extends Type
             implements javax.lang.model.type.ArrayType {
 
         public Type elemtype;
 
         public ArrayType(Type elemtype, TypeSymbol arrayClass) {
-            super(ARRAY, arrayClass);
+            super(arrayClass);
             this.elemtype = elemtype;
         }
 
         @Override
+        public TypeTag getTag() {
+            return ARRAY;
+        }
+
         public <R,S> R accept(Type.Visitor<R,S> v, S s) {
             return v.visitArrayType(this, s);
         }
@@ -808,7 +1040,7 @@ public class Type implements PrimitiveType {
         }
 
         public int hashCode() {
-            return (ARRAY << 5) + elemtype.hashCode();
+            return (ARRAY.ordinal() << 5) + elemtype.hashCode();
         }
 
         public boolean isVarargs() {
@@ -825,6 +1057,16 @@ public class Type implements PrimitiveType {
             return elemtype.isParameterized();
         }
 
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
         public boolean isRaw() {
             return elemtype.isRaw();
         }
@@ -871,17 +1113,25 @@ public class Type implements PrimitiveType {
         public Type restype;
         public List<Type> thrown;
 
+        /** The type annotations on the method receiver.
+         */
+        public Type recvtype;
+
         public MethodType(List<Type> argtypes,
                           Type restype,
                           List<Type> thrown,
                           TypeSymbol methodClass) {
-            super(METHOD, methodClass);
+            super(methodClass);
             this.argtypes = argtypes;
             this.restype = restype;
             this.thrown = thrown;
         }
 
         @Override
+        public TypeTag getTag() {
+            return METHOD;
+        }
+
         public <R,S> R accept(Type.Visitor<R,S> v, S s) {
             return v.visitMethodType(this, s);
         }
@@ -895,36 +1145,9 @@ public class Type implements PrimitiveType {
             return "(" + argtypes + ")" + restype;
         }
 
-        public boolean equals(Object obj) {
-            if (this == obj)
-                return true;
-            if (!(obj instanceof MethodType))
-                return false;
-            MethodType m = (MethodType)obj;
-            List<Type> args1 = argtypes;
-            List<Type> args2 = m.argtypes;
-            while (!args1.isEmpty() && !args2.isEmpty()) {
-                if (!args1.head.equals(args2.head))
-                    return false;
-                args1 = args1.tail;
-                args2 = args2.tail;
-            }
-            if (!args1.isEmpty() || !args2.isEmpty())
-                return false;
-            return restype.equals(m.restype);
-        }
-
-        public int hashCode() {
-            int h = METHOD;
-            for (List<Type> thisargs = this.argtypes;
-                 thisargs.tail != null; /*inlined: thisargs.nonEmpty()*/
-                 thisargs = thisargs.tail)
-                h = (h << 5) + thisargs.head.hashCode();
-            return (h << 5) + this.restype.hashCode();
-        }
-
         public List<Type>        getParameterTypes() { return argtypes; }
         public Type              getReturnType()     { return restype; }
+        public Type              getReceiverType()   { return recvtype; }
         public List<Type>        getThrownTypes()    { return thrown; }
 
         public boolean isErroneous() {
@@ -944,7 +1167,7 @@ public class Type implements PrimitiveType {
         }
 
         public boolean contains(Type elem) {
-            return elem == this || contains(argtypes, elem) || restype.contains(elem);
+            return elem == this || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem);
         }
 
         public MethodType asMethodType() { return this; }
@@ -953,6 +1176,7 @@ public class Type implements PrimitiveType {
             for (List<Type> l = argtypes; l.nonEmpty(); l = l.tail)
                 l.head.complete();
             restype.complete();
+            recvtype.complete();
             for (List<Type> l = thrown; l.nonEmpty(); l = l.tail)
                 l.head.complete();
         }
@@ -977,7 +1201,12 @@ public class Type implements PrimitiveType {
     public static class PackageType extends Type implements NoType {
 
         PackageType(TypeSymbol tsym) {
-            super(PACKAGE, tsym);
+            super(tsym);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return PACKAGE;
         }
 
         @Override
@@ -1020,26 +1249,36 @@ public class Type implements PrimitiveType {
         public Type lower;
 
         public TypeVar(Name name, Symbol owner, Type lower) {
-            super(TYPEVAR, null);
-            tsym = new TypeSymbol(0, name, this, owner);
+            super(null);
+            tsym = new TypeVariableSymbol(0, name, this, owner);
             assert lower != null;
             this.lower = lower;
         }
 
         public TypeVar(TypeSymbol tsym, Type bound, Type lower) {
-            super(TYPEVAR, tsym);
+            super(tsym);
             assert lower != null;
             this.bound = bound;
             this.lower = lower;
         }
 
         @Override
+        public TypeTag getTag() {
+            return TYPEVAR;
+        }
+
+        @Override
         public <R,S> R accept(Type.Visitor<R,S> v, S s) {
             return v.visitTypeVar(this, s);
         }
 
         @Override
-        public Type getUpperBound() { return bound; }
+        public Type getUpperBound() {
+            if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) {
+                bound = tsym.type.getUpperBound();
+            }
+            return bound;
+        }
 
         int rank_field = -1;
 
@@ -1056,6 +1295,17 @@ public class Type implements PrimitiveType {
             return false;
         }
 
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
+        @Override
         public <R, P> R accept(TypeVisitor<R, P> v, P p) {
             return v.visitTypeVariable(this, p);
         }
@@ -1101,26 +1351,35 @@ public class Type implements PrimitiveType {
 
     public static abstract class DelegatedType extends Type {
         public Type qtype;
-        public DelegatedType(int tag, Type qtype) {
-            super(tag, qtype.tsym);
+        public TypeTag tag;
+        public DelegatedType(TypeTag tag, Type qtype) {
+            super(qtype.tsym);
+            this.tag = tag;
             this.qtype = qtype;
         }
+        public TypeTag getTag() { return tag; }
         public String toString() { return qtype.toString(); }
         public List<Type> getTypeArguments() { return qtype.getTypeArguments(); }
         public Type getEnclosingType() { return qtype.getEnclosingType(); }
         public List<Type> getParameterTypes() { return qtype.getParameterTypes(); }
         public Type getReturnType() { return qtype.getReturnType(); }
+        public Type getReceiverType() { return qtype.getReceiverType(); }
         public List<Type> getThrownTypes() { return qtype.getThrownTypes(); }
         public List<Type> allparams() { return qtype.allparams(); }
         public Type getUpperBound() { return qtype.getUpperBound(); }
         public boolean isErroneous() { return qtype.isErroneous(); }
     }
 
+    /**
+     * The type of a generic method type. It consists of a method type and
+     * a list of method type-parameters that are used within the method
+     * type.
+     */
     public static class ForAll extends DelegatedType implements ExecutableType {
         public List<Type> tvars;
 
         public ForAll(List<Type> tvars, Type qtype) {
-            super(FORALL, qtype);
+            super(FORALL, (MethodType)qtype);
             this.tvars = tvars;
         }
 
@@ -1139,57 +1398,6 @@ public class Type implements PrimitiveType {
             return qtype.isErroneous();
         }
 
-        /**
-         * Replaces this ForAll's typevars with a set of concrete Java types
-         * and returns the instantiated generic type. Subclasses should override
-         * in order to check that the list of types is a valid instantiation
-         * of the ForAll's typevars.
-         *
-         * @param actuals list of actual types
-         * @param types types instance
-         * @return qtype where all occurrences of tvars are replaced
-         * by types in actuals
-         */
-        public Type inst(List<Type> actuals, Types types) {
-            return types.subst(qtype, tvars, actuals);
-        }
-
-        /**
-         * Kind of type-constraint derived during type inference
-         */
-        public enum ConstraintKind {
-            /**
-             * upper bound constraint (a type variable must be instantiated
-             * with a type T, where T is a subtype of all the types specified by
-             * its EXTENDS constraints).
-             */
-            EXTENDS,
-            /**
-             * lower bound constraint (a type variable must be instantiated
-             * with a type T, where T is a supertype of all the types specified by
-             * its SUPER constraints).
-             */
-            SUPER,
-            /**
-             * equality constraint (a type variable must be instantiated to the type
-             * specified by its EQUAL constraint.
-             */
-            EQUAL;
-        }
-
-        /**
-         * Get the type-constraints of a given kind for a given type-variable of
-         * this ForAll type. Subclasses should override in order to return more
-         * accurate sets of constraints.
-         *
-         * @param tv the type-variable for which the constraint is to be retrieved
-         * @param ck the constraint kind to be retrieved
-         * @return the list of types specified by the selected constraint
-         */
-        public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
-            return List.nil();
-        }
-
         public Type map(Mapping f) {
             return f.apply(qtype);
         }
@@ -1199,7 +1407,7 @@ public class Type implements PrimitiveType {
         }
 
         public MethodType asMethodType() {
-            return qtype.asMethodType();
+            return (MethodType)qtype;
         }
 
         public void complete() {
@@ -1222,21 +1430,60 @@ public class Type implements PrimitiveType {
         }
     }
 
-    /** A class for instantiatable variables, for use during type
-     *  inference.
+    /** A class for inference variables, for use during method/diamond type
+     *  inference. An inference variable has upper/lower bounds and a set
+     *  of equality constraints. Such bounds are set during subtyping, type-containment,
+     *  type-equality checks, when the types being tested contain inference variables.
+     *  A change listener can be attached to an inference variable, to receive notifications
+     *  whenever the bounds of an inference variable change.
      */
     public static class UndetVar extends DelegatedType {
-        public List<Type> lobounds = List.nil();
-        public List<Type> hibounds = List.nil();
+
+        /** Inference variable change listener. The listener method is called
+         *  whenever a change to the inference variable's bounds occurs
+         */
+        public interface UndetVarListener {
+            /** called when some inference variable bounds (of given kinds ibs) change */
+            void varChanged(UndetVar uv, Set<InferenceBound> ibs);
+        }
+
+        /**
+         * Inference variable bound kinds
+         */
+        public enum InferenceBound {
+            /** upper bounds */
+            UPPER,
+            /** lower bounds */
+            LOWER,
+            /** equality constraints */
+            EQ;
+        }
+
+        /** inference variable bounds */
+        protected Map<InferenceBound, List<Type>> bounds;
+
+        /** inference variable's inferred type (set from Infer.java) */
         public Type inst = null;
 
+        /** number of declared (upper) bounds */
+        public int declaredCount;
+
+        /** inference variable's change listener */
+        public UndetVarListener listener = null;
+
         @Override
         public <R,S> R accept(Type.Visitor<R,S> v, S s) {
             return v.visitUndetVar(this, s);
         }
 
-        public UndetVar(Type origin) {
+        public UndetVar(TypeVar origin, Types types) {
             super(UNDETVAR, origin);
+            bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
+            List<Type> declaredBounds = types.getBounds(origin);
+            declaredCount = declaredBounds.length();
+            bounds.put(InferenceBound.UPPER, declaredBounds);
+            bounds.put(InferenceBound.LOWER, List.<Type>nil());
+            bounds.put(InferenceBound.EQ, List.<Type>nil());
         }
 
         public String toString() {
@@ -1244,30 +1491,171 @@ public class Type implements PrimitiveType {
             else return qtype + "?";
         }
 
+        @Override
+        public boolean isPartial() {
+            return true;
+        }
+
+        @Override
         public Type baseType() {
             if (inst != null) return inst.baseType();
             else return this;
         }
+
+        /** get all bounds of a given kind */
+        public List<Type> getBounds(InferenceBound... ibs) {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (InferenceBound ib : ibs) {
+                buf.appendList(bounds.get(ib));
+            }
+            return buf.toList();
+        }
+
+        /** get the list of declared (upper) bounds */
+        public List<Type> getDeclaredBounds() {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            int count = 0;
+            for (Type b : getBounds(InferenceBound.UPPER)) {
+                if (count++ == declaredCount) break;
+                buf.append(b);
+            }
+            return buf.toList();
+        }
+
+        /** internal method used to override an undetvar bounds */
+        public void setBounds(InferenceBound ib, List<Type> newBounds) {
+            bounds.put(ib, newBounds);
+        }
+
+        /** add a bound of a given kind - this might trigger listener notification */
+        public final void addBound(InferenceBound ib, Type bound, Types types) {
+            addBound(ib, bound, types, false);
+        }
+
+        protected void addBound(InferenceBound ib, Type bound, Types types, boolean update) {
+            Type bound2 = toTypeVarMap.apply(bound);
+            List<Type> prevBounds = bounds.get(ib);
+            for (Type b : prevBounds) {
+                //check for redundancy - use strict version of isSameType on tvars
+                //(as the standard version will lead to false positives w.r.t. clones ivars)
+                if (types.isSameType(b, bound2, true) || bound == qtype) return;
+            }
+            bounds.put(ib, prevBounds.prepend(bound2));
+            notifyChange(EnumSet.of(ib));
+        }
+        //where
+            Type.Mapping toTypeVarMap = new Mapping("toTypeVarMap") {
+                @Override
+                public Type apply(Type t) {
+                    if (t.hasTag(UNDETVAR)) {
+                        UndetVar uv = (UndetVar)t;
+                        return uv.inst != null ? uv.inst : uv.qtype;
+                    } else {
+                        return t.map(this);
+                    }
+                }
+            };
+
+        /** replace types in all bounds - this might trigger listener notification */
+        public void substBounds(List<Type> from, List<Type> to, Types types) {
+            List<Type> instVars = from.diff(to);
+            //if set of instantiated ivars is empty, there's nothing to do!
+            if (instVars.isEmpty()) return;
+            final EnumSet<InferenceBound> boundsChanged = EnumSet.noneOf(InferenceBound.class);
+            UndetVarListener prevListener = listener;
+            try {
+                //setup new listener for keeping track of changed bounds
+                listener = new UndetVarListener() {
+                    public void varChanged(UndetVar uv, Set<InferenceBound> ibs) {
+                        boundsChanged.addAll(ibs);
+                    }
+                };
+                for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
+                    InferenceBound ib = _entry.getKey();
+                    List<Type> prevBounds = _entry.getValue();
+                    ListBuffer<Type> newBounds = ListBuffer.lb();
+                    ListBuffer<Type> deps = ListBuffer.lb();
+                    //step 1 - re-add bounds that are not dependent on ivars
+                    for (Type t : prevBounds) {
+                        if (!t.containsAny(instVars)) {
+                            newBounds.append(t);
+                        } else {
+                            deps.append(t);
+                        }
+                    }
+                    //step 2 - replace bounds
+                    bounds.put(ib, newBounds.toList());
+                    //step 3 - for each dependency, add new replaced bound
+                    for (Type dep : deps) {
+                        addBound(ib, types.subst(dep, from, to), types, true);
+                    }
+                }
+            } finally {
+                listener = prevListener;
+                if (!boundsChanged.isEmpty()) {
+                    notifyChange(boundsChanged);
+                }
+            }
+        }
+
+        private void notifyChange(EnumSet<InferenceBound> ibs) {
+            if (listener != null) {
+                listener.varChanged(this, ibs);
+            }
+        }
+
+        public boolean isCaptured() {
+            return false;
+        }
     }
 
-    /** Represents VOID or NONE.
+    /**
+     * This class is used to represent synthetic captured inference variables
+     * that can be generated during nested generic method calls. The only difference
+     * between these inference variables and ordinary ones is that captured inference
+     * variables cannot get new bounds through incorporation.
      */
-    static class JCNoType extends Type implements NoType {
-        public JCNoType(int tag) {
-            super(tag, null);
+    public static class CapturedUndetVar extends UndetVar {
+
+        public CapturedUndetVar(CapturedType origin, Types types) {
+            super(origin, types);
+            if (!origin.lower.hasTag(BOT)) {
+                bounds.put(InferenceBound.LOWER, List.of(origin.lower));
+            }
         }
 
         @Override
-        public TypeKind getKind() {
-            switch (tag) {
-            case VOID:  return TypeKind.VOID;
-            case NONE:  return TypeKind.NONE;
-            default:
-                throw new AssertionError("Unexpected tag: " + tag);
+        public void addBound(InferenceBound ib, Type bound, Types types, boolean update) {
+            if (update) {
+                //only change bounds if request comes from substBounds
+                super.addBound(ib, bound, types, update);
             }
         }
 
         @Override
+        public boolean isCaptured() {
+            return true;
+        }
+    }
+
+    /** Represents NONE.
+     */
+    public static class JCNoType extends Type implements NoType {
+        public JCNoType() {
+            super(null);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return NONE;
+        }
+
+        @Override
+        public TypeKind getKind() {
+            return TypeKind.NONE;
+        }
+
+        @Override
         public <R, P> R accept(TypeVisitor<R, P> v, P p) {
             return v.visitNoType(this, p);
         }
@@ -1276,9 +1664,43 @@ public class Type implements PrimitiveType {
         public boolean isInterface() { return false; }
    }
 
+    /** Represents VOID.
+     */
+    public static class JCVoidType extends Type implements NoType {
+
+        public JCVoidType() {
+            super(null);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return VOID;
+        }
+
+        @Override
+        public TypeKind getKind() {
+            return TypeKind.VOID;
+        }
+
+        @Override
+        public <R, P> R accept(TypeVisitor<R, P> v, P p) {
+            return v.visitNoType(this, p);
+        }
+
+        @Override
+        public boolean isPrimitiveOrVoid() {
+            return true;
+        }
+    }
+
     static class BottomType extends Type implements NullType {
         public BottomType() {
-            super(TypeTags.BOT, null);
+            super(null);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return BOT;
         }
 
         @Override
@@ -1300,6 +1722,12 @@ public class Type implements PrimitiveType {
         public String stringValue() {
             return "null";
         }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
     }
 
     public static class ErrorType extends ClassType
@@ -1317,7 +1745,6 @@ public class Type implements PrimitiveType {
 
         public ErrorType(Type originalType, TypeSymbol tsym, boolean modifyClassSym) {
             super(noType, List.<Type>nil(), tsym);
-            tag = ERROR;
             this.originalType = (originalType == null ? noType : originalType);
             if (modifyClassSym && tsym instanceof ClassSymbol) {
                 ClassSymbol c = (ClassSymbol)tsym;
@@ -1327,6 +1754,26 @@ public class Type implements PrimitiveType {
             }
         }
 
+        @Override
+        public TypeTag getTag() {
+            return ERROR;
+        }
+
+        @Override
+        public boolean isPartial() {
+            return true;
+        }
+
+        @Override
+        public boolean isReference() {
+            return true;
+        }
+
+        @Override
+        public boolean isNullOrReference() {
+            return true;
+        }
+
         public ErrorType(Name name, Symbol container, Type originalType) {
             this(new ClassSymbol(PUBLIC|STATIC|ACYCLIC, name, null, container), originalType);
         }
@@ -1337,7 +1784,7 @@ public class Type implements PrimitiveType {
         }
 
         public Type constType(Object constValue) { return this; }
-        public Type getEnclosingType()          { return this; }
+        public Type getEnclosingType()           { return this; }
         public Type getReturnType()              { return this; }
         public Type asSub(Symbol sym)            { return this; }
         public Type map(Mapping f)               { return this; }
@@ -1372,11 +1819,222 @@ public class Type implements PrimitiveType {
         }
     }
 
+    public static class AnnotatedType extends Type
+            implements
+                javax.lang.model.type.ArrayType,
+                javax.lang.model.type.DeclaredType,
+                javax.lang.model.type.PrimitiveType,
+                javax.lang.model.type.TypeVariable,
+                javax.lang.model.type.WildcardType {
+        /** The type annotations on this type.
+         */
+        public List<Attribute.TypeCompound> typeAnnotations;
+
+        /** The underlying type that is annotated.
+         */
+        public Type underlyingType;
+
+        public AnnotatedType(Type underlyingType) {
+            super(underlyingType.tsym);
+            this.typeAnnotations = List.nil();
+            this.underlyingType = underlyingType;
+            Assert.check(!underlyingType.isAnnotated(),
+                    "Can't annotate already annotated type: " + underlyingType);
+        }
+
+        public AnnotatedType(List<Attribute.TypeCompound> typeAnnotations,
+                Type underlyingType) {
+            super(underlyingType.tsym);
+            this.typeAnnotations = typeAnnotations;
+            this.underlyingType = underlyingType;
+            Assert.check(!underlyingType.isAnnotated(),
+                    "Can't annotate already annotated type: " + underlyingType +
+                    "; adding: " + typeAnnotations);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return underlyingType.getTag();
+        }
+
+        @Override
+        public boolean isAnnotated() {
+            return true;
+        }
+
+        @Override
+        public List<? extends Attribute.TypeCompound> getAnnotationMirrors() {
+            return typeAnnotations;
+        }
+
+        @Override
+        public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+            return JavacAnnoConstructs.getAnnotation(this, annotationType);
+        }
+
+        @Override
+        public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
+            return JavacAnnoConstructs.getAnnotationsByType(this, annotationType);
+        }
+
+        @Override
+        public TypeKind getKind() {
+            return underlyingType.getKind();
+        }
+
+        @Override
+        public Type unannotatedType() {
+            return underlyingType;
+        }
+
+        @Override
+        public <R,S> R accept(Type.Visitor<R,S> v, S s) {
+            return v.visitAnnotatedType(this, s);
+        }
+
+        @Override
+        public <R, P> R accept(TypeVisitor<R, P> v, P p) {
+            return underlyingType.accept(v, p);
+        }
+
+        @Override
+        public Type map(Mapping f) {
+            underlyingType.map(f);
+            return this;
+        }
+
+        @Override
+        public Type constType(Object constValue) { return underlyingType.constType(constValue); }
+        @Override
+        public Type getEnclosingType()           { return underlyingType.getEnclosingType(); }
+
+        @Override
+        public Type getReturnType()              { return underlyingType.getReturnType(); }
+        @Override
+        public List<Type> getTypeArguments()     { return underlyingType.getTypeArguments(); }
+        @Override
+        public List<Type> getParameterTypes()    { return underlyingType.getParameterTypes(); }
+        @Override
+        public Type getReceiverType()            { return underlyingType.getReceiverType(); }
+        @Override
+        public List<Type> getThrownTypes()       { return underlyingType.getThrownTypes(); }
+        @Override
+        public Type getUpperBound()              { return underlyingType.getUpperBound(); }
+        @Override
+        public Type getLowerBound()              { return underlyingType.getLowerBound(); }
+
+        @Override
+        public boolean isErroneous()             { return underlyingType.isErroneous(); }
+        @Override
+        public boolean isCompound()              { return underlyingType.isCompound(); }
+        @Override
+        public boolean isInterface()             { return underlyingType.isInterface(); }
+        @Override
+        public List<Type> allparams()            { return underlyingType.allparams(); }
+        @Override
+        public boolean isPrimitive()             { return underlyingType.isPrimitive(); }
+        @Override
+        public boolean isPrimitiveOrVoid()       { return underlyingType.isPrimitiveOrVoid(); }
+        @Override
+        public boolean isNumeric()               { return underlyingType.isNumeric(); }
+        @Override
+        public boolean isReference()             { return underlyingType.isReference(); }
+        @Override
+        public boolean isNullOrReference()       { return underlyingType.isNullOrReference(); }
+        @Override
+        public boolean isPartial()               { return underlyingType.isPartial(); }
+        @Override
+        public boolean isParameterized()         { return underlyingType.isParameterized(); }
+        @Override
+        public boolean isRaw()                   { return underlyingType.isRaw(); }
+        @Override
+        public boolean isFinal()                 { return underlyingType.isFinal(); }
+        @Override
+        public boolean isSuperBound()            { return underlyingType.isSuperBound(); }
+        @Override
+        public boolean isExtendsBound()          { return underlyingType.isExtendsBound(); }
+        @Override
+        public boolean isUnbound()               { return underlyingType.isUnbound(); }
+
+        @Override
+        public String toString() {
+            // 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() + ")";
+            } else {
+                return "({} :: " + underlyingType.toString() +")";
+            }
+        }
+
+        @Override
+        public boolean contains(Type t)          { return underlyingType.contains(t); }
+
+        @Override
+        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
+        public TypeSymbol asElement()            { return underlyingType.asElement(); }
+
+        // TODO: attach annotations?
+        @Override
+        public MethodType asMethodType()         { return underlyingType.asMethodType(); }
+
+        @Override
+        public void complete()                   { underlyingType.complete(); }
+
+        @Override
+        public TypeMirror getComponentType()     { return ((ArrayType)underlyingType).getComponentType(); }
+
+        // The result is an ArrayType, but only in the model sense, not the Type sense.
+        public AnnotatedType makeVarargs() {
+            AnnotatedType atype = new AnnotatedType(((ArrayType)underlyingType).makeVarargs());
+            atype.typeAnnotations = this.typeAnnotations;
+            return atype;
+        }
+
+        @Override
+        public TypeMirror getExtendsBound()      { return ((WildcardType)underlyingType).getExtendsBound(); }
+        @Override
+        public TypeMirror getSuperBound()        { return ((WildcardType)underlyingType).getSuperBound(); }
+    }
+
+    public static class UnknownType extends Type {
+
+        public UnknownType() {
+            super(null);
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return UNKNOWN;
+        }
+
+        @Override
+        public <R, P> R accept(TypeVisitor<R, P> v, P p) {
+            return v.visitUnknown(this, p);
+        }
+
+        @Override
+        public boolean isPartial() {
+            return true;
+        }
+    }
+
     /**
      * A visitor for types.  A visitor is used to implement operations
      * (or relations) on types.  Most common operations on types are
      * binary relations and this interface is designed for binary
-     * relations, that is, operations on the form
+     * relations, that is, operations of the form
      * Type × S → R.
      * <!-- In plain text: Type x S -> R -->
      *
@@ -1397,6 +2055,7 @@ public class Type implements PrimitiveType {
         R visitForAll(ForAll t, S s);
         R visitUndetVar(UndetVar t, S s);
         R visitErrorType(ErrorType t, S s);
+        R visitAnnotatedType(AnnotatedType t, S s);
         R visitType(Type t, S s);
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java b/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java
index c3fba38..89f6ea4 100644
--- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java
@@ -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
@@ -25,6 +25,9 @@
 
 package com.sun.tools.javac.code;
 
+import java.util.Iterator;
+
+import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.util.*;
 
 /** A type annotation position.
@@ -34,17 +37,98 @@ import com.sun.tools.javac.util.*;
 *  This code and its internal interfaces are subject to change or
 *  deletion without notice.</b>
 */
+// Code duplicated in com.sun.tools.classfile.TypeAnnotation.Position
 public class TypeAnnotationPosition {
 
+    public enum TypePathEntryKind {
+        ARRAY(0),
+        INNER_TYPE(1),
+        WILDCARD(2),
+        TYPE_ARGUMENT(3);
+
+        public final int tag;
+
+        private TypePathEntryKind(int tag) {
+            this.tag = tag;
+        }
+    }
+
+    public static class TypePathEntry {
+        /** The fixed number of bytes per TypePathEntry. */
+        public static final int bytesPerEntry = 2;
+
+        public final TypePathEntryKind tag;
+        public final int arg;
+
+        public static final TypePathEntry ARRAY = new TypePathEntry(TypePathEntryKind.ARRAY);
+        public static final TypePathEntry INNER_TYPE = new TypePathEntry(TypePathEntryKind.INNER_TYPE);
+        public static final TypePathEntry WILDCARD = new TypePathEntry(TypePathEntryKind.WILDCARD);
+
+        private TypePathEntry(TypePathEntryKind tag) {
+            Assert.check(tag == TypePathEntryKind.ARRAY ||
+                    tag == TypePathEntryKind.INNER_TYPE ||
+                    tag == TypePathEntryKind.WILDCARD,
+                    "Invalid TypePathEntryKind: " + tag);
+            this.tag = tag;
+            this.arg = 0;
+        }
+
+        public TypePathEntry(TypePathEntryKind tag, int arg) {
+            Assert.check(tag == TypePathEntryKind.TYPE_ARGUMENT,
+                    "Invalid TypePathEntryKind: " + tag);
+            this.tag = tag;
+            this.arg = arg;
+        }
+
+        public static TypePathEntry fromBinary(int tag, int arg) {
+            Assert.check(arg == 0 || tag == TypePathEntryKind.TYPE_ARGUMENT.tag,
+                    "Invalid TypePathEntry tag/arg: " + tag + "/" + arg);
+            switch (tag) {
+            case 0:
+                return ARRAY;
+            case 1:
+                return INNER_TYPE;
+            case 2:
+                return WILDCARD;
+            case 3:
+                return new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg);
+            default:
+                Assert.error("Invalid TypePathEntryKind tag: " + tag);
+                return null;
+            }
+        }
+
+        @Override
+        public String toString() {
+            return tag.toString() +
+                    (tag == TypePathEntryKind.TYPE_ARGUMENT ? ("(" + arg + ")") : "");
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (! (other instanceof TypePathEntry)) {
+                return false;
+            }
+            TypePathEntry tpe = (TypePathEntry) other;
+            return this.tag == tpe.tag && this.arg == tpe.arg;
+        }
+
+        @Override
+        public int hashCode() {
+            return this.tag.hashCode() * 17 + this.arg;
+        }
+    }
+
     public TargetType type = TargetType.UNKNOWN;
 
     // For generic/array types.
-    public List<Integer> location = List.nil();
+    public List<TypePathEntry> location = List.nil();
 
     // Tree position.
     public int pos = -1;
 
-    // For typecasts, type tests, new (and locals, as start_pc).
+    // For type casts, type tests, new, locals (as start_pc),
+    // and method and constructor reference type arguments.
     public boolean isValidOffset = false;
     public int offset = -1;
 
@@ -59,11 +143,22 @@ public class TypeAnnotationPosition {
     // For type parameter and method parameter
     public int parameter_index = Integer.MIN_VALUE;
 
-    // For class extends, implements, and throws classes
+    // For class extends, implements, and throws clauses
     public int type_index = Integer.MIN_VALUE;
 
-    // For wildcards
-    public TypeAnnotationPosition wildcard_position = null;
+    // 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
     public String toString() {
@@ -72,27 +167,28 @@ public class TypeAnnotationPosition {
         sb.append(type);
 
         switch (type) {
-        // type case
-        case TYPECAST:
-        case TYPECAST_GENERIC_OR_ARRAY:
-            // object creation
+        // instanceof
         case INSTANCEOF:
-        case INSTANCEOF_GENERIC_OR_ARRAY:
-            // new expression
+        // new expression
         case NEW:
-        case NEW_GENERIC_OR_ARRAY:
-        case NEW_TYPE_ARGUMENT:
-        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
             sb.append(", offset = ");
             sb.append(offset);
             break;
-            // local variable
+        // local variable
         case LOCAL_VARIABLE:
-        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            if (lvarOffset == null) {
+                sb.append(", lvarOffset is null!");
+                break;
+            }
             sb.append(", {");
             for (int i = 0; i < lvarOffset.length; ++i) {
                 if (i != 0) sb.append("; ");
-                sb.append(", start_pc = ");
+                sb.append("start_pc = ");
                 sb.append(lvarOffset[i]);
                 sb.append(", length = ");
                 sb.append(lvarLength[i]);
@@ -101,73 +197,69 @@ public class TypeAnnotationPosition {
             }
             sb.append("}");
             break;
-            // method receiver
+        // method receiver
         case METHOD_RECEIVER:
             // Do nothing
             break;
-            // type parameters
+        // type parameter
         case CLASS_TYPE_PARAMETER:
         case METHOD_TYPE_PARAMETER:
             sb.append(", param_index = ");
             sb.append(parameter_index);
             break;
-            // type parameters bound
+        // type parameter bound
         case CLASS_TYPE_PARAMETER_BOUND:
-        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
         case METHOD_TYPE_PARAMETER_BOUND:
-        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
             sb.append(", param_index = ");
             sb.append(parameter_index);
             sb.append(", bound_index = ");
             sb.append(bound_index);
             break;
-            // wildcard
-        case WILDCARD_BOUND:
-        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
-            sb.append(", wild_card = ");
-            sb.append(wildcard_position);
-            break;
-            // Class extends and implements clauses
+        // class extends or implements clause
         case CLASS_EXTENDS:
-        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
             sb.append(", type_index = ");
             sb.append(type_index);
             break;
-            // throws
+        // throws
         case THROWS:
             sb.append(", type_index = ");
             sb.append(type_index);
             break;
-        case CLASS_LITERAL:
-        case CLASS_LITERAL_GENERIC_OR_ARRAY:
-            sb.append(", offset = ");
-            sb.append(offset);
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            sb.append(", exception_index = ");
+            sb.append(exception_index);
             break;
-            // method parameter: not specified
-        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
             sb.append(", param_index = ");
             sb.append(parameter_index);
             break;
-            // method type argument: wasn't specified
-        case METHOD_TYPE_ARGUMENT:
-        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
             sb.append(", offset = ");
             sb.append(offset);
             sb.append(", type_index = ");
             sb.append(type_index);
             break;
-            // We don't need to worry abut these
-        case METHOD_RETURN_GENERIC_OR_ARRAY:
-        case FIELD_GENERIC_OR_ARRAY:
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
             break;
         case UNKNOWN:
+            sb.append(", position UNKNOWN!");
             break;
         default:
-            //                throw new AssertionError("unknown type: " + type);
+            Assert.error("Unknown target type: " + type);
         }
 
         // Append location data for generics/arrays.
-        if (type.hasLocation()) {
+        if (!location.isEmpty()) {
             sb.append(", location = (");
             sb.append(location);
             sb.append(")");
@@ -176,6 +268,11 @@ public class TypeAnnotationPosition {
         sb.append(", pos = ");
         sb.append(pos);
 
+        if (onLambda != null) {
+            sb.append(", onLambda hash = ");
+            sb.append(onLambda.hashCode());
+        }
+
         sb.append(']');
         return sb.toString();
     }
@@ -186,10 +283,44 @@ public class TypeAnnotationPosition {
      * @return true if the target has not been optimized away
      */
     public boolean emitToClassfile() {
-        if (type == TargetType.WILDCARD_BOUND
-            || type == TargetType.WILDCARD_BOUND_GENERIC_OR_ARRAY)
-            return wildcard_position.isValidOffset;
-        else
-            return !type.isLocal() || isValidOffset;
+        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.
+     *
+     * @param list The bytecode representation of the type path.
+     */
+    public static List<TypePathEntry> getTypePathFromBinary(java.util.List<Integer> list) {
+        ListBuffer<TypePathEntry> loc = ListBuffer.lb();
+        Iterator<Integer> iter = list.iterator();
+        while (iter.hasNext()) {
+            Integer fst = iter.next();
+            Assert.check(iter.hasNext(), "Could not decode type path: " + list);
+            Integer snd = iter.next();
+            loc = loc.append(TypePathEntry.fromBinary(fst, snd));
+        }
+        return loc.toList();
+    }
+
+    public static List<Integer> getBinaryFromTypePath(java.util.List<TypePathEntry> locs) {
+        ListBuffer<Integer> loc = ListBuffer.lb();
+        for (TypePathEntry tpe : locs) {
+            loc = loc.append(tpe.tag.tag);
+            loc = loc.append(tpe.arg);
+        }
+        return loc.toList();
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
new file mode 100644
index 0000000..d26e8cc
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
@@ -0,0 +1,1288 @@
+/*
+ * 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.  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.code;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.type.TypeKind;
+
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Type.AnnotatedType;
+import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.code.Type.CapturedType;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.Type.ErrorType;
+import com.sun.tools.javac.code.Type.ForAll;
+import com.sun.tools.javac.code.Type.MethodType;
+import com.sun.tools.javac.code.Type.PackageType;
+import com.sun.tools.javac.code.Type.TypeVar;
+import com.sun.tools.javac.code.Type.UndetVar;
+import com.sun.tools.javac.code.Type.Visitor;
+import com.sun.tools.javac.code.Type.WildcardType;
+import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry;
+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;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
+
+/**
+ * Contains operations specific to processing type annotations.
+ * This class has two functions:
+ * separate declaration from type annotations and insert the type
+ * annotations to their types;
+ * and determine the TypeAnnotationPositions for all type annotations.
+ */
+public class TypeAnnotations {
+    // Class cannot be instantiated.
+    private TypeAnnotations() {}
+
+    /**
+     * Separate type annotations from declaration annotations and
+     * determine the correct positions for type annotations.
+     * This version only visits types in signatures and should be
+     * called from MemberEnter.
+     * The method takes the Annotate object as parameter and
+     * adds an Annotator to the correct Annotate queue for
+     * later processing.
+     */
+    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);
+            }
+        } );
+    }
+
+    /**
+     * This version only visits types in bodies, that is, field initializers,
+     * top-level blocks, and method bodies, and should be called from Attr.
+     */
+    public static void organizeTypeAnnotationsBodies(Symtab syms, Names names, Log log, JCClassDecl tree) {
+        new TypeAnnotationPositions(syms, names, log, false).scan(tree);
+    }
+
+    public 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) {
+        if (a == null) return AnnotationType.BOTH;
+        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 == null) {
+            return inferTargetMetaInfo(a, s);
+        }
+        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;
+        private final Log log;
+        private final boolean sigOnly;
+
+        private TypeAnnotationPositions(Symtab syms, Names names, Log log, boolean sigOnly) {
+            this.syms = syms;
+            this.names = names;
+            this.log = log;
+            this.sigOnly = sigOnly;
+        }
+
+        /*
+         * When traversing the AST we keep the "frames" of visited
+         * trees in order to determine the position of annotations.
+         */
+        private ListBuffer<JCTree> frames = ListBuffer.lb();
+
+        protected void push(JCTree t) { frames = frames.prepend(t); }
+        protected JCTree pop() { return frames.next(); }
+        // could this be frames.elems.tail.head?
+        private JCTree peek2() { return frames.toList().tail.head; }
+
+        @Override
+        public void scan(JCTree tree) {
+            push(tree);
+            super.scan(tree);
+            pop();
+        }
+
+        /**
+         * Separates type annotations from declaration annotations.
+         * This step is needed because in certain locations (where declaration
+         * and type annotations can be mixed, e.g. the type of a field)
+         * we never build an JCAnnotatedType. This step finds these
+         * annotations and marks them as if they were part of the type.
+         */
+        private void separateAnnotationsKinds(JCTree typetree, Type type, Symbol sym,
+                TypeAnnotationPosition pos) {
+            /*
+            System.out.printf("separateAnnotationsKinds(typetree: %s, type: %s, symbol: %s, pos: %s%n",
+                    typetree, type, sym, pos);
+            */
+            List<Attribute.Compound> annotations = sym.getRawAttributes();
+            ListBuffer<Attribute.Compound> declAnnos = new ListBuffer<Attribute.Compound>();
+            ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<Attribute.TypeCompound>();
+
+            for (Attribute.Compound a : annotations) {
+                switch (annotationType(syms, names, a, sym)) {
+                case DECLARATION:
+                    declAnnos.append(a);
+                    break;
+                case BOTH: {
+                    declAnnos.append(a);
+                    Attribute.TypeCompound ta = toTypeCompound(a, pos);
+                    typeAnnos.append(ta);
+                    break;
+                }
+                case TYPE: {
+                    Attribute.TypeCompound ta = toTypeCompound(a, pos);
+                    typeAnnos.append(ta);
+                    break;
+                }
+                }
+            }
+
+            sym.resetAnnotations();
+            sym.setDeclarationAttributes(declAnnos.toList());
+
+            if (typeAnnos.isEmpty()) {
+                return;
+            }
+
+            List<Attribute.TypeCompound> typeAnnotations = typeAnnos.toList();
+
+            if (type == null) {
+                // When type is null, put the type annotations to the symbol.
+                // This is used for constructor return annotations, for which
+                // no appropriate type exists.
+                sym.appendUniqueTypeAttributes(typeAnnotations);
+                return;
+            }
+
+            // type is non-null and annotations are added to that type
+            type = typeWithAnnotations(typetree, type, typeAnnotations, log);
+
+            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.appendUniqueTypeAttributes(typeAnnotations);
+
+            if (sym.getKind() == ElementKind.PARAMETER ||
+                    sym.getKind() == ElementKind.LOCAL_VARIABLE ||
+                    sym.getKind() == ElementKind.RESOURCE_VARIABLE ||
+                    sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
+                // Make sure all type annotations from the symbol are also
+                // on the owner.
+                sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes());
+            }
+        }
+
+        // This method has a similar purpose as
+        // {@link com.sun.tools.javac.parser.JavacParser.insertAnnotationsToMostInner(JCExpression, List<JCTypeAnnotation>, boolean)}
+        // We found a type annotation in a declaration annotation position,
+        // for example, on the return type.
+        // Such an annotation is _not_ part of an JCAnnotatedType tree and we therefore
+        // need to set its position explicitly.
+        // The method returns a copy of type that contains these annotations.
+        //
+        // As a side effect the method sets the type annotation position of "annotations".
+        // Note that it is assumed that all annotations share the same position.
+        private static Type typeWithAnnotations(final JCTree typetree, final Type type,
+                final List<Attribute.TypeCompound> annotations, Log log) {
+            // System.out.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s)%n",
+            //         typetree, type, annotations);
+            if (annotations.isEmpty()) {
+                return type;
+            }
+            if (type.hasTag(TypeTag.ARRAY)) {
+                Type toreturn;
+                Type.ArrayType tomodify;
+                Type.ArrayType arType;
+                {
+                    Type touse = type;
+                    if (type.isAnnotated()) {
+                        Type.AnnotatedType atype = (Type.AnnotatedType)type;
+                        toreturn = new Type.AnnotatedType(atype.underlyingType);
+                        ((Type.AnnotatedType)toreturn).typeAnnotations = atype.typeAnnotations;
+                        touse = atype.underlyingType;
+                        arType = (Type.ArrayType) touse;
+                        tomodify = new Type.ArrayType(null, arType.tsym);
+                        ((Type.AnnotatedType)toreturn).underlyingType = tomodify;
+                    } else {
+                        arType = (Type.ArrayType) touse;
+                        tomodify = new Type.ArrayType(null, arType.tsym);
+                        toreturn = tomodify;
+                    }
+                }
+                JCArrayTypeTree arTree = arrayTypeTree(typetree);
+
+                ListBuffer<TypePathEntry> depth = ListBuffer.lb();
+                depth = depth.append(TypePathEntry.ARRAY);
+                while (arType.elemtype.hasTag(TypeTag.ARRAY)) {
+                    if (arType.elemtype.isAnnotated()) {
+                        Type.AnnotatedType aelemtype = (Type.AnnotatedType) arType.elemtype;
+                        Type.AnnotatedType newAT = new Type.AnnotatedType(aelemtype.underlyingType);
+                        tomodify.elemtype = newAT;
+                        newAT.typeAnnotations = aelemtype.typeAnnotations;
+                        arType = (Type.ArrayType) aelemtype.underlyingType;
+                        tomodify = new Type.ArrayType(null, arType.tsym);
+                        newAT.underlyingType = tomodify;
+                    } else {
+                        arType = (Type.ArrayType) arType.elemtype;
+                        tomodify.elemtype = new Type.ArrayType(null, arType.tsym);
+                        tomodify = (Type.ArrayType) tomodify.elemtype;
+                    }
+                    arTree = arrayTypeTree(arTree.elemtype);
+                    depth = depth.append(TypePathEntry.ARRAY);
+                }
+                Type arelemType = typeWithAnnotations(arTree.elemtype, arType.elemtype, annotations, log);
+                tomodify.elemtype = arelemType;
+                {
+                    // All annotations share the same position; modify the first one.
+                    Attribute.TypeCompound a = annotations.get(0);
+                    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();
+                JCTree enclTr = typetree;
+
+                while (enclEl != null &&
+                        enclEl.getKind() != ElementKind.PACKAGE &&
+                        enclTy != null &&
+                        enclTy.getKind() != TypeKind.NONE &&
+                        enclTy.getKind() != TypeKind.ERROR &&
+                        (enclTr.getKind() == JCTree.Kind.MEMBER_SELECT ||
+                         enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE ||
+                         enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) {
+                    // Iterate also over the type tree, not just the type: the type is already
+                    // completely resolved and we cannot distinguish where the annotation
+                    // belongs for a nested type.
+                    if (enclTr.getKind() == JCTree.Kind.MEMBER_SELECT) {
+                        // only change encl in this case.
+                        enclTy = enclTy.getEnclosingType();
+                        enclEl = enclEl.getEnclosingElement();
+                        enclTr = ((JCFieldAccess)enclTr).getExpression();
+                    } else if (enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE) {
+                        enclTr = ((JCTypeApply)enclTr).getType();
+                    } else {
+                        // only other option because of while condition
+                        enclTr = ((JCAnnotatedType)enclTr).getUnderlyingType();
+                    }
+                }
+
+                /** We are trying to annotate some enclosing type,
+                 * but nothing more exists.
+                 */
+                if (enclTy != null &&
+                        enclTy.getKind() == TypeKind.NONE &&
+                        (enclTr.getKind() == JCTree.Kind.IDENTIFIER ||
+                         enclTr.getKind() == JCTree.Kind.MEMBER_SELECT ||
+                         enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE ||
+                         enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) {
+                    // TODO: also if it's "java. @A lang.Object", that is,
+                    // if it's on a package?
+                    log.error(enclTr.pos(), "cant.annotate.nested.type", enclTr.toString());
+                    return type;
+                }
+
+                // At this point we have visited the part of the nested
+                // type that is written in the source code.
+                // Now count from here to the actual top-level class to determine
+                // the correct nesting.
+
+                // The genericLocation for the annotation.
+                ListBuffer<TypePathEntry> depth = ListBuffer.lb();
+
+                Type topTy = enclTy;
+                while (enclEl != null &&
+                        enclEl.getKind() != ElementKind.PACKAGE &&
+                        topTy != null &&
+                        topTy.getKind() != TypeKind.NONE &&
+                        topTy.getKind() != TypeKind.ERROR) {
+                    topTy = topTy.getEnclosingType();
+                    enclEl = enclEl.getEnclosingElement();
+
+                    if (topTy != null && topTy.getKind() != TypeKind.NONE) {
+                        // Only count enclosing types.
+                        depth = depth.append(TypePathEntry.INNER_TYPE);
+                    }
+                }
+
+                if (depth.nonEmpty()) {
+                    // Only need to change the annotation positions
+                    // if they are on an enclosed type.
+                    // All annotations share the same position; modify the first one.
+                    Attribute.TypeCompound a = annotations.get(0);
+                    TypeAnnotationPosition p = a.position;
+                    p.location = p.location.appendList(depth.toList());
+                }
+
+                Type ret = typeWithAnnotations(type, enclTy, annotations);
+                typetree.type = ret;
+                return ret;
+            }
+        }
+
+        private static JCArrayTypeTree arrayTypeTree(JCTree typetree) {
+            if (typetree.getKind() == JCTree.Kind.ARRAY_TYPE) {
+                return (JCArrayTypeTree) typetree;
+            } else if (typetree.getKind() == JCTree.Kind.ANNOTATED_TYPE) {
+                return (JCArrayTypeTree) ((JCAnnotatedType)typetree).underlyingType;
+            } else {
+                Assert.error("Could not determine array type from type tree: " + typetree);
+                return null;
+            }
+        }
+
+        /** Return a copy of the first type that only differs by
+         * inserting the annotations to the left-most/inner-most type
+         * or the type given by stopAt.
+         *
+         * We need the stopAt parameter to know where on a type to
+         * put the annotations.
+         * If we have nested classes Outer > Middle > Inner, and we
+         * have the source type "@A Middle.Inner", we will invoke
+         * this method with type = Outer.Middle.Inner,
+         * stopAt = Middle.Inner, and annotations = @A.
+         *
+         * @param type The type to copy.
+         * @param stopAt The type to stop at.
+         * @param annotations The annotations to insert.
+         * @return A copy of type that contains the annotations.
+         */
+        private static Type typeWithAnnotations(final Type type,
+                final Type stopAt,
+                final List<Attribute.TypeCompound> annotations) {
+            Visitor<Type, List<TypeCompound>> visitor =
+                    new Type.Visitor<Type, List<Attribute.TypeCompound>>() {
+                @Override
+                public Type visitClassType(ClassType t, List<TypeCompound> s) {
+                    // assert that t.constValue() == null?
+                    if (t == stopAt ||
+                        t.getEnclosingType() == Type.noType) {
+                        return new AnnotatedType(s, t);
+                    } else {
+                        ClassType ret = new ClassType(t.getEnclosingType().accept(this, s),
+                                t.typarams_field, t.tsym);
+                        ret.all_interfaces_field = t.all_interfaces_field;
+                        ret.allparams_field = t.allparams_field;
+                        ret.interfaces_field = t.interfaces_field;
+                        ret.rank_field = t.rank_field;
+                        ret.supertype_field = t.supertype_field;
+                        return ret;
+                    }
+                }
+
+                @Override
+                public Type visitAnnotatedType(AnnotatedType t, List<TypeCompound> s) {
+                    return new AnnotatedType(t.typeAnnotations, t.underlyingType.accept(this, s));
+                }
+
+                @Override
+                public Type visitWildcardType(WildcardType t, List<TypeCompound> s) {
+                    return new AnnotatedType(s, t);
+                }
+
+                @Override
+                public Type visitArrayType(ArrayType t, List<TypeCompound> s) {
+                    ArrayType ret = new ArrayType(t.elemtype.accept(this, s), t.tsym);
+                    return ret;
+                }
+
+                @Override
+                public Type visitMethodType(MethodType t, List<TypeCompound> s) {
+                    // Impossible?
+                    return t;
+                }
+
+                @Override
+                public Type visitPackageType(PackageType t, List<TypeCompound> s) {
+                    // Impossible?
+                    return t;
+                }
+
+                @Override
+                public Type visitTypeVar(TypeVar t, List<TypeCompound> s) {
+                    return new AnnotatedType(s, t);
+                }
+
+                @Override
+                public Type visitCapturedType(CapturedType t, List<TypeCompound> s) {
+                    return new AnnotatedType(s, t);
+                }
+
+                @Override
+                public Type visitForAll(ForAll t, List<TypeCompound> s) {
+                    // Impossible?
+                    return t;
+                }
+
+                @Override
+                public Type visitUndetVar(UndetVar t, List<TypeCompound> s) {
+                    // Impossible?
+                    return t;
+                }
+
+                @Override
+                public Type visitErrorType(ErrorType t, List<TypeCompound> s) {
+                    return new AnnotatedType(s, t);
+                }
+
+                @Override
+                public Type visitType(Type t, List<TypeCompound> s) {
+                    return new AnnotatedType(s, t);
+                }
+            };
+
+            return type.accept(visitor, annotations);
+        }
+
+        private static Attribute.TypeCompound toTypeCompound(Attribute.Compound a, TypeAnnotationPosition p) {
+            // It is safe to alias the position.
+            return new Attribute.TypeCompound(a, p);
+        }
+
+
+        /* This is the beginning of the second part of organizing
+         * type annotations: determine the type annotation positions.
+         */
+
+        private void resolveFrame(JCTree tree, JCTree frame,
+                List<JCTree> path, TypeAnnotationPosition p) {
+            /*
+            System.out.println("Resolving tree: " + tree + " kind: " + tree.getKind());
+            System.out.println("    Framing tree: " + frame + " kind: " + frame.getKind());
+            */
+
+            // Note that p.offset is set in
+            // com.sun.tools.javac.jvm.Gen.setTypeAnnotationPositions(int)
+
+            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;
+
+                case INSTANCE_OF:
+                    p.type = TargetType.INSTANCEOF;
+                    p.pos = frame.pos;
+                    return;
+
+                case NEW_CLASS:
+                    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 {
+                        p.type = TargetType.NEW;
+                    }
+                    p.pos = frame.pos;
+                    return;
+
+                case NEW_ARRAY:
+                    p.type = TargetType.NEW;
+                    p.pos = frame.pos;
+                    return;
+
+                case ANNOTATION_TYPE:
+                case CLASS:
+                case ENUM:
+                case INTERFACE:
+                    p.pos = frame.pos;
+                    if (((JCClassDecl)frame).extending == tree) {
+                        p.type = TargetType.CLASS_EXTENDS;
+                        p.type_index = -1;
+                    } else if (((JCClassDecl)frame).implementing.contains(tree)) {
+                        p.type = TargetType.CLASS_EXTENDS;
+                        p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree);
+                    } else if (((JCClassDecl)frame).typarams.contains(tree)) {
+                        p.type = TargetType.CLASS_TYPE_PARAMETER;
+                        p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree);
+                    } else {
+                        Assert.error("Could not determine position of tree " + tree +
+                                " within frame " + frame);
+                    }
+                    return;
+
+                case METHOD: {
+                    JCMethodDecl frameMethod = (JCMethodDecl) frame;
+                    p.pos = frame.pos;
+                    if (frameMethod.thrown.contains(tree)) {
+                        p.type = TargetType.THROWS;
+                        p.type_index = frameMethod.thrown.indexOf(tree);
+                    } else if (frameMethod.restype == tree) {
+                        p.type = TargetType.METHOD_RETURN;
+                    } else if (frameMethod.typarams.contains(tree)) {
+                        p.type = TargetType.METHOD_TYPE_PARAMETER;
+                        p.parameter_index = frameMethod.typarams.indexOf(tree);
+                    } else {
+                        Assert.error("Could not determine position of tree " + tree +
+                                " within frame " + frame);
+                    }
+                    return;
+                }
+
+                case PARAMETERIZED_TYPE: {
+                    List<JCTree> newPath = path.tail;
+
+                    if (((JCTypeApply)frame).clazz == tree) {
+                        // generic: RAW; noop
+                    } else if (((JCTypeApply)frame).arguments.contains(tree)) {
+                        JCTypeApply taframe = (JCTypeApply) frame;
+                        int arg = taframe.arguments.indexOf(tree);
+                        p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg));
+
+                        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);
+                    }
+
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case MEMBER_REFERENCE: {
+                    JCMemberReference mrframe = (JCMemberReference) frame;
+
+                    if (mrframe.expr == tree) {
+                        switch (mrframe.mode) {
+                        case INVOKE:
+                            p.type = TargetType.METHOD_REFERENCE;
+                            break;
+                        case NEW:
+                            p.type = TargetType.CONSTRUCTOR_REFERENCE;
+                            break;
+                        default:
+                            Assert.error("Unknown method reference mode " + mrframe.mode +
+                                    " for tree " + tree + " within frame " + frame);
+                        }
+                        p.pos = frame.pos;
+                    } else if (mrframe.typeargs != null &&
+                            mrframe.typeargs.contains(tree)) {
+                        int arg = mrframe.typeargs.indexOf(tree);
+                        p.type_index = arg;
+                        switch (mrframe.mode) {
+                        case INVOKE:
+                            p.type = TargetType.METHOD_REFERENCE_TYPE_ARGUMENT;
+                            break;
+                        case NEW:
+                            p.type = TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT;
+                            break;
+                        default:
+                            Assert.error("Unknown method reference mode " + mrframe.mode +
+                                    " for tree " + tree + " within frame " + frame);
+                        }
+                        p.pos = frame.pos;
+                    } else {
+                        Assert.error("Could not determine type argument position of tree " + tree +
+                                " within frame " + frame);
+                    }
+                    return;
+                }
+
+                case ARRAY_TYPE: {
+                    ListBuffer<TypePathEntry> index = ListBuffer.lb();
+                    index = index.append(TypePathEntry.ARRAY);
+                    List<JCTree> newPath = path.tail;
+                    while (true) {
+                        JCTree npHead = newPath.tail.head;
+                        if (npHead.hasTag(JCTree.Tag.TYPEARRAY)) {
+                            newPath = newPath.tail;
+                            index = index.append(TypePathEntry.ARRAY);
+                        } else if (npHead.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
+                            newPath = newPath.tail;
+                        } else {
+                            break;
+                        }
+                    }
+                    p.location = p.location.prependList(index.toList());
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case TYPE_PARAMETER:
+                    if (path.tail.tail.head.hasTag(JCTree.Tag.CLASSDEF)) {
+                        JCClassDecl clazz = (JCClassDecl)path.tail.tail.head;
+                        p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND;
+                        p.parameter_index = clazz.typarams.indexOf(path.tail.head);
+                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
+                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
+                            // Account for an implicit Object as bound 0
+                            p.bound_index += 1;
+                        }
+                    } else if (path.tail.tail.head.hasTag(JCTree.Tag.METHODDEF)) {
+                        JCMethodDecl method = (JCMethodDecl)path.tail.tail.head;
+                        p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND;
+                        p.parameter_index = method.typarams.indexOf(path.tail.head);
+                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
+                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
+                            // Account for an implicit Object as bound 0
+                            p.bound_index += 1;
+                        }
+                    } else {
+                        Assert.error("Could not determine position of tree " + tree +
+                                " within frame " + frame);
+                    }
+                    p.pos = frame.pos;
+                    return;
+
+                case VARIABLE:
+                    VarSymbol v = ((JCVariableDecl)frame).sym;
+                    p.pos = frame.pos;
+                    switch (v.getKind()) {
+                        case LOCAL_VARIABLE:
+                            p.type = TargetType.LOCAL_VARIABLE;
+                            break;
+                        case FIELD:
+                            p.type = TargetType.FIELD;
+                            break;
+                        case PARAMETER:
+                            if (v.getQualifiedName().equals(names._this)) {
+                                // TODO: Intro a separate ElementKind?
+                                p.type = TargetType.METHOD_RECEIVER;
+                            } else {
+                                p.type = TargetType.METHOD_FORMAL_PARAMETER;
+                                p.parameter_index = methodParamIndex(path, frame);
+                            }
+                            break;
+                        case EXCEPTION_PARAMETER:
+                            p.type = TargetType.EXCEPTION_PARAMETER;
+                            break;
+                        case RESOURCE_VARIABLE:
+                            p.type = TargetType.RESOURCE_VARIABLE;
+                            break;
+                        default:
+                            Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind());
+                    }
+                    if (v.getKind() != ElementKind.FIELD) {
+                        v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes());
+                    }
+                    return;
+
+                case ANNOTATED_TYPE: {
+                    if (frame == tree) {
+                        // This is only true for the first annotated type we see.
+                        // For any other annotated types along the path, we do
+                        // 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) ||
+                                utype.getKind().equals(TypeKind.ARRAY)) {
+                            // Type parameters, wildcards, and arrays have the declaring
+                            // class/method as enclosing elements.
+                            // There is actually nothing to do for them.
+                        } else {
+                            locateNestedTypes(utype, p);
+                        }
+                    }
+                    List<JCTree> newPath = path.tail;
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case UNION_TYPE: {
+                    List<JCTree> newPath = path.tail;
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case INTERSECTION_TYPE: {
+                    JCTypeIntersection isect = (JCTypeIntersection)frame;
+                    p.type_index = isect.bounds.indexOf(tree);
+                    List<JCTree> newPath = path.tail;
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case METHOD_INVOCATION: {
+                    JCMethodInvocation invocation = (JCMethodInvocation)frame;
+                    if (!invocation.typeargs.contains(tree)) {
+                        Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation);
+                    }
+                    p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT;
+                    p.pos = invocation.pos;
+                    p.type_index = invocation.typeargs.indexOf(tree);
+                    return;
+                }
+
+                case EXTENDS_WILDCARD:
+                case SUPER_WILDCARD: {
+                    // Annotations in wildcard bounds
+                    p.location = p.location.prepend(TypePathEntry.WILDCARD);
+                    List<JCTree> newPath = path.tail;
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                case MEMBER_SELECT: {
+                    List<JCTree> newPath = path.tail;
+                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                    return;
+                }
+
+                default:
+                    Assert.error("Unresolved frame: " + frame + " of kind: " + frame.getKind() +
+                            "\n    Looking for tree: " + tree);
+                    return;
+            }
+        }
+
+        private static void locateNestedTypes(Type type, TypeAnnotationPosition p) {
+            // The number of "steps" to get from the full type to the
+            // left-most outer type.
+            ListBuffer<TypePathEntry> depth = ListBuffer.lb();
+
+            Type encl = type.getEnclosingType();
+            while (encl != null &&
+                    encl.getKind() != TypeKind.NONE &&
+                    encl.getKind() != TypeKind.ERROR) {
+                depth = depth.append(TypePathEntry.INNER_TYPE);
+                encl = encl.getEnclosingType();
+            }
+            if (depth.nonEmpty()) {
+                p.location = p.location.prependList(depth.toList());
+            }
+        }
+
+        private static int methodParamIndex(List<JCTree> path, JCTree param) {
+            List<JCTree> curr = path;
+            while (curr.head.getTag() != Tag.METHODDEF &&
+                    curr.head.getTag() != Tag.LAMBDA) {
+                curr = curr.tail;
+            }
+            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.
+        // This flag is used to prevent from visiting inner classes.
+        private boolean isInClass = false;
+
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            if (isInClass)
+                return;
+            isInClass = true;
+
+            if (sigOnly) {
+                scan(tree.mods);
+                scan(tree.typarams);
+                scan(tree.extending);
+                scan(tree.implementing);
+            }
+            scan(tree.defs);
+        }
+
+        /**
+         * Resolve declaration vs. type annotations in methods and
+         * then determine the positions.
+         */
+        @Override
+        public void visitMethodDef(final JCMethodDecl tree) {
+            if (tree.sym == null || tree.sym.type == null) {
+                // Something most be wrong, e.g. a class not found.
+                // Quietly ignore. (See test FailOver15.java)
+                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()) {
+                        pos.pos = tree.pos;
+                        // Use null to mark that the annotations go with the symbol.
+                        separateAnnotationsKinds(tree, null, tree.sym, pos);
+                    } else {
+                        pos.pos = tree.restype != null ? tree.restype.pos : tree.pos;
+                        separateAnnotationsKinds(tree.restype, tree.sym.type.getReturnType(),
+                                tree.sym, pos);
+                    }
+                }
+                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;
+                    pos.pos = tree.recvparam.vartype.pos;
+                    separateAnnotationsKinds(tree.recvparam.vartype, tree.recvparam.sym.type,
+                            tree.recvparam.sym, pos);
+                }
+                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;
+                        separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+                    }
+                    ++i;
+                }
+            }
+
+            push(tree);
+            // super.visitMethodDef(tree);
+            if (sigOnly) {
+                scan(tree.mods);
+                scan(tree.restype);
+                scan(tree.typarams);
+                scan(tree.recvparam);
+                scan(tree.params);
+                scan(tree.thrown);
+            } else {
+                scan(tree.defaultValue);
+                scan(tree.body);
+            }
+            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.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 or visitLambda.
+            } else if (tree.sym.getKind() == ElementKind.FIELD) {
+                if (sigOnly) {
+                    TypeAnnotationPosition pos = new TypeAnnotationPosition();
+                    pos.type = TargetType.FIELD;
+                    pos.pos = tree.pos;
+                    separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos);
+                }
+            } else if (tree.sym.getKind() == ElementKind.LOCAL_VARIABLE) {
+                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.
+            } else {
+                // There is nothing else in a variable declaration that needs separation.
+                Assert.error("Unhandled variable kind: " + tree + " of kind: " + tree.sym.getKind());
+            }
+
+            push(tree);
+            // super.visitVarDef(tree);
+            scan(tree.mods);
+            scan(tree.vartype);
+            if (!sigOnly) {
+                scan(tree.init);
+            }
+            pop();
+        }
+
+        @Override
+        public void visitBlock(JCBlock tree) {
+            // Do not descend into top-level blocks when only interested
+            // in the signature.
+            if (!sigOnly) {
+                scan(tree.stats);
+            }
+        }
+
+        @Override
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            push(tree);
+            findPosition(tree, tree, tree.annotations);
+            pop();
+            super.visitAnnotatedType(tree);
+        }
+
+        @Override
+        public void visitTypeParameter(JCTypeParameter tree) {
+            findPosition(tree, peek2(), tree.annotations);
+            super.visitTypeParameter(tree);
+        }
+
+        @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();
+            ListBuffer<TypePathEntry> depth = ListBuffer.lb();
+
+            // handle annotations associated with dimensions
+            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);
+                    p.location = p.location.appendList(depth.toList());
+                }
+
+                setTypeAnnotationPos(tree.dimAnnotations.get(i), p);
+            }
+
+            // handle "free" annotations
+            // 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.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;
+                }
+            }
+            scan(tree.elems);
+        }
+
+        private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
+            if (!annotations.isEmpty()) {
+                /*
+                System.out.println("Finding pos for: " + annotations);
+                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);
+            }
+        }
+
+        private static void setTypeAnnotationPos(List<JCAnnotation> annotations,
+                TypeAnnotationPosition position) {
+            for (JCAnnotation anno : annotations) {
+                // 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;
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/code/TypeTag.java b/src/share/classes/com/sun/tools/javac/code/TypeTag.java
new file mode 100644
index 0000000..418f1e1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/code/TypeTag.java
@@ -0,0 +1,240 @@
+/*
+ * 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
+ * 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.code;
+
+import com.sun.source.tree.Tree.Kind;
+
+import javax.lang.model.type.TypeKind;
+
+import static com.sun.tools.javac.code.TypeTag.NumericClasses.*;
+
+/** An interface for type tag values, which distinguish between different
+ *  sorts of types.
+ *
+ *  <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 enum TypeTag {
+    /** The tag of the basic type `byte'.
+     */
+    BYTE(BYTE_CLASS, BYTE_SUPERCLASSES, true),
+
+    /** The tag of the basic type `char'.
+     */
+    CHAR(CHAR_CLASS, CHAR_SUPERCLASSES, true),
+
+    /** The tag of the basic type `short'.
+     */
+    SHORT(SHORT_CLASS, SHORT_SUPERCLASSES, true),
+
+    /** The tag of the basic type `long'.
+     */
+    LONG(LONG_CLASS, LONG_SUPERCLASSES, true),
+
+    /** The tag of the basic type `float'.
+     */
+    FLOAT(FLOAT_CLASS, FLOAT_SUPERCLASSES, true),
+    /** The tag of the basic type `int'.
+     */
+    INT(INT_CLASS, INT_SUPERCLASSES, true),
+    /** The tag of the basic type `double'.
+     */
+    DOUBLE(DOUBLE_CLASS, DOUBLE_CLASS, true),
+    /** The tag of the basic type `boolean'.
+     */
+    BOOLEAN(0, 0, true),
+
+    /** The tag of the type `void'.
+     */
+    VOID,
+
+    /** The tag of all class and interface types.
+     */
+    CLASS,
+
+    /** The tag of all array types.
+     */
+    ARRAY,
+
+    /** The tag of all (monomorphic) method types.
+     */
+    METHOD,
+
+    /** The tag of all package "types".
+     */
+    PACKAGE,
+
+    /** The tag of all (source-level) type variables.
+     */
+    TYPEVAR,
+
+    /** The tag of all type arguments.
+     */
+    WILDCARD,
+
+    /** The tag of all polymorphic (method-) types.
+     */
+    FORALL,
+
+    /** The tag of deferred expression types in method context
+     */
+    DEFERRED,
+
+    /** The tag of the bottom type {@code <null>}.
+     */
+    BOT,
+
+    /** The tag of a missing type.
+     */
+    NONE,
+
+    /** The tag of the error type.
+     */
+    ERROR,
+
+    /** The tag of an unknown type
+     */
+    UNKNOWN,
+
+    /** The tag of all instantiatable type variables.
+     */
+    UNDETVAR,
+
+    /** Pseudo-types, these are special tags
+     */
+    UNINITIALIZED_THIS,
+
+    UNINITIALIZED_OBJECT;
+
+    final int superClasses;
+    final int numericClass;
+    final boolean isPrimitive;
+
+    private TypeTag() {
+        this(0, 0, false);
+    }
+
+    private TypeTag(int numericClass, int superClasses, boolean isPrimitive) {
+        this.superClasses = superClasses;
+        this.numericClass = numericClass;
+        this.isPrimitive = isPrimitive;
+    }
+
+    public static class NumericClasses {
+        public static final int BYTE_CLASS = 1;
+        public static final int CHAR_CLASS = 2;
+        public static final int SHORT_CLASS = 4;
+        public static final int INT_CLASS = 8;
+        public static final int LONG_CLASS = 16;
+        public static final int FLOAT_CLASS = 32;
+        public static final int DOUBLE_CLASS = 64;
+
+        static final int BYTE_SUPERCLASSES = BYTE_CLASS | SHORT_CLASS | INT_CLASS |
+                LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS;
+
+        static final int CHAR_SUPERCLASSES = CHAR_CLASS | INT_CLASS |
+                LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS;
+
+        static final int SHORT_SUPERCLASSES = SHORT_CLASS | INT_CLASS |
+                LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS;
+
+        static final int INT_SUPERCLASSES = INT_CLASS | LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS;
+
+        static final int LONG_SUPERCLASSES = LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS;
+
+        static final int FLOAT_SUPERCLASSES = FLOAT_CLASS | DOUBLE_CLASS;
+    }
+
+    public boolean isStrictSubRangeOf(TypeTag tag) {
+        /*  Please don't change the implementation of this method to call method
+         *  isSubRangeOf. Both methods are called from hotspot code, the current
+         *  implementation is better performance-wise than the commented modification.
+         */
+        return (this.superClasses & tag.numericClass) != 0 && this != tag;
+    }
+
+    public boolean isSubRangeOf(TypeTag tag) {
+        return (this.superClasses & tag.numericClass) != 0;
+    }
+
+    /** Returns the number of type tags.
+     */
+    public static int getTypeTagCount() {
+        // last two tags are not included in the total as long as they are pseudo-types
+        return (UNDETVAR.ordinal() + 1);
+    }
+
+    public Kind getKindLiteral() {
+        switch (this) {
+        case INT:
+            return Kind.INT_LITERAL;
+        case LONG:
+            return Kind.LONG_LITERAL;
+        case FLOAT:
+            return Kind.FLOAT_LITERAL;
+        case DOUBLE:
+            return Kind.DOUBLE_LITERAL;
+        case BOOLEAN:
+            return Kind.BOOLEAN_LITERAL;
+        case CHAR:
+            return Kind.CHAR_LITERAL;
+        case CLASS:
+            return Kind.STRING_LITERAL;
+        case BOT:
+            return Kind.NULL_LITERAL;
+        default:
+            throw new AssertionError("unknown literal kind " + this);
+        }
+    }
+
+    public TypeKind getPrimitiveTypeKind() {
+        switch (this) {
+        case BOOLEAN:
+            return TypeKind.BOOLEAN;
+        case BYTE:
+            return TypeKind.BYTE;
+        case SHORT:
+            return TypeKind.SHORT;
+        case INT:
+            return TypeKind.INT;
+        case LONG:
+            return TypeKind.LONG;
+        case CHAR:
+            return TypeKind.CHAR;
+        case FLOAT:
+            return TypeKind.FLOAT;
+        case DOUBLE:
+            return TypeKind.DOUBLE;
+        case VOID:
+            return TypeKind.VOID;
+        default:
+            throw new AssertionError("unknown primitive type " + this);
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/code/TypeTags.java b/src/share/classes/com/sun/tools/javac/code/TypeTags.java
deleted file mode 100644
index 463def2..0000000
--- a/src/share/classes/com/sun/tools/javac/code/TypeTags.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 1999, 2005, 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.code;
-
-
-/** An interface for type tag values, which distinguish between different
- *  sorts of types.
- *
- *  <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 TypeTags {
-
-    private TypeTags() {} // uninstantiable
-
-    /** The tag of the basic type `byte'.
-     */
-    public static final int BYTE = 1;
-
-    /** The tag of the basic type `char'.
-     */
-    public static final int CHAR = BYTE+1;
-
-    /** The tag of the basic type `short'.
-     */
-    public static final int SHORT = CHAR+1;
-
-    /** The tag of the basic type `int'.
-     */
-    public static final int INT = SHORT+1;
-
-    /** The tag of the basic type `long'.
-     */
-    public static final int LONG = INT+1;
-
-    /** The tag of the basic type `float'.
-     */
-    public static final int FLOAT = LONG+1;
-
-    /** The tag of the basic type `double'.
-     */
-    public static final int DOUBLE = FLOAT+1;
-
-    /** The tag of the basic type `boolean'.
-     */
-    public static final int BOOLEAN = DOUBLE+1;
-
-    /** The tag of the type `void'.
-     */
-    public static final int VOID = BOOLEAN+1;
-
-    /** The tag of all class and interface types.
-     */
-    public static final int CLASS = VOID+1;
-
-    /** The tag of all array types.
-     */
-    public static final int ARRAY = CLASS+1;
-
-    /** The tag of all (monomorphic) method types.
-     */
-    public static final int METHOD = ARRAY+1;
-
-    /** The tag of all package "types".
-     */
-    public static final int PACKAGE = METHOD+1;
-
-    /** The tag of all (source-level) type variables.
-     */
-    public static final int TYPEVAR = PACKAGE+1;
-
-    /** The tag of all type arguments.
-     */
-    public static final int WILDCARD = TYPEVAR+1;
-
-    /** The tag of all polymorphic (method-) types.
-     */
-    public static final int FORALL = WILDCARD+1;
-
-    /** The tag of the bottom type <null>.
-     */
-    public static final int BOT = FORALL+1;
-
-    /** The tag of a missing type.
-     */
-    public static final int NONE = BOT+1;
-
-    /** The tag of the error type.
-     */
-    public static final int ERROR = NONE+1;
-
-    /** The tag of an unknown type
-     */
-    public static final int UNKNOWN = ERROR+1;
-
-    /** The tag of all instantiatable type variables.
-     */
-    public static final int UNDETVAR = UNKNOWN+1;
-
-    /** The number of type tags.
-     */
-    public static final int TypeTagCount = UNDETVAR+1;
-
-    /** The maximum tag of a basic type.
-     */
-    public static final int lastBaseTag = BOOLEAN;
-
-    /** The minimum tag of a partial type
-     */
-    public static final int firstPartialTag = ERROR;
-}
diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java
index cb6008b..b937a8b 100644
--- a/src/share/classes/com/sun/tools/javac/code/Types.java
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java
@@ -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
@@ -26,24 +26,31 @@
 package com.sun.tools.javac.code;
 
 import java.lang.ref.SoftReference;
-import java.util.*;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
+import javax.tools.JavaFileObject;
 
-import com.sun.tools.javac.jvm.ClassReader;
 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;
+import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Check;
-import java.util.logging.Logger;
-import javax.lang.model.type.TypeKind;
-
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.jvm.ClassReader;
+import com.sun.tools.javac.util.*;
+import static com.sun.tools.javac.code.BoundKind.*;
+import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Scope.*;
-import static com.sun.tools.javac.code.Type.*;
-import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.Symbol.*;
-import static com.sun.tools.javac.code.Flags.*;
-import static com.sun.tools.javac.code.BoundKind.*;
+import static com.sun.tools.javac.code.Type.*;
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.jvm.ClassFile.externalize;
 import static com.sun.tools.javac.util.ListBuffer.lb;
 
 /**
@@ -79,10 +86,16 @@ public class Types {
     final boolean allowBoxing;
     final boolean allowCovariantReturns;
     final boolean allowObjectToPrimitiveCast;
+    final boolean allowDefaultMethods;
     final ClassReader reader;
     final Check chk;
+    final Enter enter;
+    JCDiagnostic.Factory diags;
     List<Warner> warnStack = List.nil();
     final Name capturedName;
+    private final FunctionDescriptorLookupError functionDescriptorLookupError;
+
+    public final Warner noWarnings;
 
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
@@ -101,10 +114,15 @@ public class Types {
         allowCovariantReturns = source.allowCovariantReturns();
         allowGenerics = source.allowGenerics();
         allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast();
+        allowDefaultMethods = source.allowDefaultMethods();
         reader = ClassReader.instance(context);
         chk = Check.instance(context);
+        enter = Enter.instance(context);
         capturedName = names.fromString("<captured wildcard>");
         messages = JavacMessages.instance(context);
+        diags = JCDiagnostic.Factory.instance(context);
+        functionDescriptorLookupError = new FunctionDescriptorLookupError();
+        noWarnings = new Warner(null);
     }
     // </editor-fold>
 
@@ -192,7 +210,7 @@ public class Types {
                     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;
@@ -256,7 +274,7 @@ public class Types {
                         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());
                     }
@@ -277,8 +295,9 @@ public class Types {
      * conversion to s?
      */
     public boolean isConvertible(Type t, Type s, Warner warn) {
-        if (t.tag == ERROR)
+        if (t.hasTag(ERROR)) {
             return true;
+        }
         boolean tPrimitive = t.isPrimitive();
         boolean sPrimitive = s.isPrimitive();
         if (tPrimitive == sPrimitive) {
@@ -295,16 +314,413 @@ public class Types {
      * convertions to s?
      */
     public boolean isConvertible(Type t, Type s) {
-        return isConvertible(t, s, Warner.noWarnings);
+        return isConvertible(t, s, noWarnings);
     }
     // </editor-fold>
 
+    // <editor-fold defaultstate="collapsed" desc="findSam">
+
+    /**
+     * Exception used to report a function descriptor lookup failure. The exception
+     * wraps a diagnostic that can be used to generate more details error
+     * messages.
+     */
+    public static class FunctionDescriptorLookupError extends RuntimeException {
+        private static final long serialVersionUID = 0;
+
+        JCDiagnostic diagnostic;
+
+        FunctionDescriptorLookupError() {
+            this.diagnostic = null;
+        }
+
+        FunctionDescriptorLookupError setMessage(JCDiagnostic diag) {
+            this.diagnostic = diag;
+            return this;
+        }
+
+        public JCDiagnostic getDiagnostic() {
+            return diagnostic;
+        }
+    }
+
+    /**
+     * A cache that keeps track of function descriptors associated with given
+     * functional interfaces.
+     */
+    class DescriptorCache {
+
+        private WeakHashMap<TypeSymbol, Entry> _map = new WeakHashMap<TypeSymbol, Entry>();
+
+        class FunctionDescriptor {
+            Symbol descSym;
+
+            FunctionDescriptor(Symbol descSym) {
+                this.descSym = descSym;
+            }
+
+            public Symbol getSymbol() {
+                return descSym;
+            }
+
+            public Type getType(Type site) {
+                site = removeWildcards(site);
+                if (!chk.checkValidGenericType(site)) {
+                    //if the inferred functional interface type is not well-formed,
+                    //or if it's not a subtype of the original target, issue an error
+                    throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
+                }
+                return memberType(site, descSym);
+            }
+        }
+
+        class Entry {
+            final FunctionDescriptor cachedDescRes;
+            final int prevMark;
+
+            public Entry(FunctionDescriptor cachedDescRes,
+                    int prevMark) {
+                this.cachedDescRes = cachedDescRes;
+                this.prevMark = prevMark;
+            }
+
+            boolean matches(int mark) {
+                return  this.prevMark == mark;
+            }
+        }
+
+        FunctionDescriptor get(TypeSymbol origin) throws FunctionDescriptorLookupError {
+            Entry e = _map.get(origin);
+            CompoundScope members = membersClosure(origin.type, false);
+            if (e == null ||
+                    !e.matches(members.getMark())) {
+                FunctionDescriptor descRes = findDescriptorInternal(origin, members);
+                _map.put(origin, new Entry(descRes, members.getMark()));
+                return descRes;
+            }
+            else {
+                return e.cachedDescRes;
+            }
+        }
+
+        /**
+         * Compute the function descriptor associated with a given functional interface
+         */
+        public FunctionDescriptor findDescriptorInternal(TypeSymbol origin,
+                CompoundScope membersCache) throws FunctionDescriptorLookupError {
+            if (!origin.isInterface() || (origin.flags() & ANNOTATION) != 0) {
+                //t must be an interface
+                throw failure("not.a.functional.intf", origin);
+            }
+
+            final ListBuffer<Symbol> abstracts = ListBuffer.lb();
+            for (Symbol sym : membersCache.getElements(new DescriptorFilter(origin))) {
+                Type mtype = memberType(origin.type, sym);
+                if (abstracts.isEmpty() ||
+                        (sym.name == abstracts.first().name &&
+                        overrideEquivalent(mtype, memberType(origin.type, abstracts.first())))) {
+                    abstracts.append(sym);
+                } else {
+                    //the target method(s) should be the only abstract members of t
+                    throw failure("not.a.functional.intf.1",  origin,
+                            diags.fragment("incompatible.abstracts", Kinds.kindName(origin), origin));
+                }
+            }
+            if (abstracts.isEmpty()) {
+                //t must define a suitable non-generic method
+                throw failure("not.a.functional.intf.1", origin,
+                            diags.fragment("no.abstracts", Kinds.kindName(origin), origin));
+            } else if (abstracts.size() == 1) {
+                return new FunctionDescriptor(abstracts.first());
+            } else { // size > 1
+                FunctionDescriptor descRes = mergeDescriptors(origin, abstracts.toList());
+                if (descRes == null) {
+                    //we can get here if the functional interface is ill-formed
+                    ListBuffer<JCDiagnostic> descriptors = ListBuffer.lb();
+                    for (Symbol desc : abstracts) {
+                        String key = desc.type.getThrownTypes().nonEmpty() ?
+                                "descriptor.throws" : "descriptor";
+                        descriptors.append(diags.fragment(key, desc.name,
+                                desc.type.getParameterTypes(),
+                                desc.type.getReturnType(),
+                                desc.type.getThrownTypes()));
+                    }
+                    JCDiagnostic.MultilineDiagnostic incompatibleDescriptors =
+                            new JCDiagnostic.MultilineDiagnostic(diags.fragment("incompatible.descs.in.functional.intf",
+                            Kinds.kindName(origin), origin), descriptors.toList());
+                    throw failure(incompatibleDescriptors);
+                }
+                return descRes;
+            }
+        }
+
+        /**
+         * Compute a synthetic type for the target descriptor given a list
+         * of override-equivalent methods in the functional interface type.
+         * The resulting method type is a method type that is override-equivalent
+         * and return-type substitutable with each method in the original list.
+         */
+        private FunctionDescriptor mergeDescriptors(TypeSymbol origin, List<Symbol> methodSyms) {
+            //pick argument types - simply take the signature that is a
+            //subsignature of all other signatures in the list (as per JLS 8.4.2)
+            List<Symbol> mostSpecific = List.nil();
+            outer: for (Symbol msym1 : methodSyms) {
+                Type mt1 = memberType(origin.type, msym1);
+                for (Symbol msym2 : methodSyms) {
+                    Type mt2 = memberType(origin.type, msym2);
+                    if (!isSubSignature(mt1, mt2)) {
+                        continue outer;
+                    }
+                }
+                mostSpecific = mostSpecific.prepend(msym1);
+            }
+            if (mostSpecific.isEmpty()) {
+                return null;
+            }
+
+
+            //pick return types - this is done in two phases: (i) first, the most
+            //specific return type is chosen using strict subtyping; if this fails,
+            //a second attempt is made using return type substitutability (see JLS 8.4.5)
+            boolean phase2 = false;
+            Symbol bestSoFar = null;
+            while (bestSoFar == null) {
+                outer: for (Symbol msym1 : mostSpecific) {
+                    Type mt1 = memberType(origin.type, msym1);
+                    for (Symbol msym2 : methodSyms) {
+                        Type mt2 = memberType(origin.type, msym2);
+                        if (phase2 ?
+                                !returnTypeSubstitutable(mt1, mt2) :
+                                !isSubtypeInternal(mt1.getReturnType(), mt2.getReturnType())) {
+                            continue outer;
+                        }
+                    }
+                    bestSoFar = msym1;
+                }
+                if (phase2) {
+                    break;
+                } else {
+                    phase2 = true;
+                }
+            }
+            if (bestSoFar == null) return null;
+
+            //merge thrown types - form the intersection of all the thrown types in
+            //all the signatures in the list
+            List<Type> thrown = null;
+            for (Symbol msym1 : methodSyms) {
+                Type mt1 = memberType(origin.type, msym1);
+                thrown = (thrown == null) ?
+                    mt1.getThrownTypes() :
+                    chk.intersect(mt1.getThrownTypes(), thrown);
+            }
+
+            final List<Type> thrown1 = thrown;
+            return new FunctionDescriptor(bestSoFar) {
+                @Override
+                public Type getType(Type origin) {
+                    Type mt = memberType(origin, getSymbol());
+                    return createMethodTypeWithThrown(mt, thrown1);
+                }
+            };
+        }
+
+        boolean isSubtypeInternal(Type s, Type t) {
+            return (s.isPrimitive() && t.isPrimitive()) ?
+                    isSameType(t, s) :
+                    isSubtype(s, t);
+        }
+
+        FunctionDescriptorLookupError failure(String msg, Object... args) {
+            return failure(diags.fragment(msg, args));
+        }
+
+        FunctionDescriptorLookupError failure(JCDiagnostic diag) {
+            return functionDescriptorLookupError.setMessage(diag);
+        }
+    }
+
+    private DescriptorCache descCache = new DescriptorCache();
+
+    /**
+     * Find the method descriptor associated to this class symbol - if the
+     * symbol 'origin' is not a functional interface, an exception is thrown.
+     */
+    public Symbol findDescriptorSymbol(TypeSymbol origin) throws FunctionDescriptorLookupError {
+        return descCache.get(origin).getSymbol();
+    }
+
+    /**
+     * Find the type of the method descriptor associated to this class symbol -
+     * if the symbol 'origin' is not a functional interface, an exception is thrown.
+     */
+    public Type findDescriptorType(Type origin) throws FunctionDescriptorLookupError {
+        return descCache.get(origin.tsym).getType(origin);
+    }
+
+    /**
+     * Is given type a functional interface?
+     */
+    public boolean isFunctionalInterface(TypeSymbol tsym) {
+        try {
+            findDescriptorSymbol(tsym);
+            return true;
+        } catch (FunctionDescriptorLookupError ex) {
+            return false;
+        }
+    }
+
+    public boolean isFunctionalInterface(Type site) {
+        try {
+            findDescriptorType(site);
+            return true;
+        } catch (FunctionDescriptorLookupError ex) {
+            return false;
+        }
+    }
+
+    public Type removeWildcards(Type site) {
+        Type capturedSite = capture(site);
+        if (capturedSite != site) {
+            Type formalInterface = site.tsym.type;
+            ListBuffer<Type> typeargs = ListBuffer.lb();
+            List<Type> actualTypeargs = site.getTypeArguments();
+            List<Type> capturedTypeargs = capturedSite.getTypeArguments();
+            //simply replace the wildcards with its bound
+            for (Type t : formalInterface.getTypeArguments()) {
+                if (actualTypeargs.head.hasTag(WILDCARD)) {
+                    WildcardType wt = (WildcardType)actualTypeargs.head.unannotatedType();
+                    Type bound;
+                    switch (wt.kind) {
+                        case EXTENDS:
+                        case UNBOUND:
+                            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;
+                            break;
+                        default:
+                            bound = wt.type;
+                    }
+                    typeargs.append(bound);
+                } else {
+                    typeargs.append(actualTypeargs.head);
+                }
+                actualTypeargs = actualTypeargs.tail;
+                capturedTypeargs = capturedTypeargs.tail;
+            }
+            return subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
+        } else {
+            return site;
+        }
+    }
+
+    /**
+     * Create a symbol for a class that implements a given functional interface
+     * and overrides its functional descriptor. This routine is used for two
+     * main purposes: (i) checking well-formedness of a functional interface;
+     * (ii) perform functional interface bridge calculation.
+     */
+    public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) {
+        Assert.check(targets.nonEmpty() && isFunctionalInterface(targets.head));
+        Symbol descSym = findDescriptorSymbol(targets.head.tsym);
+        Type descType = findDescriptorType(targets.head);
+        ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass());
+        csym.completer = null;
+        csym.members_field = new Scope(csym);
+        MethodSymbol instDescSym = new MethodSymbol(descSym.flags(), descSym.name, descType, csym);
+        csym.members_field.enter(instDescSym);
+        Type.ClassType ctype = new Type.ClassType(Type.noType, List.<Type>nil(), csym);
+        ctype.supertype_field = syms.objectType;
+        ctype.interfaces_field = targets;
+        csym.type = ctype;
+        csym.sourcefile = ((ClassSymbol)csym.owner).sourcefile;
+        return csym;
+    }
+
+    /**
+     * Find the minimal set of methods that are overridden by the functional
+     * descriptor in 'origin'. All returned methods are assumed to have different
+     * erased signatures.
+     */
+    public List<Symbol> functionalInterfaceBridges(TypeSymbol origin) {
+        Assert.check(isFunctionalInterface(origin));
+        Symbol descSym = findDescriptorSymbol(origin);
+        CompoundScope members = membersClosure(origin.type, false);
+        ListBuffer<Symbol> overridden = ListBuffer.lb();
+        outer: for (Symbol m2 : members.getElementsByName(descSym.name, bridgeFilter)) {
+            if (m2 == descSym) continue;
+            else if (descSym.overrides(m2, origin, Types.this, false)) {
+                for (Symbol m3 : overridden) {
+                    if (isSameType(m3.erasure(Types.this), m2.erasure(Types.this)) ||
+                            (m3.overrides(m2, origin, Types.this, false) &&
+                            (pendingBridges((ClassSymbol)origin, m3.enclClass()) ||
+                            (((MethodSymbol)m2).binaryImplementation((ClassSymbol)m3.owner, Types.this) != null)))) {
+                        continue outer;
+                    }
+                }
+                overridden.add(m2);
+            }
+        }
+        return overridden.toList();
+    }
+    //where
+        private Filter<Symbol> bridgeFilter = new Filter<Symbol>() {
+            public boolean accepts(Symbol t) {
+                return t.kind == Kinds.MTH &&
+                        t.name != names.init &&
+                        t.name != names.clinit &&
+                        (t.flags() & SYNTHETIC) == 0;
+            }
+        };
+        private boolean pendingBridges(ClassSymbol origin, TypeSymbol s) {
+            //a symbol will be completed from a classfile if (a) symbol has
+            //an associated file object with CLASS kind and (b) the symbol has
+            //not been entered
+            if (origin.classfile != null &&
+                    origin.classfile.getKind() == JavaFileObject.Kind.CLASS &&
+                    enter.getEnv(origin) == null) {
+                return false;
+            }
+            if (origin == s) {
+                return true;
+            }
+            for (Type t : interfaces(origin.type)) {
+                if (pendingBridges((ClassSymbol)t.tsym, s)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    // </editor-fold>
+
+   /**
+    * Scope filter used to skip methods that should be ignored (such as methods
+    * overridden by j.l.Object) during function interface conversion interface check
+    */
+    class DescriptorFilter implements Filter<Symbol> {
+
+       TypeSymbol origin;
+
+       DescriptorFilter(TypeSymbol origin) {
+           this.origin = origin;
+       }
+
+       @Override
+       public boolean accepts(Symbol sym) {
+           return sym.kind == Kinds.MTH &&
+                   (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT &&
+                   !overridesObjectMethod(origin, sym) &&
+                   (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
+       }
+    };
+
     // <editor-fold defaultstate="collapsed" desc="isSubtype">
     /**
      * Is t an unchecked subtype of s?
      */
     public boolean isSubtypeUnchecked(Type t, Type s) {
-        return isSubtypeUnchecked(t, s, Warner.noWarnings);
+        return isSubtypeUnchecked(t, s, noWarnings);
     }
     /**
      * Is t an unchecked subtype of s?
@@ -318,30 +734,26 @@ public class Types {
     }
     //where
         private boolean isSubtypeUncheckedInternal(Type t, Type s, Warner warn) {
-            if (t.tag == ARRAY && s.tag == ARRAY) {
-                if (((ArrayType)t).elemtype.tag <= lastBaseTag) {
+            if (t.hasTag(ARRAY) && s.hasTag(ARRAY)) {
+                t = t.unannotatedType();
+                s = s.unannotatedType();
+                if (((ArrayType)t).elemtype.isPrimitive()) {
                     return isSameType(elemtype(t), elemtype(s));
                 } else {
                     return isSubtypeUnchecked(elemtype(t), elemtype(s), warn);
                 }
             } else if (isSubtype(t, s)) {
                 return true;
-            }
-            else if (t.tag == TYPEVAR) {
+            } else if (t.hasTag(TYPEVAR)) {
                 return isSubtypeUnchecked(t.getUpperBound(), s, warn);
-            }
-            else if (s.tag == UNDETVAR) {
-                UndetVar uv = (UndetVar)s;
-                if (uv.inst != null)
-                    return isSubtypeUnchecked(t, uv.inst, warn);
-            }
-            else if (!s.isRaw()) {
+            } else if (!s.isRaw()) {
                 Type t2 = asSuper(t, s.tsym);
                 if (t2 != null && t2.isRaw()) {
-                    if (isReifiable(s))
+                    if (isReifiable(s)) {
                         warn.silentWarn(LintCategory.UNCHECKED);
-                    else
+                    } else {
                         warn.warn(LintCategory.UNCHECKED);
+                    }
                     return true;
                 }
             }
@@ -349,10 +761,14 @@ public class Types {
         }
 
         private void checkUnsafeVarargsConversion(Type t, Type s, Warner warn) {
-            if (t.tag != ARRAY || isReifiable(t)) return;
+            if (!t.hasTag(ARRAY) || isReifiable(t)) {
+                return;
+            }
+            t = t.unannotatedType();
+            s = s.unannotatedType();
             ArrayType from = (ArrayType)t;
             boolean shouldWarn = false;
-            switch (s.tag) {
+            switch (s.getTag()) {
                 case ARRAY:
                     ArrayType to = (ArrayType)s;
                     shouldWarn = from.isVarargs() &&
@@ -382,7 +798,13 @@ public class Types {
         if (t == s)
             return true;
 
-        if (s.tag >= firstPartialTag)
+        t = t.unannotatedType();
+        s = s.unannotatedType();
+
+        if (t == s)
+            return true;
+
+        if (s.isPartial())
             return isSuperType(s, t);
 
         if (s.isCompound()) {
@@ -402,28 +824,31 @@ public class Types {
     // where
         private TypeRelation isSubtype = new TypeRelation()
         {
+            @Override
             public Boolean visitType(Type t, Type s) {
-                switch (t.tag) {
-                case BYTE: case CHAR:
-                    return (t.tag == s.tag ||
-                              t.tag + 2 <= s.tag && s.tag <= DOUBLE);
-                case SHORT: case INT: case LONG: case FLOAT: case DOUBLE:
-                    return t.tag <= s.tag && s.tag <= DOUBLE;
-                case BOOLEAN: case VOID:
-                    return t.tag == s.tag;
-                case TYPEVAR:
-                    return isSubtypeNoCapture(t.getUpperBound(), s);
-                case BOT:
-                    return
-                        s.tag == BOT || s.tag == CLASS ||
-                        s.tag == ARRAY || s.tag == TYPEVAR;
-                case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
-                case NONE:
-                case UNKNOWN:
-                    return false;
-                default:
-                    throw new AssertionError("isSubtype " + t.tag);
-                }
+                switch (t.getTag()) {
+                 case BYTE:
+                     return (!s.hasTag(CHAR) && t.getTag().isSubRangeOf(s.getTag()));
+                 case CHAR:
+                     return (!s.hasTag(SHORT) && t.getTag().isSubRangeOf(s.getTag()));
+                 case SHORT: case INT: case LONG:
+                 case FLOAT: case DOUBLE:
+                     return t.getTag().isSubRangeOf(s.getTag());
+                 case BOOLEAN: case VOID:
+                     return t.hasTag(s.getTag());
+                 case TYPEVAR:
+                     return isSubtypeNoCapture(t.getUpperBound(), s);
+                 case BOT:
+                     return
+                         s.hasTag(BOT) || s.hasTag(CLASS) ||
+                         s.hasTag(ARRAY) || s.hasTag(TYPEVAR);
+                 case WILDCARD: //we shouldn't be here - avoids crash (see 7034495)
+                 case NONE:
+                 case UNKNOWN:
+                     return false;
+                 default:
+                     throw new AssertionError("isSubtype " + t.getTag());
+                 }
             }
 
             private Set<TypePair> cache = new HashSet<TypePair>();
@@ -478,8 +903,6 @@ public class Types {
             public Boolean visitClassType(ClassType t, Type s) {
                 final Symbol _ssym = s.tsym;
                 if (_ssym == null) {
-                    TypeKind _skind = s.getKind();
-                    Logger.getLogger(Types.class.getName()).warning("Types.isSubtype.visitClassType type t: [" + t.toString() +"]; type s: [" + s.toString() + ","+ _skind +"] has a null symbol."); //NOI18N
                     return false;
                 }
                 Type sup = asSuper(t, _ssym);
@@ -498,14 +921,14 @@ public class Types {
 
             @Override
             public Boolean visitArrayType(ArrayType t, Type s) {
-                if (s.tag == ARRAY) {
-                    if (t.elemtype.tag <= lastBaseTag)
+                if (s.hasTag(ARRAY)) {
+                    if (t.elemtype.isPrimitive())
                         return isSameType(t.elemtype, elemtype(s));
                     else
                         return isSubtypeNoCapture(t.elemtype, elemtype(s));
                 }
 
-                if (s.tag == CLASS) {
+                if (s.hasTag(CLASS)) {
                     Name sname = s.tsym.getQualifiedName();
                     return sname == names.java_lang_Object
                         || sname == names.java_lang_Cloneable
@@ -518,13 +941,15 @@ public class Types {
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
                 //todo: test against origin needed? or replace with substitution?
-                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN)
+                if (t == s || t.qtype == s || s.hasTag(ERROR) || s.hasTag(UNKNOWN)) {
                     return true;
+                } else if (s.hasTag(BOT)) {
+                    //if 's' is 'null' there's no instantiated type U for which
+                    //U <: s (but 'null' itself, which is not a valid type)
+                    return false;
+                }
 
-                if (t.inst != null)
-                    return isSubtypeNoCapture(t.inst, s); // TODO: ", warn"?
-
-                t.hibounds = t.hibounds.prepend(s);
+                t.addBound(InferenceBound.UPPER, s, Types.this);
                 return true;
             }
 
@@ -583,7 +1008,7 @@ public class Types {
      * Is t a supertype of s?
      */
     public boolean isSuperType(Type t, Type s) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case ERROR:
         case UNKNOWN:
             return true;
@@ -591,11 +1016,11 @@ public class Types {
             UndetVar undet = (UndetVar)t;
             if (t == s ||
                 undet.qtype == s ||
-                s.tag == ERROR ||
-                s.tag == BOT) return true;
-            if (undet.inst != null)
-                return isSubtype(s, undet.inst);
-            undet.lobounds = undet.lobounds.prepend(s);
+                s.hasTag(ERROR) ||
+                s.hasTag(BOT)) {
+                return true;
+            }
+            undet.addBound(InferenceBound.LOWER, s, this);
             return true;
         }
         default:
@@ -610,9 +1035,12 @@ public class Types {
      * lists are of different length, return false.
      */
     public boolean isSameTypes(List<Type> ts, List<Type> ss) {
+        return isSameTypes(ts, ss, false);
+    }
+    public boolean isSameTypes(List<Type> ts, List<Type> ss, boolean strict) {
         while (ts.tail != null && ss.tail != null
                /*inlined: ts.nonEmpty() && ss.nonEmpty()*/ &&
-               isSameType(ts.head, ss.head)) {
+               isSameType(ts.head, ss.head, strict)) {
             ts = ts.tail;
             ss = ss.tail;
         }
@@ -621,31 +1049,54 @@ public class Types {
     }
 
     /**
+    * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that
+    * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes
+    * a single variable arity parameter (iii) whose declared type is Object[],
+    * (iv) has a return type of Object and (v) is native.
+    */
+   public boolean isSignaturePolymorphic(MethodSymbol msym) {
+       List<Type> argtypes = msym.type.getParameterTypes();
+       return (msym.flags_field & NATIVE) != 0 &&
+               msym.owner == syms.methodHandleType.tsym &&
+               argtypes.tail.tail == null &&
+               argtypes.head.hasTag(TypeTag.ARRAY) &&
+               msym.type.getReturnType().tsym == syms.objectType.tsym &&
+               ((ArrayType)argtypes.head).elemtype.tsym == syms.objectType.tsym;
+   }
+
+    /**
      * Is t the same type as s?
      */
     public boolean isSameType(Type t, Type s) {
-        return isSameType.visit(t, s);
+        return isSameType(t, s, false);
+    }
+    public boolean isSameType(Type t, Type s, boolean strict) {
+        return strict ?
+                isSameTypeStrict.visit(t, s) :
+                isSameTypeLoose.visit(t, s);
+    }
+    public boolean isSameAnnotatedType(Type t, Type s) {
+        return isSameAnnotatedType.visit(t, s);
     }
     // where
-        private TypeRelation isSameType = new TypeRelation() {
+        abstract class SameTypeVisitor extends TypeRelation {
 
             public Boolean visitType(Type t, Type s) {
                 if (t == s)
                     return true;
 
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return visit(s, t);
 
-                switch (t.tag) {
+                switch (t.getTag()) {
                 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
                 case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE:
-                    return t.tag == s.tag;
+                    return t.hasTag(s.getTag());
                 case TYPEVAR: {
-                    if (s.tag == TYPEVAR) {
+                    if (s.hasTag(TYPEVAR)) {
                         //type-substitution does not preserve type-var types
                         //check that type var symbols and bounds are indeed the same
-                        return t.tsym == s.tsym &&
-                                visit(t.getUpperBound(), s.getUpperBound());
+                        return sameTypeVars((TypeVar)t.unannotatedType(), (TypeVar)s.unannotatedType());
                     }
                     else {
                         //special case for s == ? super X, where upper(s) = u
@@ -656,13 +1107,15 @@ public class Types {
                     }
                 }
                 default:
-                    throw new AssertionError("isSameType " + t.tag);
+                    throw new AssertionError("isSameType " + t.getTag());
                 }
             }
 
+            abstract boolean sameTypeVars(TypeVar tv1, TypeVar tv2);
+
             @Override
             public Boolean visitWildcardType(WildcardType t, Type s) {
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return visit(s, t);
                 else
                     return false;
@@ -673,7 +1126,7 @@ public class Types {
                 if (t == s)
                     return true;
 
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return visit(s, t);
 
                 if (s.isSuperBound() && !s.isExtendsBound())
@@ -683,29 +1136,31 @@ public class Types {
                     if (!visit(supertype(t), supertype(s)))
                         return false;
 
-                    HashSet<SingletonType> set = new HashSet<SingletonType>();
+                    HashSet<UniqueType> set = new HashSet<UniqueType>();
                     for (Type x : interfaces(t))
-                        set.add(new SingletonType(x));
+                        set.add(new UniqueType(x, Types.this));
                     for (Type x : interfaces(s)) {
-                        if (!set.remove(new SingletonType(x)))
+                        if (!set.remove(new UniqueType(x, Types.this)))
                             return false;
                     }
                     return (set.isEmpty());
                 }
                 return t.tsym == s.tsym
                     && visit(t.getEnclosingType(), s.getEnclosingType())
-                    && containsTypeEquivalent(t.getTypeArguments(), s.getTypeArguments());
+                    && containsTypes(t.getTypeArguments(), s.getTypeArguments());
             }
 
+            abstract protected boolean containsTypes(List<Type> ts1, List<Type> ts2);
+
             @Override
             public Boolean visitArrayType(ArrayType t, Type s) {
                 if (t == s)
                     return true;
 
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return visit(s, t);
 
-                return s.tag == ARRAY
+                return s.hasTag(ARRAY)
                     && containsTypeEquivalent(t.elemtype, elemtype(s));
             }
 
@@ -723,8 +1178,9 @@ public class Types {
 
             @Override
             public Boolean visitForAll(ForAll t, Type s) {
-                if (s.tag != FORALL)
+                if (!s.hasTag(FORALL)) {
                     return false;
+                }
 
                 ForAll forAll = (ForAll)s;
                 return hasSameBounds(t, forAll)
@@ -733,25 +1189,17 @@ public class Types {
 
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
-                if (s.tag == WILDCARD)
+                if (s.hasTag(WILDCARD)) {
                     // FIXME, this might be leftovers from before capture conversion
                     return false;
+                }
 
-                if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN)
+                if (t == s || t.qtype == s || s.hasTag(ERROR) || s.hasTag(UNKNOWN)) {
                     return true;
+                }
 
-                if (t.inst != null)
-                    return visit(t.inst, s);
+                t.addBound(InferenceBound.EQ, s, Types.this);
 
-                t.inst = fromUnknownFun.apply(s);
-                for (List<Type> l = t.lobounds; l.nonEmpty(); l = l.tail) {
-                    if (!isSubtype(l.head, t.inst))
-                        return false;
-                }
-                for (List<Type> l = t.hibounds; l.nonEmpty(); l = l.tail) {
-                    if (!isSubtype(t.inst, l.head))
-                        return false;
-                }
                 return true;
             }
 
@@ -759,51 +1207,86 @@ public class Types {
             public Boolean visitErrorType(ErrorType t, Type s) {
                 return s.isErroneous() && t.tsym.name == s.tsym.name;
             }
+        }
+
+        /**
+         * Standard type-equality relation - type variables are considered
+         * equals if they share the same type symbol.
+         */
+        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());
+            }
+            @Override
+            protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
+                return containsTypeEquivalent(ts1, ts2);
+            }
         };
-    // </editor-fold>
 
-    // <editor-fold defaultstate="collapsed" desc="fromUnknownFun">
-    /**
-     * A mapping that turns all unknown types in this type to fresh
-     * unknown variables.
-     */
-    public Mapping fromUnknownFun = new Mapping("fromUnknownFun") {
-            public Type apply(Type t) {
-                if (t.tag == UNKNOWN) return new UndetVar(t);
-                else return t.map(this);
+        /**
+         * Strict type-equality relation - type variables are considered
+         * equals if they share the same object identity.
+         */
+        TypeRelation isSameTypeStrict = new SameTypeVisitor() {
+            @Override
+            boolean sameTypeVars(TypeVar tv1, TypeVar tv2) {
+                return tv1 == tv2;
+            }
+            @Override
+            protected boolean containsTypes(List<Type> ts1, List<Type> ts2) {
+                return isSameTypes(ts1, ts2, true);
+            }
+
+            @Override
+            public Boolean visitWildcardType(WildcardType t, Type s) {
+                if (!s.hasTag(WILDCARD)) {
+                    return false;
+                } else {
+                    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">
     public boolean containedBy(Type t, Type s) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case UNDETVAR:
-            if (s.tag == WILDCARD) {
+            if (s.hasTag(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: {
                         Type bound = upperBound(s);
-                        // We should check the new upper bound against any of the
-                        // undetvar's lower bounds.
-                        for (Type t2 : undetvar.lobounds) {
-                            if (!isSubtype(t2, bound))
-                                return false;
-                        }
-                        undetvar.hibounds = undetvar.hibounds.prepend(bound);
+                        undetvar.addBound(InferenceBound.UPPER, bound, this);
                         break;
                     }
                     case SUPER: {
                         Type bound = lowerBound(s);
-                        // We should check the new lower bound against any of the
-                        // undetvar's lower bounds.
-                        for (Type t2 : undetvar.hibounds) {
-                            if (!isSubtype(bound, t2))
-                                return false;
-                        }
-                        undetvar.lobounds = undetvar.lobounds.prepend(bound);
+                        undetvar.addBound(InferenceBound.LOWER, bound, this);
                         break;
                     }
                 }
@@ -859,8 +1342,8 @@ public class Types {
         private TypeRelation containsType = new TypeRelation() {
 
             private Type U(Type t) {
-                while (t.tag == WILDCARD) {
-                    WildcardType w = (WildcardType)t;
+                while (t.hasTag(WILDCARD)) {
+                    WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isSuperBound())
                         return w.bound == null ? syms.objectType : w.bound.bound;
                     else
@@ -870,8 +1353,8 @@ public class Types {
             }
 
             private Type L(Type t) {
-                while (t.tag == WILDCARD) {
-                    WildcardType w = (WildcardType)t;
+                while (t.hasTag(WILDCARD)) {
+                    WildcardType w = (WildcardType)t.unannotatedType();
                     if (w.isExtendsBound())
                         return syms.botType;
                     else
@@ -881,7 +1364,7 @@ public class Types {
             }
 
             public Boolean visitType(Type t, Type s) {
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return containedBy(s, t);
                 else
                     return isSameType(t, s);
@@ -903,7 +1386,7 @@ public class Types {
 
             @Override
             public Boolean visitWildcardType(WildcardType t, Type s) {
-                if (s.tag >= firstPartialTag)
+                if (s.isPartial())
                     return containedBy(s, t);
                 else {
 //                    debugContainsType(t, s);
@@ -916,10 +1399,11 @@ public class Types {
 
             @Override
             public Boolean visitUndetVar(UndetVar t, Type s) {
-                if (s.tag != WILDCARD)
+                if (!s.hasTag(WILDCARD)) {
                     return isSameType(t, s);
-                else
+                } else {
                     return false;
+                }
             }
 
             @Override
@@ -929,15 +1413,15 @@ public class Types {
         };
 
     public boolean isCaptureOf(Type s, WildcardType t) {
-        if (s.tag != TYPEVAR || !((TypeVar)s).isCaptured())
+        if (!s.hasTag(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)
+        if (!s.hasTag(WILDCARD))
             return false;
-        WildcardType w = (WildcardType)s;
+        WildcardType w = (WildcardType)s.unannotatedType();
         return w.kind == t.kind && w.type == t.type;
     }
 
@@ -951,9 +1435,29 @@ public class Types {
     }
     // </editor-fold>
 
+    /**
+     * Can t and s be compared for equality?  Any primitive ==
+     * primitive or primitive == object comparisons here are an error.
+     * Unboxing and correct primitive == primitive comparisons are
+     * already dealt with in Attr.visitBinary.
+     *
+     */
+    public boolean isEqualityComparable(Type s, Type t, Warner warn) {
+        if (t.isNumeric() && s.isNumeric())
+            return true;
+
+        boolean tPrimitive = t.isPrimitive();
+        boolean sPrimitive = s.isPrimitive();
+        if (!tPrimitive && !sPrimitive) {
+            return isCastable(s, t, warn) || isCastable(t, s, warn);
+        } else {
+            return false;
+        }
+    }
+
     // <editor-fold defaultstate="collapsed" desc="isCastable">
     public boolean isCastable(Type t, Type s) {
-        return isCastable(t, s, Warner.noWarnings);
+        return isCastable(t, s, noWarnings);
     }
 
     /**
@@ -987,15 +1491,15 @@ public class Types {
         private TypeRelation isCastable = new TypeRelation() {
 
             public Boolean visitType(Type t, Type s) {
-                if (s.tag == ERROR)
+                if (s.hasTag(ERROR))
                     return true;
 
-                switch (t.tag) {
+                switch (t.getTag()) {
                 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
                 case DOUBLE:
-                    return s.tag <= DOUBLE;
+                    return s.isNumeric();
                 case BOOLEAN:
-                    return s.tag == BOOLEAN;
+                    return s.hasTag(BOOLEAN);
                 case VOID:
                     return false;
                 case BOT:
@@ -1012,11 +1516,11 @@ public class Types {
 
             @Override
             public Boolean visitClassType(ClassType t, Type s) {
-                if (s.tag == ERROR || s.tag == BOT)
+                if (s.hasTag(ERROR) || s.hasTag(BOT))
                     return true;
 
-                if (s.tag == TYPEVAR) {
-                    if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
+                if (s.hasTag(TYPEVAR)) {
+                    if (isCastable(t, s.getUpperBound(), noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1024,30 +1528,17 @@ public class Types {
                     }
                 }
 
-                if (t.isCompound()) {
-                    Warner oldWarner = warnStack.head;
-                    warnStack.head = Warner.noWarnings;
-                    if (!visit(supertype(t), s))
-                        return false;
-                    for (Type intf : interfaces(t)) {
-                        if (!visit(intf, s))
-                            return false;
-                    }
-                    if (warnStack.head.hasLint(LintCategory.UNCHECKED))
-                        oldWarner.warn(LintCategory.UNCHECKED);
-                    return true;
-                }
-
-                if (s.isCompound()) {
-                    // call recursively to reuse the above code
-                    return visitClassType((ClassType)s, t);
+                if (t.isCompound() || s.isCompound()) {
+                    return !t.isCompound() ?
+                            visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) :
+                            visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false);
                 }
 
-                if (s.tag == CLASS || s.tag == ARRAY) {
+                if (s.hasTag(CLASS) || s.hasTag(ARRAY)) {
                     boolean upcast;
                     if ((upcast = isSubtype(erasure(t), erasure(s)))
                         || isSubtype(erasure(s), erasure(t))) {
-                        if (!upcast && s.tag == ARRAY) {
+                        if (!upcast && s.hasTag(ARRAY)) {
                             if (!isReifiable(s))
                                 warnStack.head.warn(LintCategory.UNCHECKED);
                             return true;
@@ -1100,7 +1591,7 @@ public class Types {
                     }
 
                     // Sidecast
-                    if (s.tag == CLASS) {
+                    if (s.hasTag(CLASS)) {
                         if ((s.tsym.flags() & INTERFACE) != 0) {
                             return ((t.tsym.flags() & FINAL) == 0)
                                 ? sideCast(t, s, warnStack.head)
@@ -1118,14 +1609,26 @@ public class Types {
                 return false;
             }
 
+            boolean visitIntersectionType(IntersectionClassType ict, Type s, boolean reverse) {
+                Warner warn = noWarnings;
+                for (Type c : ict.getComponents()) {
+                    warn.clear();
+                    if (reverse ? !isCastable(s, c, warn) : !isCastable(c, s, warn))
+                        return false;
+                }
+                if (warn.hasLint(LintCategory.UNCHECKED))
+                    warnStack.head.warn(LintCategory.UNCHECKED);
+                return true;
+            }
+
             @Override
             public Boolean visitArrayType(ArrayType t, Type s) {
-                switch (s.tag) {
+                switch (s.getTag()) {
                 case ERROR:
                 case BOT:
                     return true;
                 case TYPEVAR:
-                    if (isCastable(s, t, Warner.noWarnings)) {
+                    if (isCastable(s, t, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1134,9 +1637,8 @@ public class Types {
                 case CLASS:
                     return isSubtype(t, s);
                 case ARRAY:
-                    if (elemtype(t).tag <= lastBaseTag ||
-                            elemtype(s).tag <= lastBaseTag) {
-                        return elemtype(t).tag == elemtype(s).tag;
+                    if (elemtype(t).isPrimitive() || elemtype(s).isPrimitive()) {
+                        return elemtype(t).hasTag(elemtype(s).getTag());
                     } else {
                         return visit(elemtype(t), elemtype(s));
                     }
@@ -1147,14 +1649,14 @@ public class Types {
 
             @Override
             public Boolean visitTypeVar(TypeVar t, Type s) {
-                switch (s.tag) {
+                switch (s.getTag()) {
                 case ERROR:
                 case BOT:
                     return true;
                 case TYPEVAR:
                     if (isSubtype(t, s)) {
                         return true;
-                    } else if (isCastable(t.bound, s, Warner.noWarnings)) {
+                    } else if (isCastable(t.bound, s, noWarnings)) {
                         warnStack.head.warn(LintCategory.UNCHECKED);
                         return true;
                     } else {
@@ -1188,8 +1690,8 @@ public class Types {
      * conservative in that it is allowed to say that two types are
      * not disjoint, even though they actually are.
      *
-     * The type C<X> is castable to C<Y> exactly if X and Y are not
-     * disjoint.
+     * The type {@code C<X>} is castable to {@code C<Y>} exactly if
+     * {@code X} and {@code Y} are not disjoint.
      */
     public boolean disjointType(Type t, Type s) {
         return disjointType.visit(t, s);
@@ -1199,8 +1701,9 @@ public class Types {
 
             private Set<TypePair> cache = new HashSet<TypePair>();
 
+            @Override
             public Boolean visitType(Type t, Type s) {
-                if (s.tag == WILDCARD)
+                if (s.hasTag(WILDCARD))
                     return visit(s, t);
                 else
                     return notSoftSubtypeRecursive(t, s) || notSoftSubtypeRecursive(s, t);
@@ -1237,10 +1740,10 @@ public class Types {
                 if (t.isUnbound())
                     return false;
 
-                if (s.tag != WILDCARD) {
+                if (!s.hasTag(WILDCARD)) {
                     if (t.isExtendsBound())
                         return notSoftSubtypeRecursive(s, t.type);
-                    else // isSuperBound()
+                    else
                         return notSoftSubtypeRecursive(t.type, s);
                 }
 
@@ -1266,7 +1769,10 @@ public class Types {
      * Returns the lower bounds of the formals of a method.
      */
     public List<Type> lowerBoundArgtypes(Type t) {
-        return map(t.getParameterTypes(), lowerBoundMapping);
+        return lowerBounds(t.getParameterTypes());
+    }
+    public List<Type> lowerBounds(List<Type> ts) {
+        return map(ts, lowerBoundMapping);
     }
     private final Mapping lowerBoundMapping = new Mapping("lowerBound") {
             public Type apply(Type t) {
@@ -1281,26 +1787,26 @@ public class Types {
      * something of type `t' can be a subtype of `s'? This is
      * different from the question "is `t' not a subtype of `s'?"
      * when type variables are involved: Integer is not a subtype of T
-     * where <T extends Number> but it is not true that Integer cannot
+     * where {@code <T extends Number>} but it is not true that Integer cannot
      * possibly be a subtype of T.
      */
     public boolean notSoftSubtype(Type t, Type s) {
         if (t == s) return false;
-        if (t.tag == TYPEVAR) {
+        if (t.hasTag(TYPEVAR)) {
             TypeVar tv = (TypeVar) t;
             return !isCastable(tv.bound,
                                relaxBound(s),
-                               Warner.noWarnings);
+                               noWarnings);
         }
-        if (s.tag != WILDCARD)
+        if (!s.hasTag(WILDCARD))
             s = upperBound(s);
 
         return !isSubtype(t, relaxBound(s));
     }
 
     private Type relaxBound(Type t) {
-        if (t.tag == TYPEVAR) {
-            while (t.tag == TYPEVAR)
+        if (t.hasTag(TYPEVAR)) {
+            while (t.hasTag(TYPEVAR))
                 t = t.getUpperBound();
             t = rewriteQuantifiers(t, true, true);
         }
@@ -1349,19 +1855,20 @@ public class Types {
 
     // <editor-fold defaultstate="collapsed" desc="Array Utils">
     public boolean isArray(Type t) {
-        while (t.tag == WILDCARD)
+        while (t.hasTag(WILDCARD))
             t = upperBound(t);
-        return t.tag == ARRAY;
+        return t.hasTag(ARRAY);
     }
 
     /**
      * The element type of an array.
      */
     public Type elemtype(Type t) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case WILDCARD:
             return elemtype(upperBound(t));
         case ARRAY:
+            t = t.unannotatedType();
             return ((ArrayType)t).elemtype;
         case FORALL:
             return elemtype(((ForAll)t).qtype);
@@ -1391,12 +1898,25 @@ public class Types {
      */
     public int dimensions(Type t) {
         int result = 0;
-        while (t.tag == ARRAY) {
+        while (t.hasTag(ARRAY)) {
             result++;
             t = elemtype(t);
         }
         return result;
     }
+
+    /**
+     * Returns an ArrayType with the component type t
+     *
+     * @param t The component type of the ArrayType
+     * @return the ArrayType for the given component
+     */
+    public ArrayType makeArrayType(Type t) {
+        if (t.hasTag(VOID) || t.hasTag(PACKAGE)) {
+            Assert.error("Type t must not be a VOID or PACKAGE type, " + t.toString());
+        }
+        return new ArrayType(t, syms.arrayClass);
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="asSuper">
@@ -1423,11 +1943,11 @@ public class Types {
                     return t;
 
                 Type st = supertype(t);
-                if (st.tag == CLASS || st.tag == TYPEVAR || st.tag == ERROR) {
+                if (st.hasTag(CLASS) || st.hasTag(TYPEVAR) || st.hasTag(ERROR)) {
                     Type x = asSuper(st, sym);
                     if (x != null)
                         return x;
-                } else if (st.tag == NONE && t.tsym.type.isErroneous() && t.tsym.flatName() != names.java_lang_Object) {
+                } else if (st.hasTag(NONE) && t.tsym.type.isErroneous() && t.tsym.flatName() != names.java_lang_Object) {
                     return t.tsym.type;
                 }
                 if (sym != null && (sym.flags() & INTERFACE) != 0) {
@@ -1467,13 +1987,13 @@ public class Types {
      * @param sym a symbol
      */
     public Type asOuterSuper(Type t, Symbol sym) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case CLASS:
             do {
                 Type s = asSuper(t, sym);
                 if (s != null) return s;
                 t = t.getEnclosingType();
-            } while (t.tag == CLASS);
+            } while (t.hasTag(CLASS));
             return null;
         case ARRAY:
             return isSubtype(t, sym.type) ? sym.type : null;
@@ -1494,16 +2014,16 @@ public class Types {
      * @param sym a symbol
      */
     public Type asEnclosingSuper(Type t, Symbol sym) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case CLASS:
             do {
                 Type s = asSuper(t, sym);
                 if (s != null) return s;
                 Type outer = t.getEnclosingType();
-                t = (outer.tag == CLASS) ? outer :
+                t = (outer.hasTag(CLASS)) ? outer :
                     (t.tsym.owner.enclClass() != null) ? t.tsym.owner.enclClass().type :
                     Type.noType;
-            } while (t.tag == CLASS);
+            } while (t.hasTag(CLASS));
             return null;
         case ARRAY:
             return isSubtype(t, sym.type) ? sym.type : null;
@@ -1583,7 +2103,7 @@ public class Types {
 
     // <editor-fold defaultstate="collapsed" desc="isAssignable">
     public boolean isAssignable(Type t, Type s) {
-        return isAssignable(t, s, Warner.noWarnings);
+        return isAssignable(t, s, noWarnings);
     }
 
     /**
@@ -1593,9 +2113,9 @@ public class Types {
      * (not defined for Method and ForAll types)
      */
     public boolean isAssignable(Type t, Type s, Warner warn) {
-        if (t.tag <= INT && t.constValue() != null) {
+        if (t.getTag().isSubRangeOf(INT) && t.constValue() != null) {
             int value = ((Number)t.constValue()).intValue();
-            switch (s.tag) {
+            switch (s.getTag()) {
             case BYTE:
                 if (Byte.MIN_VALUE <= value && value <= Byte.MAX_VALUE)
                     return true;
@@ -1611,7 +2131,7 @@ public class Types {
             case INT:
                 return true;
             case CLASS:
-                switch (unboxedType(s).tag) {
+                switch (unboxedType(s).getTag()) {
                 case BYTE:
                 case CHAR:
                 case SHORT:
@@ -1630,16 +2150,18 @@ public class Types {
      * type parameters in t are deleted.
      */
     public Type erasure(Type t) {
-        return eraseNotNeeded(t)? t : erasure(t, false);
+        return (t == null || eraseNotNeeded(t)) ? t : erasure(t, false);
     }
     //where
     private boolean eraseNotNeeded(Type t) {
-        return (t.tag <= lastBaseTag) || (syms.stringType.tsym == t.tsym);
+        // We don't want to erase primitive types and String type as that
+        // operation is idempotent. Also, erasing these could result in loss
+        // of information such as constant values attached to such types.
+        return (t.isPrimitive()) || (syms.stringType.tsym == t.tsym);
     }
 
-    //where
     private Type erasure(Type t, boolean recurse) {
-        if (t == null || t.tag <= lastBaseTag)
+        if (t == null || t.isPrimitive())
             return t; /* fast special case */
         else
             return erasure.visit(t, recurse);
@@ -1647,7 +2169,7 @@ public class Types {
     // where
         private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() {
             public Type visitType(Type t, Boolean recurse) {
-                if (t.tag <= lastBaseTag)
+                if (t.isPrimitive())
                     return t; /*fast special case*/
                 else
                     return t.map(recurse ? erasureRecFun : erasureFun);
@@ -1676,6 +2198,19 @@ public class Types {
             public Type visitErrorType(ErrorType t, Boolean recurse) {
                 return t;
             }
+
+            @Override
+            public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) {
+                Type erased = erasure(t.underlyingType, recurse);
+                if (erased.isAnnotated()) {
+                    // This can only happen when the underlying type is a
+                    // type variable and the upper bound of it is annotated.
+                    // The annotation on the type variable overrides the one
+                    // on the bound.
+                    erased = ((AnnotatedType)erased).underlyingType;
+                }
+                return new AnnotatedType(t.typeAnnotations, erased);
+            }
         };
 
     private Mapping erasureFun = new Mapping ("erasure") {
@@ -1707,45 +2242,28 @@ public class Types {
      * @param supertype         is objectType if all bounds are interfaces,
      *                          null otherwise.
      */
-    public Type makeCompoundType(List<Type> bounds,
-                                 Type supertype) {
+    public Type makeCompoundType(List<Type> bounds) {
+        return makeCompoundType(bounds, bounds.head.tsym.isInterface());
+    }
+    public Type makeCompoundType(List<Type> bounds, boolean allInterfaces) {
+        Assert.check(bounds.nonEmpty());
+        Type firstExplicitBound = bounds.head;
+        if (allInterfaces) {
+            bounds = bounds.prepend(syms.objectType);
+        }
         ClassSymbol bc =
             new ClassSymbol(ABSTRACT|PUBLIC|SYNTHETIC|COMPOUND|ACYCLIC,
                             Type.moreInfo
                                 ? names.fromString(bounds.toString())
                                 : names.empty,
+                            null,
                             syms.noSymbol);
-        if (bounds.head.tag == TYPEVAR)
-            // error condition, recover
-                bc.erasure_field = syms.objectType;
-            else
-                bc.erasure_field = erasure(bounds.head);
-            bc.members_field = new Scope(bc);
-        ClassType bt = (ClassType)bc.type;
-        bt.allparams_field = List.nil();
-        if (supertype != null) {
-            bt.supertype_field = supertype;
-            bt.interfaces_field = bounds;
-        } else {
-            bt.supertype_field = bounds.head;
-            bt.interfaces_field = bounds.tail;
-        }
-        Assert.check(bt.supertype_field.tsym.completer != null
-                || !bt.supertype_field.isInterface(),
-            bt.supertype_field);
-        return bt;
-    }
-
-    /**
-     * Same as {@link #makeCompoundType(List,Type)}, except that the
-     * second parameter is computed directly. Note that this might
-     * cause a symbol completion.  Hence, this version of
-     * makeCompoundType may not be called during a classfile read.
-     */
-    public Type makeCompoundType(List<Type> bounds) {
-        Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
-            supertype(bounds.head) : null;
-        return makeCompoundType(bounds, supertype);
+        bc.type = new IntersectionClassType(bounds, bc, allInterfaces);
+        bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ?
+                syms.objectType : // error condition, recover
+                erasure(firstExplicitBound);
+        bc.members_field = new Scope(bc);
+        return bc.type;
     }
 
     /**
@@ -1804,7 +2322,7 @@ public class Types {
              */
             @Override
             public Type visitTypeVar(TypeVar t, Void ignored) {
-                if (t.bound.tag == TYPEVAR ||
+                if (t.bound.hasTag(TYPEVAR) ||
                     (!t.bound.isCompound() && !t.bound.isInterface())) {
                     return t.bound;
                 } else {
@@ -1822,7 +2340,7 @@ public class Types {
 
             @Override
             public Type visitErrorType(ErrorType t, Void ignored) {
-                return t;
+                return Type.noType;
             }
         };
     // </editor-fold>
@@ -1889,6 +2407,13 @@ public class Types {
                 return List.nil();
             }
         };
+
+    public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
+        for (Type i2 : interfaces(origin.type)) {
+            if (isym == i2.tsym) return true;
+        }
+        return false;
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="isDerivedRaw">
@@ -1928,12 +2453,8 @@ public class Types {
      * @param supertype         is objectType if all bounds are interfaces,
      *                          null otherwise.
      */
-    public void setBounds(TypeVar t, List<Type> bounds, Type supertype) {
-        if (bounds.tail.isEmpty())
-            t.bound = bounds.head;
-        else
-            t.bound = makeCompoundType(bounds, supertype);
-        t.rank_field = -1;
+    public void setBounds(TypeVar t, List<Type> bounds) {
+        setBounds(t, bounds, bounds.head.tsym.isInterface());
     }
 
     /**
@@ -1945,10 +2466,10 @@ public class Types {
      * Note that this check might cause a symbol completion. Hence, this version of
      * setBounds may not be called during a classfile read.
      */
-    public void setBounds(TypeVar t, List<Type> bounds) {
-        Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
-            syms.objectType : null;
-        setBounds(t, bounds, supertype);
+    public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) {
+        t.bound = bounds.tail.isEmpty() ?
+                bounds.head :
+                makeCompoundType(bounds, allInterfaces);
         t.rank_field = -1;
     }
     // </editor-fold>
@@ -1958,7 +2479,9 @@ public class Types {
      * Return list of bounds of the given type variable.
      */
     public List<Type> getBounds(TypeVar t) {
-        if (t.bound.isErroneous() || !t.bound.isCompound())
+        if (t.bound.hasTag(NONE))
+            return List.nil();
+        else if (t.bound.isErroneous() || !t.bound.isCompound())
             return List.of(t.bound);
         else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
             return interfaces(t).prepend(supertype(t));
@@ -2044,6 +2567,15 @@ public class Types {
             hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
     }
 
+    public boolean overridesObjectMethod(TypeSymbol origin, Symbol msym) {
+        for (Scope.Entry e = syms.objectType.tsym.members().lookup(msym.name) ; e.scope != null ; e = e.next()) {
+            if (msym.overrides(e.sym, origin, Types.this, true)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
     class ImplementationCache {
 
@@ -2094,8 +2626,8 @@ public class Types {
         }
 
         private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
-            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
-                while (t.tag == TYPEVAR)
+            for (Type t = origin.type; t.hasTag(CLASS) || t.hasTag(TYPEVAR); t = supertype(t)) {
+                while (t.hasTag(TYPEVAR))
                     t = t.getUpperBound();
                 TypeSymbol c = t.tsym;
                 for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
@@ -2137,6 +2669,8 @@ public class Types {
             }
         }
 
+        List<TypeSymbol> seenTypes = List.nil();
+
         /** members closure visitor methods **/
 
         public CompoundScope visitType(Type t, Boolean skipInterface) {
@@ -2145,21 +2679,33 @@ public class Types {
 
         @Override
         public CompoundScope visitClassType(ClassType t, Boolean skipInterface) {
-            ClassSymbol csym = (ClassSymbol)t.tsym;
-            Entry e = _map.get(csym);
-            if (e == null || !e.matches(skipInterface)) {
-                CompoundScope membersClosure = new CompoundScope(csym);
-                if (!skipInterface) {
-                    for (Type i : interfaces(t)) {
-                        membersClosure.addSubScope(visit(i, skipInterface));
+            if (seenTypes.contains(t.tsym)) {
+                //this is possible when an interface is implemented in multiple
+                //superclasses, or when a classs hierarchy is circular - in such
+                //cases we don't need to recurse (empty scope is returned)
+                return new CompoundScope(t.tsym);
+            }
+            try {
+                seenTypes = seenTypes.prepend(t.tsym);
+                ClassSymbol csym = (ClassSymbol)t.tsym;
+                Entry e = _map.get(csym);
+                if (e == null || !e.matches(skipInterface)) {
+                    CompoundScope membersClosure = new CompoundScope(csym);
+                    if (!skipInterface) {
+                        for (Type i : interfaces(t)) {
+                            membersClosure.addSubScope(visit(i, skipInterface));
+                        }
                     }
+                    membersClosure.addSubScope(visit(supertype(t), skipInterface));
+                    membersClosure.addSubScope(csym.members());
+                    e = new Entry(skipInterface, membersClosure);
+                    _map.put(csym, e);
                 }
-                membersClosure.addSubScope(visit(supertype(t), skipInterface));
-                membersClosure.addSubScope(csym.members());
-                e = new Entry(skipInterface, membersClosure);
-                _map.put(csym, e);
+                return e.compoundScope;
+            }
+            finally {
+                seenTypes = seenTypes.tail;
             }
-            return e.compoundScope;
         }
 
         @Override
@@ -2175,6 +2721,59 @@ public class Types {
     }
     // </editor-fold>
 
+
+    //where
+    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
+        Filter<Symbol> filter = new MethodFilter(ms, site);
+        List<MethodSymbol> candidates = List.nil();
+            for (Symbol s : membersClosure(site, false).getElements(filter)) {
+                if (!site.tsym.isInterface() && !s.owner.isInterface()) {
+                    return List.of((MethodSymbol)s);
+                } else if (!candidates.contains(s)) {
+                    candidates = candidates.prepend((MethodSymbol)s);
+                }
+            }
+            return prune(candidates);
+        }
+
+    public List<MethodSymbol> prune(List<MethodSymbol> methods) {
+        ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
+        for (MethodSymbol m1 : methods) {
+            boolean isMin_m1 = true;
+            for (MethodSymbol m2 : methods) {
+                if (m1 == m2) continue;
+                if (m2.owner != m1.owner &&
+                        asSuper(m2.owner.type, m1.owner) != null) {
+                    isMin_m1 = false;
+                    break;
+                }
+            }
+            if (isMin_m1)
+                methodsMin.append(m1);
+        }
+        return methodsMin.toList();
+    }
+    // where
+            private class MethodFilter implements Filter<Symbol> {
+
+                Symbol msym;
+                Type site;
+
+                MethodFilter(Symbol msym, Type site) {
+                    this.msym = msym;
+                    this.site = site;
+                }
+
+                public boolean accepts(Symbol s) {
+                    return s.kind == Kinds.MTH &&
+                            s.name == msym.name &&
+                            (s.flags() & SYNTHETIC) == 0 &&
+                            s.isInheritedIn(site.tsym, Types.this) &&
+                            overrideEquivalent(memberType(site, s), memberType(site, msym));
+                }
+            };
+    // </editor-fold>
+
     /**
      * Does t have the same arguments as s?  It is assumed that both
      * types are (possibly polymorphic) method types.  Monomorphic
@@ -2210,13 +2809,13 @@ public class Types {
 
             @Override
             public Boolean visitMethodType(MethodType t, Type s) {
-                return s.tag == METHOD
+                return s.hasTag(METHOD)
                     && containsTypeEquivalent(t.argtypes, s.getParameterTypes());
             }
 
             @Override
             public Boolean visitForAll(ForAll t, Type s) {
-                if (s.tag != FORALL)
+                if (!s.hasTag(FORALL))
                     return strict ? false : visitMethodType(t.asMethodType(), s);
 
                 ForAll forAll = (ForAll)s;
@@ -2361,7 +2960,7 @@ public class Types {
             if (elemtype == t.elemtype)
                 return t;
             else
-                return new ArrayType(upperBound(elemtype), t.tsym);
+                return new ArrayType(elemtype, t.tsym);
         }
 
         @Override
@@ -2550,7 +3149,8 @@ public class Types {
      * graph. Undefined for all but reference types.
      */
     public int rank(Type t) {
-        switch(t.tag) {
+        t = t.unannotatedType();
+        switch(t.getTag()) {
         case CLASS: {
             ClassType cls = (ClassType)t;
             if (cls.rank_field < 0) {
@@ -2621,7 +3221,7 @@ public class Types {
      */
     @Deprecated
     public String toString(Type t) {
-        if (t.tag == FORALL) {
+        if (t.hasTag(FORALL)) {
             ForAll forAll = (ForAll)t;
             return typaramsString(forAll.tvars) + forAll.qtype;
         }
@@ -2635,7 +3235,7 @@ public class Types {
             for (Type t : tvars) {
                 if (!first) s.append(", ");
                 first = false;
-                appendTyparamString(((TypeVar)t), s);
+                appendTyparamString(((TypeVar)t.unannotatedType()), s);
             }
             s.append('>');
             return s.toString();
@@ -2689,9 +3289,9 @@ public class Types {
             if (st == null) // FIXME: shouldn't be null
                 st = Type.noType;
             if (!t.isCompound()) {
-                if (st.tag == CLASS) {
+                if (st.hasTag(CLASS)) {
                     cl = insert(closure(st), t);
-                } else if (st.tag == TYPEVAR) {
+                } else if (st.hasTag(TYPEVAR)) {
                     cl = closure(st).prepend(t);
                 } else {
                     cl = List.of(t);
@@ -2744,20 +3344,22 @@ public class Types {
             return cl1;
         if (cl1.isEmpty() || cl2.isEmpty())
             return List.nil();
-        if (cl1.head.tsym.precedes(cl2.head.tsym, this))
-            return intersect(cl1.tail, cl2);
-        if (cl2.head.tsym.precedes(cl1.head.tsym, this))
-            return intersect(cl1, cl2.tail);
-        if (isSameType(cl1.head, cl2.head))
-            return intersect(cl1.tail, cl2.tail).prepend(cl1.head);
-        if (cl1.head.tsym == cl2.head.tsym &&
-            cl1.head.tag == CLASS && cl2.head.tag == CLASS) {
-            if (cl1.head.isParameterized() && cl2.head.isParameterized()) {
-                Type merge = merge(cl1.head,cl2.head);
-                return intersect(cl1.tail, cl2.tail).prepend(merge);
-            }
-            if (cl1.head.isRaw() || cl2.head.isRaw())
-                return intersect(cl1.tail, cl2.tail).prepend(erasure(cl1.head));
+        if (cl1.head != null && cl1.head.tsym != null && cl2.head != null && cl2.head.tsym != null) {
+            if (cl1.head.tsym.precedes(cl2.head.tsym, this))
+                return intersect(cl1.tail, cl2);
+            if (cl2.head.tsym.precedes(cl1.head.tsym, this))
+                return intersect(cl1, cl2.tail);
+            if (isSameType(cl1.head, cl2.head))
+                return intersect(cl1.tail, cl2.tail).prepend(cl1.head);
+            if (cl1.head.tsym == cl2.head.tsym &&
+                cl1.head.hasTag(CLASS) && cl2.head.hasTag(CLASS)) {
+                if (cl1.head.isParameterized() && cl2.head.isParameterized()) {
+                    Type merge = merge(cl1.head,cl2.head);
+                    return intersect(cl1.tail, cl2.tail).prepend(merge);
+                }
+                if (cl1.head.isRaw() || cl2.head.isRaw())
+                    return intersect(cl1.tail, cl2.tail).prepend(erasure(cl1.head));
+            }
         }
         return intersect(cl1.tail, cl2.tail);
     }
@@ -2771,7 +3373,7 @@ public class Types {
             }
             @Override
             public int hashCode() {
-                return 127 * Types.hashCode(t1) + Types.hashCode(t2);
+                return 127 * Types.this.hashCode(t1) + Types.this.hashCode(t2);
             }
             @Override
             public boolean equals(Object obj) {
@@ -2886,7 +3488,7 @@ public class Types {
         final int CLASS_BOUND = 2;
         int boundkind = 0;
         for (Type t : ts) {
-            switch (t.tag) {
+            switch (t.getTag()) {
             case CLASS:
                 boundkind |= CLASS_BOUND;
                 break;
@@ -2896,8 +3498,8 @@ public class Types {
             case  TYPEVAR:
                 do {
                     t = t.getUpperBound();
-                } while (t.tag == TYPEVAR);
-                if (t.tag == ARRAY) {
+                } while (t.hasTag(TYPEVAR));
+                if (t.hasTag(ARRAY)) {
                     boundkind |= ARRAY_BOUND;
                 } else {
                     boundkind |= CLASS_BOUND;
@@ -2937,13 +3539,14 @@ public class Types {
 
         case CLASS_BOUND:
             // calculate lub(A, B)
-            while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
+            while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) {
                 ts = ts.tail;
+            }
             Assert.check(!ts.isEmpty());
             //step 1 - compute erased candidate set (EC)
             List<Type> cl = erasedSupertypes(ts.head);
             for (Type t : ts.tail) {
-                if (t.tag == CLASS || t.tag == TYPEVAR)
+                if (t.hasTag(CLASS) || t.hasTag(TYPEVAR))
                     cl = intersect(cl, erasedSupertypes(t));
             }
             //step 2 - compute minimal erased candidate set (MEC)
@@ -2965,7 +3568,7 @@ public class Types {
             // calculate lub(A, B[])
             List<Type> classes = List.of(arraySuperType());
             for (Type t : ts) {
-                if (t.tag != ARRAY) // Filter out any arrays
+                if (!t.hasTag(ARRAY)) // Filter out any arrays
                     classes = classes.prepend(t);
             }
             // lub(A, B[]) is lub(A, arraySuperType)
@@ -2976,7 +3579,7 @@ public class Types {
         List<Type> erasedSupertypes(Type t) {
             ListBuffer<Type> buf = lb();
             for (Type sup : closure(t)) {
-                if (sup.tag == TYPEVAR) {
+                if (sup.hasTag(TYPEVAR)) {
                     buf.append(sup);
                 } else {
                     buf.append(erasure(sup));
@@ -2993,8 +3596,7 @@ public class Types {
                     if (arraySuperType == null) {
                         // JLS 10.8: all arrays implement Cloneable and Serializable.
                         arraySuperType = makeCompoundType(List.of(syms.serializableType,
-                                                                  syms.cloneableType),
-                                                          syms.objectType);
+                                                                  syms.cloneableType), true);
                     }
                 }
             }
@@ -3046,14 +3648,14 @@ public class Types {
     /**
      * Compute a hash code on a type.
      */
-    public static int hashCode(Type t) {
+    public int hashCode(Type t) {
         return hashCode.visit(t);
     }
     // where
         private static final UnaryVisitor<Integer> hashCode = new UnaryVisitor<Integer>() {
 
             public Integer visitType(Type t, Void ignored) {
-                return t.tag;
+                return t.getTag().ordinal();
             }
 
             @Override
@@ -3069,6 +3671,16 @@ public class Types {
             }
 
             @Override
+            public Integer visitMethodType(MethodType t, Void ignored) {
+                int h = METHOD.ordinal();
+                for (List<Type> thisargs = t.argtypes;
+                     thisargs.tail != null;
+                     thisargs = thisargs.tail)
+                    h = (h << 5) + visit(thisargs.head);
+                return (h << 5) + visit(t.restype);
+            }
+
+            @Override
             public Integer visitWildcardType(WildcardType t, Void ignored) {
                 int result = t.kind.hashCode();
                 if (t.type != null) {
@@ -3123,11 +3735,11 @@ public class Types {
      */
     public boolean returnTypeSubstitutable(Type r1, Type r2) {
         if (hasSameArgs(r1, r2))
-            return resultSubtype(r1, r2, Warner.noWarnings);
+            return resultSubtype(r1, r2, noWarnings);
         else
             return covariantReturnType(r1.getReturnType(),
                                        erasure(r2.getReturnType()),
-                                       Warner.noWarnings);
+                                       noWarnings);
     }
 
     public boolean returnTypeSubstitutable(Type r1,
@@ -3169,7 +3781,7 @@ public class Types {
      * Return the class that boxes the given primitive.
      */
     public ClassSymbol boxedClass(Type t) {
-        return reader.enterClass(syms.boxedName[t.tag]);
+        return reader.enterClass(syms.boxedName[t.getTag().ordinal()]);
     }
 
     /**
@@ -3197,6 +3809,14 @@ public class Types {
         }
         return Type.noType;
     }
+
+    /**
+     * Return the unboxed type if 't' is a boxed class, otherwise return 't' itself.
+     */
+    public Type unboxedTypeOrType(Type t) {
+        Type unboxedType = unboxedType(t);
+        return unboxedType.hasTag(NONE) ? t : unboxedType;
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="Capture conversion">
@@ -3245,7 +3865,7 @@ public class Types {
         return buf.reverse();
     }
     public Type capture(Type t) {
-        if (t == null || t.tag != CLASS)
+        if (t == null || !t.hasTag(CLASS))
             return t;
         if (t.getEnclosingType() != Type.noType) {
             Type capturedEncl = capture(t.getEnclosingType());
@@ -3254,6 +3874,7 @@ public class Types {
                 t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
             }
         }
+        t = t.unannotatedType();
         ClassType cls = (ClassType)t;
         if (cls.isRaw() || !cls.isParameterized())
             return cls;
@@ -3272,9 +3893,9 @@ public class Types {
                !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) {
@@ -3310,7 +3931,8 @@ public class Types {
         public List<Type> freshTypeVariables(List<Type> types) {
             ListBuffer<Type> result = lb();
             for (Type t : types) {
-                if (t.tag == WILDCARD) {
+                if (t.hasTag(WILDCARD)) {
+                    t = t.unannotatedType();
                     Type bound = ((WildcardType)t).getExtendsBound();
                     if (bound == null)
                         bound = syms.objectType;
@@ -3403,11 +4025,18 @@ public class Types {
     }
 
     private boolean giveWarning(Type from, Type to) {
-        Type subFrom = asSub(from, to.tsym);
-        return to.isParameterized() &&
-                (!(isUnbounded(to) ||
-                isSubtype(from, to) ||
-                ((subFrom != null) && containsType(to.allparams(), subFrom.allparams()))));
+        List<Type> bounds = to.isCompound() ?
+                ((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to);
+        for (Type b : bounds) {
+            Type subFrom = asSub(from, b.tsym);
+            if (b.isParameterized() &&
+                    (!(isUnbounded(b) ||
+                    isSubtype(from, b) ||
+                    ((subFrom != null) && containsType(b.allparams(), subFrom.allparams()))))) {
+                return true;
+            }
+        }
+        return false;
     }
 
     private List<Type> superClosure(Type t, Type s) {
@@ -3472,14 +4101,14 @@ public class Types {
 
         @Override
         public Void visitClassType(ClassType source, Type target) throws AdaptFailure {
-            if (target.tag == CLASS)
+            if (target.hasTag(CLASS))
                 adaptRecursive(source.allparams(), target.allparams());
             return null;
         }
 
         @Override
         public Void visitArrayType(ArrayType source, Type target) throws AdaptFailure {
-            if (target.tag == ARRAY)
+            if (target.hasTag(ARRAY))
                 adaptRecursive(elemtype(source), elemtype(target));
             return null;
         }
@@ -3619,44 +4248,49 @@ public class Types {
 
         @Override
         public Type visitCapturedType(CapturedType t, Void s) {
-            Type bound = visitWildcardType(t.wildcard, null);
-            return (bound.contains(t)) ?
-                    erasure(bound) :
-                    bound;
+            Type w_bound = t.wildcard.type;
+            Type bound = w_bound.contains(t) ?
+                        erasure(w_bound) :
+                        visit(w_bound);
+            return rewriteAsWildcardType(visit(bound), t.wildcard.bound, t.wildcard.kind);
         }
 
         @Override
         public Type visitTypeVar(TypeVar t, Void s) {
             if (rewriteTypeVars) {
-                Type bound = high ?
-                    (t.bound.contains(t) ?
+                Type bound = t.bound.contains(t) ?
                         erasure(t.bound) :
-                        visit(t.bound)) :
-                    syms.botType;
-                return rewriteAsWildcardType(bound, t);
-            }
-            else
+                        visit(t.bound);
+                return rewriteAsWildcardType(bound, t, EXTENDS);
+            } else {
                 return t;
+            }
         }
 
         @Override
         public Type visitWildcardType(WildcardType t, Void s) {
-            Type bound = high ? t.getExtendsBound() :
-                                t.getSuperBound();
-            if (bound == null)
-            bound = high ? syms.objectType : syms.botType;
-            return rewriteAsWildcardType(visit(bound), t.bound);
+            Type bound2 = visit(t.type);
+            return t.type == bound2 ? t : rewriteAsWildcardType(bound2, t.bound, t.kind);
         }
 
-        private Type rewriteAsWildcardType(Type bound, TypeVar formal) {
-            return high ?
-                makeExtendsWildcard(B(bound), formal) :
-                makeSuperWildcard(B(bound), formal);
+        private Type rewriteAsWildcardType(Type bound, TypeVar formal, BoundKind bk) {
+            switch (bk) {
+               case EXTENDS: return high ?
+                       makeExtendsWildcard(B(bound), formal) :
+                       makeExtendsWildcard(syms.objectType, formal);
+               case SUPER: return high ?
+                       makeSuperWildcard(syms.botType, formal) :
+                       makeSuperWildcard(B(bound), formal);
+               case UNBOUND: return makeExtendsWildcard(syms.objectType, formal);
+               default:
+                   Assert.error("Invalid bound kind " + bk);
+                   return null;
+            }
         }
 
         Type B(Type t) {
-            while (t.tag == WILDCARD) {
-                WildcardType w = (WildcardType)t;
+            while (t.hasTag(WILDCARD)) {
+                WildcardType w = (WildcardType)t.unannotatedType();
                 t = high ?
                     w.getExtendsBound() :
                     w.getSuperBound();
@@ -3700,7 +4334,7 @@ public class Types {
      * substituted by the wildcard
      */
     private WildcardType makeSuperWildcard(Type bound, TypeVar formal) {
-        if (bound.tag == BOT) {
+        if (bound.hasTag(BOT)) {
             return new WildcardType(syms.objectType,
                                     BoundKind.UNBOUND,
                                     syms.boundClass,
@@ -3716,21 +4350,28 @@ public class Types {
     /**
      * A wrapper for a type that allows use in sets.
      */
-    class SingletonType {
-        final Type t;
-        SingletonType(Type t) {
-            this.t = t;
+    public static class UniqueType {
+        public final Type type;
+        final Types types;
+
+        public UniqueType(Type type, Types types) {
+            this.type = type;
+            this.types = types;
         }
+
         public int hashCode() {
-            return Types.hashCode(t);
+            return types.hashCode(type);
         }
+
         public boolean equals(Object obj) {
-            return (obj instanceof SingletonType) &&
-                isSameType(t, ((SingletonType)obj).t);
+            return (obj instanceof UniqueType) &&
+                types.isSameAnnotatedType(type, ((UniqueType)obj).type);
         }
+
         public String toString() {
-            return t.toString();
+            return type.toString();
         }
+
     }
     // </editor-fold>
 
@@ -3759,6 +4400,8 @@ public class Types {
         public R visitForAll(ForAll t, S s)             { return visitType(t, s); }
         public R visitUndetVar(UndetVar t, S s)         { return visitType(t, s); }
         public R visitErrorType(ErrorType t, S s)       { return visitType(t, s); }
+        // Pretend annotations don't exist
+        public R visitAnnotatedType(AnnotatedType t, S s) { return visit(t.underlyingType, s); }
     }
 
     /**
@@ -3850,8 +4493,12 @@ public class Types {
     // <editor-fold defaultstate="collapsed" desc="Annotation support">
 
     public RetentionPolicy getRetention(Attribute.Compound a) {
+        return getRetention(a.type.tsym);
+    }
+
+    public RetentionPolicy getRetention(Symbol sym) {
         RetentionPolicy vis = RetentionPolicy.CLASS; // the default
-        Attribute.Compound c = a.type.tsym.attribute(syms.retentionType.tsym);
+        Attribute.Compound c = sym.attribute(syms.retentionType.tsym);
         if (c != null) {
             Attribute value = c.member(names.value);
             if (value != null && value instanceof Attribute.Enum) {
@@ -3865,4 +4512,177 @@ public class Types {
         return vis;
     }
     // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Signature Generation">
+
+    public static abstract class SignatureGenerator {
+
+        private final Types types;
+
+        protected abstract void append(char ch);
+        protected abstract void append(byte[] ba);
+        protected abstract void append(Name name);
+        protected void classReference(ClassSymbol c) { /* by default: no-op */ }
+
+        protected SignatureGenerator(Types types) {
+            this.types = types;
+        }
+
+        /**
+         * Assemble signature of given type in string buffer.
+         */
+        public void assembleSig(Type type) {
+            type = type.unannotatedType();
+            switch (type.getTag()) {
+                case BYTE:
+                    append('B');
+                    break;
+                case SHORT:
+                    append('S');
+                    break;
+                case CHAR:
+                    append('C');
+                    break;
+                case INT:
+                    append('I');
+                    break;
+                case LONG:
+                    append('J');
+                    break;
+                case FLOAT:
+                    append('F');
+                    break;
+                case DOUBLE:
+                    append('D');
+                    break;
+                case BOOLEAN:
+                    append('Z');
+                    break;
+                case VOID:
+                    append('V');
+                    break;
+                case ERROR:
+                case CLASS:
+                    append('L');
+                    assembleClassSig(type);
+                    append(';');
+                    break;
+                case ARRAY:
+                    ArrayType at = (ArrayType) type;
+                    append('[');
+                    assembleSig(at.elemtype);
+                    break;
+                case METHOD:
+                    MethodType mt = (MethodType) type;
+                    append('(');
+                    assembleSig(mt.argtypes);
+                    append(')');
+                    assembleSig(mt.restype);
+                    if (hasTypeVar(mt.thrown)) {
+                        for (List<Type> l = mt.thrown; l.nonEmpty(); l = l.tail) {
+                            append('^');
+                            assembleSig(l.head);
+                        }
+                    }
+                    break;
+                case WILDCARD: {
+                    Type.WildcardType ta = (Type.WildcardType) type;
+                    switch (ta.kind) {
+                        case SUPER:
+                            append('-');
+                            assembleSig(ta.type);
+                            break;
+                        case EXTENDS:
+                            append('+');
+                            assembleSig(ta.type);
+                            break;
+                        case UNBOUND:
+                            append('*');
+                            break;
+                        default:
+                            throw new AssertionError(ta.kind);
+                    }
+                    break;
+                }
+                case TYPEVAR:
+                    append('T');
+                    append(type.tsym.name);
+                    append(';');
+                    break;
+                case FORALL:
+                    Type.ForAll ft = (Type.ForAll) type;
+                    assembleParamsSig(ft.tvars);
+                    assembleSig(ft.qtype);
+                    break;
+                default:
+                    throw new AssertionError("typeSig " + type.getTag());
+            }
+        }
+
+        public boolean hasTypeVar(List<Type> l) {
+            while (l.nonEmpty()) {
+                if (l.head.hasTag(TypeTag.TYPEVAR)) {
+                    return true;
+                }
+                l = l.tail;
+            }
+            return false;
+        }
+
+        public void assembleClassSig(Type type) {
+            type = type.unannotatedType();
+            ClassType ct = (ClassType) type;
+            ClassSymbol c = (ClassSymbol) ct.tsym;
+            classReference(c);
+            Type outer = ct.getEnclosingType();
+            if (outer.allparams().nonEmpty() && c.owner.enclClass() != null) {
+                boolean rawOuter =
+                        c.owner.kind == Kinds.MTH || // either a local class
+                        c.name == types.names.empty; // or anonymous
+                assembleClassSig(rawOuter
+                        ? types.erasure(outer)
+                        : outer);
+                append('.');
+                Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname));
+                append(rawOuter
+                        ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength() + 1, c.flatname.getByteLength())
+                        : c.name);
+            } else {
+                if (c == types.syms.errSymbol) {
+                    append(externalize(types.names.java_lang_Object));
+                } else {
+                    append(externalize(c.flatname));
+                }
+            }
+            if (ct.getTypeArguments().nonEmpty()) {
+                append('<');
+                assembleSig(ct.getTypeArguments());
+                append('>');
+            }
+        }
+
+        public void assembleParamsSig(List<Type> typarams) {
+            append('<');
+            for (List<Type> ts = typarams; ts.nonEmpty(); ts = ts.tail) {
+                Type.TypeVar tvar = (Type.TypeVar) ts.head;
+                append(tvar.tsym.name);
+                List<Type> bounds = types.getBounds(tvar);
+                if ((bounds.head.tsym.flags() & INTERFACE) != 0) {
+                    append(':');
+                }
+                for (List<Type> l = bounds; l.nonEmpty(); l = l.tail) {
+                    append(':');
+                    assembleSig(l.head);
+                }
+            }
+            append('>');
+        }
+
+        private void assembleSig(List<Type> types) {
+            for (List<Type> ts = types; ts.nonEmpty(); ts = ts.tail) {
+                assembleSig(ts.head);
+            }
+        }
+    }
+    // </editor-fold>
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Annotate.java b/src/share/classes/com/sun/tools/javac/comp/Annotate.java
index 5c13eb5..da997f2 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java
@@ -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
@@ -25,12 +25,19 @@
 
 package com.sun.tools.javac.comp;
 
+import java.util.Map;
+
 import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 
+import static com.sun.tools.javac.code.TypeTag.ARRAY;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
 /** Enter annotations on symbols.  Annotations accumulate in a queue,
  *  which is processed at the top level of any set of recursive calls
  *  requesting it be processed.
@@ -81,13 +88,28 @@ public class Annotate {
     public int enterCount = 0;
 
     ListBuffer<Annotator> q = new ListBuffer<Annotator>();
+    ListBuffer<Annotator> typesQ = new ListBuffer<Annotator>();
+    ListBuffer<Annotator> repeatedQ = new ListBuffer<Annotator>();
+    ListBuffer<Annotator> afterRepeatedQ = new ListBuffer<Annotator>();
+
+    public void earlier(Annotator a) {
+        q.prepend(a);
+    }
 
-    public void later(Annotator a) {
+    public void normal(Annotator a) {
         q.append(a);
     }
 
-    public void earlier(Annotator a) {
-        q.prepend(a);
+    public void typeAnnotation(Annotator a) {
+        typesQ.append(a);
+    }
+
+    public void repeated(Annotator a) {
+        repeatedQ.append(a);
+    }
+
+    public void afterRepeated(Annotator a) {
+        afterRepeatedQ.append(a);
     }
 
     /** Called when the Enter phase starts. */
@@ -105,8 +127,18 @@ public class Annotate {
         if (enterCount != 0) return;
         enterCount++;
         try {
-            while (q.nonEmpty())
+            while (q.nonEmpty()) {
                 q.next().enterAnnotation();
+            }
+            while (typesQ.nonEmpty()) {
+                typesQ.next().enterAnnotation();
+            }
+            while (repeatedQ.nonEmpty()) {
+                repeatedQ.next().enterAnnotation();
+            }
+            while (afterRepeatedQ.nonEmpty()) {
+                afterRepeatedQ.next().enterAnnotation();
+            }
         } finally {
             enterCount--;
         }
@@ -122,6 +154,56 @@ public class Annotate {
         String toString();
     }
 
+    /**
+     * This context contains all the information needed to synthesize new
+     * annotations trees by the completer for repeating annotations.
+     */
+    public class AnnotateRepeatedContext<T extends Attribute.Compound> {
+        public final Env<AttrContext> env;
+        public final Map<Symbol.TypeSymbol, ListBuffer<T>> annotated;
+        public final Map<T, JCDiagnostic.DiagnosticPosition> pos;
+        public final Log log;
+        public final boolean isTypeCompound;
+
+        public AnnotateRepeatedContext(Env<AttrContext> env,
+                                       Map<Symbol.TypeSymbol, ListBuffer<T>> annotated,
+                                       Map<T, JCDiagnostic.DiagnosticPosition> pos,
+                                       Log log,
+                                       boolean isTypeCompound) {
+            Assert.checkNonNull(env);
+            Assert.checkNonNull(annotated);
+            Assert.checkNonNull(pos);
+            Assert.checkNonNull(log);
+
+            this.env = env;
+            this.annotated = annotated;
+            this.pos = pos;
+            this.log = log;
+            this.isTypeCompound = isTypeCompound;
+        }
+
+        /**
+         * Process a list of repeating annotations returning a new
+         * Attribute.Compound that is the attribute for the synthesized tree
+         * for the container.
+         *
+         * @param repeatingAnnotations a List of repeating annotations
+         * @return a new Attribute.Compound that is the container for the repeatingAnnotations
+         */
+        public T processRepeatedAnnotations(List<T> repeatingAnnotations, Symbol sym) {
+            return Annotate.this.processRepeatedAnnotations(repeatingAnnotations, this, sym);
+        }
+
+        /**
+         * Queue the Annotator a on the repeating annotations queue of the
+         * Annotate instance this context belongs to.
+         *
+         * @param a the Annotator to enqueue for repeating annotation annotating
+         */
+        public void annotateRepeated(Annotator a) {
+            Annotate.this.repeated(a);
+        }
+    }
 
 /* ********************************************************************
  * Compute an attribute from its annotation.
@@ -134,6 +216,21 @@ public class Annotate {
     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.
@@ -147,7 +244,7 @@ public class Annotate {
             isError = true;
         }
         List<JCExpression> args = a.args;
-        if (args.length() == 1 && args.head.getTag() != JCTree.ASSIGN) {
+        if (args.length() == 1 && !args.head.hasTag(ASSIGN)) {
             // special case: elided "value=" assumed
             args.head = make.at(TreeInfo.getStartPos(args.head)).
                 Assign(make.Ident(names.value), args.head);
@@ -156,13 +253,13 @@ public class Annotate {
             new ListBuffer<Pair<MethodSymbol,Attribute>>();
         for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
             JCExpression t = tl.head;
-            if (t.getTag() != JCTree.ASSIGN) {
+            if (!t.hasTag(ASSIGN)) {
                 log.error(t.pos(), "annotation.value.must.be.name.value");
                 enterAttributeValue(t.type = syms.errType, t, env);
                 continue;
             }
             JCAssign assign = (JCAssign)t;
-            if (assign.lhs.getTag() != JCTree.IDENT) {
+            if (!assign.lhs.hasTag(IDENT)) {
                 log.error(t.pos(), "annotation.value.must.be.name.value");
                 enterAttributeValue(t.type = syms.errType, t, env);
                 continue;
@@ -180,12 +277,26 @@ public class Annotate {
                 log.error(left.pos(), "no.annotation.member", left.name, a.type);
             Type result = method.type.getReturnType();
             Attribute value = enterAttributeValue(result, assign.rhs, env);
-            if (!method.type.isErroneous() && !(value instanceof Attribute.Error))
+            if (!method.type.isErroneous())
                 buf.append(new Pair<MethodSymbol,Attribute>
                            ((MethodSymbol)method, value));
             t.type = result;
         }
-        return new Attribute.Compound(a.type, buf.toList());
+        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,
@@ -205,9 +316,9 @@ public class Annotate {
         
         if (erroneous) {
             switch (tree.getTag()) {
-                case JCTree.ANNOTATION:
+                case ANNOTATION:
                     return enterAnnotation((JCAnnotation)tree, expected, env);
-                case JCTree.NEWARRAY:
+                case NEWARRAY:
                     JCNewArray na = (JCNewArray)tree;
                     if (na.elemtype != null) {
                         log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
@@ -248,14 +359,14 @@ public class Annotate {
                                        (((JCFieldAccess) tree).selected).type);
         }
         if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) {
-            if (tree.getTag() != JCTree.ANNOTATION) {
+            if (!tree.hasTag(ANNOTATION)) {
                 log.error(tree.pos(), "annotation.value.must.be.annotation");
                 return new Attribute.Error(expected);
             }
             return enterAnnotation((JCAnnotation)tree, expected, env);
         }
-        if (expected.tag == TypeTags.ARRAY) { // should really be isArray()
-            if (tree.getTag() != JCTree.NEWARRAY) {
+        if (expected.hasTag(ARRAY)) { // should really be isArray()
+            if (!tree.hasTag(NEWARRAY)) {
                 tree = make.at(tree.pos).
                     NewArray(null, List.<JCExpression>nil(), List.of(tree));
             }
@@ -275,7 +386,7 @@ public class Annotate {
             return new Attribute.
                 Array(expected, buf.toArray(new Attribute[buf.length()]));
         }
-        if (expected.tag == TypeTags.CLASS &&
+        if (expected.hasTag(CLASS) &&
             (expected.tsym.flags() & Flags.ENUM) != 0) {
             attr.attribExpr(tree, env, expected);
             Symbol sym = TreeInfo.symbol(tree);
@@ -292,4 +403,240 @@ public class Annotate {
         log.error(tree.pos(), "annotation.value.not.allowable.type");
         return new Attribute.Error(attr.attribExpr(tree, env, expected));
     }
+
+    /* *********************************
+     * Support for repeating annotations
+     ***********************************/
+
+    /* Process repeated annotations. This method returns the
+     * synthesized container annotation or null IFF all repeating
+     * annotation are invalid.  This method reports errors/warnings.
+     */
+    private <T extends Attribute.Compound> T processRepeatedAnnotations(List<T> annotations,
+            AnnotateRepeatedContext<T> ctx,
+            Symbol on) {
+        T firstOccurrence = annotations.head;
+        List<Attribute> repeated = List.nil();
+        Type origAnnoType = null;
+        Type arrayOfOrigAnnoType = null;
+        Type targetContainerType = null;
+        MethodSymbol containerValueSymbol = null;
+
+        Assert.check(!annotations.isEmpty() &&
+                     !annotations.tail.isEmpty()); // i.e. size() > 1
+
+        int count = 0;
+        for (List<T> al = annotations;
+             !al.isEmpty();
+             al = al.tail)
+        {
+            count++;
+
+            // There must be more than a single anno in the annotation list
+            Assert.check(count > 1 || !al.tail.isEmpty());
+
+            T currentAnno = al.head;
+
+            origAnnoType = currentAnno.type;
+            if (arrayOfOrigAnnoType == null) {
+                arrayOfOrigAnnoType = types.makeArrayType(origAnnoType);
+            }
+
+            // Only report errors if this isn't the first occurrence I.E. count > 1
+            boolean reportError = count > 1;
+            Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno), reportError);
+            if (currentContainerType == null) {
+                continue;
+            }
+            // Assert that the target Container is == for all repeated
+            // annos of the same annotation type, the types should
+            // come from the same Symbol, i.e. be '=='
+            Assert.check(targetContainerType == null || currentContainerType == targetContainerType);
+            targetContainerType = currentContainerType;
+
+            containerValueSymbol = validateContainer(targetContainerType, origAnnoType, ctx.pos.get(currentAnno));
+
+            if (containerValueSymbol == null) { // Check of CA type failed
+                // errors are already reported
+                continue;
+            }
+
+            repeated = repeated.prepend(currentAnno);
+        }
+
+        if (!repeated.isEmpty()) {
+            repeated = repeated.reverse();
+            TreeMaker m = make.at(ctx.pos.get(firstOccurrence));
+            Pair<MethodSymbol, Attribute> p =
+                    new Pair<MethodSymbol, Attribute>(containerValueSymbol,
+                                                      new Attribute.Array(arrayOfOrigAnnoType, repeated));
+            if (ctx.isTypeCompound) {
+                /* TODO: the following code would be cleaner:
+                Attribute.TypeCompound at = new Attribute.TypeCompound(targetContainerType, List.of(p),
+                        ((Attribute.TypeCompound)annotations.head).position);
+                JCTypeAnnotation annoTree = m.TypeAnnotation(at);
+                at = enterTypeAnnotation(annoTree, targetContainerType, ctx.env);
+                */
+                // However, we directly construct the TypeCompound to keep the
+                // direct relation to the contained TypeCompounds.
+                Attribute.TypeCompound at = new Attribute.TypeCompound(targetContainerType, List.of(p),
+                        ((Attribute.TypeCompound)annotations.head).position);
+
+                // TODO: annotation applicability checks from below?
+
+                at.setSynthesized(true);
+
+                @SuppressWarnings("unchecked")
+                T x = (T) at;
+                return x;
+            } else {
+                Attribute.Compound c = new Attribute.Compound(targetContainerType, List.of(p));
+                JCAnnotation annoTree = m.Annotation(c);
+
+                if (!chk.annotationApplicable(annoTree, on))
+                    log.error(annoTree.pos(), "invalid.repeatable.annotation.incompatible.target", targetContainerType, origAnnoType);
+
+                if (!chk.validateAnnotationDeferErrors(annoTree))
+                    log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType);
+
+                c = enterAnnotation(annoTree, targetContainerType, ctx.env);
+                c.setSynthesized(true);
+
+                @SuppressWarnings("unchecked")
+                T x = (T) c;
+                return x;
+            }
+        } else {
+            return null; // errors should have been reported elsewhere
+        }
+    }
+
+    /** Fetches the actual Type that should be the containing annotation. */
+    private Type getContainingType(Attribute.Compound currentAnno,
+            DiagnosticPosition pos,
+            boolean reportError)
+    {
+        Type origAnnoType = currentAnno.type;
+        TypeSymbol origAnnoDecl = origAnnoType.tsym;
+
+        // Fetch the Repeatable annotation from the current
+        // annotation's declaration, or null if it has none
+        Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym);
+        if (ca == null) { // has no Repeatable annotation
+            if (reportError)
+                log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
+            return null;
+        }
+
+        return filterSame(extractContainingType(ca, pos, origAnnoDecl),
+                          origAnnoType);
+    }
+
+    // returns null if t is same as 's', returns 't' otherwise
+    private Type filterSame(Type t, Type s) {
+        if (t == null || s == null) {
+            return t;
+        }
+
+        return types.isSameType(t, s) ? null : t;
+    }
+
+    /** Extract the actual Type to be used for a containing annotation. */
+    private Type extractContainingType(Attribute.Compound ca,
+            DiagnosticPosition pos,
+            TypeSymbol annoDecl)
+    {
+        // The next three checks check that the Repeatable annotation
+        // on the declaration of the annotation type that is repeating is
+        // valid.
+
+        // Repeatable must have at least one element
+        if (ca.values.isEmpty()) {
+            log.error(pos, "invalid.repeatable.annotation", annoDecl);
+            return null;
+        }
+        Pair<MethodSymbol,Attribute> p = ca.values.head;
+        Name name = p.fst.name;
+        if (name != names.value) { // should contain only one element, named "value"
+            log.error(pos, "invalid.repeatable.annotation", annoDecl);
+            return null;
+        }
+        if (!(p.snd instanceof Attribute.Class)) { // check that the value of "value" is an Attribute.Class
+            log.error(pos, "invalid.repeatable.annotation", annoDecl);
+            return null;
+        }
+
+        return ((Attribute.Class)p.snd).getValue();
+    }
+
+    /* Validate that the suggested targetContainerType Type is a valid
+     * container type for repeated instances of originalAnnoType
+     * annotations. Return null and report errors if this is not the
+     * case, return the MethodSymbol of the value element in
+     * targetContainerType if it is suitable (this is needed to
+     * synthesize the container). */
+    private MethodSymbol validateContainer(Type targetContainerType,
+                                           Type originalAnnoType,
+                                           DiagnosticPosition pos) {
+        MethodSymbol containerValueSymbol = null;
+        boolean fatalError = false;
+
+        // Validate that there is a (and only 1) value method
+        Scope scope = targetContainerType.tsym.members();
+        int nr_value_elems = 0;
+        boolean error = false;
+        for(Symbol elm : scope.getElementsByName(names.value)) {
+            nr_value_elems++;
+
+            if (nr_value_elems == 1 &&
+                elm.kind == Kinds.MTH) {
+                containerValueSymbol = (MethodSymbol)elm;
+            } else {
+                error = true;
+            }
+        }
+        if (error) {
+            log.error(pos,
+                      "invalid.repeatable.annotation.multiple.values",
+                      targetContainerType,
+                      nr_value_elems);
+            return null;
+        } else if (nr_value_elems == 0) {
+            log.error(pos,
+                      "invalid.repeatable.annotation.no.value",
+                      targetContainerType);
+            return null;
+        }
+
+        // validate that the 'value' element is a method
+        // probably "impossible" to fail this
+        if (containerValueSymbol.kind != Kinds.MTH) {
+            log.error(pos,
+                      "invalid.repeatable.annotation.invalid.value",
+                      targetContainerType);
+            fatalError = true;
+        }
+
+        // validate that the 'value' element has the correct return type
+        // i.e. array of original anno
+        Type valueRetType = containerValueSymbol.type.getReturnType();
+        Type expectedType = types.makeArrayType(originalAnnoType);
+        if (!(types.isArray(valueRetType) &&
+              types.isSameType(expectedType, valueRetType))) {
+            log.error(pos,
+                      "invalid.repeatable.annotation.value.return",
+                      targetContainerType,
+                      valueRetType,
+                      expectedType);
+            fatalError = true;
+        }
+        if (error) {
+            fatalError = true;
+        }
+
+        // The conditions for a valid containing annotation are made
+        // in Check.validateRepeatedAnnotaton();
+
+        return fatalError ? null : containerValueSymbol;
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
index f744c72..92d93b6 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,33 +26,39 @@
 package com.sun.tools.javac.comp;
 
 import java.util.*;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
 import javax.lang.model.element.ElementKind;
+import javax.lang.model.type.TypeKind;
 import javax.tools.JavaFileObject;
 
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.TreeVisitor;
+import com.sun.source.util.SimpleTreeVisitor;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Lint.LintCategory;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.comp.Check.CheckContext;
+import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
+import com.sun.tools.javac.comp.Infer.InferenceContext;
+import com.sun.tools.javac.comp.Infer.FreeTypeListener;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.tree.*;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
-
-import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.code.Lint.LintCategory;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.code.Type.*;
-
-import com.sun.source.tree.IdentifierTree;
-import com.sun.source.tree.MemberSelectTree;
-import com.sun.source.tree.TreeVisitor;
-import com.sun.source.util.SimpleTreeVisitor;
-
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.ANNOTATION;
+import static com.sun.tools.javac.code.Flags.BLOCK;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.code.TypeTag.WILDCARD;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** This is the main context-dependent analysis phase in GJC. It
  *  encompasses name resolution, type checking and constant folding as
@@ -76,7 +82,9 @@ public class Attr extends JCTree.Visitor {
     final Symtab syms;
     final Resolve rs;
     final Infer infer;
+    final DeferredAttr deferredAttr;
     final Check chk;
+    final Flow flow;
     final MemberEnter memberEnter;
     final TreeMaker make;
     final ConstFold cfolder;
@@ -103,10 +111,12 @@ public class Attr extends JCTree.Visitor {
         syms = Symtab.instance(context);
         rs = Resolve.instance(context);
         chk = Check.instance(context);
+        flow = Flow.instance(context);
         memberEnter = MemberEnter.instance(context);
         make = TreeMaker.instance(context);
         enter = Enter.instance(context);
         infer = Infer.instance(context);
+        deferredAttr = DeferredAttr.instance(context);
         cfolder = ConstFold.instance(context);
         target = Target.instance(context);
         types = Types.instance(context);
@@ -124,19 +134,40 @@ public class Attr extends JCTree.Visitor {
         allowCovariantReturns = source.allowCovariantReturns();
         allowAnonOuterThis = source.allowAnonOuterThis();
         allowStringsInSwitch = source.allowStringsInSwitch();
+        allowPoly = source.allowPoly();
+        allowTypeAnnos = source.allowTypeAnnotations();
+        allowLambda = source.allowLambda();
+        allowDefaultMethods = source.allowDefaultMethods();
         sourceName = source.name;
         relax = (options.isSet("-retrofit") ||
                  options.isSet("-relax"));
         findDiamonds = options.get("findDiamond") != null &&
                  source.allowDiamond();
         useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
+        identifyLambdaCandidate = options.getBoolean("identifyLambdaCandidate", false);
         isBackgroundCompilation = options.get("backgroundCompilation") != null;     //NOI18N
+
+        statInfo = new ResultInfo(NIL, Type.noType);
+        varInfo = new ResultInfo(VAR, Type.noType);
+        unknownExprInfo = new ResultInfo(VAL, Type.noType);
+        unknownAnyPolyInfo = new ResultInfo(VAL, Infer.anyPoly);
+        unknownTypeInfo = new ResultInfo(TYP, Type.noType);
+        unknownTypeExprInfo = new ResultInfo(Kinds.TYP | Kinds.VAL, Type.noType);
+        recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext);
     }
 
     /** Switch: relax some constraints for retrofit mode.
      */
     boolean relax;
 
+    /** Switch: support target-typing inference
+     */
+    boolean allowPoly;
+
+    /** Switch: support type annotations.
+     */
+    boolean allowTypeAnnos;
+
     /** Switch: support generics?
      */
     boolean allowGenerics;
@@ -157,6 +188,14 @@ public class Attr extends JCTree.Visitor {
      */
     boolean allowCovariantReturns;
 
+    /** Switch: support lambda expressions ?
+     */
+    boolean allowLambda;
+
+    /** Switch: support default methods ?
+     */
+    boolean allowDefaultMethods;
+
     /** Switch: allow references to surrounding object from anonymous
      * objects during constructor call?
      */
@@ -179,6 +218,12 @@ public class Attr extends JCTree.Visitor {
     boolean useBeforeDeclarationWarning;
 
     /**
+     * Switch: generate warnings whenever an anonymous inner class that is convertible
+     * to a lambda expression is found
+     */
+    boolean identifyLambdaCandidate;
+
+    /**
      * Switch: allow strings in switch?
      */
     boolean allowStringsInSwitch;
@@ -196,20 +241,32 @@ public class Attr extends JCTree.Visitor {
      *  are correct.
      *
      *  @param tree     The tree whose kind and type is checked
-     *  @param owntype  The computed type of the tree
      *  @param ownkind  The computed kind of the tree
-     *  @param pkind    The expected kind (or: protokind) of the tree
-     *  @param pt       The expected type (or: prototype) of the tree
+     *  @param resultInfo  The expected result of the tree
      */
-    Type check(JCTree tree, Type owntype, int ownkind, int pkind, Type pt) {
-        if (owntype.tag != ERROR && pt.tag != METHOD && pt.tag != FORALL) {
-            if ((ownkind & ~pkind) == 0) {
-                owntype = chk.checkType(tree.pos(), owntype, pt, errKey);
+    Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) {
+        InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
+        Type owntype = found;
+        if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) {
+            if (allowPoly && inferenceContext.free(found)) {
+                inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
+                    @Override
+                    public void typesInferred(InferenceContext inferenceContext) {
+                        ResultInfo pendingResult =
+                                    resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+                        check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
+                    }
+                });
+                return tree.type = resultInfo.pt;
             } else {
-                log.error(tree.pos(), "unexpected.type",
-                          kindNames(pkind),
-                          kindName(ownkind));
-                owntype = types.createErrorType(owntype);
+                if ((ownkind & ~resultInfo.pkind) == 0) {
+                    owntype = resultInfo.check(tree, owntype);
+                } else {
+                    log.error(tree.pos(), "unexpected.type",
+                            kindNames(resultInfo.pkind),
+                            kindName(ownkind));
+                    owntype = types.createErrorType(owntype);
+                }
             }
         }
         tree.type = owntype;
@@ -222,7 +279,7 @@ public class Attr extends JCTree.Visitor {
      *  @param env    The current environment.
      */
     boolean isAssignableAsBlankFinal(VarSymbol v, Env<AttrContext> env) {
-        Symbol owner = env.info.scope.owner;
+        Symbol owner = owner(env);
            // owner refers to the innermost variable, method or
            // initializer block declaration at this point.
         return
@@ -237,6 +294,44 @@ public class Attr extends JCTree.Visitor {
              ((v.flags() & STATIC) != 0) == Resolve.isStatic(env));
     }
 
+    /**
+     * Return the innermost enclosing owner symbol in a given attribution context
+     */
+    Symbol owner(Env<AttrContext> env) {
+        while (true) {
+            switch (env.tree.getTag()) {
+                case VARDEF:
+                    //a field can be owner
+                    VarSymbol vsym = ((JCVariableDecl)env.tree).sym;
+                    if (vsym.owner.kind == TYP) {
+                        return vsym;
+                    }
+                    break;
+                case METHODDEF:
+                    //method def is always an owner
+                    return ((JCMethodDecl)env.tree).sym;
+                case CLASSDEF:
+                    //class def is always an owner
+                    return ((JCClassDecl)env.tree).sym;
+                case LAMBDA:
+                    //a lambda is an owner - return a fresh synthetic method symbol
+                    return new MethodSymbol(0, names.empty, null, syms.methodClass);
+                case BLOCK:
+                    //static/instance init blocks are owner
+                    Symbol blockSym = env.info.scope.owner;
+                    if ((blockSym.flags() & BLOCK) != 0) {
+                        return blockSym;
+                    }
+                    break;
+                case TOPLEVEL:
+                    //toplevel is always an owner (for pkge decls)
+                    return env.info.scope.owner;
+            }
+            Assert.checkNonNull(env.next);
+            env = env.next;
+        }
+    }
+
     /** Check that variable can be assigned to.
      *  @param pos    The current source code position.
      *  @param v      The assigned varaible
@@ -249,15 +344,13 @@ public class Attr extends JCTree.Visitor {
             ((v.flags() & HASINIT) != 0
              ||
              !((base == null ||
-               (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) &&
+               (base.hasTag(IDENT) && TreeInfo.name(base) == names._this)) &&
                isAssignableAsBlankFinal(v, env)))) {
             if (v.isResourceVariable()) { //TWR resource
                 log.error(pos, "try.resource.may.not.be.assigned", v);
             } else {
                 log.error(pos, "cant.assign.val.to.final.var", v);
             }
-        } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) {
-            v.flags_field &= ~EFFECTIVELY_FINAL;
         }
     }
 
@@ -267,7 +360,7 @@ public class Attr extends JCTree.Visitor {
      *  @param tree    The candidate tree.
      */
     boolean isStaticReference(JCTree tree) {
-        if (tree.getTag() == JCTree.SELECT) {
+        if (tree.hasTag(SELECT)) {
             Symbol lsym = TreeInfo.symbol(((JCFieldAccess) tree).selected);
             if (lsym == null || lsym.kind != TYP) {
                 return false;
@@ -334,7 +427,16 @@ public class Attr extends JCTree.Visitor {
     public Type attribType(JCTree node, TypeSymbol sym) {
         Env<AttrContext> env = enter.typeEnvs.get(sym);
         Env<AttrContext> localEnv = env.dup(node, env.info.dup());
-        return attribTree(node, localEnv, Kinds.TYP, Type.noType);
+        return attribTree(node, localEnv, unknownTypeInfo);
+    }
+
+    public Type attribImportQualifier(JCImport tree, Env<AttrContext> env) {
+        // Attribute qualifying package or class.
+        JCFieldAccess s = (JCFieldAccess)tree.qualid;
+        return attribTree(s.selected,
+                       env,
+                       new ResultInfo(tree.staticImport ? TYP : (TYP | PCK),
+                       Type.noType));
     }
 
     public Env<AttrContext> attribExprToTree(JCTree expr, Env<AttrContext> env, JCTree tree) {
@@ -387,6 +489,73 @@ public class Attr extends JCTree.Visitor {
         }
     }
 
+    class ResultInfo {
+        final int pkind;
+        final Type pt;
+        final CheckContext checkContext;
+
+        ResultInfo(int pkind, Type pt) {
+            this(pkind, pt, chk.basicHandler);
+        }
+
+        protected ResultInfo(int pkind, Type pt, CheckContext checkContext) {
+            this.pkind = pkind;
+            this.pt = pt;
+            this.checkContext = checkContext;
+        }
+
+        protected Type check(final DiagnosticPosition pos, final Type found) {
+            return chk.checkType(pos, found, pt, checkContext);
+        }
+
+        protected ResultInfo dup(Type newPt) {
+            return new ResultInfo(pkind, newPt, checkContext);
+        }
+
+        protected ResultInfo dup(CheckContext newContext) {
+            return new ResultInfo(pkind, pt, newContext);
+        }
+    }
+
+    class RecoveryInfo extends ResultInfo {
+
+        public RecoveryInfo(final DeferredAttr.DeferredAttrContext deferredAttrContext) {
+            this(deferredAttrContext, Type.recoveryType);
+        }
+        
+        public RecoveryInfo(final DeferredAttr.DeferredAttrContext deferredAttrContext, final Type pt) {
+            super(Kinds.VAL, pt, new Check.NestedCheckContext(chk.basicHandler) {
+                @Override
+                public DeferredAttr.DeferredAttrContext deferredAttrContext() {
+                    return deferredAttrContext;
+                }
+                @Override
+                public boolean compatible(Type found, Type req, Warner warn) {
+                    return true;
+                }
+                @Override
+                public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                    chk.basicHandler.report(pos, details);
+                }
+            });
+        }
+    }
+
+    final ResultInfo statInfo;
+    final ResultInfo varInfo;
+    final ResultInfo unknownAnyPolyInfo;
+    final ResultInfo unknownExprInfo;
+    final ResultInfo unknownTypeInfo;
+    final ResultInfo unknownTypeExprInfo;
+    final ResultInfo recoveryInfo;
+
+    Type pt() {
+        return resultInfo.pt;
+    }
+
+    int pkind() {
+        return resultInfo.pkind;
+    }
 
 /* ************************************************************************
  * Visitor methods
@@ -396,17 +565,9 @@ public class Attr extends JCTree.Visitor {
      */
     Env<AttrContext> env;
 
-    /** Visitor argument: the currently expected proto-kind.
-     */
-    int pkind;
-
-    /** Visitor argument: the currently expected proto-type.
-     */
-    Type pt;
-
-    /** Visitor argument: the error key to be generated when a type error occurs
+    /** Visitor argument: the currently expected attribution result.
      */
-    String errKey;
+    ResultInfo resultInfo;
 
     /** Visitor result: the computed type.
      */
@@ -417,73 +578,69 @@ public class Attr extends JCTree.Visitor {
      *
      *  @param tree    The tree to be visited.
      *  @param env     The environment visitor argument.
-     *  @param pkind   The protokind visitor argument.
-     *  @param pt      The prototype visitor argument.
+     *  @param resultInfo   The result info visitor argument.
      */
-    Type attribTree(JCTree tree, Env<AttrContext> env, int pkind, Type pt) {
-        return attribTree(tree, env, pkind, pt, "incompatible.types");
-    }
-
-    Type attribTree(JCTree tree, Env<AttrContext> env, int pkind, Type pt, String errKey) {
+    Type attribTree(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
         Env<AttrContext> prevEnv = this.env;
-        int prevPkind = this.pkind;
-        Type prevPt = this.pt;
-        String prevErrKey = this.errKey;
+        ResultInfo prevResult = this.resultInfo;
         try {
             this.env = env;
-            this.pkind = pkind;
-            this.pt = pt;
-            this.errKey = errKey;
-            if (tree == null) {
-                String source = env.toplevel.sourcefile != null ? env.toplevel.getSourceFile().toUri().toASCIIString() : "<unknown>";
-                
-                if (env.enclClass != null) {
-                    int start = env.enclClass.getStartPosition();
-                    String lineNumber = env.toplevel.getLineMap() != null ? "" + env.toplevel.getLineMap().getLineNumber(start) : "<unknown>";
-                    String name = String.valueOf(env.enclClass.name);
-                    
-                    Logger.getLogger(Attr.class.getName()).log(Level.WARNING, "Attr.attribTree has a null tree. Enclosing class: {0} starting on line {1} (offset {2}) in file {3}", new Object[] {name, lineNumber, start, source}); //NOI18N
-                } else {
-                    Logger.getLogger(Attr.class.getName()).log(Level.WARNING, "Attr.attribTree has a null tree. No enclosing class, file {3}", new Object[] {source}); //NOI18N
-                }
-                Logger.getLogger(Attr.class.getName()).log(Level.FINER, "Attr.attribTree has a null tree. Enclosing class: [{0}]", env.enclClass); //NOI18N
-            } else {
-                tree.accept(this);
+            this.resultInfo = resultInfo;
+            tree.accept(this);
+            if (tree == breakTree &&
+                    resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
+                throw new BreakAttr(copyEnv(env));
             }
-            if (breakTree != null && tree == breakTree)
-                throw new BreakAttr(env);
             return result;
         } catch (CompletionFailure ex) {
             tree.type = syms.errType;
             return chk.completionError(tree.pos(), ex);
         } finally {
             this.env = prevEnv;
-            this.pkind = prevPkind;
-            this.pt = prevPt;
-            this.errKey = prevErrKey;
+            this.resultInfo = prevResult;
+        }
+    }
+
+    Env<AttrContext> copyEnv(Env<AttrContext> env) {
+        Env<AttrContext> newEnv =
+                env.dup(env.tree, env.info.dup(copyScope(env.info.scope)));
+        if (newEnv.outer != null) {
+            newEnv.outer = copyEnv(newEnv.outer);
+        }
+        return newEnv;
+    }
+
+    Scope copyScope(Scope sc) {
+        Scope newScope = new Scope(sc.owner);
+        List<Symbol> elemsList = List.nil();
+        while (sc != null) {
+            for (Scope.Entry e = sc.elems ; e != null ; e = e.sibling) {
+                elemsList = elemsList.prepend(e.sym);
+            }
+            sc = sc.next;
+        }
+        for (Symbol s : elemsList) {
+            newScope.enter(s);
         }
+        return newScope;
     }
 
     /** Derived visitor method: attribute an expression tree.
      */
     public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt) {
-        return attribTree(tree, env, VAL, pt != null && pt.tag != ERROR ? pt : Type.noType);
-    }
-
-    public Type attribExpr(JCTree tree, Env<AttrContext> env, Type pt, String key) {
-        return attribTree(tree, env, VAL, pt.tag != ERROR ? pt : Type.noType, key);
+        return attribTree(tree, env, new ResultInfo(VAL, pt != null && !pt.hasTag(ERROR) ? pt : Type.noType));
     }
 
     /** Derived visitor method: attribute an expression tree with
      *  no constraints on the computed type.
      */
-    Type attribExpr(JCTree tree, Env<AttrContext> env) {
-        return attribTree(tree, env, VAL, Type.noType);
+    public Type attribExpr(JCTree tree, Env<AttrContext> env) {
+        return attribTree(tree, env, unknownExprInfo);
     }
 
     /** Derived visitor method: attribute a type tree.
      */
-    Type attribType(JCTree tree, Env<AttrContext> env) {
+    public Type attribType(JCTree tree, Env<AttrContext> env) {
         Type result = attribType(tree, env, Type.noType);
         return result;
     }
@@ -491,14 +648,14 @@ public class Attr extends JCTree.Visitor {
     /** Derived visitor method: attribute a type tree.
      */
     Type attribType(JCTree tree, Env<AttrContext> env, Type pt) {
-        Type result = attribTree(tree, env, TYP, pt);
+        Type result = attribTree(tree, env, new ResultInfo(TYP, pt));
         return result;
     }
 
     /** Derived visitor method: attribute a statement or definition tree.
      */
     public Type attribStat(JCTree tree, Env<AttrContext> env) {
-        return attribTree(tree, env, NIL, Type.noType);
+        return attribTree(tree, env, statInfo);
     }
 
     /** Attribute a list of expressions, returning a list of types.
@@ -517,14 +674,21 @@ public class Attr extends JCTree.Visitor {
             attribStat(l.head, env);
     }
 
-    /** Attribute the arguments in a method call, returning a list of types.
+    /** Attribute the arguments in a method call, returning the method kind.
      */
-    List<Type> attribArgs(List<JCExpression> trees, Env<AttrContext> env) {
-        ListBuffer<Type> argtypes = new ListBuffer<Type>();
-        for (List<JCExpression> l = trees; l.nonEmpty(); l = l.tail)
-            argtypes.append(chk.checkNonVoid(
-                l.head.pos(), types.upperBound(attribTree(l.head, env, VAL, Infer.anyPoly))));
-        return argtypes.toList();
+    int attribArgs(List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) {
+        int kind = VAL;
+        for (JCExpression arg : trees) {
+            Type argtype;
+            if (allowPoly && deferredAttr.isDeferred(env, arg)) {
+                argtype = deferredAttr.new DeferredType(arg, env);
+                kind |= POLY;
+            } else {
+                argtype = chk.checkNonVoid(arg, attribTree(arg, env, unknownAnyPolyInfo));
+            }
+            argtypes.append(argtype);
+        }
+        return kind;
     }
 
     /** Attribute a type argument list, returning a list of types.
@@ -568,21 +732,8 @@ public class Attr extends JCTree.Visitor {
             }
             a.tsym.flags_field &= ~UNATTRIBUTED;
         }
-        for (JCTypeParameter tvar : typarams)
+        for (JCTypeParameter tvar : typarams) {
             chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
-        attribStats(typarams, env);
-    }
-
-    void attribBounds(List<JCTypeParameter> typarams) {
-        for (JCTypeParameter typaram : typarams) {
-            Type bound = typaram.type.getUpperBound();
-            if (bound != null && bound.tsym instanceof ClassSymbol) {
-                ClassSymbol c = (ClassSymbol)bound.tsym;
-                if ((c.flags_field & COMPOUND) != 0) {
-                    Assert.check((c.flags_field & UNATTRIBUTED) != 0, c);
-                    attribClass(typaram.pos(), c);
-                }
-            }
         }
     }
 
@@ -602,38 +753,37 @@ public class Attr extends JCTree.Visitor {
      *  @param env         The env for the const value
      *  @param initializer The initializer for the const value
      *  @param type        The expected type, or null
-     *  @see VarSymbol#setlazyConstValue
+     *  @see VarSymbol#setLazyConstValue
      */
     public Object attribLazyConstantValue(Env<AttrContext> env,
                                       JCTree.JCExpression initializer,
                                       Type type) {
 
-        // in case no lint value has been set up for this env, scan up
-        // env stack looking for smallest enclosing env for which it is set.
-        Env<AttrContext> lintEnv = env;
-        while (lintEnv.info.lint == null)
-            lintEnv = lintEnv.next;
-
-        // Having found the enclosing lint value, we can initialize the lint value for this class
-        // ... but ...
-        // There's a problem with evaluating annotations in the right order, such that
-        // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be
-        // null. In that case, calling augment will throw an NPE. To avoid this, for now we
-        // revert to the jdk 6 behavior and ignore the (unevaluated) attributes.
-        if (env.info.enclVar.attributes_field == null)
-            env.info.lint = lintEnv.info.lint;
-        else
-            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
+        /*  When this env was created, it didn't have the correct lint nor had
+         *  annotations has been processed.
+         *  But now at this phase we have already processed annotations and the
+         *  correct lint must have been set in chk, so we should use that one to
+         *  attribute the initializer.
+         */
+        Lint prevLint = env.info.lint;
+        env.info.lint = chk.getLint();
 
-        Lint prevLint = chk.setLint(env.info.lint);
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
 
         try {
+            // 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)
+            if (itype.constValue() != null) {
                 return coerce(itype, type).constValue();
-            else
+            } else {
                 return null;
+            }
         } finally {
             env.info.lint = prevLint;
             log.useSource(prevSource);
@@ -666,7 +816,7 @@ public class Attr extends JCTree.Visitor {
                    boolean checkExtensible) {
         if (t.isErroneous())
             return t;
-        if (t.tag == TYPEVAR && !classExpected && !interfaceExpected) {
+        if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) {
             // check that type variable is already visible
             if (t.getUpperBound() == null) {
                 log.error(tree.pos(), "illegal.forward.ref");
@@ -695,6 +845,13 @@ public class Attr extends JCTree.Visitor {
         return t;
     }
 
+    Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) {
+        Assert.check((env.enclClass.sym.flags() & ENUM) != 0 || env.enclClass.sym.kind == ERR);
+        id.type = env.info.scope.owner.type;
+        id.sym = env.info.scope.owner;
+        return id.type;
+    }
+
     public void visitClassDef(JCClassDecl tree) {
         // Local classes have not been entered yet, so we need to do it now:
         if ((env.info.scope.owner.kind & (VAR | MTH)) != 0
@@ -718,7 +875,7 @@ public class Attr extends JCTree.Visitor {
             // disable implicit outer instance from being passed.
             // (This would be an illegal access to "this before super").
             if (env.info.isSelfCall &&
-                env.tree.getTag() == JCTree.NEWCLASS &&
+                env.tree.hasTag(NEWCLASS) &&
                 ((JCNewClass) env.tree).encl == null)
             {
                 c.flags_field |= NOOUTERTHIS;
@@ -735,14 +892,22 @@ public class Attr extends JCTree.Visitor {
             result = null;
             return;
         }
-        Lint lint = env.info.lint.augment(m.attributes_field, m.flags());
+        boolean isDefaultMethod = (m.flags() & DEFAULT) != 0;
+
+        Lint lint = env.info.lint.augment(m);
         Lint prevLint = chk.setLint(lint);
         MethodSymbol prevMethod = chk.setMethod(m);
         try {
             deferredLintHandler.flush(tree.pos());
             chk.checkDeprecatedAnnotation(tree.pos(), m);
 
-            attribBounds(tree.typarams);
+
+            // Create a new environment with local scope
+            // for attributing the method.
+            Env<AttrContext> localEnv = memberEnter.methodEnv(tree, env);
+            localEnv.info.lint = lint;
+
+            attribStats(tree.typarams, localEnv);
 
             // If we override any other methods, check that we do so properly.
             // JLS ???
@@ -753,11 +918,9 @@ public class Attr extends JCTree.Visitor {
             }
             chk.checkOverride(tree, m);
 
-            // Create a new environment with local scope
-            // for attributing the method.
-            Env<AttrContext> localEnv = memberEnter.methodEnv(tree, env);
-
-            localEnv.info.lint = lint;
+            if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
+                log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
+            }
 
             // Enter all type parameters into the local method scope.
             for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail)
@@ -782,6 +945,16 @@ public class Attr extends JCTree.Visitor {
             // Check that result type is well-formed.
             chk.validate(tree.restype, localEnv);
 
+            // Check that receiver type is well-formed.
+            if (tree.recvparam != null) {
+                // Use a new environment to check the receiver parameter.
+                // Otherwise I get "might not have been initialized" errors.
+                // Is there a better way?
+                Env<AttrContext> newEnv = memberEnter.methodEnv(tree, env);
+                attribType(tree.recvparam, newEnv);
+                chk.validate(tree.recvparam, newEnv);
+            }
+
             // annotation method checks
             if ((owner.flags() & ANNOTATION) != 0) {
                 // annotation method cannot have throws clause
@@ -813,8 +986,7 @@ public class Attr extends JCTree.Visitor {
                 // Empty bodies are only allowed for
                 // abstract, native, or interface methods, or for methods
                 // in a retrofit signature class.
-                if ((owner.flags() & INTERFACE) == 0 &&
-                    (tree.mods.flags & (ABSTRACT | NATIVE)) == 0 &&
+                if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0 &&
                     !relax)
                     log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
                 if (tree.defaultValue != null) {
@@ -823,10 +995,12 @@ public class Attr extends JCTree.Visitor {
                                   "default.allowed.in.intf.annotation.member");
                 }
             } else {
-                if ((owner.flags() & INTERFACE) != 0) {
-                    log.error(tree.body.pos(), "intf.meth.cant.have.body");
-                } else if ((tree.mods.flags & ABSTRACT) != 0) {
-                    log.error(tree.pos(), "abstract.meth.cant.have.body");
+                if ((tree.sym.flags() & ABSTRACT) != 0 && !isDefaultMethod) {
+                    if ((owner.flags() & INTERFACE) != 0) {
+                        log.error(tree.body.pos(), "intf.meth.cant.have.body");
+                    } else {
+                        log.error(tree.pos(), "abstract.meth.cant.have.body");
+                    }
                 } else if ((tree.mods.flags & NATIVE) != 0) {
                     log.error(tree.pos(), "native.meth.cant.have.body");
                 }
@@ -854,12 +1028,19 @@ public class Attr extends JCTree.Visitor {
                                   env.enclClass.sym);
                     }
                 }
+
                 if (!isBackgroundCompilation) {
                     tree.localEnv = dupLocalEnv(localEnv);
                 }
+
+                // Attribute all type annotations in the body
+                memberEnter.typeAnnotate(tree.body, localEnv, m);
+                annotate.flush();
+
                 // Attribute method body.
                 attribStat(tree.body, localEnv);
             }
+
             localEnv.info.scope.leave();
             result = tree.type = m.type;
             chk.validateAnnotations(tree.mods.annotations, m);
@@ -880,7 +1061,12 @@ public class Attr extends JCTree.Visitor {
                 memberEnter.memberEnter(tree, env);
                 annotate.flush();
             }
-            tree.sym.flags_field |= EFFECTIVELY_FINAL;
+        } else {
+            if (tree.init != null) {
+                // Field initializer expression need to be entered.
+                memberEnter.typeAnnotate(tree.init, env, tree.sym);
+                annotate.flush();
+            }
         }
 
         VarSymbol v = tree.sym;
@@ -889,18 +1075,24 @@ public class Attr extends JCTree.Visitor {
             result = null;
             return;
         }
-        Lint lint = env.info.lint.augment(v.attributes_field, v.flags());
+        Lint lint = env.info.lint.augment(v);
         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 {
             chk.checkDeprecatedAnnotation(tree.pos(), v);
 
             if (tree.init != null) {
-                if ((v.flags_field & FINAL) != 0 && tree.init.getTag() != JCTree.NEWCLASS) {
+                if ((v.flags_field & FINAL) != 0 &&
+                        !tree.init.hasTag(NEWCLASS) &&
+                        !tree.init.hasTag(LAMBDA) &&
+                        !tree.init.hasTag(REFERENCE)) {
                     // In this case, `v' is final.  Ensure that it's initializer is
                     // evaluated.
                     v.getConstValue(); // ensure initializer is evaluated
@@ -937,16 +1129,37 @@ public class Attr extends JCTree.Visitor {
             Env<AttrContext> localEnv =
                 env.dup(tree, env.info.dup(env.info.scope.dupUnshared()));
             localEnv.info.scope.owner =
-                new MethodSymbol(tree.flags | BLOCK, names.empty, null,
-                                 env.info.scope.owner);
+                new MethodSymbol(tree.flags | BLOCK |
+                    env.info.scope.owner.flags() & STRICTFP, names.empty, null,
+                    env.info.scope.owner);
             if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++;
+
+            // Attribute all type annotations in the block
+            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.appendClassInitTypeAttributes(tas);
+                } else {
+                    cs.appendInitTypeAttributes(tas);
+                }
+            }
+
             attribStats(tree.stats, localEnv);
         } else {
             // Create a new local environment with a local scope.
             Env<AttrContext> localEnv =
                 env.dup(tree, env.info.dup(env.info.scope.dup()));
-            attribStats(tree.stats, localEnv);
-            localEnv.info.scope.leave();
+            try {
+                attribStats(tree.stats, localEnv);
+            } finally {
+                localEnv.info.scope.leave();
+            }
         }
         result = null;
     }
@@ -966,51 +1179,62 @@ public class Attr extends JCTree.Visitor {
     public void visitForLoop(JCForLoop tree) {
         Env<AttrContext> loopEnv =
             env.dup(env.tree, env.info.dup(env.info.scope.dup()));
-        attribStats(tree.init, loopEnv);
-        if (tree.cond != null) attribExpr(tree.cond, loopEnv, syms.booleanType);
-        loopEnv.tree = tree; // before, we were not in loop!
-        attribStats(tree.step, loopEnv);
-        attribStat(tree.body, loopEnv);
-        loopEnv.info.scope.leave();
-        result = null;
+        try {
+            attribStats(tree.init, loopEnv);
+            if (tree.cond != null) attribExpr(tree.cond, loopEnv, syms.booleanType);
+            loopEnv.tree = tree; // before, we were not in loop!
+            attribStats(tree.step, loopEnv);
+            attribStat(tree.body, loopEnv);
+            result = null;
+        }
+        finally {
+            loopEnv.info.scope.leave();
+        }
     }
 
     public void visitForeachLoop(JCEnhancedForLoop tree) {
         Env<AttrContext> loopEnv =
             env.dup(env.tree, env.info.dup(env.info.scope.dup()));
-        attribStat(tree.var, loopEnv);
-        Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv));
-        chk.checkNonVoid(tree.pos(), exprType);
-        Type elemtype = types.elemtype(exprType); // perhaps expr is an array?
-        if (elemtype == null) {
-            // or perhaps expr implements Iterable<T>?
-            Type base = types.asSuper(exprType, syms.iterableType.tsym);
-            if (base == null) {
-                log.error(tree.expr.pos(),
-                        "foreach.not.applicable.to.type",
-                        exprType,
-                        diags.fragment("type.req.array.or.iterable"));
-                elemtype = types.createErrorType(exprType);
-            } else {
-                List<Type> iterableParams = base.allparams();
-                elemtype = iterableParams.isEmpty()
-                    ? syms.objectType
-                    : types.upperBound(iterableParams.head);
+        try {
+            //the Formal Parameter of a for-each loop is not in the scope when
+            //attributing the for-each expression; we mimick this by attributing
+            //the for-each expression first (against original scope).
+            Type exprType = types.upperBound(attribExpr(tree.expr, loopEnv));
+            attribStat(tree.var, loopEnv);
+            chk.checkNonVoid(tree.pos(), exprType);
+            Type elemtype = types.elemtype(exprType); // perhaps expr is an array?
+            if (elemtype == null) {
+                // or perhaps expr implements Iterable<T>?
+                Type base = types.asSuper(exprType, syms.iterableType.tsym);
+                if (base == null) {
+                    log.error(tree.expr.pos(),
+                            "foreach.not.applicable.to.type",
+                            exprType,
+                            diags.fragment("type.req.array.or.iterable"));
+                    elemtype = types.createErrorType(exprType);
+                } else {
+                    List<Type> iterableParams = base.allparams();
+                    elemtype = iterableParams.isEmpty()
+                        ? syms.objectType
+                        : types.upperBound(iterableParams.head);
+                }
             }
+            if (tree.var.sym != null)
+                chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type);
+            loopEnv.tree = tree; // before, we were not in loop!
+            attribStat(tree.body, loopEnv);
+            result = null;
+        }
+        finally {
+            loopEnv.info.scope.leave();
         }
-        if (tree.var.sym != null)
-            chk.checkType(tree.expr.pos(), elemtype, tree.var.sym.type);
-        loopEnv.tree = tree; // before, we were not in loop!
-        attribStat(tree.body, loopEnv);
-        loopEnv.info.scope.leave();
-        result = null;
     }
 
     public void visitLabelled(JCLabeledStatement tree) {
         // Check that label is not used in an enclosing statement
         Env<AttrContext> env1 = env;
-        while (env1 != null && env1.tree.getTag() != JCTree.CLASSDEF) {
-            if (env1.tree.getTag() == JCTree.LABELLED &&
+        while (env1 != null && !env1.tree.hasTag(CLASSDEF)) {
+            if (env1.tree.hasTag(LABELLED) &&
                 ((JCLabeledStatement) env1.tree).label == tree.label) {
                 log.error(tree.pos(), "label.already.in.use",
                           tree.label);
@@ -1029,77 +1253,92 @@ public class Attr extends JCTree.Visitor {
         Env<AttrContext> switchEnv =
             env.dup(tree, env.info.dup(env.info.scope.dup()));
 
-        boolean enumSwitch =
-            allowEnums &&
-            (seltype.tsym.flags() & Flags.ENUM) != 0;
-        boolean stringSwitch = false;
-        if (types.isSameType(seltype, syms.stringType)) {
-            if (allowStringsInSwitch) {
-                stringSwitch = true;
-            } else {
-                log.error(tree.selector.pos(), "string.switch.not.supported.in.source", sourceName);
-            }
-        }
-        if (!enumSwitch && !stringSwitch)
-            seltype = chk.checkType(tree.selector.pos(), seltype, syms.intType);
-
-        // Attribute all cases and
-        // check that there are no duplicate case labels or default clauses.
-        Set<Object> labels = new HashSet<Object>(); // The set of case labels.
-        boolean hasDefault = false;      // Is there a default label?
-        for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
-            JCCase c = l.head;
-            if (c == breakTree)
-                throw new BreakAttr(env);
-            Env<AttrContext> caseEnv =
-                switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
-            if (c.pat != null) {
-                if (enumSwitch) {
-                    Symbol sym = enumConstant(c.pat, seltype);
-                    if (sym == null) {
-                        log.error(c.pat.pos(), "enum.label.must.be.unqualified.enum");
-                    } else if (!labels.add(sym)) {
-                        log.error(c.pos(), "duplicate.case.label");
-                    }
+        try {
+
+            boolean enumSwitch =
+                allowEnums && seltype.tsym != null &&
+                (seltype.tsym.flags() & Flags.ENUM) != 0;
+            boolean stringSwitch = false;
+            if (types.isSameType(seltype, syms.stringType)) {
+                if (allowStringsInSwitch) {
+                    stringSwitch = true;
                 } else {
-                    Type pattype = attribExpr(c.pat, switchEnv, seltype);
-                    if (pattype.tag != ERROR) {
-                        if (pattype.constValue() == null) {
-                            log.error(c.pat.pos(),
-                                      (stringSwitch ? "string.const.req" : "const.expr.req"));
-                        } else if (labels.contains(pattype.constValue())) {
-                            log.error(c.pos(), "duplicate.case.label");
+                    log.error(tree.selector.pos(), "string.switch.not.supported.in.source", sourceName);
+                }
+            }
+            if (!enumSwitch && !stringSwitch)
+                seltype = chk.checkType(tree.selector.pos(), seltype, syms.intType);
+
+            // Attribute all cases and
+            // check that there are no duplicate case labels or default clauses.
+            Set<Object> labels = new HashSet<Object>(); // The set of case labels.
+            boolean hasDefault = false;      // Is there a default label?
+            for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
+                JCCase c = l.head;
+                if (c == breakTree &&
+                        resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK)
+                    throw new BreakAttr(env);
+                Env<AttrContext> caseEnv =
+                    switchEnv.dup(c, env.info.dup(switchEnv.info.scope.dup()));
+                boolean baCatched = false;
+                try {
+                    if (c.pat != null) {
+                        if (enumSwitch) {
+                            Symbol sym = enumConstant(c.pat, seltype);
+                            if (sym == null) {
+                                log.error(c.pat.pos(), "enum.label.must.be.unqualified.enum");
+                            } else if (!labels.add(sym)) {
+                                log.error(c.pos(), "duplicate.case.label");
+                            }
                         } else {
-                            labels.add(pattype.constValue());
+                            Type pattype = attribExpr(c.pat, switchEnv, seltype);
+                            if (!pattype.hasTag(ERROR)) {
+                                if (pattype.constValue() == null) {
+                                    log.error(c.pat.pos(),
+                                              (stringSwitch ? "string.const.req" : "const.expr.req"));
+                                } else if (labels.contains(pattype.constValue())) {
+                                    log.error(c.pos(), "duplicate.case.label");
+                                } else {
+                                    labels.add(pattype.constValue());
+                                }
+                            }
                         }
+                    } else if (hasDefault) {
+                        log.error(c.pos(), "duplicate.default.label");
+                    } else {
+                        hasDefault = true;
+                    }
+                    attribStats(c.stats, caseEnv);
+                } catch (BreakAttr ba) {
+                    baCatched = true;
+                    throw ba;
+                } finally {
+                    caseEnv.info.scope.leave();
+                    if (!baCatched) {
+                        addVars(c.stats, switchEnv.info.scope);
                     }
                 }
-            } else if (hasDefault) {
-                log.error(c.pos(), "duplicate.default.label");
-            } else {
-                hasDefault = true;
             }
-            attribStats(c.stats, caseEnv);
-            caseEnv.info.scope.leave();
-            addVars(c.stats, switchEnv.info.scope);
-        }
 
-        switchEnv.info.scope.leave();
-        result = null;
+            result = null;
+        }
+        finally {
+            switchEnv.info.scope.leave();
+        }
     }
     // where
         /** Add any variables defined in stats to the switch scope. */
         private static void addVars(List<JCStatement> stats, Scope switchScope) {
             for (;stats.nonEmpty(); stats = stats.tail) {
                 JCTree stat = stats.head;
-                if (stat.getTag() == JCTree.VARDEF)
+                if (stat.hasTag(VARDEF) && ((JCVariableDecl) stat).sym != null)
                     switchScope.enter(((JCVariableDecl) stat).sym);
             }
         }
     // where
     /** Return the selected enumeration constant symbol, or null. */
     private Symbol enumConstant(JCTree tree, Type enumType) {
-        if (tree.getTag() != JCTree.IDENT) {
+        if (!tree.hasTag(IDENT)) {
             log.error(tree.pos(), "enum.label.must.be.unqualified.enum");
             return syms.errSymbol;
         }
@@ -1127,67 +1366,81 @@ public class Attr extends JCTree.Visitor {
     public void visitTry(JCTry tree) {
         // Create a new local environment with a local
         Env<AttrContext> localEnv = env.dup(tree, env.info.dup(env.info.scope.dup()));
-        boolean isTryWithResource = tree.resources.nonEmpty();
-        // Create a nested environment for attributing the try block if needed
-        Env<AttrContext> tryEnv = isTryWithResource ?
-            env.dup(tree, localEnv.info.dup(localEnv.info.scope.dup())) :
-            localEnv;
-        // Attribute resource declarations
-        for (JCTree resource : tree.resources) {
-            if (resource.getTag() == JCTree.VARDEF) {
-                attribStat(resource, tryEnv);
-                chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type");
-
-                //check that resource type cannot throw InterruptedException
-                checkAutoCloseable(resource.pos(), localEnv, resource.type);
-
-                VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource);
-                var.setData(ElementKind.RESOURCE_VARIABLE);
-            } else {
-                attribExpr(resource, tryEnv, syms.autoCloseableType, "try.not.applicable.to.type");
+        try {
+            boolean isTryWithResource = tree.resources.nonEmpty();
+            // Create a nested environment for attributing the try block if needed
+            Env<AttrContext> tryEnv = isTryWithResource ?
+                env.dup(tree, localEnv.info.dup(localEnv.info.scope.dup())) :
+                localEnv;
+            try {
+                // Attribute resource declarations
+                for (JCTree resource : tree.resources) {
+                    CheckContext twrContext = new Check.NestedCheckContext(resultInfo.checkContext) {
+                        @Override
+                        public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                            chk.basicHandler.report(pos, diags.fragment("try.not.applicable.to.type", details));
+                        }
+                    };
+                    ResultInfo twrResult = new ResultInfo(VAL, syms.autoCloseableType, twrContext);
+                    if (resource.hasTag(VARDEF)) {
+                        attribStat(resource, tryEnv);
+                        twrResult.check(resource, resource.type);
+
+                        //check that resource type cannot throw InterruptedException
+                        checkAutoCloseable(resource.pos(), localEnv, resource.type);
+
+                        VarSymbol var = ((JCVariableDecl) resource).sym;
+                        var.setData(ElementKind.RESOURCE_VARIABLE);
+                    } else {
+                        attribTree(resource, tryEnv, twrResult);
+                    }
+                }
+                // Attribute body
+                attribStat(tree.body, tryEnv);
+            } finally {
+                if (isTryWithResource)
+                    tryEnv.info.scope.leave();
             }
-        }
-        // Attribute body
-        attribStat(tree.body, tryEnv);
-        if (isTryWithResource)
-            tryEnv.info.scope.leave();
 
-        // Attribute catch clauses
-        for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
-            JCCatch c = l.head;
-            Env<AttrContext> catchEnv =
-                localEnv.dup(c, localEnv.info.dup(localEnv.info.scope.dup()));
-            Type ctype = attribStat(c.param, catchEnv);
-            if (TreeInfo.isMultiCatch(c)) {
-                //multi-catch parameter is implicitly marked as final
-                c.param.sym.flags_field |= FINAL | UNION;
-            }
-            if (c.param.sym.kind == Kinds.VAR) {
-                c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER);
+            // Attribute catch clauses
+            for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
+                JCCatch c = l.head;
+                Env<AttrContext> catchEnv =
+                    localEnv.dup(c, localEnv.info.dup(localEnv.info.scope.dup()));
+                try {
+                    Type ctype = attribStat(c.param, catchEnv);
+                    if (TreeInfo.isMultiCatch(c)) {
+                        //multi-catch parameter is implicitly marked as final
+                        c.param.sym.flags_field |= FINAL | UNION;
+                    }
+                    if (c.param.sym.kind == Kinds.VAR) {
+                        c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER);
+                    }
+                    chk.checkType(c.param.vartype.pos(),
+                                  chk.checkClassType(c.param.vartype.pos(), ctype),
+                                  syms.throwableType);
+                    attribStat(c.body, catchEnv);
+                } finally {
+                    catchEnv.info.scope.leave();
+                }
             }
-            chk.checkType(c.param.vartype.pos(),
-                          chk.checkClassType(c.param.vartype.pos(), ctype),
-                          syms.throwableType);
-            attribStat(c.body, catchEnv);
-            catchEnv.info.scope.leave();
-        }
 
-        // Attribute finalizer
-        if (tree.finalizer != null) attribStat(tree.finalizer, localEnv);
-
-        localEnv.info.scope.leave();
-        result = null;
+            // Attribute finalizer
+            if (tree.finalizer != null) attribStat(tree.finalizer, localEnv);
+            result = null;
+        }
+        finally {
+            localEnv.info.scope.leave();
+        }
     }
 
     void checkAutoCloseable(DiagnosticPosition pos, Env<AttrContext> env, Type resource) {
         if (!resource.isErroneous() &&
-                types.asSuper(resource, syms.autoCloseableType.tsym) != null) {
+            types.asSuper(resource, syms.autoCloseableType.tsym) != null &&
+            !types.isSameType(resource, syms.autoCloseableType)) { // Don't emit warning for AutoCloseable itself
             Symbol close = syms.noSymbol;
-            boolean prevDeferDiags = log.deferDiagnostics;
-            Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
+            Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
             try {
-                log.deferDiagnostics = true;
-                log.deferredDiagnostics = ListBuffer.lb();
                 close = rs.resolveQualifiedMethod(pos,
                         env,
                         resource,
@@ -1196,8 +1449,7 @@ public class Attr extends JCTree.Visitor {
                         List.<Type>nil());
             }
             finally {
-                log.deferDiagnostics = prevDeferDiags;
-                log.deferredDiagnostics = prevDeferredDiags;
+                log.popDiagnosticHandler(discardHandler);
             }
             if (close.kind == MTH &&
                     close.overrides(syms.autoCloseableClose, resource.tsym, types, true) &&
@@ -1209,50 +1461,93 @@ public class Attr extends JCTree.Visitor {
     }
 
     public void visitConditional(JCConditional tree) {
-        attribExpr(tree.cond, env, syms.booleanType);
-        attribExpr(tree.truepart, env);
-        attribExpr(tree.falsepart, env);
-        result = check(tree,
-                       capture(condType(tree.pos(), tree.cond.type,
-                                        tree.truepart.type, tree.falsepart.type)),
-                       VAL, pkind, pt);
+        Type condtype = attribExpr(tree.cond, env, syms.booleanType);
+
+        tree.polyKind = (!allowPoly ||
+                pt().hasTag(NONE) && pt() != Type.recoveryType ||
+                isBooleanOrNumeric(env, tree)) ?
+                PolyKind.STANDALONE : PolyKind.POLY;
+
+        if (tree.polyKind == PolyKind.POLY && resultInfo.pt.hasTag(VOID)) {
+            //cannot get here (i.e. it means we are returning from void method - which is already an error)
+            resultInfo.checkContext.report(tree, diags.fragment("conditional.target.cant.be.void"));
+            result = tree.type = types.createErrorType(resultInfo.pt);
+            return;
+        }
+
+        ResultInfo condInfo = tree.polyKind == PolyKind.STANDALONE ?
+                unknownExprInfo :
+                resultInfo.dup(new Check.NestedCheckContext(resultInfo.checkContext) {
+                    //this will use enclosing check context to check compatibility of
+                    //subexpression against target type; if we are in a method check context,
+                    //depending on whether boxing is allowed, we could have incompatibilities
+                    @Override
+                    public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                        enclosingContext.report(pos, diags.fragment("incompatible.type.in.conditional", details));
+                    }
+                });
+
+        Type truetype = attribTree(tree.truepart, env, condInfo);
+        Type falsetype = attribTree(tree.falsepart, env, condInfo);
+
+        Type owntype = (tree.polyKind == PolyKind.STANDALONE) ? condType(tree, truetype, falsetype) : pt();
+        if (condtype.constValue() != null &&
+                truetype.constValue() != null &&
+                falsetype.constValue() != null &&
+                !owntype.hasTag(NONE)) {
+            //constant folding
+            owntype = cfolder.coerce(condtype.isTrue() ? truetype : falsetype, owntype);
+        }
+        result = check(tree, owntype, VAL, resultInfo);
     }
     //where
-        /** Compute the type of a conditional expression, after
-         *  checking that it exists. See Spec 15.25.
-         *
-         *  @param pos      The source position to be used for
-         *                  error diagnostics.
-         *  @param condtype The type of the expression's condition.
-         *  @param thentype The type of the expression's then-part.
-         *  @param elsetype The type of the expression's else-part.
-         */
-        private Type condType(DiagnosticPosition pos,
-                              Type condtype,
-                              Type thentype,
-                              Type elsetype) {
-            Type ctype = condType1(pos, condtype, thentype, elsetype);
-
-            // If condition and both arms are numeric constants,
-            // evaluate at compile-time.
-            return ((condtype.constValue() != null) &&
-                    (thentype.constValue() != null) &&
-                    (elsetype.constValue() != null))
-                ? cfolder.coerce(condtype.isTrue()?thentype:elsetype, ctype)
-                : ctype;
+        private boolean isBooleanOrNumeric(Env<AttrContext> env, JCExpression tree) {
+            switch (tree.getTag()) {
+                case LITERAL: return ((JCLiteral)tree).typetag.isSubRangeOf(DOUBLE) ||
+                              ((JCLiteral)tree).typetag == BOOLEAN ||
+                              ((JCLiteral)tree).typetag == BOT;
+                case LAMBDA: case REFERENCE: return false;
+                case PARENS: return isBooleanOrNumeric(env, ((JCParens)tree).expr);
+                case CONDEXPR:
+                    JCConditional condTree = (JCConditional)tree;
+                    return isBooleanOrNumeric(env, condTree.truepart) &&
+                            isBooleanOrNumeric(env, condTree.falsepart);
+                case APPLY:
+                    JCMethodInvocation speculativeMethodTree =
+                            (JCMethodInvocation)deferredAttr.attribSpeculative(tree, env, unknownExprInfo);
+                    Type owntype = TreeInfo.symbol(speculativeMethodTree.meth).type.getReturnType();
+                    return types.unboxedTypeOrType(owntype).isPrimitive();
+                case NEWCLASS:
+                    JCExpression className =
+                            removeClassParams.translate(((JCNewClass)tree).clazz);
+                    JCExpression speculativeNewClassTree =
+                            (JCExpression)deferredAttr.attribSpeculative(className, env, unknownTypeInfo);
+                    return types.unboxedTypeOrType(speculativeNewClassTree.type).isPrimitive();
+                default:
+                    Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type;
+                    speculativeType = types.unboxedTypeOrType(speculativeType);
+                    return speculativeType.isPrimitive();
+            }
         }
+        //where
+            TreeTranslator removeClassParams = new TreeTranslator() {
+                @Override
+                public void visitTypeApply(JCTypeApply tree) {
+                    result = translate(tree.clazz);
+                }
+            };
+
         /** Compute the type of a conditional expression, after
-         *  checking that it exists.  Does not take into
+         *  checking that it exists.  See JLS 15.25. Does not take into
          *  account the special case where condition and both arms
          *  are constants.
          *
          *  @param pos      The source position to be used for error
          *                  diagnostics.
-         *  @param condtype The type of the expression's condition.
          *  @param thentype The type of the expression's then-part.
          *  @param elsetype The type of the expression's else-part.
          */
-        private Type condType1(DiagnosticPosition pos, Type condtype,
+        private Type condType(DiagnosticPosition pos,
                                Type thentype, Type elsetype) {
             // If same type, that is the result
             if (types.isSameType(thentype, elsetype))
@@ -1271,18 +1566,23 @@ public class Attr extends JCTree.Visitor {
                 // If one arm has an integer subrange type (i.e., byte,
                 // short, or char), and the other is an integer constant
                 // that fits into the subrange, return the subrange type.
-                if (thenUnboxed.tag < INT && elseUnboxed.tag == INT &&
-                    types.isAssignable(elseUnboxed, thenUnboxed))
+                if (thenUnboxed.getTag().isStrictSubRangeOf(INT) &&
+                    elseUnboxed.hasTag(INT) &&
+                    types.isAssignable(elseUnboxed, thenUnboxed)) {
                     return thenUnboxed.baseType();
-                if (elseUnboxed.tag < INT && thenUnboxed.tag == INT &&
-                    types.isAssignable(thenUnboxed, elseUnboxed))
+                }
+                if (elseUnboxed.getTag().isStrictSubRangeOf(INT) &&
+                    thenUnboxed.hasTag(INT) &&
+                    types.isAssignable(thenUnboxed, elseUnboxed)) {
                     return elseUnboxed.baseType();
+                }
 
-                for (int i = BYTE; i < VOID; i++) {
-                    Type candidate = syms.typeOfTag[i];
+                for (TypeTag tag : primitiveTags) {
+                    Type candidate = syms.typeOfTag[tag.ordinal()];
                     if (types.isSubtype(thenUnboxed, candidate) &&
-                        types.isSubtype(elseUnboxed, candidate))
+                        types.isSubtype(elseUnboxed, candidate)) {
                         return candidate;
+                    }
                 }
             }
 
@@ -1299,7 +1599,7 @@ public class Attr extends JCTree.Visitor {
             if (types.isSubtype(elsetype, thentype))
                 return thentype.baseType();
 
-            if (!allowBoxing || thentype.tag == VOID || elsetype.tag == VOID) {
+            if (!allowBoxing || thentype.hasTag(VOID) || elsetype.hasTag(VOID)) {
                 log.error(pos, "neither.conditional.subtype",
                           thentype, elsetype);
                 return thentype.baseType();
@@ -1311,6 +1611,17 @@ public class Attr extends JCTree.Visitor {
             return types.lub(thentype.baseType(), elsetype.baseType());
         }
 
+    final static TypeTag[] primitiveTags = new TypeTag[]{
+        BYTE,
+        CHAR,
+        SHORT,
+        INT,
+        LONG,
+        FLOAT,
+        DOUBLE,
+        BOOLEAN,
+    };
+
     public void visitIf(JCIf tree) {
         attribExpr(tree.cond, env, syms.booleanType);
         attribStat(tree.thenpart, env);
@@ -1352,7 +1663,7 @@ public class Attr extends JCTree.Visitor {
          *  @param env     The environment current at the jump statement.
          */
         private JCTree findJumpTarget(DiagnosticPosition pos,
-                                    int tag,
+                                    JCTree.Tag tag,
                                     Name label,
                                     Env<AttrContext> env) {
             // Search environments outwards from the point of jump.
@@ -1360,43 +1671,44 @@ public class Attr extends JCTree.Visitor {
             LOOP:
             while (env1 != null) {
                 switch (env1.tree.getTag()) {
-                case JCTree.LABELLED:
-                    JCLabeledStatement labelled = (JCLabeledStatement)env1.tree;
-                    if (label == labelled.label) {
-                        // If jump is a continue, check that target is a loop.
-                        if (tag == JCTree.CONTINUE) {
-                            if (labelled.body.getTag() != JCTree.DOLOOP &&
-                                labelled.body.getTag() != JCTree.WHILELOOP &&
-                                labelled.body.getTag() != JCTree.FORLOOP &&
-                                labelled.body.getTag() != JCTree.FOREACHLOOP)
-                                log.error(pos, "not.loop.label", label);
-                            // Found labelled statement target, now go inwards
-                            // to next non-labelled tree.
-                            return TreeInfo.referencedStatement(labelled);
-                        } else {
-                            return labelled;
+                    case LABELLED:
+                        JCLabeledStatement labelled = (JCLabeledStatement)env1.tree;
+                        if (label == labelled.label) {
+                            // If jump is a continue, check that target is a loop.
+                            if (tag == CONTINUE) {
+                                if (!labelled.body.hasTag(DOLOOP) &&
+                                        !labelled.body.hasTag(WHILELOOP) &&
+                                        !labelled.body.hasTag(FORLOOP) &&
+                                        !labelled.body.hasTag(FOREACHLOOP))
+                                    log.error(pos, "not.loop.label", label);
+                                // Found labelled statement target, now go inwards
+                                // to next non-labelled tree.
+                                return TreeInfo.referencedStatement(labelled);
+                            } else {
+                                return labelled;
+                            }
                         }
-                    }
-                    break;
-                case JCTree.DOLOOP:
-                case JCTree.WHILELOOP:
-                case JCTree.FORLOOP:
-                case JCTree.FOREACHLOOP:
-                    if (label == null) return env1.tree;
-                    break;
-                case JCTree.SWITCH:
-                    if (label == null && tag == JCTree.BREAK) return env1.tree;
-                    break;
-                case JCTree.METHODDEF:
-                case JCTree.CLASSDEF:
-                    break LOOP;
-                default:
+                        break;
+                    case DOLOOP:
+                    case WHILELOOP:
+                    case FORLOOP:
+                    case FOREACHLOOP:
+                        if (label == null) return env1.tree;
+                        break;
+                    case SWITCH:
+                        if (label == null && tag == BREAK) return env1.tree;
+                        break;
+                    case LAMBDA:
+                    case METHODDEF:
+                    case CLASSDEF:
+                        break LOOP;
+                    default:
                 }
                 env1 = env1.next;
             }
             if (label != null)
                 log.error(pos, "undef.label", label);
-            else if (tag == JCTree.CONTINUE)
+            else if (tag == CONTINUE)
                 log.error(pos, "cont.outside.loop");
             else
                 log.error(pos, "break.outside.switch.loop");
@@ -1406,33 +1718,31 @@ public class Attr extends JCTree.Visitor {
     public void visitReturn(JCReturn tree) {
         // Check that there is an enclosing method which is
         // nested within than the enclosing class.
-        if (env.enclMethod == null ||
-            env.enclMethod.sym.owner != env.enclClass.sym) {
+        if (env.info.returnResult == null) {
             log.error(tree.pos(), "ret.outside.meth");
-            if (tree.expr != null)
-                attribExpr(tree.expr, env);
         } else {
             // Attribute return expression, if it exists, and check that
             // it conforms to result type of enclosing method.
-            Symbol m = env.enclMethod.sym;
-            Type retType = m != null && m.type != null ? m.type.getReturnType() : null;
-            if (retType != null && retType.tag == VOID) {
-                if (tree.expr != null) {
-                    log.error(tree.expr.pos(),
-                              "cant.ret.val.from.meth.decl.void");
-                    attribExpr(tree.expr, env, retType);
+            if (tree.expr != null) {
+                if (env.info.returnResult.pt.hasTag(VOID)) {
+                    env.info.returnResult.checkContext.report(tree.expr.pos(),
+                              diags.fragment("unexpected.ret.val"));
                 }
-            } else if (tree.expr == null) {
-                log.error(tree.pos(), "missing.ret.val");
-            } else {
-                attribExpr(tree.expr, env, retType);
+                attribTree(tree.expr, env, env.info.returnResult);
+            } else if (!env.info.returnResult.pt.hasTag(VOID) &&
+                    !env.info.returnResult.pt.hasTag(NONE)) {
+                env.info.returnResult.checkContext.report(tree.pos(),
+                              diags.fragment("missing.ret.val"));
             }
         }
         result = null;
     }
 
     public void visitThrow(JCThrow tree) {
-        attribExpr(tree.expr, env, syms.throwableType);
+        Type owntype = attribExpr(tree.expr, env, allowPoly ? Type.noType : syms.throwableType);
+        if (allowPoly) {
+            chk.checkType(tree, owntype, syms.throwableType);
+        }
         result = null;
     }
 
@@ -1464,17 +1774,18 @@ public class Attr extends JCTree.Visitor {
         boolean isConstructorCall =
             methName == names._this || methName == names._super;
 
+        ListBuffer<Type> argtypesBuf = ListBuffer.lb();
         if (isConstructorCall) {
             // We are seeing a ...this(...) or ...super(...) call.
             // Check that this is the first statement in a constructor.
             checkFirstConstructorStat(tree, env);
-
             // Record the fact
             // that this is a constructor call (using isSelfCall).
             localEnv.info.isSelfCall = true;
 
             // Attribute arguments, yielding list of argument types.
-            argtypes = attribArgs(tree.args, localEnv);
+            attribArgs(tree.args, localEnv, argtypesBuf);
+            argtypes = argtypesBuf.toList();
             typeargtypes = attribTypes(tree.typeargs, localEnv);
 
             // Variable `site' points to the class in which the called
@@ -1489,14 +1800,14 @@ public class Attr extends JCTree.Visitor {
                 }
             }
 
-            if (site.tag == CLASS || site.tag == ERROR) {
+            if (site.hasTag(CLASS) || site.hasTag(ERROR)) {
                 Type encl = site.getEnclosingType();
-                while (encl != null && encl.tag == TYPEVAR)
+                while (encl != null && encl.hasTag(TYPEVAR))
                     encl = encl.getUpperBound();
-                if (encl.tag == CLASS) {
+                if (encl.hasTag(CLASS)) {
                     // we are calling a nested class
 
-                    if (tree.meth.getTag() == JCTree.SELECT) {
+                    if (tree.meth.hasTag(SELECT)) {
                         JCTree qualifier = ((JCFieldAccess) tree.meth).selected;
 
                         // We are seeing a prefixed call, of the form
@@ -1512,7 +1823,7 @@ public class Attr extends JCTree.Visitor {
                         rs.resolveImplicitThis(tree.meth.pos(),
                                                localEnv, site, true);
                     }
-                } else if (tree.meth.getTag() == JCTree.SELECT) {
+                } else if (tree.meth.hasTag(SELECT)) {
                     log.error(tree.meth.pos(), "illegal.qual.not.icls",
                               site.tsym);
                 }
@@ -1527,7 +1838,7 @@ public class Attr extends JCTree.Visitor {
                 // current instance (JLS ???).
                 boolean selectSuperPrev = localEnv.info.selectSuper;
                 localEnv.info.selectSuper = true;
-                localEnv.info.varArgs = false;
+                localEnv.info.pendingResolutionPhase = null;
                 Symbol sym = rs.resolveConstructor(
                     tree.meth.pos(), localEnv, site, argtypes, typeargtypes);
                 localEnv.info.selectSuper = selectSuperPrev;
@@ -1537,16 +1848,17 @@ public class Attr extends JCTree.Visitor {
 
                 // ...and check that it is legal in the current context.
                 // (this will also set the tree's type)
-                Type mpt = newMethTemplate(argtypes, typeargtypes);
-                checkId(tree.meth, site, sym, localEnv, MTH,
-                        mpt, tree.varargsElement != null);
+                Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
+                checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt));
             }
             result = tree.type = syms.voidType;
         } else {
             // Otherwise, we are seeing a regular method call.
             // Attribute the arguments, yielding list of argument types, ...
+            int kind = VAL;
             try {
-                argtypes = attribArgs(tree.args, localEnv);
+                kind = attribArgs(tree.args, localEnv, argtypesBuf);
+                argtypes = argtypesBuf.toList();
                 typeargtypes = attribAnyTypes(tree.typeargs, localEnv);
             } catch (BreakAttr bae) {
                 attribExpr(tree.meth, localEnv);
@@ -1556,48 +1868,50 @@ public class Attr extends JCTree.Visitor {
             // ... and attribute the method using as a prototype a methodtype
             // whose formal argument types is exactly the list of actual
             // arguments (this will also set the method symbol).
-            Type mpt = newMethTemplate(argtypes, typeargtypes);
-            localEnv.info.varArgs = false;
-            Type mtype = attribExpr(tree.meth, localEnv, mpt);
-            if (localEnv.info.varArgs)
-                Assert.check(mtype.isErroneous() || tree.varargsElement != null);
+            Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
+            localEnv.info.pendingResolutionPhase = null;
+            Type mtype = attribTree(tree.meth, localEnv, new ResultInfo(kind, mpt, resultInfo.checkContext));
 
             // Compute the result type.
             Type restype = mtype.getReturnType();
-            if (restype.tag == WILDCARD)
+            if (restype.hasTag(WILDCARD))
                 throw new AssertionError(mtype);
 
-            // as a special case, array.clone() has a result that is
-            // the same as static type of the array being cloned
-            if (tree.meth.getTag() == JCTree.SELECT &&
-                allowCovariantReturns &&
-                methName == names.clone &&
-                types.isArray(((JCFieldAccess) tree.meth).selected.type))
-                restype = ((JCFieldAccess) tree.meth).selected.type;
-
-            // as a special case, x.getClass() has type Class<? extends |X|>
-            if (allowGenerics &&
-                methName == names.getClass && tree.args.isEmpty()) {
-                Type qualifier = (tree.meth.getTag() == JCTree.SELECT)
+            Type qualifier = (tree.meth.hasTag(SELECT))
                     ? ((JCFieldAccess) tree.meth).selected.type
                     : env.enclClass.sym.type;
-                restype = new
-                    ClassType(restype.getEnclosingType(),
-                              List.<Type>of(new WildcardType(types.erasure(qualifier),
-                                                               BoundKind.EXTENDS,
-                                                               syms.boundClass)),
-                              restype.tsym);
-            }
+            restype = adjustMethodReturnType(qualifier, methName, argtypes, restype);
 
             chk.checkRefTypes(tree.typeargs, typeargtypes);
 
             // Check that value of resulting type is admissible in the
             // current context.  Also, capture the return type
-            result = check(tree, capture(restype), VAL, pkind, pt);
+            result = check(tree, capture(restype), VAL, resultInfo);
         }
         chk.validate(tree.typeargs, localEnv);
     }
     //where
+        Type adjustMethodReturnType(Type qualifierType, Name methodName, List<Type> argtypes, Type restype) {
+            if (allowCovariantReturns &&
+                    methodName == names.clone &&
+                types.isArray(qualifierType)) {
+                // as a special case, array.clone() has a result that is
+                // the same as static type of the array being cloned
+                return qualifierType;
+            } else if (allowGenerics &&
+                    methodName == names.getClass &&
+                    argtypes.isEmpty()) {
+                // as a special case, x.getClass() has type Class<? extends |X|>
+                return new ClassType(restype.getEnclosingType(),
+                              List.<Type>of(new WildcardType(types.erasure(qualifierType),
+                                                               BoundKind.EXTENDS,
+                                                               syms.boundClass)),
+                              restype.tsym);
+            } else {
+                return restype;
+            }
+        }
+
         /** Check that given application node appears as first statement
          *  in a constructor call.
          *  @param tree   The application node
@@ -1607,7 +1921,7 @@ public class Attr extends JCTree.Visitor {
             JCMethodDecl enclMethod = env.enclMethod;
             if (enclMethod != null && enclMethod.name == names.init) {
                 JCBlock body = enclMethod.body;
-                if (body.stats.head.getTag() == JCTree.EXEC &&
+                if (body.stats.head.hasTag(EXEC) &&
                     ((JCExpressionStatement) body.stats.head).expr == tree)
                     return true;
             }
@@ -1618,12 +1932,12 @@ public class Attr extends JCTree.Visitor {
 
         /** Obtain a method type with given argument types.
          */
-        Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes) {
-            MethodType mt = new MethodType(argtypes, null, null, syms.methodClass);
+        Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) {
+            MethodType mt = new MethodType(argtypes, restype, List.<Type>nil(), syms.methodClass);
             return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt);
         }
 
-    public void visitNewClass(JCNewClass tree) {
+    public void visitNewClass(final JCNewClass tree) {
         Type owntype = types.createErrorType(tree.type);
 
         // The local environment of a class creation is
@@ -1637,10 +1951,24 @@ public class Attr extends JCTree.Visitor {
         // If enclosing class is given, attribute it, and
         // complete class name to be fully qualified
         JCExpression clazz = tree.clazz; // Class field following new
-        JCExpression clazzid =          // Identifier in class field
-            (clazz.getTag() == JCTree.TYPEAPPLY)
-            ? ((JCTypeApply) clazz).clazz
-            : clazz;
+        JCExpression clazzid;            // Identifier in class field
+        JCAnnotatedType annoclazzid;     // Annotated type enclosing clazzid
+        annoclazzid = null;
+
+        if (clazz.hasTag(TYPEAPPLY)) {
+            clazzid = ((JCTypeApply) clazz).clazz;
+            if (clazzid.hasTag(ANNOTATED_TYPE)) {
+                annoclazzid = (JCAnnotatedType) clazzid;
+                clazzid = annoclazzid.underlyingType;
+            }
+        } else {
+            if (clazz.hasTag(ANNOTATED_TYPE)) {
+                annoclazzid = (JCAnnotatedType) clazz;
+                clazzid = annoclazzid.underlyingType;
+            } else {
+                clazzid = clazz;
+            }
+        }
 
         JCExpression clazzid1 = clazzid; // The same in fully qualified form
 
@@ -1655,20 +1983,38 @@ public class Attr extends JCTree.Visitor {
             // yields a clazz T.C.
             Type encltype = chk.checkRefType(tree.encl.pos(),
                                              attribExpr(tree.encl, env));
+            // TODO 308: in <expr>.new C, do we also want to add the type annotations
+            // from expr to the combined type, or not? Yes, do this.
             clazzid1 = make.at(clazz.pos).Select(make.Type(encltype),
                                                  ((JCIdent) clazzid).name);
-            if (clazz.getTag() == JCTree.TYPEAPPLY)
-                clazz = make.at(tree.pos).
-                    TypeApply(clazzid1,
-                              ((JCTypeApply) clazz).arguments);
-            else
-                clazz = clazzid1;
+
+            if (clazz.hasTag(ANNOTATED_TYPE)) {
+                JCAnnotatedType annoType = (JCAnnotatedType) clazz;
+                List<JCAnnotation> annos = annoType.annotations;
+
+                if (annoType.underlyingType.hasTag(TYPEAPPLY)) {
+                    clazzid1 = make.at(tree.pos).
+                        TypeApply(clazzid1,
+                                  ((JCTypeApply) clazz).arguments);
+                }
+
+                clazzid1 = make.at(tree.pos).
+                    AnnotatedType(annos, clazzid1);
+            } else if (clazz.hasTag(TYPEAPPLY)) {
+                clazzid1 = make.at(tree.pos).
+                    TypeApply(clazzid1,
+                              ((JCTypeApply) clazz).arguments);
+            }
+
+            clazz = clazzid1;
         }
 
         // Attribute clazz expression and store
         // symbol + type back into the attributed tree.
-        Type clazztype = attribType(clazz, env);
-        Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype);
+        Type clazztype = TreeInfo.isEnumInit(env.tree) ?
+            attribIdentAsEnumType(env, (JCIdent)clazz) :
+            attribType(clazz, env);
+
         clazztype = chk.checkDiamond(tree, clazztype);
         chk.validate(clazz, localEnv);
         if (tree.encl != null) {
@@ -1677,6 +2023,9 @@ public class Attr extends JCTree.Visitor {
             tree.clazz.type = clazztype;
             TreeInfo.setSymbol(clazzid, TreeInfo.symbol(clazzid1));
             clazzid.type = ((JCIdent) clazzid).sym.type;
+            if (annoclazzid != null) {
+                annoclazzid.type = clazzid.type;
+            }
             if (!clazztype.isErroneous()) {
                 if (cdef != null && clazztype.tsym.isInterface()) {
                     log.error(tree.encl.pos(), "anon.class.impl.intf.no.qual.for.new");
@@ -1685,59 +2034,24 @@ public class Attr extends JCTree.Visitor {
                 }
             }
         } else if (!clazztype.tsym.isInterface() &&
-                   clazztype.getEnclosingType().tag == CLASS) {
+                   clazztype.getEnclosingType().hasTag(CLASS)) {
             // Check for the existence of an apropos outer instance
             rs.resolveImplicitThis(tree.pos(), env, clazztype);
         }
 
         // Attribute constructor arguments.
-        List<Type> argtypes = attribArgs(tree.args, localEnv);
+        ListBuffer<Type> argtypesBuf = ListBuffer.lb();
+        int pkind = attribArgs(tree.args, localEnv, argtypesBuf);
+        List<Type> argtypes = argtypesBuf.toList();
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
-        if (TreeInfo.isDiamond(tree) && !clazztype.isErroneous()) {
-            clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
-            clazz.type = clazztype;
-        } else if (allowDiamondFinder &&
-                tree.def == null &&
-                !clazztype.isErroneous() &&
-                clazztype.getTypeArguments().nonEmpty() &&
-                findDiamonds) {
-            boolean prevDeferDiags = log.deferDiagnostics;
-            Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
-            Type inferred = null;
-            try {
-                //disable diamond-related diagnostics
-                log.deferDiagnostics = true;
-                log.deferredDiagnostics = ListBuffer.lb();
-                inferred = attribDiamond(localEnv,
-                        tree,
-                        clazztype,
-                        mapping,
-                        argtypes,
-                        typeargtypes);
-            }
-            finally {
-                log.deferDiagnostics = prevDeferDiags;
-                log.deferredDiagnostics = prevDeferredDiags;
-            }
-            if (inferred != null &&
-                    !inferred.isErroneous() &&
-                    inferred.tag == CLASS &&
-                    types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings)) {
-                String key = types.isSameType(clazztype, inferred) ?
-                    "diamond.redundant.args" :
-                    "diamond.redundant.args.1";
-                log.warning(tree.clazz.pos(), key, clazztype, inferred);
-            }
-        }
-
         // If we have made no mistakes in the class type...
-        boolean wasError = clazztype.tag == ERROR;
-        if (clazztype.tag == CLASS || wasError) {
+        boolean wasError = clazztype.hasTag(ERROR);
+        if (clazztype.hasTag(CLASS) || wasError) {
             // Enums may not be instantiated except implicitly
             if (allowEnums &&
                 (clazztype.tsym.flags_field&Flags.ENUM) != 0 &&
-                (env.tree.getTag() != JCTree.VARDEF ||
+                (!env.tree.hasTag(VARDEF) ||
                  (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 ||
                  ((JCVariableDecl) env.tree).init != tree))
                 log.error(tree.pos(), "enum.cant.be.instantiated");
@@ -1758,6 +2072,45 @@ public class Attr extends JCTree.Visitor {
                 // Error recovery: pretend no arguments were supplied.
                 argtypes = List.nil();
                 typeargtypes = List.nil();
+            } else if (TreeInfo.isDiamond(tree) && !wasError) {
+                ClassType site = new ClassType(clazztype.getEnclosingType(),
+                            clazztype.tsym.type.getTypeArguments(),
+                            clazztype.tsym);
+
+                Env<AttrContext> diamondEnv = localEnv.dup(tree);
+                diamondEnv.info.selectSuper = cdef != null;
+                diamondEnv.info.pendingResolutionPhase = null;
+
+                //if the type of the instance creation expression is a class type
+                //apply method resolution inference (JLS 15.12.2.7). The return type
+                //of the resolved constructor will be a partially instantiated type
+                Symbol constructor = rs.resolveDiamond(tree.pos(),
+                            diamondEnv,
+                            site,
+                            argtypes,
+                            typeargtypes);
+                tree.constructor = constructor.baseSymbol();
+
+                final TypeSymbol csym = clazztype.tsym;
+                ResultInfo diamondResult = new ResultInfo(MTH, newMethodTemplate(resultInfo.pt, argtypes, typeargtypes), new Check.NestedCheckContext(resultInfo.checkContext) {
+                    @Override
+                    public void report(DiagnosticPosition _unused, JCDiagnostic details) {
+                        enclosingContext.report(tree.clazz,
+                                diags.fragment("cant.apply.diamond.1", diags.fragment("diamond", csym), details));
+                    }
+                });
+                Type constructorType = tree.constructorType = types.createErrorType(clazztype);
+                constructorType = checkId(tree, site,
+                        constructor,
+                        diamondEnv,
+                        diamondResult);
+
+                tree.clazz.type = types.createErrorType(clazztype);
+                if (!constructorType.isErroneous()) {
+                    tree.clazz.type = clazztype = constructorType.getReturnType();
+                    tree.constructorType = types.createMethodTypeWithReturn(constructorType, syms.voidType);
+                }
+                clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true);
             }
 
             // Resolve the called constructor under the assumption
@@ -1769,24 +2122,27 @@ public class Attr extends JCTree.Visitor {
                 //order to avoid downstream failures
                 Env<AttrContext> rsEnv = localEnv.dup(tree);
                 rsEnv.info.selectSuper = cdef != null;
-                rsEnv.info.varArgs = false;
+                rsEnv.info.pendingResolutionPhase = null;
                 tree.constructor = rs.resolveConstructor(
                     tree.pos(), rsEnv, clazztype, argtypes, typeargtypes);
-                tree.constructorType = tree.constructor.type.isErroneous() ?
-                    syms.errType :
-                    checkMethod(clazztype,
-                        tree.constructor,
-                        rsEnv,
-                        tree.args,
-                        argtypes,
-                        typeargtypes,
-                        rsEnv.info.varArgs);
-                if (rsEnv.info.varArgs)
-                    Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);
-                Env<AttrContext> enclosing;
-
-                if (tree.constructor.kind == MTH && tree.constructor.type.isErroneous() && ((enclosing = enter.getEnv(tree.constructor.enclClass())) == null || enclosing.toplevel != env.toplevel)) {
-                    log.error(tree, "type.error", tree.constructor);
+                if (cdef == null) { //do not check twice!
+                    tree.constructorType = checkId(tree,
+                            clazztype,
+                            tree.constructor,
+                            rsEnv,
+                            new ResultInfo(pkind, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
+                    if (rsEnv.info.lastResolveVarargs())
+                        Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);                    
+                    Env<AttrContext> enclosing;
+                    if (tree.constructor.kind == MTH && tree.constructor.type.isErroneous() && ((enclosing = enter.getEnv(tree.constructor.enclClass())) == null || enclosing.toplevel != env.toplevel)) {
+                        log.error(tree, "type.error", tree.constructor);
+                    }
+                }
+                if (cdef == null &&
+                        !clazztype.isErroneous() &&
+                        clazztype.getTypeArguments().nonEmpty() &&
+                        findDiamonds) {
+                    findDiamond(localEnv, tree, clazztype);
                 }
             }
 
@@ -1866,148 +2222,106 @@ public class Attr extends JCTree.Visitor {
                     cdef.extending = clazzCopy;
                 }
 
+                checkLambdaCandidate(tree, cdef.sym, clazztype);
+
                 // If an outer instance is given,
                 // prefix it to the constructor arguments
-                List<JCExpression> treeArgs = tree.args;
+                // "encl" will be cleared in TransTypes
                 if (tree.encl != null && !clazztype.tsym.isInterface()) {
-                    treeArgs = treeArgs.prepend(makeNullCheck(tree.encl));
+                    tree.args = tree.args.prepend(makeNullCheck(tree.encl));
                     argtypes = argtypes.prepend(tree.encl.type);
                 }
 
                 // Reassign clazztype and recompute constructor.
                 clazztype = cdef.sym.type;
-                boolean useVarargs = tree.varargsElement != null;
-                Symbol sym = rs.resolveConstructor(
-                    tree.pos(), localEnv, clazztype, argtypes,
-                    typeargtypes, true, useVarargs);
-                if (!(sym.kind < AMBIGUOUS || tree.constructorType == null || tree.constructorType.isErroneous()))
-                        Assert.error("Attr.visitNewClass tree [" + tree + "] with constructor type [" + tree.constructorType + "] has symbol [" + sym + "] of kind [ " + sym.kind + "]");
+                Symbol sym = tree.constructor = rs.resolveConstructor(
+                    tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
+                Assert.check(sym.kind < AMBIGUOUS, "Attr.visitNewClass tree [" + tree + "] with constructor type [" + tree.constructorType + "] has symbol [" + sym + "] of kind [ " + sym.kind + "]");
                 tree.constructor = sym;
-                if (tree.constructor.kind > ERRONEOUS) {
-                    tree.constructorType =  syms.errType;
-                }
-                else {
-                    tree.constructorType = checkMethod(clazztype,
-                            tree.constructor,
-                            localEnv,
-                            treeArgs,
-                            argtypes,
-                            typeargtypes,
-                            useVarargs);
+                tree.constructorType = checkId(tree,
+                    clazztype,
+                    tree.constructor,
+                    localEnv,
+                    new ResultInfo(pkind, 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)
                 owntype = wasError ? types.createErrorType(clazztype) : clazztype;
         }
-        result = check(tree, owntype, VAL, pkind, pt);
+        result = check(tree, owntype, VAL, resultInfo);
         chk.validate(tree.typeargs, localEnv);
     }
-
-    Type attribDiamond(Env<AttrContext> env,
-                        JCNewClass tree,
-                        Type clazztype,
-                        Pair<Scope, Scope> mapping,
-                        List<Type> argtypes,
-                        List<Type> typeargtypes) {
-        if (clazztype.isErroneous() ||
-                clazztype.isInterface() ||
-                mapping == erroneousMapping) {
-            //if the type of the instance creation expression is erroneous,
-            //or if it's an interface, or if something prevented us to form a valid
-            //mapping, return the (possibly erroneous) type unchanged
-            return clazztype;
-        }
-
-        //dup attribution environment and augment the set of inference variables
-        Env<AttrContext> localEnv = env.dup(tree);
-        localEnv.info.tvars = clazztype.tsym.type.getTypeArguments();
-
-        //if the type of the instance creation expression is a class type
-        //apply method resolution inference (JLS 15.12.2.7). The return type
-        //of the resolved constructor will be a partially instantiated type
-        ((ClassSymbol) clazztype.tsym).members_field = mapping.snd;
-        Symbol constructor;
-        try {
-            constructor = rs.resolveDiamond(tree.pos(),
-                    localEnv,
-                    clazztype,
-                    argtypes,
-                    typeargtypes);
-        } finally {
-            ((ClassSymbol) clazztype.tsym).members_field = mapping.fst;
-        }
-        if (constructor.kind == MTH) {
-            ClassType ct = new ClassType(clazztype.getEnclosingType(),
-                    clazztype.tsym.type.getTypeArguments(),
-                    clazztype.tsym);
-            clazztype = checkMethod(ct,
-                    constructor,
-                    localEnv,
-                    tree.args,
-                    argtypes,
-                    typeargtypes,
-                    localEnv.info.varArgs).getReturnType();
-        } else {
-            clazztype = syms.errType;
-        }
-
-        if (clazztype.tag == FORALL && !pt.isErroneous()) {
-            //if the resolved constructor's return type has some uninferred
-            //type-variables, infer them using the expected type and declared
-            //bounds (JLS 15.12.2.8).
+    //where
+        void findDiamond(Env<AttrContext> env, JCNewClass tree, Type clazztype) {
+            JCTypeApply ta = (JCTypeApply)tree.clazz;
+            List<JCExpression> prevTypeargs = ta.arguments;
             try {
-                clazztype = infer.instantiateExpr((ForAll) clazztype,
-                        pt.tag == NONE ? syms.objectType : pt,
-                        Warner.noWarnings);
-            } catch (Infer.InferenceException ex) {
-                //an error occurred while inferring uninstantiated type-variables
-                log.error(tree.clazz.pos(),
-                        "cant.apply.diamond.1",
-                        diags.fragment("diamond", clazztype.tsym),
-                        ex.diagnostic);
-            }
-        }
-        return chk.checkClassType(tree.clazz.pos(),
-                clazztype,
-                true);
-    }
-
-    /** Creates a synthetic scope containing fake generic constructors.
-     *  Assuming that the original scope contains a constructor of the kind:
-     *  Foo(X x, Y y), where X,Y are class type-variables declared in Foo,
-     *  the synthetic scope is added a generic constructor of the kind:
-     *  <X,Y>Foo<X,Y>(X x, Y y). This is crucial in order to enable diamond
-     *  inference. The inferred return type of the synthetic constructor IS
-     *  the inferred type for the diamond operator.
-     */
-    private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype) {
-        if (ctype.tag != CLASS) {
-            return erroneousMapping;
+                //create a 'fake' diamond AST node by removing type-argument trees
+                ta.arguments = List.nil();
+                ResultInfo findDiamondResult = new ResultInfo(VAL,
+                        resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt());
+                Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type;
+                Type polyPt = allowPoly ?
+                        syms.objectType :
+                        clazztype;
+                if (!inferred.isErroneous() &&
+                    (allowPoly && pt() == Infer.anyPoly ?
+                        types.isSameType(inferred, clazztype) :
+                        types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings))) {
+                    String key = types.isSameType(clazztype, inferred) ?
+                        "diamond.redundant.args" :
+                        "diamond.redundant.args.1";
+                    log.warning(tree.clazz.pos(), key, clazztype, inferred);
+                }
+            } finally {
+                ta.arguments = prevTypeargs;
+            }
         }
 
-        Pair<Scope, Scope> mapping =
-                new Pair<Scope, Scope>(ctype.tsym.members(), new Scope(ctype.tsym));
+            private void checkLambdaCandidate(JCNewClass tree, ClassSymbol csym, Type clazztype) {
+                if (allowLambda &&
+                        identifyLambdaCandidate &&
+                        clazztype.hasTag(CLASS) &&
+                        !pt().hasTag(NONE) &&
+                        types.isFunctionalInterface(clazztype.tsym)) {
+                    Symbol descriptor = types.findDescriptorSymbol(clazztype.tsym);
+                    int count = 0;
+                    boolean found = false;
+                    for (Symbol sym : csym.members().getElements()) {
+                        if ((sym.flags() & SYNTHETIC) != 0 ||
+                                sym.isConstructor()) continue;
+                        count++;
+                        if (sym.kind != MTH ||
+                                !sym.name.equals(descriptor.name)) continue;
+                        Type mtype = types.memberType(clazztype, sym);
+                        if (types.overrideEquivalent(mtype, types.memberType(clazztype, descriptor))) {
+                            found = true;
+                        }
+                    }
+                    if (found && count == 1) {
+                        log.note(tree.def, "potential.lambda.found");
+                    }
+                }
+            }
 
-        //for each constructor in the original scope, create a synthetic constructor
-        //whose return type is the type of the class in which the constructor is
-        //declared, and insert it into the new scope.
-        for (Scope.Entry e = mapping.fst.lookup(names.init);
-                e.scope != null;
-                e = e.next()) {
-            Type synthRestype = new ClassType(ctype.getEnclosingType(),
-                        ctype.tsym.type.getTypeArguments(),
-                        ctype.tsym);
-            MethodSymbol synhConstr = new MethodSymbol(e.sym.flags(),
-                    names.init,
-                    types.createMethodTypeWithReturn(e.sym.type, synthRestype),
-                    e.sym.owner);
-            mapping.snd.enter(synhConstr);
+    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");
+            }
         }
-        return mapping;
     }
 
-    private final Pair<Scope,Scope> erroneousMapping = new Pair<Scope,Scope>(null, null);
 
     /** Make an attributed null check tree.
      */
@@ -2016,8 +2330,8 @@ public class Attr extends JCTree.Visitor {
         Name name = TreeInfo.name(arg);
         if (name == names._this || name == names._super) return arg;
 
-        int optag = JCTree.NULLCHK;
-        JCUnary tree = make.at(arg.pos).Unary(optag, arg);
+        JCTree.Tag optag = NULLCHK;
+        JCUnary tree = make.at(Position.NOPOS).Unary(optag, arg);
         tree.operator = syms.nullcheck;
         tree.type = arg.type;
         return tree;
@@ -2025,59 +2339,748 @@ public class Attr extends JCTree.Visitor {
 
     public void visitNewArray(JCNewArray tree) {
         Type owntype = types.createErrorType(tree.type);
+        Env<AttrContext> localEnv = env.dup(tree);
         Type elemtype;
         if (tree.elemtype != null) {
-            elemtype = attribType(tree.elemtype, env);
-            chk.validate(tree.elemtype, env);
+            elemtype = attribType(tree.elemtype, localEnv);
+            chk.validate(tree.elemtype, localEnv);
             owntype = elemtype;
             for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
-                attribExpr(l.head, env, syms.intType);
+                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
-            if (pt.tag == ARRAY) {
-                elemtype = types.elemtype(pt);
+            if (pt().hasTag(ARRAY)) {
+                elemtype = types.elemtype(pt());
             } else {
-                if (pt.tag != ERROR) {
+                if (!pt().hasTag(ERROR)) {
                     log.error(tree.pos(), "illegal.initializer.for.type",
-                              pt);
+                              pt());
                 }
-                elemtype = types.createErrorType(pt);
+                elemtype = types.createErrorType(pt());
             }
         }
         if (tree.elems != null) {
-            attribExprs(tree.elems, env, elemtype);
+            attribExprs(tree.elems, localEnv, elemtype);
             owntype = new ArrayType(elemtype, syms.arrayClass);
         }
         if (!types.isReifiable(elemtype))
             log.error(tree.pos(), "generic.array.creation");
-        result = check(tree, owntype, VAL, pkind, pt);
+        result = check(tree, owntype, VAL, resultInfo);
+    }
+
+    /*
+     * A lambda expression can only be attributed when a target-type is available.
+     * In addition, if the target-type is that of a functional interface whose
+     * descriptor contains inference variables in argument position the lambda expression
+     * is 'stuck' (see DeferredAttr).
+     */
+    @Override
+    public void visitLambda(final JCLambda that) {
+        if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) {
+            if (pt().hasTag(NONE)) {
+                //lambda only allowed in assignment or method invocation/cast context
+                log.error(that.pos(), "unexpected.lambda");
+            }
+        }
+        //create an environment for attribution of the lambda expression
+        final Env<AttrContext> localEnv = lambdaEnv(that, env);
+        boolean needsRecovery = resultInfo != recoveryInfo &&
+                resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK;
+        Type target = null;
+        try {
+            target = pt();
+            List<Type> explicitParamTypes = null;
+            if (that.paramKind == JCLambda.ParameterKind.EXPLICIT) {
+                //attribute lambda parameters
+                attribStats(that.params, localEnv);
+                explicitParamTypes = TreeInfo.types(that.params);
+                target = infer.instantiateFunctionalInterface(that, target, explicitParamTypes, resultInfo.checkContext);
+            }
+
+            Type lambdaType;
+            if (pt().hasTag(NONE) && pt() != Type.recoveryType) {
+                resultInfo = recoveryInfo;
+            }
+            if (pt() != Type.recoveryType && pt() != Infer.anyPoly) {
+                target = targetChecker.visit(target, that);
+                lambdaType = types.findDescriptorType(target);
+            } else {
+                target = Type.recoveryType;
+                lambdaType = fallbackDescriptorType(that);
+            }
+
+            setFunctionalInfo(localEnv, that, pt(), lambdaType, target, resultInfo.checkContext);
+
+            if (lambdaType.hasTag(FORALL)) {
+                //lambda expression target desc cannot be a generic method
+                resultInfo.checkContext.report(that, diags.fragment("invalid.generic.lambda.target",
+                        lambdaType, kindName(target.tsym), target.tsym));
+                result = that.type = types.createErrorType(pt());
+                return;
+            }
+
+            if (that.paramKind == JCLambda.ParameterKind.IMPLICIT) {
+                //add param type info in the AST
+                List<Type> actuals = lambdaType.getParameterTypes();
+                List<JCVariableDecl> params = that.params;
+
+                boolean arityMismatch = false;
+
+                while (params.nonEmpty()) {
+                    if (actuals.isEmpty()) {
+                        //not enough actuals to perform lambda parameter inference
+                        arityMismatch = true;
+                    }
+                    //reset previously set info
+                    Type argType = arityMismatch ?
+                            syms.errType :
+                            actuals.head;
+                    params.head.vartype = make.at(Position.NOPOS).Type(argType);
+                    params.head.sym = null;
+                    actuals = actuals.isEmpty() ?
+                            actuals :
+                            actuals.tail;
+                    params = params.tail;
+                }
+
+                //attribute lambda parameters
+                attribStats(that.params, localEnv);
+
+                if (arityMismatch) {
+                    resultInfo.checkContext.report(that, diags.fragment("incompatible.arg.types.in.lambda"));
+                        result = that.type = types.createErrorType(target);
+                        return;
+                }
+            }
+
+            //from this point on, no recovery is needed; if we are in assignment context
+            //we will be able to attribute the whole lambda body, regardless of errors;
+            //if we are in a 'check' method context, and the lambda is not compatible
+            //with the target-type, it will be recovered anyway in Attr.checkId
+            needsRecovery = false;
+
+            FunctionalReturnContext funcContext = that.getBodyKind() == JCLambda.BodyKind.EXPRESSION ?
+                    new ExpressionLambdaReturnContext((JCExpression)that.getBody(), resultInfo.checkContext) :
+                    new FunctionalReturnContext(resultInfo.checkContext);
+
+            ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ?
+                recoveryInfo :
+                new LambdaResultInfo(lambdaType.getReturnType(), funcContext);
+            localEnv.info.returnResult = bodyResultInfo;
+
+            Log.DeferredDiagnosticHandler lambdaDeferredHandler = new Log.DeferredDiagnosticHandler(log);
+            try {
+                if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
+                    attribTree(that.getBody(), localEnv, bodyResultInfo);
+                } else {
+                    JCBlock body = (JCBlock)that.body;
+                    if (body == breakTree &&
+                            resultInfo.checkContext.deferredAttrContext().mode == AttrMode.CHECK) {
+                        throw new BreakAttr(copyEnv(localEnv));
+                    }
+                    attribStats(body.stats, localEnv);
+                }
+
+                if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
+                    //check for errors in lambda body
+                    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),
+                                    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
+                            //a target-independent error (which will cause method diagnostic
+                            //to be skipped).
+                            result = that.type = types.createErrorType(target);
+                            return;
+                        }
+                    }
+                }
+            } finally {
+                lambdaDeferredHandler.reportDeferredDiagnostics();
+                log.popDiagnosticHandler(lambdaDeferredHandler);
+            }
+
+            result = check(that, target, VAL, resultInfo);
+
+            boolean isSpeculativeRound =
+                    resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+
+            preFlow(that);
+            flow.analyzeLambda(env, that, make, isSpeculativeRound);
+
+            checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound);
+
+            if (!isSpeculativeRound) {
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target);
+            }
+            result = check(that, target, VAL, resultInfo);
+        } catch (Types.FunctionDescriptorLookupError ex) {
+            JCDiagnostic cause = ex.getDiagnostic();
+            resultInfo.checkContext.report(that, cause);
+            result = that.type = types.createErrorType(pt());
+            return;
+        } catch (BreakAttr ba) {
+            check(that, target, VAL, resultInfo);
+            needsRecovery = false;
+            throw ba;
+        } finally {
+            localEnv.info.scope.leave();
+            if (needsRecovery) {
+                attribTree(that, env, recoveryInfo);
+            }
+        }
+    }
+    //where
+        void preFlow(JCLambda tree) {
+            new PostAttrAnalyzer() {
+                @Override
+                public void scan(JCTree tree) {
+                    if (tree == null ||
+                            (tree.type != null &&
+                            tree.type == Type.stuckType)) {
+                        //don't touch stuck expressions!
+                        return;
+                    }
+                    super.scan(tree);
+                }
+            }.scan(tree);
+        }
+
+        Types.MapVisitor<DiagnosticPosition> targetChecker = new Types.MapVisitor<DiagnosticPosition>() {
+
+            @Override
+            public Type visitClassType(ClassType t, DiagnosticPosition pos) {
+                return t.isCompound() ?
+                        visitIntersectionClassType((IntersectionClassType)t, pos) : t;
+            }
+
+            public Type visitIntersectionClassType(IntersectionClassType ict, DiagnosticPosition pos) {
+                Symbol desc = types.findDescriptorSymbol(makeNotionalInterface(ict));
+                Type target = null;
+                for (Type bound : ict.getExplicitComponents()) {
+                    TypeSymbol boundSym = bound.tsym;
+                    if (types.isFunctionalInterface(boundSym) &&
+                            types.findDescriptorSymbol(boundSym) == desc) {
+                        target = bound;
+                    } else if (!boundSym.isInterface() || (boundSym.flags() & ANNOTATION) != 0) {
+                        //bound must be an interface
+                        reportIntersectionError(pos, "not.an.intf.component", boundSym);
+                    }
+                }
+                return target != null ?
+                        target :
+                        ict.getExplicitComponents().head; //error recovery
+            }
+
+            private TypeSymbol makeNotionalInterface(IntersectionClassType ict) {
+                ListBuffer<Type> targs = ListBuffer.lb();
+                ListBuffer<Type> supertypes = ListBuffer.lb();
+                for (Type i : ict.interfaces_field) {
+                    if (i.isParameterized()) {
+                        targs.appendList(i.tsym.type.allparams());
+                    }
+                    supertypes.append(i.tsym.type);
+                }
+                IntersectionClassType notionalIntf =
+                        (IntersectionClassType)types.makeCompoundType(supertypes.toList());
+                notionalIntf.allparams_field = targs.toList();
+                notionalIntf.tsym.flags_field |= INTERFACE;
+                return notionalIntf.tsym;
+            }
+
+            private void reportIntersectionError(DiagnosticPosition pos, String key, Object... args) {
+                resultInfo.checkContext.report(pos, diags.fragment("bad.intersection.target.for.functional.expr",
+                        diags.fragment(key, args)));
+            }
+        };
+
+        private Type fallbackDescriptorType(JCExpression tree) {
+            switch (tree.getTag()) {
+                case LAMBDA:
+                    JCLambda lambda = (JCLambda)tree;
+                    List<Type> argtypes = List.nil();
+                    for (JCVariableDecl param : lambda.params) {
+                        argtypes = param.vartype != null ?
+                                argtypes.append(param.vartype.type) :
+                                argtypes.append(syms.errType);
+                    }
+                    return new MethodType(argtypes, Type.recoveryType,
+                            List.of(syms.throwableType), syms.methodClass);
+                case REFERENCE:
+                    return new MethodType(List.<Type>nil(), Type.recoveryType,
+                            List.of(syms.throwableType), syms.methodClass);
+                default:
+                    Assert.error("Cannot get here!");
+            }
+            return null;
+        }
+
+        private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
+                final InferenceContext inferenceContext, final Type... ts) {
+            checkAccessibleTypes(pos, env, inferenceContext, List.from(ts));
+        }
+
+        private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
+                final InferenceContext inferenceContext, final List<Type> ts) {
+            if (inferenceContext.free(ts)) {
+                inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
+                    @Override
+                    public void typesInferred(InferenceContext inferenceContext) {
+                        checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts));
+                    }
+                });
+            } else {
+                for (Type t : ts) {
+                    rs.checkAccessibleType(env, t);
+                }
+            }
+        }
+
+        /**
+         * Lambda/method reference have a special check context that ensures
+         * that i.e. a lambda return type is compatible with the expected
+         * type according to both the inherited context and the assignment
+         * context.
+         */
+        class FunctionalReturnContext extends Check.NestedCheckContext {
+
+            FunctionalReturnContext(CheckContext enclosingContext) {
+                super(enclosingContext);
+            }
+
+            @Override
+            public boolean compatible(Type found, Type req, Warner warn) {
+                //return type must be compatible in both current context and assignment context
+                return chk.basicHandler.compatible(found, inferenceContext().asFree(req), warn);
+            }
+
+            @Override
+            public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                enclosingContext.report(pos, diags.fragment("incompatible.ret.type.in.lambda", details));
+            }
+        }
+
+        class ExpressionLambdaReturnContext extends FunctionalReturnContext {
+
+            JCExpression expr;
+
+            ExpressionLambdaReturnContext(JCExpression expr, CheckContext enclosingContext) {
+                super(enclosingContext);
+                this.expr = expr;
+            }
+
+            @Override
+            public boolean compatible(Type found, Type req, Warner warn) {
+                //a void return is compatible with an expression statement lambda
+                return TreeInfo.isExpressionStatement(expr) && req.hasTag(VOID) ||
+                        super.compatible(found, req, warn);
+            }
+        }
+
+        class LambdaResultInfo extends ResultInfo {
+
+            LambdaResultInfo(Type pt, CheckContext checkContext) {
+                super(VAL, pt, checkContext);
+            }
+
+            @Override
+            protected Type check(DiagnosticPosition pos, Type found) {
+                return super.check(pos, found.baseType());
+            }
+
+            @Override
+            protected ResultInfo dup(CheckContext newContext) {
+                return new LambdaResultInfo(pt, newContext);
+            }
+
+            @Override
+            protected ResultInfo dup(Type newPt) {
+                return new LambdaResultInfo(newPt, checkContext);
+            }
+        }
+
+        /**
+        * Lambda compatibility. Check that given return types, thrown types, parameter types
+        * are compatible with the expected functional interface descriptor. This means that:
+        * (i) parameter types must be identical to those of the target descriptor; (ii) return
+        * types must be compatible with the return type of the expected descriptor;
+        * (iii) finish inference of thrown types if required.
+        */
+        private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext, boolean speculativeAttr) {
+            Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType());
+
+            //return values have already been checked - but if lambda has no return
+            //values, we must ensure that void/value compatibility is correct;
+            //this amounts at checking that, if a lambda body can complete normally,
+            //the descriptor's return type must be void
+            if (tree.getBodyKind() == JCLambda.BodyKind.STATEMENT && tree.canCompleteNormally &&
+                    !returnType.hasTag(VOID) && returnType != Type.recoveryType) {
+                checkContext.report(tree, diags.fragment("incompatible.ret.type.in.lambda",
+                        diags.fragment("missing.ret.val", returnType)));
+            }
+
+            List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes());
+            if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) {
+                checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda"));
+            }
+
+            if (!speculativeAttr) {
+                List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes());
+                chk.unhandled(tree.inferredThrownTypes == null ? List.<Type>nil() : tree.inferredThrownTypes, thrownTypes);
+            }
+        }
+
+        private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) {
+            Env<AttrContext> lambdaEnv;
+            Symbol owner = env.info.scope.owner;
+            if (owner.kind == VAR && owner.owner.kind == TYP) {
+                //field initializer
+                lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared()));
+                lambdaEnv.info.scope.owner =
+                    new MethodSymbol((owner.flags() & STATIC) | BLOCK, names.empty, null,
+                                     env.info.scope.owner);
+            } else {
+                lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup()));
+            }
+            return lambdaEnv;
+        }
+
+    @Override
+    public void visitReference(final JCMemberReference that) {
+        if (pt().isErroneous() || (pt().hasTag(NONE) && pt() != Type.recoveryType)) {
+            if (pt().hasTag(NONE)) {
+                //method reference only allowed in assignment or method invocation/cast context
+                log.error(that.pos(), "unexpected.mref");
+            }
+            result = that.type = types.createErrorType(pt());
+            return;
+        }
+        final Env<AttrContext> localEnv = env.dup(that);
+        try {
+            //attribute member reference qualifier - if this is a constructor
+            //reference, the expected kind must be a type
+            Type exprType = attribTree(that.expr, env, memberReferenceQualifierResult(that));
+
+            if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
+                exprType = chk.checkConstructorRefType(that.expr, exprType);
+            }
+
+            if (exprType.isErroneous()) {
+                //if the qualifier expression contains problems,
+                //give up attribution of method reference
+                result = that.type = exprType;
+                return;
+            }
+
+            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
+            List<Type> typeargtypes = List.nil();
+            if (that.typeargs != null) {
+                typeargtypes = attribTypes(that.typeargs, localEnv);
+            }
+
+            Type target;
+            Type desc;
+            if (pt() != Type.recoveryType) {
+                target = targetChecker.visit(pt(), that);
+                desc = types.findDescriptorType(target);
+            } else {
+                target = Type.recoveryType;
+                desc = fallbackDescriptorType(that);
+            }
+
+            setFunctionalInfo(localEnv, that, pt(), desc, target, resultInfo.checkContext);
+            List<Type> argtypes = desc.getParameterTypes();
+            Resolve.MethodCheck referenceCheck = rs.resolveMethodCheck;
+
+            if (resultInfo.checkContext.inferenceContext().free(argtypes)) {
+                referenceCheck = rs.new MethodReferenceCheck(resultInfo.checkContext.inferenceContext());
+            }
+
+            Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = null;
+            List<Type> saved_undet = resultInfo.checkContext.inferenceContext().save();
+            try {
+                refResult = rs.resolveMemberReference(that.pos(), localEnv, that, that.expr.type,
+                        that.name, argtypes, typeargtypes, true, referenceCheck,
+                        resultInfo.checkContext.inferenceContext());
+            } finally {
+                resultInfo.checkContext.inferenceContext().rollback(saved_undet);
+            }
+
+            Symbol refSym = refResult.fst;
+            Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
+
+            if (refSym.kind != MTH) {
+                boolean targetError;
+                switch (refSym.kind) {
+                    case ABSENT_MTH:
+                        targetError = false;
+                        break;
+                    case WRONG_MTH:
+                    case WRONG_MTHS:
+                    case AMBIGUOUS:
+                    case HIDDEN:
+                    case STATICERR:
+                    case MISSING_ENCL:
+                        targetError = true;
+                        break;
+                    default:
+                        Assert.error("unexpected result kind " + refSym.kind);
+                        targetError = false;
+                }
+
+                JCDiagnostic detailsDiag = ((Resolve.ResolveError)refSym).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT,
+                                that, exprType.tsym, exprType, that.name, argtypes, typeargtypes);
+
+                JCDiagnostic.DiagnosticType diagKind = targetError ?
+                        JCDiagnostic.DiagnosticType.FRAGMENT : JCDiagnostic.DiagnosticType.ERROR;
+
+                JCDiagnostic diag = diags.create(diagKind, log.currentSource(), that,
+                        "invalid.mref", Kinds.kindName(that.getMode()), detailsDiag);
+
+                if (targetError && target == Type.recoveryType) {
+                    //a target error doesn't make sense during recovery stage
+                    //as we don't know what actual parameter types are
+                    result = that.type = target;
+                    return;
+                } else {
+                    if (targetError) {
+                        resultInfo.checkContext.report(that, diag);
+                    } else {
+                        log.report(diag);
+                    }
+                    result = that.type = types.createErrorType(target);
+                    return;
+                }
+            }
+
+            that.sym = refSym.baseSymbol();
+            that.kind = lookupHelper.referenceKind(that.sym);
+            that.ownerAccessible = rs.isAccessible(localEnv, that.sym.enclClass());
+
+            if (desc.getReturnType() == Type.recoveryType) {
+                // stop here
+                result = that.type = target;
+                return;
+            }
+
+            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) &&
+                        !that.sym.isStatic()) {
+                    log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+                            diags.fragment("non-static.cant.be.ref", Kinds.kindName(refSym), refSym));
+                    result = that.type = types.createErrorType(target);
+                    return;
+                }
+
+                if (that.kind.isUnbound() &&
+                        that.getMode() == ReferenceMode.INVOKE &&
+                        TreeInfo.isStaticSelector(that.expr, names) &&
+                        that.sym.isStatic()) {
+                    log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+                            diags.fragment("static.method.in.unbound.lookup", Kinds.kindName(refSym), refSym));
+                    result = that.type = types.createErrorType(target);
+                    return;
+                }
+
+                if (that.sym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) &&
+                        exprType.getTypeArguments().nonEmpty()) {
+                    //static ref with class type-args
+                    log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+                            diags.fragment("static.mref.with.targs"));
+                    result = that.type = types.createErrorType(target);
+                    return;
+                }
+
+                if (that.sym.isStatic() && !TreeInfo.isStaticSelector(that.expr, names) &&
+                        !that.kind.isUnbound()) {
+                    //no static bound mrefs
+                    log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()),
+                            diags.fragment("static.bound.mref"));
+                    result = that.type = types.createErrorType(target);
+                    return;
+                }
+
+                if (!refSym.isStatic() && that.kind == JCMemberReference.ReferenceKind.SUPER) {
+                    // Check that super-qualified symbols are not abstract (JLS)
+                    rs.checkNonAbstract(that.pos(), that.sym);
+                }
+            }
+
+            ResultInfo checkInfo =
+                    resultInfo.dup(newMethodTemplate(
+                        desc.getReturnType().hasTag(VOID) ? Type.noType : desc.getReturnType(),
+                        that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes));
+
+            Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo);
+
+            if (that.kind.isUnbound() &&
+                    resultInfo.checkContext.inferenceContext().free(argtypes.head)) {
+                //re-generate inference constraints for unbound receiver
+                if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asFree(argtypes.head), exprType)) {
+                    //cannot happen as this has already been checked - we just need
+                    //to regenerate the inference constraints, as that has been lost
+                    //as a result of the call to inferenceContext.save()
+                    Assert.error("Can't get here");
+                }
+            }
+
+            if (!refType.isErroneous()) {
+                refType = types.createMethodTypeWithReturn(refType,
+                        adjustMethodReturnType(lookupHelper.site, that.name, checkInfo.pt.getParameterTypes(), refType.getReturnType()));
+            }
+
+            //go ahead with standard method reference compatibility check - note that param check
+            //is a no-op (as this has been taken care during method applicability)
+            boolean isSpeculativeRound =
+                    resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+            checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
+            if (!isSpeculativeRound) {
+                checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, target);
+            }
+            result = check(that, target, VAL, resultInfo);
+        } catch (Types.FunctionDescriptorLookupError ex) {
+            JCDiagnostic cause = ex.getDiagnostic();
+            resultInfo.checkContext.report(that, cause);
+            result = that.type = types.createErrorType(pt());
+            return;
+        }
+    }
+    //where
+        ResultInfo memberReferenceQualifierResult(JCMemberReference tree) {
+            //if this is a constructor reference, the expected kind must be a type
+            return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType);
+        }
+
+
+    @SuppressWarnings("fallthrough")
+    void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
+        Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType());
+
+        Type resType;
+        switch (tree.getMode()) {
+            case NEW:
+                if (!tree.expr.type.isRaw()) {
+                    resType = tree.expr.type;
+                    break;
+                }
+            default:
+                resType = refType.getReturnType();
+        }
+
+        Type incompatibleReturnType = resType;
+
+        if (returnType.hasTag(VOID)) {
+            incompatibleReturnType = null;
+        }
+
+        if (!returnType.hasTag(VOID) && !resType.hasTag(VOID)) {
+            if (resType.isErroneous() ||
+                    new FunctionalReturnContext(checkContext).compatible(resType, returnType, types.noWarnings)) {
+                incompatibleReturnType = null;
+            }
+        }
+
+        if (incompatibleReturnType != null) {
+            checkContext.report(tree, diags.fragment("incompatible.ret.type.in.mref",
+                    diags.fragment("inconvertible.types", resType, descriptor.getReturnType())));
+        }
+
+        if (!speculativeAttr) {
+            List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes());
+            if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
+                log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes());
+            }
+        }
+    }
+
+    /**
+     * Set functional type info on the underlying AST. Note: as the target descriptor
+     * might contain inference variables, we might need to register an hook in the
+     * current inference context.
+     */
+    private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
+            final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
+        if (checkContext.inferenceContext().free(descriptorType)) {
+            checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType), new FreeTypeListener() {
+                public void typesInferred(InferenceContext inferenceContext) {
+                    setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
+                            inferenceContext.asInstType(primaryTarget), checkContext);
+                }
+            });
+        } else {
+            ListBuffer<Type> targets = ListBuffer.lb();
+            if (pt.hasTag(CLASS)) {
+                if (pt.isCompound()) {
+                    targets.append(types.removeWildcards(primaryTarget)); //this goes first
+                    for (Type t : ((IntersectionClassType)pt()).interfaces_field) {
+                        if (t != primaryTarget) {
+                            targets.append(types.removeWildcards(t));
+                        }
+                    }
+                } else {
+                    targets.append(types.removeWildcards(primaryTarget));
+                }
+            }
+            fExpr.targets = targets.toList();
+            if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
+                    pt != Type.recoveryType) {
+                //check that functional interface class is well-formed
+                ClassSymbol csym = types.makeFunctionalInterfaceClass(env,
+                        names.empty, List.of(fExpr.targets.head), ABSTRACT);
+                chk.checkImplementations(env.tree, csym, csym);
+            }
+        }
     }
 
     public void visitParens(JCParens tree) {
-        Type owntype = attribTree(tree.expr, env, pkind, pt);
-        result = check(tree, owntype, pkind, pkind, pt);
+        Type owntype = attribTree(tree.expr, env, resultInfo);
+        result = check(tree, owntype, pkind(), resultInfo);
         Symbol sym = TreeInfo.symbol(tree);
         if (sym != null && (sym.kind&(TYP|PCK)) != 0)
             log.error(tree.pos(), "illegal.start.of.type");
     }
 
     public void visitAssign(JCAssign tree) {
-        Type owntype = attribTree(tree.lhs, env.dup(tree), VAR, Type.noType);
+        Type owntype = attribTree(tree.lhs, env.dup(tree), varInfo);
         Type capturedType = capture(owntype);
         attribExpr(tree.rhs, env, owntype);
-        result = check(tree, capturedType, VAL, pkind, pt);
+        result = check(tree, capturedType, VAL, resultInfo);
     }
 
     public void visitAssignop(JCAssignOp tree) {
         // Attribute arguments.
-        Type owntype = attribTree(tree.lhs, env, VAR, Type.noType);
+        Type owntype = attribTree(tree.lhs, env, varInfo);
         Type operand = attribExpr(tree.rhs, env);
         // Find operator.
         Symbol operator = tree.operator = rs.resolveBinaryOperator(
-            tree.pos(), tree.getTag() - JCTree.ASGOffset, env,
+            tree.pos(), tree.getTag().noAssignOp(), env,
             owntype, operand);
 
         if (operator.kind == MTH &&
@@ -2085,7 +3088,7 @@ public class Attr extends JCTree.Visitor {
                 !operand.isErroneous()) {
             chk.checkOperator(tree.pos(),
                               (OperatorSymbol)operator,
-                              tree.getTag() - JCTree.ASGOffset,
+                              tree.getTag().noAssignOp(),
                               owntype,
                               operand);
             chk.checkDivZero(tree.rhs.pos(), operator, operand);
@@ -2093,13 +3096,13 @@ public class Attr extends JCTree.Visitor {
                               operator.type.getReturnType(),
                               owntype);
         }
-        result = check(tree, owntype, VAL, pkind, pt);
+        result = check(tree, owntype, VAL, resultInfo);
     }
 
     public void visitUnary(JCUnary tree) {
         // Attribute arguments.
-        Type argtype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC)
-            ? attribTree(tree.arg, env, VAR, Type.noType)
+        Type argtype = (tree.getTag().isIncOrDecUnaryOp())
+            ? attribTree(tree.arg, env, varInfo)
             : chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env));
 
         // Find operator.
@@ -2109,7 +3112,7 @@ public class Attr extends JCTree.Visitor {
         Type owntype = types.createErrorType(tree.type);
         if (operator.kind == MTH &&
                 !argtype.isErroneous()) {
-            owntype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC)
+            owntype = (tree.getTag().isIncOrDecUnaryOp())
                 ? tree.arg.type
                 : operator.type.getReturnType();
             int opc = ((OperatorSymbol)operator).opcode;
@@ -2131,73 +3134,132 @@ public class Attr extends JCTree.Visitor {
                 }
             }
         }
-        result = check(tree, owntype, VAL, pkind, pt);
+        result = check(tree, owntype, VAL, resultInfo);
     }
 
     public void visitBinary(JCBinary tree) {
-        // Attribute arguments.
-        Type left = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.lhs, env));
-        Type right = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.rhs, env));
-
-        // Find operator.
-        Symbol operator = tree.operator =
-            rs.resolveBinaryOperator(tree.pos(), tree.getTag(), env, left, right);
-
-        Type owntype = types.createErrorType(tree.type);
-        if (operator.kind == MTH &&
-                !left.isErroneous() &&
-                !right.isErroneous()) {
-            owntype = operator.type.getReturnType();
-            int opc = chk.checkOperator(tree.lhs.pos(),
-                                        (OperatorSymbol)operator,
-                                        tree.getTag(),
-                                        left,
-                                        right);
-
-            // If both arguments are constants, fold them.
-            if (left.constValue() != null && right.constValue() != null) {
-                Type ctype = cfolder.fold2(opc, left, right);
-                if (ctype != null) {
-                    owntype = cfolder.coerce(ctype, owntype);
+        boolean baCatched = false;
+        try {
+            // Attribute arguments.
+            Type left = chk.checkNonVoid(tree.lhs.pos(), attribTree(tree.lhs, env, new ResultInfo(VAL | TYP , Type.noType)));
+            Type right = chk.checkNonVoid(tree.lhs.pos(), attribTree(tree.rhs, env, new ResultInfo(VAL | TYP , Type.noType)));
+
+            // Find operator.
+            Symbol operator = tree.operator =
+                rs.resolveBinaryOperator(tree.pos(), tree.getTag(), env, left, right);
+
+            Type owntype = types.createErrorType(tree.type);
+            if (operator.kind == MTH &&
+                    !left.isErroneous() &&
+                    !right.isErroneous()) {
+                owntype = operator.type.getReturnType();
+                // This will figure out when unboxing can happen and
+                // choose the right comparison operator.
+                int opc = chk.checkOperator(tree.lhs.pos(),
+                                            (OperatorSymbol)operator,
+                                            tree.getTag(),
+                                            left,
+                                            right);
+
+                // If both arguments are constants, fold them.
+                if (left.constValue() != null && right.constValue() != null) {
+                    Type ctype = cfolder.fold2(opc, left, right);
+                    if (ctype != null) {
+                        owntype = cfolder.coerce(ctype, owntype);
+
+                        // Remove constant types from arguments to
+                        // conserve space. The parser will fold concatenations
+                        // of string literals; the code here also
+                        // gets rid of intermediate results when some of the
+                        // operands are constant identifiers.
+                        if (tree.lhs.type.tsym == syms.stringType.tsym) {
+                            tree.lhs.type = syms.stringType;
+                        }
+                        if (tree.rhs.type.tsym == syms.stringType.tsym) {
+                            tree.rhs.type = syms.stringType;
+                        }
+                    }
+                }
 
-                    // Remove constant types from arguments to
-                    // conserve space. The parser will fold concatenations
-                    // of string literals; the code here also
-                    // gets rid of intermediate results when some of the
-                    // operands are constant identifiers.
-                    if (tree.lhs.type.tsym == syms.stringType.tsym) {
-                        tree.lhs.type = syms.stringType;
+                // Check that argument types of a reference ==, != are
+                // castable to each other, (JLS 15.21).  Note: unboxing
+                // comparisons will not have an acmp* opc at this point.
+                if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
+                    if (!types.isEqualityComparable(left, right,
+                                                    new Warner(tree.pos()))) {
+                        log.error(tree.pos(), "incomparable.types", left, right);
                     }
-                    if (tree.rhs.type.tsym == syms.stringType.tsym) {
-                        tree.rhs.type = syms.stringType;
+                }
+
+                chk.checkDivZero(tree.rhs.pos(), operator, right);
+            }
+            result = check(tree, owntype, VAL, resultInfo);
+        } catch (BreakAttr ba) {
+            baCatched = true;
+            throw ba;
+        } finally {
+            if ((baCatched || result.isErroneous()) && tree.hasTag(BITAND)) {
+                //error recovery
+                List<JCExpression> bounds = collectIntersectionBounds(tree);
+                if (bounds != null) {
+                    Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
+                    try {
+                        Type owntype = checkIntersection(tree, bounds);
+                        if (!owntype.isErroneous()) {
+                            tree.type = result = owntype;
+                        }
+                    } finally {
+                        log.popDiagnosticHandler(discardHandler);
                     }
                 }
             }
-
-            // Check that argument types of a reference ==, != are
-            // castable to each other, (JLS???).
-            if ((opc == ByteCodes.if_acmpeq || opc == ByteCodes.if_acmpne)) {
-                if (!types.isCastable(left, right, new Warner(tree.pos()))) {
-                    log.error(tree.pos(), "incomparable.types", left, right);
+        }
+    }
+    
+    private List<JCExpression> collectIntersectionBounds(JCTree tree) {
+        if (tree.hasTag(BITAND)) {
+            List<JCExpression> left = collectIntersectionBounds(((JCBinary)tree).lhs);
+            if (left != null) {
+                List<JCExpression> right = collectIntersectionBounds(((JCBinary)tree).rhs);
+                if (right != null) {
+                    return left.appendList(right);
                 }
             }
-
-            chk.checkDivZero(tree.rhs.pos(), operator, right);
+        } else if (tree instanceof JCExpression && tree.type != null) {
+            return List.of((JCExpression)tree);
         }
-        result = check(tree, owntype, VAL, pkind, pt);
+        return null;
     }
 
-    public void visitTypeCast(JCTypeCast tree) {
+    public void visitTypeCast(final JCTypeCast tree) {
         Type clazztype = attribType(tree.clazz, env);
         chk.validate(tree.clazz, env, false);
         //a fresh environment is required for 292 inference to work properly ---
         //see Infer.instantiatePolymorphicSignatureInstance()
         Env<AttrContext> localEnv = env.dup(tree);
-        Type exprtype = attribExpr(tree.expr, localEnv, Infer.anyPoly);
-        Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
+        //should we propagate the target type?
+        final ResultInfo castInfo;
+        JCExpression expr = TreeInfo.skipParens(tree.expr);
+        boolean isPoly = expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE);
+        if (isPoly) {
+            //expression is a poly - we need to propagate target type info
+            castInfo = new ResultInfo(VAL, clazztype, new Check.NestedCheckContext(resultInfo.checkContext) {
+                @Override
+                public boolean compatible(Type found, Type req, Warner warn) {
+                    return types.isCastable(found, req, warn);
+                }
+            });
+        } else {
+            //standalone cast - target-type info is not propagated
+            castInfo = unknownExprInfo;
+        }
+        Type exprtype = attribTree(tree.expr, localEnv, castInfo);
+        Type owntype = isPoly ? clazztype : chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
         if (exprtype.constValue() != null)
             owntype = cfolder.coerce(exprtype, owntype);
-        result = check(tree, capture(owntype), VAL, pkind, pt);
+        result = check(tree, capture(owntype), VAL, resultInfo);
+        if (!isPoly)
+            chk.checkRedundantCast(localEnv, tree);
     }
 
     public void visitTypeTest(JCInstanceOf tree) {
@@ -2207,7 +3269,7 @@ public class Attr extends JCTree.Visitor {
             tree.clazz.pos(), attribType(tree.clazz, env));
         chk.validate(tree.clazz, env, false);
         chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
-        result = check(tree, syms.booleanType, VAL, pkind, pt);
+        result = check(tree, syms.booleanType, VAL, resultInfo);
     }
 
     public void visitIndexed(JCArrayAccess tree) {
@@ -2216,27 +3278,25 @@ public class Attr extends JCTree.Visitor {
         attribExpr(tree.index, env, syms.intType);
         if (types.isArray(atype))
             owntype = types.elemtype(atype);
-        else if (atype.tag != ERROR)
+        else if (!atype.hasTag(ERROR))
             log.error(tree.pos(), "array.req.but.found", atype);
-        if ((pkind & VAR) == 0) owntype = capture(owntype);
-        result = check(tree, owntype, VAR, pkind, pt);
+        if ((pkind() & VAR) == 0) owntype = capture(owntype);
+        result = check(tree, owntype, VAR, resultInfo);
     }
 
     public void visitIdent(JCIdent tree) {
         Symbol sym;
-        boolean varArgs = false;
 
         // Find symbol
-        if (pt.tag == METHOD || pt.tag == FORALL) {
+        if (pt().hasTag(METHOD) || pt().hasTag(FORALL)) {
             // If we are looking for a method, the prototype `pt' will be a
             // method type with the type of the call's arguments as parameters.
-            env.info.varArgs = false;
-            sym = rs.resolveMethod(tree.pos(), env, tree.name, pt.getParameterTypes(), pt.getTypeArguments());
-            varArgs = env.info.varArgs;
+            env.info.pendingResolutionPhase = null;
+            sym = rs.resolveMethod(tree.pos(), env, tree.name, pt().getParameterTypes(), pt().getTypeArguments());
         } else if (tree.sym != null && tree.sym.kind != VAR) {
             sym = tree.sym;
         } else {
-            sym = rs.resolveIdent(tree.pos(), env, tree.name, pkind);
+            sym = rs.resolveIdent(tree.pos(), env, tree.name, pkind());
         }
         tree.sym = sym;
 
@@ -2271,19 +3331,9 @@ public class Attr extends JCTree.Visitor {
             // illegal forward reference.
             checkInit(tree, env, v, false);
 
-            // If symbol is a local variable accessed from an embedded
-            // inner class check that it is final.
-            if (v.owner.kind == MTH &&
-                v.owner != env.info.scope.owner &&
-                (v.flags_field & FINAL) == 0) {
-                log.error(tree.pos(),
-                          "local.var.accessed.from.icls.needs.final",
-                          v);
-            }
-
             // If we are expecting a variable (as opposed to a value), check
             // that the variable is assignable in the current environment.
-            if (pkind == VAR)
+            if (pkind() == VAR)
                 checkAssignable(tree.pos(), v, null, env);
         }
 
@@ -2304,7 +3354,7 @@ public class Attr extends JCTree.Visitor {
             while (env1.outer != null && !rs.isAccessible(env, env1.enclClass.sym.type, sym))
                 env1 = env1.outer;
         }
-        result = checkId(tree, env1.enclClass.sym.type, sym, env, pkind, pt, varArgs);
+        result = checkId(tree, env1.enclClass.sym.type, sym, env, resultInfo);
     }
 
     public void visitSelect(JCFieldAccess tree) {
@@ -2317,22 +3367,22 @@ public class Attr extends JCTree.Visitor {
         } else if (tree.name == names.error) {
             skind = ERR;
         } else {
-            if ((pkind & PCK) != 0) skind = skind | PCK;
-            if ((pkind & TYP) != 0) skind = skind | TYP | PCK;
-            if ((pkind & (VAL | MTH)) != 0) skind = skind | VAL | TYP;
+            if ((pkind() & PCK) != 0) skind = skind | PCK;
+            if ((pkind() & TYP) != 0) skind = skind | TYP | PCK;
+            if ((pkind() & (VAL | MTH)) != 0) skind = skind | VAL | TYP;
         }
 
         // Attribute the qualifier expression, and determine its symbol (if any).
-        Type site = attribTree(tree.selected, env, skind, Infer.anyPoly);
-        if ((pkind & (PCK | TYP)) == 0)
+        Type site = attribTree(tree.selected, env, new ResultInfo(skind, Infer.anyPoly));
+        if ((pkind() & (PCK | TYP)) == 0)
             site = capture(site); // Capture field access
 
         // don't allow T.class T[].class, etc
         if (skind == TYP) {
             Type elt = site;
-            while (elt.tag == ARRAY)
-                elt = ((ArrayType)elt).elemtype;
-            if (elt.tag == TYPEVAR) {
+            while (elt.hasTag(ARRAY))
+                elt = ((ArrayType)elt.unannotatedType()).elemtype;
+            if (elt.hasTag(TYPEVAR)) {
                 log.error(tree.pos(), "type.var.cant.be.deref");
                 result = tree.type = types.createErrorType(tree.type);
                 return;
@@ -2348,27 +3398,18 @@ public class Attr extends JCTree.Visitor {
             sitesym != null &&
             sitesym.name == names._super;
 
-        // If selected expression is polymorphic, strip
-        // type parameters and remember in env.info.tvars, so that
-        // they can be added later (in Attr.checkId and Infer.instantiateMethod).
-        if (tree.selected.type.tag == FORALL) {
-            ForAll pstype = (ForAll)tree.selected.type;
-            env.info.tvars = pstype.tvars;
-            site = tree.selected.type = pstype.qtype;
-        }
-
         // Determine the symbol represented by the selection.
-        env.info.varArgs = false;
-        Symbol sym = selectSym(tree, sitesym, site, env, pt, pkind);
-        if (sym.exists() && !isType(sym) && (pkind & (PCK | TYP)) != 0) {
+        env.info.pendingResolutionPhase = null;
+        Symbol sym = selectSym(tree, sitesym, site, env, resultInfo);
+        if (sym.exists() && !isType(sym) && (pkind() & (PCK | TYP)) != 0) {
             site = capture(site);
-            sym = selectSym(tree, sitesym, site, env, pt, pkind);
+            sym = selectSym(tree, sitesym, site, env, resultInfo);
         }
-        boolean varArgs = env.info.varArgs;
+        boolean varArgs = env.info.lastResolveVarargs();
         tree.sym = sym;
 
-        if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR) {
-            while (site.tag == TYPEVAR) site = site.getUpperBound();
+        if (site.hasTag(TYPEVAR) && !isType(sym) && sym.kind != ERR) {
+            while (site.hasTag(TYPEVAR)) site = site.getUpperBound();
             site = capture(site);
         }
 
@@ -2382,7 +3423,7 @@ public class Attr extends JCTree.Visitor {
 
             // If we are expecting a variable (as opposed to a value), check
             // that the variable is assignable in the current environment.
-            if (pkind == VAR)
+            if (pkind() == VAR)
                 checkAssignable(tree.pos(), v, tree.selected, env);
         }
 
@@ -2398,8 +3439,8 @@ public class Attr extends JCTree.Visitor {
 
         // Disallow selecting a type from an expression
         if (isType(sym) && (sitesym==null || (sitesym.kind&(TYP|PCK)) == 0)) {
-            tree.type = check(tree.selected, pt,
-                              sitesym == null ? VAL : sitesym.kind, TYP|PCK, pt);
+            tree.type = check(tree.selected, pt(),
+                              sitesym == null ? VAL : sitesym.kind, new ResultInfo(TYP|PCK, pt()));
         }
 
         if (isType(sitesym)) {
@@ -2413,9 +3454,10 @@ public class Attr extends JCTree.Visitor {
             } else {
                 // Check if type-qualified fields or methods are static (JLS)
                 if ((sym.flags() & STATIC) == 0 &&
+                    !env.next.tree.hasTag(REFERENCE) &&
                     sym.name != names._super &&
                     (sym.kind == VAR || sym.kind == MTH)) {
-                    rs.access(rs.new StaticError(sym),
+                    rs.accessBase(rs.new StaticError(sym),
                               tree.pos(), site, sym.name, true);
                 }
             }
@@ -2439,8 +3481,7 @@ public class Attr extends JCTree.Visitor {
         }
 
         env.info.selectSuper = selectSuperPrev;
-        result = checkId(tree, site, sym, env, pkind, pt, varArgs);
-        env.info.tvars = List.nil();
+        result = checkId(tree, site, sym, env, resultInfo);
     }
     //where
         /** Determine symbol referenced by a Select expression,
@@ -2448,34 +3489,25 @@ public class Attr extends JCTree.Visitor {
          *  @param tree   The select tree.
          *  @param site   The type of the selected expression,
          *  @param env    The current environment.
-         *  @param pt     The current prototype.
-         *  @param pkind  The expected kind(s) of the Select expression.
+         *  @param resultInfo The current result.
          */
         private Symbol selectSym(JCFieldAccess tree,
-                                     Type site,
-                                     Env<AttrContext> env,
-                                     Type pt,
-                                     int pkind) {
-            return selectSym(tree, site.tsym, site, env, pt, pkind);
-        }
-        private Symbol selectSym(JCFieldAccess tree,
                                  Symbol location,
                                  Type site,
                                  Env<AttrContext> env,
-                                 Type pt,
-                                 int pkind) {
+                                 ResultInfo resultInfo) {
             DiagnosticPosition pos = tree.pos();
             Name name = tree.name;
-            switch (site.tag) {
+            switch (site.getTag()) {
             case PACKAGE:
-                return rs.access(
-                    rs.findIdentInPackage(env, site.tsym, name, pkind),
+                return rs.accessBase(
+                    rs.findIdentInPackage(env, site.tsym, name, resultInfo.pkind),
                     pos, location, site, name, true);
             case ARRAY:
             case CLASS:
-                if (pt.tag == METHOD || pt.tag == FORALL) {
+                if (resultInfo.pt.hasTag(METHOD) || resultInfo.pt.hasTag(FORALL)) {
                     return rs.resolveQualifiedMethod(
-                        pos, env, location, site, name, pt.getParameterTypes(), pt.getTypeArguments());
+                        pos, env, location, site, name, resultInfo.pt.getParameterTypes(), resultInfo.pt.getTypeArguments());
                 } else if (name == names._this || name == names._super) {
                     return rs.resolveSelf(pos, env, site.tsym, name);
                 } else if (name == names._class) {
@@ -2490,9 +3522,9 @@ public class Attr extends JCTree.Visitor {
                         STATIC | PUBLIC | FINAL, names._class, t, site.tsym);
                 } else {
                     // We are seeing a plain identifier as selector.
-                    Symbol sym = rs.findIdentInType(env, site, name, pkind);
-                    if ((pkind & ERRONEOUS) == 0)
-                        sym = rs.access(sym, pos, location, site, name, true);
+                    Symbol sym = rs.findIdentInType(env, site, name, resultInfo.pkind);
+                    if ((resultInfo.pkind & ERRONEOUS) == 0)
+                        sym = rs.accessBase(sym, pos, location, site, name, true);
                     return sym;
                 }
             case WILDCARD:
@@ -2505,7 +3537,7 @@ public class Attr extends JCTree.Visitor {
                 // other words, we are seeing this illegal program:
                 // class B<T> extends A<T.foo> {}
                 Symbol sym = (site.getUpperBound() != null)
-                    ? selectSym(tree, location, capture(site.getUpperBound()), env, pt, pkind)
+                    ? selectSym(tree, location, capture(site.getUpperBound()), env, resultInfo)
                     : null;
                 if (sym == null) {
                     log.error(pos, "type.var.cant.be.deref");
@@ -2514,7 +3546,7 @@ public class Attr extends JCTree.Visitor {
                     Symbol sym2 = (sym.flags() & Flags.PRIVATE) != 0 ?
                         rs.new AccessError(env, site, sym) :
                                 sym;
-                    rs.access(sym2, pos, location, site, name, true);
+                    rs.accessBase(sym2, pos, location, site, name, true);
                     return sym;
                 }
             case ERROR:
@@ -2559,24 +3591,73 @@ public class Attr extends JCTree.Visitor {
          *                    expression, otherwise the type of the current class.
          *  @param sym        The symbol representing the identifier.
          *  @param env        The current environment.
-         *  @param pkind      The set of expected kinds.
-         *  @param pt         The expected type.
+         *  @param resultInfo    The expected result
          */
         Type checkId(JCTree tree,
                      Type site,
                      Symbol sym,
                      Env<AttrContext> env,
-                     int pkind,
+                     ResultInfo resultInfo) {
+            return (resultInfo.pt.hasTag(FORALL) || resultInfo.pt.hasTag(METHOD)) ?
+                    checkMethodId(tree, site, sym, env, resultInfo) :
+                    checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo);
+        }
+
+        Type checkMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            boolean isPolymorhicSignature =
+                (sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) != 0;
+            return isPolymorhicSignature ?
+                    checkSigPolyMethodId(tree, site, sym, env, resultInfo) :
+                    checkMethodIdInternal(tree, site, sym, env, resultInfo);
+        }
+
+        Type checkSigPolyMethodId(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            //recover original symbol for signature polymorphic methods
+            checkMethodIdInternal(tree, site, sym.baseSymbol(), env, resultInfo);
+            env.info.pendingResolutionPhase = Resolve.MethodResolutionPhase.BASIC;
+            return sym.type;
+        }
+
+        Type checkMethodIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            if ((resultInfo.pkind & POLY) != 0) {
+                Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase));
+                Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo);
+                resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase));
+                return owntype;
+            } else {
+                return checkIdInternal(tree, site, sym, resultInfo.pt, env, resultInfo);
+            }
+        }
+
+        Type checkIdInternal(JCTree tree,
+                     Type site,
+                     Symbol sym,
                      Type pt,
-                     boolean useVarargs) {
-            if (pt.isErroneous()) return tree.type = types.createErrorType(site);
+                     Env<AttrContext> env,
+                     ResultInfo resultInfo) {
+            if (pt.isErroneous()) {
+                return tree.type = types.createErrorType(site);
+            }
             Type owntype; // The computed type of this identifier occurrence.
             switch (sym.kind) {
             case TYP:
                 // For types, the computed type equals the symbol's type,
                 // except for two situations:
                 owntype = sym.type;
-                if (owntype.tag == CLASS) {
+                if (owntype.hasTag(CLASS)) {
+                    chk.checkForBadAuxiliaryClassAccess(tree.pos(), env, (ClassSymbol)sym);
                     Type ownOuter = owntype.getEnclosingType();
 
                     // (a) If the symbol's type is parameterized, erase it
@@ -2596,10 +3677,20 @@ public class Attr extends JCTree.Visitor {
                     //
                     // Then the type of the last expression above is
                     // Tree<Point>.Visitor.
-                    else if (ownOuter != null && ownOuter.tag == CLASS && site != ownOuter) {
+                    else if (ownOuter != null && ownOuter.hasTag(CLASS) && site != ownOuter) {
                         Type normOuter = site;
-                        if (normOuter.tag == CLASS)
+                        if (normOuter.hasTag(CLASS)) {
                             normOuter = types.asEnclosingSuper(site, ownOuter.tsym);
+                            if (site.isAnnotated()) {
+                                // Propagate any type annotations.
+                                // TODO: should asEnclosingSuper do this?
+                                // Note that the type annotations in site will be updated
+                                // by annotateType. Therefore, modify site instead
+                                // of creating a new AnnotatedType.
+                                ((AnnotatedType)site).underlyingType = normOuter;
+                                normOuter = site;
+                            }
+                        }
                         if (normOuter == null) // perhaps from an import
                             normOuter = types.erasure(ownOuter);
                         if (normOuter != ownOuter)
@@ -2614,10 +3705,10 @@ public class Attr extends JCTree.Visitor {
                 // which is being assigned to, issue an unchecked warning if
                 // its type changes under erasure.
                 if (allowGenerics &&
-                    pkind == VAR &&
+                    resultInfo.pkind == VAR &&
                     v.owner.kind == TYP &&
                     (v.flags() & STATIC) == 0 &&
-                    (site.tag == CLASS || site.tag == TYPEVAR)) {
+                    (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) {
                     Type s = types.asOuterSuper(site, v.owner);
                     if (s != null &&
                         s.isRaw() &&
@@ -2634,30 +3725,20 @@ public class Attr extends JCTree.Visitor {
                     ? types.memberType(site, sym)
                     : sym.type;
 
-                if (env.info.tvars.nonEmpty()) {
-                    Type owntype1 = new ForAll(env.info.tvars, owntype);
-                    for (List<Type> l = env.info.tvars; l.nonEmpty(); l = l.tail)
-                        if (!owntype.contains(l.head)) {
-                            log.error(tree.pos(), "undetermined.type", owntype1);
-                            owntype1 = types.createErrorType(owntype1);
-                        }
-                    owntype = owntype1;
-                }
-
                 // If the variable is a constant, record constant value in
                 // computed type.
                 if (v.getConstValue() != null && isStaticReference(tree))
                     owntype = owntype.constType(v.getConstValue());
 
-                if (pkind == VAL) {
+                if (resultInfo.pkind == VAL) {
                     owntype = capture(owntype); // capture "names as expressions"
                 }
                 break;
             case MTH: {
-                JCMethodInvocation app = (JCMethodInvocation)env.tree;
-                owntype = checkMethod(site, sym, env, app.args,
-                                      pt.getParameterTypes(), pt.getTypeArguments(),
-                                      env.info.varArgs);
+                owntype = checkMethod(site, sym,
+                        new ResultInfo(resultInfo.pkind, resultInfo.pt.getReturnType(), resultInfo.checkContext),
+                        env, TreeInfo.args(env.tree), resultInfo.pt.getParameterTypes(),
+                        resultInfo.pt.getTypeArguments());
                 break;
             }
             case PCK: case ERR:
@@ -2675,17 +3756,17 @@ public class Attr extends JCTree.Visitor {
             if (sym.name != names.init) {
                 chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
                 chk.checkSunAPI(tree.pos(), sym);
+                chk.checkProfile(tree.pos(), sym);
             }
             
-            Env<AttrContext> enclosing;
-            
+            Env<AttrContext> enclosing;            
             if (owntype.isErroneous() && (sym.kind == MTH || sym.kind == VAR) && ((enclosing = enter.getEnv(sym.enclClass())) == null || enclosing.toplevel != env.toplevel)) {
                 log.error(tree, "type.error", sym);
             }
 
             // Test (3): if symbol is a variable, check that its type and
             // kind are compatible with the prototype and protokind.
-            return check(tree, owntype, sym.kind, pkind, pt);
+            return check(tree, owntype, sym.kind, resultInfo);
         }
 
         /** Check that variable is initialized and evaluate the variable's
@@ -2712,10 +3793,10 @@ public class Attr extends JCTree.Visitor {
             // and are subject to definite assignment checking.
             if ((env.info.enclVar == v || v.pos > tree.pos) &&
                 v.owner.kind == TYP &&
-                canOwnInitializer(env.info.scope.owner) &&
+                canOwnInitializer(owner(env)) &&
                 v.owner == env.info.scope.owner.enclClass() &&
                 ((v.flags() & STATIC) != 0) == Resolve.isStatic(env) &&
-                (env.tree.getTag() != JCTree.ASSIGN ||
+                (!env.tree.hasTag(ASSIGN) ||
                  TreeInfo.skipParens(((JCAssign) env.tree).lhs) != tree)) {
                 String suffix = (env.info.enclVar == v) ?
                                 "self.ref" : "forward.ref";
@@ -2798,20 +3879,20 @@ public class Attr extends JCTree.Visitor {
     Warner noteWarner = new Warner();
 
     /**
-     * Check that method arguments conform to its instantation.
+     * Check that method arguments conform to its instantiation.
      **/
     public Type checkMethod(Type site,
                             Symbol sym,
+                            ResultInfo resultInfo,
                             Env<AttrContext> env,
                             final List<JCExpression> argtrees,
                             List<Type> argtypes,
-                            List<Type> typeargtypes,
-                            boolean useVarargs) {
+                            List<Type> typeargtypes) {
         // Test (5): if symbol is an instance method of a raw type, issue
         // an unchecked warning if its argument types change under erasure.
         if (allowGenerics &&
             (sym.flags() & STATIC) == 0 &&
-            (site.tag == CLASS || site.tag == TYPEVAR)) {
+            (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) {
             Type s = types.asOuterSuper(site, sym.owner);
             if (s != null && s.isRaw() &&
                 !types.isSameTypes(sym.type.getParameterTypes(),
@@ -2822,141 +3903,98 @@ public class Attr extends JCTree.Visitor {
             }
         }
 
+        if (env.info.defaultSuperCallSite != null) {
+            for (Type sup : types.interfaces(env.enclClass.type).prepend(types.supertype((env.enclClass.type)))) {
+                if (!sup.tsym.isSubClass(sym.enclClass(), types) ||
+                        types.isSameType(sup, env.info.defaultSuperCallSite)) continue;
+                List<MethodSymbol> icand_sup =
+                        types.interfaceCandidates(sup, (MethodSymbol)sym);
+                if (icand_sup.nonEmpty() &&
+                        icand_sup.head != sym &&
+                        icand_sup.head.overrides(sym, icand_sup.head.enclClass(), types, true)) {
+                    log.error(env.tree.pos(), "illegal.default.super.call", env.info.defaultSuperCallSite,
+                        diags.fragment("overridden.default", sym, sup));
+                    break;
+                }
+            }
+            env.info.defaultSuperCallSite = null;
+        }
+
+        if (sym.isStatic() && site.isInterface() && env.tree.hasTag(APPLY)) {
+            JCMethodInvocation app = (JCMethodInvocation)env.tree;
+            if (app.meth.hasTag(SELECT) &&
+                    !TreeInfo.isStaticSelector(((JCFieldAccess)app.meth).selected, names)) {
+                log.error(env.tree.pos(), "illegal.static.intf.meth.call", site);
+            }
+        }
+
         // Compute the identifier's instantiated type.
         // For methods, we need to compute the instance type by
         // Resolve.instantiate from the symbol's type as well as
         // any type arguments and value arguments.
         noteWarner.clear();
-        Type owntype = rs.instantiate(env,
-                                      site,
-                                      sym,
-                                      argtypes,
-                                      typeargtypes,
-                                      true,
-                                      useVarargs,
-                                      noteWarner);
-        boolean warned = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED);
-
-        // If this fails, something went wrong; we should not have
-        // found the identifier in the first place.
-        if (owntype == null) {
-            if (!(pt.isErroneous() || site.isErroneous()))
-                log.error(env.tree.pos(),
-                          "internal.error.cant.instantiate",
-                          sym, site,
-                          Type.toString(pt.getParameterTypes()));
-            owntype = types.createErrorType(site);
-        } else {
-            // System.out.println("call   : " + env.tree);
-            // System.out.println("method : " + owntype);
-            // System.out.println("actuals: " + argtypes);
-            List<Type> formals = owntype.getParameterTypes();
-            Type last = useVarargs ? formals.last() : null;
-            if (sym.name==names.init &&
-                sym.owner == syms.enumSym)
-                formals = formals.tail.tail;
-            List<JCExpression> args = argtrees;
-            while (formals.head != last) {
-                JCTree arg = args.head;
-                Warner warn = chk.convertWarner(arg.pos(), arg.type, formals.head);
-                assertConvertible(arg, arg.type, formals.head, warn);
-                warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
-                args = args.tail;
-                formals = formals.tail;
-            }
-            if (useVarargs) {
-                Type varArg = types.elemtype(last);
-                while (args.tail != null) {
-                    JCTree arg = args.head;
-                    Warner warn = chk.convertWarner(arg.pos(), arg.type, varArg);
-                    assertConvertible(arg, arg.type, varArg, warn);
-                    warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
-                    args = args.tail;
-                }
-            } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
-                // non-varargs call to varargs method
-                Type varParam = owntype.getParameterTypes().last();
-                Type lastArg = argtypes.last();
-                if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) &&
-                    !types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
-                    log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
-                                types.elemtype(varParam),
-                                varParam);
-            }
-
-            if (warned && sym.type.tag == FORALL) {
-                chk.warnUnchecked(env.tree.pos(),
-                                  "unchecked.meth.invocation.applied",
-                                  kindName(sym),
-                                  sym.name,
-                                  rs.methodArguments(sym.type.getParameterTypes()),
-                                  rs.methodArguments(argtypes),
-                                  kindName(sym.location()),
-                                  sym.location());
-                owntype = new MethodType(owntype.getParameterTypes(),
-                                         types.erasure(owntype.getReturnType()),
-                                         types.erasure(owntype.getThrownTypes()),
-                                         syms.methodClass);
-            }
-            if (useVarargs) {
-                JCTree tree = env.tree;
-                Type argtype = owntype.getParameterTypes().last();
-                if (owntype.getReturnType().tag != FORALL || warned) {
-                    chk.checkVararg(env.tree.pos(), owntype.getParameterTypes(), sym);
-                }
-                Type elemtype = types.elemtype(argtype);
-                switch (tree.getTag()) {
-                case JCTree.APPLY:
-                    ((JCMethodInvocation) tree).varargsElement = elemtype;
-                    break;
-                case JCTree.NEWCLASS:
-                    ((JCNewClass) tree).varargsElement = elemtype;
-                    break;
-                default:
-                    throw new AssertionError(""+tree);
-                }
-            }
-        }
-        return owntype;
-    }
+        try {
+            Type owntype = rs.checkMethod(
+                    env,
+                    site,
+                    sym,
+                    resultInfo,
+                    argtypes,
+                    typeargtypes,
+                    noteWarner);
 
-    private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
-        if (actual == null || formal == null || types.isConvertible(actual, formal, warn))
-            return;
+            DeferredAttr.DeferredTypeMap checkDeferredMap =
+                deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
 
-        if (formal.isCompound()
-            && types.isSubtype(actual, types.supertype(formal))
-            && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
-            return;
+            argtypes = Type.map(argtypes, checkDeferredMap);
 
-        if (false) {
-            // TODO: make assertConvertible work
-            chk.typeError(tree.pos(), diags.fragment("incompatible.types"), actual, formal);
-            throw new AssertionError("Tree: " + tree
-                                     + " actual:" + actual
-                                     + " formal: " + formal);
+            if (noteWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
+                chk.warnUnchecked(env.tree.pos(),
+                        "unchecked.meth.invocation.applied",
+                        kindName(sym),
+                        sym.name,
+                        rs.methodArguments(sym.type.getParameterTypes()),
+                        rs.methodArguments(Type.map(argtypes, checkDeferredMap)),
+                        kindName(sym.location()),
+                        sym.location());
+               owntype = new MethodType(owntype.getParameterTypes(),
+                       types.erasure(owntype.getReturnType()),
+                       types.erasure(owntype.getThrownTypes()),
+                       syms.methodClass);
+            }
+
+            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, env.info.lastResolveVarargs(),
+                    resultInfo.checkContext.inferenceContext());
+        } catch (Infer.InferenceException ex) {
+            //invalid target type - propagate exception outwards or report error
+            //depending on the current check context
+            resultInfo.checkContext.report(env.tree.pos(), ex.getDiagnostic());
+            return types.createErrorType(sym.type);
+        } catch (Resolve.InapplicableMethodException ex) {
+            Assert.error(ex.getDiagnostic().getMessage(Locale.getDefault()));
+            return null;
         }
     }
 
     public void visitLiteral(JCLiteral tree) {
         result = check(
-            tree, litType(tree.typetag).constType(tree.value), VAL, pkind, pt);
+            tree, litType(tree.typetag).constType(tree.value), VAL, resultInfo);
     }
     //where
     /** Return the type of a literal with given type tag.
      */
-    Type litType(int tag) {
-        return (tag == TypeTags.CLASS) ? syms.stringType : syms.typeOfTag[tag];
+    Type litType(TypeTag tag) {
+        return (tag == CLASS) ? syms.stringType : syms.typeOfTag[tag.ordinal()];
     }
 
     public void visitTypeIdent(JCPrimitiveTypeTree tree) {
-        result = check(tree, syms.typeOfTag[tree.typetag], TYP, pkind, pt);
+        result = check(tree, syms.typeOfTag[tree.typetag.ordinal()], TYP, resultInfo);
     }
 
     public void visitTypeArray(JCArrayTypeTree tree) {
         Type etype = attribType(tree.elemtype, env);
         Type type = new ArrayType(etype, syms.arrayClass);
-        result = check(tree, type, TYP, pkind, pt);
+        result = check(tree, type, TYP, resultInfo);
     }
 
     /** Visitor method for parameterized types.
@@ -2972,7 +4010,7 @@ public class Attr extends JCTree.Visitor {
         // Attribute type parameters
         List<Type> actuals = attribTypes(tree.arguments, env);
 
-        if (clazztype.tag == CLASS) {
+        if (clazztype.hasTag(CLASS)) {
             List<Type> formals = clazztype.tsym.type.getTypeArguments();
             if (actuals.isEmpty()) //diamond
                 actuals = formals;
@@ -2987,16 +4025,16 @@ public class Attr extends JCTree.Visitor {
                 }
                 // Compute the proper generic outer
                 Type clazzOuter = clazztype.getEnclosingType();
-                if (clazzOuter.tag == CLASS) {
+                if (clazzOuter.hasTag(CLASS)) {
                     Type site;
                     JCExpression clazz = TreeInfo.typeIn(tree.clazz);
-                    if (clazz.getTag() == JCTree.IDENT) {
+                    if (clazz.hasTag(IDENT)) {
                         site = env.enclClass.sym.type;
-                    } else if (clazz.getTag() == JCTree.SELECT) {
+                    } else if (clazz.hasTag(SELECT)) {
                         site = ((JCFieldAccess) clazz).selected.type;
                     } else throw new AssertionError(""+tree);
-                    if (clazzOuter.tag == CLASS && site != clazzOuter) {
-                        if (site.tag == CLASS)
+                    if (clazzOuter.hasTag(CLASS) && site != clazzOuter) {
+                        if (site.hasTag(CLASS))
                             site = types.asOuterSuper(site, clazzOuter.tsym);
                         if (site == null)
                             site = types.erasure(clazzOuter);
@@ -3004,6 +4042,12 @@ public class Attr extends JCTree.Visitor {
                     }
                 }
                 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",
@@ -3014,7 +4058,7 @@ public class Attr extends JCTree.Visitor {
                 owntype = types.createErrorType(tree.type);
             }
         }
-        result = check(tree, owntype, TYP, pkind, pt);
+        result = check(tree, owntype, TYP, resultInfo);
     }
 
     public void visitTypeUnion(JCTypeUnion tree) {
@@ -3051,8 +4095,8 @@ public class Attr extends JCTree.Visitor {
                 all_multicatchTypes.append(ctype);
             }
         }
-        Type t = check(tree, types.lub(multicatchTypes.toList()), TYP, pkind, pt);
-        if (t.tag == CLASS) {
+        Type t = check(tree, types.lub(multicatchTypes.toList()), TYP, resultInfo);
+        if (t.hasTag(CLASS)) {
             List<Type> alternatives =
                 ((all_multicatchTypes == null) ? multicatchTypes : all_multicatchTypes).toList();
             t = new UnionClassType((ClassType) t, alternatives);
@@ -3060,63 +4104,86 @@ public class Attr extends JCTree.Visitor {
         tree.type = result = t;
     }
 
+    public void visitTypeIntersection(JCTypeIntersection tree) {
+        attribTypes(tree.bounds, env);
+        tree.type = result = checkIntersection(tree, tree.bounds);
+    }
+
     public void visitTypeParameter(JCTypeParameter tree) {
-        TypeVar a = (TypeVar)tree.type;
+        TypeVar typeVar = (TypeVar) tree.type;
+
+        if (tree.annotations != null && tree.annotations.nonEmpty()) {
+            AnnotatedType antype = new AnnotatedType(typeVar);
+            annotateType(antype, tree.annotations);
+            tree.type = antype;
+        }
+
+        if (!typeVar.bound.isErroneous()) {
+            //fixup type-parameter bound computed in 'attribTypeVariables'
+            typeVar.bound = checkIntersection(tree, tree.bounds);
+        }
+    }
+
+    Type checkIntersection(JCTree tree, List<JCExpression> bounds) {
         Set<Type> boundSet = new HashSet<Type>();
-        if (a.bound.isErroneous())
-            return;
-        List<Type> bs = types.getBounds(a);
-        if (tree.bounds.nonEmpty()) {
+        if (bounds.nonEmpty()) {
             // accept class or interface or typevar as first bound.
-            Type b = checkBase(bs.head, tree.bounds.head, env, false, false, false);
-            boundSet.add(types.erasure(b));
-            if (b.isErroneous()) {
-                a.bound = b;
+            bounds.head.type = checkBase(bounds.head.type, bounds.head, env, false, false, false);
+            boundSet.add(types.erasure(bounds.head.type));
+            if (bounds.head.type.isErroneous()) {
+                return bounds.head.type;
             }
-            else if (b.tag == TYPEVAR) {
+            else if (bounds.head.type.hasTag(TYPEVAR)) {
                 // if first bound was a typevar, do not accept further bounds.
-                if (tree.bounds.tail.nonEmpty()) {
-                    log.error(tree.bounds.tail.head.pos(),
+                if (bounds.tail.nonEmpty()) {
+                    log.error(bounds.tail.head.pos(),
                               "type.var.may.not.be.followed.by.other.bounds");
-                    tree.bounds = List.of(tree.bounds.head);
-                    a.bound = bs.head;
+                    return bounds.head.type;
                 }
             } else {
                 // if first bound was a class or interface, accept only interfaces
                 // as further bounds.
-                for (JCExpression bound : tree.bounds.tail) {
-                    bs = bs.tail;
-                    Type i = checkBase(bs.head, bound, env, false, true, false);
-                    if (i.isErroneous())
-                        a.bound = i;
-                    else if (i.tag == CLASS)
-                        chk.checkNotRepeated(bound.pos(), types.erasure(i), boundSet);
+                for (JCExpression bound : bounds.tail) {
+                    bound.type = checkBase(bound.type, bound, env, false, true, false);
+                    if (bound.type.isErroneous()) {
+                        bounds = List.of(bound);
+                    }
+                    else if (bound.type.hasTag(CLASS)) {
+                        chk.checkNotRepeated(bound.pos(), types.erasure(bound.type), boundSet);
+                    }
                 }
             }
         }
-        bs = types.getBounds(a);
 
-        // in case of multiple bounds ...
-        if (bs.length() > 1) {
+        if (bounds.length() == 0) {
+            return syms.objectType;
+        } else if (bounds.length() == 1) {
+            return bounds.head.type;
+        } else {
+            Type owntype = types.makeCompoundType(TreeInfo.types(bounds));
+            if (tree.hasTag(TYPEINTERSECTION)) {
+                ((IntersectionClassType)owntype).intersectionKind =
+                        IntersectionClassType.IntersectionKind.EXPLICIT;
+            }
             // ... the variable's bound is a class type flagged COMPOUND
             // (see comment for TypeVar.bound).
             // In this case, generate a class tree that represents the
             // bound class, ...
             JCExpression extending;
             List<JCExpression> implementing;
-            if ((bs.head.tsym.flags() & INTERFACE) == 0) {
-                extending = tree.bounds.head;
-                implementing = tree.bounds.tail;
+            if (!bounds.head.type.isInterface()) {
+                extending = bounds.head;
+                implementing = bounds.tail;
             } else {
                 extending = null;
-                implementing = tree.bounds;
+                implementing = bounds;
             }
-            JCClassDecl cd = make.at(tree.pos).ClassDef(
+            JCClassDecl cd = make.at(tree).ClassDef(
                 make.Modifiers(PUBLIC | ABSTRACT),
-                tree.name, List.<JCTypeParameter>nil(),
+                names.empty, List.<JCTypeParameter>nil(),
                 extending, implementing, List.<JCTree>nil());
 
-            ClassSymbol c = (ClassSymbol)a.getUpperBound().tsym;
+            ClassSymbol c = (ClassSymbol)owntype.tsym;
             Assert.check((c.flags() & COMPOUND) != 0);
             cd.sym = c;
             c.sourcefile = env.toplevel.sourcefile;
@@ -3125,10 +4192,11 @@ public class Attr extends JCTree.Visitor {
             c.flags_field |= UNATTRIBUTED;
             Env<AttrContext> cenv = enter.classEnv(cd, env);
             enter.typeEnvs.put(c, cenv);
+            attribClass(c);
+            return owntype;
         }
     }
 
-
     public void visitWildcard(JCWildcard tree) {
         //- System.err.println("visitWildcard("+tree+");");//DEBUG
         Type type = (tree.kind.kind == BoundKind.UNBOUND)
@@ -3137,18 +4205,68 @@ public class Attr extends JCTree.Visitor {
         result = check(tree, new WildcardType(chk.checkRefType(tree.pos(), type),
                                               tree.kind.kind,
                                               syms.boundClass),
-                       TYP, pkind, pt);
+                       TYP, resultInfo);
     }
 
     public void visitAnnotation(JCAnnotation tree) {
-        log.error(tree.pos(), "annotation.not.valid.for.type", pt);
+        log.error(tree.pos(), "annotation.not.valid.for.type", pt());
         result = tree.type = syms.errType;
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        Type underlyingType = attribType(tree.getUnderlyingType(), env);
+        this.attribAnnotationTypes(tree.annotations, env);
+        AnnotatedType antype = new AnnotatedType(underlyingType);
+        annotateType(antype, tree.annotations);
+        result = tree.type = antype;
+    }
+
+    /**
+     * Apply the annotations to the particular type.
+     */
+    public void annotateType(final AnnotatedType type, final List<JCAnnotation> annotations) {
+        if (annotations.isEmpty())
+            return;
+        annotate.typeAnnotation(new Annotate.Annotator() {
+            @Override
+            public String toString() {
+                return "annotate " + annotations + " onto " + type;
+            }
+            @Override
+            public void enterAnnotation() {
+                List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
+                type.typeAnnotations = compounds;
+            }
+        });
+    }
+
+    private static List<Attribute.TypeCompound> fromAnnotations(List<JCAnnotation> annotations) {
+        if (annotations.isEmpty())
+            return List.nil();
+
+        ListBuffer<Attribute.TypeCompound> buf = ListBuffer.lb();
+        for (JCAnnotation anno : annotations) {
+            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();
+    }
+
     public void visitErroneous(JCErroneous tree) {
         if (tree.errs != null)
-            for (JCTree err : tree.errs)
-                attribTree(err, env, ERR - PCK, pt);
+            for (JCTree err : tree.errs) {
+                try {
+                    attribTree(err, env, new ResultInfo(ERR - PCK, pt()));
+                } catch (AssertionError ae) {
+                    //ignore
+                }
+            }
         result = tree.type = syms.errType;
     }
 
@@ -3162,7 +4280,7 @@ public class Attr extends JCTree.Visitor {
      * Attribute an env for either a top level tree or class declaration.
      */
     public void attrib(Env<AttrContext> env) {
-        if (env.tree.getTag() == JCTree.TOPLEVEL)
+        if (env.tree.hasTag(TOPLEVEL))
             attribTopLevel(env);
         else
             attribClass(env.tree.pos(), env.enclClass.sym);
@@ -3208,11 +4326,11 @@ public class Attr extends JCTree.Visitor {
         Type st = types.supertype(c.type);
         if ((c.flags_field & Flags.COMPOUND) == 0) {
             // First, attribute superclass.
-            if (st.tag == CLASS)
+            if (st.hasTag(CLASS))
                 attribClass((ClassSymbol)st.tsym);
 
             // Next attribute owner, if it is a class.
-            if (c.owner.kind == TYP && c.owner.type.tag == CLASS)
+            if (c.owner.kind == TYP && c.owner.type.hasTag(CLASS))
                 attribClass((ClassSymbol)c.owner);
         }
 
@@ -3225,7 +4343,6 @@ public class Attr extends JCTree.Visitor {
             // Get environment current at the point of class definition.
             Env<AttrContext> env = enter.typeEnvs.get(c);
             if (env == null) {
-                Logger.getLogger(Attr.class.getName()).warning("Attr.attribClass has a null env for class: [" + c + "]. TypeEnvs map: [" + enter.typeEnvs + "]."); //NOI18N
                 return;
             }
 
@@ -3235,19 +4352,18 @@ public class Attr extends JCTree.Visitor {
             // lint value is set. Typically, this is the parent env, but might be further if there
             // are any envs created as a result of TypeParameter nodes.
             Env<AttrContext> lintEnv = env;
-            while (lintEnv.info.lint == null) {
-                if (lintEnv.next == null)
-                    Logger.getLogger(Attr.class.getName()).warning("Attr.attribClass has a lintEnv: [" + lintEnv + "] with a null next field."); //NOI18N
+            while (lintEnv.info.lint == null)
                 lintEnv = lintEnv.next;
-            }
 
             // Having found the enclosing lint value, we can initialize the lint value for this class
-            env.info.lint = lintEnv.info.lint.augment(c.attributes_field, c.flags());
+            env.info.lint = lintEnv.info.lint.augment(c);
 
             Lint prevLint = chk.setLint(env.info.lint);
             JavaFileObject prev = log.useSource(c.sourcefile);
+            ResultInfo prevReturnRes = env.info.returnResult;
 
             try {
+                env.info.returnResult = null;
                 // java.lang.Enum may not be subclassed by a non-enum
                 if (st.tsym == syms.enumSym &&
                     ((c.flags_field & (Flags.ENUM|Flags.COMPOUND)) == 0))
@@ -3256,15 +4372,16 @@ public class Attr extends JCTree.Visitor {
                 // Enums may not be extended by source-level classes
                 if (st.tsym != null &&
                     ((st.tsym.flags_field & Flags.ENUM) != 0) &&
-                    ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0) &&
-                    !target.compilerBootstrap(c)) {
+                    ((c.flags_field & (Flags.ENUM | Flags.COMPOUND)) == 0)) {
                     log.error(env.tree.pos(), "enum.types.not.extensible");
                 }
                 attribClassBody(env, c);
 
                 deferredLintHandler.flush(env.tree.pos());
                 chk.checkDeprecatedAnnotation(env.tree.pos(), c);
+                chk.checkClassOverrideEqualsAndHashIfNeeded(env.tree.pos(), c);
             } finally {
+                env.info.returnResult = prevReturnRes;
                 log.useSource(prev);
                 chk.setLint(prevLint);
             }
@@ -3287,7 +4404,7 @@ public class Attr extends JCTree.Visitor {
         chk.validateAnnotations(tree.mods.annotations, c);
 
         // Validate type parameters, supertype and interfaces.
-        attribBounds(tree.typarams);
+        attribStats(tree.typarams, env);
         if (!c.isAnonymous()) {
             //already checked if anonymous
             chk.validate(tree.typarams, env);
@@ -3309,11 +4426,24 @@ public class Attr extends JCTree.Visitor {
             if (tree.typarams.nonEmpty())
                 log.error(tree.typarams.head.pos(),
                           "intf.annotation.cant.have.type.params");
+
+            // If this annotation has a @Repeatable, validate
+            Attribute.Compound repeatable = c.attribute(syms.repeatableType.tsym);
+            if (repeatable != null) {
+                // get diagnostic position for error reporting
+                DiagnosticPosition cbPos = getDiagnosticPosition(tree, repeatable.type);
+                Assert.checkNonNull(cbPos);
+
+                chk.validateRepeatable(c, repeatable, cbPos);
+            }
         } else {
             // Check that all extended classes and interfaces
             // are compatible (i.e. no two define methods with same arguments
             // yet different return types).  (JLS 8.4.6.3)
             chk.checkCompatibleSupertypes(tree.pos(), c.type);
+            if (allowDefaultMethods) {
+                chk.checkDefaultMethodClashes(tree.pos(), c.type);
+            }
         }
 
         // Check that class does not import the same parameterized interface
@@ -3355,7 +4485,7 @@ public class Attr extends JCTree.Visitor {
                 ((c.flags() & STATIC) == 0 || c.name == names.empty) &&
                 (TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) {
                 Symbol sym = null;
-                if (l.head.getTag() == JCTree.VARDEF) sym = ((JCVariableDecl) l.head).sym;
+                if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym;
                 if (sym == null ||
                     sym.kind != VAR ||
                     ((VarSymbol) sym).getConstValue() == null) {
@@ -3377,11 +4507,44 @@ public class Attr extends JCTree.Visitor {
         if (env.info.lint.isEnabled(LintCategory.SERIAL) &&
             isSerializable(c) &&
             (c.flags() & Flags.ENUM) == 0 &&
-            (c.flags() & ABSTRACT) == 0) {
+            checkForSerial(c)) {
             checkSerialVersionUID(tree, c);
         }
+        if (allowTypeAnnos) {
+            // Correctly organize the postions of the type annotations
+            TypeAnnotations.organizeTypeAnnotationsBodies(this.syms, this.names, this.log, tree);
+
+            // Check type annotations applicability rules
+            validateTypeAnnotations(tree);
+        }
     }
         // where
+        boolean checkForSerial(ClassSymbol c) {
+            if ((c.flags() & ABSTRACT) == 0) {
+                return true;
+            } else {
+                return c.members().anyMatch(anyNonAbstractOrDefaultMethod);
+            }
+        }
+
+        public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = new Filter<Symbol>() {
+            @Override
+            public boolean accepts(Symbol s) {
+                return s.kind == Kinds.MTH &&
+                       (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
+            }
+        };
+
+        /** get a diagnostic position for an attribute of Type t, or null if attribute missing */
+        private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
+            for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) {
+                if (types.isSameType(al.head.annotationType.type, t))
+                    return al.head.pos();
+            }
+
+            return null;
+        }
+
         /** check if a class is a subtype of Serializable, if that is available. */
         private boolean isSerializable(ClassSymbol c) {
             try {
@@ -3413,7 +4576,7 @@ public class Attr extends JCTree.Visitor {
                         TreeInfo.diagnosticPositionFor(svuid, tree), "improper.SVUID", c);
 
             // check that it is long
-            else if (svuid.type.tag != TypeTags.LONG)
+            else if (!svuid.type.hasTag(LONG))
                 log.warning(LintCategory.SERIAL,
                         TreeInfo.diagnosticPositionFor(svuid, tree), "long.SVUID", c);
 
@@ -3427,11 +4590,112 @@ public class Attr extends JCTree.Visitor {
         return types.capture(type);
     }
 
+    private void validateTypeAnnotations(JCTree tree) {
+        tree.accept(typeAnnotationsValidator);
+    }
+    //where
+    private final JCTree.Visitor typeAnnotationsValidator = new TreeScanner() {
+
+        private boolean checkAllAnnotations = false;
+
+        public void visitAnnotation(JCAnnotation tree) {
+            if (tree.hasTag(TYPE_ANNOTATION) || checkAllAnnotations) {
+                chk.validateTypeAnnotation(tree, false);
+            }
+            super.visitAnnotation(tree);
+        }
+        public void visitTypeParameter(JCTypeParameter tree) {
+            chk.validateTypeAnnotations(tree.annotations, true);
+            scan(tree.bounds);
+            // Don't call super.
+            // This is needed because above we call validateTypeAnnotation with
+            // false, which would forbid annotations on type parameters.
+            // super.visitTypeParameter(tree);
+        }
+        public void visitMethodDef(JCMethodDecl tree) {
+            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);
+            }
+            super.visitMethodDef(tree);
+        }
+        public void visitVarDef(final JCVariableDecl tree) {
+            if (tree.sym != null && tree.sym.type != null)
+                validateAnnotatedType(tree, tree.sym.type);
+            super.visitVarDef(tree);
+        }
+        public void visitTypeCast(JCTypeCast tree) {
+            if (tree.clazz != null && tree.clazz.type != null)
+                validateAnnotatedType(tree.clazz, tree.clazz.type);
+            super.visitTypeCast(tree);
+        }
+        public void visitTypeTest(JCInstanceOf tree) {
+            if (tree.clazz != null && tree.clazz.type != null)
+                validateAnnotatedType(tree.clazz, tree.clazz.type);
+            super.visitTypeTest(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)
+         * and override visitSelect and visitTypeApply.
+         * However, we only set the annotated type in the top-level type
+         * of the symbol.
+         * Therefore, we need to override each individual location where a type
+         * can occur.
+         */
+        private void validateAnnotatedType(final JCTree errtree, final Type type) {
+            if (type.getEnclosingType() != null &&
+                    type != type.getEnclosingType()) {
+                validateEnclosingAnnotatedType(errtree, type.getEnclosingType());
+            }
+            for (Type targ : type.getTypeArguments()) {
+                validateAnnotatedType(errtree, targ);
+            }
+        }
+        private void validateEnclosingAnnotatedType(final JCTree errtree, final Type type) {
+            validateAnnotatedType(errtree, type);
+            if (type.tsym != null &&
+                    type.tsym.isStatic() &&
+                    type.getAnnotationMirrors().nonEmpty()) {
+                    // Enclosing static classes cannot have type annotations.
+                log.error(errtree.pos(), "cant.annotate.static.class");
+            }
+        }
+    };
+
     public Env<AttrContext> dupLocalEnv(Env<AttrContext> localEnv) {
         return localEnv.dup(localEnv.tree, localEnv.info.dup(localEnv.info.scope.dupUnshared()));
     }
 
-    // <editor-fold desc="post-attribution visitor">
+// <editor-fold desc="post-attribution visitor">
 
     /**
      * Handle missing types/symbols in an AST. This routine is useful when
@@ -3440,8 +4704,8 @@ public class Attr extends JCTree.Visitor {
      * mode (e.g. by an IDE) and the AST contains semantic errors, this routine
      * prevents NPE to be progagated during subsequent compilation steps.
      */
-    public void postAttr(Env<AttrContext> env) {
-        new PostAttrAnalyzer().scan(env.tree);
+    public void postAttr(JCTree tree) {
+        new PostAttrAnalyzer().scan(tree);
     }
 
     class PostAttrAnalyzer extends TreeScanner {
@@ -3537,6 +4801,25 @@ public class Attr extends JCTree.Visitor {
         }
 
         @Override
+        public void visitLambda(JCLambda that) {
+            super.visitLambda(that);
+            if (that.targets == null) {
+                that.targets = List.nil();
+            }
+        }
+
+        @Override
+        public void visitReference(JCMemberReference that) {
+            super.visitReference(that);
+            if (that.sym == null) {
+                that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol);
+            }
+            if (that.targets == null) {
+                that.targets = List.nil();
+            }
+        }
+
+        @Override
         public void visitErroneous(JCErroneous tree) {
             scan(tree.errs);
         }
diff --git a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
index 1589ccb..964770a 100644
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
+++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -56,11 +56,7 @@ public class AttrContext {
 
     /** Are arguments to current function applications boxed into an array for varargs?
      */
-    boolean varArgs = false;
-
-    /** A list of type variables that are all-quantifed in current context.
-     */
-    List<Type> tvars = List.nil();
+    Resolve.MethodResolutionPhase pendingResolutionPhase = null;
 
     /** A record of the lint/SuppressWarnings currently in effect
      */
@@ -71,6 +67,15 @@ public class AttrContext {
      */
     Symbol enclVar = null;
 
+    /** ResultInfo to be used for attributing 'return' statement expressions
+     * (set by Attr.visitMethod and Attr.visitLambda)
+     */
+    Attr.ResultInfo returnResult = null;
+
+    /** Symbol corresponding to the site of a qualified default super call
+     */
+    Type defaultSuperCallSite = null;
+
     /** Duplicate this context, replacing scope field and copying all others.
      */
     AttrContext dup(Scope scope) {
@@ -79,10 +84,11 @@ public class AttrContext {
         info.staticLevel = staticLevel;
         info.isSelfCall = isSelfCall;
         info.selectSuper = selectSuper;
-        info.varArgs = varArgs;
-        info.tvars = tvars;
+        info.pendingResolutionPhase = pendingResolutionPhase;
         info.lint = lint;
         info.enclVar = enclVar;
+        info.returnResult = returnResult;
+        info.defaultSuperCallSite = defaultSuperCallSite;
         return info;
     }
 
@@ -98,7 +104,13 @@ public class AttrContext {
         return scope.getElements();
     }
 
+    boolean lastResolveVarargs() {
+        return pendingResolutionPhase != null &&
+                pendingResolutionPhase.isVarargsRequired();
+    }
+
+    @Override
     public String toString() {
-        return "AttrContext[" + scope.toString() + "]";
+        return scope != null ? "AttrContext[" + scope.toString() + "]" : "AttrContext[]";
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Check.java b/src/share/classes/com/sun/tools/javac/comp/Check.java
index 117872f..b0d53f6 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -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
@@ -26,7 +26,9 @@
 package com.sun.tools.javac.comp;
 
 import java.util.*;
-import java.util.Set;
+
+import javax.tools.JavaFileManager;
+import javax.lang.model.element.ElementKind;
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.jvm.*;
@@ -35,18 +37,24 @@ import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
 
-import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.code.Lint;
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
+import com.sun.tools.javac.comp.Infer.InferenceContext;
+import com.sun.tools.javac.comp.Infer.FreeTypeListener;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
 
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.ANNOTATION;
+import static com.sun.tools.javac.code.Flags.SYNCHRONIZED;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
-import javax.lang.model.element.ElementKind;
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.code.TypeTag.WILDCARD;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Type checking helper class for the attribution phase.
  *
@@ -61,16 +69,19 @@ public class Check {
 
     private final Names names;
     private final Log log;
+    private final Resolve rs;
     private final Symtab syms;
     private final Enter enter;
+    private final DeferredAttr deferredAttr;
     private final Infer infer;
     private final Types types;
     private final JCDiagnostic.Factory diags;
-    private final boolean skipAnnotations;
     private boolean warnOnSyntheticConflicts;
     private boolean suppressAbortOnBadClassFile;
     private boolean enableSunApiLintControl;
     private final TreeInfo treeinfo;
+    private final JavaFileManager fileManager;
+    private final Profile profile;
 
     // The set of lint options currently in effect. It is initialized
     // from the context, and then is set/reset as needed by Attr as it
@@ -92,23 +103,31 @@ public class Check {
         context.put(checkKey, this);
 
         names = Names.instance(context);
+        dfltTargetMeta = new Name[] { names.PACKAGE, names.TYPE,
+            names.FIELD, names.METHOD, names.CONSTRUCTOR,
+            names.ANNOTATION_TYPE, names.LOCAL_VARIABLE, names.PARAMETER};
         log = Log.instance(context);
+        rs = Resolve.instance(context);
         syms = Symtab.instance(context);
         enter = Enter.instance(context);
+        deferredAttr = DeferredAttr.instance(context);
         infer = Infer.instance(context);
-        this.types = Types.instance(context);
+        types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         Options options = Options.instance(context);
         lint = Lint.instance(context);
         treeinfo = TreeInfo.instance(context);
+        fileManager = context.get(JavaFileManager.class);
 
         Source source = Source.instance(context);
         allowGenerics = source.allowGenerics();
+        allowVarargs = source.allowVarargs();
         allowAnnotations = source.allowAnnotations();
         allowCovariantReturns = source.allowCovariantReturns();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
-        complexInference = options.isSet(COMPLEXINFERENCE);
-        skipAnnotations = options.isSet("skipAnnotations");
+        allowDefaultMethods = source.allowDefaultMethods();
+        allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
+        complexInference = options.isSet("complexinference");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
         enableSunApiLintControl = options.isSet("enableSunApiLintControl");
@@ -116,6 +135,8 @@ public class Check {
         Target target = Target.instance(context);
         syntheticNameChar = target.syntheticNameChar();
 
+        profile = Profile.instance(context);
+
         boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
         boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
         boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI);
@@ -135,6 +156,10 @@ public class Check {
      */
     boolean allowGenerics;
 
+    /** Switch: varargs enabled?
+     */
+    boolean allowVarargs;
+
     /** Switch: annotations enabled?
      */
     boolean allowAnnotations;
@@ -147,6 +172,14 @@ public class Check {
      */
     boolean allowSimplifiedVarargs;
 
+    /** Switch: default methods enabled?
+     */
+    boolean allowDefaultMethods;
+
+    /** Switch: should unrelated return types trigger a method clash?
+     */
+    boolean allowStrictMethodClashCheck;
+
     /** Switch: -complexinference option set?
      */
     boolean complexInference;
@@ -186,6 +219,14 @@ public class Check {
         return prev;
     }
 
+    /*  This idiom should be used only in cases when it is needed to set the lint
+     *  of an environment that has been created in a phase previous to annotations
+     *  processing.
+     */
+    Lint getLint() {
+        return lint;
+    }
+
     DeferredLintHandler setDeferredLintHandler(DeferredLintHandler newDeferredLintHandler) {
         DeferredLintHandler prev = deferredLintHandler;
         deferredLintHandler = newDeferredLintHandler;
@@ -218,7 +259,6 @@ public class Check {
 
     /** Warn about unsafe vararg method decl.
      *  @param pos        Position to be used for error reporting.
-     *  @param sym        The deprecated symbol.
      */
     void warnUnsafeVararg(DiagnosticPosition pos, String key, Object... args) {
         if (lint.isEnabled(LintCategory.VARARGS) && allowSimplifiedVarargs)
@@ -254,29 +294,12 @@ public class Check {
      *  @param ex         The failure to report.
      */
     public Type completionError(DiagnosticPosition pos, CompletionFailure ex) {
-        log.error(pos, "cant.access", ex.sym, ex.getDetailValue());
+        log.error(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE, pos, "cant.access", ex.sym, ex.getDetailValue());
         if (ex instanceof ClassReader.BadClassFile
                 && !suppressAbortOnBadClassFile) throw new Abort();
         else return syms.errType;
     }
 
-    /** Report a type error.
-     *  @param pos        Position to be used for error reporting.
-     *  @param problem    A string describing the error.
-     *  @param found      The type that was found.
-     *  @param req        The type that was required.
-     */
-    Type typeError(DiagnosticPosition pos, Object problem, Type found, Type req) {
-        log.error(pos, "prob.found.req",
-                  problem, found, req);
-        return types.createErrorType(found);
-    }
-
-    Type typeError(DiagnosticPosition pos, String problem, Type found, Type req, Object explanation) {
-        log.error(pos, "prob.found.req.1", problem, found, req, explanation);
-        return types.createErrorType(found);
-    }
-
     /** Report an error that wrong type tag was found.
      *  @param pos        Position to be used for error reporting.
      *  @param required   An internationalized string describing the type tag
@@ -286,7 +309,7 @@ public class Check {
     Type typeTagError(DiagnosticPosition pos, Object required, Object found) {
         // this error used to be raised by the parser,
         // but has been delayed to this point:
-        if (found instanceof Type && ((Type)found).tag == VOID) {
+        if (found instanceof Type && ((Type)found).hasTag(VOID)) {
             log.error(pos, "illegal.start.of.type");
             return syms.errType;
         }
@@ -364,7 +387,7 @@ public class Check {
             for (Scope.Entry e = s.next.lookup(c.name);
                  e.scope != null && e.sym.owner == c.owner;
                  e = e.next()) {
-                if (e.sym.kind == TYP && e.sym.type.tag != TYPEVAR &&
+                if (e.sym.kind == TYP && !e.sym.type.hasTag(TYPEVAR) &&
                     (e.sym.owner.kind & (VAR | MTH)) != 0 &&
                     c.name != names.error) {
                     duplicateError(pos, e.sym);
@@ -403,7 +426,7 @@ public class Check {
  **************************************************************************/
 
     /** Return name of local class.
-     *  This is of the form    <enclClass> $ n <classname>
+     *  This is of the form   {@code <enclClass> $ n <classname> }
      *  where
      *    enclClass is the flat name of the enclosing class,
      *    classname is the simple name of the local class
@@ -431,6 +454,88 @@ public class Check {
  * Type Checking
  **************************************************************************/
 
+    /**
+     * A check context is an object that can be used to perform compatibility
+     * checks - depending on the check context, meaning of 'compatibility' might
+     * vary significantly.
+     */
+    public interface CheckContext {
+        /**
+         * Is type 'found' compatible with type 'req' in given context
+         */
+        boolean compatible(Type found, Type req, Warner warn);
+        /**
+         * Report a check error
+         */
+        void report(DiagnosticPosition pos, JCDiagnostic details);
+        /**
+         * Obtain a warner for this check context
+         */
+        public Warner checkWarner(DiagnosticPosition pos, Type found, Type req);
+
+        public Infer.InferenceContext inferenceContext();
+
+        public DeferredAttr.DeferredAttrContext deferredAttrContext();
+    }
+
+    /**
+     * This class represent a check context that is nested within another check
+     * context - useful to check sub-expressions. The default behavior simply
+     * redirects all method calls to the enclosing check context leveraging
+     * the forwarding pattern.
+     */
+    static class NestedCheckContext implements CheckContext {
+        CheckContext enclosingContext;
+
+        NestedCheckContext(CheckContext enclosingContext) {
+            this.enclosingContext = enclosingContext;
+        }
+
+        public boolean compatible(Type found, Type req, Warner warn) {
+            return enclosingContext.compatible(found, req, warn);
+        }
+
+        public void report(DiagnosticPosition pos, JCDiagnostic details) {
+            enclosingContext.report(pos, details);
+        }
+
+        public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
+            return enclosingContext.checkWarner(pos, found, req);
+        }
+
+        public Infer.InferenceContext inferenceContext() {
+            return enclosingContext.inferenceContext();
+        }
+
+        public DeferredAttrContext deferredAttrContext() {
+            return enclosingContext.deferredAttrContext();
+        }
+    }
+
+    /**
+     * Check context to be used when evaluating assignment/return statements
+     */
+    CheckContext basicHandler = new CheckContext() {
+        public void report(DiagnosticPosition pos, JCDiagnostic details) {
+            log.error(pos, "prob.found.req", details);
+        }
+        public boolean compatible(Type found, Type req, Warner warn) {
+            return types.isAssignable(found, req, warn);
+        }
+
+        public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
+            return convertWarner(pos, found, req);
+        }
+
+        public InferenceContext inferenceContext() {
+            return infer.emptyContext;
+        }
+
+        public DeferredAttrContext deferredAttrContext() {
+            return deferredAttr.emptyDeferredAttrContext;
+        }
+    };
+
     /** Check that a given type is assignable to a given proto-type.
      *  If it is, return the type, otherwise return errType.
      *  @param pos        Position to be used for error reporting.
@@ -438,64 +543,32 @@ public class Check {
      *  @param req        The type that was required.
      */
     public Type checkType(DiagnosticPosition pos, Type found, Type req) {
-        return checkType(pos, found, req, "incompatible.types");
+        return checkType(pos, found, req, basicHandler);
     }
 
-    Type checkType(DiagnosticPosition pos, Type found, Type req, String errKey) {
-        if (req.tag == ERROR)
+    Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) {
+        final Infer.InferenceContext inferenceContext = checkContext.inferenceContext();
+        if (inferenceContext.free(req)) {
+            inferenceContext.addFreeTypeListener(List.of(req), new FreeTypeListener() {
+                @Override
+                public void typesInferred(InferenceContext inferenceContext) {
+                    checkType(pos, found, inferenceContext.asInstType(req), checkContext);
+                }
+            });
+        }
+        if (req.hasTag(ERROR))
             return req;
-        if (found.tag == FORALL)
-            return instantiatePoly(pos, (ForAll)found, req, convertWarner(pos, found, req));
-        if (req.tag == NONE)
+        if (req.hasTag(NONE))
             return found;
-        if (types.isAssignable(found, req, convertWarner(pos, found, req)))
+        if (found == null || checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
             return found;
-        if (found.tag <= DOUBLE && req.tag <= DOUBLE)
-            return typeError(pos, diags.fragment("possible.loss.of.precision"), found, req);
-        if (found.isSuperBound()) {
-            log.error(pos, "assignment.from.super-bound", found);
-            return types.createErrorType(found);
-        }
-        if (req.isExtendsBound()) {
-            log.error(pos, "assignment.to.extends-bound", req);
-            return types.createErrorType(found);
-        }
-        return typeError(pos, diags.fragment(errKey), found, req);
-    }
-
-    /** Instantiate polymorphic type to some prototype, unless
-     *  prototype is `anyPoly' in which case polymorphic type
-     *  is returned unchanged.
-     */
-    Type instantiatePoly(DiagnosticPosition pos, ForAll t, Type pt, Warner warn) throws Infer.NoInstanceException {
-        if (pt == Infer.anyPoly && complexInference) {
-            return t;
-        } else if (pt == Infer.anyPoly || pt.tag == NONE) {
-            Type newpt = t.qtype.tag <= VOID ? t.qtype : syms.objectType;
-            return instantiatePoly(pos, t, newpt, warn);
-        } else if (pt.tag == ERROR) {
-            return pt;
         } else {
-            try {
-                return infer.instantiateExpr(t, pt, warn);
-            } catch (Infer.NoInstanceException ex) {
-                if (ex.isAmbiguous) {
-                    JCDiagnostic d = ex.getDiagnostic();
-                    log.error(pos,
-                              "undetermined.type" + (d!=null ? ".1" : ""),
-                              t, d);
-                    return types.createErrorType(pt);
-                } else {
-                    JCDiagnostic d = ex.getDiagnostic();
-                    return typeError(pos,
-                                     diags.fragment("incompatible.types" + (d!=null ? ".1" : ""), d),
-                                     t, pt);
-                }
-            } catch (Infer.InvalidInstanceException ex) {
-                JCDiagnostic d = ex.getDiagnostic();
-                log.error(pos, "invalid.inferred.types", t.tvars, d);
-                return types.createErrorType(pt);
+            if (found.isNumeric() && req.isNumeric()) {
+                checkContext.report(pos, diags.fragment("possible.loss.of.precision", found, req));
+                return types.createErrorType(found);
             }
+            checkContext.report(pos, diags.fragment("inconvertible.types", found, req));
+            return types.createErrorType(found);
         }
     }
 
@@ -506,41 +579,61 @@ public class Check {
      *  @param req        The target type of the cast.
      */
     Type checkCastable(DiagnosticPosition pos, Type found, Type req) {
-        if (found.tag == FORALL) {
-            instantiatePoly(pos, (ForAll) found, req, castWarner(pos, found, req));
-            return req;
-        } else if (types.isCastable(found, req, castWarner(pos, found, req))) {
+        return checkCastable(pos, found, req, basicHandler);
+    }
+    Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
+        if (types.isCastable(found, req, castWarner(pos, found, req))) {
             return req;
         } else {
-            return typeError(pos,
-                             diags.fragment("inconvertible.types"),
-                             found, req);
+            checkContext.report(pos, diags.fragment("inconvertible.types", found, req));
+            return types.createErrorType(found);
         }
     }
-//where
-        /** Is type a type variable, or a (possibly multi-dimensional) array of
-         *  type variables?
-         */
-        boolean isTypeVar(Type t) {
-            return t.tag == TYPEVAR || t.tag == ARRAY && isTypeVar(types.elemtype(t));
+
+    /** Check for redundant casts (i.e. where source type is a subtype of target type)
+     * The problem should only be reported for non-292 cast
+     */
+    public void checkRedundantCast(Env<AttrContext> env, JCTypeCast tree) {
+        if (!tree.type.isErroneous() &&
+                (env.info.lint == null || env.info.lint.isEnabled(Lint.LintCategory.CAST))
+                && types.isSameType(tree.expr.type, tree.clazz.type)
+                && !(ignoreAnnotatedCasts && TreeInfo.containsTypeAnnotation(tree.clazz))
+                && !is292targetTypeCast(tree)) {
+            log.warning(Lint.LintCategory.CAST,
+                    tree.pos(), "redundant.cast", tree.expr.type);
         }
+    }
+    //where
+        private boolean is292targetTypeCast(JCTypeCast tree) {
+            boolean is292targetTypeCast = false;
+            JCExpression expr = TreeInfo.skipParens(tree.expr);
+            if (expr.hasTag(APPLY)) {
+                JCMethodInvocation apply = (JCMethodInvocation)expr;
+                Symbol sym = TreeInfo.symbol(apply.meth);
+                is292targetTypeCast = sym != null &&
+                    sym.kind == MTH &&
+                    (sym.flags() & HYPOTHETICAL) != 0;
+            }
+            return is292targetTypeCast;
+        }
+
+        private static final boolean ignoreAnnotatedCasts = true;
 
     /** Check that a type is within some bounds.
      *
-     *  Used in TypeApply to verify that, e.g., X in V<X> is a valid
+     *  Used in TypeApply to verify that, e.g., X in {@code V<X>} is a valid
      *  type argument.
-     *  @param pos           Position to be used for error reporting.
      *  @param a             The type that should be bounded by bs.
-     *  @param bs            The bound.
+     *  @param bound         The bound.
      */
     private boolean checkExtends(Type a, Type bound) {
          if (a.isUnbound()) {
              return true;
-         } else if (a.tag != WILDCARD) {
+         } else if (!a.hasTag(WILDCARD)) {
              a = types.upperBound(a);
              return types.isSubtype(a, bound);
          } else if (a.isExtendsBound()) {
-             return types.isCastable(bound, types.upperBound(a), Warner.noWarnings);
+             return types.isCastable(bound, types.upperBound(a), types.noWarnings);
          } else if (a.isSuperBound()) {
              return !types.notSoftSubtype(types.lowerBound(a), bound);
          }
@@ -552,7 +645,7 @@ public class Check {
      *  @param t             The type to be checked.
      */
     Type checkNonVoid(DiagnosticPosition pos, Type t) {
-        if (t.tag == VOID) {
+        if (t.hasTag(VOID)) {
             log.error(pos, "void.not.allowed.here");
             return types.createErrorType(t);
         } else {
@@ -560,19 +653,57 @@ public class Check {
         }
     }
 
+    Type checkClassOrArrayType(DiagnosticPosition pos, Type t) {
+        if (!t.hasTag(CLASS) && !t.hasTag(ARRAY) && !t.hasTag(ERROR)) {
+            return typeTagError(pos,
+                                diags.fragment("type.req.class.array"),
+                                asTypeParam(t));
+        } else {
+            return t;
+        }
+    }
+
     /** Check that type is a class or interface type.
      *  @param pos           Position to be used for error reporting.
      *  @param t             The type to be checked.
      */
     Type checkClassType(DiagnosticPosition pos, Type t) {
-        if (t.tag != CLASS && t.tag != ERROR)
+        if (!t.hasTag(CLASS) && !t.hasTag(ERROR)) {
             return typeTagError(pos,
                                 diags.fragment("type.req.class"),
-                                (t.tag == TYPEVAR)
-                                ? diags.fragment("type.parameter", t)
-                                : t);
-        else
+                                asTypeParam(t));
+        } else {
             return t;
+        }
+    }
+    //where
+        private Object asTypeParam(Type t) {
+            return (t.hasTag(TYPEVAR))
+                                    ? diags.fragment("type.parameter", t)
+                                    : t;
+        }
+
+    /** Check that type is a valid qualifier for a constructor reference expression
+     */
+    Type checkConstructorRefType(DiagnosticPosition pos, Type t) {
+        t = checkClassOrArrayType(pos, t);
+        if (t.hasTag(CLASS)) {
+            if ((t.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
+                log.error(pos, "abstract.cant.be.instantiated", t.tsym);
+                t = types.createErrorType(t);
+            } else if ((t.tsym.flags() & ENUM) != 0) {
+                log.error(pos, "enum.cant.be.instantiated");
+                t = types.createErrorType(t);
+            } else {
+                t = checkClassType(pos, t, true);
+            }
+        } else if (t.hasTag(ARRAY)) {
+            if (!types.isReifiable(((ArrayType)t).elemtype)) {
+                log.error(pos, "generic.array.creation");
+                t = types.createErrorType(t);
+            }
+        }
+        return t;
     }
 
     /** Check that type is a class or interface type.
@@ -585,7 +716,7 @@ public class Check {
         if (noBounds && t.isParameterized()) {
             List<Type> args = t.getTypeArguments();
             while (args.nonEmpty()) {
-                if (args.head.tag == WILDCARD)
+                if (args.head.hasTag(WILDCARD))
                     return typeTagError(pos,
                                         diags.fragment("type.req.exact"),
                                         args.head);
@@ -600,11 +731,8 @@ public class Check {
      *  @param t             The type to be checked.
      */
     Type checkReifiableReferenceType(DiagnosticPosition pos, Type t) {
-        if (t.tag != CLASS && t.tag != ARRAY && t.tag != ERROR) {
-            return typeTagError(pos,
-                                diags.fragment("type.req.class.array"),
-                                t);
-        } else if (!types.isReifiable(t)) {
+        t = checkClassOrArrayType(pos, t);
+        if (!t.isErroneous() && !types.isReifiable(t)) {
             log.error(pos, "illegal.generic.type.for.instof");
             return types.createErrorType(t);
         } else {
@@ -618,18 +746,12 @@ public class Check {
      *  @param t             The type to be checked.
      */
     Type checkRefType(DiagnosticPosition pos, Type t) {
-        switch (t.tag) {
-        case CLASS:
-        case ARRAY:
-        case TYPEVAR:
-        case WILDCARD:
-        case ERROR:
+        if (t.isReference())
             return t;
-        default:
+        else
             return typeTagError(pos,
                                 diags.fragment("type.req.ref"),
                                 t);
-        }
     }
 
     /** Check that each type is a reference type, i.e. a class, interface or array type
@@ -651,19 +773,12 @@ public class Check {
      *  @param t             The type to be checked.
      */
     Type checkNullOrRefType(DiagnosticPosition pos, Type t) {
-        switch (t.tag) {
-        case CLASS:
-        case ARRAY:
-        case TYPEVAR:
-        case WILDCARD:
-        case BOT:
-        case ERROR:
+        if (t.isReference() || t.hasTag(BOT))
             return t;
-        default:
+        else
             return typeTagError(pos,
                                 diags.fragment("type.req.ref"),
                                 t);
-        }
     }
 
     /** Check that flag set does not contain elements of two conflicting sets. s
@@ -751,22 +866,89 @@ public class Check {
                     (s.flags() & (STATIC | FINAL)) != 0);
         }
 
-    /**
-     * Check that vararg method call is sound
-     * @param pos Position to be used for error reporting.
-     * @param argtypes Actual arguments supplied to vararg method.
-     */
-    void checkVararg(DiagnosticPosition pos, List<Type> argtypes, Symbol msym) {
-        Type argtype = argtypes.last();
-        if (!types.isReifiable(argtype) &&
-                (!allowSimplifiedVarargs ||
-                msym.attribute(syms.trustMeType.tsym) == null ||
-                !isTrustMeAllowedOnMethod(msym))) {
-            warnUnchecked(pos,
-                              "unchecked.generic.array.creation",
-                              argtype);
-        }
+    Type checkMethod(final Type mtype,
+            final Symbol sym,
+            final Env<AttrContext> env,
+            final List<JCExpression> argtrees,
+            final List<Type> argtypes,
+            final boolean useVarargs,
+            InferenceContext inferenceContext) {
+        // System.out.println("call   : " + env.tree);
+        // System.out.println("method : " + owntype);
+        // System.out.println("actuals: " + argtypes);
+        if (inferenceContext.free(mtype)) {
+            inferenceContext.addFreeTypeListener(List.of(mtype), new FreeTypeListener() {
+                public void typesInferred(InferenceContext inferenceContext) {
+                    checkMethod(inferenceContext.asInstType(mtype), sym, env, argtrees, argtypes, useVarargs, inferenceContext);
+                }
+            });
+            return mtype;
+        }
+        Type owntype = mtype;
+        List<Type> formals = owntype.getParameterTypes();
+        Type last = useVarargs ? formals.last() : null;
+        if (sym.name == names.init &&
+                sym.owner == syms.enumSym)
+                formals = formals.tail.tail;
+        List<JCExpression> args = argtrees;
+        if (args != null) {
+            //this is null when type-checking a method reference
+            while (formals.head != last) {
+                JCTree arg = args.head;
+                Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
+                assertConvertible(arg, arg.type, formals.head, warn);
+                args = args.tail;
+                formals = formals.tail;
+            }
+            if (useVarargs) {
+                Type varArg = types.elemtype(last);
+                while (args.tail != null) {
+                    JCTree arg = args.head;
+                    Warner warn = convertWarner(arg.pos(), arg.type, varArg);
+                    assertConvertible(arg, arg.type, varArg, warn);
+                    args = args.tail;
+                }
+            } else if ((sym.flags() & (VARARGS | SIGNATURE_POLYMORPHIC)) == VARARGS &&
+                    allowVarargs) {
+                // non-varargs call to varargs method
+                Type varParam = owntype.getParameterTypes().last();
+                Type lastArg = argtypes.last();
+                if (types.isSubtypeUnchecked(lastArg, types.elemtype(varParam)) &&
+                        !types.isSameType(types.erasure(varParam), types.erasure(lastArg)))
+                    log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
+                            types.elemtype(varParam), varParam);
+            }
+        }
+        if (useVarargs) {
+            Type argtype = owntype.getParameterTypes().last();
+            if (!types.isReifiable(argtype) &&
+                    (!allowSimplifiedVarargs ||
+                    sym.attribute(syms.trustMeType.tsym) == null ||
+                    !isTrustMeAllowedOnMethod(sym))) {
+                warnUnchecked(env.tree.pos(),
+                                  "unchecked.generic.array.creation",
+                                  argtype);
+            }
+            if ((sym.baseSymbol().flags() & SIGNATURE_POLYMORPHIC) == 0) {
+                TreeInfo.setVarargsElement(env.tree, types.elemtype(argtype));
+            }
+         }
+         PolyKind pkind = (sym.type.hasTag(FORALL) &&
+                 sym.type.getReturnType().containsAny(((ForAll)sym.type).tvars)) ?
+                 PolyKind.POLY : PolyKind.STANDALONE;
+         TreeInfo.setPolyKind(env.tree, pkind);
+         return owntype;
     }
+    //where
+        private void assertConvertible(JCTree tree, Type actual, Type formal, Warner warn) {
+            if (types.isConvertible(actual, formal, warn))
+                return;
+
+            if (formal.isCompound()
+                && types.isSubtype(actual, types.supertype(formal))
+                && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
+                return;
+        }
 
     /**
      * Check that type 't' is a valid instantiation of a generic class
@@ -827,7 +1009,7 @@ public class Check {
             bounds = bounds_buf.toList();
 
             for (Type arg : types.capture(type).getTypeArguments()) {
-                if (arg.tag == TYPEVAR &&
+                if (arg.hasTag(TYPEVAR) &&
                         arg.getUpperBound().isErroneous() &&
                         !bounds.head.isErroneous() &&
                         !isTypeArgErroneous(args.head)) {
@@ -864,7 +1046,7 @@ public class Check {
         };
 
     /** Check that given modifiers are legal for given symbol and
-     *  return modifiers together with any implicit modififiers for that symbol.
+     *  return modifiers together with any implicit modifiers for that symbol.
      *  Warning: we can't use flags() here since this method
      *  is called during class enter, when flags() would cause a premature
      *  completion.
@@ -894,14 +1076,24 @@ public class Check {
                     mask = PRIVATE;
                 } else
                     mask = ConstructorFlags;
-            }  else if ((sym.owner.flags_field & INTERFACE) != 0)
-                mask = implicit = InterfaceMethodFlags;
+            }  else if ((sym.owner.flags_field & INTERFACE) != 0) {
+                if ((flags & (DEFAULT | STATIC)) != 0) {
+                    mask = InterfaceMethodMask;
+                    implicit = PUBLIC;
+                    if ((flags & DEFAULT) != 0) {
+                        implicit |= ABSTRACT;
+                    }
+                } else {
+                    mask = implicit = InterfaceMethodFlags;
+                }
+            }
             else {
                 mask = MethodFlags;
             }
             // Imply STRICTFP if owner has STRICTFP set.
-            if (((flags|implicit) & Flags.ABSTRACT) == 0)
-              implicit |= sym.owner.flags_field & STRICTFP;
+            if (((flags|implicit) & Flags.ABSTRACT) == 0 ||
+                ((flags) & Flags.DEFAULT) != 0)
+                implicit |= sym.owner.flags_field & STRICTFP;
             break;
         case TYP:
         case ERR:
@@ -943,7 +1135,7 @@ public class Check {
         default:
             throw new AssertionError();
         }
-        long illegal = flags & StandardFlags & ~mask;
+        long illegal = flags & ExtendedStandardFlags & ~mask;
         if (illegal != 0) {
             if ((illegal & INTERFACE) != 0) {
                 log.error(pos, "intf.not.allowed.here");
@@ -959,42 +1151,48 @@ public class Check {
                   // in the presence of inner classes. Should it be deleted here?
                   checkDisjoint(pos, flags,
                                 ABSTRACT,
-                                PRIVATE | STATIC))) {
+                                PRIVATE | STATIC | DEFAULT))) {
             if (checkDisjoint(pos, flags,
-                                ABSTRACT | INTERFACE,
-                                FINAL | NATIVE | SYNCHRONIZED)) {
+                               STATIC,
+                               DEFAULT)) {
                 if (checkDisjoint(pos, flags,
-                                    PUBLIC,
-                                    PRIVATE | PROTECTED)) {
+                                    ABSTRACT | INTERFACE,
+                                    FINAL | NATIVE | SYNCHRONIZED)) {
                     if (checkDisjoint(pos, flags,
-                                        PRIVATE,
-                                        PUBLIC | PROTECTED)) {
+                                        PUBLIC,
+                                        PRIVATE | PROTECTED)) {
                         if (checkDisjoint(pos, flags,
-                                            FINAL,
-                                            VOLATILE)) {
-                            if ((sym.kind == TYP ||
-                                    checkDisjoint(pos, flags,
-                                                ABSTRACT | NATIVE,
-                                                STRICTFP))) {
+                                            PRIVATE,
+                                            PUBLIC | PROTECTED)) {
+                            if (checkDisjoint(pos, flags,
+                                                FINAL,
+                                                VOLATILE)) {
+                                if ((sym.kind == TYP ||
+                                        checkDisjoint(pos, flags,
+                                                    ABSTRACT | NATIVE,
+                                                    STRICTFP))) {
+                                } else {
+                                    flags &= ~STRICTFP;
+                                }
                             } else {
-                                flags &= ~STRICTFP;
+                                flags &= ~VOLATILE;
                             }
                         } else {
-                            flags &= ~(VOLATILE);
+                            flags &= ~(PUBLIC | PROTECTED);
                         }
                     } else {
-                        flags &= ~(PUBLIC | PROTECTED);
+                        flags &= ~(PRIVATE | PROTECTED);
                     }
                 } else {
-                    flags &= ~(PRIVATE | PROTECTED);
+                    flags &= ~(FINAL | NATIVE | SYNCHRONIZED);
                 }
             } else {
-                flags &= ~(FINAL | NATIVE | SYNCHRONIZED);
-            }                
+                flags &= ~DEFAULT;
+            }
         } else {
-            flags &= ~(PRIVATE | STATIC);
+            flags &= ~(PRIVATE | STATIC | DEFAULT);
         }
-        return flags & (mask | ~StandardFlags) | implicit;
+        return flags & (mask | ~ExtendedStandardFlags) | implicit;
     }
 
 
@@ -1006,7 +1204,7 @@ public class Check {
      *  <i>not</i> final.
      */
     private long implicitEnumFinalFlag(JCTree tree) {
-        if (tree.getTag() != JCTree.CLASSDEF) return 0;
+        if (!tree.hasTag(CLASSDEF)) return 0;
         class SpecialTreeVisitor extends JCTree.Visitor {
             boolean specialized;
             SpecialTreeVisitor() {
@@ -1042,11 +1240,13 @@ public class Check {
 
     /** 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
      *  class B<A extends C> { ... }
      *  class C extends B<C> { ... }
+     *  }</pre>
      *
      *  and we can't make sure that the bound is already attributed because
      *  of possible cycles.
@@ -1086,7 +1286,7 @@ public class Check {
 
         @Override
         public void visitTypeApply(JCTypeApply tree) {
-            if (tree.type != null && tree.type.tag == CLASS) {
+            if (tree.type != null && tree.type.hasTag(CLASS)) {
                 List<JCExpression> args = tree.arguments;
                 List<Type> forms = tree.type.tsym.type.getTypeArguments();
 
@@ -1118,7 +1318,7 @@ public class Check {
                 // not parameterized at all.
                 if (tree.type.getEnclosingType().isRaw())
                     log.error(tree.pos(), "improperly.formed.type.inner.raw.param");
-                if (tree.clazz.getTag() == JCTree.SELECT)
+                if (tree.clazz.hasTag(SELECT))
                     visitSelectInternal((JCFieldAccess)tree.clazz);
             }
         }
@@ -1137,7 +1337,7 @@ public class Check {
 
         @Override
         public void visitSelect(JCFieldAccess tree) {
-            if (tree.type.tag == CLASS) {
+            if (tree.type.hasTag(CLASS)) {
                 visitSelectInternal(tree);
 
                 // Check that this type is either fully parameterized, or
@@ -1160,6 +1360,11 @@ public class Check {
             }
         }
 
+        @Override
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            tree.underlyingType.accept(this);
+        }
+
         /** Default visitor method: do nothing.
          */
         @Override
@@ -1183,18 +1388,23 @@ public class Check {
             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.tag == CLASS &&
-                !TreeInfo.isDiamond(tree) &&
-                !env.enclClass.name.isEmpty() &&  //anonymous or intersection
-                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);
         }
     }
+    //where
+        private boolean withinAnonConstr(Env<AttrContext> env) {
+            return env.enclClass.name.isEmpty() &&
+                    env.enclMethod != null && env.enclMethod.name == names.init;
+        }
 
 /* *************************************************************************
  * Exception checking
@@ -1207,6 +1417,8 @@ public class Check {
     /** Is given type a subtype of some of the types in given list?
      */
     boolean subset(Type t, List<Type> ts) {
+        if (t == null)
+            return false;
         for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
             if (types.isSubtype(t, l.head)) return true;
         return false;
@@ -1216,6 +1428,8 @@ public class Check {
      *  some of the types in given list?
      */
     boolean intersects(Type t, List<Type> ts) {
+        if (t == null)
+            return false;
         for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
             if (types.isSubtype(t, l.head) || types.isSubtype(l.head, t)) return true;
         return false;
@@ -1225,13 +1439,13 @@ public class Check {
      *  in the list.
      */
     List<Type> incl(Type t, List<Type> ts) {
-        return subset(t, ts) ? ts : excl(t, ts).prepend(t);
+        return (t == null || subset(t, ts)) ? ts : excl(t, ts).prepend(t);
     }
 
     /** Remove type set from type set list.
      */
     List<Type> excl(Type t, List<Type> ts) {
-        if (ts.isEmpty()) {
+        if (t == null || ts.isEmpty()) {
             return ts;
         } else {
             List<Type> ts1 = excl(t, ts.tail);
@@ -1284,9 +1498,9 @@ public class Check {
     boolean isUnchecked(Type exc) {
         return
             (exc == null) ? true :
-            (exc.tag == TYPEVAR) ? isUnchecked(types.supertype(exc)) :
-            (exc.tag == CLASS) ? isUnchecked((ClassSymbol)exc.tsym) :
-            exc.tag == BOT || exc.tag == ERROR;
+            (exc.hasTag(TYPEVAR)) ? isUnchecked(types.supertype(exc)) :
+            (exc.hasTag(CLASS)) ? isUnchecked((ClassSymbol)exc.tsym) :
+            exc.hasTag(BOT) || exc.hasTag(ERROR);
     }
 
     /** Same, but handling completion failures.
@@ -1417,6 +1631,7 @@ public class Check {
                    (other.flags() & STATIC) == 0) {
             log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.static",
                       cannotOverride(m, other));
+            m.flags_field |= BAD_OVERRIDE;
             return;
         }
 
@@ -1428,6 +1643,7 @@ public class Check {
             log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.meth",
                       cannotOverride(m, other),
                       asFlagSet(other.flags() & (FINAL | STATIC)));
+            m.flags_field |= BAD_OVERRIDE;
             return;
         }
 
@@ -1442,8 +1658,9 @@ public class Check {
             log.error(TreeInfo.diagnosticPositionFor(m, tree), "override.weaker.access",
                       cannotOverride(m, other),
                       other.flags() == 0 ?
-                          Flag.PACKAGE :
+                          "package" :
                           asFlagSet(other.flags() & AccessFlags));
+            m.flags_field |= BAD_OVERRIDE;
             return;
         }
 
@@ -1471,6 +1688,7 @@ public class Check {
                           "override.incompatible.ret",
                           cannotOverride(m, other),
                           mtres, otres);
+                m.flags_field |= BAD_OVERRIDE;
                 return;
             }
         } else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) {
@@ -1490,6 +1708,7 @@ public class Check {
                       "override.meth.doesnt.throw",
                       cannotOverride(m, other),
                       unhandledUnerased.head);
+            m.flags_field |= BAD_OVERRIDE;
             return;
         }
         else if (unhandledUnerased.nonEmpty()) {
@@ -1547,7 +1766,7 @@ public class Check {
             // case, we will have dealt with when examining the supertype classes
             ClassSymbol mc = m.enclClass();
             Type st = types.supertype(origin.type);
-            if (st.tag != CLASS)
+            if (!st.hasTag(CLASS))
                 return true;
             MethodSymbol stimpl = m.implementation((ClassSymbol)st.tsym, types, false);
 
@@ -1570,10 +1789,10 @@ public class Check {
      */
     public void checkCompatibleConcretes(DiagnosticPosition pos, Type site) {
         Type sup = types.supertype(site);
-        if (sup.tag != CLASS) return;
+        if (!sup.hasTag(CLASS)) return;
 
         for (Type t1 = sup;
-             t1.tsym.type.isParameterized();
+             t1.hasTag(CLASS) && t1.tsym.type.isParameterized();
              t1 = types.supertype(t1)) {
             for (Scope.Entry e1 = t1.tsym.members().elems;
                  e1 != null;
@@ -1591,7 +1810,7 @@ public class Check {
                 if (st1 == s1.type) continue;
 
                 for (Type t2 = sup;
-                     t2.tag == CLASS;
+                     t2.hasTag(CLASS);
                      t2 = types.supertype(t2)) {
                     for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name);
                          e2.scope != null;
@@ -1664,7 +1883,7 @@ public class Check {
 
     /** Compute all the supertypes of t, indexed by type symbol. */
     private void closure(Type t, Map<TypeSymbol,Type> typeMap) {
-        if (t.tag != CLASS) return;
+        if (!t.hasTag(CLASS)) return;
         if (typeMap.put(t.tsym, t) == null) {
             closure(types.supertype(t), typeMap);
             for (Type i : types.interfaces(t))
@@ -1674,7 +1893,7 @@ public class Check {
 
     /** Compute all the supertypes of t, indexed by type symbol (except thise in typesSkip). */
     private void closure(Type t, Map<TypeSymbol,Type> typesSkip, Map<TypeSymbol,Type> typeMap) {
-        if (t.tag != CLASS) return;
+        if (!t.hasTag(CLASS)) return;
         if (typesSkip.get(t.tsym) != null) return;
         if (typeMap.put(t.tsym, t) == null) {
             closure(types.supertype(t), typesSkip, typeMap);
@@ -1688,13 +1907,15 @@ public class Check {
         for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) {
             Symbol s1 = e1.sym;
             Type st1 = null;
-            if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types)) continue;
+            if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types) ||
+                    (s1.flags() & SYNTHETIC) != 0) continue;
             Symbol impl = ((MethodSymbol)s1).implementation(site.tsym, types, false);
             if (impl != null && (impl.flags() & ABSTRACT) == 0) continue;
             for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); e2.scope != null; e2 = e2.next()) {
                 Symbol s2 = e2.sym;
                 if (s1 == s2) continue;
-                if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types)) continue;
+                if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types) ||
+                        (s2.flags() & SYNTHETIC) != 0) continue;
                 if (st1 == null) st1 = types.memberType(t1, s1);
                 Type st2 = types.memberType(t2, s2);
                 if (types.overrideEquivalent(st1, st2)) {
@@ -1704,9 +1925,10 @@ public class Check {
                     Type rt2 = types.subst(st2.getReturnType(), tvars2, tvars1);
                     boolean compat =
                         types.isSameType(rt1, rt2) ||
-                        rt1.tag >= CLASS && rt2.tag >= CLASS &&
-                        (types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
-                         types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
+                        !rt1.isPrimitiveOrVoid() &&
+                        !rt2.isPrimitiveOrVoid() &&
+                        (types.covariantReturnType(rt1, rt2, types.noWarnings) ||
+                         types.covariantReturnType(rt2, rt1, types.noWarnings)) ||
                          checkCommonOverriderIn(s1,s2,site);
                     if (!compat) {
                         log.error(pos, "types.incompatible.diff.ret",
@@ -1737,23 +1959,11 @@ public class Check {
                 Symbol s3 = e.sym;
                 if (s3 == s1 || s3 == s2 || s3.kind != MTH || (s3.flags() & (BRIDGE|SYNTHETIC)) != 0) continue;
                 Type st3 = types.memberType(site,s3);
-                if (types.overrideEquivalent(st3, st1) && types.overrideEquivalent(st3, st2)) {
-                    if (s3.owner == site.tsym) {
-                        return true;
-                    }
-                    List<Type> tvars1 = st1.getTypeArguments();
-                    List<Type> tvars2 = st2.getTypeArguments();
-                    List<Type> tvars3 = st3.getTypeArguments();
-                    Type rt1 = st1.getReturnType();
-                    Type rt2 = st2.getReturnType();
-                    Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1);
-                    Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2);
-                    boolean compat =
-                        rt13.tag >= CLASS && rt23.tag >= CLASS &&
-                        (types.covariantReturnType(rt13, rt1, Warner.noWarnings) &&
-                         types.covariantReturnType(rt23, rt2, Warner.noWarnings));
-                    if (compat)
-                        return true;
+                if (types.overrideEquivalent(st3, st1) &&
+                        types.overrideEquivalent(st3, st2) &&
+                        types.returnTypeSubstitutable(st3, st1) &&
+                        types.returnTypeSubstitutable(st3, st2)) {
+                    return true;
                 }
             }
         }
@@ -1772,7 +1982,7 @@ public class Check {
                 log.error(tree.pos(), "enum.no.finalize");
                 return;
             }
-        for (Type t = origin.type; t.tag == CLASS;
+        for (Type t = origin.type; t.hasTag(CLASS);
              t = types.supertype(t)) {
             if (t != origin.type) {
                 checkOverride(tree, t, origin, m);
@@ -1796,6 +2006,55 @@ public class Check {
         }
     }
 
+    private Filter<Symbol> equalsHasCodeFilter = new Filter<Symbol>() {
+        public boolean accepts(Symbol s) {
+            return MethodSymbol.implementation_filter.accepts(s) &&
+                    (s.flags() & BAD_OVERRIDE) == 0;
+
+        }
+    };
+
+    public void checkClassOverrideEqualsAndHashIfNeeded(DiagnosticPosition pos,
+            ClassSymbol someClass) {
+        /* At present, annotations cannot possibly have a method that is override
+         * equivalent with Object.equals(Object) but in any case the condition is
+         * fine for completeness.
+         */
+        if (syms.objectType.isErroneous() ||
+            someClass == (ClassSymbol)syms.objectType.tsym ||
+            someClass.isInterface() || someClass.isEnum() ||
+            (someClass.flags() & ANNOTATION) != 0 ||
+            (someClass.flags() & ABSTRACT) != 0) return;
+        //anonymous inner classes implementing interfaces need especial treatment
+        if (someClass.isAnonymous()) {
+            List<Type> interfaces =  types.interfaces(someClass.type);
+            if (interfaces != null && !interfaces.isEmpty() &&
+                interfaces.head.tsym == syms.comparatorType.tsym) return;
+        }
+        checkClassOverrideEqualsAndHash(pos, someClass);
+    }
+
+    private void checkClassOverrideEqualsAndHash(DiagnosticPosition pos,
+            ClassSymbol someClass) {
+        if (lint.isEnabled(LintCategory.OVERRIDES)) {
+            MethodSymbol equalsAtObject = (MethodSymbol)syms.objectType
+                    .tsym.members().lookup(names.equals).sym;
+            MethodSymbol hashCodeAtObject = (MethodSymbol)syms.objectType
+                    .tsym.members().lookup(names.hashCode).sym;
+            MethodSymbol equalsImpl = types.implementation(equalsAtObject,
+                    someClass, false, equalsHasCodeFilter);
+            boolean overridesEquals = equalsImpl != null && equalsImpl.owner == someClass;
+            MethodSymbol hasCodeImpl = types.implementation(hashCodeAtObject,
+                    someClass, false, equalsHasCodeFilter);
+            boolean overridesHashCode = hasCodeImpl != null && hasCodeImpl != hashCodeAtObject;
+
+            if (overridesEquals && !overridesHashCode) {
+                log.warning(LintCategory.OVERRIDES, pos,
+                        "override.equals.but.not.hashcode", someClass);
+            }
+        }
+    }
+
     private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) {
         ClashFilter cf = new ClashFilter(origin.type);
         return (cf.accepts(s1) &&
@@ -1809,6 +2068,9 @@ public class Check {
      *  @param c            The class.
      */
     void checkAllDefined(DiagnosticPosition pos, ClassSymbol c) {
+        if (c.type == null || c.type.isErroneous()) {
+            return ;
+        }
         try {
             MethodSymbol undef = firstUndef(c, c);
             if (undef != null) {
@@ -1843,16 +2105,26 @@ public class Check {
                      undef == null && e != null;
                      e = e.sibling) {
                     if (e.sym.kind == MTH &&
-                        (e.sym.flags() & (ABSTRACT|IPROXY)) == ABSTRACT) {
+                        (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) {
                         MethodSymbol absmeth = (MethodSymbol)e.sym;
                         MethodSymbol implmeth = absmeth.implementation(impl, types, true);
-                        if (implmeth == null || implmeth == absmeth)
+                        if (implmeth == null || implmeth == absmeth) {
+                            //look for default implementations
+                            if (allowDefaultMethods) {
+                                MethodSymbol prov = types.interfaceCandidates(impl.type, absmeth).head;
+                                if (prov != null && prov.overrides(absmeth, impl, types, true)) {
+                                    implmeth = prov;
+                                }
+                            }
+                        }
+                        if (implmeth == null || implmeth == absmeth) {
                             undef = absmeth;
+                        }
                     }
                 }
                 if (undef == null) {
                     Type st = types.supertype(c.type);
-                    if (st.tag == CLASS)
+                    if (st.hasTag(CLASS))
                         undef = firstUndef(impl, (ClassSymbol)st.tsym);
                 }
                 for (List<Type> l = types.interfaces(c.type);
@@ -1935,7 +2207,7 @@ public class Check {
         }
 
         void checkClass(DiagnosticPosition pos, Symbol c, List<JCTree> supertypes) {
-            if ((c.flags_field & ACYCLIC) != 0)
+            if (c == null || (c.flags_field & ACYCLIC) != 0)
                 return;
             if (seenClasses.contains(c)) {
                 errorFound = true;
@@ -1943,7 +2215,7 @@ public class Check {
             } else if (!c.type.isErroneous()) {
                 try {
                     seenClasses = seenClasses.prepend(c);
-                    if (c.type.tag == CLASS) {
+                    if (c.type.hasTag(CLASS)) {
                         if (supertypes.nonEmpty()) {
                             scan(supertypes);
                         }
@@ -1988,13 +2260,13 @@ public class Check {
 
     private void checkNonCyclic1(DiagnosticPosition pos, Type t, List<TypeVar> seen) {
         final TypeVar tv;
-        if  (t.tag == TYPEVAR && (t.tsym.flags() & UNATTRIBUTED) != 0)
+        if  (t.hasTag(TYPEVAR) && (t.tsym.flags() & UNATTRIBUTED) != 0)
             return;
         if (seen.contains(t)) {
             tv = (TypeVar)t;
             tv.bound = types.createErrorType(t);
             log.error(pos, "cyclic.inheritance", t);
-        } else if (t.tag == TYPEVAR) {
+        } else if (t.hasTag(TYPEVAR)) {
             tv = (TypeVar)t;
             seen = seen.prepend(tv);
             for (Type b : types.getBounds(tv))
@@ -2020,14 +2292,14 @@ public class Check {
         } else if (!c.type.isErroneous()) {
             try {
                 c.flags_field |= LOCKED;
-                if (c.type.tag == CLASS) {
+                if (c.type.hasTag(CLASS)) {
                     ClassType clazz = (ClassType)c.type;
                     if (clazz.interfaces_field != null)
                         for (List<Type> l=clazz.interfaces_field; l.nonEmpty(); l=l.tail)
                             complete &= checkNonCyclicInternal(pos, l.head);
                     if (clazz.supertype_field != null) {
                         Type st = clazz.supertype_field;
-                        if (st != null && st.tag == CLASS)
+                        if (st != null && st.hasTag(CLASS))
                             complete &= checkNonCyclicInternal(pos, st);
                     }
                     if (c.owner.kind == TYP)
@@ -2049,7 +2321,7 @@ public class Check {
         for (List<Type> l=types.interfaces(c.type); l.nonEmpty(); l=l.tail)
             l.head = types.createErrorType((ClassSymbol)l.head.tsym, Type.noType);
         Type st = types.supertype(c.type);
-        if (st.tag == CLASS)
+        if (st.hasTag(CLASS))
             ((ClassType)c.type).supertype_field = types.createErrorType((ClassSymbol)st.tsym, Type.noType);
         c.type = types.createErrorType(c, c.type);
         c.flags_field |= ACYCLIC;
@@ -2060,14 +2332,13 @@ public class Check {
      *  @param tree         The class definition whose members are checked.
      */
     void checkImplementations(JCClassDecl tree) {
-        checkImplementations(tree, tree.sym);
+        checkImplementations(tree, tree.sym, tree.sym);
     }
-//where
+    //where
         /** Check that all methods which implement some
          *  method in `ic' conform to the method they implement.
          */
-        void checkImplementations(JCClassDecl tree, ClassSymbol ic) {
-            ClassSymbol origin = tree.sym;
+        void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) {
             for (List<Type> l = types.closure(ic.type); l.nonEmpty(); l = l.tail) {
                 ElementKind kind = l.head.tsym.getKind();
 
@@ -2108,7 +2379,7 @@ public class Check {
     void checkCompatibleSupertypes(DiagnosticPosition pos, Type c) {
         List<Type> supertypes = types.interfaces(c);
         Type supertype = types.supertype(c);
-        if (supertype.tag == CLASS &&
+        if (supertype.hasTag(CLASS) &&
             (supertype.tsym.flags() & ABSTRACT) != 0)
             supertypes = supertypes.prepend(supertype);
         for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) {
@@ -2160,7 +2431,7 @@ public class Check {
                 if (m2 == m1) continue;
                 //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
                 //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
-                if (!types.isSubSignature(sym.type, types.memberType(site, m2), false) &&
+                if (!types.isSubSignature(sym.type, types.memberType(site, m2), allowStrictMethodClashCheck) &&
                         types.hasSameArgs(m2.erasure(types), m1.erasure(types))) {
                     sym.flags_field |= CLASH;
                     String key = m1 == sym ?
@@ -2194,7 +2465,7 @@ public class Check {
         for (Symbol s : types.membersClosure(site, true).getElementsByName(sym.name, cf)) {
             //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
             //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
-            if (!types.isSubSignature(sym.type, types.memberType(site, s), false) &&
+            if (!types.isSubSignature(sym.type, types.memberType(site, s), allowStrictMethodClashCheck) &&
                     types.hasSameArgs(s.erasure(types), sym.erasure(types))) {
                 log.error(pos,
                         "name.clash.same.erasure.no.hide",
@@ -2228,6 +2499,65 @@ public class Check {
          }
      }
 
+    void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) {
+        if (site == null || site.isErroneous()) {
+            return;
+        }
+        DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site);
+        for (Symbol m : types.membersClosure(site, false).getElements(dcf)) {
+            Assert.check(m.kind == MTH);
+            List<MethodSymbol> prov = types.interfaceCandidates(site, (MethodSymbol)m);
+            if (prov.size() > 1) {
+                ListBuffer<Symbol> abstracts = ListBuffer.lb();
+                ListBuffer<Symbol> defaults = ListBuffer.lb();
+                for (MethodSymbol provSym : prov) {
+                    if ((provSym.flags() & DEFAULT) != 0) {
+                        defaults = defaults.append(provSym);
+                    } else if ((provSym.flags() & ABSTRACT) != 0) {
+                        abstracts = abstracts.append(provSym);
+                    }
+                    if (defaults.nonEmpty() && defaults.size() + abstracts.size() >= 2) {
+                        //strong semantics - issue an error if two sibling interfaces
+                        //have two override-equivalent defaults - or if one is abstract
+                        //and the other is default
+                        String errKey;
+                        Symbol s1 = defaults.first();
+                        Symbol s2;
+                        if (defaults.size() > 1) {
+                            errKey = "types.incompatible.unrelated.defaults";
+                            s2 = defaults.toList().tail.head;
+                        } else {
+                            errKey = "types.incompatible.abstract.default";
+                            s2 = abstracts.first();
+                        }
+                        log.error(pos, errKey,
+                                Kinds.kindName(site.tsym), site,
+                                m.name, types.memberType(site, m).getParameterTypes(),
+                                s1.location(), s2.location());
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    //where
+     private class DefaultMethodClashFilter implements Filter<Symbol> {
+
+         Type site;
+
+         DefaultMethodClashFilter(Type site) {
+             this.site = site;
+         }
+
+         public boolean accepts(Symbol s) {
+             return s.kind == MTH &&
+                     (s.flags() & DEFAULT) != 0 &&
+                     s.isInheritedIn(site.tsym, types) &&
+                     !s.isConstructor();
+         }
+     }
+
     /** Report a conflict between a user symbol and a synthetic symbol.
      */
     private void syntheticError(DiagnosticPosition pos, Symbol sym) {
@@ -2306,9 +2636,12 @@ public class Check {
         tree.accept(new AnnotationValidator());
     }
 
-    /** Annotation types are restricted to primitives, String, an
+    /**
+     *  {@literal
+     *  Annotation types are restricted to primitives, String, an
      *  enum, an annotation, Class, Class<?>, Class<? extends
      *  Anything>, arrays of the preceding.
+     *  }
      */
     void validateAnnotationType(JCTree restype) {
         // restype may be null if an error occurred, so don't bother validating it
@@ -2339,7 +2672,7 @@ public class Check {
      * @jls 9.6 Annotation Types
      */
     void validateAnnotationMethod(DiagnosticPosition pos, MethodSymbol m) {
-        for (Type sup = syms.annotationType; sup.tag == CLASS; sup = types.supertype(sup)) {
+        for (Type sup = syms.annotationType; sup.hasTag(CLASS); sup = types.supertype(sup)) {
             Scope s = sup.tsym.members();
             for (Scope.Entry e = s.lookup(m.name); e.scope != null; e = e.next()) {
                 if (e.sym.kind == MTH &&
@@ -2353,14 +2686,20 @@ public class Check {
     /** Check the annotations of a symbol.
      */
     public void validateAnnotations(List<JCAnnotation> annotations, Symbol s) {
-        if (skipAnnotations) return;
         for (JCAnnotation a : annotations)
             validateAnnotation(a, s);
     }
 
+    /** Check the type annotations.
+     */
+    public void validateTypeAnnotations(List<JCAnnotation> annotations, boolean isTypeParameter) {
+        for (JCAnnotation a : annotations)
+            validateTypeAnnotation(a, isTypeParameter);
+    }
+
     /** Check an annotation of a symbol.
      */
-    public void validateAnnotation(JCAnnotation a, Symbol s) {
+    private void validateAnnotation(JCAnnotation a, Symbol s) {
         validateAnnotationTree(a);
 
         if (!annotationApplicable(a, s))
@@ -2370,6 +2709,210 @@ public class Check {
             if (!isOverrider(s))
                 log.error(a.pos(), "method.does.not.override.superclass");
         }
+
+        if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) {
+            if (s.kind != TYP) {
+                log.error(a.pos(), "bad.functional.intf.anno");
+            } else {
+                try {
+                    types.findDescriptorSymbol((TypeSymbol)s);
+                } catch (Types.FunctionDescriptorLookupError ex) {
+                    log.error(a.pos(), "bad.functional.intf.anno.1", ex.getDiagnostic());
+                }
+            }
+        }
+    }
+
+    public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
+        Assert.checkNonNull(a.type, "annotation tree hasn't been attributed yet: " + a);
+        validateAnnotationTree(a);
+
+        if (!isTypeAnnotation(a, isTypeParameter))
+            log.error(a.pos(), "annotation.type.not.applicable");
+    }
+
+    /**
+     * Validate the proposed container 'repeatable' on the
+     * annotation type symbol 's'. Report errors at position
+     * 'pos'.
+     *
+     * @param s The (annotation)type declaration annotated with a @Repeatable
+     * @param repeatable the @Repeatable on 's'
+     * @param pos where to report errors
+     */
+    public void validateRepeatable(TypeSymbol s, Attribute.Compound repeatable, DiagnosticPosition pos) {
+        Assert.check(types.isSameType(repeatable.type, syms.repeatableType));
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = repeatable.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            // errors should already have been reported during Annotate
+            return;
+        }
+
+        validateValue(t.tsym, s, pos);
+        validateRetention(t.tsym, s, pos);
+        validateDocumented(t.tsym, s, pos);
+        validateInherited(t.tsym, s, pos);
+        validateTarget(t.tsym, s, pos);
+        validateDefault(t.tsym, s, pos);
+    }
+
+    private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
+        Scope.Entry e = container.members().lookup(names.value);
+        if (e.scope != null && e.sym.kind == MTH) {
+            MethodSymbol m = (MethodSymbol) e.sym;
+            Type ret = m.getReturnType();
+            if (!(ret.hasTag(ARRAY) && types.isSameType(((ArrayType)ret).elemtype, contained.type))) {
+                log.error(pos, "invalid.repeatable.annotation.value.return",
+                        container, ret, types.makeArrayType(contained.type));
+            }
+        } else {
+            log.error(pos, "invalid.repeatable.annotation.no.value", container);
+        }
+    }
+
+    private void validateRetention(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        Attribute.RetentionPolicy containerRetention = types.getRetention(container);
+        Attribute.RetentionPolicy containedRetention = types.getRetention(contained);
+
+        boolean error = false;
+        switch (containedRetention) {
+        case RUNTIME:
+            if (containerRetention != Attribute.RetentionPolicy.RUNTIME) {
+                error = true;
+            }
+            break;
+        case CLASS:
+            if (containerRetention == Attribute.RetentionPolicy.SOURCE)  {
+                error = true;
+            }
+        }
+        if (error ) {
+            log.error(pos, "invalid.repeatable.annotation.retention",
+                      container, containerRetention,
+                      contained, containedRetention);
+        }
+    }
+
+    private void validateDocumented(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        if (contained.attribute(syms.documentedType.tsym) != null) {
+            if (container.attribute(syms.documentedType.tsym) == null) {
+                log.error(pos, "invalid.repeatable.annotation.not.documented", container, contained);
+            }
+        }
+    }
+
+    private void validateInherited(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        if (contained.attribute(syms.inheritedType.tsym) != null) {
+            if (container.attribute(syms.inheritedType.tsym) == null) {
+                log.error(pos, "invalid.repeatable.annotation.not.inherited", container, contained);
+            }
+        }
+    }
+
+    private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        // The set of targets the container is applicable to must be a subset
+        // (with respect to annotation target semantics) of the set of targets
+        // the contained is applicable to. The target sets may be implicit or
+        // explicit.
+
+        Set<Name> containerTargets;
+        Attribute.Array containerTarget = getAttributeTargetAttribute(container);
+        if (containerTarget == null) {
+            containerTargets = getDefaultTargetSet();
+        } else {
+            containerTargets = new HashSet<Name>();
+        for (Attribute app : containerTarget.values) {
+            if (!(app instanceof Attribute.Enum)) {
+                continue; // recovery
+            }
+            Attribute.Enum e = (Attribute.Enum)app;
+            containerTargets.add(e.value.name);
+        }
+        }
+
+        Set<Name> containedTargets;
+        Attribute.Array containedTarget = getAttributeTargetAttribute(contained);
+        if (containedTarget == null) {
+            containedTargets = getDefaultTargetSet();
+        } else {
+            containedTargets = new HashSet<Name>();
+        for (Attribute app : containedTarget.values) {
+            if (!(app instanceof Attribute.Enum)) {
+                continue; // recovery
+            }
+            Attribute.Enum e = (Attribute.Enum)app;
+            containedTargets.add(e.value.name);
+        }
+        }
+
+        if (!isTargetSubsetOf(containerTargets, containedTargets)) {
+            log.error(pos, "invalid.repeatable.annotation.incompatible.target", container, contained);
+        }
+    }
+
+    /* get a set of names for the default target */
+    private Set<Name> getDefaultTargetSet() {
+        if (defaultTargets == null) {
+            Set<Name> targets = new HashSet<Name>();
+            targets.add(names.ANNOTATION_TYPE);
+            targets.add(names.CONSTRUCTOR);
+            targets.add(names.FIELD);
+            targets.add(names.LOCAL_VARIABLE);
+            targets.add(names.METHOD);
+            targets.add(names.PACKAGE);
+            targets.add(names.PARAMETER);
+            targets.add(names.TYPE);
+
+            defaultTargets = java.util.Collections.unmodifiableSet(targets);
+        }
+
+        return defaultTargets;
+    }
+    private Set<Name> defaultTargets;
+
+
+    /** Checks that s is a subset of t, with respect to ElementType
+     * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}
+     */
+    private boolean isTargetSubsetOf(Set<Name> s, Set<Name> t) {
+        // Check that all elements in s are present in t
+        for (Name n2 : s) {
+            boolean currentElementOk = false;
+            for (Name n1 : t) {
+                if (n1 == n2) {
+                    currentElementOk = true;
+                    break;
+                } else if (n1 == names.TYPE && n2 == names.ANNOTATION_TYPE) {
+                    currentElementOk = true;
+                    break;
+                }
+            }
+            if (!currentElementOk)
+                return false;
+        }
+        return true;
+    }
+
+    private void validateDefault(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        // validate that all other elements of containing type has defaults
+        Scope scope = container.members();
+        for(Symbol elm : scope.getElements()) {
+            if (elm.name != names.value &&
+                elm.kind == Kinds.MTH &&
+                ((MethodSymbol)elm).defaultValue == null) {
+                log.error(pos,
+                          "invalid.repeatable.annotation.elem.nondefault",
+                          container,
+                          elm);
+            }
+        }
     }
 
     /** Is s a method symbol that overrides a method in a superclass? */
@@ -2390,47 +2933,90 @@ public class Check {
         return false;
     }
 
-    /** Is the annotation applicable to the symbol? */
-    boolean annotationApplicable(JCAnnotation a, Symbol s) {
+    /** Is the annotation applicable to type annotations? */
+    protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
         Attribute.Compound atTarget =
             a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
-        if (atTarget == null) return true;
+        if (atTarget == null) {
+            // An annotation without @Target is not a type annotation.
+            return false;
+        }
+
         Attribute atValue = atTarget.member(names.value);
-        if (!(atValue instanceof Attribute.Array)) return true; // error recovery
+        if (!(atValue instanceof Attribute.Array)) {
+            return false; // error recovery
+        }
+
         Attribute.Array arr = (Attribute.Array) atValue;
         for (Attribute app : arr.values) {
-            if (!(app instanceof Attribute.Enum)) return true; // recovery
+            if (!(app instanceof Attribute.Enum)) {
+                return false; // recovery
+            }
             Attribute.Enum e = (Attribute.Enum) app;
-            if (e.value.name == names.TYPE)
+
+            if (e.value.name == names.TYPE_USE)
+                return true;
+            else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER)
+                return true;
+        }
+        return false;
+    }
+
+    /** Is the annotation applicable to the symbol? */
+    boolean annotationApplicable(JCAnnotation a, Symbol s) {
+        Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
+        Name[] targets;
+
+        if (arr == null) {
+            targets = defaultTargetMetaInfo(a, s);
+        } else {
+            // TODO: can we optimize this?
+            targets = new Name[arr.values.length];
+            for (int i=0; i<arr.values.length; ++i) {
+                Attribute app = arr.values[i];
+                if (!(app instanceof Attribute.Enum)) {
+                    return true; // recovery
+                }
+                Attribute.Enum e = (Attribute.Enum) app;
+                targets[i] = e.value.name;
+            }
+        }
+        for (Name target : targets) {
+            if (target == names.TYPE)
                 { if (s.kind == TYP) return true; }
-            else if (e.value.name == names.FIELD)
+            else if (target == names.FIELD)
                 { if (s.kind == VAR && s.owner.kind != MTH) return true; }
-            else if (e.value.name == names.METHOD)
+            else if (target == names.METHOD)
                 { if (s.kind == MTH && !s.isConstructor()) return true; }
-            else if (e.value.name == names.PARAMETER)
+            else if (target == names.PARAMETER)
                 { if (s.kind == VAR &&
                       s.owner.kind == MTH &&
                       (s.flags() & PARAMETER) != 0)
                     return true;
                 }
-            else if (e.value.name == names.CONSTRUCTOR)
+            else if (target == names.CONSTRUCTOR)
                 { if (s.kind == MTH && s.isConstructor()) return true; }
-            else if (e.value.name == names.LOCAL_VARIABLE)
+            else if (target == names.LOCAL_VARIABLE)
                 { if (s.kind == VAR && s.owner.kind == MTH &&
                       (s.flags() & PARAMETER) == 0)
                     return true;
                 }
-            else if (e.value.name == names.ANNOTATION_TYPE)
+            else if (target == names.ANNOTATION_TYPE)
                 { if (s.kind == TYP && (s.flags() & ANNOTATION) != 0)
                     return true;
                 }
-            else if (e.value.name == names.PACKAGE)
+            else if (target == names.PACKAGE)
                 { if (s.kind == PCK) return true; }
-            else if (e.value.name == names.TYPE_USE)
+            else if (target == names.TYPE_USE)
                 { if (s.kind == TYP ||
                       s.kind == VAR ||
                       (s.kind == MTH && !s.isConstructor() &&
-                       s.type.getReturnType().tag != VOID))
+                      !s.type.getReturnType().hasTag(VOID)) ||
+                      (s.kind == MTH && s.isConstructor()))
+                    return true;
+                }
+            else if (target == names.TYPE_PARAMETER)
+                { if (s.kind == TYP && s.type.hasTag(TYPEVAR))
                     return true;
                 }
             else
@@ -2439,40 +3025,70 @@ public class Check {
         return false;
     }
 
+
+    Attribute.Array getAttributeTargetAttribute(Symbol s) {
+        Attribute.Compound atTarget =
+            s.attribute(syms.annotationTargetType.tsym);
+        if (atTarget == null) return null; // ok, is applicable
+        Attribute atValue = atTarget.member(names.value);
+        if (!(atValue instanceof Attribute.Array)) return null; // error recovery
+        return (Attribute.Array) atValue;
+    }
+
+    private final Name[] dfltTargetMeta;
+    private Name[] defaultTargetMetaInfo(JCAnnotation a, Symbol s) {
+        return dfltTargetMeta;
+    }
+
     /** Check an annotation value.
+     *
+     * @param a The annotation tree to check
+     * @return true if this annotation tree is valid, otherwise false
      */
-    public void validateAnnotation(JCAnnotation a) {
-        // collect an inventory of the members (sorted alphabetically)
-        Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
-            public int compare(Symbol t, Symbol t1) {
-                return t.name.compareTo(t1.name);
-            }
-        });
+    public boolean validateAnnotationDeferErrors(JCAnnotation a) {
+        boolean res = false;
+        final Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log);
+        try {
+            res = validateAnnotation(a);
+        } finally {
+            log.popDiagnosticHandler(diagHandler);
+        }
+        return res;
+    }
+
+    private boolean validateAnnotation(JCAnnotation a) {
+        boolean isValid = true;
+        // 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);
 
-        // count them off as they're annotated
+        // remove the ones that are assigned values
         for (JCTree arg : a.args) {
-            if (arg.getTag() != JCTree.ASSIGN) continue; // recovery
+            if (!arg.hasTag(ASSIGN)) continue; // recovery
             JCAssign assign = (JCAssign) arg;
             Symbol m = TreeInfo.symbol(assign.lhs);
             if (m == null || m.type.isErroneous()) continue;
-            if (!members.remove(m))
+            if (!members.remove(m)) {
+                isValid = false;
                 log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
                           m.name, a.type);
+            }
         }
 
         // all the remaining ones better have default values
-        ListBuffer<Name> missingDefaults = ListBuffer.lb();
+        List<Name> missingDefaults = List.nil();
         for (MethodSymbol m : members) {
             if (m.defaultValue == null && !m.type.isErroneous() && m.name != m.name.table.names.clinit) {
-                missingDefaults.append(m.name);
+                missingDefaults = missingDefaults.append(m.name);
             }
         }
+        missingDefaults = missingDefaults.reverse();
         if (missingDefaults.nonEmpty()) {
+            isValid = false;
             String key = (missingDefaults.size() > 1)
                     ? "annotation.missing.default.value.1"
                     : "annotation.missing.default.value";
@@ -2483,21 +3099,23 @@ public class Check {
         // repeated values in its value member
         if (a.annotationType.type.tsym != syms.annotationTargetType.tsym ||
             a.args.tail == null)
-            return;
+            return isValid;
 
-        if (a.args.head.getTag() != JCTree.ASSIGN) return; // error recovery
+        if (!a.args.head.hasTag(ASSIGN)) return false; // error recovery
         JCAssign assign = (JCAssign) a.args.head;
         Symbol m = TreeInfo.symbol(assign.lhs);
-        if (m.name != names.value) return;
+        if (m.name != names.value) return false;
         JCTree rhs = assign.rhs;
-        if (rhs.getTag() != JCTree.NEWARRAY) return;
+        if (!rhs.hasTag(NEWARRAY)) return false;
         JCNewArray na = (JCNewArray) rhs;
         Set<Symbol> targets = new HashSet<Symbol>();
         for (JCTree elem : na.elems) {
             if (!targets.add(TreeInfo.symbol(elem))) {
+                isValid = false;
                 log.error(elem.pos(), "repeated.annotation.target");
             }
         }
+        return isValid;
     }
 
     void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) {
@@ -2521,7 +3139,7 @@ public class Check {
                     warnDeprecated(pos, s);
                 }
             });
-        };
+        }
     }
 
     void checkSunAPI(final DiagnosticPosition pos, final Symbol s) {
@@ -2531,12 +3149,18 @@ public class Check {
                     if (enableSunApiLintControl)
                       warnSunApi(pos, "sun.proprietary", s);
                     else
-                      log.strictWarning(pos, "sun.proprietary", s);
+                      log.mandatoryWarning(pos, "sun.proprietary", s);
                 }
             });
         }
     }
 
+    void checkProfile(final DiagnosticPosition pos, final Symbol s) {
+        if (profile != Profile.DEFAULT && (s.flags() & NOT_IN_PROFILE) != 0) {
+            log.error(pos, "not.in.profile", s, profile);
+        }
+    }
+
 /* *************************************************************************
  * Check for recursive annotation elements.
  **************************************************************************/
@@ -2549,7 +3173,7 @@ public class Check {
         try {
             tree.sym.flags_field |= LOCKED;
             for (JCTree def : tree.defs) {
-                if (def.getTag() != JCTree.METHODDEF) continue;
+                if (!def.hasTag(METHODDEF)) continue;
                 JCMethodDecl meth = (JCMethodDecl)def;
                 checkAnnotationResType(meth.pos(), meth.restype.type);
             }
@@ -2581,12 +3205,12 @@ public class Check {
     }
 
     void checkAnnotationResType(DiagnosticPosition pos, Type type) {
-        switch (type.tag) {
-        case TypeTags.CLASS:
+        switch (type.getTag()) {
+        case CLASS:
             if ((type.tsym.flags() & ANNOTATION) != 0)
                 checkNonCyclicElementsInternal(pos, type.tsym);
             break;
-        case TypeTags.ARRAY:
+        case ARRAY:
             checkAnnotationResType(pos, types.elemtype(type));
             break;
         default:
@@ -2657,7 +3281,7 @@ public class Check {
      */
     int checkOperator(DiagnosticPosition pos,
                        OperatorSymbol operator,
-                       int tag,
+                       JCTree.Tag tag,
                        Type left,
                        Type right) {
         if (operator.opcode == ByteCodes.error) {
@@ -2679,7 +3303,7 @@ public class Check {
     void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) {
         if (operand.constValue() != null
             && lint.isEnabled(LintCategory.DIVZERO)
-            && operand.tag <= LONG
+            && operand.getTag().isSubRangeOf(LONG)
             && ((Number) (operand.constValue())).longValue() == 0) {
             int opc = ((OperatorSymbol)operator).opcode;
             if (opc == ByteCodes.idiv || opc == ByteCodes.imod
@@ -2693,7 +3317,8 @@ public class Check {
      * Check for empty statements after if
      */
     void checkEmptyIf(JCIf tree) {
-        if (tree.thenpart.getTag() == JCTree.SKIP && tree.elsepart == null && lint.isEnabled(LintCategory.EMPTY))
+        if (tree.thenpart.hasTag(SKIP) && tree.elsepart == null &&
+                lint.isEnabled(LintCategory.EMPTY))
             log.warning(LintCategory.EMPTY, tree.thenpart.pos(), "empty.if");
     }
 
@@ -2751,7 +3376,6 @@ public class Check {
      *  @param pos           Position for error reporting.
      *  @param sym           The symbol.
      *  @param s             The scope
-     *  @param staticImport  Whether or not this was a static import
      */
     boolean checkUniqueStaticImport(DiagnosticPosition pos, Symbol sym, Scope s) {
         return checkUniqueImport(pos, sym, s, true);
@@ -2797,7 +3421,7 @@ public class Check {
     }
         // where
         private boolean isCanonical(JCTree tree) {
-            while (tree.getTag() == JCTree.SELECT) {
+            while (tree.hasTag(SELECT)) {
                 JCFieldAccess s = (JCFieldAccess) tree;
                 if (s.sym.owner != TreeInfo.symbol(s.selected))
                     return false;
@@ -2806,6 +3430,19 @@ public class Check {
             return true;
         }
 
+    /** Check that an auxiliary class is not accessed from any other file than its own.
+     */
+    void checkForBadAuxiliaryClassAccess(DiagnosticPosition pos, Env<AttrContext> env, ClassSymbol c) {
+        if (lint.isEnabled(Lint.LintCategory.AUXILIARYCLASS) &&
+            (c.flags() & AUXILIARY) != 0 &&
+            rs.isAccessible(env, c) &&
+            !fileManager.isSameFile(c.sourcefile, env.toplevel.sourcefile))
+        {
+            log.warning(pos, "auxiliary.class.accessed.from.outside.of.its.source.file",
+                        c, c.sourcefile);
+        }
+    }
+
     private class ConversionWarner extends Warner {
         final String uncheckedKey;
         final Type found;
diff --git a/src/share/classes/com/sun/tools/javac/comp/CompileStates.java b/src/share/classes/com/sun/tools/javac/comp/CompileStates.java
new file mode 100644
index 0000000..f192063
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/comp/CompileStates.java
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+package com.sun.tools.javac.comp;
+
+import java.util.HashMap;
+
+import com.sun.tools.javac.util.Context;
+
+/** Partial map to record which compiler phases have been executed
+ *  for each compilation unit. Used for ATTR and FLOW phases.
+ *
+ *  <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 CompileStates extends HashMap<Env<AttrContext>, CompileStates.CompileState> {
+    /** The context key for the compile states. */
+    protected static final Context.Key<CompileStates> compileStatesKey =
+        new Context.Key<CompileStates>();
+
+    /** Get the CompileStates instance for this context. */
+    public static CompileStates instance(Context context) {
+        CompileStates instance = context.get(compileStatesKey);
+        if (instance == null) {
+            instance = new CompileStates(context);
+        }
+        return instance;
+    }
+
+    /** Ordered list of compiler phases for each compilation unit. */
+    public enum CompileState {
+        INIT(0),
+        PARSE(1),
+        ENTER(2),
+        PROCESS(3),
+        ATTR(4),
+        FLOW(5),
+        TRANSTYPES(6),
+        UNLAMBDA(7),
+        LOWER(8),
+        GENERATE(9);
+
+        CompileState(int value) {
+            this.value = value;
+        }
+        public boolean isAfter(CompileState other) {
+            return value > other.value;
+        }
+        public static CompileState max(CompileState a, CompileState b) {
+            return a.value > b.value ? a : b;
+        }
+        private final int value;
+    };
+
+    private static final long serialVersionUID = 1812267524140424433L;
+
+    protected Context context;
+
+    public CompileStates(Context context) {
+        this.context = context;
+        context.put(compileStatesKey, this);
+    }
+
+    public boolean isDone(Env<AttrContext> env, CompileState cs) {
+        CompileState ecs = get(env);
+        return (ecs != null) && !cs.isAfter(ecs);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/comp/ConstFold.java b/src/share/classes/com/sun/tools/javac/comp/ConstFold.java
index cd017d4..1901c19 100644
--- a/src/share/classes/com/sun/tools/javac/comp/ConstFold.java
+++ b/src/share/classes/com/sun/tools/javac/comp/ConstFold.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2006, 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
@@ -29,9 +29,8 @@ import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.util.*;
 
-import com.sun.tools.javac.code.Type.*;
+import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 
-import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 
 /** Helper class for constant folding, used by the attribution phase.
@@ -61,9 +60,9 @@ strictfp class ConstFold {
         syms = Symtab.instance(context);
     }
 
-    static Integer minusOne = -1;
-    static Integer zero     = 0;
-    static Integer one      = 1;
+    static final Integer minusOne = -1;
+    static final Integer zero     = 0;
+    static final Integer one      = 1;
 
    /** Convert boolean to integer (true = 1, false = 0).
     */
@@ -176,19 +175,19 @@ strictfp class ConstFold {
                 case imod:
                     return syms.intType.constType(intValue(l) % intValue(r));
                 case iand:
-                    return (left.tag == BOOLEAN
+                    return (left.hasTag(BOOLEAN)
                       ? syms.booleanType : syms.intType)
                       .constType(intValue(l) & intValue(r));
                 case bool_and:
                     return syms.booleanType.constType(b2i((intValue(l) & intValue(r)) != 0));
                 case ior:
-                    return (left.tag == BOOLEAN
+                    return (left.hasTag(BOOLEAN)
                       ? syms.booleanType : syms.intType)
                       .constType(intValue(l) | intValue(r));
                 case bool_or:
                     return syms.booleanType.constType(b2i((intValue(l) | intValue(r)) != 0));
                 case ixor:
-                    return (left.tag == BOOLEAN
+                    return (left.hasTag(BOOLEAN)
                       ? syms.booleanType : syms.intType)
                       .constType(intValue(l) ^ intValue(r));
                 case ishl: case ishll:
@@ -326,7 +325,7 @@ strictfp class ConstFold {
 
     /** Coerce constant type to target type.
      *  @param etype      The source type of the coercion,
-     *                    which is assumed to be a constant type compatble with
+     *                    which is assumed to be a constant type compatible with
      *                    ttype.
      *  @param ttype      The target type of the coercion.
      */
@@ -334,9 +333,9 @@ strictfp class ConstFold {
          // WAS if (etype.baseType() == ttype.baseType())
          if (etype.tsym.type == ttype.tsym.type)
              return etype;
-         if (etype.tag <= DOUBLE) {
+         if (etype.isNumeric()) {
              Object n = etype.constValue();
-             switch (ttype.tag) {
+             switch (ttype.getTag()) {
              case BYTE:
                  return syms.byteType.constType(0 + (byte)intValue(n));
              case CHAR:
diff --git a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
new file mode 100644
index 0000000..eb73fe1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
@@ -0,0 +1,1076 @@
+/*
+ * 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.  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.comp;
+
+import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.tree.*;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.comp.Attr.ResultInfo;
+import com.sun.tools.javac.comp.Infer.InferenceContext;
+import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase;
+import com.sun.tools.javac.comp.Resolve.ReferenceLookupHelper;
+import com.sun.tools.javac.tree.JCTree.*;
+
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+/**
+ * This is an helper class that is used to perform deferred type-analysis.
+ * Each time a poly expression occurs in argument position, javac attributes it
+ * with a temporary 'deferred type' that is checked (possibly multiple times)
+ * against an expected formal type.
+ *
+ *  <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 DeferredAttr extends JCTree.Visitor {
+    protected static final Context.Key<DeferredAttr> deferredAttrKey =
+        new Context.Key<DeferredAttr>();
+
+    final Attr attr;
+    final Check chk;
+    final JCDiagnostic.Factory diags;
+    final Enter enter;
+    final Infer infer;
+    final Resolve rs;
+    final Log log;
+    final Symtab syms;
+    final TreeMaker make;
+    final Types types;
+
+    public static DeferredAttr instance(Context context) {
+        DeferredAttr instance = context.get(deferredAttrKey);
+        if (instance == null)
+            instance = new DeferredAttr(context);
+        return instance;
+    }
+
+    protected DeferredAttr(Context context) {
+        context.put(deferredAttrKey, this);
+        attr = Attr.instance(context);
+        chk = Check.instance(context);
+        diags = JCDiagnostic.Factory.instance(context);
+        enter = Enter.instance(context);
+        infer = Infer.instance(context);
+        rs = Resolve.instance(context);
+        log = Log.instance(context);
+        syms = Symtab.instance(context);
+        make = TreeMaker.instance(context);
+        types = Types.instance(context);
+        Names names = Names.instance(context);
+        stuckTree = make.Ident(names.empty).setType(Type.stuckType);
+        emptyDeferredAttrContext =
+            new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) {
+                @Override
+                void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List<Type> stuckVars) {
+                    Assert.error("Empty deferred context!");
+                }
+                @Override
+                void complete() {
+                    Assert.error("Empty deferred context!");
+                }
+            };
+    }
+
+    /** shared tree for stuck expressions */
+    final JCTree stuckTree;
+
+    /**
+     * This type represents a deferred type. A deferred type starts off with
+     * no information on the underlying expression type. Such info needs to be
+     * discovered through type-checking the deferred type against a target-type.
+     * Every deferred type keeps a pointer to the AST node from which it originated.
+     */
+    public class DeferredType extends Type {
+
+        public JCExpression tree;
+        Env<AttrContext> env;
+        AttrMode mode;
+        SpeculativeCache speculativeCache;
+
+        DeferredType(JCExpression tree, Env<AttrContext> env) {
+            super(null);
+            this.tree = tree;
+            this.env = attr.copyEnv(env);
+            this.speculativeCache = new SpeculativeCache();
+        }
+
+        @Override
+        public TypeTag getTag() {
+            return DEFERRED;
+        }
+
+        /**
+         * A speculative cache is used to keep track of all overload resolution rounds
+         * that triggered speculative attribution on a given deferred type. Each entry
+         * stores a pointer to the speculative tree and the resolution phase in which the entry
+         * has been added.
+         */
+        class SpeculativeCache {
+
+            private Map<Symbol, List<Entry>> cache =
+                    new WeakHashMap<Symbol, List<Entry>>();
+
+            class Entry {
+                JCTree speculativeTree;
+                Resolve.MethodResolutionPhase phase;
+
+                public Entry(JCTree speculativeTree, MethodResolutionPhase phase) {
+                    this.speculativeTree = speculativeTree;
+                    this.phase = phase;
+                }
+
+                boolean matches(Resolve.MethodResolutionPhase phase) {
+                    return this.phase == phase;
+                }
+            }
+
+            /**
+             * Retrieve a speculative cache entry corresponding to given symbol
+             * and resolution phase
+             */
+            Entry get(Symbol msym, MethodResolutionPhase phase) {
+                List<Entry> entries = cache.get(msym);
+                if (entries == null) return null;
+                for (Entry e : entries) {
+                    if (e.matches(phase)) return e;
+                }
+                return null;
+            }
+
+            /**
+             * Stores a speculative cache entry corresponding to given symbol
+             * and resolution phase
+             */
+            void put(Symbol msym, JCTree speculativeTree, MethodResolutionPhase phase) {
+                List<Entry> entries = cache.get(msym);
+                if (entries == null) {
+                    entries = List.nil();
+                }
+                cache.put(msym, entries.prepend(new Entry(speculativeTree, phase)));
+            }
+        }
+
+        /**
+         * Get the type that has been computed during a speculative attribution round
+         */
+        Type speculativeType(Symbol msym, MethodResolutionPhase phase) {
+            SpeculativeCache.Entry e = speculativeCache.get(msym, phase);
+            return e != null ? e.speculativeTree.type : Type.noType;
+        }
+
+        /**
+         * Check a deferred type against a potential target-type. Depending on
+         * the current attribution mode, a normal vs. speculative attribution
+         * round is performed on the underlying AST node. There can be only one
+         * speculative round for a given target method symbol; moreover, a normal
+         * attribution round must follow one or more speculative rounds.
+         */
+        Type check(ResultInfo resultInfo) {
+            return check(resultInfo, stuckVars(tree, env, resultInfo), basicCompleter);
+        }
+
+        Type check(ResultInfo resultInfo, List<Type> stuckVars, DeferredTypeCompleter deferredTypeCompleter) {
+            DeferredAttrContext deferredAttrContext =
+                    resultInfo.checkContext.deferredAttrContext();
+            Assert.check(deferredAttrContext != emptyDeferredAttrContext);
+            if (stuckVars.nonEmpty()) {
+                deferredAttrContext.addDeferredAttrNode(this, resultInfo, stuckVars);
+                return Type.noType;
+            } else {
+                try {
+                    return deferredTypeCompleter.complete(this, resultInfo, deferredAttrContext);
+                } finally {
+                    mode = deferredAttrContext.mode;
+                }
+            }
+        }
+    }
+
+    /**
+     * A completer for deferred types. Defines an entry point for type-checking
+     * a deferred type.
+     */
+    interface DeferredTypeCompleter {
+        /**
+         * Entry point for type-checking a deferred type. Depending on the
+         * circumstances, type-checking could amount to full attribution
+         * or partial structural check (aka potential applicability).
+         */
+        Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext);
+    }
+
+    /**
+     * A basic completer for deferred types. This completer type-checks a deferred type
+     * using attribution; depending on the attribution mode, this could be either standard
+     * or speculative attribution.
+     */
+    DeferredTypeCompleter basicCompleter = new DeferredTypeCompleter() {
+        public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
+            switch (deferredAttrContext.mode) {
+                case SPECULATIVE:
+                    //Note: if a symbol is imported twice we might do two identical
+                    //speculative rounds...
+                    Assert.check(dt.mode == null || dt.mode == AttrMode.SPECULATIVE);
+                    JCTree speculativeTree = attribSpeculative(dt.tree, dt.env, resultInfo);
+                    dt.speculativeCache.put(deferredAttrContext.msym, speculativeTree, deferredAttrContext.phase);
+                    return speculativeTree.type;
+                case CHECK:
+                    Assert.check(dt.mode != null);
+                    return attr.attribTree(dt.tree, dt.env, resultInfo);
+            }
+            Assert.error();
+            return null;
+        }
+    };
+
+    DeferredTypeCompleter dummyCompleter = new DeferredTypeCompleter() {
+        public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
+            Assert.check(deferredAttrContext.mode == AttrMode.CHECK);
+            return dt.tree.type = Type.stuckType;
+        }
+    };
+
+    /**
+     * The 'mode' in which the deferred type is to be type-checked
+     */
+    public enum AttrMode {
+        /**
+         * A speculative type-checking round is used during overload resolution
+         * mainly to generate constraints on inference variables. Side-effects
+         * arising from type-checking the expression associated with the deferred
+         * type are reversed after the speculative round finishes. This means the
+         * expression tree will be left in a blank state.
+         */
+        SPECULATIVE,
+        /**
+         * This is the plain type-checking mode. Produces side-effects on the underlying AST node
+         */
+        CHECK;
+    }
+
+    /**
+     * Routine that performs speculative type-checking; the input AST node is
+     * cloned (to avoid side-effects cause by Attr) and compiler state is
+     * restored after type-checking. All diagnostics (but critical ones) are
+     * disabled during speculative type-checking.
+     */
+    JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
+        final JCTree newTree = new TreeCopier<Object>(make).copy(tree);
+        Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
+        speculativeEnv.info.scope.owner = env.info.scope.owner;
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
+                new Log.DeferredDiagnosticHandler(log, new Filter<JCDiagnostic>() {
+            public boolean accepts(final JCDiagnostic d) {
+                class PosScanner extends TreeScanner {
+                    boolean found = false;
+
+                    @Override
+                    public void scan(JCTree tree) {
+                        if (tree != null &&
+                                tree.pos() == d.getDiagnosticPosition()) {
+                            found = true;
+                        }
+                        super.scan(tree);
+                    }
+                };
+                PosScanner posScanner = new PosScanner();
+                posScanner.scan(newTree);
+                return posScanner.found;
+            }
+        });
+        try {
+            attr.attribTree(newTree, speculativeEnv, resultInfo);
+            unenterScanner.scan(newTree);
+            return newTree;
+        } finally {
+            unenterScanner.scan(newTree);
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
+        }
+    }
+    //where
+        protected TreeScanner unenterScanner = new TreeScanner() {
+            @Override
+            public void visitClassDef(JCClassDecl tree) {
+                ClassSymbol csym = tree.sym;
+                //if something went wrong during method applicability check
+                //it is possible that nested expressions inside argument expression
+                //are left unchecked - in such cases there's nothing to clean up.
+                if (csym == null) return;
+                enter.typeEnvs.remove(csym);
+                chk.compiled.remove(csym.flatname);
+                syms.classes.remove(csym.flatname);
+                super.visitClassDef(tree);
+            }
+        };
+
+    /**
+     * A deferred context is created on each method check. A deferred context is
+     * used to keep track of information associated with the method check, such as
+     * the symbol of the method being checked, the overload resolution phase,
+     * the kind of attribution mode to be applied to deferred types and so forth.
+     * As deferred types are processed (by the method check routine) stuck AST nodes
+     * are added (as new deferred attribution nodes) to this context. The complete()
+     * routine makes sure that all pending nodes are properly processed, by
+     * progressively instantiating all inference variables on which one or more
+     * deferred attribution node is stuck.
+     */
+    class DeferredAttrContext {
+
+        /** attribution mode */
+        final AttrMode mode;
+
+        /** symbol of the method being checked */
+        final Symbol msym;
+
+        /** method resolution step */
+        final Resolve.MethodResolutionPhase phase;
+
+        /** inference context */
+        final InferenceContext inferenceContext;
+
+        /** parent deferred context */
+        final DeferredAttrContext parent;
+
+        /** Warner object to report warnings */
+        final Warner warn;
+
+        /** list of deferred attribution nodes to be processed */
+        ArrayList<DeferredAttrNode> deferredAttrNodes = new ArrayList<DeferredAttrNode>();
+
+        DeferredAttrContext(AttrMode mode, Symbol msym, MethodResolutionPhase phase,
+                InferenceContext inferenceContext, DeferredAttrContext parent, Warner warn) {
+            this.mode = mode;
+            this.msym = msym;
+            this.phase = phase;
+            this.parent = parent;
+            this.warn = warn;
+            this.inferenceContext = inferenceContext;
+        }
+
+        /**
+         * Adds a node to the list of deferred attribution nodes - used by Resolve.rawCheckArgumentsApplicable
+         * Nodes added this way act as 'roots' for the out-of-order method checking process.
+         */
+        void addDeferredAttrNode(final DeferredType dt, ResultInfo resultInfo, List<Type> stuckVars) {
+            deferredAttrNodes.add(new DeferredAttrNode(dt, resultInfo, stuckVars));
+        }
+
+        /**
+         * Incrementally process all nodes, by skipping 'stuck' nodes and attributing
+         * 'unstuck' ones. If at any point no progress can be made (no 'unstuck' nodes)
+         * some inference variable might get eagerly instantiated so that all nodes
+         * can be type-checked.
+         */
+        void complete() {
+            while (!deferredAttrNodes.isEmpty()) {
+                Set<Type> stuckVars = new LinkedHashSet<Type>();
+                boolean progress = false;
+                //scan a defensive copy of the node list - this is because a deferred
+                //attribution round can add new nodes to the list
+                for (DeferredAttrNode deferredAttrNode : List.from(deferredAttrNodes)) {
+                    if (!deferredAttrNode.process(this)) {
+                        stuckVars.addAll(deferredAttrNode.stuckVars);
+                    } else {
+                        deferredAttrNodes.remove(deferredAttrNode);
+                        progress = true;
+                    }
+                }
+                if (!progress) {
+                    //remove all variables that have already been instantiated
+                    //from the list of stuck variables
+                    inferenceContext.solveAny(List.from(stuckVars), warn);
+                    inferenceContext.notifyChange();
+                }
+            }
+        }
+    }
+
+    /**
+     * Class representing a deferred attribution node. It keeps track of
+     * a deferred type, along with the expected target type information.
+     */
+    class DeferredAttrNode implements Infer.FreeTypeListener {
+
+        /** underlying deferred type */
+        DeferredType dt;
+
+        /** underlying target type information */
+        ResultInfo resultInfo;
+
+        /** list of uninferred inference variables causing this node to be stuck */
+        List<Type> stuckVars;
+
+        DeferredAttrNode(DeferredType dt, ResultInfo resultInfo, List<Type> stuckVars) {
+            this.dt = dt;
+            this.resultInfo = resultInfo;
+            this.stuckVars = stuckVars;
+            if (!stuckVars.isEmpty()) {
+                resultInfo.checkContext.inferenceContext().addFreeTypeListener(stuckVars, this);
+            }
+        }
+
+        @Override
+        public void typesInferred(InferenceContext inferenceContext) {
+            stuckVars = List.nil();
+            resultInfo = resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+        }
+
+        /**
+         * Process a deferred attribution node.
+         * Invariant: a stuck node cannot be processed.
+         */
+        @SuppressWarnings("fallthrough")
+        boolean process(DeferredAttrContext deferredAttrContext) {
+            switch (deferredAttrContext.mode) {
+                case SPECULATIVE:
+                    dt.check(resultInfo, List.<Type>nil(), new StructuralStuckChecker());
+                    return true;
+                case CHECK:
+                    if (stuckVars.nonEmpty()) {
+                        //stuck expression - see if we can propagate
+                        if (deferredAttrContext.parent != emptyDeferredAttrContext &&
+                                Type.containsAny(deferredAttrContext.parent.inferenceContext.inferencevars, List.from(stuckVars))) {
+                            deferredAttrContext.parent.deferredAttrNodes.add(this);
+                            dt.check(resultInfo, List.<Type>nil(), dummyCompleter);
+                            return true;
+                        } else {
+                            return false;
+                        }
+                    } else {
+                        dt.check(resultInfo, stuckVars, basicCompleter);
+                        return true;
+                    }
+                default:
+                    throw new AssertionError("Bad mode");
+            }
+        }
+
+        /**
+         * Structural checker for stuck expressions
+         */
+        class StructuralStuckChecker extends TreeScanner implements DeferredTypeCompleter {
+
+            ResultInfo resultInfo;
+            InferenceContext inferenceContext;
+
+            public Type complete(DeferredType dt, ResultInfo resultInfo, DeferredAttrContext deferredAttrContext) {
+                this.resultInfo = resultInfo;
+                this.inferenceContext = deferredAttrContext.inferenceContext;
+                dt.tree.accept(this);
+                dt.speculativeCache.put(deferredAttrContext.msym, stuckTree, deferredAttrContext.phase);
+                return Type.noType;
+            }
+
+            @Override
+            public void visitLambda(JCLambda tree) {
+                Check.CheckContext checkContext = resultInfo.checkContext;
+                Type pt = resultInfo.pt;
+                if (inferenceContext.inferencevars.contains(pt)) {
+                    //ok
+                    return;
+                } else {
+                    //must be a functional descriptor
+                    try {
+                        Type desc = types.findDescriptorType(pt);
+                        if (desc.getParameterTypes().length() != tree.params.length()) {
+                            checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda"));
+                        }
+                    } catch (Types.FunctionDescriptorLookupError ex) {
+                        checkContext.report(null, ex.getDiagnostic());
+                    }
+                }
+            }
+
+            @Override
+            public void visitNewClass(JCNewClass tree) {
+                //do nothing
+            }
+
+            @Override
+            public void visitApply(JCMethodInvocation tree) {
+                //do nothing
+            }
+
+            @Override
+            public void visitReference(JCMemberReference tree) {
+                Check.CheckContext checkContext = resultInfo.checkContext;
+                Type pt = resultInfo.pt;
+                if (inferenceContext.inferencevars.contains(pt)) {
+                    //ok
+                    return;
+                } else {
+                    try {
+                        types.findDescriptorType(pt);
+                    } catch (Types.FunctionDescriptorLookupError ex) {
+                        checkContext.report(null, ex.getDiagnostic());
+                    }
+                    switch (tree.sym.kind) {
+                        //note: as argtypes are erroneous types, type-errors must
+                        //have been caused by arity mismatch
+                        case Kinds.ABSENT_MTH:
+                        case Kinds.WRONG_MTH:
+                        case Kinds.WRONG_MTHS:
+                        case Kinds.STATICERR:
+                        case Kinds.MISSING_ENCL:
+                           checkContext.report(null, diags.fragment("incompatible.arg.types.in.mref"));
+                    }
+                }
+            }
+        }
+    }
+
+    /** an empty deferred attribution context - all methods throw exceptions */
+    final DeferredAttrContext emptyDeferredAttrContext;
+
+    /**
+     * Map a list of types possibly containing one or more deferred types
+     * into a list of ordinary types. Each deferred type D is mapped into a type T,
+     * where T is computed by retrieving the type that has already been
+     * computed for D during a previous deferred attribution round of the given kind.
+     */
+    class DeferredTypeMap extends Type.Mapping {
+
+        DeferredAttrContext deferredAttrContext;
+
+        protected DeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
+            super(String.format("deferredTypeMap[%s]", mode));
+            this.deferredAttrContext = new DeferredAttrContext(mode, msym, phase,
+                    infer.emptyContext, emptyDeferredAttrContext, types.noWarnings);
+        }
+
+        protected boolean validState(DeferredType dt) {
+            return dt.mode != null &&
+                    deferredAttrContext.mode.ordinal() <= dt.mode.ordinal();
+        }
+
+        @Override
+        public Type apply(Type t) {
+            if (!t.hasTag(DEFERRED)) {
+                return t.map(this);
+            } else {
+                DeferredType dt = (DeferredType)t;
+                Assert.check(validState(dt));
+                return typeOf(dt);
+            }
+        }
+
+        protected Type typeOf(DeferredType dt) {
+            switch (deferredAttrContext.mode) {
+                case CHECK:
+                    return dt.tree.type == null ? Type.noType : dt.tree.type;
+                case SPECULATIVE:
+                    return dt.speculativeType(deferredAttrContext.msym, deferredAttrContext.phase);
+            }
+            Assert.error();
+            return null;
+        }
+    }
+
+    /**
+     * Specialized recovery deferred mapping.
+     * Each deferred type D is mapped into a type T, where T is computed either by
+     * (i) retrieving the type that has already been computed for D during a previous
+     * attribution round (as before), or (ii) by synthesizing a new type R for D
+     * (the latter step is useful in a recovery scenario).
+     */
+    public class RecoveryDeferredTypeMap extends DeferredTypeMap {
+        
+        private Type pt = null;
+
+        public RecoveryDeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
+            super(mode, msym, phase != null ? phase : MethodResolutionPhase.BOX);
+        }
+
+        @Override
+        protected Type typeOf(DeferredType dt) {
+            Type owntype = super.typeOf(dt);
+            return owntype == Type.noType ?
+                        recover(dt) : owntype;
+        }
+
+        @Override
+        protected boolean validState(DeferredType dt) {
+            return true;
+        }
+
+        @Override
+        public Type apply(Type t) {
+            if (t.hasTag(METHOD) && deferredAttrContext.mode == AttrMode.CHECK) {
+                Type mtype = deferredAttrContext.msym.type;
+                mtype = mtype.hasTag(ERROR) ? ((ErrorType)mtype).getOriginalType() : null;
+                if (mtype != null && mtype.hasTag(METHOD)) {
+                    List<Type> argtypes1 = map(t.getParameterTypes(), mtype.getParameterTypes());
+                    Type restype1 = this.apply(t.getReturnType());
+                    List<Type> thrown1 = Type.map(t.getThrownTypes(), this);
+                    if (argtypes1 == t.getParameterTypes() &&
+                        restype1 == t.getReturnType() &&
+                        thrown1 == t.getThrownTypes()) return t;
+                    else return new MethodType(argtypes1, restype1, thrown1, t.tsym);
+                }
+            }
+            return super.apply(t); //To change body of generated methods, choose Tools | Templates.
+        }
+        
+        /**
+         * Synthesize a type for a deferred type that hasn't been previously
+         * reduced to an ordinary type. Functional deferred types and conditionals
+         * are mapped to themselves, in order to have a richer diagnostic
+         * representation. Remaining deferred types are attributed using
+         * a default expected type (j.l.Object).
+         */
+        private Type recover(DeferredType dt) {
+            dt.check(pt != null ? attr.new RecoveryInfo(deferredAttrContext, pt) {
+                @Override
+                protected Type check(DiagnosticPosition pos, Type found) {
+                    return chk.checkNonVoid(pos, super.check(pos, found));
+                }
+            } : attr.new RecoveryInfo(deferredAttrContext) {
+                @Override
+                protected Type check(DiagnosticPosition pos, Type found) {
+                    return chk.checkNonVoid(pos, super.check(pos, found));
+                }
+            });
+            return super.apply(dt);
+        }
+        
+        private List<Type> map(List<Type> ts, List<Type> pts) {
+            if (ts.nonEmpty()) {
+                List<Type> tail1 = map(ts.tail, pts != null ? pts.tail : null);
+                pt = pts != null && pts.nonEmpty() ? pts.head : null;
+                Type t = this.apply(ts.head);
+                pt = null;
+                if (tail1 != ts.tail || t != ts.head)
+                    return tail1.prepend(t);
+            }
+            return ts;
+        }
+    }
+
+    /**
+     * Retrieves the list of inference variables that need to be inferred before
+     * an AST node can be type-checked
+     */
+    @SuppressWarnings("fallthrough")
+    List<Type> stuckVars(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
+                if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
+            return List.nil();
+        } else {
+            return stuckVarsInternal(tree, resultInfo.pt, env, resultInfo.checkContext.inferenceContext());
+        }
+    }
+    //where
+        private List<Type> stuckVarsInternal(JCTree tree, Type pt, Env<AttrContext> env, Infer.InferenceContext inferenceContext) {
+            StuckChecker sc = new StuckChecker(pt, env, inferenceContext);
+            sc.scan(tree);
+            return List.from(sc.stuckVars);
+        }
+
+    /**
+     * A special tree scanner that would only visit portions of a given tree.
+     * The set of nodes visited by the scanner can be customized at construction-time.
+     */
+    abstract static class FilterScanner extends TreeScanner {
+
+        final Filter<JCTree> treeFilter;
+
+        FilterScanner(final Set<JCTree.Tag> validTags) {
+            this.treeFilter = new Filter<JCTree>() {
+                public boolean accepts(JCTree t) {
+                    return validTags.contains(t.getTag());
+                }
+            };
+        }
+
+        @Override
+        public void scan(JCTree tree) {
+            if (tree != null) {
+                if (treeFilter.accepts(tree)) {
+                    super.scan(tree);
+                } else {
+                    skip(tree);
+                }
+            }
+        }
+
+        /**
+         * handler that is executed when a node has been discarded
+         */
+        abstract void skip(JCTree tree);
+    }
+
+    /**
+     * A tree scanner suitable for visiting the target-type dependent nodes of
+     * a given argument expression.
+     */
+    static class PolyScanner extends FilterScanner {
+
+        PolyScanner() {
+            super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE));
+        }
+
+        @Override
+        void skip(JCTree tree) {
+            //do nothing
+        }
+    }
+
+    /**
+     * A tree scanner suitable for visiting the target-type dependent nodes nested
+     * within a lambda expression body.
+     */
+    static class LambdaReturnScanner extends FilterScanner {
+
+        LambdaReturnScanner() {
+            super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP,
+                    FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP));
+        }
+
+        @Override
+        void skip(JCTree tree) {
+            //do nothing
+        }
+    }
+
+    /**
+     * This visitor is used to check that structural expressions conform
+     * to their target - this step is required as inference could end up
+     * inferring types that make some of the nested expressions incompatible
+     * with their corresponding instantiated target
+     */
+    class StuckChecker extends PolyScanner {
+
+        Type pt;
+        Env<AttrContext> env;
+        Infer.InferenceContext inferenceContext;
+        Set<Type> stuckVars = new LinkedHashSet<Type>();
+
+        StuckChecker(Type pt, Env<AttrContext> env, Infer.InferenceContext inferenceContext) {
+            this.pt = pt;
+            this.env = env;
+            this.inferenceContext = inferenceContext;
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            if (inferenceContext.inferenceVars().contains(pt)) {
+                stuckVars.add(pt);
+            }
+            if (!types.isFunctionalInterface(pt)) {
+                return;
+            }
+            Type descType = types.findDescriptorType(pt);
+            List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
+            if (tree.paramKind == JCLambda.ParameterKind.IMPLICIT &&
+                    freeArgVars.nonEmpty()) {
+                stuckVars.addAll(freeArgVars);
+            }
+            scanLambdaBody(tree, descType.getReturnType());
+        }
+
+        @Override
+        public void visitReference(JCMemberReference tree) {
+            scan(tree.expr);
+            if (inferenceContext.inferenceVars().contains(pt)) {
+                stuckVars.add(pt);
+                return;
+            }
+            if (!types.isFunctionalInterface(pt)) {
+                return;
+            }
+
+            Type descType = types.findDescriptorType(pt);
+            List<Type> freeArgVars = inferenceContext.freeVarsIn(descType.getParameterTypes());
+            Env<AttrContext> localEnv = env.dup(tree, env.info.dup());
+            if (freeArgVars.nonEmpty()) {
+                //perform arity-based check
+                JCExpression exprTree = (JCExpression)attribSpeculative(tree.getQualifierExpression(), localEnv,
+                        attr.memberReferenceQualifierResult(tree));
+                ListBuffer<Type> argtypes = ListBuffer.lb();
+                for (Type t : descType.getParameterTypes()) {
+                    argtypes.append(Type.noType);
+                }
+                JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree);
+                mref2.expr = exprTree;
+                Pair<Symbol, ReferenceLookupHelper> lookupRes =
+                        rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type,
+                            tree.name, argtypes.toList(), null, true, rs.arityMethodCheck,
+                            inferenceContext);
+                Symbol res = tree.sym = lookupRes.fst;
+                if (res.kind >= Kinds.ERRONEOUS ||
+                        res.type.hasTag(FORALL) ||
+                        (res.flags() & Flags.VARARGS) != 0 ||
+                        (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
+                        exprTree.type.isRaw())) {
+                    stuckVars.addAll(freeArgVars);
+                }
+            }
+        }
+
+        void scanLambdaBody(JCLambda lambda, final Type pt) {
+            if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
+                stuckVars.addAll(stuckVarsInternal(lambda.body, pt, env, inferenceContext));
+            } else {
+                LambdaReturnScanner lambdaScanner = new LambdaReturnScanner() {
+                    @Override
+                    public void visitReturn(JCReturn tree) {
+                        if (tree.expr != null) {
+                            stuckVars.addAll(stuckVarsInternal(tree.expr, pt, env, inferenceContext));
+                        }
+                    }
+                };
+                lambdaScanner.scan(lambda.body);
+            }
+        }
+    }
+
+    /**
+     * Does the argument expression {@code expr} need speculative type-checking?
+     */
+    boolean isDeferred(Env<AttrContext> env, JCExpression expr) {
+        DeferredChecker dc = new DeferredChecker(env);
+        dc.scan(expr);
+        return dc.result.isPoly();
+    }
+
+    /**
+     * The kind of an argument expression. This is used by the analysis that
+     * determines as to whether speculative attribution is necessary.
+     */
+    enum ArgumentExpressionKind {
+
+        /** kind that denotes poly argument expression */
+        POLY,
+        /** kind that denotes a standalone expression */
+        NO_POLY,
+        /** kind that denotes a primitive/boxed standalone expression */
+        PRIMITIVE;
+
+        /**
+         * Does this kind denote a poly argument expression
+         */
+        public final boolean isPoly() {
+            return this == POLY;
+        }
+
+        /**
+         * Does this kind denote a primitive standalone expression
+         */
+        public final boolean isPrimitive() {
+            return this == PRIMITIVE;
+        }
+
+        /**
+         * Compute the kind of a standalone expression of a given type
+         */
+        static ArgumentExpressionKind standaloneKind(Type type, Types types) {
+            return types.unboxedTypeOrType(type).isPrimitive() ?
+                    ArgumentExpressionKind.PRIMITIVE :
+                    ArgumentExpressionKind.NO_POLY;
+        }
+
+        /**
+         * Compute the kind of a method argument expression given its symbol
+         */
+        static ArgumentExpressionKind methodKind(Symbol sym, Types types) {
+            Type restype = sym.type.getReturnType();
+            if (sym.type.hasTag(FORALL) &&
+                    restype.containsAny(((ForAll)sym.type).tvars)) {
+                return ArgumentExpressionKind.POLY;
+            } else {
+                return ArgumentExpressionKind.standaloneKind(restype, types);
+            }
+        }
+    }
+
+    /**
+     * Tree scanner used for checking as to whether an argument expression
+     * requires speculative attribution
+     */
+    final class DeferredChecker extends FilterScanner {
+
+        Env<AttrContext> env;
+        ArgumentExpressionKind result;
+
+        public DeferredChecker(Env<AttrContext> env) {
+            super(deferredCheckerTags);
+            this.env = env;
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            //a lambda is always a poly expression
+            result = ArgumentExpressionKind.POLY;
+        }
+
+        @Override
+        public void visitReference(JCMemberReference tree) {
+            //a method reference is always a poly expression
+            result = ArgumentExpressionKind.POLY;
+        }
+
+        @Override
+        public void visitTypeCast(JCTypeCast tree) {
+            //a cast is always a standalone expression
+            result = ArgumentExpressionKind.NO_POLY;
+        }
+
+        @Override
+        public void visitConditional(JCConditional tree) {
+            scan(tree.truepart);
+            if (!result.isPrimitive()) {
+                result = ArgumentExpressionKind.POLY;
+                return;
+            }
+            scan(tree.falsepart);
+            result = reduce(ArgumentExpressionKind.PRIMITIVE);
+        }
+
+        @Override
+        public void visitNewClass(JCNewClass tree) {
+            result = (TreeInfo.isDiamond(tree) || attr.findDiamonds) ?
+                    ArgumentExpressionKind.POLY : ArgumentExpressionKind.NO_POLY;
+        }
+
+        @Override
+        public void visitApply(JCMethodInvocation tree) {
+            Name name = TreeInfo.name(tree.meth);
+
+            //fast path
+            if (tree.typeargs.nonEmpty() ||
+                    name == name.table.names._this ||
+                    name == name.table.names._super) {
+                result = ArgumentExpressionKind.NO_POLY;
+                return;
+            }
+
+            //slow path
+            final JCExpression rec = tree.meth.hasTag(SELECT) ?
+                    ((JCFieldAccess)tree.meth).selected :
+                    null;
+
+            if (rec != null && !isSimpleReceiver(rec)) {
+                //give up if receiver is too complex (to cut down analysis time)
+                result = ArgumentExpressionKind.POLY;
+                return;
+            }
+
+            Type site = rec != null ?
+                    attribSpeculative(rec, env, attr.unknownTypeExprInfo).type :
+                    env.enclClass.sym.type;
+
+            while (site.hasTag(TYPEVAR)) {
+                site = site.getUpperBound();
+            }
+
+            List<Type> args = rs.dummyArgs(tree.args.length());
+
+            Resolve.LookupHelper lh = rs.new LookupHelper(name, site, args, List.<Type>nil(), MethodResolutionPhase.VARARITY) {
+                @Override
+                Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                    return rec == null ?
+                        rs.findFun(env, name, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
+                        rs.findMethod(env, site, name, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired(), false);
+                }
+                @Override
+                Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+                    return sym;
+                }
+            };
+
+            Symbol sym = rs.lookupMethod(env, tree, site.tsym, rs.arityMethodCheck, lh);
+
+            if (sym.kind == Kinds.AMBIGUOUS) {
+                Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol();
+                result = ArgumentExpressionKind.PRIMITIVE;
+                for (Symbol s : err.ambiguousSyms) {
+                    if (result.isPoly()) break;
+                    if (s.kind == Kinds.MTH) {
+                        result = reduce(ArgumentExpressionKind.methodKind(s, types));
+                    }
+                }
+            } else {
+                result = (sym.kind == Kinds.MTH) ?
+                    ArgumentExpressionKind.methodKind(sym, types) :
+                    ArgumentExpressionKind.NO_POLY;
+            }
+        }
+        //where
+            private boolean isSimpleReceiver(JCTree rec) {
+                switch (rec.getTag()) {
+                    case IDENT:
+                        return true;
+                    case SELECT:
+                        return isSimpleReceiver(((JCFieldAccess)rec).selected);
+                    case TYPEAPPLY:
+                    case TYPEARRAY:
+                        return true;
+                    case ANNOTATED_TYPE:
+                        return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType);
+                    default:
+                        return false;
+                }
+            }
+            private ArgumentExpressionKind reduce(ArgumentExpressionKind kind) {
+                switch (result) {
+                    case PRIMITIVE: return kind;
+                    case NO_POLY: return kind.isPoly() ? kind : result;
+                    case POLY: return result;
+                    default:
+                        Assert.error();
+                        return null;
+                }
+            }
+
+        @Override
+        public void visitLiteral(JCLiteral tree) {
+            Type litType = attr.litType(tree.typetag);
+            result = ArgumentExpressionKind.standaloneKind(litType, types);
+        }
+
+        @Override
+        void skip(JCTree tree) {
+            result = ArgumentExpressionKind.NO_POLY;
+        }
+    }
+    //where
+    private EnumSet<JCTree.Tag> deferredCheckerTags =
+            EnumSet.of(LAMBDA, REFERENCE, PARENS, TYPECAST,
+                    CONDEXPR, NEWCLASS, APPLY, LITERAL);
+}
diff --git a/src/share/classes/com/sun/tools/javac/comp/Enter.java b/src/share/classes/com/sun/tools/javac/comp/Enter.java
index 445e8f8..2fc9e4d 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -40,7 +40,7 @@ import com.sun.tools.javac.code.Scope.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.*;
-import com.sun.tools.javac.main.RecognizedOptions.PkgInfo;
+import com.sun.tools.javac.main.Option.PkgInfo;
 import com.sun.tools.javac.model.LazyTreeLoader;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -56,7 +56,7 @@ import static com.sun.tools.javac.code.Kinds.*;
  *  the symbol table. The pass consists of two phases, organized as
  *  follows:
  *
- *  <p>In the first phase, all class symbols are intered into their
+ *  <p>In the first phase, all class symbols are entered into their
  *  enclosing scope, descending recursively down the tree for classes
  *  which are members of other classes. The class symbols are given a
  *  MemberEnter object as completer.
@@ -84,12 +84,12 @@ import static com.sun.tools.javac.code.Kinds.*;
  *
  *  <p>Classes migrate from one phase to the next via queues:
  *
- *  <pre>
+ *  <pre>{@literal
  *  class enter -> (Enter.uncompleted)         --> member enter (1)
  *              -> (MemberEnter.halfcompleted) --> member enter (2)
  *              -> (Todo)                      --> attribute
  *                                              (only for toplevel classes)
- *  </pre>
+ *  }</pre>
  *
  *  <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.
@@ -144,7 +144,11 @@ public class Enter extends JCTree.Visitor {
 
         predefClassDef = make.ClassDef(
             make.Modifiers(PUBLIC),
-            syms.predefClass.name, null, null, null, null);
+            syms.predefClass.name,
+            List.<JCTypeParameter>nil(),
+            null,
+            List.<JCExpression>nil(),
+            List.<JCTree>nil());
         predefClassDef.sym = syms.predefClass;
         todo = Todo.instance(context);
         fileManager = context.get(JavaFileManager.class);
@@ -182,7 +186,7 @@ public class Enter extends JCTree.Visitor {
         Env<AttrContext> lintEnv = localEnv;
         while (lintEnv.info.lint == null)
             lintEnv = lintEnv.next;
-        localEnv.info.lint = lintEnv.info.lint.augment(sym.attributes_field, sym.flags());
+        localEnv.info.lint = lintEnv.info.lint.augment(sym);
         return localEnv;
     }
 
@@ -253,7 +257,7 @@ public class Enter extends JCTree.Visitor {
      *  only, and members go into the class member scope.
      */
     Scope enterScope(Env<AttrContext> env) {
-        return (env.tree.getTag() == JCTree.CLASSDEF)
+        return (env.tree.hasTag(JCTree.Tag.CLASSDEF))
             ? ((JCClassDecl) env.tree).sym.members_field
             : env.info.scope;
     }
@@ -353,7 +357,7 @@ public class Enter extends JCTree.Visitor {
                                 tree.packge);
                     if (addEnv || (tree0.packageAnnotations.isEmpty() &&
                                    tree.docComments != null &&
-                                   tree.docComments.get(tree) != null)) {
+                                   tree.docComments.hasComment(tree))) {
                         typeEnvs.put(tree.packge, topEnv);
                     }
                 }
@@ -373,6 +377,8 @@ public class Enter extends JCTree.Visitor {
         compilationUnits.put(tree.sourcefile.toUri(), tree);
         classEnter(tree.defs, topEnv);
         if (addEnv) {
+            if ((tree.packge.flags_field & APT_CLEANED) != 0)
+                todo.remove(tree.packge);
             todo.append(topEnv);
         }
         log.useSource(prev);
@@ -504,21 +510,28 @@ public class Enter extends JCTree.Visitor {
         } else if (reattr && c.completer == null) {
             new ElementScanner6<Void, Void>() {
                 @Override
-                public Void visitType(TypeElement e, Void p) {
-                    if (e instanceof ClassSymbol)
-                        ((ClassSymbol) e).flags_field |= FROMCLASS;
-                    return super.visitType(e, p);
+                public Void visitType(TypeElement te, Void p) {
+                    if (te instanceof ClassSymbol && ((ClassSymbol) te).completer == null) {
+                        ((ClassSymbol) te).flags_field |= FROMCLASS;
+                        for (Scope.Entry e = ((ClassSymbol) te).members().elems; e != null; e = e.sibling) {
+                            try {
+                                if (e.sym != null && e.sym.owner == te)
+                                    scan(e.sym);
+                            } catch (CompletionFailure cf) {}
+                        }
+                    }
+                    return null;
                 }
                 @Override
-                public Void visitExecutable(ExecutableElement e, Void p) {
-                    if (e instanceof MethodSymbol)
-                        ((MethodSymbol) e).flags_field |= FROMCLASS;
+                public Void visitExecutable(ExecutableElement ee, Void p) {
+                    if (ee instanceof MethodSymbol)
+                        ((MethodSymbol) ee).flags_field |= FROMCLASS;
                     return null;
                 }
                 @Override
-                public Void visitVariable(VariableElement e, Void p) {
-                    if (e instanceof VarSymbol)
-                        ((VarSymbol) e).flags_field |= FROMCLASS;
+                public Void visitVariable(VariableElement ve, Void p) {
+                    if (ve instanceof VarSymbol)
+                        ((VarSymbol) ve).flags_field |= FROMCLASS;
                     return null;
                 }
             }.scan(c);
diff --git a/src/share/classes/com/sun/tools/javac/comp/Env.java b/src/share/classes/com/sun/tools/javac/comp/Env.java
index c46cafe..c788055 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Env.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Env.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -116,12 +116,13 @@ public class Env<A> implements Iterable<Env<A>> {
 
     /** Return closest enclosing environment which points to a tree with given tag.
      */
-    public Env<A> enclosing(int tag) {
+    public Env<A> enclosing(JCTree.Tag tag) {
         Env<A> env1 = this;
-        while (env1 != null && env1.tree.getTag() != tag) env1 = env1.next;
+        while (env1 != null && !env1.tree.hasTag(tag)) env1 = env1.next;
         return env1;
     }
 
+    @Override
     public String toString() {
         return "Env[" + info + (outer == null ? "" : ",outer=" + outer) + "]";
     }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Flow.java b/src/share/classes/com/sun/tools/javac/comp/Flow.java
index e2214de..2a0887c 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -28,8 +28,9 @@
 package com.sun.tools.javac.comp;
 
 import java.util.HashMap;
-import java.util.Map;
-import java.util.LinkedHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.tree.*;
@@ -39,20 +40,22 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.tools.JavaFileObject;
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.BLOCK;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
-
-/** This pass implements dataflow analysis for Java programs.
- *  Liveness analysis checks that every statement is reachable.
- *  Exception analysis ensures that every checked exception that is
- *  thrown is declared or caught.  Definite assignment analysis
- *  ensures that each variable is assigned when used.  Definite
- *  unassignment analysis ensures that no final variable is assigned
- *  more than once.
+import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
+import static com.sun.tools.javac.code.TypeTag.VOID;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+/** This pass implements dataflow analysis for Java programs though
+ *  different AST visitor steps. Liveness analysis (see AliveAlanyzer) checks that
+ *  every statement is reachable. Exception analysis (see FlowAnalyzer) ensures that
+ *  every checked exception that is thrown is declared or caught.  Definite assignment analysis
+ *  (see AssignAnalyzer) ensures that each variable is assigned when used.  Definite
+ *  unassignment analysis (see AssignAnalyzer) in ensures that no final variable
+ *  is assigned more than once. Finally, local variable capture analysis (see CaptureAnalyzer)
+ *  determines that local variables accessed within the scope of an inner class/lambda
+ *  are either final or effectively-final.
  *
  *  <p>The JLS has a number of problems in the
  *  specification of these flow analysis problems. This implementation
@@ -149,7 +152,7 @@ import static com.sun.tools.javac.code.TypeTags.*;
  *  exception to this [no pun intended] is that checked exceptions that
  *  are known to be caught or declared to be caught in the enclosing
  *  method are not recorded in the queue, but instead are recorded in a
- *  global variable "Set<Type> thrown" that records the type of all
+ *  global variable "{@code Set<Type> thrown}" that records the type of all
  *  exceptions that can be thrown.
  *
  *  <p>Other minor issues the treatment of members of other classes
@@ -180,7 +183,7 @@ import static com.sun.tools.javac.code.TypeTags.*;
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-public class Flow extends TreeScanner {
+public class Flow {
     protected static final Context.Key<Flow> flowKey =
         new Context.Key<Flow>();
 
@@ -191,10 +194,14 @@ public class Flow extends TreeScanner {
     private final Check chk;
     private       TreeMaker make;
     private final Resolve rs;
+    private final JCDiagnostic.Factory diags;
+    private final Enter enter;
+    private JCClassDecl reanalyzedClass;
     private Env<AttrContext> attrEnv;
     private       Lint lint;
     private final boolean allowImprovedRethrowAnalysis;
     private final boolean allowImprovedCatchAnalysis;
+    private final boolean allowEffectivelyFinalInInnerClasses;
 
     public static Flow instance(Context context) {
         Flow instance = context.get(flowKey);
@@ -203,6 +210,74 @@ public class Flow extends TreeScanner {
         return instance;
     }
 
+    public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
+        new AliveAnalyzer().analyzeTree(env, make);
+        new AssignAnalyzer().analyzeTree(env, make);
+        new FlowAnalyzer().analyzeTree(env, make);
+        new CaptureAnalyzer().analyzeTree(env, make);
+    }
+
+    public void analyzeLambda(Env<AttrContext> env, JCLambda that, TreeMaker make, boolean speculative) {
+        Log.DiagnosticHandler diagHandler = null;
+        //we need to disable diagnostics temporarily; the problem is that if
+        //a lambda expression contains e.g. an unreachable statement, an error
+        //message will be reported and will cause compilation to skip the flow analyis
+        //step - if we suppress diagnostics, we won't stop at Attr for flow-analysis
+        //related errors, which will allow for more errors to be detected
+        if (!speculative) {
+            diagHandler = new Log.DiscardDiagnosticHandler(log);
+        }
+        try {
+            new AliveAnalyzer().analyzeTree(env, that, make);
+            new LambdaFlowAnalyzer().analyzeTree(env, that, make);
+        } finally {
+            if (!speculative) {
+                log.popDiagnosticHandler(diagHandler);
+            }
+        }
+    }
+
+    public void reanalyzeMethod (final TreeMaker make, final JCClassDecl classDef) {
+        JCClassDecl oldReanalyzedClass = reanalyzedClass;
+        try {
+            reanalyzedClass = classDef;
+            Env<AttrContext> env = enter.getEnv(classDef.sym);
+            new AliveAnalyzer().analyzeTree(env, classDef, make);
+            new AssignAnalyzer().analyzeTree(env, classDef, make);
+            new FlowAnalyzer().analyzeTree(env, classDef, make);
+            new CaptureAnalyzer().analyzeTree(env, classDef, make);
+        } finally {
+            reanalyzedClass = oldReanalyzedClass;
+        }
+    }
+
+    /**
+     * Definite assignment scan mode
+     */
+    enum FlowKind {
+        /**
+         * This is the normal DA/DU analysis mode
+         */
+        NORMAL("var.might.already.be.assigned", false),
+        /**
+         * This is the speculative DA/DU analysis mode used to speculatively
+         * derive assertions within loop bodies
+         */
+        SPECULATIVE_LOOP("var.might.be.assigned.in.loop", true);
+
+        final String errKey;
+        final boolean isFinal;
+
+        FlowKind(String errKey, boolean isFinal) {
+            this.errKey = errKey;
+            this.isFinal = isFinal;
+        }
+
+        boolean isFinal() {
+            return isFinal;
+        }
+    }
+
     protected Flow(Context context) {
         context.put(flowKey, this);
         names = Names.instance(context);
@@ -212,1357 +287,2217 @@ public class Flow extends TreeScanner {
         chk = Check.instance(context);
         lint = Lint.instance(context);
         rs = Resolve.instance(context);
+        diags = JCDiagnostic.Factory.instance(context);
+        enter = Enter.instance(context);
         Source source = Source.instance(context);
         allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
         allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
+        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses();
     }
 
-    /** A flag that indicates whether the last statement could
-     *  complete normally.
-     */
-    private boolean alive;
-
-    /** The set of definitely assigned variables.
-     */
-    Bits inits;
-
-    /** The set of definitely unassigned variables.
-     */
-    Bits uninits;
-
-    HashMap<Symbol, List<Type>> preciseRethrowTypes;
-
-    /** The set of variables that are definitely unassigned everywhere
-     *  in current try block. This variable is maintained lazily; it is
-     *  updated only when something gets removed from uninits,
-     *  typically by being assigned in reachable code.  To obtain the
-     *  correct set of variables which are definitely unassigned
-     *  anywhere in current try block, intersect uninitsTry and
-     *  uninits.
-     */
-    Bits uninitsTry;
-
-    /** When analyzing a condition, inits and uninits are null.
-     *  Instead we have:
-     */
-    Bits initsWhenTrue;
-    Bits initsWhenFalse;
-    Bits uninitsWhenTrue;
-    Bits uninitsWhenFalse;
-
-    /** A mapping from addresses to variable symbols.
-     */
-    VarSymbol[] vars;
-
-    /** The current class being defined.
-     */
-    JCClassDecl classDef;
-
-    JCClassDecl reanalyzedClass;
-
-    /** The first variable sequence number in this class definition.
-     */
-    int firstadr;
-
-    /** The next available variable sequence number.
-     */
-    int nextadr;
-
-    /** The list of possibly thrown declarable exceptions.
+    /**
+     * Utility method to reset several Bits instances.
      */
-    List<Type> thrown;
+    private void resetBits(Bits... bits) {
+        for (Bits b : bits) {
+            b.reset();
+        }
+    }
 
-    /** The list of exceptions that are either caught or declared to be
-     *  thrown.
+    /**
+     * Base visitor class for all visitors implementing dataflow analysis logic.
+     * This class define the shared logic for handling jumps (break/continue statements).
      */
-    List<Type> caught;
+    static abstract class BaseAnalyzer<P extends BaseAnalyzer.PendingExit> extends TreeScanner {
 
-    /** The list of unreferenced automatic resources.
-     */
-    Scope unrefdResources;
+        enum JumpKind {
+            BREAK(JCTree.Tag.BREAK) {
+                @Override
+                JCTree getTarget(JCTree tree) {
+                    return ((JCBreak)tree).target;
+                }
+            },
+            CONTINUE(JCTree.Tag.CONTINUE) {
+                @Override
+                JCTree getTarget(JCTree tree) {
+                    return ((JCContinue)tree).target;
+                }
+            };
 
-    /** Set when processing a loop body the second time for DU analysis. */
-    boolean loopPassTwo = false;
+            final JCTree.Tag treeTag;
 
-    /*-------------------- Environments ----------------------*/
+            private JumpKind(Tag treeTag) {
+                this.treeTag = treeTag;
+            }
 
-    /** A pending exit.  These are the statements return, break, and
-     *  continue.  In addition, exception-throwing expressions or
-     *  statements are put here when not known to be caught.  This
-     *  will typically result in an error unless it is within a
-     *  try-finally whose finally block cannot complete normally.
-     */
-    static class PendingExit {
-        JCTree tree;
-        Bits inits;
-        Bits uninits;
-        Type thrown;
-        PendingExit(JCTree tree, Bits inits, Bits uninits) {
-            this.tree = tree;
-            this.inits = inits.dup();
-            this.uninits = uninits.dup();
-        }
-        PendingExit(JCTree tree, Type thrown) {
-            this.tree = tree;
-            this.thrown = thrown;
+            abstract JCTree getTarget(JCTree tree);
         }
-    }
-
-    /** The currently pending exits that go from current inner blocks
-     *  to an enclosing block, in source order.
-     */
-    ListBuffer<PendingExit> pendingExits;
-
-    /*-------------------- Exceptions ----------------------*/
 
-    /** Complain that pending exceptions are not caught.
-     */
-    public void errorUncaught() {
-        for (PendingExit exit = pendingExits.next();
-             exit != null;
-             exit = pendingExits.next()) {
-            if (classDef != null &&
-                classDef.pos == exit.tree.pos) {
-                log.error(exit.tree.pos(),
-                        "unreported.exception.default.constructor",
-                        exit.thrown);
-            } else if (exit.tree.getTag() == JCTree.VARDEF &&
-                    ((JCVariableDecl)exit.tree).sym.isResourceVariable()) {
-                log.error(exit.tree.pos(),
-                        "unreported.exception.implicit.close",
-                        exit.thrown,
-                        ((JCVariableDecl)exit.tree).sym.name);
-            } else {
-                log.error(exit.tree.pos(),
-                        "unreported.exception.need.to.catch.or.throw",
-                        exit.thrown);
+        /** The currently pending exits that go from current inner blocks
+         *  to an enclosing block, in source order.
+         */
+        ListBuffer<P> pendingExits;
+
+        /** A pending exit.  These are the statements return, break, and
+         *  continue.  In addition, exception-throwing expressions or
+         *  statements are put here when not known to be caught.  This
+         *  will typically result in an error unless it is within a
+         *  try-finally whose finally block cannot complete normally.
+         */
+        static class PendingExit {
+            JCTree tree;
+
+            PendingExit(JCTree tree) {
+                this.tree = tree;
             }
-        }
-    }
 
-    /** Record that exception is potentially thrown and check that it
-     *  is caught.
-     */
-    void markThrown(JCTree tree, Type exc) {
-        if (exc != syms.unknownType) {
-            if (!chk.isUnchecked(tree.pos(), exc)) {
-                if (!chk.isHandled(exc, caught))
-                    pendingExits.append(new PendingExit(tree, exc));
-                    thrown = chk.incl(exc, thrown);
+            void resolveJump() {
+                //do nothing
             }
         }
-    }
-
-    /*-------------- Processing variables ----------------------*/
 
-    /** Do we need to track init/uninit state of this symbol?
-     *  I.e. is symbol either a local or a blank final variable?
-     */
-    boolean trackable(VarSymbol sym) {
-        return sym != null && sym.owner != null &&
-            (sym.owner.kind == MTH ||
-             ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL &&
-              classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)) &&
-              (reanalyzedClass == null || ((ClassSymbol)sym.owner).isEnclosedBy(reanalyzedClass.sym)));
-    }
+        abstract void markDead();
 
-    /** Initialize new trackable variable by setting its address field
-     *  to the next available sequence number and entering it under that
-     *  index into the vars array.
-     */
-    void newVar(VarSymbol sym) {
-        if (nextadr == vars.length) {
-            VarSymbol[] newvars = new VarSymbol[nextadr * 2];
-            System.arraycopy(vars, 0, newvars, 0, nextadr);
-            vars = newvars;
-        }
-        sym.adr = nextadr;
-        vars[nextadr] = sym;
-        inits.excl(nextadr);
-        uninits.incl(nextadr);
-        nextadr++;
-    }
+        /** Record an outward transfer of control. */
+        void recordExit(JCTree tree, P pe) {
+            pendingExits.append(pe);
+            markDead();
+        }
 
-    /** Record an initialization of a trackable variable.
-     */
-    void letInit(DiagnosticPosition pos, VarSymbol sym) {
-        if (sym.adr >= firstadr && trackable(sym)) {
-            if ((sym.flags() & FINAL) != 0) {
-                if ((sym.flags() & PARAMETER) != 0) {
-                    if ((sym.flags() & UNION) != 0) { //multi-catch parameter
-                        log.error(pos, "multicatch.parameter.may.not.be.assigned",
-                                  sym);
-                    }
-                    else {
-                        log.error(pos, "final.parameter.may.not.be.assigned",
-                              sym);
-                    }
-                } else if (!uninits.isMember(sym.adr)) {
-                    log.error(pos,
-                              loopPassTwo
-                              ? "var.might.be.assigned.in.loop"
-                              : "var.might.already.be.assigned",
-                              sym);
-                } else if (!inits.isMember(sym.adr)) {
-                    // reachable assignment
-                    uninits.excl(sym.adr);
-                    uninitsTry.excl(sym.adr);
+        /** Resolve all jumps of this statement. */
+        private boolean resolveJump(JCTree tree,
+                        ListBuffer<P> oldPendingExits,
+                        JumpKind jk) {
+            boolean resolved = false;
+            List<P> exits = pendingExits.toList();
+            pendingExits = oldPendingExits;
+            for (; exits.nonEmpty(); exits = exits.tail) {
+                P exit = exits.head;
+                if (exit.tree.hasTag(jk.treeTag) &&
+                        jk.getTarget(exit.tree) == tree) {
+                    exit.resolveJump();
+                    resolved = true;
                 } else {
-                    //log.rawWarning(pos, "unreachable assignment");//DEBUG
-                    uninits.excl(sym.adr);
+                    pendingExits.append(exit);
                 }
             }
-            inits.incl(sym.adr);
-        } else if ((sym.flags() & FINAL) != 0) {
-            log.error(pos, "var.might.already.be.assigned", sym);
-        }
-    }
-
-    /** If tree is either a simple name or of the form this.name or
-     *  C.this.name, and tree represents a trackable variable,
-     *  record an initialization of the variable.
-     */
-    void letInit(JCTree tree) {
-        tree = TreeInfo.skipParens(tree);
-        if (tree.getTag() == JCTree.IDENT || tree.getTag() == JCTree.SELECT) {
-            Symbol sym = TreeInfo.symbol(tree);
-            if (sym != null && sym.kind == VAR) {
-                letInit(tree.pos(), (VarSymbol)sym);
-            }
+            return resolved;
         }
-    }
 
-    /** Check that trackable variable is initialized.
-     */
-    void checkInit(DiagnosticPosition pos, VarSymbol sym) {
-        if ((sym.adr >= firstadr || (sym.owner != null && sym.owner.kind != TYP)) &&
-            trackable(sym) &&
-            inits != null && !inits.isMember(sym.adr)) {
-            log.error(pos, "var.might.not.have.been.initialized",
-                      sym);
-            inits.incl(sym.adr);
+        /** Resolve all breaks of this statement. */
+        boolean resolveContinues(JCTree tree) {
+            return resolveJump(tree, new ListBuffer<P>(), JumpKind.CONTINUE);
         }
-    }
-
-    /*-------------------- Handling jumps ----------------------*/
-
-    /** Record an outward transfer of control. */
-    void recordExit(JCTree tree) {
-        pendingExits.append(new PendingExit(tree, inits, uninits));
-        markDead();
-    }
 
-    /** Resolve all breaks of this statement. */
-    boolean resolveBreaks(JCTree tree,
-                          ListBuffer<PendingExit> oldPendingExits) {
-        boolean result = false;
-        List<PendingExit> exits = pendingExits.toList();
-        pendingExits = oldPendingExits;
-        for (; exits.nonEmpty(); exits = exits.tail) {
-            PendingExit exit = exits.head;
-            if (exit.tree.getTag() == JCTree.BREAK &&
-                ((JCBreak) exit.tree).target == tree) {
-                inits.andSet(exit.inits);
-                uninits.andSet(exit.uninits);
-                result = true;
-            } else {
-                pendingExits.append(exit);
-            }
+        /** Resolve all continues of this statement. */
+        boolean resolveBreaks(JCTree tree, ListBuffer<P> oldPendingExits) {
+            return resolveJump(tree, oldPendingExits, JumpKind.BREAK);
         }
-        return result;
-    }
 
-    /** Resolve all continues of this statement. */
-    boolean resolveContinues(JCTree tree) {
-        boolean result = false;
-        List<PendingExit> exits = pendingExits.toList();
-        pendingExits = new ListBuffer<PendingExit>();
-        for (; exits.nonEmpty(); exits = exits.tail) {
-            PendingExit exit = exits.head;
-            if (exit.tree.getTag() == JCTree.CONTINUE &&
-                ((JCContinue) exit.tree).target == tree) {
-                inits.andSet(exit.inits);
-                uninits.andSet(exit.uninits);
-                result = true;
-            } else {
-                pendingExits.append(exit);
+        @Override
+        public void scan(JCTree tree) {
+            if (tree != null && (
+                    tree.type == null ||
+                    tree.type != Type.stuckType)) {
+                super.scan(tree);
             }
         }
-        return result;
-    }
-
-    /** Record that statement is unreachable.
-     */
-    void markDead() {
-        inits.inclRange(firstadr, nextadr);
-        uninits.inclRange(firstadr, nextadr);
-        alive = false;
-    }
-
-    /** Split (duplicate) inits/uninits into WhenTrue/WhenFalse sets
-     */
-    void split(boolean setToNull) {
-        initsWhenFalse = inits.dup();
-        uninitsWhenFalse = uninits.dup();
-        initsWhenTrue = inits;
-        uninitsWhenTrue = uninits;
-        if (setToNull)
-            inits = uninits = null;
     }
 
-    /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
+    /**
+     * This pass implements the first step of the dataflow analysis, namely
+     * the liveness analysis check. This checks that every statement is reachable.
+     * The output of this analysis pass are used by other analyzers. This analyzer
+     * sets the 'finallyCanCompleteNormally' field in the JCTry class.
      */
-    void merge() {
-        inits = initsWhenFalse.andSet(initsWhenTrue);
-        uninits = uninitsWhenFalse.andSet(uninitsWhenTrue);
-    }
+    class AliveAnalyzer extends BaseAnalyzer<BaseAnalyzer.PendingExit> {
 
-/* ************************************************************************
- * Visitor methods for statements and definitions
- *************************************************************************/
+        /** A flag that indicates whether the last statement could
+         *  complete normally.
+         */
+        private boolean alive;
 
-    /** Analyze a definition.
-     */
-    void scanDef(JCTree tree) {
-        scanStat(tree);
-        if (tree != null && tree.getTag() == JCTree.BLOCK && !alive) {
-            log.error(tree.pos(),
-                      "initializer.must.be.able.to.complete.normally");
+        @Override
+        void markDead() {
+            alive = false;
         }
-    }
 
-    /** Analyze a statement. Check that statement is reachable.
-     */
-    void scanStat(JCTree tree) {
-        if (!alive && tree != null) {
-            log.error(tree.pos(), "unreachable.stmt");
-            if (tree.getTag() != JCTree.SKIP) alive = true;
+    /*************************************************************************
+     * Visitor methods for statements and definitions
+     *************************************************************************/
+
+        /** Analyze a definition.
+         */
+        void scanDef(JCTree tree) {
+            scanStat(tree);
+            if (tree != null && tree.hasTag(JCTree.Tag.BLOCK) && !alive) {
+                log.error(tree.pos(),
+                          "initializer.must.be.able.to.complete.normally");
+            }
         }
-        scan(tree);
-    }
 
-    /** Analyze list of statements.
-     */
-    void scanStats(List<? extends JCStatement> trees) {
-        if (trees != null)
-            for (List<? extends JCStatement> l = trees; l.nonEmpty(); l = l.tail)
-                scanStat(l.head);
-    }
-
-    /** Analyze an expression. Make sure to set (un)inits rather than
-     *  (un)initsWhenTrue(WhenFalse) on exit.
-     */
-    void scanExpr(JCTree tree) {
-        if (tree != null) {
+        /** Analyze a statement. Check that statement is reachable.
+         */
+        void scanStat(JCTree tree) {
+            if (!alive && tree != null) {
+                log.error(tree.pos(), "unreachable.stmt");
+                if (!tree.hasTag(SKIP)) alive = true;
+            }
             scan(tree);
-            if (inits == null) merge();
         }
-    }
-
-    /** Analyze a list of expressions.
-     */
-    void scanExprs(List<? extends JCExpression> trees) {
-        if (trees != null)
-            for (List<? extends JCExpression> l = trees; l.nonEmpty(); l = l.tail)
-                scanExpr(l.head);
-    }
 
-    /** Analyze a condition. Make sure to set (un)initsWhenTrue(WhenFalse)
-     *  rather than (un)inits on exit.
-     */
-    void scanCond(JCTree tree) {
-        if (tree.type != null && tree.type.isFalse()) {
-            if (inits == null) merge();
-            initsWhenTrue = inits.dup();
-            initsWhenTrue.inclRange(firstadr, nextadr);
-            uninitsWhenTrue = uninits.dup();
-            uninitsWhenTrue.inclRange(firstadr, nextadr);
-            initsWhenFalse = inits;
-            uninitsWhenFalse = uninits;
-        } else if (tree.type != null && tree.type.isTrue()) {
-            if (inits == null) merge();
-            initsWhenFalse = inits.dup();
-            initsWhenFalse.inclRange(firstadr, nextadr);
-            uninitsWhenFalse = uninits.dup();
-            uninitsWhenFalse.inclRange(firstadr, nextadr);
-            initsWhenTrue = inits;
-            uninitsWhenTrue = uninits;
-        } else {
-            scan(tree);
-            if (inits != null)
-                split(tree.type != syms.unknownType);
+        /** Analyze list of statements.
+         */
+        void scanStats(List<? extends JCStatement> trees) {
+            if (trees != null)
+                for (List<? extends JCStatement> l = trees; l.nonEmpty(); l = l.tail)
+                    scanStat(l.head);
         }
-        if (tree.type != syms.unknownType)
-            inits = uninits = null;
-    }
 
-    /* ------------ Visitor methods for various sorts of trees -------------*/
+        /* ------------ Visitor methods for various sorts of trees -------------*/
 
-    public void visitClassDef(JCClassDecl tree) {
-        JCClassDecl classDefPrev = classDef;
-        List<Type> thrownPrev = thrown;
-        List<Type> caughtPrev = caught;
-        boolean alivePrev = alive;
-        int firstadrPrev = firstadr;
-        int nextadrPrev = nextadr;
-        ListBuffer<PendingExit> pendingExitsPrev = pendingExits;
-        Lint lintPrev = lint;
-
-        pendingExits = new ListBuffer<PendingExit>();
-        if (tree.name != names.empty) {
-            caught = List.nil();
-            firstadr = nextadr;
-        }
-        classDef = tree;
-        thrown = List.nil();
-        if (tree.sym != null)
-            lint = lint.augment(tree.sym.attributes_field);
-
-        try {
-            // define all the static fields
-            for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                if (l.head.getTag() == JCTree.VARDEF) {
-                    JCVariableDecl def = (JCVariableDecl)l.head;
-                    if ((def.mods.flags & STATIC) != 0) {
-                        VarSymbol sym = def.sym;
-                        if (trackable(sym))
-                            newVar(sym);
-                    }
-                }
-            }
+        public void visitClassDef(JCClassDecl tree) {
+            if (tree.sym == null) return;
+            boolean alivePrev = alive;
+            ListBuffer<PendingExit> pendingExitsPrev = pendingExits;
+            Lint lintPrev = lint;
 
-            // process all the static initializers
-            for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                if (l.head.getTag() != JCTree.METHODDEF &&
-                    (TreeInfo.flags(l.head) & STATIC) != 0) {
-                    scanDef(l.head);
-                    errorUncaught();
-                }
-            }
+            pendingExits = new ListBuffer<PendingExit>();
+            lint = lint.augment(tree.sym);
 
-            // add intersection of all thrown clauses of initial constructors
-            // to set of caught exceptions, unless class is anonymous.
-            if (tree.name != names.empty) {
-                boolean firstConstructor = true;
+            try {
+                // process all the static initializers
                 for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                    if (TreeInfo.isInitialConstructor(l.head)) {
-                        MethodSymbol sym = ((JCMethodDecl) l.head).sym;
-                        List<Type> mthrown = sym != null
-                                ? sym.type.getThrownTypes() : List.<Type>nil();
-                        if (firstConstructor) {
-                            caught = mthrown;
-                            firstConstructor = false;
-                        } else {
-                            caught = chk.intersect(mthrown, caught);
-                        }
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) != 0) {
+                        scanDef(l.head);
+                        if (pendingExits.nonEmpty()) pendingExits.clear();
                     }
                 }
-            }
 
-            // define all the instance fields
-            for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                if (l.head.getTag() == JCTree.VARDEF) {
-                    JCVariableDecl def = (JCVariableDecl)l.head;
-                    if ((def.mods.flags & STATIC) == 0) {
-                        VarSymbol sym = def.sym;
-                        if (trackable(sym))
-                            newVar(sym);
+                // process all the instance initializers
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) == 0) {
+                        scanDef(l.head);
+                        if (pendingExits.nonEmpty()) pendingExits.clear();
                     }
                 }
-            }
-
-            // process all the instance initializers
-            for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                if (l.head.getTag() != JCTree.METHODDEF &&
-                    (TreeInfo.flags(l.head) & STATIC) == 0) {
-                    scanDef(l.head);
-                    errorUncaught();
-                }
-            }
 
-            // in an anonymous class, add the set of thrown exceptions to
-            // the throws clause of the synthetic constructor and propagate
-            // outwards.
-            // Changing the throws clause on the fly is okay here because
-            // the anonymous constructor can't be invoked anywhere else,
-            // and its type hasn't been cached.
-            if (tree.name == names.empty && thrownPrev != null) {
+                // process all the methods
                 for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                    if (TreeInfo.isInitialConstructor(l.head)) {
-                        JCMethodDecl mdef = (JCMethodDecl)l.head;
-                        mdef.thrown = make.Types(thrown);
-                        mdef.sym.type = types.createMethodTypeWithThrown(mdef.sym.type, thrown);
+                    if (l.head.hasTag(METHODDEF)) {
+                        scan(l.head);
                     }
                 }
-                thrownPrev = chk.union(thrown, thrownPrev);
+            } finally {
+                pendingExits = pendingExitsPrev;
+                alive = alivePrev;
+                lint = lintPrev;
             }
+        }
 
-            // process all the methods
-            for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
-                if (l.head.getTag() == JCTree.METHODDEF) {
-                    scan(l.head);
-                    errorUncaught();
-                }
-            }
+        public void visitMethodDef(JCMethodDecl tree) {
+            if (tree.body == null || tree.sym == null) return;
+            Lint lintPrev = lint;
 
-            thrown = thrownPrev;
-        } finally {
-            pendingExits = pendingExitsPrev;
-            alive = alivePrev;
-            nextadr = nextadrPrev;
-            firstadr = firstadrPrev;
-            caught = caughtPrev;
-            classDef = classDefPrev;
-            lint = lintPrev;
-        }
-    }
+            lint = lint.augment(tree.sym);
 
-    public void visitMethodDef(JCMethodDecl tree) {
-        if (tree.body == null) return;
-        if (tree.sym == null) {
-            String methodName = String.valueOf(tree.name);
-            int methodStart = tree.getStartPosition();
+            Assert.check(pendingExits.isEmpty());
 
-            if (classDef != null && classDef.sym != null) {
-                JavaFileObject file = classDef.sym.sourcefile != null ? classDef.sym.sourcefile : classDef.sym.classfile;
-                String source = file != null ? file.toUri().toASCIIString() : "<unknown>";
-                int classStart = classDef.getStartPosition();
-                String className = String.valueOf(classDef.sym.flatname);
+            try {
+                alive = true;
+                scanStat(tree.body);
 
-                Logger.getLogger(Flow.class.getName()).log(Level.WARNING, "Flow.visitMethodDef has a null tree.sym. Method name: {0}, offset: {1}, enclosing class name: {2}, offset: {3}, source file: {4}", new Object[] {methodName, methodStart, className, classStart, source}); //NOI18N
-            } else {
-                String className = classDef != null ? String.valueOf(classDef.name) : "<unknown>";
+                if (alive && tree.sym.type.getReturnType() != null && !tree.sym.type.getReturnType().hasTag(VOID))
+                    log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
 
-                Logger.getLogger(Flow.class.getName()).log(Level.WARNING, "Flow.visitMethodDef has a null tree.sym. Method name: {0}, offset: {1}, enclosing class name: {2}", new Object[] {methodName, methodStart, className}); //NOI18N
+                pendingExits = new ListBuffer<PendingExit>();
+            } finally {
+                lint = lintPrev;
             }
-            Logger.getLogger(Flow.class.getName()).log(Level.FINER, "Flow.visitMethodDef has a null tree.sym. Tree: [{0}] Enclosing class: [{1}]", new Object[] {tree, classDef}); //NOI18N
-            return;
         }
-        List<Type> caughtPrev = caught;
-        List<Type> mthrown = tree.sym.type.getThrownTypes();
-        Bits initsPrev = inits.dup();
-        Bits uninitsPrev = uninits.dup();
-        int nextadrPrev = nextadr;
-        int firstadrPrev = firstadr;
-        Lint lintPrev = lint;
-
-        lint = lint.augment(tree.sym.attributes_field);
 
-        Assert.check(pendingExits.isEmpty());
-
-        try {
-            boolean isInitialConstructor =
-                TreeInfo.isInitialConstructor(tree);
-
-            if (!isInitialConstructor)
-                firstadr = nextadr;
-            for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
-                JCVariableDecl def = l.head;
-                scan(def);
-                inits.incl(def.sym.adr);
-                uninits.excl(def.sym.adr);
-            }
-            if (isInitialConstructor)
-                caught = chk.union(caught, mthrown);
-            else if ((tree.sym.flags() & (BLOCK | STATIC)) != BLOCK)
-                caught = mthrown;
-            // else we are in an instance initializer block;
-            // leave caught unchanged.
-
-            alive = true;
-            scanStat(tree.body);
-
-            if (alive && tree.sym.type.getReturnType() != null && tree.sym.type.getReturnType().tag != VOID)
-                log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
-
-            if (isInitialConstructor) {
-                for (int i = firstadr; i < nextadr; i++)
-                    if (vars[i].owner == classDef.sym)
-                        checkInit(TreeInfo.diagEndPos(tree.body), vars[i]);
-            }
-            List<PendingExit> exits = pendingExits.toList();
-            pendingExits = new ListBuffer<PendingExit>();
-            while (exits.nonEmpty()) {
-                PendingExit exit = exits.head;
-                exits = exits.tail;
-                if (exit.thrown == null) {
-                    if (isInitialConstructor && exit.tree.getTag() == JCTree.RETURN) {
-                        inits = exit.inits;
-                        for (int i = firstadr; i < nextadr; i++)
-                            checkInit(exit.tree.pos(), vars[i]);
-                    }
-                } else {
-                    // uncaught throws will be reported later
-                    pendingExits.append(exit);
+        public void visitVarDef(JCVariableDecl tree) {
+            if (tree.init != null && tree.sym != null) {
+                Lint lintPrev = lint;
+                lint = lint.augment(tree.sym);
+                try{
+                    scan(tree.init);
+                } finally {
+                    lint = lintPrev;
                 }
             }
-        } finally {
-            inits = initsPrev;
-            uninits = uninitsPrev;
-            nextadr = nextadrPrev;
-            firstadr = firstadrPrev;
-            caught = caughtPrev;
-            lint = lintPrev;
         }
-    }
 
-    public void visitVarDef(JCVariableDecl tree) {
-        if (tree.sym == null) {
-            if (tree.type == null)
-                tree.type = syms.unknownType;
-            tree.sym = new VarSymbol(0, tree.name, tree.type, syms.noSymbol);
-            tree.sym.adr = 0;
-            String variableName = String.valueOf(tree.name);
-            int variableStart = tree.getStartPosition();
-
-            if (classDef != null && classDef.sym != null) {
-                JavaFileObject file = classDef.sym.sourcefile != null ? classDef.sym.sourcefile : classDef.sym.classfile;
-                String source = file != null ? file.toUri().toASCIIString() : "<unknown>";
-                int classStart = classDef.getStartPosition();
-                String className = String.valueOf(classDef.sym.flatname);
-
-                Logger.getLogger(Flow.class.getName()).log(Level.WARNING, "Flow.visitVarDef has a null tree.sym. Variable name: {0}, offset: {1}, enclosing class name: {2}, offset: {3}, source file: {4}", new Object[] {variableName, variableStart, className, classStart, source}); //NOI18N
-            } else {
-                String className = classDef != null ? String.valueOf(classDef.name) : "<unknown>";
-
-                Logger.getLogger(Flow.class.getName()).log(Level.WARNING, "Flow.visitVarDef has a null tree.sym. Variable name: {0}, offset: {1}, enclosing class name: {2}", new Object[] {variableName, variableStart, className}); //NOI18N
-            }
-            Logger.getLogger(Flow.class.getName()).log(Level.FINER, "Flow.visitVarDef has a null tree.sym. Tree: [{0}] Enclosing class: [{1}]", new Object[] {tree, classDef}); //NOI18N
-            return;
-        }
-        boolean track = trackable(tree.sym);
-        if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
-        if (tree.init != null) {
-            Lint lintPrev = lint;
-            lint = lint.augment(tree.sym.attributes_field);
-            try{
-                scanExpr(tree.init);
-                if (track) letInit(tree.pos(), tree.sym);
-            } finally {
-                lint = lintPrev;
-            }
+        public void visitBlock(JCBlock tree) {
+            scanStats(tree.stats);
         }
-    }
-
-    public void visitBlock(JCBlock tree) {
-        int nextadrPrev = nextadr;
-        scanStats(tree.stats);
-        nextadr = nextadrPrev;
-    }
 
-    public void visitDoLoop(JCDoWhileLoop tree) {
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        boolean prevLoopPassTwo = loopPassTwo;
-        pendingExits = new ListBuffer<PendingExit>();
-        int prevErrors = log.nerrors;
-        do {
-            Bits uninitsEntry = uninits.dup();
-            uninitsEntry.excludeFrom(nextadr);
+        public void visitDoLoop(JCDoWhileLoop tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<PendingExit>();
             scanStat(tree.body);
             alive |= resolveContinues(tree);
-            scanCond(tree.cond);
-            if (log.nerrors !=  prevErrors ||
-                loopPassTwo ||
-                uninitsEntry.dup().diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
-                break;
-            inits = initsWhenTrue;
-            uninits = uninitsEntry.andSet(uninitsWhenTrue);
-            loopPassTwo = true;
-            alive = true;
-        } while (true);
-        loopPassTwo = prevLoopPassTwo;
-        inits = initsWhenFalse;
-        uninits = uninitsWhenFalse;
-        if (tree.cond.type != null)
-            alive = alive && !tree.cond.type.isTrue();
-        alive |= resolveBreaks(tree, prevPendingExits);
-    }
+            scan(tree.cond);
+            if (tree.cond.type != null)
+                alive = alive && !tree.cond.type.isTrue();
+            alive |= resolveBreaks(tree, prevPendingExits);
+        }
 
-    public void visitWhileLoop(JCWhileLoop tree) {
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        boolean prevLoopPassTwo = loopPassTwo;
-        Bits initsCond;
-        Bits uninitsCond;
-        pendingExits = new ListBuffer<PendingExit>();
-        int prevErrors = log.nerrors;
-        do {
-            Bits uninitsEntry = uninits.dup();
-            uninitsEntry.excludeFrom(nextadr);
-            scanCond(tree.cond);
-            initsCond = initsWhenFalse;
-            uninitsCond = uninitsWhenFalse;
-            inits = initsWhenTrue;
-            uninits = uninitsWhenTrue;
+        public void visitWhileLoop(JCWhileLoop tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<PendingExit>();
+            scan(tree.cond);
             if (tree.cond.type != null)
                 alive = !tree.cond.type.isFalse();
             scanStat(tree.body);
             alive |= resolveContinues(tree);
-            if (log.nerrors != prevErrors ||
-                loopPassTwo ||
-                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
-                break;
-            uninits = uninitsEntry.andSet(uninits);
-            loopPassTwo = true;
-            alive = true;
-        } while (true);
-        loopPassTwo = prevLoopPassTwo;
-        inits = initsCond;
-        uninits = uninitsCond;
-        alive = resolveBreaks(tree, prevPendingExits) ||
-            tree.cond.type != null && !tree.cond.type.isTrue();
-    }
+            alive = resolveBreaks(tree, prevPendingExits) ||
+                tree.cond.type != null && !tree.cond.type.isTrue();
+        }
 
-    public void visitForLoop(JCForLoop tree) {
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        boolean prevLoopPassTwo = loopPassTwo;
-        int nextadrPrev = nextadr;
-        scanStats(tree.init);
-        Bits initsCond;
-        Bits uninitsCond;
-        pendingExits = new ListBuffer<PendingExit>();
-        int prevErrors = log.nerrors;
-        do {
-            Bits uninitsEntry = uninits.dup();
-            uninitsEntry.excludeFrom(nextadr);
+        public void visitForLoop(JCForLoop tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            scanStats(tree.init);
+            pendingExits = new ListBuffer<PendingExit>();
             if (tree.cond != null && tree.cond.type != null) {
-                scanCond(tree.cond);
-                initsCond = initsWhenFalse;
-                uninitsCond = uninitsWhenFalse;
-                inits = initsWhenTrue;
-                uninits = uninitsWhenTrue;
+                scan(tree.cond);
                 alive = !tree.cond.type.isFalse();
             } else {
-                initsCond = inits.dup();
-                initsCond.inclRange(firstadr, nextadr);
-                uninitsCond = uninits.dup();
-                uninitsCond.inclRange(firstadr, nextadr);
                 alive = true;
             }
             scanStat(tree.body);
             alive |= resolveContinues(tree);
             scan(tree.step);
-            if (log.nerrors != prevErrors ||
-                loopPassTwo ||
-                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
-                break;
-            uninits = uninitsEntry.andSet(uninits);
-            loopPassTwo = true;
-            alive = true;
-        } while (true);
-        loopPassTwo = prevLoopPassTwo;
-        inits = initsCond;
-        uninits = uninitsCond;
-        alive = resolveBreaks(tree, prevPendingExits) ||
-            tree.cond != null && tree.cond.type != null && !tree.cond.type.isTrue();
-        nextadr = nextadrPrev;
-    }
+            alive = resolveBreaks(tree, prevPendingExits) ||
+                tree.cond != null && tree.cond.type != null && !tree.cond.type.isTrue();
+        }
 
-    public void visitForeachLoop(JCEnhancedForLoop tree) {
-        visitVarDef(tree.var);
-
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        boolean prevLoopPassTwo = loopPassTwo;
-        int nextadrPrev = nextadr;
-        Bits initsExpr = inits;
-        Bits uninitsExpr = uninits;
-        scan(tree.expr);
-        if (inits == null) {
-            inits = initsExpr;
-            uninits = uninitsExpr;
-        }
-        Bits initsStart = inits.dup();
-        Bits uninitsStart = uninits.dup();
-
-        if (tree.var.sym != null)
-            letInit(tree.pos(), tree.var.sym);
-        pendingExits = new ListBuffer<PendingExit>();
-        int prevErrors = log.nerrors;
-        do {
-            Bits uninitsEntry = uninits.dup();
-            uninitsEntry.excludeFrom(nextadr);
+        public void visitForeachLoop(JCEnhancedForLoop tree) {
+            visitVarDef(tree.var);
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            scan(tree.expr);
+            pendingExits = new ListBuffer<PendingExit>();
             scanStat(tree.body);
             alive |= resolveContinues(tree);
-            if (log.nerrors != prevErrors ||
-                loopPassTwo ||
-                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
-                break;
-            uninits = uninitsEntry.andSet(uninits);
-            loopPassTwo = true;
-            alive = true;
-        } while (true);
-        loopPassTwo = prevLoopPassTwo;
-        inits = initsStart;
-        uninits = uninitsStart.andSet(uninits);
-        resolveBreaks(tree, prevPendingExits);
-        alive = true;
-        nextadr = nextadrPrev;
-    }
-
-    public void visitLabelled(JCLabeledStatement tree) {
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        pendingExits = new ListBuffer<PendingExit>();
-        scanStat(tree.body);
-        alive |= resolveBreaks(tree, prevPendingExits);
-    }
-
-    public void visitSwitch(JCSwitch tree) {
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        pendingExits = new ListBuffer<PendingExit>();
-        int nextadrPrev = nextadr;
-        scanExpr(tree.selector);
-        Bits initsSwitch = inits;
-        Bits uninitsSwitch = uninits.dup();
-        boolean hasDefault = false;
-        for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
-            alive = true;
-            inits = initsSwitch.dup();
-            uninits = uninits.andSet(uninitsSwitch);
-            JCCase c = l.head;
-            if (c.pat == null)
-                hasDefault = true;
-            else
-                scanExpr(c.pat);
-            scanStats(c.stats);
-            addVars(c.stats, initsSwitch, uninitsSwitch);
-            // Warn about fall-through if lint switch fallthrough enabled.
-            if (!loopPassTwo &&
-                alive &&
-                lint.isEnabled(Lint.LintCategory.FALLTHROUGH) &&
-                c.stats.nonEmpty() && l.tail.nonEmpty())
-                log.warning(Lint.LintCategory.FALLTHROUGH,
-                            l.tail.head.pos(),
-                            "possible.fall-through.into.case");
-        }
-        if (!hasDefault) {
-            inits.andSet(initsSwitch);
+            resolveBreaks(tree, prevPendingExits);
             alive = true;
         }
-        alive |= resolveBreaks(tree, prevPendingExits);
-        nextadr = nextadrPrev;
-    }
-    // where
-        /** Add any variables defined in stats to inits and uninits. */
-        private static void addVars(List<JCStatement> stats, Bits inits,
-                                    Bits uninits) {
-            for (;stats.nonEmpty(); stats = stats.tail) {
-                JCTree stat = stats.head;
-                if (stat.getTag() == JCTree.VARDEF) {
-                    int adr = ((JCVariableDecl) stat).sym.adr;
-                    inits.excl(adr);
-                    uninits.incl(adr);
-                }
-            }
+
+        public void visitLabelled(JCLabeledStatement tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<PendingExit>();
+            scanStat(tree.body);
+            alive |= resolveBreaks(tree, prevPendingExits);
         }
 
-    public void visitTry(JCTry tree) {
-        List<Type> caughtPrev = caught;
-        List<Type> thrownPrev = thrown;
-        thrown = List.nil();
-        for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
-            List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
-                    ((JCTypeUnion)l.head.param.vartype).alternatives :
-                    List.of(l.head.param.vartype);
-            for (JCExpression ct : subClauses) {
-                caught = chk.incl(ct.type, caught);
-            }
-        }
-        ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
-        Bits uninitsTryPrev = uninitsTry;
-        ListBuffer<PendingExit> prevPendingExits = pendingExits;
-        pendingExits = new ListBuffer<PendingExit>();
-        Bits initsTry = inits.dup();
-        uninitsTry = uninits.dup();
-        for (JCTree resource : tree.resources) {
-            if (resource instanceof JCVariableDecl) {
-                JCVariableDecl vdecl = (JCVariableDecl) resource;
-                visitVarDef(vdecl);
-                unrefdResources.enter(vdecl.sym);
-                resourceVarDecls.append(vdecl);
-            } else if (resource instanceof JCExpression) {
-                scanExpr((JCExpression) resource);
-            } else {
-                throw new AssertionError(tree);  // parser error
-            }
-        }
-        for (JCTree resource : tree.resources) {
-            List<Type> closeableSupertypes = resource.type.isCompound() ?
-                types.interfaces(resource.type).prepend(types.supertype(resource.type)) :
-                List.of(resource.type);
-            for (Type sup : closeableSupertypes) {
-                if (types.asSuper(sup, syms.autoCloseableType.tsym) != null) {
-                    Symbol closeMethod = rs.resolveQualifiedMethod(tree,
-                            attrEnv,
-                            sup,
-                            names.close,
-                            List.<Type>nil(),
-                            List.<Type>nil());
-                    if (closeMethod.kind == MTH) {
-                        for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) {
-                            markThrown(resource, t);
-                        }
-                    }
-                }
+        public void visitSwitch(JCSwitch tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<PendingExit>();
+            scan(tree.selector);
+            boolean hasDefault = false;
+            for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
+                alive = true;
+                JCCase c = l.head;
+                if (c.pat == null)
+                    hasDefault = true;
+                else
+                    scan(c.pat);
+                scanStats(c.stats);
+                // Warn about fall-through if lint switch fallthrough enabled.
+                if (alive &&
+                    lint.isEnabled(Lint.LintCategory.FALLTHROUGH) &&
+                    c.stats.nonEmpty() && l.tail.nonEmpty())
+                    log.warning(Lint.LintCategory.FALLTHROUGH,
+                                l.tail.head.pos(),
+                                "possible.fall-through.into.case");
             }
-        }
-        scanStat(tree.body);
-        List<Type> thrownInTry = allowImprovedCatchAnalysis ?
-            chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) :
-            thrown;
-        thrown = thrownPrev;
-        caught = caughtPrev;
-        boolean aliveEnd = alive;
-        uninitsTry.andSet(uninits);
-        Bits initsEnd = inits;
-        Bits uninitsEnd = uninits;
-        int nextadrCatch = nextadr;
-
-        if (!resourceVarDecls.isEmpty() &&
-                lint.isEnabled(Lint.LintCategory.TRY)) {
-            for (JCVariableDecl resVar : resourceVarDecls) {
-                if (unrefdResources.includes(resVar.sym)) {
-                    log.warning(Lint.LintCategory.TRY, resVar.pos(),
-                                "try.resource.not.referenced", resVar.sym);
-                    unrefdResources.remove(resVar.sym);
-                }
+            if (!hasDefault) {
+                alive = true;
             }
+            alive |= resolveBreaks(tree, prevPendingExits);
         }
 
-        List<Type> caughtInTry = List.nil();
-        for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
-            alive = true;
-            JCVariableDecl param = l.head.param;
-            List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
-                    ((JCTypeUnion)l.head.param.vartype).alternatives :
-                    List.of(l.head.param.vartype);
-            List<Type> ctypes = List.nil();
-            List<Type> rethrownTypes = chk.diff(thrownInTry, caughtInTry);
-            for (JCExpression ct : subClauses) {
-                Type exc = ct.type;
-                if (exc != null && exc != syms.unknownType) {
-                    ctypes = ctypes.append(exc);
-                    if (types.isSameType(exc, syms.objectType))
-                        continue;
-                    checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry);
-                    caughtInTry = chk.incl(exc, caughtInTry);
+        public void visitTry(JCTry tree) {
+            ListBuffer<PendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<PendingExit>();
+            for (JCTree resource : tree.resources) {
+                if (resource instanceof JCVariableDecl) {
+                    JCVariableDecl vdecl = (JCVariableDecl) resource;
+                    visitVarDef(vdecl);
+                } else if (resource instanceof JCExpression) {
+                    scan((JCExpression) resource);
+                } else {
+                    throw new AssertionError(tree);  // parser error
                 }
             }
-            inits = initsTry.dup();
-            uninits = uninitsTry.dup();
-            scan(param);
-            inits.incl(param.sym.adr);
-            uninits.excl(param.sym.adr);
-            preciseRethrowTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes));
-            scanStat(l.head.body);
-            initsEnd.andSet(inits);
-            uninitsEnd.andSet(uninits);
-            nextadr = nextadrCatch;
-            preciseRethrowTypes.remove(param.sym);
-            aliveEnd |= alive;
-        }
-        if (tree.finalizer != null) {
-            List<Type> savedThrown = thrown;
-            thrown = List.nil();
-            inits = initsTry.dup();
-            uninits = uninitsTry.dup();
-            ListBuffer<PendingExit> exits = pendingExits;
-            pendingExits = prevPendingExits;
-            alive = true;
-            scanStat(tree.finalizer);
-            if (!alive) {
-                // discard exits and exceptions from try and finally
-                thrown = chk.union(thrown, thrownPrev);
-                if (!loopPassTwo &&
-                    lint.isEnabled(Lint.LintCategory.FINALLY)) {
-                    log.warning(Lint.LintCategory.FINALLY,
-                            TreeInfo.diagEndPos(tree.finalizer),
-                            "finally.cannot.complete");
-                }
-            } else {
-                thrown = chk.union(thrown, chk.diff(thrownInTry, caughtInTry));
-                thrown = chk.union(thrown, savedThrown);
-                uninits.andSet(uninitsEnd);
-                // FIX: this doesn't preserve source order of exits in catch
-                // versus finally!
-                while (exits.nonEmpty()) {
-                    PendingExit exit = exits.next();
-                    if (exit.inits != null) {
-                        exit.inits.orSet(inits);
-                        exit.uninits.andSet(uninits);
+
+            scanStat(tree.body);
+            boolean aliveEnd = alive;
+
+            for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
+                alive = true;
+                JCVariableDecl param = l.head.param;
+                scan(param);
+                scanStat(l.head.body);
+                aliveEnd |= alive;
+            }
+            if (tree.finalizer != null) {
+                ListBuffer<PendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                alive = true;
+                scanStat(tree.finalizer);
+                tree.finallyCanCompleteNormally = alive;
+                if (!alive) {
+                    if (lint.isEnabled(Lint.LintCategory.FINALLY)) {
+                        log.warning(Lint.LintCategory.FINALLY,
+                                TreeInfo.diagEndPos(tree.finalizer),
+                                "finally.cannot.complete");
                     }
-                    pendingExits.append(exit);
+                } else {
+                    while (exits.nonEmpty()) {
+                        pendingExits.append(exits.next());
+                    }
+                    alive = aliveEnd;
                 }
-                inits.orSet(initsEnd);
+            } else {
                 alive = aliveEnd;
+                ListBuffer<PendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                while (exits.nonEmpty()) pendingExits.append(exits.next());
             }
-        } else {
-            thrown = chk.union(thrown, chk.diff(thrownInTry, caughtInTry));
-            inits = initsEnd;
-            uninits = uninitsEnd;
-            alive = aliveEnd;
-            ListBuffer<PendingExit> exits = pendingExits;
-            pendingExits = prevPendingExits;
-            while (exits.nonEmpty()) pendingExits.append(exits.next());
         }
-        uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
-    }
 
-    void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) {
-        if (chk.subset(exc, caughtInTry)) {
-            log.error(pos, "except.already.caught", exc);
-        } else if (!chk.isUnchecked(pos, exc) &&
-                !isExceptionOrThrowable(exc) &&
-                !chk.intersects(exc, thrownInTry)) {
-            log.error(pos, "except.never.thrown.in.try", exc);
-        } else if (allowImprovedCatchAnalysis) {
-            List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
-            // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
-            // unchecked exception, the result list would not be empty, as the augmented
-            // thrown set includes { RuntimeException, Error }; if 'exc' was a checked
-            // exception, that would have been covered in the branch above
-            if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty() &&
-                    !isExceptionOrThrowable(exc)) {
-                String key = catchableThrownTypes.length() == 1 ?
-                        "unreachable.catch" :
-                        "unreachable.catch.1";
-                log.warning(pos, key, catchableThrownTypes);
+        @Override
+        public void visitIf(JCIf tree) {
+            scan(tree.cond);
+            scanStat(tree.thenpart);
+            if (tree.elsepart != null) {
+                boolean aliveAfterThen = alive;
+                alive = true;
+                scanStat(tree.elsepart);
+                alive = alive | aliveAfterThen;
+            } else {
+                alive = true;
             }
         }
-    }
-    //where
-        private boolean isExceptionOrThrowable(Type exc) {
-            return exc.tsym == syms.throwableType.tsym ||
-                exc.tsym == syms.exceptionType.tsym;
-        }
-
-
-    public void visitConditional(JCConditional tree) {
-        scanCond(tree.cond);
-        Bits initsBeforeElse = initsWhenFalse;
-        Bits uninitsBeforeElse = uninitsWhenFalse;
-        inits = initsWhenTrue;
-        uninits = uninitsWhenTrue;
-        if (tree.truepart.type != null && tree.truepart.type.tag == BOOLEAN &&
-            tree.falsepart.type != null && tree.falsepart.type.tag == BOOLEAN) {
-            // if b and c are boolean valued, then
-            // v is (un)assigned after a?b:c when true iff
-            //    v is (un)assigned after b when true and
-            //    v is (un)assigned after c when true
-            scanCond(tree.truepart);
-            Bits initsAfterThenWhenTrue = initsWhenTrue.dup();
-            Bits initsAfterThenWhenFalse = initsWhenFalse.dup();
-            Bits uninitsAfterThenWhenTrue = uninitsWhenTrue.dup();
-            Bits uninitsAfterThenWhenFalse = uninitsWhenFalse.dup();
-            inits = initsBeforeElse;
-            uninits = uninitsBeforeElse;
-            scanCond(tree.falsepart);
-            initsWhenTrue.andSet(initsAfterThenWhenTrue);
-            initsWhenFalse.andSet(initsAfterThenWhenFalse);
-            uninitsWhenTrue.andSet(uninitsAfterThenWhenTrue);
-            uninitsWhenFalse.andSet(uninitsAfterThenWhenFalse);
-        } else {
-            scanExpr(tree.truepart);
-            Bits initsAfterThen = inits.dup();
-            Bits uninitsAfterThen = uninits.dup();
-            inits = initsBeforeElse;
-            uninits = uninitsBeforeElse;
-            scanExpr(tree.falsepart);
-            inits.andSet(initsAfterThen);
-            uninits.andSet(uninitsAfterThen);
+
+        public void visitBreak(JCBreak tree) {
+            recordExit(tree, new PendingExit(tree));
         }
-    }
 
-    public void visitIf(JCIf tree) {
-        scanCond(tree.cond);
-        Bits initsBeforeElse = initsWhenFalse;
-        Bits uninitsBeforeElse = uninitsWhenFalse;
-        inits = initsWhenTrue;
-        uninits = uninitsWhenTrue;
-        scanStat(tree.thenpart);
-        if (tree.elsepart != null) {
-            boolean aliveAfterThen = alive;
-            alive = true;
-            Bits initsAfterThen = inits.dup();
-            Bits uninitsAfterThen = uninits.dup();
-            inits = initsBeforeElse;
-            uninits = uninitsBeforeElse;
-            scanStat(tree.elsepart);
-            inits.andSet(initsAfterThen);
-            uninits.andSet(uninitsAfterThen);
-            alive = alive | aliveAfterThen;
-        } else {
-            inits.andSet(initsBeforeElse);
-            uninits.andSet(uninitsBeforeElse);
-            alive = true;
+        public void visitContinue(JCContinue tree) {
+            recordExit(tree, new PendingExit(tree));
         }
-    }
 
+        public void visitReturn(JCReturn tree) {
+            scan(tree.expr);
+            recordExit(tree, new PendingExit(tree));
+        }
 
+        public void visitThrow(JCThrow tree) {
+            scan(tree.expr);
+            markDead();
+        }
 
-    public void visitBreak(JCBreak tree) {
-        recordExit(tree);
-    }
+        public void visitApply(JCMethodInvocation tree) {
+            scan(tree.meth);
+            scan(tree.args);
+        }
 
-    public void visitContinue(JCContinue tree) {
-        recordExit(tree);
-    }
+        public void visitNewClass(JCNewClass tree) {
+            scan(tree.encl);
+            scan(tree.args);
+            if (tree.def != null) {
+                scan(tree.def);
+            }
+        }
 
-    public void visitReturn(JCReturn tree) {
-        scanExpr(tree.expr);
-        // if not initial constructor, should markDead instead of recordExit
-        recordExit(tree);
-    }
+        @Override
+        public void visitLambda(JCLambda tree) {
+            if (tree.type != null &&
+                    tree.type.isErroneous()) {
+                return;
+            }
 
-    public void visitThrow(JCThrow tree) {
-        scanExpr(tree.expr);
-        Symbol sym = TreeInfo.symbol(tree.expr);
-        if (sym != null &&
-            sym.kind == VAR &&
-            (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
-            preciseRethrowTypes.get(sym) != null &&
-            allowImprovedRethrowAnalysis) {
-            for (Type t : preciseRethrowTypes.get(sym)) {
-                markThrown(tree, t);
+            ListBuffer<PendingExit> prevPending = pendingExits;
+            boolean prevAlive = alive;
+            try {
+                pendingExits = ListBuffer.lb();
+                alive = true;
+                scanStat(tree.body);
+                tree.canCompleteNormally = alive;
+            }
+            finally {
+                pendingExits = prevPending;
+                alive = prevAlive;
             }
         }
-        else {
-            markThrown(tree, tree.expr.type);
+
+        public void visitTopLevel(JCCompilationUnit tree) {
+            // Do nothing for TopLevel since each class is visited individually
         }
-        markDead();
-    }
 
-    public void visitApply(JCMethodInvocation tree) {
-        scanExpr(tree.meth);
-        scanExprs(tree.args);
-        if (tree.meth.type != null) {
-            for (List<Type> l = tree.meth.type.getThrownTypes(); l.nonEmpty(); l = l.tail)
-                markThrown(tree, l.head);
+    /**************************************************************************
+     * main method
+     *************************************************************************/
+
+        /** Perform definite assignment/unassignment analysis on a tree.
+         */
+        public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
+            analyzeTree(env, env.tree, make);
+        }
+        public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) {
+            try {
+                attrEnv = env;
+                Flow.this.make = make;
+                pendingExits = new ListBuffer<PendingExit>();
+                alive = true;
+                scan(tree);
+            } finally {
+                pendingExits = null;
+                Flow.this.make = null;
+            }
         }
     }
 
-    public void visitNewClass(JCNewClass tree) {
-        scanExpr(tree.encl);
-        scanExprs(tree.args);
-       // scan(tree.def);
-        if (tree.constructorType != null)
-            for (List<Type> l = tree.constructorType.getThrownTypes();
-                 l.nonEmpty();
-                 l = l.tail) {
-                markThrown(tree, l.head);
-            }
-        List<Type> caughtPrev = caught;
-        try {
-            // If the new class expression defines an anonymous class,
-            // analysis of the anonymous constructor may encounter thrown
-            // types which are unsubstituted type variables.
-            // However, since the constructor's actual thrown types have
-            // already been marked as thrown, it is safe to simply include
-            // each of the constructor's formal thrown types in the set of
-            // 'caught/declared to be thrown' types, for the duration of
-            // the class def analysis.
-            if (tree.def != null && tree.constructorType != null)
+    /**
+     * This pass implements the second step of the dataflow analysis, namely
+     * the exception analysis. This is to ensure that every checked exception that is
+     * thrown is declared or caught. The analyzer uses some info that has been set by
+     * the liveliness analyzer.
+     */
+    class FlowAnalyzer extends BaseAnalyzer<FlowAnalyzer.FlowPendingExit> {
+
+        /** A flag that indicates whether the last statement could
+         *  complete normally.
+         */
+        HashMap<Symbol, List<Type>> preciseRethrowTypes;
+
+        /** The current class being defined.
+         */
+        JCClassDecl classDef;
+
+        /** The list of possibly thrown declarable exceptions.
+         */
+        List<Type> thrown;
+
+        /** The list of exceptions that are either caught or declared to be
+         *  thrown.
+         */
+        List<Type> caught;
+
+        class FlowPendingExit extends BaseAnalyzer.PendingExit {
+
+            Type thrown;
+
+            FlowPendingExit(JCTree tree, Type thrown) {
+                super(tree);
+                this.thrown = thrown;
+            }
+        }
+
+        @Override
+        void markDead() {
+            //do nothing
+        }
+
+        /*-------------------- Exceptions ----------------------*/
+
+        /** Complain that pending exceptions are not caught.
+         */
+        void errorUncaught() {
+            for (FlowPendingExit exit = pendingExits.next();
+                 exit != null;
+                 exit = pendingExits.next()) {
+                if (classDef != null &&
+                    classDef.pos == exit.tree.pos) {
+                    log.error(exit.tree.pos(),
+                            "unreported.exception.default.constructor",
+                            exit.thrown);
+                } else if (exit.tree.hasTag(VARDEF) &&
+                        ((JCVariableDecl)exit.tree).sym.isResourceVariable()) {
+                    log.error(exit.tree.pos(),
+                            "unreported.exception.implicit.close",
+                            exit.thrown,
+                            ((JCVariableDecl)exit.tree).sym.name);
+                } else {
+                    log.error(exit.tree.pos(),
+                            "unreported.exception.need.to.catch.or.throw",
+                            exit.thrown);
+                }
+            }
+        }
+
+        /** Record that exception is potentially thrown and check that it
+         *  is caught.
+         */
+        void markThrown(JCTree tree, Type exc) {
+            if (exc != syms.unknownType) {
+                if (!chk.isUnchecked(tree.pos(), exc)) {
+                    if (!chk.isHandled(exc, caught)) {
+                        pendingExits.append(new FlowPendingExit(tree, exc));
+                    }
+                    thrown = chk.incl(exc, thrown);
+                }
+            }
+        }
+
+    /*************************************************************************
+     * Visitor methods for statements and definitions
+     *************************************************************************/
+
+        /* ------------ Visitor methods for various sorts of trees -------------*/
+
+        public void visitClassDef(JCClassDecl tree) {
+            if (tree.sym == null) return;
+
+            JCClassDecl classDefPrev = classDef;
+            List<Type> thrownPrev = thrown;
+            List<Type> caughtPrev = caught;
+            ListBuffer<FlowPendingExit> pendingExitsPrev = pendingExits;
+            Lint lintPrev = lint;
+
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            if (tree.name != names.empty) {
+                caught = List.nil();
+            }
+            classDef = tree;
+            thrown = List.nil();
+            if (tree.sym != null)
+                lint = lint.augment(tree.sym);
+
+            try {
+                // process all the static initializers
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) != 0) {
+                        scan(l.head);
+                        errorUncaught();
+                    }
+                }
+
+                // add intersection of all thrown clauses of initial constructors
+                // to set of caught exceptions, unless class is anonymous.
+                if (tree.name != names.empty) {
+                    boolean firstConstructor = true;
+                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                        if (TreeInfo.isInitialConstructor(l.head)) {
+                            MethodSymbol sym = ((JCMethodDecl) l.head).sym;
+                            List<Type> mthrown = sym != null
+                                    ? sym.type.getThrownTypes() : List.<Type>nil();
+                            if (firstConstructor) {
+                                caught = mthrown;
+                                firstConstructor = false;
+                            } else {
+                                caught = chk.intersect(mthrown, caught);
+                            }
+                        }
+                    }
+                }
+
+                // process all the instance initializers
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) == 0) {
+                        scan(l.head);
+                        errorUncaught();
+                    }
+                }
+
+                // in an anonymous class, add the set of thrown exceptions to
+                // the throws clause of the synthetic constructor and propagate
+                // outwards.
+                // Changing the throws clause on the fly is okay here because
+                // the anonymous constructor can't be invoked anywhere else,
+                // and its type hasn't been cached.
+                if (tree.name == names.empty && thrownPrev != null) {
+                    for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                        if (TreeInfo.isInitialConstructor(l.head)) {
+                            JCMethodDecl mdef = (JCMethodDecl)l.head;
+                            mdef.thrown = make.Types(thrown);
+                            mdef.sym.type = types.createMethodTypeWithThrown(mdef.sym.type, thrown);
+                        }
+                    }
+                    thrownPrev = chk.union(thrown, thrownPrev);
+                }
+
+                // process all the methods
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (l.head.hasTag(METHODDEF)) {
+                        scan(l.head);
+                        errorUncaught();
+                    }
+                }
+
+                thrown = thrownPrev;
+            } finally {
+                pendingExits = pendingExitsPrev;
+                caught = caughtPrev;
+                classDef = classDefPrev;
+                lint = lintPrev;
+            }
+        }
+
+        public void visitMethodDef(JCMethodDecl tree) {
+            if (tree.body == null || tree.sym == null) return;
+
+            List<Type> caughtPrev = caught;
+            List<Type> mthrown = tree.sym.type.getThrownTypes();
+            Lint lintPrev = lint;
+
+            lint = lint.augment(tree.sym);
+
+            Assert.check(pendingExits.isEmpty());
+
+            try {
+                for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
+                    JCVariableDecl def = l.head;
+                    scan(def);
+                }
+                if (TreeInfo.isInitialConstructor(tree))
+                    caught = chk.union(caught, mthrown);
+                else if ((tree.sym.flags() & (BLOCK | STATIC)) != BLOCK)
+                    caught = mthrown;
+                // else we are in an instance initializer block;
+                // leave caught unchanged.
+
+                scan(tree.body);
+
+                List<FlowPendingExit> exits = pendingExits.toList();
+                pendingExits = new ListBuffer<FlowPendingExit>();
+                while (exits.nonEmpty()) {
+                    FlowPendingExit exit = exits.head;
+                    exits = exits.tail;
+                    if (exit.thrown != null) {
+                        // uncaught throws will be reported later
+                        pendingExits.append(exit);
+                    }
+                }
+            } finally {
+                caught = caughtPrev;
+                lint = lintPrev;
+            }
+        }
+
+        public void visitVarDef(JCVariableDecl tree) {
+            if (tree.sym == null) return;
+            if (tree.init != null) {
+                Lint lintPrev = lint;
+                lint = lint.augment(tree.sym);
+                try{
+                    scan(tree.init);
+                } finally {
+                    lint = lintPrev;
+                }
+            }
+        }
+
+        public void visitBlock(JCBlock tree) {
+            scan(tree.stats);
+        }
+
+        public void visitDoLoop(JCDoWhileLoop tree) {
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            scan(tree.body);
+            resolveContinues(tree);
+            scan(tree.cond);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitWhileLoop(JCWhileLoop tree) {
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            scan(tree.cond);
+            scan(tree.body);
+            resolveContinues(tree);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitForLoop(JCForLoop tree) {
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            scan(tree.init);
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            if (tree.cond != null) {
+                scan(tree.cond);
+            }
+            scan(tree.body);
+            resolveContinues(tree);
+            scan(tree.step);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitForeachLoop(JCEnhancedForLoop tree) {
+            visitVarDef(tree.var);
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            scan(tree.expr);
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            scan(tree.body);
+            resolveContinues(tree);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitLabelled(JCLabeledStatement tree) {
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            scan(tree.body);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitSwitch(JCSwitch tree) {
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            scan(tree.selector);
+            for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
+                JCCase c = l.head;
+                if (c.pat != null) {
+                    scan(c.pat);
+                }
+                scan(c.stats);
+            }
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitTry(JCTry tree) {
+            List<Type> caughtPrev = caught;
+            List<Type> thrownPrev = thrown;
+            thrown = List.nil();
+            for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
+                List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
+                        ((JCTypeUnion)l.head.param.vartype).alternatives :
+                        List.of(l.head.param.vartype);
+                for (JCExpression ct : subClauses) {
+                    caught = chk.incl(ct.type, caught);
+                }
+            }
+
+            ListBuffer<FlowPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<FlowPendingExit>();
+            for (JCTree resource : tree.resources) {
+                if (resource instanceof JCVariableDecl) {
+                    JCVariableDecl vdecl = (JCVariableDecl) resource;
+                    visitVarDef(vdecl);
+                } else if (resource instanceof JCExpression) {
+                    scan((JCExpression) resource);
+                } else {
+                    throw new AssertionError(tree);  // parser error
+                }
+            }
+            for (JCTree resource : tree.resources) {
+                List<Type> closeableSupertypes = resource.type.isCompound() ?
+                    types.interfaces(resource.type).prepend(types.supertype(resource.type)) :
+                    List.of(resource.type);
+                for (Type sup : closeableSupertypes) {
+                    if (types.asSuper(sup, syms.autoCloseableType.tsym) != null) {
+                        Symbol closeMethod = rs.resolveQualifiedMethod(tree,
+                                attrEnv,
+                                sup,
+                                names.close,
+                                List.<Type>nil(),
+                                List.<Type>nil());
+                        Type mt = types.memberType(resource.type, closeMethod);
+                        if (closeMethod.kind == MTH) {
+                            for (Type t : mt.getThrownTypes()) {
+                                markThrown(resource, t);
+                            }
+                        }
+                    }
+                }
+            }
+            scan(tree.body);
+            List<Type> thrownInTry = allowImprovedCatchAnalysis ?
+                chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) :
+                thrown;
+            thrown = thrownPrev;
+            caught = caughtPrev;
+
+            List<Type> caughtInTry = List.nil();
+            for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
+                JCVariableDecl param = l.head.param;
+                List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
+                        ((JCTypeUnion)l.head.param.vartype).alternatives :
+                        List.of(l.head.param.vartype);
+                List<Type> ctypes = List.nil();
+                List<Type> rethrownTypes = chk.diff(thrownInTry, caughtInTry);
+                for (JCExpression ct : subClauses) {
+                    Type exc = ct.type;
+                    if (exc != null && exc != syms.unknownType) {
+                        ctypes = ctypes.append(exc);
+                        if (types.isSameType(exc, syms.objectType))
+                            continue;
+                        checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry);
+                        caughtInTry = chk.incl(exc, caughtInTry);
+                    }
+                }
+                scan(param);
+                preciseRethrowTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes));
+                scan(l.head.body);
+                preciseRethrowTypes.remove(param.sym);
+            }
+            if (tree.finalizer != null) {
+                List<Type> savedThrown = thrown;
+                thrown = List.nil();
+                ListBuffer<FlowPendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                scan(tree.finalizer);
+                if (!tree.finallyCanCompleteNormally) {
+                    // discard exits and exceptions from try and finally
+                    thrown = chk.union(thrown, thrownPrev);
+                } else {
+                    thrown = chk.union(thrown, chk.diff(thrownInTry, caughtInTry));
+                    thrown = chk.union(thrown, savedThrown);
+                    // FIX: this doesn't preserve source order of exits in catch
+                    // versus finally!
+                    while (exits.nonEmpty()) {
+                        pendingExits.append(exits.next());
+                    }
+                }
+            } else {
+                thrown = chk.union(thrown, chk.diff(thrownInTry, caughtInTry));
+                ListBuffer<FlowPendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                while (exits.nonEmpty()) pendingExits.append(exits.next());
+            }
+        }
+
+        @Override
+        public void visitIf(JCIf tree) {
+            scan(tree.cond);
+            scan(tree.thenpart);
+            if (tree.elsepart != null) {
+                scan(tree.elsepart);
+            }
+        }
+
+        void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) {
+            if (chk.subset(exc, caughtInTry)) {
+                log.error(pos, "except.already.caught", exc);
+            } else if (!chk.isUnchecked(pos, exc) &&
+                    !isExceptionOrThrowable(exc) &&
+                    !chk.intersects(exc, thrownInTry)) {
+                log.error(pos, "except.never.thrown.in.try", exc);
+            } else if (allowImprovedCatchAnalysis) {
+                List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
+                // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
+                // unchecked exception, the result list would not be empty, as the augmented
+                // thrown set includes { RuntimeException, Error }; if 'exc' was a checked
+                // exception, that would have been covered in the branch above
+                if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty() &&
+                        !isExceptionOrThrowable(exc)) {
+                    String key = catchableThrownTypes.length() == 1 ?
+                            "unreachable.catch" :
+                            "unreachable.catch.1";
+                    log.warning(pos, key, catchableThrownTypes);
+                }
+            }
+        }
+        //where
+            private boolean isExceptionOrThrowable(Type exc) {
+                return exc.tsym == syms.throwableType.tsym ||
+                    exc.tsym == syms.exceptionType.tsym;
+            }
+
+        public void visitBreak(JCBreak tree) {
+            recordExit(tree, new FlowPendingExit(tree, null));
+        }
+
+        public void visitContinue(JCContinue tree) {
+            recordExit(tree, new FlowPendingExit(tree, null));
+        }
+
+        public void visitReturn(JCReturn tree) {
+            scan(tree.expr);
+            recordExit(tree, new FlowPendingExit(tree, null));
+        }
+
+        public void visitThrow(JCThrow tree) {
+            scan(tree.expr);
+            Symbol sym = TreeInfo.symbol(tree.expr);
+            if (sym != null &&
+                sym.kind == VAR &&
+                (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
+                preciseRethrowTypes.get(sym) != null &&
+                allowImprovedRethrowAnalysis) {
+                for (Type t : preciseRethrowTypes.get(sym)) {
+                    markThrown(tree, t);
+                }
+            }
+            else {
+                markThrown(tree, tree.expr.type);
+            }
+            markDead();
+        }
+
+        public void visitApply(JCMethodInvocation tree) {
+            scan(tree.meth);
+            scan(tree.args);
+            if (tree.meth.type != null) {
+                for (List<Type> l = tree.meth.type.getThrownTypes(); l.nonEmpty(); l = l.tail)
+                    markThrown(tree, l.head);
+            }
+        }
+
+        public void visitNewClass(JCNewClass tree) {
+            scan(tree.encl);
+            scan(tree.args);
+           // scan(tree.def);
+            if (tree.constructorType != null) {
                 for (List<Type> l = tree.constructorType.getThrownTypes();
                      l.nonEmpty();
                      l = l.tail) {
-                    caught = chk.incl(l.head, caught);
+                    markThrown(tree, l.head);
                 }
-            scan(tree.def);
+            }
+            List<Type> caughtPrev = caught;
+            try {
+                // If the new class expression defines an anonymous class,
+                // analysis of the anonymous constructor may encounter thrown
+                // types which are unsubstituted type variables.
+                // However, since the constructor's actual thrown types have
+                // already been marked as thrown, it is safe to simply include
+                // each of the constructor's formal thrown types in the set of
+                // 'caught/declared to be thrown' types, for the duration of
+                // the class def analysis.
+                if (tree.def != null && tree.constructor != null && tree.constructor.type != null)
+                    for (List<Type> l = tree.constructor.type.getThrownTypes();
+                         l.nonEmpty();
+                         l = l.tail) {
+                        caught = chk.incl(l.head, caught);
+                    }
+                scan(tree.def);
+            }
+            finally {
+                caught = caughtPrev;
+            }
         }
-        finally {
-            caught = caughtPrev;
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            if (tree.type != null &&
+                    tree.type.isErroneous()) {
+                return;
+            }
+            List<Type> prevCaught = caught;
+            List<Type> prevThrown = thrown;
+            ListBuffer<FlowPendingExit> prevPending = pendingExits;
+            try {
+                pendingExits = ListBuffer.lb();
+                caught = tree.getDescriptorType(types).getThrownTypes();
+                thrown = List.nil();
+                scan(tree.body);
+                List<FlowPendingExit> exits = pendingExits.toList();
+                pendingExits = new ListBuffer<FlowPendingExit>();
+                while (exits.nonEmpty()) {
+                    FlowPendingExit exit = exits.head;
+                    exits = exits.tail;
+                    if (exit.thrown != null) {
+                        // uncaught throws will be reported later
+                        pendingExits.append(exit);
+                    }
+                }
+
+                errorUncaught();
+            } finally {
+                pendingExits = prevPending;
+                caught = prevCaught;
+                thrown = prevThrown;
+            }
         }
-    }
 
-    public void visitNewArray(JCNewArray tree) {
-        scanExprs(tree.dims);
-        scanExprs(tree.elems);
-    }
+        public void visitTopLevel(JCCompilationUnit tree) {
+            // Do nothing for TopLevel since each class is visited individually
+        }
 
-    public void visitAssert(JCAssert tree) {
-        Bits initsExit = inits.dup();
-        Bits uninitsExit = uninits.dup();
-        scanCond(tree.cond);
-        uninitsExit.andSet(uninitsWhenTrue);
-        if (tree.detail != null) {
-            inits = initsWhenFalse;
-            uninits = uninitsWhenFalse;
-            scanExpr(tree.detail);
-        }
-        inits = initsExit;
-        uninits = uninitsExit;
-    }
+    /**************************************************************************
+     * main method
+     *************************************************************************/
 
-    public void visitAssign(JCAssign tree) {
-        JCTree lhs = TreeInfo.skipParens(tree.lhs);
-        if (!(lhs instanceof JCIdent)) scanExpr(lhs);
-        scanExpr(tree.rhs);
-        letInit(lhs);
+        /** Perform definite assignment/unassignment analysis on a tree.
+         */
+        public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
+            analyzeTree(env, env.tree, make);
+        }
+        public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) {
+            try {
+                attrEnv = env;
+                Flow.this.make = make;
+                pendingExits = new ListBuffer<FlowPendingExit>();
+                preciseRethrowTypes = new HashMap<Symbol, List<Type>>();
+                this.thrown = this.caught = null;
+                this.classDef = null;
+                scan(tree);
+            } finally {
+                pendingExits = null;
+                Flow.this.make = null;
+                this.thrown = this.caught = null;
+                this.classDef = null;
+            }
+        }
     }
 
-    public void visitAssignop(JCAssignOp tree) {
-        scanExpr(tree.lhs);
-        scanExpr(tree.rhs);
-        letInit(tree.lhs);
+    /**
+     * Specialized pass that performs inference of thrown types for lambdas.
+     */
+    class LambdaFlowAnalyzer extends FlowAnalyzer {
+        @Override
+        public void visitLambda(JCLambda tree) {
+            if (tree.type != null &&
+                    tree.type.isErroneous()) {
+                return;
+            }
+            List<Type> prevCaught = caught;
+            List<Type> prevThrown = thrown;
+            ListBuffer<FlowPendingExit> prevPending = pendingExits;
+            try {
+                pendingExits = ListBuffer.lb();
+                caught = List.of(syms.throwableType);
+                thrown = List.nil();
+                scan(tree.body);
+                tree.inferredThrownTypes = thrown;
+            } finally {
+                pendingExits = prevPending;
+                caught = prevCaught;
+                thrown = prevThrown;
+            }
+        }
     }
 
-    public void visitUnary(JCUnary tree) {
-        switch (tree.getTag()) {
-        case JCTree.NOT:
-            scanCond(tree.arg);
-            Bits t = initsWhenFalse;
-            initsWhenFalse = initsWhenTrue;
-            initsWhenTrue = t;
-            t = uninitsWhenFalse;
-            uninitsWhenFalse = uninitsWhenTrue;
-            uninitsWhenTrue = t;
-            break;
-        case JCTree.PREINC: case JCTree.POSTINC:
-        case JCTree.PREDEC: case JCTree.POSTDEC:
-            scanExpr(tree.arg);
-            letInit(tree.arg);
-            break;
-        default:
-            scanExpr(tree.arg);
+    /**
+     * This pass implements (i) definite assignment analysis, which ensures that
+     * each variable is assigned when used and (ii) definite unassignment analysis,
+     * which ensures that no final variable is assigned more than once. This visitor
+     * depends on the results of the liveliness analyzer. This pass is also used to mark
+     * effectively-final local variables/parameters.
+     */
+    class AssignAnalyzer extends BaseAnalyzer<AssignAnalyzer.AssignPendingExit> {
+
+        /** The set of definitely assigned variables.
+         */
+        final Bits inits;
+
+        /** The set of definitely unassigned variables.
+         */
+        final Bits uninits;
+
+        /** The set of variables that are definitely unassigned everywhere
+         *  in current try block. This variable is maintained lazily; it is
+         *  updated only when something gets removed from uninits,
+         *  typically by being assigned in reachable code.  To obtain the
+         *  correct set of variables which are definitely unassigned
+         *  anywhere in current try block, intersect uninitsTry and
+         *  uninits.
+         */
+        final Bits uninitsTry;
+
+        /** When analyzing a condition, inits and uninits are null.
+         *  Instead we have:
+         */
+        final Bits initsWhenTrue;
+        final Bits initsWhenFalse;
+        final Bits uninitsWhenTrue;
+        final Bits uninitsWhenFalse;
+
+        /** A mapping from addresses to variable symbols.
+         */
+        VarSymbol[] vars;
+
+        /** The current class being defined.
+         */
+        JCClassDecl classDef;
+
+        /** The first variable sequence number in this class definition.
+         */
+        int firstadr;
+
+        /** The next available variable sequence number.
+         */
+        int nextadr;
+
+        /** The first variable sequence number in a block that can return.
+         */
+        int returnadr;
+
+        /** The list of unreferenced automatic resources.
+         */
+        Scope unrefdResources;
+
+        /** Set when processing a loop body the second time for DU analysis. */
+        FlowKind flowKind = FlowKind.NORMAL;
+
+        /** The starting position of the analysed tree */
+        int startPos;
+
+        AssignAnalyzer() {
+            inits = new Bits();
+            uninits = new Bits();
+            uninitsTry = new Bits();
+            initsWhenTrue = new Bits(true);
+            initsWhenFalse = new Bits(true);
+            uninitsWhenTrue = new Bits(true);
+            uninitsWhenFalse = new Bits(true);
+        }
+
+        class AssignPendingExit extends BaseAnalyzer.PendingExit {
+
+            final Bits exit_inits = new Bits(true);
+            final Bits exit_uninits = new Bits(true);
+
+            AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
+                super(tree);
+                this.exit_inits.assign(inits);
+                this.exit_uninits.assign(uninits);
+            }
+
+            void resolveJump() {
+                inits.andSet(exit_inits);
+                uninits.andSet(exit_uninits);
+            }
+        }
+
+        @Override
+        void markDead() {
+            inits.inclRange(returnadr, nextadr);
+            uninits.inclRange(returnadr, nextadr);
+        }
+
+        /*-------------- Processing variables ----------------------*/
+
+        /** Do we need to track init/uninit state of this symbol?
+         *  I.e. is symbol either a local or a blank final variable?
+         */
+        boolean trackable(VarSymbol sym) {
+            return sym != null && sym.owner != null &&
+                sym.pos >= startPos &&
+                (sym.owner.kind == MTH ||
+                 sym.owner.kind == TYP &&
+                  ((sym.flags() & (FINAL | HASINIT | PARAMETER)) == FINAL &&                  
+                  classDef.sym.isEnclosedBy((ClassSymbol)sym.owner)) &&
+                  (reanalyzedClass == null || ((ClassSymbol)sym.owner).isEnclosedBy(reanalyzedClass.sym)));
+        }
+
+        /** Initialize new trackable variable by setting its address field
+         *  to the next available sequence number and entering it under that
+         *  index into the vars array.
+         */
+        void newVar(VarSymbol sym) {
+            vars = ArrayUtils.ensureCapacity(vars, nextadr);
+            if ((sym.flags() & FINAL) == 0) {
+                sym.flags_field |= EFFECTIVELY_FINAL;
+            }
+            sym.adr = nextadr;
+            vars[nextadr] = sym;
+            inits.excl(nextadr);
+            uninits.incl(nextadr);
+            nextadr++;
+        }
+
+        /** Record an initialization of a trackable variable.
+         */
+        void letInit(DiagnosticPosition pos, VarSymbol sym) {
+            if (sym.adr >= firstadr && trackable(sym)) {
+                if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
+                    if (!uninits.isMember(sym.adr)) {
+                        //assignment targeting an effectively final variable
+                        //makes the variable lose its status of effectively final
+                        //if the variable is _not_ definitively unassigned
+                        sym.flags_field &= ~EFFECTIVELY_FINAL;
+                    } else {
+                        uninit(sym);
+                    }
+                }
+                else if ((sym.flags() & FINAL) != 0) {
+                    if ((sym.flags() & PARAMETER) != 0) {
+                        if ((sym.flags() & UNION) != 0) { //multi-catch parameter
+                            log.error(pos, "multicatch.parameter.may.not.be.assigned",
+                                      sym);
+                        }
+                        else {
+                            log.error(pos, "final.parameter.may.not.be.assigned",
+                                  sym);
+                        }
+                    } else if (!uninits.isMember(sym.adr)) {
+                        log.error(pos, flowKind.errKey, sym);
+                    } else {
+                        uninit(sym);
+                    }
+                }
+                inits.incl(sym.adr);
+            } else if ((sym.flags() & FINAL) != 0) {
+                log.error(pos, "var.might.already.be.assigned", sym);
+            }
+        }
+        //where
+            void uninit(VarSymbol sym) {
+                if (!inits.isMember(sym.adr)) {
+                    // reachable assignment
+                    uninits.excl(sym.adr);
+                    uninitsTry.excl(sym.adr);
+                } else {
+                    //log.rawWarning(pos, "unreachable assignment");//DEBUG
+                    uninits.excl(sym.adr);
+                }
+            }
+
+        /** If tree is either a simple name or of the form this.name or
+         *  C.this.name, and tree represents a trackable variable,
+         *  record an initialization of the variable.
+         */
+        void letInit(JCTree tree) {
+            tree = TreeInfo.skipParens(tree);
+            if (tree.hasTag(IDENT) || tree.hasTag(SELECT)) {
+                Symbol sym = TreeInfo.symbol(tree);
+                if (sym != null && sym.kind == VAR) {
+                    letInit(tree.pos(), (VarSymbol)sym);
+                }
+            }
+        }
+
+        /** Check that trackable variable is initialized.
+         */
+        void checkInit(DiagnosticPosition pos, VarSymbol sym) {
+            if ((sym.adr >= firstadr || (sym.owner != null && sym.owner.kind != TYP && sym.owner.kind != ERR)) &&
+                trackable(sym) &&
+                inits != null && !inits.isMember(sym.adr)) {
+                log.error(pos, "var.might.not.have.been.initialized",
+                          sym);
+                inits.incl(sym.adr);
+            }
         }
-    }
 
-    public void visitBinary(JCBinary tree) {
-        switch (tree.getTag()) {
-        case JCTree.AND:
-            scanCond(tree.lhs);
-            Bits initsWhenFalseLeft = initsWhenFalse;
-            Bits uninitsWhenFalseLeft = uninitsWhenFalse;
-            inits = initsWhenTrue;
-            uninits = uninitsWhenTrue;
-            scanCond(tree.rhs);
-            initsWhenFalse.andSet(initsWhenFalseLeft);
-            uninitsWhenFalse.andSet(uninitsWhenFalseLeft);
-            break;
-        case JCTree.OR:
-            scanCond(tree.lhs);
-            Bits initsWhenTrueLeft = initsWhenTrue;
-            Bits uninitsWhenTrueLeft = uninitsWhenTrue;
-            inits = initsWhenFalse;
-            uninits = uninitsWhenFalse;
-            scanCond(tree.rhs);
-            initsWhenTrue.andSet(initsWhenTrueLeft);
-            uninitsWhenTrue.andSet(uninitsWhenTrueLeft);
-            break;
-        default:
+        /** Split (duplicate) inits/uninits into WhenTrue/WhenFalse sets
+         */
+        void split(boolean setToNull) {
+            initsWhenFalse.assign(inits);
+            uninitsWhenFalse.assign(uninits);
+            initsWhenTrue.assign(inits);
+            uninitsWhenTrue.assign(uninits);
+            if (setToNull) {
+                resetBits(inits, uninits);
+            }
+        }
+
+        /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
+         */
+        void merge() {
+            inits.assign(initsWhenFalse.andSet(initsWhenTrue));
+            uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue));
+        }
+
+    /* ************************************************************************
+     * Visitor methods for statements and definitions
+     *************************************************************************/
+
+        /** Analyze an expression. Make sure to set (un)inits rather than
+         *  (un)initsWhenTrue(WhenFalse) on exit.
+         */
+        void scanExpr(JCTree tree) {
+            if (tree != null) {
+                scan(tree);
+                if (inits.isReset()) merge();
+            }
+        }
+
+        /** Analyze a list of expressions.
+         */
+        void scanExprs(List<? extends JCExpression> trees) {
+            if (trees != null)
+                for (List<? extends JCExpression> l = trees; l.nonEmpty(); l = l.tail)
+                    scanExpr(l.head);
+        }
+
+        /** Analyze a condition. Make sure to set (un)initsWhenTrue(WhenFalse)
+         *  rather than (un)inits on exit.
+         */
+        void scanCond(JCTree tree) {
+            if (tree.type != null && tree.type.isFalse()) {
+                if (inits.isReset()) merge();
+                initsWhenTrue.assign(inits);
+                initsWhenTrue.inclRange(firstadr, nextadr);
+                uninitsWhenTrue.assign(uninits);
+                uninitsWhenTrue.inclRange(firstadr, nextadr);
+                initsWhenFalse.assign(inits);
+                uninitsWhenFalse.assign(uninits);
+            } else if (tree.type != null && tree.type.isTrue()) {
+                if (inits.isReset()) merge();
+                initsWhenFalse.assign(inits);
+                initsWhenFalse.inclRange(firstadr, nextadr);
+                uninitsWhenFalse.assign(uninits);
+                uninitsWhenFalse.inclRange(firstadr, nextadr);
+                initsWhenTrue.assign(inits);
+                uninitsWhenTrue.assign(uninits);
+            } else {
+                scan(tree);
+                if (!inits.isReset())
+                    split(tree.type != syms.unknownType);
+            }
+            if (tree.type != syms.unknownType) {
+                resetBits(inits, uninits);
+            }
+        }
+
+        /* ------------ Visitor methods for various sorts of trees -------------*/
+
+        public void visitClassDef(JCClassDecl tree) {
+            if (tree.sym == null) return;
+
+            JCClassDecl classDefPrev = classDef;
+            int firstadrPrev = firstadr;
+            int nextadrPrev = nextadr;
+            ListBuffer<AssignPendingExit> pendingExitsPrev = pendingExits;
+            Lint lintPrev = lint;
+
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            if (tree.name != names.empty) {
+                firstadr = nextadr;
+            }
+            classDef = tree;
+            lint = lint.augment(tree.sym);
+
+            try {
+                // define all the static fields
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (l.head.hasTag(VARDEF)) {
+                        JCVariableDecl def = (JCVariableDecl)l.head;
+                        if ((def.mods.flags & STATIC) != 0) {
+                            VarSymbol sym = def.sym;
+                            if (trackable(sym))
+                                newVar(sym);
+                        }
+                    }
+                }
+
+                // process all the static initializers
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) != 0) {
+                        scan(l.head);
+                        if (pendingExits.nonEmpty()) pendingExits.clear();
+                    }
+                }
+
+                // define all the instance fields
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (l.head.hasTag(VARDEF)) {
+                        JCVariableDecl def = (JCVariableDecl)l.head;
+                        if ((def.mods.flags & STATIC) == 0) {
+                            VarSymbol sym = def.sym;
+                            if (trackable(sym))
+                                newVar(sym);
+                        }
+                    }
+                }
+
+                // process all the instance initializers
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (!l.head.hasTag(METHODDEF) &&
+                        (TreeInfo.flags(l.head) & STATIC) == 0) {
+                        scan(l.head);
+                        if (pendingExits.nonEmpty()) pendingExits.clear();
+                    }
+                }
+
+                // process all the methods
+                for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+                    if (l.head.hasTag(METHODDEF)) {
+                        scan(l.head);
+                    }
+                }
+            } finally {
+                pendingExits = pendingExitsPrev;
+                nextadr = nextadrPrev;
+                firstadr = firstadrPrev;
+                classDef = classDefPrev;
+                lint = lintPrev;
+            }
+        }
+
+        public void visitMethodDef(JCMethodDecl tree) {
+            if (tree.body == null || tree.sym == null) return;
+
+            final Bits initsPrev = new Bits(inits);
+            final Bits uninitsPrev = new Bits(uninits);
+            int nextadrPrev = nextadr;
+            int firstadrPrev = firstadr;
+            int returnadrPrev = returnadr;
+            Lint lintPrev = lint;
+
+            lint = lint.augment(tree.sym);
+
+            Assert.check(pendingExits.isEmpty());
+
+            try {
+                boolean isInitialConstructor =
+                    TreeInfo.isInitialConstructor(tree);
+
+                if (!isInitialConstructor)
+                    firstadr = nextadr;
+                for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
+                    JCVariableDecl def = l.head;
+                    scan(def);
+                    inits.incl(def.sym.adr);
+                    uninits.excl(def.sym.adr);
+                }
+                // else we are in an instance initializer block;
+                // leave caught unchanged.
+                scan(tree.body);
+
+                if (isInitialConstructor) {
+                    for (int i = firstadr; i < nextadr; i++)
+                        if (vars[i].owner == classDef.sym)
+                            checkInit(TreeInfo.diagEndPos(tree.body), vars[i]);
+                }
+                List<AssignPendingExit> exits = pendingExits.toList();
+                pendingExits = new ListBuffer<AssignPendingExit>();
+                while (exits.nonEmpty()) {
+                    AssignPendingExit exit = exits.head;
+                    exits = exits.tail;
+                    if (isInitialConstructor && exit.tree.hasTag(RETURN)) {
+                        inits.assign(exit.exit_inits);
+                        for (int i = firstadr; i < nextadr; i++)
+                            checkInit(exit.tree.pos(), vars[i]);
+                    }
+                }
+            } finally {
+                inits.assign(initsPrev);
+                uninits.assign(uninitsPrev);
+                nextadr = nextadrPrev;
+                firstadr = firstadrPrev;
+                returnadr = returnadrPrev;
+                lint = lintPrev;
+            }
+        }
+
+        public void visitVarDef(JCVariableDecl tree) {
+            if (tree.sym == null) return;
+            boolean track = trackable(tree.sym);
+            if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
+            if (tree.init != null) {
+                Lint lintPrev = lint;
+                lint = lint.augment(tree.sym);
+                try{
+                    scanExpr(tree.init);
+                    if (track) letInit(tree.pos(), tree.sym);
+                } finally {
+                    lint = lintPrev;
+                }
+            }
+        }
+
+        public void visitBlock(JCBlock tree) {
+            int nextadrPrev = nextadr;
+            scan(tree.stats);
+            nextadr = nextadrPrev;
+        }
+
+        public void visitDoLoop(JCDoWhileLoop tree) {
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            FlowKind prevFlowKind = flowKind;
+            flowKind = FlowKind.NORMAL;
+            final Bits initsSkip = new Bits(true);
+            final Bits uninitsSkip = new Bits(true);
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            int prevErrors = log.nerrors;
+            do {
+                final Bits uninitsEntry = new Bits(uninits);
+                uninitsEntry.excludeFrom(nextadr);
+                scan(tree.body);
+                resolveContinues(tree);
+                scanCond(tree.cond);
+                if (!flowKind.isFinal()) {
+                    initsSkip.assign(initsWhenFalse);
+                    uninitsSkip.assign(uninitsWhenFalse);
+                }
+                if (log.nerrors !=  prevErrors ||
+                    flowKind.isFinal() ||
+                    new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
+                    break;
+                inits.assign(initsWhenTrue);
+                uninits.assign(uninitsEntry.andSet(uninitsWhenTrue));
+                flowKind = FlowKind.SPECULATIVE_LOOP;
+            } while (true);
+            flowKind = prevFlowKind;
+            inits.assign(initsSkip);
+            uninits.assign(uninitsSkip);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitWhileLoop(JCWhileLoop tree) {
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            FlowKind prevFlowKind = flowKind;
+            flowKind = FlowKind.NORMAL;
+            final Bits initsSkip = new Bits(true);
+            final Bits uninitsSkip = new Bits(true);
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            int prevErrors = log.nerrors;
+            final Bits uninitsEntry = new Bits(uninits);
+            uninitsEntry.excludeFrom(nextadr);
+            do {
+                scanCond(tree.cond);
+                if (!flowKind.isFinal()) {
+                    initsSkip.assign(initsWhenFalse) ;
+                    uninitsSkip.assign(uninitsWhenFalse);
+                }
+                inits.assign(initsWhenTrue);
+                uninits.assign(uninitsWhenTrue);
+                scan(tree.body);
+                resolveContinues(tree);
+                if (log.nerrors != prevErrors ||
+                    flowKind.isFinal() ||
+                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
+                    break;
+                uninits.assign(uninitsEntry.andSet(uninits));
+                flowKind = FlowKind.SPECULATIVE_LOOP;
+            } while (true);
+            flowKind = prevFlowKind;
+            //a variable is DA/DU after the while statement, if it's DA/DU assuming the
+            //branch is not taken AND if it's DA/DU before any break statement
+            inits.assign(initsSkip);
+            uninits.assign(uninitsSkip);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitForLoop(JCForLoop tree) {
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            FlowKind prevFlowKind = flowKind;
+            flowKind = FlowKind.NORMAL;
+            int nextadrPrev = nextadr;
+            scan(tree.init);
+            final Bits initsSkip = new Bits(true);
+            final Bits uninitsSkip = new Bits(true);
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            int prevErrors = log.nerrors;
+            do {
+                final Bits uninitsEntry = new Bits(uninits);
+                uninitsEntry.excludeFrom(nextadr);
+                if (tree.cond != null) {
+                    scanCond(tree.cond);
+                    if (!flowKind.isFinal()) {
+                        initsSkip.assign(initsWhenFalse);
+                        uninitsSkip.assign(uninitsWhenFalse);
+                    }
+                    inits.assign(initsWhenTrue);
+                    uninits.assign(uninitsWhenTrue);
+                } else if (!flowKind.isFinal()) {
+                    initsSkip.assign(inits);
+                    initsSkip.inclRange(firstadr, nextadr);
+                    uninitsSkip.assign(uninits);
+                    uninitsSkip.inclRange(firstadr, nextadr);
+                }
+                scan(tree.body);
+                resolveContinues(tree);
+                scan(tree.step);
+                if (log.nerrors != prevErrors ||
+                    flowKind.isFinal() ||
+                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
+                    break;
+                uninits.assign(uninitsEntry.andSet(uninits));
+                flowKind = FlowKind.SPECULATIVE_LOOP;
+            } while (true);
+            flowKind = prevFlowKind;
+            //a variable is DA/DU after a for loop, if it's DA/DU assuming the
+            //branch is not taken AND if it's DA/DU before any break statement
+            inits.assign(initsSkip);
+            uninits.assign(uninitsSkip);
+            resolveBreaks(tree, prevPendingExits);
+            nextadr = nextadrPrev;
+        }
+
+        public void visitForeachLoop(JCEnhancedForLoop tree) {
+            visitVarDef(tree.var);
+
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            FlowKind prevFlowKind = flowKind;
+            flowKind = FlowKind.NORMAL;
+            int nextadrPrev = nextadr;
+            scan(tree.expr);
+            final Bits initsStart = new Bits(inits);
+            final Bits uninitsStart = new Bits(uninits);
+
+            if (tree.var.sym != null)
+                letInit(tree.pos(), tree.var.sym);
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            int prevErrors = log.nerrors;
+            do {
+                final Bits uninitsEntry = new Bits(uninits);
+                uninitsEntry.excludeFrom(nextadr);
+                scan(tree.body);
+                resolveContinues(tree);
+                if (log.nerrors != prevErrors ||
+                    flowKind.isFinal() ||
+                    new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
+                    break;
+                uninits.assign(uninitsEntry.andSet(uninits));
+                flowKind = FlowKind.SPECULATIVE_LOOP;
+            } while (true);
+            flowKind = prevFlowKind;
+            inits.assign(initsStart);
+            uninits.assign(uninitsStart.andSet(uninits));
+            resolveBreaks(tree, prevPendingExits);
+            nextadr = nextadrPrev;
+        }
+
+        public void visitLabelled(JCLabeledStatement tree) {
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            scan(tree.body);
+            resolveBreaks(tree, prevPendingExits);
+        }
+
+        public void visitSwitch(JCSwitch tree) {
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            int nextadrPrev = nextadr;
+            scanExpr(tree.selector);
+            final Bits initsSwitch = new Bits(inits);
+            final Bits uninitsSwitch = new Bits(uninits);
+            boolean hasDefault = false;
+            for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
+                inits.assign(initsSwitch);
+                uninits.assign(uninits.andSet(uninitsSwitch));
+                JCCase c = l.head;
+                if (c.pat == null)
+                    hasDefault = true;
+                else
+                    scanExpr(c.pat);
+                scan(c.stats);
+                addVars(c.stats, initsSwitch, uninitsSwitch);
+                // Warn about fall-through if lint switch fallthrough enabled.
+            }
+            if (!hasDefault) {
+                inits.andSet(initsSwitch);
+            }
+            resolveBreaks(tree, prevPendingExits);
+            nextadr = nextadrPrev;
+        }
+        // where
+            /** Add any variables defined in stats to inits and uninits. */
+            private void addVars(List<JCStatement> stats, final Bits inits,
+                                        final Bits uninits) {
+                for (;stats.nonEmpty(); stats = stats.tail) {
+                    JCTree stat = stats.head;
+                    if (stat.hasTag(VARDEF)) {
+                        int adr = ((JCVariableDecl) stat).sym.adr;
+                        inits.excl(adr);
+                        uninits.incl(adr);
+                    }
+                }
+            }
+
+        public void visitTry(JCTry tree) {
+            ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
+            final Bits uninitsTryPrev = new Bits(uninitsTry);
+            ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+            pendingExits = new ListBuffer<AssignPendingExit>();
+            final Bits initsTry = new Bits(inits);
+            uninitsTry.assign(uninits);
+            for (JCTree resource : tree.resources) {
+                if (resource instanceof JCVariableDecl) {
+                    JCVariableDecl vdecl = (JCVariableDecl) resource;
+                    visitVarDef(vdecl);
+                    unrefdResources.enter(vdecl.sym);
+                    resourceVarDecls.append(vdecl);
+                } else if (resource instanceof JCExpression) {
+                    scanExpr((JCExpression) resource);
+                } else {
+                    throw new AssertionError(tree);  // parser error
+                }
+            }
+            scan(tree.body);
+            uninitsTry.andSet(uninits);
+            final Bits initsEnd = new Bits(inits);
+            final Bits uninitsEnd = new Bits(uninits);
+            int nextadrCatch = nextadr;
+
+            if (!resourceVarDecls.isEmpty() &&
+                    lint.isEnabled(Lint.LintCategory.TRY)) {
+                for (JCVariableDecl resVar : resourceVarDecls) {
+                    if (unrefdResources.includes(resVar.sym)) {
+                        log.warning(Lint.LintCategory.TRY, resVar.pos(),
+                                    "try.resource.not.referenced", resVar.sym);
+                        unrefdResources.remove(resVar.sym);
+                    }
+                }
+            }
+
+            /*  The analysis of each catch should be independent.
+             *  Each one should have the same initial values of inits and
+             *  uninits.
+             */
+            final Bits initsCatchPrev = new Bits(initsTry);
+            final Bits uninitsCatchPrev = new Bits(uninitsTry);
+
+            for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
+                JCVariableDecl param = l.head.param;
+                inits.assign(initsCatchPrev);
+                uninits.assign(uninitsCatchPrev);
+                scan(param);
+                if (param.sym != null) {
+                    inits.incl(param.sym.adr);
+                    uninits.excl(param.sym.adr);
+                }
+                scan(l.head.body);
+                initsEnd.andSet(inits);
+                uninitsEnd.andSet(uninits);
+                nextadr = nextadrCatch;
+            }
+            if (tree.finalizer != null) {
+                inits.assign(initsTry);
+                uninits.assign(uninitsTry);
+                ListBuffer<AssignPendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                scan(tree.finalizer);
+                if (!tree.finallyCanCompleteNormally) {
+                    // discard exits and exceptions from try and finally
+                } else {
+                    uninits.andSet(uninitsEnd);
+                    // FIX: this doesn't preserve source order of exits in catch
+                    // versus finally!
+                    while (exits.nonEmpty()) {
+                        AssignPendingExit exit = exits.next();
+                        if (exit.exit_inits != null) {
+                            exit.exit_inits.orSet(inits);
+                            exit.exit_uninits.andSet(uninits);
+                        }
+                        pendingExits.append(exit);
+                    }
+                    inits.orSet(initsEnd);
+                }
+            } else {
+                inits.assign(initsEnd);
+                uninits.assign(uninitsEnd);
+                ListBuffer<AssignPendingExit> exits = pendingExits;
+                pendingExits = prevPendingExits;
+                while (exits.nonEmpty()) pendingExits.append(exits.next());
+            }
+            uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
+        }
+
+        public void visitConditional(JCConditional tree) {
+            scanCond(tree.cond);
+            final Bits initsBeforeElse = new Bits(initsWhenFalse);
+            final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
+            inits.assign(initsWhenTrue);
+            uninits.assign(uninitsWhenTrue);
+            if (tree.truepart.type != null && tree.truepart.type.hasTag(BOOLEAN) &&
+                tree.falsepart.type != null && tree.falsepart.type.hasTag(BOOLEAN)) {
+                // if b and c are boolean valued, then
+                // v is (un)assigned after a?b:c when true iff
+                //    v is (un)assigned after b when true and
+                //    v is (un)assigned after c when true
+                scanCond(tree.truepart);
+                final Bits initsAfterThenWhenTrue = new Bits(initsWhenTrue);
+                final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse);
+                final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue);
+                final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse);
+                inits.assign(initsBeforeElse);
+                uninits.assign(uninitsBeforeElse);
+                scanCond(tree.falsepart);
+                initsWhenTrue.andSet(initsAfterThenWhenTrue);
+                initsWhenFalse.andSet(initsAfterThenWhenFalse);
+                uninitsWhenTrue.andSet(uninitsAfterThenWhenTrue);
+                uninitsWhenFalse.andSet(uninitsAfterThenWhenFalse);
+            } else {
+                scanExpr(tree.truepart);
+                final Bits initsAfterThen = new Bits(inits);
+                final Bits uninitsAfterThen = new Bits(uninits);
+                inits.assign(initsBeforeElse);
+                uninits.assign(uninitsBeforeElse);
+                scanExpr(tree.falsepart);
+                inits.andSet(initsAfterThen);
+                uninits.andSet(uninitsAfterThen);
+            }
+        }
+
+        public void visitIf(JCIf tree) {
+            scanCond(tree.cond);
+            final Bits initsBeforeElse = new Bits(initsWhenFalse);
+            final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
+            inits.assign(initsWhenTrue);
+            uninits.assign(uninitsWhenTrue);
+            scan(tree.thenpart);
+            if (tree.elsepart != null) {
+                final Bits initsAfterThen = new Bits(inits);
+                final Bits uninitsAfterThen = new Bits(uninits);
+                inits.assign(initsBeforeElse);
+                uninits.assign(uninitsBeforeElse);
+                scan(tree.elsepart);
+                inits.andSet(initsAfterThen);
+                uninits.andSet(uninitsAfterThen);
+            } else {
+                inits.andSet(initsBeforeElse);
+                uninits.andSet(uninitsBeforeElse);
+            }
+        }
+
+        public void visitBreak(JCBreak tree) {
+            recordExit(tree, new AssignPendingExit(tree, inits, uninits));
+        }
+
+        public void visitContinue(JCContinue tree) {
+            recordExit(tree, new AssignPendingExit(tree, inits, uninits));
+        }
+
+        public void visitReturn(JCReturn tree) {
+            scanExpr(tree.expr);
+            recordExit(tree, new AssignPendingExit(tree, inits, uninits));
+        }
+
+        public void visitThrow(JCThrow tree) {
+            scanExpr(tree.expr);
+            markDead();
+        }
+
+        public void visitApply(JCMethodInvocation tree) {
+            scanExpr(tree.meth);
+            scanExprs(tree.args);
+        }
+
+        public void visitNewClass(JCNewClass tree) {
+            scanExpr(tree.encl);
+            scanExprs(tree.args);
+            scan(tree.def);
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            final Bits prevUninits = new Bits(uninits);
+            final Bits prevInits = new Bits(inits);
+            int returnadrPrev = returnadr;
+            ListBuffer<AssignPendingExit> prevPending = pendingExits;
+            try {
+                returnadr = nextadr;
+                pendingExits = new ListBuffer<AssignPendingExit>();
+                for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
+                    JCVariableDecl def = l.head;
+                    scan(def);
+                    inits.incl(def.sym.adr);
+                    uninits.excl(def.sym.adr);
+                }
+                if (tree.getBodyKind() == JCLambda.BodyKind.EXPRESSION) {
+                    scanExpr(tree.body);
+                } else {
+                    scan(tree.body);
+                }
+            }
+            finally {
+                returnadr = returnadrPrev;
+                uninits.assign(prevUninits);
+                inits.assign(prevInits);
+                pendingExits = prevPending;
+            }
+        }
+
+        public void visitNewArray(JCNewArray tree) {
+            scanExprs(tree.dims);
+            scanExprs(tree.elems);
+        }
+
+        public void visitAssert(JCAssert tree) {
+            final Bits initsExit = new Bits(inits);
+            final Bits uninitsExit = new Bits(uninits);
+            scanCond(tree.cond);
+            uninitsExit.andSet(uninitsWhenTrue);
+            if (tree.detail != null) {
+                inits.assign(initsWhenFalse);
+                uninits.assign(uninitsWhenFalse);
+                scanExpr(tree.detail);
+            }
+            inits.assign(initsExit);
+            uninits.assign(uninitsExit);
+        }
+
+        public void visitAssign(JCAssign tree) {
+            JCTree lhs = TreeInfo.skipParens(tree.lhs);
+            if (!(lhs instanceof JCIdent)) {
+                scanExpr(lhs);
+            }
+            scanExpr(tree.rhs);
+            letInit(lhs);
+        }
+
+        public void visitAssignop(JCAssignOp tree) {
             scanExpr(tree.lhs);
             scanExpr(tree.rhs);
+            letInit(tree.lhs);
         }
-    }
 
-    public void visitIdent(JCIdent tree) {
-        if (tree.sym != null && tree.sym.kind == VAR) {
-            checkInit(tree.pos(), (VarSymbol)tree.sym);
-            referenced(tree.sym);
+        public void visitUnary(JCUnary tree) {
+            switch (tree.getTag()) {
+            case NOT:
+                scanCond(tree.arg);
+                final Bits t = new Bits(initsWhenFalse);
+                initsWhenFalse.assign(initsWhenTrue);
+                initsWhenTrue.assign(t);
+                t.assign(uninitsWhenFalse);
+                uninitsWhenFalse.assign(uninitsWhenTrue);
+                uninitsWhenTrue.assign(t);
+                break;
+            case PREINC: case POSTINC:
+            case PREDEC: case POSTDEC:
+                scanExpr(tree.arg);
+                letInit(tree.arg);
+                break;
+            default:
+                scanExpr(tree.arg);
+            }
         }
-    }
 
-    public void visitErroneous(JCErroneous tree) {
-        for (JCTree err : tree.errs) {
-            //scanExpr ensures that (un)inits is non-null, which happens after scanCond (invoked e.g. by visitBinary):
-            scanExpr(err);
+        public void visitBinary(JCBinary tree) {
+            switch (tree.getTag()) {
+            case AND:
+                scanCond(tree.lhs);
+                final Bits initsWhenFalseLeft = new Bits(initsWhenFalse);
+                final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse);
+                inits.assign(initsWhenTrue);
+                uninits.assign(uninitsWhenTrue);
+                scanCond(tree.rhs);
+                initsWhenFalse.andSet(initsWhenFalseLeft);
+                uninitsWhenFalse.andSet(uninitsWhenFalseLeft);
+                break;
+            case OR:
+                scanCond(tree.lhs);
+                final Bits initsWhenTrueLeft = new Bits(initsWhenTrue);
+                final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue);
+                inits.assign(initsWhenFalse);
+                uninits.assign(uninitsWhenFalse);
+                scanCond(tree.rhs);
+                initsWhenTrue.andSet(initsWhenTrueLeft);
+                uninitsWhenTrue.andSet(uninitsWhenTrueLeft);
+                break;
+            default:
+                scanExpr(tree.lhs);
+                scanExpr(tree.rhs);
+            }
         }
-    }
 
-    void referenced(Symbol sym) {
-        unrefdResources.remove(sym);
-    }
+        public void visitIdent(JCIdent tree) {
+            if (tree.sym != null && tree.sym.kind == VAR) {
+                checkInit(tree.pos(), (VarSymbol)tree.sym);
+                referenced(tree.sym);
+            }
+        }
 
-    public void visitTypeCast(JCTypeCast tree) {
-        super.visitTypeCast(tree);
-        if (tree.type != null && !tree.type.isErroneous()
-            && lint.isEnabled(Lint.LintCategory.CAST)
-            && types.isSameType(tree.expr.type, tree.clazz.type)
-            && !is292targetTypeCast(tree)) {
-            log.warning(Lint.LintCategory.CAST,
-                    tree.pos(), "redundant.cast", tree.expr.type);
+        public void visitErroneous(JCErroneous tree) {
+            for (JCTree err : tree.errs) {
+                //scanExpr ensures that (un)inits is non-null, which happens after scanCond (invoked e.g. by visitBinary):
+                scanExpr(err);
+            }
         }
-    }
-    //where
-        private boolean is292targetTypeCast(JCTypeCast tree) {
-            boolean is292targetTypeCast = false;
-            JCExpression expr = TreeInfo.skipParens(tree.expr);
-            if (expr.getTag() == JCTree.APPLY) {
-                JCMethodInvocation apply = (JCMethodInvocation)expr;
-                Symbol sym = TreeInfo.symbol(apply.meth);
-                is292targetTypeCast = sym != null &&
-                    sym.kind == MTH &&
-                    (sym.flags() & POLYMORPHIC_SIGNATURE) != 0;
-            }
-            return is292targetTypeCast;
-        }
-
-    public void visitTopLevel(JCCompilationUnit tree) {
-        // Do nothing for TopLevel since each class is visited individually
-    }
 
-/**************************************************************************
- * main method
- *************************************************************************/
-
-    public void init(final TreeMaker make, final JCClassDecl enclClass) {
-        this.make = make;
-        inits = new Bits();
-        uninits = new Bits();
-        uninitsTry = new Bits();
-        initsWhenTrue = initsWhenFalse =
-            uninitsWhenTrue = uninitsWhenFalse = null;
-        if (vars == null)
-            vars = new VarSymbol[32];
-        else
-            for (int i=0; i<vars.length; i++)
-                vars[i] = null;
-        firstadr = 0;
-        nextadr = 0;
-        pendingExits = new ListBuffer<PendingExit>();
-        preciseRethrowTypes = new HashMap<Symbol, List<Type>>();
-        alive = true;
-        this.thrown = this.caught = null;
-        this.classDef = null;
-        unrefdResources = new Scope(enclClass.sym);
-    }
+        void referenced(Symbol sym) {
+            unrefdResources.remove(sym);
+        }
 
-    public void cleanup() {
-        // note that recursive invocations of this method fail hard
-        inits = uninits = uninitsTry = null;
-        initsWhenTrue = initsWhenFalse =
-            uninitsWhenTrue = uninitsWhenFalse = null;
-        if (vars != null) for (int i=0; i<vars.length; i++)
-            vars[i] = null;
-        firstadr = 0;
-        nextadr = 0;
-        pendingExits = null;
-        this.make = null;
-        this.thrown = this.caught = null;
-        this.classDef = null;
-        unrefdResources = null;
-    }
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            // annotations don't get scanned
+            tree.underlyingType.accept(this);
+        }
 
-    public void reanalyzeMethod (final TreeMaker make, final JCClassDecl classDef) {
-        JCClassDecl oldReanalyzedClass = reanalyzedClass;
-        try {
-            init (make, classDef);
-            reanalyzedClass = classDef;
-            scan(classDef);
-        } finally {
-            reanalyzedClass = oldReanalyzedClass;
-            cleanup();
+        public void visitTopLevel(JCCompilationUnit tree) {
+            // Do nothing for TopLevel since each class is visited individually
+        }
+
+    /**************************************************************************
+     * main method
+     *************************************************************************/
+
+        /** Perform definite assignment/unassignment analysis on a tree.
+         */
+        public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
+            analyzeTree(env, env.tree, make);
+        }
+
+        public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) {
+            try {
+                attrEnv = env;
+                Flow.this.make = make;
+                startPos = tree.pos().getStartPosition();
+
+                if (vars == null)
+                    vars = new VarSymbol[32];
+                else
+                    for (int i=0; i<vars.length; i++)
+                        vars[i] = null;
+                firstadr = 0;
+                nextadr = 0;
+                pendingExits = new ListBuffer<AssignPendingExit>();
+                this.classDef = null;
+                unrefdResources = new Scope(env.enclClass.sym);
+                scan(tree);
+            } finally {
+                // note that recursive invocations of this method fail hard
+                startPos = -1;
+                resetBits(inits, uninits, uninitsTry, initsWhenTrue,
+                        initsWhenFalse, uninitsWhenTrue, uninitsWhenFalse);
+                if (vars != null) for (int i=0; i<vars.length; i++)
+                    vars[i] = null;
+                firstadr = 0;
+                nextadr = 0;
+                pendingExits = null;
+                Flow.this.make = null;
+                this.classDef = null;
+                unrefdResources = null;
+            }
         }
     }
 
-    /** Perform definite assignment/unassignment analysis on a tree.
+    /**
+     * This pass implements the last step of the dataflow analysis, namely
+     * the effectively-final analysis check. This checks that every local variable
+     * reference from a lambda body/local inner class is either final or effectively final.
+     * As effectively final variables are marked as such during DA/DU, this pass must run after
+     * AssignAnalyzer.
      */
-    public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
-        try {
-            attrEnv = env;
-            JCTree tree = env.tree;
-            init(make, env.enclClass);
-            scan(tree);
-        } finally {
-            cleanup();
+    class CaptureAnalyzer extends BaseAnalyzer<BaseAnalyzer.PendingExit> {
+
+        JCTree currentTree; //local class or lambda
+
+        @Override
+        void markDead() {
+            //do nothing
+        }
+
+        @SuppressWarnings("fallthrough")
+        void checkEffectivelyFinal(DiagnosticPosition pos, VarSymbol sym) {
+            if (currentTree != null &&
+                    sym.owner.kind == MTH &&
+                    sym.pos < currentTree.getStartPosition()) {
+                switch (currentTree.getTag()) {
+                    case CLASSDEF:
+                        if (!allowEffectivelyFinalInInnerClasses) {
+                            if ((sym.flags() & FINAL) == 0) {
+                                reportInnerClsNeedsFinalError(pos, sym);
+                            }
+                            break;
+                        }
+                    case LAMBDA:
+                        if ((sym.flags() & (EFFECTIVELY_FINAL | FINAL)) == 0) {
+                           reportEffectivelyFinalError(pos, sym);
+                        }
+                }
+            }
+        }
+
+        @SuppressWarnings("fallthrough")
+        void letInit(JCTree tree) {
+            tree = TreeInfo.skipParens(tree);
+            if (tree.hasTag(IDENT) || tree.hasTag(SELECT)) {
+                Symbol sym = TreeInfo.symbol(tree);
+                if (currentTree != null &&
+                        sym.kind == VAR &&
+                        sym.owner.kind == MTH &&
+                        ((VarSymbol)sym).pos < currentTree.getStartPosition()) {
+                    switch (currentTree.getTag()) {
+                        case CLASSDEF:
+                            if (!allowEffectivelyFinalInInnerClasses) {
+                                reportInnerClsNeedsFinalError(tree, sym);
+                                break;
+                            }
+                        case LAMBDA:
+                            reportEffectivelyFinalError(tree, sym);
+                    }
+                }
+            }
+        }
+
+        void reportEffectivelyFinalError(DiagnosticPosition pos, Symbol sym) {
+            String subKey = currentTree.hasTag(LAMBDA) ?
+                  "lambda"  : "inner.cls";
+            log.error(pos, "cant.ref.non.effectively.final.var", sym, diags.fragment(subKey));
+        }
+
+        void reportInnerClsNeedsFinalError(DiagnosticPosition pos, Symbol sym) {
+            log.error(pos,
+                    "local.var.accessed.from.icls.needs.final",
+                    sym);
+        }
+
+    /*************************************************************************
+     * Visitor methods for statements and definitions
+     *************************************************************************/
+
+        /* ------------ Visitor methods for various sorts of trees -------------*/
+
+        public void visitClassDef(JCClassDecl tree) {
+            JCTree prevTree = currentTree;
+            try {
+                currentTree = tree.sym.isLocal() ? tree : null;
+                super.visitClassDef(tree);
+            } finally {
+                currentTree = prevTree;
+            }
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            JCTree prevTree = currentTree;
+            try {
+                currentTree = tree;
+                super.visitLambda(tree);
+            } finally {
+                currentTree = prevTree;
+            }
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            if (tree.sym != null && tree.sym.kind == VAR) {
+                checkEffectivelyFinal(tree, (VarSymbol)tree.sym);
+            }
+        }
+
+        public void visitAssign(JCAssign tree) {
+            JCTree lhs = TreeInfo.skipParens(tree.lhs);
+            if (!(lhs instanceof JCIdent)) {
+                scan(lhs);
+            }
+            scan(tree.rhs);
+            letInit(lhs);
+        }
+
+        public void visitAssignop(JCAssignOp tree) {
+            scan(tree.lhs);
+            scan(tree.rhs);
+            letInit(tree.lhs);
+        }
+
+        public void visitUnary(JCUnary tree) {
+            switch (tree.getTag()) {
+                case PREINC: case POSTINC:
+                case PREDEC: case POSTDEC:
+                    scan(tree.arg);
+                    letInit(tree.arg);
+                    break;
+                default:
+                    scan(tree.arg);
+            }
+        }
+
+        public void visitTopLevel(JCCompilationUnit tree) {
+            // Do nothing for TopLevel since each class is visited individually
+        }
+
+    /**************************************************************************
+     * main method
+     *************************************************************************/
+
+        /** Perform definite assignment/unassignment analysis on a tree.
+         */
+        public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
+            analyzeTree(env, env.tree, make);
+        }
+        public void analyzeTree(Env<AttrContext> env, JCTree tree, TreeMaker make) {
+            try {
+                attrEnv = env;
+                Flow.this.make = make;
+                pendingExits = new ListBuffer<PendingExit>();
+                scan(tree);
+            } finally {
+                pendingExits = null;
+                Flow.this.make = null;
+            }
         }
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java
index a7093dd..ebeaba2 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java
@@ -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
@@ -29,14 +29,30 @@ import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCTypeCast;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.*;
+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.Type.*;
-import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
+import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
+import com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph;
+import com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node;
+import com.sun.tools.javac.comp.Resolve.InapplicableMethodException;
+import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode;
 
-import static com.sun.tools.javac.code.TypeTags.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+
+import static com.sun.tools.javac.code.TypeTag.*;
 
 /** Helper class for type parameter inference, used by the attribution phase.
  *
@@ -49,14 +65,15 @@ public class Infer {
     protected static final Context.Key<Infer> inferKey =
         new Context.Key<Infer>();
 
-    /** A value for prototypes that admit any type, including polymorphic ones. */
-    public static final Type anyPoly = new Type(NONE, null);
-
+    Resolve rs;
+    Check chk;
     Symtab syms;
     Types types;
-    Check chk;
-    Resolve rs;
     JCDiagnostic.Factory diags;
+    Log log;
+
+    /** should the graph solver be used? */
+    boolean allowGraphInference;
 
     public static Infer instance(Context context) {
         Infer instance = context.get(inferKey);
@@ -67,551 +84,222 @@ public class Infer {
 
     protected Infer(Context context) {
         context.put(inferKey, this);
-        syms = Symtab.instance(context);
-        types = Types.instance(context);
+
         rs = Resolve.instance(context);
         chk = Check.instance(context);
+        syms = Symtab.instance(context);
+        types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
-        ambiguousNoInstanceException =
-            new NoInstanceException(true, diags);
-        unambiguousNoInstanceException =
-            new NoInstanceException(false, diags);
-        invalidInstanceException =
-            new InvalidInstanceException(diags);
-
-    }
-
-    public static class InferenceException extends Resolve.InapplicableMethodException {
-        private static final long serialVersionUID = 0;
-
-        InferenceException(JCDiagnostic.Factory diags) {
-            super(diags);
-        }
+        log = Log.instance(context);
+        inferenceException = new InferenceException(diags);
+        Options options = Options.instance(context);
+        allowGraphInference = Source.instance(context).allowGraphInference()
+                && options.isUnset("useLegacyInference");
     }
 
-    public static class NoInstanceException extends InferenceException {
-        private static final long serialVersionUID = 1;
-
-        boolean isAmbiguous; // exist several incomparable best instances?
+    /** A value for prototypes that admit any type, including polymorphic ones. */
+    public static final Type anyPoly = new JCNoType();
 
-        NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) {
-            super(diags);
-            this.isAmbiguous = isAmbiguous;
-        }
-    }
+   /**
+    * This exception class is design to store a list of diagnostics corresponding
+    * to inference errors that can arise during a method applicability check.
+    */
+    public static class InferenceException extends InapplicableMethodException {
+        private static final long serialVersionUID = 0;
 
-    public static class InvalidInstanceException extends InferenceException {
-        private static final long serialVersionUID = 2;
+        List<JCDiagnostic> messages = List.nil();
 
-        InvalidInstanceException(JCDiagnostic.Factory diags) {
+        InferenceException(JCDiagnostic.Factory diags) {
             super(diags);
         }
-    }
-
-    private final NoInstanceException ambiguousNoInstanceException;
-    private final NoInstanceException unambiguousNoInstanceException;
-    private final InvalidInstanceException invalidInstanceException;
-
-/***************************************************************************
- * Auxiliary type values and classes
- ***************************************************************************/
-
-    /** A mapping that turns type variables into undetermined type variables.
-     */
-    Mapping fromTypeVarFun = new Mapping("fromTypeVarFun") {
-            public Type apply(Type t) {
-                if (t.tag == TYPEVAR) return new UndetVar(t);
-                else return t.map(this);
-            }
-        };
-
-    /** A mapping that returns its type argument with every UndetVar replaced
-     *  by its `inst' field. Throws a NoInstanceException
-     *  if this not possible because an `inst' field is null.
-     *  Note: mutually referring undertvars will be left uninstantiated
-     *  (that is, they will be replaced by the underlying type-variable).
-     */
-
-    Mapping getInstFun = new Mapping("getInstFun") {
-            public Type apply(Type t) {
-                switch (t.tag) {
-                    case UNKNOWN:
-                        throw ambiguousNoInstanceException
-                            .setMessage("undetermined.type");
-                    case UNDETVAR:
-                        UndetVar that = (UndetVar) t;
-                        if (that.inst == null)
-                            throw ambiguousNoInstanceException
-                                .setMessage("type.variable.has.undetermined.type",
-                                            that.qtype);
-                        return isConstraintCyclic(that) ?
-                            that.qtype :
-                            apply(that.inst);
-                        default:
-                            return t.map(this);
-                }
-            }
-
-            private boolean isConstraintCyclic(UndetVar uv) {
-                Types.UnaryVisitor<Boolean> constraintScanner =
-                        new Types.UnaryVisitor<Boolean>() {
-
-                    List<Type> seen = List.nil();
-
-                    Boolean visit(List<Type> ts) {
-                        for (Type t : ts) {
-                            if (visit(t)) return true;
-                        }
-                        return false;
-                    }
-
-                    public Boolean visitType(Type t, Void ignored) {
-                        return false;
-                    }
-
-                    @Override
-                    public Boolean visitClassType(ClassType t, Void ignored) {
-                        if (t.isCompound()) {
-                            return visit(types.supertype(t)) ||
-                                    visit(types.interfaces(t));
-                        } else {
-                            return visit(t.getTypeArguments());
-                        }
-                    }
-                    @Override
-                    public Boolean visitWildcardType(WildcardType t, Void ignored) {
-                        return visit(t.type);
-                    }
-
-                    @Override
-                    public Boolean visitUndetVar(UndetVar t, Void ignored) {
-                        if (seen.contains(t)) {
-                            return true;
-                        } else {
-                            seen = seen.prepend(t);
-                            return visit(t.inst);
-                        }
-                    }
-                };
-                return constraintScanner.visit(uv);
-            }
-        };
-
-/***************************************************************************
- * Mini/Maximization of UndetVars
- ***************************************************************************/
-
-    /** Instantiate undetermined type variable to its minimal upper bound.
-     *  Throw a NoInstanceException if this not possible.
-     */
-    void maximizeInst(UndetVar that, Warner warn) throws NoInstanceException {
-        List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
-        if (that.inst == null) {
-            if (hibounds.isEmpty())
-                that.inst = syms.objectType;
-            else if (hibounds.tail.isEmpty())
-                that.inst = hibounds.head;
-            else
-                that.inst = types.glb(hibounds);
-        }
-        if (that.inst == null ||
-            that.inst.isErroneous())
-            throw ambiguousNoInstanceException
-                .setMessage("no.unique.maximal.instance.exists",
-                            that.qtype, hibounds);
-    }
-    //where
-        private boolean isSubClass(Type t, final List<Type> ts) {
-            t = t.baseType();
-            if (t.tag == TYPEVAR) {
-                List<Type> bounds = types.getBounds((TypeVar)t);
-                for (Type s : ts) {
-                    if (!types.isSameType(t, s.baseType())) {
-                        for (Type bound : bounds) {
-                            if (!isSubClass(bound, List.of(s.baseType())))
-                                return false;
-                        }
-                    }
-                }
-            } else {
-                for (Type s : ts) {
-                    if (!t.tsym.isSubClass(s.baseType().tsym, types))
-                        return false;
-                }
-            }
-            return true;
-        }
 
-    private Filter<Type> errorFilter = new Filter<Type>() {
         @Override
-        public boolean accepts(Type t) {
-            return !t.isErroneous();
+        InapplicableMethodException setMessage(JCDiagnostic diag) {
+            if (diag != null) {
+                messages = messages.append(diag);
+            }
+            return this;
         }
-    };
 
-    private final Filter<Type> botFilter = new Filter<Type>() {
         @Override
-        public boolean accepts(Type t) {
-            return t.tag != BOT;
+        public JCDiagnostic getDiagnostic() {
+            return messages.head;
         }
-    };
 
-    /** Instantiate undetermined type variable to the lub of all its lower bounds.
-     *  Throw a NoInstanceException if this not possible.
-     */
-    void minimizeInst(UndetVar that, Warner warn) throws NoInstanceException {
-        List<Type> lobounds = Type.filter(that.lobounds, errorFilter);
-        if (that.inst == null) {
-            if (lobounds.isEmpty())
-                that.inst = syms.botType;
-            else if (lobounds.tail.isEmpty())
-                that.inst = lobounds.head.isPrimitive() ? syms.errType : lobounds.head;
-            else {
-                that.inst = types.lub(lobounds);
-            }
-            if (that.inst == null || that.inst.tag == ERROR)
-                    throw ambiguousNoInstanceException
-                        .setMessage("no.unique.minimal.instance.exists",
-                                    that.qtype, lobounds);
-            // VGJ: sort of inlined maximizeInst() below.  Adding
-            // bounds can cause lobounds that are above hibounds.
-            List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
-            Type hb = null;
-            if (hibounds.isEmpty())
-                hb = syms.objectType;
-            else if (hibounds.tail.isEmpty())
-                hb = hibounds.head;
-            else
-                hb = types.glb(hibounds);
-            if (hb == null ||
-                hb.isErroneous())
-                throw ambiguousNoInstanceException
-                        .setMessage("incompatible.upper.bounds",
-                                    that.qtype, hibounds);
+        void clear() {
+            messages = List.nil();
         }
     }
 
-/***************************************************************************
- * Exported Methods
- ***************************************************************************/
-
-    /** Try to instantiate expression type `that' to given type `to'.
-     *  If a maximal instantiation exists which makes this type
-     *  a subtype of type `to', return the instantiated type.
-     *  If no instantiation exists, or if several incomparable
-     *  best instantiations exist throw a NoInstanceException.
-     */
-    public Type instantiateExpr(ForAll that,
-                                Type to,
-                                Warner warn) throws InferenceException {
-        List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
-        for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
-            UndetVar uv = (UndetVar) l.head;
-            TypeVar tv = (TypeVar)uv.qtype;
-            ListBuffer<Type> hibounds = new ListBuffer<Type>();
-            for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) {
-                hibounds.append(types.subst(t, that.tvars, undetvars));
-            }
-
-            List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
-            if (inst.nonEmpty() && inst.head.tag != BOT) {
-                uv.inst = inst.head;
-            }
-            uv.hibounds = hibounds.toList();
-        }
-        Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
-        if (!types.isSubtype(qtype1,
-                qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
-            throw unambiguousNoInstanceException
-                .setMessage("infer.no.conforming.instance.exists",
-                            that.tvars, that.qtype, to);
-        }
-        for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
-            maximizeInst((UndetVar) l.head, warn);
-        // System.out.println(" = " + qtype1.map(getInstFun));//DEBUG
-
-        // check bounds
-        List<Type> targs = Type.map(undetvars, getInstFun);
-        if (Type.containsAny(targs, that.tvars)) {
-            //replace uninferred type-vars
-            targs = types.subst(targs,
-                    that.tvars,
-                    instantiateAsUninferredVars(undetvars, that.tvars));
-        }
-        return chk.checkType(warn.pos(), that.inst(targs, types), to);
-    }
-    //where
-    private List<Type> instantiateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
-        Assert.check(undetvars.length() == tvars.length());
-        ListBuffer<Type> new_targs = ListBuffer.lb();
-        //step 1 - create synthetic captured vars
-        for (Type t : undetvars) {
-            UndetVar uv = (UndetVar)t;
-            Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
-            new_targs = new_targs.append(newArg);
-        }
-        //step 2 - replace synthetic vars in their bounds
-        List<Type> formals = tvars;
-        for (Type t : new_targs.toList()) {
-            CapturedType ct = (CapturedType)t;
-            ct.bound = types.subst(ct.bound, tvars, new_targs.toList());
-            WildcardType wt = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass);
-            wt.bound = (TypeVar)formals.head;
-            ct.wildcard = wt;
-            formals = formals.tail;
-        }
-        return new_targs.toList();
-    }
+    protected final InferenceException inferenceException;
 
-    /** Instantiate method type `mt' by finding instantiations of
-     *  `tvars' so that method can be applied to `argtypes'.
+    // <editor-fold defaultstate="collapsed" desc="Inference routines">
+    /**
+     * Main inference entry point - instantiate a generic method type
+     * using given argument types and (possibly) an expected target-type.
      */
-    public Type instantiateMethod(final Env<AttrContext> env,
+    public Type instantiateMethod(Env<AttrContext> env,
                                   List<Type> tvars,
                                   MethodType mt,
-                                  final Symbol msym,
-                                  final List<Type> argtypes,
-                                  final boolean allowBoxing,
-                                  final boolean useVarargs,
-                                  final Warner warn) throws InferenceException {
+                                  Attr.ResultInfo resultInfo,
+                                  Symbol msym,
+                                  List<Type> argtypes,
+                                  boolean allowBoxing,
+                                  boolean useVarargs,
+                                  Resolve.MethodResolutionContext resolveContext,
+                                  Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
-        List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
-        List<Type> formals = mt.argtypes;
-        //need to capture exactly once - otherwise subsequent
-        //applicability checks might fail
-        final List<Type> capturedArgs = types.capture(argtypes);
-        List<Type> actuals = capturedArgs;
-        List<Type> actualsNoCapture = argtypes;
-        // instantiate all polymorphic argument types and
-        // set up lower bounds constraints for undetvars
-        Type varargsFormal = useVarargs ? formals.last() : null;
-        if (varargsFormal == null &&
-                actuals.size() != formals.size()) {
-            throw unambiguousNoInstanceException
-                .setMessage("infer.arg.length.mismatch");
-        }
-        while (actuals.nonEmpty() && formals.head != varargsFormal) {
-            Type formal = formals.head;
-            Type actual = actuals.head.baseType();
-            Type actualNoCapture = actualsNoCapture.head.baseType();
-            if (actual.tag == FORALL)
-                actual = instantiateArg((ForAll)actual, formal, tvars, warn);
-            Type undetFormal = types.subst(formal, tvars, undetvars);
-            boolean works = allowBoxing
-                ? types.isConvertible(actual, undetFormal, warn)
-                : types.isSubtypeUnchecked(actual, undetFormal, warn);
-            if (!works) {
-                throw unambiguousNoInstanceException
-                    .setMessage("infer.no.conforming.assignment.exists",
-                                tvars, actualNoCapture, formal);
-            }
-            formals = formals.tail;
-            actuals = actuals.tail;
-            actualsNoCapture = actualsNoCapture.tail;
-        }
-
-        if (formals.head != varargsFormal) // not enough args
-            throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
-
-        // for varargs arguments as well
-        if (useVarargs) {
-            Type elemType = types.elemtype(varargsFormal);
-            Type elemUndet = types.subst(elemType, tvars, undetvars);
-            while (actuals.nonEmpty()) {
-                Type actual = actuals.head.baseType();
-                Type actualNoCapture = actualsNoCapture.head.baseType();
-                if (actual.tag == FORALL)
-                    actual = instantiateArg((ForAll)actual, elemType, tvars, warn);
-                boolean works = types.isConvertible(actual, elemUndet, warn);
-                if (!works) {
-                    throw unambiguousNoInstanceException
-                        .setMessage("infer.no.conforming.assignment.exists",
-                                    tvars, actualNoCapture, elemType);
+        final InferenceContext inferenceContext = new InferenceContext(tvars);
+        inferenceException.clear();
+        try {
+            DeferredAttr.DeferredAttrContext deferredAttrContext =
+                        resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn);
+
+            resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext,
+                    argtypes, mt.getParameterTypes(), warn);
+
+            if (allowGraphInference &&
+                    resultInfo != null &&
+                    !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+                //inject return constraints earlier
+                checkWithinBounds(inferenceContext, warn); //propagation
+                Type newRestype = generateReturnConstraints(resultInfo, mt, inferenceContext);
+                mt = (MethodType)types.createMethodTypeWithReturn(mt, newRestype);
+                //propagate outwards if needed
+                if (resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) {
+                    //propagate inference context outwards and exit
+                    inferenceContext.dupTo(resultInfo.checkContext.inferenceContext());
+                    deferredAttrContext.complete();
+                    return mt;
                 }
-                actuals = actuals.tail;
-                actualsNoCapture = actualsNoCapture.tail;
             }
-        }
 
-        // minimize as yet undetermined type variables
-        for (Type t : undetvars)
-            minimizeInst((UndetVar) t, warn);
+            deferredAttrContext.complete();
 
-        /** Type variables instantiated to bottom */
-        ListBuffer<Type> restvars = new ListBuffer<Type>();
+            // minimize as yet undetermined type variables
+            if (allowGraphInference) {
+                inferenceContext.solve(warn);
+            } else {
+                inferenceContext.solveLegacy(true, warn, LegacyInferenceSteps.EQ_LOWER.steps); //minimizeInst
+            }
 
-        /** Undet vars instantiated to bottom */
-        final ListBuffer<Type> restundet = new ListBuffer<Type>();
+            mt = (MethodType)inferenceContext.asInstType(mt);
 
-        /** Instantiated types or TypeVars if under-constrained */
-        ListBuffer<Type> insttypes = new ListBuffer<Type>();
+            if (!allowGraphInference &&
+                    inferenceContext.restvars().nonEmpty() &&
+                    resultInfo != null &&
+                    !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+                generateReturnConstraints(resultInfo, mt, inferenceContext);
+                inferenceContext.solveLegacy(false, warn, LegacyInferenceSteps.EQ_UPPER.steps); //maximizeInst
+                mt = (MethodType)inferenceContext.asInstType(mt);
+            }
 
-        /** Instantiated types or UndetVars if under-constrained */
-        ListBuffer<Type> undettypes = new ListBuffer<Type>();
+            if (resultInfo != null && rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
+                log.note(env.tree.pos, "deferred.method.inst", msym, mt, resultInfo.pt);
+            }
 
-        for (Type t : undetvars) {
-            UndetVar uv = (UndetVar)t;
-            if (uv.inst.tag == BOT) {
-                restvars.append(uv.qtype);
-                restundet.append(uv);
-                insttypes.append(uv.qtype);
-                undettypes.append(uv);
-                uv.inst = null;
+            // return instantiated version of method type
+            return mt;
+        } finally {
+            if (resultInfo != null || !allowGraphInference) {
+                inferenceContext.notifyChange();
             } else {
-                insttypes.append(uv.inst);
-                undettypes.append(uv.inst);
+                inferenceContext.notifyChange(inferenceContext.boundedVars());
             }
         }
-        checkWithinBounds(tvars, undettypes.toList(), warn);
-
-        mt = (MethodType)types.subst(mt, tvars, insttypes.toList());
+    }
 
-        if (!restvars.isEmpty()) {
-            // if there are uninstantiated variables,
-            // quantify result type with them
-            final List<Type> inferredTypes = insttypes.toList();
-            final List<Type> all_tvars = tvars; //this is the wrong tvars
-            return new UninferredMethodType(mt, restvars.toList()) {
-                @Override
-                List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
-                    for (Type t : restundet.toList()) {
-                        UndetVar uv = (UndetVar)t;
-                        if (uv.qtype == tv) {
-                            switch (ck) {
-                                case EXTENDS: return Type.filter(uv.hibounds, botFilter)
-                                        .appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
-                                case SUPER: return uv.lobounds;
-                                case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
-                            }
-                        }
-                    }
-                    return List.nil();
+    /**
+     * Generate constraints from the generic method's return type. If the method
+     * call occurs in a context where a type T is expected, use the expected
+     * type to derive more constraints on the generic method inference variables.
+     */
+    Type generateReturnConstraints(Attr.ResultInfo resultInfo,
+            MethodType mt, InferenceContext inferenceContext) {
+        Type from = mt.getReturnType();
+        if (mt.getReturnType().containsAny(inferenceContext.inferencevars) &&
+                resultInfo.checkContext.inferenceContext() != emptyContext) {
+            from = types.capture(from);
+            //add synthetic captured ivars
+            for (Type t : from.getTypeArguments()) {
+                if (t.hasTag(TYPEVAR) && ((TypeVar)t).isCaptured()) {
+                    inferenceContext.addVar((TypeVar)t);
                 }
-                @Override
-                void check(List<Type> inferred, Types types) throws NoInstanceException {
-                    // check that actuals conform to inferred formals
-                    checkArgumentsAcceptable(env, capturedArgs, getParameterTypes(), allowBoxing, useVarargs, warn);
-                    // check that inferred bounds conform to their bounds
-                    checkWithinBounds(all_tvars,
-                           types.subst(inferredTypes, tvars, inferred), warn);
-                    if (useVarargs) {
-                        chk.checkVararg(env.tree.pos(), getParameterTypes(), msym);
-                    }
-            }};
+            }
         }
-        else {
-            // check that actuals conform to inferred formals
-            checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
-            // return instantiated version of method type
-            return mt;
+        Type qtype1 = inferenceContext.asFree(from);
+        Type to = returnConstraintTarget(qtype1, resultInfo.pt);
+        Assert.check(allowGraphInference || !resultInfo.checkContext.inferenceContext().free(to),
+                "legacy inference engine cannot handle constraints on both sides of a subtyping assertion");
+        //we need to skip capture?
+        Warner retWarn = new Warner();
+        if (!resultInfo.checkContext.compatible(qtype1, resultInfo.checkContext.inferenceContext().asFree(to), retWarn) ||
+                //unchecked conversion is not allowed in source 7 mode
+                (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) {
+            throw inferenceException
+                    .setMessage("infer.no.conforming.instance.exists",
+                    inferenceContext.restvars(), mt.getReturnType(), to);
         }
+        return from;
     }
-    //where
-
-        /**
-         * A delegated type representing a partially uninferred method type.
-         * The return type of a partially uninferred method type is a ForAll
-         * type - when the return type is instantiated (see Infer.instantiateExpr)
-         * the underlying method type is also updated.
-         */
-        static abstract class UninferredMethodType extends DelegatedType {
 
-            final List<Type> tvars;
-
-            public UninferredMethodType(MethodType mtype, List<Type> tvars) {
-                super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
-                this.tvars = tvars;
-                asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
-            }
-
-            @Override
-            public MethodType asMethodType() {
-                return qtype.asMethodType();
-            }
-
-            @Override
-            public Type map(Mapping f) {
-                return qtype.map(f);
-            }
-
-            void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
-                //update method type with newly inferred type-arguments
-                qtype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
-                                       restype,
-                                       types.subst(UninferredMethodType.this.getThrownTypes(), tvars, inferred),
-                                       UninferredMethodType.this.qtype.tsym);
-                check(inferred, types);
+    Type returnConstraintTarget(Type from, Type to) {
+        if (from.hasTag(VOID)) {
+            return syms.voidType;
+        } else if (to.hasTag(NONE)) {
+            return from.isPrimitive() ? from : syms.objectType;
+        } else if (from.hasTag(UNDETVAR) && to.isPrimitive()) {
+            if (!allowGraphInference) {
+                //if legacy, just return boxed type
+                return types.boxedClass(to).type;
             }
-
-            abstract void check(List<Type> inferred, Types types) throws NoInstanceException;
-
-            abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
-
-            class UninferredReturnType extends ForAll {
-                public UninferredReturnType(List<Type> tvars, Type restype) {
-                    super(tvars, restype);
-                }
-                @Override
-                public Type inst(List<Type> actuals, Types types) {
-                    Type newRestype = super.inst(actuals, types);
-                    instantiateReturnType(newRestype, actuals, types);
-                    return newRestype;
-                }
-                @Override
-                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
-                    return UninferredMethodType.this.getConstraints(tv, ck);
+            //if graph inference we need to skip conflicting boxed bounds...
+            UndetVar uv = (UndetVar)from;
+            for (Type t : uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)) {
+                Type boundAsPrimitive = types.unboxedType(t);
+                if (boundAsPrimitive == null) continue;
+                if (types.isConvertible(boundAsPrimitive, to)) {
+                    //effectively skip return-type constraint generation (compatibility)
+                    return syms.objectType;
                 }
             }
+            return types.boxedClass(to).type;
+        } else {
+            return to;
         }
+    }
 
-        private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
-                boolean allowBoxing, boolean useVarargs, Warner warn) {
-            try {
-                rs.checkRawArgumentsAcceptable(env, actuals, formals,
-                       allowBoxing, useVarargs, warn);
-            }
-            catch (Resolve.InapplicableMethodException ex) {
-                // inferred method is not applicable
-                throw invalidInstanceException.setMessage(ex.getDiagnostic());
+    /**
+      * Infer cyclic inference variables as described in 15.12.2.8.
+      */
+    private void instantiateAsUninferredVars(List<Type> vars, InferenceContext inferenceContext) {
+        ListBuffer<Type> todo = ListBuffer.lb();
+        //step 1 - create fresh tvars
+        for (Type t : vars) {
+            UndetVar uv = (UndetVar)inferenceContext.asFree(t);
+            List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER);
+            if (Type.containsAny(upperBounds, vars)) {
+                TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner);
+                fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), syms.botType);
+                todo.append(uv);
+                uv.inst = fresh_tvar.type;
+            } else if (upperBounds.nonEmpty()) {
+                uv.inst = types.glb(upperBounds);
+            } else {
+                uv.inst = syms.objectType;
             }
         }
-
-    /** Try to instantiate argument type `that' to given type `to'.
-     *  If this fails, try to insantiate `that' to `to' where
-     *  every occurrence of a type variable in `tvars' is replaced
-     *  by an unknown type.
-     */
-    private Type instantiateArg(ForAll that,
-                                Type to,
-                                List<Type> tvars,
-                                Warner warn) throws InferenceException {
-        List<Type> targs;
-        try {
-            return instantiateExpr(that, to, warn);
-        } catch (NoInstanceException ex) {
-            Type to1 = to;
-            for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
-                to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
-            return instantiateExpr(that, to1, warn);
-        }
-    }
-
-    /** check that type parameters are within their bounds.
-     */
-    void checkWithinBounds(List<Type> tvars,
-                                   List<Type> arguments,
-                                   Warner warn)
-        throws InvalidInstanceException {
-        for (List<Type> tvs = tvars, args = arguments;
-             tvs.nonEmpty();
-             tvs = tvs.tail, args = args.tail) {
-            if (args.head instanceof UndetVar ||
-                    tvars.head.getUpperBound().isErroneous()) continue;
-            List<Type> bounds = types.subst(types.getBounds((TypeVar)tvs.head), tvars, arguments);
-            if (!types.isSubtypeUnchecked(args.head, bounds, warn))
-                throw invalidInstanceException
-                    .setMessage("inferred.do.not.conform.to.bounds",
-                                args.head, bounds);
+        //step 2 - replace fresh tvars in their bounds
+        List<Type> formals = vars;
+        for (Type t : todo) {
+            UndetVar uv = (UndetVar)t;
+            TypeVar ct = (TypeVar)uv.inst;
+            ct.bound = types.glb(inferenceContext.asInstTypes(types.getBounds(ct)));
+            if (ct.bound.isErroneous()) {
+                //report inference error if glb fails
+                reportBoundError(uv, BoundErrorKind.BAD_UPPER);
+            }
+            formals = formals.tail;
         }
     }
 
@@ -620,9 +308,9 @@ public class Infer {
      * method signature. The target return type is computed from the immediately
      * enclosing scope surrounding the polymorphic-signature call.
      */
-    Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site,
-                                            Name name,
+    Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env,
                                             MethodSymbol spMethod,  // sig. poly. method or null if none
+                                            Resolve.MethodResolutionContext resolveContext,
                                             List<Type> argtypes) {
         final Type restype;
 
@@ -635,13 +323,13 @@ public class Infer {
         //the polymorphic signature call environment is nested.
 
         switch (env.next.tree.getTag()) {
-            case JCTree.TYPECAST:
+            case TYPECAST:
                 JCTypeCast castTree = (JCTypeCast)env.next.tree;
                 restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ?
                     castTree.clazz.type :
                     syms.objectType;
                 break;
-            case JCTree.EXEC:
+            case EXEC:
                 JCTree.JCExpressionStatement execTree =
                         (JCTree.JCExpressionStatement)env.next.tree;
                 restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ?
@@ -652,7 +340,7 @@ public class Infer {
                 restype = syms.objectType;
         }
 
-        List<Type> paramtypes = Type.map(argtypes, implicitArgType);
+        List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step));
         List<Type> exType = spMethod != null ?
             spMethod.getThrownTypes() :
             List.of(syms.throwableType); // make it throw all exceptions
@@ -664,14 +352,1580 @@ public class Infer {
         return mtype;
     }
     //where
-        Mapping implicitArgType = new Mapping ("implicitArgType") {
-                public Type apply(Type t) {
-                    t = types.erasure(t);
-                    if (t.tag == BOT)
-                        // nulls type as the marker type Null (which has no instances)
-                        // infer as java.lang.Void for now
-                        t = types.boxedClass(syms.voidType).type;
-                    return t;
+        class ImplicitArgType extends DeferredAttr.DeferredTypeMap {
+
+            public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) {
+                rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase);
+            }
+
+            public Type apply(Type t) {
+                t = types.erasure(super.apply(t));
+                if (t.hasTag(BOT))
+                    // nulls type as the marker type Null (which has no instances)
+                    // infer as java.lang.Void for now
+                    t = types.boxedClass(syms.voidType).type;
+                return t;
+            }
+        }
+
+    /**
+      * This method is used to infer a suitable target SAM in case the original
+      * SAM type contains one or more wildcards. An inference process is applied
+      * so that wildcard bounds, as well as explicit lambda/method ref parameters
+      * (where applicable) are used to constraint the solution.
+      */
+    public Type instantiateFunctionalInterface(DiagnosticPosition pos, Type funcInterface,
+            List<Type> paramTypes, Check.CheckContext checkContext) {
+        if (types.capture(funcInterface) == funcInterface) {
+            //if capture doesn't change the type then return the target unchanged
+            //(this means the target contains no wildcards!)
+            return funcInterface;
+        } else {
+            Type formalInterface = funcInterface.tsym.type;
+            InferenceContext funcInterfaceContext =
+                    new InferenceContext(funcInterface.tsym.type.getTypeArguments());
+
+            Assert.check(paramTypes != null);
+            //get constraints from explicit params (this is done by
+            //checking that explicit param types are equal to the ones
+            //in the functional interface descriptors)
+            List<Type> descParameterTypes = types.findDescriptorType(formalInterface).getParameterTypes();
+            if (descParameterTypes.size() != paramTypes.size()) {
+                checkContext.report(pos, diags.fragment("incompatible.arg.types.in.lambda"));
+                return types.createErrorType(funcInterface);
+            }
+            for (Type p : descParameterTypes) {
+                if (!types.isSameType(funcInterfaceContext.asFree(p), paramTypes.head)) {
+                    checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                    return types.createErrorType(funcInterface);
                 }
-        };
+                paramTypes = paramTypes.tail;
+            }
+
+            try {
+                funcInterfaceContext.solve(funcInterfaceContext.boundedVars(), types.noWarnings);
+            } catch (InferenceException ex) {
+                checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+            }
+
+            List<Type> actualTypeargs = funcInterface.getTypeArguments();
+            for (Type t : funcInterfaceContext.undetvars) {
+                UndetVar uv = (UndetVar)t;
+                if (uv.inst == null) {
+                    uv.inst = actualTypeargs.head;
+                }
+                actualTypeargs = actualTypeargs.tail;
+            }
+
+            Type owntype = funcInterfaceContext.asInstType(formalInterface);
+            if (!chk.checkValidGenericType(owntype)) {
+                //if the inferred functional interface type is not well-formed,
+                //or if it's not a subtype of the original target, issue an error
+                checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+            }
+            return owntype;
+        }
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Bound checking">
+    /**
+     * Check bounds and perform incorporation
+     */
+    void checkWithinBounds(InferenceContext inferenceContext,
+                             Warner warn) throws InferenceException {
+        MultiUndetVarListener mlistener = new MultiUndetVarListener(inferenceContext.undetvars);
+        List<Type> saved_undet = inferenceContext.save();
+        try {
+            while (true) {
+                mlistener.reset();
+                if (!allowGraphInference) {
+                    //in legacy mode we lack of transitivity, so bound check
+                    //cannot be run in parallel with other incoprporation rounds
+                    for (Type t : inferenceContext.undetvars) {
+                        UndetVar uv = (UndetVar)t;
+                        IncorporationStep.CHECK_BOUNDS.apply(uv, inferenceContext, warn);
+                    }
+                }
+                for (Type t : inferenceContext.undetvars) {
+                    UndetVar uv = (UndetVar)t;
+                    //bound incorporation
+                    EnumSet<IncorporationStep> incorporationSteps = allowGraphInference ?
+                            incorporationStepsGraph : incorporationStepsLegacy;
+                    for (IncorporationStep is : incorporationSteps) {
+                        if (is.accepts(uv, inferenceContext)) {
+                            is.apply(uv, inferenceContext, warn);
+                        }
+                    }
+                }
+                if (!mlistener.changed || !allowGraphInference) break;
+            }
+        }
+        finally {
+            mlistener.detach();
+            if (incorporationCache.size() == MAX_INCORPORATION_STEPS) {
+                inferenceContext.rollback(saved_undet);
+            }
+            incorporationCache.clear();
+        }
     }
+    //where
+        /**
+         * This listener keeps track of changes on a group of inference variable
+         * bounds. Note: the listener must be detached (calling corresponding
+         * method) to make sure that the underlying inference variable is
+         * left in a clean state.
+         */
+        class MultiUndetVarListener implements UndetVar.UndetVarListener {
+
+            boolean changed;
+            List<Type> undetvars;
+
+            public MultiUndetVarListener(List<Type> undetvars) {
+                this.undetvars = undetvars;
+                for (Type t : undetvars) {
+                    UndetVar uv = (UndetVar)t;
+                    uv.listener = this;
+                }
+            }
+
+            public void varChanged(UndetVar uv, Set<InferenceBound> ibs) {
+                //avoid non-termination
+                if (incorporationCache.size() < MAX_INCORPORATION_STEPS) {
+                    changed = true;
+                }
+            }
+
+            void reset() {
+                changed = false;
+            }
+
+            void detach() {
+                for (Type t : undetvars) {
+                    UndetVar uv = (UndetVar)t;
+                    uv.listener = null;
+                }
+            }
+        };
+
+        /** max number of incorporation rounds */
+        static final int MAX_INCORPORATION_STEPS = 100;
+
+    /**
+     * This enumeration defines an entry point for doing inference variable
+     * bound incorporation - it can be used to inject custom incorporation
+     * logic into the basic bound checking routine
+     */
+    enum IncorporationStep {
+        /**
+         * Performs basic bound checking - i.e. is the instantiated type for a given
+         * inference variable compatible with its bounds?
+         */
+        CHECK_BOUNDS() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.instTypes(), infer.types);
+                infer.checkCompatibleUpperBounds(uv, inferenceContext);
+                if (uv.inst != null) {
+                    Type inst = uv.inst;
+                    for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                        if (!isSubtype(inst, inferenceContext.asFree(u), warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.UPPER);
+                        }
+                    }
+                    for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                        if (!isSubtype(inferenceContext.asFree(l), inst, warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.LOWER);
+                        }
+                    }
+                    for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                        if (!isSameType(inst, inferenceContext.asFree(e), infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.EQ);
+                        }
+                    }
+                }
+            }
+            @Override
+            boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
+                //applies to all undetvars
+                return true;
+            }
+        },
+        /**
+         * Check consistency of equality constraints. This is a slightly more aggressive
+         * inference routine that is designed as to maximize compatibility with JDK 7.
+         * Note: this is not used in graph mode.
+         */
+        EQ_CHECK_LEGACY() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                Type eq = null;
+                for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                    Assert.check(!inferenceContext.free(e));
+                    if (eq != null && !isSameType(e, eq, infer)) {
+                        infer.reportBoundError(uv, BoundErrorKind.EQ);
+                    }
+                    eq = e;
+                    for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                        Assert.check(!inferenceContext.free(l));
+                        if (!isSubtype(l, e, warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER);
+                        }
+                    }
+                    for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                        if (inferenceContext.free(u)) continue;
+                        if (!isSubtype(e, u, warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER);
+                        }
+                    }
+                }
+            }
+        },
+        /**
+         * Check consistency of equality constraints.
+         */
+        EQ_CHECK() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                    if (e.containsAny(inferenceContext.inferenceVars())) continue;
+                    for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                        if (!isSubtype(e, inferenceContext.asFree(u), warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER);
+                        }
+                    }
+                    for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                        if (!isSubtype(inferenceContext.asFree(l), e, warn, infer)) {
+                            infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER);
+                        }
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha <: T} and {@code alpha :> S}
+         * perform {@code S <: T} (which could lead to new bounds).
+         */
+        CROSS_UPPER_LOWER() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b1 : uv.getBounds(InferenceBound.UPPER)) {
+                    for (Type b2 : uv.getBounds(InferenceBound.LOWER)) {
+                        isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn , infer);
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha <: T} and {@code alpha == S}
+         * perform {@code S <: T} (which could lead to new bounds).
+         */
+        CROSS_UPPER_EQ() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b1 : uv.getBounds(InferenceBound.UPPER)) {
+                    for (Type b2 : uv.getBounds(InferenceBound.EQ)) {
+                        isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer);
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha :> S} and {@code alpha == T}
+         * perform {@code S <: T} (which could lead to new bounds).
+         */
+        CROSS_EQ_LOWER() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b1 : uv.getBounds(InferenceBound.EQ)) {
+                    for (Type b2 : uv.getBounds(InferenceBound.LOWER)) {
+                        isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer);
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha == S} and {@code alpha == T}
+         * perform {@code S == T} (which could lead to new bounds).
+         */
+        CROSS_EQ_EQ() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b1 : uv.getBounds(InferenceBound.EQ)) {
+                    for (Type b2 : uv.getBounds(InferenceBound.EQ)) {
+                        if (b1 != b2) {
+                            isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1), infer);
+                        }
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha <: beta} propagate lower bounds
+         * from alpha to beta; also propagate upper bounds from beta to alpha.
+         */
+        PROP_UPPER() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b : uv.getBounds(InferenceBound.UPPER)) {
+                    if (inferenceContext.inferenceVars().contains(b)) {
+                        UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
+                        if (uv2.isCaptured()) continue;
+                        //alpha <: beta
+                        //0. set beta :> alpha
+                        addBound(InferenceBound.LOWER, uv2, inferenceContext.asInstType(uv.qtype), infer);
+                        //1. copy alpha's lower to beta's
+                        for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                            addBound(InferenceBound.LOWER, uv2, inferenceContext.asInstType(l), infer);
+                        }
+                        //2. copy beta's upper to alpha's
+                        for (Type u : uv2.getBounds(InferenceBound.UPPER)) {
+                            addBound(InferenceBound.UPPER, uv, inferenceContext.asInstType(u), infer);
+                        }
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha :> beta} propagate lower bounds
+         * from beta to alpha; also propagate upper bounds from alpha to beta.
+         */
+        PROP_LOWER() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b : uv.getBounds(InferenceBound.LOWER)) {
+                    if (inferenceContext.inferenceVars().contains(b)) {
+                        UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
+                        if (uv2.isCaptured()) continue;
+                        //alpha :> beta
+                        //0. set beta <: alpha
+                        addBound(InferenceBound.UPPER, uv2, inferenceContext.asInstType(uv.qtype), infer);
+                        //1. copy alpha's upper to beta's
+                        for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                            addBound(InferenceBound.UPPER, uv2, inferenceContext.asInstType(u), infer);
+                        }
+                        //2. copy beta's lower to alpha's
+                        for (Type l : uv2.getBounds(InferenceBound.LOWER)) {
+                            addBound(InferenceBound.LOWER, uv, inferenceContext.asInstType(l), infer);
+                        }
+                    }
+                }
+            }
+        },
+        /**
+         * Given a bound set containing {@code alpha == beta} propagate lower/upper
+         * bounds from alpha to beta and back.
+         */
+        PROP_EQ() {
+            public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) {
+                Infer infer = inferenceContext.infer();
+                for (Type b : uv.getBounds(InferenceBound.EQ)) {
+                    if (inferenceContext.inferenceVars().contains(b)) {
+                        UndetVar uv2 = (UndetVar)inferenceContext.asFree(b);
+                        if (uv2.isCaptured()) continue;
+                        //alpha == beta
+                        //0. set beta == alpha
+                        addBound(InferenceBound.EQ, uv2, inferenceContext.asInstType(uv.qtype), infer);
+                        //1. copy all alpha's bounds to beta's
+                        for (InferenceBound ib : InferenceBound.values()) {
+                            for (Type b2 : uv.getBounds(ib)) {
+                                if (b2 != uv2) {
+                                    addBound(ib, uv2, inferenceContext.asInstType(b2), infer);
+                                }
+                            }
+                        }
+                        //2. copy all beta's bounds to alpha's
+                        for (InferenceBound ib : InferenceBound.values()) {
+                            for (Type b2 : uv2.getBounds(ib)) {
+                                if (b2 != uv) {
+                                    addBound(ib, uv, inferenceContext.asInstType(b2), infer);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        };
+
+        abstract void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn);
+
+        boolean accepts(UndetVar uv, InferenceContext inferenceContext) {
+            return !uv.isCaptured();
+        }
+
+        boolean isSubtype(Type s, Type t, Warner warn, Infer infer) {
+            return doIncorporationOp(IncorporationBinaryOpKind.IS_SUBTYPE, s, t, warn, infer);
+        }
+
+        boolean isSameType(Type s, Type t, Infer infer) {
+            return doIncorporationOp(IncorporationBinaryOpKind.IS_SAME_TYPE, s, t, null, infer);
+        }
+
+        void addBound(InferenceBound ib, UndetVar uv, Type b, Infer infer) {
+            doIncorporationOp(opFor(ib), uv, b, null, infer);
+        }
+
+        IncorporationBinaryOpKind opFor(InferenceBound boundKind) {
+            switch (boundKind) {
+                case EQ:
+                    return IncorporationBinaryOpKind.ADD_EQ_BOUND;
+                case LOWER:
+                    return IncorporationBinaryOpKind.ADD_LOWER_BOUND;
+                case UPPER:
+                    return IncorporationBinaryOpKind.ADD_UPPER_BOUND;
+                default:
+                    Assert.error("Can't get here!");
+                    return null;
+            }
+        }
+
+        boolean doIncorporationOp(IncorporationBinaryOpKind opKind, Type op1, Type op2, Warner warn, Infer infer) {
+            IncorporationBinaryOp newOp = infer.new IncorporationBinaryOp(opKind, op1, op2);
+            Boolean res = infer.incorporationCache.get(newOp);
+            if (res == null) {
+                infer.incorporationCache.put(newOp, res = newOp.apply(warn));
+            }
+            return res;
+        }
+    }
+
+    /** incorporation steps to be executed when running in legacy mode */
+    EnumSet<IncorporationStep> incorporationStepsLegacy = EnumSet.of(IncorporationStep.EQ_CHECK_LEGACY);
+
+    /** incorporation steps to be executed when running in graph mode */
+    EnumSet<IncorporationStep> incorporationStepsGraph =
+            EnumSet.complementOf(EnumSet.of(IncorporationStep.EQ_CHECK_LEGACY));
+
+    /**
+     * Three kinds of basic operation are supported as part of an incorporation step:
+     * (i) subtype check, (ii) same type check and (iii) bound addition (either
+     * upper/lower/eq bound).
+     */
+    enum IncorporationBinaryOpKind {
+        IS_SUBTYPE() {
+            @Override
+            boolean apply(Type op1, Type op2, Warner warn, Types types) {
+                return types.isSubtypeUnchecked(op1, op2, warn);
+            }
+        },
+        IS_SAME_TYPE() {
+            @Override
+            boolean apply(Type op1, Type op2, Warner warn, Types types) {
+                return types.isSameType(op1, op2);
+            }
+        },
+        ADD_UPPER_BOUND() {
+            @Override
+            boolean apply(Type op1, Type op2, Warner warn, Types types) {
+                UndetVar uv = (UndetVar)op1;
+                uv.addBound(InferenceBound.UPPER, op2, types);
+                return true;
+            }
+        },
+        ADD_LOWER_BOUND() {
+            @Override
+            boolean apply(Type op1, Type op2, Warner warn, Types types) {
+                UndetVar uv = (UndetVar)op1;
+                uv.addBound(InferenceBound.LOWER, op2, types);
+                return true;
+            }
+        },
+        ADD_EQ_BOUND() {
+            @Override
+            boolean apply(Type op1, Type op2, Warner warn, Types types) {
+                UndetVar uv = (UndetVar)op1;
+                uv.addBound(InferenceBound.EQ, op2, types);
+                return true;
+            }
+        };
+
+        abstract boolean apply(Type op1, Type op2, Warner warn, Types types);
+    }
+
+    /**
+     * This class encapsulates a basic incorporation operation; incorporation
+     * operations takes two type operands and a kind. Each operation performed
+     * during an incorporation round is stored in a cache, so that operations
+     * are not executed unnecessarily (which would potentially lead to adding
+     * same bounds over and over).
+     */
+    class IncorporationBinaryOp {
+
+        IncorporationBinaryOpKind opKind;
+        Type op1;
+        Type op2;
+
+        IncorporationBinaryOp(IncorporationBinaryOpKind opKind, Type op1, Type op2) {
+            this.opKind = opKind;
+            this.op1 = op1;
+            this.op2 = op2;
+        }
+
+        @Override
+        public boolean equals(Object o) {
+            if (!(o instanceof IncorporationBinaryOp)) {
+                return false;
+            } else {
+                IncorporationBinaryOp that = (IncorporationBinaryOp)o;
+                return opKind == that.opKind &&
+                        types.isSameType(op1, that.op1, true) &&
+                        types.isSameType(op2, that.op2, true);
+            }
+        }
+
+        @Override
+        public int hashCode() {
+            int result = opKind.hashCode();
+            result *= 127;
+            result += types.hashCode(op1);
+            result *= 127;
+            result += types.hashCode(op2);
+            return result;
+        }
+
+        boolean apply(Warner warn) {
+            return opKind.apply(op1, op2, warn, types);
+        }
+    }
+
+    /** an incorporation cache keeps track of all executed incorporation-related operations */
+    Map<IncorporationBinaryOp, Boolean> incorporationCache =
+            new HashMap<IncorporationBinaryOp, Boolean>();
+
+    /**
+     * Make sure that the upper bounds we got so far lead to a solvable inference
+     * variable by making sure that a glb exists.
+     */
+    void checkCompatibleUpperBounds(UndetVar uv, InferenceContext inferenceContext) {
+        List<Type> hibounds =
+                Type.filter(uv.getBounds(InferenceBound.UPPER), new BoundFilter(inferenceContext));
+        Type hb = null;
+        if (hibounds.isEmpty())
+            hb = syms.objectType;
+        else if (hibounds.tail.isEmpty())
+            hb = hibounds.head;
+        else
+            hb = types.glb(hibounds);
+        if (hb == null || hb.isErroneous())
+            reportBoundError(uv, BoundErrorKind.BAD_UPPER);
+    }
+    //where
+        protected static class BoundFilter implements Filter<Type> {
+
+            InferenceContext inferenceContext;
+
+            public BoundFilter(InferenceContext inferenceContext) {
+                this.inferenceContext = inferenceContext;
+            }
+
+            @Override
+            public boolean accepts(Type t) {
+                return !t.isErroneous() && !inferenceContext.free(t) &&
+                        !t.hasTag(BOT);
+            }
+        };
+
+    /**
+     * This enumeration defines all possible bound-checking related errors.
+     */
+    enum BoundErrorKind {
+        /**
+         * The (uninstantiated) inference variable has incompatible upper bounds.
+         */
+        BAD_UPPER() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("incompatible.upper.bounds", uv.qtype,
+                        uv.getBounds(InferenceBound.UPPER));
+            }
+        },
+        /**
+         * An equality constraint is not compatible with an upper bound.
+         */
+        BAD_EQ_UPPER() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("incompatible.eq.upper.bounds", uv.qtype,
+                        uv.getBounds(InferenceBound.EQ), uv.getBounds(InferenceBound.UPPER));
+            }
+        },
+        /**
+         * An equality constraint is not compatible with a lower bound.
+         */
+        BAD_EQ_LOWER() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("incompatible.eq.lower.bounds", uv.qtype,
+                        uv.getBounds(InferenceBound.EQ), uv.getBounds(InferenceBound.LOWER));
+            }
+        },
+        /**
+         * Instantiated inference variable is not compatible with an upper bound.
+         */
+        UPPER() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("inferred.do.not.conform.to.upper.bounds", uv.inst,
+                        uv.getBounds(InferenceBound.UPPER));
+            }
+        },
+        /**
+         * Instantiated inference variable is not compatible with a lower bound.
+         */
+        LOWER() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("inferred.do.not.conform.to.lower.bounds", uv.inst,
+                        uv.getBounds(InferenceBound.LOWER));
+            }
+        },
+        /**
+         * Instantiated inference variable is not compatible with an equality constraint.
+         */
+        EQ() {
+            @Override
+            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
+                return ex.setMessage("inferred.do.not.conform.to.eq.bounds", uv.inst,
+                        uv.getBounds(InferenceBound.EQ));
+            }
+        };
+
+        abstract InapplicableMethodException setMessage(InferenceException ex, UndetVar uv);
+    }
+
+    /**
+     * Report a bound-checking error of given kind
+     */
+    void reportBoundError(UndetVar uv, BoundErrorKind bk) {
+        throw bk.setMessage(inferenceException, uv);
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Inference engine">
+    /**
+     * Graph inference strategy - act as an input to the inference solver; a strategy is
+     * composed of two ingredients: (i) find a node to solve in the inference graph,
+     * and (ii) tell th engine when we are done fixing inference variables
+     */
+    interface GraphStrategy {
+        /**
+         * Pick the next node (leaf) to solve in the graph
+         */
+        Node pickNode(InferenceGraph g);
+        /**
+         * Is this the last step?
+         */
+        boolean done();
+    }
+
+    /**
+     * Simple solver strategy class that locates all leaves inside a graph
+     * and picks the first leaf as the next node to solve
+     */
+    abstract class LeafSolver implements GraphStrategy {
+        public Node pickNode(InferenceGraph g) {
+                        Assert.check(!g.nodes.isEmpty(), "No nodes to solve!");
+            return g.nodes.get(0);
+        }
+
+        boolean isSubtype(Type s, Type t, Warner warn, Infer infer) {
+            return doIncorporationOp(IncorporationBinaryOpKind.IS_SUBTYPE, s, t, warn, infer);
+        }
+
+        boolean isSameType(Type s, Type t, Infer infer) {
+            return doIncorporationOp(IncorporationBinaryOpKind.IS_SAME_TYPE, s, t, null, infer);
+        }
+
+        void addBound(InferenceBound ib, UndetVar uv, Type b, Infer infer) {
+            doIncorporationOp(opFor(ib), uv, b, null, infer);
+        }
+
+        IncorporationBinaryOpKind opFor(InferenceBound boundKind) {
+            switch (boundKind) {
+                case EQ:
+                    return IncorporationBinaryOpKind.ADD_EQ_BOUND;
+                case LOWER:
+                    return IncorporationBinaryOpKind.ADD_LOWER_BOUND;
+                case UPPER:
+                    return IncorporationBinaryOpKind.ADD_UPPER_BOUND;
+                default:
+                    Assert.error("Can't get here!");
+                    return null;
+            }
+        }
+
+        boolean doIncorporationOp(IncorporationBinaryOpKind opKind, Type op1, Type op2, Warner warn, Infer infer) {
+            IncorporationBinaryOp newOp = infer.new IncorporationBinaryOp(opKind, op1, op2);
+            Boolean res = infer.incorporationCache.get(newOp);
+            if (res == null) {
+                infer.incorporationCache.put(newOp, res = newOp.apply(warn));
+            }
+            return res;
+        }
+    }
+
+    /**
+     * This solver uses an heuristic to pick the best leaf - the heuristic
+     * tries to select the node that has maximal probability to contain one
+     * or more inference variables in a given list
+     */
+    abstract class BestLeafSolver extends LeafSolver {
+
+        List<Type> varsToSolve;
+
+        BestLeafSolver(List<Type> varsToSolve) {
+            this.varsToSolve = varsToSolve;
+        }
+
+        /**
+         * Computes the minimum path that goes from a given node to any of the nodes
+         * containing a variable in {@code varsToSolve}. For any given path, the cost
+         * is computed as the total number of type-variables that should be eagerly
+         * instantiated across that path.
+         */
+        int computeMinPath(InferenceGraph g, Node n) {
+            return computeMinPath(g, n, List.<Node>nil(), 0);
+        }
+
+        int computeMinPath(InferenceGraph g, Node n, List<Node> path, int cost) {
+            if (path.contains(n)) return Integer.MAX_VALUE;
+            List<Node> path2 = path.prepend(n);
+            int cost2 = cost + n.data.size();
+            if (!Collections.disjoint(n.data, varsToSolve)) {
+                return cost2;
+            } else {
+               int bestPath = Integer.MAX_VALUE;
+               for (Node n2 : g.nodes) {
+                   if (n2.deps.contains(n)) {
+                       int res = computeMinPath(g, n2, path2, cost2);
+                       if (res < bestPath) {
+                           bestPath = res;
+                       }
+                   }
+                }
+               return bestPath;
+            }
+        }
+
+        /**
+         * Pick the leaf that minimize cost
+         */
+        @Override
+        public Node pickNode(final InferenceGraph g) {
+            final Map<Node, Integer> leavesMap = new HashMap<Node, Integer>();
+            for (Node n : g.nodes) {
+                if (n.isLeaf(n)) {
+                    leavesMap.put(n, computeMinPath(g, n));
+                }
+            }
+            Assert.check(!leavesMap.isEmpty(), "No nodes to solve!");
+            TreeSet<Node> orderedLeaves = new TreeSet<Node>(new Comparator<Node>() {
+                public int compare(Node n1, Node n2) {
+                    return leavesMap.get(n1) - leavesMap.get(n2);
+                }
+            });
+            orderedLeaves.addAll(leavesMap.keySet());
+            return orderedLeaves.first();
+        }
+    }
+
+    /**
+     * The inference process can be thought of as a sequence of steps. Each step
+     * instantiates an inference variable using a subset of the inference variable
+     * bounds, if certain condition are met. Decisions such as the sequence in which
+     * steps are applied, or which steps are to be applied are left to the inference engine.
+     */
+    enum InferenceStep {
+
+        /**
+         * Instantiate an inference variables using one of its (ground) equality
+         * constraints
+         */
+        EQ(InferenceBound.EQ) {
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                return filterBounds(uv, inferenceContext).head;
+            }
+        },
+        /**
+         * Instantiate an inference variables using its (ground) lower bounds. Such
+         * bounds are merged together using lub().
+         */
+        LOWER(InferenceBound.LOWER) {
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                Infer infer = inferenceContext.infer();
+                List<Type> lobounds = filterBounds(uv, inferenceContext);
+                Type owntype = lobounds.nonEmpty() ? lobounds.tail.tail == null ? lobounds.head : infer.types.lub(lobounds) : null;
+                if (owntype == null || owntype.isPrimitive() || owntype.hasTag(ERROR)) {
+                    throw infer.inferenceException
+                        .setMessage("no.unique.minimal.instance.exists",
+                                    uv.qtype, lobounds);
+                } else {
+                    return owntype;
+                }
+            }
+        },
+        /**
+         * Infer uninstantiated/unbound inference variables occurring in 'throws'
+         * clause as RuntimeException
+         */
+        THROWS(InferenceBound.UPPER) {
+            @Override
+            public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
+                if ((t.qtype.tsym.flags() & Flags.THROWS) == 0) {
+                    //not a throws undet var
+                    return false;
+                }
+                if (t.getBounds(InferenceBound.EQ, InferenceBound.LOWER, InferenceBound.UPPER)
+                            .diff(t.getDeclaredBounds()).nonEmpty()) {
+                    //not an unbounded undet var
+                    return false;
+                }
+                Infer infer = inferenceContext.infer();
+                for (Type db : t.getDeclaredBounds()) {
+                    if (t.isInterface()) continue;
+                    if (infer.types.asSuper(infer.syms.runtimeExceptionType, db.tsym) != null) {
+                        //declared bound is a supertype of RuntimeException
+                        return true;
+                    }
+                }
+                //declared bound is more specific then RuntimeException - give up
+                return false;
+            }
+
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                return inferenceContext.infer().syms.runtimeExceptionType;
+            }
+        },
+        /**
+         * Instantiate an inference variables using its (ground) upper bounds. Such
+         * bounds are merged together using glb().
+         */
+        UPPER(InferenceBound.UPPER) {
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                Infer infer = inferenceContext.infer();
+                List<Type> hibounds = filterBounds(uv, inferenceContext);
+                Type owntype = hibounds.nonEmpty() ? hibounds.tail.tail == null ? hibounds.head : infer.types.glb(hibounds) : null;
+                if (owntype == null || owntype.isPrimitive() || owntype.isErroneous()) {
+                    throw infer.inferenceException
+                        .setMessage("no.unique.maximal.instance.exists",
+                                    uv.qtype, hibounds);
+                } else {
+                    return owntype;
+                }
+            }
+        },
+        /**
+         * Like the former; the only difference is that this step can only be applied
+         * if all upper bounds are ground.
+         */
+        UPPER_LEGACY(InferenceBound.UPPER) {
+            @Override
+            public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
+                return !inferenceContext.free(t.getBounds(ib)) && !t.isCaptured();
+            }
+
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                return UPPER.solve(uv, inferenceContext);
+            }
+        },
+        /**
+         * Like the former; the only difference is that this step can only be applied
+         * if all upper/lower bounds are ground.
+         */
+        CAPTURED(InferenceBound.UPPER) {
+            @Override
+            public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
+                return !inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER));
+            }
+
+            @Override
+            Type solve(UndetVar uv, InferenceContext inferenceContext) {
+                Infer infer = inferenceContext.infer();
+                Type upper = UPPER.filterBounds(uv, inferenceContext).nonEmpty() ?
+                        UPPER.solve(uv, inferenceContext) :
+                        infer.syms.objectType;
+                Type lower = LOWER.filterBounds(uv, inferenceContext).nonEmpty() ?
+                        LOWER.solve(uv, inferenceContext) :
+                        infer.syms.botType;
+                CapturedType prevCaptured = (CapturedType)uv.qtype;
+                return new CapturedType(prevCaptured.tsym.name, prevCaptured.tsym.owner, upper, lower, prevCaptured.wildcard);
+            }
+        };
+
+        final InferenceBound ib;
+
+        InferenceStep(InferenceBound ib) {
+            this.ib = ib;
+        }
+
+        /**
+         * Find an instantiated type for a given inference variable within
+         * a given inference context
+         */
+        abstract Type solve(UndetVar uv, InferenceContext inferenceContext);
+
+        /**
+         * Can the inference variable be instantiated using this step?
+         */
+        public boolean accepts(UndetVar t, InferenceContext inferenceContext) {
+            return filterBounds(t, inferenceContext).nonEmpty() && !t.isCaptured();
+        }
+
+        /**
+         * Return the subset of ground bounds in a given bound set (i.e. eq/lower/upper)
+         */
+        List<Type> filterBounds(UndetVar uv, InferenceContext inferenceContext) {
+            return Type.filter(uv.getBounds(ib), new BoundFilter(inferenceContext));
+        }
+    }
+
+    /**
+     * This enumeration defines the sequence of steps to be applied when the
+     * solver works in legacy mode. The steps in this enumeration reflect
+     * the behavior of old inference routine (see JLS SE 7 15.12.2.7/15.12.2.8).
+     */
+    enum LegacyInferenceSteps {
+
+        EQ_LOWER(EnumSet.of(InferenceStep.EQ, InferenceStep.LOWER)),
+        EQ_UPPER(EnumSet.of(InferenceStep.EQ, InferenceStep.UPPER_LEGACY));
+
+        final EnumSet<InferenceStep> steps;
+
+        LegacyInferenceSteps(EnumSet<InferenceStep> steps) {
+            this.steps = steps;
+        }
+    }
+
+    /**
+     * This enumeration defines the sequence of steps to be applied when the
+     * graph solver is used. This order is defined so as to maximize compatibility
+     * w.r.t. old inference routine (see JLS SE 7 15.12.2.7/15.12.2.8).
+     */
+    enum GraphInferenceSteps {
+
+        EQ(EnumSet.of(InferenceStep.EQ)),
+        EQ_LOWER(EnumSet.of(InferenceStep.EQ, InferenceStep.LOWER)),
+        EQ_LOWER_THROWS_UPPER_CAPTURED(EnumSet.of(InferenceStep.EQ, InferenceStep.LOWER, InferenceStep.UPPER, InferenceStep.THROWS, InferenceStep.CAPTURED));
+
+        final EnumSet<InferenceStep> steps;
+
+        GraphInferenceSteps(EnumSet<InferenceStep> steps) {
+            this.steps = steps;
+        }
+    }
+
+    /**
+     * This is the graph inference solver - the solver organizes all inference variables in
+     * a given inference context by bound dependencies - in the general case, such dependencies
+     * would lead to a cyclic directed graph (hence the name); the dependency info is used to build
+     * an acyclic graph, where all cyclic variables are bundled together. An inference
+     * step corresponds to solving a node in the acyclic graph - this is done by
+     * relying on a given strategy (see GraphStrategy).
+     */
+    class GraphSolver {
+
+        InferenceContext inferenceContext;
+        Warner warn;
+
+        GraphSolver(InferenceContext inferenceContext, Warner warn) {
+            this.inferenceContext = inferenceContext;
+            this.warn = warn;
+        }
+
+        /**
+         * Solve variables in a given inference context. The amount of variables
+         * to be solved, and the way in which the underlying acyclic graph is explored
+         * depends on the selected solver strategy.
+         */
+        void solve(GraphStrategy sstrategy) {
+            checkWithinBounds(inferenceContext, warn); //initial propagation of bounds
+            InferenceGraph inferenceGraph = new InferenceGraph();
+            while (!sstrategy.done()) {
+                InferenceGraph.Node nodeToSolve = sstrategy.pickNode(inferenceGraph);
+                List<Type> varsToSolve = List.from(nodeToSolve.data);
+                List<Type> saved_undet = inferenceContext.save();
+                try {
+                    //repeat until all variables are solved
+                    outer: while (Type.containsAny(inferenceContext.restvars(), varsToSolve)) {
+                        //for each inference phase
+                        for (GraphInferenceSteps step : GraphInferenceSteps.values()) {
+                            if (inferenceContext.solveBasic(varsToSolve, step.steps)) {
+                                checkWithinBounds(inferenceContext, warn);
+                                continue outer;
+                            }
+                        }
+                        //no progress
+                        throw inferenceException.setMessage();
+                    }
+                }
+                catch (InferenceException ex) {
+                    //did we fail because of interdependent ivars?
+                    inferenceContext.rollback(saved_undet);
+                    instantiateAsUninferredVars(varsToSolve, inferenceContext);
+                    checkWithinBounds(inferenceContext, warn);
+                }
+                inferenceGraph.deleteNode(nodeToSolve);
+            }
+        }
+
+        /**
+         * The dependencies between the inference variables that need to be solved
+         * form a (possibly cyclic) graph. This class reduces the original dependency graph
+         * to an acyclic version, where cyclic nodes are folded into a single 'super node'.
+         */
+        class InferenceGraph {
+
+            /**
+             * This class represents a node in the graph. Each node corresponds
+             * to an inference variable and has edges (dependencies) on other
+             * nodes. The node defines an entry point that can be used to receive
+             * updates on the structure of the graph this node belongs to (used to
+             * keep dependencies in sync).
+             */
+            class Node extends GraphUtils.TarjanNode<ListBuffer<Type>> {
+
+                Set<Node> deps;
+
+                Node(Type ivar) {
+                    super(ListBuffer.of(ivar));
+                    this.deps = new HashSet<Node>();
+                }
+
+                @Override
+                public Iterable<? extends Node> getDependencies() {
+                    return deps;
+                }
+
+                @Override
+                public String printDependency(GraphUtils.Node<ListBuffer<Type>> to) {
+                    StringBuilder buf = new StringBuilder();
+                    String sep = "";
+                    for (Type from : data) {
+                        UndetVar uv = (UndetVar)inferenceContext.asFree(from);
+                        for (Type bound : uv.getBounds(InferenceBound.values())) {
+                            if (bound.containsAny(List.from(to.data))) {
+                                buf.append(sep);
+                                buf.append(bound);
+                                sep = ",";
+                            }
+                        }
+                    }
+                    return buf.toString();
+                }
+
+                boolean isLeaf(Node n) {
+                    //no deps, or only one self dep
+                    return (n.deps.isEmpty() ||
+                            n.deps.size() == 1 && n.deps.contains(n));
+                }
+
+                void mergeWith(List<? extends Node> nodes) {
+                    for (Node n : nodes) {
+                        Assert.check(n.data.length() == 1, "Attempt to merge a compound node!");
+                        data.appendList(n.data);
+                        deps.addAll(n.deps);
+                    }
+                    //update deps
+                    Set<Node> deps2 = new HashSet<Node>();
+                    for (Node d : deps) {
+                        if (data.contains(d.data.first())) {
+                            deps2.add(this);
+                        } else {
+                            deps2.add(d);
+                        }
+                    }
+                    deps = deps2;
+                }
+
+                void graphChanged(Node from, Node to) {
+                    if (deps.contains(from)) {
+                        deps.remove(from);
+                        if (to != null) {
+                            deps.add(to);
+                        }
+                    }
+                }
+            }
+
+            /** the nodes in the inference graph */
+            ArrayList<Node> nodes;
+
+            InferenceGraph() {
+                initNodes();
+            }
+
+            /**
+             * Delete a node from the graph. This update the underlying structure
+             * of the graph (including dependencies) via listeners updates.
+             */
+            public void deleteNode(Node n) {
+                Assert.check(nodes.contains(n));
+                nodes.remove(n);
+                notifyUpdate(n, null);
+            }
+
+            /**
+             * Notify all nodes of a change in the graph. If the target node is
+             * {@code null} the source node is assumed to be removed.
+             */
+            void notifyUpdate(Node from, Node to) {
+                for (Node n : nodes) {
+                    n.graphChanged(from, to);
+                }
+            }
+
+            /**
+             * Create the graph nodes. First a simple node is created for every inference
+             * variables to be solved. Then Tarjan is used to found all connected components
+             * in the graph. For each component containing more than one node, a super node is
+                 * created, effectively replacing the original cyclic nodes.
+             */
+            void initNodes() {
+                nodes = new ArrayList<Node>();
+                for (Type t : inferenceContext.restvars()) {
+                    nodes.add(new Node(t));
+                }
+                for (Node n_i : nodes) {
+                    Type i = n_i.data.first();
+                    for (Node n_j : nodes) {
+                        Type j = n_j.data.first();
+                        UndetVar uv_i = (UndetVar)inferenceContext.asFree(i);
+                        if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
+                            //update i's deps
+                            n_i.deps.add(n_j);
+                        }
+                    }
+                }
+                ArrayList<Node> acyclicNodes = new ArrayList<Node>();
+                for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
+                    if (conSubGraph.length() > 1) {
+                        Node root = conSubGraph.head;
+                        root.mergeWith(conSubGraph.tail);
+                        for (Node n : conSubGraph) {
+                            notifyUpdate(n, root);
+                        }
+                    }
+                    acyclicNodes.add(conSubGraph.head);
+                }
+                nodes = acyclicNodes;
+            }
+
+            /**
+             * Debugging: dot representation of this graph
+             */
+            String toDot() {
+                StringBuilder buf = new StringBuilder();
+                for (Type t : inferenceContext.undetvars) {
+                    UndetVar uv = (UndetVar)t;
+                    buf.append(String.format("var %s - upper bounds = %s, lower bounds = %s, eq bounds = %s\\n",
+                            uv.qtype, uv.getBounds(InferenceBound.UPPER), uv.getBounds(InferenceBound.LOWER),
+                            uv.getBounds(InferenceBound.EQ)));
+                }
+                return GraphUtils.toDot(nodes, "inferenceGraph" + hashCode(), buf.toString());
+            }
+        }
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Inference context">
+    /**
+     * Functional interface for defining inference callbacks. Certain actions
+     * (i.e. subtyping checks) might need to be redone after all inference variables
+     * have been fixed.
+     */
+    interface FreeTypeListener {
+        void typesInferred(InferenceContext inferenceContext);
+    }
+
+    /**
+     * An inference context keeps track of the set of variables that are free
+     * in the current context. It provides utility methods for opening/closing
+     * types to their corresponding free/closed forms. It also provide hooks for
+     * attaching deferred post-inference action (see PendingCheck). Finally,
+     * it can be used as an entry point for performing upper/lower bound inference
+     * (see InferenceKind).
+     */
+     class InferenceContext {
+
+        /** list of inference vars as undet vars */
+        List<Type> undetvars;
+
+        /** list of inference vars in this context */
+        List<Type> inferencevars;
+
+        java.util.Map<FreeTypeListener, List<Type>> freeTypeListeners =
+                new java.util.HashMap<FreeTypeListener, List<Type>>();
+
+        List<FreeTypeListener> freetypeListeners = List.nil();
+
+        public InferenceContext(List<Type> inferencevars) {
+            this.undetvars = Type.map(inferencevars, fromTypeVarFun);
+            this.inferencevars = inferencevars;
+        }
+        //where
+            Mapping fromTypeVarFun = new Mapping("fromTypeVarFunWithBounds") {
+                // mapping that turns inference variables into undet vars
+                public Type apply(Type t) {
+                    if (t.hasTag(TYPEVAR)) {
+                        TypeVar tv = (TypeVar)t;
+                        return tv.isCaptured() ?
+                                new CapturedUndetVar((CapturedType)tv, types) :
+                                new UndetVar(tv, types);
+                    } else {
+                        return t.map(this);
+                    }
+                }
+            };
+
+        /**
+         * add a new inference var to this inference context
+         */
+        void addVar(TypeVar t) {
+            this.undetvars = this.undetvars.prepend(fromTypeVarFun.apply(t));
+            this.inferencevars = this.inferencevars.prepend(t);
+        }
+
+        /**
+         * returns the list of free variables (as type-variables) in this
+         * inference context
+         */
+        List<Type> inferenceVars() {
+            return inferencevars;
+        }
+
+        /**
+         * returns the list of uninstantiated variables (as type-variables) in this
+         * inference context
+         */
+        List<Type> restvars() {
+            return filterVars(new Filter<UndetVar>() {
+                public boolean accepts(UndetVar uv) {
+                    return uv.inst == null;
+                }
+            });
+        }
+
+        /**
+         * returns the list of instantiated variables (as type-variables) in this
+         * inference context
+         */
+        List<Type> instvars() {
+            return filterVars(new Filter<UndetVar>() {
+                public boolean accepts(UndetVar uv) {
+                    return uv.inst != null;
+                }
+            });
+        }
+
+        /**
+         * Get list of bounded inference variables (where bound is other than
+         * declared bounds).
+         */
+        final List<Type> boundedVars() {
+            return filterVars(new Filter<UndetVar>() {
+                public boolean accepts(UndetVar uv) {
+                    return uv.getBounds(InferenceBound.UPPER)
+                            .diff(uv.getDeclaredBounds())
+                            .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty();
+                }
+            });
+        }
+
+        private List<Type> filterVars(Filter<UndetVar> fu) {
+            ListBuffer<Type> res = ListBuffer.lb();
+            for (Type t : undetvars) {
+                UndetVar uv = (UndetVar)t;
+                if (fu.accepts(uv)) {
+                    res.append(uv.qtype);
+                }
+            }
+            return res.toList();
+        }
+
+        /**
+         * is this type free?
+         */
+        final boolean free(Type t) {
+            return t.containsAny(inferencevars);
+        }
+
+        final boolean free(List<Type> ts) {
+            for (Type t : ts) {
+                if (free(t)) return true;
+            }
+            return false;
+        }
+
+        /**
+         * Returns a list of free variables in a given type
+         */
+        final List<Type> freeVarsIn(Type t) {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type iv : inferenceVars()) {
+                if (t.contains(iv)) {
+                    buf.add(iv);
+                }
+            }
+            return buf.toList();
+        }
+
+        final List<Type> freeVarsIn(List<Type> ts) {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type t : ts) {
+                buf.appendList(freeVarsIn(t));
+            }
+            ListBuffer<Type> buf2 = ListBuffer.lb();
+            for (Type t : buf) {
+                if (!buf2.contains(t)) {
+                    buf2.add(t);
+                }
+            }
+            return buf2.toList();
+        }
+
+        /**
+         * Replace all free variables in a given type with corresponding
+         * undet vars (used ahead of subtyping/compatibility checks to allow propagation
+         * of inference constraints).
+         */
+        final Type asFree(Type t) {
+            return types.subst(t, inferencevars, undetvars);
+        }
+
+        final List<Type> asFree(List<Type> ts) {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type t : ts) {
+                buf.append(asFree(t));
+            }
+            return buf.toList();
+        }
+
+        List<Type> instTypes() {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type t : undetvars) {
+                UndetVar uv = (UndetVar)t;
+                buf.append(uv.inst != null ? uv.inst : uv.qtype);
+            }
+            return buf.toList();
+        }
+
+        /**
+         * Replace all free variables in a given type with corresponding
+         * instantiated types - if one or more free variable has not been
+         * fully instantiated, it will still be available in the resulting type.
+         */
+        Type asInstType(Type t) {
+            return types.subst(t, inferencevars, instTypes());
+        }
+
+        List<Type> asInstTypes(List<Type> ts) {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type t : ts) {
+                buf.append(asInstType(t));
+            }
+            return buf.toList();
+        }
+
+        /**
+         * Add custom hook for performing post-inference action
+         */
+        void addFreeTypeListener(List<Type> types, FreeTypeListener ftl) {
+            freeTypeListeners.put(ftl, freeVarsIn(types));
+        }
+
+        /**
+         * Mark the inference context as complete and trigger evaluation
+         * of all deferred checks.
+         */
+        void notifyChange() {
+            notifyChange(inferencevars.diff(restvars()));
+        }
+
+        void notifyChange(List<Type> inferredVars) {
+            InferenceException thrownEx = null;
+            for (Map.Entry<FreeTypeListener, List<Type>> entry :
+                    new HashMap<FreeTypeListener, List<Type>>(freeTypeListeners).entrySet()) {
+                if (!Type.containsAny(entry.getValue(), inferencevars.diff(inferredVars))) {
+                    try {
+                        entry.getKey().typesInferred(this);
+                        freeTypeListeners.remove(entry.getKey());
+                    } catch (InferenceException ex) {
+                        if (thrownEx == null) {
+                            thrownEx = ex;
+                        }
+                    }
+                }
+            }
+            //inference exception multiplexing - present any inference exception
+            //thrown when processing listeners as a single one
+            if (thrownEx != null) {
+                throw thrownEx;
+            }
+        }
+
+        /**
+         * Save the state of this inference context
+         */
+        List<Type> save() {
+            ListBuffer<Type> buf = ListBuffer.lb();
+            for (Type t : undetvars) {
+                UndetVar uv = (UndetVar)t;
+                UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types);
+                for (InferenceBound ib : InferenceBound.values()) {
+                    for (Type b : uv.getBounds(ib)) {
+                        uv2.addBound(ib, b, types);
+                    }
+                }
+                uv2.inst = uv.inst;
+                buf.add(uv2);
+            }
+            return buf.toList();
+        }
+
+        /**
+         * Restore the state of this inference context to the previous known checkpoint
+         */
+        void rollback(List<Type> saved_undet) {
+             Assert.check(saved_undet != null && saved_undet.length() == undetvars.length());
+            //restore bounds (note: we need to preserve the old instances)
+            for (Type t : undetvars) {
+                UndetVar uv = (UndetVar)t;
+                UndetVar uv_saved = (UndetVar)saved_undet.head;
+                for (InferenceBound ib : InferenceBound.values()) {
+                    uv.setBounds(ib, uv_saved.getBounds(ib));
+                }
+                uv.inst = uv_saved.inst;
+                saved_undet = saved_undet.tail;
+            }
+        }
+
+        /**
+         * Copy variable in this inference context to the given context
+         */
+        void dupTo(final InferenceContext that) {
+            that.inferencevars = that.inferencevars.appendList(inferencevars);
+            that.undetvars = that.undetvars.appendList(undetvars);
+            //set up listeners to notify original inference contexts as
+            //propagated vars are inferred in new context
+            for (Type t : inferencevars) {
+                that.freeTypeListeners.put(new FreeTypeListener() {
+                    public void typesInferred(InferenceContext inferenceContext) {
+                        InferenceContext.this.notifyChange();
+                    }
+                }, List.of(t));
+            }
+        }
+
+        /**
+         * Solve with given graph strategy.
+         */
+        private void solve(GraphStrategy ss, Warner warn) {
+            GraphSolver s = new GraphSolver(this, warn);
+            s.solve(ss);
+        }
+
+        /**
+         * Solve all variables in this context.
+         */
+        public void solve(Warner warn) {
+            solve(new LeafSolver() {
+                public boolean done() {
+                    return restvars().isEmpty();
+                }
+            }, warn);
+        }
+
+        /**
+         * Solve all variables in the given list.
+         */
+        public void solve(final List<Type> vars, Warner warn) {
+            solve(new BestLeafSolver(vars) {
+                public boolean done() {
+                    return !free(asInstTypes(vars));
+                }
+            }, warn);
+        }
+
+        /**
+         * Solve at least one variable in given list.
+         */
+        public void solveAny(List<Type> varsToSolve, Warner warn) {
+            checkWithinBounds(this, warn); //propagate bounds
+            List<Type> boundedVars = boundedVars().intersect(restvars()).intersect(varsToSolve);
+            if (boundedVars.isEmpty()) {
+                throw inferenceException.setMessage("cyclic.inference",
+                                freeVarsIn(varsToSolve));
+            }
+            solve(new BestLeafSolver(boundedVars) {
+                public boolean done() {
+                    return instvars().intersect(varsToSolve).nonEmpty();
+                }
+            }, warn);
+        }
+
+        /**
+         * Apply a set of inference steps
+         */
+        private boolean solveBasic(EnumSet<InferenceStep> steps) {
+            return solveBasic(inferencevars, steps);
+        }
+
+        private boolean solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) {
+            boolean changed = false;
+            for (Type t : varsToSolve.intersect(restvars())) {
+                UndetVar uv = (UndetVar)asFree(t);
+                for (InferenceStep step : steps) {
+                    if (step.accepts(uv, this)) {
+                        uv.inst = step.solve(uv, this);
+                        changed = true;
+                        break;
+                    }
+                }
+            }
+            return changed;
+        }
+
+        /**
+         * Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
+         * During overload resolution, instantiation is done by doing a partial
+         * inference process using eq/lower bound instantiation. During check,
+         * we also instantiate any remaining vars by repeatedly using eq/upper
+         * instantiation, until all variables are solved.
+         */
+        public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
+            while (true) {
+                boolean stuck = !solveBasic(steps);
+                if (restvars().isEmpty() || partial) {
+                    //all variables have been instantiated - exit
+                    break;
+                } else if (stuck) {
+                    //some variables could not be instantiated because of cycles in
+                    //upper bounds - provide a (possibly recursive) default instantiation
+                    instantiateAsUninferredVars(restvars(), this);
+                    break;
+                } else {
+                    //some variables have been instantiated - replace newly instantiated
+                    //variables in remaining upper bounds and continue
+                    for (Type t : undetvars) {
+                        UndetVar uv = (UndetVar)t;
+                        uv.substBounds(inferenceVars(), instTypes(), types);
+                    }
+                }
+            }
+            checkWithinBounds(this, warn);
+        }
+
+        private Infer infer() {
+            //back-door to infer
+            return Infer.this;
+        }
+    }
+
+    final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());
+    // </editor-fold>
+}
diff --git a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
new file mode 100644
index 0000000..21b6791
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
@@ -0,0 +1,2007 @@
+/*
+ * 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.  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.comp;
+
+import com.sun.tools.javac.tree.*;
+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.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;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.MethodType;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.comp.LambdaToMethod.LambdaAnalyzerPreprocessor.*;
+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.JCDiagnostic.DiagnosticPosition;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*;
+import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Kinds.*;
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+/**
+ * This pass desugars lambda expressions into static methods
+ *
+ *  <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 LambdaToMethod extends TreeTranslator {
+
+    private JCDiagnostic.Factory diags;
+    private Log log;
+    private Lower lower;
+    private Names names;
+    private Symtab syms;
+    private Resolve rs;
+    private TreeMaker make;
+    private Types types;
+    private TransTypes transTypes;
+    private Env<AttrContext> attrEnv;
+
+    /** the analyzer scanner */
+    private LambdaAnalyzerPreprocessor analyzer;
+
+    /** map from lambda trees to translation contexts */
+    private Map<JCTree, TranslationContext<?>> contextMap;
+
+    /** current translation context (visitor argument) */
+    private TranslationContext<?> context;
+
+    /** info about the current class being processed */
+    private KlassInfo kInfo;
+
+    /** dump statistics about lambda code generation */
+    private boolean dumpLambdaToMethodStats;
+
+    /** Flag for alternate metafactories indicating the lambda object is intended to be serializable */
+    public static final int FLAG_SERIALIZABLE = 1 << 0;
+
+    /** Flag for alternate metafactories indicating the lambda object has multiple targets */
+    public static final int FLAG_MARKERS = 1 << 1;
+
+    /** Flag for alternate metafactories indicating the lambda object requires multiple bridges */
+    public static final int FLAG_BRIDGES = 1 << 2;
+
+    private class KlassInfo {
+
+        /**
+         * list of methods to append
+         */
+        private ListBuffer<JCTree> appendedMethodList;
+
+        /**
+         * list of deserialization cases
+         */
+        private final Map<String, ListBuffer<JCStatement>> deserializeCases;
+
+       /**
+         * deserialize method symbol
+         */
+        private final MethodSymbol deserMethodSym;
+
+        /**
+         * deserialize method parameter symbol
+         */
+        private final VarSymbol deserParamSym;
+
+        private KlassInfo(Symbol kSym) {
+            appendedMethodList = ListBuffer.lb();
+            deserializeCases = new HashMap<String, ListBuffer<JCStatement>>();
+            long flags = PRIVATE | STATIC | SYNTHETIC;
+            MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType,
+                    List.<Type>nil(), syms.methodClass);
+            deserMethodSym = makeSyntheticMethod(flags, names.deserializeLambda, type, kSym);
+            deserParamSym = new VarSymbol(FINAL, names.fromString("lambda"),
+                    syms.serializedLambdaType, deserMethodSym);
+        }
+
+        private void addMethod(JCTree decl) {
+            appendedMethodList = appendedMethodList.prepend(decl);
+        }
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="Instantiating">
+    private static final Context.Key<LambdaToMethod> unlambdaKey =
+            new Context.Key<LambdaToMethod>();
+
+    public static LambdaToMethod instance(Context context) {
+        LambdaToMethod instance = context.get(unlambdaKey);
+        if (instance == null) {
+            instance = new LambdaToMethod(context);
+        }
+        return instance;
+    }
+
+    private LambdaToMethod(Context context) {
+        diags = JCDiagnostic.Factory.instance(context);
+        log = Log.instance(context);
+        lower = Lower.instance(context);
+        names = Names.instance(context);
+        syms = Symtab.instance(context);
+        rs = Resolve.instance(context);
+        make = TreeMaker.instance(context);
+        types = Types.instance(context);
+        transTypes = TransTypes.instance(context);
+        analyzer = new LambdaAnalyzerPreprocessor();
+        Options options = Options.instance(context);
+        dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats");
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="translate methods">
+    @Override
+    public <T extends JCTree> T translate(T tree) {
+        TranslationContext<?> newContext = contextMap.get(tree);
+        return translate(tree, newContext != null ? newContext : context);
+    }
+
+    <T extends JCTree> T translate(T tree, TranslationContext<?> newContext) {
+        TranslationContext<?> prevContext = context;
+        try {
+            context = newContext;
+            return super.translate(tree);
+        }
+        finally {
+            context = prevContext;
+        }
+    }
+
+    <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));
+        }
+        return buf.toList();
+    }
+
+    public JCTree translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) {
+        this.make = make;
+        this.attrEnv = env;
+        this.context = null;
+        this.contextMap = new HashMap<JCTree, TranslationContext<?>>();
+        return translate(cdef);
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="visitor methods">
+    /**
+     * Visit a class.
+     * Maintain the translatedMethodList across nested classes.
+     * Append the translatedMethodList to the class after it is translated.
+     * @param tree
+     */
+    @Override
+    public void visitClassDef(JCClassDecl tree) {
+        if (tree.sym.owner.kind == PCK) {
+            //analyze class
+            tree = analyzer.analyzeAndPreprocessClass(tree);
+        }
+        KlassInfo prevKlassInfo = kInfo;
+        try {
+            kInfo = new KlassInfo(tree.sym);
+            super.visitClassDef(tree);
+            if (!kInfo.deserializeCases.isEmpty()) {
+                kInfo.addMethod(makeDeserializeMethod(tree.sym));
+            }
+            //add all translated instance methods here
+            List<JCTree> newMethods = kInfo.appendedMethodList.toList();
+            tree.defs = tree.defs.appendList(newMethods);
+            for (JCTree lambda : newMethods) {
+                tree.sym.members().enter(((JCMethodDecl)lambda).sym);
+            }
+            result = tree;
+        } finally {
+            kInfo = prevKlassInfo;
+        }
+    }
+
+    /**
+     * Translate a lambda into a method to be inserted into the class.
+     * Then replace the lambda site with an invokedynamic call of to lambda
+     * meta-factory, which will use the lambda method.
+     * @param tree
+     */
+    @Override
+    public void visitLambda(JCLambda tree) {
+        LambdaTranslationContext localContext = (LambdaTranslationContext)context;
+        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.setTypeAttributes(ownerTypeAnnos.toList());
+                sym.setTypeAttributes(lambdaTypeAnnos.toList());
+            }
+        }
+
+        //create the method declaration hoisting the lambda body
+        JCMethodDecl lambdaDecl = make.MethodDef(make.Modifiers(sym.flags_field),
+                sym.name,
+                make.QualIdent(lambdaType.getReturnType().tsym),
+                List.<JCTypeParameter>nil(),
+                localContext.syntheticParams,
+                lambdaType.getThrownTypes() == null ?
+                    List.<JCExpression>nil() :
+                    make.Types(lambdaType.getThrownTypes()),
+                null,
+                null);
+        lambdaDecl.sym = sym;
+        lambdaDecl.type = lambdaType;
+
+        //translate lambda body
+        //As the lambda body is translated, all references to lambda locals,
+        //captured variables, enclosing members are adjusted accordingly
+        //to refer to the static method parameters (rather than i.e. acessing to
+        //captured members directly).
+        lambdaDecl.body = translate(makeLambdaBody(tree, lambdaDecl));
+
+        //Add the method to the list of methods to be added to this class.
+        kInfo.addMethod(lambdaDecl);
+
+        //now that we have generated a method for the lambda expression,
+        //we can translate the lambda into a method reference pointing to the newly
+        //created method.
+        //
+        //Note that we need to adjust the method handle so that it will match the
+        //signature of the SAM descriptor - this means that the method reference
+        //should be added the following synthetic arguments:
+        //
+        // * the "this" argument if it is an instance method
+        // * enclosing locals captured by the lambda expression
+
+        ListBuffer<JCExpression> syntheticInits = ListBuffer.lb();
+
+        if (!sym.isStatic()) {
+            syntheticInits.append(makeThis(
+                    sym.owner.enclClass().asType(),
+                    localContext.owner.enclClass()));
+        }
+
+        //add captured locals
+        for (Symbol fv : localContext.getSymbolMap(CAPTURED_VAR).keySet()) {
+            if (fv != localContext.self) {
+                JCTree captured_local = make.Ident(fv).setType(fv.type);
+                syntheticInits.append((JCExpression) captured_local);
+            }
+        }
+
+        //then, determine the arguments to the indy call
+        List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev);
+
+        //build a sam instance using an indy call to the meta-factory
+        int refKind = referenceKind(sym);
+
+        //convert to an invokedynamic call
+        result = makeMetafactoryIndyCall(context, refKind, sym, indy_args);
+    }
+
+    private JCIdent makeThis(Type type, Symbol owner) {
+        VarSymbol _this = new VarSymbol(PARAMETER | FINAL | SYNTHETIC,
+                names._this,
+                type,
+                owner);
+        return make.Ident(_this);
+    }
+
+    /**
+     * Translate a method reference into an invokedynamic call to the
+     * meta-factory.
+     * @param tree
+     */
+    @Override
+    public void visitReference(JCMemberReference tree) {
+        ReferenceTranslationContext localContext = (ReferenceTranslationContext)context;
+
+        //first determine the method symbol to be used to generate the sam instance
+        //this is either the method reference symbol, or the bridged reference symbol
+        Symbol refSym = localContext.needsBridge() ?
+            localContext.bridgeSym :
+            tree.sym;
+
+        //build the bridge method, if needed
+        if (localContext.needsBridge()) {
+            bridgeMemberReference(tree, localContext);
+        }
+
+        //the qualifying expression is treated as a special captured arg
+        JCExpression init;
+        switch(tree.kind) {
+
+            case IMPLICIT_INNER:    /** Inner :: new */
+            case SUPER:             /** super :: instMethod */
+                init = makeThis(
+                    localContext.owner.enclClass().asType(),
+                    localContext.owner.enclClass());
+                break;
+
+            case BOUND:             /** Expr :: instMethod */
+                init = tree.getQualifierExpression();
+                break;
+
+            case UNBOUND:           /** Type :: instMethod */
+            case STATIC:            /** Type :: staticMethod */
+            case TOPLEVEL:          /** Top level :: new */
+            case ARRAY_CTOR:        /** ArrayType :: new */
+                init = null;
+                break;
+
+            default:
+                throw new InternalError("Should not have an invalid kind");
+        }
+
+        List<JCExpression> indy_args = init==null? List.<JCExpression>nil() : translate(List.of(init), localContext.prev);
+
+
+        //build a sam instance using an indy call to the meta-factory
+        result = makeMetafactoryIndyCall(localContext, localContext.referenceKind(), refSym, indy_args);
+    }
+
+    /**
+     * Translate identifiers within a lambda to the mapped identifier
+     * @param tree
+     */
+    @Override
+    public void visitIdent(JCIdent tree) {
+        if (context == null || !analyzer.lambdaIdentSymbolFilter(tree.sym)) {
+            super.visitIdent(tree);
+        } else {
+            LambdaTranslationContext lambdaContext = (LambdaTranslationContext) context;
+            if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) {
+                Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym);
+                result = make.Ident(translatedSym).setType(tree.type);
+                translatedSym.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.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.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);
+            } else {
+                //access to untranslated symbols (i.e. compile-time constants,
+                //members defined inside the lambda body, etc.) )
+                super.visitIdent(tree);
+            }
+        }
+    }
+
+    @Override
+    public void visitVarDef(JCVariableDecl tree) {
+        LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context;
+        if (context != null && lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
+            JCExpression init = translate(tree.init);
+            result = make.VarDef((VarSymbol)lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym), init);
+        } else if (context != null && lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
+            JCExpression init = translate(tree.init);
+            VarSymbol xsym = (VarSymbol)lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
+            result = make.VarDef(xsym, init);
+            // Replace the entered symbol for this variable
+            Scope sc = tree.sym.owner.members();
+            if (sc != null) {
+                sc.remove(tree.sym);
+                sc.enter(xsym);
+            }
+        } else {
+            super.visitVarDef(tree);
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Translation helper methods">
+
+    private JCBlock makeLambdaBody(JCLambda tree, JCMethodDecl lambdaMethodDecl) {
+        return tree.getBodyKind() == JCLambda.BodyKind.EXPRESSION ?
+                makeLambdaExpressionBody((JCExpression)tree.body, lambdaMethodDecl) :
+                makeLambdaStatementBody((JCBlock)tree.body, lambdaMethodDecl, tree.canCompleteNormally);
+    }
+
+    private JCBlock makeLambdaExpressionBody(JCExpression expr, JCMethodDecl lambdaMethodDecl) {
+        Type restype = lambdaMethodDecl.type.getReturnType();
+        boolean isLambda_void = expr.type.hasTag(VOID);
+        boolean isTarget_void = restype.hasTag(VOID);
+        boolean isTarget_Void = types.isSameType(restype, types.boxedClass(syms.voidType).type);
+        if (isTarget_void) {
+            //target is void:
+            // BODY;
+            JCStatement stat = make.Exec(expr);
+            return make.Block(0, List.<JCStatement>of(stat));
+        } else if (isLambda_void && isTarget_Void) {
+            //void to Void conversion:
+            // BODY; return null;
+            ListBuffer<JCStatement> stats = ListBuffer.lb();
+            stats.append(make.Exec(expr));
+            stats.append(make.Return(make.Literal(BOT, null).setType(syms.botType)));
+            return make.Block(0, stats.toList());
+        } else {
+            //non-void to non-void conversion:
+            // return (TYPE)BODY;
+            JCExpression retExpr = transTypes.coerce(attrEnv, expr, restype);
+            return make.Block(0, List.<JCStatement>of(make.Return(retExpr)));
+        }
+    }
+
+    private JCBlock makeLambdaStatementBody(JCBlock block, final JCMethodDecl lambdaMethodDecl, boolean completeNormally) {
+        final Type restype = lambdaMethodDecl.type.getReturnType();
+        final boolean isTarget_void = restype.hasTag(VOID);
+        boolean isTarget_Void = types.isSameType(restype, types.boxedClass(syms.voidType).type);
+
+        class LambdaBodyTranslator extends TreeTranslator {
+
+            @Override
+            public void visitClassDef(JCClassDecl tree) {
+                //do NOT recurse on any inner classes
+                result = tree;
+            }
+
+            @Override
+            public void visitLambda(JCLambda tree) {
+                //do NOT recurse on any nested lambdas
+                result = tree;
+            }
+
+            @Override
+            public void visitReturn(JCReturn tree) {
+                boolean isLambda_void = tree.expr == null;
+                if (isTarget_void && !isLambda_void) {
+                    //Void to void conversion:
+                    // { TYPE $loc = RET-EXPR; return; }
+                    VarSymbol loc = makeSyntheticVar(0, names.fromString("$loc"), tree.expr.type, lambdaMethodDecl.sym);
+                    JCVariableDecl varDef = make.VarDef(loc, tree.expr);
+                    result = make.Block(0, List.<JCStatement>of(varDef, make.Return(null)));
+                } else if (!isTarget_void || !isLambda_void) {
+                    //non-void to non-void conversion:
+                    // return (TYPE)RET-EXPR;
+                    tree.expr = transTypes.coerce(attrEnv, tree.expr, restype);
+                    result = tree;
+                } else {
+                    result = tree;
+                }
+
+            }
+        }
+
+        JCBlock trans_block = new LambdaBodyTranslator().translate(block);
+        if (completeNormally && isTarget_Void) {
+            //there's no return statement and the lambda (possibly inferred)
+            //return type is java.lang.Void; emit a synthetic return statement
+            trans_block.stats = trans_block.stats.append(make.Return(make.Literal(BOT, null).setType(syms.botType)));
+        }
+        return trans_block;
+    }
+
+    private JCMethodDecl makeDeserializeMethod(Symbol kSym) {
+        ListBuffer<JCCase> cases = ListBuffer.lb();
+        ListBuffer<JCBreak> breaks = ListBuffer.lb();
+        for (Map.Entry<String, ListBuffer<JCStatement>> entry : kInfo.deserializeCases.entrySet()) {
+            JCBreak br = make.Break(null);
+            breaks.add(br);
+            List<JCStatement> stmts = entry.getValue().append(br).toList();
+            cases.add(make.Case(make.Literal(entry.getKey()), stmts));
+        }
+        JCSwitch sw = make.Switch(deserGetter("getImplMethodName", syms.stringType), cases.toList());
+        for (JCBreak br : breaks) {
+            br.target = sw;
+        }
+        JCBlock body = make.Block(0L, List.<JCStatement>of(
+                sw,
+                make.Throw(makeNewClass(
+                    syms.illegalArgumentExceptionType,
+                    List.<JCExpression>of(make.Literal("Invalid lambda deserialization"))))));
+        JCMethodDecl deser = make.MethodDef(make.Modifiers(kInfo.deserMethodSym.flags()),
+                        names.deserializeLambda,
+                        make.QualIdent(kInfo.deserMethodSym.getReturnType().tsym),
+                        List.<JCTypeParameter>nil(),
+                        List.of(make.VarDef(kInfo.deserParamSym, null)),
+                        List.<JCExpression>nil(),
+                        body,
+                        null);
+        deser.sym = kInfo.deserMethodSym;
+        deser.type = kInfo.deserMethodSym.type;
+        //System.err.printf("DESER: '%s'\n", deser);
+        return deser;
+    }
+
+    /** Make an attributed class instance creation expression.
+     *  @param ctype    The class type.
+     *  @param args     The constructor arguments.
+     *  @param cons     The constructor symbol
+     */
+    JCNewClass makeNewClass(Type ctype, List<JCExpression> args, Symbol cons) {
+        JCNewClass tree = make.NewClass(null,
+            null, make.QualIdent(ctype.tsym), args, null);
+        tree.constructor = cons;
+        tree.type = ctype;
+        return tree;
+    }
+
+    /** Make an attributed class instance creation expression.
+     *  @param ctype    The class type.
+     *  @param args     The constructor arguments.
+     */
+    JCNewClass makeNewClass(Type ctype, List<JCExpression> args) {
+        return makeNewClass(ctype, args,
+                rs.resolveConstructor(null, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil()));
+     }
+
+    private void addDeserializationCase(int implMethodKind, Symbol refSym, Type targetType, MethodSymbol samSym,
+            DiagnosticPosition pos, List<Object> staticArgs, MethodType indyType) {
+        String functionalInterfaceClass = classSig(targetType);
+        String functionalInterfaceMethodName = samSym.getSimpleName().toString();
+        String functionalInterfaceMethodSignature = methodSig(types.erasure(samSym.type));
+        String implClass = classSig(types.erasure(refSym.owner.type));
+        String implMethodName = refSym.getQualifiedName().toString();
+        String implMethodSignature = methodSig(types.erasure(refSym.type));
+
+        JCExpression kindTest = eqTest(syms.intType, deserGetter("getImplMethodKind", syms.intType), make.Literal(implMethodKind));
+        ListBuffer<JCExpression> serArgs = ListBuffer.lb();
+        int i = 0;
+        for (Type t : indyType.getParameterTypes()) {
+            List<JCExpression> indexAsArg = ListBuffer.<JCExpression>lb().append(make.Literal(i)).toList();
+            List<Type> argTypes = ListBuffer.<Type>lb().append(syms.intType).toList();
+            serArgs.add(make.TypeCast(types.erasure(t), deserGetter("getCapturedArg", syms.objectType, argTypes, indexAsArg)));
+            ++i;
+        }
+        JCStatement stmt = make.If(
+                deserTest(deserTest(deserTest(deserTest(deserTest(
+                    kindTest,
+                    "getFunctionalInterfaceClass", functionalInterfaceClass),
+                    "getFunctionalInterfaceMethodName", functionalInterfaceMethodName),
+                    "getFunctionalInterfaceMethodSignature", functionalInterfaceMethodSignature),
+                    "getImplClass", implClass),
+                    "getImplMethodSignature", implMethodSignature),
+                make.Return(makeIndyCall(
+                    pos,
+                    syms.lambdaMetafactory,
+                    names.altMetafactory,
+                    staticArgs, indyType, serArgs.toList(), samSym.name)),
+                null);
+        ListBuffer<JCStatement> stmts = kInfo.deserializeCases.get(implMethodName);
+        if (stmts == null) {
+            stmts = ListBuffer.lb();
+            kInfo.deserializeCases.put(implMethodName, stmts);
+        }
+        /****
+        System.err.printf("+++++++++++++++++\n");
+        System.err.printf("*functionalInterfaceClass: '%s'\n", functionalInterfaceClass);
+        System.err.printf("*functionalInterfaceMethodName: '%s'\n", functionalInterfaceMethodName);
+        System.err.printf("*functionalInterfaceMethodSignature: '%s'\n", functionalInterfaceMethodSignature);
+        System.err.printf("*implMethodKind: %d\n", implMethodKind);
+        System.err.printf("*implClass: '%s'\n", implClass);
+        System.err.printf("*implMethodName: '%s'\n", implMethodName);
+        System.err.printf("*implMethodSignature: '%s'\n", implMethodSignature);
+        ****/
+        stmts.append(stmt);
+    }
+
+    private JCExpression eqTest(Type argType, JCExpression arg1, JCExpression arg2) {
+        JCBinary testExpr = make.Binary(JCTree.Tag.EQ, arg1, arg2);
+        testExpr.operator = rs.resolveBinaryOperator(null, JCTree.Tag.EQ, attrEnv, argType, argType);
+        testExpr.setType(syms.booleanType);
+        return testExpr;
+    }
+
+    private JCExpression deserTest(JCExpression prev, String func, String lit) {
+        MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass);
+        Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil());
+        JCMethodInvocation eqtest = make.Apply(
+                List.<JCExpression>nil(),
+                make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt),
+                List.<JCExpression>of(make.Literal(lit)));
+        eqtest.setType(syms.booleanType);
+        JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest);
+        compound.operator = rs.resolveBinaryOperator(null, JCTree.Tag.AND, attrEnv, syms.booleanType, syms.booleanType);
+        compound.setType(syms.booleanType);
+        return compound;
+    }
+
+    private JCExpression deserGetter(String func, Type type) {
+        return deserGetter(func, type, List.<Type>nil(), List.<JCExpression>nil());
+    }
+
+    private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) {
+        MethodType getmt = new MethodType(argTypes, type, List.<Type>nil(), syms.methodClass);
+        Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.<Type>nil());
+        return make.Apply(
+                    List.<JCExpression>nil(),
+                    make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt),
+                    args).setType(type);
+    }
+
+    /**
+     * Create new synthetic method with given flags, name, type, owner
+     */
+    private MethodSymbol makeSyntheticMethod(long flags, Name name, Type type, Symbol owner) {
+        return new MethodSymbol(flags | SYNTHETIC, name, type, owner);
+    }
+
+    /**
+     * Create new synthetic variable with given flags, name, type, owner
+     */
+    private VarSymbol makeSyntheticVar(long flags, String name, Type type, Symbol owner) {
+        return makeSyntheticVar(flags, names.fromString(name), type, owner);
+    }
+
+    /**
+     * Create new synthetic variable with given flags, name, type, owner
+     */
+    private VarSymbol makeSyntheticVar(long flags, Name name, Type type, Symbol owner) {
+        return new VarSymbol(flags | SYNTHETIC, name, type, owner);
+    }
+
+    /**
+     * Set varargsElement field on a given tree (must be either a new class tree
+     * or a method call tree)
+     */
+    private void setVarargsIfNeeded(JCTree tree, Type varargsElement) {
+        if (varargsElement != null) {
+            switch (tree.getTag()) {
+                case APPLY: ((JCMethodInvocation)tree).varargsElement = varargsElement; break;
+                case NEWCLASS: ((JCNewClass)tree).varargsElement = varargsElement; break;
+                default: throw new AssertionError();
+            }
+        }
+    }
+
+    /**
+     * Convert method/constructor arguments by inserting appropriate cast
+     * as required by type-erasure - this is needed when bridging a lambda/method
+     * reference, as the bridged signature might require downcast to be compatible
+     * with the generated signature.
+     */
+    private List<JCExpression> convertArgs(Symbol meth, List<JCExpression> args, Type varargsElement) {
+       Assert.check(meth.kind == Kinds.MTH);
+       List<Type> formals = types.erasure(meth.type).getParameterTypes();
+       if (varargsElement != null) {
+           Assert.check((meth.flags() & VARARGS) != 0);
+       }
+       return transTypes.translateArgs(args, formals, varargsElement, attrEnv);
+    }
+
+    // </editor-fold>
+
+    /**
+     * Generate an adapter method "bridge" for a method reference which cannot
+     * be used directly.
+     */
+    private class MemberReferenceBridger {
+
+        private final JCMemberReference tree;
+        private final ReferenceTranslationContext localContext;
+        private final ListBuffer<JCExpression> args = ListBuffer.lb();
+        private final ListBuffer<JCVariableDecl> params = ListBuffer.lb();
+
+        MemberReferenceBridger(JCMemberReference tree, ReferenceTranslationContext localContext) {
+            this.tree = tree;
+            this.localContext = localContext;
+        }
+
+        /**
+         * Generate the bridge
+         */
+        JCMethodDecl bridge() {
+            int prevPos = make.pos;
+            try {
+                make.at(tree);
+                Type samDesc = localContext.bridgedRefSig();
+                List<Type> samPTypes = samDesc.getParameterTypes();
+
+                //an extra argument is prepended to the signature of the bridge in case
+                //the member reference is an instance method reference (in which case
+                //the receiver expression is passed to the bridge itself).
+                Type recType = null;
+                switch (tree.kind) {
+                    case IMPLICIT_INNER:
+                        recType = tree.sym.owner.type.getEnclosingType();
+                        break;
+                    case BOUND:
+                        recType = tree.getQualifierExpression().type;
+                        break;
+                    case UNBOUND:
+                        recType = samPTypes.head;
+                        samPTypes = samPTypes.tail;
+                        break;
+                }
+
+                //generate the parameter list for the bridged member reference - the
+                //bridge signature will match the signature of the target sam descriptor
+
+                VarSymbol rcvr = (recType == null)
+                        ? null
+                        : addParameter("rec$", recType, false);
+
+                List<Type> refPTypes = tree.sym.type.getParameterTypes();
+                int refSize = refPTypes.size();
+                int samSize = samPTypes.size();
+                // Last parameter to copy from referenced method
+                int last = localContext.needsVarArgsConversion() ? refSize - 1 : refSize;
+
+                List<Type> l = refPTypes;
+                // Use parameter types of the referenced method, excluding final var args
+                for (int i = 0; l.nonEmpty() && i < last; ++i) {
+                    addParameter("x$" + i, l.head, true);
+                    l = l.tail;
+                }
+                // Flatten out the var args
+                for (int i = last; i < samSize; ++i) {
+                    addParameter("xva$" + i, tree.varargsElement, true);
+                }
+
+                //generate the bridge method declaration
+                JCMethodDecl bridgeDecl = make.MethodDef(make.Modifiers(localContext.bridgeSym.flags()),
+                        localContext.bridgeSym.name,
+                        make.QualIdent(samDesc.getReturnType().tsym),
+                        List.<JCTypeParameter>nil(),
+                        params.toList(),
+                        tree.sym.type.getThrownTypes() == null
+                        ? List.<JCExpression>nil()
+                        : make.Types(tree.sym.type.getThrownTypes()),
+                        null,
+                        null);
+                bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym;
+                bridgeDecl.type = localContext.bridgeSym.type =
+                        types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList()));
+
+                //bridge method body generation - this can be either a method call or a
+                //new instance creation expression, depending on the member reference kind
+                JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE)
+                        ? bridgeExpressionInvoke(makeReceiver(rcvr))
+                        : bridgeExpressionNew();
+
+                //the body is either a return expression containing a method call,
+                //or the method call itself, depending on whether the return type of
+                //the bridge is non-void/void.
+                bridgeDecl.body = makeLambdaExpressionBody(bridgeExpr, bridgeDecl);
+
+                return bridgeDecl;
+            } finally {
+                make.at(prevPos);
+            }
+        }
+        //where
+            private JCExpression makeReceiver(VarSymbol rcvr) {
+                if (rcvr == null) return null;
+                JCExpression rcvrExpr = make.Ident(rcvr);
+                Type rcvrType = tree.sym.enclClass().type;
+                if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) {
+                    rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType);
+                }
+                return rcvrExpr;
+            }
+
+        /**
+         * determine the receiver of the bridged method call - the receiver can
+         * be either the synthetic receiver parameter or a type qualifier; the
+         * original qualifier expression is never used here, as it might refer
+         * to symbols not available in the static context of the bridge
+         */
+        private JCExpression bridgeExpressionInvoke(JCExpression rcvr) {
+            JCExpression qualifier =
+                    tree.sym.isStatic() ?
+                        make.Type(tree.sym.owner.type) :
+                        (rcvr != null) ?
+                            rcvr :
+                            tree.getQualifierExpression();
+
+            //create the qualifier expression
+            JCFieldAccess select = make.Select(qualifier, tree.sym.name);
+            select.sym = tree.sym;
+            select.type = tree.sym.erasure(types);
+
+            //create the method call expression
+            JCExpression apply = make.Apply(List.<JCExpression>nil(), select,
+                    convertArgs(tree.sym, args.toList(), tree.varargsElement)).
+                    setType(tree.sym.erasure(types).getReturnType());
+
+            apply = transTypes.coerce(apply, localContext.generatedRefSig().getReturnType());
+            setVarargsIfNeeded(apply, tree.varargsElement);
+            return apply;
+        }
+
+        /**
+         * the enclosing expression is either 'null' (no enclosing type) or set
+         * to the first bridge synthetic parameter
+         */
+        private JCExpression bridgeExpressionNew() {
+            if (tree.kind == ReferenceKind.ARRAY_CTOR) {
+                //create the array creation expression
+                JCNewArray newArr = make.NewArray(
+                        make.Type(types.elemtype(tree.getQualifierExpression().type)),
+                        List.of(make.Ident(params.first())),
+                        null);
+                newArr.type = tree.getQualifierExpression().type;
+                return newArr;
+            } else {
+                JCExpression encl = null;
+                switch (tree.kind) {
+                    case UNBOUND:
+                    case IMPLICIT_INNER:
+                        encl = make.Ident(params.first());
+                }
+
+                //create the instance creation expression
+                JCNewClass newClass = make.NewClass(encl,
+                        List.<JCExpression>nil(),
+                        make.Type(tree.getQualifierExpression().type),
+                        convertArgs(tree.sym, args.toList(), tree.varargsElement),
+                        null);
+                newClass.constructor = tree.sym;
+                newClass.constructorType = tree.sym.erasure(types);
+                newClass.type = tree.getQualifierExpression().type;
+                setVarargsIfNeeded(newClass, tree.varargsElement);
+                return newClass;
+            }
+        }
+
+        private VarSymbol addParameter(String name, Type p, boolean genArg) {
+            VarSymbol vsym = new VarSymbol(0, names.fromString(name), p, localContext.bridgeSym);
+            params.append(make.VarDef(vsym, null));
+            if (genArg) {
+                args.append(make.Ident(vsym));
+            }
+            return vsym;
+        }
+    }
+
+    /**
+     * Bridges a member reference - this is needed when:
+     * * Var args in the referenced method need to be flattened away
+     * * super is used
+     */
+    private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) {
+        kInfo.addMethod(new MemberReferenceBridger(tree, localContext).bridge());
+    }
+
+    private MethodType typeToMethodType(Type mt) {
+        Type type = types.erasure(mt);
+        return new MethodType(type.getParameterTypes(),
+                        type.getReturnType(),
+                        type.getThrownTypes(),
+                        syms.methodClass);
+    }
+
+    /**
+     * Generate an indy method call to the meta factory
+     */
+    private JCExpression makeMetafactoryIndyCall(TranslationContext<?> context,
+            int refKind, Symbol refSym, List<JCExpression> indy_args) {
+        JCFunctionalExpression tree = context.tree;
+        //determine the static bsm args
+        MethodSymbol samSym = (MethodSymbol) types.findDescriptorSymbol(tree.type.tsym);
+        List<Object> staticArgs = List.<Object>of(
+                typeToMethodType(samSym.type),
+                new Pool.MethodHandle(refKind, refSym, types),
+                typeToMethodType(tree.getDescriptorType(types)));
+
+        //computed indy arg types
+        ListBuffer<Type> indy_args_types = ListBuffer.lb();
+        for (JCExpression arg : indy_args) {
+            indy_args_types.append(arg.type);
+        }
+
+        //finally, compute the type of the indy call
+        MethodType indyType = new MethodType(indy_args_types.toList(),
+                tree.type,
+                List.<Type>nil(),
+                syms.methodClass);
+
+        Name metafactoryName = context.needsAltMetafactory() ?
+                names.altMetafactory : names.metafactory;
+
+        if (context.needsAltMetafactory()) {
+            ListBuffer<Object> markers = ListBuffer.lb();
+            for (Type t : tree.targets.tail) {
+                if (t.tsym != syms.serializableType.tsym) {
+                    markers.append(t.tsym);
+                }
+            }
+            int flags = context.isSerializable() ? FLAG_SERIALIZABLE : 0;
+            boolean hasMarkers = markers.nonEmpty();
+            boolean hasBridges = context.bridges.nonEmpty();
+            if (hasMarkers) {
+                flags |= FLAG_MARKERS;
+            }
+            if (hasBridges) {
+                flags |= FLAG_BRIDGES;
+            }
+            staticArgs = staticArgs.append(flags);
+            if (hasMarkers) {
+                staticArgs = staticArgs.append(markers.length());
+                staticArgs = staticArgs.appendList(markers.toList());
+            }
+            if (hasBridges) {
+                staticArgs = staticArgs.append(context.bridges.length() - 1);
+                for (Symbol s : context.bridges) {
+                    Type s_erasure = s.erasure(types);
+                    if (!types.isSameType(s_erasure, samSym.erasure(types))) {
+                        staticArgs = staticArgs.append(s.erasure(types));
+                    }
+                }
+            }
+            if (context.isSerializable()) {
+                addDeserializationCase(refKind, refSym, tree.type, samSym,
+                        tree, staticArgs, indyType);
+            }
+        }
+
+        return makeIndyCall(tree, syms.lambdaMetafactory, metafactoryName, staticArgs, indyType, indy_args, samSym.name);
+    }
+
+    /**
+     * Generate an indy method call with given name, type and static bootstrap
+     * arguments types
+     */
+    private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
+            List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
+            Name methName) {
+        int prevPos = make.pos;
+        try {
+            make.at(pos);
+            List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
+                    syms.stringType,
+                    syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));
+
+            Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
+                    bsmName, bsm_staticArgs, List.<Type>nil());
+
+            DynamicMethodSymbol dynSym =
+                    new DynamicMethodSymbol(methName,
+                                            syms.noSymbol,
+                                            bsm.isStatic() ?
+                                                ClassFile.REF_invokeStatic :
+                                                ClassFile.REF_invokeVirtual,
+                                            (MethodSymbol)bsm,
+                                            indyType,
+                                            staticArgs.toArray());
+
+            JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
+            qualifier.sym = dynSym;
+            qualifier.type = indyType.getReturnType();
+
+            JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
+            proxyCall.type = indyType.getReturnType();
+            return proxyCall;
+        } finally {
+            make.at(prevPos);
+        }
+    }
+    //where
+    private List<Type> bsmStaticArgToTypes(List<Object> args) {
+        ListBuffer<Type> argtypes = ListBuffer.lb();
+        for (Object arg : args) {
+            argtypes.append(bsmStaticArgToType(arg));
+        }
+        return argtypes.toList();
+    }
+
+    private Type bsmStaticArgToType(Object arg) {
+        Assert.checkNonNull(arg);
+        if (arg instanceof ClassSymbol) {
+            return syms.classType;
+        } else if (arg instanceof Integer) {
+            return syms.intType;
+        } else if (arg instanceof Long) {
+            return syms.longType;
+        } else if (arg instanceof Float) {
+            return syms.floatType;
+        } else if (arg instanceof Double) {
+            return syms.doubleType;
+        } else if (arg instanceof String) {
+            return syms.stringType;
+        } else if (arg instanceof Pool.MethodHandle) {
+            return syms.methodHandleType;
+        } else if (arg instanceof MethodType) {
+            return syms.methodTypeType;
+        } else {
+            Assert.error("bad static arg " + arg.getClass());
+            return null;
+        }
+    }
+
+    /**
+     * Get the opcode associated with this method reference
+     */
+    private int referenceKind(Symbol refSym) {
+        if (refSym.isConstructor()) {
+            return ClassFile.REF_newInvokeSpecial;
+        } else {
+            if (refSym.isStatic()) {
+                return ClassFile.REF_invokeStatic;
+            } else if (refSym.enclClass().isInterface()) {
+                return ClassFile.REF_invokeInterface;
+            } else {
+                return (refSym.flags() & PRIVATE) != 0 ?
+                        ClassFile.REF_invokeSpecial :
+                        ClassFile.REF_invokeVirtual;
+            }
+        }
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="Lambda/reference analyzer">
+    /**
+     * This visitor collects information about translation of a lambda expression.
+     * More specifically, it keeps track of the enclosing contexts and captured locals
+     * accessed by the lambda being translated (as well as other useful info).
+     * It also translates away problems for LambdaToMethod.
+     */
+    class LambdaAnalyzerPreprocessor extends TreeTranslator {
+
+        /** the frame stack - used to reconstruct translation info about enclosing scopes */
+        private List<Frame> frameStack;
+
+        /**
+         * keep the count of lambda expression (used to generate unambiguous
+         * names)
+         */
+        private int lambdaCount = 0;
+
+        /**
+         * keep the count of lambda expression defined in given context (used to
+         * generate unambiguous names for serializable lambdas)
+         */
+        private Map<String, Integer> serializableLambdaCounts =
+                new HashMap<String, Integer>();
+
+        private Map<Symbol, JCClassDecl> localClassDefs;
+
+        /**
+         * maps for fake clinit symbols to be used as owners of lambda occurring in
+         * a static var init context
+         */
+        private Map<ClassSymbol, Symbol> clinits =
+                new HashMap<ClassSymbol, Symbol>();
+
+        private JCClassDecl analyzeAndPreprocessClass(JCClassDecl tree) {
+            frameStack = List.nil();
+            localClassDefs = new HashMap<Symbol, JCClassDecl>();
+            return translate(tree);
+        }
+
+        @Override
+        public void visitBlock(JCBlock tree) {
+            List<Frame> prevStack = frameStack;
+            try {
+                if (frameStack.nonEmpty() && frameStack.head.tree.hasTag(CLASSDEF)) {
+                    frameStack = frameStack.prepend(new Frame(tree));
+                }
+                super.visitBlock(tree);
+            }
+            finally {
+                frameStack = prevStack;
+            }
+        }
+
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            List<Frame> prevStack = frameStack;
+            Map<String, Integer> prevSerializableLambdaCount =
+                    serializableLambdaCounts;
+            Map<ClassSymbol, Symbol> prevClinits = clinits;
+            DiagnosticSource prevSource = log.currentSource();
+            try {
+                log.useSource(tree.sym.sourcefile);
+                serializableLambdaCounts = new HashMap<String, Integer>();
+                prevClinits = new HashMap<ClassSymbol, Symbol>();
+                if (tree.sym.owner.kind == MTH) {
+                    localClassDefs.put(tree.sym, tree);
+                }
+                if (directlyEnclosingLambda() != null) {
+                    tree.sym.owner = owner();
+                    if (tree.sym.hasOuterInstance()) {
+                        //if a class is defined within a lambda, the lambda must capture
+                        //its enclosing instance (if any)
+                        TranslationContext<?> localContext = context();
+                        while (localContext != null) {
+                            if (localContext.tree.getTag() == LAMBDA) {
+                                ((LambdaTranslationContext)localContext)
+                                        .addSymbol(tree.sym.type.getEnclosingType().tsym, CAPTURED_THIS);
+                            }
+                            localContext = localContext.prev;
+                        }
+                    }
+                }
+                frameStack = frameStack.prepend(new Frame(tree));
+                super.visitClassDef(tree);
+            }
+            finally {
+                log.useSource(prevSource.getFile());
+                frameStack = prevStack;
+                serializableLambdaCounts = prevSerializableLambdaCount;
+                clinits = prevClinits;
+            }
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            if (context() != null && lambdaIdentSymbolFilter(tree.sym)) {
+                if (tree.sym.kind == VAR &&
+                        tree.sym.owner.kind == MTH &&
+                        tree.type.constValue() == null) {
+                    TranslationContext<?> localContext = context();
+                    while (localContext != null) {
+                        if (localContext.tree.getTag() == LAMBDA) {
+                            JCTree block = capturedDecl(localContext.depth, tree.sym);
+                            if (block == null) break;
+                            ((LambdaTranslationContext)localContext)
+                                    .addSymbol(tree.sym, CAPTURED_VAR);
+                        }
+                        localContext = localContext.prev;
+                    }
+                } else if (tree.sym.owner.kind == TYP) {
+                    TranslationContext<?> localContext = context();
+                    while (localContext != null) {
+                        if (localContext.tree.hasTag(LAMBDA)) {
+                            JCTree block = capturedDecl(localContext.depth, tree.sym);
+                            if (block == null) break;
+                            switch (block.getTag()) {
+                                case CLASSDEF:
+                                    JCClassDecl cdecl = (JCClassDecl)block;
+                                    ((LambdaTranslationContext)localContext)
+                                            .addSymbol(cdecl.sym, CAPTURED_THIS);
+                                    break;
+                                default:
+                                    Assert.error("bad block kind");
+                            }
+                        }
+                        localContext = localContext.prev;
+                    }
+                }
+            }
+            super.visitIdent(tree);
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            List<Frame> prevStack = frameStack;
+            try {
+                LambdaTranslationContext context = (LambdaTranslationContext)makeLambdaContext(tree);
+                frameStack = frameStack.prepend(new Frame(tree));
+                for (JCVariableDecl param : tree.params) {
+                    context.addSymbol(param.sym, PARAM);
+                    frameStack.head.addLocal(param.sym);
+                }
+                contextMap.put(tree, context);
+                super.visitLambda(tree);
+                context.complete();
+            }
+            finally {
+                frameStack = prevStack;
+            }
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            List<Frame> prevStack = frameStack;
+            try {
+                frameStack = frameStack.prepend(new Frame(tree));
+                super.visitMethodDef(tree);
+            }
+            finally {
+                frameStack = prevStack;
+            }
+        }
+
+        @Override
+        public void visitNewClass(JCNewClass tree) {
+            if (lambdaNewClassFilter(context(), tree)) {
+                TranslationContext<?> localContext = context();
+                while (localContext != null) {
+                    if (localContext.tree.getTag() == LAMBDA) {
+                        ((LambdaTranslationContext)localContext)
+                                .addSymbol(tree.type.getEnclosingType().tsym, CAPTURED_THIS);
+                    }
+                    localContext = localContext.prev;
+                }
+            }
+            if (context() != null && tree.type.tsym.owner.kind == MTH) {
+                LambdaTranslationContext lambdaContext = (LambdaTranslationContext)context();
+                captureLocalClassDefs(tree.type.tsym, lambdaContext);
+            }
+            super.visitNewClass(tree);
+        }
+        //where
+            void captureLocalClassDefs(Symbol csym, final LambdaTranslationContext lambdaContext) {
+                JCClassDecl localCDef = localClassDefs.get(csym);
+                if (localCDef != null && localCDef.pos < lambdaContext.tree.pos) {
+                    BasicFreeVarCollector fvc = lower.new BasicFreeVarCollector() {
+                        @Override
+                        void addFreeVars(ClassSymbol c) {
+                            captureLocalClassDefs(c, lambdaContext);
+                        }
+                        @Override
+                        void visitSymbol(Symbol sym) {
+                            if (sym.kind == VAR &&
+                                    sym.owner.kind == MTH &&
+                                    ((VarSymbol)sym).getConstValue() == null) {
+                                TranslationContext<?> localContext = context();
+                                while (localContext != null) {
+                                    if (localContext.tree.getTag() == LAMBDA) {
+                                        JCTree block = capturedDecl(localContext.depth, sym);
+                                        if (block == null) break;
+                                        ((LambdaTranslationContext)localContext).addSymbol(sym, CAPTURED_VAR);
+                                    }
+                                    localContext = localContext.prev;
+                                }
+                            }
+                        }
+                    };
+                    fvc.scan(localCDef);
+                }
+        }
+
+        /**
+         * Method references to local class constructors, may, if the local
+         * class references local variables, have implicit constructor
+         * parameters added in Lower; As a result, the invokedynamic bootstrap
+         * information added in the LambdaToMethod pass will have the wrong
+         * signature. Hooks between Lower and LambdaToMethod have been added to
+         * handle normal "new" in this case. This visitor converts potentially
+         * effected method references into a lambda containing a normal "new" of
+         * the class.
+         *
+         * @param tree
+         */
+        @Override
+        public void visitReference(JCMemberReference tree) {
+            if (tree.getMode() == ReferenceMode.NEW
+                    && tree.kind != ReferenceKind.ARRAY_CTOR
+                    && tree.sym.owner.isLocal()) {
+                MethodSymbol consSym = (MethodSymbol) tree.sym;
+                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
+                JCNewClass nc = makeNewClass(classType, make.Idents(params));
+                nc.pos = tree.pos;
+
+                // Make lambda holding the new-class call
+                JCLambda slam = make.Lambda(params, nc);
+                slam.targets = tree.targets;
+                slam.type = tree.type;
+                slam.pos = tree.pos;
+
+                // Now it is a lambda, process as such
+                visitLambda(slam);
+            } else {
+                super.visitReference(tree);
+                contextMap.put(tree, makeReferenceContext(tree));
+            }
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            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)) {
+                        JCClassDecl clazz = (JCClassDecl)capturedDecl(localContext.depth, tree.sym);
+                        if (clazz == null) break;
+                        ((LambdaTranslationContext)localContext).addSymbol(clazz.sym, CAPTURED_THIS);
+                    }
+                    localContext = localContext.prev;
+                }
+            }
+            super.visitSelect(tree);
+        }
+
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            TranslationContext<?> context = context();
+            LambdaTranslationContext ltc = (context != null && context instanceof LambdaTranslationContext)?
+                    (LambdaTranslationContext)context :
+                    null;
+            if (ltc != null) {
+                if (frameStack.head.tree.hasTag(LAMBDA)) {
+                    ltc.addSymbol(tree.sym, LOCAL_VAR);
+                }
+                // Check for type variables (including as type arguments).
+                // If they occur within class nested in a lambda, mark for erasure
+                Type type = tree.sym.asType();
+                if (inClassWithinLambda() && !types.isSameType(types.erasure(type), type)) {
+                    ltc.addSymbol(tree.sym, TYPE_VAR);
+                }
+            }
+
+            List<Frame> prevStack = frameStack;
+            try {
+                if (tree.sym.owner.kind == MTH) {
+                    frameStack.head.addLocal(tree.sym);
+                }
+                frameStack = frameStack.prepend(new Frame(tree));
+                super.visitVarDef(tree);
+            }
+            finally {
+                frameStack = prevStack;
+            }
+        }
+
+        private Name lambdaName() {
+            return names.lambda.append(names.fromString("" + lambdaCount++));
+        }
+
+        /**
+         * For a serializable lambda, generate a name which maximizes name
+         * stability across deserialization.
+         * @param owner
+         * @return Name to use for the synthetic lambda method name
+         */
+        private Name serializedLambdaName(Symbol owner) {
+            StringBuilder buf = new StringBuilder();
+            buf.append(names.lambda);
+            // Append the name of the method enclosing the lambda.
+            String methodName = owner.name.toString();
+            if (methodName.equals("<clinit>"))
+                methodName = "static";
+            else if (methodName.equals("<init>"))
+                methodName = "new";
+            buf.append(methodName);
+            buf.append('$');
+            // Append a hash of the enclosing method signature to differentiate
+            // overloaded enclosing methods.  For lambdas enclosed in lambdas,
+            // the generated lambda method will not have type yet, but the
+            // enclosing method's name will have been generated with this same
+            // method, so it will be unique and never be overloaded.
+            Assert.check(owner.type != null || directlyEnclosingLambda() != null);
+            if (owner.type != null) {
+                int methTypeHash = methodSig(owner.type).hashCode();
+                buf.append(Integer.toHexString(methTypeHash));
+            }
+            buf.append('$');
+            // The above appended name components may not be unique, append a
+            // count based on the above name components.
+            String temp = buf.toString();
+            Integer count = serializableLambdaCounts.get(temp);
+            if (count == null) {
+                count = 0;
+            }
+            buf.append(count++);
+            serializableLambdaCounts.put(temp, count);
+            return names.fromString(buf.toString());
+        }
+
+        /**
+         * Return a valid owner given the current declaration stack
+         * (required to skip synthetic lambda symbols)
+         */
+        private Symbol owner() {
+            return owner(false);
+        }
+
+        @SuppressWarnings("fallthrough")
+        private Symbol owner(boolean skipLambda) {
+            List<Frame> frameStack2 = frameStack;
+            while (frameStack2.nonEmpty()) {
+                switch (frameStack2.head.tree.getTag()) {
+                    case VARDEF:
+                        if (((JCVariableDecl)frameStack2.head.tree).sym.isLocal()) {
+                            frameStack2 = frameStack2.tail;
+                            break;
+                        }
+                        JCClassDecl cdecl = (JCClassDecl)frameStack2.tail.head.tree;
+                        return initSym(cdecl.sym,
+                                ((JCVariableDecl)frameStack2.head.tree).sym.flags() & STATIC);
+                    case BLOCK:
+                        JCClassDecl cdecl2 = (JCClassDecl)frameStack2.tail.head.tree;
+                        return initSym(cdecl2.sym,
+                                ((JCBlock)frameStack2.head.tree).flags & STATIC);
+                    case CLASSDEF:
+                        return ((JCClassDecl)frameStack2.head.tree).sym;
+                    case METHODDEF:
+                        return ((JCMethodDecl)frameStack2.head.tree).sym;
+                    case LAMBDA:
+                        if (!skipLambda)
+                            return ((LambdaTranslationContext)contextMap
+                                    .get(frameStack2.head.tree)).translatedSym;
+                    default:
+                        frameStack2 = frameStack2.tail;
+                }
+            }
+            Assert.error();
+            return null;
+        }
+
+        private Symbol initSym(ClassSymbol csym, long flags) {
+            boolean isStatic = (flags & STATIC) != 0;
+            if (isStatic) {
+                //static clinits are generated in Gen - so we need to fake them
+                Symbol clinit = clinits.get(csym);
+                if (clinit == null) {
+                    clinit = makeSyntheticMethod(STATIC,
+                            names.clinit,
+                            new MethodType(List.<Type>nil(), syms.voidType, List.<Type>nil(), syms.methodClass),
+                            csym);
+                    clinits.put(csym, clinit);
+                }
+                return clinit;
+            } else {
+                //get the first constructor and treat it as the instance init sym
+                for (Symbol s : csym.members_field.getElementsByName(names.init)) {
+                    return s;
+                }
+            }
+            Assert.error("init not found");
+            return null;
+        }
+
+        private JCTree directlyEnclosingLambda() {
+            if (frameStack.isEmpty()) {
+                return null;
+            }
+            List<Frame> frameStack2 = frameStack;
+            while (frameStack2.nonEmpty()) {
+                switch (frameStack2.head.tree.getTag()) {
+                    case CLASSDEF:
+                    case METHODDEF:
+                        return null;
+                    case LAMBDA:
+                        return frameStack2.head.tree;
+                    default:
+                        frameStack2 = frameStack2.tail;
+                }
+            }
+            Assert.error();
+            return null;
+        }
+
+        private boolean inClassWithinLambda() {
+            if (frameStack.isEmpty()) {
+                return false;
+            }
+            List<Frame> frameStack2 = frameStack;
+            boolean classFound = false;
+            while (frameStack2.nonEmpty()) {
+                switch (frameStack2.head.tree.getTag()) {
+                    case LAMBDA:
+                        return classFound;
+                    case CLASSDEF:
+                        classFound = true;
+                        frameStack2 = frameStack2.tail;
+                        break;
+                    default:
+                        frameStack2 = frameStack2.tail;
+                }
+            }
+            // No lambda
+            return false;
+        }
+
+        /**
+         * Return the declaration corresponding to a symbol in the enclosing
+         * scope; the depth parameter is used to filter out symbols defined
+         * in nested scopes (which do not need to undergo capture).
+         */
+        private JCTree capturedDecl(int depth, Symbol sym) {
+            int currentDepth = frameStack.size() - 1;
+            for (Frame block : frameStack) {
+                switch (block.tree.getTag()) {
+                    case CLASSDEF:
+                        ClassSymbol clazz = ((JCClassDecl)block.tree).sym;
+                        if (sym.isMemberOf(clazz, types)) {
+                            return currentDepth > depth ? null : block.tree;
+                        }
+                        break;
+                    case VARDEF:
+                        if (((JCVariableDecl)block.tree).sym == sym &&
+                                sym.owner.kind == MTH) { //only locals are captured
+                            return currentDepth > depth ? null : block.tree;
+                        }
+                        break;
+                    case BLOCK:
+                    case METHODDEF:
+                    case LAMBDA:
+                        if (block.locals != null && block.locals.contains(sym)) {
+                            return currentDepth > depth ? null : block.tree;
+                        }
+                        break;
+                    default:
+                        Assert.error("bad decl kind " + block.tree.getTag());
+                }
+                currentDepth--;
+            }
+            return null;
+        }
+
+        private TranslationContext<?> context() {
+            for (Frame frame : frameStack) {
+                TranslationContext<?> context = contextMap.get(frame.tree);
+                if (context != null) {
+                    return context;
+                }
+            }
+            return null;
+        }
+
+        /**
+         *  This is used to filter out those identifiers that needs to be adjusted
+         *  when translating away lambda expressions
+         */
+        private boolean lambdaIdentSymbolFilter(Symbol sym) {
+            return (sym.kind == VAR || sym.kind == MTH)
+                    && !sym.isStatic()
+                    && sym.name != names.init;
+        }
+
+        /**
+         * This is used to filter out those new class expressions that need to
+         * be qualified with an enclosing tree
+         */
+        private boolean lambdaNewClassFilter(TranslationContext<?> context, JCNewClass tree) {
+            if (context != null
+                    && tree.encl == null
+                    && tree.def == null
+                    && !tree.type.getEnclosingType().hasTag(NONE)) {
+                Type encl = tree.type.getEnclosingType();
+                Type current = context.owner.enclClass().type;
+                while (!current.hasTag(NONE)) {
+                    if (current.tsym.isSubClass(encl.tsym, types)) {
+                        return true;
+                    }
+                    current = current.getEnclosingType();
+                }
+                return false;
+            } else {
+                return false;
+            }
+        }
+
+        private TranslationContext<JCLambda> makeLambdaContext(JCLambda tree) {
+            return new LambdaTranslationContext(tree);
+        }
+
+        private TranslationContext<JCMemberReference> makeReferenceContext(JCMemberReference tree) {
+            return new ReferenceTranslationContext(tree);
+        }
+
+        private class Frame {
+            final JCTree tree;
+            List<Symbol> locals;
+
+            public Frame(JCTree tree) {
+                this.tree = tree;
+            }
+
+            void addLocal(Symbol sym) {
+                if (locals == null) {
+                    locals = List.nil();
+                }
+                locals = locals.prepend(sym);
+            }
+        }
+
+        /**
+         * This class is used to store important information regarding translation of
+         * lambda expression/method references (see subclasses).
+         */
+        private abstract class TranslationContext<T extends JCFunctionalExpression> {
+
+            /** the underlying (untranslated) tree */
+            T tree;
+
+            /** points to the adjusted enclosing scope in which this lambda/mref expression occurs */
+            Symbol owner;
+
+            /** the depth of this lambda expression in the frame stack */
+            int depth;
+
+            /** the enclosing translation context (set for nested lambdas/mref) */
+            TranslationContext<?> prev;
+
+            /** list of methods to be bridged by the meta-factory */
+            List<Symbol> bridges;
+
+            TranslationContext(T tree) {
+                this.tree = tree;
+                this.owner = owner();
+                this.depth = frameStack.size() - 1;
+                this.prev = context();
+                ClassSymbol csym =
+                        types.makeFunctionalInterfaceClass(attrEnv, names.empty, tree.targets, ABSTRACT | INTERFACE);
+                this.bridges = types.functionalInterfaceBridges(csym);
+            }
+
+            /** does this functional expression need to be created using alternate metafactory? */
+            boolean needsAltMetafactory() {
+                return tree.targets.length() > 1 ||
+                        isSerializable() ||
+                        bridges.length() > 1;
+            }
+
+            /** does this functional expression require serialization support? */
+            boolean isSerializable() {
+                for (Type target : tree.targets) {
+                    if (types.asSuper(target, syms.serializableType.tsym) != null) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+        }
+
+        /**
+         * This class retains all the useful information about a lambda expression;
+         * the contents of this class are filled by the LambdaAnalyzer visitor,
+         * and the used by the main translation routines in order to adjust references
+         * to captured locals/members, etc.
+         */
+        private class LambdaTranslationContext extends TranslationContext<JCLambda> {
+
+            /** variable in the enclosing context to which this lambda is assigned */
+            Symbol self;
+
+            /** map from original to translated lambda parameters */
+            Map<Symbol, Symbol> lambdaParams = new LinkedHashMap<Symbol, Symbol>();
+
+            /** map from original to translated lambda locals */
+            Map<Symbol, Symbol> lambdaLocals = new LinkedHashMap<Symbol, Symbol>();
+
+            /** map from variables in enclosing scope to translated synthetic parameters */
+            Map<Symbol, Symbol> capturedLocals  = new LinkedHashMap<Symbol, Symbol>();
+
+            /** map from class symbols to translated synthetic parameters (for captured member access) */
+            Map<Symbol, Symbol> capturedThis = new LinkedHashMap<Symbol, Symbol>();
+
+            /** map from original to translated lambda locals */
+            Map<Symbol, Symbol> typeVars = new LinkedHashMap<Symbol, Symbol>();
+
+            /** the synthetic symbol for the method hoisting the translated lambda */
+            Symbol translatedSym;
+
+            List<JCVariableDecl> syntheticParams;
+
+            LambdaTranslationContext(JCLambda tree) {
+                super(tree);
+                Frame frame = frameStack.head;
+                if (frame.tree.hasTag(VARDEF)) {
+                    self = ((JCVariableDecl)frame.tree).sym;
+                }
+                Name name = isSerializable() ? serializedLambdaName(owner) : lambdaName();
+                this.translatedSym = makeSyntheticMethod(0, name, null, owner.enclClass());
+                if (dumpLambdaToMethodStats) {
+                    log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym);
+                }
+            }
+
+            /**
+             * Translate a symbol of a given kind into something suitable for the
+             * synthetic lambda body
+             */
+            Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) {
+                Symbol ret;
+                switch (skind) {
+                    case CAPTURED_THIS:
+                        ret = sym;  // self represented
+                        break;
+                    case TYPE_VAR:
+                        // Just erase the type var
+                        ret = new VarSymbol(sym.flags(), name,
+                                types.erasure(sym.type), sym.owner);
+                        break;
+                    case CAPTURED_VAR:
+                        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:
+                        ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
+                }
+                if (ret != sym) {
+                    ret.setDeclarationAttributes(sym.getRawAttributes());
+                    ret.setTypeAttributes(sym.getRawTypeAttributes());
+                }
+                return ret;
+            }
+
+            void addSymbol(Symbol sym, LambdaSymbolKind skind) {
+                Map<Symbol, Symbol> transMap = null;
+                Name preferredName;
+                switch (skind) {
+                    case CAPTURED_THIS:
+                        transMap = capturedThis;
+                        preferredName = names.fromString("encl$" + capturedThis.size());
+                        break;
+                    case CAPTURED_VAR:
+                        transMap = capturedLocals;
+                        preferredName = names.fromString("cap$" + capturedLocals.size());
+                        break;
+                    case LOCAL_VAR:
+                        transMap = lambdaLocals;
+                        preferredName = sym.name;
+                        break;
+                    case PARAM:
+                        transMap = lambdaParams;
+                        preferredName = sym.name;
+                        break;
+                    case TYPE_VAR:
+                        transMap = typeVars;
+                        preferredName = sym.name;
+                        break;
+                    default: throw new AssertionError();
+                }
+                if (!transMap.containsKey(sym)) {
+                    transMap.put(sym, translate(preferredName, sym, skind));
+                }
+            }
+
+            Map<Symbol, Symbol> getSymbolMap(LambdaSymbolKind... skinds) {
+                LinkedHashMap<Symbol, Symbol> translationMap = new LinkedHashMap<Symbol, Symbol>();
+                for (LambdaSymbolKind skind : skinds) {
+                    switch (skind) {
+                        case CAPTURED_THIS:
+                            translationMap.putAll(capturedThis);
+                            break;
+                        case CAPTURED_VAR:
+                            translationMap.putAll(capturedLocals);
+                            break;
+                        case LOCAL_VAR:
+                            translationMap.putAll(lambdaLocals);
+                            break;
+                        case PARAM:
+                            translationMap.putAll(lambdaParams);
+                            break;
+                        case TYPE_VAR:
+                            translationMap.putAll(typeVars);
+                            break;
+                        default: throw new AssertionError();
+                    }
+                }
+                return translationMap;
+            }
+
+            /**
+             * The translatedSym is not complete/accurate until the analysis is
+             * finished.  Once the analysis is finished, the translatedSym is
+             * "completed" -- updated with type information, access modifiers,
+             * and full parameter list.
+             */
+            void complete() {
+                if (syntheticParams != null) {
+                    return;
+                }
+                boolean inInterface = translatedSym.owner.isInterface();
+                boolean thisReferenced = !getSymbolMap(CAPTURED_THIS).isEmpty();
+
+                // 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();
+
+                // The signature of the method is augmented with the following
+                // synthetic parameters:
+                //
+                // 1) reference to enclosing contexts captured by the lambda expression
+                // 2) enclosing locals captured by the lambda expression
+                for (Symbol thisSym : getSymbolMap(CAPTURED_VAR, PARAM).values()) {
+                    params.append(make.VarDef((VarSymbol) thisSym, null));
+                }
+
+                syntheticParams = params.toList();
+
+                //prepend synthetic args to translated lambda method signature
+                translatedSym.type = types.createMethodTypeWithParameters(
+                        generatedLambdaSig(),
+                        TreeInfo.types(syntheticParams));
+            }
+
+            Type generatedLambdaSig() {
+                return types.erasure(tree.getDescriptorType(types));
+            }
+        }
+
+        /**
+         * This class retains all the useful information about a method reference;
+         * the contents of this class are filled by the LambdaAnalyzer visitor,
+         * and the used by the main translation routines in order to adjust method
+         * references (i.e. in case a bridge is needed)
+         */
+        private class ReferenceTranslationContext extends TranslationContext<JCMemberReference> {
+
+            final boolean isSuper;
+            final Symbol bridgeSym;
+
+            ReferenceTranslationContext(JCMemberReference tree) {
+                super(tree);
+                this.isSuper = tree.hasKind(ReferenceKind.SUPER);
+                this.bridgeSym = needsBridge()
+                        ? makeSyntheticMethod(isSuper ? 0 : STATIC,
+                                              lambdaName().append(names.fromString("$bridge")), null,
+                                              owner.enclClass())
+                        : null;
+                if (dumpLambdaToMethodStats) {
+                    String key = bridgeSym == null ?
+                            "mref.stat" : "mref.stat.1";
+                    log.note(tree, key, needsAltMetafactory(), bridgeSym);
+                }
+            }
+
+            /**
+             * Get the opcode associated with this method reference
+             */
+            int referenceKind() {
+                return LambdaToMethod.this.referenceKind(needsBridge() ? bridgeSym : tree.sym);
+            }
+
+            boolean needsVarArgsConversion() {
+                return tree.varargsElement != null;
+            }
+
+            /**
+             * @return Is this an array operation like clone()
+             */
+            boolean isArrayOp() {
+                return tree.sym.owner == syms.arrayClass;
+            }
+
+            boolean isPrivateConstructor() {
+                //hack needed to workaround 292 bug (8005122)
+                //when 292 issue is fixed we should simply remove this
+                return tree.sym.name == names.init &&
+                        (tree.sym.flags() & PRIVATE) != 0;
+            }
+
+            boolean receiverAccessible() {
+                //hack needed to workaround 292 bug (7087658)
+                //when 292 issue is fixed we should remove this and change the backend
+                //code to always generate a method handle to an accessible method
+                return tree.ownerAccessible;
+            }
+
+            /**
+             * Does this reference needs a bridge (i.e. var args need to be
+             * expanded or "super" is used)
+             */
+            final boolean needsBridge() {
+                return isSuper || needsVarArgsConversion() || isArrayOp() ||
+                        isPrivateConstructor() || !receiverAccessible();
+            }
+
+            Type generatedRefSig() {
+                return types.erasure(tree.sym.type);
+            }
+
+            Type bridgedRefSig() {
+                return types.erasure(types.findDescriptorSymbol(tree.targets.head.tsym).type);
+            }
+        }
+    }
+    // </editor-fold>
+
+    enum LambdaSymbolKind {
+        CAPTURED_VAR,
+        CAPTURED_THIS,
+        LOCAL_VAR,
+        PARAM,
+        TYPE_VAR;
+    }
+
+    /**
+     * ****************************************************************
+     * Signature Generation
+     * ****************************************************************
+     */
+
+    private String methodSig(Type type) {
+        L2MSignatureGenerator sg = new L2MSignatureGenerator();
+        sg.assembleSig(type);
+        return sg.toString();
+    }
+
+    private String classSig(Type type) {
+        L2MSignatureGenerator sg = new L2MSignatureGenerator();
+        sg.assembleClassSig(type);
+        return sg.toString();
+    }
+
+    /**
+     * Signature Generation
+     */
+    private class L2MSignatureGenerator extends Types.SignatureGenerator {
+
+        /**
+         * An output buffer for type signatures.
+         */
+        StringBuilder sb = new StringBuilder();
+
+        L2MSignatureGenerator() {
+            super(types);
+        }
+
+        @Override
+        protected void append(char ch) {
+            sb.append(ch);
+        }
+
+        @Override
+        protected void append(byte[] ba) {
+            sb.append(new String(ba));
+        }
+
+        @Override
+        protected void append(Name name) {
+            sb.append(name.toString());
+        }
+
+        @Override
+        public String toString() {
+            return sb.toString();
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/comp/Lower.java b/src/share/classes/com/sun/tools/javac/comp/Lower.java
index 3953399..ea23cce 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -28,8 +28,9 @@ package com.sun.tools.javac.comp;
 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.RecognizedOptions.PkgInfo;
+import com.sun.tools.javac.main.Option.PkgInfo;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -40,11 +41,15 @@ import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.code.Type.*;
 
 import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.tree.EndPosTable;
 
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.BLOCK;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import javax.lang.model.type.TypeKind;
 
 /** This pass translates away some syntactic sugar: inner classes,
  *  class literals, assertions, foreach loops, etc.
@@ -125,7 +130,7 @@ public class Lower extends TreeTranslator {
 
     /** A hash table mapping syntax trees to their ending source positions.
      */
-    Map<JCTree, Integer> endPositions;
+    EndPosTable endPosTable;
 
 /**************************************************************************
  * Global mappings
@@ -135,6 +140,10 @@ public class Lower extends TreeTranslator {
      */
     Map<ClassSymbol, JCClassDecl> classdefs;
 
+    /** A hash table mapping local classes to a list of pruned trees.
+     */
+    public Map<ClassSymbol, List<JCTree>> prunedTree = new WeakHashMap<ClassSymbol, List<JCTree>>();
+
     /** A hash table mapping virtual accessed symbols in outer subclasses
      *  to the actually referred symbol in superclasses.
      */
@@ -156,6 +165,12 @@ public class Lower extends TreeTranslator {
      */
     JCTree outermostMemberDef;
 
+    /** A map from local variable symbols to their translation (as per LambdaToMethod).
+     * This is required when a capturing local class is created from a lambda (in which
+     * case the captured symbols should be replaced with the translated lambda symbols).
+     */
+    Map<Symbol, Symbol> lambdaTranslationMap = null;
+
     /** A navigator class for assembling a mapping from local class symbols
      *  to class definition trees.
      *  There is only one case; all other cases simply traverse down the tree.
@@ -199,10 +214,51 @@ public class Lower extends TreeTranslator {
     Map<ClassSymbol,List<VarSymbol>> freevarCache;
 
     /** A navigator class for collecting the free variables accessed
-     *  from a local class.
-     *  There is only one case; all other cases simply traverse down the tree.
+     *  from a local class. There is only one case; all other cases simply
+     *  traverse down the tree. This class doesn't deal with the specific
+     *  of Lower - it's an abstract visitor that is meant to be reused in
+     *  order to share the local variable capture logic.
+     */
+    abstract class BasicFreeVarCollector extends TreeScanner {
+
+        /** Add all free variables of class c to fvs list
+         *  unless they are already there.
+         */
+        abstract void addFreeVars(ClassSymbol c);
+
+        /** If tree refers to a variable in owner of local class, add it to
+         *  free variables list.
+         */
+        public void visitIdent(JCIdent tree) {
+            visitSymbol(tree.sym);
+        }
+        // where
+        abstract void visitSymbol(Symbol _sym);
+
+        /** If tree refers to a class instance creation expression
+         *  add all free variables of the freshly created class.
+         */
+        public void visitNewClass(JCNewClass tree) {
+            ClassSymbol c = (ClassSymbol)tree.constructor.owner;
+            addFreeVars(c);
+            super.visitNewClass(tree);
+        }
+
+        /** If tree refers to a superclass constructor call,
+         *  add all free variables of the superclass.
+         */
+        public void visitApply(JCMethodInvocation tree) {
+            if (TreeInfo.name(tree.meth) == names._super) {
+                addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner);
+            }
+            super.visitApply(tree);
+        }
+    }
+
+    /**
+     * Lower-specific subclass of {@code BasicFreeVarCollector}.
      */
-    class FreeVarCollector extends TreeScanner {
+    class FreeVarCollector extends BasicFreeVarCollector {
 
         /** The owner of the local class.
          */
@@ -231,10 +287,8 @@ public class Lower extends TreeTranslator {
             fvs = fvs.prepend(v);
         }
 
-        /** Add all free variables of class c to fvs list
-         *  unless they are already there.
-         */
-        private void addFreeVars(ClassSymbol c) {
+        @Override
+        void addFreeVars(ClassSymbol c) {
             List<VarSymbol> fvs = freevarCache.get(c);
             if (fvs != null) {
                 for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
@@ -243,15 +297,8 @@ public class Lower extends TreeTranslator {
             }
         }
 
-        /** If tree refers to a variable in owner of local class, add it to
-         *  free variables list.
-         */
-        public void visitIdent(JCIdent tree) {
-            result = tree;
-            visitSymbol(tree.sym);
-        }
-        // where
-        private void visitSymbol(Symbol _sym) {
+        @Override
+        void visitSymbol(Symbol _sym) {
             Symbol sym = _sym;
             if (sym.kind == VAR || sym.kind == MTH) {
                 while (sym != null && sym.owner != owner)
@@ -274,7 +321,6 @@ public class Lower extends TreeTranslator {
          */
         public void visitNewClass(JCNewClass tree) {
             ClassSymbol c = (ClassSymbol)tree.constructor.owner;
-            addFreeVars(c);
             if (tree.encl == null &&
                 c.hasOuterInstance() &&
                 outerThisStack.head != null)
@@ -299,13 +345,14 @@ public class Lower extends TreeTranslator {
          */
         public void visitApply(JCMethodInvocation tree) {
             if (TreeInfo.name(tree.meth) == names._super) {
-                addFreeVars((ClassSymbol) TreeInfo.symbol(tree.meth).owner);
                 Symbol constructor = TreeInfo.symbol(tree.meth);
-                ClassSymbol c = (ClassSymbol)constructor.owner;
-                if (c.hasOuterInstance() &&
-                    tree.meth.getTag() != JCTree.SELECT &&
-                    outerThisStack.head != null)
-                    visitSymbol(outerThisStack.head);
+                if (constructor.owner.kind == TYP) {
+                    ClassSymbol c = (ClassSymbol)constructor.owner;
+                    if (c.hasOuterInstance() &&
+                        !tree.meth.hasTag(SELECT) &&
+                        outerThisStack.head != null)
+                        visitSymbol(outerThisStack.head);
+                }
             }
             super.visitApply(tree);
         }
@@ -482,7 +529,7 @@ public class Lower extends TreeTranslator {
      *  @param value      The literal's value.
      */
     JCExpression makeLit(Type type, Object value) {
-        return make.Literal(type.tag, value).setType(type.constType(value));
+        return make.Literal(type.getTag(), value).setType(type.constType(value));
     }
 
     /** Make an attributed tree representing null.
@@ -499,7 +546,7 @@ public class Lower extends TreeTranslator {
         JCNewClass tree = make.NewClass(null,
             null, make.QualIdent(ctype.tsym), args, null);
         tree.constructor = rs.resolveConstructor(
-            make_pos, attrEnv, ctype, TreeInfo.types(args), null, false, false);
+            make_pos, attrEnv, ctype, TreeInfo.types(args), List.<Type>nil());
         tree.type = ctype;
         return tree;
     }
@@ -508,7 +555,7 @@ public class Lower extends TreeTranslator {
      *  @param optag    The operators tree tag.
      *  @param arg      The operator's argument.
      */
-    JCUnary makeUnary(int optag, JCExpression arg) {
+    JCUnary makeUnary(JCTree.Tag optag, JCExpression arg) {
         JCUnary tree = make.Unary(optag, arg);
         tree.operator = rs.resolveUnaryOperator(
             make_pos, optag, attrEnv, arg.type);
@@ -521,7 +568,7 @@ public class Lower extends TreeTranslator {
      *  @param lhs      The operator's left argument.
      *  @param rhs      The operator's right argument.
      */
-    JCBinary makeBinary(int optag, JCExpression lhs, JCExpression rhs) {
+    JCBinary makeBinary(JCTree.Tag optag, JCExpression lhs, JCExpression rhs) {
         JCBinary tree = make.Binary(optag, lhs, rhs);
         tree.operator = rs.resolveBinaryOperator(
             make_pos, optag, attrEnv, lhs.type, rhs.type);
@@ -534,10 +581,10 @@ public class Lower extends TreeTranslator {
      *  @param lhs      The operator's left argument.
      *  @param rhs      The operator's right argument.
      */
-    JCAssignOp makeAssignop(int optag, JCTree lhs, JCTree rhs) {
+    JCAssignOp makeAssignop(JCTree.Tag optag, JCTree lhs, JCTree rhs) {
         JCAssignOp tree = make.Assignop(optag, lhs, rhs);
         tree.operator = rs.resolveBinaryOperator(
-            make_pos, tree.getTag() - JCTree.ASGOffset, attrEnv, lhs.type, rhs.type);
+            make_pos, tree.getTag().noAssignOp(), attrEnv, lhs.type, rhs.type);
         tree.type = lhs.type;
         return tree;
     }
@@ -546,7 +593,7 @@ public class Lower extends TreeTranslator {
      *  reference type..
      */
     JCExpression makeString(JCExpression tree) {
-        if (tree.type.tag >= CLASS) {
+        if (!tree.type.isPrimitiveOrVoid()) {
             return tree;
         } else {
             Symbol valueOfSym = lookupMethod(tree.pos(),
@@ -563,10 +610,19 @@ public class Lower extends TreeTranslator {
      *  @param flags    The class symbol's flags
      *  @param owner    The class symbol's owner
      */
-    private ClassSymbol makeEmptyClass(long flags, ClassSymbol owner) {
+    JCClassDecl makeEmptyClass(long flags, ClassSymbol owner) {
+        return makeEmptyClass(flags, owner, null, true);
+    }
+
+    JCClassDecl makeEmptyClass(long flags, ClassSymbol owner, Name flatname,
+            boolean addToDefs) {
         // Create class symbol.
         ClassSymbol c = reader.defineClass(names.empty, owner);
-        c.flatname = chk.localClassName(c);
+        if (flatname != null) {
+            c.flatname = flatname;
+        } else {
+            c.flatname = chk.localClassName(c);
+        }
         c.sourcefile = owner.sourcefile;
         c.completer = null;
         c.members_field = new Scope(c);
@@ -591,10 +647,9 @@ public class Lower extends TreeTranslator {
         cdef.type = c.type;
 
         // Append class definition tree to owner's definitions.
-        if (odef != null)
+        if (addToDefs && odef != null)
             odef.defs = odef.defs.prepend(cdef);
-
-        return c;
+        return cdef;
     }
 
 /**************************************************************************
@@ -670,7 +725,7 @@ public class Lower extends TreeTranslator {
     };
 
     /** Look up a synthetic name in a given scope.
-     *  @param scope        The scope.
+     *  @param s            The scope.
      *  @param name         The name.
      */
     private Symbol lookupSynthetic(Name name, Scope s) {
@@ -681,7 +736,7 @@ public class Lower extends TreeTranslator {
     /** Look up a method in a given scope.
      */
     private MethodSymbol lookupMethod(DiagnosticPosition pos, Name name, Type qual, List<Type> args) {
-        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, null);
+        return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, List.<Type>nil());
     }
 
     /** Look up a constructor.
@@ -701,7 +756,7 @@ public class Lower extends TreeTranslator {
      * and synthethise a class (with makeEmptyClass) if one is not available.
      * However, there is a small possibility that an existing class will not
      * be generated as expected if it is inside a conditional with a constant
-     * expression. If that is found to be the case, create an empty class here.
+     * expression. If that is found to be the case, create an empty class tree here.
      */
     private void checkAccessConstructorTags() {
         for (List<ClassSymbol> l = accessConstrTags; l.nonEmpty(); l = l.tail) {
@@ -718,7 +773,7 @@ public class Lower extends TreeTranslator {
     // where
     private boolean isTranslatedClassAvailable(ClassSymbol c) {
         for (JCTree tree: translated) {
-            if (tree.getTag() == JCTree.CLASSDEF
+            if (tree.hasTag(CLASSDEF)
                     && ((JCClassDecl) tree).sym == c) {
                 return true;
             }
@@ -742,7 +797,7 @@ public class Lower extends TreeTranslator {
      *  This numbering scheme is used by the backend to decide whether
      *  to issue an invokevirtual or invokespecial call.
      *
-     *  @see Gen.visitSelect(Select tree)
+     *  @see Gen#visitSelect(JCFieldAccess tree)
      */
     private static final int
         DEREFcode = 0,
@@ -800,13 +855,13 @@ public class Lower extends TreeTranslator {
     private static int accessCode(JCTree tree, JCTree enclOp) {
         if (enclOp == null)
             return DEREFcode;
-        else if (enclOp.getTag() == JCTree.ASSIGN &&
+        else if (enclOp.hasTag(ASSIGN) &&
                  tree == TreeInfo.skipParens(((JCAssign) enclOp).lhs))
             return ASSIGNcode;
-        else if (JCTree.PREINC <= enclOp.getTag() && enclOp.getTag() <= JCTree.POSTDEC &&
+        else if (enclOp.getTag().isIncOrDecUnaryOp() &&
                  tree == TreeInfo.skipParens(((JCUnary) enclOp).arg))
-            return (enclOp.getTag() - JCTree.PREINC) * 2 + PREINCcode;
-        else if (JCTree.BITOR_ASG <= enclOp.getTag() && enclOp.getTag() <= JCTree.MOD_ASG &&
+            return mapTagToUnaryOpCode(enclOp.getTag());
+        else if (enclOp.getTag().isAssignop() &&
                  tree == TreeInfo.skipParens(((JCAssignOp) enclOp).lhs))
             return accessCode(((OperatorSymbol) ((JCAssignOp) enclOp).operator).opcode);
         else
@@ -830,39 +885,39 @@ public class Lower extends TreeTranslator {
     /** Return tree tag for assignment operation corresponding
      *  to given binary operator.
      */
-    private static int treeTag(OperatorSymbol operator) {
+    private static JCTree.Tag treeTag(OperatorSymbol operator) {
         switch (operator.opcode) {
         case ByteCodes.ior: case ByteCodes.lor:
-            return JCTree.BITOR_ASG;
+            return BITOR_ASG;
         case ByteCodes.ixor: case ByteCodes.lxor:
-            return JCTree.BITXOR_ASG;
+            return BITXOR_ASG;
         case ByteCodes.iand: case ByteCodes.land:
-            return JCTree.BITAND_ASG;
+            return BITAND_ASG;
         case ByteCodes.ishl: case ByteCodes.lshl:
         case ByteCodes.ishll: case ByteCodes.lshll:
-            return JCTree.SL_ASG;
+            return SL_ASG;
         case ByteCodes.ishr: case ByteCodes.lshr:
         case ByteCodes.ishrl: case ByteCodes.lshrl:
-            return JCTree.SR_ASG;
+            return SR_ASG;
         case ByteCodes.iushr: case ByteCodes.lushr:
         case ByteCodes.iushrl: case ByteCodes.lushrl:
-            return JCTree.USR_ASG;
+            return USR_ASG;
         case ByteCodes.iadd: case ByteCodes.ladd:
         case ByteCodes.fadd: case ByteCodes.dadd:
         case ByteCodes.string_add:
-            return JCTree.PLUS_ASG;
+            return PLUS_ASG;
         case ByteCodes.isub: case ByteCodes.lsub:
         case ByteCodes.fsub: case ByteCodes.dsub:
-            return JCTree.MINUS_ASG;
+            return MINUS_ASG;
         case ByteCodes.imul: case ByteCodes.lmul:
         case ByteCodes.fmul: case ByteCodes.dmul:
-            return JCTree.MUL_ASG;
+            return MUL_ASG;
         case ByteCodes.idiv: case ByteCodes.ldiv:
         case ByteCodes.fdiv: case ByteCodes.ddiv:
-            return JCTree.DIV_ASG;
+            return DIV_ASG;
         case ByteCodes.imod: case ByteCodes.lmod:
         case ByteCodes.fmod: case ByteCodes.dmod:
-            return JCTree.MOD_ASG;
+            return MOD_ASG;
         default:
             throw new AssertionError();
         }
@@ -1001,7 +1056,7 @@ public class Lower extends TreeTranslator {
         if (!currentClass.isSubClass(sym.owner, types))
             return true;
         if ((sym.flags() & STATIC) != 0 ||
-            tree.getTag() != JCTree.SELECT ||
+            !tree.hasTag(SELECT) ||
             TreeInfo.name(((JCFieldAccess) tree).selected) == names._super)
             return false;
         return !((JCFieldAccess) tree).selected.type.tsym.isSubClass(currentClass, types);
@@ -1016,7 +1071,7 @@ public class Lower extends TreeTranslator {
         if (protAccess) {
             Symbol qualifier = null;
             ClassSymbol c = currentClass;
-            if (tree.getTag() == JCTree.SELECT && (sym.flags() & STATIC) == 0) {
+            if (tree.hasTag(SELECT) && (sym.flags() & STATIC) == 0) {
                 qualifier = ((JCFieldAccess) tree).selected.type.tsym;
                 while (!qualifier.isSubClass(c, types)) {
                     c = c.owner.enclClass();
@@ -1034,6 +1089,12 @@ public class Lower extends TreeTranslator {
         }
     }
 
+    private void addPrunedInfo(JCTree tree) {
+        List<JCTree> infoList = prunedTree.get(currentClass);
+        infoList = (infoList == null) ? List.of(tree) : infoList.prepend(tree);
+        prunedTree.put(currentClass, infoList);
+    }
+
     /** Ensure that identifier is accessible, return tree accessing the identifier.
      *  @param sym      The accessed symbol.
      *  @param tree     The tree referring to the symbol.
@@ -1056,7 +1117,7 @@ public class Lower extends TreeTranslator {
             Assert.check(sym != null && (sym.flags_field & FINAL) != 0);
             tree = make.at(tree.pos).Ident(sym);
         }
-        JCExpression base = (tree.getTag() == JCTree.SELECT) ? ((JCFieldAccess) tree).selected : null;
+        JCExpression base = (tree.hasTag(SELECT)) ? ((JCFieldAccess) tree).selected : null;
         switch (sym.kind) {
         case TYP:
             if (sym.owner.kind != PCK) {
@@ -1066,11 +1127,11 @@ public class Lower extends TreeTranslator {
                 while (base != null &&
                        TreeInfo.symbol(base) != null &&
                        TreeInfo.symbol(base).kind != PCK) {
-                    base = (base.getTag() == JCTree.SELECT)
+                    base = (base.hasTag(SELECT))
                         ? ((JCFieldAccess) base).selected
                         : null;
                 }
-                if (tree.getTag() == JCTree.IDENT) {
+                if (tree.hasTag(IDENT)) {
                     ((JCIdent) tree).name = flatname;
                 } else if (base == null) {
                     tree = make.at(tree.pos).Ident(sym);
@@ -1106,7 +1167,10 @@ public class Lower extends TreeTranslator {
                     // Constants are replaced by their constant value.
                     if (sym.kind == VAR) {
                         Object cv = ((VarSymbol)sym).getConstValue();
-                        if (cv != null) return makeLit(sym.type, cv);
+                        if (cv != null) {
+                            addPrunedInfo(tree);
+                            return makeLit(sym.type, cv);
+                        }
                     }
 
                     // Private variables and methods are replaced by calls
@@ -1136,6 +1200,14 @@ public class Lower extends TreeTranslator {
                             accessBase(tree.pos(), sym), sym).setType(tree.type);
                     }
                 }
+            } else if (sym.owner.kind == MTH && lambdaTranslationMap != null) {
+                //sym is a local variable - check the lambda translation map to
+                //see if sym has been translated to something else in the current
+                //scope (by LambdaToMethod)
+                Symbol translatedSym = lambdaTranslationMap.get(sym);
+                if (translatedSym != null) {
+                    tree = make.at(tree.pos).Ident(translatedSym);
+                }
             }
         }
         return tree;
@@ -1196,7 +1268,7 @@ public class Lower extends TreeTranslator {
             ctag = null;
         }
         if (ctag == null)
-            ctag = makeEmptyClass(STATIC | SYNTHETIC, topClass);
+            ctag = makeEmptyClass(STATIC | SYNTHETIC, topClass).sym;
         // keep a record of all tags, to verify that all are generated as required
         accessConstrTags = accessConstrTags.prepend(ctag);
         return ctag;
@@ -1208,7 +1280,6 @@ public class Lower extends TreeTranslator {
     void makeAccessible(Symbol sym) {
         JCClassDecl cdef = classDef(sym.owner.enclClass());
         if (cdef == null) Assert.error("class def not found: " + sym + " in " + sym.owner + "\nflags: " + sym.flags() +
-                (sym.kind == VAR ? "\norginal: " + ((VarSymbol)sym).originalVar : sym.kind == MTH ? "\noriginal: " + ((MethodSymbol)sym).originalMethod : "") +
                 "\noutermostMemberDef: " + outermostMemberDef + "\noutermostClassDef: " + outermostClassDef);
         if (sym.name == names.init) {
             cdef.defs = cdef.defs.prepend(
@@ -1223,6 +1294,42 @@ public class Lower extends TreeTranslator {
         }
     }
 
+    /** Maps unary operator integer codes to JCTree.Tag objects
+     *  @param unaryOpCode the unary operator code
+     */
+    private static Tag mapUnaryOpCodeToTag(int unaryOpCode){
+        switch (unaryOpCode){
+            case PREINCcode:
+                return PREINC;
+            case PREDECcode:
+                return PREDEC;
+            case POSTINCcode:
+                return POSTINC;
+            case POSTDECcode:
+                return POSTDEC;
+            default:
+                return NO_TAG;
+        }
+    }
+
+    /** Maps JCTree.Tag objects to unary operator integer codes
+     *  @param tag the JCTree.Tag
+     */
+    private static int mapTagToUnaryOpCode(Tag tag){
+        switch (tag){
+            case PREINC:
+                return PREINCcode;
+            case PREDEC:
+                return PREDECcode;
+            case POSTINC:
+                return POSTINCcode;
+            case POSTDEC:
+                return POSTDECcode;
+            default:
+                return -1;
+        }
+    }
+
     /** Construct definition of an access method.
      *  @param pos        The source code position of the definition.
      *  @param vsym       The private or protected symbol.
@@ -1262,8 +1369,7 @@ public class Lower extends TreeTranslator {
                 expr = make.Assign(ref, args.head);
                 break;
             case PREINCcode: case POSTINCcode: case PREDECcode: case POSTDECcode:
-                expr = makeUnary(
-                    ((acode1 - PREINCcode) >> 1) + JCTree.PREINC, ref);
+                expr = makeUnary(mapUnaryOpCodeToTag(acode1), ref);
                 break;
             default:
                 expr = make.Assignop(
@@ -1370,7 +1476,7 @@ public class Lower extends TreeTranslator {
     Name outerThisName(Type type, Symbol owner) {
         Type t = type.getEnclosingType();
         int nestingLevel = 0;
-        while (t.tag == CLASS) {
+        while (t.hasTag(CLASS)) {
             t = t.getEnclosingType();
             nestingLevel++;
         }
@@ -1380,24 +1486,51 @@ public class Lower extends TreeTranslator {
         return result;
     }
 
-    /** Definition for this$n field.
-     *  @param pos        The source code position of the definition.
-     *  @param owner      The class in which the definition goes.
-     */
-    JCVariableDecl outerThisDef(int pos, Symbol owner) {
-        long flags = FINAL | SYNTHETIC;
+    private VarSymbol makeOuterThisVarSymbol(Symbol owner, long flags) {
         if (owner.kind == TYP &&
             target.usePrivateSyntheticFields())
             flags |= PRIVATE;
         Type target = types.erasure(owner.enclClass().type.getEnclosingType());
-        VarSymbol outerThis = new VarSymbol(
-            flags, outerThisName(target, owner), target, owner);
+        VarSymbol outerThis =
+            new VarSymbol(flags, outerThisName(target, owner), target, owner);
         outerThisStack = outerThisStack.prepend(outerThis);
-        JCVariableDecl vd = make.at(pos).VarDef(outerThis, null);
+        return outerThis;
+    }
+
+    private JCVariableDecl makeOuterThisVarDecl(int pos, VarSymbol sym) {
+        JCVariableDecl vd = make.at(pos).VarDef(sym, null);
         vd.vartype = access(vd.vartype);
         return vd;
     }
 
+    /** Definition for this$n field.
+     *  @param pos        The source code position of the definition.
+     *  @param owner      The method in which the definition goes.
+     */
+    JCVariableDecl outerThisDef(int pos, MethodSymbol owner) {
+        ClassSymbol c = owner.enclClass();
+        boolean isMandated =
+            // Anonymous constructors
+            (owner.isConstructor() && owner.isAnonymous()) ||
+            // Constructors of non-private inner member classes
+            (owner.isConstructor() && c.isInner() &&
+             !c.isPrivate() && !c.isStatic());
+        long flags =
+            FINAL | (isMandated ? MANDATED : SYNTHETIC);
+        VarSymbol outerThis = makeOuterThisVarSymbol(owner, flags);
+        owner.extraParams = owner.extraParams.prepend(outerThis);
+        return makeOuterThisVarDecl(pos, outerThis);
+    }
+
+    /** Definition for this$n field.
+     *  @param pos        The source code position of the definition.
+     *  @param owner      The class in which the definition goes.
+     */
+    JCVariableDecl outerThisDef(int pos, ClassSymbol owner) {
+        VarSymbol outerThis = makeOuterThisVarSymbol(owner, FINAL | SYNTHETIC);
+        return makeOuterThisVarDecl(pos, outerThis);
+    }
+
     /** Return a list of trees that load the free variables in given list,
      *  in reverse order.
      *  @param pos          The source code position to be used for the trees.
@@ -1414,7 +1547,7 @@ public class Lower extends TreeTranslator {
             return access(v, make.at(pos).Ident(v), null, false);
         }
 
-    /** Construct a tree simulating the expression <C.this>.
+    /** Construct a tree simulating the expression {@code C.this}.
      *  @param pos           The source code position to be used for the tree.
      *  @param c             The qualifier class.
      */
@@ -1494,7 +1627,7 @@ public class Lower extends TreeTranslator {
             new VarSymbol(SYNTHETIC | FINAL,
                           makeSyntheticName(names.fromString("twrVar" +
                                            depth), twrVars),
-                          (resource.type.tag == TypeTags.BOT) ?
+                          (resource.type.hasTag(BOT)) ?
                           syms.autoCloseableType : resource.type,
                           currentMethodSym);
             twrVars.enter(syntheticTwrVar);
@@ -1545,25 +1678,10 @@ public class Lower extends TreeTranslator {
             new VarSymbol(0, make.paramName(2),
                           syms.throwableType,
                           currentMethodSym);
-        boolean prevDeferDiags = log.deferDiagnostics;
-        Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
-        JCMethodInvocation call;
-        try {
-            //disable diagnostics
-            log.deferDiagnostics = true;
-            log.deferredDiagnostics = ListBuffer.lb();
-            call = makeCall(make.Ident(primaryException),
+        JCStatement addSuppressionStatement =
+            make.Exec(makeCall(make.Ident(primaryException),
                     names.addSuppressed,
-                    List.<JCExpression>of(make.Ident(catchException)));
-        } catch (FatalError e) {
-            call = makeCall(make.Ident(primaryException),
-                    names.addSuppressedException,
-                    List.<JCExpression>of(make.Ident(catchException)));
-        } finally {
-            log.deferDiagnostics = prevDeferDiags;
-            log.deferredDiagnostics = prevDeferredDiags;
-        }
-        JCStatement addSuppressionStatement = make.Exec(call);
+                               List.<JCExpression>of(make.Ident(catchException))));
 
         // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
         JCBlock tryBlock =
@@ -1586,6 +1704,11 @@ public class Lower extends TreeTranslator {
     }
 
     private JCStatement makeResourceCloseInvocation(JCExpression resource) {
+        // convert to AutoCloseable if needed
+        if (types.asSuper(resource.type, syms.autoCloseableType.tsym) == null) {
+            resource = (JCExpression) convert(resource, syms.autoCloseableType);
+        }
+
         // create resource.close() method invocation
         JCExpression resourceClose = makeCall(resource,
                                               names.close,
@@ -1594,11 +1717,11 @@ public class Lower extends TreeTranslator {
     }
 
     private JCExpression makeNonNullCheck(JCExpression expression) {
-        return makeBinary(JCTree.NE, expression, makeNull());
+        return makeBinary(NE, expression, makeNull());
     }
 
     /** Construct a tree that represents the outer instance
-     *  <C.this>. Never pick the current `this'.
+     *  {@code C.this}. Never pick the current `this'.
      *  @param pos           The source code position to be used for the tree.
      *  @param c             The qualifier class.
      */
@@ -1633,7 +1756,7 @@ public class Lower extends TreeTranslator {
     }
 
     /** Construct a tree that represents the closest outer instance
-     *  <C.this> such that the given symbol is a member of C.
+     *  {@code C.this} such that the given symbol is a member of C.
      *  @param pos           The source code position to be used for the tree.
      *  @param sym           The accessed symbol.
      *  @param preciseMatch  should we accept a type that is a subtype of
@@ -1683,7 +1806,7 @@ public class Lower extends TreeTranslator {
         return tree;
     }
 
-    /** Return tree simulating the assignment <this.name = name>, where
+    /** Return tree simulating the assignment {@code this.name = name}, where
      *  name is the name of a free variable.
      */
     JCStatement initField(int pos, Name name) {
@@ -1700,7 +1823,7 @@ public class Lower extends TreeTranslator {
                     make.Ident(rhs)).setType(lhs.erasure(types)));
     }
 
-    /** Return tree simulating the assignment <this.this$n = this$n>.
+    /** Return tree simulating the assignment {@code this.this$n = this$n}.
      */
     JCStatement initOuterThis(int pos) {
         VarSymbol rhs = outerThisStack.head;
@@ -1735,7 +1858,7 @@ public class Lower extends TreeTranslator {
             if (e.sym.kind == TYP &&
                 e.sym.name == names.empty &&
                 (e.sym.flags() & INTERFACE) == 0) return (ClassSymbol) e.sym;
-        return makeEmptyClass(STATIC | SYNTHETIC, clazz);
+        return makeEmptyClass(STATIC | SYNTHETIC, clazz).sym;
     }
 
     /** Return symbol for "class$" method. If there is no method definition
@@ -1821,7 +1944,7 @@ public class Lower extends TreeTranslator {
             // $newcache.getClass().getComponentType().getClassLoader() : cl$"
             JCExpression clvalue =
                 make.Conditional(
-                    makeBinary(JCTree.EQ, make.Ident(clsym), makeNull()),
+                    makeBinary(EQ, make.Ident(clsym), makeNull()),
                     make.Assign(
                         make.Ident(clsym),
                         makeCall(
@@ -1869,7 +1992,7 @@ public class Lower extends TreeTranslator {
         JCStatement rethrow;
         if (target.hasInitCause()) {
             // rethrow = "throw new NoClassDefFoundError().initCause(e);
-            JCTree throwExpr =
+            JCExpression throwExpr =
                 makeCall(makeNewClass(syms.noClassDefFoundErrorType,
                                       List.<JCExpression>nil()),
                          names.initCause,
@@ -1915,7 +2038,7 @@ public class Lower extends TreeTranslator {
      *  @param sig      The signature of type T.
      */
     private Name cacheName(String sig) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         if (sig.startsWith("[")) {
             buf = buf.append("array");
             while (sig.startsWith("[")) {
@@ -1962,13 +2085,13 @@ public class Lower extends TreeTranslator {
     }
 
     private JCExpression classOfType(Type type, DiagnosticPosition pos) {
-        switch (type.tag) {
+        switch (type.getTag()) {
         case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
         case DOUBLE: case BOOLEAN: case VOID:
             // replace with <BoxedClass>.TYPE
             ClassSymbol c = types.boxedClass(type);
             Symbol typeSym =
-                rs.access(
+                rs.accessBase(
                     rs.findIdentInType(attrEnv, c.type, names.TYPE, VAR),
                     pos, c.type, names.TYPE, true);
             if (typeSym.kind == VAR)
@@ -1989,7 +2112,7 @@ public class Lower extends TreeTranslator {
                 writer.xClassName(type).toString().replace('/', '.');
             Symbol cs = cacheSym(pos, sig);
             return make_at(pos).Conditional(
-                makeBinary(JCTree.EQ, make.Ident(cs), makeNull()),
+                makeBinary(EQ, make.Ident(cs), makeNull()),
                 make.Assign(
                     make.Ident(cs),
                     make.App(
@@ -2036,7 +2159,7 @@ public class Lower extends TreeTranslator {
                                                             List.<Type>nil());
             JCClassDecl containerDef = classDef(container);
             make_at(containerDef.pos());
-            JCExpression notStatus = makeUnary(JCTree.NOT, make.App(make.Select(
+            JCExpression notStatus = makeUnary(NOT, make.App(make.Select(
                     classOfType(types.erasure(outermostClass.type),
                                 containerDef.pos()),
                     desiredAssertionStatusSym)));
@@ -2045,7 +2168,7 @@ public class Lower extends TreeTranslator {
             containerDef.defs = containerDef.defs.prepend(assertDisabledDef);
         }
         make_at(pos);
-        return makeUnary(JCTree.NOT, make.Ident(assertDisabledSym));
+        return makeUnary(NOT, make.Ident(assertDisabledSym));
     }
 
 
@@ -2075,9 +2198,9 @@ public class Lower extends TreeTranslator {
     JCTree abstractRval(JCTree rval, Type type, TreeBuilder builder) {
         rval = TreeInfo.skipParens(rval);
         switch (rval.getTag()) {
-        case JCTree.LITERAL:
+        case LITERAL:
             return builder.build(rval);
-        case JCTree.IDENT:
+        case IDENT:
             JCIdent id = (JCIdent) rval;
             if ((id.sym.flags() & FINAL) != 0 && id.sym.owner.kind == MTH)
                 return builder.build(rval);
@@ -2110,9 +2233,9 @@ public class Lower extends TreeTranslator {
     JCTree abstractLval(JCTree lval, final TreeBuilder builder) {
         lval = TreeInfo.skipParens(lval);
         switch (lval.getTag()) {
-        case JCTree.IDENT:
+        case IDENT:
             return builder.build(lval);
-        case JCTree.SELECT: {
+        case SELECT: {
             final JCFieldAccess s = (JCFieldAccess)lval;
             JCTree selected = TreeInfo.skipParens(s.selected);
             Symbol lid = TreeInfo.symbol(s.selected);
@@ -2123,7 +2246,7 @@ public class Lower extends TreeTranslator {
                     }
                 });
         }
-        case JCTree.INDEXED: {
+        case INDEXED: {
             final JCArrayAccess i = (JCArrayAccess)lval;
             return abstractRval(i.indexed, new TreeBuilder() {
                     public JCTree build(final JCTree indexed) {
@@ -2138,7 +2261,7 @@ public class Lower extends TreeTranslator {
                     }
                 });
         }
-        case JCTree.TYPECAST: {
+        case TYPECAST: {
             return abstractLval(((JCTypeCast)lval).expr, builder);
         }
         }
@@ -2171,9 +2294,8 @@ public class Lower extends TreeTranslator {
         } else {
             make_at(tree.pos());
             T result = super.translate(tree);
-            if (endPositions != null && result != tree) {
-                Integer endPos = endPositions.remove(tree);
-                if (endPos != null) endPositions.put(result, endPos);
+            if (endPosTable != null && result != tree) {
+                endPosTable.replaceTree(tree, result);
             }
             return result;
         }
@@ -2228,7 +2350,7 @@ public class Lower extends TreeTranslator {
                                 null, List.<JCExpression>nil(), List.<JCTree>nil());
             ClassSymbol c = tree.packge.package_info;
             c.flags_field |= flags;
-            c.attributes_field = tree.packge.attributes_field;
+            c.setAttributes(tree.packge);
             ClassType ctype = (ClassType) c.type;
             ctype.supertype_field = syms.objectType;
             ctype.interfaces_field = List.nil();
@@ -2245,7 +2367,8 @@ public class Lower extends TreeTranslator {
             case LEGACY:
                 return tree.packageAnnotations.nonEmpty();
             case NONEMPTY:
-                for (Attribute.Compound a: tree.packge.attributes_field) {
+                for (Attribute.Compound a :
+                         tree.packge.getDeclarationAttributes()) {
                     Attribute.RetentionPolicy p = types.getRetention(a);
                     if (p != Attribute.RetentionPolicy.SOURCE)
                         return true;
@@ -2358,7 +2481,7 @@ public class Lower extends TreeTranslator {
         for (List<JCTree> defs = tree.defs;
              defs.nonEmpty();
              defs=defs.tail) {
-            if (defs.head.getTag() == JCTree.VARDEF && (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) {
+            if (defs.head.hasTag(VARDEF) && (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) {
                 JCVariableDecl var = (JCVariableDecl)defs.head;
                 visitEnumConstantDef(var, nextOrdinal++);
                 values.append(make.QualIdent(var.sym));
@@ -2473,11 +2596,6 @@ public class Lower extends TreeTranslator {
 
         enumDefs.appendList(otherDefs.toList());
         tree.defs = enumDefs.toList();
-
-        // Add the necessary members for the EnumCompatibleMode
-        if (target.compilerBootstrap(tree.sym)) {
-            addEnumCompatibleMembers(tree);
-        }
     }
         // where
         private MethodSymbol systemArraycopyMethod;
@@ -2510,7 +2628,6 @@ public class Lower extends TreeTranslator {
                                        "enum" + target.syntheticNameChar() + "name"),
                       syms.stringType, tree.sym);
             nameParam.mods.flags |= SYNTHETIC; nameParam.sym.flags_field |= SYNTHETIC;
-
             JCVariableDecl ordParam = make.
                 Param(names.fromString(target.syntheticNameChar() +
                                        "enum" + target.syntheticNameChar() +
@@ -2521,36 +2638,14 @@ public class Lower extends TreeTranslator {
             tree.params = tree.params.prepend(ordParam).prepend(nameParam);
 
             MethodSymbol m = tree.sym;
+            m.extraParams = m.extraParams.prepend(ordParam.sym);
+            m.extraParams = m.extraParams.prepend(nameParam.sym);
             Type olderasure = m.erasure(types);
             m.erasure_field = new MethodType(
                 olderasure.getParameterTypes().prepend(syms.intType).prepend(syms.stringType),
                 olderasure.getReturnType(),
                 olderasure.getThrownTypes(),
                 syms.methodClass);
-
-            if (target.compilerBootstrap(m.owner)) {
-                // Initialize synthetic name field
-                Symbol nameVarSym = lookupSynthetic(names.fromString("$name"),
-                                                    tree.sym.owner.members());
-                JCIdent nameIdent = make.Ident(nameParam.sym);
-                JCIdent id1 = make.Ident(nameVarSym);
-                JCAssign newAssign = make.Assign(id1, nameIdent);
-                newAssign.type = id1.type;
-                JCExpressionStatement nameAssign = make.Exec(newAssign);
-                nameAssign.type = id1.type;
-                tree.body.stats = tree.body.stats.prepend(nameAssign);
-
-                // Initialize synthetic ordinal field
-                Symbol ordinalVarSym = lookupSynthetic(names.fromString("$ordinal"),
-                                                       tree.sym.owner.members());
-                JCIdent ordIdent = make.Ident(ordParam.sym);
-                id1 = make.Ident(ordinalVarSym);
-                newAssign = make.Assign(id1, ordIdent);
-                newAssign.type = id1.type;
-                JCExpressionStatement ordinalAssign = make.Exec(newAssign);
-                ordinalAssign.type = id1.type;
-                tree.body.stats = tree.body.stats.prepend(ordinalAssign);
-            }
         }
 
         JCMethodDecl prevMethodDef = currentMethodDef;
@@ -2608,9 +2703,14 @@ public class Lower extends TreeTranslator {
             if (fvs.nonEmpty()) {
                 List<Type> addedargtypes = List.nil();
                 for (List<VarSymbol> l = fvs; l.nonEmpty(); l = l.tail) {
-                    if (TreeInfo.isInitialConstructor(tree))
+                    if (TreeInfo.isInitialConstructor(tree)) {
+                        final Name pName = proxyName(l.head.name);
+                        m.extraParams =
+                            m.extraParams.append((VarSymbol)
+                                                 (proxies.lookup(pName).sym));
                         added = added.prepend(
-                            initField(tree.body.pos, proxyName(l.head.name)));
+                          initField(tree.body.pos, pName));
+                    }
                     addedargtypes = addedargtypes.prepend(l.head.erasure(types));
                 }
                 Type olderasure = m.erasure(types);
@@ -2640,7 +2740,52 @@ public class Lower extends TreeTranslator {
             }
             outerThisStack = prevOuterThisStack;
         } else {
-            super.visitMethodDef(tree);
+            Map<Symbol, Symbol> prevLambdaTranslationMap =
+                    lambdaTranslationMap;
+            try {
+                lambdaTranslationMap = (tree.sym.flags() & SYNTHETIC) != 0 &&
+                        tree.sym.name.startsWith(names.lambda) ?
+                        makeTranslationMap(tree) : null;
+                super.visitMethodDef(tree);
+            } finally {
+                lambdaTranslationMap = prevLambdaTranslationMap;
+            }
+        }
+        result = tree;
+    }
+    //where
+        private Map<Symbol, Symbol> makeTranslationMap(JCMethodDecl tree) {
+            Map<Symbol, Symbol> translationMap = new HashMap<Symbol,Symbol>();
+            for (JCVariableDecl vd : tree.params) {
+                Symbol p = vd.sym;
+                if (p != p.baseSymbol()) {
+                    translationMap.put(p.baseSymbol(), p);
+                }
+            }
+            return translationMap;
+        }
+
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        // No need to retain type annotations in the tree
+        // tree.annotations = translate(tree.annotations);
+        tree.annotations = List.nil();
+        tree.underlyingType = translate(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;
     }
@@ -2719,12 +2864,15 @@ public class Lower extends TreeTranslator {
 
     /** Visitor method for conditional expressions.
      */
+    @Override
     public void visitConditional(JCConditional tree) {
         JCTree cond = tree.cond = translate(tree.cond, syms.booleanType);
         if (cond.type.isTrue()) {
             result = convert(translate(tree.truepart, tree.type), tree.type);
+            addPrunedInfo(cond);
         } else if (cond.type.isFalse()) {
             result = convert(translate(tree.falsepart, tree.type), tree.type);
+            addPrunedInfo(cond);
         } else {
             // Condition is not a compile-time constant.
             tree.truepart = translate(tree.truepart, tree.type);
@@ -2733,14 +2881,14 @@ public class Lower extends TreeTranslator {
         }
     }
 //where
-        private JCTree convert(JCTree tree, Type pt) {
-            if (tree.type == pt || tree.type.tag == TypeTags.BOT)
-                return tree;
-            JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree);
-            result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt)
-                                                           : pt;
-            return result;
-        }
+    private JCTree convert(JCTree tree, Type pt) {
+        if (tree.type == pt || tree.type.hasTag(BOT))
+            return tree;
+        JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree);
+        result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt)
+                                                       : pt;
+        return result;
+    }
 
     /** Visitor method for if statements.
      */
@@ -2748,12 +2896,14 @@ public class Lower extends TreeTranslator {
         JCTree cond = tree.cond = translate(tree.cond, syms.booleanType);
         if (cond.type.isTrue()) {
             result = translate(tree.thenpart);
+            addPrunedInfo(cond);
         } else if (cond.type.isFalse()) {
             if (tree.elsepart != null) {
                 result = translate(tree.elsepart);
             } else {
                 result = make.Skip();
             }
+            addPrunedInfo(cond);
         } else {
             // Condition is not a compile-time constant.
             tree.thenpart = translate(tree.thenpart);
@@ -2773,13 +2923,13 @@ public class Lower extends TreeTranslator {
                 List.<JCExpression>nil() : List.of(translate(tree.detail));
             if (!tree.cond.type.isFalse()) {
                 cond = makeBinary
-                    (JCTree.AND,
+                    (AND,
                      cond,
-                     makeUnary(JCTree.NOT, tree.cond));
+                     makeUnary(NOT, tree.cond));
             }
             result =
                 make.If(cond,
-                        make_at(detailPos).
+                        make_at(tree).
                            Throw(makeNewClass(syms.assertionErrorType, exnArgs)),
                         null);
         } else {
@@ -2836,7 +2986,7 @@ public class Lower extends TreeTranslator {
             // first argument.
             if (c.hasOuterInstance()) {
                 JCExpression thisArg;
-                if (tree.meth.getTag() == JCTree.SELECT) {
+                if (tree.meth.hasTag(SELECT)) {
                     thisArg = attr.
                         makeNullCheck(translate(((JCFieldAccess) tree.meth).selected));
                     tree.meth = make.Ident(constructor);
@@ -2857,7 +3007,7 @@ public class Lower extends TreeTranslator {
             // If the translated method itself is an Apply tree, we are
             // seeing an access method invocation. In this case, append
             // the method arguments to the arguments of the access method.
-            if (tree.meth.getTag() == JCTree.APPLY) {
+            if (tree.meth.hasTag(APPLY)) {
                 JCMethodInvocation app = (JCMethodInvocation)tree.meth;
                 app.args = tree.args.prependList(app.args);
                 result = app;
@@ -2913,7 +3063,7 @@ public class Lower extends TreeTranslator {
             return tree;
         if (havePrimitive) {
             Type unboxedTarget = types.unboxedType(type);
-            if (unboxedTarget.tag != NONE) {
+            if (!unboxedTarget.hasTag(NONE)) {
                 if (!types.isSubtype(tree.type, unboxedTarget)) //e.g. Character c = 89;
                     tree.type = unboxedTarget.constType(tree.type.constValue());
                 return (T)boxPrimitive((JCExpression)tree, type);
@@ -2955,7 +3105,7 @@ public class Lower extends TreeTranslator {
         if (tree.type == null || tree.type.isErroneous())
             return tree;
         Type unboxedType = types.unboxedType(tree.type);
-        if (unboxedType.tag == NONE) {
+        if (unboxedType.hasTag(NONE)) {
             unboxedType = primitive;
             if (!unboxedType.isPrimitive())
                 throw new AssertionError(unboxedType);
@@ -2999,7 +3149,7 @@ public class Lower extends TreeTranslator {
         // If translated left hand side is an Apply, we are
         // seeing an access method invocation. In this case, append
         // right hand side as last argument of the access method.
-        if (tree.lhs.getTag() == JCTree.APPLY) {
+        if (tree.lhs.hasTag(APPLY)) {
             JCMethodInvocation app = (JCMethodInvocation)tree.lhs;
             app.args = List.of(tree.rhs).prependList(app.args);
             result = app;
@@ -3009,14 +3159,17 @@ public class Lower extends TreeTranslator {
     }
 
     public void visitAssignop(final JCAssignOp tree) {
-        if (!tree.lhs.type.isPrimitive() && !tree.lhs.type.isErroneous() &&
-            tree.operator.type.getReturnType().isPrimitive()) {
+        JCTree lhsAccess = access(TreeInfo.skipParens(tree.lhs));
+        final boolean boxingReq = !tree.lhs.type.isPrimitive() && !tree.lhs.type.isErroneous() &&
+            tree.operator.type.getReturnType().isPrimitive();
+
+        if (boxingReq || lhsAccess.hasTag(APPLY)) {
             // boxing required; need to rewrite as x = (unbox typeof x)(x op y);
             // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
             // (but without recomputing x)
             JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() {
                     public JCTree build(final JCTree lhs) {
-                        int newTag = tree.getTag() - JCTree.ASGOffset;
+                        JCTree.Tag newTag = tree.getTag().noAssignOp();
                         // Erasure (TransTypes) can change the type of
                         // tree.lhs.  However, we can still get the
                         // unerased type of tree.lhs as it is stored
@@ -3032,8 +3185,9 @@ public class Lower extends TreeTranslator {
                         JCBinary opResult = make.Binary(newTag, expr, tree.rhs);
                         opResult.operator = newOperator;
                         opResult.type = newOperator.type.getReturnType();
-                        JCTypeCast newRhs = make.TypeCast(types.unboxedType(tree.type),
-                                                          opResult);
+                        JCExpression newRhs = boxingReq ?
+                            make.TypeCast(types.unboxedType(tree.type), opResult) :
+                            opResult;
                         return make.Assign((JCExpression)lhs, newRhs).setType(tree.type);
                     }
                 });
@@ -3046,7 +3200,7 @@ public class Lower extends TreeTranslator {
         // If translated left hand side is an Apply, we are
         // seeing an access method invocation. In this case, append
         // right hand side as last argument of the access method.
-        if (tree.lhs.getTag() == JCTree.APPLY) {
+        if (tree.lhs.hasTag(APPLY)) {
             JCMethodInvocation app = (JCMethodInvocation)tree.lhs;
             // if operation is a += on strings,
             // make sure to convert argument to string
@@ -3066,13 +3220,13 @@ public class Lower extends TreeTranslator {
         // or
         // translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2
         // where OP is += or -=
-        final boolean cast = TreeInfo.skipParens(tree.arg).getTag() == JCTree.TYPECAST;
+        final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST);
         return abstractLval(tree.arg, new TreeBuilder() {
                 public JCTree build(final JCTree tmp1) {
                     return abstractRval(tmp1, tree.arg.type, new TreeBuilder() {
                             public JCTree build(final JCTree tmp2) {
-                                int opcode = (tree.getTag() == JCTree.POSTINC)
-                                    ? JCTree.PLUS_ASG : JCTree.MINUS_ASG;
+                                JCTree.Tag opcode = (tree.hasTag(POSTINC))
+                                    ? PLUS_ASG : MINUS_ASG;
                                 JCTree lhs = cast
                                     ? make.TypeCast(tree.arg.type, (JCExpression)tmp1)
                                     : tmp1;
@@ -3087,25 +3241,24 @@ public class Lower extends TreeTranslator {
     }
 
     public void visitUnary(JCUnary tree) {
-        boolean isUpdateOperator =
-            JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC;
+        boolean isUpdateOperator = tree.getTag().isIncOrDecUnaryOp();
         if (isUpdateOperator && !tree.arg.type.isPrimitive()) {
             switch(tree.getTag()) {
-            case JCTree.PREINC:            // ++ e
+            case PREINC:            // ++ e
                     // translate to e += 1
-            case JCTree.PREDEC:            // -- e
+            case PREDEC:            // -- e
                     // translate to e -= 1
                 {
-                    int opcode = (tree.getTag() == JCTree.PREINC)
-                        ? JCTree.PLUS_ASG : JCTree.MINUS_ASG;
+                    JCTree.Tag opcode = (tree.hasTag(PREINC))
+                        ? PLUS_ASG : MINUS_ASG;
                     JCAssignOp newTree = makeAssignop(opcode,
                                                     tree.arg,
                                                     make.Literal(1));
                     result = translate(newTree, tree.type);
                     return;
                 }
-            case JCTree.POSTINC:           // e ++
-            case JCTree.POSTDEC:           // e --
+            case POSTINC:           // e ++
+            case POSTDEC:           // e --
                 {
                     result = translate(lowerBoxedPostop(tree), tree.type);
                     return;
@@ -3116,14 +3269,14 @@ public class Lower extends TreeTranslator {
 
         tree.arg = boxIfNeeded(translate(tree.arg, tree), tree.type);
 
-        if (tree.getTag() == JCTree.NOT && tree.arg.type.constValue() != null) {
+        if (tree.hasTag(NOT) && tree.arg.type.constValue() != null) {
             tree.type = cfolder.fold1(bool_not, tree.arg.type);
         }
 
         // If translated left hand side is an Apply, we are
         // seeing an access method invocation. In this case, return
         // that access method invocation as result.
-        if (isUpdateOperator && tree.arg.getTag() == JCTree.APPLY) {
+        if (isUpdateOperator && tree.arg.hasTag(APPLY)) {
             result = tree.arg;
         } else {
             result = tree;
@@ -3134,7 +3287,7 @@ public class Lower extends TreeTranslator {
         List<Type> formals = tree.operator.type.getParameterTypes();
         JCTree lhs = tree.lhs = translate(tree.lhs, formals.head);
         switch (tree.getTag()) {
-        case JCTree.OR:
+        case OR:
             if (lhs.type.isTrue()) {
                 result = lhs;
                 return;
@@ -3144,7 +3297,7 @@ public class Lower extends TreeTranslator {
                 return;
             }
             break;
-        case JCTree.AND:
+        case AND:
             if (lhs.type.isFalse()) {
                 result = lhs;
                 return;
@@ -3180,7 +3333,7 @@ public class Lower extends TreeTranslator {
          *
          * (where arrayexpr is of an array type) gets translated to
          *
-         * <pre>
+         * <pre>{@code
          *     for ( { arraytype #arr = arrayexpr;
          *             int #len = array.length;
          *             int #i = 0; };
@@ -3188,7 +3341,7 @@ public class Lower extends TreeTranslator {
          *         T v = arr$[#i];
          *         stmt;
          *     }
-         * </pre>
+         * }</pre>
          *
          * where #arr, #len, and #i are freshly named synthetic local variables.
          */
@@ -3214,9 +3367,9 @@ public class Lower extends TreeTranslator {
             indexdef.init.type = indexdef.type = syms.intType.constType(0);
 
             List<JCStatement> loopinit = List.of(arraycachedef, lencachedef, indexdef);
-            JCBinary cond = makeBinary(JCTree.LT, make.Ident(index), make.Ident(lencache));
+            JCBinary cond = makeBinary(LT, make.Ident(index), make.Ident(lencache));
 
-            JCExpressionStatement step = make.Exec(makeUnary(JCTree.PREINC, make.Ident(index)));
+            JCExpressionStatement step = make.Exec(makeUnary(PREINC, make.Ident(index)));
 
             Type elemtype = types.elemtype(tree.expr.type);
             JCExpression loopvarinit = make.Indexed(make.Ident(arraycache),
@@ -3258,14 +3411,14 @@ public class Lower extends TreeTranslator {
          *     for ( T v : coll ) stmt ;
          * </pre>
          *
-         * (where coll implements Iterable<? extends T>) gets translated to
+         * (where coll implements {@code Iterable<? extends T>}) gets translated to
          *
-         * <pre>
+         * <pre>{@code
          *     for ( Iterator<? extends T> #i = coll.iterator(); #i.hasNext(); ) {
          *         T v = (T) #i.next();
          *         stmt;
          *     }
-         * </pre>
+         * }</pre>
          *
          * where #i is a freshly named synthetic local variable.
          */
@@ -3277,19 +3430,24 @@ public class Lower extends TreeTranslator {
             if (iterableType.getTypeArguments().nonEmpty())
                 iteratorTarget = types.erasure(iterableType.getTypeArguments().head);
             Type eType = tree.expr.type;
+            while (eType.hasTag(TYPEVAR)) {
+                eType = eType.getUpperBound();
+            }
             tree.expr.type = types.erasure(eType);
-            if (eType.tag == TYPEVAR && eType.getUpperBound().isCompound())
+            if (eType.isCompound())
                 tree.expr = make.TypeCast(types.erasure(iterableType), tree.expr);
             Symbol iterator = lookupMethod(tree.expr.pos(),
                                            names.iterator,
-                                           types.erasure(syms.iterableType),
+                                           eType,
                                            List.<Type>nil());
             VarSymbol itvar = new VarSymbol(0, names.fromString("i" + target.syntheticNameChar()),
                                             types.erasure(iterator.type.getReturnType()),
                                             currentMethodSym);
-            JCStatement init = make.
-                VarDef(itvar,
-                       make.App(make.Select(tree.expr, iterator)));
+
+             JCStatement init = make.
+                VarDef(itvar, make.App(make.Select(tree.expr, iterator)
+                     .setType(types.erasure(iterator.type))));
+
             Symbol hasNext = lookupMethod(tree.expr.pos(),
                                           names.hasNext,
                                           itvar.type,
@@ -3617,15 +3775,26 @@ public class Lower extends TreeTranslator {
 
     public void visitSelect(JCFieldAccess tree) {
         // need to special case-access of the form C.super.x
-        // these will always need an access method.
+        // these will always need an access method, unless C
+        // is a default interface subclassed by the current class.
         boolean qualifiedSuperAccess =
-            tree.selected.getTag() == JCTree.SELECT &&
-            TreeInfo.name(tree.selected) == names._super;
+            tree.selected.hasTag(SELECT) &&
+            TreeInfo.name(tree.selected) == names._super &&
+            !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass);
         tree.selected = translate(tree.selected);
-        if (tree.name == names._class)
+        if (tree.name == names._class) {
             result = classOf(tree.selected);
-        else if (tree.name == names._this || tree.name == names._super)
+        }
+        else if (tree.name == names._super &&
+                types.isDirectSuperInterface(tree.selected.type.tsym, currentClass)) {
+            //default super call!! Not a classic qualified super call
+            TypeSymbol supSym = tree.selected.type.tsym;
+            Assert.checkNonNull(types.asSuper(currentClass.type, supSym));
+            result = tree;
+        }
+        else if (tree.name == names._this || tree.name == names._super) {
             result = makeThis(tree.pos(), tree.selected.type.tsym);
+        }
         else
             result = access(tree.sym, tree, enclOp, qualifiedSuperAccess);
     }
@@ -3644,8 +3813,16 @@ public class Lower extends TreeTranslator {
 
     @Override
     public void visitTry(JCTry tree) {
+        /* special case of try without catchers and with finally emtpy.
+         * Don't give it a try, translate only the body.
+         */
         if (tree.resources.isEmpty()) {
-            super.visitTry(tree);
+            if (tree.catchers.isEmpty() &&
+                (tree.finalizer == null || tree.finalizer.getStatements().isEmpty())) {
+                result = translate(tree.body);
+            } else {
+                super.visitTry(tree);
+            }
         } else {
             result = makeTwrTry(tree);
         }
@@ -3666,10 +3843,10 @@ public class Lower extends TreeTranslator {
         try {
             attrEnv = env;
             this.make = make;
-            endPositions = env.toplevel.endPositions;
+            endPosTable = env.toplevel.endPositions;
             currentClass = null;
             currentMethodDef = null;
-            outermostClassDef = (cdef.getTag() == JCTree.CLASSDEF) ? (JCClassDecl)cdef : null;
+            outermostClassDef = (cdef.hasTag(CLASSDEF)) ? (JCClassDecl)cdef : null;
             outermostMemberDef = null;
             this.translated = new ListBuffer<JCTree>();
             classdefs = new HashMap<ClassSymbol,JCClassDecl>();
@@ -3695,7 +3872,7 @@ public class Lower extends TreeTranslator {
             // note that recursive invocations of this method fail hard
             attrEnv = null;
             this.make = null;
-            endPositions = null;
+            endPosTable = null;
             currentClass = null;
             currentMethodDef = null;
             outermostClassDef = null;
@@ -3715,168 +3892,4 @@ public class Lower extends TreeTranslator {
         }
         return translated.toList();
     }
-
-    //////////////////////////////////////////////////////////////
-    // The following contributed by Borland for bootstrapping purposes
-    //////////////////////////////////////////////////////////////
-    private void addEnumCompatibleMembers(JCClassDecl cdef) {
-        make_at(null);
-
-        // Add the special enum fields
-        VarSymbol ordinalFieldSym = addEnumOrdinalField(cdef);
-        VarSymbol nameFieldSym = addEnumNameField(cdef);
-
-        // Add the accessor methods for name and ordinal
-        MethodSymbol ordinalMethodSym = addEnumFieldOrdinalMethod(cdef, ordinalFieldSym);
-        MethodSymbol nameMethodSym = addEnumFieldNameMethod(cdef, nameFieldSym);
-
-        // Add the toString method
-        addEnumToString(cdef, nameFieldSym);
-
-        // Add the compareTo method
-        addEnumCompareTo(cdef, ordinalFieldSym);
-    }
-
-    private VarSymbol addEnumOrdinalField(JCClassDecl cdef) {
-        VarSymbol ordinal = new VarSymbol(PRIVATE|FINAL|SYNTHETIC,
-                                          names.fromString("$ordinal"),
-                                          syms.intType,
-                                          cdef.sym);
-        cdef.sym.members().enter(ordinal);
-        cdef.defs = cdef.defs.prepend(make.VarDef(ordinal, null));
-        return ordinal;
-    }
-
-    private VarSymbol addEnumNameField(JCClassDecl cdef) {
-        VarSymbol name = new VarSymbol(PRIVATE|FINAL|SYNTHETIC,
-                                          names.fromString("$name"),
-                                          syms.stringType,
-                                          cdef.sym);
-        cdef.sym.members().enter(name);
-        cdef.defs = cdef.defs.prepend(make.VarDef(name, null));
-        return name;
-    }
-
-    private MethodSymbol addEnumFieldOrdinalMethod(JCClassDecl cdef, VarSymbol ordinalSymbol) {
-        // Add the accessor methods for ordinal
-        Symbol ordinalSym = lookupMethod(cdef.pos(),
-                                         names.ordinal,
-                                         cdef.type,
-                                         List.<Type>nil());
-
-        Assert.check(ordinalSym instanceof MethodSymbol);
-
-        JCStatement ret = make.Return(make.Ident(ordinalSymbol));
-        cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)ordinalSym,
-                                                    make.Block(0L, List.of(ret))));
-
-        return (MethodSymbol)ordinalSym;
-    }
-
-    private MethodSymbol addEnumFieldNameMethod(JCClassDecl cdef, VarSymbol nameSymbol) {
-        // Add the accessor methods for name
-        Symbol nameSym = lookupMethod(cdef.pos(),
-                                   names._name,
-                                   cdef.type,
-                                   List.<Type>nil());
-
-        Assert.check(nameSym instanceof MethodSymbol);
-
-        JCStatement ret = make.Return(make.Ident(nameSymbol));
-
-        cdef.defs = cdef.defs.append(make.MethodDef((MethodSymbol)nameSym,
-                                                    make.Block(0L, List.of(ret))));
-
-        return (MethodSymbol)nameSym;
-    }
-
-    private MethodSymbol addEnumToString(JCClassDecl cdef,
-                                         VarSymbol nameSymbol) {
-        Symbol toStringSym = lookupMethod(cdef.pos(),
-                                          names.toString,
-                                          cdef.type,
-                                          List.<Type>nil());
-
-        JCTree toStringDecl = null;
-        if (toStringSym != null)
-            toStringDecl = TreeInfo.declarationFor(toStringSym, cdef);
-
-        if (toStringDecl != null)
-            return (MethodSymbol)toStringSym;
-
-        JCStatement ret = make.Return(make.Ident(nameSymbol));
-
-        JCTree resTypeTree = make.Type(syms.stringType);
-
-        MethodType toStringType = new MethodType(List.<Type>nil(),
-                                                 syms.stringType,
-                                                 List.<Type>nil(),
-                                                 cdef.sym);
-        toStringSym = new MethodSymbol(PUBLIC,
-                                       names.toString,
-                                       toStringType,
-                                       cdef.type.tsym);
-        toStringDecl = make.MethodDef((MethodSymbol)toStringSym,
-                                      make.Block(0L, List.of(ret)));
-
-        cdef.defs = cdef.defs.prepend(toStringDecl);
-        cdef.sym.members().enter(toStringSym);
-
-        return (MethodSymbol)toStringSym;
-    }
-
-    private MethodSymbol addEnumCompareTo(JCClassDecl cdef, VarSymbol ordinalSymbol) {
-        Symbol compareToSym = lookupMethod(cdef.pos(),
-                                   names.compareTo,
-                                   cdef.type,
-                                   List.of(cdef.sym.type));
-
-        Assert.check(compareToSym instanceof MethodSymbol);
-
-        JCMethodDecl compareToDecl = (JCMethodDecl) TreeInfo.declarationFor(compareToSym, cdef);
-
-        ListBuffer<JCStatement> blockStatements = new ListBuffer<JCStatement>();
-
-        JCModifiers mod1 = make.Modifiers(0L);
-        Name oName = names.fromString("o");
-        JCVariableDecl par1 = make.Param(oName, cdef.type, compareToSym);
-
-        JCIdent paramId1 = make.Ident(names.java_lang_Object);
-        paramId1.type = cdef.type;
-        paramId1.sym = par1.sym;
-
-        ((MethodSymbol)compareToSym).params = List.of(par1.sym);
-
-        JCIdent par1UsageId = make.Ident(par1.sym);
-        JCIdent castTargetIdent = make.Ident(cdef.sym);
-        JCTypeCast cast = make.TypeCast(castTargetIdent, par1UsageId);
-        cast.setType(castTargetIdent.type);
-
-        Name otherName = names.fromString("other");
-
-        VarSymbol otherVarSym = new VarSymbol(mod1.flags,
-                                              otherName,
-                                              cdef.type,
-                                              compareToSym);
-        JCVariableDecl otherVar = make.VarDef(otherVarSym, cast);
-        blockStatements.append(otherVar);
-
-        JCIdent id1 = make.Ident(ordinalSymbol);
-
-        JCIdent fLocUsageId = make.Ident(otherVarSym);
-        JCExpression sel = make.Select(fLocUsageId, ordinalSymbol);
-        JCBinary bin = makeBinary(JCTree.MINUS, id1, sel);
-        JCReturn ret = make.Return(bin);
-        blockStatements.append(ret);
-        JCMethodDecl compareToMethod = make.MethodDef((MethodSymbol)compareToSym,
-                                                   make.Block(0L,
-                                                              blockStatements.toList()));
-        compareToMethod.params = List.of(par1);
-        cdef.defs = cdef.defs.append(compareToMethod);
-
-        return (MethodSymbol)compareToSym;
-    }
-    //////////////////////////////////////////////////////////////
-    // The above contributed by Borland for bootstrapping purposes
-    //////////////////////////////////////////////////////////////
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
index baf1456..98b7002 100644
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
@@ -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
@@ -25,28 +25,38 @@
 
 package com.sun.tools.javac.comp;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.Set;
+
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Modifier;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
 
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.ANNOTATION;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.ERROR;
+import static com.sun.tools.javac.code.TypeTag.FORALL;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
+import static com.sun.tools.javac.code.TypeTag.VOID;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import com.sun.tools.javac.model.LazyTreeLoader;
+import com.sun.tools.javac.parser.Tokens.Comment;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.model.LazyTreeLoader;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.Modifier;
 
 /** This is the second phase of Enter, in which classes are completed
  *  by entering their members into the class scope using
@@ -77,12 +87,11 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     private final Annotate annotate;
     private final Types types;
     private final JCDiagnostic.Factory diags;
+    private final Source source;
     private final Target target;
     private final DeferredLintHandler deferredLintHandler;
     private final JavacMessages messages;
     private final LazyTreeLoader treeLoader;
-
-    private final boolean skipAnnotations;
     private final boolean ignoreNoLang;
 
     public static MemberEnter instance(Context context) {
@@ -106,10 +115,11 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         annotate = Annotate.instance(context);
         types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
+        source = Source.instance(context);
         target = Target.instance(context);
         deferredLintHandler = DeferredLintHandler.instance(context);
+        allowTypeAnnos = source.allowTypeAnnotations();
         Options options = Options.instance(context);
-        skipAnnotations = options.isSet("skipAnnotations");
         boolean ideMode = options.get("ide") != null;
         boolean backgroundCompilation = options.get("backgroundCompilation") != null;
         ignoreNoLang = ideMode && !backgroundCompilation;
@@ -117,13 +127,17 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         treeLoader = LazyTreeLoader.instance(context);
     }
 
+    /** Switch: support type annotations.
+     */
+    boolean allowTypeAnnos;
+
     /** A queue for classes whose members still need to be entered into the
      *  symbol table.
      */
     public ListBuffer<Env<AttrContext>> halfcompleted = new ListBuffer<Env<AttrContext>>();
 
     /** Set to true only when the first of a set of classes is
-     *  processed from the halfcompleted queue.
+     *  processed from the half completed queue.
      */
     boolean isFirst = true;
 
@@ -139,8 +153,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     /** Import all classes of a class or package on demand.
      *  @param pos           Position to be used for error reporting.
      *  @param tsym          The class or package the members of which are imported.
-     *  @param toScope   The (import) scope in which imported classes
-     *               are entered.
+     *  @param env           The env in which the imported classes will be entered.
      */
     private void importAll(int pos,
                            final TypeSymbol tsym,
@@ -166,8 +179,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     /** Import all static members of a class or package on demand.
      *  @param pos           Position to be used for error reporting.
      *  @param tsym          The class or package the members of which are imported.
-     *  @param toScope   The (import) scope in which imported classes
-     *               are entered.
+     *  @param env           The env in which the imported classes will be entered.
      */
     private void importStaticAll(int pos,
                                  final TypeSymbol tsym,
@@ -365,12 +377,16 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
      *  @param params      The method's value parameters.
      *  @param res             The method's result type,
      *                 null if it is a constructor.
+     *  @param recvparam       The method's receiver parameter,
+     *                 null if none given; TODO: or already set here?
      *  @param thrown      The method's thrown exceptions.
      *  @param env             The method's (local) environment.
      */
-    Type signature(List<JCTypeParameter> typarams,
+    Type signature(MethodSymbol msym,
+                   List<JCTypeParameter> typarams,
                    List<JCVariableDecl> params,
                    JCTree res,
+                   JCVariableDecl recvparam,
                    List<JCExpression> thrown,
                    Env<AttrContext> env) {
 
@@ -388,18 +404,33 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         // Attribute result type, if one is given.
         Type restype = res == null ? syms.voidType : attr.attribType(res, env);
 
+        // Attribute receiver type, if one is given.
+        Type recvtype;
+        if (recvparam!=null) {
+            memberEnter(recvparam, env);
+            recvtype = recvparam.vartype.type;
+        } else {
+            recvtype = null;
+        }
+
         // Attribute thrown exceptions.
         ListBuffer<Type> thrownbuf = new ListBuffer<Type>();
         for (List<JCExpression> l = thrown; l.nonEmpty(); l = l.tail) {
             Type exc = attr.attribType(l.head, env);
-            if (exc.tag != TYPEVAR)
+            if (!exc.hasTag(TYPEVAR)) {
                 exc = chk.checkClassType(l.head.pos(), exc);
+            } else if (exc.tsym.owner == msym) {
+                //mark inference variables in 'throws' clause
+                exc.tsym.flags_field |= THROWS;
+            }
             thrownbuf.append(exc);
         }
-        Type mtype = new MethodType(argbuf.toList(),
+        MethodType mtype = new MethodType(argbuf.toList(),
                                     restype,
                                     thrownbuf.toList(),
                                     syms.methodClass);
+        mtype.recvtype = recvtype;
+
         return tvars.isEmpty() ? mtype : new ForAll(tvars, mtype);
     }
 
@@ -436,10 +467,13 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     /** Enter members for a class.
      */
     void finishClass(JCClassDecl tree, Env<AttrContext> env) {
-        if ((tree.mods.flags & Flags.ENUM) != 0 &&
-            (types.supertype(tree.sym.type).tsym.flags() & Flags.ENUM) == 0) {
-            if (tree.sym == null || (tree.sym.flags_field & Flags.FROMCLASS) == 0)
-                addEnumMembers(tree, env);
+        if ((tree.mods.flags & Flags.ENUM) != 0) {
+            Type supertype = types.supertype(tree.sym.type);
+            if (supertype != null && !supertype.hasTag(TypeTag.NONE)
+                    && (supertype.tsym.flags() & Flags.ENUM) == 0
+                    && (tree.sym.flags_field & Flags.FROMCLASS) == 0) {
+                    addEnumMembers(tree, env);
+            }
         }
         memberEnter(tree.defs, env);
     }
@@ -460,9 +494,27 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                       List.<JCExpression>nil(), // thrown
                       null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))),
                       null);
-        Map<JCTree, String> docComments = env.toplevel.docComments;
+        class HardcodedComment implements Comment {
+            private final String key;
+            public HardcodedComment(String key) {
+                this.key = key;
+            }
+            public String getText() {
+                return messages.getLocalizedString(key); //NOI18N
+            }
+            public int getSourcePos(int index) {
+                return -1;
+            }
+            public CommentStyle getStyle() {
+                return CommentStyle.JAVADOC;
+            }
+            public boolean isDeprecated() {
+                return false;
+            }
+        }
+        DocCommentTable docComments = env.toplevel.docComments;
         if (docComments != null)
-            docComments.put(values, messages.getLocalizedString("compiler.javadoc.enum.values")); //NOI18N
+            docComments.putComment(values, new HardcodedComment("compiler.javadoc.enum.values")); //NOI18N
         memberEnter(values, env);
 
         // public static T valueOf(String name) { return ???; }
@@ -471,53 +523,16 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                       names.valueOf,
                       make.Type(tree.sym.type),
                       List.<JCTypeParameter>nil(),
-                      List.of(make.VarDef(make.Modifiers(Flags.PARAMETER),
+                      List.of(make.VarDef(make.Modifiers(Flags.PARAMETER |
+                                                         Flags.MANDATED),
                                             names.fromString("name"),
                                             make.Type(syms.stringType), null)),
                       List.<JCExpression>nil(), // thrown
                       null, //make.Block(0, Tree.emptyList.prepend(make.Return(make.Ident(names._null)))),
                       null);
         if (docComments != null)
-            docComments.put(valueOf, messages.getLocalizedString("compiler.javadoc.enum.valueOf")); //NOI18N
+            docComments.putComment(valueOf, new HardcodedComment("compiler.javadoc.enum.valueOf")); //NOI18N
         memberEnter(valueOf, env);
-
-        // the remaining members are for bootstrapping only
-        if (!target.compilerBootstrap(tree.sym)) return;
-
-        // public final int ordinal() { return ???; }
-        JCMethodDecl ordinal = make.at(tree.pos).
-            MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL),
-                      names.ordinal,
-                      make.Type(syms.intType),
-                      List.<JCTypeParameter>nil(),
-                      List.<JCVariableDecl>nil(),
-                      List.<JCExpression>nil(),
-                      null,
-                      null);
-        memberEnter(ordinal, env);
-
-        // public final String name() { return ???; }
-        JCMethodDecl name = make.
-            MethodDef(make.Modifiers(Flags.PUBLIC|Flags.FINAL),
-                      names._name,
-                      make.Type(syms.stringType),
-                      List.<JCTypeParameter>nil(),
-                      List.<JCVariableDecl>nil(),
-                      List.<JCExpression>nil(),
-                      null,
-                      null);
-        memberEnter(name, env);
-
-        // public int compareTo(E other) { return ???; }
-        MethodSymbol compareTo = new
-            MethodSymbol(Flags.PUBLIC,
-                         names.compareTo,
-                         new MethodType(List.of(tree.sym.type),
-                                        syms.intType,
-                                        List.<Type>nil(),
-                                        syms.methodClass),
-                         tree.sym);
-        memberEnter(make.MethodDef(compareTo, null), env);
     }
 
     public void visitTopLevel(JCCompilationUnit tree) {
@@ -544,33 +559,32 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         // process package annotations
         annotateLater(tree.packageAnnotations, env, tree.packge);
 
-        // Import-on-demand java.lang.
-        importAll(tree.pos, reader.enterPackage(names.java_lang), env);
+        DeferredLintHandler prevLintHandler = chk.setDeferredLintHandler(DeferredLintHandler.immediateHandler);
 
-        // Process all import clauses.
-        memberEnter(tree.defs, env);
+        try {
+            // Import-on-demand java.lang.
+            importAll(tree.pos, reader.enterPackage(names.java_lang), env);
+
+            // Process all import clauses.
+            memberEnter(tree.defs, env);
+        } finally {
+            chk.setDeferredLintHandler(prevLintHandler);
+        }
     }
 
     // process the non-static imports and the static imports of types.
     public void visitImport(JCImport tree) {
-        JCTree imp = tree.qualid;
+        JCFieldAccess imp = (JCFieldAccess)tree.qualid;
         Name name = TreeInfo.name(imp);
-        TypeSymbol p;
 
         // Create a local environment pointing to this tree to disable
         // effects of other imports in Resolve.findGlobalType
         Env<AttrContext> localEnv = env.dup(tree);
 
-        // Attribute qualifying package or class.
-        JCFieldAccess s = (JCFieldAccess) imp;
-        p = attr.
-            attribTree(s.selected,
-                       localEnv,
-                       tree.staticImport ? TYP : (TYP | PCK),
-                       Type.noType).tsym;
+        TypeSymbol p = attr.attribImportQualifier(tree, localEnv).tsym;
         if (name == names.asterisk) {
             // Import on demand.
-            chk.checkCanonical(s.selected);
+            chk.checkCanonical(imp.selected);
             if (tree.staticImport)
                 importStaticAll(tree.pos, p, env);
             else
@@ -579,7 +593,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             // Named type import.
             if (tree.staticImport) {
                 importNamedStatic(tree.pos(), p, name, localEnv);
-                chk.checkCanonical(s.selected);
+                chk.checkCanonical(imp.selected);
             } else {
                 TypeSymbol c = attribImportType(imp, localEnv).tsym;
                 chk.checkCanonical(imp);
@@ -603,14 +617,14 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     }
     
     private boolean isSameAPType(Type t, Type s) {
-        return    types.isSameType(t, s)
+        return    t != null && !t.hasTag(TypeTag.UNKNOWN) && types.isSameType(t, s)
                || t.tsym != null && s.tsym != null && s.isErroneous() && t.tsym.name == s.tsym.name;
     }
     
     private boolean isSameMethod(Type ot, Type os) {
-        if (ot.tag != os.tag) return false;
+        if (ot.getTag() != os.getTag()) return false;
         
-        switch (ot.tag) {
+        switch (ot.getTag()) {
             case METHOD: {
                 MethodType t = (MethodType) ot;
                 MethodType s = (MethodType) os;
@@ -646,19 +660,30 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         MethodSymbol m = new MethodSymbol(0, tree.name, null, enclScope.owner);
         m.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, m, tree);
         tree.sym = m;
+
+        //if this is a default method, add the DEFAULT flag to the enclosing interface
+        if ((tree.mods.flags & DEFAULT) != 0) {
+            m.enclClass().flags_field |= DEFAULT;
+        }
+
         Env<AttrContext> localEnv = methodEnv(tree, env);
 
         DeferredLintHandler prevLintHandler =
                 chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
         try {
             // Compute the method type
-            m.type = signature(tree.typarams, tree.params,
-                               tree.restype, tree.thrown,
+            m.type = signature(m, tree.typarams, tree.params,
+                               tree.restype, tree.recvparam,
+                               tree.thrown,
                                localEnv);
         } finally {
             chk.setDeferredLintHandler(prevLintHandler);
         }
 
+        if (types.isSignaturePolymorphic(m)) {
+            m.flags_field |= SIGNATURE_POLYMORPHIC;
+        }
+
         if ((enclScope.owner.flags_field & FROMCLASS) != 0) {
             for (Scope.Entry e = enclScope.lookup(tree.name); e.scope == enclScope; e = e.next()) {
                 if (e.sym.kind == MTH) {
@@ -670,7 +695,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                             localEnv = methodEnv(tree, env);
                             tree.sym.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, tree.sym, tree) | (tree.sym.flags_field & APT_CLEANED);
                             tree.sym.flags_field |= FROMCLASS;
-                            if (tree.sym.type.tag == FORALL) {
+                            if (tree.sym.type.hasTag(FORALL)) {
                                 for(List<Type> tvars = ((ForAll)tree.sym.type).tvars; tvars.nonEmpty(); tvars = tvars.tail)
                                     localEnv.info.scope.enter(tvars.head.tsym);
                             }
@@ -697,8 +722,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                             prevLintHandler =
                                     chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
                             try {
-                                tree.sym.type = signature(tree.typarams, tree.params,
-                                        tree.restype, tree.thrown,
+                                tree.sym.type = signature(tree.sym, tree.typarams, tree.params,
+                                        tree.restype, tree.recvparam, tree.thrown,
                                         localEnv);
                             } finally {
                                 chk.setDeferredLintHandler(prevLintHandler);
@@ -768,6 +793,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                 enclScope.enter(m);
         }
         annotateLater(tree.mods.annotations, localEnv, tree.sym);
+        // Visit the signature of the method. Note that
+        // TypeAnnotate doesn't descend into the body.
+        typeAnnotate(tree, localEnv, tree.sym);
+
         if (tree.defaultValue != null)
             annotateDefaultValueLater(tree.defaultValue, localEnv, tree.sym);
     }
@@ -781,6 +810,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             env.dup(tree, env.info.dup(env.info.scope.dupUnshared()));
         localEnv.enclMethod = tree;
         localEnv.info.scope.owner = tree.sym;
+        if (tree.sym.type != null) {
+            //when this is called in the enter stage, there's no type to be set
+            localEnv.info.returnResult = attr.new ResultInfo(VAL, tree.sym.type.getReturnType());
+        }
         if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++;
         return localEnv;
     }
@@ -795,17 +828,45 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         DeferredLintHandler prevLintHandler =
                 chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
         try {
-            attr.attribType(tree.vartype, localEnv);
+            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);
         }
 
+        if (tree.vartype.type != null && tree.vartype.type.hasTag(VOID)) {
+            log.error(tree.vartype, "illegal.start.of.type");
+            tree.vartype.type = syms.errType;
+        }
+
         if ((tree.mods.flags & VARARGS) != 0) {
             //if we are entering a varargs parameter, we need to replace its type
             //(a plain array type) with the more precise VarargsType --- we need
             //to do it this way because varargs is represented in the tree as a modifier
             //on the parameter declaration, and not as a distinct type of array node.
-            ArrayType atype = (ArrayType)tree.vartype.type;
+            ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType();
             tree.vartype.type = atype.makeVarargs();
         }
         Scope enclScope = enter.enterScope(env);
@@ -838,7 +899,9 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         tree.sym = v;
         if (tree.init != null) {
             v.flags_field |= HASINIT;
-            if ((v.flags_field & FINAL) != 0 && tree.init.getTag() != JCTree.NEWCLASS) {
+            if ((v.flags_field & FINAL) != 0 &&
+                    !tree.init.hasTag(NEWCLASS) &&
+                    !tree.init.hasTag(LAMBDA)) {
                 Env<AttrContext> initEnv = getInitEnv(tree, env);
                 initEnv.info.enclVar = v;
                 v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init);
@@ -853,8 +916,16 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             }
         }
         annotateLater(tree.mods.annotations, localEnv, v);
+        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
@@ -867,11 +938,11 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     Env<AttrContext> initEnv(JCVariableDecl tree, Env<AttrContext> env) {
         Env<AttrContext> localEnv = env.dupto(new AttrContextEnv(tree, env.info.dup()));
         if (tree.sym.owner.kind == TYP || tree.sym.owner.kind == ERR) {
-            localEnv.info.scope = new Scope.DelegatedScope(env.info.scope);
+            localEnv.info.scope = env.info.scope.dupUnshared();
             localEnv.info.scope.owner = tree.sym;
         }
         if ((tree.mods.flags & STATIC) != 0 ||
-            (env.enclClass.sym.flags() & INTERFACE) != 0)
+                ((env.enclClass.sym.flags() & INTERFACE) != 0 && env.enclMethod == null))
             localEnv.info.staticLevel++;
         return localEnv;
     }
@@ -887,13 +958,17 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     }
 
     public Env<AttrContext> getBaseEnv(JCClassDecl tree, Env<AttrContext> env) {
+        if (tree.sym == null)
+            return null;
         Env<AttrContext> bEnv = baseEnv(tree, env);
         return bEnv;
     }
 
     public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
+        if (tree.sym == null)
+            return null;
         Env<AttrContext> mEnv = methodEnv(tree, env);
-        mEnv.info.lint = mEnv.info.lint.augment(tree.sym.attributes_field, tree.sym.flags());
+        mEnv.info.lint = mEnv.info.lint.augment(tree.sym);
         for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail)
             mEnv.info.scope.enterIfAbsent(l.head.type.tsym);
         for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail)
@@ -902,6 +977,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     }
 
     public Env<AttrContext> getInitEnv(JCVariableDecl tree, Env<AttrContext> env) {
+        if (tree.sym == null)
+            return null;
         Env<AttrContext> iEnv = initEnv(tree, env);
         return iEnv;
     }
@@ -930,23 +1007,29 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     void annotateLater(final List<JCAnnotation> annotations,
                        final Env<AttrContext> localEnv,
                        final Symbol s) {
-        if (annotations.isEmpty()) return;
-        if (s.kind != PCK || (s.flags_field & APT_CLEANED) != 0) s.attributes_field = null; // mark it incomplete for now
-        annotate.later(new Annotate.Annotator() {
+        if (annotations.isEmpty()) {
+            return;
+        }
+        if (s.kind != PCK || (s.flags_field & APT_CLEANED) != 0) {
+            s.resetAnnotations(); // mark Annotations as incomplete for now
+        }
+        annotate.normal(new Annotate.Annotator() {
+                @Override
                 public String toString() {
                     return "annotate " + annotations + " onto " + s + " in " + s.owner;
                 }
+
+                @Override
                 public void enterAnnotation() {
-                    if (s.kind != PCK) s.attributes_field = null;
+                    Assert.check(s.kind == PCK || s.annotationsPendingCompletion());
                     JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
                     try {
-                        if (s.attributes_field != null &&
-                            s.attributes_field.nonEmpty() &&
+                        if (s.hasAnnotations() &&
                             annotations.nonEmpty())
                             log.error(annotations.head.pos,
                                       "already.annotated",
                                       kindName(s), s);
-                        enterAnnotations(annotations, localEnv, s);
+                        actualEnterAnnotations(annotations, localEnv, s);
                     } finally {
                         log.useSource(prev);
                     }
@@ -959,7 +1042,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
      * java.lang.Deprecated.
      **/
     private boolean hasDeprecatedAnnotation(List<JCAnnotation> annotations) {
-        for (List<JCAnnotation> al = annotations; al.nonEmpty(); al = al.tail) {
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
             JCAnnotation a = al.head;
             if (a.annotationType.type == syms.deprecatedType && a.args.isEmpty())
                 return true;
@@ -967,57 +1050,62 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
         return false;
     }
 
-
     /** Enter a set of annotations. */
-    private void enterAnnotations(List<JCAnnotation> annotations,
+    private void actualEnterAnnotations(List<JCAnnotation> annotations,
                           Env<AttrContext> env,
                           Symbol s) {
-        ListBuffer<Attribute.Compound> buf =
-            new ListBuffer<Attribute.Compound>();
-        Set<TypeSymbol> annotated = new HashSet<TypeSymbol>();
-        if (!skipAnnotations)
-        for (List<JCAnnotation> al = annotations; al.nonEmpty(); al = al.tail) {
+        Map<TypeSymbol, ListBuffer<Attribute.Compound>> annotated =
+                new LinkedHashMap<TypeSymbol, ListBuffer<Attribute.Compound>>();
+        Map<Attribute.Compound, DiagnosticPosition> pos =
+                new HashMap<Attribute.Compound, DiagnosticPosition>();
+
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
             JCAnnotation a = al.head;
             Attribute.Compound c = annotate.enterAnnotation(a,
                                                             syms.annotationType,
                                                             env);
-            if (c == null) continue;
-            buf.append(c);
+            if (c == null) {
+                continue;
+            }
+
+            if (annotated.containsKey(a.type.tsym)) {
+                if (source.allowRepeatedAnnotations()) {
+                    ListBuffer<Attribute.Compound> l = annotated.get(a.type.tsym);
+                    l = l.append(c);
+                    annotated.put(a.type.tsym, l);
+                    pos.put(c, a.pos());
+                } else {
+                    log.error(a.pos(), "duplicate.annotation");
+                }
+            } else {
+                annotated.put(a.type.tsym, ListBuffer.of(c));
+                pos.put(c, a.pos());
+            }
+
             // Note: @Deprecated has no effect on local variables and parameters
             if (!c.type.isErroneous()
                 && s.owner.kind != MTH
-                && types.isSameType(c.type, syms.deprecatedType))
+                && types.isSameType(c.type, syms.deprecatedType)) {
                 s.flags_field |= Flags.DEPRECATED;
-            // Internally to java.lang.invoke, a @PolymorphicSignature annotation
-            // acts like a classfile attribute.
-            if (!c.type.isErroneous() &&
-                    (types.isSameType(c.type, syms.polymorphicSignatureType) ||
-                     types.isSameType(c.type, syms.transientPolymorphicSignatureType))) {
-                if (!target.hasMethodHandles()) {
-                    // Somebody is compiling JDK7 source code to a JDK6 target.
-                    // Make it an error, since it is unlikely but important.
-                    log.error(env.tree.pos(),
-                            "wrong.target.for.polymorphic.signature.definition",
-                            target.name);
-                }
-                // Pull the flag through for better diagnostics, even on a bad target.
-                s.flags_field |= Flags.POLYMORPHIC_SIGNATURE;
             }
-            if (!annotated.add(a.type.tsym))
-                log.error(a.pos, "duplicate.annotation");
         }
-        s.attributes_field = buf.toList();
+
+        s.setDeclarationAttributesWithCompletion(
+                annotate.new AnnotateRepeatedContext<Attribute.Compound>(env, annotated, pos, log, false));
     }
 
     /** Queue processing of an attribute default value. */
     void annotateDefaultValueLater(final JCExpression defaultValue,
                                    final Env<AttrContext> localEnv,
                                    final MethodSymbol m) {
-        annotate.later(new Annotate.Annotator() {
+        annotate.normal(new Annotate.Annotator() {
+                @Override
                 public String toString() {
                     return "annotate " + m.owner + "." +
                         m + " default " + defaultValue;
                 }
+
+                @Override
                 public void enterAnnotation() {
                     JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
                     try {
@@ -1072,7 +1160,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             // If this is a toplevel-class, make sure any preceding import
             // clauses have been seen.
             if (c.owner.kind == PCK) {
-                memberEnter(env.toplevel, env.enclosing(JCTree.TOPLEVEL));
+                memberEnter(env.toplevel, env.enclosing(TOPLEVEL));
                 if ((c.flags_field & APT_CLEANED) != 0) {
                     todo.remove(c);
                 }
@@ -1088,40 +1176,34 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             Type supertype = null;
             ListBuffer<Type> interfaces = new ListBuffer<Type>();
             ListBuffer<Type> all_interfaces = null; // lazy init
-            
             DiagnosticPosition prevPos = deferredLintHandler.getPos();
             DeferredLintHandler prevLintHandler =
                     chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
             try {
+                if (tree.extending != null)
+                    typeAnnotate(tree.extending, baseEnv, sym);
+                for (JCExpression impl : tree.implementing)
+                    typeAnnotate(impl, baseEnv, sym);
+                annotate.flush();
+
                 // Determine supertype.
                 supertype =
                     (tree.extending != null)
                     ? attr.attribBase(tree.extending, baseEnv, true, false, true)
-                    : ((tree.mods.flags & Flags.ENUM) != 0 && !target.compilerBootstrap(c))
+                    : ((tree.mods.flags & Flags.ENUM) != 0)
                     ? attr.attribBase(enumBase(tree.pos, c), baseEnv,
                                       true, false, false)
                     : (c.fullname == names.java_lang_Object)
                     ? Type.noType
                     : syms.objectType;
                 ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
-                ct.supertype_field = supertype;
 
                 // Determine interfaces.
                 Set<Type> interfaceSet = new HashSet<Type>();
                 List<JCExpression> interfaceTrees = tree.implementing;
-                if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) {
-                    // add interface Comparable<T>
-                    interfaceTrees =
-                        interfaceTrees.prepend(make.Type(new ClassType(syms.comparableType.getEnclosingType(),
-                                                                       List.of(c.type),
-                                                                       syms.comparableType.tsym)));
-                    // add interface Serializable
-                    interfaceTrees =
-                        interfaceTrees.prepend(make.Type(syms.serializableType));
-                }
                 for (JCExpression iface : interfaceTrees) {
                     Type i = attr.attribBase(iface, baseEnv, false, true, true);
-                    if (i.tag == CLASS) {
+                    if (i.hasTag(CLASS)) {
                         interfaces.append(i);
                         if (all_interfaces != null) all_interfaces.append(i);
                         chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
@@ -1135,6 +1217,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                 deferredLintHandler.setPos(prevPos);
                 chk.setDeferredLintHandler(prevLintHandler);
             }
+            
             if ((c.flags_field & ANNOTATION) != 0) {
                 ct.interfaces_field = List.of(syms.annotationType);
                 ct.all_interfaces_field = ct.interfaces_field;
@@ -1165,6 +1248,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             if (hasDeprecatedAnnotation(tree.mods.annotations))
                 c.flags_field |= DEPRECATED;
             annotateLater(tree.mods.annotations, baseEnv, c);
+            // class type parameters use baseEnv but everything uses env
 
             chk.checkNonCyclicDecl(tree);
 
@@ -1173,6 +1257,10 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                     chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
             try {
                 attr.attribTypeVariables(tree.typarams, baseEnv);
+                // Do this here, where we have the symbol.
+                for (JCTypeParameter tp : tree.typarams)
+                    typeAnnotate(tp, baseEnv, sym);
+                annotate.flush();
             } finally {
                 deferredLintHandler.setPos(prevPos);
                 chk.setDeferredLintHandler(prevLintHandler);
@@ -1186,9 +1274,12 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                 List<Type> thrown = List.nil();
                 long ctorFlags = 0;
                 boolean based = false;
-                if (c.name.isEmpty()) {
-                    JCNewClass nc = (JCNewClass)env.next.tree;
+                boolean addConstructor = !c.type.isErroneous();
+                JCNewClass nc = null;
+                if (addConstructor && c.name.isEmpty()) {
+                    nc = (JCNewClass)env.next.tree;
                     if (nc.constructor != null) {
+                        addConstructor = nc.constructor.kind != ERR;
                         Type superConstrType = types.memberType(c.type,
                                                                 nc.constructor);
                         argtypes = superConstrType.getParameterTypes();
@@ -1201,38 +1292,44 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
                         thrown = superConstrType.getThrownTypes();
                     }
                 }
-                JCTree constrDef = DefaultConstructor(make.at(tree.pos), c,
-                                                    typarams, argtypes, thrown,
-                                                    ctorFlags, based);
-                tree.defs = tree.defs.prepend(constrDef);
-            }
-
-            // If this is a class, enter symbols for this and super into
-            // current scope.
-            if ((c.flags_field & INTERFACE) == 0) {
-                VarSymbol thisSym =
-                    new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
-                thisSym.pos = Position.FIRSTPOS;
-                env.info.scope.enter(thisSym);
-                if (ct.supertype_field.tag == CLASS) {
-                    VarSymbol superSym =
-                        new VarSymbol(FINAL | HASINIT, names._super,
-                                      ct.supertype_field, c);
-                    superSym.pos = Position.FIRSTPOS;
-                    env.info.scope.enter(superSym);
+                if (addConstructor) {
+                    MethodSymbol basedConstructor = nc != null ?
+                            (MethodSymbol)nc.constructor : null;
+                    JCTree constrDef = DefaultConstructor(make.at(tree.pos), c,
+                                                        basedConstructor,
+                                                        typarams, argtypes, thrown,
+                                                        ctorFlags, based);
+                    tree.defs = tree.defs.prepend(constrDef);
                 }
             }
 
+            // enter symbols for 'this' into current scope.
+            VarSymbol thisSym =
+                new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
+            thisSym.pos = Position.FIRSTPOS;
+            env.info.scope.enter(thisSym);
+            // if this is a class, enter symbol for 'super' into current scope.
+            if ((c.flags_field & INTERFACE) == 0 &&
+                    ct.supertype_field.hasTag(CLASS)) {
+                VarSymbol superSym =
+                    new VarSymbol(FINAL | HASINIT, names._super,
+                                  ct.supertype_field, c);
+                superSym.pos = Position.FIRSTPOS;
+                env.info.scope.enter(superSym);
+            }
+
             // check that no package exists with same fully qualified name,
             // but admit classes in the unnamed package which have the same
             // name as a top-level package.
             if (checkClash &&
                 c.owner.kind == PCK && c.owner != syms.unnamedPackage &&
-                reader.packageExists(c.fullname))
-                {
-                    log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c);
-                }
-
+                reader.packageExists(c.fullname)) {
+                log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c);
+            }
+            if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 &&
+                !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) {
+                c.flags_field |= AUXILIARY;
+            }
         } catch (CompletionFailure ex) {
             chk.completionError(tree.pos(), ex);
         } catch (Attr.BreakAttr br) {
@@ -1253,12 +1350,156 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             } finally {
                 isFirst = true;
             }
+        }
+        if (allowTypeAnnos) {
+            TypeAnnotations.organizeTypeAnnotationsSignatures(syms, names, log, tree, annotate);
+        }
+    }
 
-            // commit pending annotations
-            annotate.flush();
+    /*
+     * 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) {
+        Map<TypeSymbol, ListBuffer<Attribute.TypeCompound>> annotated =
+                new LinkedHashMap<TypeSymbol, ListBuffer<Attribute.TypeCompound>>();
+        Map<Attribute.TypeCompound, DiagnosticPosition> pos =
+                new HashMap<Attribute.TypeCompound, DiagnosticPosition>();
+
+        for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
+            JCAnnotation a = al.head;
+            Attribute.TypeCompound tc = annotate.enterTypeAnnotation(a,
+                    syms.annotationType,
+                    env);
+            if (tc == null) {
+                continue;
+            }
+
+            if (annotated.containsKey(a.type.tsym)) {
+                if (source.allowRepeatedAnnotations()) {
+                    ListBuffer<Attribute.TypeCompound> l = annotated.get(a.type.tsym);
+                    l = l.append(tc);
+                    annotated.put(a.type.tsym, l);
+                    pos.put(tc, a.pos());
+                } else {
+                    log.error(a.pos(), "duplicate.annotation");
+                }
+            } else {
+                annotated.put(a.type.tsym, ListBuffer.of(tc));
+                pos.put(tc, a.pos());
+            }
+        }
+
+        if (s != null) {
+            s.appendTypeAttributesWithCompletion(
+                    annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true));
         }
     }
 
+    public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym) {
+        if (allowTypeAnnos) {
+            tree.accept(new TypeAnnotate(env, sym));
+        }
+    }
+
+    /**
+     * We need to use a TreeScanner, because it is not enough to visit the top-level
+     * annotations. We also need to visit type arguments, etc.
+     */
+    private class TypeAnnotate extends TreeScanner {
+        private Env<AttrContext> env;
+        private Symbol sym;
+
+        public TypeAnnotate(final Env<AttrContext> env, final Symbol sym) {
+            this.env = env;
+            this.sym = sym;
+        }
+
+        void annotateTypeLater(final List<JCAnnotation> annotations) {
+            if (annotations.isEmpty()) {
+                return;
+            }
+
+            annotate.normal(new Annotate.Annotator() {
+                @Override
+                public String toString() {
+                    return "type annotate " + annotations + " onto " + sym + " in " + sym.owner;
+                }
+                @Override
+                public void enterAnnotation() {
+                    JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
+                    try {
+                        actualEnterTypeAnnotations(annotations, env, sym);
+                    } finally {
+                        log.useSource(prev);
+                    }
+                }
+            });
+        }
+
+        @Override
+        public void visitAnnotatedType(final JCAnnotatedType tree) {
+            annotateTypeLater(tree.annotations);
+            super.visitAnnotatedType(tree);
+        }
+
+        @Override
+        public void visitTypeParameter(final JCTypeParameter tree) {
+            annotateTypeLater(tree.annotations);
+            super.visitTypeParameter(tree);
+        }
+
+        @Override
+        public void visitNewArray(final JCNewArray tree) {
+            annotateTypeLater(tree.annotations);
+            for (List<JCAnnotation> dimAnnos : tree.dimAnnotations)
+                annotateTypeLater(dimAnnos);
+            super.visitNewArray(tree);
+        }
+
+        @Override
+        public void visitMethodDef(final JCMethodDecl tree) {
+            scan(tree.mods);
+            scan(tree.restype);
+            scan(tree.typarams);
+            scan(tree.recvparam);
+            scan(tree.params);
+            scan(tree.thrown);
+            scan(tree.defaultValue);
+            // 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);
+            }
+        }
+    }
+
+
     private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
         Scope baseScope = new Scope(tree.sym);
         //import already entered local classes into base scope
@@ -1268,11 +1509,14 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
             }
         }
         //import current type-parameters into base scope
-        if (tree.typarams != null)
+        if (tree.typarams != null) {
             for (List<JCTypeParameter> typarams = tree.typarams;
                  typarams.nonEmpty();
-                 typarams = typarams.tail)
-                baseScope.enter(typarams.head.type.tsym);
+                 typarams = typarams.tail) {
+                if (typarams.head != null && typarams.head.type != null)
+                    baseScope.enter(typarams.head.type.tsym);
+            }
+        }
         Env<AttrContext> outer = env.outer; // the base clause can't see members of this class
         Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(baseScope));
         localEnv.baseClause = true;
@@ -1306,9 +1550,12 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
     }
 
     Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) {
-        if (t.tag != ERROR)
+        if (!t.hasTag(ERROR))
             return t;
 
+        while (t.isAnnotated())
+            t = ((AnnotatedType)t).unannotatedType();
+        
         return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) {
             private Type modelType;
 
@@ -1351,7 +1598,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
 
         @Override
         public void visitIdent(JCIdent tree) {
-            if (tree.type.tag != ERROR) {
+            if (!tree.type.hasTag(ERROR)) {
                 result = tree.type;
             } else {
                 result = synthesizeClass(tree.name, syms.unnamedPackage).type;
@@ -1360,7 +1607,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
 
         @Override
         public void visitSelect(JCFieldAccess tree) {
-            if (tree.type.tag != ERROR) {
+            if (!tree.type.hasTag(ERROR)) {
                 result = tree.type;
             } else {
                 Type selectedType;
@@ -1378,19 +1625,22 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
 
         @Override
         public void visitTypeApply(JCTypeApply tree) {
-            if (tree.type.tag != ERROR) {
+            if (!tree.type.hasTag(ERROR)) {
                 result = tree.type;
             } else {
-                ClassType clazzType = (ClassType) visit(tree.clazz);
-                if (synthesizedSymbols.contains(clazzType.tsym))
-                    synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());
-                final List<Type> actuals = visit(tree.arguments);
-                result = new ErrorType(tree.type, clazzType.tsym) {
-                    @Override
-                    public List<Type> getTypeArguments() {
-                        return actuals;
-                    }
-                };
+                result = visit(tree.clazz);
+                if (result.hasTag(CLASS) || result.hasTag(ERROR)) {
+                    ClassType clazzType = (ClassType) result;
+                    if (synthesizedSymbols.contains(clazzType.tsym))
+                        synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());
+                    final List<Type> actuals = visit(tree.arguments);
+                    result = new ErrorType(tree.type, clazzType.tsym) {
+                        @Override
+                        public List<Type> getTypeArguments() {
+                            return actuals;
+                        }
+                    };
+                }
             }
         }
 
@@ -1449,35 +1699,78 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
      */
     JCTree DefaultConstructor(TreeMaker make,
                             ClassSymbol c,
+                            MethodSymbol baseInit,
                             List<Type> typarams,
                             List<Type> argtypes,
                             List<Type> thrown,
                             long flags,
                             boolean based) {
-        List<JCVariableDecl> params = make.Params(argtypes, syms.noSymbol);
-        List<JCStatement> stats = List.nil();
-        if (!c.type.isErroneous() && c.type != syms.objectType)
-            stats = stats.prepend(SuperCall(make, typarams, params, based));
+        JCTree result;
         if ((c.flags() & ENUM) != 0 &&
-            (types.supertype(c.type).tsym == syms.enumSym ||
-             target.compilerBootstrap(c))) {
+            (types.supertype(c.type).tsym == syms.enumSym)) {
             // constructors of true enums are private
             flags = (flags & ~AccessFlags) | PRIVATE | GENERATEDCONSTR;
         } else
             flags |= (c.flags() & AccessFlags) | GENERATEDCONSTR;
-        if (c.name.isEmpty()) flags |= ANONCONSTR;
-        JCTree result = make.MethodDef(
-            make.Modifiers(flags),
-            names.init,
-            null,
-            make.TypeParams(typarams),
-            params,
-            make.Types(thrown),
-            make.Block(0, stats),
-            null);
+        if (c.name.isEmpty()) {
+            flags |= ANONCONSTR;
+        }
+        Type mType = new MethodType(argtypes, null, thrown, c);
+        Type initType = typarams.nonEmpty() ?
+                new ForAll(typarams, mType) :
+                mType;
+        MethodSymbol init = new MethodSymbol(flags, names.init,
+                initType, c);
+        init.params = createDefaultConstructorParams(make, baseInit, init,
+                argtypes, based);
+        List<JCVariableDecl> params = make.Params(argtypes, init);
+        List<JCStatement> stats = List.nil();
+        if (c.type != syms.objectType) {
+            stats = stats.prepend(SuperCall(make, typarams, params, based));
+        }
+        result = make.MethodDef(init, make.Block(0, stats));
         return result;
     }
 
+    private List<VarSymbol> createDefaultConstructorParams(
+            TreeMaker make,
+            MethodSymbol baseInit,
+            MethodSymbol init,
+            List<Type> argtypes,
+            boolean based) {
+        List<VarSymbol> initParams = null;
+        List<Type> argTypesList = argtypes;
+        if (based) {
+            /*  In this case argtypes will have an extra type, compared to baseInit,
+             *  corresponding to the type of the enclosing instance i.e.:
+             *
+             *  Inner i = outer.new Inner(1){}
+             *
+             *  in the above example argtypes will be (Outer, int) and baseInit
+             *  will have parameter's types (int). So in this case we have to add
+             *  first the extra type in argtypes and then get the names of the
+             *  parameters from baseInit.
+             */
+            initParams = List.nil();
+            VarSymbol param = new VarSymbol(0, make.paramName(0), argtypes.head, init);
+            initParams = initParams.append(param);
+            argTypesList = argTypesList.tail;
+        }
+        if (baseInit != null && baseInit.params != null &&
+            baseInit.params.nonEmpty() && argTypesList.nonEmpty()) {
+            initParams = (initParams == null) ? List.<VarSymbol>nil() : initParams;
+            List<VarSymbol> baseInitParams = baseInit.params;
+            while (baseInitParams.nonEmpty() && argTypesList.nonEmpty()) {
+                VarSymbol param = new VarSymbol(baseInitParams.head.flags(),
+                        baseInitParams.head.name, argTypesList.head, init);
+                initParams = initParams.append(param);
+                baseInitParams = baseInitParams.tail;
+                argTypesList = argTypesList.tail;
+            }
+        }
+        return initParams;
+    }
+
     /** Generate call to superclass constructor. This is:
      *
      *    super(id_0, ..., id_n)
diff --git a/src/share/classes/com/sun/tools/javac/comp/Repair.java b/src/share/classes/com/sun/tools/javac/comp/Repair.java
index 9de7582..ba962cf 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Repair.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Repair.java
@@ -34,10 +34,10 @@ import com.sun.tools.javac.code.Symbol.MethodSymbol;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.code.TypeTags;
+import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.jvm.Pool;
-import com.sun.tools.javac.parser.Token;
+import com.sun.tools.javac.parser.Tokens;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCAssignOp;
 import com.sun.tools.javac.tree.JCTree.JCBinary;
@@ -46,6 +46,7 @@ import com.sun.tools.javac.tree.JCTree.JCCase;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCErroneous;
 import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
 import com.sun.tools.javac.tree.JCTree.JCImport;
 import com.sun.tools.javac.tree.JCTree.JCLiteral;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
@@ -71,6 +72,7 @@ import java.util.logging.Logger;
 import javax.lang.model.element.ElementKind;
 import javax.tools.JavaFileObject;
 
+
 /**
  *
  * @author Dusan Balek
@@ -99,6 +101,7 @@ public class Repair extends TreeTranslator {
     private TreeMaker make;
     private JCDiagnostic.Factory diags;
     private boolean allowEnums;
+    private boolean allowLambda;
     
     private Env<AttrContext> attrEnv;
     private boolean hasError;
@@ -123,6 +126,7 @@ public class Repair extends TreeTranslator {
         diags = JCDiagnostic.Factory.instance(context);
         Source source = Source.instance(context);
         allowEnums = source.allowEnums();
+        allowLambda = source.allowLambda();
     }
 
     @Override
@@ -144,7 +148,7 @@ public class Repair extends TreeTranslator {
         }
         if (tree.type != null && tree.type.isErroneous() || tree.type == syms.unknownType) {
             JCTree parent = parents.head;
-            if (parent == null || parent.getTag() != JCTree.CLASSDEF) {
+            if (parent == null || !parent.hasTag(JCTree.Tag.CLASSDEF)) {
                 hasError = true;
                 if (err == null && errMessage == null)
                     errMessage = "Erroneous tree type: " + tree.type;
@@ -152,18 +156,18 @@ public class Repair extends TreeTranslator {
         }
         if (!(hasError && tree instanceof JCStatement))
             return tree;
-        if (tree.getTag() == JCTree.CASE)
+        if (tree.hasTag(JCTree.Tag.CASE))
             return tree;
-        if (tree.getTag() == JCTree.CLASSDEF || tree.getTag() == JCTree.VARDEF) {
+        if (tree.hasTag(JCTree.Tag.CLASSDEF) || tree.hasTag(JCTree.Tag.VARDEF)) {
             JCTree parent = parents.head;
-            if (parent == null || (parent.getTag() != JCTree.BLOCK && parent.getTag() != JCTree.CASE))
+            if (parent == null || (!parent.hasTag(JCTree.Tag.BLOCK) && !parent.hasTag(JCTree.Tag.CASE)))
                 return tree;
         }
         String msg = err != null ? err.getMessage(null) : errMessage;
         hasError = false;
         err = null;
         errMessage = null;
-        if (tree.getTag() == JCTree.BLOCK) {
+        if (tree.hasTag(JCTree.Tag.BLOCK)) {
             ((JCBlock)tree).stats = List.of(generateErrStat(tree.pos(), msg));
             return tree;
         }
@@ -182,8 +186,8 @@ public class Repair extends TreeTranslator {
     @Override
     public void visitTypeParameter(JCTypeParameter tree) {
         super.visitTypeParameter(tree);
-        if (tree.type != null && tree.type.tag == TypeTags.TYPEVAR) {
-            Type.TypeVar tv = (Type.TypeVar)tree.type;
+        if (tree.type != null && tree.type.hasTag(TypeTag.TYPEVAR)) {
+            Type.TypeVar tv = (Type.TypeVar)tree.type.unannotatedType();
             if (tv.bound != null && tv.bound.isErroneous() || tv.bound == syms.unknownType) {
                 if (err == null && errMessage == null)
                     errMessage = "Erroneous type var bound: " + tv.bound;
@@ -208,7 +212,7 @@ public class Repair extends TreeTranslator {
         }
         if (hasError) {
             JCTree parent = parents != null ? parents.tail.head : null;
-            if (parent != null && parent.getTag() == JCTree.CLASSDEF) {
+            if (parent != null && parent.hasTag(JCTree.Tag.CLASSDEF)) {
                 tree.init = err != null ? generateErrExpr(err.getTree(), err.getMessage(null)) : generateErrExpr(tree.init, errMessage);
                 hasError = false;
                 err = null;
@@ -218,7 +222,7 @@ public class Repair extends TreeTranslator {
             }
         } else if (tree.sym == null) {
             JCTree parent = parents != null ? parents.tail.head : null;
-            if (parent != null && parent.getTag() != JCTree.CLASSDEF) {
+            if (parent != null && !parent.hasTag(JCTree.Tag.CLASSDEF)) {
                 hasError = true;
                 if (err == null && errMessage == null)
                     errMessage = "Null tree sym: " + tree;
@@ -240,9 +244,7 @@ public class Repair extends TreeTranslator {
         if (isErrClass && tree.body != null) {
             JCMethodInvocation app = TreeInfo.firstConstructorCall(tree);
             Name meth = app != null ? TreeInfo.name(app.meth) : null;
-            Symbol sym = app != null ? TreeInfo.symbol(app.meth) : null;
-            if (meth != null && (meth == meth.table.names._this || meth == meth.table.names._super)
-                    && sym != null && sym.owner.getQualifiedName() != meth.table.names.java_lang_Enum)
+            if (meth != null && (meth == meth.table.names._this || meth == meth.table.names._super))
                 tree.body.stats.tail = List.<JCStatement>nil();
             else
                 tree.body.stats = List.<JCStatement>nil();
@@ -272,7 +274,7 @@ public class Repair extends TreeTranslator {
         List<JCStatement> last = null;
         for (List<JCStatement> l = tree.stats; l.nonEmpty(); l = l.tail) {
             l.head = translate(l.head);
-            if (last == null && l.head.getTag() == JCTree.THROW)
+            if (last == null && l.head.hasTag(JCTree.Tag.THROW))
                 last = l;
         }
         if (last != null)
@@ -362,7 +364,7 @@ public class Repair extends TreeTranslator {
         List<JCStatement> last = null;
         for (List<JCStatement> l = tree.stats; l.nonEmpty(); l = l.tail) {
             l.head = translate(l.head);
-            if (last == null && l.head.getTag() == JCTree.THROW)
+            if (last == null && l.head.hasTag(JCTree.Tag.THROW))
                 last = l;
         }
         if (last != null)
@@ -371,15 +373,31 @@ public class Repair extends TreeTranslator {
     }
 
     @Override
+    public void visitLambda(JCTree.JCLambda tree) {        
+        if (!allowLambda) {
+            hasError = true;
+        }
+        super.visitLambda(tree);
+    }
+
+    @Override
+    public void visitReference(JCTree.JCMemberReference tree) {
+        if (!allowLambda) {
+            hasError = true;
+        }
+        super.visitReference(tree);
+    }
+
+    @Override
     public void visitErroneous(JCErroneous tree) {
         hasError = true;
         result = tree;
     }
-    
+
     private JCStatement generateErrStat(DiagnosticPosition pos, String msg) {
         make.at(pos);
         ClassType ctype = (ClassType)syms.runtimeExceptionType;
-        Symbol ctor = rs.resolveConstructor(pos, attrEnv, ctype, List.of(syms.stringType), null, false, false);
+        Symbol ctor = rs.resolveConstructor(pos, attrEnv, ctype, List.of(syms.stringType), null);
         if (ctor.kind == Kinds.MTH) {
             JCLiteral literal = make.Literal(msg != null ? ERR_MESSAGE + " - " + msg : ERR_MESSAGE); //NOI18N
             JCNewClass tree = make.NewClass(null, null, make.QualIdent(ctype.tsym), List.<JCExpression>of(literal), null);
@@ -387,7 +405,7 @@ public class Repair extends TreeTranslator {
             tree.constructor = ctor;
             return make.Throw(tree);
         }
-        ctor = rs.resolveConstructor(pos, attrEnv, ctype, List.<Type>nil(), null, false, false);
+        ctor = rs.resolveConstructor(pos, attrEnv, ctype, List.<Type>nil(), null);
         if (ctor.kind == Kinds.MTH) {
             JCNewClass tree = make.NewClass(null, null, make.QualIdent(ctype.tsym), List.<JCExpression>nil(), null);
             tree.type = ctype;
@@ -413,12 +431,26 @@ public class Repair extends TreeTranslator {
         make.at(null);
         return make.MethodDef(sym, make.Block(0, List.<JCStatement>of(generateErrStat(null, null))));
     }
+    
+    private JCExpressionStatement generateFakeConstructorCall(MethodSymbol ctor) {
+        make.at(null);
+        JCTree.JCIdent ident = make.Ident(syms.objectType.tsym.name.table.names._this);
+        ident.sym = ctor;
+        ident.type = ctor.type;
+        List<JCExpression> args = List.nil();
+        for (Symbol.VarSymbol param : ((MethodSymbol)ctor).params().reverse()) {
+            args = args.prepend(make.Ident(param));
+        }
+        JCMethodInvocation meth = make.Apply(List.<JCExpression>nil(), ident, args);
+        meth.type = ctor.type.getReturnType();
+        return make.Exec(meth);
+    }
 
     private void translateClass(ClassSymbol c) {
         if (c == null)
             return;
         Type st = types.supertype(c.type);
-        if (st != null && st.tag == TypeTags.CLASS)
+        if (st != null && st.hasTag(TypeTag.CLASS))
             translateClass((ClassSymbol)st.tsym);
         LOGGER.finest("Repair.translateClass: " + c); //NOI18N
         if (repairedClasses.contains(c)) {
@@ -473,7 +505,7 @@ public class Repair extends TreeTranslator {
                             log.currentSource(),
                             tree,
                             "expected",         //NOI18N
-                            Token.IDENTIFIER);
+                            Tokens.TokenKind.IDENTIFIER);
                 } else if (fixedTopLevelName != null) {
                     c.fullname = Symbol.TypeSymbol.formFullName(c.name, enclosingElement);
                     c.flatname = Symbol.TypeSymbol.formFlatName(c.name, enclosingElement);
@@ -511,11 +543,11 @@ public class Repair extends TreeTranslator {
                     }
                     List<JCTree> last = null;
                     for (List<JCTree> l = tree.defs; l != null && l.nonEmpty(); l = l.tail) {
-                        if (l.head.getTag() == JCTree.METHODDEF)
+                        if (l.head.hasTag(JCTree.Tag.METHODDEF))
                             nonAbstractMethods.remove(((JCMethodDecl)l.head).sym);
                         hasError = false;
                         err = null;
-                        if (l.head.getTag() == JCTree.CLASSDEF && ((JCClassDecl)l.head).name == c.name.table.names.error) {
+                        if (l.head.hasTag(JCTree.Tag.CLASSDEF) && ((JCClassDecl)l.head).name == c.name.table.names.error) {
                             Scope.Entry prev = null;
                             for (Scope.Entry e = tree.sym.members_field.elems; e != null; e = e.sibling) {
                                 if (e.sym == ((JCClassDecl)l.head).sym) {
@@ -536,12 +568,17 @@ public class Repair extends TreeTranslator {
                                 tree.defs = l.tail;
                         } else {
                             l.head = translate(l.head);
-                            if ((l.head.getTag() == JCTree.METHODDEF && ((JCMethodDecl)l.head).sym == null)
-                                    || (l.head.getTag() == JCTree.VARDEF && ((JCVariableDecl)l.head).sym == null)) {
+                            if ((l.head.hasTag(JCTree.Tag.METHODDEF) && ((JCMethodDecl)l.head).sym == null)
+                                    || (l.head.hasTag(JCTree.Tag.VARDEF) && ((JCVariableDecl)l.head).sym == null)) {
                                 hasError = true;
+                            } else if (c.type != syms.objectType && l.head.hasTag(JCTree.Tag.METHODDEF)
+                                    && ((JCMethodDecl)l.head).body != null
+                                    && ((JCMethodDecl)l.head).name == ((JCMethodDecl)l.head).name.table.names.init
+                                    && TreeInfo.firstConstructorCall(l.head) == null) {
+                                ((JCMethodDecl)l.head).body.stats = ((JCMethodDecl)l.head).body.stats.append(generateFakeConstructorCall(((JCMethodDecl)l.head).sym));
                             }
                             if (hasError) {
-                                if (l.head.getTag() == JCTree.CLASSDEF && tree.sym.members_field.includes(((JCClassDecl)l.head).sym)) {
+                                if (l.head.hasTag(JCTree.Tag.CLASSDEF) && tree.sym.members_field.includes(((JCClassDecl)l.head).sym)) {
                                     last = l;
                                 } else {
                                     if (last != null)
diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
index bd43f6a..3bf2759 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,29 +25,49 @@
 
 package com.sun.tools.javac.comp;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.api.Formattable.LocalizedString;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.comp.Attr.ResultInfo;
+import com.sun.tools.javac.comp.Check.CheckContext;
+import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
+import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
+import com.sun.tools.javac.comp.DeferredAttr.DeferredType;
+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.api.Formattable.LocalizedString;
-import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
-
-import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
-
-import static com.sun.tools.javac.code.Flags.*;
-import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
+import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
+import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
-import javax.lang.model.element.ElementVisitor;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.HashSet;
+
+import javax.lang.model.element.ElementVisitor;
+
+import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.BLOCK;
+import static com.sun.tools.javac.code.Kinds.*;
+import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
+import static com.sun.tools.javac.code.TypeTag.*;
+import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
  *
@@ -63,6 +83,8 @@ public class Resolve {
     Names names;
     Log log;
     Symtab syms;
+    Attr attr;
+    DeferredAttr deferredAttr;
     Check chk;
     Infer infer;
     ClassReader reader;
@@ -72,28 +94,21 @@ public class Resolve {
     public final boolean boxingEnabled; // = source.allowBoxing();
     public final boolean varargsEnabled; // = source.allowVarargs();
     public final boolean allowMethodHandles;
+    public final boolean allowDefaultMethods;
+    public final boolean allowStructuralMostSpecific;
     private final boolean debugResolve;
+    private final boolean compactMethodDiags;
+    final EnumSet<VerboseResolutionMode> verboseResolutionMode;
     private final boolean ideMode;
 
     Scope polymorphicSignatureScope;
 
-    public static Resolve instance(Context context) {
-        Resolve instance = context.get(resolveKey);
-        if (instance == null)
-            instance = new Resolve(context);
-        return instance;
-    }
-
     protected Resolve(Context context) {
         context.put(resolveKey, this);
         syms = Symtab.instance(context);
 
         varNotFound = new
             SymbolNotFoundError(ABSENT_VAR);
-        wrongMethod = new
-            InapplicableSymbolError(syms.errSymbol);
-        wrongMethods = new
-            InapplicableSymbolsError(syms.errSymbol);
         methodNotFound = new
             SymbolNotFoundError(ABSENT_MTH);
         typeNotFound = new
@@ -101,6 +116,8 @@ public class Resolve {
 
         names = Names.instance(context);
         log = Log.instance(context);
+        attr = Attr.instance(context);
+        deferredAttr = DeferredAttr.instance(context);
         chk = Check.instance(context);
         infer = Infer.instance(context);
         reader = ClassReader.instance(context);
@@ -112,8 +129,13 @@ public class Resolve {
         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();
+        allowDefaultMethods = source.allowDefaultMethods();
+        allowStructuralMostSpecific = source.allowStructuralMostSpecific();
         polymorphicSignatureScope = new Scope(syms.noSymbol);
 
         inapplicableMethodException = new InapplicableMethodException(diags);
@@ -122,11 +144,120 @@ public class Resolve {
 
     /** error symbols, which are returned when resolution fails
      */
-    final SymbolNotFoundError varNotFound;
-    final InapplicableSymbolError wrongMethod;
-    final InapplicableSymbolsError wrongMethods;
-    final SymbolNotFoundError methodNotFound;
-    final SymbolNotFoundError typeNotFound;
+    private final SymbolNotFoundError varNotFound;
+    private final SymbolNotFoundError methodNotFound;
+    private final SymbolNotFoundError typeNotFound;
+
+    public static Resolve instance(Context context) {
+        Resolve instance = context.get(resolveKey);
+        if (instance == null)
+            instance = new Resolve(context);
+        return instance;
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="Verbose resolution diagnostics support">
+    enum VerboseResolutionMode {
+        SUCCESS("success"),
+        FAILURE("failure"),
+        APPLICABLE("applicable"),
+        INAPPLICABLE("inapplicable"),
+        DEFERRED_INST("deferred-inference"),
+        PREDEF("predef"),
+        OBJECT_INIT("object-init"),
+        INTERNAL("internal");
+
+        final String opt;
+
+        private VerboseResolutionMode(String opt) {
+            this.opt = opt;
+        }
+
+        static EnumSet<VerboseResolutionMode> getVerboseResolutionMode(Options opts) {
+            String s = opts.get("verboseResolution");
+            EnumSet<VerboseResolutionMode> res = EnumSet.noneOf(VerboseResolutionMode.class);
+            if (s == null) return res;
+            if (s.contains("all")) {
+                res = EnumSet.allOf(VerboseResolutionMode.class);
+            }
+            Collection<String> args = Arrays.asList(s.split(","));
+            for (VerboseResolutionMode mode : values()) {
+                if (args.contains(mode.opt)) {
+                    res.add(mode);
+                } else if (args.contains("-" + mode.opt)) {
+                    res.remove(mode);
+                }
+            }
+            return res;
+        }
+    }
+
+    void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
+            List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
+        boolean success = bestSoFar.kind < ERRONEOUS;
+
+        if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
+            return;
+        } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
+            return;
+        }
+
+        if (bestSoFar.name == names.init &&
+                bestSoFar.owner == syms.objectType.tsym &&
+                !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
+            return; //skip diags for Object constructor resolution
+        } else if (site == syms.predefClass.type &&
+                !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
+            return; //skip spurious diags for predef symbols (i.e. operators)
+        } else if (currentResolutionContext.internalResolution &&
+                !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
+            return;
+        }
+
+        int pos = 0;
+        int mostSpecificPos = -1;
+        ListBuffer<JCDiagnostic> subDiags = ListBuffer.lb();
+        for (Candidate c : currentResolutionContext.candidates) {
+            if (currentResolutionContext.step != c.step ||
+                    (c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE)) ||
+                    (!c.isApplicable() && !verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))) {
+                continue;
+            } else {
+                subDiags.append(c.isApplicable() ?
+                        getVerboseApplicableCandidateDiag(pos, c.sym, c.mtype) :
+                        getVerboseInapplicableCandidateDiag(pos, c.sym, c.details));
+                if (c.sym == bestSoFar)
+                    mostSpecificPos = pos;
+                pos++;
+            }
+        }
+        String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
+        List<Type> argtypes2 = Type.map(argtypes,
+                    deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, bestSoFar, currentResolutionContext.step));
+        JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name,
+                site.tsym, mostSpecificPos, currentResolutionContext.step,
+                methodArguments(argtypes2),
+                methodArguments(typeargtypes));
+        JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
+        log.report(d);
+    }
+
+    JCDiagnostic getVerboseApplicableCandidateDiag(int pos, Symbol sym, Type inst) {
+        JCDiagnostic subDiag = null;
+        if (sym.type.hasTag(FORALL)) {
+            subDiag = diags.fragment("partial.inst.sig", inst);
+        }
+
+        String key = subDiag == null ?
+                "applicable.method.found" :
+                "applicable.method.found.1";
+
+        return diags.fragment(key, pos, sym, subDiag);
+    }
+
+    JCDiagnostic getVerboseInapplicableCandidateDiag(int pos, Symbol sym, JCDiagnostic subDiag) {
+        return diags.fragment("not.applicable.method.found", pos, sym, subDiag);
+    }
+    // </editor-fold>
 
 /* ************************************************************************
  * Identifier resolution
@@ -217,12 +348,12 @@ public class Resolve {
     }
 
     boolean isAccessible(Env<AttrContext> env, Type t, boolean checkInner) {
-        return (t.tag == ARRAY)
-            ? isAccessible(env, types.elemtype(t))
+        return (t.hasTag(ARRAY))
+            ? isAccessible(env, types.upperBound(types.elemtype(t)))
             : isAccessible(env, t.tsym, checkInner);
     }
 
-    /** Is symbol accessible as a member of given type in given evironment?
+    /** Is symbol accessible as a member of given type in given environment?
      *  @param env    The current environment.
      *  @param site   The type of which the tested symbol is regarded
      *                as a member.
@@ -285,7 +416,6 @@ public class Resolve {
         else {
             Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true);
             return (s2 == null || s2 == sym || sym.owner == s2.owner ||
-                    s2.isPolymorphicSignatureGeneric() ||
                     !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym)));
         }
     }
@@ -309,12 +439,66 @@ public class Resolve {
             return c != null;
         }
 
+    /**
+     * Performs a recursive scan of a type looking for accessibility problems
+     * from current attribution environment
+     */
+    void checkAccessibleType(Env<AttrContext> env, Type t) {
+        accessibilityChecker.visit(t, env);
+    }
+
+    /**
+     * Accessibility type-visitor
+     */
+    Types.SimpleVisitor<Void, Env<AttrContext>> accessibilityChecker =
+            new Types.SimpleVisitor<Void, Env<AttrContext>>() {
+
+        void visit(List<Type> ts, Env<AttrContext> env) {
+            for (Type t : ts) {
+                visit(t, env);
+            }
+        }
+
+        public Void visitType(Type t, Env<AttrContext> env) {
+            return null;
+        }
+
+        @Override
+        public Void visitArrayType(ArrayType t, Env<AttrContext> env) {
+            visit(t.elemtype, env);
+            return null;
+        }
+
+        @Override
+        public Void visitClassType(ClassType t, Env<AttrContext> env) {
+            visit(t.getTypeArguments(), env);
+            if (!isAccessible(env, t, true)) {
+                accessBase(new AccessError(t.tsym), env.tree.pos(), env.enclClass.sym, t, t.tsym.name, true);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitWildcardType(WildcardType t, Env<AttrContext> env) {
+            visit(t.type, env);
+            return null;
+        }
+
+        @Override
+        public Void visitMethodType(MethodType t, Env<AttrContext> env) {
+            visit(t.getParameterTypes(), env);
+            visit(t.getReturnType(), env);
+            visit(t.getThrownTypes(), env);
+            return null;
+        }
+    };
+
     /** Try to instantiate the type of a method so that it fits
-     *  given type arguments and argument types. If succesful, return
+     *  given type arguments and argument types. If successful, return
      *  the method's instantiated type, else return null.
      *  The instantiation will take into account an additional leading
      *  formal parameter if the method is an instance method seen as a member
-     *  of un underdetermined site In this case, we treat site as an additional
+     *  of an under determined site. In this case, we treat site as an additional
      *  parameter and the parameters of the class containing the method as
      *  additional type variables that get instantiated.
      *
@@ -329,29 +513,22 @@ public class Resolve {
     Type rawInstantiate(Env<AttrContext> env,
                         Type site,
                         Symbol m,
+                        ResultInfo resultInfo,
                         List<Type> argtypes,
                         List<Type> typeargtypes,
                         boolean allowBoxing,
                         boolean useVarargs,
-                        Warner warn)
-        throws Infer.InferenceException {
-        boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles;
-        if (useVarargs && (m.flags() & VARARGS) == 0)
-            throw inapplicableMethodException.setMessage();
-        Type mt = types.memberType(site, m);
+                        Warner warn) throws Infer.InferenceException {
 
+        Type mt = types.memberType(site, m);
         // tvars is the list of formal type variables for which type arguments
         // need to inferred.
-        List<Type> tvars = null;
-        if (env.info.tvars != null) {
-            tvars = types.newInstances(env.info.tvars);
-            mt = types.subst(mt, env.info.tvars, tvars);
-        }
+        List<Type> tvars = List.nil();
         if (typeargtypes == null) typeargtypes = List.nil();
-        if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
+        if (!mt.hasTag(FORALL) && typeargtypes.nonEmpty()) {
             // This is not a polymorphic method, but typeargs are supplied
             // which is fine, see JLS 15.12.2.1
-        } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) {
+        } else if (mt.hasTag(FORALL) && typeargtypes.nonEmpty()) {
             ForAll pmt = (ForAll) mt;
             if (typeargtypes.length() != pmt.tvars.length())
                 throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
@@ -368,7 +545,7 @@ public class Resolve {
                 actuals = actuals.tail;
             }
             mt = types.subst(pmt.qtype, pmt.tvars, typeargtypes);
-        } else if (mt.tag == FORALL) {
+        } else if (mt.hasTag(FORALL)) {
             ForAll pmt = (ForAll) mt;
             List<Type> tvars1 = types.newInstances(pmt.tvars);
             tvars = tvars.appendList(tvars1);
@@ -376,240 +553,783 @@ public class Resolve {
         }
 
         // find out whether we need to go the slow route via infer
-        boolean instNeeded = tvars.tail != null || /*inlined: tvars.nonEmpty()*/
-                polymorphicSignature;
+        boolean instNeeded = tvars.tail != null; /*inlined: tvars.nonEmpty()*/
         for (List<Type> l = argtypes;
              l.tail != null/*inlined: l.nonEmpty()*/ && !instNeeded;
              l = l.tail) {
-            if (l.head.tag == FORALL) instNeeded = true;
+            if (l.head.hasTag(FORALL)) instNeeded = true;
         }
 
         if (instNeeded)
-            return polymorphicSignature ?
-                infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes) :
-                infer.instantiateMethod(env,
+            return infer.instantiateMethod(env,
                                     tvars,
                                     (MethodType)mt,
+                                    resultInfo,
                                     m,
                                     argtypes,
                                     allowBoxing,
                                     useVarargs,
+                                    currentResolutionContext,
                                     warn);
 
-        checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(),
-                                allowBoxing, useVarargs, warn);
+        currentResolutionContext.methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn),
+                                argtypes, mt.getParameterTypes(), warn);
         return mt;
     }
 
+    Type checkMethod(Env<AttrContext> env,
+                     Type site,
+                     Symbol m,
+                     ResultInfo resultInfo,
+                     List<Type> argtypes,
+                     List<Type> typeargtypes,
+                     Warner warn) {
+        MethodResolutionContext prevContext = currentResolutionContext;
+        try {
+            currentResolutionContext = new MethodResolutionContext();
+            currentResolutionContext.attrMode = DeferredAttr.AttrMode.CHECK;
+            if (env.tree.hasTag(JCTree.Tag.REFERENCE)) {
+                //method/constructor references need special check class
+                //to handle inference variables in 'argtypes' (might happen
+                //during an unsticking round)
+                currentResolutionContext.methodCheck =
+                        new MethodReferenceCheck(resultInfo.checkContext.inferenceContext());
+            }
+            MethodResolutionPhase step = currentResolutionContext.step = env.info.pendingResolutionPhase;
+            return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
+                    step.isBoxingRequired(), step.isVarargsRequired(), warn);
+        }
+        finally {
+            currentResolutionContext = prevContext;
+        }
+    }
+
     /** Same but returns null instead throwing a NoInstanceException
      */
     Type instantiate(Env<AttrContext> env,
                      Type site,
                      Symbol m,
+                     ResultInfo resultInfo,
                      List<Type> argtypes,
                      List<Type> typeargtypes,
                      boolean allowBoxing,
                      boolean useVarargs,
                      Warner warn) {
         try {
-            return rawInstantiate(env, site, m, argtypes, typeargtypes,
+            return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
                                   allowBoxing, useVarargs, warn);
         } catch (InapplicableMethodException ex) {
             return null;
         }
     }
 
-    /** Check if a parameter list accepts a list of args.
+    /**
+     * This interface defines an entry point that should be used to perform a
+     * method check. A method check usually consist in determining as to whether
+     * a set of types (actuals) is compatible with another set of types (formals).
+     * Since the notion of compatibility can vary depending on the circumstances,
+     * this interfaces allows to easily add new pluggable method check routines.
      */
-    boolean argumentsAcceptable(Env<AttrContext> env,
+    interface MethodCheck {
+        /**
+         * Main method check routine. A method check usually consist in determining
+         * as to whether a set of types (actuals) is compatible with another set of
+         * types (formals). If an incompatibility is found, an unchecked exception
+         * is assumed to be thrown.
+         */
+        void argumentsAcceptable(Env<AttrContext> env,
+                                DeferredAttrContext deferredAttrContext,
                                 List<Type> argtypes,
                                 List<Type> formals,
-                                boolean allowBoxing,
-                                boolean useVarargs,
-                                Warner warn) {
-        try {
-            checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn);
-            return true;
-        } catch (InapplicableMethodException ex) {
-            return false;
-        }
+                                Warner warn);
+
+        /**
+         * Retrieve the method check object that will be used during a
+         * most specific check.
+         */
+        MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict);
     }
-    void checkRawArgumentsAcceptable(Env<AttrContext> env,
-                                List<Type> argtypes,
-                                List<Type> formals,
-                                boolean allowBoxing,
-                                boolean useVarargs,
-                                Warner warn) {
-        Type varargsFormal = useVarargs ? formals.last() : null;
-        if (varargsFormal == null &&
-                argtypes.size() != formals.size()) {
-            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
-        }
-
-        while (argtypes.nonEmpty() && formals.nonEmpty() && formals.head != varargsFormal) {
-            boolean works = allowBoxing
-                ? types.isConvertible(argtypes.head, formals.head, warn)
-                : types.isSubtypeUnchecked(argtypes.head, formals.head, warn);
-            if (!works)
-                throw inapplicableMethodException.setMessage("no.conforming.assignment.exists",
-                        argtypes.head,
-                        formals.head);
-            argtypes = argtypes.tail;
-            formals = formals.tail;
-        }
-
-        if (formals.head != varargsFormal)
-            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
-
-        if (useVarargs) {
-            Type elt = types.elemtype(varargsFormal);
-            while (argtypes.nonEmpty()) {
-                if (!types.isConvertible(argtypes.head, elt, warn))
-                    throw inapplicableMethodException.setMessage("varargs.argument.mismatch",
-                            argtypes.head,
-                            elt);
-                argtypes = argtypes.tail;
-            }
-            //check varargs element type accessibility
-            if (!isAccessible(env, elt)) {
-                Symbol location = env.enclClass.sym;
-                throw inapplicableMethodException.setMessage("inaccessible.varargs.type",
-                            elt,
-                            Kinds.kindName(location),
-                            location);
-            }
+
+    /**
+     * Helper enum defining all method check diagnostics (used by resolveMethodCheck).
+     */
+    enum MethodCheckDiag {
+        /**
+         * Actuals and formals differs in length.
+         */
+        ARITY_MISMATCH("arg.length.mismatch", "infer.arg.length.mismatch"),
+        /**
+         * An actual is incompatible with a formal.
+         */
+        ARG_MISMATCH("no.conforming.assignment.exists", "infer.no.conforming.assignment.exists"),
+        /**
+         * An actual is incompatible with the varargs element type.
+         */
+        VARARG_MISMATCH("varargs.argument.mismatch", "infer.varargs.argument.mismatch"),
+        /**
+         * The varargs element type is inaccessible.
+         */
+        INACCESSIBLE_VARARGS("inaccessible.varargs.type", "inaccessible.varargs.type");
+
+        final String basicKey;
+        final String inferKey;
+
+        MethodCheckDiag(String basicKey, String inferKey) {
+            this.basicKey = basicKey;
+            this.inferKey = inferKey;
+        }
+
+        String regex() {
+            return String.format("([a-z]*\\.)*(%s|%s)", basicKey, inferKey);
         }
-        return;
     }
-    // where
-        public static class InapplicableMethodException extends RuntimeException {
-            private static final long serialVersionUID = 0;
 
-            JCDiagnostic diagnostic;
-            JCDiagnostic.Factory diags;
+    /**
+     * Dummy method check object. All methods are deemed applicable, regardless
+     * of their formal parameter types.
+     */
+    MethodCheck nilMethodCheck = new MethodCheck() {
+        public void argumentsAcceptable(Env<AttrContext> env, DeferredAttrContext deferredAttrContext, List<Type> argtypes, List<Type> formals, Warner warn) {
+            //do nothing - method always applicable regardless of actuals
+        }
 
-            InapplicableMethodException(JCDiagnostic.Factory diags) {
-                this.diagnostic = null;
-                this.diags = diags;
-            }
-            InapplicableMethodException setMessage() {
-                this.diagnostic = null;
-                return this;
-            }
-            InapplicableMethodException setMessage(String key) {
-                this.diagnostic = key != null ? diags.fragment(key) : null;
-                return this;
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return this;
+        }
+    };
+
+    /**
+     * Base class for 'real' method checks. The class defines the logic for
+     * iterating through formals and actuals and provides and entry point
+     * that can be used by subclasses in order to define the actual check logic.
+     */
+    abstract class AbstractMethodCheck implements MethodCheck {
+        @Override
+        public void argumentsAcceptable(final Env<AttrContext> env,
+                                    DeferredAttrContext deferredAttrContext,
+                                    List<Type> argtypes,
+                                    List<Type> formals,
+                                    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;
+
+            Type varargsFormal = useVarargs ? formals.last() : null;
+
+            if (varargsFormal == null &&
+                    argtypes.size() != formals.size()) {
+                reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
             }
-            InapplicableMethodException setMessage(String key, Object... args) {
-                this.diagnostic = key != null ? diags.fragment(key, args) : null;
-                return this;
+
+            while (argtypes.nonEmpty() && formals.nonEmpty() && formals.head != varargsFormal) {
+                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;
             }
-            InapplicableMethodException setMessage(JCDiagnostic diag) {
-                this.diagnostic = diag;
-                return this;
+
+            if (formals.head != varargsFormal) {
+                reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
             }
 
-            public JCDiagnostic getDiagnostic() {
-                return diagnostic;
+            if (useVarargs) {
+                //note: if applicability check is triggered by most specific test,
+                //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()) {
+                    DiagnosticPosition pos = trees != null ? trees.head : null;
+                    checkArg(pos, true, argtypes.head, elt, deferredAttrContext, warn);
+                    argtypes = argtypes.tail;
+                    trees = trees != null ? trees.tail : trees;
+                }
             }
         }
-        private final InapplicableMethodException inapplicableMethodException;
 
-/* ***************************************************************************
- *  Symbol lookup
- *  the following naming conventions for arguments are used
- *
- *       env      is the environment where the symbol was mentioned
- *       site     is the type of which the symbol is a member
- *       name     is the symbol's name
- *                if no arguments are given
- *       argtypes are the value arguments, if we search for a method
- *
- *  If no symbol was found, a ResolveError detailing the problem is returned.
- ****************************************************************************/
-
-    /** Find field. Synthetic fields are always skipped.
-     *  @param env     The current environment.
-     *  @param site    The original type from where the selection takes place.
-     *  @param name    The name of the field.
-     *  @param c       The class to search for the field. This is always
-     *                 a superclass or implemented interface of site's class.
-     */
-    Symbol findField(Env<AttrContext> env,
-                     Type site,
-                     Name name,
-                     TypeSymbol c) {
-        while (c.type.tag == TYPEVAR)
-            c = c.type.getUpperBound().tsym;
-        Symbol bestSoFar = varNotFound;
-        Symbol sym;
-        Scope.Entry e = c.members().lookup(name);
-        while (e.scope != null) {
-            if (e.sym.kind == VAR && (e.sym.flags_field & SYNTHETIC) == 0) {
-                return isAccessible(env, site, e.sym)
-                    ? e.sym : new AccessError(env, site, e.sym);
+        /**
+         * Does the actual argument conforms to the corresponding formal?
+         */
+        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;
+            if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) {
+                Object[] args2 = new Object[args.length + 1];
+                System.arraycopy(args, 0, args2, 1, args.length);
+                args2[0] = inferenceContext.inferenceVars();
+                args = args2;
             }
-            e = e.next();
-        }
-        Type st = types.supertype(c.type);
-        if (st != null && (st.tag == CLASS || st.tag == TYPEVAR)) {
-            sym = findField(env, site, name, st.tsym);
-            if (sym.kind < bestSoFar.kind) bestSoFar = sym;
+            String key = inferDiag ? diag.inferKey : diag.basicKey;
+            throw ex.setMessage(diags.create(DiagnosticType.FRAGMENT, log.currentSource(), pos, key, args));
         }
-        for (List<Type> l = types.interfaces(c.type);
-             bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
-             l = l.tail) {
-            sym = findField(env, site, name, l.head.tsym);
-            if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS &&
-                sym.owner != bestSoFar.owner)
-                bestSoFar = new AmbiguityError(bestSoFar, sym);
-            else if (sym.kind < bestSoFar.kind)
-                bestSoFar = sym;
+
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return nilMethodCheck;
         }
-        return bestSoFar;
     }
 
-    /** Resolve a field identifier, throw a fatal error if not found.
-     *  @param pos       The position to use for error reporting.
-     *  @param env       The environment current at the method invocation.
-     *  @param site      The type of the qualifying expression, in which
-     *                   identifier is searched.
-     *  @param name      The identifier's name.
+    /**
+     * Arity-based method check. A method is applicable if the number of actuals
+     * supplied conforms to the method signature.
      */
-    public VarSymbol resolveInternalField(DiagnosticPosition pos, Env<AttrContext> env,
-                                          Type site, Name name) {
-        Symbol sym = findField(env, site, name, site.tsym);
-        if (sym.kind == VAR) return (VarSymbol)sym;
-        else throw new FatalError(
-                 diags.fragment("fatal.err.cant.locate.field",
-                                name));
+    MethodCheck arityMethodCheck = new AbstractMethodCheck() {
+        @Override
+        void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+            //do nothing - actual always compatible to formals
+        }
+    };
+
+    List<Type> dummyArgs(int length) {
+        ListBuffer<Type> buf = ListBuffer.lb();
+        for (int i = 0 ; i < length ; i++) {
+            buf.append(Type.noType);
+        }
+        return buf.toList();
     }
 
-    /** Find unqualified variable or field with given name.
-     *  Synthetic fields always skipped.
-     *  @param env     The current environment.
-     *  @param name    The name of the variable or field.
+    /**
+     * Main method applicability routine. Given a list of actual types A,
+     * a list of formal types F, determines whether the types in A are
+     * compatible (by method invocation conversion) with the types in F.
+     *
+     * Since this routine is shared between overload resolution and method
+     * type-inference, a (possibly empty) inference context is used to convert
+     * formal types to the corresponding 'undet' form ahead of a compatibility
+     * check so that constraints can be propagated and collected.
+     *
+     * Moreover, if one or more types in A is a deferred type, this routine uses
+     * DeferredAttr in order to perform deferred attribution. If one or more actual
+     * deferred types are stuck, they are placed in a queue and revisited later
+     * after the remainder of the arguments have been seen. If this is not sufficient
+     * to 'unstuck' the argument, a cyclic inference error is called out.
+     *
+     * A method check handler (see above) is used in order to report errors.
      */
-    Symbol findVar(Env<AttrContext> env, Name name) {
-        Symbol bestSoFar = varNotFound;
-        Symbol sym;
-        Env<AttrContext> env1 = env;
-        boolean staticOnly = false;
-        while (env1.outer != null) {
-            if (isStatic(env1)) staticOnly = true;
-            Scope.Entry e = env1.info.scope.lookup(name);
-            while (e.scope != null &&
-                   (e.sym.kind != VAR ||
-                    (e.sym.flags_field & SYNTHETIC) != 0))
-                e = e.next();
-            sym = (e.scope != null)
-                ? e.sym
-                : findField(
-                    env1, env1.enclClass.sym.type, name, env1.enclClass.sym);
-            if (sym.exists()) {
-                if (staticOnly &&
-                    sym.kind == VAR &&
-                    sym.owner.kind == TYP &&
+    MethodCheck resolveMethodCheck = new AbstractMethodCheck() {
+
+        @Override
+        void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+            ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
+            mresult.check(pos, actual);
+        }
+
+        @Override
+        public void argumentsAcceptable(final Env<AttrContext> env,
+                                    DeferredAttrContext deferredAttrContext,
+                                    List<Type> argtypes,
+                                    List<Type> formals,
+                                    Warner warn) {
+            super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
+            //should we expand formals?
+            if (deferredAttrContext.phase.isVarargsRequired()) {
+                //check varargs element type accessibility
+                varargsAccessible(env, types.elemtype(formals.last()),
+                        deferredAttrContext.inferenceContext);
+            }
+        }
+
+        private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
+            if (inferenceContext.free(t)) {
+                inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
+                    @Override
+                    public void typesInferred(InferenceContext inferenceContext) {
+                        varargsAccessible(env, inferenceContext.asInstType(t), inferenceContext);
+                    }
+                });
+            } else {
+                if (!isAccessible(env, t)) {
+                    Symbol location = env.enclClass.sym;
+                    reportMC(env.tree, MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location);
+                }
+            }
+        }
+
+        private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
+                final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
+            CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
+                MethodCheckDiag methodDiag = varargsCheck ?
+                                 MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;
+
+                @Override
+                public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                    reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
+                }
+            };
+            return new MethodResultInfo(to, checkContext);
+        }
+
+        @Override
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return new MostSpecificCheck(strict, actuals);
+        }
+    };
+
+    class MethodReferenceCheck extends AbstractMethodCheck {
+
+        InferenceContext pendingInferenceContext;
+
+        MethodReferenceCheck(InferenceContext pendingInferenceContext) {
+            this.pendingInferenceContext = pendingInferenceContext;
+        }
+
+        @Override
+        void checkArg(DiagnosticPosition pos, boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) {
+            ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn);
+            mresult.check(pos, actual);
+        }
+
+        private ResultInfo methodCheckResult(final boolean varargsCheck, Type to,
+                final DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner) {
+            CheckContext checkContext = new MethodCheckContext(!deferredAttrContext.phase.isBoxingRequired(), deferredAttrContext, rsWarner) {
+                MethodCheckDiag methodDiag = varargsCheck ?
+                                 MethodCheckDiag.VARARG_MISMATCH : MethodCheckDiag.ARG_MISMATCH;
+
+                @Override
+                public boolean compatible(Type found, Type req, Warner warn) {
+                    found = pendingInferenceContext.asFree(found);
+                    req = infer.returnConstraintTarget(found, req);
+                    return super.compatible(found, req, warn);
+                }
+
+                @Override
+                public void report(DiagnosticPosition pos, JCDiagnostic details) {
+                    reportMC(pos, methodDiag, deferredAttrContext.inferenceContext, details);
+                }
+            };
+            return new MethodResultInfo(to, checkContext);
+        }
+
+        @Override
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            return new MostSpecificCheck(strict, actuals);
+        }
+    };
+
+    /**
+     * Check context to be used during method applicability checks. A method check
+     * context might contain inference variables.
+     */
+    abstract class MethodCheckContext implements CheckContext {
+
+        boolean strict;
+        DeferredAttrContext deferredAttrContext;
+        Warner rsWarner;
+
+        public MethodCheckContext(boolean strict, DeferredAttrContext deferredAttrContext, Warner rsWarner) {
+           this.strict = strict;
+           this.deferredAttrContext = deferredAttrContext;
+           this.rsWarner = rsWarner;
+        }
+
+        public boolean compatible(Type found, Type req, Warner warn) {
+            return strict ?
+                    types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req), warn) :
+                    types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req), warn);
+        }
+
+        public void report(DiagnosticPosition pos, JCDiagnostic details) {
+            throw inapplicableMethodException.setMessage(details);
+        }
+
+        public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
+            return rsWarner;
+        }
+
+        public InferenceContext inferenceContext() {
+            return deferredAttrContext.inferenceContext;
+        }
+
+        public DeferredAttrContext deferredAttrContext() {
+            return deferredAttrContext;
+        }
+    }
+
+    /**
+     * ResultInfo class to be used during method applicability checks. Check
+     * for deferred types goes through special path.
+     */
+    class MethodResultInfo extends ResultInfo {
+
+        public MethodResultInfo(Type pt, CheckContext checkContext) {
+            attr.super(VAL, pt, checkContext);
+        }
+
+        @Override
+        protected Type check(DiagnosticPosition pos, Type found) {
+            if (found.hasTag(DEFERRED)) {
+                DeferredType dt = (DeferredType)found;
+                return dt.check(this);
+            } else {
+                return super.check(pos, chk.checkNonVoid(pos, types.capture(U(found.baseType()))));
+            }
+        }
+
+        /**
+         * javac has a long-standing 'simplification' (see 6391995):
+         * given an actual argument type, the method check is performed
+         * on its upper bound. This leads to inconsistencies when an
+         * argument type is checked against itself. For example, given
+         * a type-variable T, it is not true that {@code U(T) <: T},
+         * so we need to guard against that.
+         */
+        private Type U(Type found) {
+            return found == pt ?
+                    found : types.upperBound(found);
+        }
+
+        @Override
+        protected MethodResultInfo dup(Type newPt) {
+            return new MethodResultInfo(newPt, checkContext);
+        }
+
+        @Override
+        protected ResultInfo dup(CheckContext newContext) {
+            return new MethodResultInfo(pt, newContext);
+        }
+    }
+
+    /**
+     * Most specific method applicability routine. Given a list of actual types A,
+     * a list of formal types F1, and a list of formal types F2, the routine determines
+     * as to whether the types in F1 can be considered more specific than those in F2 w.r.t.
+     * argument types A.
+     */
+    class MostSpecificCheck implements MethodCheck {
+
+        boolean strict;
+        List<Type> actuals;
+
+        MostSpecificCheck(boolean strict, List<Type> actuals) {
+            this.strict = strict;
+            this.actuals = actuals;
+        }
+
+        @Override
+        public void argumentsAcceptable(final Env<AttrContext> env,
+                                    DeferredAttrContext deferredAttrContext,
+                                    List<Type> formals1,
+                                    List<Type> formals2,
+                                    Warner warn) {
+            formals2 = adjustArgs(formals2, deferredAttrContext.msym, formals1.length(), deferredAttrContext.phase.isVarargsRequired());
+            while (formals2.nonEmpty()) {
+                ResultInfo mresult = methodCheckResult(formals2.head, deferredAttrContext, warn, actuals.head);
+                mresult.check(null, formals1.head);
+                formals1 = formals1.tail;
+                formals2 = formals2.tail;
+                actuals = actuals.isEmpty() ? actuals : actuals.tail;
+            }
+        }
+
+       /**
+        * Create a method check context to be used during the most specific applicability check
+        */
+        ResultInfo methodCheckResult(Type to, DeferredAttr.DeferredAttrContext deferredAttrContext,
+               Warner rsWarner, Type actual) {
+           return attr.new ResultInfo(Kinds.VAL, to,
+                   new MostSpecificCheckContext(strict, deferredAttrContext, rsWarner, actual));
+        }
+
+        /**
+         * Subclass of method check context class that implements most specific
+         * method conversion. If the actual type under analysis is a deferred type
+         * a full blown structural analysis is carried out.
+         */
+        class MostSpecificCheckContext extends MethodCheckContext {
+
+            Type actual;
+
+            public MostSpecificCheckContext(boolean strict, DeferredAttrContext deferredAttrContext, Warner rsWarner, Type actual) {
+                super(strict, deferredAttrContext, rsWarner);
+                this.actual = actual;
+            }
+
+            public boolean compatible(Type found, Type req, Warner warn) {
+                if (!allowStructuralMostSpecific || actual == null) {
+                    return super.compatible(found, req, warn);
+                } else {
+                    switch (actual.getTag()) {
+                        case DEFERRED:
+                            DeferredType dt = (DeferredType) actual;
+                            DeferredType.SpeculativeCache.Entry e = dt.speculativeCache.get(deferredAttrContext.msym, deferredAttrContext.phase);
+                            return (e == null || e.speculativeTree == deferredAttr.stuckTree)
+                                    ? false : mostSpecific(found, req, e.speculativeTree, warn);
+                        default:
+                            return standaloneMostSpecific(found, req, actual, warn);
+                    }
+                }
+            }
+
+            private boolean mostSpecific(Type t, Type s, JCTree tree, Warner warn) {
+                MostSpecificChecker msc = new MostSpecificChecker(t, s, warn);
+                msc.scan(tree);
+                return msc.result;
+            }
+
+            boolean polyMostSpecific(Type t1, Type t2, Warner warn) {
+                return (!t1.isPrimitive() && t2.isPrimitive())
+                        ? true : super.compatible(t1, t2, warn);
+            }
+
+            boolean standaloneMostSpecific(Type t1, Type t2, Type exprType, Warner warn) {
+                return (exprType.isPrimitive() == t1.isPrimitive()
+                        && exprType.isPrimitive() != t2.isPrimitive())
+                        ? true : super.compatible(t1, t2, warn);
+            }
+
+            /**
+             * Structural checker for most specific.
+             */
+            class MostSpecificChecker extends DeferredAttr.PolyScanner {
+
+                final Type t;
+                final Type s;
+                final Warner warn;
+                boolean result;
+
+                MostSpecificChecker(Type t, Type s, Warner warn) {
+                    this.t = t;
+                    this.s = s;
+                    this.warn = warn;
+                    result = true;
+                }
+
+                @Override
+                void skip(JCTree tree) {
+                    result &= standaloneMostSpecific(t, s, tree.type, warn);
+                }
+
+                @Override
+                public void visitConditional(JCConditional tree) {
+                    if (tree.polyKind == PolyKind.STANDALONE) {
+                        result &= standaloneMostSpecific(t, s, tree.type, warn);
+                    } else {
+                        super.visitConditional(tree);
+                    }
+                }
+
+                @Override
+                public void visitApply(JCMethodInvocation tree) {
+                    result &= (tree.polyKind == PolyKind.STANDALONE)
+                            ? standaloneMostSpecific(t, s, tree.type, warn)
+                            : polyMostSpecific(t, s, warn);
+                }
+
+                @Override
+                public void visitNewClass(JCNewClass tree) {
+                    result &= (tree.polyKind == PolyKind.STANDALONE)
+                            ? standaloneMostSpecific(t, s, tree.type, warn)
+                            : polyMostSpecific(t, s, warn);
+                }
+
+                @Override
+                public void visitReference(JCMemberReference tree) {
+                    if (types.isFunctionalInterface(t.tsym) &&
+                            types.isFunctionalInterface(s.tsym) &&
+                            types.asSuper(t, s.tsym) == null &&
+                            types.asSuper(s, t.tsym) == null) {
+                        Type desc_t = types.findDescriptorType(t);
+                        Type desc_s = types.findDescriptorType(s);
+                        if (types.isSameTypes(desc_t.getParameterTypes(), desc_s.getParameterTypes())) {
+                            if (!desc_s.getReturnType().hasTag(VOID)) {
+                                //perform structural comparison
+                                Type ret_t = desc_t.getReturnType();
+                                Type ret_s = desc_s.getReturnType();
+                                result &= ((tree.refPolyKind == PolyKind.STANDALONE)
+                                        ? standaloneMostSpecific(ret_t, ret_s, tree.sym.type.getReturnType(), warn)
+                                        : polyMostSpecific(ret_t, ret_s, warn));
+                            } else {
+                                return;
+                            }
+                        } else {
+                            result &= false;
+                        }
+                    } else {
+                        result &= MostSpecificCheckContext.super.compatible(t, s, warn);
+                    }
+                }
+
+                @Override
+                public void visitLambda(JCLambda tree) {
+                    if (types.isFunctionalInterface(t.tsym) &&
+                            types.isFunctionalInterface(s.tsym) &&
+                            types.asSuper(t, s.tsym) == null &&
+                            types.asSuper(s, t.tsym) == null) {
+                        Type desc_t = types.findDescriptorType(t);
+                        Type desc_s = types.findDescriptorType(s);
+                        if (tree.paramKind == JCLambda.ParameterKind.EXPLICIT
+                                || types.isSameTypes(desc_t.getParameterTypes(), desc_s.getParameterTypes())) {
+                            if (!desc_s.getReturnType().hasTag(VOID)) {
+                                //perform structural comparison
+                                Type ret_t = desc_t.getReturnType();
+                                Type ret_s = desc_s.getReturnType();
+                                scanLambdaBody(tree, ret_t, ret_s);
+                            } else {
+                                return;
+                            }
+                        } else {
+                            result &= false;
+                        }
+                    } else {
+                        result &= MostSpecificCheckContext.super.compatible(t, s, warn);
+                    }
+                }
+                //where
+
+                void scanLambdaBody(JCLambda lambda, final Type t, final Type s) {
+                    if (lambda.getBodyKind() == JCTree.JCLambda.BodyKind.EXPRESSION) {
+                        result &= MostSpecificCheckContext.this.mostSpecific(t, s, lambda.body, warn);
+                    } else {
+                        DeferredAttr.LambdaReturnScanner lambdaScanner =
+                                new DeferredAttr.LambdaReturnScanner() {
+                                    @Override
+                                    public void visitReturn(JCReturn tree) {
+                                        if (tree.expr != null) {
+                                            result &= MostSpecificCheckContext.this.mostSpecific(t, s, tree.expr, warn);
+                                        }
+                                    }
+                                };
+                        lambdaScanner.scan(lambda.body);
+                    }
+                }
+            }
+        }
+
+        public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) {
+            Assert.error("Cannot get here!");
+            return null;
+        }
+    }
+
+    public static class InapplicableMethodException extends RuntimeException {
+        private static final long serialVersionUID = 0;
+
+        JCDiagnostic diagnostic;
+        JCDiagnostic.Factory diags;
+
+        InapplicableMethodException(JCDiagnostic.Factory diags) {
+            this.diagnostic = null;
+            this.diags = diags;
+        }
+        InapplicableMethodException setMessage() {
+            return setMessage((JCDiagnostic)null);
+        }
+        InapplicableMethodException setMessage(String key) {
+            return setMessage(key != null ? diags.fragment(key) : null);
+        }
+        InapplicableMethodException setMessage(String key, Object... args) {
+            return setMessage(key != null ? diags.fragment(key, args) : null);
+        }
+        InapplicableMethodException setMessage(JCDiagnostic diag) {
+            this.diagnostic = diag;
+            return this;
+        }
+
+        public JCDiagnostic getDiagnostic() {
+            return diagnostic;
+        }
+    }
+    private final InapplicableMethodException inapplicableMethodException;
+
+/* ***************************************************************************
+ *  Symbol lookup
+ *  the following naming conventions for arguments are used
+ *
+ *       env      is the environment where the symbol was mentioned
+ *       site     is the type of which the symbol is a member
+ *       name     is the symbol's name
+ *                if no arguments are given
+ *       argtypes are the value arguments, if we search for a method
+ *
+ *  If no symbol was found, a ResolveError detailing the problem is returned.
+ ****************************************************************************/
+
+    /** Find field. Synthetic fields are always skipped.
+     *  @param env     The current environment.
+     *  @param site    The original type from where the selection takes place.
+     *  @param name    The name of the field.
+     *  @param c       The class to search for the field. This is always
+     *                 a superclass or implemented interface of site's class.
+     */
+    Symbol findField(Env<AttrContext> env,
+                     Type site,
+                     Name name,
+                     TypeSymbol c) {
+        while (c.type.hasTag(TYPEVAR))
+            c = c.type.getUpperBound().tsym;
+        Symbol bestSoFar = varNotFound;
+        Symbol sym;
+        Scope.Entry e = c.members().lookup(name);
+        while (e.scope != null) {
+            if (e.sym.kind == VAR && (e.sym.flags_field & SYNTHETIC) == 0) {
+                return isAccessible(env, site, e.sym)
+                    ? e.sym : new AccessError(env, site, e.sym);
+            }
+            e = e.next();
+        }
+        Type st = types.supertype(c.type);
+        if (st != null && (st.hasTag(CLASS) || st.hasTag(TYPEVAR))) {
+            sym = findField(env, site, name, st.tsym);
+            if (sym.kind < bestSoFar.kind) bestSoFar = sym;
+        }
+        for (List<Type> l = types.interfaces(c.type);
+             bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
+             l = l.tail) {
+            sym = findField(env, site, name, l.head.tsym);
+            if (bestSoFar.exists() && sym.exists() &&
+                sym.owner != bestSoFar.owner)
+                bestSoFar = new AmbiguityError(bestSoFar, sym);
+            else if (sym.kind < bestSoFar.kind)
+                bestSoFar = sym;
+        }
+        return bestSoFar;
+    }
+
+    /** Resolve a field identifier, throw a fatal error if not found.
+     *  @param pos       The position to use for error reporting.
+     *  @param env       The environment current at the method invocation.
+     *  @param site      The type of the qualifying expression, in which
+     *                   identifier is searched.
+     *  @param name      The identifier's name.
+     */
+    public VarSymbol resolveInternalField(DiagnosticPosition pos, Env<AttrContext> env,
+                                          Type site, Name name) {
+        Symbol sym = findField(env, site, name, site.tsym);
+        if (sym.kind == VAR) return (VarSymbol)sym;
+        else throw new FatalError(
+                 diags.fragment("fatal.err.cant.locate.field",
+                                name));
+    }
+
+    /** Find unqualified variable or field with given name.
+     *  Synthetic fields always skipped.
+     *  @param env     The current environment.
+     *  @param name    The name of the variable or field.
+     */
+    Symbol findVar(Env<AttrContext> env, Name name) {
+        Symbol bestSoFar = varNotFound;
+        Symbol sym;
+        Env<AttrContext> env1 = env;
+        boolean staticOnly = false;
+        while (env1.outer != null) {
+            if (isStatic(env1)) staticOnly = true;
+            Scope.Entry e = env1.info.scope.lookup(name);
+            while (e.scope != null &&
+                   (e.sym.kind != VAR ||
+                    (e.sym.flags_field & SYNTHETIC) != 0))
+                e = e.next();
+            sym = (e.scope != null)
+                ? e.sym
+                : findField(
+                    env1, env1.enclClass.sym.type, name, env1.enclClass.sym);
+            if (sym.exists()) {
+                if (staticOnly &&
+                    sym.kind == VAR &&
+                    sym.owner.kind == TYP &&
                     (sym.flags() & STATIC) == 0)
                     return new StaticError(sym);
                 else
@@ -684,33 +1404,41 @@ public class Resolve {
                       boolean allowBoxing,
                       boolean useVarargs,
                       boolean operator) {
-        if (sym.kind == ERR) return bestSoFar;
-        if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
+        if (sym.kind == ERR ||
+                !sym.isInheritedIn(site.tsym, types)) {
+            return bestSoFar;
+        } else if (useVarargs && (sym.flags() & VARARGS) == 0) {
+            return bestSoFar.kind >= ERRONEOUS ?
+                    new BadVarargsMethod((ResolveError)bestSoFar) :
+                    bestSoFar;
+        }
         Assert.check(sym.kind < AMBIGUOUS);
         try {
-            rawInstantiate(env, site, sym, argtypes, typeargtypes,
-                               allowBoxing, useVarargs, Warner.noWarnings);
+            Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
+                               allowBoxing, useVarargs, types.noWarnings);
+            if (!operator || verboseResolutionMode.contains(VerboseResolutionMode.PREDEF))
+                currentResolutionContext.addApplicableCandidate(sym, mt);
         } catch (InapplicableMethodException ex) {
+            if (!operator)
+                currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic());
             switch (bestSoFar.kind) {
-            case ABSENT_MTH:
-                return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
-            case WRONG_MTH:
-                if (operator) return bestSoFar;
-                wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation);
-            case WRONG_MTHS:
-                return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic());
-            default:
-                return bestSoFar;
+                case ABSENT_MTH:
+                    return new InapplicableSymbolError(currentResolutionContext);
+                case WRONG_MTH:
+                    if (operator) return bestSoFar;
+                    bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
+                default:
+                    return bestSoFar;
             }
         }
         if (!isAccessible(env, site, sym)) {
             return (bestSoFar.kind == ABSENT_MTH)
                 ? new AccessError(env, site, sym)
                 : bestSoFar;
-            }
+        }
         return (bestSoFar.kind > AMBIGUOUS)
             ? sym
-            : mostSpecific(sym, bestSoFar, env, site,
+            : mostSpecific(argtypes, sym, bestSoFar, env, site,
                            allowBoxing && operator, useVarargs);
     }
 
@@ -724,7 +1452,7 @@ public class Resolve {
      *  @param allowBoxing Allow boxing conversions of arguments.
      *  @param useVarargs Box trailing arguments into an array for varargs.
      */
-    Symbol mostSpecific(Symbol m1,
+    Symbol mostSpecific(List<Type> argtypes, Symbol m1,
                         Symbol m2,
                         Env<AttrContext> env,
                         final Type site,
@@ -733,8 +1461,10 @@ public class Resolve {
         switch (m2.kind) {
         case MTH:
             if (m1 == m2) return m1;
-            boolean m1SignatureMoreSpecific = signatureMoreSpecific(env, site, m1, m2, allowBoxing, useVarargs);
-            boolean m2SignatureMoreSpecific = signatureMoreSpecific(env, site, m2, m1, allowBoxing, useVarargs);
+            boolean m1SignatureMoreSpecific =
+                    signatureMoreSpecific(argtypes, env, site, m1, m2, allowBoxing, useVarargs);
+            boolean m2SignatureMoreSpecific =
+                    signatureMoreSpecific(argtypes, env, site, m2, m1, allowBoxing, useVarargs);
             if (m1SignatureMoreSpecific && m2SignatureMoreSpecific) {
                 Type mt1 = types.memberType(site, m1);
                 Type mt2 = types.memberType(site, m2);
@@ -765,99 +1495,58 @@ public class Resolve {
                 if (m1Abstract && !m2Abstract) return m2;
                 if (m2Abstract && !m1Abstract) return m1;
                 // both abstract or both concrete
-                if (!m1Abstract && !m2Abstract)
-                    return ambiguityError(m1, m2);
-                // check that both signatures have the same erasure
-                if (!types.isSameTypes(m1.erasure(types).getParameterTypes(),
-                                       m2.erasure(types).getParameterTypes()))
-                    return ambiguityError(m1, m2);
-                // both abstract, neither overridden; merge throws clause and result type
-                Type mst = mostSpecificReturnType(mt1, mt2);
-                if (mst == null) {
-                    // Theoretically, this can't happen, but it is possible
-                    // due to error recovery or mixing incompatible class files
-                    return ambiguityError(m1, m2);
-                }
-                Symbol mostSpecific = mst == mt1 ? m1 : m2;
-                List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
-                Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
-                MethodSymbol result = new MethodSymbol(
-                        mostSpecific.flags(),
-                        mostSpecific.name,
-                        newSig,
-                        mostSpecific.owner) {
-                    @Override
-                    public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
-                        if (origin == site.tsym)
-                            return this;
-                        else
-                            return super.implementation(origin, types, checkResult);
-                    }
-                };
-                return result;
+                return ambiguityError(m1, m2);
             }
             if (m1SignatureMoreSpecific) return m1;
             if (m2SignatureMoreSpecific) return m2;
             return ambiguityError(m1, m2);
         case AMBIGUOUS:
-            AmbiguityError e = (AmbiguityError)m2;
-            Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs);
-            Symbol err2 = mostSpecific(m1, e.sym2, env, site, allowBoxing, useVarargs);
-            if (err1 == err2) return err1;
-            if (err1 == e.sym && err2 == e.sym2) return m2;
-            if (err1 instanceof AmbiguityError &&
-                err2 instanceof AmbiguityError &&
-                ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym)
-                return ambiguityError(m1, m2);
-            else
-                return ambiguityError(err1, err2);
+            //check if m1 is more specific than all ambiguous methods in m2
+            AmbiguityError e = (AmbiguityError)m2.baseSymbol();
+            for (Symbol s : e.ambiguousSyms) {
+                if (mostSpecific(argtypes, m1, s, env, site, allowBoxing, useVarargs) != m1) {
+                    return e.addAmbiguousSymbol(m1);
+                }
+            }
+            return m1;
         default:
             throw new AssertionError();
         }
     }
     //where
-    private boolean signatureMoreSpecific(Env<AttrContext> env, Type site, Symbol m1, Symbol m2, boolean allowBoxing, boolean useVarargs) {
+    private boolean signatureMoreSpecific(List<Type> actuals, Env<AttrContext> env, Type site, Symbol m1, Symbol m2, boolean allowBoxing, boolean useVarargs) {
         noteWarner.clear();
-        Type mtype1 = types.memberType(site, adjustVarargs(m1, m2, useVarargs));
-        Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs),
-                types.lowerBoundArgtypes(mtype1), null,
-                allowBoxing, false, noteWarner);
-        return mtype2 != null &&
-                !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
-    }
-    //where
-    private Symbol adjustVarargs(Symbol to, Symbol from, boolean useVarargs) {
-        List<Type> fromArgs = from.type.getParameterTypes();
-        List<Type> toArgs = to.type.getParameterTypes();
-        if (useVarargs &&
-                (from.flags() & VARARGS) != 0 &&
-                (to.flags() & VARARGS) != 0) {
-            Type varargsTypeFrom = fromArgs.last();
-            Type varargsTypeTo = toArgs.last();
-            ListBuffer<Type> args = ListBuffer.lb();
-            if (toArgs.length() < fromArgs.length()) {
-                //if we are checking a varargs method 'from' against another varargs
-                //method 'to' (where arity of 'to' < arity of 'from') then expand signature
-                //of 'to' to 'fit' arity of 'from' (this means adding fake formals to 'to'
-                //until 'to' signature has the same arity as 'from')
-                while (fromArgs.head != varargsTypeFrom) {
-                    args.append(toArgs.head == varargsTypeTo ? types.elemtype(varargsTypeTo) : toArgs.head);
-                    fromArgs = fromArgs.tail;
-                    toArgs = toArgs.head == varargsTypeTo ?
-                        toArgs :
-                        toArgs.tail;
-                }
-            } else {
-                //formal argument list is same as original list where last
-                //argument (array type) is removed
-                args.appendList(toArgs.reverse().tail.reverse());
-            }
-            //append varargs element type as last synthetic formal
-            args.append(types.elemtype(varargsTypeTo));
-            Type mtype = types.createMethodTypeWithParameters(to.type, args.toList());
-            return new MethodSymbol(to.flags_field & ~VARARGS, to.name, mtype, to.owner);
+        int maxLength = Math.max(
+                            Math.max(m1.type.getParameterTypes().length(), actuals.length()),
+                            m2.type.getParameterTypes().length());
+        MethodResolutionContext prevResolutionContext = currentResolutionContext;
+        try {
+            currentResolutionContext = new MethodResolutionContext();
+            currentResolutionContext.step = prevResolutionContext.step;
+            currentResolutionContext.methodCheck =
+                    prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing);
+            Type mst = instantiate(env, site, m2, null,
+                    adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null,
+                    allowBoxing, useVarargs, noteWarner);
+            return mst != null &&
+                    !noteWarner.hasLint(Lint.LintCategory.UNCHECKED);
+        } finally {
+            currentResolutionContext = prevResolutionContext;
+        }
+    }
+    private List<Type> adjustArgs(List<Type> args, Symbol msym, int length, boolean allowVarargs) {
+        if ((msym.flags() & VARARGS) != 0 && allowVarargs) {
+            Type varargsElem = types.elemtype(args.last());
+            if (varargsElem == null) {
+                Assert.error("Bad varargs = " + args.last() + " " + msym);
+            }
+            List<Type> newArgs = args.reverse().tail.prepend(varargsElem).reverse();
+            while (newArgs.length() < length) {
+                newArgs = newArgs.append(newArgs.last());
+            }
+            return newArgs;
         } else {
-            return to;
+            return args;
         }
     }
     //where
@@ -865,7 +1554,7 @@ public class Resolve {
         Type rt1 = mt1.getReturnType();
         Type rt2 = mt2.getReturnType();
 
-        if (mt1.tag == FORALL && mt2.tag == FORALL) {
+        if (mt1.hasTag(FORALL) && mt2.hasTag(FORALL)) {
             //if both are generic methods, adjust return type ahead of subtyping check
             rt1 = types.subst(rt1, mt1.getTypeArguments(), mt2.getTypeArguments());
         }
@@ -891,6 +1580,42 @@ public class Resolve {
         }
     }
 
+    Symbol findMethodInScope(Env<AttrContext> env,
+            Type site,
+            Name name,
+            List<Type> argtypes,
+            List<Type> typeargtypes,
+            Scope sc,
+            Symbol bestSoFar,
+            boolean allowBoxing,
+            boolean useVarargs,
+            boolean operator,
+            boolean abstractok) {
+        for (Symbol s : sc.getElementsByName(name, new LookupFilter(abstractok))) {
+            bestSoFar = selectBest(env, site, argtypes, typeargtypes, s,
+                    bestSoFar, allowBoxing, useVarargs, operator);
+        }
+        return bestSoFar;
+    }
+    //where
+        class LookupFilter implements Filter<Symbol> {
+
+            boolean abstractOk;
+
+            LookupFilter(boolean abstractOk) {
+                this.abstractOk = abstractOk;
+            }
+
+            public boolean accepts(Symbol s) {
+                long flags = s.flags();
+                return s.kind == MTH &&
+                        (flags & SYNTHETIC) == 0 &&
+                        (abstractOk ||
+                        (flags & DEFAULT) != 0 ||
+                        (flags & ABSTRACT) == 0);
+            }
+        };
+
     /** Find best qualified method matching given name, type and value
      *  arguments.
      *  @param env       The current environment.
@@ -911,18 +1636,17 @@ public class Resolve {
                       boolean useVarargs,
                       boolean operator) {
         Symbol bestSoFar = methodNotFound;
-        return findMethod(env,
+        bestSoFar = findMethod(env,
                           site,
                           name,
                           argtypes,
                           typeargtypes,
                           site.tsym.type,
-                          true,
                           bestSoFar,
                           allowBoxing,
                           useVarargs,
-                          operator,
-                          new HashSet<TypeSymbol>());
+                          operator);
+        return bestSoFar;
     }
     // where
     private Symbol findMethod(Env<AttrContext> env,
@@ -931,56 +1655,133 @@ public class Resolve {
                               List<Type> argtypes,
                               List<Type> typeargtypes,
                               Type intype,
-                              boolean abstractok,
                               Symbol bestSoFar,
                               boolean allowBoxing,
                               boolean useVarargs,
-                              boolean operator,
-                              Set<TypeSymbol> seen) {
-        for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
-            while (ct.tag == TYPEVAR)
-                ct = ct.getUpperBound();
-            ClassSymbol c = (ClassSymbol)ct.tsym;
-            if (!seen.add(c)) return bestSoFar;
-            if ((c.flags() & (ABSTRACT | INTERFACE | ENUM)) == 0)
-                abstractok = false;
-            for (Scope.Entry e = c.members().lookup(name);
-                 e.scope != null;
-                 e = e.next()) {
-                //- System.out.println(" e " + e.sym);
-                if (e.sym.kind == MTH &&
-                    (e.sym.flags_field & SYNTHETIC) == 0) {
-                    bestSoFar = selectBest(env, site, argtypes, typeargtypes,
-                                           e.sym, bestSoFar,
-                                           allowBoxing,
-                                           useVarargs,
-                                           operator);
+                              boolean operator) {
+        @SuppressWarnings({"unchecked","rawtypes"})
+        List<Type>[] itypes = (List<Type>[])new List[] { List.<Type>nil(), List.<Type>nil() };
+        InterfaceLookupPhase iphase = InterfaceLookupPhase.ABSTRACT_OK;
+        for (TypeSymbol s : superclasses(intype)) {
+            bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes,
+                    s.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
+            if (name == names.init) return bestSoFar;
+            iphase = (iphase == null) ? null : iphase.update(s, this);
+            if (iphase != null) {
+                for (Type itype : types.interfaces(s.type)) {
+                    itypes[iphase.ordinal()] = types.union(types.closure(itype), itypes[iphase.ordinal()]);
                 }
             }
-            if (name == names.init)
-                break;
-            //- System.out.println(" - " + bestSoFar);
-            if (abstractok) {
-                Symbol concrete = methodNotFound;
-                if ((bestSoFar.flags() & ABSTRACT) == 0)
-                    concrete = bestSoFar;
-                for (List<Type> l = types.interfaces(c.type);
-                     l.nonEmpty();
-                     l = l.tail) {
-                    bestSoFar = findMethod(env, site, name, argtypes,
-                                           typeargtypes,
-                                           l.head, abstractok, bestSoFar,
-                                           allowBoxing, useVarargs, operator, seen);
-                }
+        }
+
+        Symbol concrete = bestSoFar.kind < ERR &&
+                (bestSoFar.flags() & ABSTRACT) == 0 ?
+                bestSoFar : methodNotFound;
+
+        for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
+            if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethods) break;
+            //keep searching for abstract methods
+            for (Type itype : itypes[iphase2.ordinal()]) {
+                if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
+                if (iphase2 == InterfaceLookupPhase.DEFAULT_OK &&
+                        (itype.tsym.flags() & DEFAULT) == 0) continue;
+                bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes,
+                        itype.tsym.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
                 if (concrete != bestSoFar &&
-                    concrete.kind < ERR  && bestSoFar.kind < ERR &&
-                    types.isSubSignature(concrete.type, bestSoFar.type))
+                        concrete.kind < ERR  && bestSoFar.kind < ERR &&
+                        types.isSubSignature(concrete.type, bestSoFar.type)) {
+                    //this is an hack - as javac does not do full membership checks
+                    //most specific ends up comparing abstract methods that might have
+                    //been implemented by some concrete method in a subclass and,
+                    //because of raw override, it is possible for an abstract method
+                    //to be more specific than the concrete method - so we need
+                    //to explicitly call that out (see CR 6178365)
                     bestSoFar = concrete;
+                }
             }
         }
         return bestSoFar;
     }
 
+    enum InterfaceLookupPhase {
+        ABSTRACT_OK() {
+            @Override
+            InterfaceLookupPhase update(Symbol s, Resolve rs) {
+                //We should not look for abstract methods if receiver is a concrete class
+                //(as concrete classes are expected to implement all abstracts coming
+                //from superinterfaces)
+                if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) {
+                    return this;
+                } else if (rs.allowDefaultMethods) {
+                    return DEFAULT_OK;
+                } else {
+                    return null;
+                }
+            }
+        },
+        DEFAULT_OK() {
+            @Override
+            InterfaceLookupPhase update(Symbol s, Resolve rs) {
+                return this;
+            }
+        };
+
+        abstract InterfaceLookupPhase update(Symbol s, Resolve rs);
+    }
+
+    /**
+     * Return an Iterable object to scan the superclasses of a given type.
+     * It's crucial that the scan is done lazily, as we don't want to accidentally
+     * access more supertypes than strictly needed (as this could trigger completion
+     * errors if some of the not-needed supertypes are missing/ill-formed).
+     */
+    Iterable<TypeSymbol> superclasses(final Type intype) {
+        return new Iterable<TypeSymbol>() {
+            public Iterator<TypeSymbol> iterator() {
+                return new Iterator<TypeSymbol>() {
+
+                    List<TypeSymbol> seen = List.nil();
+                    TypeSymbol currentSym = symbolFor(intype);
+                    TypeSymbol prevSym = null;
+
+                    public boolean hasNext() {
+                        if (currentSym == syms.noSymbol) {
+                            currentSym = symbolFor(types.supertype(prevSym.type));
+                        }
+                        return currentSym != null;
+                    }
+
+                    public TypeSymbol next() {
+                        prevSym = currentSym;
+                        currentSym = syms.noSymbol;
+                        Assert.check(prevSym != null || prevSym != syms.noSymbol);
+                        return prevSym;
+                    }
+
+                    public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+
+                    TypeSymbol symbolFor(Type t) {
+                        if (!t.hasTag(CLASS) &&
+                                !t.hasTag(TYPEVAR)) {
+                            return null;
+                        }
+                        while (t.hasTag(TYPEVAR))
+                            t = t.getUpperBound();
+                        if (seen.contains(t.tsym)) {
+                            //degenerate case in which we have a circular
+                            //class hierarchy - because of ill-formed classfiles
+                            return null;
+                        }
+                        seen = seen.prepend(t.tsym);
+                        return t.tsym;
+                    }
+                };
+            }
+        };
+    }
+
     /** Find unqualified method matching given name, type and value arguments.
      *  @param env       The current environment.
      *  @param name      The method's name.
@@ -1103,7 +1904,7 @@ public class Resolve {
             e = e.next();
         }
         Type st = types.supertype(c.type);
-        if (st != null && st.tag == CLASS) {
+        if (st != null && st.hasTag(CLASS)) {
             sym = findMemberType(env, site, name, st.tsym);
             if (sym.kind < bestSoFar.kind) bestSoFar = sym;
         }
@@ -1153,7 +1954,7 @@ public class Resolve {
                  e = e.next()) {
                 if (e.sym.kind == TYP) {
                     if (staticOnly &&
-                        e.sym.type.tag == TYPEVAR &&
+                        e.sym.type.hasTag(TYPEVAR) &&
                         e.sym.owner.kind == TYP) return new StaticError(e.sym);
                     return e.sym;
                 }
@@ -1162,8 +1963,8 @@ public class Resolve {
             sym = findMemberType(env1, env1.enclClass.sym.type, name,
                                  env1.enclClass.sym);
             if (staticOnly && sym.kind == TYP &&
-                sym.type.tag == CLASS &&
-                sym.type.getEnclosingType().tag == CLASS &&
+                sym.type.hasTag(CLASS) &&
+                sym.type.getEnclosingType().hasTag(CLASS) &&
                 env1.enclClass.sym.type.isParameterized() &&
                 sym.type.getEnclosingType().isParameterized())
                 return new StaticError(sym);
@@ -1175,7 +1976,7 @@ public class Resolve {
                 staticOnly = true;
         }
 
-        if (env.tree.getTag() != JCTree.IMPORT) {
+        if (!env.tree.hasTag(IMPORT)) {
             sym = findGlobalType(env, env.toplevel.namedImportScope, name);
             if (sym.exists()) return sym;
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
@@ -1194,7 +1995,7 @@ public class Resolve {
 
     /** Find an unqualified identifier which matches a specified kind set.
      *  @param env       The current environment.
-     *  @param name      The indentifier's name.
+     *  @param name      The identifier's name.
      *  @param kind      Indicates the possible symbol kinds
      *                   (a subset of VAL, TYP, PCK).
      */
@@ -1210,6 +2011,9 @@ public class Resolve {
 
         if ((kind & TYP) != 0) {
             sym = findType(env, name);
+            if (sym.kind==TYP) {
+                 reportDependence(env.enclClass.sym, sym);
+            }
             if (sym.exists()) return sym;
             else if (sym.kind < bestSoFar.kind) bestSoFar = sym;
         }
@@ -1218,6 +2022,14 @@ public class Resolve {
         else return bestSoFar;
     }
 
+    /** Report dependencies.
+     * @param from The enclosing class sym
+     * @param to   The found identifier that the class depends on.
+     */
+    public void reportDependence(Symbol from, Symbol to) {
+        // Override if you want to collect the reported dependencies.
+    }
+
     /** Find an identifier in a package which matches a specified kind set.
      *  @param env       The current environment.
      *  @param name      The identifier's name.
@@ -1278,77 +2090,145 @@ public class Resolve {
     /** If `sym' is a bad symbol: report error and return errSymbol
      *  else pass through unchanged,
      *  additional arguments duplicate what has been used in trying to find the
-     *  symbol (--> flyweight pattern). This improves performance since we
+     *  symbol {@literal (--> flyweight pattern)}. This improves performance since we
      *  expect misses to happen frequently.
      *
      *  @param sym       The symbol that was found, or a ResolveError.
      *  @param pos       The position to use for error reporting.
+     *  @param location  The symbol the served as a context for this lookup
      *  @param site      The original type from where the selection took place.
      *  @param name      The symbol's name.
+     *  @param qualified Did we get here through a qualified expression resolution?
      *  @param argtypes  The invocation's value arguments,
      *                   if we looked for a method.
      *  @param typeargtypes  The invocation's type arguments,
      *                   if we looked for a method.
+     *  @param logResolveHelper helper class used to log resolve errors
      */
-    Symbol access(Symbol sym,
+    Symbol accessInternal(Symbol sym,
                   DiagnosticPosition pos,
                   Symbol location,
                   Type site,
                   Name name,
                   boolean qualified,
                   List<Type> argtypes,
-                  List<Type> typeargtypes) {
+                  List<Type> typeargtypes,
+                  LogResolveHelper logResolveHelper) {
         if (sym.kind >= AMBIGUOUS) {
             ResolveError errSym = (ResolveError)sym;
-            if (!site.isErroneous() &&
-                !Type.isErroneous(argtypes) &&
-                (typeargtypes==null || !Type.isErroneous(typeargtypes)))
-                logResolveError(errSym, pos, location, site, name, argtypes, typeargtypes);
             sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
+            argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
+            if (logResolveHelper.resolveDiagnosticNeeded(site, argtypes, typeargtypes)) {
+                logResolveError(errSym, pos, location, site, name, argtypes, typeargtypes);
+            }
         }
         return sym;
     }
 
-    /** Same as original access(), but without location.
+    /**
+     * Variant of the generalized access routine, to be used for generating method
+     * resolution diagnostics
+     */
+    Symbol accessMethod(Symbol sym,
+                  DiagnosticPosition pos,
+                  Symbol location,
+                  Type site,
+                  Name name,
+                  boolean qualified,
+                  List<Type> argtypes,
+                  List<Type> typeargtypes) {
+        return accessInternal(sym, pos, location, site, name, qualified, argtypes, typeargtypes, methodLogResolveHelper);
+    }
+
+    /** Same as original accessMethod(), but without location.
      */
-    Symbol access(Symbol sym,
+    Symbol accessMethod(Symbol sym,
                   DiagnosticPosition pos,
                   Type site,
                   Name name,
                   boolean qualified,
                   List<Type> argtypes,
                   List<Type> typeargtypes) {
-        return access(sym, pos, site.tsym, site, name, qualified, argtypes, typeargtypes);
+        return accessMethod(sym, pos, site.tsym, site, name, qualified, argtypes, typeargtypes);
     }
 
-    /** Same as original access(), but without type arguments and arguments.
+    /**
+     * Variant of the generalized access routine, to be used for generating variable,
+     * type resolution diagnostics
      */
-    Symbol access(Symbol sym,
+    Symbol accessBase(Symbol sym,
                   DiagnosticPosition pos,
                   Symbol location,
                   Type site,
                   Name name,
                   boolean qualified) {
-        if (sym.kind >= AMBIGUOUS)
-            return access(sym, pos, location, site, name, qualified, List.<Type>nil(), null);
-        else
-            return sym;
+        return accessInternal(sym, pos, location, site, name, qualified, List.<Type>nil(), null, basicLogResolveHelper);
     }
 
-    /** Same as original access(), but without location, type arguments and arguments.
+    /** Same as original accessBase(), but without location.
      */
-    Symbol access(Symbol sym,
+    Symbol accessBase(Symbol sym,
                   DiagnosticPosition pos,
                   Type site,
                   Name name,
                   boolean qualified) {
-        return access(sym, pos, site.tsym, site, name, qualified);
+        return accessBase(sym, pos, site.tsym, site, name, qualified);
     }
 
+    interface LogResolveHelper {
+        boolean resolveDiagnosticNeeded(Type site, List<Type> argtypes, List<Type> typeargtypes);
+        List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes);
+    }
+
+    LogResolveHelper basicLogResolveHelper = new LogResolveHelper() {
+        public boolean resolveDiagnosticNeeded(Type site, List<Type> argtypes, List<Type> typeargtypes) {
+            return !site.isErroneous();
+        }
+        public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) {
+            return argtypes;
+        }
+    };
+
+    LogResolveHelper methodLogResolveHelper = new LogResolveHelper() {
+        public boolean resolveDiagnosticNeeded(Type site, List<Type> argtypes, List<Type> typeargtypes) {
+            return !site.isErroneous() &&
+                        !Type.isErroneous(argtypes) &&
+                        (typeargtypes == null || !Type.isErroneous(typeargtypes));
+        }
+        public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) {
+            return (syms.operatorNames.contains(name)) ?
+                    argtypes :
+                    Type.map(argtypes, new ResolveDeferredRecoveryMap(accessedSym));
+        }
+
+        class ResolveDeferredRecoveryMap extends DeferredAttr.RecoveryDeferredTypeMap {
+
+            public ResolveDeferredRecoveryMap(Symbol msym) {
+                deferredAttr.super(AttrMode.SPECULATIVE, msym, currentResolutionContext.step);
+            }
+
+            @Override
+            protected Type typeOf(DeferredType dt) {
+                Type res = super.typeOf(dt);
+                if (!res.isErroneous()) {
+                    switch (TreeInfo.skipParens(dt.tree).getTag()) {
+                        case LAMBDA:
+                        case REFERENCE:
+                            return dt;
+                        case CONDEXPR:
+                            return res == Type.recoveryType ?
+                                    dt : res;
+                    }
+                }
+                return res;
+            }
+        }
+    };
+
     /** Check that sym is not an abstract method.
      */
     void checkNonAbstract(DiagnosticPosition pos, Symbol sym) {
-        if ((sym.flags() & ABSTRACT) != 0)
+        if ((sym.flags() & ABSTRACT) != 0 && (sym.flags() & DEFAULT) == 0)
             log.error(pos, "abstract.cant.be.accessed.directly",
                       kindName(sym), sym, sym.location());
     }
@@ -1383,7 +2263,7 @@ public class Resolve {
     }
 
     public void printscopes(Type t) {
-        while (t.tag == CLASS) {
+        while (t.hasTag(CLASS)) {
             printscopes(t.tsym.members());
             t = types.supertype(t);
         }
@@ -1403,7 +2283,7 @@ public class Resolve {
      */
     Symbol resolveIdent(DiagnosticPosition pos, Env<AttrContext> env,
                         Name name, int kind) {
-        return access(
+        return accessBase(
             findIdent(env, name, kind),
             pos, env.enclClass.sym.type, name, false);
     }
@@ -1420,32 +2300,14 @@ public class Resolve {
                          Name name,
                          List<Type> argtypes,
                          List<Type> typeargtypes) {
-        Symbol sym = startResolution();
-        List<MethodResolutionPhase> steps = methodResolutionSteps;
-        while (steps.nonEmpty() &&
-               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
-               sym.kind >= ERRONEOUS) {
-            currentStep = steps.head;
-            sym = findFun(env, name, argtypes, typeargtypes,
-                    steps.head.isBoxingRequired,
-                    env.info.varArgs = steps.head.isVarargsRequired);
-            methodResolutionCache.put(steps.head, sym);
-            steps = steps.tail;
-        }
-        if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
-            MethodResolutionPhase errPhase =
-                    firstErroneousResolutionPhase();
-            sym = access(methodResolutionCache.get(errPhase),
-                    pos, env.enclClass.sym.type, name, false, argtypes, typeargtypes);
-            env.info.varArgs = errPhase.isVarargsRequired;
-        }
-        return sym;
-    }
-
-    private Symbol startResolution() {
-        wrongMethod.clear();
-        wrongMethods.clear();
-        return methodNotFound;
+        return lookupMethod(env, pos, env.enclClass.sym, resolveMethodCheck,
+                new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) {
+                    @Override
+                    Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                        return findFun(env, name, argtypes, typeargtypes,
+                                phase.isBoxingRequired(),
+                                phase.isVarargsRequired());
+                    }});
     }
 
     /** Resolve a qualified method identifier
@@ -1465,80 +2327,62 @@ public class Resolve {
     Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env<AttrContext> env,
                                   Symbol location, Type site, Name name, List<Type> argtypes,
                                   List<Type> typeargtypes) {
-        Symbol sym = startResolution();
-        List<MethodResolutionPhase> steps = methodResolutionSteps;
-        while (steps.nonEmpty() &&
-               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
-               sym.kind >= ERRONEOUS) {
-            currentStep = steps.head;
-            sym = findMethod(env, site, name, argtypes, typeargtypes,
-                    steps.head.isBoxingRequired(),
-                    env.info.varArgs = steps.head.isVarargsRequired(), false);
-            methodResolutionCache.put(steps.head, sym);
-            steps = steps.tail;
-        }
-        if (sym.kind >= AMBIGUOUS) {
-            if (site.tsym.isPolymorphicSignatureGeneric()) {
-                //polymorphic receiver - synthesize new method symbol
-                env.info.varArgs = false;
-                sym = findPolymorphicSignatureInstance(env,
-                        site, name, null, argtypes);
+        return resolveQualifiedMethod(new MethodResolutionContext(), pos, env, location, site, name, argtypes, typeargtypes);
+    }
+    private Symbol resolveQualifiedMethod(MethodResolutionContext resolveContext,
+                                  DiagnosticPosition pos, Env<AttrContext> env,
+                                  Symbol location, Type site, Name name, List<Type> argtypes,
+                                  List<Type> typeargtypes) {
+        return lookupMethod(env, pos, location, resolveContext, new BasicLookupHelper(name, site, argtypes, typeargtypes) {
+            @Override
+            Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                return findMethod(env, site, name, argtypes, typeargtypes,
+                        phase.isBoxingRequired(),
+                        phase.isVarargsRequired(), false);
             }
-            else {
-                //if nothing is found return the 'first' error
-                MethodResolutionPhase errPhase =
-                        firstErroneousResolutionPhase();
-                sym = access(methodResolutionCache.get(errPhase),
-                        pos, location, site, name, true, argtypes, typeargtypes);
-                env.info.varArgs = errPhase.isVarargsRequired;
-            }
-        } else if (allowMethodHandles && sym.isPolymorphicSignatureGeneric()) {
-            //non-instantiated polymorphic signature - synthesize new method symbol
-            env.info.varArgs = false;
-            sym = findPolymorphicSignatureInstance(env,
-                    site, name, (MethodSymbol)sym, argtypes);
-        }
-        return sym;
+            @Override
+            Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+                if (sym.kind >= AMBIGUOUS) {
+                    sym = super.access(env, pos, location, sym);
+                } else if (allowMethodHandles) {
+                    MethodSymbol msym = (MethodSymbol)sym;
+                    if ((msym.flags() & SIGNATURE_POLYMORPHIC) != 0) {
+                        return findPolymorphicSignatureInstance(env, sym, argtypes);
+                    }
+                }
+                return sym;
+            }
+        });
     }
 
     /** Find or create an implicit method of exactly the given type (after erasure).
      *  Searches in a side table, not the main scope of the site.
      *  This emulates the lookup process required by JSR 292 in JVM.
      *  @param env       Attribution environment
-     *  @param site      The original type from where the selection takes place.
-     *  @param name      The method's name.
-     *  @param spMethod  A template for the implicit method, or null.
-     *  @param argtypes  The required argument types.
-     *  @param typeargtypes  The required type arguments.
+     *  @param spMethod  signature polymorphic method - i.e. MH.invokeExact
+     *  @param argtypes  The required argument types
      */
-    Symbol findPolymorphicSignatureInstance(Env<AttrContext> env, Type site,
-                                            Name name,
-                                            MethodSymbol spMethod,  // sig. poly. method or null if none
+    Symbol findPolymorphicSignatureInstance(Env<AttrContext> env,
+                                            final Symbol spMethod,
                                             List<Type> argtypes) {
         Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
-                site, name, spMethod, argtypes);
-        long flags = ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE |
-                    (spMethod != null ?
-                        spMethod.flags() & Flags.AccessFlags :
-                        Flags.PUBLIC | Flags.STATIC);
-        Symbol m = null;
-        for (Scope.Entry e = polymorphicSignatureScope.lookup(name);
-             e.scope != null;
-             e = e.next()) {
-            Symbol sym = e.sym;
-            if (types.isSameType(mtype, sym.type) &&
-                (sym.flags() & Flags.STATIC) == (flags & Flags.STATIC) &&
-                types.isSameType(sym.owner.type, site)) {
-               m = sym;
-               break;
+                (MethodSymbol)spMethod, currentResolutionContext, argtypes);
+        for (Symbol sym : polymorphicSignatureScope.getElementsByName(spMethod.name)) {
+            if (types.isSameType(mtype, sym.type)) {
+               return sym;
             }
         }
-        if (m == null) {
-            // create the desired method
-            m = new MethodSymbol(flags, name, mtype, site.tsym);
-            polymorphicSignatureScope.enter(m);
-        }
-        return m;
+
+        // create the desired method
+        long flags = ABSTRACT | HYPOTHETICAL | spMethod.flags() & Flags.AccessFlags;
+        Symbol msym = new MethodSymbol(flags, spMethod.name, mtype, spMethod.owner) {
+            @Override
+            public Symbol baseSymbol() {
+                return spMethod;
+            }
+        };
+        polymorphicSignatureScope.enter(msym);
+        return msym;
     }
 
     /** Resolve a qualified method identifier, throw a fatal error if not
@@ -1555,8 +2399,10 @@ public class Resolve {
                                         Type site, Name name,
                                         List<Type> argtypes,
                                         List<Type> typeargtypes) {
-        Symbol sym = resolveQualifiedMethod(
-            pos, env, site.tsym, site, name, argtypes, typeargtypes);
+        MethodResolutionContext resolveContext = new MethodResolutionContext();
+        resolveContext.internalResolution = true;
+        Symbol sym = resolveQualifiedMethod(resolveContext, pos, env, site.tsym,
+                site, name, argtypes, typeargtypes);
         if (sym.kind == MTH) return (MethodSymbol)sym;
         else throw new FatalError(
                  diags.fragment("fatal.err.cant.locate.meth",
@@ -1577,24 +2423,54 @@ public class Resolve {
                               Type site,
                               List<Type> argtypes,
                               List<Type> typeargtypes) {
-        Symbol sym = startResolution();
-        List<MethodResolutionPhase> steps = methodResolutionSteps;
-        while (steps.nonEmpty() &&
-               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
-               sym.kind >= ERRONEOUS) {
-            currentStep = steps.head;
-            sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
-                    steps.head.isBoxingRequired(),
-                    env.info.varArgs = steps.head.isVarargsRequired());
-            methodResolutionCache.put(steps.head, sym);
-            steps = steps.tail;
-        }
-        if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
-            MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
-            sym = access(methodResolutionCache.get(errPhase),
-                    pos, site, names.init, true, argtypes, typeargtypes);
-            env.info.varArgs = errPhase.isVarargsRequired();
-        }
+        return resolveConstructor(new MethodResolutionContext(), pos, env, site, argtypes, typeargtypes);
+    }
+
+    private Symbol resolveConstructor(MethodResolutionContext resolveContext,
+                              final DiagnosticPosition pos,
+                              Env<AttrContext> env,
+                              Type site,
+                              List<Type> argtypes,
+                              List<Type> typeargtypes) {
+        return lookupMethod(env, pos, site.tsym, resolveContext, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
+            @Override
+            Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                return findConstructor(pos, env, site, argtypes, typeargtypes,
+                        phase.isBoxingRequired(),
+                        phase.isVarargsRequired());
+            }
+        });
+    }
+
+    /** Resolve a constructor, throw a fatal error if not found.
+     *  @param pos       The position to use for error reporting.
+     *  @param env       The environment current at the method invocation.
+     *  @param site      The type to be constructed.
+     *  @param argtypes  The types of the invocation's value arguments.
+     *  @param typeargtypes  The types of the invocation's type arguments.
+     */
+    public MethodSymbol resolveInternalConstructor(DiagnosticPosition pos, Env<AttrContext> env,
+                                        Type site,
+                                        List<Type> argtypes,
+                                        List<Type> typeargtypes) {
+        MethodResolutionContext resolveContext = new MethodResolutionContext();
+        resolveContext.internalResolution = true;
+        Symbol sym = resolveConstructor(resolveContext, pos, env, site, argtypes, typeargtypes);
+        if (sym.kind == MTH) return (MethodSymbol)sym;
+        else throw new FatalError(
+                 diags.fragment("fatal.err.cant.locate.ctor", site));
+    }
+
+    Symbol findConstructor(DiagnosticPosition pos, Env<AttrContext> env,
+                              Type site, List<Type> argtypes,
+                              List<Type> typeargtypes,
+                              boolean allowBoxing,
+                              boolean useVarargs) {
+        Symbol sym = findMethod(env, site,
+                                    names.init, argtypes,
+                                    typeargtypes, allowBoxing,
+                                    useVarargs, false);
+        chk.checkDeprecated(pos, env.info.scope.owner, sym);
         return sym;
     }
 
@@ -1613,124 +2489,551 @@ public class Resolve {
                               Type site,
                               List<Type> argtypes,
                               List<Type> typeargtypes) {
-        Symbol sym = startResolution();
-        List<MethodResolutionPhase> steps = methodResolutionSteps;
-        while (steps.nonEmpty() &&
-               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
-               sym.kind >= ERRONEOUS) {
-            currentStep = steps.head;
-            sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
-                    steps.head.isBoxingRequired(),
-                    env.info.varArgs = steps.head.isVarargsRequired());
-            methodResolutionCache.put(steps.head, sym);
-            steps = steps.tail;
+        return lookupMethod(env, pos, site.tsym, resolveMethodCheck,
+                new BasicLookupHelper(names.init, site, argtypes, typeargtypes) {
+                    @Override
+                    Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                        return findDiamond(env, site, argtypes, typeargtypes,
+                                phase.isBoxingRequired(),
+                                phase.isVarargsRequired());
+                    }
+                    @Override
+                    Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+                        if (sym.kind >= AMBIGUOUS) {
+                            final JCDiagnostic details = sym.kind == WRONG_MTH ?
+                                            ((InapplicableSymbolError)sym).errCandidate().snd :
+                                            null;
+                            sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) {
+                                @Override
+                                JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
+                                        Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+                                    String key = details == null ?
+                                        "cant.apply.diamond" :
+                                        "cant.apply.diamond.1";
+                                    return diags.create(dkind, log.currentSource(), pos, key,
+                                            diags.fragment("diamond", site.tsym), details);
+                                }
+                            };
+                            sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes);
+                            env.info.pendingResolutionPhase = currentResolutionContext.step;
+                        }
+                        return sym;
+                    }});
+    }
+
+    /** This method scans all the constructor symbol in a given class scope -
+     *  assuming that the original scope contains a constructor of the kind:
+     *  {@code Foo(X x, Y y)}, where X,Y are class type-variables declared in Foo,
+     *  a method check is executed against the modified constructor type:
+     *  {@code <X,Y>Foo<X,Y>(X x, Y y)}. This is crucial in order to enable diamond
+     *  inference. The inferred return type of the synthetic constructor IS
+     *  the inferred type for the diamond operator.
+     */
+    private Symbol findDiamond(Env<AttrContext> env,
+                              Type site,
+                              List<Type> argtypes,
+                              List<Type> typeargtypes,
+                              boolean allowBoxing,
+                              boolean useVarargs) {
+        Symbol bestSoFar = methodNotFound;
+        for (Scope.Entry e = site.tsym.members().lookup(names.init);
+             e.scope != null;
+             e = e.next()) {
+            final Symbol sym = e.sym;
+            //- System.out.println(" e " + e.sym);
+            if (sym.kind == MTH &&
+                (sym.flags_field & SYNTHETIC) == 0) {
+                    List<Type> oldParams = e.sym.type.hasTag(FORALL) ?
+                            ((ForAll)sym.type).tvars :
+                            List.<Type>nil();
+                    Type constrType = new ForAll(site.tsym.type.getTypeArguments().appendList(oldParams),
+                            types.createMethodTypeWithReturn(sym.type.asMethodType(), site));
+                    MethodSymbol newConstr = new MethodSymbol(sym.flags(), names.init, constrType, site.tsym) {
+                        @Override
+                        public Symbol baseSymbol() {
+                            return sym;
+                        }
+                    };
+                    bestSoFar = selectBest(env, site, argtypes, typeargtypes,
+                            newConstr,
+                            bestSoFar,
+                            allowBoxing,
+                            useVarargs,
+                            false);
+            }
         }
-        if (sym.kind >= AMBIGUOUS) {
-            final JCDiagnostic details = sym.kind == WRONG_MTH ?
-                ((InapplicableSymbolError)sym).explanation :
-                null;
-            Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") {
+        return bestSoFar;
+    }
+
+
+
+    /** Resolve operator.
+     *  @param pos       The position to use for error reporting.
+     *  @param optag     The tag of the operation tree.
+     *  @param env       The environment current at the operation.
+     *  @param argtypes  The types of the operands.
+     */
+    Symbol resolveOperator(DiagnosticPosition pos, JCTree.Tag optag,
+                           Env<AttrContext> env, List<Type> argtypes) {
+        MethodResolutionContext prevResolutionContext = currentResolutionContext;
+        try {
+            currentResolutionContext = new MethodResolutionContext();
+            Name name = treeinfo.operatorName(optag);
+            return lookupMethod(env, pos, syms.predefClass, currentResolutionContext,
+                    new BasicLookupHelper(name, syms.predefClass.type, argtypes, null, BOX) {
                 @Override
-                JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos,
-                        Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
-                    String key = details == null ?
-                        "cant.apply.diamond" :
-                        "cant.apply.diamond.1";
-                    return diags.create(dkind, log.currentSource(), pos, key,
-                            diags.fragment("diamond", site.tsym), details);
+                Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                    return findMethod(env, site, name, argtypes, typeargtypes,
+                            phase.isBoxingRequired(),
+                            phase.isVarargsRequired(), true);
                 }
-            };
-            MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
-            sym = access(errSym, pos, site, names.init, true, argtypes, typeargtypes);
-            env.info.varArgs = errPhase.isVarargsRequired();
+                @Override
+                Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+                    return accessMethod(sym, pos, env.enclClass.sym.type, name,
+                          false, argtypes, null);
+                }
+            });
+        } finally {
+            currentResolutionContext = prevResolutionContext;
         }
-        return sym;
     }
 
-    /** Resolve constructor.
+    /** Resolve operator.
      *  @param pos       The position to use for error reporting.
-     *  @param env       The environment current at the constructor invocation.
-     *  @param site      The type of class for which a constructor is searched.
-     *  @param argtypes  The types of the constructor invocation's value
-     *                   arguments.
-     *  @param typeargtypes  The types of the constructor invocation's type
-     *                   arguments.
-     *  @param allowBoxing Allow boxing and varargs conversions.
-     *  @param useVarargs Box trailing arguments into an array for varargs.
+     *  @param optag     The tag of the operation tree.
+     *  @param env       The environment current at the operation.
+     *  @param arg       The type of the operand.
      */
-    Symbol resolveConstructor(DiagnosticPosition pos, Env<AttrContext> env,
-                              Type site, List<Type> argtypes,
-                              List<Type> typeargtypes,
-                              boolean allowBoxing,
-                              boolean useVarargs) {
-        Symbol sym = findMethod(env, site,
-                                names.init, argtypes,
-                                typeargtypes, allowBoxing,
-                                useVarargs, false);
-        chk.checkDeprecated(pos, env.info.scope.owner, sym);
-        return sym;
+    Symbol resolveUnaryOperator(DiagnosticPosition pos, JCTree.Tag optag, Env<AttrContext> env, Type arg) {
+        return resolveOperator(pos, optag, env, List.of(arg));
     }
 
-    /** Resolve a constructor, throw a fatal error if not found.
+    /** Resolve binary operator.
      *  @param pos       The position to use for error reporting.
-     *  @param env       The environment current at the method invocation.
-     *  @param site      The type to be constructed.
-     *  @param argtypes  The types of the invocation's value arguments.
-     *  @param typeargtypes  The types of the invocation's type arguments.
+     *  @param optag     The tag of the operation tree.
+     *  @param env       The environment current at the operation.
+     *  @param left      The types of the left operand.
+     *  @param right     The types of the right operand.
      */
-    public MethodSymbol resolveInternalConstructor(DiagnosticPosition pos, Env<AttrContext> env,
-                                        Type site,
-                                        List<Type> argtypes,
-                                        List<Type> typeargtypes) {
-        Symbol sym = resolveConstructor(
-            pos, env, site, argtypes, typeargtypes);
-        if (sym.kind == MTH) return (MethodSymbol)sym;
-        else throw new FatalError(
-                 diags.fragment("fatal.err.cant.locate.ctor", site));
+    Symbol resolveBinaryOperator(DiagnosticPosition pos,
+                                 JCTree.Tag optag,
+                                 Env<AttrContext> env,
+                                 Type left,
+                                 Type right) {
+        return resolveOperator(pos, optag, env, List.of(left, right));
     }
 
-    /** Resolve operator.
-     *  @param pos       The position to use for error reporting.
-     *  @param optag     The tag of the operation tree.
-     *  @param env       The environment current at the operation.
-     *  @param argtypes  The types of the operands.
-     */
-    Symbol resolveOperator(DiagnosticPosition pos, int optag,
-                           Env<AttrContext> env, List<Type> argtypes) {
-        startResolution();
-        Name name = treeinfo.operatorName(optag);
-        Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
-                                null, false, false, true);
-        if (boxingEnabled && sym.kind >= WRONG_MTHS)
-            sym = findMethod(env, syms.predefClass.type, name, argtypes,
-                             null, true, false, true);
-        return access(sym, pos, env.enclClass.sym.type, name,
-                      false, argtypes, null);
+    /**
+     * Resolution of member references is typically done as a single
+     * overload resolution step, where the argument types A are inferred from
+     * the target functional descriptor.
+     *
+     * If the member reference is a method reference with a type qualifier,
+     * a two-step lookup process is performed. The first step uses the
+     * expected argument list A, while the second step discards the first
+     * type from A (which is treated as a receiver type).
+     *
+     * There are two cases in which inference is performed: (i) if the member
+     * reference is a constructor reference and the qualifier type is raw - in
+     * which case diamond inference is used to infer a parameterization for the
+     * type qualifier; (ii) if the member reference is an unbound reference
+     * where the type qualifier is raw - in that case, during the unbound lookup
+     * the receiver argument type is used to infer an instantiation for the raw
+     * qualifier type.
+     *
+     * When a multi-step resolution process is exploited, it is an error
+     * if two candidates are found (ambiguity).
+     *
+     * This routine returns a pair (T,S), where S is the member reference symbol,
+     * and T is the type of the class in which S is defined. This is necessary as
+     * the type T might be dynamically inferred (i.e. if constructor reference
+     * has a raw qualifier).
+     */
+    Pair<Symbol, ReferenceLookupHelper> resolveMemberReference(DiagnosticPosition pos,
+                                  Env<AttrContext> env,
+                                  JCMemberReference referenceTree,
+                                  Type site,
+                                  Name name, List<Type> argtypes,
+                                  List<Type> typeargtypes,
+                                  boolean boxingAllowed,
+                                  MethodCheck methodCheck,
+                                  InferenceContext inferenceContext) {
+        MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC;
+
+        ReferenceLookupHelper boundLookupHelper;
+        if (!name.equals(names.init)) {
+            //method reference
+            boundLookupHelper =
+                    new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase);
+        } else if (site.hasTag(ARRAY)) {
+            //array constructor reference
+            boundLookupHelper =
+                    new ArrayConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase);
+        } else {
+            //class constructor reference
+            boundLookupHelper =
+                    new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase);
+        }
+
+        //step 1 - bound lookup
+        Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
+        Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, methodCheck, boundLookupHelper);
+
+        //step 2 - unbound lookup
+        ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup(inferenceContext);
+        Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
+        Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, methodCheck, unboundLookupHelper);
+
+        //merge results
+        Pair<Symbol, ReferenceLookupHelper> res;
+        if (!lookupSuccess(unboundSym)) {
+            res = new Pair<Symbol, ReferenceLookupHelper>(boundSym, boundLookupHelper);
+            env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
+        } else if (lookupSuccess(boundSym)) {
+            res = new Pair<Symbol, ReferenceLookupHelper>(ambiguityError(boundSym, unboundSym), boundLookupHelper);
+            env.info.pendingResolutionPhase = boundEnv.info.pendingResolutionPhase;
+        } else {
+            res = new Pair<Symbol, ReferenceLookupHelper>(unboundSym, unboundLookupHelper);
+            env.info.pendingResolutionPhase = unboundEnv.info.pendingResolutionPhase;
+        }
+
+        return res;
+    }
+    //private
+        boolean lookupSuccess(Symbol s) {
+            return s.kind == MTH || s.kind == AMBIGUOUS;
+        }
+
+    /**
+     * Helper for defining custom method-like lookup logic; a lookup helper
+     * provides hooks for (i) the actual lookup logic and (ii) accessing the
+     * lookup result (this step might result in compiler diagnostics to be generated)
+     */
+    abstract class LookupHelper {
+
+        /** name of the symbol to lookup */
+        Name name;
+
+        /** location in which the lookup takes place */
+        Type site;
+
+        /** actual types used during the lookup */
+        List<Type> argtypes;
+
+        /** type arguments used during the lookup */
+        List<Type> typeargtypes;
+
+        /** Max overload resolution phase handled by this helper */
+        MethodResolutionPhase maxPhase;
+
+        LookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            this.name = name;
+            this.site = site;
+            this.argtypes = argtypes;
+            this.typeargtypes = typeargtypes;
+            this.maxPhase = maxPhase;
+        }
+
+        /**
+         * Should lookup stop at given phase with given result
+         */
+        protected boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
+            return phase.ordinal() > maxPhase.ordinal() ||
+                    sym.kind < ERRONEOUS || sym.kind == AMBIGUOUS;
+        }
+
+        /**
+         * Search for a symbol under a given overload resolution phase - this method
+         * is usually called several times, once per each overload resolution phase
+         */
+        abstract Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase);
+
+        /**
+         * Dump overload resolution info
+         */
+        void debug(DiagnosticPosition pos, Symbol sym) {
+            //do nothing
+        }
+
+        /**
+         * Validate the result of the lookup
+         */
+        abstract Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym);
+    }
+
+    abstract class BasicLookupHelper extends LookupHelper {
+
+        BasicLookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
+            this(name, site, argtypes, typeargtypes, MethodResolutionPhase.VARARITY);
+        }
+
+        BasicLookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(name, site, argtypes, typeargtypes, maxPhase);
+        }
+
+        @Override
+        final Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+            Symbol sym = doLookup(env, phase);
+            if (sym.kind == AMBIGUOUS) {
+                AmbiguityError a_err = (AmbiguityError)sym.baseSymbol();
+                sym = a_err.mergeAbstracts(site);
+            }
+            return sym;
+        }
+
+        abstract Symbol doLookup(Env<AttrContext> env, MethodResolutionPhase phase);
+
+        @Override
+        Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+            if (sym.kind >= AMBIGUOUS) {
+                //if nothing is found return the 'first' error
+                sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes);
+            }
+            return sym;
+        }
+
+        @Override
+        void debug(DiagnosticPosition pos, Symbol sym) {
+            reportVerboseResolutionDiagnostic(pos, name, site, argtypes, typeargtypes, sym);
+        }
+    }
+
+    /**
+     * Helper class for member reference lookup. A reference lookup helper
+     * defines the basic logic for member reference lookup; a method gives
+     * access to an 'unbound' helper used to perform an unbound member
+     * reference lookup.
+     */
+    abstract class ReferenceLookupHelper extends LookupHelper {
+
+        /** The member reference tree */
+        JCMemberReference referenceTree;
+
+        ReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
+                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(name, site, argtypes, typeargtypes, maxPhase);
+            this.referenceTree = referenceTree;
+
+        }
+
+        /**
+         * Returns an unbound version of this lookup helper. By default, this
+         * method returns an dummy lookup helper.
+         */
+        ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
+            //dummy loopkup helper that always return 'methodNotFound'
+            return new ReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase) {
+                @Override
+                ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
+                    return this;
+                }
+                @Override
+                Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+                    return methodNotFound;
+                }
+                @Override
+                ReferenceKind referenceKind(Symbol sym) {
+                    Assert.error();
+                    return null;
+                }
+            };
+        }
+
+        /**
+         * Get the kind of the member reference
+         */
+        abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym);
+
+        Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+            if (sym.kind == AMBIGUOUS) {
+                AmbiguityError a_err = (AmbiguityError)sym;
+                sym = a_err.mergeAbstracts(site);
+            }
+            //skip error reporting
+            return sym;
+        }
+    }
+
+    /**
+     * Helper class for method reference lookup. The lookup logic is based
+     * upon Resolve.findMethod; in certain cases, this helper class has a
+     * corresponding unbound helper class (see UnboundMethodReferenceLookupHelper).
+     * In such cases, non-static lookup results are thrown away.
+     */
+    class MethodReferenceLookupHelper extends ReferenceLookupHelper {
+
+        MethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
+                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(referenceTree, name, site, argtypes, typeargtypes, maxPhase);
+        }
+
+        @Override
+        final Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+            return findMethod(env, site, name, argtypes, typeargtypes,
+                    phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
+        }
+
+        @Override
+        ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
+            if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
+                    argtypes.nonEmpty() &&
+                    (argtypes.head.hasTag(NONE) ||
+                    types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) {
+                return new UnboundMethodReferenceLookupHelper(referenceTree, name,
+                        site, argtypes, typeargtypes, maxPhase);
+            } else {
+                return super.unboundLookup(inferenceContext);
+            }
+        }
+
+        @Override
+        ReferenceKind referenceKind(Symbol sym) {
+            if (sym.isStatic()) {
+                return ReferenceKind.STATIC;
+            } else {
+                Name selName = TreeInfo.name(referenceTree.getQualifierExpression());
+                return selName != null && selName == names._super ?
+                        ReferenceKind.SUPER :
+                        ReferenceKind.BOUND;
+            }
+        }
+    }
+
+    /**
+     * Helper class for unbound method reference lookup. Essentially the same
+     * as the basic method reference lookup helper; main difference is that static
+     * lookup results are thrown away. If qualifier type is raw, an attempt to
+     * infer a parameterized type is made using the first actual argument (that
+     * would otherwise be ignored during the lookup).
+     */
+    class UnboundMethodReferenceLookupHelper extends MethodReferenceLookupHelper {
+
+        UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
+                List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase);
+            if (site.isRaw() && !argtypes.head.hasTag(NONE)) {
+                Type asSuperSite = types.asSuper(argtypes.head, site.tsym);
+                this.site = asSuperSite;
+            }
+        }
+
+        @Override
+        ReferenceLookupHelper unboundLookup(InferenceContext inferenceContext) {
+            return this;
+        }
+
+        @Override
+        ReferenceKind referenceKind(Symbol sym) {
+            return ReferenceKind.UNBOUND;
+        }
+    }
+
+    /**
+     * Helper class for array constructor lookup; an array constructor lookup
+     * is simulated by looking up a method that returns the array type specified
+     * as qualifier, and that accepts a single int parameter (size of the array).
+     */
+    class ArrayConstructorReferenceLookupHelper extends ReferenceLookupHelper {
+
+        ArrayConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
+                List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase);
+        }
+
+        @Override
+        protected Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+            Scope sc = new Scope(syms.arrayClass);
+            MethodSymbol arrayConstr = new MethodSymbol(PUBLIC, name, null, site.tsym);
+            arrayConstr.type = new MethodType(List.<Type>of(syms.intType), site, List.<Type>nil(), syms.methodClass);
+            sc.enter(arrayConstr);
+            return findMethodInScope(env, site, name, argtypes, typeargtypes, sc, methodNotFound, phase.isBoxingRequired(), phase.isVarargsRequired(), false, false);
+        }
+
+        @Override
+        ReferenceKind referenceKind(Symbol sym) {
+            return ReferenceKind.ARRAY_CTOR;
+        }
+    }
+
+    /**
+     * Helper class for constructor reference lookup. The lookup logic is based
+     * upon either Resolve.findMethod or Resolve.findDiamond - depending on
+     * whether the constructor reference needs diamond inference (this is the case
+     * if the qualifier type is raw). A special erroneous symbol is returned
+     * if the lookup returns the constructor of an inner class and there's no
+     * enclosing instance in scope.
+     */
+    class ConstructorReferenceLookupHelper extends ReferenceLookupHelper {
+
+        boolean needsInference;
+
+        ConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site, List<Type> argtypes,
+                List<Type> typeargtypes, MethodResolutionPhase maxPhase) {
+            super(referenceTree, names.init, site, argtypes, typeargtypes, maxPhase);
+            if (site.isRaw()) {
+                this.site = new ClassType(site.getEnclosingType(), site.tsym.type.getTypeArguments(), site.tsym);
+                needsInference = true;
+            }
+        }
+
+        @Override
+        protected Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) {
+            Symbol sym = needsInference ?
+                findDiamond(env, site, argtypes, typeargtypes, phase.isBoxingRequired(), phase.isVarargsRequired()) :
+                findMethod(env, site, name, argtypes, typeargtypes,
+                        phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
+            return sym.kind != MTH ||
+                          site.getEnclosingType().hasTag(NONE) ||
+                          hasEnclosingInstance(env, site) ?
+                          sym : new InvalidSymbolError(Kinds.MISSING_ENCL, sym, null) {
+                    @Override
+                    JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+                       return diags.create(dkind, log.currentSource(), pos,
+                            "cant.access.inner.cls.constr", site.tsym.name, argtypes, site.getEnclosingType());
+                    }
+                };
+        }
+
+        @Override
+        ReferenceKind referenceKind(Symbol sym) {
+            return site.getEnclosingType().hasTag(NONE) ?
+                    ReferenceKind.TOPLEVEL : ReferenceKind.IMPLICIT_INNER;
+        }
     }
 
-    /** Resolve operator.
-     *  @param pos       The position to use for error reporting.
-     *  @param optag     The tag of the operation tree.
-     *  @param env       The environment current at the operation.
-     *  @param arg       The type of the operand.
+    /**
+     * Main overload resolution routine. On each overload resolution step, a
+     * lookup helper class is used to perform the method/constructor lookup;
+     * at the end of the lookup, the helper is used to validate the results
+     * (this last step might trigger overload resolution diagnostics).
      */
-    Symbol resolveUnaryOperator(DiagnosticPosition pos, int optag, Env<AttrContext> env, Type arg) {
-        return resolveOperator(pos, optag, env, List.of(arg));
+    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, MethodCheck methodCheck, LookupHelper lookupHelper) {
+        MethodResolutionContext resolveContext = new MethodResolutionContext();
+        resolveContext.methodCheck = methodCheck;
+        return lookupMethod(env, pos, location, resolveContext, lookupHelper);
     }
 
-    /** Resolve binary operator.
-     *  @param pos       The position to use for error reporting.
-     *  @param optag     The tag of the operation tree.
-     *  @param env       The environment current at the operation.
-     *  @param left      The types of the left operand.
-     *  @param right     The types of the right operand.
-     */
-    Symbol resolveBinaryOperator(DiagnosticPosition pos,
-                                 int optag,
-                                 Env<AttrContext> env,
-                                 Type left,
-                                 Type right) {
-        return resolveOperator(pos, optag, env, List.of(left, right));
+    Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location,
+            MethodResolutionContext resolveContext, LookupHelper lookupHelper) {
+        MethodResolutionContext prevResolutionContext = currentResolutionContext;
+        try {
+            Symbol bestSoFar = methodNotFound;
+            currentResolutionContext = resolveContext;
+            for (MethodResolutionPhase phase : methodResolutionSteps) {
+                if (!phase.isApplicable(boxingEnabled, varargsEnabled) ||
+                        lookupHelper.shouldStop(bestSoFar, phase)) break;
+                MethodResolutionPhase prevPhase = currentResolutionContext.step;
+                Symbol prevBest = bestSoFar;
+                currentResolutionContext.step = phase;
+                Symbol sym = lookupHelper.lookup(env, phase);
+                lookupHelper.debug(pos, sym);
+                bestSoFar = phase.mergeResults(bestSoFar, sym);
+                env.info.pendingResolutionPhase = (prevBest == bestSoFar) ? prevPhase : phase;
+            }
+            return lookupHelper.access(env, pos, location, bestSoFar);
+        } finally {
+            currentResolutionContext = prevResolutionContext;
+        }
     }
 
     /**
@@ -1748,7 +3051,7 @@ public class Resolve {
         // 'Inner classes cannot have static declarations is already reported
         // and there is no need to report 'Non-static {0} {1} cannot be referenced from a static context'.
         boolean staticInnerDecl = false;
-        if (env.tree.getTag() == JCTree.VARDEF && (TreeInfo.flags(env.tree) & (STATIC | INTERFACE)) != 0) {
+        if (env.tree.hasTag(VARDEF) && (TreeInfo.flags(env.tree) & (STATIC | INTERFACE)) != 0) {
             Symbol sym = ((JCVariableDecl)env.tree).sym;
             if (sym == null || sym.kind != VAR || ((VarSymbol) sym).getConstValue() == null) {
                 sym = env.enclClass.sym;
@@ -1764,19 +3067,55 @@ public class Resolve {
             if (env1.enclClass.sym == c) {
                 Symbol sym = env1.info.scope.lookup(name).sym;
                 if (sym != null) {
-                    if (staticOnly && !staticInnerDecl) {
-                        sym = new StaticError(sym);
-                    }
-                    return access(sym, pos, env.enclClass.sym.type,
+                    if (staticOnly && !staticInnerDecl) sym = new StaticError(sym);
+                    return accessBase(sym, pos, env.enclClass.sym.type,
                                   name, true);
                 }
             }
             if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
             env1 = env1.outer;
         }
+        if (allowDefaultMethods && c.isInterface() &&
+                name == names._super && !isStatic(env) &&
+                types.isDirectSuperInterface(c, env.enclClass.sym)) {
+            //this might be a default super call if one of the superinterfaces is 'c'
+            for (Type t : pruneInterfaces(env.enclClass.type)) {
+                if (t.tsym == c) {
+                    env.info.defaultSuperCallSite = t;
+                    return new VarSymbol(0, names._super,
+                            types.asSuper(env.enclClass.type, c), env.enclClass.sym);
+                }
+            }
+            //find a direct superinterface that is a subtype of 'c'
+            for (Type i : types.interfaces(env.enclClass.type)) {
+                if (i.tsym.isSubClass(c, types) && i.tsym != c) {
+                    log.error(pos, "illegal.default.super.call", c,
+                            diags.fragment("redundant.supertype", c, i));
+                    return syms.errSymbol;
+                }
+            }
+            Assert.error();
+        }
         log.error(pos, "not.encl.class", c);
         return syms.errSymbol;
     }
+    //where
+    private List<Type> pruneInterfaces(Type t) {
+        ListBuffer<Type> result = ListBuffer.lb();
+        for (Type t1 : types.interfaces(t)) {
+            boolean shouldAdd = true;
+            for (Type t2 : types.interfaces(t)) {
+                if (t1 != t2 && types.isSubtypeNoCapture(t2, t1)) {
+                    shouldAdd = false;
+                }
+            }
+            if (shouldAdd) {
+                result.append(t1);
+            }
+        }
+        return result.toList();
+    }
+
 
     /**
      * Resolve `c.this' for an enclosing class c that contains the
@@ -1789,6 +3128,23 @@ public class Resolve {
                                  Env<AttrContext> env,
                                  Symbol member,
                                  boolean isSuperCall) {
+        Symbol sym = resolveSelfContainingInternal(env, member, isSuperCall);
+        if (sym == null) {
+            log.error(pos, "encl.class.required", member);
+            return syms.errSymbol;
+        } else {
+            return accessBase(sym, pos, env.enclClass.sym.type, sym.name, true);
+        }
+    }
+
+    boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
+        Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
+        return encl != null && encl.kind < ERRONEOUS;
+    }
+
+    private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
+                                 Symbol member,
+                                 boolean isSuperCall) {
         Name name = names._this;
         Env<AttrContext> env1 = isSuperCall ? env.outer : env;
         boolean staticOnly = false;
@@ -1799,8 +3155,7 @@ public class Resolve {
                     Symbol sym = env1.info.scope.lookup(name).sym;
                     if (sym != null) {
                         if (staticOnly) sym = new StaticError(sym);
-                        return access(sym, pos, env.enclClass.sym.type,
-                                      name, true);
+                        return sym;
                     }
                 }
                 if ((env1.enclClass.sym.flags() & STATIC) != 0)
@@ -1808,8 +3163,7 @@ public class Resolve {
                 env1 = env1.outer;
             }
         }
-        log.error(pos, "encl.class.required", member);
-        return syms.errSymbol;
+        return null;
     }
 
     /**
@@ -1857,7 +3211,19 @@ public class Resolve {
     private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
 
     public Object methodArguments(List<Type> argtypes) {
-        return argtypes.isEmpty() ? noArgs : argtypes;
+        if (argtypes == null || argtypes.isEmpty()) {
+            return noArgs;
+        } else {
+            ListBuffer<Object> diagArgs = ListBuffer.lb();
+            for (Type t : argtypes) {
+                if (t.hasTag(DEFERRED)) {
+                    diagArgs.append(((DeferredAttr.DeferredType)t).tree);
+                } else {
+                    diagArgs.append(t);
+                }
+            }
+            return diagArgs;
+        }
     }
 
     /**
@@ -1865,7 +3231,7 @@ public class Resolve {
      * represent a different kinds of resolution error - as such they must
      * specify how they map into concrete compiler diagnostics.
      */
-    private abstract class ResolveError extends Symbol {
+    abstract class ResolveError extends Symbol {
 
         /** The name of the kind of error, for debugging only. */
         final String debugName;
@@ -1922,17 +3288,6 @@ public class Resolve {
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes);
-
-        /**
-         * A name designates an operator if it consists
-         * of a non-empty sequence of operator symbols +-~!/*%&|^<>=
-         */
-        boolean isOperator(Name name) {
-            int i = 0;
-            while (i < name.getByteLength() &&
-                   "+-~!*/%&|^<>=".indexOf(name.getByteAt(i)) >= 0) i++;
-            return i > 0 && i == name.getByteLength();
-        }
     }
 
     /**
@@ -1961,9 +3316,7 @@ public class Resolve {
 
         @Override
         public Symbol access(Name name, TypeSymbol location) {
-            if (sym.kind >= AMBIGUOUS)
-                return ((ResolveError)sym).access(name, location);
-            else if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0)
+            if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0)
                 return types.createErrorType(name, location, sym.type).tsym;
             else
                 return sym;
@@ -1993,7 +3346,7 @@ public class Resolve {
             if (name == names.error)
                 return null;
 
-            if (isOperator(name)) {
+            if (syms.operatorNames.contains(name)) {
                 boolean isUnaryOp = argtypes.size() == 1;
                 String key = argtypes.size() == 1 ?
                     "operator.cant.be.applied" :
@@ -2015,24 +3368,27 @@ public class Resolve {
                 hasLocation = !location.name.equals(names._this) &&
                         !location.name.equals(names._super);
             }
-            boolean isConstructor = kind == ABSENT_MTH &&
-                    name == names.table.names.init;
+            boolean isConstructor = kind == ABSENT_MTH && name == names.init;
             KindName kindname = isConstructor ? KindName.CONSTRUCTOR : absentKind(kind);
             Name idname = isConstructor ? site.tsym.name : name;
             String errKey = getErrorKey(kindname, typeargtypes.nonEmpty(), hasLocation);
             if (hasLocation) {
                 return diags.create(dkind, log.currentSource(), pos,
                         errKey, kindname, idname, //symbol kindname, name
-                        typeargtypes, argtypes, //type parameters and arguments (if any)
+                        typeargtypes, args(argtypes), //type parameters and arguments (if any)
                         getLocationDiag(location, site)); //location kindname, type
             }
             else {
                 return diags.create(dkind, log.currentSource(), pos,
                         errKey, kindname, idname, //symbol kindname, name
-                        typeargtypes, argtypes); //type parameters and arguments (if any)
+                        typeargtypes, args(argtypes)); //type parameters and arguments (if any)
             }
         }
         //where
+        private Object args(List<Type> args) {
+            return args.isEmpty() ? args : methodArguments(args);
+        }
+
         private String getErrorKey(KindName kindname, boolean hasTypeArgs, boolean hasLocation) {
             String key = "cant.resolve";
             String suffix = hasLocation ? ".location" : "";
@@ -2065,34 +3421,27 @@ public class Resolve {
      * (either a method, a constructor or an operand) is not applicable
      * given an actual arguments/type argument list.
      */
-    class InapplicableSymbolError extends InvalidSymbolError {
+    class InapplicableSymbolError extends ResolveError {
 
-        /** An auxiliary explanation set in case of instantiation errors. */
-        JCDiagnostic explanation;
+        protected MethodResolutionContext resolveContext;
 
-        InapplicableSymbolError(Symbol sym) {
-            super(WRONG_MTH, sym, "inapplicable symbol error");
+        InapplicableSymbolError(MethodResolutionContext context) {
+            this(WRONG_MTH, "inapplicable symbol error", context);
         }
 
-        /** Update sym and explanation and return this.
-         */
-        InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) {
-            this.sym = sym;
-            if (this.sym == sym && explanation != null)
-                this.explanation = explanation; //update the details
-            return this;
+        protected InapplicableSymbolError(int kind, String debugName, MethodResolutionContext context) {
+            super(kind, debugName);
+            this.resolveContext = context;
         }
 
-        /** Update sym and return this.
-         */
-        InapplicableSymbolError setWrongSym(Symbol sym) {
-            this.sym = sym;
-            return this;
+        @Override
+        public String toString() {
+            return super.toString();
         }
 
         @Override
-        public String toString() {
-            return super.toString() + " explanation=" + explanation;
+        public boolean exists() {
+            return true;
         }
 
         @Override
@@ -2106,7 +3455,7 @@ public class Resolve {
             if (name == names.error)
                 return null;
 
-            if (isOperator(name)) {
+            if (syms.operatorNames.contains(name)) {
                 boolean isUnaryOp = argtypes.size() == 1;
                 String key = argtypes.size() == 1 ?
                     "operator.cant.be.applied" :
@@ -2117,26 +3466,58 @@ public class Resolve {
                         key, name, first, second);
             }
             else {
-                Symbol ws = sym.asMemberOf(site, types);
+                Pair<Symbol, JCDiagnostic> c = errCandidate();
+                if (compactMethodDiags) {
+                    for (Map.Entry<Template, DiagnosticRewriter> _entry :
+                            MethodResolutionDiagHelper.rewriters.entrySet()) {
+                        if (_entry.getKey().matches(c.snd)) {
+                            JCDiagnostic simpleDiag =
+                                    _entry.getValue().rewriteDiagnostic(diags, pos,
+                                        log.currentSource(), dkind, c.snd);
+                            simpleDiag.setFlag(DiagnosticFlag.COMPRESSED);
+                            return simpleDiag;
+                        }
+                    }
+                }
+                Symbol ws = c.fst.asMemberOf(site, types);
                 return diags.create(dkind, log.currentSource(), pos,
-                          "cant.apply.symbol" + (explanation != null ? ".1" : ""),
+                          "cant.apply.symbol",
                           kindName(ws),
                           ws.name == names.init ? ws.owner.name : ws.name,
                           methodArguments(ws.type.getParameterTypes()),
                           methodArguments(argtypes),
                           kindName(ws.owner),
                           ws.owner.type,
-                          explanation);
+                          c.snd);
             }
         }
 
-        void clear() {
-            explanation = null;
-        }
-
         @Override
         public Symbol access(Name name, TypeSymbol location) {
-            return types.createErrorType(name, location, syms.errSymbol.type).tsym;
+            Candidate c = bestCandidate();
+            return types.createErrorType(name, location, c != null ? c.sym.type : syms.errSymbol.type).tsym;
+        }
+        
+        private Candidate bestCandidate() {
+            Candidate bestSoFar = null;
+            for (Candidate c : resolveContext.candidates) {
+                if (bestSoFar != null && bestSoFar.sym != c.sym) {
+                    bestSoFar = null;
+                    break;
+                }
+                bestSoFar = c;
+            }
+            return bestSoFar;
+        }
+
+        protected Pair<Symbol, JCDiagnostic> errCandidate() {
+            Candidate bestSoFar = null;
+            for (Candidate c : resolveContext.candidates) {
+                if (c.isApplicable()) continue;
+                bestSoFar = c;
+            }
+            Assert.checkNonNull(bestSoFar);
+            return new Pair<Symbol, JCDiagnostic>(bestSoFar.sym, bestSoFar.details);
         }
     }
 
@@ -2145,12 +3526,10 @@ public class Resolve {
      * (either methods, constructors or operands) is not applicable
      * given an actual arguments/type argument list.
      */
-    class InapplicableSymbolsError extends ResolveError {
+    class InapplicableSymbolsError extends InapplicableSymbolError {
 
-        private List<Candidate> candidates = List.nil();
-
-        InapplicableSymbolsError(Symbol sym) {
-            super(WRONG_MTHS, "inapplicable symbols");
+        InapplicableSymbolsError(MethodResolutionContext context) {
+            super(WRONG_MTHS, "inapplicable symbols", context);
         }
 
         @Override
@@ -2161,86 +3540,83 @@ public class Resolve {
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            if (candidates.nonEmpty()) {
+            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),
-                        getName(),
-                        argtypes);
-                return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
+                        name == names.init ? site.tsym.name : name,
+                        methodArguments(argtypes));
+                return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(filteredCandidates, site));
+            } else if (filteredCandidates.size() == 1) {
+                Map.Entry<Symbol, JCDiagnostic> _e =
+                                filteredCandidates.entrySet().iterator().next();
+                final Pair<Symbol, JCDiagnostic> p = new Pair<Symbol, JCDiagnostic>(_e.getKey(), _e.getValue());
+                JCDiagnostic d = new InapplicableSymbolError(resolveContext) {
+                    @Override
+                    protected Pair<Symbol, JCDiagnostic> errCandidate() {
+                        return p;
+                    }
+                }.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) {
-            List<JCDiagnostic> details = List.nil();
-            for (Candidate c : candidates)
-                details = details.prepend(c.getDiagnostic(site));
-            return details.reverse();
-        }
-
-        Symbol addCandidate(MethodResolutionPhase currentStep, Symbol sym, JCDiagnostic details) {
-            Candidate c = new Candidate(currentStep, sym, details);
-            if (c.isValid() && !candidates.contains(c))
-                candidates = candidates.append(c);
-            return this;
-        }
-
-        void clear() {
-            candidates = List.nil();
-        }
-
-        private Name getName() {
-            Symbol sym = candidates.head.sym;
-            return sym.name == names.init ?
-                sym.owner.name :
-                sym.name;
-        }
-
-        private class Candidate {
-
-            final MethodResolutionPhase step;
-            final Symbol sym;
-            final JCDiagnostic details;
-
-            private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details) {
-                this.step = step;
-                this.sym = sym;
-                this.details = details;
-            }
-
-            JCDiagnostic getDiagnostic(Type site) {
-                return diags.fragment("inapplicable.method",
-                        Kinds.kindName(sym),
-                        sym.location(site, types),
-                        sym.asMemberOf(site, types),
-                        details);
+            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;
             }
 
-            @Override
-            public boolean equals(Object o) {
-                if (o instanceof Candidate) {
-                    Symbol s1 = this.sym;
-                    Symbol s2 = ((Candidate)o).sym;
-                    if  ((s1 != s2 &&
-                        (s1.overrides(s2, s1.owner.type.tsym, types, false) ||
-                        (s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
-                        ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
-                        return true;
+            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 false;
+                return candidates;
             }
 
-            boolean isValid() {
-                return  (((sym.flags() & VARARGS) != 0 && step == VARARITY) ||
-                          (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC));
+            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;
             }
-        }
     }
 
     /**
@@ -2277,7 +3653,7 @@ public class Resolve {
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            if (sym.owner.type.tag == ERROR)
+            if (sym.owner.type.hasTag(ERROR))
                 return null;
 
             if (sym.name == names.init && sym.owner != site.tsym) {
@@ -2322,7 +3698,7 @@ public class Resolve {
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            Symbol errSym = ((sym.kind == TYP && sym.type.tag == CLASS)
+            Symbol errSym = ((sym.kind == TYP && sym.type.hasTag(CLASS))
                 ? types.erasure(sym.type).tsym
                 : sym);
             return diags.create(dkind, log.currentSource(), pos,
@@ -2335,14 +3711,32 @@ public class Resolve {
      * (either methods, constructors or operands) are ambiguous
      * given an actual arguments/type argument list.
      */
-    class AmbiguityError extends InvalidSymbolError {
+    class AmbiguityError extends ResolveError {
 
         /** The other maximally specific symbol */
-        Symbol sym2;
+        List<Symbol> ambiguousSyms = List.nil();
+
+        @Override
+        public boolean exists() {
+            return true;
+        }
 
         AmbiguityError(Symbol sym1, Symbol sym2) {
-            super(AMBIGUOUS, sym1, "ambiguity error");
-            this.sym2 = sym2;
+            super(AMBIGUOUS, "ambiguity error");
+            ambiguousSyms = flatten(sym2).appendList(flatten(sym1));
+        }
+
+        private List<Symbol> flatten(Symbol sym) {
+            if (sym.kind == AMBIGUOUS) {
+                return ((AmbiguityError)sym).ambiguousSyms;
+            } else {
+                return List.of(sym);
+            }
+        }
+
+        AmbiguityError addAmbiguousSymbol(Symbol s) {
+            ambiguousSyms = ambiguousSyms.prepend(s);
+            return this;
         }
 
         @Override
@@ -2353,34 +3747,223 @@ public class Resolve {
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            AmbiguityError pair = this;
-            while (true) {
-                if (pair.sym.kind == AMBIGUOUS)
-                    pair = (AmbiguityError)pair.sym;
-                else if (pair.sym2.kind == AMBIGUOUS)
-                    pair = (AmbiguityError)pair.sym2;
-                else break;
-            }
-            Name sname = pair.sym.name;
-            if (sname == names.init) sname = pair.sym.owner.name;
+            List<Symbol> diagSyms = ambiguousSyms.reverse();
+            Symbol s1 = diagSyms.head;
+            Symbol s2 = diagSyms.tail.head;
+            Name sname = s1.name;
+            if (sname == names.init) sname = s1.owner.name;
             return diags.create(dkind, log.currentSource(),
                       pos, "ref.ambiguous", sname,
-                      kindName(pair.sym),
-                      pair.sym,
-                      pair.sym.location(site, types),
-                      kindName(pair.sym2),
-                      pair.sym2,
-                      pair.sym2.location(site, types));
+                      kindName(s1),
+                      s1,
+                      s1.location(site, types),
+                      kindName(s2),
+                      s2,
+                      s2.location(site, types));
+        }
+
+        /**
+         * If multiple applicable methods are found during overload and none of them
+         * is more specific than the others, attempt to merge their signatures.
+         */
+        Symbol mergeAbstracts(Type site) {
+            List<Symbol> ambiguousInOrder = ambiguousSyms.reverse();
+            for (Symbol s : ambiguousInOrder) {
+                Type mt = types.memberType(site, s);
+                boolean found = true;
+                List<Type> allThrown = mt.getThrownTypes();
+                for (Symbol s2 : ambiguousInOrder) {
+                    Type mt2 = types.memberType(site, s2);
+                    if ((s2.flags() & ABSTRACT) == 0 ||
+                        !types.overrideEquivalent(mt, mt2) ||
+                        !types.isSameTypes(s.erasure(types).getParameterTypes(),
+                                       s2.erasure(types).getParameterTypes())) {
+                        //ambiguity cannot be resolved
+                        return this;
+                    }
+                    Type mst = mostSpecificReturnType(mt, mt2);
+                    if (mst == null || mst != mt) {
+                        found = false;
+                        break;
+                    }
+                    allThrown = chk.intersect(allThrown, mt2.getThrownTypes());
+                }
+                if (found) {
+                    //all ambiguous methods were abstract and one method had
+                    //most specific return type then others
+                    return (allThrown == mt.getThrownTypes()) ?
+                            s : new MethodSymbol(
+                                s.flags(),
+                                s.name,
+                                types.createMethodTypeWithThrown(mt, allThrown),
+                                s.owner);
+                }
+            }
+            return this;
+        }
+
+        @Override
+        protected Symbol access(Name name, TypeSymbol location) {
+            Symbol firstAmbiguity = ambiguousSyms.last();
+            return firstAmbiguity.kind == TYP ?
+                    types.createErrorType(name, location, firstAmbiguity.type).tsym :
+                    firstAmbiguity;
+        }
+    }
+
+    class BadVarargsMethod extends ResolveError {
+
+        ResolveError delegatedError;
+
+        BadVarargsMethod(ResolveError delegatedError) {
+            super(delegatedError.kind, "badVarargs");
+            this.delegatedError = delegatedError;
+        }
+
+        @Override
+        public Symbol baseSymbol() {
+            return delegatedError.baseSymbol();
+        }
+
+        @Override
+        protected Symbol access(Name name, TypeSymbol location) {
+            return delegatedError.access(name, location);
+        }
+
+        @Override
+        public boolean exists() {
+            return true;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+            return delegatedError.getDiagnostic(dkind, pos, location, site, name, argtypes, typeargtypes);
+        }
+    }
+
+    /**
+     * 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;
+                if (d == null) {
+                    return false;
+                }
+                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),
-        VARARITY(true, true);
+        VARARITY(true, true) {
+            @Override
+            public Symbol mergeResults(Symbol bestSoFar, Symbol sym) {
+                switch (sym.kind) {
+                    case WRONG_MTH:
+                        return (bestSoFar.kind == WRONG_MTH || bestSoFar.kind == WRONG_MTHS) ?
+                            bestSoFar :
+                            sym;
+                    case ABSENT_MTH:
+                        return bestSoFar;
+                    default:
+                        return sym;
+                }
+            }
+        };
 
-        boolean isBoxingRequired;
-        boolean isVarargsRequired;
+        final boolean isBoxingRequired;
+        final boolean isVarargsRequired;
 
         MethodResolutionPhase(boolean isBoxingRequired, boolean isVarargsRequired) {
            this.isBoxingRequired = isBoxingRequired;
@@ -2399,26 +3982,95 @@ public class Resolve {
             return (varargsEnabled || !isVarargsRequired) &&
                    (boxingEnabled || !isBoxingRequired);
         }
-    }
 
-    private Map<MethodResolutionPhase, Symbol> methodResolutionCache =
-        new HashMap<MethodResolutionPhase, Symbol>(MethodResolutionPhase.values().length);
+        public Symbol mergeResults(Symbol prev, Symbol sym) {
+            return sym;
+        }
+    }
 
     final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY);
 
-    private MethodResolutionPhase currentStep = null;
+    /**
+     * A resolution context is used to keep track of intermediate results of
+     * overload resolution, such as list of method that are not applicable
+     * (used to generate more precise diagnostics) and so on. Resolution contexts
+     * can be nested - this means that when each overload resolution routine should
+     * work within the resolution context it created.
+     */
+    class MethodResolutionContext {
+
+        private List<Candidate> candidates = List.nil();
+
+        MethodResolutionPhase step = null;
+
+        MethodCheck methodCheck = resolveMethodCheck;
+
+        private boolean internalResolution = false;
+        private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
 
-    private MethodResolutionPhase firstErroneousResolutionPhase() {
-        MethodResolutionPhase bestSoFar = BASIC;
-        Symbol sym = methodNotFound;
-        List<MethodResolutionPhase> steps = methodResolutionSteps;
-        while (steps.nonEmpty() &&
-               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
-               sym.kind >= WRONG_MTHS) {
-            sym = methodResolutionCache.get(steps.head);
-            bestSoFar = steps.head;
-            steps = steps.tail;
+        void addInapplicableCandidate(Symbol sym, JCDiagnostic details) {
+            Candidate c = new Candidate(currentResolutionContext.step, sym, details, null);
+            candidates = candidates.append(c);
+        }
+
+        void addApplicableCandidate(Symbol sym, Type mtype) {
+            Candidate c = new Candidate(currentResolutionContext.step, sym, null, mtype);
+            candidates = candidates.append(c);
+        }
+
+        DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) {
+            return deferredAttr.new DeferredAttrContext(attrMode, sym, step, inferenceContext, pendingResult != null ? pendingResult.checkContext.deferredAttrContext() : deferredAttr.emptyDeferredAttrContext, warn);
+        }
+
+        /**
+         * This class represents an overload resolution candidate. There are two
+         * kinds of candidates: applicable methods and inapplicable methods;
+         * applicable methods have a pointer to the instantiated method type,
+         * while inapplicable candidates contain further details about the
+         * reason why the method has been considered inapplicable.
+         */
+        @SuppressWarnings("overrides")
+        class Candidate {
+
+            final MethodResolutionPhase step;
+            final Symbol sym;
+            final JCDiagnostic details;
+            final Type mtype;
+
+            private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details, Type mtype) {
+                this.step = step;
+                this.sym = sym;
+                this.details = details;
+                this.mtype = mtype;
+            }
+
+            @Override
+            public boolean equals(Object o) {
+                if (o instanceof Candidate) {
+                    Symbol s1 = this.sym;
+                    Symbol s2 = ((Candidate)o).sym;
+                    if  ((s1 != s2 &&
+                            (s1.overrides(s2, s1.owner.type.tsym, types, false) ||
+                            (s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
+                            ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
+                        return true;
+                }
+                return false;
+            }
+
+            boolean isApplicable() {
+                return mtype != null;
+            }
+        }
+
+        DeferredAttr.AttrMode attrMode() {
+            return attrMode;
+        }
+
+        boolean internal() {
+            return internalResolution;
         }
-        return bestSoFar;
     }
+
+    MethodResolutionContext currentResolutionContext = null;
 }
diff --git a/src/share/classes/com/sun/tools/javac/comp/Todo.java b/src/share/classes/com/sun/tools/javac/comp/Todo.java
index 84f1cb8..3f81c01 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Todo.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Todo.java
@@ -25,7 +25,7 @@
 
 package com.sun.tools.javac.comp;
 
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.Context;
 import java.util.AbstractQueue;
@@ -108,10 +108,11 @@ public class Todo extends AbstractQueue<Env<AttrContext>> {
         return contentsByFile;
     }
 
-    void remove(ClassSymbol cs) {
+    void remove(TypeSymbol sym) {
         for (Iterator<Env<AttrContext>> it = contents.listIterator(); it.hasNext();) {
             Env<AttrContext> env = it.next();
-            if (env.tree != null && env.tree.getTag() == JCTree.CLASSDEF && ((JCTree.JCClassDecl)env.tree).sym == cs) {
+            if (env.tree != null && (env.tree.hasTag(JCTree.Tag.CLASSDEF) && ((JCTree.JCClassDecl)env.tree).sym == sym
+                    || env.tree.hasTag(JCTree.Tag.TOPLEVEL) && ((JCTree.JCCompilationUnit)env.tree).packge == sym)) {
                 it.remove();
                 if (contentsByFile != null)
                     removeByFile(env);
diff --git a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
index 4fa7608..31fa14b 100644
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -27,8 +27,6 @@ package com.sun.tools.javac.comp;
 
 import java.util.*;
 
-import javax.lang.model.element.ElementKind;
-
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
@@ -39,7 +37,10 @@ import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
+import static com.sun.tools.javac.code.TypeTag.VOID;
+import static com.sun.tools.javac.comp.CompileStates.CompileState;
 
 /** This pass translates Generic Java to conventional Java.
  *
@@ -67,6 +68,7 @@ public class TransTypes extends TreeTranslator {
     private TreeMaker make;
     private Enter enter;
     private boolean allowEnums;
+    private boolean allowInterfaceBridges;
     private Types types;
     private final Resolve resolve;
 
@@ -77,8 +79,11 @@ public class TransTypes extends TreeTranslator {
      */
     private final boolean addBridges;
 
+    private final CompileStates compileStates;
+
     protected TransTypes(Context context) {
         context.put(transTypesKey, this);
+        compileStates = CompileStates.instance(context);
         names = Names.instance(context);
         log = Log.instance(context);
         syms = Symtab.instance(context);
@@ -87,6 +92,7 @@ public class TransTypes extends TreeTranslator {
         Source source = Source.instance(context);
         allowEnums = source.allowEnums();
         addBridges = source.addBridges();
+        allowInterfaceBridges = source.allowDefaultMethods();
         types = Types.instance(context);
         make = TreeMaker.instance(context);
         resolve = Resolve.instance(context);
@@ -120,10 +126,20 @@ public class TransTypes extends TreeTranslator {
      *  @param tree    The expression tree.
      *  @param target  The target type.
      */
+    public JCExpression coerce(Env<AttrContext> env, JCExpression tree, Type target) {
+        Env<AttrContext> prevEnv = this.env;
+        try {
+            this.env = env;
+            return coerce(tree, target);
+        }
+        finally {
+            this.env = prevEnv;
+        }
+    }
     JCExpression coerce(JCExpression tree, Type target) {
         Type btarget = target.baseType();
         if (tree.type.isPrimitive() == target.isPrimitive()) {
-            return types.isAssignable(tree.type, btarget, Warner.noWarnings)
+            return types.isAssignable(tree.type, btarget, types.noWarnings)
                 ? tree
                 : cast(tree, btarget);
         }
@@ -134,17 +150,21 @@ public class TransTypes extends TreeTranslator {
      *  Then, coerce to some given target type unless target type is null.
      *  This operation is used in situations like the following:
      *
+     *  <pre>{@code
      *  class Cell<A> { A value; }
      *  ...
      *  Cell<Integer> cell;
      *  Integer x = cell.value;
+     *  }</pre>
      *
      *  Since the erasure of Cell.value is Object, but the type
      *  of cell.value in the assignment is Integer, we need to
      *  adjust the original type of cell.value to Object, and insert
      *  a cast to Integer. That is, the last assignment becomes:
      *
+     *  <pre>{@code
      *  Integer x = (Integer)cell.value;
+     *  }</pre>
      *
      *  @param tree       The expression tree whose type might need adjustment.
      *  @param erasedType The expression's type after erasure.
@@ -153,11 +173,14 @@ public class TransTypes extends TreeTranslator {
      */
     JCExpression retype(JCExpression tree, Type erasedType, Type target) {
 //      System.err.println("retype " + tree + " to " + erasedType);//DEBUG
-        if (erasedType.tag > lastBaseTag) {
-            if (target != null && target.isPrimitive())
+        if (!erasedType.isPrimitive()) {
+            if (target != null && target.isPrimitive()) {
                 target = erasure(tree.type);
+            }
             tree.type = erasedType;
-            if (target != null) return coerce(tree, target);
+            if (target != null) {
+                return coerce(tree, target);
+            }
         }
         return tree;
     }
@@ -192,6 +215,20 @@ public class TransTypes extends TreeTranslator {
         return _args;
     }
 
+    public <T extends JCTree> List<T> translateArgs(List<T> _args,
+                                           List<Type> parameters,
+                                           Type varargsElement,
+                                           Env<AttrContext> localEnv) {
+        Env<AttrContext> prevEnv = env;
+        try {
+            env = localEnv;
+            return translateArgs(_args, parameters, varargsElement);
+        }
+        finally {
+            env = prevEnv;
+        }
+    }
+
     /** Add a bridge definition and enter corresponding method symbol in
      *  local scope of origin.
      *
@@ -217,12 +254,19 @@ public class TransTypes extends TreeTranslator {
 
         // Create a bridge method symbol and a bridge definition without a body.
         Type bridgeType = meth.erasure(types);
-        long flags = impl.flags() & AccessFlags | SYNTHETIC | BRIDGE;
+        long flags = impl.flags() & AccessFlags | SYNTHETIC | BRIDGE |
+                (origin.isInterface() ? DEFAULT : 0);
         if (hypothetical) flags |= HYPOTHETICAL;
         MethodSymbol bridge = new MethodSymbol(flags,
                                                meth.name,
                                                bridgeType,
                                                origin);
+        /* once JDK-6996415 is solved it should be checked if this approach can
+         * be applied to method addOverrideBridgesIfNeeded
+         */
+        bridge.params = createBridgeParams(impl, bridge, bridgeType);
+        bridge.setAttributes(impl);
+
         if (!hypothetical) {
             JCMethodDecl md = make.MethodDef(bridge, null);
 
@@ -243,7 +287,7 @@ public class TransTypes extends TreeTranslator {
                            make.Select(receiver, impl).setType(calltype),
                            translateArgs(make.Idents(md.params), origErasure.getParameterTypes(), null))
                 .setType(calltype);
-            JCStatement stat = (origErasure.getReturnType().tag == VOID)
+            JCStatement stat = (origErasure.getReturnType().hasTag(VOID))
                 ? make.Exec(call)
                 : make.Return(coerce(call, bridgeType.getReturnType()));
             md.body = make.Block(0, List.of(stat));
@@ -257,6 +301,26 @@ public class TransTypes extends TreeTranslator {
         overridden.put(bridge, meth);
     }
 
+    private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge,
+            Type bridgeType) {
+        List<VarSymbol> bridgeParams = null;
+        if (impl.params != null) {
+            bridgeParams = List.nil();
+            List<VarSymbol> implParams = impl.params;
+            Type.MethodType mType = (Type.MethodType)bridgeType;
+            List<Type> argTypes = mType.argtypes;
+            while (implParams.nonEmpty() && argTypes.nonEmpty()) {
+                VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC,
+                        implParams.head.name, argTypes.head, bridge);
+                param.setAttributes(implParams.head);
+                bridgeParams = bridgeParams.append(param);
+                implParams = implParams.tail;
+                argTypes = argTypes.tail;
+            }
+        }
+        return bridgeParams;
+    }
+
     /** Add bridge if given symbol is a non-private, non-static member
      *  of the given class, which is either defined in the class or non-final
      *  inherited, and one of the two following conditions holds:
@@ -326,11 +390,12 @@ public class TransTypes extends TreeTranslator {
         }
     }
     // where
-        Filter<Symbol> overrideBridgeFilter = new Filter<Symbol>() {
+        private Filter<Symbol> overrideBridgeFilter = new Filter<Symbol>() {
             public boolean accepts(Symbol s) {
                 return (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC;
             }
         };
+
         /**
          * @param method The symbol for which a bridge might have to be added
          * @param impl The implementation of method
@@ -400,7 +465,7 @@ public class TransTypes extends TreeTranslator {
      */
     void addBridges(DiagnosticPosition pos, ClassSymbol origin, ListBuffer<JCTree> bridges) {
         Type st = types.supertype(origin.type);
-        while (st.tag == CLASS) {
+        while (st.hasTag(CLASS)) {
 //          if (isSpecialization(st))
             addBridges(pos, st.tsym, origin, bridges);
             st = types.supertype(st);
@@ -449,14 +514,15 @@ public class TransTypes extends TreeTranslator {
         result = tree;
     }
 
-    JCMethodDecl currentMethod = null;
+    JCTree currentMethod = null;
     public void visitMethodDef(JCMethodDecl tree) {
-        JCMethodDecl previousMethod = currentMethod;
+        JCTree previousMethod = currentMethod;
         try {
             currentMethod = tree;
             tree.restype = translate(tree.restype, null);
             tree.typarams = List.nil();
             tree.params = translateVarDefs(tree.params);
+            tree.recvparam = translate(tree.recvparam, null);
             tree.thrown = translate(tree.thrown, null);
             tree.body = translate(tree.body, tree.sym.erasure(types).getReturnType());
             tree.type = erasure(tree.type);
@@ -517,6 +583,20 @@ public class TransTypes extends TreeTranslator {
         result = tree;
     }
 
+    public void visitLambda(JCLambda tree) {
+        JCTree prevMethod = currentMethod;
+        try {
+            currentMethod = null;
+            tree.params = translate(tree.params);
+            tree.body = translate(tree.body, null);
+            tree.type = erasure(tree.type);
+            result = tree;
+        }
+        finally {
+            currentMethod = prevMethod;
+        }
+    }
+
     public void visitSwitch(JCSwitch tree) {
         Type selsuper = types.supertype(tree.selector.type);
         boolean enumSwitch = selsuper != null &&
@@ -568,7 +648,7 @@ public class TransTypes extends TreeTranslator {
     }
 
     public void visitReturn(JCReturn tree) {
-        tree.expr = translate(tree.expr, currentMethod.sym.erasure(types).getReturnType());
+        tree.expr = translate(tree.expr, currentMethod != null ? types.erasure(currentMethod.type).getReturnType() : null);
         result = tree;
     }
 
@@ -599,19 +679,28 @@ public class TransTypes extends TreeTranslator {
             Assert.check(tree.args.length() == argtypes.length());
         tree.args = translateArgs(tree.args, argtypes, tree.varargsElement);
 
+        tree.type = types.erasure(tree.type);
         // Insert casts of method invocation results as needed.
         result = retype(tree, mt.getReturnType(), pt);
     }
 
     public void visitNewClass(JCNewClass tree) {
-        if (tree.encl != null)
-            tree.encl = translate(tree.encl, erasure(tree.encl.type));
+        if (tree.encl != null) {
+            if (tree.def == null) {
+                tree.encl = translate(tree.encl, erasure(tree.encl.type));
+            } else {
+                //originally was deleted in Attr.visitNewClass
+                tree.encl = null;
+            }
+        }
         tree.clazz = translate(tree.clazz, null);
         if (tree.varargsElement != null)
             tree.varargsElement = types.erasure(tree.varargsElement);
         tree.args = translateArgs(
             tree.args, tree.constructor.erasure(types).getParameterTypes(), tree.varargsElement);
         tree.def = translate(tree.def, null);
+        if (tree.constructorType != null)
+            tree.constructorType = erasure(tree.constructorType);
         tree.type = erasure(tree.type);
         result = tree;
     }
@@ -638,8 +727,8 @@ public class TransTypes extends TreeTranslator {
     public void visitAssign(JCAssign tree) {
         tree.lhs = translate(tree.lhs, null);
         tree.rhs = translate(tree.rhs, erasure(tree.lhs.type));
-        tree.type = erasure(tree.type);
-        result = tree;
+        tree.type = erasure(tree.lhs.type);
+        result = retype(tree, tree.type, pt);
     }
 
     public void visitAssignop(JCAssignOp tree) {
@@ -662,8 +751,18 @@ public class TransTypes extends TreeTranslator {
 
     public void visitTypeCast(JCTypeCast tree) {
         tree.clazz = translate(tree.clazz, null);
+        Type originalTarget = tree.type;
         tree.type = erasure(tree.type);
         tree.expr = translate(tree.expr, tree.type);
+        if (originalTarget.isCompound()) {
+            Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget;
+            for (Type c : ict.getExplicitComponents()) {
+                Type ec = erasure(c);
+                if (!types.isSameType(ec, tree.type)) {
+                    tree.expr = coerce(tree.expr, ec);
+                }
+            }
+        }
         result = tree;
     }
 
@@ -691,7 +790,7 @@ public class TransTypes extends TreeTranslator {
         Type et = tree.sym.erasure(types);
 
         // Map type variables to their bounds.
-        if (tree.sym.kind == TYP && tree.sym.type.tag == TYPEVAR) {
+        if (tree.sym.kind == TYP && tree.sym.type.hasTag(TYPEVAR)) {
             result = make.at(tree.pos).Type(et);
         } else
         // Map constants expressions to themselves.
@@ -710,7 +809,7 @@ public class TransTypes extends TreeTranslator {
 
     public void visitSelect(JCFieldAccess tree) {
         Type t = tree.selected.type;
-        while (t.tag == TYPEVAR)
+        while (t.hasTag(TYPEVAR))
             t = t.getUpperBound();
         if (t.isCompound()) {
             if ((tree.sym.flags() & IPROXY) != 0) {
@@ -737,6 +836,12 @@ public class TransTypes extends TreeTranslator {
         }
     }
 
+    public void visitReference(JCMemberReference tree) {
+        tree.expr = translate(tree.expr, null);
+        tree.type = erasure(tree.type);
+        result = tree;
+    }
+
     public void visitTypeArray(JCArrayTypeTree tree) {
         tree.elemtype = translate(tree.elemtype, null);
         tree.type = erasure(tree.type);
@@ -750,6 +855,12 @@ public class TransTypes extends TreeTranslator {
         result = clazz;
     }
 
+    public void visitTypeIntersection(JCTypeIntersection tree) {
+        tree.bounds = translate(tree.bounds, null);
+        tree.type = erasure(tree.type);
+        result = tree;
+    }
+
 /**************************************************************************
  * utility methods
  *************************************************************************/
@@ -834,7 +945,7 @@ public class TransTypes extends TreeTranslator {
                        translateArgs(make.Idents(md.params),
                                      implErasure.getParameterTypes(), null))
             .setType(calltype);
-        JCStatement stat = (member.getReturnType().tag == VOID)
+        JCStatement stat = (member.getReturnType().hasTag(VOID))
             ? make.Exec(call)
             : make.Return(coerce(call, member.erasure(types).getReturnType()));
         md.body = make.Block(0, List.of(stat));
@@ -848,16 +959,40 @@ public class TransTypes extends TreeTranslator {
 
     private Env<AttrContext> env;
 
+    private static final String statePreviousToFlowAssertMsg =
+            "The current compile state [%s] of class %s is previous to FLOW";
+
     void translateClass(ClassSymbol c) {
         Type st = types.supertype(c.type);
-
         // process superclass before derived
-        if (st.tag == CLASS)
+        if (st.hasTag(CLASS)) {
             translateClass((ClassSymbol)st.tsym);
+        }
 
         Env<AttrContext> myEnv = enter.typeEnvs.remove(c);
-        if (myEnv == null)
+        if (myEnv == null) {
             return;
+        }
+
+        /*  The two assertions below are set for early detection of any attempt
+         *  to translate a class that:
+         *
+         *  1) has no compile state being it the most outer class.
+         *     We accept this condition for inner classes.
+         *
+         *  2) has a compile state which is previous to Flow state.
+         */
+        boolean envHasCompState = compileStates.get(myEnv) != null;
+        if (!envHasCompState && c.outermostClass() == c) {
+            Assert.error("No info for outermost class: " + myEnv.enclClass.sym);
+        }
+
+        if (envHasCompState &&
+                CompileState.FLOW.isAfter(compileStates.get(myEnv))) {
+            Assert.error(String.format(statePreviousToFlowAssertMsg,
+                    compileStates.get(myEnv), myEnv.enclClass.sym));
+        }
+
         Env<AttrContext> oldEnv = env;
         try {
             env = myEnv;
@@ -876,8 +1011,9 @@ public class TransTypes extends TreeTranslator {
                     ListBuffer<JCTree> bridges = new ListBuffer<JCTree>();
                     if (false) //see CR: 6996415
                         bridges.appendList(addOverrideBridgesIfNeeded(tree, c));
-                    if ((tree.sym.flags() & INTERFACE) == 0)
-                        addBridges(tree.pos(), tree.sym, bridges);
+                    if (allowInterfaceBridges || (tree.sym.flags() & INTERFACE) == 0) {
+                        addBridges(tree.pos(), c, bridges);
+                    }
                     tree.defs = bridges.toList().prependList(tree.defs);
                 }
                 tree.type = erasure(tree.type);
diff --git a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
index ff10fd3..e49e9e0 100644
--- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.file;
 
-import java.util.Comparator;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -41,6 +40,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -56,14 +56,12 @@ import javax.tools.StandardJavaFileManager;
 
 import com.sun.tools.javac.file.RelativePath.RelativeFile;
 import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
-import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.BaseFileManager;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 
 import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.main.OptionName.*;
 
 /**
  * This class provides access to the source, class and other files
@@ -83,34 +81,16 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
             return buffer.toString().toCharArray();
     }
 
-    /** Encapsulates knowledge of paths
-     */
-    private Paths paths;
-
     private FSInfo fsInfo;
 
     private boolean contextUseOptimizedZip;
     private ZipFileIndexCache zipFileIndexCache;
 
-    private final File uninited = new File("U N I N I T E D");
-
     private final Set<JavaFileObject.Kind> sourceOrClass =
         EnumSet.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS);
 
-    /** The standard output directory, primarily used for classes.
-     *  Initialized by the "-d" option.
-     *  If classOutDir = null, files are written into same directory as the sources
-     *  they were generated from.
-     */
-    private File classOutDir = uninited;
-
-    /** The output directory, used when generating sources while processing annotations.
-     *  Initialized by the "-s" option.
-     */
-    private File sourceOutDir = uninited;
-
     protected boolean mmappedIO;
-    protected boolean ignoreSymbolFile;
+    protected boolean symbolFileEnabled;
 
     protected enum SortFiles implements Comparator<File> {
         FORWARD {
@@ -154,13 +134,6 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
     @Override
     public void setContext(Context context) {
         super.setContext(context);
-        if (paths == null) {
-            paths = Paths.instance(context);
-        } else {
-            // Reuse the Paths object as it stores the locations that
-            // have been set with setLocation, etc.
-            paths.setContext(context);
-        }
 
         fsInfo = FSInfo.instance(context);
 
@@ -169,7 +142,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
             zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
 
         mmappedIO = options.isSet("mmappedIO");
-        ignoreSymbolFile = options.isSet("ignore.symbol.file");
+        symbolFileEnabled = !options.isSet("ignore.symbol.file");
 
         String sf = options.get("sortFiles");
         if (sf != null) {
@@ -177,9 +150,16 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
         }
     }
 
+    /**
+     * Set whether or not to use ct.sym as an alternate to rt.jar.
+     */
+    public void setSymbolFileEnabled(boolean b) {
+        symbolFileEnabled = b;
+    }
+
     @Override
     public boolean isDefaultBootClassPath() {
-        return paths.isDefaultBootClassPath();
+        return locations.isDefaultBootClassPath();
     }
 
     public JavaFileObject getFileForInput(String name) {
@@ -493,7 +473,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
      */
     private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException {
         File origZipFileName = zipFileName;
-        if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) {
+        if (symbolFileEnabled && locations.isDefaultBootClassPathRtJar(zipFileName)) {
             File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
             if (new File(file.getName()).equals(new File("jre")))
                 file = file.getParentFile();
@@ -780,7 +760,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
         } else if (location == SOURCE_OUTPUT) {
             dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir());
         } else {
-            Iterable<? extends File> path = paths.getPathForLocation(location);
+            Iterable<? extends File> path = locations.getLocation(location);
             dir = null;
             for (File f: path) {
                 dir = f;
@@ -815,69 +795,25 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
         throws IOException
     {
         nullCheck(location);
-        paths.lazy();
-
-        final File dir = location.isOutputLocation() ? getOutputDirectory(path) : null;
-
-        if (location == CLASS_OUTPUT)
-            classOutDir = getOutputLocation(dir, D);
-        else if (location == SOURCE_OUTPUT)
-            sourceOutDir = getOutputLocation(dir, S);
-        else
-            paths.setPathForLocation(location, path);
-    }
-    // where
-        private File getOutputDirectory(Iterable<? extends File> path) throws IOException {
-            if (path == null)
-                return null;
-            Iterator<? extends File> pathIter = path.iterator();
-            if (!pathIter.hasNext())
-                throw new IllegalArgumentException("empty path for directory");
-            File dir = pathIter.next();
-            if (pathIter.hasNext())
-                throw new IllegalArgumentException("path too long for directory");
-            if (!dir.exists())
-                throw new FileNotFoundException(dir + ": does not exist");
-            else if (!dir.isDirectory())
-                throw new IOException(dir + ": not a directory");
-            return dir;
-        }
-
-    private File getOutputLocation(File dir, OptionName defaultOptionName) {
-        if (dir != null)
-            return dir;
-        String arg = options.get(defaultOptionName);
-        if (arg == null)
-            return null;
-        return new File(arg);
+        locations.setLocation(location, path);
     }
 
     public Iterable<? extends File> getLocation(Location location) {
         nullCheck(location);
-        paths.lazy();
-        if (location == CLASS_OUTPUT) {
-            return (getClassOutDir() == null ? null : List.of(getClassOutDir()));
-        } else if (location == SOURCE_OUTPUT) {
-            return (getSourceOutDir() == null ? null : List.of(getSourceOutDir()));
-        } else
-            return paths.getPathForLocation(location);
+        return locations.getLocation(location);
     }
 
     private File getClassOutDir() {
-        if (classOutDir == uninited)
-            classOutDir = getOutputLocation(null, D);
-        return classOutDir;
+        return locations.getOutputLocation(CLASS_OUTPUT);
     }
 
     private File getSourceOutDir() {
-        if (sourceOutDir == uninited)
-            sourceOutDir = getOutputLocation(null, S);
-        return sourceOutDir;
+        return locations.getOutputLocation(SOURCE_OUTPUT);
     }
 
     /**
-     * Enforces the specification of a "relative" URI as used in
-     * {@linkplain #getFileForInput(Location,String,URI)
+     * Enforces the specification of a "relative" name as used in
+     * {@linkplain #getFileForInput(Location,String,String)
      * getFileForInput}.  This method must follow the rules defined in
      * that method, do not make any changes without consulting the
      * specification.
diff --git a/src/share/classes/com/sun/tools/javac/file/Locations.java b/src/share/classes/com/sun/tools/javac/file/Locations.java
new file mode 100644
index 0000000..7ee850b
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/file/Locations.java
@@ -0,0 +1,776 @@
+/*
+ * 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.javac.file;
+
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.zip.ZipFile;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+
+import javax.tools.JavaFileManager;
+import javax.tools.StandardJavaFileManager;
+import static javax.tools.StandardLocation.*;
+import static com.sun.tools.javac.main.Option.*;
+
+/** This class converts command line arguments, environment variables
+ *  and system properties (in File.pathSeparator-separated String form)
+ *  into a boot class path, user class path, and source path (in
+ *  {@code Collection<String>} form).
+ *
+ *  <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 Locations {
+
+    /** The log to use for warning output */
+    private Log log;
+
+    /** Collection of command-line options */
+    private Options options;
+
+    /** Handler for -Xlint options */
+    private Lint lint;
+
+    /** Access to (possibly cached) file info */
+    private FSInfo fsInfo;
+
+    /** Whether to warn about non-existent path elements */
+    private boolean warn;
+
+    // TODO: remove need for this
+    private boolean inited = false; // TODO? caching bad?
+
+    public Locations() {
+        initHandlers();
+    }
+
+    public void update(Log log, Options options, Lint lint, FSInfo fsInfo) {
+        this.log = log;
+        this.options = options;
+        this.lint = lint;
+        this.fsInfo = fsInfo;
+    }
+
+    public Collection<File> bootClassPath() {
+        return getLocation(PLATFORM_CLASS_PATH);
+    }
+
+    public boolean isDefaultBootClassPath() {
+        BootClassPathLocationHandler h =
+                (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
+        return h.isDefault();
+    }
+
+    boolean isDefaultBootClassPathRtJar(File file) {
+        BootClassPathLocationHandler h =
+                (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
+        return h.isDefaultRtJar(file);
+    }
+
+    public Collection<File> userClassPath() {
+        return getLocation(CLASS_PATH);
+    }
+
+    public Collection<File> sourcePath() {
+        Collection<File> p = getLocation(SOURCE_PATH);
+        // TODO: this should be handled by the LocationHandler
+        return p == null || p.isEmpty() ? null : p;
+    }
+
+    /**
+     * Split a path into its elements. Empty path elements will be ignored.
+     * @param path The path to be split
+     * @return The elements of the path
+     */
+    private static Iterable<File> getPathEntries(String path) {
+        return getPathEntries(path, null);
+    }
+
+    /**
+     * Split a path into its elements. If emptyPathDefault is not null, all
+     * empty elements in the path, including empty elements at either end of
+     * the path, will be replaced with the value of emptyPathDefault.
+     * @param path The path to be split
+     * @param emptyPathDefault The value to substitute for empty path elements,
+     *  or null, to ignore empty path elements
+     * @return The elements of the path
+     */
+    private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
+        ListBuffer<File> entries = new ListBuffer<File>();
+        int start = 0;
+        while (start <= path.length()) {
+            int sep = path.indexOf(File.pathSeparatorChar, start);
+            if (sep == -1)
+                sep = path.length();
+            if (start < sep)
+                entries.add(new File(path.substring(start, sep)));
+            else if (emptyPathDefault != null)
+                entries.add(emptyPathDefault);
+            start = sep + 1;
+        }
+        return entries;
+    }
+
+    /**
+     * Utility class to help evaluate a path option.
+     * Duplicate entries are ignored, jar class paths can be expanded.
+     */
+    private class Path extends LinkedHashSet<File> {
+        private static final long serialVersionUID = 0;
+
+        private boolean expandJarClassPaths = false;
+        private Set<File> canonicalValues = new HashSet<File>();
+
+        public Path expandJarClassPaths(boolean x) {
+            expandJarClassPaths = x;
+            return this;
+        }
+
+        /** What to use when path element is the empty string */
+        private File emptyPathDefault = null;
+
+        public Path emptyPathDefault(File x) {
+            emptyPathDefault = x;
+            return this;
+        }
+
+        public Path() { super(); }
+
+        public Path addDirectories(String dirs, boolean warn) {
+            boolean prev = expandJarClassPaths;
+            expandJarClassPaths = true;
+            try {
+                if (dirs != null)
+                    for (File dir : getPathEntries(dirs))
+                        addDirectory(dir, warn);
+                return this;
+            } finally {
+                expandJarClassPaths = prev;
+            }
+        }
+
+        public Path addDirectories(String dirs) {
+            return addDirectories(dirs, warn);
+        }
+
+        private void addDirectory(File dir, boolean warn) {
+            if (!dir.isDirectory()) {
+                if (warn)
+                    log.warning(Lint.LintCategory.PATH,
+                            "dir.path.element.not.found", dir);
+                return;
+            }
+
+            File[] files = dir.listFiles();
+            if (files == null)
+                return;
+
+            for (File direntry : files) {
+                if (isArchive(direntry))
+                    addFile(direntry, warn);
+            }
+        }
+
+        public Path addFiles(String files, boolean warn) {
+            if (files != null) {
+                addFiles(getPathEntries(files, emptyPathDefault), warn);
+            }
+            return this;
+        }
+
+        public Path addFiles(String files) {
+            return addFiles(files, warn);
+        }
+
+        public Path addFiles(Iterable<? extends File> files, boolean warn) {
+            if (files != null) {
+                for (File file: files)
+                    addFile(file, warn);
+            }
+            return this;
+        }
+
+        public Path addFiles(Iterable<? extends File> files) {
+            return addFiles(files, warn);
+        }
+
+        public void addFile(File file, boolean warn) {
+            if (contains(file)) {
+                // discard duplicates
+                return;
+            }
+
+            if (! fsInfo.exists(file)) {
+                /* No such file or directory exists */
+                if (warn) {
+                    log.warning(Lint.LintCategory.PATH,
+                            "path.element.not.found", file);
+                }
+                super.add(file);
+                return;
+            }
+
+            File canonFile = fsInfo.getCanonicalFile(file);
+            if (canonicalValues.contains(canonFile)) {
+                /* Discard duplicates and avoid infinite recursion */
+                return;
+            }
+
+            if (fsInfo.isFile(file)) {
+                /* File is an ordinary file. */
+                if (!isArchive(file)) {
+                    /* Not a recognized extension; open it to see if
+                     it looks like a valid zip file. */
+                    try {
+                        ZipFile z = new ZipFile(file);
+                        z.close();
+                        if (warn) {
+                            log.warning(Lint.LintCategory.PATH,
+                                    "unexpected.archive.file", file);
+                        }
+                    } catch (IOException e) {
+                        // FIXME: include e.getLocalizedMessage in warning
+                        if (warn) {
+                            log.warning(Lint.LintCategory.PATH,
+                                    "invalid.archive.file", file);
+                        }
+                        return;
+                    }
+                }
+            }
+
+            /* Now what we have left is either a directory or a file name
+               conforming to archive naming convention */
+            super.add(file);
+            canonicalValues.add(canonFile);
+
+            if (expandJarClassPaths && fsInfo.isFile(file))
+                addJarClassPath(file, warn);
+        }
+
+        // Adds referenced classpath elements from a jar's Class-Path
+        // Manifest entry.  In some future release, we may want to
+        // update this code to recognize URLs rather than simple
+        // filenames, but if we do, we should redo all path-related code.
+        private void addJarClassPath(File jarFile, boolean warn) {
+            try {
+                for (File f: fsInfo.getJarClassPath(jarFile)) {
+                    addFile(f, warn);
+                }
+            } catch (IOException e) {
+                log.error("error.reading.file", jarFile, JavacFileManager.getMessage(e));
+            }
+        }
+    }
+
+    /**
+     * Base class for handling support for the representation of Locations.
+     * Implementations are responsible for handling the interactions between
+     * the command line options for a location, and API access via setLocation.
+     * @see #initHandlers
+     * @see #getHandler
+     */
+    protected abstract class LocationHandler {
+        final Location location;
+        final Set<Option> options;
+
+        /**
+         * Create a handler. The location and options provide a way to map
+         * from a location or an option to the corresponding handler.
+         * @see #initHandlers
+         */
+        protected LocationHandler(Location location, Option... options) {
+            this.location = location;
+            this.options = options.length == 0 ?
+                EnumSet.noneOf(Option.class):
+                EnumSet.copyOf(Arrays.asList(options));
+        }
+
+        // TODO: TEMPORARY, while Options still used for command line options
+        void update(Options optionTable) {
+            for (Option o: options) {
+                String v = optionTable.get(o);
+                if (v != null) {
+                    handleOption(o, v);
+                }
+            }
+        }
+
+        /** @see JavaFileManager#handleOption */
+        abstract boolean handleOption(Option option, String value);
+        /** @see StandardJavaFileManager#getLocation */
+        abstract Collection<File> getLocation();
+        /** @see StandardJavaFileManager#setLocation */
+        abstract void setLocation(Iterable<? extends File> files) throws IOException;
+    }
+
+    /**
+     * General purpose implementation for output locations,
+     * such as -d/CLASS_OUTPUT and -s/SOURCE_OUTPUT.
+     * All options are treated as equivalent (i.e. aliases.)
+     * The value is a single file, possibly null.
+     */
+    private class OutputLocationHandler extends LocationHandler {
+        private File outputDir;
+
+        OutputLocationHandler(Location location, Option... options) {
+            super(location, options);
+        }
+
+        @Override
+        boolean handleOption(Option option, String value) {
+            if (!options.contains(option))
+                return false;
+
+            // TODO: could/should validate outputDir exists and is a directory
+            // need to decide how best to report issue for benefit of
+            // direct API call on JavaFileManager.handleOption(specifies IAE)
+            // vs. command line decoding.
+            outputDir = new File(value);
+            return true;
+        }
+
+        @Override
+        Collection<File> getLocation() {
+            return (outputDir == null) ? null : Collections.singleton(outputDir);
+        }
+
+        @Override
+        void setLocation(Iterable<? extends File> files) throws IOException {
+            if (files == null) {
+                outputDir = null;
+            } else {
+                Iterator<? extends File> pathIter = files.iterator();
+                if (!pathIter.hasNext())
+                    throw new IllegalArgumentException("empty path for directory");
+                File dir = pathIter.next();
+                if (pathIter.hasNext())
+                    throw new IllegalArgumentException("path too long for directory");
+                if (!dir.exists())
+                    throw new FileNotFoundException(dir + ": does not exist");
+                else if (!dir.isDirectory())
+                    throw new IOException(dir + ": not a directory");
+                outputDir = dir;
+            }
+        }
+    }
+
+    /**
+     * General purpose implementation for search path locations,
+     * such as -sourcepath/SOURCE_PATH and -processorPath/ANNOTATION_PROCESS_PATH.
+     * All options are treated as equivalent (i.e. aliases.)
+     * The value is an ordered set of files and/or directories.
+     */
+    private class SimpleLocationHandler extends LocationHandler {
+        protected Collection<File> searchPath;
+
+        SimpleLocationHandler(Location location, Option... options) {
+            super(location, options);
+        }
+
+        @Override
+        boolean handleOption(Option option, String value) {
+            if (!options.contains(option))
+                return false;
+            searchPath = value == null ? null :
+                    Collections.unmodifiableCollection(createPath().addFiles(value));
+            return true;
+        }
+
+        @Override
+        Collection<File> getLocation() {
+            return searchPath;
+        }
+
+        @Override
+        void setLocation(Iterable<? extends File> files) {
+            Path p;
+            if (files == null) {
+                p = computePath(null);
+            } else {
+                p = createPath().addFiles(files);
+            }
+            searchPath = Collections.unmodifiableCollection(p);
+        }
+
+        protected Path computePath(String value) {
+            return createPath().addFiles(value);
+        }
+
+        protected Path createPath() {
+            return new Path();
+        }
+    }
+
+    /**
+     * Subtype of SimpleLocationHandler for -classpath/CLASS_PATH.
+     * If no value is given, a default is provided, based on system properties
+     * and other values.
+     */
+    private class ClassPathLocationHandler extends SimpleLocationHandler {
+        ClassPathLocationHandler() {
+            super(StandardLocation.CLASS_PATH,
+                    Option.CLASSPATH, Option.CP);
+        }
+
+        @Override
+        Collection<File> getLocation() {
+            lazy();
+            return searchPath;
+        }
+
+        @Override
+        protected Path computePath(String value) {
+            String cp = value;
+
+            // CLASSPATH environment variable when run from `javac'.
+            if (cp == null) cp = System.getProperty("env.class.path");
+
+            // If invoked via a java VM (not the javac launcher), use the
+            // platform class path
+            if (cp == null && System.getProperty("application.home") == null)
+                cp = System.getProperty("java.class.path");
+
+            // Default to current working directory.
+            if (cp == null) cp = ".";
+
+            return createPath().addFiles(cp);
+        }
+
+        @Override
+        protected Path createPath() {
+            return new Path()
+                .expandJarClassPaths(true)         // Only search user jars for Class-Paths
+                .emptyPathDefault(new File("."));  // Empty path elt ==> current directory
+        }
+
+        private void lazy() {
+            if (searchPath == null)
+                setLocation(null);
+        }
+    }
+
+    /**
+     * Custom subtype of LocationHandler for PLATFORM_CLASS_PATH.
+     * Various options are supported for different components of the
+     * platform class path.
+     * Setting a value with setLocation overrides all existing option values.
+     * Setting any option overrides any value set with setLocation, and reverts
+     * to using default values for options that have not been set.
+     * Setting -bootclasspath or -Xbootclasspath overrides any existing
+     * value for -Xbootclasspath/p: and -Xbootclasspath/a:.
+     */
+    private class BootClassPathLocationHandler extends LocationHandler {
+        private Collection<File> searchPath;
+        final Map<Option, String> optionValues = new EnumMap<Option,String>(Option.class);
+
+        /**
+         * rt.jar as found on the default bootclasspath.
+         * If the user specified a bootclasspath, null is used.
+         */
+        private File defaultBootClassPathRtJar = null;
+
+        /**
+         *  Is bootclasspath the default?
+         */
+        private boolean isDefaultBootClassPath;
+
+        BootClassPathLocationHandler() {
+            super(StandardLocation.PLATFORM_CLASS_PATH,
+                    Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
+                    Option.XBOOTCLASSPATH_PREPEND,
+                    Option.XBOOTCLASSPATH_APPEND,
+                    Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
+                    Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
+        }
+
+        boolean isDefault() {
+            lazy();
+            return isDefaultBootClassPath;
+        }
+
+        boolean isDefaultRtJar(File file) {
+            lazy();
+            return file.equals(defaultBootClassPathRtJar);
+        }
+
+        @Override
+        boolean handleOption(Option option, String value) {
+            if (!options.contains(option))
+                return false;
+
+            option = canonicalize(option);
+            optionValues.put(option, value);
+            if (option == BOOTCLASSPATH) {
+                optionValues.remove(XBOOTCLASSPATH_PREPEND);
+                optionValues.remove(XBOOTCLASSPATH_APPEND);
+            }
+            searchPath = null;  // reset to "uninitialized"
+            return true;
+        }
+        // where
+            // TODO: would be better if option aliasing was handled at a higher
+            // level
+            private Option canonicalize(Option option) {
+                switch (option) {
+                    case XBOOTCLASSPATH:
+                        return Option.BOOTCLASSPATH;
+                    case DJAVA_ENDORSED_DIRS:
+                        return Option.ENDORSEDDIRS;
+                    case DJAVA_EXT_DIRS:
+                        return Option.EXTDIRS;
+                    default:
+                        return option;
+                }
+            }
+
+        @Override
+        Collection<File> getLocation() {
+            lazy();
+            return searchPath;
+        }
+
+        @Override
+        void setLocation(Iterable<? extends File> files) {
+            if (files == null) {
+                searchPath = null;  // reset to "uninitialized"
+            } else {
+                defaultBootClassPathRtJar = null;
+                isDefaultBootClassPath = false;
+                Path p = new Path().addFiles(files, false);
+                searchPath = Collections.unmodifiableCollection(p);
+                optionValues.clear();
+            }
+        }
+
+        Path computePath() {
+            defaultBootClassPathRtJar = null;
+            Path path = new Path();
+
+            String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
+            String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
+            String extdirsOpt = optionValues.get(EXTDIRS);
+            String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
+            String xbootclasspathAppendOpt = optionValues.get(XBOOTCLASSPATH_APPEND);
+            path.addFiles(xbootclasspathPrependOpt);
+
+            if (endorseddirsOpt != null)
+                path.addDirectories(endorseddirsOpt);
+            else
+                path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
+
+            if (bootclasspathOpt != null) {
+                path.addFiles(bootclasspathOpt);
+            } else {
+                // Standard system classes for this compiler's release.
+                String files = System.getProperty("sun.boot.class.path");
+                path.addFiles(files, false);
+                File rt_jar = new File("rt.jar");
+                for (File file : getPathEntries(files)) {
+                    if (new File(file.getName()).equals(rt_jar))
+                        defaultBootClassPathRtJar = file;
+                }
+            }
+
+            path.addFiles(xbootclasspathAppendOpt);
+
+            // Strictly speaking, standard extensions are not bootstrap
+            // classes, but we treat them identically, so we'll pretend
+            // that they are.
+            if (extdirsOpt != null)
+                path.addDirectories(extdirsOpt);
+            else
+                path.addDirectories(System.getProperty("java.ext.dirs"), false);
+
+            isDefaultBootClassPath =
+                    (xbootclasspathPrependOpt == null) &&
+                    (bootclasspathOpt == null) &&
+                    (xbootclasspathAppendOpt == null);
+
+            return path;
+        }
+
+        private void lazy() {
+            if (searchPath == null)
+                searchPath = Collections.unmodifiableCollection(computePath());
+        }
+    }
+
+    Map<Location, LocationHandler> handlersForLocation;
+    Map<Option, LocationHandler> handlersForOption;
+
+    void initHandlers() {
+        handlersForLocation = new HashMap<Location, LocationHandler>();
+        handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);
+
+        LocationHandler[] handlers = {
+            new BootClassPathLocationHandler(),
+            new ClassPathLocationHandler(),
+            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
+            new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
+            new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S),
+            new OutputLocationHandler((StandardLocation.NATIVE_HEADER_OUTPUT), Option.H)
+        };
+
+        for (LocationHandler h: handlers) {
+            handlersForLocation.put(h.location, h);
+            for (Option o: h.options)
+                handlersForOption.put(o, h);
+        }
+    }
+
+    boolean handleOption(Option option, String value) {
+        LocationHandler h = handlersForOption.get(option);
+        return (h == null ? false : h.handleOption(option, value));
+    }
+
+    Collection<File> getLocation(Location location) {
+        LocationHandler h = getHandler(location);
+        return (h == null ? null : h.getLocation());
+    }
+
+    File getOutputLocation(Location location) {
+        if (!location.isOutputLocation())
+            throw new IllegalArgumentException();
+        LocationHandler h = getHandler(location);
+        return ((OutputLocationHandler) h).outputDir;
+    }
+
+    void setLocation(Location location, Iterable<? extends File> files) throws IOException {
+        LocationHandler h = getHandler(location);
+        if (h == null) {
+            if (location.isOutputLocation())
+                h = new OutputLocationHandler(location);
+            else
+                h = new SimpleLocationHandler(location);
+            handlersForLocation.put(location, h);
+        }
+        h.setLocation(files);
+    }
+
+    protected LocationHandler getHandler(Location location) {
+        location.getClass(); // null check
+        lazy();
+        return handlersForLocation.get(location);
+    }
+
+// TOGO
+    protected void lazy() {
+        if (!inited) {
+            warn = lint.isEnabled(Lint.LintCategory.PATH);
+
+            for (LocationHandler h: handlersForLocation.values()) {
+                h.update(options);
+            }
+
+            inited = true;
+        }
+    }
+
+    /** Is this the name of an archive file? */
+    private boolean isArchive(File file) {
+        String n = file.getName().toLowerCase();
+        return fsInfo.isFile(file)
+            && (n.endsWith(".jar") || n.endsWith(".zip"));
+    }
+
+    /**
+     * Utility method for converting a search path string to an array
+     * of directory and JAR file URLs.
+     *
+     * Note that this method is called by apt and the DocletInvoker.
+     *
+     * @param path the search path string
+     * @return the resulting array of directory and JAR file URLs
+     */
+    public static URL[] pathToURLs(String path) {
+        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
+        URL[] urls = new URL[st.countTokens()];
+        int count = 0;
+        while (st.hasMoreTokens()) {
+            URL url = fileToURL(new File(st.nextToken()));
+            if (url != null) {
+                urls[count++] = url;
+            }
+        }
+        urls = Arrays.copyOf(urls, count);
+        return urls;
+    }
+
+    /**
+     * Returns the directory or JAR file URL corresponding to the specified
+     * local file name.
+     *
+     * @param file the File object
+     * @return the resulting directory or JAR file URL, or null if unknown
+     */
+    private static URL fileToURL(File file) {
+        String name;
+        try {
+            name = file.getCanonicalPath();
+        } catch (IOException e) {
+            name = file.getAbsolutePath();
+        }
+        name = name.replace(File.separatorChar, '/');
+        if (!name.startsWith("/")) {
+            name = "/" + name;
+        }
+        // If the file does not exist, then assume that it's a directory
+        if (!file.isFile()) {
+            name = name + "/";
+        }
+        try {
+            return new URL("file", "", name);
+        } catch (MalformedURLException e) {
+            throw new IllegalArgumentException(file.toString());
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/file/Paths.java b/src/share/classes/com/sun/tools/javac/file/Paths.java
deleted file mode 100644
index 3e0ec5a..0000000
--- a/src/share/classes/com/sun/tools/javac/file/Paths.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Copyright (c) 2003, 2011, 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.file;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.StringTokenizer;
-import java.util.zip.ZipFile;
-import javax.tools.JavaFileManager.Location;
-
-import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Options;
-
-import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.main.OptionName.*;
-
-/** This class converts command line arguments, environment variables
- *  and system properties (in File.pathSeparator-separated String form)
- *  into a boot class path, user class path, and source path (in
- *  Collection<String> form).
- *
- *  <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 Paths {
-
-    /** The context key for the todo list */
-    protected static final Context.Key<Paths> pathsKey =
-        new Context.Key<Paths>();
-
-    /** Get the Paths instance for this context.
-     *  @param context the context
-     *  @return the Paths instance for this context
-     */
-    public static Paths instance(Context context) {
-        Paths instance = context.get(pathsKey);
-        if (instance == null)
-            instance = new Paths(context);
-        return instance;
-    }
-
-    /** The log to use for warning output */
-    private Log log;
-
-    /** Collection of command-line options */
-    private Options options;
-
-    /** Handler for -Xlint options */
-    private Lint lint;
-
-    /** Access to (possibly cached) file info */
-    private FSInfo fsInfo;
-
-    protected Paths(Context context) {
-        context.put(pathsKey, this);
-        pathsForLocation = new HashMap<Location,Path>(16);
-        setContext(context);
-    }
-
-    void setContext(Context context) {
-        log = Log.instance(context);
-        options = Options.instance(context);
-        lint = Lint.instance(context);
-        fsInfo = FSInfo.instance(context);
-    }
-
-    /** Whether to warn about non-existent path elements */
-    private boolean warn;
-
-    private Map<Location, Path> pathsForLocation;
-
-    private boolean inited = false; // TODO? caching bad?
-
-    /**
-     * rt.jar as found on the default bootclass path.  If the user specified a
-     * bootclasspath, null is used.
-     */
-    private File defaultBootClassPathRtJar = null;
-
-    /**
-     *  Is bootclasspath the default?
-     */
-    private boolean isDefaultBootClassPath;
-
-    Path getPathForLocation(Location location) {
-        Path path = pathsForLocation.get(location);
-        if (path == null)
-            setPathForLocation(location, null);
-        return pathsForLocation.get(location);
-    }
-
-    void setPathForLocation(Location location, Iterable<? extends File> path) {
-        // TODO? if (inited) throw new IllegalStateException
-        // TODO: otherwise reset sourceSearchPath, classSearchPath as needed
-        Path p;
-        if (path == null) {
-            if (location == CLASS_PATH)
-                p = computeUserClassPath();
-            else if (location == PLATFORM_CLASS_PATH)
-                p = computeBootClassPath(); // sets isDefaultBootClassPath
-            else if (location == ANNOTATION_PROCESSOR_PATH)
-                p = computeAnnotationProcessorPath();
-            else if (location == SOURCE_PATH)
-                p = computeSourcePath();
-            else
-                // no defaults for other paths
-                p = null;
-        } else {
-            if (location == PLATFORM_CLASS_PATH) {
-                defaultBootClassPathRtJar = null;
-                isDefaultBootClassPath = false;
-            }
-            p = new Path();
-            for (File f: path)
-                p.addFile(f, warn); // TODO: is use of warn appropriate?
-        }
-        pathsForLocation.put(location, p);
-    }
-
-    public boolean isDefaultBootClassPath() {
-        lazy();
-        return isDefaultBootClassPath;
-    }
-
-    protected void lazy() {
-        if (!inited) {
-            warn = lint.isEnabled(Lint.LintCategory.PATH);
-
-            pathsForLocation.put(PLATFORM_CLASS_PATH, computeBootClassPath());
-            pathsForLocation.put(CLASS_PATH, computeUserClassPath());
-            pathsForLocation.put(SOURCE_PATH, computeSourcePath());
-
-            inited = true;
-        }
-    }
-
-    public Collection<File> bootClassPath() {
-        lazy();
-        return Collections.unmodifiableCollection(getPathForLocation(PLATFORM_CLASS_PATH));
-    }
-    public Collection<File> userClassPath() {
-        lazy();
-        return Collections.unmodifiableCollection(getPathForLocation(CLASS_PATH));
-    }
-    public Collection<File> sourcePath() {
-        lazy();
-        Path p = getPathForLocation(SOURCE_PATH);
-        return p == null || p.size() == 0
-            ? null
-            : Collections.unmodifiableCollection(p);
-    }
-
-    boolean isDefaultBootClassPathRtJar(File file) {
-        return file.equals(defaultBootClassPathRtJar);
-    }
-
-    /**
-     * Split a path into its elements. Empty path elements will be ignored.
-     * @param path The path to be split
-     * @return The elements of the path
-     */
-    private static Iterable<File> getPathEntries(String path) {
-        return getPathEntries(path, null);
-    }
-
-    /**
-     * Split a path into its elements. If emptyPathDefault is not null, all
-     * empty elements in the path, including empty elements at either end of
-     * the path, will be replaced with the value of emptyPathDefault.
-     * @param path The path to be split
-     * @param emptyPathDefault The value to substitute for empty path elements,
-     *  or null, to ignore empty path elements
-     * @return The elements of the path
-     */
-    private static Iterable<File> getPathEntries(String path, File emptyPathDefault) {
-        ListBuffer<File> entries = new ListBuffer<File>();
-        int start = 0;
-        while (start <= path.length()) {
-            int sep = path.indexOf(File.pathSeparatorChar, start);
-            if (sep == -1)
-                sep = path.length();
-            if (start < sep)
-                entries.add(new File(path.substring(start, sep)));
-            else if (emptyPathDefault != null)
-                entries.add(emptyPathDefault);
-            start = sep + 1;
-        }
-        return entries;
-    }
-
-    private class Path extends LinkedHashSet<File> {
-        private static final long serialVersionUID = 0;
-
-        private boolean expandJarClassPaths = false;
-        private Set<File> canonicalValues = new HashSet<File>();
-
-        public Path expandJarClassPaths(boolean x) {
-            expandJarClassPaths = x;
-            return this;
-        }
-
-        /** What to use when path element is the empty string */
-        private File emptyPathDefault = null;
-
-        public Path emptyPathDefault(File x) {
-            emptyPathDefault = x;
-            return this;
-        }
-
-        public Path() { super(); }
-
-        public Path addDirectories(String dirs, boolean warn) {
-            boolean prev = expandJarClassPaths;
-            expandJarClassPaths = true;
-            try {
-                if (dirs != null)
-                    for (File dir : getPathEntries(dirs))
-                        addDirectory(dir, warn);
-                return this;
-            } finally {
-                expandJarClassPaths = prev;
-            }
-        }
-
-        public Path addDirectories(String dirs) {
-            return addDirectories(dirs, warn);
-        }
-
-        private void addDirectory(File dir, boolean warn) {
-            if (!dir.isDirectory()) {
-                if (warn)
-                    log.warning(Lint.LintCategory.PATH,
-                            "dir.path.element.not.found", dir);
-                return;
-            }
-
-            File[] files = dir.listFiles();
-            if (files == null)
-                return;
-
-            for (File direntry : files) {
-                if (isArchive(direntry))
-                    addFile(direntry, warn);
-            }
-        }
-
-        public Path addFiles(String files, boolean warn) {
-            if (files != null) {
-                for (File file : getPathEntries(files, emptyPathDefault))
-                    addFile(file, warn);
-            }
-            return this;
-        }
-
-        public Path addFiles(String files) {
-            return addFiles(files, warn);
-        }
-
-        public void addFile(File file, boolean warn) {
-            if (contains(file)) {
-                // discard duplicates
-                return;
-            }
-
-            if (! fsInfo.exists(file)) {
-                /* No such file or directory exists */
-                if (warn) {
-                    log.warning(Lint.LintCategory.PATH,
-                            "path.element.not.found", file);
-                }
-                super.add(file);
-                return;
-            }
-
-            File canonFile = fsInfo.getCanonicalFile(file);
-            if (canonicalValues.contains(canonFile)) {
-                /* Discard duplicates and avoid infinite recursion */
-                return;
-            }
-
-            if (fsInfo.isFile(file)) {
-                /* File is an ordinary file. */
-                if (!isArchive(file)) {
-                    /* Not a recognized extension; open it to see if
-                     it looks like a valid zip file. */
-                    try {
-                        ZipFile z = new ZipFile(file);
-                        z.close();
-                        if (warn) {
-                            log.warning(Lint.LintCategory.PATH,
-                                    "unexpected.archive.file", file);
-                        }
-                    } catch (IOException e) {
-                        // FIXME: include e.getLocalizedMessage in warning
-                        if (warn) {
-                            log.warning(Lint.LintCategory.PATH,
-                                    "invalid.archive.file", file);
-                        }
-                        return;
-                    }
-                }
-            }
-
-            /* Now what we have left is either a directory or a file name
-               conforming to archive naming convention */
-            super.add(file);
-            canonicalValues.add(canonFile);
-
-            if (expandJarClassPaths && fsInfo.isFile(file))
-                addJarClassPath(file, warn);
-        }
-
-        // Adds referenced classpath elements from a jar's Class-Path
-        // Manifest entry.  In some future release, we may want to
-        // update this code to recognize URLs rather than simple
-        // filenames, but if we do, we should redo all path-related code.
-        private void addJarClassPath(File jarFile, boolean warn) {
-            try {
-                for (File f: fsInfo.getJarClassPath(jarFile)) {
-                    addFile(f, warn);
-                }
-            } catch (IOException e) {
-                log.error("error.reading.file", jarFile, JavacFileManager.getMessage(e));
-            }
-        }
-    }
-
-    private Path computeBootClassPath() {
-        defaultBootClassPathRtJar = null;
-        Path path = new Path();
-
-        String bootclasspathOpt = options.get(BOOTCLASSPATH);
-        String endorseddirsOpt = options.get(ENDORSEDDIRS);
-        String extdirsOpt = options.get(EXTDIRS);
-        String xbootclasspathPrependOpt = options.get(XBOOTCLASSPATH_PREPEND);
-        String xbootclasspathAppendOpt = options.get(XBOOTCLASSPATH_APPEND);
-
-        path.addFiles(xbootclasspathPrependOpt);
-
-        if (endorseddirsOpt != null)
-            path.addDirectories(endorseddirsOpt);
-        else
-            path.addDirectories(System.getProperty("java.endorsed.dirs"), false);
-
-        if (bootclasspathOpt != null) {
-            path.addFiles(bootclasspathOpt);
-        } else {
-            // Standard system classes for this compiler's release.
-            String files = System.getProperty("sun.boot.class.path");
-            path.addFiles(files, false);
-            File rt_jar = new File("rt.jar");
-            for (File file : getPathEntries(files)) {
-                if (new File(file.getName()).equals(rt_jar))
-                    defaultBootClassPathRtJar = file;
-            }
-        }
-
-        path.addFiles(xbootclasspathAppendOpt);
-
-        // Strictly speaking, standard extensions are not bootstrap
-        // classes, but we treat them identically, so we'll pretend
-        // that they are.
-        if (extdirsOpt != null)
-            path.addDirectories(extdirsOpt);
-        else
-            path.addDirectories(System.getProperty("java.ext.dirs"), false);
-
-        isDefaultBootClassPath =
-                (xbootclasspathPrependOpt == null) &&
-                (bootclasspathOpt == null) &&
-                (xbootclasspathAppendOpt == null);
-
-        return path;
-    }
-
-    private Path computeUserClassPath() {
-        String cp = options.get(CLASSPATH);
-
-        // CLASSPATH environment variable when run from `javac'.
-        if (cp == null) cp = System.getProperty("env.class.path");
-
-        // If invoked via a java VM (not the javac launcher), use the
-        // platform class path
-        if (cp == null && System.getProperty("application.home") == null)
-            cp = System.getProperty("java.class.path");
-
-        // Default to current working directory.
-        if (cp == null) cp = ".";
-
-        return new Path()
-            .expandJarClassPaths(true)        // Only search user jars for Class-Paths
-            .emptyPathDefault(new File("."))  // Empty path elt ==> current directory
-            .addFiles(cp);
-    }
-
-    private Path computeSourcePath() {
-        String sourcePathArg = options.get(SOURCEPATH);
-        if (sourcePathArg == null)
-            return null;
-
-        return new Path().addFiles(sourcePathArg);
-    }
-
-    private Path computeAnnotationProcessorPath() {
-        String processorPathArg = options.get(PROCESSORPATH);
-        if (processorPathArg == null)
-            return null;
-
-        return new Path().addFiles(processorPathArg);
-    }
-
-    /** The actual effective locations searched for sources */
-    private Path sourceSearchPath;
-
-    public Collection<File> sourceSearchPath() {
-        if (sourceSearchPath == null) {
-            lazy();
-            Path sourcePath = getPathForLocation(SOURCE_PATH);
-            Path userClassPath = getPathForLocation(CLASS_PATH);
-            sourceSearchPath = sourcePath != null ? sourcePath : userClassPath;
-        }
-        return Collections.unmodifiableCollection(sourceSearchPath);
-    }
-
-    /** The actual effective locations searched for classes */
-    private Path classSearchPath;
-
-    public Collection<File> classSearchPath() {
-        if (classSearchPath == null) {
-            lazy();
-            Path bootClassPath = getPathForLocation(PLATFORM_CLASS_PATH);
-            Path userClassPath = getPathForLocation(CLASS_PATH);
-            classSearchPath = new Path();
-            classSearchPath.addAll(bootClassPath);
-            classSearchPath.addAll(userClassPath);
-        }
-        return Collections.unmodifiableCollection(classSearchPath);
-    }
-
-    /** The actual effective locations for non-source, non-class files */
-    private Path otherSearchPath;
-
-    Collection<File> otherSearchPath() {
-        if (otherSearchPath == null) {
-            lazy();
-            Path userClassPath = getPathForLocation(CLASS_PATH);
-            Path sourcePath = getPathForLocation(SOURCE_PATH);
-            if (sourcePath == null)
-                otherSearchPath = userClassPath;
-            else {
-                otherSearchPath = new Path();
-                otherSearchPath.addAll(userClassPath);
-                otherSearchPath.addAll(sourcePath);
-            }
-        }
-        return Collections.unmodifiableCollection(otherSearchPath);
-    }
-
-    /** Is this the name of an archive file? */
-    private boolean isArchive(File file) {
-        String n = file.getName().toLowerCase();
-        return fsInfo.isFile(file)
-            && (n.endsWith(".jar") || n.endsWith(".zip"));
-    }
-
-    /**
-     * Utility method for converting a search path string to an array
-     * of directory and JAR file URLs.
-     *
-     * Note that this method is called by apt and the DocletInvoker.
-     *
-     * @param path the search path string
-     * @return the resulting array of directory and JAR file URLs
-     */
-    public static URL[] pathToURLs(String path) {
-        StringTokenizer st = new StringTokenizer(path, File.pathSeparator);
-        URL[] urls = new URL[st.countTokens()];
-        int count = 0;
-        while (st.hasMoreTokens()) {
-            URL url = fileToURL(new File(st.nextToken()));
-            if (url != null) {
-                urls[count++] = url;
-            }
-        }
-        if (urls.length != count) {
-            URL[] tmp = new URL[count];
-            System.arraycopy(urls, 0, tmp, 0, count);
-            urls = tmp;
-        }
-        return urls;
-    }
-
-    /**
-     * Returns the directory or JAR file URL corresponding to the specified
-     * local file name.
-     *
-     * @param file the File object
-     * @return the resulting directory or JAR file URL, or null if unknown
-     */
-    private static URL fileToURL(File file) {
-        String name;
-        try {
-            name = file.getCanonicalPath();
-        } catch (IOException e) {
-            name = file.getAbsolutePath();
-        }
-        name = name.replace(File.separatorChar, '/');
-        if (!name.startsWith("/")) {
-            name = "/" + name;
-        }
-        // If the file does not exist, then assume that it's a directory
-        if (!file.isFile()) {
-            name = name + "/";
-        }
-        try {
-            return new URL("file", "", name);
-        } catch (MalformedURLException e) {
-            throw new IllegalArgumentException(file.toString());
-        }
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
index 1ca860e..48f035d 100644
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
@@ -38,7 +38,6 @@ import java.util.Calendar;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -60,7 +59,7 @@ import com.sun.tools.javac.file.RelativePath.RelativeFile;
  * the command line.)
  *
  * Location where to look for/generate optimized zip index files can be
- * provided using "-XDcachezipindexdir=<directory>". If this flag is not
+ * provided using "{@code -XDcachezipindexdir=<directory>}". If this flag is not
  * provided, the default location is the value of the "java.io.tmpdir" system
  * property.
  *
@@ -84,7 +83,7 @@ public class ZipFileIndex {
     public final static long NOT_MODIFIED = Long.MIN_VALUE;
 
 
-    private static boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
+    private static final boolean NON_BATCH_MODE = System.getProperty("nonBatchMode") != null;// TODO: Use -XD compiler switch for this.
 
     private Map<RelativeDirectory, DirectoryEntry> directories =
             Collections.<RelativeDirectory, DirectoryEntry>emptyMap();
@@ -549,17 +548,15 @@ public class ZipFileIndex {
                 }
 
                 if (i >= 0) {
-                    zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2];
-                    zipDir[0] = endbuf[i + 10];
-                    zipDir[1] = endbuf[i + 11];
+                    zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12)];
                     int sz = get4ByteLittleEndian(endbuf, i + 16);
                     // a negative offset or the entries field indicates a
                     // potential zip64 archive
-                    if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) {
+                    if (sz < 0 || get2ByteLittleEndian(endbuf, i + 10) == 0xffff) {
                         throw new ZipFormatException("detected a zip64 archive");
                     }
                     zipRandomFile.seek(start + sz);
-                    zipRandomFile.readFully(zipDir, 2, zipDir.length - 2);
+                    zipRandomFile.readFully(zipDir, 0, zipDir.length);
                     return;
                 } else {
                     endbufend = endbufpos + 21;
@@ -569,14 +566,13 @@ public class ZipFileIndex {
         }
 
         private void buildIndex() throws IOException {
-            int entryCount = get2ByteLittleEndian(zipDir, 0);
+            int len = zipDir.length;
 
             // Add each of the files
-            if (entryCount > 0) {
+            if (len > 0) {
                 directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
                 ArrayList<Entry> entryList = new ArrayList<Entry>();
-                int pos = 2;
-                for (int i = 0; i < entryCount; i++) {
+                for (int pos = 0; pos < len; ) {
                     pos = readEntry(pos, entryList, directories);
                 }
 
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java b/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java
index 81085cd..7cd696e 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -277,7 +277,7 @@ public interface ByteCodes {
 
     /** Shift and mask constants for shifting prefix instructions.
      *  a pair of instruction codes such as LCMP ; IFEQ is encoded
-     *  in Symtab as (LCMP << preShift) + IFEQ.
+     *  in Symtab as {@literal (LCMP << preShift) + IFEQ }.
      */
     int preShift        = 9;
     int preMask         = (1 << preShift) - 1;
diff --git a/src/share/classes/com/sun/tools/javac/jvm/CRTable.java b/src/share/classes/com/sun/tools/javac/jvm/CRTable.java
index a2c1edc..3184c09 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/CRTable.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/CRTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -31,6 +31,7 @@ import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.EndPosTable;
 
 /** This class contains the CharacterRangeTable for some method
  *  and the hashtable for mapping trees or lists of trees to their
@@ -54,9 +55,9 @@ implements CRTFlags {
      */
     private Map<Object,SourceRange> positions = new HashMap<Object,SourceRange>();
 
-    /** The hashtable for ending positions stored in the parser.
+    /** The object for ending positions stored in the parser.
      */
-    private Map<JCTree, Integer> endPositions;
+    private EndPosTable endPosTable;
 
     /** The tree of the method this table is intended for.
      *  We should traverse this tree to get source ranges.
@@ -65,9 +66,9 @@ implements CRTFlags {
 
     /** Constructor
      */
-    public CRTable(JCTree.JCMethodDecl tree, Map<JCTree, Integer> endPositions) {
+    public CRTable(JCTree.JCMethodDecl tree, EndPosTable endPosTable) {
         this.methodTree = tree;
-        this.endPositions = endPositions;
+        this.endPosTable = endPosTable;
     }
 
     /** Create a new CRTEntry and add it to the entries.
@@ -161,7 +162,7 @@ implements CRTFlags {
     }
 
     /** Source file positions in CRT are integers in the format:
-     *  line-number << LINESHIFT + column-number
+     *  {@literal line-number << LINESHIFT + column-number }
      */
      private int encodePosition(int pos, Position.LineMap lineMap, Log log) {
          int line = lineMap.getLineNumber(pos);
@@ -502,6 +503,14 @@ implements CRTFlags {
             result = sr;
         }
 
+        @Override
+        public void visitLetExpr(LetExpr tree) {
+            SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
+            sr.mergeWith(csp(tree.defs));
+            sr.mergeWith(csp(tree.expr));
+            result = sr;
+        }
+
         public void visitTypeParameter(JCTypeParameter tree) {
             SourceRange sr = new SourceRange(startPos(tree), endPos(tree));
             sr.mergeWith(csp(tree.bounds));
@@ -524,7 +533,7 @@ implements CRTFlags {
          */
         public int startPos(JCTree tree) {
             if (tree == null) return Position.NOPOS;
-            return tree.pos;
+            return TreeInfo.getStartPos(tree);
         }
 
         /** The end position of given tree, if it has
@@ -532,12 +541,7 @@ implements CRTFlags {
          */
         public int endPos(JCTree tree) {
             if (tree == null) return Position.NOPOS;
-            if (tree.getTag() == JCTree.BLOCK)
-                return ((JCBlock) tree).endpos;
-            Integer endpos = endPositions.get(tree);
-            if (endpos != null)
-                return endpos.intValue();
-            return Position.NOPOS;
+            return TreeInfo.getEndPos(tree, endPosTable);
         }
     }
 
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java b/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java
index 966a84d..e1ff3ac 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.tools.javac.jvm;
 
 import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.Types.UniqueType;
 import com.sun.tools.javac.util.Name;
 
 
@@ -45,7 +47,7 @@ import com.sun.tools.javac.util.Name;
  *     classSignature         ::= [ typeparams ] supertype { interfacetype }
  *  </pre>
  *  <p>The type syntax in signatures is extended as follows:
- *  <pre>
+ *  <pre>{@literal
  *     type       ::= ... | classtype | methodtype | typevar
  *     classtype  ::= classsig { '.' classsig }
  *     classig    ::= 'L' name [typeargs] ';'
@@ -54,7 +56,7 @@ import com.sun.tools.javac.util.Name;
  *     typeargs   ::= '<' type { type } '>'
  *     typeparams ::= '<' typeparam { typeparam } '>'
  *     typeparam  ::= name ':' type
- *  </pre>
+ *  }</pre>
  *  <p>This class defines constants used in class files as well
  *  as routines to convert between internal ``.'' and external ``/''
  *  separators in class names.
@@ -84,6 +86,16 @@ public class ClassFile {
     public final static int CONSTANT_MethodType = 16;
     public final static int CONSTANT_InvokeDynamic = 18;
 
+    public final static int REF_getField = 1;
+    public final static int REF_getStatic = 2;
+    public final static int REF_putField = 3;
+    public final static int REF_putStatic = 4;
+    public final static int REF_invokeVirtual = 5;
+    public final static int REF_invokeStatic = 6;
+    public final static int REF_invokeSpecial = 7;
+    public final static int REF_newInvokeSpecial = 8;
+    public final static int REF_invokeInterface = 9;
+
     public final static int MAX_PARAMETERS = 0xff;
     public final static int MAX_DIMENSIONS = 0xff;
     public final static int MAX_CODE = 0xffff;
@@ -94,7 +106,8 @@ public class ClassFile {
         V45_3(45, 3), // base level for all attributes
         V49(49, 0),   // JDK 1.5: enum, generics, annotations
         V50(50, 0),   // JDK 1.6: stackmaps
-        V51(51, 0);   // JDK 1.7
+        V51(51, 0),   // JDK 1.7
+        V52(52, 0);   // JDK 1.8: lambda, type annos, param names
         Version(int major, int minor) {
             this.major = major;
             this.minor = minor;
@@ -155,22 +168,29 @@ public class ClassFile {
      */
     public static class NameAndType {
         Name name;
-        Type type;
+        UniqueType uniqueType;
+        Types types;
 
-        NameAndType(Name name, Type type) {
+        NameAndType(Name name, Type type, Types types) {
             this.name = name;
-            this.type = type;
+            this.uniqueType = new UniqueType(type, types);
+            this.types = types;
+        }
+
+        void setType(Type type) {
+            this.uniqueType = new UniqueType(type, types);
         }
 
+        @Override
         public boolean equals(Object other) {
-            return
-                other instanceof NameAndType &&
-                name == ((NameAndType) other).name &&
-                type.equals(((NameAndType) other).type);
+            return (other instanceof NameAndType &&
+                    name == ((NameAndType) other).name &&
+                        uniqueType.equals(((NameAndType) other).uniqueType));
         }
 
+        @Override
         public int hashCode() {
-            return name.hashCode() * type.hashCode();
+            return name.hashCode() * uniqueType.hashCode();
         }
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
index fa7e786..e5cc4b1 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -35,7 +35,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.logging.Logger;
 import javax.lang.model.SourceVersion;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileManager;
@@ -57,11 +56,11 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
 import static com.sun.tools.javac.jvm.ClassFile.*;
 import static com.sun.tools.javac.jvm.ClassFile.Version.*;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** This class provides operations to read a classfile into an internal
  *  representation. The internal representation is anchored in a
@@ -117,6 +116,9 @@ public class ClassReader implements Completer {
      */
     boolean lintClassfile;
 
+    /** Switch: allow default methods
+     */
+    boolean allowDefaultMethods;
 
     /** Switch: preserve parameter names from the variable table.
      */
@@ -133,6 +135,11 @@ public class ClassReader implements Completer {
      **/
     public boolean preferSource;
 
+    /**
+     * The currently selected profile.
+     */
+    public final Profile profile;
+
     /** The log to use for verbose output
      */
     final Log log;
@@ -219,6 +226,13 @@ public class ClassReader implements Completer {
      */
     boolean haveParameterNameIndices;
 
+    /** Set this to false every time we start reading a method
+     * and are saving parameter names.  Set it to true when we see
+     * MethodParameters, if it's set when we see a LocalVariableTable,
+     * then we ignore the parameter names from the LVT.
+     */
+    boolean sawMethodParameters;
+
     /**
      * The set of attribute names for which warnings have been generated for the current class
      */
@@ -280,16 +294,21 @@ public class ClassReader implements Completer {
         annotate = Annotate.instance(context);
         verbose        = options.isSet(VERBOSE);
         checkClassFile = options.isSet("-checkclassfile");
+
         ideMode = options.get("ide") != null;
         Source source = Source.instance(context);
         allowGenerics    = source.allowGenerics();
         allowVarargs     = source.allowVarargs();
         allowAnnotations = source.allowAnnotations();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
+        allowDefaultMethods = source.allowDefaultMethods();
+
         saveParameterNames = options.isSet("save-parameter-names");
         cacheCompletionFailure = options.isUnset("dev");
         preferSource = "source".equals(options.get("-Xprefer"));
 
+        profile = Profile.instance(context);
+
         completionFailureName =
             options.isSet("failcomplete")
             ? names.fromString(options.get("failcomplete"))
@@ -305,7 +324,9 @@ public class ClassReader implements Completer {
     /** Add member to class unless it is synthetic.
      */
     private void enterMember(ClassSymbol c, Symbol sym) {
-        if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC)
+        // Synthetic members are not entered -- reason lost to history (optimization?).
+        // Lambda methods must be entered because they may have inner classes (which reference them)
+        if ((sym.flags_field & (SYNTHETIC|BRIDGE)) != SYNTHETIC || sym.name.startsWith(names.lambda))
             c.members_field.enter(sym);
     }
 
@@ -341,14 +362,14 @@ public class ClassReader implements Completer {
 
     /** Read a character.
      */
-    char nextChar() {
+    protected char nextChar() {
         return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
     }
 
     /** Read a byte.
      */
-    byte nextByte() {
-        return buf[bp++];
+    int nextByte() {
+        return buf[bp++] & 0xFF;
     }
 
     /** Read an integer.
@@ -491,20 +512,20 @@ public class ClassReader implements Completer {
         case CONSTANT_Fieldref: {
             ClassSymbol owner = readClassSymbol(getChar(index + 1));
             NameAndType nt = (NameAndType)readPool(getChar(index + 3));
-            poolObj[i] = new VarSymbol(0, nt.name, nt.type, owner);
+            poolObj[i] = new VarSymbol(0, nt.name, nt.uniqueType.type, owner);
             break;
         }
         case CONSTANT_Methodref:
         case CONSTANT_InterfaceMethodref: {
             ClassSymbol owner = readClassSymbol(getChar(index + 1));
             NameAndType nt = (NameAndType)readPool(getChar(index + 3));
-            poolObj[i] = new MethodSymbol(0, nt.name, nt.type, owner);
+            poolObj[i] = new MethodSymbol(0, nt.name, nt.uniqueType.type, owner);
             break;
         }
         case CONSTANT_NameandType:
             poolObj[i] = new NameAndType(
                 readName(getChar(index + 1)),
-                readType(getChar(index + 3)));
+                readType(getChar(index + 3)), types);
             break;
         case CONSTANT_Integer:
             poolObj[i] = getInt(index + 1);
@@ -535,7 +556,7 @@ public class ClassReader implements Completer {
 
     /** Read signature and convert to type.
      */
-    Type readType(int i) {
+    protected Type readType(int i) {
         int index = poolIdx[i];
         return sigToType(buf, index + 3, getChar(index + 1));
     }
@@ -571,7 +592,7 @@ public class ClassReader implements Completer {
 
     /** Read name.
      */
-    Name readName(int i) {
+    protected Name readName(int i) {
         return (Name) (readPool(i));
     }
 
@@ -855,17 +876,17 @@ public class ClassReader implements Completer {
             tvar = (TypeVar)findTypeVar(name);
         }
         List<Type> bounds = List.nil();
-        Type st = null;
+        boolean allInterfaces = false;
         if (signature[sigp] == ':' && signature[sigp+1] == ':') {
             sigp++;
-            st = syms.objectType;
+            allInterfaces = true;
         }
         while (signature[sigp] == ':') {
             sigp++;
             bounds = bounds.prepend(sigToType());
         }
         if (!sigEnterPhase) {
-            types.setBounds(tvar, bounds.reverse(), st);
+            types.setBounds(tvar, bounds.reverse(), allInterfaces);
         }
         return tvar;
     }
@@ -909,7 +930,7 @@ public class ClassReader implements Completer {
             this.kinds = kinds;
         }
 
-        public boolean accepts(AttributeKind kind) {
+        protected boolean accepts(AttributeKind kind) {
             if (kinds.contains(kind)) {
                 if (majorVersion > version.major || (majorVersion == version.major && minorVersion >= version.minor))
                     return true;
@@ -930,11 +951,11 @@ public class ClassReader implements Completer {
             return false;
         }
 
-        public abstract void read(Symbol sym, int attrLen);
+        protected abstract void read(Symbol sym, int attrLen);
 
-        public final Name name;
-        public final ClassFile.Version version;
-        public final Set<AttributeKind> kinds;
+        protected final Name name;
+        protected final ClassFile.Version version;
+        protected final Set<AttributeKind> kinds;
     }
 
     protected Set<AttributeKind> CLASS_ATTRIBUTE =
@@ -951,7 +972,7 @@ public class ClassReader implements Completer {
             // v45.3 attributes
 
             new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (readAllOfClassFile || saveParameterNames)
                         ((MethodSymbol)sym).code = readCode(sym);
                     else
@@ -960,7 +981,7 @@ public class ClassReader implements Completer {
             },
 
             new AttributeReader(names.ConstantValue, V45_3, MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     Object v = readPool(nextChar());
                     // Ignore ConstantValue attribute if field not final.
                     if ((sym.flags() & FINAL) != 0)
@@ -969,13 +990,13 @@ public class ClassReader implements Completer {
             },
 
             new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     sym.flags_field |= DEPRECATED;
                 }
             },
 
             new AttributeReader(names.Exceptions, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     int nexceptions = nextChar();
                     List<Type> thrown = List.nil();
                     for (int j = 0; j < nexceptions; j++)
@@ -986,16 +1007,16 @@ public class ClassReader implements Completer {
             },
 
             new AttributeReader(names.InnerClasses, V45_3, CLASS_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     ClassSymbol c = (ClassSymbol) sym;
                     readInnerClasses(c);
                 }
             },
 
             new AttributeReader(names.LocalVariableTable, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     int newbp = bp + attrLen;
-                    if (saveParameterNames) {
+                    if (saveParameterNames && !sawMethodParameters) {
                         // Pick up parameter names from the variable table.
                         // Parameter names are not explicitly identified as such,
                         // but all parameter name entries in the LocalVariableTable
@@ -1028,16 +1049,44 @@ public class ClassReader implements Completer {
                 }
             },
 
+            new AttributeReader(names.MethodParameters, V52, MEMBER_ATTRIBUTE) {
+                protected void read(Symbol sym, int attrlen) {
+                    int newbp = bp + attrlen;
+                    if (saveParameterNames) {
+                        sawMethodParameters = true;
+                        int numEntries = nextByte();
+                        parameterNameIndices = new int[numEntries];
+                        haveParameterNameIndices = true;
+                        for (int i = 0; i < numEntries; i++) {
+                            int nameIndex = nextChar();
+                            int flags = nextChar();
+                            parameterNameIndices[i] = nameIndex;
+                        }
+                    }
+                    bp = newbp;
+                }
+            },
+
+
             new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     ClassSymbol c = (ClassSymbol) sym;
                     Name n = readName(nextChar());
                     c.sourcefile = new SourceFileObject(n, c.flatname);
+                    // If the class is a toplevel class, originating from a Java source file,
+                    // but the class name does not match the file name, then it is
+                    // an auxiliary class.
+                    String sn = n.toString();
+                    if (c.owner.kind == Kinds.PCK &&
+                        sn.endsWith(".java") &&
+                        !sn.equals(c.name.toString()+".java")) {
+                        c.flags_field |= AUXILIARY;
+                    }
                 }
             },
 
             new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     // bridge methods are visible when generics not enabled
                     if (allowGenerics || (sym.flags_field & BRIDGE) == 0)
                         sym.flags_field |= SYNTHETIC;
@@ -1047,7 +1096,7 @@ public class ClassReader implements Completer {
             // standard v49 attributes
 
             new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     int newbp = bp + attrLen;
                     readEnclosingMethodAttr(sym);
                     bp = newbp;
@@ -1056,11 +1105,11 @@ public class ClassReader implements Completer {
 
             new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
                 @Override
-                public boolean accepts(AttributeKind kind) {
+                protected boolean accepts(AttributeKind kind) {
                     return super.accepts(kind) && (allowGenerics || ideMode);
                 }
 
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (sym.kind == TYP) {
                         ClassSymbol c = (ClassSymbol) sym;
                         readingClassAttr = true;
@@ -1089,31 +1138,31 @@ public class ClassReader implements Completer {
             // v49 annotation attributes
 
             new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotationDefault(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachParameterAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachParameterAnnotations(sym);
                 }
             },
@@ -1121,14 +1170,14 @@ public class ClassReader implements Completer {
             // additional "legacy" v49 attributes, superceded by flags
 
             new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (allowAnnotations || ideMode)
                         sym.flags_field |= ANNOTATION;
                 }
             },
 
             new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     sym.flags_field |= BRIDGE;
                     if (!allowGenerics)
                         sym.flags_field &= ~SYNTHETIC;
@@ -1136,56 +1185,27 @@ public class ClassReader implements Completer {
             },
 
             new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     sym.flags_field |= ENUM;
                 }
             },
 
             new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (allowVarargs || ideMode)
                         sym.flags_field |= VARARGS;
                 }
             },
 
-            // nb-javac attributes
-
-            new AttributeReader(names._org_netbeans_TypeSignature, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
-                    sym.type = readType(nextChar());
-                }
-            },
-            
-            new AttributeReader(names._org_netbeans_ParameterNames, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
-                    int newbp = bp + attrLen;
-                    List<Name> parameterNames = List.nil();
-                    int numParams = 0;
-                    if (sym.type != null) {
-                        List<Type> parameterTypes = sym.type.getParameterTypes();
-                        if (parameterTypes != null)
-                            numParams = parameterTypes.length();
-                    }
-                    for (int i = 0; i < numParams; i++) {
-                        if (bp < newbp - 1)
-                            parameterNames = parameterNames.prepend(readName(nextChar()));
-                    }
-                    parameterNames = parameterNames.reverse();
-                    while(parameterNames.length() < numParams)
-                        parameterNames = parameterNames.prepend(names.empty);
-                    ((MethodSymbol)sym).savedParameterNames = parameterNames;
-                }
-            },
-
-            new AttributeReader(names._org_netbeans_SourceLevelAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
-                    attachAnnotations(sym);
+            new AttributeReader(names.RuntimeVisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) {
+                protected void read(Symbol sym, int attrLen) {
+                    attachTypeAnnotations(sym);
                 }
             },
 
-            new AttributeReader(names._org_netbeans_SourceLevelParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                public void read(Symbol sym, int attrLen) {
-                    attachParameterAnnotations(sym);
+            new AttributeReader(names.RuntimeInvisibleTypeAnnotations, V52, CLASS_OR_MEMBER_ATTRIBUTE) {
+                protected void read(Symbol sym, int attrLen) {
+                    attachTypeAnnotations(sym);
                 }
             },
 
@@ -1274,7 +1294,7 @@ public class ClassReader implements Completer {
         if (nt == null)
             return null;
 
-        MethodType type = nt.type.asMethodType();
+        MethodType type = nt.uniqueType.type.asMethodType();
 
         for (Scope.Entry e = scope.lookup(nt.name); e.scope != null; e = e.next())
             if (e.sym.kind == MTH && isSameBinaryType(e.sym.type.asMethodType(), type))
@@ -1286,16 +1306,16 @@ public class ClassReader implements Completer {
         if ((flags & INTERFACE) != 0)
             // no enclosing instance
             return null;
-        if (nt.type.getParameterTypes().isEmpty())
+        if (nt.uniqueType.type.getParameterTypes().isEmpty())
             // no parameters
             return null;
 
         // A constructor of an inner class.
         // Remove the first argument (the enclosing instance)
-        nt.type = new MethodType(nt.type.getParameterTypes().tail,
-                                 nt.type.getReturnType(),
-                                 nt.type.getThrownTypes(),
-                                 syms.methodClass);
+        nt.setType(new MethodType(nt.uniqueType.type.getParameterTypes().tail,
+                                 nt.uniqueType.type.getReturnType(),
+                                 nt.uniqueType.type.getThrownTypes(),
+                                 syms.methodClass));
         // Try searching again
         return findMethod(nt, scope, flags);
     }
@@ -1372,7 +1392,7 @@ public class ClassReader implements Completer {
 
     /** Attach annotations.
      */
-    void attachAnnotations(final Symbol sym) {
+    protected void attachAnnotations(final Symbol sym) {
         int numAttributes = nextChar();
         if (numAttributes != 0) {
             ListBuffer<CompoundAnnotationProxy> proxies =
@@ -1381,21 +1401,27 @@ public class ClassReader implements Completer {
                 CompoundAnnotationProxy proxy = readCompoundAnnotation();
                 if (proxy.type.tsym == syms.proprietaryType.tsym)
                     sym.flags_field |= PROPRIETARY;
-                else
+                else if (proxy.type.tsym == syms.profileType.tsym) {
+                    if (profile != Profile.DEFAULT) {
+                        for (Pair<Name,Attribute> v: proxy.values) {
+                            if (v.fst == names.value && v.snd instanceof Attribute.Constant) {
+                                Attribute.Constant c = (Attribute.Constant) v.snd;
+                                if (c.type == syms.intType && ((Integer) c.value) > profile.value) {
+                                    sym.flags_field |= NOT_IN_PROFILE;
+                                }
+                            }
+                        }
+                    }
+                } else
                     proxies.append(proxy);
-                if (majorVersion >= V51.major &&
-                        (proxy.type.tsym == syms.polymorphicSignatureType.tsym ||
-                         proxy.type.tsym == syms.transientPolymorphicSignatureType.tsym)) {
-                    sym.flags_field |= POLYMORPHIC_SIGNATURE;
-                }
             }
-            annotate.later(new AnnotationCompleter(sym, proxies.toList()));
+            annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
         }
     }
 
     /** Attach parameter annotations.
      */
-    void attachParameterAnnotations(final Symbol method) {
+    protected void attachParameterAnnotations(final Symbol method) {
         final MethodSymbol meth = (MethodSymbol)method;
         int numParameters = buf[bp++] & 0xFF;
         List<VarSymbol> parameters = meth.params();
@@ -1410,12 +1436,33 @@ public class ClassReader implements Completer {
         }
     }
 
+    protected void attachTypeAnnotations(final Symbol sym) {
+        int numAttributes = nextChar();
+        if (numAttributes != 0) {
+            ListBuffer<TypeAnnotationProxy> proxies =
+                ListBuffer.lb();
+            for (int i = 0; i < numAttributes; i++)
+                proxies.append(readTypeAnnotation());
+            annotate.normal(new TypeAnnotationCompleter(sym, proxies.toList()));
+        }
+    }
+
     /** Attach the default value for an annotation element.
      */
     void attachAnnotationDefault(final Symbol sym) {
         final MethodSymbol meth = (MethodSymbol)sym; // only on methods
         final Attribute value = readAttributeValue();
-        annotate.later(new AnnotationDefaultCompleter(meth, value));
+
+        // The default value is set later during annotation. It might
+        // be the case that the Symbol sym is annotated _after_ the
+        // repeating instances that depend on this default value,
+        // because of this we set an interim value that tells us this
+        // element (most likely) has a default.
+        //
+        // Set interim value for now, reset just before we do this
+        // properly at annotate time.
+        meth.defaultValue = value;
+        annotate.normal(new AnnotationDefaultCompleter(meth, value));
     }
 
     Type readTypeOrClassSymbol(int i) {
@@ -1446,6 +1493,111 @@ public class ClassReader implements Completer {
         return new CompoundAnnotationProxy(t, pairs.toList());
     }
 
+    TypeAnnotationProxy readTypeAnnotation() {
+        TypeAnnotationPosition position = readPosition();
+        CompoundAnnotationProxy proxy = readCompoundAnnotation();
+
+        return new TypeAnnotationProxy(proxy, position);
+    }
+
+    TypeAnnotationPosition readPosition() {
+        int tag = nextByte(); // TargetType tag is a byte
+
+        if (!TargetType.isValidTargetTypeValue(tag))
+            throw this.badClassFile("bad.type.annotation.value", String.format("0x%02X", tag));
+
+        TypeAnnotationPosition position = new TypeAnnotationPosition();
+        TargetType type = TargetType.fromTargetTypeValue(tag);
+
+        position.type = type;
+
+        switch (type) {
+        // instanceof
+        case INSTANCEOF:
+        // new expression
+        case NEW:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
+            position.offset = nextChar();
+            break;
+        // local variable
+        case LOCAL_VARIABLE:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            int table_length = nextChar();
+            position.lvarOffset = new int[table_length];
+            position.lvarLength = new int[table_length];
+            position.lvarIndex = new int[table_length];
+
+            for (int i = 0; i < table_length; ++i) {
+                position.lvarOffset[i] = nextChar();
+                position.lvarLength[i] = nextChar();
+                position.lvarIndex[i] = nextChar();
+            }
+            break;
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            position.exception_index = nextChar();
+            break;
+        // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameter
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            position.parameter_index = nextByte();
+            break;
+        // type parameter bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND:
+            position.parameter_index = nextByte();
+            position.bound_index = nextByte();
+            break;
+        // class extends or implements clause
+        case CLASS_EXTENDS:
+            position.type_index = nextChar();
+            break;
+        // throws
+        case THROWS:
+            position.type_index = nextChar();
+            break;
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
+            position.parameter_index = nextByte();
+            break;
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
+            position.offset = nextChar();
+            position.type_index = nextByte();
+            break;
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
+            break;
+        case UNKNOWN:
+            throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!");
+        default:
+            throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + position);
+        }
+
+        { // See whether there is location info and read it
+            int len = nextByte();
+            ListBuffer<Integer> loc = ListBuffer.lb();
+            for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i)
+                loc = loc.append(nextByte());
+            position.location = TypeAnnotationPosition.getTypePathFromBinary(loc.toList());
+        }
+
+        return position;
+    }
+
     Attribute readAttributeValue() {
         char c = (char) buf[bp++];
         switch (c) {
@@ -1735,6 +1887,9 @@ public class ClassReader implements Completer {
         public void enterAnnotation() {
             JavaFileObject previousClassFile = currentClassFile;
             try {
+                // Reset the interim value set earlier in
+                // attachAnnotationDefault().
+                sym.defaultValue = null;
                 currentClassFile = classFile;
                 sym.defaultValue = deproxy(sym.type.getReturnType(), value);
             } finally {
@@ -1758,13 +1913,50 @@ public class ClassReader implements Completer {
         }
         // implement Annotate.Annotator.enterAnnotation()
         public void enterAnnotation() {
+            if ((sym.flags_field & FROMCLASS) == 0 && ((sym.flags_field & PARAMETER) == 0 || (sym.owner.flags_field & FROMCLASS) == 0))
+                return;
             JavaFileObject previousClassFile = currentClassFile;
             try {
                 currentClassFile = classFile;
                 List<Attribute.Compound> newList = deproxyCompoundList(l);
-                sym.attributes_field = ((sym.attributes_field == null)
-                                        ? newList
-                                        : newList.prependList(sym.attributes_field));
+                if (sym.annotationsPendingCompletion()) {
+                    sym.setDeclarationAttributes(newList);
+                } else {
+                    sym.appendAttributes(newList);
+                }
+            } finally {
+                currentClassFile = previousClassFile;
+            }
+        }
+    }
+
+    class TypeAnnotationCompleter extends AnnotationCompleter {
+
+        List<TypeAnnotationProxy> proxies;
+
+        TypeAnnotationCompleter(Symbol sym,
+                List<TypeAnnotationProxy> proxies) {
+            super(sym, List.<CompoundAnnotationProxy>nil());
+            this.proxies = proxies;
+        }
+
+        List<Attribute.TypeCompound> deproxyTypeCompoundList(List<TypeAnnotationProxy> proxies) {
+            ListBuffer<Attribute.TypeCompound> buf = ListBuffer.lb();
+            for (TypeAnnotationProxy proxy: proxies) {
+                Attribute.Compound compound = deproxyCompound(proxy.compound);
+                Attribute.TypeCompound typeCompound = new Attribute.TypeCompound(compound, proxy.position);
+                buf.add(typeCompound);
+            }
+            return buf.toList();
+        }
+
+        @Override
+        public void enterAnnotation() {
+            JavaFileObject previousClassFile = currentClassFile;
+            try {
+                currentClassFile = classFile;
+                List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies);
+                sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes()));
             } finally {
                 currentClassFile = previousClassFile;
             }
@@ -1793,6 +1985,17 @@ public class ClassReader implements Completer {
         long flags = adjustMethodFlags(nextChar());
         Name name = readName(nextChar());
         Type type = readType(nextChar());
+        if (currentOwner.isInterface() &&
+                (flags & ABSTRACT) == 0 && !name.equals(names.clinit)) {
+            if (majorVersion > Target.JDK1_8.majorVersion ||
+                    (majorVersion == Target.JDK1_8.majorVersion && minorVersion >= Target.JDK1_8.minorVersion)) {
+                currentOwner.flags_field |= DEFAULT;
+                flags |= DEFAULT | ABSTRACT;
+            } else {
+                //protect against ill-formed classfiles
+                throw new CompletionFailure(currentOwner, "default method found in pre JDK 8 classfile");
+            }
+        }
         if (name == names.init && currentOwner.hasOuterInstance()) {
             // Sometimes anonymous classes don't have an outer
             // instance, however, there is no reliable way to tell so
@@ -1804,6 +2007,9 @@ public class ClassReader implements Completer {
                                       syms.methodClass);
         }
         MethodSymbol m = new MethodSymbol(flags, name, type, currentOwner);
+        if (types.isSignaturePolymorphic(m)) {
+            m.flags_field |= SIGNATURE_POLYMORPHIC;
+        }
         if (saveParameterNames)
             initParameterNames(m);
         Symbol prevOwner = currentOwner;
@@ -1854,6 +2060,7 @@ public class ClassReader implements Completer {
         } else
             Arrays.fill(parameterNameIndices, 0);
         haveParameterNameIndices = false;
+        sawMethodParameters = false;
     }
 
     /**
@@ -1873,12 +2080,16 @@ public class ClassReader implements Completer {
         // if no names were found in the class file, there's nothing more to do
         if (!haveParameterNameIndices || sym.type == null || sym.type.getParameterTypes() == null)
             return;
-
-        int firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
-        // the code in readMethod may have skipped the first parameter when
-        // setting up the MethodType. If so, we make a corresponding allowance
-        // here for the position of the first parameter.  Note that this
-        // assumes the skipped parameter has a width of 1 -- i.e. it is not
+        // If we get parameter names from MethodParameters, then we
+        // don't need to skip.
+        int firstParam = 0;
+        if (!sawMethodParameters) {
+            firstParam = ((sym.flags() & STATIC) == 0) ? 1 : 0;
+            // the code in readMethod may have skipped the first
+            // parameter when setting up the MethodType. If so, we
+            // make a corresponding allowance here for the position of
+            // the first parameter.  Note that this assumes the
+            // skipped parameter has a width of 1 -- i.e. it is not
         // a double width type (long or double.)
         if (sym.name == names.init && currentOwner.hasOuterInstance()) {
             // Sometimes anonymous classes don't have an outer
@@ -1889,21 +2100,24 @@ public class ClassReader implements Completer {
         }
 
         if (sym.type != jvmType) {
-            // reading the method attributes has caused the symbol's type to
-            // be changed. (i.e. the Signature attribute.)  This may happen if
-            // there are hidden (synthetic) parameters in the descriptor, but
-            // not in the Signature.  The position of these hidden parameters
-            // is unspecified; for now, assume they are at the beginning, and
-            // so skip over them. The primary case for this is two hidden
-            // parameters passed into Enum constructors.
+                // reading the method attributes has caused the
+                // symbol's type to be changed. (i.e. the Signature
+                // attribute.)  This may happen if there are hidden
+                // (synthetic) parameters in the descriptor, but not
+                // in the Signature.  The position of these hidden
+                // parameters is unspecified; for now, assume they are
+                // at the beginning, and so skip over them. The
+                // primary case for this is two hidden parameters
+                // passed into Enum constructors.
             int skip = Code.width(jvmType.getParameterTypes())
                     - Code.width(sym.type.getParameterTypes());
             firstParam += skip;
         }
+        }
         List<Name> paramNames = List.nil();
         int index = firstParam;
         for (Type t: sym.type.getParameterTypes()) {
-            int nameIdx = (index < parameterNameIndices.length
+            int nameIdx = (index >= 0 && index < parameterNameIndices.length
                     ? parameterNameIndices[index] : 0);
             Name name = nameIdx == 0 ? names.empty : readName(nameIdx);
             paramNames = paramNames.prepend(name);
@@ -1935,7 +2149,7 @@ public class ClassReader implements Completer {
      *  `typevars'.
      */
     protected void enterTypevars(Type t) {
-        if (t.getEnclosingType() != null && t.getEnclosingType().tag == CLASS)
+        if (t.getEnclosingType() != null && t.getEnclosingType().hasTag(CLASS))
             enterTypevars(t.getEnclosingType());
         for (List<Type> xs = t.getTypeArguments(); xs.nonEmpty(); xs = xs.tail)
             typevars.enter(xs.head.tsym);
@@ -1960,7 +2174,7 @@ public class ClassReader implements Completer {
 
         // prepare type variable table
         typevars = typevars.dup(currentOwner);
-        if (ct.getEnclosingType().tag == CLASS)
+        if (ct.getEnclosingType().hasTag(CLASS))
             enterTypevars(ct.getEnclosingType());
 
         // read flags, or skip if this is an inner class
@@ -1987,7 +2201,7 @@ public class ClassReader implements Completer {
 
         if (readAllOfClassFile) {
             for (int i = 1; i < poolObj.length; i++) readPool(i);
-            c.pool = new Pool(poolObj.length, poolObj);
+            c.pool = new Pool(poolObj.length, poolObj, types);
         }
 
         // reset and read rest of classinfo
@@ -2682,7 +2896,7 @@ public class ClassReader implements Completer {
      *  @param arg An argument for substitution into the output string.
      */
     private void printCCF(String key, Object arg) {
-        log.printNoteLines(key, arg);
+        log.printLines(key, arg);
     }
 
 
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
index 372034a..27f3420 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,27 +26,33 @@
 package com.sun.tools.javac.jvm;
 
 import java.io.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
 
-import java.util.logging.Logger;
 import javax.tools.JavaFileManager;
 import javax.tools.FileObject;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Attribute.RetentionPolicy;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.Types.UniqueType;
 import com.sun.tools.javac.file.BaseFileObject;
+import com.sun.tools.javac.jvm.Pool.DynamicMethod;
+import com.sun.tools.javac.jvm.Pool.Method;
+import com.sun.tools.javac.jvm.Pool.MethodHandle;
+import com.sun.tools.javac.jvm.Pool.Variable;
 import com.sun.tools.javac.util.*;
 
-import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.jvm.UninitializedType.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
 
@@ -70,11 +76,11 @@ public class ClassWriter extends ClassFile {
      */
     private boolean verbose;
 
-    /** Switch: scrable private names.
+    /** Switch: scramble private field names.
      */
     private boolean scramble;
 
-    /** Switch: scrable private names.
+    /** Switch: scramble all field names.
      */
     private boolean scrambleAll;
 
@@ -90,7 +96,7 @@ public class ClassWriter extends ClassFile {
      */
     private boolean genCrt;
 
-    /** Switch: describe the generated stackmap
+    /** Switch: describe the generated stackmap.
      */
     boolean debugstackmap;
     
@@ -108,26 +114,22 @@ public class ClassWriter extends ClassFile {
     private Types types;
 
     /** The initial sizes of the data and constant pool buffers.
-     *  sizes are increased when buffers get full.
+     *  Sizes are increased when buffers get full.
      */
     static final int DATA_BUF_SIZE = 0x0fff0;
     static final int POOL_BUF_SIZE = 0x1fff0;
 
     /** An output buffer for member info.
      */
-    ByteBuffer databuf = new ByteBuffer(DATA_BUF_SIZE);
+    protected ByteBuffer databuf = new ByteBuffer(DATA_BUF_SIZE);
 
     /** An output buffer for the constant pool.
      */
-    ByteBuffer poolbuf = new ByteBuffer(POOL_BUF_SIZE);
-
-    /** An output buffer for type signatures.
-     */
-    ByteBuffer sigbuf = new ByteBuffer();
+    protected ByteBuffer poolbuf = new ByteBuffer(POOL_BUF_SIZE);
 
     /** The constant pool.
      */
-    Pool pool;
+    protected Pool pool;
 
     /** The inner classes to be written, as a set.
      */
@@ -138,6 +140,11 @@ public class ClassWriter extends ClassFile {
      */
     ListBuffer<ClassSymbol> innerClassesQueue;
 
+    /** The bootstrap methods to be written in the corresponding class attribute
+     *  (one for each invokedynamic)
+     */
+    Map<DynamicMethod, MethodHandle> bootstrapMethods;
+
     /** The log to use for verbose output.
      */
     private final Log log;
@@ -149,8 +156,9 @@ public class ClassWriter extends ClassFile {
     private final JavaFileManager fileManager;
     
     private boolean allowGenerics;
-    private boolean preserveErrors = false;
-    private ClassSymbol generatedClass;
+
+    /** Sole signature generator */
+    private final CWSignatureGenerator signatureGen;
 
     /** The tags and constants used in compressed stackmap. */
     static final int SAME_FRAME_SIZE = 64;
@@ -180,6 +188,7 @@ public class ClassWriter extends ClassFile {
         source = Source.instance(context);
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);
+        signatureGen = new CWSignatureGenerator(types);
 
         verbose        = options.isSet(VERBOSE);
         scramble       = options.isSet("-scramble");
@@ -267,182 +276,90 @@ public class ClassWriter extends ClassFile {
         buf.elems[adr+3] = (byte)((x      ) & 0xFF);
     }
 
-/******************************************************************
- * Signature Generation
- ******************************************************************/
-
-    /** Assemble signature of given type in string buffer.
+    /**
+     * Signature Generation
      */
-    void assembleSig(Type type) {
-        switch (type.tag) {
-        case BYTE:
-            sigbuf.appendByte('B');
-            break;
-        case SHORT:
-            sigbuf.appendByte('S');
-            break;
-        case CHAR:
-            sigbuf.appendByte('C');
-            break;
-        case INT:
-            sigbuf.appendByte('I');
-            break;
-        case LONG:
-            sigbuf.appendByte('J');
-            break;
-        case FLOAT:
-            sigbuf.appendByte('F');
-            break;
-        case DOUBLE:
-            sigbuf.appendByte('D');
-            break;
-        case BOOLEAN:
-            sigbuf.appendByte('Z');
-            break;
-        case VOID:
-            sigbuf.appendByte('V');
-            break;
-        case ERROR:
-            if (preserveErrors) {
-                sigbuf.appendByte('R');
-                assembleClassSig(type);
-                sigbuf.appendByte(';');
-                break;
-            }
-        case CLASS:
-            sigbuf.appendByte('L');
-            assembleClassSig(type);
-            sigbuf.appendByte(';');
-            break;
-        case ARRAY:
-            ArrayType at = (ArrayType)type;
-            sigbuf.appendByte('[');
-            assembleSig(at.elemtype);
-            break;
-        case METHOD:
-            MethodType mt = (MethodType)type;
-            sigbuf.appendByte('(');
-            assembleSig(mt.argtypes);
-            sigbuf.appendByte(')');
-            assembleSig(mt.restype);
-            if (hasTypeVar(mt.thrown)) {
-                for (List<Type> l = mt.thrown; l.nonEmpty(); l = l.tail) {
-                    sigbuf.appendByte('^');
-                    assembleSig(l.head);
-                }
-            }
-            break;
-        case WILDCARD: {
-            WildcardType ta = (WildcardType) type;
-            switch (ta.kind) {
-            case SUPER:
-                sigbuf.appendByte('-');
-                assembleSig(ta.type);
-                break;
-            case EXTENDS:
-                sigbuf.appendByte('+');
-                assembleSig(ta.type);
-                break;
-            case UNBOUND:
-                sigbuf.appendByte('*');
-                break;
-            default:
-                throw new AssertionError(ta.kind);
+    private class CWSignatureGenerator extends Types.SignatureGenerator {
+
+        /**
+         * An output buffer for type signatures.
+         */
+        ByteBuffer sigbuf = new ByteBuffer();
+
+        CWSignatureGenerator(Types types) {
+            super(types);
+        }
+
+        /**
+         * Assemble signature of given type in string buffer.
+         * Check for uninitialized types before calling the general case.
+         */
+        @Override
+        public void assembleSig(Type type) {
+            type = type.unannotatedType();
+            switch (type.getTag()) {
+                case UNINITIALIZED_THIS:
+                case UNINITIALIZED_OBJECT:
+                    // we don't yet have a spec for uninitialized types in the
+                    // local variable table
+                    assembleSig(types.erasure(((UninitializedType)type).qtype));
+                    break;
+                case ERROR:
+                    if (preserveErrors) {
+                        append('R');
+                        assembleClassSig(type);
+                        append(';');
+                        break;
+                    }
+                default:
+                    super.assembleSig(type);
             }
-            break;
         }
-        case TYPEVAR:
-            sigbuf.appendByte('T');
-            sigbuf.appendName(type.tsym.name);
-            sigbuf.appendByte(';');
-            break;
-        case FORALL:
-            ForAll ft = (ForAll)type;
-            assembleParamsSig(ft.tvars);
-            assembleSig(ft.qtype);
-            break;
-        case UNINITIALIZED_THIS:
-        case UNINITIALIZED_OBJECT:
-            // we don't yet have a spec for uninitialized types in the
-            // local variable table
-            assembleSig(types.erasure(((UninitializedType)type).qtype));
-            break;
-        default:
-            throw new AssertionError("typeSig " + type.tag);
+
+        @Override
+        protected void append(char ch) {
+            sigbuf.appendByte(ch);
         }
-    }
 
-    boolean hasTypeVar(List<Type> l) {
-        while (l.nonEmpty()) {
-            if (l.head.tag == TypeTags.TYPEVAR) return true;
-            l = l.tail;
+        @Override
+        protected void append(byte[] ba) {
+            sigbuf.appendBytes(ba);
         }
-        return false;
-    }
 
-    void assembleClassSig(Type type) {
-        ClassType ct = (ClassType)type;
-        ClassSymbol c = (ClassSymbol)ct.tsym;
-        enterInner(c);
-        Type outer = ct.getEnclosingType();
-        if (outer.allparams().nonEmpty()) {
-            boolean rawOuter =
-                c.owner.kind == MTH || // either a local class
-                c.name == names.empty; // or anonymous
-            assembleClassSig(rawOuter
-                             ? types.erasure(outer)
-                             : outer);
-            sigbuf.appendByte('.');
-            Assert.check(c.flatname.startsWith(c.owner.enclClass().flatname));
-            sigbuf.appendName(rawOuter
-                              ? c.flatname.subName(c.owner.enclClass().flatname.getByteLength()+1,c.flatname.getByteLength())
-                              : c.name);
-        } else {
-            if (c == syms.errSymbol) {
-                Logger.getLogger(ClassWriter.class.getName()).warning("ClassWriter.assembleClassSig: <any> appears in the [" + generatedClass + "]'s signature."); //NOI18N
-                sigbuf.appendBytes(externalize(names.java_lang_Object));
-            } else {
-                sigbuf.appendBytes(externalize(c.flatname));
-            }
+        @Override
+        protected void append(Name name) {
+            sigbuf.appendName(name);
         }
-        if (ct.getTypeArguments().nonEmpty()) {
-            sigbuf.appendByte('<');
-            assembleSig(ct.getTypeArguments());
-            sigbuf.appendByte('>');
+
+        @Override
+        protected void classReference(ClassSymbol c) {
+            enterInner(c);
         }
-    }
 
+        private void reset() {
+            sigbuf.reset();
+        }
 
-    void assembleSig(List<Type> types) {
-        for (List<Type> ts = types; ts.nonEmpty(); ts = ts.tail)
-            assembleSig(ts.head);
-    }
+        private Name toName() {
+            return sigbuf.toName(names);
+        }
 
-    void assembleParamsSig(List<Type> typarams) {
-        sigbuf.appendByte('<');
-        for (List<Type> ts = typarams; ts.nonEmpty(); ts = ts.tail) {
-            TypeVar tvar = (TypeVar)ts.head;
-            sigbuf.appendName(tvar.tsym.name);
-            List<Type> bounds = types.getBounds(tvar);
-            if ((bounds.head.tsym.flags() & INTERFACE) != 0) {
-                sigbuf.appendByte(':');
-            }
-            for (List<Type> l = bounds; l.nonEmpty(); l = l.tail) {
-                sigbuf.appendByte(':');
-                assembleSig(l.head);
-            }
+        private boolean isEmpty() {
+            return sigbuf.length == 0;
         }
-        sigbuf.appendByte('>');
     }
 
-    /** Return signature of given type
+    protected boolean preserveErrors = false;
+    
+    /**
+     * Return signature of given type
      */
-    Name typeSig(Type type) {
-        Assert.check(sigbuf.length == 0);
+    protected Name typeSig(Type type) {
+        Assert.check(signatureGen.isEmpty());
         //- System.out.println(" ? " + type);
-        assembleSig(type);
-        Name n = sigbuf.toName(names);
-        sigbuf.reset();
+        signatureGen.assembleSig(type);
+        Name n = signatureGen.toName();
+        signatureGen.reset();
         //- System.out.println("   " + n);
         return n;
     }
@@ -451,14 +368,14 @@ public class ClassWriter extends ClassFile {
      *  external representation.
      */
     public Name xClassName(Type t) {
-        if (t.tag == ERROR)
+        if (t.hasTag(ERROR))
             t = syms.objectType;
-        if (t.tag == CLASS) {
+        if (t.hasTag(CLASS)) {
             return names.fromUtf(externalize(t.tsym.flatName()));
-        } else if (t.tag == ARRAY) {
+        } else if (t.hasTag(ARRAY)) {
             return typeSig(types.erasure(t));
         } else {
-            throw new AssertionError("xClassName");
+            throw new AssertionError("xClassName: " + t + ", tag: " + t.getTag());
         }
     }
 
@@ -491,18 +408,33 @@ public class ClassWriter extends ClassFile {
         while (i < pool.pp) {
             Object value = pool.pool[i];
             Assert.checkNonNull(value);
-            if (value instanceof Pool.Method)
-                value = ((Pool.Method)value).m;
-            else if (value instanceof Pool.Variable)
-                value = ((Pool.Variable)value).v;
+            if (value instanceof Method || value instanceof Variable)
+                value = ((DelegatedSymbol)value).getUnderlyingSymbol();
 
             if (value instanceof MethodSymbol) {
                 MethodSymbol m = (MethodSymbol)value;
-                poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0
-                          ? CONSTANT_InterfaceMethodref
-                          : CONSTANT_Methodref);
-                poolbuf.appendChar(pool.put(m.owner));
-                poolbuf.appendChar(pool.put(nameType(m)));
+                if (!m.isDynamic()) {
+                    poolbuf.appendByte((m.owner.flags() & INTERFACE) != 0
+                              ? CONSTANT_InterfaceMethodref
+                              : CONSTANT_Methodref);
+                    poolbuf.appendChar(pool.put(m.owner));
+                    poolbuf.appendChar(pool.put(nameType(m)));
+                } else {
+                    //invokedynamic
+                    DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
+                    MethodHandle handle = new MethodHandle(dynSym.bsmKind, dynSym.bsm, types);
+                    DynamicMethod dynMeth = new DynamicMethod(dynSym, types);
+                    bootstrapMethods.put(dynMeth, handle);
+                    //init cp entries
+                    pool.put(names.BootstrapMethods);
+                    pool.put(handle);
+                    for (Object staticArg : dynSym.staticArgs) {
+                        pool.put(staticArg);
+                    }
+                    poolbuf.appendByte(CONSTANT_InvokeDynamic);
+                    poolbuf.appendChar(bootstrapMethods.size() - 1);
+                    poolbuf.appendChar(pool.put(nameType(dynSym)));
+                }
             } else if (value instanceof VarSymbol) {
                 VarSymbol v = (VarSymbol)value;
                 poolbuf.appendByte(CONSTANT_Fieldref);
@@ -519,7 +451,7 @@ public class ClassWriter extends ClassFile {
                 ClassSymbol c = (ClassSymbol)value;
                 if (c.owner.kind == TYP) pool.put(c.owner);
                 poolbuf.appendByte(CONSTANT_Class);
-                if (c.type.tag == ARRAY) {
+                if (c.type.hasTag(ARRAY)) {
                     poolbuf.appendChar(pool.put(typeSig(c.type)));
                 } else {
                     poolbuf.appendChar(pool.put(names.fromUtf(externalize(c.flatname))));
@@ -529,7 +461,7 @@ public class ClassWriter extends ClassFile {
                 NameAndType nt = (NameAndType)value;
                 poolbuf.appendByte(CONSTANT_NameandType);
                 poolbuf.appendChar(pool.put(nt.name));
-                poolbuf.appendChar(pool.put(typeSig(nt.type)));
+                poolbuf.appendChar(pool.put(typeSig(nt.uniqueType.type)));
             } else if (value instanceof Integer) {
                 poolbuf.appendByte(CONSTANT_Integer);
                 poolbuf.appendInt(((Integer)value).intValue());
@@ -547,11 +479,21 @@ public class ClassWriter extends ClassFile {
             } else if (value instanceof String) {
                 poolbuf.appendByte(CONSTANT_String);
                 poolbuf.appendChar(pool.put(names.fromString((String)value)));
-            } else if (value instanceof Type) {
-                Type type = (Type)value;
-                if (type.tag == CLASS) enterInner((ClassSymbol)type.tsym);
-                poolbuf.appendByte(CONSTANT_Class);
-                poolbuf.appendChar(pool.put(xClassName(type)));
+            } else if (value instanceof UniqueType) {
+                Type type = ((UniqueType)value).type;
+                if (type instanceof MethodType) {
+                    poolbuf.appendByte(CONSTANT_MethodType);
+                    poolbuf.appendChar(pool.put(typeSig((MethodType)type)));
+                } else {
+                    if (type.hasTag(CLASS)) enterInner((ClassSymbol)type.tsym);
+                    poolbuf.appendByte(CONSTANT_Class);
+                    poolbuf.appendChar(pool.put(xClassName(type)));
+                }
+            } else if (value instanceof MethodHandle) {
+                MethodHandle ref = (MethodHandle)value;
+                poolbuf.appendByte(CONSTANT_MethodHandle);
+                poolbuf.appendByte(ref.refKind);
+                poolbuf.appendChar(pool.put(ref.refSym));
             } else {
                 Assert.error("writePool " + value);
             }
@@ -578,7 +520,7 @@ public class ClassWriter extends ClassFile {
         return new NameAndType(fieldName(sym),
                                retrofit
                                ? sym.erasure(types)
-                               : sym.externalType(types));
+                               : sym.externalType(types), types);
         // if we retrofit, then the NameAndType has been read in as is
         // and no change is necessary. If we compile normally, the
         // NameAndType is generated from a symbol reference, and the
@@ -592,7 +534,7 @@ public class ClassWriter extends ClassFile {
     /** Write header for an attribute to data buffer and return
      *  position past attribute length index.
      */
-    int writeAttr(Name attrName) {
+    protected int writeAttr(Name attrName) {
         databuf.appendChar(pool.put(attrName));
         databuf.appendInt(0);
         return databuf.length;
@@ -600,7 +542,7 @@ public class ClassWriter extends ClassFile {
 
     /** Fill in attribute length.
      */
-    void endAttr(int index) {
+    protected void endAttr(int index) {
         putInt(databuf, index - 4, databuf.length - index);
     }
 
@@ -624,14 +566,13 @@ public class ClassWriter extends ClassFile {
     int writeEnclosingMethodAttribute(ClassSymbol c) {
         if (!target.hasEnclosingMethodAttribute())
             return 0;
-        return writeEnclosingMethodLikeAttribute(names.EnclosingMethod, c);
+        return writeEnclosingMethodAttribute(names.EnclosingMethod, c);
     }
 
-    /** Write the attribute with the format of EnclosingMethod attribute and given name
-     *  if needed.
+    /** Write the EnclosingMethod attribute with a specified name.
      *  Returns the number of attributes written (0 or 1).
      */
-    protected int writeEnclosingMethodLikeAttribute(Name attributeName, ClassSymbol c) {
+    protected int writeEnclosingMethodAttribute(Name attributeName, ClassSymbol c) {
         if (c.owner.kind != MTH && // neither a local class
             c.name != names.empty) // nor anonymous
             return 0;
@@ -696,7 +637,7 @@ public class ClassWriter extends ClassFile {
             (flags & (SYNTHETIC|BRIDGE)) != SYNTHETIC &&
             (flags & ANONCONSTR) == 0 &&
             (!types.isSameType(sym.type, sym.erasure(types)) ||
-             hasTypeVar(sym.type.getThrownTypes()))) {
+            signatureGen.hasTypeVar(sym.type.getThrownTypes()))) {
             // note that a local class with captured variables
             // will get a signature attribute
             int alenIdx = writeAttr(names.Signature);
@@ -704,35 +645,67 @@ public class ClassWriter extends ClassFile {
             endAttr(alenIdx);
             acount++;
         }
-        acount += writeJavaAnnotations(sym.getAnnotationMirrors());
-        if (sym.externalType(types).isErroneous()) {
-            int rsIdx = writeAttr(names._org_netbeans_TypeSignature);
-            try {
-                preserveErrors = true;
-                databuf.appendChar(pool.put(typeSig(sym.type)));
-            } finally {
-                preserveErrors = false;
-            }
-            endAttr(rsIdx);
-            acount++;
-        }
+        acount += writeJavaAnnotations(sym.getRawAttributes());
+        acount += writeExtraJavaAnnotations(sym.getRawAttributes());
+        acount += writeTypeAnnotations(sym.getRawTypeAttributes(), false);
+        acount += writeExtraTypeAnnotations(sym.getRawTypeAttributes());
         return acount;
     }
 
+    /**Allows subclasses to write additional member attributes
+     *
+     * @return the number of attributes written
+     */
+    protected int writeExtraMemberAttributes(Symbol sym) {
+        return 0;
+    }
+
+    /**
+     * Write method parameter names attribute.
+     */
+    int writeMethodParametersAttr(MethodSymbol m) {
+        MethodType ty = m.externalType(types).asMethodType();
+        final int allparams = ty.argtypes.size();
+        if (m.params != null && allparams != 0) {
+            final int attrIndex = writeAttr(names.MethodParameters);
+            databuf.appendByte(allparams);
+            // Write extra parameters first
+            for (VarSymbol s : m.extraParams) {
+                final int flags =
+                    ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
+                    ((int) m.flags() & SYNTHETIC);
+                databuf.appendChar(pool.put(s.name));
+                databuf.appendChar(flags);
+            }
+            // Now write the real parameters
+            for (VarSymbol s : m.params) {
+                final int flags =
+                    ((int) s.flags() & (FINAL | SYNTHETIC | MANDATED)) |
+                    ((int) m.flags() & SYNTHETIC);
+                databuf.appendChar(pool.put(s.name));
+                databuf.appendChar(flags);
+            }
+            endAttr(attrIndex);
+            return 1;
+        } else
+            return 0;
+    }
+
+
     /** Write method parameter annotations;
      *  return number of attributes written.
      */
     int writeParameterAttrs(MethodSymbol m) {
         boolean hasVisible = false;
         boolean hasInvisible = false;
-        boolean hasSourceLevel = false;
-        if (m.params != null) for (VarSymbol s : m.params) {
-            for (Attribute.Compound a : s.getAnnotationMirrors()) {
-                switch (types.getRetention(a)) {
-                case SOURCE: hasSourceLevel = true; break;
-                case CLASS: hasInvisible = true; break;
-                case RUNTIME: hasVisible = true; break;
-                default: ;// /* fail soft */ throw new AssertionError(vis);
+        if (m.params != null) {
+            for (VarSymbol s : m.params) {
+                for (Attribute.Compound a : s.getRawAttributes()) {
+                    switch (types.getRetention(a)) {
+                    case CLASS: hasInvisible = true; break;
+                    case RUNTIME: hasVisible = true; break;
+                    default: ;// /* fail soft */ throw new AssertionError(vis);
+                    }
                 }
             }
         }
@@ -743,7 +716,7 @@ public class ClassWriter extends ClassFile {
             databuf.appendByte(m.params.length());
             for (VarSymbol s : m.params) {
                 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
-                for (Attribute.Compound a : s.getAnnotationMirrors())
+                for (Attribute.Compound a : s.getRawAttributes())
                     if (types.getRetention(a) == RetentionPolicy.RUNTIME)
                         buf.append(a);
                 databuf.appendChar(buf.length());
@@ -758,7 +731,7 @@ public class ClassWriter extends ClassFile {
             databuf.appendByte(m.params.length());
             for (VarSymbol s : m.params) {
                 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
-                for (Attribute.Compound a : s.getAnnotationMirrors())
+                for (Attribute.Compound a : s.getRawAttributes())
                     if (types.getRetention(a) == RetentionPolicy.CLASS)
                         buf.append(a);
                 databuf.appendChar(buf.length());
@@ -768,31 +741,16 @@ public class ClassWriter extends ClassFile {
             endAttr(attrIndex);
             attrCount++;
         }
-        if (hasSourceLevel) {
-            int attrIndex = writeAttr(names._org_netbeans_SourceLevelParameterAnnotations);
-            databuf.appendByte(m.params.length());
-            for (VarSymbol s : m.params) {
-                ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
-                for (Attribute.Compound a : s.getAnnotationMirrors())
-                    if (types.getRetention(a) == RetentionPolicy.SOURCE)
-                        buf.append(a);
-                databuf.appendChar(buf.length());
-                for (Attribute.Compound a : buf)
-                    writeCompoundAttribute(a);
-            }
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        if (m.code == null && m.params != null && m.params.nonEmpty()) {
-            int attrIndex = writeAttr(names._org_netbeans_ParameterNames);
-            for (VarSymbol s : m.params)
-                databuf.appendChar(pool.put(s.name));
-            endAttr(attrIndex);
-            attrCount++;
-        }
         return attrCount;
     }
 
+    /**Allows subclasses to write additional parameter attributes
+     *
+     * @return the number of attributes written
+     */
+    protected int writeExtraParameterAttributes(MethodSymbol m) {
+        return 0;
+    }
 /**********************************************************************
  * Writing Java-language annotations (aka metadata, attributes)
  **********************************************************************/
@@ -804,10 +762,8 @@ public class ClassWriter extends ClassFile {
         if (attrs.isEmpty()) return 0;
         ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>();
         ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>();
-        ListBuffer<Attribute.Compound> sourceLevel = new ListBuffer<Attribute.Compound>();
         for (Attribute.Compound a : attrs) {
             switch (types.getRetention(a)) {
-            case SOURCE: sourceLevel.append(a); break;
             case CLASS: invisibles.append(a); break;
             case RUNTIME: visibles.append(a); break;
             default: ;// /* fail soft */ throw new AssertionError(vis);
@@ -831,24 +787,88 @@ public class ClassWriter extends ClassFile {
             endAttr(attrIndex);
             attrCount++;
         }
-        if (sourceLevel.length() != 0) {
-            int attrIndex = writeAttr(names._org_netbeans_SourceLevelAnnotations);
-            databuf.appendChar(sourceLevel.length());
-            for (Attribute.Compound a : sourceLevel)
-                writeCompoundAttribute(a);
+        return attrCount;
+    }
+    
+    /**Allows subclasses to write additional Java-language annotations
+     *
+     * @return the number of JVM attributes written
+     */
+    protected int writeExtraJavaAnnotations(List<Attribute.Compound> attrs) {
+        return 0;
+    }
+
+    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.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.
+                    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)) {
+            case SOURCE: break;
+            case CLASS: invisibles.append(tc); break;
+            case RUNTIME: visibles.append(tc); break;
+            default: ;// /* fail soft */ throw new AssertionError(vis);
+            }
+        }
+
+        int attrCount = 0;
+        if (visibles.length() != 0) {
+            int attrIndex = writeAttr(names.RuntimeVisibleTypeAnnotations);
+            databuf.appendChar(visibles.length());
+            for (Attribute.TypeCompound p : visibles)
+                writeTypeAnnotation(p);
+            endAttr(attrIndex);
+            attrCount++;
+        }
+
+        if (invisibles.length() != 0) {
+            int attrIndex = writeAttr(names.RuntimeInvisibleTypeAnnotations);
+            databuf.appendChar(invisibles.length());
+            for (Attribute.TypeCompound p : invisibles)
+                writeTypeAnnotation(p);
             endAttr(attrIndex);
             attrCount++;
         }
+
         return attrCount;
     }
 
+    /**Allows subclasses to write additional type annotations
+     *
+     * @return the number of JVM attributes written
+     */
+    protected int writeExtraTypeAnnotations(List<Attribute.TypeCompound> attrs) {
+        return 0;
+    }
+
     /** A visitor to write an attribute including its leading
      *  single-character marker.
      */
     class AttributeWriter implements Attribute.Visitor {
         public void visitConstant(Attribute.Constant _value) {
             Object value = _value.value;
-            switch (_value.type.tag) {
+            switch (_value.type.getTag()) {
             case BYTE:
                 databuf.appendByte('B');
                 break;
@@ -890,7 +910,7 @@ public class ClassWriter extends ClassFile {
         }
         public void visitClass(Attribute.Class clazz) {
             databuf.appendByte('c');
-            databuf.appendChar(pool.put(typeSig(clazz.type)));
+            databuf.appendChar(pool.put(typeSig(clazz.classType)));
         }
         public void visitCompound(Attribute.Compound compound) {
             databuf.appendByte('@');
@@ -910,14 +930,107 @@ public class ClassWriter extends ClassFile {
     AttributeWriter awriter = new AttributeWriter();
 
     /** Write a compound attribute excluding the '@' marker. */
-    void writeCompoundAttribute(Attribute.Compound c) {
+    protected void writeCompoundAttribute(Attribute.Compound c) {
         databuf.appendChar(pool.put(typeSig(c.type)));
-        databuf.appendChar(c.values.length());
+        int count = c.values.length();//don't try to write erroneous attributes
+        for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
+            if (p.snd instanceof Attribute.Error) count--;
+        }
+        databuf.appendChar(count);
         for (Pair<Symbol.MethodSymbol,Attribute> p : c.values) {
+            if (p.snd instanceof Attribute.Error) continue;
             databuf.appendChar(pool.put(p.fst.name));
             p.snd.accept(awriter);
         }
     }
+
+    protected void writeTypeAnnotation(Attribute.TypeCompound c) {
+        writePosition(c.position);
+        writeCompoundAttribute(c);
+    }
+
+    void writePosition(TypeAnnotationPosition p) {
+        databuf.appendByte(p.type.targetTypeValue()); // TargetType tag is a byte
+        switch (p.type) {
+        // instanceof
+        case INSTANCEOF:
+        // new expression
+        case NEW:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
+            databuf.appendChar(p.offset);
+            break;
+        // local variable
+        case LOCAL_VARIABLE:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            databuf.appendChar(p.lvarOffset.length);  // for table length
+            for (int i = 0; i < p.lvarOffset.length; ++i) {
+                databuf.appendChar(p.lvarOffset[i]);
+                databuf.appendChar(p.lvarLength[i]);
+                databuf.appendChar(p.lvarIndex[i]);
+            }
+            break;
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            databuf.appendChar(p.exception_index);
+            break;
+        // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameter
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            databuf.appendByte(p.parameter_index);
+            break;
+        // type parameter bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND:
+            databuf.appendByte(p.parameter_index);
+            databuf.appendByte(p.bound_index);
+            break;
+        // class extends or implements clause
+        case CLASS_EXTENDS:
+            databuf.appendChar(p.type_index);
+            break;
+        // throws
+        case THROWS:
+            databuf.appendChar(p.type_index);
+            break;
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
+            databuf.appendByte(p.parameter_index);
+            break;
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
+            databuf.appendChar(p.offset);
+            databuf.appendByte(p.type_index);
+            break;
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
+            break;
+        case UNKNOWN:
+            throw new AssertionError("jvm.ClassWriter: UNKNOWN target type should never occur!");
+        default:
+            throw new AssertionError("jvm.ClassWriter: Unknown target type for position: " + p);
+        }
+
+        { // Append location data for generics/arrays.
+            databuf.appendByte(p.location.size());
+            java.util.List<Integer> loc = TypeAnnotationPosition.getBinaryFromTypePath(p.location);
+            for (int i : loc)
+                databuf.appendByte((byte)i);
+        }
+    }
+
 /**********************************************************************
  * Writing Objects
  **********************************************************************/
@@ -934,14 +1047,15 @@ public class ClassWriter extends ClassFile {
             System.err.println("error: " + c + ": " + ex.getMessage());
             throw ex;
         }
-        if (c.type.tag != CLASS && c.type.tag != ERROR) return; // arrays
+        if (!c.type.hasTag(CLASS) && !c.type.hasTag(ERROR)) return; // arrays
         if (pool != null && // pool might be null if called from xClassName
             c.owner.enclClass() != null &&
             (innerClasses == null || !innerClasses.contains(c))) {
 //          log.errWriter.println("enter inner " + c);//DEBUG
             enterInner(c.owner.enclClass());
             pool.put(c);
-            pool.put(c.name);
+            if (c.name != names.empty)
+                pool.put(c.name);
             if (innerClasses == null) {
                 innerClasses = new HashSet<ClassSymbol>();
                 innerClassesQueue = new ListBuffer<ClassSymbol>();
@@ -964,9 +1078,11 @@ public class ClassWriter extends ClassFile {
             char flags = (char) adjustFlags(inner.flags_field);
             if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
             if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag
+            flags &= ~STRICTFP; //inner classes should not have the strictfp flag set.
             if (dumpInnerClassModifiers) {
-                log.errWriter.println("INNERCLASS  " + inner.name);
-                log.errWriter.println("---" + flagNames(flags));
+                PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
+                pw.println("INNERCLASS  " + inner.name);
+                pw.println("---" + flagNames(flags));
             }
             databuf.appendChar(pool.get(inner));
             databuf.appendChar(
@@ -978,14 +1094,36 @@ public class ClassWriter extends ClassFile {
         endAttr(alenIdx);
     }
 
+    /** Write "bootstrapMethods" attribute.
+     */
+    void writeBootstrapMethods() {
+        int alenIdx = writeAttr(names.BootstrapMethods);
+        databuf.appendChar(bootstrapMethods.size());
+        for (Map.Entry<DynamicMethod, MethodHandle> entry : bootstrapMethods.entrySet()) {
+            DynamicMethod dmeth = entry.getKey();
+            DynamicMethodSymbol dsym = (DynamicMethodSymbol)dmeth.baseSymbol();
+            //write BSM handle
+            databuf.appendChar(pool.get(entry.getValue()));
+            //write static args length
+            databuf.appendChar(dsym.staticArgs.length);
+            //write static args array
+            Object[] uniqueArgs = dmeth.uniqueStaticArgs;
+            for (Object o : uniqueArgs) {
+                databuf.appendChar(pool.get(o));
+            }
+        }
+        endAttr(alenIdx);
+    }
+
     /** Write field symbol, entering all references into constant pool.
      */
     void writeField(VarSymbol v) {
         int flags = adjustFlags(v.flags());
         databuf.appendChar(flags);
         if (dumpFieldModifiers) {
-            log.errWriter.println("FIELD  " + fieldName(v));
-            log.errWriter.println("---" + flagNames(v.flags()));
+            PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
+            pw.println("FIELD  " + fieldName(v));
+            pw.println("---" + flagNames(v.flags()));
         }
         databuf.appendChar(pool.put(fieldName(v)));
         databuf.appendChar(pool.put(typeSig(v.erasure(types))));
@@ -998,6 +1136,7 @@ public class ClassWriter extends ClassFile {
             acount++;
         }
         acount += writeMemberAttrs(v);
+        acount += writeExtraMemberAttributes(v);
         endAttrs(acountIdx, acount);
     }
 
@@ -1007,8 +1146,9 @@ public class ClassWriter extends ClassFile {
         int flags = adjustFlags(m.flags());
         databuf.appendChar(flags);
         if (dumpMethodModifiers) {
-            log.errWriter.println("METHOD  " + fieldName(m));
-            log.errWriter.println("---" + flagNames(m.flags()));
+            PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
+            pw.println("METHOD  " + fieldName(m));
+            pw.println("---" + flagNames(m.flags()));
         }
         databuf.appendChar(pool.put(fieldName(m)));
         databuf.appendChar(pool.put(typeSig(m.externalType(types))));
@@ -1035,8 +1175,12 @@ public class ClassWriter extends ClassFile {
             endAttr(alenIdx);
             acount++;
         }
+        if (options.isSet(PARAMETERS))
+            acount += writeMethodParametersAttr(m);
         acount += writeMemberAttrs(m);
+        acount += writeExtraMemberAttributes(m);
         acount += writeParameterAttrs(m);
+        acount += writeExtraParameterAttributes(m);
         endAttrs(acountIdx, acount);
         m.code = null; // to conserve space
     }
@@ -1139,6 +1283,9 @@ public class ClassWriter extends ClassFile {
             endAttr(alenIdx);
             acount++;
         }
+
+        acount += writeTypeAnnotations(code.meth.getRawTypeAttributes(), true);
+
         endAttrs(acountIdx, acount);
     }
     //where
@@ -1218,7 +1365,7 @@ public class ClassWriter extends ClassFile {
                 if (debugstackmap) System.out.print("empty");
                 databuf.appendByte(0);
             }
-            else switch(t.tag) {
+            else switch(t.getTag()) {
             case BYTE:
             case CHAR:
             case SHORT:
@@ -1443,7 +1590,7 @@ public class ClassWriter extends ClassFile {
         }
 
         static boolean isInt(Type t) {
-            return (t.tag < TypeTags.INT || t.tag == TypeTags.BOOLEAN);
+            return (t.getTag().isStrictSubRangeOf(INT)  || t.hasTag(BOOLEAN));
         }
 
         static boolean isSameType(Type t1, Type t2, Types types) {
@@ -1452,15 +1599,15 @@ public class ClassWriter extends ClassFile {
 
             if (isInt(t1) && isInt(t2)) { return true; }
 
-            if (t1.tag == UNINITIALIZED_THIS) {
-                return t2.tag == UNINITIALIZED_THIS;
-            } else if (t1.tag == UNINITIALIZED_OBJECT) {
-                if (t2.tag == UNINITIALIZED_OBJECT) {
+            if (t1.hasTag(UNINITIALIZED_THIS)) {
+                return t2.hasTag(UNINITIALIZED_THIS);
+            } else if (t1.hasTag(UNINITIALIZED_OBJECT)) {
+                if (t2.hasTag(UNINITIALIZED_OBJECT)) {
                     return ((UninitializedType)t1).offset == ((UninitializedType)t2).offset;
                 } else {
                     return false;
                 }
-            } else if (t2.tag == UNINITIALIZED_THIS || t2.tag == UNINITIALIZED_OBJECT) {
+            } else if (t2.hasTag(UNINITIALIZED_THIS) || t2.hasTag(UNINITIALIZED_OBJECT)) {
                 return false;
             }
 
@@ -1527,7 +1674,7 @@ public class ClassWriter extends ClassFile {
             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;
@@ -1541,34 +1688,35 @@ public class ClassWriter extends ClassFile {
     public void writeClassFile(OutputStream out, ClassSymbol c)
         throws IOException, PoolOverflow, StringOverflow {
         Assert.check((c.flags() & COMPOUND) == 0);
-        generatedClass = c;
         databuf.reset();
         poolbuf.reset();
-        sigbuf.reset();
+        signatureGen.reset();
         pool = c.pool;
         innerClasses = null;
         innerClassesQueue = null;
+        bootstrapMethods = new LinkedHashMap<DynamicMethod, MethodHandle>();
 
         Type supertype = types.supertype(c.type);
         List<Type> interfaces = types.interfaces(c.type);
         List<Type> typarams = c.type.getTypeArguments();
 
-        int flags = adjustFlags(c.flags());
+        int flags = adjustFlags(c.flags() & ~DEFAULT);
         if ((flags & PROTECTED) != 0) flags |= PUBLIC;
         flags = flags & ClassFlags & ~STRICTFP;
         if ((flags & INTERFACE) == 0) flags |= ACC_SUPER;
         if (c.isInner() && c.name.isEmpty()) flags &= ~FINAL;
         if (dumpClassModifiers) {
-            log.errWriter.println();
-            log.errWriter.println("CLASSFILE  " + c.getQualifiedName());
-            log.errWriter.println("---" + flagNames(flags));
+            PrintWriter pw = log.getWriter(Log.WriterKind.ERROR);
+            pw.println();
+            pw.println("CLASSFILE  " + c.getQualifiedName());
+            pw.println("---" + flagNames(flags));
         }
         databuf.appendChar(flags);
 
         databuf.appendChar(pool.put(c));
-        if (supertype.tag == ERROR)
+        if (supertype.hasTag(ERROR))
             supertype = syms.objectType;
-        databuf.appendChar(supertype.tag == CLASS ? pool.put(supertype.tsym) : 0);
+        databuf.appendChar(supertype.hasTag(CLASS) ? pool.put(supertype.tsym) : 0);
         databuf.appendChar(interfaces.length());
         for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
             databuf.appendChar(pool.put(l.head.tsym));
@@ -1606,12 +1754,12 @@ public class ClassWriter extends ClassFile {
         if (sigReq) {
             Assert.check(allowGenerics);
             int alenIdx = writeAttr(names.Signature);
-            if (typarams.length() != 0) assembleParamsSig(typarams);
-            assembleSig(supertype);
+            if (typarams.length() != 0) signatureGen.assembleParamsSig(typarams);
+            signatureGen.assembleSig(supertype);
             for (List<Type> l = interfaces; l.nonEmpty(); l = l.tail)
-                assembleSig(l.head);
-            databuf.appendChar(pool.put(sigbuf.toName(names)));
-            sigbuf.reset();
+                signatureGen.assembleSig(l.head);
+            databuf.appendChar(pool.put(signatureGen.toName()));
+            signatureGen.reset();
             endAttr(alenIdx);
             acount++;
         }
@@ -1642,7 +1790,10 @@ public class ClassWriter extends ClassFile {
         }
 
         acount += writeFlagAttrs(c.flags());
-        acount += writeJavaAnnotations(c.getAnnotationMirrors());
+        acount += writeJavaAnnotations(c.getRawAttributes());
+        acount += writeExtraJavaAnnotations(c.getRawAttributes());
+        acount += writeTypeAnnotations(c.getRawTypeAttributes(), false);
+        acount += writeExtraTypeAnnotations(c.getRawTypeAttributes());
         acount += writeEnclosingMethodAttribute(c);
         acount += writeExtraClassAttributes(c);
 
@@ -1656,6 +1807,12 @@ public class ClassWriter extends ClassFile {
             writeInnerClasses();
             acount++;
         }
+
+        if (!bootstrapMethods.isEmpty()) {
+            writeBootstrapMethods();
+            acount++;
+        }
+
         endAttrs(acountIdx, acount);
 
         poolbuf.appendBytes(databuf.elems, 0, databuf.length);
@@ -1685,6 +1842,8 @@ public class ClassWriter extends ClassFile {
             result |= ACC_BRIDGE;
         if ((flags & VARARGS) != 0  && target.useVarargsFlag())
             result |= ACC_VARARGS;
+        if ((flags & DEFAULT) != 0)
+            result &= ~ABSTRACT;
         return result;
     }
 
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Code.java b/src/share/classes/com/sun/tools/javac/jvm/Code.java
index 33ba424..30166de 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -27,10 +27,12 @@ package com.sun.tools.javac.jvm;
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Types.UniqueType;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.BOT;
+import static com.sun.tools.javac.code.TypeTag.INT;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import static com.sun.tools.javac.jvm.UninitializedType.*;
 import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame;
@@ -122,7 +124,7 @@ public class Code {
 
 /*---------- internal fields: --------------- */
 
-    /** Are we generating code with jumps >= 32K?
+    /** Are we generating code with jumps ≥ 32K?
      */
     public boolean fatcode;
 
@@ -224,7 +226,7 @@ public class Code {
      *  JVM architecture).
      */
     public static int typecode(Type type) {
-        switch (type.tag) {
+        switch (type.getTag()) {
         case BYTE: return BYTEcode;
         case SHORT: return SHORTcode;
         case CHAR: return CHARcode;
@@ -243,7 +245,7 @@ public class Code {
         case UNINITIALIZED_THIS:
         case UNINITIALIZED_OBJECT:
             return OBJECTcode;
-        default: throw new AssertionError("typecode " + type.tag);
+        default: throw new AssertionError("typecode " + type.getTag());
         }
     }
 
@@ -284,7 +286,7 @@ public class Code {
     /** Given a type, return its code for allocating arrays of that type.
      */
     public static int arraycode(Type type) {
-        switch (type.tag) {
+        switch (type.getTag()) {
         case BYTE: return 8;
         case BOOLEAN: return 4;
         case SHORT: return 9;
@@ -317,11 +319,7 @@ public class Code {
      */
     private  void emit1(int od) {
         if (!alive) return;
-        if (cp == code.length) {
-            byte[] newcode = new byte[cp * 2];
-            System.arraycopy(code, 0, newcode, 0, cp);
-            code = newcode;
-        }
+        code = ArrayUtils.ensureCapacity(code, cp);
         code[cp++] = (byte)od;
     }
 
@@ -378,6 +376,17 @@ public class Code {
         Assert.check(alive || state.stacksize == 0);
     }
 
+    /** Emit a ldc (or ldc_w) instruction, taking into account operand size
+    */
+    public void emitLdc(int od) {
+        if (od <= 255) {
+            emitop1(ldc1, od);
+        }
+        else {
+            emitop2(ldc2, od);
+        }
+    }
+
     /** Emit a multinewarray instruction.
      */
     public void emitMultianewarray(int ndims, int type, Type arrayType) {
@@ -464,7 +473,15 @@ public class Code {
     public void emitInvokedynamic(int desc, Type mtype) {
         // N.B. this format is under consideration by the JSR 292 EG
         int argsize = width(mtype.getParameterTypes());
-        emitop(invokedynamic);
+        int prevPos = pendingStatPos;
+        try {
+            //disable line number generation (we could have used 'emit1', that
+            //bypasses stackmap generation - which is needed for indy calls)
+            pendingStatPos = Position.NOPOS;
+            emitop(invokedynamic);
+        } finally {
+            pendingStatPos = prevPos;
+        }
         if (!alive) return;
         emit2(desc);
         emit2(0);
@@ -484,7 +501,7 @@ public class Code {
             state.pop(1);
             //sometimes 'null type' is treated as a one-dimensional array type
             //see Gen.visitLiteral - we should handle this case accordingly
-            Type stackType = a.tag == BOT ?
+            Type stackType = a.hasTag(BOT) ?
                 syms.objectType :
                 types.erasure(types.elemtype(a));
             state.push(stackType); }
@@ -905,8 +922,15 @@ public class Code {
         if (o instanceof Long) return syms.longType;
         if (o instanceof Double) return syms.doubleType;
         if (o instanceof ClassSymbol) return syms.classType;
-        if (o instanceof Type.ArrayType) return syms.classType;
-        throw new AssertionError(o);
+        if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
+        if (o instanceof UniqueType) return typeForPool(((UniqueType)o).type);
+        if (o instanceof Type) {
+            Type ty = ((Type)o).unannotatedType();
+
+            if (ty instanceof Type.ArrayType) return syms.classType;
+            if (ty instanceof Type.MethodType) return syms.methodTypeType;
+        }
+        throw new AssertionError("Invalid type of constant pool entry: " + o.getClass());
     }
 
     /** Emit an opcode with a one-byte operand field;
@@ -993,7 +1017,16 @@ public class Code {
             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);
@@ -1034,7 +1067,7 @@ public class Code {
             Object o = pool.pool[od];
             Type t = (o instanceof Symbol)
                 ? ((Symbol)o).erasure(types)
-                : types.erasure(((Type)o));
+                : types.erasure((((UniqueType)o).type));
             state.push(t);
             break; }
         case ldc2w:
@@ -1080,13 +1113,15 @@ public class Code {
             while (cp % incr != 0) emitop0(nop);
     }
 
-    /** Place a byte into code at address pc. Pre: pc + 1 <= cp.
+    /** Place a byte into code at address pc.
+     *  Pre: {@literal pc + 1 <= cp }.
      */
     private void put1(int pc, int op) {
         code[pc] = (byte)op;
     }
 
-    /** Place two bytes into code at address pc. Pre: pc + 2 <= cp.
+    /** Place two bytes into code at address pc.
+     *  Pre: {@literal pc + 2 <= cp }.
      */
     private void put2(int pc, int od) {
         // pre: pc + 2 <= cp
@@ -1094,7 +1129,8 @@ public class Code {
         put1(pc+1, od);
     }
 
-    /** Place four  bytes into code at address pc. Pre: pc + 4 <= cp.
+    /** Place four  bytes into code at address pc.
+     *  Pre: {@literal pc + 4 <= cp }.
      */
     public void put4(int pc, int od) {
         // pre: pc + 4 <= cp
@@ -1245,12 +1281,8 @@ public class Code {
 
         if (stackMapBuffer == null) {
             stackMapBuffer = new StackMapFrame[20];
-        } else if (stackMapBuffer.length == stackMapBufferSize) {
-            StackMapFrame[] newStackMapBuffer =
-                new StackMapFrame[stackMapBufferSize << 1];
-            System.arraycopy(stackMapBuffer, 0, newStackMapBuffer,
-                             0, stackMapBufferSize);
-            stackMapBuffer = newStackMapBuffer;
+        } else {
+            stackMapBuffer = ArrayUtils.ensureCapacity(stackMapBuffer, stackMapBufferSize);
         }
         StackMapFrame frame =
             stackMapBuffer[stackMapBufferSize++] = new StackMapFrame();
@@ -1318,12 +1350,10 @@ public class Code {
 
         if (stackMapTableBuffer == null) {
             stackMapTableBuffer = new StackMapTableFrame[20];
-        } else if (stackMapTableBuffer.length == stackMapBufferSize) {
-            StackMapTableFrame[] newStackMapTableBuffer =
-                new StackMapTableFrame[stackMapBufferSize << 1];
-            System.arraycopy(stackMapTableBuffer, 0, newStackMapTableBuffer,
-                             0, stackMapBufferSize);
-            stackMapTableBuffer = newStackMapTableBuffer;
+        } else {
+            stackMapTableBuffer = ArrayUtils.ensureCapacity(
+                                    stackMapTableBuffer,
+                                    stackMapBufferSize);
         }
         stackMapTableBuffer[stackMapBufferSize++] =
                 StackMapTableFrame.getInstance(frame, lastFrame.pc, lastFrame.locals, types);
@@ -1545,7 +1575,28 @@ public class Code {
      */
     public void addCatch(
         char startPc, char endPc, char handlerPc, char catchType) {
-        catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType});
+            catchInfo.append(new char[]{startPc, endPc, handlerPc, catchType});
+        }
+
+
+    public void compressCatchTable() {
+        ListBuffer<char[]> compressedCatchInfo = ListBuffer.lb();
+        List<Integer> handlerPcs = List.nil();
+        for (char[] catchEntry : catchInfo) {
+            handlerPcs = handlerPcs.prepend((int)catchEntry[2]);
+        }
+        for (char[] catchEntry : catchInfo) {
+            int startpc = catchEntry[0];
+            int endpc = catchEntry[1];
+            if (startpc == endpc ||
+                    (startpc == (endpc - 1) &&
+                    handlerPcs.contains(startpc))) {
+                continue;
+            } else {
+                compressedCatchInfo.append(catchEntry);
+            }
+        }
+        catchInfo = compressedCatchInfo;
     }
 
 
@@ -1612,7 +1663,7 @@ public class Code {
         State dup() {
             try {
                 State state = (State)super.clone();
-                state.defined = defined.dup();
+                state.defined = new Bits(defined);
                 state.stack = stack.clone();
                 if (locks != null) state.locks = locks.clone();
                 if (debugCode) {
@@ -1628,10 +1679,8 @@ public class Code {
         void lock(int register) {
             if (locks == null) {
                 locks = new int[20];
-            } else if (locks.length == nlocks) {
-                int[] newLocks = new int[locks.length << 1];
-                System.arraycopy(locks, 0, newLocks, 0, locks.length);
-                locks = newLocks;
+            } else {
+                locks = ArrayUtils.ensureCapacity(locks, nlocks);
             }
             locks[nlocks] = register;
             nlocks++;
@@ -1645,23 +1694,19 @@ public class Code {
 
         void push(Type t) {
             if (debugCode) System.err.println("   pushing " + t);
-            switch (t.tag) {
-            case TypeTags.VOID:
+            switch (t.getTag()) {
+            case VOID:
                 return;
-            case TypeTags.BYTE:
-            case TypeTags.CHAR:
-            case TypeTags.SHORT:
-            case TypeTags.BOOLEAN:
+            case BYTE:
+            case CHAR:
+            case SHORT:
+            case BOOLEAN:
                 t = syms.intType;
                 break;
             default:
                 break;
             }
-            if (stacksize+2 >= stack.length) {
-                Type[] newstack = new Type[2*stack.length];
-                System.arraycopy(stack, 0, newstack, 0, stack.length);
-                stack = newstack;
-            }
+            stack = ArrayUtils.ensureCapacity(stack, stacksize+2);
             stack[stacksize++] = t;
             switch (width(t)) {
             case 1:
@@ -1715,7 +1760,7 @@ public class Code {
          *  of its current type. */
         void forceStackTop(Type t) {
             if (!alive) return;
-            switch (t.tag) {
+            switch (t.getTag()) {
             case CLASS:
             case ARRAY:
                 int width = width(t);
@@ -1746,7 +1791,7 @@ public class Code {
         }
 
         State join(State other) {
-            defined = defined.andSet(other.defined);
+            defined.andSet(other.defined);
             Assert.check(stacksize == other.stacksize
                     && nlocks == other.nlocks);
             for (int i=0; i<stacksize; ) {
@@ -1817,7 +1862,7 @@ public class Code {
         }
     }
 
-    static Type jsrReturnValue = new Type(TypeTags.INT, null);
+    static final Type jsrReturnValue = new JCPrimitiveType(INT, null);
 
 
 /* **************************************************************************
@@ -1848,13 +1893,7 @@ public class Code {
     /** Add a new local variable. */
     private void addLocalVar(VarSymbol v) {
         int adr = v.adr;
-        if (adr+1 >= lvar.length) {
-            int newlength = lvar.length << 1;
-            if (newlength <= adr) newlength = adr + 10;
-            LocalVar[] new_lvar = new LocalVar[newlength];
-            System.arraycopy(lvar, 0, new_lvar, 0, lvar.length);
-            lvar = new_lvar;
-        }
+        lvar = ArrayUtils.ensureCapacity(lvar, adr+1);
         Assert.checkNull(lvar[adr]);
         if (pendingJumps != null) resolvePending();
         lvar[adr] = new LocalVar(v);
@@ -1864,7 +1903,7 @@ public class Code {
     /** Set the current variable defined state. */
     public void setDefined(Bits newDefined) {
         if (alive && newDefined != state.defined) {
-            Bits diff = state.defined.dup().xorSet(newDefined);
+            Bits diff = new Bits(state.defined).xorSet(newDefined);
             for (int adr = diff.nextBit(0);
                  adr >= 0;
                  adr = diff.nextBit(adr+1)) {
@@ -1920,25 +1959,87 @@ public class Code {
                 if (length < Character.MAX_VALUE) {
                     v.length = length;
                     putVar(v);
+                    fillLocalVarPosition(v);
                 }
             }
         }
         state.defined.excl(adr);
     }
 
+    private void fillLocalVarPosition(LocalVar lv) {
+        if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations())
+            return;
+        for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
+            TypeAnnotationPosition p = ta.position;
+            p.lvarOffset = new int[] { (int)lv.start_pc };
+            p.lvarLength = new int[] { (int)lv.length };
+            p.lvarIndex = new int[] { (int)lv.reg };
+            p.isValidOffset = true;
+        }
+    }
+
+    // Method to be called after compressCatchTable to
+    // fill in the exception table index for type
+    // annotations on exception parameters.
+    public void fillExceptionParameterPositions() {
+        for (int i = 0; i < varBufferSize; ++i) {
+            LocalVar lv = varBuffer[i];
+            if (lv == null || lv.sym == null
+                    || !lv.sym.hasTypeAnnotations()
+                    || !lv.sym.isExceptionParameter())
+                continue;
+
+            for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
+                TypeAnnotationPosition p = ta.position;
+                // 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(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 ct = catchEntry[3];
+            if (catchType == ct) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
     /** Put a live variable range into the buffer to be output to the
      *  class file.
      */
     void putVar(LocalVar var) {
-        if (!varDebugInfo) return;
+        // Keep local variables if
+        // 1) we need them for debug information
+        // 2) it is an exception type and it contains type annotations
+        if (!varDebugInfo &&
+                (!var.sym.isExceptionParameter() ||
+                var.sym.hasTypeAnnotations())) return;
         if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
         if (varBuffer == null)
             varBuffer = new LocalVar[20];
-        else if (varBufferSize >= varBuffer.length) {
-            LocalVar[] newVarBuffer = new LocalVar[varBufferSize*2];
-            System.arraycopy(varBuffer, 0, newVarBuffer, 0, varBuffer.length);
-            varBuffer = newVarBuffer;
-        }
+        else
+            varBuffer = ArrayUtils.ensureCapacity(varBuffer, varBufferSize);
         varBuffer[varBufferSize++] = var;
     }
 
@@ -1951,7 +2052,7 @@ public class Code {
     private int newLocal(int typecode) {
         int reg = nextreg;
         int w = width(typecode);
-        nextreg = reg + w;
+        nextreg = w > 0 ? reg + w : reg + 1;
         if (nextreg > max_locals) max_locals = nextreg;
         return reg;
     }
@@ -1972,7 +2073,7 @@ public class Code {
         nextreg = max_locals;
     }
 
-    /** End scopes of all variables with registers >= first.
+    /** End scopes of all variables with registers ≥ first.
      */
     public void endScopes(int first) {
         int prevNextReg = nextreg;
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
index b8cc107..2b8bc5a 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,12 +26,12 @@
 package com.sun.tools.javac.jvm;
 import java.util.*;
 
-import javax.lang.model.element.ElementKind;
-
 import com.sun.tools.javac.util.*;
 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.*;
 
@@ -39,14 +39,16 @@ import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.Code.*;
 import com.sun.tools.javac.jvm.Items.*;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import static com.sun.tools.javac.jvm.CRTFlags.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** This pass maps flat Java (i.e. without inner classes) to bytecodes.
  *
@@ -70,6 +72,7 @@ public class Gen extends JCTree.Visitor {
     private final Map<Type,Symbol> stringBufferAppend;
     private Name accessDollar;
     private final Types types;
+    private final Lower lower;
 
     /** Switch: GJ mode?
      */
@@ -92,6 +95,10 @@ public class Gen extends JCTree.Visitor {
         return instance;
     }
 
+    /* Constant pool, reset by genClass.
+     */
+    private Pool pool;
+
     protected Gen(Context context) {
         context.put(genKey, this);
 
@@ -111,6 +118,7 @@ public class Gen extends JCTree.Visitor {
         stringBufferAppend = new HashMap<Type,Symbol>();
         accessDollar = names.
             fromString("access" + target.syntheticNameChar());
+        lower = Lower.instance(context);
 
         Options options = Options.instance(context);
         lineDebugInfo =
@@ -123,6 +131,7 @@ public class Gen extends JCTree.Visitor {
         genCrt = options.isSet(XJCOV);
         debugCode = options.isSet("debugcode");
         allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
+        pool = new Pool(types);
 
         generateIproxies =
             target.requiresIproxy() ||
@@ -171,10 +180,6 @@ public class Gen extends JCTree.Visitor {
      */
     private boolean useJsrLocally;
 
-    /* Constant pool, reset by genClass.
-     */
-    private Pool pool = new Pool();
-
     /** Code buffer, set by genMethod.
      */
     private Code code;
@@ -195,9 +200,10 @@ public class Gen extends JCTree.Visitor {
      */
     private int nerrs = 0;
 
-    /** A hash table mapping syntax trees to their ending source positions.
+    /** An object containing mappings of syntax trees to their
+     *  ending source positions.
      */
-    private Map<JCTree, Integer> endPositions;
+    EndPosTable endPosTable;
 
     /** Generate code to load an integer constant.
      *  @param n     The integer to be loaded.
@@ -245,10 +251,10 @@ public class Gen extends JCTree.Visitor {
     /** Construct a symbol to reflect the qualifying type that should
      *  appear in the byte code as per JLS 13.1.
      *
-     *  For target >= 1.2: Clone a method with the qualifier as owner (except
+     *  For {@literal target >= 1.2}: Clone a method with the qualifier as owner (except
      *  for those cases where we need to work around VM bugs).
      *
-     *  For target <= 1.1: If qualified variable or method is defined in a
+     *  For {@literal target <= 1.1}: If qualified variable or method is defined in a
      *  non-accessible class, clone it with the qualifier class as owner.
      *
      *  @param sym    The accessed symbol
@@ -256,7 +262,7 @@ public class Gen extends JCTree.Visitor {
      */
     Symbol binaryQualifier(Symbol sym, Type site) {
 
-        if (site.tag == ARRAY) {
+        if (site.hasTag(ARRAY)) {
             if (sym == syms.lengthVar ||
                 sym.owner != syms.arrayClass)
                 return sym;
@@ -303,13 +309,21 @@ public class Gen extends JCTree.Visitor {
      */
     int makeRef(DiagnosticPosition pos, Type type) {
         checkDimension(pos, type);
-        return pool.put(type.tag == 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.
      */
     private void checkDimension(DiagnosticPosition pos, Type t) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case METHOD:
             checkDimension(pos, t.getReturnType());
             for (List<Type> args = t.getParameterTypes(); args.nonEmpty(); args = args.tail)
@@ -433,7 +447,7 @@ public class Gen extends JCTree.Visitor {
      */
     boolean hasFinally(JCTree target, Env<GenContext> env) {
         while (env.tree != target) {
-            if (env.tree.getTag() == JCTree.TRY && env.info.finalize.hasFinalizer())
+            if (env.tree.hasTag(TRY) && env.info.finalize.hasFinalizer())
                 return true;
             env = env.next;
         }
@@ -444,14 +458,16 @@ public class Gen extends JCTree.Visitor {
  * Normalizing class-members.
  *************************************************************************/
 
-    /** Distribute member initializer code into constructors and <clinit>
+    /** Distribute member initializer code into constructors and {@code <clinit>}
      *  method.
      *  @param defs         The list of class member declarations.
      *  @param c            The enclosing class.
      */
     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
@@ -460,17 +476,17 @@ public class Gen extends JCTree.Visitor {
         for (List<JCTree> l = defs; l.nonEmpty(); l = l.tail) {
             JCTree def = l.head;
             switch (def.getTag()) {
-            case JCTree.BLOCK:
+            case BLOCK:
                 JCBlock block = (JCBlock)def;
                 if ((block.flags & STATIC) != 0)
                     clinitCode.append(block);
                 else
                     initCode.append(block);
                 break;
-            case JCTree.METHODDEF:
+            case METHODDEF:
                 methodDefs.append(def);
                 break;
-            case JCTree.VARDEF:
+            case VARDEF:
                 JCVariableDecl vdef = (JCVariableDecl) def;
                 VarSymbol sym = vdef.sym;
                 checkDimension(vdef.pos(), sym.type);
@@ -480,20 +496,16 @@ public class Gen extends JCTree.Visitor {
                         JCStatement init = make.at(vdef.pos()).
                             Assignment(sym, vdef.init);
                         initCode.append(init);
-                        if (endPositions != null) {
-                            Integer endPos = endPositions.remove(vdef);
-                            if (endPos != null) endPositions.put(init, endPos);
-                        }
+                        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.
                         JCStatement init = make.at(vdef.pos).
                             Assignment(sym, vdef.init);
                         clinitCode.append(init);
-                        if (endPositions != null) {
-                            Integer endPos = endPositions.remove(vdef);
-                            if (endPos != null) endPositions.put(init, endPos);
-                        }
+                        endPosTable.replaceTree(vdef, init);
+                        clinitTAs.addAll(getAndRemoveNonFieldTAs(sym));
                     } else {
                         checkStringConstant(vdef.init.pos(), sym.getConstValue());
                     }
@@ -506,8 +518,10 @@ public class Gen extends JCTree.Visitor {
         // Insert any instance initializers into all constructors.
         if (initCode.length() != 0) {
             List<JCStatement> inits = initCode.toList();
+            initTAs.addAll(c.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
@@ -516,7 +530,8 @@ public class Gen extends JCTree.Visitor {
             Symbol clinit = c.members().lookup(names.clinit).sym;
             if (!(clinit instanceof MethodSymbol)) {
                 clinit = new MethodSymbol(
-                    STATIC, names.clinit,
+                    STATIC | (c.flags() & STRICTFP),
+                    names.clinit,
                     new MethodType(
                         List.<Type>nil(), syms.voidType,
                         List.<Type>nil(), syms.methodClass),
@@ -527,11 +542,31 @@ public class Gen extends JCTree.Visitor {
             JCBlock block = make.at(clinitStats.head.pos()).Block(0, clinitStats);
             block.endpos = TreeInfo.endPos(clinitStats.last());
             methodDefs.append(make.MethodDef((MethodSymbol)clinit, block));
+
+            if (!clinitTAs.isEmpty())
+                clinit.appendUniqueTypeAttributes(clinitTAs.toList());
+            if (!c.getClassInitTypeAttributes().isEmpty())
+                clinit.appendUniqueTypeAttributes(c.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.setTypeAttributes(fieldTAs.toList());
+        return nonfieldTAs.toList();
+    }
+
     /** Check a constant value and report if it is a string that is
      *  too large.
      */
@@ -549,8 +584,9 @@ public class Gen extends JCTree.Visitor {
      *  @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.
@@ -584,6 +620,8 @@ public class Gen extends JCTree.Visitor {
             md.body.stats = newstats.toList();
             if (md.body.endpos == Position.NOPOS)
                 md.body.endpos = TreeInfo.endPos(md.body.stats.last());
+
+            md.sym.appendUniqueTypeAttributes(initTAs);
         }
     }
 
@@ -696,7 +734,7 @@ public class Gen extends JCTree.Visitor {
      *  should be emitted, if so, put a new entry into CRTable
      *  and call method to generate bytecode.
      *  If not, just call method to generate bytecode.
-     *  @see    #genStat(Tree, Env)
+     *  @see    #genStat(JCTree, Env)
      *
      *  @param  tree     The tree to be visited.
      *  @param  env      The environment to use.
@@ -710,7 +748,7 @@ public class Gen extends JCTree.Visitor {
         }
         int startpc = code.curPc();
         genStat(tree, env);
-        if (tree.getTag() == JCTree.BLOCK) crtFlags |= CRT_BLOCK;
+        if (tree.hasTag(Tag.BLOCK)) crtFlags |= CRT_BLOCK;
         code.crt.put(tree, crtFlags, startpc, code.curPc());
     }
 
@@ -720,7 +758,7 @@ public class Gen extends JCTree.Visitor {
         if (code.isAlive()) {
             code.statBegin(tree.pos);
             genDef(tree, env);
-        } else if (env.info.isSwitch && tree.getTag() == JCTree.VARDEF) {
+        } else if (env.info.isSwitch && tree.hasTag(VARDEF)) {
             // variables whose declarations are in a switch
             // can be used even if the decl is unreachable.
             code.newLocal(((JCVariableDecl) tree).sym);
@@ -763,7 +801,7 @@ public class Gen extends JCTree.Visitor {
      *  should be emitted, if so, put a new entry into CRTable
      *  and call method to generate bytecode.
      *  If not, just call method to generate bytecode.
-     *  @see    #genCond(Tree,boolean)
+     *  @see    #genCond(JCTree,boolean)
      *
      *  @param  tree     The tree to be visited.
      *  @param  crtFlags The CharacterRangeTable flags
@@ -787,7 +825,7 @@ public class Gen extends JCTree.Visitor {
      */
     public CondItem genCond(JCTree _tree, boolean markBranches) {
         JCTree inner_tree = TreeInfo.skipParens(_tree);
-        if (inner_tree.getTag() == JCTree.CONDEXPR) {
+        if (inner_tree.hasTag(CONDEXPR)) {
             JCConditional tree = (JCConditional)inner_tree;
             CondItem cond = genCond(tree.cond, CRT_FLOW_CONTROLLER);
             if (cond.isTrue()) {
@@ -823,6 +861,62 @@ public class Gen extends JCTree.Visitor {
         }
     }
 
+    /** Visitor class for expressions which might be constant expressions.
+     *  This class is a subset of TreeScanner. Intended to visit trees pruned by
+     *  Lower as long as constant expressions looking for references to any
+     *  ClassSymbol. Any such reference will be added to the constant pool so
+     *  automated tools can detect class dependencies better.
+     */
+    class ClassReferenceVisitor extends JCTree.Visitor {
+
+        @Override
+        public void visitTree(JCTree tree) {}
+
+        @Override
+        public void visitBinary(JCBinary tree) {
+            tree.lhs.accept(this);
+            tree.rhs.accept(this);
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            if (tree.selected.type.hasTag(CLASS)) {
+                makeRef(tree.selected.pos(), tree.selected.type);
+            }
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            if (tree.sym.owner instanceof ClassSymbol) {
+                pool.put(tree.sym.owner);
+            }
+        }
+
+        @Override
+        public void visitConditional(JCConditional tree) {
+            tree.cond.accept(this);
+            tree.truepart.accept(this);
+            tree.falsepart.accept(this);
+        }
+
+        @Override
+        public void visitUnary(JCUnary tree) {
+            tree.arg.accept(this);
+        }
+
+        @Override
+        public void visitParens(JCParens tree) {
+            tree.expr.accept(this);
+        }
+
+        @Override
+        public void visitTypeCast(JCTypeCast tree) {
+            tree.expr.accept(this);
+        }
+    }
+
+    private ClassReferenceVisitor classReferenceVisitor = new ClassReferenceVisitor();
+
     /** Visitor method: generate code for an expression, catching and reporting
      *  any completion failures.
      *  @param tree    The expression to be visited.
@@ -833,6 +927,7 @@ public class Gen extends JCTree.Visitor {
         try {
             if (tree.type != null && tree.type.constValue() != null) {
                 // Short circuit any expressions which are constants
+                tree.accept(classReferenceVisitor);
                 checkStringConstant(tree.pos(), tree.type.constValue());
                 result = items.makeImmediateItem(tree.type, tree.type.constValue());
             } else {
@@ -899,9 +994,19 @@ public class Gen extends JCTree.Visitor {
          */
         void genMethod(JCMethodDecl tree, Env<GenContext> env, boolean fatcode) {
             MethodSymbol meth = tree.sym;
-//      System.err.println("Generating " + meth + " in " + meth.owner); //DEBUG
-            if (Code.width(types.erasure(env.enclMethod.sym.type).getParameterTypes())  +
-                (((tree.mods.flags & STATIC) == 0 || meth.isConstructor()) ? 1 : 0) >
+            int extras = 0;
+            // Count up extra parameters
+            if (meth.isConstructor()) {
+                extras++;
+                if (meth.enclClass().isInner() &&
+                    !meth.enclClass().isStatic()) {
+                    extras++;
+                }
+            } else if ((tree.mods.flags & STATIC) == 0) {
+                extras++;
+            }
+            //      System.err.println("Generating " + meth + " in " + meth.owner); //DEBUG
+            if (Code.width(types.erasure(env.enclMethod.sym.type).getParameterTypes()) + extras >
                 ClassFile.MAX_PARAMETERS) {
                 log.error(tree.pos(), "limit.parameters");
                 nerrs++;
@@ -929,7 +1034,7 @@ public class Gen extends JCTree.Visitor {
                 if (code.isAlive()) {
                     code.statBegin(TreeInfo.endPos(tree.body));
                     if (env.enclMethod == null ||
-                        env.enclMethod.sym.type.getReturnType().tag == VOID) {
+                        env.enclMethod.sym.type.getReturnType().hasTag(VOID)) {
                         code.emitop0(return_);
                     } else {
                         // sometime dead code seems alive (4415991);
@@ -962,6 +1067,12 @@ public class Gen extends JCTree.Visitor {
                     code.lastFrame = null;
                     code.frameBeforeLast = null;
                 }
+
+                // Compress exception table
+                code.compressCatchTable();
+
+                // Fill in type annotation positions for exception parameters
+                code.fillExceptionParameterPositions();
             }
         }
 
@@ -1033,7 +1144,7 @@ public class Gen extends JCTree.Visitor {
         Env<GenContext> localEnv = env.dup(tree, new GenContext());
         genStats(tree.stats, localEnv);
         // End the scope of all block-local variables in variable info.
-        if (env.tree.getTag() != JCTree.METHODDEF) {
+        if (!env.tree.hasTag(METHODDEF)) {
             code.statBegin(tree.endpos);
             code.endScopes(limit);
             code.pendingStatPos = Position.NOPOS;
@@ -1114,7 +1225,7 @@ public class Gen extends JCTree.Visitor {
 
     public void visitSwitch(JCSwitch tree) {
         int limit = code.nextreg;
-        Assert.check(tree.selector.type.tag != CLASS);
+        Assert.check(!tree.selector.type.hasTag(CLASS));
         int startpcCrt = genCrt ? code.curPc() : 0;
         Item sel = genExpr(tree.selector, syms.intType);
         List<JCCase> cases = tree.cases;
@@ -1440,7 +1551,6 @@ public class Gen extends JCTree.Visitor {
                     code.markDead();
                 }
             }
-
             // Resolve all breaks.
             code.resolve(exitChain);
 
@@ -1468,6 +1578,11 @@ public class Gen extends JCTree.Visitor {
                         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();
@@ -1479,6 +1594,11 @@ public class Gen extends JCTree.Visitor {
                         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;
@@ -1499,23 +1619,21 @@ public class Gen extends JCTree.Visitor {
         void registerCatch(DiagnosticPosition pos,
                            int startpc, int endpc,
                            int handler_pc, int catch_type) {
-            if (startpc != endpc) {
-                char startpc1 = (char)startpc;
-                char endpc1 = (char)endpc;
-                char handler_pc1 = (char)handler_pc;
-                if (startpc1 == startpc &&
-                    endpc1 == endpc &&
-                    handler_pc1 == handler_pc) {
-                    code.addCatch(startpc1, endpc1, handler_pc1,
-                                  (char)catch_type);
+            char startpc1 = (char)startpc;
+            char endpc1 = (char)endpc;
+            char handler_pc1 = (char)handler_pc;
+            if (startpc1 == startpc &&
+                endpc1 == endpc &&
+                handler_pc1 == handler_pc) {
+                code.addCatch(startpc1, endpc1, handler_pc1,
+                              (char)catch_type);
+            } else {
+                if (!useJsrLocally && !target.generateStackMapTable()) {
+                    useJsrLocally = true;
+                    throw new CodeSizeOverflow();
                 } else {
-                    if (!useJsrLocally && !target.generateStackMapTable()) {
-                        useJsrLocally = true;
-                        throw new CodeSizeOverflow();
-                    } else {
-                        log.error(pos, "limit.code.too.large.for.try.stmt");
-                        nerrs++;
-                    }
+                    log.error(pos, "limit.code.too.large.for.try.stmt");
+                    nerrs++;
                 }
             }
         }
@@ -1631,11 +1749,11 @@ public class Gen extends JCTree.Visitor {
         // Optimize x++ to ++x and x-- to --x.
         JCExpression e = tree.expr;
         switch (e.getTag()) {
-            case JCTree.POSTINC:
-                ((JCUnary) e).setTag(JCTree.PREINC);
+            case POSTINC:
+                ((JCUnary) e).setTag(PREINC);
                 break;
-            case JCTree.POSTDEC:
-                ((JCUnary) e).setTag(JCTree.PREDEC);
+            case POSTDEC:
+                ((JCUnary) e).setTag(PREDEC);
                 break;
         }
         genExpr(tree.expr, tree.expr.type).drop();
@@ -1668,7 +1786,16 @@ public class Gen extends JCTree.Visitor {
             r.load();
             code.emitop0(ireturn + Code.truncate(Code.typecode(pt)));
         } else {
+            /*  If we have a statement like:
+             *
+             *  return;
+             *
+             *  we need to store the code.pendingStatPos value before generating
+             *  the finalizer.
+             */
+            int tmpPos = code.pendingStatPos;
             targetEnv = unwind(env.enclMethod, env);
+            code.pendingStatPos = tmpPos;
             code.emitop0(return_);
         }
         endFinalizerGaps(env, targetEnv);
@@ -1685,13 +1812,19 @@ public class Gen extends JCTree.Visitor {
  *************************************************************************/
 
     public void visitApply(JCMethodInvocation tree) {
+        setTypeAnnotationPositions(tree.pos);
         // Generate code for method.
         Item m = genExpr(tree.meth, methodType);
         // Generate code for all arguments, where the expected types are
         // the parameters of the method's external type (that is, any implicit
         // outer instance of a super(...) call appears as first parameter).
+        MethodSymbol msym = (MethodSymbol)TreeInfo.symbol(tree.meth);
         genArgs(tree.args,
-                TreeInfo.symbol(tree.meth).externalType(types).getParameterTypes());
+                msym.externalType(types).getParameterTypes());
+        if (!msym.isDynamic()) {
+            code.statBegin(tree.pos);
+            code.markStatBegin();
+        }
         result = m.invoke();
     }
 
@@ -1720,10 +1853,50 @@ public class Gen extends JCTree.Visitor {
         result = items.makeStackItem(pt);
     }
 
+    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.hasUnknownPosition())
+                ta.tryFixPosition();
+
+            if (ta.position.matchesPos(treePos))
+                ta.position.updatePosOffset(code.cp);
+        }
+
+        if (!initOrClinit)
+            return;
+
+        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.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
         // by now.
         Assert.check(tree.encl == null && tree.def == null);
+        setTypeAnnotationPositions(tree.pos);
 
         code.emitop2(new_, makeRef(tree.pos(), tree.type));
         code.emitop0(dup);
@@ -1738,6 +1911,7 @@ public class Gen extends JCTree.Visitor {
     }
 
     public void visitNewArray(JCNewArray tree) {
+        setTypeAnnotationPositions(tree.pos);
 
         if (tree.elems != null) {
             Type elemtype = types.elemtype(tree.type);
@@ -1820,13 +1994,13 @@ public class Gen extends JCTree.Visitor {
             // If we have an increment of -32768 to +32767 of a local
             // int variable we can use an incr instruction instead of
             // proceeding further.
-            if ((tree.getTag() == JCTree.PLUS_ASG || tree.getTag() == JCTree.MINUS_ASG) &&
+            if ((tree.hasTag(PLUS_ASG) || tree.hasTag(MINUS_ASG)) &&
                 l instanceof LocalItem &&
-                tree.lhs.type.tag <= INT &&
-                tree.rhs.type.tag <= INT &&
+                tree.lhs.type.getTag().isSubRangeOf(INT) &&
+                tree.rhs.type.getTag().isSubRangeOf(INT) &&
                 tree.rhs.type.constValue() != null) {
                 int ival = ((Number) tree.rhs.type.constValue()).intValue();
-                if (tree.getTag() == JCTree.MINUS_ASG) ival = -ival;
+                if (tree.hasTag(MINUS_ASG)) ival = -ival;
                 ((LocalItem)l).incr(ival);
                 result = l;
                 return;
@@ -1842,29 +2016,29 @@ public class Gen extends JCTree.Visitor {
 
     public void visitUnary(JCUnary tree) {
         OperatorSymbol operator = (OperatorSymbol)tree.operator;
-        if (tree.getTag() == JCTree.NOT) {
+        if (tree.hasTag(NOT)) {
             CondItem od = genCond(tree.arg, false);
             result = od.negate();
         } else {
             Item od = genExpr(tree.arg, operator.type.getParameterTypes().head);
             switch (tree.getTag()) {
-            case JCTree.POS:
+            case POS:
                 result = od.load();
                 break;
-            case JCTree.NEG:
+            case NEG:
                 result = od.load();
                 code.emitop0(operator.opcode);
                 break;
-            case JCTree.COMPL:
+            case COMPL:
                 result = od.load();
                 emitMinusOne(od.typecode);
                 code.emitop0(operator.opcode);
                 break;
-            case JCTree.PREINC: case JCTree.PREDEC:
+            case PREINC: case PREDEC:
                 od.duplicate();
                 if (od instanceof LocalItem &&
                     (operator.opcode == iadd || operator.opcode == isub)) {
-                    ((LocalItem)od).incr(tree.getTag() == JCTree.PREINC ? 1 : -1);
+                    ((LocalItem)od).incr(tree.hasTag(PREINC) ? 1 : -1);
                     result = od;
                 } else {
                     od.load();
@@ -1878,12 +2052,12 @@ public class Gen extends JCTree.Visitor {
                     result = items.makeAssignItem(od);
                 }
                 break;
-            case JCTree.POSTINC: case JCTree.POSTDEC:
+            case POSTINC: case POSTDEC:
                 od.duplicate();
                 if (od instanceof LocalItem &&
                     (operator.opcode == iadd || operator.opcode == isub)) {
                     Item res = od.load();
-                    ((LocalItem)od).incr(tree.getTag() == JCTree.POSTINC ? 1 : -1);
+                    ((LocalItem)od).incr(tree.hasTag(POSTINC) ? 1 : -1);
                     result = res;
                 } else {
                     Item res = od.load();
@@ -1899,7 +2073,7 @@ public class Gen extends JCTree.Visitor {
                     result = res;
                 }
                 break;
-            case JCTree.NULLCHK:
+            case NULLCHK:
                 result = od.load();
                 code.emitop0(dup);
                 genNullCheck(tree.pos());
@@ -1927,7 +2101,7 @@ public class Gen extends JCTree.Visitor {
             // Convert buffer to string.
             bufferToString(tree.pos());
             result = items.makeStackItem(syms.stringType);
-        } else if (tree.getTag() == JCTree.AND) {
+        } else if (tree.hasTag(AND)) {
             CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER);
             if (!lcond.isFalse()) {
                 Chain falseJumps = lcond.jumpFalse();
@@ -1941,7 +2115,7 @@ public class Gen extends JCTree.Visitor {
             } else {
                 result = lcond;
             }
-        } else if (tree.getTag() == JCTree.OR) {
+        } else if (tree.hasTag(OR)) {
             CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER);
             if (!lcond.isTrue()) {
                 Chain trueJumps = lcond.jumpTrue();
@@ -1974,7 +2148,7 @@ public class Gen extends JCTree.Visitor {
          */
         void appendString(JCTree tree) {
             Type t = tree.type.baseType();
-            if (t.tag > lastBaseTag && t.tsym != syms.stringType.tsym) {
+            if (!t.isPrimitive() && t.tsym != syms.stringType.tsym) {
                 t = syms.objectType;
             }
             items.makeMemberItem(getStringBufferAppend(tree, t), false).invoke();
@@ -1998,7 +2172,7 @@ public class Gen extends JCTree.Visitor {
          */
         void appendStrings(JCTree tree) {
             tree = TreeInfo.skipParens(tree);
-            if (tree.getTag() == JCTree.PLUS && tree.type.constValue() == null) {
+            if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
                 JCBinary op = (JCBinary) tree;
                 if (op.operator.kind == MTH &&
                     ((OperatorSymbol) op.operator).opcode == string_add) {
@@ -2067,12 +2241,13 @@ public class Gen extends JCTree.Visitor {
         }
 
     public void visitTypeCast(JCTypeCast tree) {
+        setTypeAnnotationPositions(tree.pos);
         result = genExpr(tree.expr, tree.clazz.type).load();
         // Additional code is only needed if we cast to a reference type
         // which is not statically a supertype of the expression's type.
         // For basic types, the coerce(...) in genExpr(...) will do
         // the conversion.
-        if (tree.clazz.type.tag > lastBaseTag &&
+        if (!tree.clazz.type.isPrimitive() &&
             types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
             code.emitop2(checkcast, makeRef(tree.pos(), tree.clazz.type));
         }
@@ -2083,6 +2258,7 @@ public class Gen extends JCTree.Visitor {
     }
 
     public void visitTypeTest(JCInstanceOf tree) {
+        setTypeAnnotationPositions(tree.pos);
         genExpr(tree.expr, tree.expr.type).load();
         code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
         result = items.makeStackItem(syms.booleanType);
@@ -2108,6 +2284,8 @@ public class Gen extends JCTree.Visitor {
             result = res;
         } else if (sym.kind == VAR && sym.owner.kind == MTH) {
             result = items.makeLocalItem((VarSymbol)sym);
+        } else if (isInvokeDynamic(sym)) {
+            result = items.makeDynamicItem(sym);
         } else if ((sym.flags() & STATIC) != 0) {
             if (!isAccessSuper(env.enclMethod))
                 sym = binaryQualifier(sym, env.enclClass.type);
@@ -2124,10 +2302,10 @@ public class Gen extends JCTree.Visitor {
 
         if (tree.name == names._class) {
             Assert.check(target.hasClassLiterals());
-            code.emitop2(ldc2, makeRef(tree.pos(), tree.selected.type));
+            code.emitLdc(makeRef(tree.pos(), tree.selected.type));
             result = items.makeStackItem(pt);
             return;
-        }
+       }
 
         Symbol ssym = TreeInfo.symbol(tree.selected);
 
@@ -2157,8 +2335,12 @@ public class Gen extends JCTree.Visitor {
             result = items.
                 makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
         } else {
-            if (!accessSuper)
+            if (isInvokeDynamic(sym)) {
+                result = items.makeDynamicItem(sym);
+                return;
+            } else if (!accessSuper) {
                 sym = binaryQualifier(sym, tree.selected.type);
+            }
             if ((sym.flags() & STATIC) != 0) {
                 if (!selectSuper && (ssym == null || ssym.kind != TYP))
                     base = base.load();
@@ -2179,8 +2361,12 @@ public class Gen extends JCTree.Visitor {
         }
     }
 
+    public boolean isInvokeDynamic(Symbol sym) {
+        return sym.kind == MTH && ((MethodSymbol)sym).isDynamic();
+    }
+
     public void visitLiteral(JCLiteral tree) {
-        if (tree.type.tag == TypeTags.BOT) {
+        if (tree.type.hasTag(BOT)) {
             code.emitop0(aconst_null);
             if (types.dimensions(pt) > 1) {
                 code.emitop2(checkcast, makeRef(tree.pos(), pt));
@@ -2200,6 +2386,15 @@ public class Gen extends JCTree.Visitor {
         code.endScopes(limit);
     }
 
+    private void generateReferencesToPrunedTree(ClassSymbol classSymbol, Pool pool) {
+        List<JCTree> prunedInfo = lower.prunedTree.get(classSymbol);
+        if (prunedInfo != null) {
+            for (JCTree prunedTree: prunedInfo) {
+                prunedTree.accept(classReferenceVisitor);
+            }
+        }
+    }
+
 /* ************************************************************************
  * main method
  *************************************************************************/
@@ -2216,7 +2411,7 @@ public class Gen extends JCTree.Visitor {
             attrEnv = env;
             ClassSymbol c = cdef.sym;
             this.toplevel = env.toplevel;
-            this.endPositions = toplevel.endPositions;
+            this.endPosTable = toplevel.endPositions;
             // If this is a class definition requiring Miranda methods,
             // add them.
             if (generateIproxies &&
@@ -2227,6 +2422,7 @@ public class Gen extends JCTree.Visitor {
             cdef.defs = normalizeDefs(cdef.defs, c);
             c.pool = pool;
             pool.reset();
+            generateReferencesToPrunedTree(c, pool);
             Env<GenContext> localEnv =
                 new Env<GenContext>(cdef, new GenContext());
             localEnv.toplevel = env.toplevel;
@@ -2241,7 +2437,7 @@ public class Gen extends JCTree.Visitor {
             if (nerrs != 0) {
                 // if errors, discard code
                 for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) {
-                    if (l.head.getTag() == JCTree.METHODDEF)
+                    if (l.head.hasTag(METHODDEF))
                         ((JCMethodDecl) l.head).sym.code = null;
                 }
             }
@@ -2252,7 +2448,7 @@ public class Gen extends JCTree.Visitor {
             attrEnv = null;
             this.env = null;
             toplevel = null;
-            endPositions = null;
+            endPosTable = null;
             nerrs = 0;
         }
     }
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Items.java b/src/share/classes/com/sun/tools/javac/jvm/Items.java
index 5550239..054facd 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Items.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Items.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -110,6 +110,13 @@ public class Items {
         return stackItem[Code.typecode(type)];
     }
 
+    /** Make an item representing a dynamically invoked method.
+     *  @param member   The represented symbol.
+     */
+    Item makeDynamicItem(Symbol member) {
+        return new DynamicItem(member);
+    }
+
     /** Make an item representing an indexed expression.
      *  @param type    The expression's type.
      */
@@ -457,6 +464,35 @@ public class Items {
         }
     }
 
+    /** An item representing a dynamic call site.
+     */
+    class DynamicItem extends StaticItem {
+        DynamicItem(Symbol member) {
+            super(member);
+        }
+
+        Item load() {
+            assert false;
+            return null;
+        }
+
+        void store() {
+            assert false;
+        }
+
+        Item invoke() {
+            // assert target.hasNativeInvokeDynamic();
+            MethodType mtype = (MethodType)member.erasure(types);
+            int rescode = Code.typecode(mtype.restype);
+            code.emitInvokedynamic(pool.put(member), mtype);
+            return stackItem[rescode];
+        }
+
+        public String toString() {
+            return "dynamic(" + member + ")";
+        }
+    }
+
     /** An item representing an instance variable or method.
      */
     class MemberItem extends Item {
@@ -487,7 +523,7 @@ public class Items {
         Item invoke() {
             MethodType mtype = (MethodType)member.externalType(types);
             int rescode = Code.typecode(mtype.restype);
-            if ((member.owner.flags() & Flags.INTERFACE) != 0) {
+            if ((member.owner.flags() & Flags.INTERFACE) != 0 && !nonvirtual) {
                 code.emitInvokeinterface(pool.put(member), mtype);
             } else if (nonvirtual) {
                 code.emitInvokespecial(pool.put(member), mtype);
@@ -535,10 +571,8 @@ public class Items {
             int idx = pool.put(value);
             if (typecode == LONGcode || typecode == DOUBLEcode) {
                 code.emitop2(ldc2w, idx);
-            } else if (idx <= 255) {
-                code.emitop1(ldc1, idx);
             } else {
-                code.emitop2(ldc2, idx);
+                code.emitLdc(idx);
             }
         }
 
diff --git a/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java b/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
new file mode 100644
index 0000000..be3fe22
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
@@ -0,0 +1,856 @@
+/*
+ * 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
+ * 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.jvm;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+import java.util.StringTokenizer;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.NoType;
+import javax.lang.model.type.PrimitiveType;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeVariable;
+import javax.lang.model.type.TypeVisitor;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.SimpleTypeVisitor8;
+import javax.lang.model.util.Types;
+
+import javax.tools.FileObject;
+import javax.tools.JavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Scope;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+
+import static com.sun.tools.javac.main.Option.*;
+
+/** This class provides operations to write native header files for classes.
+ *
+ *  <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 JNIWriter {
+    protected static final Context.Key<JNIWriter> jniWriterKey =
+        new Context.Key<JNIWriter>();
+
+    /** Access to files. */
+    private final JavaFileManager fileManager;
+
+    JavacElements elements;
+    JavacTypes types;
+
+    /** The log to use for verbose output.
+     */
+    private final Log log;
+
+    /** Switch: verbose output.
+     */
+    private boolean verbose;
+
+    /** Switch: check all nested classes of top level class
+     */
+    private boolean checkAll;
+
+    private Mangle mangler;
+
+    private Context context;
+
+    private Symtab syms;
+
+    private String lineSep;
+
+    private final boolean isWindows =
+        System.getProperty("os.name").startsWith("Windows");
+
+    /** Get the ClassWriter instance for this context. */
+    public static JNIWriter instance(Context context) {
+        JNIWriter instance = context.get(jniWriterKey);
+        if (instance == null)
+            instance = new JNIWriter(context);
+        return instance;
+    }
+
+    /** Construct a class writer, given an options table.
+     */
+    private JNIWriter(Context context) {
+        context.put(jniWriterKey, this);
+        fileManager = context.get(JavaFileManager.class);
+        log = Log.instance(context);
+
+        Options options = Options.instance(context);
+        verbose = options.isSet(VERBOSE);
+        checkAll = options.isSet("javah:full");
+
+        this.context = context; // for lazyInit()
+        syms = Symtab.instance(context);
+
+        lineSep = System.getProperty("line.separator");
+    }
+
+    private void lazyInit() {
+        if (mangler == null) {
+            elements = JavacElements.instance(context);
+            types = JavacTypes.instance(context);
+            mangler = new Mangle(elements, types);
+        }
+    }
+
+    public boolean needsHeader(ClassSymbol c) {
+        if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
+            return false;
+
+        if (checkAll)
+            return needsHeader(c.outermostClass(), true);
+        else
+            return needsHeader(c, false);
+    }
+
+    private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) {
+        if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
+            return false;
+
+        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;
+            for (Attribute.Compound a: i.sym.getDeclarationAttributes()) {
+                if (a.type.tsym == syms.nativeHeaderType.tsym)
+                    return true;
+            }
+        }
+        if (checkNestedClasses) {
+            for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
+                if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true))
+                    return true;
+            }
+        }
+        return false;
+    }
+
+    /** Emit a class file for a given class.
+     *  @param c      The class from which a class file is generated.
+     */
+    public FileObject write(ClassSymbol c)
+        throws IOException
+    {
+        String className = c.flatName().toString();
+        FileObject outFile
+            = fileManager.getFileForOutput(StandardLocation.NATIVE_HEADER_OUTPUT,
+                "", className.replaceAll("[.$]", "_") + ".h", null);
+        Writer out = outFile.openWriter();
+        try {
+            write(out, c);
+            if (verbose)
+                log.printVerbose("wrote.file", outFile);
+            out.close();
+            out = null;
+        } finally {
+            if (out != null) {
+                // if we are propogating an exception, delete the file
+                out.close();
+                outFile.delete();
+                outFile = null;
+            }
+        }
+        return outFile; // may be null if write failed
+    }
+
+    public void write(Writer out, ClassSymbol sym)
+            throws IOException {
+        lazyInit();
+        try {
+            String cname = mangler.mangle(sym.fullname, Mangle.Type.CLASS);
+            println(out, fileTop());
+            println(out, includes());
+            println(out, guardBegin(cname));
+            println(out, cppGuardBegin());
+
+            writeStatics(out, sym);
+            writeMethods(out, sym, cname);
+
+            println(out, cppGuardEnd());
+            println(out, guardEnd(cname));
+        } catch (TypeSignature.SignatureException e) {
+            throw new IOException(e);
+        }
+    }
+
+    protected void writeStatics(Writer out, ClassSymbol sym) throws IOException {
+        List<VariableElement> classfields = getAllFields(sym);
+
+        for (VariableElement v: classfields) {
+            if (!v.getModifiers().contains(Modifier.STATIC))
+                continue;
+            String s = null;
+            s = defineForStatic(sym, v);
+            if (s != null) {
+                println(out, s);
+            }
+        }
+    }
+
+    /**
+     * Including super class fields.
+     */
+    List<VariableElement> getAllFields(TypeElement subclazz) {
+        List<VariableElement> fields = new ArrayList<VariableElement>();
+        TypeElement cd = null;
+        Stack<TypeElement> s = new Stack<TypeElement>();
+
+        cd = subclazz;
+        while (true) {
+            s.push(cd);
+            TypeElement c = (TypeElement) (types.asElement(cd.getSuperclass()));
+            if (c == null)
+                break;
+            cd = c;
+        }
+
+        while (!s.empty()) {
+            cd = s.pop();
+            fields.addAll(ElementFilter.fieldsIn(cd.getEnclosedElements()));
+        }
+
+        return fields;
+    }
+
+    protected String defineForStatic(TypeElement c, VariableElement f) {
+        CharSequence cnamedoc = c.getQualifiedName();
+        CharSequence fnamedoc = f.getSimpleName();
+
+        String cname = mangler.mangle(cnamedoc, Mangle.Type.CLASS);
+        String fname = mangler.mangle(fnamedoc, Mangle.Type.FIELDSTUB);
+
+        Assert.check(f.getModifiers().contains(Modifier.STATIC));
+
+        if (f.getModifiers().contains(Modifier.FINAL)) {
+            Object value = null;
+
+            value = f.getConstantValue();
+
+            if (value != null) { /* so it is a ConstantExpression */
+                String constString = null;
+                if ((value instanceof Integer)
+                    || (value instanceof Byte)
+                    || (value instanceof Short)) {
+                    /* covers byte, short, int */
+                    constString = value.toString() + "L";
+                } else if (value instanceof Boolean) {
+                    constString = ((Boolean) value) ? "1L" : "0L";
+                } else if (value instanceof Character) {
+                    Character ch = (Character) value;
+                    constString = String.valueOf(((int) ch) & 0xffff) + "L";
+                } else if (value instanceof Long) {
+                    // Visual C++ supports the i64 suffix, not LL.
+                    if (isWindows)
+                        constString = value.toString() + "i64";
+                    else
+                        constString = value.toString() + "LL";
+                } else if (value instanceof Float) {
+                    /* bug for bug */
+                    float fv = ((Float)value).floatValue();
+                    if (Float.isInfinite(fv))
+                        constString = ((fv < 0) ? "-" : "") + "Inff";
+                    else
+                        constString = value.toString() + "f";
+                } else if (value instanceof Double) {
+                    /* bug for bug */
+                    double d = ((Double)value).doubleValue();
+                    if (Double.isInfinite(d))
+                        constString = ((d < 0) ? "-" : "") + "InfD";
+                    else
+                        constString = value.toString();
+                }
+
+                if (constString != null) {
+                    StringBuilder s = new StringBuilder("#undef ");
+                    s.append(cname); s.append("_"); s.append(fname); s.append(lineSep);
+                    s.append("#define "); s.append(cname); s.append("_");
+                    s.append(fname); s.append(" "); s.append(constString);
+                    return s.toString();
+                }
+
+            }
+        }
+
+        return null;
+    }
+
+
+    protected void writeMethods(Writer out, ClassSymbol sym, String cname)
+            throws IOException, TypeSignature.SignatureException {
+        List<ExecutableElement> classmethods = ElementFilter.methodsIn(sym.getEnclosedElements());
+        for (ExecutableElement md: classmethods) {
+            if(md.getModifiers().contains(Modifier.NATIVE)){
+                TypeMirror mtr = types.erasure(md.getReturnType());
+                String sig = signature(md);
+                TypeSignature newtypesig = new TypeSignature(elements);
+                CharSequence methodName = md.getSimpleName();
+                boolean longName = false;
+                for (ExecutableElement md2: classmethods) {
+                    if ((md2 != md)
+                        && (methodName.equals(md2.getSimpleName()))
+                        && (md2.getModifiers().contains(Modifier.NATIVE)))
+                        longName = true;
+
+                }
+                println(out, "/*");
+                println(out, " * Class:     " + cname);
+                println(out, " * Method:    " +
+                           mangler.mangle(methodName, Mangle.Type.FIELDSTUB));
+                println(out, " * Signature: " + newtypesig.getTypeSignature(sig, mtr));
+                println(out, " */");
+                println(out, "JNIEXPORT " + jniType(mtr) +
+                           " JNICALL " +
+                           mangler.mangleMethod(md, sym,
+                                               (longName) ?
+                                               Mangle.Type.METHOD_JNI_LONG :
+                                               Mangle.Type.METHOD_JNI_SHORT));
+                print(out, "  (JNIEnv *, ");
+                List<? extends VariableElement> paramargs = md.getParameters();
+                List<TypeMirror> args = new ArrayList<TypeMirror>();
+                for (VariableElement p: paramargs) {
+                    args.add(types.erasure(p.asType()));
+                }
+                if (md.getModifiers().contains(Modifier.STATIC))
+                    print(out, "jclass");
+                else
+                    print(out, "jobject");
+
+                for (TypeMirror arg: args) {
+                    print(out, ", ");
+                    print(out, jniType(arg));
+                }
+                println(out, ");"
+                        + lineSep);
+            }
+        }
+    }
+
+    // c.f. MethodDoc.signature
+    String signature(ExecutableElement e) {
+        StringBuilder sb = new StringBuilder("(");
+        String sep = "";
+        for (VariableElement p: e.getParameters()) {
+            sb.append(sep);
+            sb.append(types.erasure(p.asType()).toString());
+            sep = ",";
+        }
+        sb.append(")");
+        return sb.toString();
+    }
+
+    protected final String jniType(TypeMirror t) {
+        TypeElement throwable = elements.getTypeElement("java.lang.Throwable");
+        TypeElement jClass = elements.getTypeElement("java.lang.Class");
+        TypeElement jString = elements.getTypeElement("java.lang.String");
+        Element tclassDoc = types.asElement(t);
+
+
+        switch (t.getKind()) {
+            case ARRAY: {
+                TypeMirror ct = ((ArrayType) t).getComponentType();
+                switch (ct.getKind()) {
+                    case BOOLEAN:  return "jbooleanArray";
+                    case BYTE:     return "jbyteArray";
+                    case CHAR:     return "jcharArray";
+                    case SHORT:    return "jshortArray";
+                    case INT:      return "jintArray";
+                    case LONG:     return "jlongArray";
+                    case FLOAT:    return "jfloatArray";
+                    case DOUBLE:   return "jdoubleArray";
+                    case ARRAY:
+                    case DECLARED: return "jobjectArray";
+                    default: throw new Error(ct.toString());
+                }
+            }
+
+            case VOID:     return "void";
+            case BOOLEAN:  return "jboolean";
+            case BYTE:     return "jbyte";
+            case CHAR:     return "jchar";
+            case SHORT:    return "jshort";
+            case INT:      return "jint";
+            case LONG:     return "jlong";
+            case FLOAT:    return "jfloat";
+            case DOUBLE:   return "jdouble";
+
+            case DECLARED: {
+                if (tclassDoc.equals(jString))
+                    return "jstring";
+                else if (types.isAssignable(t, throwable.asType()))
+                    return "jthrowable";
+                else if (types.isAssignable(t, jClass.asType()))
+                    return "jclass";
+                else
+                    return "jobject";
+            }
+        }
+
+        Assert.check(false, "jni unknown type");
+        return null; /* dead code. */
+    }
+
+    protected String fileTop() {
+        return "/* DO NOT EDIT THIS FILE - it is machine generated */";
+    }
+
+    protected String includes() {
+        return "#include <jni.h>";
+    }
+
+    /*
+     * Deal with the C pre-processor.
+     */
+    protected String cppGuardBegin() {
+        return "#ifdef __cplusplus" + lineSep
+                + "extern \"C\" {" + lineSep
+                + "#endif";
+    }
+
+    protected String cppGuardEnd() {
+        return "#ifdef __cplusplus" + lineSep
+                + "}" + lineSep
+                + "#endif";
+    }
+
+    protected String guardBegin(String cname) {
+        return "/* Header for class " + cname + " */" + lineSep
+                + lineSep
+                + "#ifndef _Included_" + cname + lineSep
+                + "#define _Included_" + cname;
+    }
+
+    protected String guardEnd(String cname) {
+        return "#endif";
+    }
+
+    protected void print(Writer out, String text) throws IOException {
+        out.write(text);
+    }
+
+    protected void println(Writer out, String text) throws IOException {
+        out.write(text);
+        out.write(lineSep);
+    }
+
+
+    private static class Mangle {
+
+        public static class Type {
+            public static final int CLASS            = 1;
+            public static final int FIELDSTUB        = 2;
+            public static final int FIELD            = 3;
+            public static final int JNI              = 4;
+            public static final int SIGNATURE        = 5;
+            public static final int METHOD_JDK_1     = 6;
+            public static final int METHOD_JNI_SHORT = 7;
+            public static final int METHOD_JNI_LONG  = 8;
+        };
+
+        private Elements elems;
+        private Types types;
+
+        Mangle(Elements elems, Types types) {
+            this.elems = elems;
+            this.types = types;
+        }
+
+        public final String mangle(CharSequence name, int mtype) {
+            StringBuilder result = new StringBuilder(100);
+            int length = name.length();
+
+            for (int i = 0; i < length; i++) {
+                char ch = name.charAt(i);
+                if (isalnum(ch)) {
+                    result.append(ch);
+                } else if ((ch == '.') &&
+                           mtype == Mangle.Type.CLASS) {
+                    result.append('_');
+                } else if (( ch == '$') &&
+                           mtype == Mangle.Type.CLASS) {
+                    result.append('_');
+                    result.append('_');
+                } else if (ch == '_' && mtype == Mangle.Type.FIELDSTUB) {
+                    result.append('_');
+                } else if (ch == '_' && mtype == Mangle.Type.CLASS) {
+                    result.append('_');
+                } else if (mtype == Mangle.Type.JNI) {
+                    String esc = null;
+                    if (ch == '_')
+                        esc = "_1";
+                    else if (ch == '.')
+                        esc = "_";
+                    else if (ch == ';')
+                        esc = "_2";
+                    else if (ch == '[')
+                        esc = "_3";
+                    if (esc != null) {
+                        result.append(esc);
+                    } else {
+                        result.append(mangleChar(ch));
+                    }
+                } else if (mtype == Mangle.Type.SIGNATURE) {
+                    if (isprint(ch)) {
+                        result.append(ch);
+                    } else {
+                        result.append(mangleChar(ch));
+                    }
+                } else {
+                    result.append(mangleChar(ch));
+                }
+            }
+
+            return result.toString();
+        }
+
+        public String mangleMethod(ExecutableElement method, TypeElement clazz,
+                                          int mtype) throws TypeSignature.SignatureException {
+            StringBuilder result = new StringBuilder(100);
+            result.append("Java_");
+
+            if (mtype == Mangle.Type.METHOD_JDK_1) {
+                result.append(mangle(clazz.getQualifiedName(), Mangle.Type.CLASS));
+                result.append('_');
+                result.append(mangle(method.getSimpleName(),
+                                     Mangle.Type.FIELD));
+                result.append("_stub");
+                return result.toString();
+            }
+
+            /* JNI */
+            result.append(mangle(getInnerQualifiedName(clazz), Mangle.Type.JNI));
+            result.append('_');
+            result.append(mangle(method.getSimpleName(),
+                                 Mangle.Type.JNI));
+            if (mtype == Mangle.Type.METHOD_JNI_LONG) {
+                result.append("__");
+                String typesig = signature(method);
+                TypeSignature newTypeSig = new TypeSignature(elems);
+                String sig = newTypeSig.getTypeSignature(typesig,  method.getReturnType());
+                sig = sig.substring(1);
+                sig = sig.substring(0, sig.lastIndexOf(')'));
+                sig = sig.replace('/', '.');
+                result.append(mangle(sig, Mangle.Type.JNI));
+            }
+
+            return result.toString();
+        }
+        //where
+            private String getInnerQualifiedName(TypeElement clazz) {
+                return elems.getBinaryName(clazz).toString();
+            }
+
+        public final String mangleChar(char ch) {
+            String s = Integer.toHexString(ch);
+            int nzeros = 5 - s.length();
+            char[] result = new char[6];
+            result[0] = '_';
+            for (int i = 1; i <= nzeros; i++)
+                result[i] = '0';
+            for (int i = nzeros+1, j = 0; i < 6; i++, j++)
+                result[i] = s.charAt(j);
+            return new String(result);
+        }
+
+        // Warning: duplicated in Gen
+        private String signature(ExecutableElement e) {
+            StringBuilder sb = new StringBuilder();
+            String sep = "(";
+            for (VariableElement p: e.getParameters()) {
+                sb.append(sep);
+                sb.append(types.erasure(p.asType()).toString());
+                sep = ",";
+            }
+            sb.append(")");
+            return sb.toString();
+        }
+
+        /* Warning: Intentional ASCII operation. */
+        private static boolean isalnum(char ch) {
+            return ch <= 0x7f && /* quick test */
+                ((ch >= 'A' && ch <= 'Z') ||
+                 (ch >= 'a' && ch <= 'z') ||
+                 (ch >= '0' && ch <= '9'));
+        }
+
+        /* Warning: Intentional ASCII operation. */
+        private static boolean isprint(char ch) {
+            return ch >= 32 && ch <= 126;
+        }
+    }
+
+    private static class TypeSignature {
+        static class SignatureException extends Exception {
+            private static final long serialVersionUID = 1L;
+            SignatureException(String reason) {
+                super(reason);
+            }
+        }
+
+        Elements elems;
+
+        /* Signature Characters */
+
+        private static final String SIG_VOID                   = "V";
+        private static final String SIG_BOOLEAN                = "Z";
+        private static final String SIG_BYTE                   = "B";
+        private static final String SIG_CHAR                   = "C";
+        private static final String SIG_SHORT                  = "S";
+        private static final String SIG_INT                    = "I";
+        private static final String SIG_LONG                   = "J";
+        private static final String SIG_FLOAT                  = "F";
+        private static final String SIG_DOUBLE                 = "D";
+        private static final String SIG_ARRAY                  = "[";
+        private static final String SIG_CLASS                  = "L";
+
+
+
+        public TypeSignature(Elements elems){
+            this.elems = elems;
+        }
+
+        /*
+         * Returns the type signature of a field according to JVM specs
+         */
+        public String getTypeSignature(String javasignature) throws SignatureException {
+            return getParamJVMSignature(javasignature);
+        }
+
+        /*
+         * Returns the type signature of a method according to JVM specs
+         */
+        public String getTypeSignature(String javasignature, TypeMirror returnType)
+                throws SignatureException {
+            String signature = null; //Java type signature.
+            String typeSignature = null; //Internal type signature.
+            List<String> params = new ArrayList<String>(); //List of parameters.
+            String paramsig = null; //Java parameter signature.
+            String paramJVMSig = null; //Internal parameter signature.
+            String returnSig = null; //Java return type signature.
+            String returnJVMType = null; //Internal return type signature.
+            int dimensions = 0; //Array dimension.
+
+            int startIndex = -1;
+            int endIndex = -1;
+            StringTokenizer st = null;
+            int i = 0;
+
+            // Gets the actual java signature without parentheses.
+            if (javasignature != null) {
+                startIndex = javasignature.indexOf("(");
+                endIndex = javasignature.indexOf(")");
+            }
+
+            if (((startIndex != -1) && (endIndex != -1))
+                &&(startIndex+1 < javasignature.length())
+                &&(endIndex < javasignature.length())) {
+                signature = javasignature.substring(startIndex+1, endIndex);
+            }
+
+            // Separates parameters.
+            if (signature != null) {
+                if (signature.indexOf(",") != -1) {
+                    st = new StringTokenizer(signature, ",");
+                    if (st != null) {
+                        while (st.hasMoreTokens()) {
+                            params.add(st.nextToken());
+                        }
+                    }
+                } else {
+                    params.add(signature);
+                }
+            }
+
+            /* JVM type signature. */
+            typeSignature = "(";
+
+            // Gets indivisual internal parameter signature.
+            while (params.isEmpty() != true) {
+                paramsig = params.remove(i).trim();
+                paramJVMSig  = getParamJVMSignature(paramsig);
+                if (paramJVMSig != null) {
+                    typeSignature += paramJVMSig;
+                }
+            }
+
+            typeSignature += ")";
+
+            // Get internal return type signature.
+
+            returnJVMType = "";
+            if (returnType != null) {
+                dimensions = dimensions(returnType);
+            }
+
+            //Gets array dimension of return type.
+            while (dimensions-- > 0) {
+                returnJVMType += "[";
+            }
+            if (returnType != null) {
+                returnSig = qualifiedTypeName(returnType);
+                returnJVMType += getComponentType(returnSig);
+            } else {
+                System.out.println("Invalid return type.");
+            }
+
+            typeSignature += returnJVMType;
+
+            return typeSignature;
+        }
+
+        /*
+         * Returns internal signature of a parameter.
+         */
+        private String getParamJVMSignature(String paramsig) throws SignatureException {
+            String paramJVMSig = "";
+            String componentType ="";
+
+            if(paramsig != null){
+
+                if(paramsig.indexOf("[]") != -1) {
+                    // Gets array dimension.
+                    int endindex = paramsig.indexOf("[]");
+                    componentType = paramsig.substring(0, endindex);
+                    String dimensionString =  paramsig.substring(endindex);
+                    if(dimensionString != null){
+                        while(dimensionString.indexOf("[]") != -1){
+                            paramJVMSig += "[";
+                            int beginindex = dimensionString.indexOf("]") + 1;
+                            if(beginindex < dimensionString.length()){
+                                dimensionString = dimensionString.substring(beginindex);
+                            }else
+                                dimensionString = "";
+                        }
+                    }
+                } else componentType = paramsig;
+
+                paramJVMSig += getComponentType(componentType);
+            }
+            return paramJVMSig;
+        }
+
+        /*
+         * Returns internal signature of a component.
+         */
+        private String getComponentType(String componentType) throws SignatureException {
+
+            String JVMSig = "";
+
+            if(componentType != null){
+                if(componentType.equals("void")) JVMSig += SIG_VOID ;
+                else if(componentType.equals("boolean"))  JVMSig += SIG_BOOLEAN ;
+                else if(componentType.equals("byte")) JVMSig += SIG_BYTE ;
+                else if(componentType.equals("char"))  JVMSig += SIG_CHAR ;
+                else if(componentType.equals("short"))  JVMSig += SIG_SHORT ;
+                else if(componentType.equals("int"))  JVMSig += SIG_INT ;
+                else if(componentType.equals("long"))  JVMSig += SIG_LONG ;
+                else if(componentType.equals("float")) JVMSig += SIG_FLOAT ;
+                else if(componentType.equals("double"))  JVMSig += SIG_DOUBLE ;
+                else {
+                    if(!componentType.equals("")){
+                        TypeElement classNameDoc = elems.getTypeElement(componentType);
+
+                        if(classNameDoc == null){
+                            throw new SignatureException(componentType);
+                        }else {
+                            String classname = classNameDoc.getQualifiedName().toString();
+                            String newclassname = classname.replace('.', '/');
+                            JVMSig += "L";
+                            JVMSig += newclassname;
+                            JVMSig += ";";
+                        }
+                    }
+                }
+            }
+            return JVMSig;
+        }
+
+        int dimensions(TypeMirror t) {
+            if (t.getKind() != TypeKind.ARRAY)
+                return 0;
+            return 1 + dimensions(((ArrayType) t).getComponentType());
+        }
+
+
+        String qualifiedTypeName(TypeMirror type) {
+            TypeVisitor<Name, Void> v = new SimpleTypeVisitor8<Name, Void>() {
+                @Override
+                public Name visitArray(ArrayType t, Void p) {
+                    return t.getComponentType().accept(this, p);
+                }
+
+                @Override
+                public Name visitDeclared(DeclaredType t, Void p) {
+                    return ((TypeElement) t.asElement()).getQualifiedName();
+                }
+
+                @Override
+                public Name visitPrimitive(PrimitiveType t, Void p) {
+                    return elems.getName(t.toString());
+                }
+
+                @Override
+                public Name visitNoType(NoType t, Void p) {
+                    if (t.getKind() == TypeKind.VOID)
+                        return elems.getName("void");
+                    return defaultAction(t, p);
+                }
+
+                @Override
+                public Name visitTypeVariable(TypeVariable t, Void p) {
+                    return t.getUpperBound().accept(this, p);
+                }
+            };
+            return v.visit(type).toString();
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Pool.java b/src/share/classes/com/sun/tools/javac/jvm/Pool.java
index a22c3a7..1437135 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Pool.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Pool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, 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
@@ -25,9 +25,19 @@
 
 package com.sun.tools.javac.jvm;
 
-import java.util.*;
-
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.code.Types.UniqueType;
+
+import com.sun.tools.javac.util.ArrayUtils;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Filter;
+import com.sun.tools.javac.util.Name;
+
+import java.util.*;
 
 /** An internal structure that corresponds to the constant pool of a classfile.
  *
@@ -53,11 +63,14 @@ public class Pool {
      */
     Map<Object,Integer> indices;
 
+    Types types;
+
     /** Construct a pool with given number of elements and element array.
      */
-    public Pool(int pp, Object[] pool) {
+    public Pool(int pp, Object[] pool, Types types) {
         this.pp = pp;
         this.pool = pool;
+        this.types = types;
         this.indices = new HashMap<Object,Integer>(pool.length);
         for (int i = 1; i < pp; i++) {
             if (pool[i] != null) indices.put(pool[i], i);
@@ -66,8 +79,8 @@ public class Pool {
 
     /** Construct an empty pool.
      */
-    public Pool() {
-        this(1, new Object[64]);
+    public Pool(Types types) {
+        this(1, new Object[64], types);
     }
 
     /** Return the number of entries in the constant pool.
@@ -83,39 +96,42 @@ public class Pool {
         indices.clear();
     }
 
-    /** Double pool buffer in size.
-     */
-    private void doublePool() {
-        Object[] newpool = new Object[pool.length * 2];
-        System.arraycopy(pool, 0, newpool, 0, pool.length);
-        pool = newpool;
-    }
-
     /** Place an object in the pool, unless it is already there.
      *  If object is a symbol also enter its owner unless the owner is a
      *  package.  Return the object's index in the pool.
      */
     public int put(Object value) {
-        if (value instanceof MethodSymbol)
-            value = new Method((MethodSymbol)value);
-        else if (value instanceof VarSymbol)
-            value = new Variable((VarSymbol)value);
+        value = makePoolValue(value);
 //      assert !(value instanceof Type.TypeVar);
         Integer index = indices.get(value);
         if (index == null) {
 //          System.err.println("put " + value + " " + value.getClass());//DEBUG
             index = pp;
             indices.put(value, index);
-            if (pp == pool.length) doublePool();
+            pool = ArrayUtils.ensureCapacity(pool, pp);
             pool[pp++] = value;
             if (value instanceof Long || value instanceof Double) {
-                if (pp == pool.length) doublePool();
+                pool = ArrayUtils.ensureCapacity(pool, pp);
                 pool[pp++] = null;
             }
         }
         return index.intValue();
     }
 
+    Object makePoolValue(Object o) {
+        if (o instanceof DynamicMethodSymbol) {
+            return new DynamicMethod((DynamicMethodSymbol)o, types);
+        } else if (o instanceof MethodSymbol) {
+            return new Method((MethodSymbol)o, types);
+        } else if (o instanceof VarSymbol) {
+            return new Variable((VarSymbol)o, types);
+        } else if (o instanceof Type) {
+            return new UniqueType((Type)o, types);
+        } else {
+            return o;
+        }
+    }
+
     /** Return the given object's index in the pool,
      *  or -1 if object is not in there.
      */
@@ -124,47 +140,182 @@ public class Pool {
         return n == null ? -1 : n.intValue();
     }
 
-    static class Method extends DelegatedSymbol {
-        MethodSymbol m;
-        Method(MethodSymbol m) {
+    static class Method extends DelegatedSymbol<MethodSymbol> {
+        UniqueType uniqueType;
+        Method(MethodSymbol m, Types types) {
             super(m);
-            this.m = m;
+            this.uniqueType = new UniqueType(m.type, types);
         }
-        public boolean equals(Object other) {
-            if (!(other instanceof Method)) return false;
-            MethodSymbol o = ((Method)other).m;
+        public boolean equals(Object any) {
+            if (!(any instanceof Method)) return false;
+            MethodSymbol o = ((Method)any).other;
+            MethodSymbol m = this.other;
             return
                 o.name == m.name &&
                 o.owner == m.owner &&
-                o.type.equals(m.type);
+                ((Method)any).uniqueType.equals(uniqueType);
         }
         public int hashCode() {
+            MethodSymbol m = this.other;
             return
                 m.name.hashCode() * 33 +
                 m.owner.hashCode() * 9 +
-                m.type.hashCode();
+                uniqueType.hashCode();
+        }
+    }
+
+    static class DynamicMethod extends Method {
+        public Object[] uniqueStaticArgs;
+
+        DynamicMethod(DynamicMethodSymbol m, Types types) {
+            super(m, types);
+            uniqueStaticArgs = getUniqueTypeArray(m.staticArgs, types);
+        }
+
+        @Override
+        public boolean equals(Object any) {
+            if (!super.equals(any)) return false;
+            if (!(any instanceof DynamicMethod)) return false;
+            DynamicMethodSymbol dm1 = (DynamicMethodSymbol)other;
+            DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)any).other;
+            return dm1.bsm == dm2.bsm &&
+                        dm1.bsmKind == dm2.bsmKind &&
+                        Arrays.equals(uniqueStaticArgs,
+                            ((DynamicMethod)any).uniqueStaticArgs);
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = super.hashCode();
+            DynamicMethodSymbol dm = (DynamicMethodSymbol)other;
+            hash += dm.bsmKind * 7 +
+                    dm.bsm.hashCode() * 11;
+            for (int i = 0; i < dm.staticArgs.length; i++) {
+                hash += (uniqueStaticArgs[i].hashCode() * 23);
+            }
+            return hash;
+        }
+
+        private Object[] getUniqueTypeArray(Object[] objects, Types types) {
+            Object[] result = new Object[objects.length];
+            for (int i = 0; i < objects.length; i++) {
+                if (objects[i] instanceof Type) {
+                    result[i] = new UniqueType((Type)objects[i], types);
+                } else {
+                    result[i] = objects[i];
+                }
+            }
+            return result;
         }
     }
 
-    static class Variable extends DelegatedSymbol {
-        VarSymbol v;
-        Variable(VarSymbol v) {
+    static class Variable extends DelegatedSymbol<VarSymbol> {
+        UniqueType uniqueType;
+        Variable(VarSymbol v, Types types) {
             super(v);
-            this.v = v;
+            this.uniqueType = new UniqueType(v.type, types);
         }
-        public boolean equals(Object other) {
-            if (!(other instanceof Variable)) return false;
-            VarSymbol o = ((Variable)other).v;
+        public boolean equals(Object any) {
+            if (!(any instanceof Variable)) return false;
+            VarSymbol o = ((Variable)any).other;
+            VarSymbol v = other;
             return
                 o.name == v.name &&
                 o.owner == v.owner &&
-                o.type.equals(v.type);
+                ((Variable)any).uniqueType.equals(uniqueType);
         }
         public int hashCode() {
+            VarSymbol v = other;
             return
                 v.name.hashCode() * 33 +
                 v.owner.hashCode() * 9 +
-                v.type.hashCode();
+                uniqueType.hashCode();
+        }
+    }
+
+    public static class MethodHandle {
+
+        /** Reference kind - see ClassFile */
+        int refKind;
+
+        /** Reference symbol */
+        Symbol refSym;
+
+        UniqueType uniqueType;
+
+        public MethodHandle(int refKind, Symbol refSym, Types types) {
+            this.refKind = refKind;
+            this.refSym = refSym;
+            this.uniqueType = new UniqueType(this.refSym.type, types);
+            checkConsistent();
+        }
+        public boolean equals(Object other) {
+            if (!(other instanceof MethodHandle)) return false;
+            MethodHandle mr = (MethodHandle) other;
+            if (mr.refKind != refKind)  return false;
+            Symbol o = mr.refSym;
+            return
+                o.name == refSym.name &&
+                o.owner == refSym.owner &&
+                ((MethodHandle)other).uniqueType.equals(uniqueType);
         }
+        public int hashCode() {
+            return
+                refKind * 65 +
+                refSym.name.hashCode() * 33 +
+                refSym.owner.hashCode() * 9 +
+                uniqueType.hashCode();
+        }
+
+        /**
+         * Check consistency of reference kind and symbol (see JVMS 4.4.8)
+         */
+        @SuppressWarnings("fallthrough")
+        private void checkConsistent() {
+            boolean staticOk = false;
+            int expectedKind = -1;
+            Filter<Name> nameFilter = nonInitFilter;
+            boolean interfaceOwner = false;
+            switch (refKind) {
+                case ClassFile.REF_getStatic:
+                case ClassFile.REF_putStatic:
+                    staticOk = true;
+                case ClassFile.REF_getField:
+                case ClassFile.REF_putField:
+                    expectedKind = Kinds.VAR;
+                    break;
+                case ClassFile.REF_newInvokeSpecial:
+                    nameFilter = initFilter;
+                    expectedKind = Kinds.MTH;
+                    break;
+                case ClassFile.REF_invokeInterface:
+                    interfaceOwner = true;
+                    expectedKind = Kinds.MTH;
+                    break;
+                case ClassFile.REF_invokeStatic:
+                    interfaceOwner = true;
+                    staticOk = true;
+                case ClassFile.REF_invokeVirtual:
+                case ClassFile.REF_invokeSpecial:
+                    expectedKind = Kinds.MTH;
+                    break;
+            }
+            Assert.check(!refSym.isStatic() || staticOk);
+            Assert.check(refSym.kind == expectedKind);
+            Assert.check(nameFilter.accepts(refSym.name));
+            Assert.check(!refSym.owner.isInterface() || interfaceOwner);
+        }
+        //where
+                Filter<Name> nonInitFilter = new Filter<Name>() {
+                    public boolean accepts(Name n) {
+                        return n != n.table.names.init && n != n.table.names.clinit;
+                    }
+                };
+
+                Filter<Name> initFilter = new Filter<Name>() {
+                    public boolean accepts(Name n) {
+                        return n == n.table.names.init;
+                    }
+                };
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Profile.java b/src/share/classes/com/sun/tools/javac/jvm/Profile.java
new file mode 100644
index 0000000..59ba84e
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/jvm/Profile.java
@@ -0,0 +1,105 @@
+/*
+ * 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.  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.jvm;
+
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Options;
+import java.util.EnumSet;
+import java.util.Set;
+
+import static com.sun.tools.javac.main.Option.PROFILE;
+
+/** The target profile.
+ *
+ *  <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 enum Profile {
+    COMPACT1("compact1", 1, Target.JDK1_8),
+    COMPACT2("compact2", 2, Target.JDK1_8),
+    COMPACT3("compact3", 3, Target.JDK1_8),
+
+    DEFAULT {
+        @Override
+        public boolean isValid(Target t) {
+            return true;
+        }
+    };
+
+    private static final Context.Key<Profile> profileKey =
+        new Context.Key<Profile>();
+
+    public static Profile instance(Context context) {
+        Profile instance = context.get(profileKey);
+        if (instance == null) {
+            Options options = Options.instance(context);
+            String profileString = options.get(PROFILE);
+            if (profileString != null) instance = lookup(profileString);
+            if (instance == null) instance = DEFAULT;
+            context.put(profileKey, instance);
+        }
+        return instance;
+    }
+
+    public final String name;
+    public final int value;
+    final Set<Target> targets;
+
+    Profile() {
+        name = null;
+        value = Integer.MAX_VALUE;
+        targets = null;
+    }
+
+    Profile(String name, int value, Target t, Target... targets) {
+        this.name = name;
+        this.value = value;
+        this.targets = EnumSet.of(t, targets);
+    }
+
+    public static Profile lookup(String name) {
+        // the set of values is small enough to do linear search
+        for (Profile p: values()) {
+            if (name.equals(p.name))
+                return p;
+        }
+        return null;
+    }
+
+    public static Profile lookup(int value) {
+        // the set of values is small enough to do linear search
+        for (Profile p: values()) {
+            if (value == p.value)
+                return p;
+        }
+        return null;
+    }
+
+    public boolean isValid(Target t) {
+        return targets.contains(t);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Target.java b/src/share/classes/com/sun/tools/javac/jvm/Target.java
index 3c81daa..54eee74 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Target.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java
@@ -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
@@ -31,7 +31,7 @@ import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.util.*;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.TARGET;
 
 /** The classfile version target.
  *
@@ -48,17 +48,6 @@ public enum Target {
     /** J2SE1.4 = Merlin. */
     JDK1_4("1.4", 48, 0),
 
-    /** Support for the JSR14 prototype compiler (targeting 1.4 VMs
-     *  augmented with a few support classes).  This is a transitional
-     *  option that will not be supported in the product.  */
-    JSR14("jsr14", 48, 0),
-
-    /** The following are undocumented transitional targets that we
-     *  had used to test VM fixes in update releases.  We do not
-     *  promise to retain support for them.  */
-    JDK1_4_1("1.4.1", 48, 0),
-    JDK1_4_2("1.4.2", 48, 0),
-
     /** Tiger. */
     JDK1_5("1.5", 49, 0),
 
@@ -66,7 +55,10 @@ public enum Target {
     JDK1_6("1.6", 50, 0),
 
     /** JDK 7. */
-    JDK1_7("1.7", 51, 0);
+    JDK1_7("1.7", 51, 0),
+
+    /** JDK 8. */
+    JDK1_8("1.8", 52, 0);
 
     private static final Context.Key<Target> targetKey =
         new Context.Key<Target>();
@@ -83,22 +75,21 @@ public enum Target {
         return instance;
     }
 
-    private static Target MIN;
+    private static final Target MIN = values()[0];
     public static Target MIN() { return MIN; }
 
-    private static Target MAX;
+    private static final Target MAX = values()[values().length - 1];
     public static Target MAX() { return MAX; }
 
-    private static Map<String,Target> tab = new HashMap<String,Target>();
+    private static final Map<String,Target> tab = new HashMap<String,Target>();
     static {
         for (Target t : values()) {
-            if (MIN == null) MIN = t;
-            MAX = t;
             tab.put(t.name, t);
         }
         tab.put("5", JDK1_5);
         tab.put("6", JDK1_6);
         tab.put("7", JDK1_7);
+        tab.put("8", JDK1_8);
     }
 
     public final String name;
@@ -110,7 +101,7 @@ public enum Target {
         this.minorVersion = minorVersion;
     }
 
-    public static final Target DEFAULT = JDK1_7;
+    public static final Target DEFAULT = JDK1_8;
 
     public static Target lookup(String name) {
         return tab.get(name);
@@ -173,23 +164,23 @@ public enum Target {
         return compareTo(JDK1_5) >= 0;
     }
 
-    /** Beginning in -target 1.4.2, we make synthetic variables
+    /** Beginning in -target 1.5, we make synthetic variables
      *  package-private instead of private.  This is to prevent the
      *  necessity of access methods, which effectively relax the
      *  protection of the field but bloat the class files and affect
      *  execution.
      */
     public boolean usePrivateSyntheticFields() {
-        return compareTo(JDK1_4_2) < 0;
+        return compareTo(JDK1_5) < 0;
     }
 
     /** Sometimes we need to create a field to cache a value like a
-     *  class literal of the assertions flag.  In -target 1.4.2 and
+     *  class literal of the assertions flag.  In -target 1.5 and
      *  later we create a new synthetic class for this instead of
      *  using the outermost class.  See 4401576.
      */
     public boolean useInnerCacheClass() {
-        return compareTo(JDK1_4_2) >= 0;
+        return compareTo(JDK1_5) >= 0;
     }
 
     /** Return true if cldc-style stack maps need to be generated. */
@@ -274,7 +265,7 @@ public enum Target {
      *  See 4468823
      */
     public boolean classLiteralsNoInit() {
-        return compareTo(JDK1_4_2) >= 0;
+        return compareTo(JDK1_5) >= 0;
     }
 
     /** Although we may not have support for class literals, when we
@@ -298,22 +289,10 @@ public enum Target {
         return compareTo(JDK1_5) >= 0;
     }
 
-    /** For bootstrapping javac only, we do without java.lang.Enum if
-     *  necessary.
-     */
-    public boolean compilerBootstrap(Symbol c) {
-        return
-            this == JSR14 &&
-            (c.flags() & Flags.ENUM) != 0 &&
-            c.flatName().toString().startsWith("com.sun.tools.")
-            // && !Target.class.getSuperclass().getName().equals("java.lang.Enum")
-            ;
-    }
-
     /** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute
      *  for improved reflection support.
      */
     public boolean hasEnclosingMethodAttribute() {
-        return compareTo(JDK1_5) >= 0 || this == JSR14;
+        return compareTo(JDK1_5) >= 0;
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java b/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java
index 82ba522..73614a0 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/UninitializedType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -27,6 +27,8 @@ package com.sun.tools.javac.jvm;
 
 import com.sun.tools.javac.code.*;
 
+import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_OBJECT;
+import static com.sun.tools.javac.code.TypeTag.UNINITIALIZED_THIS;
 
 /** These pseudo-types appear in the generated verifier tables to
  *  indicate objects that have been allocated but not yet constructed.
@@ -37,8 +39,6 @@ import com.sun.tools.javac.code.*;
  *  deletion without notice.</b>
  */
 class UninitializedType extends Type.DelegatedType {
-    public static final int UNINITIALIZED_THIS = TypeTags.TypeTagCount;
-    public static final int UNINITIALIZED_OBJECT = UNINITIALIZED_THIS + 1;
 
     public static UninitializedType uninitializedThis(Type qtype) {
         return new UninitializedType(UNINITIALIZED_THIS, qtype, -1);
@@ -49,7 +49,7 @@ class UninitializedType extends Type.DelegatedType {
     }
 
     public final int offset; // PC where allocation took place
-    private UninitializedType(int tag, Type qtype, int offset) {
+    private UninitializedType(TypeTag tag, Type qtype, int offset) {
         super(tag, qtype);
         this.offset = offset;
     }
diff --git a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
index b1a44be..c93d5a1 100644
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -29,8 +29,8 @@ import java.io.*;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.Queue;
@@ -42,27 +42,32 @@ import java.util.logging.Logger;
 
 import javax.annotation.processing.Processor;
 import javax.lang.model.SourceVersion;
+import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
-import javax.tools.DiagnosticListener;
+import javax.tools.StandardLocation;
 
-import com.sun.source.util.TaskEvent;
-import com.sun.source.util.TaskListener;
+import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.*;
+import com.sun.source.util.TaskEvent;
+import com.sun.tools.javac.api.DuplicateClassChecker;
+import com.sun.tools.javac.api.MultiTaskListener;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.parser.*;
 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.*;
 import com.sun.tools.javac.processing.*;
+import com.sun.tools.javac.tree.*;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Log.WriterKind;
 
-import static javax.tools.StandardLocation.CLASS_OUTPUT;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 import static com.sun.tools.javac.util.ListBuffer.lb;
 
@@ -187,7 +192,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         }
     }
 
-    private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
+    private static final CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
 
     protected static enum ImplicitSourcePolicy {
         /** Don't generate or process implicitly read source files. */
@@ -229,6 +234,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      */
     protected ClassWriter writer;
 
+    /** The native header writer.
+     */
+    protected JNIWriter jniWriter;
+
     /** The module for the symbol table entry phases.
      */
     protected Enter enter;
@@ -269,6 +278,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      */
     protected TransTypes transTypes;
 
+    /** The lambda translator.
+     */
+    protected LambdaToMethod lambdaToMethod;
+
     /** The syntactic sugar desweetener.
      */
     protected Lower lower;
@@ -293,6 +306,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      */
     protected ParserFactory parserFactory;
 
+    /** Broadcasting listener for progress events
+     */
+    protected MultiTaskListener taskListener;
 
     /**
      * Annotation processing may require and provide a new instance
@@ -317,11 +333,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      **/
     protected boolean implicitSourceFilesRead;
 
+    protected CompileStates compileStates;
+
     protected Map<JavaFileObject, JCCompilationUnit> notYetEntered;
 
     public boolean skipAnnotationProcessing = false;
 
     private MemberEnter memberEnter;
+    private final DuplicateClassChecker duplicateClassChecker;
     public List<JCCompilationUnit> toProcessAnnotations = List.nil();
 
     /** Construct a new compiler using a shared context.
@@ -340,12 +359,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         reader = ClassReader.instance(context);
         make = TreeMaker.instance(context);
         writer = ClassWriter.instance(context);
+        jniWriter = JNIWriter.instance(context);
         enter = Enter.instance(context);
         memberEnter = MemberEnter.instance(context);
         todo = Todo.instance(context);
 
         fileManager = context.get(JavaFileManager.class);
         parserFactory = ParserFactory.instance(context);
+        compileStates = CompileStates.instance(context);
 
         try {
             // catch completion problems with predefineds
@@ -366,11 +387,15 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         lower = Lower.instance(context);
         annotate = Annotate.instance(context);
         types = Types.instance(context);
+        taskListener = MultiTaskListener.instance(context);
+        duplicateClassChecker = context.get(DuplicateClassChecker.class);
 
         reader.sourceCompleter = this;
 
         options = Options.instance(context);
 
+        lambdaToMethod = LambdaToMethod.instance(context);
+
         verbose       = options.isSet(VERBOSE);
         sourceOutput  = options.isSet(PRINTSOURCE); // used to be -s
         stubOutput    = options.isSet("-stubs");
@@ -385,6 +410,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         devVerbose    = options.isSet("dev");
         processPcks   = options.isSet("process.packages");
         werror        = options.isSet(WERROR);
+        keepComments  = options.getBoolean("keepComments");
 
         if (source.compareTo(Source.DEFAULT) < 0) {
             if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) {
@@ -409,10 +435,17 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             ? names.fromString(options.get("failcomplete"))
             : null;
 
-        shouldStopPolicy =
-            options.isSet("shouldStopPolicy")
+        shouldStopPolicyIfError =
+            options.isSet("shouldStopPolicy") // backwards compatible
             ? CompileState.valueOf(options.get("shouldStopPolicy"))
-            : null;
+            : options.isSet("shouldStopPolicyIfError")
+            ? CompileState.valueOf(options.get("shouldStopPolicyIfError"))
+            : CompileState.INIT;
+        shouldStopPolicyIfNoError =
+            options.isSet("shouldStopPolicyIfNoError")
+            ? CompileState.valueOf(options.get("shouldStopPolicyIfNoError"))
+            : CompileState.GENERATE;
+
         if (options.isUnset("oldDiags"))
             log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context));
     }
@@ -468,7 +501,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      */
     protected boolean werror;
 
-    /** Switch: is annotation processing requested explitly via
+    /** Switch: is annotation processing requested explicitly via
      * CompilationTask.setProcessors?
      */
     protected boolean explicitAnnotationProcessingRequested = false;
@@ -489,44 +522,26 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
     public boolean verboseCompilePolicy;
 
     /**
-     * Policy of how far to continue processing. null means until first
-     * error.
+     * Policy of how far to continue compilation after errors have occurred.
+     * Set this to minimum CompileState (INIT) to stop as soon as possible
+     * after errors.
+     */
+    public CompileState shouldStopPolicyIfError;
+
+    /**
+     * Policy of how far to continue compilation when no errors have occurred.
+     * Set this to maximum CompileState (GENERATE) to perform full compilation.
+     * Set this lower to perform partial compilation, such as -proc:only.
      */
-    public CompileState shouldStopPolicy;
+    public CompileState shouldStopPolicyIfNoError;
 
     /** A queue of all as yet unattributed classes.
      */
     public Todo todo;
 
-    /** Ordered list of compiler phases for each compilation unit. */
-    public enum CompileState {
-        PARSE(1),
-        ENTER(2),
-        PROCESS(3),
-        ATTR(4),
-        FLOW(5),
-        TRANSTYPES(6),
-        LOWER(7),
-        GENERATE(8);
-        CompileState(int value) {
-            this.value = value;
-        }
-        boolean isDone(CompileState other) {
-            return value >= other.value;
-        }
-        private int value;
-    };
-    /** Partial map to record which compiler phases have been executed
-     * for each compilation unit. Used for ATTR and FLOW phases.
-     */
-    protected class CompileStates extends HashMap<Env<AttrContext>,CompileState> {
-        private static final long serialVersionUID = 1812267524140424433L;
-        boolean isDone(Env<AttrContext> env, CompileState cs) {
-            CompileState ecs = get(env);
-            return ecs != null && ecs.isDone(cs);
-        }
-    }
-    private CompileStates compileStates = new CompileStates();
+    /** A list of items to be closed when the compilation is complete.
+     */
+    public List<Closeable> closeables = List.nil();
 
     /** The set of currently compiled inputfiles, needed to ensure
      *  we don't accidentally overwrite an input file when -s is set.
@@ -535,10 +550,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
     protected Set<JavaFileObject> inputFiles = new HashSet<JavaFileObject>();
 
     protected boolean shouldStop(CompileState cs) {
-        if (shouldStopPolicy == null)
-            return (errorCount() > 0 || unrecoverableError());
-        else
-            return cs.ordinal() > shouldStopPolicy.ordinal();
+        CompileState shouldStopPolicy = (errorCount() > 0 || unrecoverableError())
+            ? shouldStopPolicyIfError
+            : shouldStopPolicyIfNoError;
+        return cs.isAfter(shouldStopPolicy);
     }
 
     /** The number of errors reported so far.
@@ -587,7 +602,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
 
     /** Parse contents of input stream.
      *  @param filename     The name of the file from which input stream comes.
-     *  @param input        The input stream to be parsed.
+     *  @param content      The characters to be parsed.
      */
     protected JCCompilationUnit parse(JavaFileObject filename, CharSequence content) {
         long msec = now();
@@ -597,7 +612,12 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             if (verbose) {
                 log.printVerbose("parsing.started", filename);
             }
-            taskStarted(new TaskEvent(TaskEvent.Kind.PARSE, filename));
+            if (!taskListener.isEmpty()) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
+                taskListener.started(e);
+                keepComments = true;
+                genEndPos = true;
+            }
             Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
             tree = parser.parseCompilationUnit();
             if (verbose) {
@@ -607,8 +627,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
 
         tree.sourcefile = filename;
 
-        if (content != null) {
-            taskFinished(new TaskEvent(TaskEvent.Kind.PARSE, tree));
+        if (content != null && !taskListener.isEmpty()) {
+            TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, tree);
+            taskListener.finished(e);
         }
 
         return tree;
@@ -619,6 +640,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             return keepComments || sourceOutput || stubOutput;
         }
 
+
     /** Parse contents of file.
      *  @param filename     The name of the file to be parsed.
      */
@@ -663,8 +685,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         if (name.equals(""))
             return syms.errSymbol;
         JavaFileObject prev = log.useSource(null);
-        boolean old = log.suppressErrorsAndWarnings;
-        log.suppressErrorsAndWarnings = true;
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log);
         try {
             JCExpression tree = null;
             for (String s : name.split("\\.", -1)) {
@@ -678,7 +699,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             toplevel.packge = syms.unnamedPackage;
             return attr.attribIdent(tree, toplevel);
         } finally {
-            log.suppressErrorsAndWarnings = old;
+            log.popDiagnosticHandler(discardHandler);
             log.useSource(prev);
         }
     }
@@ -733,8 +754,6 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
     /** Complete compiling a source file that has been accessed
      *  by the class file reader.
      *  @param c          The class the source file of which needs to be compiled.
-     *  @param filename   The name of the source file.
-     *  @param f          An input stream that reads the source file.
      */
     public void complete(ClassSymbol c) throws CompletionFailure {
 //      System.err.println("completing " + c);//DEBUG
@@ -758,11 +777,20 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             log.useSource(prev);
         }
 
-        taskStarted(new TaskEvent(TaskEvent.Kind.ENTER, tree));
+        if (!taskListener.isEmpty()) {
+            TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
+            taskListener.started(e);
+        }
+
+        if (!skipAnnotationProcessing && processAnnotations && deferredDiagnosticHandler == null)
+            deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
 
         complete(List.of(tree), c);
 
-        taskFinished(new TaskEvent(TaskEvent.Kind.ENTER, tree));
+        if (!taskListener.isEmpty()) {
+            TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
+            taskListener.finished(e);
+        }
 
         if (!skipAnnotationProcessing) {
             if (memberEnter.halfcompleted.nonEmpty() || annotate.enterCount > 0) {
@@ -831,8 +859,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
 
         // forcibly set the equivalent of -Xlint:-options, so that no further
         // warnings about command line options are generated from this point on
-        options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
-        options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);
+        options.put(XLINT_CUSTOM.text + "-" + LintCategory.OPTIONS.option, "true");
+        options.remove(XLINT_CUSTOM.text + LintCategory.OPTIONS.option);
 
         start_msec = now();
 
@@ -910,6 +938,16 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         }
     }
 
+    /**
+     * Set needRootClasses to true, in JavaCompiler subclass constructor
+     * that want to collect public apis of classes supplied on the command line.
+     */
+    protected boolean needRootClasses = false;
+
+    /**
+     * The list of classes explicitly supplied on the command line for compilation.
+     * Not always populated.
+     */
     private List<JCClassDecl> rootClasses;
 
     /**
@@ -932,25 +970,44 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
     }
 
     /**
+     * Enter the symbols found in a list of parse trees if the compilation
+     * is expected to proceed beyond anno processing into attr.
+     * As a side-effect, this puts elements on the "todo" list.
+     * Also stores a list of all top level classes in rootClasses.
+     */
+    public List<JCCompilationUnit> enterTreesIfNeeded(List<JCCompilationUnit> roots) {
+       if (shouldStop(CompileState.ATTR))
+           return List.nil();
+        return enterTrees(roots);
+    }
+
+    /**
      * Enter the symbols found in a list of parse trees.
      * As a side-effect, this puts elements on the "todo" list.
      * Also stores a list of all top level classes in rootClasses.
      */
     public List<JCCompilationUnit> enterTrees(List<JCCompilationUnit> roots) {
         //enter symbols for all files
-        for (JCCompilationUnit unit : roots) {
-            taskStarted(new TaskEvent(TaskEvent.Kind.ENTER, unit));
+        if (!taskListener.isEmpty()) {
+            for (JCCompilationUnit unit: roots) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
+                taskListener.started(e);
+            }
         }
 
         complete(roots, null);
 
-        for (JCCompilationUnit unit : roots) {
-            taskFinished(new TaskEvent(TaskEvent.Kind.ENTER, unit));
+        if (!taskListener.isEmpty()) {
+            for (JCCompilationUnit unit: roots) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, unit);
+                taskListener.finished(e);
+            }
         }
 
-        //If generating source, remember the classes declared in
-        //the original compilation units listed on the command line.
-        if (sourceOutput || stubOutput) {
+        // If generating source, or if tracking public apis,
+        // then remember the classes declared in
+        // the original compilation units listed on the command line.
+        if (needRootClasses || sourceOutput || stubOutput) {
             ListBuffer<JCClassDecl> cdefs = lb();
             for (JCCompilationUnit unit : roots) {
                 for (List<JCTree> defs = unit.defs;
@@ -989,7 +1046,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
      * advanced logic to figure out if annotation processing is
      * needed.
      */
-    boolean processAnnotations = false;
+    public boolean processAnnotations = false;
+
+    public Log.DeferredDiagnosticHandler deferredDiagnosticHandler;
 
     /**
      * Object to handle annotation processing.
@@ -1011,7 +1070,8 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         if (options.isSet(PROC, "none")) {
             processAnnotations = false;
         } else if (procEnvImpl == null) {
-            procEnvImpl = new JavacProcessingEnvironment(context, processors);
+            procEnvImpl = JavacProcessingEnvironment.instance(context);
+            procEnvImpl.setProcessors(processors);
             processAnnotations = procEnvImpl.atLeastOneProcessor();
 
             if (processAnnotations) {
@@ -1019,8 +1079,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 reader.saveParameterNames = true;
                 keepComments = true;
                 genEndPos = true;
-                taskStarted(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
-                log.deferDiagnostics = true;
+                if (!taskListener.isEmpty())
+                    taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
+                deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
             } else { // free resources
                 procEnvImpl.close();
             }
@@ -1033,7 +1094,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
     }
 
     /**
-     * Process any anotations found in the specifed compilation units.
+     * Process any annotations found in the specified compilation units.
      * @param roots a list of compilation units
      * @return an instance of the compiler in which to complete the compilation
      */
@@ -1051,7 +1112,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             // or other errors during enter which cannot be fixed by running
             // any annotation processors.
             if (unrecoverableError()) {
-                log.reportDeferredDiagnostics();
+                deferredDiagnosticHandler.reportDeferredDiagnostics();
+                log.popDiagnosticHandler(deferredDiagnosticHandler);
+                deferredDiagnosticHandler = null;
                 return this;
             }
         }
@@ -1074,10 +1137,12 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 log.error("proc.no.explicit.annotation.processing.requested",
                           classnames);
             }
-            log.reportDeferredDiagnostics();
+            Assert.checkNull(deferredDiagnosticHandler);
             return this; // continue regular compilation
         }
 
+        Assert.checkNonNull(deferredDiagnosticHandler);
+
         try {
             List<ClassSymbol> classSymbols = List.nil();
             List<PackageSymbol> pckSymbols = List.nil();
@@ -1087,7 +1152,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 if (!explicitAnnotationProcessingRequested()) {
                     log.error("proc.no.explicit.annotation.processing.requested",
                               classnames);
-                    log.reportDeferredDiagnostics();
+                    deferredDiagnosticHandler.reportDeferredDiagnostics();
+                    log.popDiagnosticHandler(deferredDiagnosticHandler);
+                    deferredDiagnosticHandler = null;
                     return this; // TODO: Will this halt compilation?
                 } else {
                     boolean errors = false;
@@ -1120,7 +1187,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                         }
                     }
                     if (errors) {
-                        log.reportDeferredDiagnostics();
+                        deferredDiagnosticHandler.reportDeferredDiagnostics();
+                        log.popDiagnosticHandler(deferredDiagnosticHandler);
+                        deferredDiagnosticHandler = null;
                         return this;
                     }
                 }
@@ -1144,20 +1213,22 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             if (c != this)
                 annotationProcessingOccurred = c.annotationProcessingOccurred = true;
             // doProcessing will have handled deferred diagnostics
-            Assert.check(c.log.deferDiagnostics == false
-                    && c.log.deferredDiagnostics.size() == 0, "Deferred diagnistics: " + c.log.deferredDiagnostics);
             return c;
         } catch (CompletionFailure ex) {
             log.error("cant.access", ex.sym, ex.getDetailValue());
-            log.reportDeferredDiagnostics();
+            deferredDiagnosticHandler.reportDeferredDiagnostics();
+            log.popDiagnosticHandler(deferredDiagnosticHandler);
+            deferredDiagnosticHandler = null;
             return this;
         }
     }
 
     private boolean unrecoverableError() {
-        for (JCDiagnostic d: log.deferredDiagnostics) {
-            if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
-                return true;
+        if (deferredDiagnosticHandler != null) {
+            for (JCDiagnostic d: deferredDiagnosticHandler.getDiagnostics()) {
+                if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RECOVERABLE))
+                    return true;
+            }
         }
         return false;
     }
@@ -1204,7 +1275,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         if (verbose)
             log.printVerbose("checking.attribution", env.enclClass.sym);
 
-        taskStarted(new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym));
+        if (!taskListener.isEmpty()) {
+            TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
+            taskListener.started(e);
+        }
 
         JavaFileObject prev = log.useSource(
                                   env.enclClass.sym.sourcefile != null ?
@@ -1212,12 +1286,18 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                                   env.toplevel.sourcefile);
         try {
             attr.attrib(env);
-            if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
+            if (!shouldStop(CompileState.ATTR)) {
                 //if in fail-over mode, ensure that AST expression nodes
                 //are correctly initialized (e.g. they have a type/symbol)
-                attr.postAttr(env);
+                attr.postAttr(env.tree);
             }
             compileStates.put(env, CompileState.ATTR);
+            if (rootClasses != null && rootClasses.contains(env.enclClass)) {
+                // This was a class that was explicitly supplied for compilation.
+                // If we want to capture the public api of this class,
+                // then now is a good time to do it.
+                reportPublicApi(env.enclClass.sym);
+            }
         }
         finally {
             log.useSource(prev);
@@ -1226,6 +1306,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         return env;
     }
 
+    /** Report the public api of a class that was supplied explicitly for compilation,
+     *  for example on the command line to javac.
+     * @param sym The symbol of the class.
+     */
+    public void reportPublicApi(ClassSymbol sym) {
+       // Override to collect the reported public api.
+    }
+
     /**
      * Perform dataflow checks on attributed parse trees.
      * These include checks for definite assignment and unreachable statements.
@@ -1284,7 +1372,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             }
         }
         finally {
-            taskFinished(new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym));
+            if (!taskListener.isEmpty()) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
+                taskListener.finished(e);
+            }
         }
     }
 
@@ -1322,6 +1413,13 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             return;
         }
 
+        if (duplicateClassChecker != null && env.tree.hasTag(Tag.CLASSDEF) && duplicateClassChecker.check(((JCClassDecl)env.tree).sym.fullname,
+                env.enclClass.sym.sourcefile != null
+                ? env.enclClass.sym.sourcefile
+                : env.toplevel.sourcefile)) {
+            return;
+        }
+
         if (compileStates.isDone(env, CompileState.LOWER)) {
             results.addAll(desugaredEnvs.get(env));
             return;
@@ -1340,13 +1438,17 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             public void visitClassDef(JCClassDecl node) {
                 if (node.sym != null) {
                     Type st = types.supertype(node.sym.type);
-                    if (st != null && st.tag == TypeTags.CLASS) {
+                    boolean envForSuperTypeFound = false;
+                    while (!envForSuperTypeFound && st != null && st.hasTag(CLASS)) {
                         ClassSymbol c = st.tsym.outermostClass();
                         Env<AttrContext> stEnv = enter.getEnv(c);
                         if (stEnv != null && env != stEnv) {
-                            if (dependencies.add(stEnv))
+                            if (dependencies.add(stEnv)) {
                                 scan(stEnv.tree);
+                            }
+                            envForSuperTypeFound = true;
                         }
+                        st = types.supertype(st);
                     }
                 }
                 super.visitClassDef(node);
@@ -1412,6 +1514,14 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             env.tree = transTypes.translateTopLevelClass(env.tree, localMake);
             compileStates.put(env, CompileState.TRANSTYPES);
 
+            if (source.allowLambda()) {
+                if (shouldStop(CompileState.UNLAMBDA))
+                    return;
+
+                env.tree = lambdaToMethod.translateTopLevelClass(env, env.tree, localMake);
+                compileStates.put(env, CompileState.UNLAMBDA);
+            }
+
             if (shouldStop(CompileState.LOWER))
                 return;
 
@@ -1470,17 +1580,25 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                                + " " + cdef.sym + "]");
             }
 
-            taskStarted(new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym));
+            if (!taskListener.isEmpty()) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym);
+                taskListener.started(e);
+            }
 
             JavaFileObject prev = log.useSource(env.enclClass.sym.sourcefile != null ?
                                       env.enclClass.sym.sourcefile :
                                       env.toplevel.sourcefile);
             try {
-                JavaFileObject file;
+                JavaFileObject file = null;
                 if (usePrintSource)
                     file = printSource(env, cdef);
-                else
+                else {
+                    if (fileManager.hasLocation(StandardLocation.NATIVE_HEADER_OUTPUT)
+                            && jniWriter.needsHeader(cdef.sym)) {
+                        jniWriter.write(cdef.sym);
+                    }
                     file = genCode(env, cdef);
+                }
                 if (results != null && file != null)
                     results.add(file);
             } catch (IOException ex) {
@@ -1491,7 +1609,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 log.useSource(prev);
             }
 
-            taskFinished(new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym));
+            if (!taskListener.isEmpty()) {
+                TaskEvent e = new TaskEvent(TaskEvent.Kind.GENERATE, env.toplevel, cdef.sym);
+                taskListener.finished(e);
+            }
         }
     }
 
@@ -1533,20 +1654,20 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                     for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
                         JCTree t = it.head;
                         switch (t.getTag()) {
-                        case JCTree.CLASSDEF:
+                        case CLASSDEF:
                             if (isInterface ||
                                 (((JCClassDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
                                 (((JCClassDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCClassDecl) t).sym.packge().getQualifiedName() == names.java_lang)
                                 newdefs.append(t);
                             break;
-                        case JCTree.METHODDEF:
+                        case METHODDEF:
                             if (isInterface ||
                                 (((JCMethodDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
                                 ((JCMethodDecl) t).sym.name == names.init ||
                                 (((JCMethodDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCMethodDecl) t).sym.packge().getQualifiedName() == names.java_lang)
                                 newdefs.append(t);
                             break;
-                        case JCTree.VARDEF:
+                        case VARDEF:
                             if (isInterface || (((JCVariableDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
                                 (((JCVariableDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCVariableDecl) t).sym.packge().getQualifiedName() == names.java_lang)
                                 newdefs.append(t);
@@ -1574,6 +1695,9 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 log.warning("proc.use.proc.or.implicit");
         }
         chk.reportDeferredDiagnostics();
+        if (log.compressedOutput) {
+            log.mandatoryNote(null, "compressed.diags");
+        }
     }
 
     /** Close the compiler, flushing the logs
@@ -1615,24 +1739,38 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
             if (names != null && disposeNames)
                 names.dispose();
             names = null;
+
+            for (Closeable c: closeables) {
+                try {
+                    c.close();
+                } catch (IOException e) {
+                    // When javac uses JDK 7 as a baseline, this code would be
+                    // better written to set any/all exceptions from all the
+                    // Closeables as suppressed exceptions on the FatalError
+                    // that is thrown.
+                    JCDiagnostic msg = diagFactory.fragment("fatal.err.cant.close");
+                    throw new FatalError(msg, e);
+                }
+            }
+            closeables = List.nil();
         }
     }
 
     protected void printNote(String lines) {
-        Log.printLines(log.noticeWriter, lines);
+        log.printRawLines(Log.WriterKind.NOTICE, lines);
     }
 
     /** Print numbers of errors and warnings.
      */
-    protected void printCount(String kind, int count) {
+    public void printCount(String kind, int count) {
         if (count != 0) {
             String key;
             if (count == 1)
                 key = "count." + kind;
             else
                 key = "count." + kind + ".plural";
-            log.printErrLines(key, String.valueOf(count));
-            log.errWriter.flush();
+            log.printLines(WriterKind.ERROR, key, String.valueOf(count));
+            log.flush(Log.WriterKind.ERROR);
         }
     }
 
@@ -1650,6 +1788,10 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         start_msec = prev.start_msec;
         notYetEntered = prev.notYetEntered;
         hasBeenUsed = true;
+        closeables = prev.closeables;
+        prev.closeables = List.nil();
+        shouldStopPolicyIfError = prev.shouldStopPolicyIfError;
+        shouldStopPolicyIfNoError = prev.shouldStopPolicyIfNoError;
     }
 
     public static void enableLogging() {
@@ -1660,20 +1802,4 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
        }
 
     }
-
-    private void taskStarted(TaskEvent evt) {
-        TaskListener tl = context.get(TaskListener.class);
-
-        if (tl != null) {
-            tl.started(evt);
-        }
-    }
-
-    private void taskFinished(TaskEvent evt) {
-        TaskListener tl = context.get(TaskListener.class);
-
-        if (tl != null) {
-            tl.finished(evt);
-        }
-    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/main/JavacOption.java b/src/share/classes/com/sun/tools/javac/main/JavacOption.java
deleted file mode 100644
index e39793d..0000000
--- a/src/share/classes/com/sun/tools/javac/main/JavacOption.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2006, 2008, 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.main;
-
-import java.io.PrintWriter;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Options;
-
-/**
- * TODO: describe com.sun.tools.javac.main.JavacOption
- *
- * <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></p>
- */
-public interface JavacOption {
-
-    OptionKind getKind();
-
-    /** Does this option take a (separate) operand?
-     *  @return true if this option takes a separate operand
-     */
-    boolean hasArg();
-
-    /** Does argument string match option pattern?
-     *  @param arg   the command line argument string
-     *  @return true if {@code arg} matches this option
-     */
-    boolean matches(String arg);
-
-    /** Process an option with an argument.
-     *  @param options the accumulated set of analyzed options
-     *  @param option  the option to be processed
-     *  @param arg     the arg for the option to be processed
-     *  @return true if an error was detected
-     */
-    boolean process(Options options, String option, String arg);
-
-    /** Process the option with no argument.
-     *  @param options the accumulated set of analyzed options
-     *  @param option  the option to be processed
-     *  @return true if an error was detected
-     */
-    boolean process(Options options, String option);
-
-    OptionName getName();
-
-    enum OptionKind {
-        NORMAL,
-        EXTENDED,
-        HIDDEN,
-    }
-
-    enum ChoiceKind {
-        ONEOF,
-        ANYOF
-    }
-
-    /** This class represents an option recognized by the main program
-     */
-    static class Option implements JavacOption {
-
-        /** Option string.
-         */
-        OptionName name;
-
-        /** Documentation key for arguments.
-         */
-        String argsNameKey;
-
-        /** Documentation key for description.
-         */
-        String descrKey;
-
-        /** Suffix option (-foo=bar or -foo:bar)
-         */
-        boolean hasSuffix;
-
-        /** The kind of choices for this option, if any.
-         */
-        ChoiceKind choiceKind;
-
-        /** The choices for this option, if any, and whether or not the choices
-         *  are hidden
-         */
-        Map<String,Boolean> choices;
-
-        Option(OptionName name, String argsNameKey, String descrKey) {
-            this.name = name;
-            this.argsNameKey = argsNameKey;
-            this.descrKey = descrKey;
-            char lastChar = name.optionName.charAt(name.optionName.length()-1);
-            hasSuffix = lastChar == ':' || lastChar == '=';
-        }
-
-        Option(OptionName name, String descrKey) {
-            this(name, null, descrKey);
-        }
-
-        Option(OptionName name, String descrKey, ChoiceKind choiceKind, String... choices) {
-            this(name, descrKey, choiceKind, createChoices(choices));
-        }
-
-        private static Map<String,Boolean> createChoices(String... choices) {
-            Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
-            for (String c: choices)
-                map.put(c, false);
-            return map;
-        }
-
-        Option(OptionName name, String descrKey, ChoiceKind choiceKind,
-                Map<String,Boolean> choices) {
-            this(name, null, descrKey);
-            if (choiceKind == null || choices == null)
-                throw new NullPointerException();
-            this.choiceKind = choiceKind;
-            this.choices = choices;
-        }
-
-        @Override
-        public String toString() {
-            return name.optionName;
-        }
-
-        public boolean hasArg() {
-            return argsNameKey != null && !hasSuffix;
-        }
-
-        public boolean matches(String option) {
-            if (!hasSuffix)
-                return option.equals(name.optionName);
-
-            if (!option.startsWith(name.optionName))
-                return false;
-
-            if (choices != null) {
-                String arg = option.substring(name.optionName.length());
-                if (choiceKind == ChoiceKind.ONEOF)
-                    return choices.keySet().contains(arg);
-                else {
-                    for (String a: arg.split(",+")) {
-                        if (!choices.keySet().contains(a))
-                            return false;
-                    }
-                }
-            }
-
-            return true;
-        }
-
-        /** Print a line of documentation describing this option, if standard.
-         * @param out the stream to which to write the documentation
-         */
-        void help(PrintWriter out) {
-            String s = "  " + helpSynopsis();
-            out.print(s);
-            for (int j = Math.min(s.length(), 28); j < 29; j++) out.print(" ");
-            Log.printLines(out, Main.getLocalizedString(descrKey));
-        }
-
-        String helpSynopsis() {
-            StringBuilder sb = new StringBuilder();
-            sb.append(name);
-            if (argsNameKey == null) {
-                if (choices != null) {
-                    String sep = "{";
-                    for (Map.Entry<String,Boolean> e: choices.entrySet()) {
-                        if (!e.getValue()) {
-                            sb.append(sep);
-                            sb.append(e.getKey());
-                            sep = ",";
-                        }
-                    }
-                    sb.append("}");
-                }
-            } else {
-                if (!hasSuffix)
-                    sb.append(" ");
-                sb.append(Main.getLocalizedString(argsNameKey));
-            }
-
-            return sb.toString();
-        }
-
-        /** Print a line of documentation describing this option, if non-standard.
-         *  @param out the stream to which to write the documentation
-         */
-        void xhelp(PrintWriter out) {}
-
-        /** Process the option (with arg). Return true if error detected.
-         */
-        public boolean process(Options options, String option, String arg) {
-            if (options != null) {
-                if (choices != null) {
-                    if (choiceKind == ChoiceKind.ONEOF) {
-                        // some clients like to see just one of option+choice set
-                        for (String s: choices.keySet())
-                            options.remove(option + s);
-                        String opt = option + arg;
-                        options.put(opt, opt);
-                        // some clients like to see option (without trailing ":")
-                        // set to arg
-                        String nm = option.substring(0, option.length() - 1);
-                        options.put(nm, arg);
-                    } else {
-                        // set option+word for each word in arg
-                        for (String a: arg.split(",+")) {
-                            String opt = option + a;
-                            options.put(opt, opt);
-                        }
-                    }
-                }
-                options.put(option, arg);
-            }
-            return false;
-        }
-
-        /** Process the option (without arg). Return true if error detected.
-         */
-        public boolean process(Options options, String option) {
-            if (hasSuffix)
-                return process(options, name.optionName, option.substring(name.optionName.length()));
-            else
-                return process(options, option, option);
-        }
-
-        public OptionKind getKind() { return OptionKind.NORMAL; }
-
-        public OptionName getName() { return name; }
-    };
-
-    /** A nonstandard or extended (-X) option
-     */
-    static class XOption extends Option {
-        XOption(OptionName name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-        }
-        XOption(OptionName name, String descrKey) {
-            this(name, null, descrKey);
-        }
-        XOption(OptionName name, String descrKey, ChoiceKind kind, String... choices) {
-            super(name, descrKey, kind, choices);
-        }
-        XOption(OptionName name, String descrKey, ChoiceKind kind, Map<String,Boolean> choices) {
-            super(name, descrKey, kind, choices);
-        }
-        @Override
-        void help(PrintWriter out) {}
-        @Override
-        void xhelp(PrintWriter out) { super.help(out); }
-        @Override
-        public OptionKind getKind() { return OptionKind.EXTENDED; }
-    };
-
-    /** A hidden (implementor) option
-     */
-    static class HiddenOption extends Option {
-        HiddenOption(OptionName name) {
-            super(name, null, null);
-        }
-        HiddenOption(OptionName name, String argsNameKey) {
-            super(name, argsNameKey, null);
-        }
-        @Override
-        void help(PrintWriter out) {}
-        @Override
-        void xhelp(PrintWriter out) {}
-        @Override
-        public OptionKind getKind() { return OptionKind.HIDDEN; }
-    };
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/main/Main.java b/src/share/classes/com/sun/tools/javac/main/Main.java
index 6fd8655..72a279d 100644
--- a/src/share/classes/com/sun/tools/javac/main/Main.java
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -33,25 +33,32 @@ import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.LinkedHashSet;
-import java.util.MissingResourceException;
 import java.util.Set;
+
+import javax.annotation.processing.Processor;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
-import javax.annotation.processing.Processor;
 
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Plugin;
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.javac.api.BasicJavacTask;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.file.CacheFSInfo;
 import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.jvm.Profile;
 import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.main.JavacOption.Option;
-import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;
-import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.processing.AnnotationProcessingError;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+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.*;
 
-import static com.sun.tools.javac.main.OptionName.*;
-
-/** This class provides a commandline interface to the GJC compiler.
+/** This class provides a command line interface to the javac compiler.
  *
  *  <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.
@@ -68,6 +75,10 @@ public class Main {
      */
     PrintWriter out;
 
+    /** The log to use for diagnostic output.
+     */
+    public Log log;
+
     /**
      * If true, certain errors will cause an exception, such as command line
      * arg errors, or exceptions in user provided code.
@@ -77,48 +88,69 @@ public class Main {
 
     /** Result codes.
      */
-    static final int
-        EXIT_OK = 0,        // Compilation completed with no errors.
-        EXIT_ERROR = 1,     // Completed but reported errors.
-        EXIT_CMDERR = 2,    // Bad command-line arguments
-        EXIT_SYSERR = 3,    // System error or resource exhaustion.
-        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
+    public enum Result {
+        OK(0),        // Compilation completed with no errors.
+        ERROR(1),     // Completed but reported errors.
+        CMDERR(2),    // Bad command-line arguments
+        SYSERR(3),    // System error or resource exhaustion.
+        ABNORMAL(4);  // Compiler terminated abnormally
+
+        Result(int exitCode) {
+            this.exitCode = exitCode;
+        }
+
+        public boolean isOK() {
+            return (exitCode == 0);
+        }
+
+        public final int exitCode;
+    }
 
-    private Option[] recognizedOptions = RecognizedOptions.getJavaCompilerOptions(new OptionHelper() {
+    private Option[] recognizedOptions =
+            Option.getJavaCompilerOptions().toArray(new Option[0]);
 
-        public void setOut(PrintWriter out) {
-            Main.this.out = out;
+    private OptionHelper optionHelper = new OptionHelper() {
+        @Override
+        public String get(Option option) {
+            return options.get(option);
         }
 
-        public void error(String key, Object... args) {
-            Main.this.error(key, args);
+        @Override
+        public void put(String name, String value) {
+            options.put(name, value);
         }
 
-        public void printVersion() {
-            Log.printLines(out, getLocalizedString("version", ownName,  JavaCompiler.version()));
+        @Override
+        public void remove(String name) {
+            options.remove(name);
         }
 
-        public void printFullVersion() {
-            Log.printLines(out, getLocalizedString("fullVersion", ownName,  JavaCompiler.fullVersion()));
+        @Override
+        public Log getLog() {
+            return log;
         }
 
-        public void printHelp() {
-            help();
+        @Override
+        public String getOwnName() {
+            return ownName;
         }
 
-        public void printXhelp() {
-            xhelp();
+        @Override
+        public void error(String key, Object... args) {
+            Main.this.error(key, args);
         }
 
+        @Override
         public void addFile(File f) {
             filenames.add(f);
         }
 
+        @Override
         public void addClassName(String s) {
             classnames.append(s);
         }
 
-    });
+    };
 
     /**
      * Construct a compiler instance.
@@ -134,6 +166,7 @@ public class Main {
         this.ownName = name;
         this.out = out;
     }
+
     /** A table of all options that's passed to the JavaCompiler constructor.  */
     private Options options = null;
 
@@ -145,42 +178,21 @@ public class Main {
      */
     public ListBuffer<String> classnames = null; // XXX sb protected
 
-    /** Print a string that explains usage.
-     */
-    void help() {
-        Log.printLines(out, getLocalizedString("msg.usage.header", ownName));
-        for (int i=0; i<recognizedOptions.length; i++) {
-            recognizedOptions[i].help(out);
-        }
-        out.println();
-    }
-
-    /** Print a string that explains usage for X options.
-     */
-    void xhelp() {
-        for (int i=0; i<recognizedOptions.length; i++) {
-            recognizedOptions[i].xhelp(out);
-        }
-        out.println();
-        Log.printLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
-    }
-
     /** Report a usage error.
      */
     void error(String key, Object... args) {
         if (apiMode) {
-            String msg = getLocalizedString(key, args);
+            String msg = log.localize(PrefixKind.JAVAC, key, args);
             throw new PropagatedException(new IllegalStateException(msg));
         }
         warning(key, args);
-        Log.printLines(out, getLocalizedString("msg.usage", ownName));
+        log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
     }
 
     /** Report a warning.
      */
     void warning(String key, Object... args) {
-        Log.printLines(out, ownName + ": "
-                       + getLocalizedString(key, args));
+        log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
     }
 
     public Option getOption(String flag) {
@@ -242,10 +254,10 @@ public class Main {
                 }
                 String operand = flags[ac];
                 ac++;
-                if (option.process(options, flag, operand))
+                if (option.process(optionHelper, flag, operand))
                     return null;
             } else {
-                if (option.process(options, flag))
+                if (option.process(optionHelper, flag))
                     return null;
             }
         }
@@ -297,6 +309,15 @@ public class Main {
             }
         }
 
+        String profileString = options.get(PROFILE);
+        if (profileString != null) {
+            Profile profile = Profile.lookup(profileString);
+            if (!profile.isValid(target)) {
+                warning("warn.profile.target.conflict", profileString, target.name);
+                return null;
+            }
+        }
+
         // handle this here so it works even if no other options given
         String showClass = options.get("showClass");
         if (showClass != null) {
@@ -305,11 +326,13 @@ public class Main {
             showClass(showClass);
         }
 
+        options.notifyListeners();
+
         return filenames;
     }
     // where
-        private boolean checkDirectory(OptionName optName) {
-            String value = options.get(optName);
+        private boolean checkDirectory(Option option) {
+            String value = options.get(option);
             if (value == null)
                 return true;
             File file = new File(value);
@@ -327,10 +350,10 @@ public class Main {
     /** Programmatic interface for main function.
      * @param args    The command line parameters.
      */
-    public int compile(String[] args) {
+    public Result compile(String[] args) {
         Context context = new Context();
         JavacFileManager.preRegister(context); // can't create it until Log has been set up
-        int result = compile(args, context);
+        Result result = compile(args, context);
         if (fileManager instanceof JavacFileManager) {
             // A fresh context was created above, so jfm must be a JavacFileManager
             ((JavacFileManager)fileManager).close();
@@ -338,14 +361,14 @@ public class Main {
         return result;
     }
 
-    public int compile(String[] args, Context context) {
+    public Result compile(String[] args, Context context) {
         return compile(args, context, List.<JavaFileObject>nil(), null);
     }
 
     /** Programmatic interface for main function.
      * @param args    The command line parameters.
      */
-    public int compile(String[] args,
+    public Result compile(String[] args,
                        Context context,
                        List<JavaFileObject> fileObjects,
                        Iterable<? extends Processor> processors)
@@ -353,12 +376,15 @@ public class Main {
         return compile(args,  null, context, fileObjects, processors);
     }
 
-    public int compile(String[] args,
-                       String[] classNames,
-                       Context context,
-                       List<JavaFileObject> fileObjects,
-                       Iterable<? extends Processor> processors)
+    public Result compile(String[] args,
+                          String[] classNames,
+                          Context context,
+                          List<JavaFileObject> fileObjects,
+                          Iterable<? extends Processor> processors)
     {
+        context.put(Log.outKey, out);
+        log = Log.instance(context);
+
         if (options == null)
             options = Options.instance(context); // creates a new one
 
@@ -372,10 +398,10 @@ public class Main {
          */
         try {
             if (args.length == 0
-                && (classNames == null || classNames.length == 0)
-                && fileObjects.isEmpty()) {
-                help();
-                return EXIT_CMDERR;
+                    && (classNames == null || classNames.length == 0)
+                    && fileObjects.isEmpty()) {
+                Option.HELP.process(optionHelper, "-help");
+                return Result.CMDERR;
             }
 
             Collection<File> files;
@@ -383,48 +409,101 @@ public class Main {
                 files = processArgs(CommandLine.parse(args), classNames);
                 if (files == null) {
                     // null signals an error in options, abort
-                    return EXIT_CMDERR;
+                    return Result.CMDERR;
                 } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
                     // it is allowed to compile nothing if just asking for help or version info
                     if (options.isSet(HELP)
                         || options.isSet(X)
                         || options.isSet(VERSION)
                         || options.isSet(FULLVERSION))
-                        return EXIT_OK;
+                        return Result.OK;
                     if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
                         error("err.no.source.files.classes");
                     } else {
                         error("err.no.source.files");
                     }
-                    return EXIT_CMDERR;
+                    return Result.CMDERR;
                 }
             } catch (java.io.FileNotFoundException e) {
-                Log.printLines(out, ownName + ": " +
-                               getLocalizedString("err.file.not.found",
-                                                  e.getMessage()));
-                return EXIT_SYSERR;
+                warning("err.file.not.found", e.getMessage());
+                return Result.SYSERR;
             }
 
             boolean forceStdOut = options.isSet("stdout");
             if (forceStdOut) {
-                out.flush();
-                out = new PrintWriter(System.out, true);
+                log.flush();
+                log.setWriters(new PrintWriter(System.out, true));
             }
 
-            context.put(Log.outKey, out);
-
             // allow System property in following line as a Mustang legacy
             boolean batchMode = (options.isUnset("nonBatchMode")
                         && System.getProperty("nonBatchMode") == null);
             if (batchMode)
                 CacheFSInfo.preRegister(context);
 
-            fileManager = context.get(JavaFileManager.class);
+            // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate
+            // invoke any available plugins
+            String plugins = options.get(PLUGIN);
+            if (plugins != null) {
+                JavacProcessingEnvironment pEnv = JavacProcessingEnvironment.instance(context);
+                ClassLoader cl = pEnv.getProcessorClassLoader();
+                ServiceLoader<Plugin> sl = ServiceLoader.load(Plugin.class, cl);
+                Set<List<String>> pluginsToCall = new LinkedHashSet<List<String>>();
+                for (String plugin: plugins.split("\\x00")) {
+                    pluginsToCall.add(List.from(plugin.split("\\s+")));
+                }
+                JavacTask task = null;
+                Iterator<Plugin> iter = sl.iterator();
+                while (iter.hasNext()) {
+                    Plugin plugin = iter.next();
+                    for (List<String> p: pluginsToCall) {
+                        if (plugin.getName().equals(p.head)) {
+                            pluginsToCall.remove(p);
+                            try {
+                                if (task == null)
+                                    task = JavacTask.instance(pEnv);
+                                plugin.init(task, p.tail.toArray(new String[p.tail.size()]));
+                            } catch (Throwable ex) {
+                                if (apiMode)
+                                    throw new RuntimeException(ex);
+                                pluginMessage(ex);
+                                return Result.SYSERR;
+                            }
+                        }
+                    }
+                }
+                for (List<String> p: pluginsToCall) {
+                    log.printLines(PrefixKind.JAVAC, "msg.plugin.not.found", p.head);
+                }
+            }
 
             comp = JavaCompiler.instance(context);
-            if (comp == null) return EXIT_SYSERR;
 
-            Log log = Log.instance(context);
+            // FIXME: this code will not be invoked if using JavacTask.parse/analyze/generate
+            String xdoclint = options.get(XDOCLINT);
+            String xdoclintCustom = options.get(XDOCLINT_CUSTOM);
+            if (xdoclint != null || xdoclintCustom != null) {
+                Set<String> doclintOpts = new LinkedHashSet<String>();
+                if (xdoclint != null)
+                    doclintOpts.add(DocLint.XMSGS_OPTION);
+                if (xdoclintCustom != null) {
+                    for (String s: xdoclintCustom.split("\\s+")) {
+                        if (s.isEmpty())
+                            continue;
+                        doclintOpts.add(s.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
+                    }
+                }
+                if (!(doclintOpts.size() == 1
+                        && doclintOpts.iterator().next().equals(DocLint.XMSGS_CUSTOM_PREFIX + "none"))) {
+                    JavacTask t = BasicJavacTask.instance(context);
+                    // standard doclet normally generates H1, H2
+                    doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
+                    new DocLint().init(t, doclintOpts.toArray(new String[doclintOpts.size()]));
+                    comp.keepComments = true;
+                }
+            }
+
+            fileManager = context.get(JavaFileManager.class);
 
             if (!files.isEmpty()) {
                 // add filenames to fileObjects
@@ -442,33 +521,33 @@ public class Main {
 
             if (log.expectDiagKeys != null) {
                 if (log.expectDiagKeys.isEmpty()) {
-                    Log.printLines(log.noticeWriter, "all expected diagnostics found");
-                    return EXIT_OK;
+                    log.printRawLines("all expected diagnostics found");
+                    return Result.OK;
                 } else {
-                    Log.printLines(log.noticeWriter, "expected diagnostic keys not found: " + log.expectDiagKeys);
-                    return EXIT_ERROR;
+                    log.printRawLines("expected diagnostic keys not found: " + log.expectDiagKeys);
+                    return Result.ERROR;
                 }
             }
 
             if (comp.errorCount() != 0)
-                return EXIT_ERROR;
+                return Result.ERROR;
         } catch (IOException ex) {
             ioMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (OutOfMemoryError ex) {
             resourceMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (StackOverflowError ex) {
             resourceMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (FatalError ex) {
             feMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (AnnotationProcessingError ex) {
             if (apiMode)
                 throw new RuntimeException(ex.getCause());
             apMessage(ex);
-            return EXIT_SYSERR;
+            return Result.SYSERR;
         } catch (ClientCodeException ex) {
             // as specified by javax.tools.JavaCompiler#getTask
             // and javax.tools.JavaCompiler.CompilationTask#call
@@ -482,7 +561,7 @@ public class Main {
             if (comp == null || comp.errorCount() == 0 ||
                 options == null || options.isSet("dev"))
                 bugMessage(ex);
-            return EXIT_ABNORMAL;
+            return Result.ABNORMAL;
         } finally {
             if (comp != null) {
                 try {
@@ -494,58 +573,64 @@ public class Main {
             filenames = null;
             options = null;
         }
-        return EXIT_OK;
+        return Result.OK;
     }
 
     /** Print a message reporting an internal error.
      */
     void bugMessage(Throwable ex) {
-        Log.printLines(out, getLocalizedString("msg.bug",
-                                               JavaCompiler.version()));
-        ex.printStackTrace(out);
+        log.printLines(PrefixKind.JAVAC, "msg.bug", JavaCompiler.version());
+        ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
     }
 
     /** Print a message reporting a fatal error.
      */
     void feMessage(Throwable ex) {
-        Log.printLines(out, ex.getMessage());
+        log.printRawLines(ex.getMessage());
         if (ex.getCause() != null && options.isSet("dev")) {
-            ex.getCause().printStackTrace(out);
+            ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
         }
     }
 
     /** Print a message reporting an input/output error.
      */
     void ioMessage(Throwable ex) {
-        Log.printLines(out, getLocalizedString("msg.io"));
-        ex.printStackTrace(out);
+        log.printLines(PrefixKind.JAVAC, "msg.io");
+        ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
     }
 
     /** Print a message reporting an out-of-resources error.
      */
     void resourceMessage(Throwable ex) {
-        Log.printLines(out, getLocalizedString("msg.resource"));
-//      System.out.println("(name buffer len = " + Name.names.length + " " + Name.nc);//DEBUG
-        ex.printStackTrace(out);
+        log.printLines(PrefixKind.JAVAC, "msg.resource");
+        ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
     }
 
     /** Print a message reporting an uncaught exception from an
      * annotation processor.
      */
     void apMessage(AnnotationProcessingError ex) {
-        Log.printLines(out,
-                       getLocalizedString("msg.proc.annotation.uncaught.exception"));
-        ex.getCause().printStackTrace(out);
+        log.printLines(PrefixKind.JAVAC, "msg.proc.annotation.uncaught.exception");
+        ex.getCause().printStackTrace(log.getWriter(WriterKind.NOTICE));
+    }
+
+    /** Print a message reporting an uncaught exception from an
+     * annotation processor.
+     */
+    void pluginMessage(Throwable ex) {
+        log.printLines(PrefixKind.JAVAC, "msg.plugin.uncaught.exception");
+        ex.printStackTrace(log.getWriter(WriterKind.NOTICE));
     }
 
     /** Display the location and checksum of a class. */
     void showClass(String className) {
-        out.println("javac: show class: " + className);
+        PrintWriter pw = log.getWriter(WriterKind.NOTICE);
+        pw.println("javac: show class: " + className);
         URL url = getClass().getResource('/' + className.replace('.', '/') + ".class");
         if (url == null)
-            out.println("  class not found");
+            pw.println("  class not found");
         else {
-            out.println("  " + url);
+            pw.println("  " + url);
             try {
                 final String algorithm = "MD5";
                 byte[] digest;
@@ -562,9 +647,9 @@ public class Main {
                 StringBuilder sb = new StringBuilder();
                 for (byte b: digest)
                     sb.append(String.format("%02x", b));
-                out.println("  " + algorithm + " checksum: " + sb);
+                pw.println("  " + algorithm + " checksum: " + sb);
             } catch (Exception e) {
-                out.println("  cannot compute digest: " + e);
+                pw.println("  cannot compute digest: " + e);
             }
         }
     }
@@ -575,35 +660,35 @@ public class Main {
      * Internationalization
      *************************************************************************/
 
-    /** Find a localized string in the resource bundle.
-     *  @param key     The key for the localized string.
-     */
-    public static String getLocalizedString(String key, Object... args) { // FIXME sb private
-        try {
-            if (messages == null)
-                messages = new JavacMessages(javacBundleName);
-            return messages.getLocalizedString("javac." + key, args);
-        }
-        catch (MissingResourceException e) {
-            throw new Error("Fatal Error: Resource for javac is missing", e);
-        }
-    }
-
-    public static void useRawMessages(boolean enable) {
-        if (enable) {
-            messages = new JavacMessages(javacBundleName) {
-                    @Override
-                    public String getLocalizedString(String key, Object... args) {
-                        return key;
-                    }
-                };
-        } else {
-            messages = new JavacMessages(javacBundleName);
-        }
-    }
-
-    private static final String javacBundleName =
+//    /** Find a localized string in the resource bundle.
+//     *  @param key     The key for the localized string.
+//     */
+//    public static String getLocalizedString(String key, Object... args) { // FIXME sb private
+//        try {
+//            if (messages == null)
+//                messages = new JavacMessages(javacBundleName);
+//            return messages.getLocalizedString("javac." + key, args);
+//        }
+//        catch (MissingResourceException e) {
+//            throw new Error("Fatal Error: Resource for javac is missing", e);
+//        }
+//    }
+//
+//    public static void useRawMessages(boolean enable) {
+//        if (enable) {
+//            messages = new JavacMessages(javacBundleName) {
+//                    @Override
+//                    public String getLocalizedString(String key, Object... args) {
+//                        return key;
+//                    }
+//                };
+//        } else {
+//            messages = new JavacMessages(javacBundleName);
+//        }
+//    }
+
+    public static final String javacBundleName =
         "com.sun.tools.javac.resources.javac";
-
-    private static JavacMessages messages;
+//
+//    private static JavacMessages messages;
 }
diff --git a/src/share/classes/com/sun/tools/javac/main/Option.java b/src/share/classes/com/sun/tools/javac/main/Option.java
new file mode 100644
index 0000000..dd3bbe8
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/main/Option.java
@@ -0,0 +1,729 @@
+/*
+ * 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.tools.javac.main;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Log.PrefixKind;
+import com.sun.tools.javac.util.Log.WriterKind;
+import com.sun.tools.javac.util.Options;
+import static com.sun.tools.javac.main.Option.ChoiceKind.*;
+import static com.sun.tools.javac.main.Option.OptionGroup.*;
+import static com.sun.tools.javac.main.Option.OptionKind.*;
+
+/**
+ * Options for javac. The specific Option to handle a command-line option
+ * is identified by searching the members of this enum in order, looking
+ * the first {@link #matches match}. The action for an Option is performed
+ * by calling {@link #process process}, and by providing a suitable
+ * {@link OptionHelper} to provide access the compiler state.
+ *
+ * <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></p>
+ */
+public enum Option {
+    G("-g", "opt.g", STANDARD, BASIC),
+
+    G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-g:", "none");
+            return false;
+        }
+    },
+
+    G_CUSTOM("-g:",  "opt.g.lines.vars.source",
+            STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
+
+    XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
+
+    XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
+            EXTENDED,   BASIC, ANYOF, getXLintChoices()),
+
+    XDOCLINT("-Xdoclint", "opt.Xdoclint", EXTENDED, BASIC),
+
+    XDOCLINT_CUSTOM("-Xdoclint:", "opt.Xdoclint.subopts", "opt.Xdoclint.custom", EXTENDED, BASIC) {
+        @Override
+        public boolean matches(String option) {
+            return DocLint.isValidOption(
+                    option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
+        }
+
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            String prev = helper.get(XDOCLINT_CUSTOM);
+            String next = (prev == null) ? option : (prev + " " + option);
+            helper.put(XDOCLINT_CUSTOM.text, next);
+            return false;
+        }
+    },
+
+    // -nowarn is retained for command-line backward compatibility
+    NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:none", option);
+            return false;
+        }
+    },
+
+    VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
+
+    // -deprecation is retained for command-line backward compatibility
+    DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:deprecation", option);
+            return false;
+        }
+    },
+
+    CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
+
+    CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-classpath", arg);
+        }
+    },
+
+    SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
+
+    BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            helper.remove("-Xbootclasspath/p:");
+            helper.remove("-Xbootclasspath/a:");
+            return super.process(helper, option, arg);
+        }
+    },
+
+    XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
+
+    XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
+
+    XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            helper.remove("-Xbootclasspath/p:");
+            helper.remove("-Xbootclasspath/a:");
+            return super.process(helper, "-bootclasspath", arg);
+        }
+    },
+
+    EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
+
+    DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-extdirs", arg);
+        }
+    },
+
+    ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
+
+    DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-endorseddirs", arg);
+        }
+    },
+
+    PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC,  ONEOF, "none", "only"),
+
+    PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
+
+    PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
+
+    PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
+
+    D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
+
+    S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
+
+    H("-h", "opt.arg.directory", "opt.headerDest", STANDARD, FILEMANAGER),
+
+    IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
+
+    ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            return super.process(helper, option, operand);
+        }
+
+    },
+
+    SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            Source source = Source.lookup(operand);
+            if (source == null) {
+                helper.error("err.invalid.source", operand);
+                return true;
+            }
+            return super.process(helper, option, operand);
+        }
+    },
+
+    TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            Target target = Target.lookup(operand);
+            if (target == null) {
+                helper.error("err.invalid.target", operand);
+                return true;
+            }
+            return super.process(helper, option, operand);
+        }
+    },
+
+    PROFILE("-profile", "opt.arg.profile", "opt.profile", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            Profile profile = Profile.lookup(operand);
+            if (profile == null) {
+                helper.error("err.invalid.profile", operand);
+                return true;
+            }
+            return super.process(helper, option, operand);
+        }
+    },
+
+    VERSION("-version", "opt.version", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "version", ownName,  JavaCompiler.version());
+            return super.process(helper, option);
+        }
+    },
+
+    FULLVERSION("-fullversion", null, HIDDEN, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "fullVersion", ownName,  JavaCompiler.fullVersion());
+            return super.process(helper, option);
+        }
+    },
+
+    DIAGS("-XDdiags=", null, HIDDEN, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            option = option.substring(option.indexOf('=') + 1);
+            String diagsOption = option.contains("%") ?
+                "-XDdiagsFormat=" :
+                "-XDdiags=";
+            diagsOption += option;
+            if (XD.matches(diagsOption))
+                return XD.process(helper, diagsOption);
+            else
+                return false;
+        }
+    },
+
+    HELP("-help", "opt.help", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
+            for (Option o: getJavaCompilerOptions()) {
+                o.help(log, OptionKind.STANDARD);
+            }
+            log.printNewline();
+            return super.process(helper, option);
+        }
+    },
+
+    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
+        @Override
+        public boolean matches(String arg) {
+            return arg.startsWith("-A");
+        }
+
+        @Override
+        public boolean hasArg() {
+            return false;
+        }
+        // Mapping for processor options created in
+        // JavacProcessingEnvironment
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            int argLength = option.length();
+            if (argLength == 2) {
+                helper.error("err.empty.A.argument");
+                return true;
+            }
+            int sepIndex = option.indexOf('=');
+            String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
+            if (!JavacProcessingEnvironment.isValidOptionName(key)) {
+                helper.error("err.invalid.A.key", option);
+                return true;
+            }
+            return process(helper, option, option);
+        }
+    },
+
+    X("-X", "opt.X", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            for (Option o: getJavaCompilerOptions()) {
+                o.help(log, OptionKind.EXTENDED);
+            }
+            log.printNewline();
+            log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
+            return super.process(helper, option);
+        }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented by the launcher.
+    J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, true) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            throw new AssertionError
+                ("the -J flag should be caught by the launcher.");
+        }
+    },
+
+    MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Type.moreInfo = true;
+            return super.process(helper, option);
+        }
+    },
+
+    // treat warnings as errors
+    WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
+
+    // prompt after each error
+    // new Option("-prompt",                                        "opt.prompt"),
+    PROMPT("-prompt", null, HIDDEN, BASIC),
+
+    // dump stack on error
+    DOE("-doe", null, HIDDEN, BASIC),
+
+    // output source after type erasure
+    PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
+
+    // display warnings for generic unchecked operations
+    WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:unchecked", option);
+            return false;
+        }
+    },
+
+    XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
+
+    XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
+
+    XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            try {
+                Log log = helper.getLog();
+                // TODO: this file should be closed at the end of compilation
+                log.setWriters(new PrintWriter(new FileWriter(arg), true));
+            } catch (java.io.IOException e) {
+                helper.error("err.error.writing.file", arg, e);
+                return true;
+            }
+            return super.process(helper, option, arg);
+        }
+    },
+
+    XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
+
+    XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
+
+    XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
+
+    XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
+
+    XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
+
+    /* -O is a no-op, accepted for backward compatibility. */
+    O("-O", null, HIDDEN, BASIC),
+
+    /* -Xjcov produces tables to support the code coverage tool jcov. */
+    XJCOV("-Xjcov", null, HIDDEN, BASIC),
+
+    PLUGIN("-Xplugin:", "opt.arg.plugin", "opt.plugin", EXTENDED, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            String p = option.substring(option.indexOf(':') + 1);
+            String prev = helper.get(PLUGIN);
+            helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p.trim());
+            return false;
+        }
+    },
+
+    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.
+     */
+    XD("-XD", null, HIDDEN, BASIC) {
+        @Override
+        public boolean matches(String s) {
+            return s.startsWith(text);
+        }
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            option = option.substring(text.length());
+            int eq = option.indexOf('=');
+            String key = (eq < 0) ? option : option.substring(0, eq);
+            String value = (eq < 0) ? option : option.substring(eq+1);
+            helper.put(key, value);
+            return false;
+        }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented by the CommandLine class.
+    AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, true) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            throw new AssertionError("the @ flag should be caught by CommandLine.");
+        }
+    },
+
+    /*
+     * TODO: With apt, the matches method accepts anything if
+     * -XclassAsDecls is used; code elsewhere does the lookup to
+     * see if the class name is both legal and found.
+     *
+     * In apt, the process method adds the candidate class file
+     * name to a separate list.
+     */
+    SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
+        @Override
+        public boolean matches(String s) {
+            return s.endsWith(".java")  // Java source file
+                || SourceVersion.isName(s);   // Legal type name
+        }
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            if (option.endsWith(".java") ) {
+                File f = new File(option);
+                if (!f.exists()) {
+                    helper.error("err.file.not.found", f);
+                    return true;
+                }
+                if (!f.isFile()) {
+                    helper.error("err.file.not.file", f);
+                    return true;
+                }
+                helper.addFile(f);
+            } else {
+                helper.addClassName(option);
+            }
+            return false;
+        }
+    };
+
+    /** The kind of an Option. This is used by the -help and -X options. */
+    public enum OptionKind {
+        /** A standard option, documented by -help. */
+        STANDARD,
+        /** An extended option, documented by -X. */
+        EXTENDED,
+        /** A hidden option, not documented. */
+        HIDDEN,
+    }
+
+    /** The group for an Option. This determines the situations in which the
+     *  option is applicable. */
+    enum OptionGroup {
+        /** A basic option, available for use on the command line or via the
+         *  Compiler API. */
+        BASIC,
+        /** An option for javac's standard JavaFileManager. Other file managers
+         *  may or may not support these options. */
+        FILEMANAGER,
+        /** A command-line option that requests information, such as -help. */
+        INFO,
+        /** A command-line "option" representing a file or class name. */
+        OPERAND
+    }
+
+    /** The kind of choice for "choice" options. */
+    enum ChoiceKind {
+        /** The expected value is exactly one of the set of choices. */
+        ONEOF,
+        /** The expected value is one of more of the set of choices. */
+        ANYOF
+    }
+
+    public final String text;
+
+    final OptionKind kind;
+
+    final OptionGroup group;
+
+    /** Documentation key for arguments.
+     */
+    final String argsNameKey;
+
+    /** Documentation key for description.
+     */
+    final String descrKey;
+
+    /** Suffix option (-foo=bar or -foo:bar)
+     */
+    final boolean hasSuffix;
+
+    /** The kind of choices for this option, if any.
+     */
+    final ChoiceKind choiceKind;
+
+    /** The choices for this option, if any, and whether or not the choices
+     *  are hidden
+     */
+    final Map<String,Boolean> choices;
+
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group) {
+        this(text, null, descrKey, kind, group, null, null, false);
+    }
+
+    Option(String text, String argsNameKey, String descrKey,
+            OptionKind kind, OptionGroup group) {
+        this(text, argsNameKey, descrKey, kind, group, null, null, false);
+    }
+
+    Option(String text, String argsNameKey, String descrKey,
+            OptionKind kind, OptionGroup group, boolean doHasSuffix) {
+        this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
+    }
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, Map<String,Boolean> choices) {
+        this(text, null, descrKey, kind, group, choiceKind, choices, false);
+    }
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, String... choices) {
+        this(text, null, descrKey, kind, group, choiceKind,
+                createChoices(choices), false);
+    }
+    // where
+        private static Map<String,Boolean> createChoices(String... choices) {
+            Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
+            for (String c: choices)
+                map.put(c, false);
+            return map;
+        }
+
+    private Option(String text, String argsNameKey, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, Map<String,Boolean> choices,
+            boolean doHasSuffix) {
+        this.text = text;
+        this.argsNameKey = argsNameKey;
+        this.descrKey = descrKey;
+        this.kind = kind;
+        this.group = group;
+        this.choiceKind = choiceKind;
+        this.choices = choices;
+        char lastChar = text.charAt(text.length()-1);
+        this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public OptionKind getKind() {
+        return kind;
+    }
+
+    public boolean hasArg() {
+        return argsNameKey != null && !hasSuffix;
+    }
+
+    public boolean matches(String option) {
+        if (!hasSuffix)
+            return option.equals(text);
+
+        if (!option.startsWith(text))
+            return false;
+
+        if (choices != null) {
+            String arg = option.substring(text.length());
+            if (choiceKind == ChoiceKind.ONEOF)
+                return choices.keySet().contains(arg);
+            else {
+                for (String a: arg.split(",+")) {
+                    if (!choices.keySet().contains(a))
+                        return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    public boolean process(OptionHelper helper, String option, String arg) {
+        if (choices != null) {
+            if (choiceKind == ChoiceKind.ONEOF) {
+                // some clients like to see just one of option+choice set
+                for (String s: choices.keySet())
+                    helper.remove(option + s);
+                String opt = option + arg;
+                helper.put(opt, opt);
+                // some clients like to see option (without trailing ":")
+                // set to arg
+                String nm = option.substring(0, option.length() - 1);
+                helper.put(nm, arg);
+            } else {
+                // set option+word for each word in arg
+                for (String a: arg.split(",+")) {
+                    String opt = option + a;
+                    helper.put(opt, opt);
+                }
+            }
+        }
+        helper.put(option, arg);
+        return false;
+    }
+
+    public boolean process(OptionHelper helper, String option) {
+        if (hasSuffix)
+            return process(helper, text, option.substring(text.length()));
+        else
+            return process(helper, option, option);
+    }
+
+    void help(Log log, OptionKind kind) {
+        if (this.kind != kind)
+            return;
+
+        log.printRawLines(WriterKind.NOTICE,
+                String.format("  %-26s %s",
+                    helpSynopsis(log),
+                    log.localize(PrefixKind.JAVAC, descrKey)));
+
+    }
+
+    private String helpSynopsis(Log log) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(text);
+        if (argsNameKey == null) {
+            if (choices != null) {
+                String sep = "{";
+                for (Map.Entry<String,Boolean> e: choices.entrySet()) {
+                    if (!e.getValue()) {
+                        sb.append(sep);
+                        sb.append(e.getKey());
+                        sep = ",";
+                    }
+                }
+                sb.append("}");
+            }
+        } else {
+            if (!hasSuffix)
+                sb.append(" ");
+            sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
+
+        }
+
+        return sb.toString();
+    }
+
+    // For -XpkgInfo:value
+    public enum PkgInfo {
+        ALWAYS, LEGACY, NONEMPTY;
+        public static PkgInfo get(Options options) {
+            String v = options.get(XPKGINFO);
+            return (v == null
+                    ? PkgInfo.LEGACY
+                    : PkgInfo.valueOf(v.toUpperCase()));
+        }
+    }
+
+    private static Map<String,Boolean> getXLintChoices() {
+        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
+        choices.put("all", false);
+        for (Lint.LintCategory c : Lint.LintCategory.values())
+            choices.put(c.option, c.hidden);
+        for (Lint.LintCategory c : Lint.LintCategory.values())
+            choices.put("-" + c.option, c.hidden);
+        choices.put("none", false);
+        return choices;
+    }
+
+    static Set<Option> getJavaCompilerOptions() {
+        return EnumSet.allOf(Option.class);
+    }
+
+    public static Set<Option> getJavacFileManagerOptions() {
+        return getOptions(EnumSet.of(FILEMANAGER));
+    }
+
+    public static Set<Option> getJavacToolOptions() {
+        return getOptions(EnumSet.of(BASIC));
+    }
+
+    static Set<Option> getOptions(Set<OptionGroup> desired) {
+        Set<Option> options = EnumSet.noneOf(Option.class);
+        for (Option option : Option.values())
+            if (desired.contains(option.group))
+                options.add(option);
+        return Collections.unmodifiableSet(options);
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/main/OptionHelper.java b/src/share/classes/com/sun/tools/javac/main/OptionHelper.java
new file mode 100644
index 0000000..4e65230
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/main/OptionHelper.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2006, 2011, 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.main;
+
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Log.PrefixKind;
+import java.io.File;
+
+/**
+ * Helper object to be used by {@link Option#process}, providing access to
+ * the compilation environment.
+ *
+ * <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></p>
+ */
+
+public abstract class OptionHelper {
+
+    /** Get the current value of an option. */
+    public abstract String get(Option option);
+
+    /** Set the value of an option. */
+    public abstract void put(String name, String value);
+
+    /** Remove any prior value for an option. */
+    public abstract void remove(String name);
+
+    /** Get access to the Log for the compilation. */
+    public abstract Log getLog();
+
+    /** Get the name of the tool, such as "javac", to be used in info like -help. */
+    public abstract String getOwnName();
+
+    /** Report an error. */
+    abstract void error(String key, Object... args);
+
+    /** Record a file to be compiled. */
+    abstract void addFile(File f);
+
+    /** Record the name of a class for annotation processing. */
+    abstract void addClassName(String s);
+
+    /** An implementation of OptionHelper that mostly throws exceptions. */
+    public static class GrumpyHelper extends OptionHelper {
+        private final Log log;
+
+        public GrumpyHelper(Log log) {
+            this.log = log;
+        }
+
+        @Override
+        public Log getLog() {
+            return log;
+        }
+
+        @Override
+        public String getOwnName() {
+            throw new IllegalStateException();
+        }
+
+        @Override
+        public String get(Option option) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        public void put(String name, String value) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        public void remove(String name) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        void error(String key, Object... args) {
+            throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
+        }
+
+        @Override
+        public void addFile(File f) {
+            throw new IllegalArgumentException(f.getPath());
+        }
+
+        @Override
+        public void addClassName(String s) {
+            throw new IllegalArgumentException(s);
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/main/OptionName.java b/src/share/classes/com/sun/tools/javac/main/OptionName.java
deleted file mode 100644
index cfaff65..0000000
--- a/src/share/classes/com/sun/tools/javac/main/OptionName.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, 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.main;
-
-
-/**
- * TODO: describe com.sun.tools.javac.main.OptionName
- *
- * <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></p>
- */
-public enum OptionName {
-    G("-g"),
-    G_NONE("-g:none"),
-    G_CUSTOM("-g:"),
-    XLINT("-Xlint"),
-    XLINT_CUSTOM("-Xlint:"),
-    DIAGS("-XDdiags="),
-    NOWARN("-nowarn"),
-    VERBOSE("-verbose"),
-    DEPRECATION("-deprecation"),
-    CLASSPATH("-classpath"),
-    CP("-cp"),
-    SOURCEPATH("-sourcepath"),
-    BOOTCLASSPATH("-bootclasspath"),
-    XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:"),
-    XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:"),
-    XBOOTCLASSPATH("-Xbootclasspath:"),
-    EXTDIRS("-extdirs"),
-    DJAVA_EXT_DIRS("-Djava.ext.dirs="),
-    ENDORSEDDIRS("-endorseddirs"),
-    DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs="),
-    PROC("-proc:"),
-    PROCESSOR("-processor"),
-    PROCESSORPATH("-processorpath"),
-    D("-d"),
-    S("-s"),
-    IMPLICIT("-implicit:"),
-    ENCODING("-encoding"),
-    SOURCE("-source"),
-    TARGET("-target"),
-    VERSION("-version"),
-    FULLVERSION("-fullversion"),
-    HELP("-help"),
-    A("-A"),
-    X("-X"),
-    J("-J"),
-    MOREINFO("-moreinfo"),
-    WERROR("-Werror"),
-    COMPLEXINFERENCE("-complexinference"),
-    PROMPT("-prompt"),
-    DOE("-doe"),
-    PRINTSOURCE("-printsource"),
-    WARNUNCHECKED("-warnunchecked"),
-    XMAXERRS("-Xmaxerrs"),
-    XMAXWARNS("-Xmaxwarns"),
-    XSTDOUT("-Xstdout"),
-    XPKGINFO("-Xpkginfo:"),
-    XPRINT("-Xprint"),
-    XPRINTROUNDS("-XprintRounds"),
-    XPRINTPROCESSORINFO("-XprintProcessorInfo"),
-    XPREFER("-Xprefer:"),
-    O("-O"),
-    XJCOV("-Xjcov"),
-    XD("-XD"),
-    AT("@"),
-    SOURCEFILE("sourcefile");
-
-    public final String optionName;
-
-    OptionName(String optionName) {
-        this.optionName = optionName;
-    }
-
-    @Override
-    public String toString() {
-        return optionName;
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
deleted file mode 100644
index 6b4eb57..0000000
--- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
+++ /dev/null
@@ -1,643 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, 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.main;
-
-import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.main.JavacOption.HiddenOption;
-import com.sun.tools.javac.main.JavacOption.Option;
-import com.sun.tools.javac.main.JavacOption.XOption;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import javax.lang.model.SourceVersion;
-
-import static com.sun.tools.javac.main.OptionName.*;
-
-/**
- * TODO: describe com.sun.tools.javac.main.RecognizedOptions
- *
- * <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></p>
- */
-public class RecognizedOptions {
-
-    private RecognizedOptions() {}
-
-    public interface OptionHelper {
-
-        void setOut(PrintWriter out);
-
-        void error(String key, Object... args);
-
-        void printVersion();
-
-        void printFullVersion();
-
-        void printHelp();
-
-        void printXhelp();
-
-        void addFile(File f);
-
-        void addClassName(String s);
-
-    }
-
-    public static class GrumpyHelper implements OptionHelper {
-
-        public void setOut(PrintWriter out) {
-            throw new IllegalArgumentException();
-        }
-
-        public void error(String key, Object... args) {
-            throw new IllegalArgumentException(Main.getLocalizedString(key, args));
-        }
-
-        public void printVersion() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printFullVersion() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printHelp() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printXhelp() {
-            throw new IllegalArgumentException();
-        }
-
-        public void addFile(File f) {
-            throw new IllegalArgumentException(f.getPath());
-        }
-
-        public void addClassName(String s) {
-            throw new IllegalArgumentException(s);
-        }
-
-    }
-
-    static Set<OptionName> javacOptions = EnumSet.of(
-        G,
-        G_NONE,
-        G_CUSTOM,
-        XLINT,
-        XLINT_CUSTOM,
-        NOWARN,
-        VERBOSE,
-        DEPRECATION,
-        CLASSPATH,
-        CP,
-        SOURCEPATH,
-        BOOTCLASSPATH,
-        XBOOTCLASSPATH_PREPEND,
-        XBOOTCLASSPATH_APPEND,
-        XBOOTCLASSPATH,
-        EXTDIRS,
-        DJAVA_EXT_DIRS,
-        ENDORSEDDIRS,
-        DJAVA_ENDORSED_DIRS,
-        PROC,
-        PROCESSOR,
-        PROCESSORPATH,
-        D,
-        S,
-        IMPLICIT,
-        ENCODING,
-        SOURCE,
-        TARGET,
-        VERSION,
-        FULLVERSION,
-        DIAGS,
-        HELP,
-        A,
-        X,
-        J,
-        MOREINFO,
-        WERROR,
-        // COMPLEXINFERENCE,
-        PROMPT,
-        DOE,
-        PRINTSOURCE,
-        WARNUNCHECKED,
-        XMAXERRS,
-        XMAXWARNS,
-        XSTDOUT,
-        XPKGINFO,
-        XPRINT,
-        XPRINTROUNDS,
-        XPRINTPROCESSORINFO,
-        XPREFER,
-        O,
-        XJCOV,
-        XD,
-        AT,
-        SOURCEFILE);
-
-    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
-        CLASSPATH,
-        CP,
-        SOURCEPATH,
-        BOOTCLASSPATH,
-        XBOOTCLASSPATH_PREPEND,
-        XBOOTCLASSPATH_APPEND,
-        XBOOTCLASSPATH,
-        EXTDIRS,
-        DJAVA_EXT_DIRS,
-        ENDORSEDDIRS,
-        DJAVA_ENDORSED_DIRS,
-        PROCESSORPATH,
-        D,
-        S,
-        ENCODING,
-        SOURCE);
-
-    static Set<OptionName> javacToolOptions = EnumSet.of(
-        G,
-        G_NONE,
-        G_CUSTOM,
-        XLINT,
-        XLINT_CUSTOM,
-        NOWARN,
-        VERBOSE,
-        DEPRECATION,
-        PROC,
-        PROCESSOR,
-        IMPLICIT,
-        SOURCE,
-        TARGET,
-        // VERSION,
-        // FULLVERSION,
-        // HELP,
-        A,
-        // X,
-        // J,
-        MOREINFO,
-        WERROR,
-        // COMPLEXINFERENCE,
-        PROMPT,
-        DOE,
-        PRINTSOURCE,
-        WARNUNCHECKED,
-        XMAXERRS,
-        XMAXWARNS,
-        // XSTDOUT,
-        XPKGINFO,
-        XPRINT,
-        XPRINTROUNDS,
-        XPRINTPROCESSORINFO,
-        XPREFER,
-        O,
-        XJCOV,
-        XD);
-
-    static Option[] getJavaCompilerOptions(OptionHelper helper) {
-        return getOptions(helper, javacOptions);
-    }
-
-    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
-        return getOptions(helper, javacFileManagerOptions);
-    }
-
-    public static Option[] getJavacToolOptions(OptionHelper helper) {
-        return getOptions(helper, javacToolOptions);
-    }
-
-    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
-        ListBuffer<Option> options = new ListBuffer<Option>();
-        for (Option option : getAll(helper))
-            if (desired.contains(option.getName()))
-                options.append(option);
-        return options.toArray(new Option[options.length()]);
-    }
-
-    /**
-     * Get all the recognized options.
-     * @param helper an {@code OptionHelper} to help when processing options
-     * @return an array of options
-     */
-    public static Option[] getAll(final OptionHelper helper) {
-        return new Option[] {
-        new Option(G,                                           "opt.g"),
-        new Option(G_NONE,                                      "opt.g.none") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-g:", "none");
-                return false;
-            }
-        },
-
-        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
-                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
-
-        new XOption(XLINT,                                      "opt.Xlint"),
-        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
-                Option.ChoiceKind.ANYOF, getXLintChoices()),
-
-        // -nowarn is retained for command-line backward compatibility
-        new Option(NOWARN,                                      "opt.nowarn") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:none", option);
-                return false;
-            }
-        },
-
-        new Option(VERBOSE,                                     "opt.verbose"),
-
-        // -deprecation is retained for command-line backward compatibility
-        new Option(DEPRECATION,                                 "opt.deprecation") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:deprecation", option);
-                return false;
-            }
-        },
-
-        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
-        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-classpath", arg);
-            }
-        },
-        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
-        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process(options, option, arg);
-            }
-        },
-        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
-        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
-        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process(options, "-bootclasspath", arg);
-            }
-        },
-        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
-        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-extdirs", arg);
-            }
-        },
-        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
-        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-endorseddirs", arg);
-            }
-        },
-        new Option(PROC,                                 "opt.proc.none.only",
-                Option.ChoiceKind.ONEOF, "none", "only"),
-        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
-        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
-        new Option(D,                   "opt.arg.directory",    "opt.d"),
-        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
-        new Option(IMPLICIT,                                    "opt.implicit",
-                Option.ChoiceKind.ONEOF, "none", "class"),
-        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
-        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
-            @Override
-            public boolean process(Options options, String option, String operand) {
-                Source source = Source.lookup(operand);
-                if (source == null) {
-                    helper.error("err.invalid.source", operand);
-                    return true;
-                }
-                return super.process(options, option, operand);
-            }
-        },
-        new Option(TARGET,              "opt.arg.release",      "opt.target") {
-            @Override
-            public boolean process(Options options, String option, String operand) {
-                Target target = Target.lookup(operand);
-                if (target == null) {
-                    helper.error("err.invalid.target", operand);
-                    return true;
-                }
-                return super.process(options, option, operand);
-            }
-        },
-        new Option(VERSION,                                     "opt.version") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printVersion();
-                return super.process(options, option);
-            }
-        },
-        new HiddenOption(FULLVERSION) {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printFullVersion();
-                return super.process(options, option);
-            }
-        },
-        new HiddenOption(DIAGS) {
-            @Override
-            public boolean process(Options options, String option) {
-                Option xd = getOptions(helper, EnumSet.of(XD))[0];
-                option = option.substring(option.indexOf('=') + 1);
-                String diagsOption = option.contains("%") ?
-                    "-XDdiagsFormat=" :
-                    "-XDdiags=";
-                diagsOption += option;
-                if (xd.matches(diagsOption))
-                    return xd.process(options, diagsOption);
-                else
-                    return false;
-            }
-        },
-        new Option(HELP,                                        "opt.help") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printHelp();
-                return super.process(options, option);
-            }
-        },
-        new Option(A,                "opt.arg.key.equals.value","opt.A") {
-            @Override
-            String helpSynopsis() {
-                hasSuffix = true;
-                return super.helpSynopsis();
-            }
-
-            @Override
-            public boolean matches(String arg) {
-                return arg.startsWith("-A");
-            }
-
-            @Override
-            public boolean hasArg() {
-                return false;
-            }
-            // Mapping for processor options created in
-            // JavacProcessingEnvironment
-            @Override
-            public boolean process(Options options, String option) {
-                int argLength = option.length();
-                if (argLength == 2) {
-                    helper.error("err.empty.A.argument");
-                    return true;
-                }
-                int sepIndex = option.indexOf('=');
-                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
-                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
-                    helper.error("err.invalid.A.key", option);
-                    return true;
-                }
-                return process(options, option, option);
-            }
-        },
-        new Option(X,                                           "opt.X") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printXhelp();
-                return super.process(options, option);
-            }
-        },
-
-        // This option exists only for the purpose of documenting itself.
-        // It's actually implemented by the launcher.
-        new Option(J,                   "opt.arg.flag",         "opt.J") {
-            @Override
-            String helpSynopsis() {
-                hasSuffix = true;
-                return super.helpSynopsis();
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                throw new AssertionError
-                    ("the -J flag should be caught by the launcher.");
-            }
-        },
-
-        // stop after parsing and attributing.
-        // new HiddenOption("-attrparseonly"),
-
-        // new Option("-moreinfo",                                      "opt.moreinfo") {
-        new HiddenOption(MOREINFO) {
-            @Override
-            public boolean process(Options options, String option) {
-                Type.moreInfo = true;
-                return super.process(options, option);
-            }
-        },
-
-        // treat warnings as errors
-        new Option(WERROR,                                      "opt.Werror"),
-
-        // use complex inference from context in the position of a method call argument
-        new HiddenOption(COMPLEXINFERENCE),
-
-        // generare source stubs
-        // new HiddenOption("-stubs"),
-
-        // relax some constraints to allow compiling from stubs
-        // new HiddenOption("-relax"),
-
-        // output source after translating away inner classes
-        // new Option("-printflat",                             "opt.printflat"),
-        // new HiddenOption("-printflat"),
-
-        // display scope search details
-        // new Option("-printsearch",                           "opt.printsearch"),
-        // new HiddenOption("-printsearch"),
-
-        // prompt after each error
-        // new Option("-prompt",                                        "opt.prompt"),
-        new HiddenOption(PROMPT),
-
-        // dump stack on error
-        new HiddenOption(DOE),
-
-        // output source after type erasure
-        // new Option("-s",                                     "opt.s"),
-        new HiddenOption(PRINTSOURCE),
-
-        // output shrouded class files
-        // new Option("-scramble",                              "opt.scramble"),
-        // new Option("-scrambleall",                           "opt.scrambleall"),
-
-        // display warnings for generic unchecked operations
-        new HiddenOption(WARNUNCHECKED) {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:unchecked", option);
-                return false;
-            }
-        },
-
-        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
-        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
-        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                try {
-                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
-                } catch (java.io.IOException e) {
-                    helper.error("err.error.writing.file", arg, e);
-                    return true;
-                }
-                return super.process(options, option, arg);
-            }
-        },
-
-        new XOption(XPRINT,                                     "opt.print"),
-
-        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
-
-        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
-
-        new XOption(XPREFER,                                    "opt.prefer",
-                Option.ChoiceKind.ONEOF, "source", "newer"),
-
-        new XOption(XPKGINFO,                                   "opt.pkginfo",
-                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
-
-        /* -O is a no-op, accepted for backward compatibility. */
-        new HiddenOption(O),
-
-        /* -Xjcov produces tables to support the code coverage tool jcov. */
-        new HiddenOption(XJCOV),
-
-        /* 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.
-         */
-        new HiddenOption(XD) {
-            String s;
-            @Override
-            public boolean matches(String s) {
-                this.s = s;
-                return s.startsWith(name.optionName);
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                s = s.substring(name.optionName.length());
-                int eq = s.indexOf('=');
-                String key = (eq < 0) ? s : s.substring(0, eq);
-                String value = (eq < 0) ? s : s.substring(eq+1);
-                options.put(key, value);
-                return false;
-            }
-        },
-
-        // This option exists only for the purpose of documenting itself.
-        // It's actually implemented by the CommandLine class.
-        new Option(AT,                   "opt.arg.file",         "opt.AT") {
-            @Override
-            String helpSynopsis() {
-                hasSuffix = true;
-                return super.helpSynopsis();
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                throw new AssertionError
-                    ("the @ flag should be caught by CommandLine.");
-            }
-        },
-
-        /*
-         * TODO: With apt, the matches method accepts anything if
-         * -XclassAsDecls is used; code elsewhere does the lookup to
-         * see if the class name is both legal and found.
-         *
-         * In apt, the process method adds the candidate class file
-         * name to a separate list.
-         */
-        new HiddenOption(SOURCEFILE) {
-            String s;
-            @Override
-            public boolean matches(String s) {
-                this.s = s;
-                return s.endsWith(".java")  // Java source file
-                    || SourceVersion.isName(s);   // Legal type name
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                if (s.endsWith(".java") ) {
-                    File f = new File(s);
-                    if (!f.exists()) {
-                        helper.error("err.file.not.found", f);
-                        return true;
-                    }
-                    if (!f.isFile()) {
-                        helper.error("err.file.not.file", f);
-                        return true;
-                    }
-                    helper.addFile(f);
-                }
-                else
-                    helper.addClassName(s);
-                return false;
-            }
-        },
-    };
-    }
-
-    public enum PkgInfo {
-        ALWAYS, LEGACY, NONEMPTY;
-        public static PkgInfo get(Options options) {
-            String v = options.get(XPKGINFO);
-            return (v == null
-                    ? PkgInfo.LEGACY
-                    : PkgInfo.valueOf(v.toUpperCase()));
-        }
-    }
-
-    private static Map<String,Boolean> getXLintChoices() {
-        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
-        choices.put("all", false);
-        for (Lint.LintCategory c : Lint.LintCategory.values())
-            choices.put(c.option, c.hidden);
-        for (Lint.LintCategory c : Lint.LintCategory.values())
-            choices.put("-" + c.option, c.hidden);
-        choices.put("none", false);
-        return choices;
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java
index bf1ec29..e44f673 100644
--- a/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java
+++ b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -25,9 +25,8 @@
 
 package com.sun.tools.javac.model;
 
-import com.sun.tools.javac.util.*;
-import java.io.ObjectInputStream;
 import java.io.IOException;
+import java.io.ObjectInputStream;
 import java.lang.annotation.*;
 import java.lang.reflect.Array;
 import java.lang.reflect.Method;
@@ -35,12 +34,14 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 import sun.reflect.annotation.*;
 
-import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.MirroredTypeException;
 import javax.lang.model.type.MirroredTypesException;
+import javax.lang.model.type.TypeMirror;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.ArrayType;
+import com.sun.tools.javac.util.*;
 
 
 /**
@@ -177,7 +178,7 @@ public class AnnotationProxyMaker {
         }
 
         public void visitClass(Attribute.Class c) {
-            value = new MirroredTypeExceptionProxy(c.type);
+            value = new MirroredTypeExceptionProxy(c.classType);
         }
 
         public void visitArray(Attribute.Array a) {
@@ -187,7 +188,7 @@ public class AnnotationProxyMaker {
                 // Construct a proxy for a MirroredTypesException
                 ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>();
                 for (Attribute value : a.values) {
-                    Type elem = ((Attribute.Class) value).type;
+                    Type elem = ((Attribute.Class) value).classType;
                     elems.append(elem);
                 }
                 value = new MirroredTypesExceptionProxy(elems.toList());
@@ -272,7 +273,7 @@ public class AnnotationProxyMaker {
 
     /**
      * ExceptionProxy for MirroredTypeException.
-     * The toString, hashCode, and equals methods foward to the underlying
+     * The toString, hashCode, and equals methods forward to the underlying
      * type.
      */
     private static final class MirroredTypeExceptionProxy extends ExceptionProxy {
diff --git a/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java b/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java
new file mode 100644
index 0000000..2f70954
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/model/JavacAnnoConstructs.java
@@ -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.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Inherited;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.TypeVariableSymbol;
+import com.sun.tools.javac.code.TargetType;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.AnnotatedType;
+import com.sun.tools.javac.util.ListBuffer;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import com.sun.tools.javac.util.List;
+
+/**
+ * Utility methods for operating on annotated constructs.
+ *
+ * <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></p>
+ */
+public class JavacAnnoConstructs {
+
+    // <editor-fold defaultstate="collapsed" desc="Symbols">
+
+    /**
+     * An internal-use utility that creates a runtime view of an
+     * annotation. This is the implementation of
+     * Element.getAnnotation(Class).
+     */
+    public static <A extends Annotation> A getAnnotation(Symbol annotated,
+                                                         Class<A> annoType) {
+        if (!annoType.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type: "
+                                               + annoType);
+        Attribute.Compound c;
+        if (annotated.kind == Kinds.TYP &&
+                annotated instanceof ClassSymbol) {
+            c = getAttributeOnClass((ClassSymbol)annotated, annoType);
+        } else if (annotated.kind == Kinds.TYP &&
+                   annotated instanceof TypeVariableSymbol) {
+            c = getAttributeOnTypeVariable((TypeVariableSymbol)annotated, annoType);
+        } else {
+            c = getAttribute(annotated, annoType);
+        }
+        return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType);
+    }
+
+    // Helper to getAnnotation[s]
+    private static <A extends Annotation> Attribute.Compound getAttribute(Symbol annotated,
+                                                                          Class<A> annoType) {
+        String name = annoType.getName();
+
+        for (Attribute.Compound anno : annotated.getRawAttributes()) {
+            if (name.equals(anno.type.tsym.flatName().toString()))
+                return anno;
+        }
+
+        return null;
+    }
+
+    // Helper to getAnnotation[s]
+    private static <A extends Annotation> Attribute.Compound
+            getAttributeOnTypeVariable(TypeVariableSymbol annotated, Class<A> annoType) {
+        String name = annoType.getName();
+
+        // Declaration annotations on type variables are stored in type attributes
+        // on the owner of the TypeVariableSymbol
+        List<Attribute.Compound> res = List.nil();
+        List<Attribute.TypeCompound> candidates = annotated.owner.getRawTypeAttributes();
+        for (Attribute.TypeCompound anno : candidates)
+            if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER ||
+                    anno.position.type == TargetType.METHOD_TYPE_PARAMETER)
+                if (name.equals(anno.type.tsym.flatName().toString()))
+                    return anno;
+
+        return null;
+    }
+
+    // Helper to getAnnotation[s]
+    private static <A extends Annotation> Attribute.Compound getAttributeOnClass(ClassSymbol annotated,
+                                                                Class<A> annoType) {
+        boolean inherited = annoType.isAnnotationPresent(Inherited.class);
+        Attribute.Compound result = null;
+        while (annotated.name != annotated.name.table.names.java_lang_Object) {
+            result = getAttribute(annotated, annoType);
+            if (result != null || !inherited)
+                break;
+            Type sup = annotated.getSuperclass();
+            if (!sup.hasTag(CLASS) || sup.isErroneous())
+                break;
+            annotated = (ClassSymbol) sup.tsym;
+        }
+        return result;
+    }
+
+    /**
+     * An internal-use utility that creates a runtime view of
+     * annotations. This is the implementation of
+     * Element.getAnnotations(Class).
+     */
+    public static <A extends Annotation> A[] getAnnotations(Symbol annotated,
+                                                            Class<A> annoType) {
+        if (!annoType.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type: "
+                                               + annoType);
+        // If annoType does not declare a container this is equivalent to wrapping
+        // getAnnotation(...) in an array.
+        Class <? extends Annotation> containerType = getContainer(annoType);
+        if (containerType == null) {
+            A res = getAnnotation(annotated, annoType);
+            int size;
+            if (res == null) {
+                size = 0;
+            } else {
+                size = 1;
+            }
+            @SuppressWarnings("unchecked") // annoType is the Class for A
+            A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);
+            if (res != null)
+                arr[0] = res;
+            return arr;
+        }
+
+        // So we have a containing type
+        String name = annoType.getName();
+        String annoTypeName = annoType.getSimpleName();
+        String containerTypeName = containerType.getSimpleName();
+        int directIndex = -1, containerIndex = -1;
+        Attribute.Compound direct = null, container = null;
+        Attribute.Compound[] rawAttributes = annotated.getRawAttributes().toArray(new Attribute.Compound[0]);
+
+        // Find directly present annotations
+        for (int i = 0; i < rawAttributes.length; i++) {
+            if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
+                directIndex = i;
+                direct = rawAttributes[i];
+            } else if(containerTypeName != null &&
+                      containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
+                containerIndex = i;
+                container = rawAttributes[i];
+            }
+        }
+
+        // Deal with inherited annotations
+        if (annotated.kind == Kinds.TYP &&
+                (annotated instanceof ClassSymbol)) {
+            ClassSymbol s = (ClassSymbol)annotated;
+            if (direct == null && container == null) {
+                direct = getAttributeOnClass(s, annoType);
+                container = getAttributeOnClass(s, containerType);
+
+                // both are inherited and found, put container last
+                if (direct != null && container != null) {
+                    directIndex = 0;
+                    containerIndex = 1;
+                } else if (direct != null) {
+                    directIndex = 0;
+                } else {
+                    containerIndex = 0;
+                }
+            } else if (direct == null) {
+                direct = getAttributeOnClass(s, annoType);
+                if (direct != null)
+                    directIndex = containerIndex + 1;
+            } else if (container == null) {
+                container = getAttributeOnClass(s, containerType);
+                if (container != null)
+                    containerIndex = directIndex + 1;
+            }
+        }
+
+        // Pack them in an array
+        Attribute[] contained0 = new Attribute[0];
+        if (container != null)
+            contained0 = unpackAttributes(container);
+        ListBuffer<Attribute.Compound> compounds = ListBuffer.lb();
+        for (Attribute a : contained0)
+            if (a instanceof Attribute.Compound)
+                compounds = compounds.append((Attribute.Compound)a);
+        Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]);
+
+        int size = (direct == null ? 0 : 1) + contained.length;
+        @SuppressWarnings("unchecked") // annoType is the Class for A
+        A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);
+
+        // if direct && container, which is first?
+        int insert = -1;
+        int length = arr.length;
+        if (directIndex >= 0 && containerIndex >= 0) {
+            if (directIndex < containerIndex) {
+                arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+                insert = 1;
+            } else {
+                arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+                insert = 0;
+                length--;
+            }
+        } else if (directIndex >= 0) {
+            arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+            return arr;
+        } else {
+            // Only container
+            insert = 0;
+        }
+
+        for (int i = 0; i + insert < length; i++)
+            arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType);
+
+        return arr;
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Types">
+
+    /**
+     * An internal-use utility that creates a runtime view of an
+     * annotation. This is the implementation of
+     * TypeMirror.getAnnotation(Class).
+     */
+    public static <A extends Annotation> A getAnnotation(AnnotatedType annotated, Class<A> annoType) {
+        if (!annoType.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type: "
+                                               + annoType);
+        Attribute.Compound c = getAttribute(annotated, annoType);
+        return c == null ? null : AnnotationProxyMaker.generateAnnotation(c, annoType);
+    }
+
+    // Helper to getAnnotation[s]
+    private static <A extends Annotation> Attribute.Compound getAttribute(Type annotated,
+                                                                          Class<A> annoType) {
+        String name = annoType.getName();
+
+        for (Attribute.Compound anno : annotated.getAnnotationMirrors()) {
+            if (name.equals(anno.type.tsym.flatName().toString()))
+                return anno;
+        }
+
+        return null;
+    }
+
+    /**
+     * An internal-use utility that creates a runtime view of
+     * annotations. This is the implementation of
+     * TypeMirror.getAnnotationsByType(Class).
+     */
+    public static <A extends Annotation> A[] getAnnotationsByType(AnnotatedType annotated, Class<A> annoType) {
+        if (!annoType.isAnnotation())
+            throw new IllegalArgumentException("Not an annotation type: "
+                                               + annoType);
+        // If annoType does not declare a container this is equivalent to wrapping
+        // getAnnotation(...) in an array.
+        Class <? extends Annotation> containerType = getContainer(annoType);
+        if (containerType == null) {
+            A res = getAnnotation(annotated, annoType);
+            int size;
+            if (res == null) {
+                size = 0;
+            } else {
+                size = 1;
+            }
+            @SuppressWarnings("unchecked") // annoType is the Class for A
+            A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);
+            if (res != null)
+                arr[0] = res;
+            return arr;
+        }
+
+        // So we have a containing type
+        String name = annoType.getName();
+        String annoTypeName = annoType.getSimpleName();
+        String containerTypeName = containerType.getSimpleName();
+        int directIndex = -1, containerIndex = -1;
+        Attribute.Compound direct = null, container = null;
+        Attribute.Compound[] rawAttributes = annotated.getAnnotationMirrors().toArray(new Attribute.Compound[0]);
+
+        // Find directly present annotations
+        for (int i = 0; i < rawAttributes.length; i++) {
+            if (annoTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
+                directIndex = i;
+                direct = rawAttributes[i];
+            } else if(containerTypeName != null &&
+                      containerTypeName.equals(rawAttributes[i].type.tsym.flatName().toString())) {
+                containerIndex = i;
+                container = rawAttributes[i];
+            }
+        }
+
+        // Pack them in an array
+        Attribute[] contained0 = new Attribute[0];
+        if (container != null)
+            contained0 = unpackAttributes(container);
+        ListBuffer<Attribute.Compound> compounds = ListBuffer.lb();
+        for (Attribute a : contained0) {
+            if (a instanceof Attribute.Compound)
+                compounds = compounds.append((Attribute.Compound)a);
+        }
+        Attribute.Compound[] contained = compounds.toArray(new Attribute.Compound[0]);
+
+        int size = (direct == null ? 0 : 1) + contained.length;
+        @SuppressWarnings("unchecked") // annoType is the Class for A
+        A[] arr = (A[])java.lang.reflect.Array.newInstance(annoType, size);
+
+        // if direct && container, which is first?
+        int insert = -1;
+        int length = arr.length;
+        if (directIndex >= 0 && containerIndex >= 0) {
+            if (directIndex < containerIndex) {
+                arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+                insert = 1;
+            } else {
+                arr[arr.length - 1] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+                insert = 0;
+                length--;
+            }
+        } else if (directIndex >= 0) {
+            arr[0] = AnnotationProxyMaker.generateAnnotation(direct, annoType);
+            return arr;
+        } else {
+            // Only container
+            insert = 0;
+        }
+
+        for (int i = 0; i + insert < length; i++)
+            arr[insert + i] = AnnotationProxyMaker.generateAnnotation(contained[i], annoType);
+
+        return arr;
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Container support">
+
+    // Needed to unpack the runtime view of containing annotations
+    private static final Class<? extends Annotation> REPEATABLE_CLASS = initRepeatable();
+    private static final Method VALUE_ELEMENT_METHOD = initValueElementMethod();
+
+    private static Class<? extends Annotation> initRepeatable() {
+        try {
+            // Repeatable will not be available when bootstrapping on
+            // JDK 7 so use a reflective lookup instead of a class
+            // literal for Repeatable.class.
+            return Class.forName("java.lang.annotation.Repeatable").asSubclass(Annotation.class);
+        } catch (ClassNotFoundException e) {
+            return null;
+        } catch (SecurityException e) {
+            return null;
+        }
+    }
+
+    private static Method initValueElementMethod() {
+        if (REPEATABLE_CLASS == null)
+            return null;
+
+        Method m = null;
+        try {
+            m = REPEATABLE_CLASS.getMethod("value");
+            if (m != null)
+                m.setAccessible(true);
+            return m;
+        } catch (NoSuchMethodException e) {
+            return null;
+        }
+    }
+
+    // Helper to getAnnotations
+    private static Class<? extends Annotation> getContainer(Class<? extends Annotation> annoType) {
+        // Since we can not refer to java.lang.annotation.Repeatable until we are
+        // bootstrapping with java 8 we need to get the Repeatable annotation using
+        // reflective invocations instead of just using its type and element method.
+        if (REPEATABLE_CLASS != null &&
+            VALUE_ELEMENT_METHOD != null) {
+            // Get the Repeatable instance on the annotations declaration
+            Annotation repeatable = (Annotation)annoType.getAnnotation(REPEATABLE_CLASS);
+            if (repeatable != null) {
+                try {
+                    // Get the value element, it should be a class
+                    // indicating the containing annotation type
+                    @SuppressWarnings("unchecked")
+                    Class<? extends Annotation> containerType = (Class)VALUE_ELEMENT_METHOD.invoke(repeatable);
+                    if (containerType == null)
+                        return null;
+
+                    return containerType;
+                } catch (ClassCastException e) {
+                    return null;
+                } catch (IllegalAccessException e) {
+                    return null;
+                } catch (InvocationTargetException e ) {
+                    return null;
+                }
+            }
+        }
+        return null;
+    }
+
+    // Helper to getAnnotations
+    private static Attribute[] unpackAttributes(Attribute.Compound container) {
+        // We now have an instance of the container,
+        // unpack it returning an instance of the
+        // contained type or null
+        return ((Attribute.Array)container.member(container.type.tsym.name.table.names.value)).values;
+    }
+
+    // </editor-fold>
+}
diff --git a/src/share/classes/com/sun/tools/javac/model/JavacElements.java b/src/share/classes/com/sun/tools/javac/model/JavacElements.java
index 77c6e86..b602a7c 100644
--- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java
+++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -25,17 +25,17 @@
 
 package com.sun.tools.javac.model;
 
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Inherited;
 import java.util.Map;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.util.Elements;
 import javax.tools.JavaFileObject;
+import static javax.lang.model.util.ElementFilter.methodsIn;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.TypeTags;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.comp.Env;
@@ -47,8 +47,8 @@ import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Name;
-
-import static javax.lang.model.util.ElementFilter.methodsIn;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
  * Utility methods for operating on program elements.
@@ -95,43 +95,6 @@ public class JavacElements implements Elements {
         loader = LazyTreeLoader.instance(context);
     }
 
-
-    /**
-     * An internal-use utility that creates a reified annotation.
-     */
-    public static <A extends Annotation> A getAnnotation(Symbol annotated,
-                                                         Class<A> annoType) {
-        if (!annoType.isAnnotation())
-            throw new IllegalArgumentException("Not an annotation type: "
-                                               + annoType);
-        String name = annoType.getName();
-        for (Attribute.Compound anno : annotated.getAnnotationMirrors())
-            if (name.equals(anno.type.tsym.flatName().toString()))
-                return AnnotationProxyMaker.generateAnnotation(anno, annoType);
-        return null;
-    }
-
-    /**
-     * An internal-use utility that creates a reified annotation.
-     * This overloaded version take annotation inheritance into account.
-     */
-    public static <A extends Annotation> A getAnnotation(ClassSymbol annotated,
-                                                         Class<A> annoType) {
-        boolean inherited = annoType.isAnnotationPresent(Inherited.class);
-        A result = null;
-        while (annotated.name != annotated.name.table.names.java_lang_Object) {
-            result = getAnnotation((Symbol)annotated, annoType);
-            if (result != null || !inherited)
-                break;
-            Type sup = annotated.getSuperclass();
-            if (sup.tag != TypeTags.CLASS || sup.isErroneous())
-                break;
-            annotated = (ClassSymbol) sup.tsym;
-        }
-        return result;
-    }
-
-
     public PackageSymbol getPackageElement(CharSequence name) {
         String strName = name.toString();
         if (strName.equals(""))
@@ -271,8 +234,10 @@ public class JavacElements implements Elements {
         tree.accept(vis);
         if (vis.result == null)
             return null;
+
+        List<Attribute.Compound> annos = sym.getRawAttributes();
         return matchAnnoToTree(cast(Attribute.Compound.class, findme),
-                               sym.getAnnotationMirrors(),
+                               annos,
                                vis.result);
     }
 
@@ -324,7 +289,7 @@ public class JavacElements implements Elements {
                 }
             }
             public void visitArray(Attribute.Array array) {
-                if (tree.getTag() == JCTree.NEWARRAY &&
+                if (tree.hasTag(NEWARRAY) &&
                         types.elemtype(array.type).tsym == findme.type.tsym) {
                     List<JCExpression> elems = ((JCNewArray) tree).elems;
                     for (Attribute value : array.values) {
@@ -363,7 +328,7 @@ public class JavacElements implements Elements {
                     scan(t.args);
             }
             public void visitAssign(JCAssign t) {
-                if (t.lhs.getTag() == JCTree.IDENT) {
+                if (t.lhs.hasTag(IDENT)) {
                     JCIdent ident = (JCIdent) t.lhs;
                     if (ident.sym == sym)
                         result = t.rhs;
@@ -396,7 +361,7 @@ public class JavacElements implements Elements {
         JCCompilationUnit toplevel = treeTop.snd;
         if (toplevel.docComments == null)
             return null;
-        return toplevel.docComments.get(tree);
+        return toplevel.docComments.getCommentText(tree);
     }
 
     public PackageElement getPackageOf(Element e) {
@@ -457,8 +422,7 @@ public class JavacElements implements Elements {
                         && (overrider.sym.flags() & Flags.SYNTHETIC) == 0)
                     {
                         if (overrider.sym.getKind() == ElementKind.METHOD
-                        && (overrides((ExecutableElement)overrider.sym, (ExecutableElement)e.sym, (TypeElement)type.asElement())
-                        || isAbstract && types.isSubSignature(types.memberType(scope.owner.type, e.sym), types.memberType(scope.owner.type, overrider.sym)))) {
+                        && (overrides((ExecutableElement)overrider.sym, (ExecutableElement)e.sym, (TypeElement)type.asElement()))) {
                             continue members;
                         }
                     }
@@ -480,18 +444,20 @@ public class JavacElements implements Elements {
      * @param e  the element being examined
      * @return all annotations of the element
      */
+    @Override
     public List<Attribute.Compound> getAllAnnotationMirrors(Element e) {
         Symbol sym = cast(Symbol.class, e);
         List<Attribute.Compound> annos = sym.getAnnotationMirrors();
         while (sym.getKind() == ElementKind.CLASS) {
             Type sup = ((ClassSymbol) sym).getSuperclass();
-            if (sup.tag != TypeTags.CLASS || sup.isErroneous() ||
+            if (!sup.hasTag(CLASS) || sup.isErroneous() ||
                     sup.tsym == syms.objectType.tsym) {
                 break;
             }
             sym = sup.tsym;
             List<Attribute.Compound> oldAnnos = annos;
-            for (Attribute.Compound anno : sym.getAnnotationMirrors()) {
+            List<Attribute.Compound> newAnnos = sym.getAnnotationMirrors();
+            for (Attribute.Compound anno : newAnnos) {
                 if (isInherited(anno.type) &&
                         !containsAnnoOfType(oldAnnos, anno.type)) {
                     annos = annos.prepend(anno);
@@ -505,11 +471,7 @@ public class JavacElements implements Elements {
      * Tests whether an annotation type is @Inherited.
      */
     private boolean isInherited(Type annotype) {
-        for (Attribute.Compound anno : annotype.tsym.getAnnotationMirrors()) {
-            if (anno.type.tsym == syms.inheritedType.tsym)
-                return true;
-        }
-        return false;
+        return annotype.tsym.attribute(syms.inheritedType.tsym) != null;
     }
 
     /**
@@ -605,6 +567,16 @@ public class JavacElements implements Elements {
         return names.fromString(cs.toString());
     }
 
+    @Override
+    public boolean isFunctionalInterface(TypeElement element) {
+        if (element.getKind() != ElementKind.INTERFACE)
+            return false;
+        else {
+            TypeSymbol tsym = cast(TypeSymbol.class, element);
+            return types.isFunctionalInterface(tsym);
+        }
+    }
+
     /**
      * Returns the tree node and compilation unit corresponding to this
      * element, or null if they can't be found.
diff --git a/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
index 0f9db58..1786080 100644
--- a/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
+++ b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -25,13 +25,18 @@
 
 package com.sun.tools.javac.model;
 
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.EnumSet;
+
 import javax.lang.model.element.*;
 import javax.lang.model.type.*;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.util.*;
 
 /**
@@ -67,6 +72,8 @@ public class JavacTypes implements javax.lang.model.util.Types {
      */
     public void setContext(Context context) {
         context.put(JavacTypes.class, this);
+        //Need ensure ClassReader is initialized before Symtab:
+        ClassReader.instance(context);
         syms = Symtab.instance(context);
         types = Types.instance(context);
     }
@@ -74,6 +81,7 @@ public class JavacTypes implements javax.lang.model.util.Types {
     public Element asElement(TypeMirror t) {
         switch (t.getKind()) {
             case DECLARED:
+            case INTERSECTION:
             case ERROR:
             case TYPEVAR:
                 Type type = cast(Type.class, t);
@@ -134,7 +142,7 @@ public class JavacTypes implements javax.lang.model.util.Types {
         Type unboxed = types.unboxedType((Type) t);
         if (! unboxed.isPrimitive())    // only true primitives, not void
             throw new IllegalArgumentException(t.toString());
-        return unboxed;
+        return (PrimitiveType)unboxed;
     }
 
     public TypeMirror capture(TypeMirror t) {
@@ -301,4 +309,31 @@ public class JavacTypes implements javax.lang.model.util.Types {
             throw new IllegalArgumentException(o.toString());
         return clazz.cast(o);
     }
+
+    public Set<MethodSymbol> getOverriddenMethods(Element elem) {
+        if (elem.getKind() != ElementKind.METHOD
+                || elem.getModifiers().contains(Modifier.STATIC)
+                || elem.getModifiers().contains(Modifier.PRIVATE))
+            return Collections.emptySet();
+
+        if (!(elem instanceof MethodSymbol))
+            throw new IllegalArgumentException();
+
+        MethodSymbol m = (MethodSymbol) elem;
+        ClassSymbol origin = (ClassSymbol) m.owner;
+
+        Set<MethodSymbol> results = new LinkedHashSet<MethodSymbol>();
+        for (Type t : types.closure(origin.type)) {
+            if (t != origin.type) {
+                ClassSymbol c = (ClassSymbol) t.tsym;
+                for (Scope.Entry e = c.members().lookup(m.name); e.scope != null; e = e.next()) {
+                    if (e.sym.kind == Kinds.MTH && m.overrides(e.sym, origin, types, true)) {
+                        results.add((MethodSymbol) e.sym);
+                    }
+                }
+            }
+        }
+
+        return results;
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
index bb0c620..e5701ce 100644
--- a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
+++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -25,9 +25,7 @@
 
 package com.sun.tools.javac.nio;
 
-
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -60,13 +58,12 @@ import javax.tools.StandardLocation;
 import static java.nio.file.FileVisitOption.*;
 import static javax.tools.StandardLocation.*;
 
-import com.sun.tools.javac.file.Paths;
 import com.sun.tools.javac.util.BaseFileManager;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 
 // NOTE the imports carefully for this compilation unit.
@@ -125,9 +122,8 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
      * Set the context for JavacPathFileManager.
      */
     @Override
-    protected void setContext(Context context) {
+    public void setContext(Context context) {
         super.setContext(context);
-        searchPaths = Paths.instance(context);
     }
 
     @Override
@@ -173,7 +169,7 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
 
     @Override
     public boolean isDefaultBootClassPath() {
-        return searchPaths.isDefaultBootClassPath();
+        return locations.isDefaultBootClassPath();
     }
 
     // <editor-fold defaultstate="collapsed" desc="Location handling">
@@ -231,13 +227,13 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
         if (locn instanceof StandardLocation) {
             switch ((StandardLocation) locn) {
                 case CLASS_PATH:
-                    files = searchPaths.userClassPath();
+                    files = locations.userClassPath();
                     break;
                 case PLATFORM_CLASS_PATH:
-                    files = searchPaths.bootClassPath();
+                    files = locations.bootClassPath();
                     break;
                 case SOURCE_PATH:
-                    files = searchPaths.sourcePath();
+                    files = locations.sourcePath();
                     break;
                 case CLASS_OUTPUT: {
                     String arg = options.get(D);
@@ -257,7 +253,8 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
             for (File f: files)
                 pl.add(f.toPath());
         }
-        pathsForLocation.put(locn, pl);
+        if (!pl.isEmpty())
+            pathsForLocation.put(locn, pl);
     }
 
     private void lazyInitSearchPaths() {
@@ -272,7 +269,6 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
         private boolean inited = false;
 
     private Map<Location, PathsForLocation> pathsForLocation;
-    private Paths searchPaths;
 
     private static class PathsForLocation extends LinkedHashSet<Path> {
         private static final long serialVersionUID = 6788510222394486733L;
@@ -518,7 +514,8 @@ public class JavacPathFileManager extends BaseFileManager implements PathFileMan
     }
 
     private static String getRelativePath(String packageName, String relativeName) {
-        return packageName.replace(".", "/") + relativeName;
+        return packageName.isEmpty()
+                ? relativeName : packageName.replace(".", "/") + "/" + relativeName;
     }
 
     private static String getBaseName(String relativePath) {
diff --git a/src/share/classes/com/sun/tools/javac/nio/PathFileManager.java b/src/share/classes/com/sun/tools/javac/nio/PathFileManager.java
index 4aff561..762b8ed 100644
--- a/src/share/classes/com/sun/tools/javac/nio/PathFileManager.java
+++ b/src/share/classes/com/sun/tools/javac/nio/PathFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -27,13 +27,14 @@ package com.sun.tools.javac.nio;
 
 import java.io.IOException;
 import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
 import java.nio.file.Path;
 import javax.tools.FileObject;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 
 /**
- *  File manager based on {@linkplain File java.nio.file.Path}.
+ *  File manager based on {@link java.nio.file.Path}.
  *
  *  Eventually, this should be moved to javax.tools.
  *  Also, JavaCompiler might reasonably provide a method getPathFileManager,
diff --git a/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java b/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java
index a46e639..357fc77 100644
--- a/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java
+++ b/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -39,7 +39,6 @@ import java.nio.charset.CharsetDecoder;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
-import java.nio.file.attribute.BasicFileAttributes;
 import javax.lang.model.element.Modifier;
 import javax.lang.model.element.NestingKind;
 import javax.tools.JavaFileObject;
diff --git a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
new file mode 100644
index 0000000..8389f38
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
@@ -0,0 +1,1391 @@
+/*
+ * 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.  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.parser;
+
+import java.text.BreakIterator;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.tools.javac.parser.DocCommentParser.TagParser.Kind;
+import com.sun.tools.javac.parser.JavacParser.AbstractEndPosTable;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.parser.Tokens.TokenKind;
+import com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCAttribute;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCEndElement;
+import com.sun.tools.javac.tree.DCTree.DCEndPosTree;
+import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DCTree.DCIdentifier;
+import com.sun.tools.javac.tree.DCTree.DCReference;
+import com.sun.tools.javac.tree.DCTree.DCStartElement;
+import com.sun.tools.javac.tree.DCTree.DCText;
+import com.sun.tools.javac.tree.DocTreeMaker;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.Position;
+import static com.sun.tools.javac.util.LayoutCharacters.*;
+
+/**
+ *
+ *  <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 DocCommentParser {
+    static class ParseException extends Exception {
+        private static final long serialVersionUID = 0;
+        ParseException(String key) {
+            super(key);
+        }
+    }
+
+    final ParserFactory fac;
+    private final EndPosTable ept;
+    final DiagnosticSource diagSource;
+    final Comment comment;
+    final DocTreeMaker m;
+    final Names names;
+
+    BreakIterator sentenceBreaker;
+
+    /** The input buffer, index of most recent character read,
+     *  index of one past last character in buffer.
+     */
+    protected char[] buf;
+    protected int bp;
+    protected int buflen;
+
+    /** The current character.
+     */
+    protected char ch;
+
+    int textStart = -1;
+    int lastNonWhite = -1;
+    boolean newline = true;
+
+    Map<Name, TagParser> tagParsers;
+
+    private final boolean breakOnError;
+    private ListBuffer<JCDiagnostic> errors = new ListBuffer<JCDiagnostic>();
+
+    DocCommentParser(ParserFactory fac, boolean breakOnError, EndPosTable ept, DiagnosticSource diagSource, Comment comment) {
+        this.fac = fac;
+        this.ept = ept;
+        this.breakOnError = breakOnError;
+        this.diagSource = diagSource;
+        this.comment = comment;
+        names = fac.names;
+        m = fac.docTreeMaker;
+
+        Locale locale = (fac.locale == null) ? Locale.getDefault() : fac.locale;
+
+        Options options = fac.options;
+        boolean useBreakIterator = options.isSet("breakIterator");
+        if (useBreakIterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage()))
+            sentenceBreaker = BreakIterator.getSentenceInstance(locale);
+
+        initTagParsers();
+    }
+
+    DCDocComment parse() {
+        errors.clear();
+        
+        String c = comment.getText();
+        buf = new char[c.length() + 1];
+        c.getChars(0, c.length(), buf, 0);
+        buf[buf.length - 1] = EOI;
+        buflen = buf.length - 1;
+        bp = -1;
+        nextChar();
+
+        List<DCTree> body = blockContent();
+        List<DCTree> tags = blockTags();
+
+        // split body into first sentence and body
+        ListBuffer<DCTree> fs = new ListBuffer<DCTree>();
+        loop:
+        for (; body.nonEmpty(); body = body.tail) {
+            DCTree t = body.head;
+            switch (t.getKind()) {
+                case TEXT:
+                    String s = ((DCText) t).getBody();
+                    int i = getSentenceBreak(s);
+                    if (i > 0) {
+                        int i0 = i;
+                        while (i0 > 0 && isWhitespace(s.charAt(i0 - 1)))
+                            i0--;
+                        fs.add(m.at(t.pos).Text(s.substring(0, i0)));
+                        int i1 = i;
+                        while (i1 < s.length() && isWhitespace(s.charAt(i1)))
+                            i1++;
+                        body = body.tail;
+                        if (i1 < s.length())
+                            body = body.prepend(m.at(t.pos + i1).Text(s.substring(i1)));
+                        break loop;
+                    } else if (body.tail.nonEmpty()) {
+                        if (isSentenceBreak(body.tail.head)) {
+                            int i0 = s.length() - 1;
+                            while (i0 > 0 && isWhitespace(s.charAt(i0)))
+                                i0--;
+                            fs.add(m.at(t.pos).Text(s.substring(0, i0 + 1)));
+                            body = body.tail;
+                            break loop;
+                        }
+                    }
+                    break;
+
+                case START_ELEMENT:
+                case END_ELEMENT:
+                    if (isSentenceBreak(t))
+                        break loop;
+                    break;
+            }
+            fs.add(t);
+        }
+
+        @SuppressWarnings("unchecked")
+        DCTree first = getFirst(fs.toList(), body, tags);
+        int pos = (first == null) ? Position.NOPOS : first.pos;
+
+        DCDocComment dc = m.at(pos).DocComment(comment, fs.toList(), body, tags);
+        
+        dc.errors = errors.toList();
+        
+        return dc;
+    }
+
+    void nextChar() {
+        ch = buf[bp < buflen ? ++bp : buflen];
+        switch (ch) {
+            case '\f': case '\n': case '\r':
+                newline = true;
+        }
+    }
+    
+    char peekNextChar() {
+        return buf[bp < buflen ? bp + 1 : buflen];
+    }
+
+    /**
+     * Read block content, consisting of text, html and inline tags.
+     * Terminated by the end of input, or the beginning of the next block tag:
+     * i.e. @ as the first non-whitespace character on a line.
+     */
+    @SuppressWarnings("fallthrough")
+    protected List<DCTree> blockContent() {
+        ListBuffer<DCTree> trees = new ListBuffer<DCTree>();
+        textStart = -1;
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fallthrough
+
+                case ' ': case '\t':
+                    nextChar();
+                    break;
+
+                case '&':
+                    entity(trees);
+                    break;
+
+                case '<':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(html());
+                    if (textStart == -1) {
+                        textStart = bp;
+                        lastNonWhite = -1;
+                    }
+                    break;
+
+                case '>':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(m.at(bp).Erroneous(newString(bp, bp+1), diagSource, "dc.bad.gt"));
+                    nextChar();
+                    if (textStart == -1) {
+                        textStart = bp;
+                        lastNonWhite = -1;
+                    }
+                    break;
+
+                case '{':
+                    inlineTag(trees);
+                    break;
+
+                case '@':
+                    if (newline) {
+                        addPendingText(trees, lastNonWhite);
+                        break loop;
+                    }
+                    // fallthrough
+
+                default:
+                    newline = false;
+                    if (textStart == -1)
+                        textStart = bp;
+                    lastNonWhite = bp;
+                    nextChar();
+            }
+        }
+
+        if (lastNonWhite != -1)
+            addPendingText(trees, lastNonWhite);
+
+        return trees.toList();
+    }
+
+    /**
+     * Read a series of block tags, including their content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     */
+    protected List<DCTree> blockTags() {
+        ListBuffer<DCTree> tags = new ListBuffer<DCTree>();
+        while (ch == '@')
+            tags.add(blockTag());
+        return tags.toList();
+    }
+
+    /**
+     * Read a single block tag, including its content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     */
+    protected DCTree blockTag() {
+        int p = bp;
+        try {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                Name name = readIdentifier();
+                TagParser tp = tagParsers.get(name);
+                if (tp == null) {
+                    List<DCTree> content = blockContent();
+                    return m.at(p).UnknownBlockTag(name, content);
+                } else {
+                    switch (tp.getKind()) {
+                        case BLOCK:
+                            return tp.parse(p);
+                        case INLINE:
+                            handleError("dc.bad.inline.tag", p);
+                            return tp.parse(p);
+                    }
+                }
+            }
+            DCErroneous err = erroneous("dc.no.tag.name", p);
+            
+            if (breakOnError) {
+                return err;
+            }
+            
+            List<DCTree> content = blockContent();            
+            return m.at(p).UnknownBlockTag(names.empty, content);
+        } catch (ParseException e) {
+            if (!breakOnError) throw new IllegalStateException(e);//should not happen
+            blockContent();
+            return erroneous(e.getMessage(), p);
+        }
+    }
+
+    protected void inlineTag(ListBuffer<DCTree> list) {
+        newline = false;
+        nextChar();
+        if (ch == '@') {
+            addPendingText(list, bp - 2);
+            list.add(inlineTag());
+            textStart = bp;
+            lastNonWhite = -1;
+        } else {
+            if (textStart == -1)
+                textStart = bp - 1;
+            lastNonWhite = bp;
+        }
+    }
+
+    /**
+     * Read a single inline tag, including its content.
+     * Standard tags parse their content appropriately.
+     * Non-standard tags are represented by {@link UnknownBlockTag}.
+     * Malformed tags may be returned as {@link Erroneous}.
+     */
+    protected DCTree inlineTag() {
+        int p = bp - 1;
+        try {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                Name name = readIdentifier();
+                skipWhitespace();
+
+                TagParser tp = tagParsers.get(name);
+                if (tp == null) {
+                    DCTree text = inlineText();
+                    if (text != null) {
+                        return m.at(p).UnknownInlineTag(name, List.of(text)).setEndPos(bp);
+                    }
+                } else if (tp.getKind() == TagParser.Kind.INLINE) {
+                    DCEndPosTree<?> tree = (DCEndPosTree<?>) tp.parse(p);
+                    if (tree != null) {
+                        return tree.setEndPos(bp);
+                    }
+                } else {
+                    inlineText(); // skip content
+                }
+            }
+            
+            DCErroneous err = erroneous("dc.no.tag.name", p);
+            
+            if (breakOnError) return err;
+
+            List<DCTree> content = inlineContent();            
+            return m.at(p).UnknownInlineTag(names.empty, content);
+        } catch (ParseException e) {
+            if (!breakOnError) throw new IllegalStateException(e);
+            return erroneous(e.getMessage(), p);
+        }
+    }
+
+    /**
+     * Read plain text content of an inline tag.
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    protected DCTree inlineText() throws ParseException {
+        skipWhitespace();
+        int pos = bp;
+        int depth = 1;
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    break;
+
+                case ' ': case '\t':
+                    break;
+
+                case '{':
+                    newline = false;
+                    lastNonWhite = bp;
+                    depth++;
+                    break;
+
+                case '}':
+                    if (--depth == 0) {
+                        DCText result = m.at(pos).Text(newString(pos, bp));
+                        nextChar();
+                        return result;
+                    }
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+
+                default:
+                    newline = false;
+                    lastNonWhite = bp;
+                    break;
+            }
+            nextChar();
+        }
+        
+        handleError("dc.unterminated.inline.tag", pos);
+        
+        return m.at(pos).Text(newString(pos, bp));
+    }
+
+    protected void handleError(String errorKey, int pos) throws ParseException {
+        if (breakOnError)
+            throw new ParseException(errorKey);
+        else {
+            DCErroneous err = erroneous(errorKey, pos);
+            errors.add(err.diag);
+        }
+    }
+    
+    /**
+     * Read Java class name, possibly followed by member
+     * Matching pairs of < > are skipped. The text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    // TODO: boolean allowMember should be enum FORBID, ALLOW, REQUIRE
+    // TODO: improve quality of parse to forbid bad constructions.
+    @SuppressWarnings("fallthrough")
+    protected DCReference reference(boolean allowMember) throws ParseException {
+        int pos = bp;
+        int depth = 0;
+
+        // scan to find the end of the signature, by looking for the first
+        // whitespace not enclosed in () or <>, or the end of the tag
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fallthrough
+
+                case ' ': case '\t':
+                    if (depth == 0)
+                        break loop;
+                    break;
+
+                case '(':
+                case '<':
+                    newline = false;
+                    depth++;
+                    break;
+
+                case ')':
+                case '>':
+                    newline = false;
+                    --depth;
+                    break;
+
+                case '}':
+                    if (bp == pos)
+                        return null;
+                    newline = false;
+                    break loop;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    // fallthrough
+
+                case '{':
+                    break loop;
+                default:
+                    newline = false;
+
+            }
+            nextChar();
+        }
+
+        if (depth != 0) {
+            handleError("dc.unterminated.signature", pos);
+        }
+
+        String sig = newString(pos, bp);
+
+        // Break sig apart into qualifiedExpr member paramTypes.
+        JCExpression qualExpr;
+        Name member;
+        List<JCTree> paramTypes;
+
+        Log.DeferredDiagnosticHandler deferredDiagnosticHandler
+                = new Log.DeferredDiagnosticHandler(fac.log);
+
+        try {
+            int hash = sig.indexOf("#");
+            int lparen = sig.indexOf("(", hash + 1);
+            if (hash == -1) {
+                if (lparen == -1) {
+                    qualExpr = parseType(sig, comment.getSourcePos(pos));
+                    member = null;
+                } else {
+                    qualExpr = null;
+                    member = parseMember(sig.substring(0, lparen));
+                }
+            } else {
+                qualExpr = (hash == 0) ? null : parseType(sig.substring(0, hash), comment.getSourcePos(pos));
+                if (lparen == -1)
+                    member = parseMember(sig.substring(hash + 1));
+                else
+                    member = parseMember(sig.substring(hash + 1, lparen));
+            }
+
+            if (lparen < 0) {
+                paramTypes = null;
+            } else {
+                int rparen = sig.indexOf(")", lparen);
+                if (rparen != sig.length() - 1) {
+                    handleError("dc.ref.bad.parens", pos);
+                    if (rparen == (-1)) {
+                        rparen = sig.length();
+                    }
+                }
+                paramTypes = parseParams(sig.substring(lparen + 1, rparen), comment.getSourcePos(pos + lparen + 1));
+            }
+
+            if (!deferredDiagnosticHandler.getDiagnostics().isEmpty()) {
+                handleError("dc.ref.syntax.error", pos);
+            }
+        } finally {
+            fac.log.popDiagnosticHandler(deferredDiagnosticHandler);
+        }
+
+        return m.at(pos).Reference(sig, qualExpr, member, paramTypes).setEndPos(bp);
+    }
+
+    JCExpression parseType(String s, int startPos) throws ParseException {
+        JavacParser p = fac.newParser(s, false, true, false);
+        JCExpression tree = p.parseType();
+        moveTree(startPos, tree, p, ept);
+        if (p.token().kind != TokenKind.EOF) {
+            handleError("dc.ref.unexpected.input", p.token().pos);
+        }
+        return tree;
+    }
+    
+    private <T extends JCTree> T moveTree(final int offset, T toMove, final JavacParser parser, final EndPosTable targetEndPos) {
+        new TreeScanner() {
+            @Override public void scan(JCTree tree) {
+                if (tree != null) {
+                    tree.pos += offset;
+                    ((AbstractEndPosTable) targetEndPos).storeEnd(tree, parser.getEndPos(tree) + offset);
+                }
+                super.scan(tree);
+            }
+        }.scan(toMove);
+        
+        return toMove;
+    }
+
+    Name parseMember(String s) throws ParseException {
+        JavacParser p = fac.newParser(s, false, false, false);
+        Name name = p.ident();
+        if (p.token().kind != TokenKind.EOF) {
+            handleError("dc.ref.unexpected.input", bp);
+            return names.error;
+        }
+        return name;
+    }
+
+    List<JCTree> parseParams(String s, int startPos) throws ParseException {
+        if (s.trim().isEmpty())
+            return List.nil();
+
+        JavacParser p = fac.newParser(s.replace("...", "[ ]"), false, true, false);
+        ListBuffer<JCTree> paramTypes = new ListBuffer<JCTree>();
+        paramTypes.add(moveTree(startPos, p.parseType(), p, ept));
+
+        if (p.token().kind == TokenKind.IDENTIFIER)
+            p.nextToken();
+
+        while (p.token().kind == TokenKind.COMMA) {
+            p.nextToken();
+            paramTypes.add(moveTree(startPos, p.parseType(), p, ept));
+
+            if (p.token().kind == TokenKind.IDENTIFIER)
+                p.nextToken();
+        }
+
+        if (p.token().kind != TokenKind.EOF) {
+            handleError("dc.ref.unexpected.input", bp);
+        }
+
+        return paramTypes.toList();
+    }
+
+    /**
+     * Read Java identifier
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected DCIdentifier identifier() throws ParseException {
+        skipWhitespace();
+        int pos = bp;
+
+        if (isJavaIdentifierStart(ch)) {
+            Name name = readJavaIdentifier();
+            return m.at(pos).Identifier(name);
+        }
+
+        handleError("dc.identifier.expected", pos);
+        return m.at(pos).Identifier(names.error);
+    }
+
+    /**
+     * Read a quoted string.
+     * It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected DCText quotedString() {
+        int pos = bp;
+        nextChar();
+
+        loop:
+        while (bp < buflen) {
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    break;
+
+                case ' ': case '\t':
+                    break;
+
+                case '"':
+                    nextChar();
+                    // trim trailing white-space?
+                    return m.at(pos).Text(newString(pos, bp));
+
+                case '@':
+                    if (newline)
+                        break loop;
+
+            }
+            nextChar();
+        }
+        return null;
+    }
+
+    /**
+     * Read general text content of an inline tag, including HTML entities and elements.
+     * Matching pairs of { } are skipped; the text is terminated by the first
+     * unmatched }. It is an error if the beginning of the next tag is detected.
+     */
+    @SuppressWarnings("fallthrough")
+    protected List<DCTree> inlineContent() {
+        ListBuffer<DCTree> trees = new ListBuffer<DCTree>();
+
+        skipWhitespace();
+        int pos = bp;
+        int depth = 1;
+        textStart = -1;
+
+        loop:
+        while (bp < buflen) {
+
+            switch (ch) {
+                case '\n': case '\r': case '\f':
+                    newline = true;
+                    // fall through
+
+                case ' ': case '\t':
+                    nextChar();
+                    break;
+
+                case '&':
+                    entity(trees);
+                    break;
+
+                case '<':
+                    newline = false;
+                    addPendingText(trees, bp - 1);
+                    trees.add(html());
+                    break;
+
+                case '{':
+                    newline = false;
+                    if (peekNextChar() == '@') {
+                        addPendingText(trees, bp - 1);
+                        pos = bp;
+                        break loop;
+                    }
+                    nextChar();
+                    depth++;
+                    break;
+
+                case '}':
+                    newline = false;
+                    if (--depth == 0) {
+                        addPendingText(trees, bp - 1);
+                        nextChar();
+                        return trees.toList();
+                    }
+                    nextChar();
+                    break;
+
+                case '@':
+                    if (newline)
+                        break loop;
+                    // fallthrough
+
+                default:
+                    if (textStart == -1)
+                        textStart = bp;
+                    nextChar();
+                    break;
+            }
+        }
+
+        DCErroneous err = erroneous("dc.unterminated.inline.tag", pos);
+        
+        if (!breakOnError) {
+            return trees.toList();
+        }
+        
+        return List.<DCTree>of(err);
+    }
+
+    protected void entity(ListBuffer<DCTree> list) {
+        newline = false;
+        addPendingText(list, bp - 1);
+        list.add(entity());
+        if (textStart == -1) {
+            textStart = bp;
+            lastNonWhite = -1;
+        }
+    }
+
+    /**
+     * Read an HTML entity.
+     * {@literal &identifier; } or {@literal &#digits; } or {@literal &#xhex-digits; }
+     */
+    protected DCTree entity() {
+        int p = bp;
+        nextChar();
+        Name name = null;
+        boolean checkSemi = false;
+        if (ch == '#') {
+            int namep = bp;
+            nextChar();
+            if (isDecimalDigit(ch)) {
+                nextChar();
+                while (isDecimalDigit(ch))
+                    nextChar();
+                name = names.fromChars(buf, namep, bp - namep);
+            } else if (ch == 'x' || ch == 'X') {
+                nextChar();
+                if (isHexDigit(ch)) {
+                    nextChar();
+                    while (isHexDigit(ch))
+                        nextChar();
+                    name = names.fromChars(buf, namep, bp - namep);
+                }
+            }
+        } else if (isIdentifierStart(ch)) {
+            name = readIdentifier();
+        }
+
+        if (name == null) {
+            DCErroneous err = erroneous("dc.bad.entity", p);
+            
+            if (breakOnError) {
+                return err;
+            } else {
+                name = names.empty;
+            }
+        } else {
+            if (ch != ';') {
+                DCErroneous err = erroneous("dc.missing.semicolon", p);
+                
+                if (breakOnError) {
+                    return err;
+                }
+            } else {
+                nextChar();
+            }
+        }
+        return m.at(p).Entity(name);
+    }
+
+    /**
+     * Read the start or end of an HTML tag, or an HTML comment
+     * {@literal <identifier attrs> } or {@literal </identifier> }
+     */
+    protected DCTree html() {
+        int p = bp;
+        nextChar();
+        if (isIdentifierStart(ch)) {
+            Name name = readIdentifier();
+            List<DCTree> attrs = htmlAttrs();
+            if (attrs != null) {
+                boolean selfClosing = false;
+                if (ch == '/') {
+                    nextChar();
+                    selfClosing = true;
+                }
+                if (ch == '>') {
+                    nextChar();
+                    return m.at(p).StartElement(name, attrs, selfClosing).setEndPos(bp);
+                }
+            }
+        } else if (ch == '/') {
+            nextChar();
+            if (isIdentifierStart(ch)) {
+                Name name = readIdentifier();
+                skipWhitespace();
+                if (ch == '>') {
+                    nextChar();
+                    return m.at(p).EndElement(name);
+                }
+            }
+        } else if (ch == '!') {
+            nextChar();
+            if (ch == '-') {
+                nextChar();
+                if (ch == '-') {
+                    nextChar();
+                    while (bp < buflen) {
+                        int dash = 0;
+                        while (ch == '-') {
+                            dash++;
+                            nextChar();
+                        }
+                        // strictly speaking, a comment should not contain "--"
+                        // so dash > 2 is an error, dash == 2 implies ch == '>'
+                        if (dash >= 2 && ch == '>') {
+                            nextChar();
+                            return m.at(p).Comment(newString(p, bp));
+                        }
+
+                        nextChar();
+                    }
+                }
+            }
+        }
+
+        bp = p + 1;
+        ch = buf[bp];
+        return erroneous("dc.malformed.html", p);//XXX: jlahoda: the span is incorrect
+    }
+
+    /**
+     * Read a series of HTML attributes, terminated by {@literal > }.
+     * Each attribute is of the form {@literal identifier[=value] }.
+     * "value" may be unquoted, single-quoted, or double-quoted.
+     */
+    protected List<DCTree> htmlAttrs() {
+        ListBuffer<DCTree> attrs = new ListBuffer<DCTree>();
+        skipWhitespace();
+
+        loop:
+        while (isIdentifierStart(ch)) {
+            int namePos = bp;
+            Name name = readIdentifier();
+            skipWhitespace();
+            List<DCTree> value = null;
+            ValueKind vkind = ValueKind.EMPTY;
+            if (ch == '=') {
+                ListBuffer<DCTree> v = new ListBuffer<DCTree>();
+                nextChar();
+                skipWhitespace();
+                if (ch == '\'' || ch == '"') {
+                    vkind = (ch == '\'') ? ValueKind.SINGLE : ValueKind.DOUBLE;
+                    char quote = ch;
+                    nextChar();
+                    textStart = bp;
+                    while (bp < buflen && ch != quote) {
+                        if (newline && ch == '@') {
+                            DCErroneous err = erroneous("dc.unterminated.string", namePos);
+                            if (breakOnError) {
+                                attrs.add(err);
+                            } else {
+                                attrValueChar(v);
+                                attrs.add(m.at(namePos).Attribute(name, vkind, v.toList()));
+                            }
+                            // No point trying to read more.
+                            // In fact, all attrs get discarded by the caller
+                            // and superseded by a malformed.html node because
+                            // the html tag itself is not terminated correctly.
+                            break loop;
+                        }
+                        attrValueChar(v);
+                    }
+                    addPendingText(v, bp - 1);
+                    nextChar();
+                } else {
+                    vkind = ValueKind.UNQUOTED;
+                    textStart = bp;
+                    while (bp < buflen && !isUnquotedAttrValueTerminator(ch)) {
+                        attrValueChar(v);
+                    }
+                    addPendingText(v, bp - 1);
+                }
+                skipWhitespace();
+                value = v.toList();
+            }
+            DCAttribute attr = m.at(namePos).Attribute(name, vkind, value);
+            attrs.add(attr);
+        }
+
+        return attrs.toList();
+    }
+
+    protected void attrValueChar(ListBuffer<DCTree> list) {
+        switch (ch) {
+            case '&':
+                entity(list);
+                break;
+
+            case '{':
+                inlineTag(list);
+                break;
+
+            default:
+                nextChar();
+        }
+    }
+
+    protected void addPendingText(ListBuffer<DCTree> list, int textEnd) {
+        if (textStart != -1) {
+            if (textStart <= textEnd) {
+                list.add(m.at(textStart).Text(newString(textStart, textEnd + 1)));
+            }
+            textStart = -1;
+        }
+    }
+
+    protected DCErroneous erroneous(String code, int pos) {
+        int i = bp - 1;
+        loop:
+        while (i > pos) {
+            switch (buf[i]) {
+                case '\f': case '\n': case '\r':
+                    newline = true;
+                    break;
+                case '\t': case ' ':
+                    break;
+                default:
+                    break loop;
+            }
+            i--;
+        }
+        textStart = -1;
+        DCErroneous result = m.at(pos).Erroneous(newString(pos, i + 1), diagSource, code);
+        if (!breakOnError) errors.add(result.diag);
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    <T> T getFirst(List<T>... lists) {
+        for (List<T> list: lists) {
+            if (list.nonEmpty())
+                return list.head;
+        }
+        return null;
+    }
+
+    protected boolean isIdentifierStart(char ch) {
+        return Character.isUnicodeIdentifierStart(ch);
+    }
+
+    protected Name readIdentifier() {
+        int start = bp;
+        nextChar();
+        while (bp < buflen && Character.isUnicodeIdentifierPart(ch))
+            nextChar();
+        return names.fromChars(buf, start, bp - start);
+    }
+
+    protected boolean isJavaIdentifierStart(char ch) {
+        return Character.isJavaIdentifierStart(ch);
+    }
+
+    protected Name readJavaIdentifier() {
+        int start = bp;
+        nextChar();
+        while (bp < buflen && Character.isJavaIdentifierPart(ch))
+            nextChar();
+        return names.fromChars(buf, start, bp - start);
+    }
+
+    protected boolean isDecimalDigit(char ch) {
+        return ('0' <= ch && ch <= '9');
+    }
+
+    protected boolean isHexDigit(char ch) {
+        return ('0' <= ch && ch <= '9')
+                || ('a' <= ch && ch <= 'f')
+                || ('A' <= ch && ch <= 'F');
+    }
+
+    protected boolean isUnquotedAttrValueTerminator(char ch) {
+        switch (ch) {
+            case '\f': case '\n': case '\r': case '\t':
+            case ' ':
+            case '"': case '\'': case '`':
+            case '=': case '<': case '>':
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    protected boolean isWhitespace(char ch) {
+        return Character.isWhitespace(ch);
+    }
+
+    protected void skipWhitespace() {
+        while (isWhitespace(ch))
+            nextChar();
+    }
+
+    protected int getSentenceBreak(String s) {
+        if (sentenceBreaker != null) {
+            sentenceBreaker.setText(s);
+            int i = sentenceBreaker.next();
+            return (i == s.length()) ? -1 : i;
+        }
+
+        // scan for period followed by whitespace
+        boolean period = false;
+        for (int i = 0; i < s.length(); i++) {
+            switch (s.charAt(i)) {
+                case '.':
+                    period = true;
+                    break;
+
+                case ' ':
+                case '\f':
+                case '\n':
+                case '\r':
+                case '\t':
+                    if (period)
+                        return i;
+                    break;
+
+                default:
+                    period = false;
+                    break;
+            }
+        }
+        return -1;
+    }
+
+
+    Set<String> htmlBlockTags = new HashSet<String>(Arrays.asList(
+                    "h1", "h2", "h3", "h4", "h5", "h6", "p", "pre"));
+
+    protected boolean isSentenceBreak(Name n) {
+        return htmlBlockTags.contains(n.toString().toLowerCase());
+    }
+
+    protected boolean isSentenceBreak(DCTree t) {
+        switch (t.getKind()) {
+            case START_ELEMENT:
+                return isSentenceBreak(((DCStartElement) t).getName());
+
+            case END_ELEMENT:
+                return isSentenceBreak(((DCEndElement) t).getName());
+        }
+        return false;
+    }
+
+    /**
+     * @param start position of first character of string
+     * @param end position of character beyond last character to be included
+     */
+    String newString(int start, int end) {
+        return new String(buf, start, end - start);
+    }
+
+    static abstract class TagParser {
+        enum Kind { INLINE, BLOCK }
+
+        Kind kind;
+        DCTree.Kind treeKind;
+
+        TagParser(Kind k, DCTree.Kind tk) {
+            kind = k;
+            treeKind = tk;
+        }
+
+        Kind getKind() {
+            return kind;
+        }
+
+        DCTree.Kind getTreeKind() {
+            return treeKind;
+        }
+
+        abstract DCTree parse(int pos) throws ParseException;
+    }
+
+    /**
+     * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javadoc.html#javadoctags">Javadoc Tags</a>
+     */
+    private void initTagParsers() {
+        TagParser[] parsers = {
+            // @author name-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.AUTHOR) {
+                public DCTree parse(int pos) {
+                    List<DCTree> name = blockContent();
+                    return m.at(pos).Author(name);
+                }
+            },
+
+            // {@code text}
+            new TagParser(Kind.INLINE, DCTree.Kind.CODE) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCTree text = inlineText();
+                    return m.at(pos).Code((DCText) text);
+                }
+            },
+
+            // @deprecated deprecated-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.DEPRECATED) {
+                public DCTree parse(int pos) {
+                    List<DCTree> reason = blockContent();
+                    return m.at(pos).Deprecated(reason);
+                }
+            },
+
+            // {@docRoot}
+            new TagParser(Kind.INLINE, DCTree.Kind.DOC_ROOT) {
+                public DCTree parse(int pos) throws ParseException {
+                    if (ch == '}' || !breakOnError) {
+                        if (ch == '}') {
+                            nextChar();
+                        } else {
+                            erroneous("dc.unexpected.content", bp);//TODO: should rather be '}' expected
+                        }
+                        return m.at(pos).DocRoot();
+                    }
+                    inlineText(); // skip unexpected content
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // @exception class-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.EXCEPTION) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCReference ref = reference(false);
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Exception(ref, description);
+                }
+            },
+
+            // {@inheritDoc}
+            new TagParser(Kind.INLINE, DCTree.Kind.INHERIT_DOC) {
+                public DCTree parse(int pos) throws ParseException {
+                    if (ch == '}' || !breakOnError) {
+                        if (ch == '}') {
+                            nextChar();
+                        } else {
+                            erroneous("dc.unexpected.content", bp);//TODO: should rather be '}' expected
+                        }
+                        return m.at(pos).InheritDoc();
+                    }
+                    inlineText(); // skip unexpected content
+                    throw new ParseException("dc.unexpected.content");
+                }
+            },
+
+            // {@link package.class#member label}
+            new TagParser(Kind.INLINE, DCTree.Kind.LINK) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    List<DCTree> label = inlineContent();
+                    return m.at(pos).Link(ref, label);
+                }
+            },
+
+            // {@linkplain package.class#member label}
+            new TagParser(Kind.INLINE, DCTree.Kind.LINK_PLAIN) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    List<DCTree> label = inlineContent();
+                    return m.at(pos).LinkPlain(ref, label);
+                }
+            },
+
+            // {@literal text}
+            new TagParser(Kind.INLINE, DCTree.Kind.LITERAL) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCTree text = inlineText();
+                    return m.at(pos).Literal((DCText) text);
+                }
+            },
+
+            // @param parameter-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.PARAM) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+
+                    boolean typaram = false;
+                    if (ch == '<') {
+                        typaram = true;
+                        nextChar();
+                    }
+
+                    DCIdentifier id = identifier();
+
+                    if (typaram) {
+                        if (ch != '>') {
+                            handleError("dc.gt.expected", bp);
+                        }
+                        nextChar();
+                    }
+
+                    skipWhitespace();
+                    List<DCTree> desc = blockContent();
+                    return m.at(pos).Param(typaram, id, desc);
+                }
+            },
+
+            // @return description
+            new TagParser(Kind.BLOCK, DCTree.Kind.RETURN) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Return(description);
+                }
+            },
+
+            // @see reference | quoted-string | HTML
+            new TagParser(Kind.BLOCK, DCTree.Kind.SEE) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    String errorKey = "dc.unexpected.content";
+                    switch (ch) {
+                        case '"':
+                            DCText string = quotedString();
+                            if (string != null) {
+                                skipWhitespace();
+                                if (ch == '@')
+                                    return m.at(pos).See(List.<DCTree>of(string));
+                            }
+                            break;
+
+                        case '<':
+                            List<DCTree> html = blockContent();
+                            if (html != null)
+                                return m.at(pos).See(html);
+                            break;
+
+                        case '@':
+                            if (newline) {
+                                handleError("dc.no.content", bp);
+                            }
+                            break;
+
+                        case EOI:
+                            if (bp == buf.length - 1)
+                                errorKey = "dc.no.content";
+                            break;
+
+                        default:
+                            if (isJavaIdentifierStart(ch) || ch == '#') {
+                                DCReference ref = reference(true);
+                                List<DCTree> description = blockContent();
+                                return m.at(pos).See(description.prepend(ref));
+                            }
+                    }
+                    
+                    handleError(errorKey, bp);
+                    
+                    return m.at(pos).See(List.<DCTree>nil());
+                }
+            },
+
+            // @serialData data-description
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_DATA) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).SerialData(description);
+                }
+            },
+
+            // @serialField field-name field-type description
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL_FIELD) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCIdentifier name = identifier();
+                    skipWhitespace();
+                    DCReference type = reference(false);
+                    List<DCTree> description = null;
+                    if (isWhitespace(ch)) {
+                        skipWhitespace();
+                        description = blockContent();
+                    }
+                    return m.at(pos).SerialField(name, type, description);
+                }
+            },
+
+            // @serial field-description | include | exclude
+            new TagParser(Kind.BLOCK, DCTree.Kind.SERIAL) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Serial(description);
+                }
+            },
+
+            // @since since-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.SINCE) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Since(description);
+                }
+            },
+
+            // @throws class-name description
+            new TagParser(Kind.BLOCK, DCTree.Kind.THROWS) {
+                public DCTree parse(int pos) throws ParseException {
+                    skipWhitespace();
+                    DCReference ref = reference(false);
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Throws(ref, description);
+                }
+            },
+
+            // {@value package.class#field}
+            new TagParser(Kind.INLINE, DCTree.Kind.VALUE) {
+                public DCTree parse(int pos) throws ParseException {
+                    DCReference ref = reference(true);
+                    skipWhitespace();
+                    if (ch == '}') {
+                        nextChar();
+                    } else {
+                        handleError("dc.unexpected.content", pos);//TODO: should rather be '}' expected
+                    }
+                    return m.at(pos).Value(ref);
+                }
+            },
+
+            // @version version-text
+            new TagParser(Kind.BLOCK, DCTree.Kind.VERSION) {
+                public DCTree parse(int pos) {
+                    List<DCTree> description = blockContent();
+                    return m.at(pos).Version(description);
+                }
+            },
+        };
+
+        tagParsers = new HashMap<Name,TagParser>();
+        for (TagParser p: parsers)
+            tagParsers.put(names.fromString(p.getTreeKind().tagName), p);
+
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java b/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java
deleted file mode 100644
index 2b74d47..0000000
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (c) 2004, 2010, 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.parser;
-
-import java.nio.*;
-
-import com.sun.tools.javac.util.*;
-import static com.sun.tools.javac.util.LayoutCharacters.*;
-
-/** An extension to the base lexical analyzer that captures
- *  and processes the contents of doc comments.  It does so by
- *  translating Unicode escape sequences and by stripping the
- *  leading whitespace and starts from each line of the comment.
- *
- *  <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 DocCommentScanner extends Scanner {
-
-    /** Create a scanner from the input buffer.  buffer must implement
-     *  array() and compact(), and remaining() must be less than limit().
-     */
-    protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) {
-        super(fac, buffer);
-    }
-
-    /** Create a scanner from the input array.  The array must have at
-     *  least a single character of extra space.
-     */
-    protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) {
-        super(fac, input, inputLength);
-    }
-
-    /** Starting position of the comment in original source
-     */
-    private int pos;
-
-    /** The comment input buffer, index of next chacter to be read,
-     *  index of one past last character in buffer.
-     */
-    private char[] buf;
-    private int bp;
-    private int buflen;
-
-    /** The current character.
-     */
-    private char ch;
-
-    /** The column number position of the current character.
-     */
-    private int col;
-
-    /** The buffer index of the last converted Unicode character
-     */
-    private int unicodeConversionBp = 0;
-
-    /**
-     * Buffer for doc comment.
-     */
-    private char[] docCommentBuffer = new char[1024];
-
-    /**
-     * Number of characters in doc comment buffer.
-     */
-    private int docCommentCount;
-
-    /**
-     * Translated and stripped contents of doc comment
-     */
-    private String docComment = null;
-
-
-    /** Unconditionally expand the comment buffer.
-     */
-    private void expandCommentBuffer() {
-        char[] newBuffer = new char[docCommentBuffer.length * 2];
-        System.arraycopy(docCommentBuffer, 0, newBuffer,
-                         0, docCommentBuffer.length);
-        docCommentBuffer = newBuffer;
-    }
-
-    /** Convert an ASCII digit from its base (8, 10, or 16)
-     *  to its value.
-     */
-    private int digit(int base) {
-        char c = ch;
-        int result = Character.digit(c, base);
-        if (result >= 0 && c > 0x7f) {
-            ch = "0123456789abcdef".charAt(result);
-        }
-        return result;
-    }
-
-    /** Convert Unicode escape; bp points to initial '\' character
-     *  (Spec 3.3).
-     */
-    private void convertUnicode() {
-        if (ch == '\\' && unicodeConversionBp != bp) {
-            bp++; ch = buf[bp]; col++;
-            if (ch == 'u') {
-                do {
-                    bp++; ch = buf[bp]; col++;
-                } while (ch == 'u');
-                int limit = bp + 3;
-                if (limit < buflen) {
-                    int d = digit(16);
-                    int code = d;
-                    while (bp < limit && d >= 0) {
-                        bp++; ch = buf[bp]; col++;
-                        d = digit(16);
-                        code = (code << 4) + d;
-                    }
-                    if (d >= 0) {
-                        ch = (char)code;
-                        unicodeConversionBp = bp;
-                        return;
-                    }
-                }
-                // "illegal.Unicode.esc", reported by base scanner
-            } else {
-                bp--;
-                ch = '\\';
-                col--;
-            }
-        }
-    }
-
-
-    /** Read next character.
-     */
-    private void scanChar() {
-        bp++;
-        ch = buf[bp];
-        switch (ch) {
-        case '\r': // return
-            col = 0;
-            break;
-        case '\n': // newline
-            if (bp == 0 || buf[bp-1] != '\r') {
-                col = 0;
-            }
-            break;
-        case '\t': // tab
-            col = (col / TabInc * TabInc) + TabInc;
-            break;
-        case '\\': // possible Unicode
-            col++;
-            convertUnicode();
-            break;
-        default:
-            col++;
-            break;
-        }
-    }
-
-    /**
-     * Read next character in doc comment, skipping over double '\' characters.
-     * If a double '\' is skipped, put in the buffer and update buffer count.
-     */
-    private void scanDocCommentChar() {
-        scanChar();
-        if (ch == '\\') {
-            if (buf[bp+1] == '\\' && unicodeConversionBp != bp) {
-                if (docCommentCount == docCommentBuffer.length)
-                    expandCommentBuffer();
-                docCommentBuffer[docCommentCount++] = ch;
-                bp++; col++;
-            } else {
-                convertUnicode();
-            }
-        }
-    }
-
-    /* Reset doc comment before reading each new token
-     */
-    public void nextToken() {
-        docComment = null;
-        super.nextToken();
-    }
-
-    /**
-     * Returns the documentation string of the current token.
-     */
-    public String docComment() {
-        return docComment;
-    }
-
-    /**
-     * Process a doc comment and make the string content available.
-     * Strips leading whitespace and stars.
-     */
-    @SuppressWarnings("fallthrough")
-    protected void processComment(CommentStyle style) {
-        if (style != CommentStyle.JAVADOC) {
-            return;
-        }
-
-        pos = pos();
-        buf = getRawCharacters(pos, endPos());
-        buflen = buf.length;
-        bp = 0;
-        col = 0;
-
-        docCommentCount = 0;
-
-        boolean firstLine = true;
-
-        // Skip over first slash
-        scanDocCommentChar();
-        // Skip over first star
-        scanDocCommentChar();
-
-        // consume any number of stars
-        while (bp < buflen && ch == '*') {
-            scanDocCommentChar();
-        }
-        // is the comment in the form /**/, /***/, /****/, etc. ?
-        if (bp < buflen && ch == '/') {
-            docComment = "";
-            return;
-        }
-
-        // skip a newline on the first line of the comment.
-        if (bp < buflen) {
-            if (ch == LF) {
-                scanDocCommentChar();
-                firstLine = false;
-            } else if (ch == CR) {
-                scanDocCommentChar();
-                if (ch == LF) {
-                    scanDocCommentChar();
-                    firstLine = false;
-                }
-            }
-        }
-
-    outerLoop:
-
-        // The outerLoop processes the doc comment, looping once
-        // for each line.  For each line, it first strips off
-        // whitespace, then it consumes any stars, then it
-        // puts the rest of the line into our buffer.
-        while (bp < buflen) {
-
-            // The wsLoop consumes whitespace from the beginning
-            // of each line.
-        wsLoop:
-
-            while (bp < buflen) {
-                switch(ch) {
-                case ' ':
-                    scanDocCommentChar();
-                    break;
-                case '\t':
-                    col = ((col - 1) / TabInc * TabInc) + TabInc;
-                    scanDocCommentChar();
-                    break;
-                case FF:
-                    col = 0;
-                    scanDocCommentChar();
-                    break;
-// Treat newline at beginning of line (blank line, no star)
-// as comment text.  Old Javadoc compatibility requires this.
-/*---------------------------------*
-                case CR: // (Spec 3.4)
-                    scanDocCommentChar();
-                    if (ch == LF) {
-                        col = 0;
-                        scanDocCommentChar();
-                    }
-                    break;
-                case LF: // (Spec 3.4)
-                    scanDocCommentChar();
-                    break;
-*---------------------------------*/
-                default:
-                    // we've seen something that isn't whitespace;
-                    // jump out.
-                    break wsLoop;
-                }
-            }
-
-            // Are there stars here?  If so, consume them all
-            // and check for the end of comment.
-            if (ch == '*') {
-                // skip all of the stars
-                do {
-                    scanDocCommentChar();
-                } while (ch == '*');
-
-                // check for the closing slash.
-                if (ch == '/') {
-                    // We're done with the doc comment
-                    // scanChar() and breakout.
-                    break outerLoop;
-                }
-            } else if (! firstLine) {
-                //The current line does not begin with a '*' so we will indent it.
-                for (int i = 1; i < col; i++) {
-                    if (docCommentCount == docCommentBuffer.length)
-                        expandCommentBuffer();
-                    docCommentBuffer[docCommentCount++] = ' ';
-                }
-            }
-
-            // The textLoop processes the rest of the characters
-            // on the line, adding them to our buffer.
-        textLoop:
-            while (bp < buflen) {
-                switch (ch) {
-                case '*':
-                    // Is this just a star?  Or is this the
-                    // end of a comment?
-                    scanDocCommentChar();
-                    if (ch == '/') {
-                        // This is the end of the comment,
-                        // set ch and return our buffer.
-                        break outerLoop;
-                    }
-                    // This is just an ordinary star.  Add it to
-                    // the buffer.
-                    if (docCommentCount == docCommentBuffer.length)
-                        expandCommentBuffer();
-                    docCommentBuffer[docCommentCount++] = '*';
-                    break;
-                case ' ':
-                case '\t':
-                    if (docCommentCount == docCommentBuffer.length)
-                        expandCommentBuffer();
-                    docCommentBuffer[docCommentCount++] = ch;
-                    scanDocCommentChar();
-                    break;
-                case FF:
-                    scanDocCommentChar();
-                    break textLoop; // treat as end of line
-                case CR: // (Spec 3.4)
-                    scanDocCommentChar();
-                    if (ch != LF) {
-                        // Canonicalize CR-only line terminator to LF
-                        if (docCommentCount == docCommentBuffer.length)
-                            expandCommentBuffer();
-                        docCommentBuffer[docCommentCount++] = (char)LF;
-                        break textLoop;
-                    }
-                    /* fall through to LF case */
-                case LF: // (Spec 3.4)
-                    // We've seen a newline.  Add it to our
-                    // buffer and break out of this loop,
-                    // starting fresh on a new line.
-                    if (docCommentCount == docCommentBuffer.length)
-                        expandCommentBuffer();
-                    docCommentBuffer[docCommentCount++] = ch;
-                    scanDocCommentChar();
-                    break textLoop;
-                default:
-                    // Add the character to our buffer.
-                    if (docCommentCount == docCommentBuffer.length)
-                        expandCommentBuffer();
-                    docCommentBuffer[docCommentCount++] = ch;
-                    scanDocCommentChar();
-                }
-            } // end textLoop
-            firstLine = false;
-        } // end outerLoop
-
-        if (docCommentCount > 0) {
-            int i = docCommentCount - 1;
-        trailLoop:
-            while (i > -1) {
-                switch (docCommentBuffer[i]) {
-                case '*':
-                    i--;
-                    break;
-                default:
-                    break trailLoop;
-                }
-            }
-            docCommentCount = i + 1;
-
-            // Store the text of the doc comment
-            docComment = new String(docCommentBuffer, 0 , docCommentCount);
-        } else {
-            docComment = "";
-        }
-    }
-
-    /** Build a map for translating between line numbers and
-     * positions in the input.
-     *
-     * @return a LineMap */
-    public Position.LineMap getLineMap() {
-        char[] buf = getVeryRawCharacters();
-        return Position.makeLineMap(buf, buf.length, '\n', true);
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/parser/EndPosParser.java b/src/share/classes/com/sun/tools/javac/parser/EndPosParser.java
deleted file mode 100644
index e7595c4..0000000
--- a/src/share/classes/com/sun/tools/javac/parser/EndPosParser.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2005, 2008, 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.parser;
-
-import java.util.Map;
-import java.util.HashMap;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.TreeInfo;
-
-import static com.sun.tools.javac.tree.JCTree.*;
-
-/**
- * This class is similar to Parser except that it stores ending
- * positions for the tree nodes.
- *
- * <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></p>
- */
-public class EndPosParser extends JavacParser {
-
-    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap) {
-        this(fac, S, keepDocComments, keepLineMap, null);
-    }
-
-    public EndPosParser(ParserFactory fac, Lexer S, boolean keepDocComments, boolean keepLineMap, Map<JCTree,Integer> endPositions) {
-        super(fac, S, keepDocComments, keepLineMap);
-        this.endPositions = endPositions == null ? new HashMap<JCTree,Integer>() : endPositions;
-    }
-
-    /** A hashtable to store ending positions
-     *  of source ranges indexed by the tree nodes.
-     *  Defined only if option flag genEndPos is set.
-     */
-    Map<JCTree, Integer> endPositions;
-
-    /** {@inheritDoc} */
-    @Override
-    protected void storeEnd(JCTree tree, int endpos) {
-        int errorEndPos = getErrorEndPos();
-        endPositions.put(tree, errorEndPos > endpos ? errorEndPos : endpos);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected <T extends JCTree> T to(T t) {
-        storeEnd(t, S.endPos());
-        return t;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected <T extends JCTree> T toP(T t) {
-        storeEnd(t, S.prevEndPos());
-        return t;
-    }
-
-    @Override
-    public JCCompilationUnit parseCompilationUnit() {
-        JCCompilationUnit t = super.parseCompilationUnit();
-        t.endPositions = endPositions;
-        return t;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    JCExpression parExpression() {
-        int pos = S.pos();
-        JCExpression t = super.parExpression();
-        return toP(F.at(pos).Parens(t));
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public int getEndPos(JCTree tree) {
-        return TreeInfo.getEndPos(tree, endPositions);
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
new file mode 100644
index 0000000..03c9123
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
@@ -0,0 +1,897 @@
+/*
+ * 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
+ * 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.parser;
+
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
+import com.sun.tools.javac.util.*;
+
+import java.nio.CharBuffer;
+
+import static com.sun.tools.javac.parser.Tokens.*;
+import static com.sun.tools.javac.util.LayoutCharacters.*;
+
+/** The lexical analyzer maps an input stream consisting of
+ *  ASCII characters and Unicode escapes into a token sequence.
+ *
+ *  <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 JavaTokenizer {
+
+    private static final boolean scannerDebug = false;
+
+    /** Allow hex floating-point literals.
+     */
+    private boolean allowHexFloats;
+
+    /** Allow binary literals.
+     */
+    private boolean allowBinaryLiterals;
+
+    /** Allow underscores in literals.
+     */
+    private boolean allowUnderscoresInLiterals;
+
+    /** The source language setting.
+     */
+    private Source source;
+
+    /** The log to be used for error reporting.
+     */
+    private final Log log;
+
+    /** The token factory. */
+    private final Tokens tokens;
+
+    /** The token kind, set by nextToken().
+     */
+    protected TokenKind tk;
+
+    /** The token's radix, set by nextToken().
+     */
+    protected int radix;
+
+    /** The token's name, set by nextToken().
+     */
+    protected Name name;
+
+    /** The position where a lexical error occurred;
+     */
+    protected int errPos = Position.NOPOS;
+
+    /** The Unicode reader (low-level stream reader).
+     */
+    protected UnicodeReader reader;
+
+    protected ScannerFactory fac;
+    
+    int seek;
+
+    private static final boolean hexFloatsWork = hexFloatsWork();
+    private static boolean hexFloatsWork() {
+        try {
+            Float.valueOf("0x1.0p1");
+            return true;
+        } catch (NumberFormatException ex) {
+            return false;
+        }
+    }
+
+    /**
+     * Create a scanner from the input array.  This method might
+     * modify the array.  To avoid copying the input array, ensure
+     * that {@code inputLength < input.length} or
+     * {@code input[input.length -1]} is a white space character.
+     *
+     * @param fac the factory which created this Scanner
+     * @param buf the input, might be modified
+     * Must be positive and less than or equal to input.length.
+     */
+    protected JavaTokenizer(ScannerFactory fac, CharBuffer buf) {
+        this(fac, new UnicodeReader(fac, buf));
+    }
+
+    protected JavaTokenizer(ScannerFactory fac, char[] buf, int inputLength) {
+        this(fac, new UnicodeReader(fac, buf, inputLength));
+    }
+
+    protected JavaTokenizer(ScannerFactory fac, UnicodeReader reader) {
+        this.fac = fac;
+        this.log = fac.log;
+        this.tokens = fac.tokens;
+        this.source = fac.source;
+        this.reader = reader;
+        this.allowBinaryLiterals = source.allowBinaryLiterals();
+        this.allowHexFloats = source.allowHexFloats();
+        this.allowUnderscoresInLiterals = source.allowUnderscoresInLiterals();
+    }
+
+    /** Report an error at the given position using the provided arguments.
+     */
+    protected void lexError(int pos, String key, Object... args) {
+        log.error(seek + pos, key, args);
+        tk = TokenKind.ERROR;
+        errPos = pos;
+    }
+
+    /** Read next character in character or string literal and copy into sbuf.
+     */
+    private void scanLitChar(int pos) {
+        if (reader.ch == '\\') {
+            if (reader.peekChar() == '\\' && !reader.isUnicode()) {
+                reader.skipChar();
+                reader.putChar('\\', true);
+            } else {
+                reader.scanChar();
+                switch (reader.ch) {
+                case '0': case '1': case '2': case '3':
+                case '4': case '5': case '6': case '7':
+                    char leadch = reader.ch;
+                    int oct = reader.digit(pos, 8);
+                    reader.scanChar();
+                    if ('0' <= reader.ch && reader.ch <= '7') {
+                        oct = oct * 8 + reader.digit(pos, 8);
+                        reader.scanChar();
+                        if (leadch <= '3' && '0' <= reader.ch && reader.ch <= '7') {
+                            oct = oct * 8 + reader.digit(pos, 8);
+                            reader.scanChar();
+                        }
+                    }
+                    reader.putChar((char)oct);
+                    break;
+                case 'b':
+                    reader.putChar('\b', true); break;
+                case 't':
+                    reader.putChar('\t', true); break;
+                case 'n':
+                    reader.putChar('\n', true); break;
+                case 'f':
+                    reader.putChar('\f', true); break;
+                case 'r':
+                    reader.putChar('\r', true); break;
+                case '\'':
+                    reader.putChar('\'', true); break;
+                case '\"':
+                    reader.putChar('\"', true); break;
+                case '\\':
+                    reader.putChar('\\', true); break;
+                default:
+                    lexError(reader.bp, "illegal.esc.char");
+                }
+            }
+        } else if (reader.bp != reader.buflen) {
+            reader.putChar(true);
+        }
+    }
+
+    private void scanDigits(int pos, int digitRadix) {
+        char saveCh;
+        int savePos;
+        do {
+            if (reader.ch != '_') {
+                reader.putChar(false);
+            } else {
+                if (!allowUnderscoresInLiterals) {
+                    lexError(pos, "unsupported.underscore.lit", source.name);
+                    allowUnderscoresInLiterals = true;
+                }
+            }
+            saveCh = reader.ch;
+            savePos = reader.bp;
+            reader.scanChar();
+        } while (reader.digit(pos, digitRadix) >= 0 || reader.ch == '_');
+        if (saveCh == '_')
+            lexError(savePos, "illegal.underscore");
+    }
+
+    /** Read fractional part of hexadecimal floating point number.
+     */
+    private void scanHexExponentAndSuffix(int pos) {
+        if (reader.ch == 'p' || reader.ch == 'P') {
+            reader.putChar(true);
+            skipIllegalUnderscores();
+            if (reader.ch == '+' || reader.ch == '-') {
+                reader.putChar(true);
+            }
+            skipIllegalUnderscores();
+            if ('0' <= reader.ch && reader.ch <= '9') {
+                scanDigits(pos, 10);
+                if (!allowHexFloats) {
+                    lexError(pos, "unsupported.fp.lit", source.name);
+                    allowHexFloats = true;
+                }
+                else if (!hexFloatsWork)
+                    lexError(pos, "unsupported.cross.fp.lit");
+            } else
+                lexError(pos, "malformed.fp.lit");
+        } else {
+            lexError(pos, "malformed.fp.lit");
+        }
+        if (reader.ch == 'f' || reader.ch == 'F') {
+            reader.putChar(true);
+            tk = TokenKind.FLOATLITERAL;
+            radix = 16;
+        } else {
+            if (reader.ch == 'd' || reader.ch == 'D') {
+                reader.putChar(true);
+            }
+            tk = TokenKind.DOUBLELITERAL;
+            radix = 16;
+        }
+    }
+
+    /** Read fractional part of floating point number.
+     */
+    private void scanFraction(int pos) {
+        skipIllegalUnderscores();
+        if ('0' <= reader.ch && reader.ch <= '9') {
+            scanDigits(pos, 10);
+        }
+        int sp1 = reader.sp;
+        if (reader.ch == 'e' || reader.ch == 'E') {
+            reader.putChar(true);
+            skipIllegalUnderscores();
+            if (reader.ch == '+' || reader.ch == '-') {
+                reader.putChar(true);
+            }
+            skipIllegalUnderscores();
+            if ('0' <= reader.ch && reader.ch <= '9') {
+                scanDigits(pos, 10);
+                return;
+            }
+            lexError(pos, "malformed.fp.lit");
+            reader.sp = sp1;
+        }
+    }
+
+    /** Read fractional part and 'd' or 'f' suffix of floating point number.
+     */
+    private void scanFractionAndSuffix(int pos) {
+        radix = 10;
+        scanFraction(pos);
+        if (reader.ch == 'f' || reader.ch == 'F') {
+            reader.putChar(true);
+            tk = TokenKind.FLOATLITERAL;
+        } else {
+            if (reader.ch == 'd' || reader.ch == 'D') {
+                reader.putChar(true);
+            }
+            tk = TokenKind.DOUBLELITERAL;
+        }
+    }
+
+    /** Read fractional part and 'd' or 'f' suffix of floating point number.
+     */
+    private void scanHexFractionAndSuffix(int pos, boolean seendigit) {
+        radix = 16;
+        Assert.check(reader.ch == '.');
+        reader.putChar(true);
+        skipIllegalUnderscores();
+        if (reader.digit(pos, 16) >= 0) {
+            seendigit = true;
+            scanDigits(pos, 16);
+        }
+        if (!seendigit)
+            lexError(pos, "invalid.hex.number");
+        else
+            scanHexExponentAndSuffix(pos);
+    }
+
+    private void skipIllegalUnderscores() {
+        if (reader.ch == '_') {
+            lexError(reader.bp, "illegal.underscore");
+            while (reader.ch == '_')
+                reader.scanChar();
+        }
+    }
+
+    /** Read a number.
+     *  @param radix  The radix of the number; one of 2, j8, 10, 16.
+     */
+    private void scanNumber(int pos, int radix) {
+        // for octal, allow base-10 digit in case it's a float literal
+        this.radix = radix;
+        int digitRadix = (radix == 8 ? 10 : radix);
+        boolean seendigit = false;
+        if (reader.digit(pos, digitRadix) >= 0) {
+            seendigit = true;
+            scanDigits(pos, digitRadix);
+        }
+        if (radix == 16 && reader.ch == '.') {
+            scanHexFractionAndSuffix(pos, seendigit);
+        } else if (seendigit && radix == 16 && (reader.ch == 'p' || reader.ch == 'P')) {
+            scanHexExponentAndSuffix(pos);
+        } else if (digitRadix == 10 && reader.ch == '.') {
+            reader.putChar(true);
+            scanFractionAndSuffix(pos);
+        } else if (digitRadix == 10 &&
+                   (reader.ch == 'e' || reader.ch == 'E' ||
+                    reader.ch == 'f' || reader.ch == 'F' ||
+                    reader.ch == 'd' || reader.ch == 'D')) {
+            scanFractionAndSuffix(pos);
+        } else {
+            if (reader.ch == 'l' || reader.ch == 'L') {
+                reader.scanChar();
+                tk = TokenKind.LONGLITERAL;
+            } else {
+                tk = TokenKind.INTLITERAL;
+            }
+        }
+    }
+
+    /** Read an identifier.
+     */
+    private void scanIdent() {
+        boolean isJavaIdentifierPart;
+        char high;
+        reader.putChar(true);
+        do {
+            switch (reader.ch) {
+            case 'A': case 'B': case 'C': case 'D': case 'E':
+            case 'F': case 'G': case 'H': case 'I': case 'J':
+            case 'K': case 'L': case 'M': case 'N': case 'O':
+            case 'P': case 'Q': case 'R': case 'S': case 'T':
+            case 'U': case 'V': case 'W': case 'X': case 'Y':
+            case 'Z':
+            case 'a': case 'b': case 'c': case 'd': case 'e':
+            case 'f': case 'g': case 'h': case 'i': case 'j':
+            case 'k': case 'l': case 'm': case 'n': case 'o':
+            case 'p': case 'q': case 'r': case 's': case 't':
+            case 'u': case 'v': case 'w': case 'x': case 'y':
+            case 'z':
+            case '$': case '_':
+            case '0': case '1': case '2': case '3': case '4':
+            case '5': case '6': case '7': case '8': case '9':
+                break;
+            case '\u0000': case '\u0001': case '\u0002': case '\u0003':
+            case '\u0004': case '\u0005': case '\u0006': case '\u0007':
+            case '\u0008': case '\u000E': case '\u000F': case '\u0010':
+            case '\u0011': case '\u0012': case '\u0013': case '\u0014':
+            case '\u0015': case '\u0016': case '\u0017':
+            case '\u0018': case '\u0019': case '\u001B':
+            case '\u007F':
+                reader.scanChar();
+                continue;
+            case '\u001A': // EOI is also a legal identifier part
+                if (reader.bp >= reader.buflen) {
+                    name = reader.name();
+                    tk = tokens.lookupKind(name);
+                    return;
+                }
+                reader.scanChar();
+                continue;
+            default:
+                if (reader.ch < '\u0080') {
+                    // all ASCII range chars already handled, above
+                    isJavaIdentifierPart = false;
+                } else {
+                    if (Character.isIdentifierIgnorable(reader.ch)) {
+                        reader.scanChar();
+                        continue;
+                    } else {
+                        high = reader.scanSurrogates();
+                        if (high != 0) {
+                            reader.putChar(high);
+                            isJavaIdentifierPart = Character.isJavaIdentifierPart(
+                                Character.toCodePoint(high, reader.ch));
+                        } else {
+                            isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch);
+                        }
+                    }
+                }
+                if (!isJavaIdentifierPart) {
+                    name = reader.name();
+                    tk = tokens.lookupKind(name);
+                    return;
+                }
+            }
+            reader.putChar(true);
+        } while (true);
+    }
+
+    /** Return true if reader.ch can be part of an operator.
+     */
+    private boolean isSpecial(char ch) {
+        switch (ch) {
+        case '!': case '%': case '&': case '*': case '?':
+        case '+': case '-': case ':': case '<': case '=':
+        case '>': case '^': case '|': case '~':
+        case '@':
+            return true;
+        default:
+            return false;
+        }
+    }
+
+    /** Read longest possible sequence of special characters and convert
+     *  to token.
+     */
+    private void scanOperator() {
+        while (true) {
+            reader.putChar(false);
+            Name newname = reader.name();
+            TokenKind tk1 = tokens.lookupKind(newname);
+            if (tk1 == TokenKind.IDENTIFIER) {
+                reader.sp--;
+                break;
+            }
+            tk = tk1;
+            reader.scanChar();
+            if (!isSpecial(reader.ch)) break;
+        }
+    }
+
+    /** Read token.
+     */
+    public Token readToken() {
+
+        reader.sp = 0;
+        name = null;
+        radix = 0;
+
+        int pos = 0;
+        int endPos = 0;
+        List<Comment> comments = null;
+
+        try {
+            loop: while (true) {
+                pos = reader.bp;
+                switch (reader.ch) {
+                case ' ': // (Spec 3.6)
+                case '\t': // (Spec 3.6)
+                case FF: // (Spec 3.6)
+                    do {
+                        reader.scanChar();
+                    } while (reader.ch == ' ' || reader.ch == '\t' || reader.ch == FF);
+                    processWhiteSpace(pos, reader.bp);
+                    break;
+                case LF: // (Spec 3.4)
+                    reader.scanChar();
+                    processLineTerminator(pos, reader.bp);
+                    break;
+                case CR: // (Spec 3.4)
+                    reader.scanChar();
+                    if (reader.ch == LF) {
+                        reader.scanChar();
+                    }
+                    processLineTerminator(pos, reader.bp);
+                    break;
+                case 'A': case 'B': case 'C': case 'D': case 'E':
+                case 'F': case 'G': case 'H': case 'I': case 'J':
+                case 'K': case 'L': case 'M': case 'N': case 'O':
+                case 'P': case 'Q': case 'R': case 'S': case 'T':
+                case 'U': case 'V': case 'W': case 'X': case 'Y':
+                case 'Z':
+                case 'a': case 'b': case 'c': case 'd': case 'e':
+                case 'f': case 'g': case 'h': case 'i': case 'j':
+                case 'k': case 'l': case 'm': case 'n': case 'o':
+                case 'p': case 'q': case 'r': case 's': case 't':
+                case 'u': case 'v': case 'w': case 'x': case 'y':
+                case 'z':
+                case '$': case '_':
+                    scanIdent();
+                    break loop;
+                case '0':
+                    reader.scanChar();
+                    if (reader.ch == 'x' || reader.ch == 'X') {
+                        reader.scanChar();
+                        skipIllegalUnderscores();
+                        if (reader.ch == '.') {
+                            scanHexFractionAndSuffix(pos, false);
+                        } else if (reader.digit(pos, 16) < 0) {
+                            lexError(pos, "invalid.hex.number");
+                        } else {
+                            scanNumber(pos, 16);
+                        }
+                    } else if (reader.ch == 'b' || reader.ch == 'B') {
+                        if (!allowBinaryLiterals) {
+                            lexError(pos, "unsupported.binary.lit", source.name);
+                            allowBinaryLiterals = true;
+                        }
+                        reader.scanChar();
+                        skipIllegalUnderscores();
+                        if (reader.digit(pos, 2) < 0) {
+                            lexError(pos, "invalid.binary.number");
+                        } else {
+                            scanNumber(pos, 2);
+                        }
+                    } else {
+                        reader.putChar('0');
+                        if (reader.ch == '_') {
+                            int savePos = reader.bp;
+                             if (!allowUnderscoresInLiterals) {
+                                lexError(pos, "unsupported.underscore.lit", source.name);
+                                allowUnderscoresInLiterals = true;
+                            }
+                            do {
+                                reader.scanChar();
+                            } while (reader.ch == '_');
+                            if (reader.digit(pos, 10) < 0) {
+                                lexError(savePos, "illegal.underscore");
+                            }
+                        }
+                        scanNumber(pos, 8);
+                    }
+                    break loop;
+                case '1': case '2': case '3': case '4':
+                case '5': case '6': case '7': case '8': case '9':
+                    scanNumber(pos, 10);
+                    break loop;
+                case '.':
+                    reader.scanChar();
+                    if ('0' <= reader.ch && reader.ch <= '9') {
+                        reader.putChar('.');
+                        scanFractionAndSuffix(pos);
+                    } else if (reader.ch == '.') {
+                        int savePos = reader.bp;
+                        reader.putChar('.'); reader.putChar('.', true);
+                        if (reader.ch == '.') {
+                            reader.scanChar();
+                            reader.putChar('.');
+                            tk = TokenKind.ELLIPSIS;
+                        } else {
+                            lexError(savePos, "illegal.dot");
+                        }
+                    } else {
+                        tk = TokenKind.DOT;
+                    }
+                    break loop;
+                case ',':
+                    reader.scanChar(); tk = TokenKind.COMMA; break loop;
+                case ';':
+                    reader.scanChar(); tk = TokenKind.SEMI; break loop;
+                case '(':
+                    reader.scanChar(); tk = TokenKind.LPAREN; break loop;
+                case ')':
+                    reader.scanChar(); tk = TokenKind.RPAREN; break loop;
+                case '[':
+                    reader.scanChar(); tk = TokenKind.LBRACKET; break loop;
+                case ']':
+                    reader.scanChar(); tk = TokenKind.RBRACKET; break loop;
+                case '{':
+                    reader.scanChar(); tk = TokenKind.LBRACE; break loop;
+                case '}':
+                    reader.scanChar(); tk = TokenKind.RBRACE; break loop;
+                case '/':
+                    reader.scanChar();
+                    if (reader.ch == '/') {
+                        do {
+                            reader.scanCommentChar();
+                        } while (reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen);
+                        if (reader.bp < reader.buflen) {
+                            comments = addComment(comments, processComment(pos, reader.bp, CommentStyle.LINE));
+                        }
+                        break;
+                    } else if (reader.ch == '*') {
+                        boolean isEmpty = false;
+                        reader.scanChar();
+                        CommentStyle style;
+                        if (reader.ch == '*') {
+                            style = CommentStyle.JAVADOC;
+                            reader.scanCommentChar();
+                            if (reader.ch == '/') {
+                                isEmpty = true;
+                            }
+                        } else {
+                            style = CommentStyle.BLOCK;
+                        }
+                        while (!isEmpty && reader.bp < reader.buflen) {
+                            if (reader.ch == '*') {
+                                reader.scanChar();
+                                if (reader.ch == '/') break;
+                            } else {
+                                reader.scanCommentChar();
+                            }
+                        }
+                        if (reader.ch == '/') {
+                            reader.scanChar();
+                            comments = addComment(comments, processComment(pos, reader.bp, style));
+                            break;
+                        } else {
+                            lexError(pos, "unclosed.comment");
+                            break loop;
+                        }
+                    } else if (reader.ch == '=') {
+                        tk = TokenKind.SLASHEQ;
+                        reader.scanChar();
+                    } else {
+                        tk = TokenKind.SLASH;
+                    }
+                    break loop;
+                case '\'':
+                    reader.scanChar();
+                    if (reader.ch == '\'') {
+                        lexError(pos, "empty.char.lit");
+                    } else {
+                        if (reader.ch == CR || reader.ch == LF)
+                            lexError(pos, "illegal.line.end.in.char.lit");
+                        scanLitChar(pos);
+                        char ch2 = reader.ch;
+                        if (reader.ch == '\'') {
+                            reader.scanChar();
+                            tk = TokenKind.CHARLITERAL;
+                        } else {
+                            lexError(pos, "unclosed.char.lit");
+                        }
+                    }
+                    break loop;
+                case '\"':
+                    reader.scanChar();
+                    while (reader.ch != '\"' && reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen)
+                        scanLitChar(pos);
+                    if (reader.ch == '\"') {
+                        tk = TokenKind.STRINGLITERAL;
+                        reader.scanChar();
+                    } else {
+                        lexError(pos, "unclosed.str.lit");
+                    }
+                    break loop;
+                default:
+                    if (isSpecial(reader.ch)) {
+                        scanOperator();
+                    } else {
+                        boolean isJavaIdentifierStart;
+                        if (reader.ch < '\u0080') {
+                            // all ASCII range chars already handled, above
+                            isJavaIdentifierStart = false;
+                        } else {
+                            char high = reader.scanSurrogates();
+                            if (high != 0) {
+                                reader.putChar(high);
+
+                                isJavaIdentifierStart = Character.isJavaIdentifierStart(
+                                    Character.toCodePoint(high, reader.ch));
+                            } else {
+                                isJavaIdentifierStart = Character.isJavaIdentifierStart(reader.ch);
+                            }
+                        }
+                        if (isJavaIdentifierStart) {
+                            scanIdent();
+                        } else if (reader.bp == reader.buflen || reader.ch == EOI && reader.bp + 1 == reader.buflen) { // JLS 3.5
+                            tk = TokenKind.EOF;
+                            pos = reader.realLength;
+                        } else {
+                            String arg = (32 < reader.ch && reader.ch < 127) ?
+                                            String.format("%s", reader.ch) :
+                                            String.format("\\u%04x", (int)reader.ch);
+                            lexError(pos, "illegal.char", arg);
+                            reader.scanChar();
+                        }
+                    }
+                    break loop;
+                }
+            }
+            endPos = reader.bp;
+            switch (tk.tag) {
+                case DEFAULT: return new Token(tk, seek + pos, seek + endPos, comments);
+                case NAMED: return new NamedToken(tk, seek + pos, seek + endPos, name, comments);
+                case STRING: return new StringToken(tk, seek + pos, seek + endPos, reader.chars(), comments);
+                case NUMERIC: return new NumericToken(tk, seek + pos, seek + endPos, reader.chars(), radix, comments);
+                default: throw new AssertionError();
+            }
+        }
+        finally {
+            if (scannerDebug) {
+                    System.out.println("nextToken(" + pos
+                                       + "," + endPos + ")=|" +
+                                       new String(reader.getRawCharacters(pos, endPos))
+                                       + "|");
+            }
+        }
+    }
+    //where
+        List<Comment> addComment(List<Comment> comments, Comment comment) {
+            return comments == null ?
+                    List.of(comment) :
+                    comments.prepend(comment);
+        }
+
+    /** Return the position where a lexical error occurred;
+     */
+    public int errPos() {
+        return errPos == Position.NOPOS ? errPos : seek + errPos;
+    }
+
+    /** Set the position where a lexical error occurred;
+     */
+    public void errPos(int pos) {
+        errPos = pos == Position.NOPOS ? pos: pos - seek;
+    }
+
+    /**
+     * Called when a complete comment has been scanned. pos and endPos
+     * will mark the comment boundary.
+     */
+    protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
+        if (scannerDebug)
+            System.out.println("processComment(" + pos
+                               + "," + endPos + "," + style + ")=|"
+                               + new String(reader.getRawCharacters(pos, endPos))
+                               + "|");
+        char[] buf = reader.getRawCharacters(pos, endPos);
+        return new BasicComment<UnicodeReader>(new UnicodeReader(fac, buf, buf.length), style);
+    }
+
+    /**
+     * Called when a complete whitespace run has been scanned. pos and endPos
+     * will mark the whitespace boundary.
+     */
+    protected void processWhiteSpace(int pos, int endPos) {
+        if (scannerDebug)
+            System.out.println("processWhitespace(" + pos
+                               + "," + endPos + ")=|" +
+                               new String(reader.getRawCharacters(pos, endPos))
+                               + "|");
+    }
+
+    /**
+     * Called when a line terminator has been processed.
+     */
+    protected void processLineTerminator(int pos, int endPos) {
+        if (scannerDebug)
+            System.out.println("processTerminator(" + pos
+                               + "," + endPos + ")=|" +
+                               new String(reader.getRawCharacters(pos, endPos))
+                               + "|");
+    }
+
+    /** Build a map for translating between line numbers and
+     * positions in the input.
+     *
+     * @return a LineMap */
+    public Position.LineMap getLineMap() {
+        char[] buf = reader.getRawCharacters();
+        return Position.makeLineMap(buf, buf.length, false);
+    }
+
+
+    /**
+    * Scan a documentation comment; determine if a deprecated tag is present.
+    * Called once the initial /, * have been skipped, positioned at the second *
+    * (which is treated as the beginning of the first line).
+    * Stops positioned at the closing '/'.
+    */
+    protected static class BasicComment<U extends UnicodeReader> implements Comment {
+
+        CommentStyle cs;
+        U comment_reader;
+
+        protected boolean deprecatedFlag = false;
+        protected boolean scanned = false;
+
+        protected BasicComment(U comment_reader, CommentStyle cs) {
+            this.comment_reader = comment_reader;
+            this.cs = cs;
+        }
+
+        public String getText() {
+            return null;
+        }
+
+        public int getSourcePos(int pos) {
+            return -1;
+        }
+
+        public CommentStyle getStyle() {
+            return cs;
+        }
+
+        public boolean isDeprecated() {
+            if (!scanned && cs == CommentStyle.JAVADOC) {
+                scanDocComment();
+            }
+            return deprecatedFlag;
+        }
+
+        @SuppressWarnings("fallthrough")
+        protected void scanDocComment() {
+            try {
+                boolean deprecatedPrefix = false;
+
+                comment_reader.bp += 3; // '/**'
+                comment_reader.ch = comment_reader.buf[comment_reader.bp];
+
+                forEachLine:
+                while (comment_reader.bp < comment_reader.buflen) {
+
+                    // Skip optional WhiteSpace at beginning of line
+                    while (comment_reader.bp < comment_reader.buflen && (comment_reader.ch == ' ' || comment_reader.ch == '\t' || comment_reader.ch == FF)) {
+                        comment_reader.scanCommentChar();
+                    }
+
+                    // Skip optional consecutive Stars
+                    while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '*') {
+                        comment_reader.scanCommentChar();
+                        if (comment_reader.ch == '/') {
+                            return;
+                        }
+                    }
+
+                    // Skip optional WhiteSpace after Stars
+                    while (comment_reader.bp < comment_reader.buflen && (comment_reader.ch == ' ' || comment_reader.ch == '\t' || comment_reader.ch == FF)) {
+                        comment_reader.scanCommentChar();
+                    }
+
+                    deprecatedPrefix = false;
+                    // At beginning of line in the JavaDoc sense.
+                    if (!deprecatedFlag) {
+                        String deprecated = "@deprecated";
+                        int i = 0;
+                        while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == deprecated.charAt(i)) {
+                            comment_reader.scanCommentChar();
+                            i++;
+                            if (i == deprecated.length()) {
+                                deprecatedPrefix = true;
+                                break;
+                            }
+                        }
+                    }
+
+                    if (deprecatedPrefix && comment_reader.bp < comment_reader.buflen) {
+                        if (Character.isWhitespace(comment_reader.ch)) {
+                            deprecatedFlag = true;
+                        } else if (comment_reader.ch == '*') {
+                            comment_reader.scanCommentChar();
+                            if (comment_reader.ch == '/') {
+                                deprecatedFlag = true;
+                                return;
+                            }
+                        }
+                    }
+
+                    // Skip rest of line
+                    while (comment_reader.bp < comment_reader.buflen) {
+                        switch (comment_reader.ch) {
+                            case '*':
+                                comment_reader.scanCommentChar();
+                                if (comment_reader.ch == '/') {
+                                    return;
+                                }
+                                break;
+                            case CR: // (Spec 3.4)
+                                comment_reader.scanCommentChar();
+                                if (comment_reader.ch != LF) {
+                                    continue forEachLine;
+                                }
+                            /* fall through to LF case */
+                            case LF: // (Spec 3.4)
+                                comment_reader.scanCommentChar();
+                                continue forEachLine;
+                            default:
+                                comment_reader.scanCommentChar();
+                        }
+                    } // rest of line
+                } // forEachLine
+                return;
+            } finally {
+                scanned = true;
+            }
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
index 5b670c9..581b4ec 100644
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -27,7 +27,12 @@ package com.sun.tools.javac.parser;
 
 import java.util.*;
 
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+import com.sun.source.util.DocTrees;
+
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.parser.Tokens.*;
+import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
@@ -35,8 +40,16 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
 
+import static com.sun.tools.javac.parser.Tokens.TokenKind.*;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.ASSERT;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.CASE;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.CATCH;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.EQ;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.GT;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT;
+import static com.sun.tools.javac.parser.Tokens.TokenKind.LT;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.util.ListBuffer.lb;
-import static com.sun.tools.javac.parser.Token.*;
 
 /** The parser maps a token sequence into an abstract syntax
  *  tree. It operates by recursive descent, with code derived
@@ -67,27 +80,71 @@ public class JavacParser implements Parser {
      */
     private Log log;
 
-    /** The keyword table. */
-    private Keywords keywords;
-
     /** The Source language setting. */
     private Source source;
 
     /** The name table. */
     private Names names;
 
+    /** End position mappings container */
+    private final AbstractEndPosTable endPosTable;
+
+    // Because of javac's limited lookahead, some contexts are ambiguous in
+    // the presence of type annotations even though they are not ambiguous
+    // in the absence of type annotations.  Consider this code:
+    //   void m(String [] m) { }
+    //   void m(String ... m) { }
+    // After parsing "String", javac calls bracketsOpt which immediately
+    // returns if the next character is not '['.  Similarly, javac can see
+    // if the next token is ... and in that case parse an ellipsis.  But in
+    // the presence of type annotations:
+    //   void m(String @A [] m) { }
+    //   void m(String @A ... m) { }
+    // no finite lookahead is enough to determine whether to read array
+    // levels or an ellipsis.  Furthermore, if you call bracketsOpt, then
+    // bracketsOpt first reads all the leading annotations and only then
+    // discovers that it needs to fail.  bracketsOpt needs a way to push
+    // back the extra annotations that it read.  (But, bracketsOpt should
+    // not *always* be allowed to push back extra annotations that it finds
+    // -- in most contexts, any such extra annotation is an error.
+    //
+    // The following two variables permit type annotations that have
+    // already been read to be stored for later use.  Alternate
+    // implementations are possible but would cause much larger changes to
+    // the parser.
+
+    /** Type annotations that have already been read but have not yet been used. **/
+    private List<JCAnnotation> typeAnnotationsPushedBack = List.nil();
+
+    /**
+     * If the parser notices extra annotations, then it either immediately
+     * issues an error (if this variable is false) or places the extra
+     * annotations in variable typeAnnotationsPushedBack (if this variable
+     * is true).
+     */
+    private boolean permitTypeAnnotationsPushBack = false;
+
+    interface ErrorRecoveryAction {
+        JCTree doRecover(JavacParser parser);
+    }
+
+    enum BasicErrorRecoveryAction implements ErrorRecoveryAction {
+        BLOCK_STMT {public JCTree doRecover(JavacParser parser) { return parser.parseStatementAsBlock(); }},
+        CATCH_CLAUSE {public JCTree doRecover(JavacParser parser) { return parser.catchClause(); }}
+    }
+
     /** Construct a parser from a given scanner, tree factory and log.
      */
     protected JavacParser(ParserFactory fac,
                      Lexer S,
                      boolean keepDocComments,
-                     boolean keepLineMap) {
+                     boolean keepLineMap,
+                     boolean keepEndPositions) {
         this.S = S;
-        S.nextToken(); // prime the pump
+        nextToken(); // prime the pump
         this.F = fac.F;
         this.log = fac.log;
         this.names = fac.names;
-        this.keywords = fac.keywords;
         this.source = fac.source;
         this.allowGenerics = source.allowGenerics();
         this.allowVarargs = source.allowVarargs();
@@ -100,10 +157,27 @@ public class JavacParser implements Parser {
         this.allowDiamond = source.allowDiamond();
         this.allowMulticatch = source.allowMulticatch();
         this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
+        this.allowLambda = source.allowLambda();
+        this.allowMethodReferences = source.allowMethodReferences();
+        this.allowDefaultMethods = source.allowDefaultMethods();
+        this.allowStaticInterfaceMethods = source.allowStaticInterfaceMethods();
+        this.allowIntersectionTypesInCast = source.allowIntersectionTypesInCast();
+        this.allowTypeAnnotations = source.allowTypeAnnotations();
         this.keepDocComments = keepDocComments;
-        docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
+        endPosTable = newEndPosTable(keepEndPositions);
+        docComments = newDocCommentTable(keepDocComments, fac, endPosTable);
+    }
+
+    protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
+        return  keepEndPositions
+                ? new SimpleEndPosTable(this)
+                : new EmptyEndPosTable(this);
+    }
+
+    protected DocCommentTable newDocCommentTable(boolean keepDocComments, ParserFactory fac, EndPosTable ept) {
+        return keepDocComments ? new LazyDocCommentTable(fac, ept) : null;
     }
 
     /** Switch: Should generics be recognized?
@@ -150,6 +224,26 @@ public class JavacParser implements Parser {
      */
     boolean allowStringFolding;
 
+    /** Switch: should we recognize lambda expressions?
+     */
+    boolean allowLambda;
+
+    /** Switch: should we allow method/constructor references?
+     */
+    boolean allowMethodReferences;
+
+    /** Switch: should we allow default methods in interfaces?
+     */
+    boolean allowDefaultMethods;
+
+    /** Switch: should we allow static methods in interfaces?
+     */
+    boolean allowStaticInterfaceMethods;
+
+    /** Switch: should we allow intersection types in cast?
+     */
+    boolean allowIntersectionTypesInCast;
+
     /** Switch: should we keep docComments?
      */
     boolean keepDocComments;
@@ -158,6 +252,20 @@ public class JavacParser implements Parser {
      */
     boolean keepLineMap;
 
+    /** Switch: should we recognize type annotations?
+     */
+    boolean allowTypeAnnotations;
+
+    /** Switch: is "this" allowed as an identifier?
+     * This is needed to parse receiver types.
+     */
+    boolean allowThisIdent;
+
+    /** The type of the method receiver, as specified by a first "this" parameter.
+     */
+    JCVariableDecl receiverParam;
+
+
     /** When terms are parsed, the mode determines which is expected:
      *     mode = EXPR        : an expression
      *     mode = TYPE        : a type
@@ -178,7 +286,62 @@ public class JavacParser implements Parser {
      */
     private int lastmode = 0;
 
-/* ---------- error recovery -------------- */
+    /* ---------- token management -------------- */
+
+    protected Token token;
+
+    public Token token() {
+        return token;
+    }
+
+    public void nextToken() {
+        S.nextToken();
+        token = S.token();
+    }
+
+    protected boolean peekToken(Filter<TokenKind> tk) {
+        return peekToken(0, tk);
+    }
+
+    protected boolean peekToken(int lookahead, Filter<TokenKind> tk) {
+        return tk.accepts(S.token(lookahead + 1).kind);
+    }
+
+    protected boolean peekToken(Filter<TokenKind> tk1, Filter<TokenKind> tk2) {
+        return peekToken(0, tk1, tk2);
+    }
+
+    protected boolean peekToken(int lookahead, Filter<TokenKind> tk1, Filter<TokenKind> tk2) {
+        return tk1.accepts(S.token(lookahead + 1).kind) &&
+                tk2.accepts(S.token(lookahead + 2).kind);
+    }
+
+    protected boolean peekToken(Filter<TokenKind> tk1, Filter<TokenKind> tk2, Filter<TokenKind> tk3) {
+        return peekToken(0, tk1, tk2, tk3);
+    }
+
+    protected boolean peekToken(int lookahead, Filter<TokenKind> tk1, Filter<TokenKind> tk2, Filter<TokenKind> tk3) {
+        return tk1.accepts(S.token(lookahead + 1).kind) &&
+                tk2.accepts(S.token(lookahead + 2).kind) &&
+                tk3.accepts(S.token(lookahead + 3).kind);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected boolean peekToken(Filter<TokenKind>... kinds) {
+        return peekToken(0, kinds);
+    }
+
+    @SuppressWarnings("unchecked")
+    protected boolean peekToken(int lookahead, Filter<TokenKind>... kinds) {
+        for (; lookahead < kinds.length ; lookahead++) {
+            if (!kinds[lookahead].accepts(S.token(lookahead + 1).kind)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /* ---------- error recovery -------------- */
 
     private JCErroneous errorTree;
 
@@ -186,9 +349,9 @@ public class JavacParser implements Parser {
      */
     private void skip(boolean stopAtImport, boolean stopAtMemberDecl, boolean stopAtIdentifier, boolean stopAtStatement) {
          while (true) {
-             switch (S.token()) {
+             switch (token.kind) {
                 case SEMI:
-                    S.nextToken();
+                    nextToken();
                     return;
                 case PUBLIC:
                 case FINAL:
@@ -226,6 +389,7 @@ public class JavacParser implements Parser {
                     if (stopAtMemberDecl)
                         return;
                     break;
+                case UNDERSCORE:
                 case IDENTIFIER:
                    if (stopAtIdentifier)
                         return;
@@ -251,15 +415,15 @@ public class JavacParser implements Parser {
                         return;
                     break;
             }
-            S.nextToken();
+            nextToken();
         }
     }
 
-    private JCErroneous syntaxError(int pos, String key, Token... args) {
+    private JCErroneous syntaxError(int pos, String key, TokenKind... args) {
         return syntaxError(pos, List.<JCTree>nil(), key, args);
     }
 
-    private JCErroneous syntaxError(int pos, List<JCTree> errs, String key, Token... args) {
+    private JCErroneous syntaxError(int pos, List<JCTree> errs, String key, TokenKind... args) {
         setErrorEndPos(pos);
         JCErroneous err = F.at(pos).Erroneous(errs);
         reportSyntaxError(err, key, (Object[])args);
@@ -287,7 +451,7 @@ public class JavacParser implements Parser {
     private void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, String key, Object... args) {
         int pos = diagPos.getPreferredPosition();
         if (pos > S.errPos() || pos == Position.NOPOS) {
-            if (S.token() == EOF) {
+            if (token.kind == EOF) {
                 error(diagPos, "premature.eof");
             } else {
                 error(diagPos, key, args);
@@ -300,25 +464,25 @@ public class JavacParser implements Parser {
      *  reported at the same position.
      */
     private JCErroneous syntaxError(String key) {
-        return syntaxError(S.pos(), key);
+        return syntaxError(token.pos, key);
     }
 
     /** Generate a syntax error at current position unless one was
      *  already reported at the same position.
      */
-    private JCErroneous syntaxError(String key, Token arg) {
-        return syntaxError(S.pos(), key, arg);
+    private JCErroneous syntaxError(String key, TokenKind arg) {
+        return syntaxError(token.pos, key, arg);
     }
 
     /** If next input token matches given token, skip it, otherwise report
      *  an error.
      */
-    public void accept(Token token) {
-        if (S.token() == token) {
-            S.nextToken();
+    public void accept(TokenKind tk) {
+        if (token.kind == tk) {
+            nextToken();
         } else {
-            setErrorEndPos(S.pos());
-            reportSyntaxError(S.prevEndPos(), "expected", token);
+            setErrorEndPos(token.pos);
+            reportSyntaxError(S.prevToken().endPos, "expected", tk);
         }
     }
 
@@ -336,75 +500,59 @@ public class JavacParser implements Parser {
     /** Report an illegal start of expression/type error at current position.
      */
     JCExpression illegal() {
-        return illegal(S.pos());
+        return illegal(token.pos);
     }
 
     /** Diagnose a modifier flag from the set, if any. */
     void checkNoMods(long mods) {
         if (mods != 0) {
             long lowestMod = mods & -mods;
-            error(S.pos(), "mod.not.allowed.here",
+            error(token.pos, "mod.not.allowed.here",
                       Flags.asFlagSet(lowestMod));
         }
     }
 
 /* ---------- doc comments --------- */
 
-    /** A hashtable to store all documentation comments
+    /** A table to store all documentation comments
      *  indexed by the tree nodes they refer to.
      *  defined only if option flag keepDocComment is set.
      */
-    private final Map<JCTree, String> docComments;
+    private final DocCommentTable docComments;
 
     /** Make an entry into docComments hashtable,
      *  provided flag keepDocComments is set and given doc comment is non-null.
      *  @param tree   The tree to be used as index in the hashtable
      *  @param dc     The doc comment to associate with the tree, or null.
      */
-    void attach(JCTree tree, String dc) {
+    void attach(JCTree tree, Comment dc) {
         if (keepDocComments && dc != null) {
 //          System.out.println("doc comment = ");System.out.println(dc);//DEBUG
-            docComments.put(tree, dc);
+            docComments.putComment(tree, dc);
         }
     }
 
-    public Map<JCTree, String> getDocComments() {
-        return docComments == null ? Collections.<JCTree,String>emptyMap() : Collections.unmodifiableMap(docComments);
+    public DocCommentTable getDocComments() {
+        return docComments;
     }
 
 /* -------- source positions ------- */
 
-    private int errorEndPos = -1;
-
     private void setErrorEndPos(int errPos) {
-        if (errPos > errorEndPos)
-            errorEndPos = errPos;
+        endPosTable.setErrorEndPos(errPos);
     }
 
-    protected int getErrorEndPos() {
-        return errorEndPos;
+    private void storeEnd(JCTree tree, int endpos) {
+        endPosTable.storeEnd(tree, endpos);
     }
 
-    /**
-     * Store ending position for a tree.
-     * @param tree   The tree.
-     * @param endpos The ending position to associate with the tree.
-     */
-    protected void storeEnd(JCTree tree, int endpos) {}
-
-    /**
-     * Store ending position for a tree.  The ending position should
-     * be the ending position of the current token.
-     * @param t The tree.
-     */
-    protected <T extends JCTree> T to(T t) { return t; }
+    private <T extends JCTree> T to(T t) {
+        return endPosTable.to(t);
+    }
 
-    /**
-     * Store ending position for a tree.  The ending position should
-     * be greater of the ending position of the previous token and errorEndPos.
-     * @param t The tree.
-     */
-    protected <T extends JCTree> T toP(T t) { return t; }
+    private <T extends JCTree> T toP(T t) {
+        return endPosTable.toP(t);
+    }
 
     /** Get the start position for a tree node.  The start position is
      * defined to be the position of the first character of the first
@@ -424,7 +572,7 @@ public class JavacParser implements Parser {
      * @param tree  The tree node
      */
     public int getEndPos(JCTree tree) {
-        return Position.NOPOS;
+        return TreeInfo.getEndPos(tree, endPosTable);
     }
 
 
@@ -435,53 +583,77 @@ public class JavacParser implements Parser {
      * Ident = IDENTIFIER
      */
     Name ident() {
-        if (S.token() == IDENTIFIER) {
-            Name name = S.name();
-            S.nextToken();
+        if (token.kind == IDENTIFIER) {
+            Name name = token.name();
+            nextToken();
             return name;
-        } else if (S.token() == ASSERT) {
+        } else if (token.kind == ASSERT) {
             if (allowAsserts) {
-                error(S.pos(), "assert.as.identifier");
-                S.nextToken();
+                error(token.pos, "assert.as.identifier");
+                nextToken();
                 return names.error;
             } else {
-                warning(S.pos(), "assert.as.identifier");
-                Name name = S.name();
-                S.nextToken();
+                warning(token.pos, "assert.as.identifier");
+                Name name = token.name();
+                nextToken();
                 return name;
             }
-        } else if (S.token() == ENUM) {
+        } else if (token.kind == ENUM) {
             if (allowEnums) {
-                error(S.pos(), "enum.as.identifier");
-                S.nextToken();
+                error(token.pos, "enum.as.identifier");
+                nextToken();
                 return names.error;
             } else {
-                warning(S.pos(), "enum.as.identifier");
-                Name name = S.name();
-                S.nextToken();
+                warning(token.pos, "enum.as.identifier");
+                Name name = token.name();
+                nextToken();
                 return name;
             }
+        } else if (token.kind == THIS) {
+            if (allowThisIdent) {
+                // Make sure we're using a supported source version.
+                checkTypeAnnotations();
+                Name name = token.name();
+                nextToken();
+                return name;
+            } else {
+                error(token.pos, "this.as.identifier");
+                nextToken();
+                return names.error;
+            }
+        } else if (token.kind == UNDERSCORE) {
+            warning(token.pos, "underscore.as.identifier");
+            Name name = token.name();
+            nextToken();
+            return name;
         } else {
             accept(IDENTIFIER);
             return names.error;
         }
-}
+    }
 
     /**
-     * Qualident = Ident { DOT Ident }
+     * Qualident = Ident { DOT [Annotations] Ident }
      */
-    public JCExpression qualident() {
-        JCExpression t = toP(F.at(S.pos()).Ident(ident()));
-        while (S.token() == DOT) {
-            int pos = S.pos();
-            S.nextToken();
+    public JCExpression qualident(boolean allowAnnos) {
+        JCExpression t = toP(F.at(token.pos).Ident(ident()));
+        while (token.kind == DOT) {
+            int pos = token.pos;
+            nextToken();
+            List<JCAnnotation> tyannos = null;
+            if (allowAnnos) {
+                tyannos = typeAnnotationsOpt();
+            }
             t = toP(F.at(pos).Select(t, ident()));
+            if (tyannos != null && tyannos.nonEmpty()) {
+                t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t));
+            }
         }
         return t;
     }
 
     JCExpression literal(Name prefix) {
-        return literal(prefix, S.pos());
+        return literal(prefix, token.pos);
     }
 
     /**
@@ -498,27 +670,29 @@ public class JavacParser implements Parser {
      */
     JCExpression literal(Name prefix, int pos) {
         JCExpression t = errorTree;
-        switch (S.token()) {
+        switch (token.kind) {
         case INTLITERAL:
             try {
                 t = F.at(pos).Literal(
-                    TypeTags.INT,
-                    Convert.string2int(strval(prefix), S.radix()));
+                    TypeTag.INT,
+                    Convert.string2int(strval(prefix), token.radix()));
             } catch (NumberFormatException ex) {
-                error(S.pos(), "int.number.too.large", strval(prefix));
+                error(token.pos, "int.number.too.large", strval(prefix));
             }
             break;
         case LONGLITERAL:
             try {
                 t = F.at(pos).Literal(
-                    TypeTags.LONG,
-                    new Long(Convert.string2long(strval(prefix), S.radix())));
+                    TypeTag.LONG,
+                    new Long(Convert.string2long(strval(prefix), token.radix())));
             } catch (NumberFormatException ex) {
-                error(S.pos(), "int.number.too.large", strval(prefix));
+                error(token.pos, "int.number.too.large", strval(prefix));
             }
             break;
         case FLOATLITERAL: {
-            String proper = (S.radix() == 16 ? ("0x"+ S.stringVal()) : S.stringVal());
+            String proper = token.radix() == 16 ?
+                    ("0x"+ token.stringVal()) :
+                    token.stringVal();
             Float n;
             try {
                 n = Float.valueOf(proper);
@@ -527,15 +701,17 @@ public class JavacParser implements Parser {
                 n = Float.NaN;
             }
             if (n.floatValue() == 0.0f && !isZero(proper))
-                error(S.pos(), "fp.number.too.small");
+                error(token.pos, "fp.number.too.small");
             else if (n.floatValue() == Float.POSITIVE_INFINITY)
-                error(S.pos(), "fp.number.too.large");
+                error(token.pos, "fp.number.too.large");
             else
-                t = F.at(pos).Literal(TypeTags.FLOAT, n);
+                t = F.at(pos).Literal(TypeTag.FLOAT, n);
             break;
         }
         case DOUBLELITERAL: {
-            String proper = (S.radix() == 16 ? ("0x"+ S.stringVal()) : S.stringVal());
+            String proper = token.radix() == 16 ?
+                    ("0x"+ token.stringVal()) :
+                    token.stringVal();
             Double n;
             try {
                 n = Double.valueOf(proper);
@@ -544,31 +720,31 @@ public class JavacParser implements Parser {
                 n = Double.NaN;
             }
             if (n.doubleValue() == 0.0d && !isZero(proper))
-                error(S.pos(), "fp.number.too.small");
+                error(token.pos, "fp.number.too.small");
             else if (n.doubleValue() == Double.POSITIVE_INFINITY)
-                error(S.pos(), "fp.number.too.large");
+                error(token.pos, "fp.number.too.large");
             else
-                t = F.at(pos).Literal(TypeTags.DOUBLE, n);
+                t = F.at(pos).Literal(TypeTag.DOUBLE, n);
             break;
         }
         case CHARLITERAL:
             t = F.at(pos).Literal(
-                TypeTags.CHAR,
-                S.stringVal().charAt(0) + 0);
+                TypeTag.CHAR,
+                token.stringVal().charAt(0) + 0);
             break;
         case STRINGLITERAL:
             t = F.at(pos).Literal(
-                TypeTags.CLASS,
-                S.stringVal());
+                TypeTag.CLASS,
+                token.stringVal());
             break;
         case TRUE: case FALSE:
             t = F.at(pos).Literal(
-                TypeTags.BOOLEAN,
-                (S.token() == TRUE ? 1 : 0));
+                TypeTag.BOOLEAN,
+                (token.kind == TRUE ? 1 : 0));
             break;
         case NULL:
             t = F.at(pos).Literal(
-                TypeTags.BOT,
+                TypeTag.BOT,
                 null);
             break;
         default:
@@ -576,11 +752,11 @@ public class JavacParser implements Parser {
         }
         if (t == errorTree)
             t = F.at(pos).Erroneous();
-        storeEnd(t, S.endPos());
-        S.nextToken();
+        storeEnd(t, token.endPos);
+        nextToken();
         return t;
     }
-//where
+    //where
         boolean isZero(String s) {
             char[] cs = s.toCharArray();
             int base = ((cs.length > 1 && Character.toLowerCase(cs[1]) == 'x') ? 16 : 10);
@@ -590,7 +766,7 @@ public class JavacParser implements Parser {
         }
 
         String strval(Name prefix) {
-            String s = S.stringVal();
+            String s = token.stringVal();
             return prefix.isEmpty() ? s : prefix + s;
         }
 
@@ -600,7 +776,34 @@ public class JavacParser implements Parser {
         return term(EXPR);
     }
 
+    /**
+     * parses (optional) type annotations followed by a type. If the
+     * annotations are present before the type and are not consumed during array
+     * parsing, this method returns a {@link JCAnnotatedType} consisting of
+     * these annotations and the underlying type. Otherwise, it returns the
+     * underlying type.
+     *
+     * <p>
+     *
+     * Note that this method sets {@code mode} to {@code TYPE} first, before
+     * parsing annotations.
+     */
     public JCExpression parseType() {
+        List<JCAnnotation> annotations = typeAnnotationsOpt();
+        return parseType(annotations);
+    }
+
+    public JCExpression parseType(List<JCAnnotation> annotations) {
+        JCExpression result = unannotatedType();
+
+        if (annotations.nonEmpty()) {
+            result = insertAnnotationsToMostInner(result, annotations, false);
+        }
+
+        return result;
+    }
+
+    public JCExpression unannotatedType() {
         return term(TYPE);
     }
 
@@ -614,6 +817,7 @@ public class JavacParser implements Parser {
     }
 
     /**
+     *  {@literal
      *  Expression = Expression1 [ExpressionRest]
      *  ExpressionRest = [AssignmentOperator Expression1]
      *  AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" |
@@ -623,21 +827,22 @@ public class JavacParser implements Parser {
      *  TypeNoParams = TypeNoParams1
      *  StatementExpression = Expression
      *  ConstantExpression = Expression
+     *  }
      */
     JCExpression term() {
         JCExpression t = term1();
         if ((mode & EXPR) != 0 &&
-            S.token() == EQ || PLUSEQ.compareTo(S.token()) <= 0 && S.token().compareTo(GTGTGTEQ) <= 0)
+            token.kind == EQ || PLUSEQ.compareTo(token.kind) <= 0 && token.kind.compareTo(GTGTGTEQ) <= 0)
             return termRest(t);
         else
             return t;
     }
 
     JCExpression termRest(JCExpression t) {
-        switch (S.token()) {
+        switch (token.kind) {
         case EQ: {
-            int pos = S.pos();
-            S.nextToken();
+            int pos = token.pos;
+            nextToken();
             mode = EXPR;
             JCExpression t1 = term();
             return toP(F.at(pos).Assign(t, t1));
@@ -653,12 +858,12 @@ public class JavacParser implements Parser {
         case LTLTEQ:
         case GTGTEQ:
         case GTGTGTEQ:
-            int pos = S.pos();
-            Token token = S.token();
-            S.nextToken();
+            int pos = token.pos;
+            TokenKind tk = token.kind;
+            nextToken();
             mode = EXPR;
             JCExpression t1 = term();
-            return F.at(pos).Assignop(optag(token), t, t1);
+            return F.at(pos).Assignop(optag(tk), t, t1);
         default:
             return t;
         }
@@ -670,7 +875,7 @@ public class JavacParser implements Parser {
      */
     JCExpression term1() {
         JCExpression t = term2();
-        if ((mode & EXPR) != 0 && S.token() == QUES) {
+        if ((mode & EXPR) != 0 && token.kind == QUES) {
             mode = EXPR;
             return term1Rest(t);
         } else {
@@ -681,9 +886,9 @@ public class JavacParser implements Parser {
     /** Expression1Rest = ["?" Expression ":" Expression1]
      */
     JCExpression term1Rest(JCExpression t) {
-        if (S.token() == QUES) {
-            int pos = S.pos();
-            S.nextToken();
+        if (token.kind == QUES) {
+            int pos = token.pos;
+            nextToken();
             JCExpression t1 = term();
             accept(COLON);
             JCExpression t2 = term1();
@@ -699,7 +904,7 @@ public class JavacParser implements Parser {
      */
     JCExpression term2() {
         JCExpression t = term3();
-        if ((mode & EXPR) != 0 && prec(S.token()) >= TreeInfo.orPrec) {
+        if ((mode & EXPR) != 0 && prec(token.kind) >= TreeInfo.orPrec) {
             mode = EXPR;
             return term2Rest(t, TreeInfo.orPrec);
         } else {
@@ -723,49 +928,44 @@ public class JavacParser implements Parser {
     JCExpression term2Rest(JCExpression t, int minprec) {
         JCExpression[] odStack = newOdStack();
         Token[] opStack = newOpStack();
-        int[] posStack = newPosStack();
+
         // optimization, was odStack = new Tree[...]; opStack = new Tree[...];
         int top = 0;
         odStack[0] = t;
-        int startPos = S.pos();
-        Token topOp = ERROR;
-        int topOpPos = Position.NOPOS;
-        while (prec(S.token()) >= minprec) {
-            posStack[top] = topOpPos;
+        int startPos = TreeInfo.getStartPos(t);
+        Token topOp = Tokens.DUMMY;
+        while (prec(token.kind) >= minprec) {
             opStack[top] = topOp;
             top++;
-            topOp = S.token();
-            topOpPos = S.pos();
-            S.nextToken();
-            odStack[top] = (topOp == INSTANCEOF) ? parseType() : term3();
-            while (top > 0 && prec(topOp) >= prec(S.token())) {
-                odStack[top-1] = makeOp(topOpPos, topOp, odStack[top-1],
+            topOp = token;
+            nextToken();
+            odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3();
+            while (top > 0 && prec(topOp.kind) >= prec(token.kind)) {
+                odStack[top-1] = makeOp(topOp.pos, topOp.kind, odStack[top-1],
                                         odStack[top]);
                 top--;
                 topOp = opStack[top];
-                topOpPos = posStack[top];
             }
         }
         Assert.check(top == 0);
         t = odStack[0];
 
-        if (t.getTag() == JCTree.PLUS) {
-            StringBuffer buf = foldStrings(t);
+        if (t.hasTag(JCTree.Tag.PLUS)) {
+            StringBuilder buf = foldStrings(t);
             if (buf != null) {
-                t = toP(F.at(startPos).Literal(TypeTags.CLASS, buf.toString()));
+                t = toP(F.at(startPos).Literal(TypeTag.CLASS, buf.toString()));
             }
         }
 
         odStackSupply.add(odStack);
         opStackSupply.add(opStack);
-        posStackSupply.add(posStack);
         return t;
     }
-//where
+    //where
         /** Construct a binary or type test node.
          */
         private JCExpression makeOp(int pos,
-                                    Token topOp,
+                                    TokenKind topOp,
                                     JCExpression od1,
                                     JCExpression od2)
         {
@@ -778,27 +978,27 @@ public class JavacParser implements Parser {
         /** If tree is a concatenation of string literals, replace it
          *  by a single literal representing the concatenated string.
          */
-        protected StringBuffer foldStrings(JCTree tree) {
-            if (!allowStringFolding)
-                return null;
+        protected StringBuilder foldStrings(JCTree tree) {
+            int depth = 0;
             List<String> buf = List.nil();
             while (true) {
-                if (tree.getTag() == JCTree.LITERAL) {
+                depth++;
+                if (tree.hasTag(LITERAL)) {
                     JCLiteral lit = (JCLiteral) tree;
-                    if (lit.typetag == TypeTags.CLASS) {
-                        StringBuffer sbuf =
-                            new StringBuffer((String)lit.value);
+                    if (lit.typetag == TypeTag.CLASS) {
+                        StringBuilder sbuf =
+                            new StringBuilder((String)lit.value);
                         while (buf.nonEmpty()) {
                             sbuf.append(buf.head);
                             buf = buf.tail;
                         }
-                        return sbuf;
+                        return allowStringFolding || depth > 1024 ? sbuf : null;
                     }
-                } else if (tree.getTag() == JCTree.PLUS) {
+                } else if (tree.hasTag(JCTree.Tag.PLUS)) {
                     JCBinary op = (JCBinary)tree;
-                    if (op.rhs.getTag() == JCTree.LITERAL) {
+                    if (op.rhs.hasTag(LITERAL)) {
                         JCLiteral lit = (JCLiteral) op.rhs;
-                        if (lit.typetag == TypeTags.CLASS) {
+                        if (lit.typetag == TypeTag.CLASS) {
                             buf = buf.prepend((String) lit.value);
                             tree = op.lhs;
                             continue;
@@ -814,7 +1014,6 @@ public class JavacParser implements Parser {
          */
         ArrayList<JCExpression[]> odStackSupply = new ArrayList<JCExpression[]>();
         ArrayList<Token[]> opStackSupply = new ArrayList<Token[]>();
-        ArrayList<int[]> posStackSupply = new ArrayList<int[]>();
 
         private JCExpression[] newOdStack() {
             if (odStackSupply.isEmpty())
@@ -828,26 +1027,28 @@ public class JavacParser implements Parser {
             return opStackSupply.remove(opStackSupply.size() - 1);
         }
 
-        private int[] newPosStack() {
-            if (posStackSupply.isEmpty())
-                return new int[infixPrecedenceLevels + 1];
-            return posStackSupply.remove(posStackSupply.size() - 1);
-        }
-
-    /** Expression3    = PrefixOp Expression3
+    /**
+     *  Expression3    = PrefixOp Expression3
      *                 | "(" Expr | TypeNoParams ")" Expression3
      *                 | Primary {Selector} {PostfixOp}
+     *
+     *  {@literal
      *  Primary        = "(" Expression ")"
      *                 | Literal
      *                 | [TypeArguments] THIS [Arguments]
      *                 | [TypeArguments] SUPER SuperSuffix
      *                 | NEW [TypeArguments] Creator
-     *                 | Ident { "." Ident }
-     *                   [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
+     *                 | "(" Arguments ")" "->" ( Expression | Block )
+     *                 | Ident "->" ( Expression | Block )
+     *                 | [Annotations] Ident { "." [Annotations] Ident }
+     *                 | Expression3 MemberReferenceSuffix
+     *                   [ [Annotations] "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
      *                   | Arguments
      *                   | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
      *                   ]
      *                 | BasicType BracketsOpt "." CLASS
+     *  }
+     *
      *  PrefixOp       = "++" | "--" | "!" | "~" | "+" | "-"
      *  PostfixOp      = "++" | "--"
      *  Type3          = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt
@@ -862,16 +1063,16 @@ public class JavacParser implements Parser {
      *  SuperSuffix    = Arguments | "." Ident [Arguments]
      */
     protected JCExpression term3() {
-        int pos = S.pos();
+        int pos = token.pos;
         JCExpression t;
         int prevmode = mode;
         List<JCExpression> typeArgs = typeArgumentsOpt(EXPR);
-        if (typeArgs != null && S.pos() <= errorEndPos) {
+        if (typeArgs != null && token.pos <= endPosTable.errorEndPos) {
             // error recovery
             mode = prevmode;
             return F.at(pos).Erroneous(typeArgs);
         }
-        switch (S.token()) {
+        switch (token.kind) {
         case QUES:
             if ((mode & TYPE) != 0 && (mode & (TYPEARG|NOPARAMS)) == TYPEARG) {
                 mode = TYPE;
@@ -880,93 +1081,62 @@ public class JavacParser implements Parser {
                 return illegal();
         case PLUSPLUS: case SUBSUB: case BANG: case TILDE: case PLUS: case SUB:
             if (typeArgs == null && (mode & EXPR) != 0) {
-                Token token = S.token();
-                S.nextToken();
+                TokenKind tk = token.kind;
+                nextToken();
                 mode = EXPR;
-                if (token == SUB &&
-                    (S.token() == INTLITERAL || S.token() == LONGLITERAL) &&
-                    S.radix() == 10) {
+                if (tk == SUB &&
+                    (token.kind == INTLITERAL || token.kind == LONGLITERAL) &&
+                    token.radix() == 10) {
                     mode = EXPR;
                     t = literal(names.hyphen, pos);
                 } else {
                     t = term3();
-                    return F.at(pos).Unary(unoptag(token), t);
+                    return F.at(pos).Unary(unoptag(tk), t);
                 }
             } else return illegal();
             break;
         case LPAREN:
             if (typeArgs == null && (mode & EXPR) != 0) {
-                S.nextToken();
-                mode = EXPR | TYPE | NOPARAMS;
-                t = term3();
-                if ((mode & TYPE) != 0 && S.token() == LT) {
-                    // Could be a cast to a parameterized type
-                    int op = JCTree.LT;
-                    int pos1 = S.pos();
-                    S.nextToken();
-                    mode &= (EXPR | TYPE);
-                    mode |= TYPEARG;
-                    JCExpression t1 = term3();
-                    if ((mode & TYPE) != 0 &&
-                        (S.token() == COMMA || S.token() == GT)) {
-                        mode = TYPE;
-                        ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
-                        args.append(t1);
-                        while (S.token() == COMMA) {
-                            S.nextToken();
-                            args.append(typeArgument());
-                        }
-                        accept(GT);
-                        t = toP(F.at(pos1).TypeApply(t, args.toList()));
-                        checkGenerics();
-                        while (S.token() == DOT) {
-                            S.nextToken();
-                            mode = TYPE;
-                            t = toP(F.at(S.pos()).Select(t, ident()));
-                            t = typeArgumentsOpt(t);
-                        }
-                        t = bracketsOpt(toP(t));
-                    } else if ((mode & EXPR) != 0) {
+                ParensResult pres = analyzeParens();
+                switch (pres) {
+                    case CAST:
+                       accept(LPAREN);
+                       mode = TYPE;
+                       int pos1 = pos;
+                       List<JCExpression> targets = List.of(t = term3());
+                       while (token.kind == AMP) {
+                           checkIntersectionTypesInCast();
+                           accept(AMP);
+                           targets = targets.prepend(term3());
+                       }
+                       if (targets.length() > 1) {
+                           t = toP(F.at(pos1).TypeIntersection(targets.reverse()));
+                       }
+                       accept(RPAREN);
+                       mode = EXPR;
+                       JCExpression t1 = term3();
+                       return F.at(pos).TypeCast(t, t1);
+                    case IMPLICIT_LAMBDA:
+                    case EXPLICIT_LAMBDA:
+                        t = lambdaExpressionOrStatement(true, pres == ParensResult.EXPLICIT_LAMBDA, pos);
+                        break;
+                    default: //PARENS
+                        accept(LPAREN);
                         mode = EXPR;
-                        JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
-                        t = F.at(pos1).Binary(op, t, e);
-                        t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
-                    } else {
-                        accept(GT);
-                    }
-                }
-                else {
-                    t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+                        t = termRest(term1Rest(term2Rest(term3(), TreeInfo.orPrec)));
+                        accept(RPAREN);
+                        t = toP(F.at(pos).Parens(t));
+                        break;
                 }
-                accept(RPAREN);
-                lastmode = mode;
-                mode = EXPR;
-                if ((lastmode & EXPR) == 0) {
-                    JCExpression t1 = term3();
-                    return F.at(pos).TypeCast(t, t1);
-                } else if ((lastmode & TYPE) != 0) {
-                    switch (S.token()) {
-                    /*case PLUSPLUS: case SUBSUB: */
-                    case BANG: case TILDE:
-                    case LPAREN: case THIS: case SUPER:
-                    case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
-                    case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
-                    case TRUE: case FALSE: case NULL:
-                    case NEW: case IDENTIFIER: case ASSERT: case ENUM:
-                    case BYTE: case SHORT: case CHAR: case INT:
-                    case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
-                        JCExpression t1 = term3();
-                        return F.at(pos).TypeCast(t, t1);
-                    }
-                }
-            } else return illegal();
-            t = toP(F.at(pos).Parens(t));
+            } else {
+                return illegal();
+            }
             break;
         case THIS:
             if ((mode & EXPR) != 0) {
                 mode = EXPR;
                 t = to(F.at(pos).Ident(names._this));
-                S.nextToken();
+                nextToken();
                 if (typeArgs == null)
                     t = argumentsOpt(null, t);
                 else
@@ -987,93 +1157,206 @@ public class JavacParser implements Parser {
         case TRUE: case FALSE: case NULL:
             if (typeArgs == null && (mode & EXPR) != 0) {
                 mode = EXPR;
-                t = literal(names.empty, S.pos());
+                t = literal(names.empty, token.pos);
             } else return illegal();
             break;
         case NEW:
             if (typeArgs != null) return illegal();
             if ((mode & EXPR) != 0) {
                 mode = EXPR;
-                S.nextToken();
-                if (S.token() == LT) typeArgs = typeArguments(false);
+                nextToken();
+                if (token.kind == LT) typeArgs = typeArguments(false);
                 t = creator(pos, typeArgs);
                 typeArgs = null;
             } else return illegal();
             break;
-        case IDENTIFIER: case ASSERT: case ENUM:
-            if (typeArgs != null) return illegal();
-            t = toP(F.at(S.pos()).Ident(ident()));
-            loop: while (true) {
-                pos = S.pos();
-                switch (S.token()) {
-                case LBRACKET:
-                    S.nextToken();
-                    if (S.token() == RBRACKET) {
-                        S.nextToken();
-                        t = bracketsOpt(t);
-                        t = toP(F.at(pos).TypeArray(t));
-                        t = bracketsSuffix(t);
+        case MONKEYS_AT:
+            // Only annotated cast types and method references are valid
+            List<JCAnnotation> typeAnnos = typeAnnotationsOpt();
+            if (typeAnnos.isEmpty()) {
+                // else there would be no '@'
+                throw new AssertionError("Expected type annotations, but found none!");
+            }
+
+            JCExpression expr = term3();
+
+            if ((mode & TYPE) == 0) {
+                // Type annotations on class literals no longer legal
+                switch (expr.getTag()) {
+                case REFERENCE: {
+                    JCMemberReference mref = (JCMemberReference) expr;
+                    mref.expr = toP(F.at(pos).AnnotatedType(typeAnnos, mref.expr));
+                    t = mref;
+                    break;
+                }
+                case SELECT: {
+                    JCFieldAccess sel = (JCFieldAccess) expr;
+
+                    if (sel.name != names._class) {
+                        return illegal();
                     } else {
-                        if ((mode & EXPR) != 0) {
-                            mode = EXPR;
-                            JCExpression t1 = term();
-                            t = to(F.at(pos).Indexed(t, t1));
-                        }
-                        accept(RBRACKET);
+                        log.error(token.pos, "no.annotations.on.dot.class");
+                        return expr;
                     }
-                    break loop;
-                case LPAREN:
-                    if ((mode & EXPR) != 0) {
-                        mode = EXPR;
-                        t = arguments(typeArgs, t);
-                        typeArgs = null;
+                }
+                default:
+                    return illegal(typeAnnos.head.pos);
+                }
+
+            } else {
+                // Type annotations targeting a cast
+                t = insertAnnotationsToMostInner(expr, typeAnnos, false);
+            }
+            break;
+        case UNDERSCORE: case IDENTIFIER: case ASSERT: case ENUM:
+            if (typeArgs != null) return illegal();
+            if ((mode & EXPR) != 0 && peekToken(ARROW)) {
+                t = lambdaExpressionOrStatement(false, false, pos);
+            } else {
+                t = toP(F.at(token.pos).Ident(ident()));
+                loop: while (true) {
+                    pos = token.pos;
+                    final List<JCAnnotation> annos = typeAnnotationsOpt();
+
+                    // need to report an error later if LBRACKET is for array
+                    // index access rather than array creation level
+                    if (!annos.isEmpty() && token.kind != LBRACKET && token.kind != ELLIPSIS) {
+                        t = toP(F.at(pos).AnnotatedType(annos, t));
+                        return syntaxError(annos.head.pos, List.<JCTree>of(t), (mode & EXPR) != 0 ? "illegal.start.of.expr" : "illegal.start.of.type");
                     }
-                    break loop;
-                case DOT:
-                    S.nextToken();
-                    int oldmode = mode;
-                    mode &= ~NOPARAMS;
-                    typeArgs = typeArgumentsOpt(EXPR);
-                    mode = oldmode;
-                    if ((mode & EXPR) != 0) {
-                        switch (S.token()) {
-                        case CLASS:
-                            if (typeArgs != null) return illegal();
-                            mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._class));
-                            S.nextToken();
-                            break loop;
-                        case THIS:
-                            if (typeArgs != null) return illegal();
-                            mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._this));
-                            S.nextToken();
-                            break loop;
-                        case SUPER:
+
+                    switch (token.kind) {
+                    case LBRACKET:
+                        nextToken();
+                        if (token.kind == RBRACKET) {
+                            nextToken();
+                            t = bracketsOpt(t);
+                            t = toP(F.at(pos).TypeArray(t));
+                            if (annos.nonEmpty()) {
+                                t = toP(F.at(pos).AnnotatedType(annos, t));
+                            }
+                            // .class is only allowed if there were no annotations
+                            JCExpression nt = bracketsSuffix(t);
+                            if (nt != t && (annos.nonEmpty() || TreeInfo.containsTypeAnnotation(t))) {
+                                // t and nt are different if bracketsSuffix parsed a .class.
+                                // The check for nonEmpty covers the case when the whole array is annotated.
+                                // Helper method isAnnotated looks for annos deeply within t.
+                                syntaxError("no.annotations.on.dot.class");
+                            }
+                            t = nt;
+                        } else {
+                            if ((mode & EXPR) != 0) {
+                                mode = EXPR;
+                                JCExpression t1 = term();
+                                if (!annos.isEmpty()) t = illegal(annos.head.pos);
+                                t = to(F.at(pos).Indexed(t, t1));
+                            }
+                            accept(RBRACKET);
+                        }
+                        break loop;
+                    case LPAREN:
+                        if ((mode & EXPR) != 0) {
                             mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._super));
-                            t = superSuffix(typeArgs, t);
+                            t = arguments(typeArgs, t);
+                            if (!annos.isEmpty()) t = illegal(annos.head.pos);
                             typeArgs = null;
-                            break loop;
-                        case NEW:
-                            if (typeArgs != null) return illegal();
+                        }
+                        break loop;
+                    case DOT:
+                        nextToken();
+                        int oldmode = mode;
+                        mode &= ~NOPARAMS;
+                        typeArgs = typeArgumentsOpt(EXPR);
+                        mode = oldmode;
+                        if ((mode & EXPR) != 0) {
+                            switch (token.kind) {
+                            case CLASS:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._class));
+                                nextToken();
+                                break loop;
+                            case THIS:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._this));
+                                nextToken();
+                                break loop;
+                            case SUPER:
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._super));
+                                t = superSuffix(typeArgs, t);
+                                typeArgs = null;
+                                break loop;
+                            case NEW:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                int pos1 = token.pos;
+                                nextToken();
+                                if (token.kind == LT) typeArgs = typeArguments(false);
+                                t = innerCreator(pos1, typeArgs, t);
+                                typeArgs = null;
+                                break loop;
+                            }
+                        }
+
+                        List<JCAnnotation> tyannos = null;
+                        if ((mode & TYPE) != 0 && token.kind == MONKEYS_AT) {
+                            tyannos = typeAnnotationsOpt();
+                        }
+                        // typeArgs saved for next loop iteration.
+                        t = toP(F.at(pos).Select(t, ident()));
+                        if (tyannos != null && tyannos.nonEmpty()) {
+                            t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t));
+                        }
+                        break;
+                    case ELLIPSIS:
+                        if (this.permitTypeAnnotationsPushBack) {
+                            this.typeAnnotationsPushedBack = annos;
+                        } else if (annos.nonEmpty()) {
+                            // Don't return here -- error recovery attempt
+                            illegal(annos.head.pos);
+                        }
+                        break loop;
+                    case LT:
+                        if ((mode & TYPE) == 0 && isUnboundMemberRef()) {
+                            //this is an unbound method reference whose qualifier
+                            //is a generic type i.e. A<S>::m
+                            int pos1 = token.pos;
+                            accept(LT);
+                            ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+                            args.append(typeArgument());
+                            while (token.kind == COMMA) {
+                                nextToken();
+                                args.append(typeArgument());
+                            }
+                            accept(GT);
+                            t = toP(F.at(pos1).TypeApply(t, args.toList()));
+                            checkGenerics();
+                            while (token.kind == DOT) {
+                                nextToken();
+                                mode = TYPE;
+                                t = toP(F.at(token.pos).Select(t, ident()));
+                                t = typeArgumentsOpt(t);
+                            }
+                            t = bracketsOpt(t);
+                            if (token.kind != COLCOL) {
+                                //method reference expected here
+                                t = illegal();
+                            }
                             mode = EXPR;
-                            int pos1 = S.pos();
-                            S.nextToken();
-                            if (S.token() == LT) typeArgs = typeArguments(false);
-                            t = innerCreator(pos1, typeArgs, t);
-                            typeArgs = null;
-                            break loop;
+                            return term3Rest(t, typeArgs);
                         }
+                        break loop;
+                    default:
+                        break loop;
                     }
-                    // typeArgs saved for next loop iteration.
-                    t = toP(F.at(pos).Select(t, ident()));
-                    break;
-                default:
-                    break loop;
                 }
             }
-            if (typeArgs != null) illegal();
+            if (typeArgs != null) {
+                illegal();
+                t = arguments(typeArgs, t); //error recovery
+            }
             t = typeArgumentsOpt(t);
             break;
         case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
@@ -1084,9 +1367,9 @@ public class JavacParser implements Parser {
         case VOID:
             if (typeArgs != null) illegal();
             if ((mode & EXPR) != 0) {
-                S.nextToken();
-                if (S.token() == DOT) {
-                    JCPrimitiveTypeTree ti = toP(F.at(pos).TypeIdent(TypeTags.VOID));
+                nextToken();
+                if (token.kind == DOT) {
+                    JCPrimitiveTypeTree ti = toP(F.at(pos).TypeIdent(TypeTag.VOID));
                     t = bracketsSuffix(ti);
                 } else {
                     return illegal(pos);
@@ -1095,8 +1378,8 @@ public class JavacParser implements Parser {
                 // Support the corner case of myMethodHandle.<void>invoke() by passing
                 // a void type (like other primitive types) to the next phase.
                 // The error will be reported in Attr.attribTypes or Attr.visitApply.
-                JCPrimitiveTypeTree ti = to(F.at(pos).TypeIdent(TypeTags.VOID));
-                S.nextToken();
+                JCPrimitiveTypeTree ti = to(F.at(pos).TypeIdent(TypeTag.VOID));
+                nextToken();
                 return ti;
                 //return illegal();
             }
@@ -1104,18 +1387,31 @@ public class JavacParser implements Parser {
         default:
             return illegal();
         }
+        return term3Rest(t, typeArgs);
+    }
+
+    JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
         if (typeArgs != null) illegal();
         while (true) {
-            int pos1 = S.pos();
-            if (S.token() == LBRACKET) {
-                S.nextToken();
+            int pos1 = token.pos;
+            final List<JCAnnotation> annos = typeAnnotationsOpt();
+
+            if (token.kind == LBRACKET) {
+                nextToken();
                 if ((mode & TYPE) != 0) {
                     int oldmode = mode;
                     mode = TYPE;
-                    if (S.token() == RBRACKET) {
-                        S.nextToken();
+                    if (token.kind == RBRACKET) {
+                        nextToken();
                         t = bracketsOpt(t);
                         t = toP(F.at(pos1).TypeArray(t));
+                        if (token.kind == COLCOL) {
+                            mode = EXPR;
+                            continue;
+                        }
+                        if (annos.nonEmpty()) {
+                            t = toP(F.at(pos1).AnnotatedType(annos, t));
+                        }
                         return t;
                     }
                     mode = oldmode;
@@ -1126,51 +1422,338 @@ public class JavacParser implements Parser {
                     t = to(F.at(pos1).Indexed(t, t1));
                 }
                 accept(RBRACKET);
-            } else if (S.token() == DOT) {
-                S.nextToken();
+            } else if (token.kind == DOT) {
+                nextToken();
                 typeArgs = typeArgumentsOpt(EXPR);
-                if (S.token() == SUPER && (mode & EXPR) != 0) {
+                if (token.kind == SUPER && (mode & EXPR) != 0) {
                     mode = EXPR;
                     t = to(F.at(pos1).Select(t, names._super));
-                    S.nextToken();
+                    nextToken();
                     t = arguments(typeArgs, t);
                     typeArgs = null;
-                } else if (S.token() == NEW && (mode & EXPR) != 0) {
+                } else if (token.kind == NEW && (mode & EXPR) != 0) {
                     if (typeArgs != null) return illegal();
                     mode = EXPR;
-                    int pos2 = S.pos();
-                    S.nextToken();
-                    if (S.token() == LT) typeArgs = typeArguments(false);
+                    int pos2 = token.pos;
+                    nextToken();
+                    if (token.kind == LT) typeArgs = typeArguments(false);
                     t = innerCreator(pos2, typeArgs, t);
                     typeArgs = null;
                 } else {
+                    List<JCAnnotation> tyannos = null;
+                    if ((mode & TYPE) != 0 && token.kind == MONKEYS_AT) {
+                        // is the mode check needed?
+                        tyannos = typeAnnotationsOpt();
+                    }
                     t = toP(F.at(pos1).Select(t, ident()));
+                    if (tyannos != null && tyannos.nonEmpty()) {
+                        t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t));
+                    }
                     t = argumentsOpt(typeArgs, typeArgumentsOpt(t));
                     typeArgs = null;
                 }
+            } else if ((mode & EXPR) != 0 && token.kind == COLCOL) {
+                mode = EXPR;
+                if (typeArgs != null) return illegal();
+                accept(COLCOL);
+                t = memberReferenceSuffix(pos1, t);
             } else {
+                if (!annos.isEmpty()) {
+                    if (permitTypeAnnotationsPushBack)
+                        typeAnnotationsPushedBack = annos;
+                    else
+                        return illegal(annos.head.pos);
+                }
                 break;
             }
         }
-        while ((S.token() == PLUSPLUS || S.token() == SUBSUB) && (mode & EXPR) != 0) {
+        while ((token.kind == PLUSPLUS || token.kind == SUBSUB) && (mode & EXPR) != 0) {
             mode = EXPR;
-            t = to(F.at(S.pos()).Unary(
-                  S.token() == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t));
-            S.nextToken();
+            t = to(F.at(token.pos).Unary(
+                  token.kind == PLUSPLUS ? POSTINC : POSTDEC, t));
+            nextToken();
         }
         return toP(t);
     }
 
+    /**
+     * If we see an identifier followed by a '<' it could be an unbound
+     * method reference or a binary expression. To disambiguate, look for a
+     * matching '>' and see if the subsequent terminal is either '.' or '::'.
+     */
+    @SuppressWarnings("fallthrough")
+    boolean isUnboundMemberRef() {
+        int pos = 0, depth = 0;
+        outer: for (Token t = S.token(pos) ; ; t = S.token(++pos)) {
+            switch (t.kind) {
+                case IDENTIFIER: case UNDERSCORE: case QUES: case EXTENDS: case SUPER:
+                case DOT: case RBRACKET: case LBRACKET: case COMMA:
+                case BYTE: case SHORT: case INT: case LONG: case FLOAT:
+                case DOUBLE: case BOOLEAN: case CHAR:
+                case MONKEYS_AT:
+                    break;
+
+                case LPAREN:
+                    // skip annotation values
+                    int nesting = 0;
+                    for (; ; pos++) {
+                        TokenKind tk2 = S.token(pos).kind;
+                        switch (tk2) {
+                            case EOF:
+                                return false;
+                            case LPAREN:
+                                nesting++;
+                                break;
+                            case RPAREN:
+                                nesting--;
+                                if (nesting == 0) {
+                                    continue outer;
+                                }
+                                break;
+                        }
+                    }
+
+                case LT:
+                    depth++; break;
+                case GTGTGT:
+                    depth--;
+                case GTGT:
+                    depth--;
+                case GT:
+                    depth--;
+                    if (depth == 0) {
+                        TokenKind nextKind = S.token(pos + 1).kind;
+                        return
+                            nextKind == TokenKind.DOT ||
+                            nextKind == TokenKind.LBRACKET ||
+                            nextKind == TokenKind.COLCOL;
+                    }
+                    break;
+                default:
+                    return false;
+            }
+        }
+    }
+
+    /**
+     * If we see an identifier followed by a '<' it could be an unbound
+     * method reference or a binary expression. To disambiguate, look for a
+     * matching '>' and see if the subsequent terminal is either '.' or '::'.
+     */
+    @SuppressWarnings("fallthrough")
+    ParensResult analyzeParens() {
+        int depth = 0;
+        boolean type = false;
+        outer: for (int lookahead = 0 ; ; lookahead++) {
+            TokenKind tk = S.token(lookahead).kind;
+            switch (tk) {
+                case COMMA:
+                    type = true;
+                case EXTENDS: case SUPER: case DOT: case AMP:
+                    //skip
+                    break;
+                case QUES:
+                    if (peekToken(lookahead, EXTENDS) ||
+                            peekToken(lookahead, SUPER)) {
+                        //wildcards
+                        type = true;
+                    }
+                    break;
+                case BYTE: case SHORT: case INT: case LONG: case FLOAT:
+                case DOUBLE: case BOOLEAN: case CHAR:
+                    if (peekToken(lookahead, RPAREN)) {
+                        //Type, ')' -> cast
+                        return ParensResult.CAST;
+                    } else if (peekToken(lookahead, LAX_IDENTIFIER)) {
+                        //Type, Identifier/'_'/'assert'/'enum' -> explicit lambda
+                        return ParensResult.EXPLICIT_LAMBDA;
+                    }
+                    break;
+                case LPAREN:
+                    if (lookahead != 0) {
+                        // '(' in a non-starting position -> parens
+                        return ParensResult.PARENS;
+                    } else if (peekToken(lookahead, RPAREN, ARROW)) {
+                        // '(', ')', '->' -> explicit lambda
+                        return ParensResult.EXPLICIT_LAMBDA;
+                    }
+                    break;
+                case RPAREN:
+                    // if we have seen something that looks like a type,
+                    // then it's a cast expression
+                    if (type) return ParensResult.CAST;
+                    // otherwise, disambiguate cast vs. parenthesized expression
+                    // based on subsequent token.
+                    switch (S.token(lookahead + 1).kind) {
+                        /*case PLUSPLUS: case SUBSUB: */
+                        case BANG: case TILDE:
+                        case LPAREN: case THIS: case SUPER:
+                        case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
+                        case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
+                        case TRUE: case FALSE: case NULL:
+                        case NEW: case IDENTIFIER: case ASSERT: case ENUM: case UNDERSCORE:
+                        case BYTE: case SHORT: case CHAR: case INT:
+                        case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
+                            return ParensResult.CAST;
+                        default:
+                            return ParensResult.PARENS;
+                    }
+                case UNDERSCORE:
+                case ASSERT:
+                case ENUM:
+                case IDENTIFIER:
+                    if (peekToken(lookahead, LAX_IDENTIFIER)) {
+                        // Identifier, Identifier/'_'/'assert'/'enum' -> explicit lambda
+                        return ParensResult.EXPLICIT_LAMBDA;
+                    } else if (peekToken(lookahead, RPAREN, ARROW)) {
+                        // Identifier, ')' '->' -> implicit lambda
+                        return ParensResult.IMPLICIT_LAMBDA;
+                    }
+                    break;
+                case FINAL:
+                case ELLIPSIS:
+                    //those can only appear in explicit lambdas
+                    return ParensResult.EXPLICIT_LAMBDA;
+                case MONKEYS_AT:
+                    type = true;
+                    lookahead += 1; //skip '@'
+                    while (peekToken(lookahead, DOT)) {
+                        lookahead += 2;
+                    }
+                    if (peekToken(lookahead, LPAREN)) {
+                        lookahead++;
+                        //skip annotation values
+                        int nesting = 0;
+                        for (; ; lookahead++) {
+                            TokenKind tk2 = S.token(lookahead).kind;
+                            switch (tk2) {
+                                case EOF:
+                                    return ParensResult.PARENS;
+                                case LPAREN:
+                                    nesting++;
+                                    break;
+                                case RPAREN:
+                                    nesting--;
+                                    if (nesting == 0) {
+                                        continue outer;
+                                    }
+                                break;
+                            }
+                        }
+                    }
+                    break;
+                case LBRACKET:
+                    if (peekToken(lookahead, RBRACKET, LAX_IDENTIFIER)) {
+                        // '[', ']', Identifier/'_'/'assert'/'enum' -> explicit lambda
+                        return ParensResult.EXPLICIT_LAMBDA;
+                    } else if (peekToken(lookahead, RBRACKET, RPAREN) ||
+                            peekToken(lookahead, RBRACKET, AMP)) {
+                        // '[', ']', ')' -> cast
+                        // '[', ']', '&' -> cast (intersection type)
+                        return ParensResult.CAST;
+                    } else if (peekToken(lookahead, RBRACKET)) {
+                        //consume the ']' and skip
+                        type = true;
+                        lookahead++;
+                        break;
+                    } else {
+                        return ParensResult.PARENS;
+                    }
+                case LT:
+                    depth++; break;
+                case GTGTGT:
+                    depth--;
+                case GTGT:
+                    depth--;
+                case GT:
+                    depth--;
+                    if (depth == 0) {
+                        if (peekToken(lookahead, RPAREN) ||
+                                peekToken(lookahead, AMP)) {
+                            // '>', ')' -> cast
+                            // '>', '&' -> cast
+                            return ParensResult.CAST;
+                        } else if (peekToken(lookahead, LAX_IDENTIFIER, COMMA) ||
+                                peekToken(lookahead, LAX_IDENTIFIER, RPAREN, ARROW) ||
+                                peekToken(lookahead, ELLIPSIS)) {
+                            // '>', Identifier/'_'/'assert'/'enum', ',' -> explicit lambda
+                            // '>', Identifier/'_'/'assert'/'enum', ')', '->' -> explicit lambda
+                            // '>', '...' -> explicit lambda
+                            return ParensResult.EXPLICIT_LAMBDA;
+                        }
+                        //it looks a type, but could still be (i) a cast to generic type,
+                        //(ii) an unbound method reference or (iii) an explicit lambda
+                        type = true;
+                        break;
+                    } else if (depth < 0) {
+                        //unbalanced '<', '>' - not a generic type
+                        return ParensResult.PARENS;
+                    }
+                    break;
+                default:
+                    //this includes EOF
+                    return type ? ParensResult.IMPLICIT_LAMBDA : ParensResult.PARENS;
+            }
+        }
+    }
+
+    /** Accepts all identifier-like tokens */
+    Filter<TokenKind> LAX_IDENTIFIER = new Filter<TokenKind>() {
+        public boolean accepts(TokenKind t) {
+            return t == IDENTIFIER || t == UNDERSCORE || t == ASSERT || t == ENUM;
+        }
+    };
+
+    enum ParensResult {
+        CAST,
+        EXPLICIT_LAMBDA,
+        IMPLICIT_LAMBDA,
+        PARENS;
+    }
+
+    JCExpression lambdaExpressionOrStatement(boolean hasParens, boolean explicitParams, int pos) {
+        List<JCVariableDecl> params = explicitParams ?
+                formalParameters(true) :
+                implicitParameters(hasParens);
+
+        return lambdaExpressionOrStatementRest(params, pos);
+    }
+
+    JCExpression lambdaExpressionOrStatementRest(List<JCVariableDecl> args, int pos) {
+        checkLambda();
+        accept(ARROW);
+
+        return token.kind == LBRACE ?
+            lambdaStatement(args, pos, token.pos) :
+            lambdaExpression(args, pos);
+    }
+
+    JCExpression lambdaStatement(List<JCVariableDecl> args, int pos, int pos2) {
+        JCBlock block = block(pos2, 0);
+        return toP(F.at(pos).Lambda(args, block));
+    }
+
+    JCExpression lambdaExpression(List<JCVariableDecl> args, int pos) {
+        JCTree expr = parseExpression();
+        if (expr.hasTag(ERRONEOUS) && ((JCErroneous)expr).errs.isEmpty()
+                && S.prevToken().kind == ARROW && S.prevToken().endPos < expr.pos)
+            expr.pos = S.prevToken().endPos;
+        return toP(F.at(pos).Lambda(args, expr));
+    }
+
     /** SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments]
      */
     JCExpression superSuffix(List<JCExpression> typeArgs, JCExpression t) {
-        S.nextToken();
-        if (S.token() == LPAREN || typeArgs != null) {
+        nextToken();
+        if (token.kind == LPAREN || typeArgs != null) {
             t = arguments(typeArgs, t);
+        } else if (token.kind == COLCOL) {
+            if (typeArgs != null) return illegal();
+            t = memberReferenceSuffix(t);
         } else {
-            int pos = S.pos();
+            int pos = token.pos;
             accept(DOT);
-            typeArgs = (S.token() == LT) ? typeArguments(false) : null;
+            typeArgs = (token.kind == LT) ? typeArguments(false) : null;
             t = toP(F.at(pos).Select(t, ident()));
             t = argumentsOpt(typeArgs, t);
         }
@@ -1180,15 +1763,15 @@ public class JavacParser implements Parser {
     /** BasicType = BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE | BOOLEAN
      */
     JCPrimitiveTypeTree basicType() {
-        JCPrimitiveTypeTree t = to(F.at(S.pos()).TypeIdent(typetag(S.token())));
-        S.nextToken();
+        JCPrimitiveTypeTree t = to(F.at(token.pos).TypeIdent(typetag(token.kind)));
+        nextToken();
         return t;
     }
 
     /** ArgumentsOpt = [ Arguments ]
      */
     JCExpression argumentsOpt(List<JCExpression> typeArgs, JCExpression t) {
-        if ((mode & EXPR) != 0 && S.token() == LPAREN || typeArgs != null) {
+        if ((mode & EXPR) != 0 && token.kind == LPAREN || typeArgs != null) {
             mode = EXPR;
             return arguments(typeArgs, t);
         } else {
@@ -1200,24 +1783,24 @@ public class JavacParser implements Parser {
      */
     List<JCExpression> arguments() {
         ListBuffer<JCExpression> args = lb();
-        if (S.token() == LPAREN) {
-            S.nextToken();
-            if (S.token() != RPAREN) {
+        if (token.kind == LPAREN) {
+            nextToken();
+            if (token.kind != RPAREN) {
                 args.append(parseExpression());
-                while (S.token() == COMMA) {
-                    S.nextToken();
+                while (token.kind == COMMA) {
+                    nextToken();
                     args.append(parseExpression());
                 }
             }
             accept(RPAREN);
         } else {
-            syntaxError(S.pos(), "expected", LPAREN);
+            syntaxError(token.pos, "expected", LPAREN);
         }
         return args.toList();
     }
 
     JCMethodInvocation arguments(List<JCExpression> typeArgs, JCExpression t) {
-        int pos = S.pos();
+        int pos = token.pos;
         List<JCExpression> args = arguments();
         return toP(F.at(pos).Apply(typeArgs, t, args));
     }
@@ -1225,7 +1808,7 @@ public class JavacParser implements Parser {
     /**  TypeArgumentsOpt = [ TypeArguments ]
      */
     JCExpression typeArgumentsOpt(JCExpression t) {
-        if (S.token() == LT &&
+        if (token.kind == LT &&
             (mode & TYPE) != 0 &&
             (mode & NOPARAMS) == 0) {
             mode = TYPE;
@@ -1240,7 +1823,7 @@ public class JavacParser implements Parser {
     }
 
     List<JCExpression> typeArgumentsOpt(int useMode) {
-        if (S.token() == LT) {
+        if (token.kind == LT) {
             checkGenerics();
             if ((mode & useMode) == 0 ||
                 (mode & NOPARAMS) != 0) {
@@ -1252,125 +1835,160 @@ public class JavacParser implements Parser {
         return null;
     }
 
-    /**  TypeArguments  = "<" TypeArgument {"," TypeArgument} ">"
+    /**
+     *  {@literal
+     *  TypeArguments  = "<" TypeArgument {"," TypeArgument} ">"
+     *  }
      */
     List<JCExpression> typeArguments(boolean diamondAllowed) {
-        if (S.token() == LT) {
-            S.nextToken();
-            if (S.token() == GT && diamondAllowed) {
+        if (token.kind == LT) {
+            nextToken();
+            if (token.kind == GT && diamondAllowed) {
                 checkDiamond();
                 mode |= DIAMOND;
-                S.nextToken();
+                nextToken();
                 return List.nil();
             } else {
                 ListBuffer<JCExpression> args = ListBuffer.lb();
                 args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
-                while (S.token() == COMMA) {
-                    S.nextToken();
+                while (token.kind == COMMA) {
+                    nextToken();
                     args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
                 }
-                switch (S.token()) {
-                case GTGTGTEQ:
-                    S.token(GTGTEQ);
-                    break;
-                case GTGTEQ:
-                    S.token(GTEQ);
-                    break;
-                case GTEQ:
-                    S.token(EQ);
-                    break;
-                case GTGTGT:
-                    S.token(GTGT);
-                    break;
-                case GTGT:
-                    S.token(GT);
+                switch (token.kind) {
+
+                case GTGTGTEQ: case GTGTEQ: case GTEQ:
+                case GTGTGT: case GTGT:
+                    token = S.split();
                     break;
                 case GT:
-                    S.nextToken();
+                    nextToken();
                     break;
                 default:
-                    args.append(syntaxError(S.pos(), "expected", GT));
+                    args.append(syntaxError(token.pos, "expected", GT));
                     break;
                 }
                 return args.toList();
             }
         } else {
-            return List.<JCExpression>of(syntaxError(S.pos(), "expected", LT));
+            return List.<JCExpression>of(syntaxError(token.pos, "expected", LT));
         }
     }
 
-    /** TypeArgument = Type
-     *               | "?"
-     *               | "?" EXTENDS Type {"&" Type}
-     *               | "?" SUPER Type
+    /**
+     *  {@literal
+     *  TypeArgument = Type
+     *               | [Annotations] "?"
+     *               | [Annotations] "?" EXTENDS Type {"&" Type}
+     *               | [Annotations] "?" SUPER Type
+     *  }
      */
     JCExpression typeArgument() {
-        if (S.token() != QUES) return parseType();
-        int pos = S.pos();
-        S.nextToken();
-        if (S.token() == EXTENDS) {
+        List<JCAnnotation> annotations = typeAnnotationsOpt();
+        if (token.kind != QUES) return parseType(annotations);
+        int pos = token.pos;
+        nextToken();
+        JCExpression result;
+        if (token.kind == EXTENDS) {
             TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.EXTENDS));
-            S.nextToken();
+            nextToken();
             JCExpression bound = parseType();
-            return F.at(pos).Wildcard(t, bound);
-        } else if (S.token() == SUPER) {
+            result = F.at(pos).Wildcard(t, bound);
+        } else if (token.kind == SUPER) {
             TypeBoundKind t = to(F.at(pos).TypeBoundKind(BoundKind.SUPER));
-            S.nextToken();
+            nextToken();
             JCExpression bound = parseType();
-            return F.at(pos).Wildcard(t, bound);
-        } else if (S.token() == IDENTIFIER) {
+            result = F.at(pos).Wildcard(t, bound);
+        } else if (LAX_IDENTIFIER.accepts(token.kind)) {
             //error recovery
             TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND);
             JCExpression wc = toP(F.at(pos).Wildcard(t, null));
-            JCIdent id = toP(F.at(S.pos()).Ident(ident()));
+            JCIdent id = toP(F.at(token.pos).Ident(ident()));
             JCErroneous err = F.at(pos).Erroneous(List.<JCTree>of(wc, id));
             reportSyntaxError(err, "expected3", GT, EXTENDS, SUPER);
-            return err;
+            result = err;
         } else {
             TypeBoundKind t = toP(F.at(pos).TypeBoundKind(BoundKind.UNBOUND));
-            return toP(F.at(pos).Wildcard(t, null));
+            result = toP(F.at(pos).Wildcard(t, null));
+        }
+        if (!annotations.isEmpty()) {
+            result = toP(F.at(annotations.head.pos).AnnotatedType(annotations,result));
         }
+        return result;
     }
 
     JCTypeApply typeArguments(JCExpression t, boolean diamondAllowed) {
-        int pos = S.pos();
+        int pos = token.pos;
         List<JCExpression> args = typeArguments(diamondAllowed);
         return toP(F.at(pos).TypeApply(t, args));
     }
 
-    /** BracketsOpt = {"[" "]"}
+    /**
+     * BracketsOpt = { [Annotations] "[" "]" }*
+     *
+     * <p>
+     *
+     * <code>annotations</code> is the list of annotations targeting
+     * the expression <code>t</code>.
      */
-    private JCExpression bracketsOpt(JCExpression t) {
-        if (S.token() == LBRACKET) {
-            int pos = S.pos();
-            S.nextToken();
-            t = bracketsOptCont(t, pos);
-            F.at(pos);
+    private JCExpression bracketsOpt(JCExpression t,
+            List<JCAnnotation> annotations) {
+        List<JCAnnotation> nextLevelAnnotations = typeAnnotationsOpt();
+
+        if (token.kind == LBRACKET) {
+            if (t == null) {
+                return illegal();
+            } else {
+                int pos = token.pos;
+                nextToken();
+                t = bracketsOptCont(t, pos, nextLevelAnnotations);
+            }
+        } else if (!nextLevelAnnotations.isEmpty()) {
+            if (permitTypeAnnotationsPushBack) {
+                this.typeAnnotationsPushedBack = nextLevelAnnotations;
+            } else {
+                return illegal(nextLevelAnnotations.head.pos);
+            }
+        }
+
+        if (!annotations.isEmpty()) {
+            t = toP(F.at(token.pos).AnnotatedType(annotations, t));
         }
         return t;
     }
 
-    private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos) {
+    /** BracketsOpt = [ "[" "]" { [Annotations] "[" "]"} ]
+     */
+    private JCExpression bracketsOpt(JCExpression t) {
+        return bracketsOpt(t, List.<JCAnnotation>nil());
+    }
+
+    private JCExpression bracketsOptCont(JCExpression t, int pos,
+            List<JCAnnotation> annotations) {
         accept(RBRACKET);
         t = bracketsOpt(t);
-        return toP(F.at(pos).TypeArray(t));
+        t = toP(F.at(pos).TypeArray(t));
+        if (annotations.nonEmpty()) {
+            t = toP(F.at(pos).AnnotatedType(annotations, t));
+        }
+        return t;
     }
 
     /** BracketsSuffixExpr = "." CLASS
      *  BracketsSuffixType =
      */
     JCExpression bracketsSuffix(JCExpression t) {
-        if ((mode & EXPR) != 0 && S.token() == DOT) {
+        if ((mode & EXPR) != 0 && token.kind == DOT) {
             mode = EXPR;
-            int pos = S.pos();
-            S.nextToken();
+            int pos = token.pos;
+            nextToken();
             accept(CLASS);
-            if (S.pos() == errorEndPos) {
+            if (token.pos == endPosTable.errorEndPos) {
                 // error recovery
-                Name name = null;
-                if (S.token() == IDENTIFIER) {
-                    name = S.name();
-                    S.nextToken();
+                Name name;
+                if (LAX_IDENTIFIER.accepts(token.kind)) {
+                    name = token.name();
+                    nextToken();
                 } else {
                     name = names.error;
                 }
@@ -1379,52 +1997,103 @@ public class JavacParser implements Parser {
                 t = toP(F.at(pos).Select(t, names._class));
             }
         } else if ((mode & TYPE) != 0) {
-            mode = TYPE;
-        } else {
-            syntaxError(S.pos(), "dot.class.expected");
+            if (token.kind != COLCOL) {
+                mode = TYPE;
+            }
+        } else if (token.kind != COLCOL) {
+            syntaxError(token.pos, "dot.class.expected");
         }
         return t;
     }
 
-    /** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
+    /**
+     * MemberReferenceSuffix = "::" [TypeArguments] Ident
+     *                       | "::" [TypeArguments] "new"
+     */
+    JCExpression memberReferenceSuffix(JCExpression t) {
+        int pos1 = token.pos;
+        accept(COLCOL);
+        return memberReferenceSuffix(pos1, t);
+    }
+
+    JCExpression memberReferenceSuffix(int pos1, JCExpression t) {
+        checkMethodReferences();
+        mode = EXPR;
+        List<JCExpression> typeArgs = null;
+        if (token.kind == LT) {
+            typeArgs = typeArguments(false);
+        }
+        Name refName;
+        ReferenceMode refMode;
+        if (token.kind == NEW) {
+            refMode = ReferenceMode.NEW;
+            refName = names.init;
+            nextToken();
+        } else {
+            refMode = ReferenceMode.INVOKE;
+            refName = ident();
+        }
+        return toP(F.at(t.getStartPosition()).Reference(refMode, refName, t, typeArgs));
+    }
+
+    /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
      */
     JCExpression creator(int newpos, List<JCExpression> typeArgs) {
-        switch (S.token()) {
+        List<JCAnnotation> newAnnotations = annotationsOpt(Tag.ANNOTATION);
+
+        switch (token.kind) {
         case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
         case DOUBLE: case BOOLEAN:
-            if (typeArgs == null)
-                return arrayCreatorRest(newpos, basicType());
+            if (typeArgs == null) {
+                if (newAnnotations.isEmpty()) {
+                    return arrayCreatorRest(newpos, basicType());
+                } else {
+                    return arrayCreatorRest(newpos, toP(F.at(newAnnotations.head.pos).AnnotatedType(newAnnotations, basicType())));
+                }
+            }
             break;
         default:
         }
-        JCExpression t = qualident();
+        JCExpression t = qualident(true);
+
         int oldmode = mode;
         mode = TYPE;
         boolean diamondFound = false;
         int lastTypeargsPos = -1;
-        if (S.token() == LT) {
+        if (token.kind == LT) {
             checkGenerics();
-            lastTypeargsPos = S.pos();
+            lastTypeargsPos = token.pos;
             t = typeArguments(t, true);
             diamondFound = (mode & DIAMOND) != 0;
         }
-        while (S.token() == DOT) {
+        while (token.kind == DOT) {
             if (diamondFound) {
                 //cannot select after a diamond
                 illegal();
             }
-            int pos = S.pos();
-            S.nextToken();
+            int pos = token.pos;
+            nextToken();
+            List<JCAnnotation> tyannos = typeAnnotationsOpt();
             t = toP(F.at(pos).Select(t, ident()));
-            if (S.token() == LT) {
-                lastTypeargsPos = S.pos();
+
+            if (tyannos != null && tyannos.nonEmpty()) {
+                t = toP(F.at(tyannos.head.pos).AnnotatedType(tyannos, t));
+            }
+
+            if (token.kind == LT) {
+                lastTypeargsPos = token.pos;
                 checkGenerics();
                 t = typeArguments(t, true);
                 diamondFound = (mode & DIAMOND) != 0;
             }
         }
         mode = oldmode;
-        if (S.token() == LBRACKET) {
+        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");
@@ -1438,27 +2107,52 @@ public class JavacParser implements Parser {
                     // modified to improve error recovery.
                     pos = typeArgs.head.pos;
                 }
-                setErrorEndPos(S.prevEndPos());
+                setErrorEndPos(S.prevToken().endPos);
                 JCErroneous err = F.at(pos).Erroneous(typeArgs.prepend(e));
                 reportSyntaxError(err, "cannot.create.array.with.type.arguments");
                 return toP(err);
             }
             return e;
-        } else if (S.token() == LPAREN) {
-            return classCreatorRest(newpos, null, typeArgs, t);
+        } else if (token.kind == LPAREN) {
+            JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t);
+            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 = newAnnotations;
+                }
+            } else {
+                // handle type annotations for instantiations
+                if (newAnnotations.nonEmpty()) {
+                    t = insertAnnotationsToMostInner(t, newAnnotations, false);
+                    newClass.clazz = t;
+                }
+            }
+            return newClass;
         } else {
-            setErrorEndPos(S.pos());
-            reportSyntaxError(S.pos(), "expected2", LPAREN, LBRACKET);
+            setErrorEndPos(token.pos);
+            reportSyntaxError(token.pos, "expected2", LPAREN, LBRACKET);
             t = toP(F.at(newpos).NewClass(null, typeArgs, t, List.<JCExpression>nil(), null));
             return toP(F.at(newpos).Erroneous(List.<JCTree>of(t)));
         }
     }
 
-    /** InnerCreator = Ident [TypeArguments] ClassCreatorRest
+    /** InnerCreator = [Annotations] Ident [TypeArguments] ClassCreatorRest
      */
     JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) {
-        JCExpression t = toP(F.at(S.pos()).Ident(ident()));
-        if (S.token() == LT) {
+        List<JCAnnotation> newAnnotations = typeAnnotationsOpt();
+
+        JCExpression t = toP(F.at(token.pos).Ident(ident()));
+
+        if (newAnnotations.nonEmpty()) {
+            t = toP(F.at(newAnnotations.head.pos).AnnotatedType(newAnnotations, t));
+        }
+
+        if (token.kind == LT) {
             int oldmode = mode;
             checkGenerics();
             t = typeArguments(t, true);
@@ -1467,35 +2161,65 @@ public class JavacParser implements Parser {
         return classCreatorRest(newpos, encl, typeArgs, t);
     }
 
-    /** ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer
-     *                         | Expression "]" {"[" Expression "]"} BracketsOpt )
+    /** ArrayCreatorRest = [Annotations] "[" ( "]" BracketsOpt ArrayInitializer
+     *                         | Expression "]" {[Annotations]  "[" Expression "]"} BracketsOpt )
      */
     JCExpression arrayCreatorRest(int newpos, JCExpression elemtype) {
+        List<JCAnnotation> annos = typeAnnotationsOpt();
+
         accept(LBRACKET);
-        if (S.token() == RBRACKET) {
+        if (token.kind == RBRACKET) {
             accept(RBRACKET);
-            elemtype = bracketsOpt(elemtype);
-            if (S.token() == LBRACE) {
-                return arrayInitializer(newpos, elemtype);
+            elemtype = bracketsOpt(elemtype, annos);
+            if (token.kind == LBRACE) {
+                JCNewArray na = (JCNewArray)arrayInitializer(newpos, elemtype);
+                if (annos.nonEmpty()) {
+                    // when an array initializer is present then
+                    // the parsed annotations should target the
+                    // new array tree
+                    // bracketsOpt inserts the annotation in
+                    // elemtype, and it needs to be corrected
+                    //
+                    JCAnnotatedType annotated = (JCAnnotatedType)elemtype;
+                    assert annotated.annotations == annos;
+                    na.annotations = annotated.annotations;
+                    na.elemtype = annotated.underlyingType;
+                }
+                return na;
             } else {
                 JCExpression t = toP(F.at(newpos).NewArray(elemtype, List.<JCExpression>nil(), null));
-                return syntaxError(S.pos(), List.<JCTree>of(t), "array.dimension.missing");
+                return syntaxError(token.pos, List.<JCTree>of(t), "array.dimension.missing");
             }
         } else {
             ListBuffer<JCExpression> dims = new ListBuffer<JCExpression>();
+
+            // maintain array dimension type annotations
+            ListBuffer<List<JCAnnotation>> dimAnnotations = ListBuffer.lb();
+            dimAnnotations.append(annos);
+
             dims.append(parseExpression());
             accept(RBRACKET);
-            while (S.token() == LBRACKET) {
-                int pos = S.pos();
-                S.nextToken();
-                if (S.token() == RBRACKET) {
-                    elemtype = bracketsOptCont(elemtype, pos);
+            while (token.kind == LBRACKET
+                    || token.kind == MONKEYS_AT) {
+                List<JCAnnotation> maybeDimAnnos = typeAnnotationsOpt();
+                int pos = token.pos;
+                nextToken();
+                if (token.kind == RBRACKET) {
+                    elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
                 } else {
-                    dims.append(parseExpression());
-                    accept(RBRACKET);
+                    if (token.kind == RBRACKET) { // no dimension
+                        elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
+                    } else {
+                        dimAnnotations.append(maybeDimAnnos);
+                        dims.append(parseExpression());
+                        accept(RBRACKET);
+                    }
                 }
             }
-            return toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
+
+            JCNewArray na = toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
+            na.dimAnnotations = dimAnnotations.toList();
+            return na;
         }
     }
 
@@ -1508,13 +2232,10 @@ public class JavacParser implements Parser {
     {
         List<JCExpression> args = arguments();
         JCClassDecl body = null;
-        if (S.token() == LBRACE) {
-            int pos = 0;
-            List<JCTree> defs = null;
-            JCModifiers mods = null;
-            pos = S.pos();
-            defs = classOrInterfaceBody(names.empty, false);
-            mods = F.at(Position.NOPOS).Modifiers(0);
+        if (token.kind == LBRACE) {
+            int pos = token.pos;
+            List<JCTree> defs = classOrInterfaceBody(names.empty, false);
+            JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
             body = toP(F.at(pos).AnonymousClassDef(mods, defs));
         }
         return toP(F.at(newpos).NewClass(encl, typeArgs, t, args, body));
@@ -1525,16 +2246,16 @@ public class JavacParser implements Parser {
     JCExpression arrayInitializer(int newpos, JCExpression t) {
         accept(LBRACE);
         ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>();
-        if (S.token() == COMMA) {
-            S.nextToken();
-        } else if (S.token() != RBRACE) {
+        if (token.kind == COMMA) {
+            nextToken();
+        } else if (token.kind != RBRACE) {
             elems.append(variableInitializer());
-            while (S.token() == COMMA) {
-                S.nextToken();
-                if (S.token() == RBRACE) break;
+            while (token.kind == COMMA) {
+                nextToken();
+                if (token.kind == RBRACE) break;
                 elems.append(variableInitializer());
             }
-            if (S.pos() <= errorEndPos)
+            if (token.pos <= endPosTable.errorEndPos)
                 skip(false, true, true, true);
         }
         accept(RBRACE);
@@ -1544,16 +2265,17 @@ public class JavacParser implements Parser {
     /** VariableInitializer = ArrayInitializer | Expression
      */
     public JCExpression variableInitializer() {
-        return S.token() == LBRACE ? arrayInitializer(S.pos(), null) : parseExpression();
+        return token.kind == LBRACE ? arrayInitializer(token.pos, null) : parseExpression();
     }
 
     /** ParExpression = "(" Expression ")"
      */
     JCExpression parExpression() {
+        int pos = token.pos;
         accept(LPAREN);
         JCExpression t = parseExpression();
         accept(RPAREN);
-        return t;
+        return toP(F.at(pos).Parens(t));
     }
 
     /** Block = "{" BlockStatements "}"
@@ -1562,19 +2284,19 @@ public class JavacParser implements Parser {
         accept(LBRACE);
         List<JCStatement> stats = blockStatements();
         JCBlock t = F.at(pos).Block(flags, stats);
-        while (S.token() == CASE || S.token() == DEFAULT) {
-            syntaxError("orphaned", S.token());
+        while (token.kind == CASE || token.kind == DEFAULT) {
+            syntaxError("orphaned", token.kind);
             switchBlockStatementGroups();
         }
         // the Block node has a field "endpos" for first char of last token, which is
         // usually but not necessarily the last char of the last token.
-        t.endpos = S.pos();
+        t.endpos = token.pos;
         accept(RBRACE);
         return toP(t);
     }
 
     public JCBlock block() {
-        return block(S.pos(), 0);
+        return block(token.pos, 0);
     }
 
     /** BlockStatements = { BlockStatement }
@@ -1586,335 +2308,353 @@ public class JavacParser implements Parser {
      */
     @SuppressWarnings("fallthrough")
     List<JCStatement> blockStatements() {
-//todo: skip to anchor on error(?)
+        //todo: skip to anchor on error(?)
         int lastErrPos = -1;
         ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>();
         while (true) {
-            switch (S.token()) {
-            case RBRACE: case CASE: case DEFAULT: case EOF:
+            List<JCStatement> stat = blockStatement();
+            if (stat.isEmpty()) {
                 return stats.toList();
-            default:
-                stats.appendList(blockStatement());
-            }
-            // error recovery
-            if (S.pos() == lastErrPos)
-                return stats.toList();
-            if (S.pos() <= errorEndPos) {
-                skip(false, true, true, true);
-                lastErrPos = S.pos();
+            } else {
+                // error recovery
+                if (token.pos == lastErrPos)
+                    return stats.toList();
+                if (token.pos <= endPosTable.errorEndPos) {
+                    skip(false, true, true, true);
+                    lastErrPos = token.pos;
+                    JCStatement last = stat.last();
+                    if (last.hasTag(EXEC)) {
+                        JCExpression lastExpr = ((JCExpressionStatement)last).expr;
+                        if (lastExpr.hasTag(ERRONEOUS) && (((JCErroneous)lastExpr).errs == null || ((JCErroneous)lastExpr).errs.isEmpty())) {
+                            storeEnd(last, S.prevToken().endPos);
+                            storeEnd(lastExpr, S.prevToken().endPos);
+                        }
+                    }
+                }
+                stats.addAll(stat);
             }
+        }
+    }
 
-            // ensure no dangling /** @deprecated */ active
-            S.resetDeprecatedFlag();
+    /*
+     * This method parses a statement treating it as a block, relaxing the
+     * JLS restrictions, allows us to parse more faulty code, doing so
+     * enables us to provide better and accurate diagnostics to the user.
+     */
+    JCStatement parseStatementAsBlock() {
+        int pos = token.pos;
+        List<JCStatement> stats = blockStatement();
+        if (stats.isEmpty()) {
+            JCErroneous e = syntaxError(pos, "illegal.start.of.stmt");
+            return toP(F.at(pos).Exec(e));
+        } else {
+            JCStatement first = stats.head;
+            String error = null;
+            switch (first.getTag()) {
+            case CLASSDEF:
+                error = "class.not.allowed";
+                break;
+            case VARDEF:
+                error = "variable.not.allowed";
+                break;
+            }
+            if (error != null) {
+                error(first, error);
+                List<JCBlock> blist = List.of(F.at(first.pos).Block(0, stats));
+                return toP(F.at(pos).Exec(F.at(first.pos).Erroneous(blist)));
+            }
+            return first;
         }
     }
 
     @SuppressWarnings("fallthrough")
     List<JCStatement> blockStatement() {
-        ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>();
-        int pos = S.pos();
+        //todo: skip to anchor on error(?)
+        int pos = token.pos;
+        switch (token.kind) {
+        case RBRACE: case CASE: case DEFAULT: case EOF:
+            return List.nil();
+        case LBRACE: case IF: case FOR: case WHILE: case DO: case TRY:
+        case SWITCH: case SYNCHRONIZED: case RETURN: case THROW: case BREAK:
+        case CONTINUE: case SEMI: case ELSE: case FINALLY: case CATCH:
+            return List.of(parseStatement());
+        case MONKEYS_AT:
+        case FINAL: {
+            Comment dc = token.comment(CommentStyle.JAVADOC);
+            JCModifiers mods = modifiersOpt();
+            if (token.kind == INTERFACE ||
+                token.kind == CLASS ||
+                allowEnums && token.kind == ENUM) {
+                return List.of(classOrInterfaceOrEnumDeclaration(mods, dc));
+            } else {
+                JCExpression t = parseType();
+                ListBuffer<JCStatement> stats =
+                        variableDeclarators(mods, t, new ListBuffer<JCStatement>());
+                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
+                storeEnd(stats.last(), token.endPos);
+                accept(SEMI);
+                return stats.toList();
+            }
+        }
+        case ABSTRACT: case STRICTFP: {
+            Comment dc = token.comment(CommentStyle.JAVADOC);
+            JCModifiers mods = modifiersOpt();
+            return List.of(classOrInterfaceOrEnumDeclaration(mods, dc));
+        }
+        case INTERFACE:
+        case CLASS:
+            Comment dc = token.comment(CommentStyle.JAVADOC);
+            return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
+        case ENUM:
+        case ASSERT:
+            if (allowEnums && token.kind == ENUM) {
+                error(token.pos, "local.enum");
+                dc = token.comment(CommentStyle.JAVADOC);
+                return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
+            } else if (allowAsserts && token.kind == ASSERT) {
+                return List.of(parseStatement());
+            }
+            /* fall through to default */
+        default:
+            Token prevToken = token;
+            JCExpression t = term(EXPR | TYPE);
+            if (token.kind == COLON && t.hasTag(IDENT)) {
+                nextToken();
+                JCStatement stat = parseStatement();
+                return List.<JCStatement>of(F.at(pos).Labelled(prevToken.name(), stat));
+            } else if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
+                pos = token.pos;
+                JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
+                F.at(pos);
+                ListBuffer<JCStatement> stats =
+                        variableDeclarators(mods, t, new ListBuffer<JCStatement>());
+                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
+                accept(SEMI);
+                storeEnd(stats.last(), S.prevToken().endPos);
+                return stats.toList();
+            } else {
+                // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
+                accept(SEMI);
+                JCExpressionStatement expr = toP(F.at(pos).Exec(checkExprStat(t)));
+                return List.<JCStatement>of(expr);
+            }
+        }
+    }
 
-        switch (S.token()) {
+    /** Statement =
+     *       Block
+     *     | IF ParExpression Statement [ELSE Statement]
+     *     | FOR "(" ForInitOpt ";" [Expression] ";" ForUpdateOpt ")" Statement
+     *     | FOR "(" FormalParameter : Expression ")" Statement
+     *     | WHILE ParExpression Statement
+     *     | DO Statement WHILE ParExpression ";"
+     *     | TRY Block ( Catches | [Catches] FinallyPart )
+     *     | TRY "(" ResourceSpecification ";"opt ")" Block [Catches] [FinallyPart]
+     *     | SWITCH ParExpression "{" SwitchBlockStatementGroups "}"
+     *     | SYNCHRONIZED ParExpression Block
+     *     | RETURN [Expression] ";"
+     *     | THROW Expression ";"
+     *     | BREAK [Ident] ";"
+     *     | CONTINUE [Ident] ";"
+     *     | ASSERT Expression [ ":" Expression ] ";"
+     *     | ";"
+     *     | ExpressionStatement
+     *     | Ident ":" Statement
+     */
+    @SuppressWarnings("fallthrough")
+    public JCStatement parseStatement() {
+        int pos = token.pos;
+        switch (token.kind) {
         case LBRACE:
-            stats.add(block());
-            break;
+            return block();
         case IF: {
-            S.nextToken();
+            nextToken();
             JCExpression cond = parExpression();
-            JCStatement thenpart = parseStatement();
+            JCStatement thenpart = parseStatementAsBlock();
             JCStatement elsepart = null;
-            if (S.token() == ELSE) {
-                S.nextToken();
-                elsepart = parseStatement();
+            if (token.kind == ELSE) {
+                nextToken();
+                elsepart = parseStatementAsBlock();
             }
-            stats.add(F.at(pos).If(cond, thenpart, elsepart));
-            break;
+            return F.at(pos).If(cond, thenpart, elsepart);
         }
         case FOR: {
-            S.nextToken();
+            nextToken();
             accept(LPAREN);
-            List<JCStatement> inits = S.token() == SEMI ? List.<JCStatement>nil() : forInit();
+            List<JCStatement> inits = token.kind == SEMI ? List.<JCStatement>nil() : forInit();
             if (inits.length() == 1 &&
-                inits.head.getTag() == JCTree.VARDEF &&
+                inits.head.hasTag(VARDEF) &&
                 ((JCVariableDecl) inits.head).init == null &&
-                S.token() == COLON) {
+                token.kind == COLON) {
                 checkForeach();
                 JCVariableDecl var = (JCVariableDecl)inits.head;
                 accept(COLON);
                 JCExpression expr = parseExpression();
                 accept(RPAREN);
-                if (errorEndPos >= S.pos()) //error recovery
-                    storeEnd(expr, errorEndPos);
-                JCStatement body = parseStatement();
-                stats.add(F.at(pos).ForeachLoop(var, expr, body));
+                if (endPosTable.errorEndPos >= token.pos) //error recovery
+                    storeEnd(expr, endPosTable.errorEndPos);
+                JCStatement body = parseStatementAsBlock();
+                return F.at(pos).ForeachLoop(var, expr, body);
             } else {
                 accept(SEMI);
-                if (errorEndPos >= S.pos() && inits.length() > 0) //error recovery
-                    storeEnd(inits.last(), errorEndPos);
-                JCExpression cond = S.token() == SEMI ? null : parseExpression();
+                if (endPosTable.errorEndPos >= token.pos && inits.length() > 0) //error recovery
+                    storeEnd(inits.last(), endPosTable.errorEndPos);
+                JCExpression cond = token.kind == SEMI ? null : parseExpression();
                 accept(SEMI);
-                if (errorEndPos >= S.pos()) //error recovery
-                    storeEnd(cond, errorEndPos);
-                List<JCExpressionStatement> steps = S.token() == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate();
+                if (endPosTable.errorEndPos >= token.pos) //error recovery
+                    storeEnd(cond, endPosTable.errorEndPos);
+                List<JCExpressionStatement> steps = token.kind == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate();
                 accept(RPAREN);
-                if (errorEndPos >= S.pos() && steps.length() > 0) //error recovery
-                    storeEnd(steps.last(), errorEndPos);
-                JCStatement body = parseStatement();
-                stats.add(F.at(pos).ForLoop(inits, cond, steps, body));
+                if (endPosTable.errorEndPos >= token.pos && steps.length() > 0) //error recovery
+                    storeEnd(steps.last(), endPosTable.errorEndPos);
+                JCStatement body = parseStatementAsBlock();
+                return F.at(pos).ForLoop(inits, cond, steps, body);
             }
-            break;
         }
         case WHILE: {
-            S.nextToken();
+            nextToken();
             JCExpression cond = parExpression();
-            JCStatement body = parseStatement();
-            stats.add(F.at(pos).WhileLoop(cond, body));
-            break;
+            JCStatement body = parseStatementAsBlock();
+            return F.at(pos).WhileLoop(cond, body);
         }
         case DO: {
-            S.nextToken();
-            JCStatement body = parseStatement();
+            nextToken();
+            JCStatement body = parseStatementAsBlock();
             accept(WHILE);
             JCExpression cond = parExpression();
             accept(SEMI);
             JCDoWhileLoop t = toP(F.at(pos).DoLoop(body, cond));
-            stats.add(t);
-            break;
+            return t;
         }
         case TRY: {
-            S.nextToken();
+            nextToken();
             List<JCTree> resources = List.<JCTree>nil();
-            if (S.token() == LPAREN) {
+            if (token.kind == LPAREN) {
                 checkTryWithResources();
-                S.nextToken();
+                nextToken();
                 resources = resources();
                 accept(RPAREN);
             }
             JCBlock body = block();
             ListBuffer<JCCatch> catchers = new ListBuffer<JCCatch>();
             JCBlock finalizer = null;
-            String err = null;
-            if (S.token() == CATCH || S.token() == FINALLY) {
-                while (S.token() == CATCH) catchers.append(catchClause());
-                if (S.token() == FINALLY) {
-                    S.nextToken();
+            if (token.kind == CATCH || token.kind == FINALLY) {
+                while (token.kind == CATCH) catchers.append(catchClause());
+                if (token.kind == FINALLY) {
+                    nextToken();
                     finalizer = block();
                 }
             } else {
                 if (allowTWR) {
                     if (resources.isEmpty())
-                        err = "try.without.catch.finally.or.resource.decls";
+                        error(pos, "try.without.catch.finally.or.resource.decls");
                 } else
-                    err = "try.without.catch.or.finally";
+                    error(pos, "try.without.catch.or.finally");
             }
-            JCTry t = F.at(pos).Try(resources, body, catchers.toList(), finalizer);
-            if (err != null)
-                error(t, err);
-            stats.add(t);
-            break;
+            return F.at(pos).Try(resources, body, catchers.toList(), finalizer);
         }
         case SWITCH: {
-            S.nextToken();
+            nextToken();
             JCExpression selector = parExpression();
             accept(LBRACE);
             List<JCCase> cases = switchBlockStatementGroups();
             JCSwitch t = to(F.at(pos).Switch(selector, cases));
             accept(RBRACE);
-            stats.add(t);
-            break;
+            return t;
         }
         case SYNCHRONIZED: {
-            S.nextToken();
+            nextToken();
             JCExpression lock = parExpression();
             JCBlock body = block();
-            stats.add(F.at(pos).Synchronized(lock, body));
-            break;
+            return F.at(pos).Synchronized(lock, body);
         }
         case RETURN: {
-            S.nextToken();
-            JCExpression result = S.token() == SEMI ? null : parseExpression();
+            nextToken();
+            JCExpression result = token.kind == SEMI ? null : parseExpression();
             accept(SEMI);
             JCReturn t = toP(F.at(pos).Return(result));
-            stats.add(t);
-            break;
+            return t;
         }
         case THROW: {
-            S.nextToken();
+            nextToken();
             JCExpression exc = parseExpression();
             accept(SEMI);
             JCThrow t = toP(F.at(pos).Throw(exc));
-            stats.add(t);
-            break;
+            return t;
         }
         case BREAK: {
-            S.nextToken();
-            Name label = (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM) ? ident() : null;
-            accept(SEMI);
-            JCBreak t = toP(F.at(pos).Break(label));
-            stats.add(t);
-            break;
-        }
-        case CONTINUE: {
-            S.nextToken();
-            Name label = (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM) ? ident() : null;
+            nextToken();
+            Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null;
             accept(SEMI);
-            JCContinue t =  toP(F.at(pos).Continue(label));
-            stats.add(t);
-            break;
-        }
-        case SEMI:
-            S.nextToken();
-            stats.add(toP(F.at(pos).Skip()));
-            break;
-        case ELSE:
-            stats.add(toP(F.Exec(syntaxError("else.without.if"))));
-            break;
-        case FINALLY:
-            stats.add(toP(F.Exec(syntaxError("finally.without.try"))));
-            break;
-        case CATCH:
-            stats.add(toP(F.Exec(syntaxError("catch.without.try"))));
-            break;
-        case MONKEYS_AT:
-        case FINAL: {
-            String dc = S.docComment();
-            JCModifiers mods = modifiersOpt();
-            if (S.token() == INTERFACE ||
-                S.token() == CLASS ||
-                allowEnums && S.token() == ENUM) {
-                stats.append(classOrInterfaceOrEnumDeclaration(mods, dc));
-            } else {
-                JCExpression t = parseType();
-                stats.appendList(variableDeclarators(mods, t,
-                                                     new ListBuffer<JCStatement>()));
-                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
-                storeEnd(stats.last(), S.endPos());
-                accept(SEMI);
-            }
-            break;
-        }
-        case ABSTRACT: case STRICTFP: {
-            String dc = S.docComment();
-            JCModifiers mods = modifiersOpt();
-            if (S.token() == INTERFACE ||
-                S.token() == CLASS ||
-                allowEnums && S.token() == ENUM) {
-                stats.append(classOrInterfaceOrEnumDeclaration(mods, dc));
-            } else {
-                mode = EXPR;
-                stats.append(to(F.at(pos).Exec(illegal(pos))));
-            }
-            break;
+            JCBreak t = toP(F.at(pos).Break(label));
+            return t;
         }
-        case INTERFACE:
-        case CLASS:
-            stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(),
-                                                           S.docComment()));
-            break;
-        case ENUM:
-        case ASSERT:
-            if (allowEnums && S.token() == ENUM) {
-                error(S.pos(), "local.enum");
-                stats.
-                    append(classOrInterfaceOrEnumDeclaration(modifiersOpt(),
-                                                             S.docComment()));
-                break;
-            } else if (allowAsserts && S.token() == ASSERT) {
-                S.nextToken();
+        case CONTINUE: {
+            nextToken();
+            Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null;
+            accept(SEMI);
+            JCContinue t =  toP(F.at(pos).Continue(label));
+            return t;
+        }
+        case SEMI:
+            nextToken();
+            return toP(F.at(pos).Skip());
+        case ELSE:
+            int elsePos = token.pos;
+            nextToken();
+            return doRecover(elsePos, BasicErrorRecoveryAction.BLOCK_STMT, "else.without.if");
+        case FINALLY:
+            int finallyPos = token.pos;
+            nextToken();
+            return doRecover(finallyPos, BasicErrorRecoveryAction.BLOCK_STMT, "finally.without.try");
+        case CATCH:
+            return doRecover(token.pos, BasicErrorRecoveryAction.CATCH_CLAUSE, "catch.without.try");
+        case ASSERT: {
+            if (allowAsserts && token.kind == ASSERT) {
+                nextToken();
                 JCExpression assertion = parseExpression();
                 JCExpression message = null;
-                if (S.token() == COLON) {
-                    S.nextToken();
+                if (token.kind == COLON) {
+                    nextToken();
                     message = parseExpression();
                 }
                 accept(SEMI);
                 JCAssert t = toP(F.at(pos).Assert(assertion, message));
-                stats.append(t);
-                break;
+                return t;
             }
-            /* fall through to default */
+            /* else fall through to default case */
+        }
+        case ENUM:
         default:
-            Name name = S.name();
-            JCExpression t = term(EXPR | TYPE);
-            if (S.token() == COLON && t.getTag() == JCTree.IDENT) {
-                S.nextToken();
+            Token prevToken = token;
+            JCExpression expr = parseExpression();
+            if (token.kind == COLON && expr.hasTag(IDENT)) {
+                nextToken();
                 JCStatement stat = parseStatement();
-                stats.append(F.at(pos).Labelled(name, stat));
-            } else if ((lastmode & TYPE) != 0 &&
-                       (S.token() == IDENTIFIER ||
-                        S.token() == ASSERT ||
-                        S.token() == ENUM)) {
-                pos = S.pos();
-                JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
-                F.at(pos);
-                stats.appendList(variableDeclarators(mods, t,
-                                                     new ListBuffer<JCStatement>()));
-                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
-                accept(SEMI);
-                storeEnd(stats.last(), S.prevEndPos());
+                return F.at(pos).Labelled(prevToken.name(), stat);
             } else {
                 // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
+                JCExpressionStatement stat = to(F.at(pos).Exec(checkExprStat(expr)));
+                if (token.kind != SEMI) // Error recovery
+                    storeEnd(stat, token.pos);
                 accept(SEMI);
-                stats.append(toP(F.at(pos).Exec(checkExprStat(t))));
+                return stat;
             }
         }
-
-        return stats.toList();
     }
 
-    /** Statement =
-     *       Block
-     *     | IF ParExpression Statement [ELSE Statement]
-     *     | FOR "(" ForInitOpt ";" [Expression] ";" ForUpdateOpt ")" Statement
-     *     | FOR "(" FormalParameter : Expression ")" Statement
-     *     | WHILE ParExpression Statement
-     *     | DO Statement WHILE ParExpression ";"
-     *     | TRY Block ( Catches | [Catches] FinallyPart )
-     *     | TRY "(" ResourceSpecification ";"opt ")" Block [Catches] [FinallyPart]
-     *     | SWITCH ParExpression "{" SwitchBlockStatementGroups "}"
-     *     | SYNCHRONIZED ParExpression Block
-     *     | RETURN [Expression] ";"
-     *     | THROW Expression ";"
-     *     | BREAK [Ident] ";"
-     *     | CONTINUE [Ident] ";"
-     *     | ASSERT Expression [ ":" Expression ] ";"
-     *     | ";"
-     *     | ExpressionStatement
-     *     | Ident ":" Statement
-     */
-    @SuppressWarnings("fallthrough")
-    public JCStatement parseStatement() {
-        int pos = S.pos();
-        //error recovery: parse the statement as a block statement, and report
-        //error if the statement is a variable or class (otherwise, the tree would be
-        //very distorted):
-        List<JCStatement> statements = blockStatement();
-        JCStatement first = statements.head;
-        String error = null;
-
-        switch (first.getTag()) {
-        case JCTree.CLASSDEF:
-            error = "class.not.allowed";
-            break;
-        case JCTree.VARDEF:
-            error = "variable.not.allowed";
-            break;
-        }
-
-        if (error != null) {
-            error(first, error);
-            statements = List.<JCStatement>of(toP(F.at(pos).Exec(F.at(first.pos).Erroneous(List.of(F.at(first.pos).Block(0, statements))))));
-        }
-
-        assert statements.size() == 1 : statements.toString();
-
-        return statements.head;
+    private JCStatement doRecover(int startPos, ErrorRecoveryAction action, String key) {
+        int errPos = S.errPos();
+        JCTree stm = action.doRecover(this);
+        S.errPos(errPos);
+        return toP(F.Exec(syntaxError(startPos, List.<JCTree>of(stm), key)));
     }
 
     /** CatchClause     = CATCH "(" FormalParameter ")" Block
+     * TODO: the "FormalParameter" is not correct, it uses the special "catchTypes" rule below.
      */
     protected JCCatch catchClause() {
-        int pos = S.pos();
+        int pos = token.pos;
         accept(CATCH);
         accept(LPAREN);
         JCModifiers mods = optFinal(Flags.PARAMETER);
@@ -1931,20 +2671,25 @@ public class JavacParser implements Parser {
     List<JCExpression> catchTypes() {
         ListBuffer<JCExpression> catchTypes = ListBuffer.lb();
         catchTypes.add(parseType());
-        while (S.token() == BAR) {
+        while (token.kind == BAR) {
             checkMulticatch();
-            S.nextToken();
-            catchTypes.add(qualident());
+            nextToken();
+            // Instead of qualident this is now parseType.
+            // But would that allow too much, e.g. arrays or generics?
+            catchTypes.add(parseType());
         }
         return catchTypes.toList();
     }
 
     /** SwitchBlockStatementGroups = { SwitchBlockStatementGroup }
+     *  SwitchBlockStatementGroup = SwitchLabel BlockStatements
+     *  SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"
      */
     List<JCCase> switchBlockStatementGroups() {
         ListBuffer<JCCase> cases = new ListBuffer<JCCase>();
         while (true) {
-            switch (S.token()) {
+            int pos = token.pos;
+            switch (token.kind) {
             case CASE:
             case DEFAULT:
                 cases.append(switchBlockStatementGroup());
@@ -1952,42 +2697,37 @@ public class JavacParser implements Parser {
             case RBRACE: case EOF:
                 return cases.toList();
             default:
-                int pos = S.pos();
-                S.nextToken(); // to ensure progress
+                nextToken(); // to ensure progress
                 syntaxError(pos, "expected3",
                     CASE, DEFAULT, RBRACE);
             }
         }
     }
 
-    /** SwitchBlockStatementGroup = SwitchLabel BlockStatements
-     *  SwitchLabel = CASE ConstantExpression ":" | DEFAULT ":"
-     */
     protected JCCase switchBlockStatementGroup() {
-        int pos = S.pos();
-        switch (S.token()) {
-        case CASE: {
-            S.nextToken();
+        int pos = token.pos;
+        List<JCStatement> stats;
+        JCCase c;
+        switch (token.kind) {
+        case CASE:
+            nextToken();
             JCExpression pat = parseExpression();
             accept(COLON);
-            List<JCStatement> stats = blockStatements();
-            JCCase c = F.at(pos).Case(pat, stats);
+            stats = blockStatements();
+            c = F.at(pos).Case(pat, stats);
             if (stats.isEmpty())
-                storeEnd(c, S.prevEndPos());
+                storeEnd(c, S.prevToken().endPos);
             return c;
-        }
-        case DEFAULT: {
-            S.nextToken();
+        case DEFAULT:
+            nextToken();
             accept(COLON);
-            List<JCStatement> stats = blockStatements();
-            JCCase c = F.at(pos).Case(null, stats);
+            stats = blockStatements();
+            c = F.at(pos).Case(null, stats);
             if (stats.isEmpty())
-                storeEnd(c, S.prevEndPos());
+                storeEnd(c, S.prevToken().endPos);
             return c;
         }
-        default:
-            throw new AssertionError(S.token().toString());
-        }
+        throw new AssertionError("should not reach here");
     }
 
     /** MoreStatementExpressions = { COMMA StatementExpression }
@@ -1997,9 +2737,9 @@ public class JavacParser implements Parser {
                                                                     T stats) {
         // This Exec is a "StatementExpression"; it subsumes no terminating token
         stats.append(toP(F.at(pos).Exec(checkExprStat(first))));
-        while (S.token() == COMMA) {
-            S.nextToken();
-            pos = S.pos();
+        while (token.kind == COMMA) {
+            nextToken();
+            pos = token.pos;
             JCExpression t = parseExpression();
             // This Exec is a "StatementExpression"; it subsumes no terminating token
             stats.append(toP(F.at(pos).Exec(checkExprStat(t))));
@@ -2012,38 +2752,53 @@ public class JavacParser implements Parser {
      */
     List<JCStatement> forInit() {
         ListBuffer<JCStatement> stats = lb();
-        int pos = S.pos();
-        if (S.token() == FINAL || S.token() == MONKEYS_AT) {
+        int pos = token.pos;
+        if (token.kind == FINAL || token.kind == MONKEYS_AT) {
             return variableDeclarators(optFinal(0), parseType(), stats).toList();
         } else {
             JCExpression t = term(EXPR | TYPE);
-            if ((lastmode & TYPE) != 0 &&
-                (S.token() == IDENTIFIER || S.token() == ASSERT || S.token() == ENUM || S.token() == COLON))
+            if ((lastmode & TYPE) != 0 && (LAX_IDENTIFIER.accepts(token.kind) || token.kind == COLON)) {
                 return variableDeclarators(modifiersOpt(), t, stats).toList();
-            else
+            } else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
+                error(pos, "bad.initializer", "for-loop");
+                return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null));
+            } else {
                 return moreStatementExpressions(pos, t, stats).toList();
+            }
         }
     }
 
     /** ForUpdate = StatementExpression MoreStatementExpressions
      */
     List<JCExpressionStatement> forUpdate() {
-        return moreStatementExpressions(S.pos(),
+        return moreStatementExpressions(token.pos,
                                         parseExpression(),
                                         new ListBuffer<JCExpressionStatement>()).toList();
     }
 
     /** AnnotationsOpt = { '@' Annotation }
+     *
+     * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION
      */
-    List<JCAnnotation> annotationsOpt() {
-        if (S.token() != MONKEYS_AT) return List.nil(); // optimization
+    List<JCAnnotation> annotationsOpt(Tag kind) {
+        if (token.kind != MONKEYS_AT) return List.nil(); // optimization
         ListBuffer<JCAnnotation> buf = new ListBuffer<JCAnnotation>();
-        while (S.token() == MONKEYS_AT) {
-            int pos = S.pos();
-            S.nextToken();
-            buf.append(annotation(pos));
+        int prevmode = mode;
+        while (token.kind == MONKEYS_AT) {
+            int pos = token.pos;
+            nextToken();
+            buf.append(annotation(pos, kind));
         }
-        return buf.toList();
+        lastmode = mode;
+        mode = prevmode;
+        List<JCAnnotation> annotations = buf.toList();
+
+        return annotations;
+    }
+
+    List<JCAnnotation> typeAnnotationsOpt() {
+        List<JCAnnotation> annotations = annotationsOpt(Tag.TYPE_ANNOTATION);
+        return annotations;
     }
 
     /** ModifiersOpt = { Modifier }
@@ -2060,17 +2815,17 @@ public class JavacParser implements Parser {
         int pos;
         if (partial == null) {
             flags = 0;
-            pos = S.pos();
+            pos = token.pos;
         } else {
             flags = partial.flags;
             annotations.appendList(partial.annotations);
             pos = partial.pos;
         }
-        int lastPos = Position.NOPOS;
+        int lastPos;
     loop:
         while (true) {
             long flag;
-            switch (S.token()) {
+            switch (token.kind) {
             case PRIVATE     : flag = Flags.PRIVATE; break;
             case PROTECTED   : flag = Flags.PROTECTED; break;
             case PUBLIC      : flag = Flags.PUBLIC; break;
@@ -2083,27 +2838,29 @@ public class JavacParser implements Parser {
             case SYNCHRONIZED: flag = Flags.SYNCHRONIZED; break;
             case STRICTFP    : flag = Flags.STRICTFP; break;
             case MONKEYS_AT  : flag = Flags.ANNOTATION; break;
-            case ERROR       : flag = 0; S.nextToken(); break;
+            case DEFAULT     : checkDefaultMethods(); flag = Flags.DEFAULT; break;
+            case ERROR       : flag = 0; nextToken(); break;
             default: break loop;
             }
-            if ((flags & flag) != 0) error(S.pos(), "repeated.modifier");
-            lastPos = S.pos();
-            S.nextToken();
+            if ((flags & flag) != 0) error(token.pos, "repeated.modifier");
+            lastPos = token.pos;
+            if (token.deprecatedFlag())
+                flags |= Flags.DEPRECATED;
+            nextToken();
             if (flag == Flags.ANNOTATION) {
                 checkAnnotations();
-                if (S.token() != INTERFACE) {
-                    JCAnnotation ann = annotation(lastPos);
+                if (token.kind != INTERFACE) {
+                    JCAnnotation ann = annotation(lastPos, Tag.ANNOTATION);
                     // if first modifier is an annotation, set pos to annotation's.
                     if (flags == 0 && annotations.isEmpty())
                         pos = ann.pos;
                     annotations.append(ann);
-                    lastPos = ann.pos;
                     flag = 0;
                 }
             }
             flags |= flag;
         }
-        switch (S.token()) {
+        switch (token.kind) {
         case ENUM:
             if (this.allowEnums) {
                 flags |= Flags.ENUM;
@@ -2112,50 +2869,58 @@ public class JavacParser implements Parser {
         case INTERFACE: flags |= Flags.INTERFACE; break;
         default: break;
         }
-
-        if (S.deprecatedFlag()) {
-            flags |= Flags.DEPRECATED;
-            S.resetDeprecatedFlag();
-        }
-
+        
         /* A modifiers tree with no modifier tokens or annotations
          * has no text position. */
-        if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty())
+        if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION | Flags.DEFAULT)) == 0 && annotations.isEmpty())
             pos = Position.NOPOS;
 
         JCModifiers mods = F.at(pos).Modifiers(flags, annotations.toList());
         if (pos != Position.NOPOS)
-            storeEnd(mods, S.prevEndPos());
+            storeEnd(mods, S.prevToken().endPos);
         return mods;
     }
 
     /** Annotation              = "@" Qualident [ "(" AnnotationFieldValues ")" ]
+     *
      * @param pos position of "@" token
+     * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION
      */
-    JCAnnotation annotation(int pos) {
+    JCAnnotation annotation(int pos, Tag kind) {
         // accept(AT); // AT consumed by caller
         checkAnnotations();
-        JCTree ident = qualident();
-        int identEndPos = S.prevEndPos();
-        boolean hasParens = S.token() == LPAREN;
+        if (kind == Tag.TYPE_ANNOTATION) {
+            checkTypeAnnotations();
+        }
+        JCTree ident = qualident(false);
+        int identEndPos = S.prevToken().endPos;
+        boolean hasParens = token.kind == LPAREN;
         List<JCExpression> fieldValues = annotationFieldValuesOpt();
-        JCAnnotation ann = F.at(pos).Annotation(ident, fieldValues);
-        storeEnd(ann, hasParens ? S.prevEndPos() : identEndPos);
+        JCAnnotation ann;
+        if (kind == Tag.ANNOTATION) {
+            ann = F.at(pos).Annotation(ident, fieldValues);
+        } else if (kind == Tag.TYPE_ANNOTATION) {
+            ann = F.at(pos).TypeAnnotation(ident, fieldValues);
+        } else {
+            throw new AssertionError("Unhandled annotation kind: " + kind);
+        }
+
+        storeEnd(ann, hasParens ? S.prevToken().endPos : identEndPos);
         return ann;
     }
 
     List<JCExpression> annotationFieldValuesOpt() {
-        return (S.token() == LPAREN) ? annotationFieldValues() : List.<JCExpression>nil();
+        return (token.kind == LPAREN) ? annotationFieldValues() : List.<JCExpression>nil();
     }
 
     /** AnnotationFieldValues   = "(" [ AnnotationFieldValue { "," AnnotationFieldValue } ] ")" */
     List<JCExpression> annotationFieldValues() {
         accept(LPAREN);
         ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>();
-        if (S.token() != RPAREN) {
+        if (token.kind != RPAREN) {
             buf.append(annotationFieldValue());
-            while (S.token() == COMMA) {
-                S.nextToken();
+            while (token.kind == COMMA) {
+                nextToken();
                 buf.append(annotationFieldValue());
             }
         }
@@ -2167,11 +2932,11 @@ public class JavacParser implements Parser {
      *                          | Identifier "=" AnnotationValue
      */
     JCExpression annotationFieldValue() {
-        if (S.token() == IDENTIFIER) {
+        if (LAX_IDENTIFIER.accepts(token.kind)) {
             mode = EXPR;
             JCExpression t1 = term1();
-            if (t1.getTag() == JCTree.IDENT && S.token() == EQ) {
-                int pos = S.pos();
+            if (t1.hasTag(IDENT) && token.kind == EQ) {
+                int pos = token.pos;
                 accept(EQ);
                 JCExpression v = annotationValue();
                 return toP(F.at(pos).Assign(t1, v));
@@ -2188,20 +2953,22 @@ public class JavacParser implements Parser {
      */
     JCExpression annotationValue() {
         int pos;
-        switch (S.token()) {
+        switch (token.kind) {
         case MONKEYS_AT:
-            pos = S.pos();
-            S.nextToken();
-            return annotation(pos);
+            pos = token.pos;
+            nextToken();
+            return annotation(pos, Tag.ANNOTATION);
         case LBRACE:
-            pos = S.pos();
+            pos = token.pos;
             accept(LBRACE);
             ListBuffer<JCExpression> buf = new ListBuffer<JCExpression>();
-            if (S.token() != RBRACE) {
+            if (token.kind == COMMA) {
+                nextToken();
+            } else if (token.kind != RBRACE) {
                 buf.append(annotationValue());
-                while (S.token() == COMMA) {
-                    S.nextToken();
-                    if (S.token() == RBRACE) break;
+                while (token.kind == COMMA) {
+                    nextToken();
+                    if (token.kind == RBRACE) break;
                     buf.append(annotationValue());
                 }
             }
@@ -2219,7 +2986,7 @@ public class JavacParser implements Parser {
                                                                          JCExpression type,
                                                                          T vdefs)
     {
-        return variableDeclaratorsRest(S.pos(), mods, type, ident(), false, null, vdefs);
+        return variableDeclaratorsRest(token.pos, mods, type, ident(), false, null, vdefs);
     }
 
     /** VariableDeclaratorsRest = VariableDeclaratorRest { "," VariableDeclarator }
@@ -2233,14 +3000,14 @@ public class JavacParser implements Parser {
                                                                      JCExpression type,
                                                                      Name name,
                                                                      boolean reqInit,
-                                                                     String dc,
+                                                                     Comment dc,
                                                                      T vdefs)
     {
         vdefs.append(variableDeclaratorRest(pos, mods, type, name, reqInit, dc));
-        while (S.token() == COMMA) {
+        while (token.kind == COMMA) {
             // All but last of multiple declarators subsume a comma
-            storeEnd((JCTree)vdefs.last(), S.endPos());
-            S.nextToken();
+            storeEnd((JCTree)vdefs.last(), token.endPos);
+            nextToken();
             vdefs.append(variableDeclarator(mods, type, reqInit, dc));
         }
         return vdefs;
@@ -2249,8 +3016,8 @@ public class JavacParser implements Parser {
     /** VariableDeclarator = Ident VariableDeclaratorRest
      *  ConstantDeclarator = Ident ConstantDeclaratorRest
      */
-    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, String dc) {
-        return variableDeclaratorRest(S.pos(), mods, type, ident(), reqInit, dc);
+    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, Comment dc) {
+        return variableDeclaratorRest(token.pos, mods, type, ident(), reqInit, dc);
     }
 
     /** VariableDeclaratorRest = BracketsOpt ["=" VariableInitializer]
@@ -2260,16 +3027,16 @@ public class JavacParser implements Parser {
      *  @param dc       The documentation comment for the variable declarations, or null.
      */
     JCVariableDecl variableDeclaratorRest(int pos, JCModifiers mods, JCExpression type, Name name,
-                                  boolean reqInit, String dc) {
+                                  boolean reqInit, Comment dc) {
         type = bracketsOpt(type);
         JCExpression init = null;
-        if (S.token() == EQ) {
-            S.nextToken();
+        if (token.kind == EQ) {
+            nextToken();
             init = variableInitializer();
-            if (init.getTag() == JCTree.ERRONEOUS && ((JCErroneous)init).errs.isEmpty() && S.prevEndPos() < init.pos)
-                init.pos = S.prevEndPos();
+            if (init.hasTag(ERRONEOUS) && ((JCErroneous)init).errs.isEmpty() && S.prevToken().endPos < init.pos)
+                init.pos = S.prevToken().endPos;
         }
-        else if (reqInit) syntaxError(S.pos(), "expected", EQ);
+        else if (reqInit) syntaxError(token.pos, "expected", EQ);
         JCVariableDecl result =
             toP(F.at(pos).VarDef(mods, name, type, init));
         attach(result, dc);
@@ -2279,11 +3046,36 @@ public class JavacParser implements Parser {
     /** VariableDeclaratorId = Ident BracketsOpt
      */
     JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type) {
-        int pos = S.pos();
-        Name name = ident();
+        return variableDeclaratorId(mods, type, false);
+    }
+    //where
+    JCVariableDecl variableDeclaratorId(JCModifiers mods, JCExpression type, boolean lambdaParameter) {
+        int pos = token.pos;
+        Name name;
+        if (lambdaParameter && token.kind == UNDERSCORE) {
+            syntaxError(pos, "expected", IDENTIFIER);
+            name = token.name();
+        } else {
+            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 &&
-                S.token() == LBRACKET) {
-            log.error(S.pos(), "varargs.and.old.array.syntax");
+                token.kind == LBRACKET) {
+            log.error(token.pos, "varargs.and.old.array.syntax");
         }
         type = bracketsOpt(type);
         return toP(F.at(pos).VarDef(mods, name, type, null));
@@ -2294,12 +3086,11 @@ public class JavacParser implements Parser {
     List<JCTree> resources() {
         ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
         defs.append(resource());
-        while (S.token() == SEMI) {
+        while (token.kind == SEMI) {
             //nb-javac: do not subsume the semicolon, so that it can be considered
             //to be a separator by the code generator
-            int semiColonPos = S.pos();
-            S.nextToken();
-            if (S.token() == RPAREN) { // Optional trailing semicolon
+            nextToken();
+            if (token.kind == RPAREN) { // Optional trailing semicolon
                                        // after last resource
                 break;
             }
@@ -2313,7 +3104,7 @@ public class JavacParser implements Parser {
     protected JCTree resource() {
         JCModifiers optFinal = optFinal(Flags.FINAL);
         JCExpression type = parseType();
-        int pos = S.pos();
+        int pos = token.pos;
         Name ident = ident();
         return variableDeclaratorRest(pos, optFinal, type, ident, true, null);
     }
@@ -2321,123 +3112,160 @@ public class JavacParser implements Parser {
     /** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
      */
     public JCTree.JCCompilationUnit parseCompilationUnit() {
-        int pos = S.pos();
+        Token firstToken = token;
         JCExpression pid = null;
-        String toplevel_dc = S.docComment();
-        String dc = S.docComment();
         JCModifiers mods = null;
+        boolean consumedToplevelDoc = false;
+        boolean seenImport = false;
+        boolean seenPackage = false;
         List<JCAnnotation> packageAnnotations = List.nil();
         ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
         boolean checkForPackage = true;
         boolean checkForImports = true;
-        while (S.token() != EOF) {
-            if (S.pos() <= errorEndPos) {
+        boolean firstTypeDecl = true;
+        while (token.kind != EOF) {
+            if (token.pos <= endPosTable.errorEndPos) {
                 // error recovery
                 skip(checkForImports, false, false, false);
-                if (S.token() == EOF)
+                if (token.kind == EOF)
                     break;
             }
-            if (checkForPackage && S.token() == MONKEYS_AT) {
+            if (checkForPackage && token.kind == MONKEYS_AT) {
                 mods = modifiersOpt();
-            } else if (S.token() == PACKAGE) {
+            } else if (token.kind == PACKAGE) {
                 if (checkForPackage) {
+                    seenPackage = true;
+                    checkForPackage = false;
                     if (mods != null) {
                         checkNoMods(mods.flags);
                         packageAnnotations = mods.annotations;
                         mods = null;
                     }
-                    S.nextToken();
-                    pid = qualident();
+                    nextToken();
+                    pid = qualident(false);
                     accept(SEMI);
-                    checkForPackage = false;
                 } else {
                     if (allowEnums)
-                        reportSyntaxError(S.pos(), "expected3", CLASS, INTERFACE, ENUM);
+                        reportSyntaxError(token.pos, "expected3", CLASS, INTERFACE, ENUM);
                     else
-                        reportSyntaxError(S.pos(), "expected2", CLASS, INTERFACE);
-                    S.nextToken();
+                        reportSyntaxError(token.pos, "expected2", CLASS, INTERFACE);
+                    nextToken();
                 }
-                dc = null;
-            } else if (checkForImports && mods == null && S.token() == IMPORT) {
-                defs.append(importDeclaration());
+            } else if (checkForImports && mods == null && token.kind == IMPORT) {
+                seenImport = true;
                 checkForPackage = false;
-                dc = null;
+                defs.append(importDeclaration());
             } else {
-                JCTree def = typeDeclaration(mods, dc);
-                if (keepDocComments && dc != null && docComments.get(def) == dc) {
-                    // If the first type declaration has consumed the first doc
-                    // comment, then don't use it for the top level comment as well.
-                    dc = null;
+                Comment docComment = token.comment(CommentStyle.JAVADOC);
+                if (docComment == null && firstTypeDecl && !seenImport && !seenPackage) {
+                    docComment = firstToken.comment(CommentStyle.JAVADOC);
+                    consumedToplevelDoc = true;
                 }
+                JCTree def = typeDeclaration(mods, docComment);
                 defs.append(def);
                 if (def instanceof JCClassDecl) {
                     checkForPackage = false;
                     checkForImports = false;
                 }
                 mods = null;
-                dc = null;
+                firstTypeDecl = false;
             }
         }
-        JCTree.JCCompilationUnit toplevel = F.at(pos).TopLevel(packageAnnotations, pid, defs.toList());
-        attach(toplevel, toplevel_dc);
+        JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(packageAnnotations, pid, defs.toList());
+        if (!consumedToplevelDoc)
+            attach(toplevel, firstToken.comment(CommentStyle.JAVADOC));
         if (defs.isEmpty())
-            storeEnd(toplevel, S.prevEndPos());
+            storeEnd(toplevel, S.prevToken().endPos);
         if (keepDocComments)
             toplevel.docComments = docComments;
         if (keepLineMap)
             toplevel.lineMap = S.getLineMap();
+        this.endPosTable.setParser(null); // remove reference to parser
+        toplevel.endPositions = this.endPosTable;
         return toplevel;
     }
 
     /** ImportDeclaration = IMPORT [ STATIC ] Ident { "." Ident } [ "." "*" ] ";"
      */
     JCTree importDeclaration() {
-        int pos = S.pos();
-        S.nextToken();
+        int pos = token.pos;
+        nextToken();
         boolean importStatic = false;
-        if (S.token() == STATIC) {
+        if (token.kind == STATIC) {
             checkStaticImports();
             importStatic = true;
-            S.nextToken();
+            nextToken();
         }
-        JCExpression pid = toP(F.at(S.pos()).Ident(ident()));
+        JCExpression pid = toP(F.at(token.pos).Ident(ident()));
         do {
-            int pos1 = S.pos();
+            int pos1 = token.pos;
             accept(DOT);
-            if (S.token() == STAR) {
+            if (token.kind == STAR) {
                 pid = to(F.at(pos1).Select(pid, names.asterisk));
-                S.nextToken();
+                nextToken();
                 break;
             } else {
                 pid = toP(F.at(pos1).Select(pid, ident()));
             }
             
             // Error recovery
-            if (S.token() == ERROR || S.token() == ELLIPSIS) {
-                String val = S.stringVal();
-                for (int i = 0; i < val.length() && val.charAt(i) == '.'; i++) {
-                    if (i < val.length() - 1) {
-                        pid = F.at(S.pos() + i).Select(pid, names.error);
-                        storeEnd(pid, S.pos() + i + 1);
-                    } else {
-                        S.token(DOT);
+            switch (token.kind) {
+                case ERROR:
+                    String val = token.stringVal();
+                    for (int i = 0; i < val.length() && val.charAt(i) == '.'; i++) {
+                        if (i < val.length() - 1) {
+                            pid = F.at(token.pos + i).Select(pid, names.error);
+                            setErrorEndPos(token.pos + i + 1);
+                            reportSyntaxError(token.pos + i, "expected", IDENTIFIER);
+                            storeEnd(pid, token.pos + i + 1);
+                        } else {
+                            nextToken();
+                            if (token.kind == STAR) {
+                                pid = to(F.at(pos1).Select(pid, names.asterisk));
+                                nextToken();
+                                break;
+                            } else {
+                                pid = toP(F.at(pos1).Select(pid, ident()));
+                            }
+                        }
                     }
-                }
-            } else if (S.token() == FLOATLITERAL || S.token() == DOUBLELITERAL) {
-                String val = S.stringVal();
-                if (val.length() > 0 && val.charAt(0) == '.') {
-                    setErrorEndPos(S.pos());
-                    reportSyntaxError(S.prevEndPos(), "expected", IDENTIFIER);
-                    pid = to(F.at(S.pos()).Select(pid, names.error));
-                    S.nextToken();
-                    if (S.token() == IDENTIFIER) {
-                        S.nextToken();
-                        storeEnd(pid, S.pos());
+                    break;
+                case ELLIPSIS:
+                    val = "...";
+                    for (int i = 0; i < val.length() && val.charAt(i) == '.'; i++) {
+                        if (i < val.length() - 1) {
+                            pid = F.at(token.pos + i).Select(pid, names.error);
+                            setErrorEndPos(token.pos + i + 1);
+                            reportSyntaxError(token.pos + i, "expected", IDENTIFIER);
+                            storeEnd(pid, token.pos + i + 1);
+                        } else {
+                            nextToken();
+                            if (token.kind == STAR) {
+                                pid = to(F.at(pos1).Select(pid, names.asterisk));
+                                nextToken();
+                                break;
+                            } else {
+                                pid = toP(F.at(pos1).Select(pid, ident()));
+                            }
+                        }
                     }
-                }
+                    break;
+                case FLOATLITERAL:
+                case DOUBLELITERAL:
+                    val = token.stringVal();
+                    if (val.length() > 0 && val.charAt(0) == '.') {
+                        setErrorEndPos(token.pos);
+                        reportSyntaxError(S.prevToken().endPos, "expected", IDENTIFIER);
+                        pid = to(F.at(token.pos).Select(pid, names.error));
+                        nextToken();
+                        if (token.kind == IDENTIFIER) {
+                            nextToken();
+                            storeEnd(pid, token.pos);
+                        }
+                    }
+                    break;
             }
-            
-        } while (S.token() == DOT);
+        } while (token.kind == DOT);
         accept(SEMI);
         return toP(F.at(pos).Import(pid, importStatic));
     }
@@ -2445,14 +3273,13 @@ public class JavacParser implements Parser {
     /** TypeDeclaration = ClassOrInterfaceOrEnumDeclaration
      *                  | ";"
      */
-    JCTree typeDeclaration(JCModifiers mods, String comment) {
-        int pos = S.pos();
-        if (mods == null && S.token() == SEMI) {
-            S.nextToken();
+    JCTree typeDeclaration(JCModifiers mods, Comment docComment) {
+        int pos = token.pos;
+        if (mods == null && token.kind == SEMI) {
+            nextToken();
             return toP(F.at(pos).Skip());
         } else {
-            String dc = S.docComment();
-            return classOrInterfaceOrEnumDeclaration(modifiersOpt(mods), dc != null ? dc : comment);
+            return classOrInterfaceOrEnumDeclaration(modifiersOpt(mods), docComment);
         }
     }
 
@@ -2461,20 +3288,20 @@ public class JavacParser implements Parser {
      *  @param mods     Any modifiers starting the class or interface declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, String dc) {
-        if (S.token() == CLASS) {
+    JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
+        if (token.kind == CLASS) {
             return classDeclaration(mods, dc);
-        } else if (S.token() == INTERFACE) {
+        } else if (token.kind == INTERFACE) {
             return interfaceDeclaration(mods, dc);
         } else if (allowEnums) {
-            if (S.token() == ENUM) {
+            if (token.kind == ENUM) {
                 return enumDeclaration(mods, dc);
             } else {
-                int pos = S.pos();
+                int pos = token.pos;
                 List<JCTree> errs;
-                if (S.token() == IDENTIFIER) {
+                if (LAX_IDENTIFIER.accepts(token.kind)) {
                     errs = List.<JCTree>of(mods, toP(F.at(pos).Ident(ident())));
-                    setErrorEndPos(S.pos());
+                    setErrorEndPos(token.pos);
                 } else {
                     errs = List.<JCTree>of(mods);
                 }
@@ -2482,17 +3309,17 @@ public class JavacParser implements Parser {
                                               CLASS, INTERFACE, ENUM)));
             }
         } else {
-            if (S.token() == ENUM) {
-                error(S.pos(), "enums.not.supported.in.source", source.name);
+            if (token.kind == ENUM) {
+                error(token.pos, "enums.not.supported.in.source", source.name);
                 allowEnums = true;
                 mods.flags|=Flags.ENUM;
                 return enumDeclaration(mods, dc);
             }
-            int pos = S.pos();
+            int pos = token.pos;
             List<JCTree> errs;
-            if (S.token() == IDENTIFIER) {
+            if (LAX_IDENTIFIER.accepts(token.kind)) {
                 errs = List.<JCTree>of(mods, toP(F.at(pos).Ident(ident())));
-                setErrorEndPos(S.pos());
+                setErrorEndPos(token.pos);
             } else {
                 errs = List.<JCTree>of(mods);
             }
@@ -2506,21 +3333,21 @@ public class JavacParser implements Parser {
      *  @param mods    The modifiers starting the class declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
-        int pos = S.pos();
+    protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) {
+        int pos = token.pos;
         accept(CLASS);
         Name name = ident();
 
         List<JCTypeParameter> typarams = typeParametersOpt();
 
         JCExpression extending = null;
-        if (S.token() == EXTENDS) {
-            S.nextToken();
+        if (token.kind == EXTENDS) {
+            nextToken();
             extending = parseType();
         }
         List<JCExpression> implementing = List.nil();
-        if (S.token() == IMPLEMENTS) {
-            S.nextToken();
+        if (token.kind == IMPLEMENTS) {
+            nextToken();
             implementing = typeList();
         }
         List<JCTree> defs = classOrInterfaceBody(name, false);
@@ -2535,16 +3362,16 @@ public class JavacParser implements Parser {
      *  @param mods    The modifiers starting the interface declaration
      *  @param dc       The documentation comment for the interface, or null.
      */
-    protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
-        int pos = S.pos();
+    protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
+        int pos = token.pos;
         accept(INTERFACE);
         Name name = ident();
 
         List<JCTypeParameter> typarams = typeParametersOpt();
 
         List<JCExpression> extending = List.nil();
-        if (S.token() == EXTENDS) {
-            S.nextToken();
+        if (token.kind == EXTENDS) {
+            nextToken();
             extending = typeList();
         }
         List<JCTree> defs = classOrInterfaceBody(name, true);
@@ -2558,20 +3385,17 @@ public class JavacParser implements Parser {
      *  @param mods    The modifiers starting the enum declaration
      *  @param dc       The documentation comment for the enum, or null.
      */
-    protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
-        int pos = S.pos();
+    protected JCClassDecl enumDeclaration(JCModifiers mods, Comment dc) {
+        int pos = token.pos;
         accept(ENUM);
-        JCModifiers newMods =
-            F.at(mods.pos).Modifiers(mods.flags|Flags.ENUM, mods.annotations);
-        storeEnd(newMods, getEndPos(mods));
         Name name = ident();
-        return enumDeclaration(newMods, dc, pos, name);
+        return enumDeclaration(mods, dc, pos, name);
     }
 
-    JCClassDecl enumDeclaration(JCModifiers mods, String dc, int pos, Name name) {
+    JCClassDecl enumDeclaration(JCModifiers mods, Comment dc, int pos, Name name) {
         List<JCExpression> implementing = List.nil();
-        if (S.token() == IMPLEMENTS) {
-            S.nextToken();
+        if (token.kind == IMPLEMENTS) {
+            nextToken();
             implementing = typeList();
         }
 
@@ -2590,41 +3414,42 @@ public class JavacParser implements Parser {
      */
     List<JCTree> enumBody(Name enumName) {
         accept(LBRACE);
-        if (S.pos() <= errorEndPos) {
+        if (token.pos <= endPosTable.errorEndPos) {
             // error recovery
             skip(false, true, false, false);
-            if (S.token() == LBRACE)
-                S.nextToken();
+            if (token.kind == LBRACE)
+                nextToken();
         }
         ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
-        if (S.token() == COMMA) {
-            S.nextToken();
-        } else if (S.token() != RBRACE && S.token() != SEMI) {
+        if (token.kind == COMMA) {
+            nextToken();
+        } else if (token.kind != RBRACE && token.kind != SEMI) {
             boolean hasError = false;
             List<JCTree> decl = enumeratorDeclaration(enumName);
             defs.appendList(decl);
-            if (decl.head.getTag() != JCTree.VARDEF || (((JCVariableDecl)decl.head).getModifiers().flags & Flags.ENUM) == 0)
+            if (!decl.head.hasTag(VARDEF) || (((JCVariableDecl)decl.head).getModifiers().flags & Flags.ENUM) == 0)
                 hasError = true;
-            while (S.token() != RBRACE && S.token() != SEMI && !hasError) {
-                if (S.token() == COMMA)
-                    S.nextToken();
+            while (token.kind != RBRACE && token.kind != SEMI && !hasError) {
+                if (token.kind == COMMA)
+                    nextToken();
                 else
-                    syntaxError(S.pos(), "expected3", COMMA, RBRACE, SEMI);
-                if (S.token() == RBRACE || S.token() == SEMI) break;
+                    syntaxError(token.pos, "expected3", COMMA, RBRACE, SEMI);
+                if (token.kind == RBRACE || token.kind == SEMI) break;
                 decl = enumeratorDeclaration(enumName);
                 defs.appendList(decl);
-                if (decl.head.getTag() != JCTree.VARDEF || (((JCVariableDecl)decl.head).getModifiers().flags & Flags.ENUM) == 0)
+                if (!decl.head.hasTag(VARDEF) || (((JCVariableDecl)decl.head).getModifiers().flags & Flags.ENUM) == 0)
                     hasError = true;
             }
         }
-        if (S.token() == SEMI)
-            S.nextToken();
-        while (S.token() != RBRACE && S.token() != EOF) {
-            defs.appendList(classOrInterfaceBodyDeclaration(enumName,
-                                                            false));
-            if (S.pos() <= errorEndPos) {
-                // error recovery
-               skip(false, true, true, false);
+        if (token.kind == SEMI) {
+            nextToken();
+            while (token.kind != RBRACE && token.kind != EOF) {
+                defs.appendList(classOrInterfaceBodyDeclaration(enumName,
+                                                                false));
+                if (token.pos <= endPosTable.errorEndPos) {
+                    // error recovery
+                   skip(false, true, true, false);
+                }
             }
         }
         accept(RBRACE);
@@ -2634,34 +3459,31 @@ public class JavacParser implements Parser {
     /** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
      */
     List<JCTree> enumeratorDeclaration(Name enumName) {
-        String dc = S.docComment();
+        Comment dc = token.comment(CommentStyle.JAVADOC);
         int flags = Flags.PUBLIC|Flags.STATIC|Flags.FINAL|Flags.ENUM;
-        if (S.deprecatedFlag()) {
+        if (token.deprecatedFlag()) {
             flags |= Flags.DEPRECATED;
-            S.resetDeprecatedFlag();
         }
-        int pos = S.pos();
-        List<JCAnnotation> annotations = annotationsOpt();
+        int pos = token.pos;
+        List<JCAnnotation> annotations = annotationsOpt(Tag.ANNOTATION);
         JCModifiers mods = F.at(annotations.isEmpty() ? Position.NOPOS : pos).Modifiers(flags, annotations);
         List<JCExpression> typeArgs = typeArgumentsOpt();
-        int identPos = S.pos();
+        int identPos = token.pos;
         Name name = ident();
         if (name != names.error) {
-            int createPos = S.pos();
-            List<JCExpression> args = (S.token() == LPAREN)
+            int createPos = token.pos;
+            List<JCExpression> args = (token.kind == LPAREN)
                 ? arguments() : List.<JCExpression>nil();
             JCClassDecl body = null;
-            if (S.token() == LBRACE) {
+            if (token.kind == LBRACE) {
                 JCModifiers mods1 = F.at(Position.NOPOS).Modifiers(Flags.ENUM | Flags.STATIC);
                 List<JCTree> defs = classOrInterfaceBody(names.empty, false);
                 body = toP(F.at(identPos).AnonymousClassDef(mods1, defs));
             }
-            if (args.isEmpty() && body == null)
-                createPos = Position.NOPOS;
             JCIdent ident = F.at(Position.NOPOS).Ident(enumName);
             JCNewClass create = F.at(createPos).NewClass(null, typeArgs, ident, args, body);
-            if (createPos != Position.NOPOS)
-                storeEnd(create, S.prevEndPos());
+            if (args.nonEmpty() || body != null)
+                storeEnd(create, S.prevToken().endPos);
             ident = F.at(Position.NOPOS).Ident(enumName);
             JCTree result = toP(F.at(identPos).VarDef(mods, name, ident, create));
             attach(result, dc);
@@ -2669,16 +3491,16 @@ public class JavacParser implements Parser {
         }
         // error recovery: not an EnumeratorDeclaration; let's try ClassBodyDeclaration
         mods = annotations.isEmpty() ? modifiersOpt() : modifiersOpt(F.at(pos).Modifiers(0, annotations));
-        if (S.token() == CLASS ||
-            S.token() == INTERFACE ||
-            allowEnums && S.token() == ENUM) {
+        if (token.kind == CLASS ||
+            token.kind == INTERFACE ||
+            allowEnums && token.kind == ENUM) {
             return List.<JCTree>of(classOrInterfaceOrEnumDeclaration(mods, dc));
-        } else if (S.token() == LBRACE &&
+        } else if (token.kind == LBRACE &&
                    (mods.flags & Flags.StandardFlags & ~Flags.STATIC) == 0 &&
                    mods.annotations.isEmpty()) {
             return List.<JCTree>of(block(pos, mods.flags));
         } else {
-            pos = S.pos();
+            pos = token.pos;
             List<JCTypeParameter> typarams = typeParametersOpt();
             // Hack alert:  if there are type arguments but no Modifiers, the start
             // position will be lost unless we set the Modifiers position.  There
@@ -2686,18 +3508,18 @@ public class JavacParser implements Parser {
             if (typarams.length() > 0 && mods.pos == Position.NOPOS) {
                 mods.pos = pos;
             }
-            Token token = S.token();
-            name = S.name();
-            pos = S.pos();
+            TokenKind tk = token.kind;
+            name = tk.tag == Tokens.Token.Tag.NAMED ? token.name() : names.error;
+            pos = token.pos;
             JCExpression type;
-            boolean isVoid = token == VOID;
+            boolean isVoid = tk == VOID;
             if (isVoid) {
-                type = to(F.at(pos).TypeIdent(TypeTags.VOID));
-                S.nextToken();
+                type = to(F.at(pos).TypeIdent(TypeTag.VOID));
+                nextToken();
             } else {
                 type = parseType();
             }
-            if (S.token() == LPAREN && type.getTag() == JCTree.IDENT) {
+            if (token.kind == LPAREN && type.hasTag(IDENT)) {
                 if (name != enumName) {
                     log.error(pos, "invalid.meth.decl.ret.type.req");
                     return List.of(methodDeclaratorRest(
@@ -2708,13 +3530,13 @@ public class JavacParser implements Parser {
                     pos, mods, null, names.init, typarams,
                     false, true, dc));
             } else {
-                pos = S.pos();
+                pos = token.pos;
                 name = ident();
-                if (S.token() == LPAREN) {
+                if (token.kind == LPAREN) {
                     return List.of(methodDeclaratorRest(
                         pos, mods, type, name, typarams,
                         false, isVoid, dc));
-                } else if (token == ENUM &&  typarams.isEmpty() && (S.token() == LBRACE || S.token() == IMPLEMENTS)) {
+                } else if (tk == ENUM &&  typarams.isEmpty() && (token.kind == LBRACE || token.kind == IMPLEMENTS)) {
                     log.error(pos, "enums.not.supported.in.source", source.name);
                     allowEnums = true;
                     JCModifiers newMods =
@@ -2726,15 +3548,15 @@ public class JavacParser implements Parser {
                         variableDeclaratorsRest(pos, mods, type, name, false, dc,
                                                 new ListBuffer<JCTree>()).toList();
                     accept(SEMI);
-                    storeEnd(defs.last(), S.prevEndPos());
+                    storeEnd(defs.last(), S.prevToken().endPos);
                     return defs;
                 } else {
-                    pos = S.pos();
+                    pos = token.pos;
                     List<JCTree> err = isVoid
                         ? List.<JCTree>of(toP(F.at(pos).MethodDef(mods, name, type, typarams,
                             List.<JCVariableDecl>nil(), List.<JCExpression>nil(), null, null)))
                         : List.<JCTree>nil();
-                    return List.<JCTree>of(syntaxError(S.pos(), err, "expected", LPAREN));
+                    return List.<JCTree>of(syntaxError(token.pos, err, "expected", LPAREN));
                 }
             }
         }
@@ -2745,8 +3567,8 @@ public class JavacParser implements Parser {
     List<JCExpression> typeList() {
         ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>();
         ts.append(parseType());
-        while (S.token() == COMMA) {
-            S.nextToken();
+        while (token.kind == COMMA) {
+            nextToken();
             ts.append(parseType());
         }
         return ts.toList();
@@ -2757,19 +3579,19 @@ public class JavacParser implements Parser {
      */
     List<JCTree> classOrInterfaceBody(Name className, boolean isInterface) {
         accept(LBRACE);
-        if (S.pos() <= errorEndPos) {
+        if (token.pos <= endPosTable.errorEndPos) {
             // error recovery
             skip(false, true, false, false);
-            if (S.token() == LBRACE)
-                S.nextToken();
+            if (token.kind == LBRACE)
+                nextToken();
         }
         ListBuffer<JCTree> defs = new ListBuffer<JCTree>();
-        while (S.token() != RBRACE && S.token() != EOF) {
+        while (token.kind != RBRACE && token.kind != EOF) {
             defs.appendList(classOrInterfaceBodyDeclaration(className, isInterface));
-            if (S.pos() <= errorEndPos) {
+            if (token.pos <= endPosTable.errorEndPos) {
                // error recovery
-               if (S.token() == LBRACE && isInterface)
-                   S.nextToken();
+               if (token.kind == LBRACE && isInterface)
+                   nextToken();
                skip(false, true, true, false);
            }
         }
@@ -2795,23 +3617,23 @@ public class JavacParser implements Parser {
      *      ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" )
      */
     public List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) {
-        if (S.token() == SEMI) {
-            S.nextToken();
+        if (token.kind == SEMI) {
+            nextToken();
             return List.<JCTree>nil();
         } else {
-            String dc = S.docComment();
-            int pos = S.pos();
+            Comment dc = token.comment(CommentStyle.JAVADOC);
+            int pos = token.pos;
             JCModifiers mods = modifiersOpt();
-            if (S.token() == CLASS ||
-                S.token() == INTERFACE ||
-                allowEnums && S.token() == ENUM) {
+            if (token.kind == CLASS ||
+                token.kind == INTERFACE ||
+                allowEnums && token.kind == ENUM) {
                 return List.<JCTree>of(classOrInterfaceOrEnumDeclaration(mods, dc));
-            } else if (S.token() == LBRACE && !isInterface &&
+            } else if (token.kind == LBRACE && !isInterface &&
                        (mods.flags & Flags.StandardFlags & ~Flags.STATIC) == 0 &&
                        mods.annotations.isEmpty()) {
                 return List.<JCTree>of(block(pos, mods.flags));
             } else {
-                pos = S.pos();
+                pos = token.pos;
                 List<JCTypeParameter> typarams = typeParametersOpt();
                 // if there are type parameters but no modifiers, save the start
                 // position of the method in the modifiers.
@@ -2819,17 +3641,27 @@ public class JavacParser implements Parser {
                     mods.pos = pos;
                     storeEnd(mods, pos);
                 }
-                Name name = S.name();
-                pos = S.pos();
+                List<JCAnnotation> annosAfterParams = annotationsOpt(Tag.ANNOTATION);
+
+                Name name = token.kind.tag == Tokens.Token.Tag.NAMED ? token.name() : names.error;
+                pos = token.pos;
                 JCExpression type;
-                boolean isVoid = S.token() == VOID;
+                boolean isVoid = token.kind == VOID;
                 if (isVoid) {
-                    type = to(F.at(pos).TypeIdent(TypeTags.VOID));
-                    S.nextToken();
+                    if (annosAfterParams.nonEmpty())
+                        illegal(annosAfterParams.head.pos);
+                    type = to(F.at(pos).TypeIdent(TypeTag.VOID));
+                    nextToken();
                 } else {
-                    type = parseType();
+                    if (annosAfterParams.nonEmpty()) {
+                        mods.annotations = mods.annotations.appendList(annosAfterParams);
+                        if (mods.pos == Position.NOPOS)
+                            mods.pos = mods.annotations.head.pos;
+                    }
+                    // method returns types are un-annotated types
+                    type = unannotatedType();
                 }
-                if (S.token() == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) {
+                if (token.kind == LPAREN && !isInterface && type.hasTag(IDENT)) {
                     if (isInterface || name != className) {
                         error(pos, "invalid.meth.decl.ret.type.req");
                         return List.of(methodDeclaratorRest(
@@ -2840,13 +3672,13 @@ public class JavacParser implements Parser {
                         pos, mods, null, names.init, typarams,
                         isInterface, true, dc));
                 } else {
-                    pos = S.pos();
+                    pos = token.pos;
                     name = ident();
-                    if (S.token() == LPAREN) {
+                    if (token.kind == LPAREN) {
                         return List.of(methodDeclaratorRest(
                             pos, mods, type, name, typarams,
                             isInterface, isVoid, dc));
-                    } else if (S.token() == ENUM &&  typarams.isEmpty() && (S.token() == LBRACE || S.token() == IMPLEMENTS)) {
+                    } else if (token.kind == ENUM &&  typarams.isEmpty() && (token.kind == LBRACE || token.kind == IMPLEMENTS)) {
                         log.error(pos, "enums.not.supported.in.source", source.name);
                         allowEnums = true;
                         JCModifiers newMods =
@@ -2858,10 +3690,10 @@ public class JavacParser implements Parser {
                             variableDeclaratorsRest(pos, mods, type, name, isInterface, dc,
                                                     new ListBuffer<JCTree>()).toList();
                         accept(SEMI);
-                        storeEnd(defs.last(), S.prevEndPos());
+                        storeEnd(defs.last(), S.prevToken().endPos);
                         return defs;
                     } else {
-                        pos = S.pos();
+                        pos = token.pos;
                         List<JCTree> err;
                         if (isVoid || typarams.nonEmpty()) {
                             JCMethodDecl meth = toP(F.at(pos).MethodDef(mods, name, type, typarams,
@@ -2871,7 +3703,7 @@ public class JavacParser implements Parser {
                         } else {
                             err = List.<JCTree>nil();
                         }
-                        return List.<JCTree>of(syntaxError(S.pos(), err, "expected", LPAREN));
+                        return List.<JCTree>of(syntaxError(token.pos, err, "expected", LPAREN));
                     }
                 }
             }
@@ -2895,66 +3727,95 @@ public class JavacParser implements Parser {
                               Name name,
                               List<JCTypeParameter> typarams,
                               boolean isInterface, boolean isVoid,
-                              String dc) {
-        List<JCVariableDecl> params = formalParameters();
-        if (!isVoid) type = bracketsOpt(type);
-        List<JCExpression> thrown = List.nil();
-        if (S.token() == THROWS) {
-            S.nextToken();
-            thrown = qualidentList();
-        }
-        JCBlock body = null;
-        JCExpression defaultValue;
-        if (S.token() == LBRACE) {
-            body = block();
-            defaultValue = null;
-        } else {
-            if (S.token() == DEFAULT) {
-                accept(DEFAULT);
-                defaultValue = annotationValue();
-            } else {
-                defaultValue = null;
+                              Comment dc) {
+        if (isInterface && (mods.flags & Flags.STATIC) != 0) {
+            checkStaticInterfaceMethods();
+        }
+        JCVariableDecl prevReceiverParam = this.receiverParam;
+        try {
+            this.receiverParam = null;
+            // Parsing formalParameters sets the receiverParam, if present
+            List<JCVariableDecl> params = formalParameters();
+            if (!isVoid) type = bracketsOpt(type);
+            List<JCExpression> thrown = List.nil();
+            if (token.kind == THROWS) {
+                nextToken();
+                thrown = qualidentList();
             }
-            accept(SEMI);
-            if (S.pos() <= errorEndPos) {
-                // error recovery
-                skip(false, true, false, false);
-                if (S.token() == LBRACE) {
-                    body = block();
+            JCBlock body = null;
+            JCExpression defaultValue;
+            if (token.kind == LBRACE) {
+                body = block();
+                defaultValue = null;
+            } else {
+                if (token.kind == DEFAULT) {
+                    accept(DEFAULT);
+                    defaultValue = annotationValue();
+                } else {
+                    defaultValue = null;
+                }
+                accept(SEMI);
+                if (token.pos <= endPosTable.errorEndPos) {
+                    // error recovery
+                    skip(false, true, false, false);
+                    if (token.kind == LBRACE) {
+                        body = block();
+                    }
                 }
             }
-        }
 
-        JCMethodDecl result =
-            toP(F.at(pos).MethodDef(mods, name, type, typarams,
-                                    params, thrown,
-                                    body, defaultValue));
-        attach(result, dc);
-        return result;
+            JCMethodDecl result =
+                    toP(F.at(pos).MethodDef(mods, name, type, typarams,
+                                            receiverParam, params, thrown,
+                                            body, defaultValue));
+            attach(result, dc);
+            return result;
+        } finally {
+            this.receiverParam = prevReceiverParam;
+        }
     }
 
-    /** QualidentList = Qualident {"," Qualident}
+    /** QualidentList = [Annotations] Qualident {"," [Annotations] Qualident}
      */
     List<JCExpression> qualidentList() {
         ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>();
-        ts.append(qualident());
-        while (S.token() == COMMA) {
-            S.nextToken();
-            ts.append(qualident());
+
+        List<JCAnnotation> typeAnnos = typeAnnotationsOpt();
+        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();
+            qi = qualident(true);
+            if (!typeAnnos.isEmpty()) {
+                JCExpression at = insertAnnotationsToMostInner(qi, typeAnnos, false);
+                ts.append(at);
+            } else {
+                ts.append(qi);
+            }
         }
         return ts.toList();
     }
 
-    /** TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
+    /**
+     *  {@literal
+     *  TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
+     *  }
      */
     List<JCTypeParameter> typeParametersOpt() {
-        if (S.token() == LT) {
+        if (token.kind == LT) {
             checkGenerics();
             ListBuffer<JCTypeParameter> typarams = new ListBuffer<JCTypeParameter>();
-            S.nextToken();
+            nextToken();
             typarams.append(typeParameter());
-            while (S.token() == COMMA) {
-                S.nextToken();
+            while (token.kind == COMMA) {
+                nextToken();
                 typarams.append(typeParameter());
             }
             accept(GT);
@@ -2964,23 +3825,27 @@ public class JavacParser implements Parser {
         }
     }
 
-    /** TypeParameter = TypeVariable [TypeParameterBound]
+    /**
+     *  {@literal
+     *  TypeParameter = [Annotations] TypeVariable [TypeParameterBound]
      *  TypeParameterBound = EXTENDS Type {"&" Type}
      *  TypeVariable = Ident
+     *  }
      */
     JCTypeParameter typeParameter() {
-        int pos = S.pos();
+        int pos = token.pos;
+        List<JCAnnotation> annos = typeAnnotationsOpt();
         Name name = ident();
         ListBuffer<JCExpression> bounds = new ListBuffer<JCExpression>();
-        if (S.token() == EXTENDS) {
-            S.nextToken();
+        if (token.kind == EXTENDS) {
+            nextToken();
             bounds.append(parseType());
-            while (S.token() == AMP) {
-                S.nextToken();
+            while (token.kind == AMP) {
+                nextToken();
                 bounds.append(parseType());
             }
         }
-        return toP(F.at(pos).TypeParameter(name, bounds.toList()));
+        return toP(F.at(pos).TypeParameter(name, bounds.toList(), annos));
     }
 
     /** FormalParameters = "(" [ FormalParameterList ] ")"
@@ -2988,20 +3853,48 @@ public class JavacParser implements Parser {
      *  FormalParameterListNovarargs = [ FormalParameterListNovarargs , ] FormalParameter
      */
     List<JCVariableDecl> formalParameters() {
+        return formalParameters(false);
+    }
+    List<JCVariableDecl> formalParameters(boolean lambdaParameters) {
         ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
-        JCVariableDecl lastParam = null;
+        JCVariableDecl lastParam;
         accept(LPAREN);
-        if (S.token() != RPAREN) {
-            params.append(lastParam = formalParameter());
-            while ((lastParam.mods.flags & Flags.VARARGS) == 0 && S.token() == COMMA) {
-                S.nextToken();
-                params.append(lastParam = formalParameter());
+        if (token.kind != RPAREN) {
+            this.allowThisIdent = true;
+            lastParam = formalParameter(lambdaParameters);
+            if (lastParam.nameexpr != null) {
+                this.receiverParam = lastParam;
+            } else {
+                params.append(lastParam);
+            }
+            this.allowThisIdent = false;
+            while ((lastParam.mods.flags & Flags.VARARGS) == 0 && token.kind == COMMA) {
+                nextToken();
+                params.append(lastParam = formalParameter(lambdaParameters));
             }
         }
         accept(RPAREN);
         return params.toList();
     }
 
+    List<JCVariableDecl> implicitParameters(boolean hasParens) {
+        if (hasParens) {
+            accept(LPAREN);
+        }
+        ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
+        if (token.kind != RPAREN && token.kind != ARROW) {
+            params.append(implicitParameter());
+            while (token.kind == COMMA) {
+                nextToken();
+                params.append(implicitParameter());
+            }
+        }
+        if (hasParens) {
+            accept(RPAREN);
+        }
+        return params.toList();
+    }
+
     JCModifiers optFinal(long flags) {
         JCModifiers mods = modifiersOpt();
         checkNoMods(mods.flags & ~(Flags.FINAL | Flags.DEPRECATED));
@@ -3009,19 +3902,113 @@ public class JavacParser implements Parser {
         return mods;
     }
 
+    /**
+     * Inserts the annotations (and possibly a new array level)
+     * to the left-most type in an array or nested type.
+     *
+     * When parsing a type like {@code @B Outer.Inner @A []}, the
+     * {@code @A} annotation should target the array itself, while
+     * {@code @B} targets the nested type {@code Outer}.
+     *
+     * Currently the parser parses the annotation first, then
+     * the array, and then inserts the annotation to the left-most
+     * nested type.
+     *
+     * When {@code createNewLevel} is true, then a new array
+     * level is inserted as the most inner type, and have the
+     * annotations target it.  This is useful in the case of
+     * varargs, e.g. {@code String @A [] @B ...}, as the parser
+     * first parses the type {@code String @A []} then inserts
+     * a new array level with {@code @B} annotation.
+     */
+    private JCExpression insertAnnotationsToMostInner(
+            JCExpression type, List<JCAnnotation> annos,
+            boolean createNewLevel) {
+        int origEndPos = getEndPos(type);
+        JCExpression mostInnerType = type;
+        JCArrayTypeTree mostInnerArrayType = null;
+        while (TreeInfo.typeIn(mostInnerType).hasTag(TYPEARRAY)) {
+            mostInnerArrayType = (JCArrayTypeTree) TreeInfo.typeIn(mostInnerType);
+            mostInnerType = mostInnerArrayType.elemtype;
+        }
+
+        if (createNewLevel) {
+            mostInnerType = to(F.at(token.pos).TypeArray(mostInnerType));
+        }
+
+        JCExpression mostInnerTypeToReturn = mostInnerType;
+        if (annos.nonEmpty()) {
+            JCExpression lastToModify = mostInnerType;
+
+            while (TreeInfo.typeIn(mostInnerType).hasTag(SELECT) ||
+                    TreeInfo.typeIn(mostInnerType).hasTag(TYPEAPPLY)) {
+                while (TreeInfo.typeIn(mostInnerType).hasTag(SELECT)) {
+                    lastToModify = mostInnerType;
+                    mostInnerType = ((JCFieldAccess) TreeInfo.typeIn(mostInnerType)).getExpression();
+                }
+                while (TreeInfo.typeIn(mostInnerType).hasTag(TYPEAPPLY)) {
+                    lastToModify = mostInnerType;
+                    mostInnerType = ((JCTypeApply) TreeInfo.typeIn(mostInnerType)).clazz;
+                }
+            }
+
+            mostInnerType = F.at(annos.head.pos).AnnotatedType(annos, mostInnerType);
+
+            if (TreeInfo.typeIn(lastToModify).hasTag(TYPEAPPLY)) {
+                ((JCTypeApply) TreeInfo.typeIn(lastToModify)).clazz = mostInnerType;
+            } else if (TreeInfo.typeIn(lastToModify).hasTag(SELECT)) {
+                ((JCFieldAccess) TreeInfo.typeIn(lastToModify)).selected = mostInnerType;
+            } else {
+                // We never saw a SELECT or TYPEAPPLY, return the annotated type.
+                mostInnerTypeToReturn = mostInnerType;
+            }
+        }
+
+        if (mostInnerArrayType == null) {
+            return mostInnerTypeToReturn;
+        } else {
+            mostInnerArrayType.elemtype = mostInnerTypeToReturn;
+            storeEnd(type, origEndPos);
+            return type;
+        }
+    }
+
     /** FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId
      *  LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter
      */
     protected JCVariableDecl formalParameter() {
+        return formalParameter(false);
+    }
+    protected JCVariableDecl formalParameter(boolean lambdaParameter) {
         JCModifiers mods = optFinal(Flags.PARAMETER);
+        // need to distinguish between vararg annos and array annos
+        // look at typeAnnotationsPushedBack comment
+        this.permitTypeAnnotationsPushBack = true;
         JCExpression type = parseType();
-        if (S.token() == ELLIPSIS) {
+        this.permitTypeAnnotationsPushBack = false;
+
+        if (token.kind == ELLIPSIS) {
+            List<JCAnnotation> varargsAnnos = typeAnnotationsPushedBack;
+            typeAnnotationsPushedBack = List.nil();
             checkVarargs();
             mods.flags |= Flags.VARARGS;
-            type = to(F.at(S.pos()).TypeArray(type));
-            S.nextToken();
+            // insert var arg type annotations
+            type = insertAnnotationsToMostInner(type, varargsAnnos, true);
+            nextToken();
+        } else {
+            // if not a var arg, then typeAnnotationsPushedBack should be null
+            if (typeAnnotationsPushedBack.nonEmpty()) {
+                reportSyntaxError(typeAnnotationsPushedBack.head.pos,
+                        "illegal.start.of.type");
+            }
+            typeAnnotationsPushedBack = List.nil();
         }
-        return variableDeclaratorId(mods, type);
+        return variableDeclaratorId(mods, type, lambdaParameter);
+    }
+
+    protected JCVariableDecl implicitParameter() {
+        JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+        return variableDeclaratorId(mods, null, true);
     }
 
 /* ---------- auxiliary methods -------------- */
@@ -3041,30 +4028,21 @@ public class JavacParser implements Parser {
     /** Check that given tree is a legal expression statement.
      */
     protected JCExpression checkExprStat(JCExpression t) {
-        switch(t.getTag()) {
-        case JCTree.PREINC: case JCTree.PREDEC:
-        case JCTree.POSTINC: case JCTree.POSTDEC:
-        case JCTree.ASSIGN:
-        case JCTree.BITOR_ASG: case JCTree.BITXOR_ASG: case JCTree.BITAND_ASG:
-        case JCTree.SL_ASG: case JCTree.SR_ASG: case JCTree.USR_ASG:
-        case JCTree.PLUS_ASG: case JCTree.MINUS_ASG:
-        case JCTree.MUL_ASG: case JCTree.DIV_ASG: case JCTree.MOD_ASG:
-        case JCTree.APPLY: case JCTree.NEWCLASS:
-        case JCTree.ERRONEOUS:
-            return t;
-        default:
+        if (!TreeInfo.isExpressionStatement(t)) {
             JCExpression ret = F.at(t.pos).Erroneous(List.<JCTree>of(t));
             error(ret, "not.stmt");
             return ret;
+        } else {
+            return t;
         }
     }
 
     /** Return precedence of operator represented by token,
      *  -1 if token is not a binary operator. @see TreeInfo.opPrec
      */
-    static int prec(Token token) {
-        int oc = optag(token);
-        return (oc >= 0) ? TreeInfo.opPrec(oc) : -1;
+    static int prec(TokenKind token) {
+        JCTree.Tag oc = optag(token);
+        return (oc != NO_TAG) ? TreeInfo.opPrec(oc) : -1;
     }
 
     /**
@@ -3080,172 +4058,341 @@ public class JavacParser implements Parser {
     }
 
     /** Return operation tag of binary operator represented by token,
-     *  -1 if token is not a binary operator.
+     *  No_TAG if token is not a binary operator.
      */
-    static int optag(Token token) {
+    static JCTree.Tag optag(TokenKind token) {
         switch (token) {
         case BARBAR:
-            return JCTree.OR;
+            return OR;
         case AMPAMP:
-            return JCTree.AND;
+            return AND;
         case BAR:
-            return JCTree.BITOR;
+            return BITOR;
         case BAREQ:
-            return JCTree.BITOR_ASG;
+            return BITOR_ASG;
         case CARET:
-            return JCTree.BITXOR;
+            return BITXOR;
         case CARETEQ:
-            return JCTree.BITXOR_ASG;
+            return BITXOR_ASG;
         case AMP:
-            return JCTree.BITAND;
+            return BITAND;
         case AMPEQ:
-            return JCTree.BITAND_ASG;
+            return BITAND_ASG;
         case EQEQ:
-            return JCTree.EQ;
+            return JCTree.Tag.EQ;
         case BANGEQ:
-            return JCTree.NE;
+            return NE;
         case LT:
-            return JCTree.LT;
+            return JCTree.Tag.LT;
         case GT:
-            return JCTree.GT;
+            return JCTree.Tag.GT;
         case LTEQ:
-            return JCTree.LE;
+            return LE;
         case GTEQ:
-            return JCTree.GE;
+            return GE;
         case LTLT:
-            return JCTree.SL;
+            return SL;
         case LTLTEQ:
-            return JCTree.SL_ASG;
+            return SL_ASG;
         case GTGT:
-            return JCTree.SR;
+            return SR;
         case GTGTEQ:
-            return JCTree.SR_ASG;
+            return SR_ASG;
         case GTGTGT:
-            return JCTree.USR;
+            return USR;
         case GTGTGTEQ:
-            return JCTree.USR_ASG;
+            return USR_ASG;
         case PLUS:
-            return JCTree.PLUS;
+            return JCTree.Tag.PLUS;
         case PLUSEQ:
-            return JCTree.PLUS_ASG;
+            return PLUS_ASG;
         case SUB:
-            return JCTree.MINUS;
+            return MINUS;
         case SUBEQ:
-            return JCTree.MINUS_ASG;
+            return MINUS_ASG;
         case STAR:
-            return JCTree.MUL;
+            return MUL;
         case STAREQ:
-            return JCTree.MUL_ASG;
+            return MUL_ASG;
         case SLASH:
-            return JCTree.DIV;
+            return DIV;
         case SLASHEQ:
-            return JCTree.DIV_ASG;
+            return DIV_ASG;
         case PERCENT:
-            return JCTree.MOD;
+            return MOD;
         case PERCENTEQ:
-            return JCTree.MOD_ASG;
+            return MOD_ASG;
         case INSTANCEOF:
-            return JCTree.TYPETEST;
+            return TYPETEST;
         default:
-            return -1;
+            return NO_TAG;
         }
     }
 
     /** Return operation tag of unary operator represented by token,
-     *  -1 if token is not a binary operator.
+     *  No_TAG if token is not a binary operator.
      */
-    static int unoptag(Token token) {
+    static JCTree.Tag unoptag(TokenKind token) {
         switch (token) {
         case PLUS:
-            return JCTree.POS;
+            return POS;
         case SUB:
-            return JCTree.NEG;
+            return NEG;
         case BANG:
-            return JCTree.NOT;
+            return NOT;
         case TILDE:
-            return JCTree.COMPL;
+            return COMPL;
         case PLUSPLUS:
-            return JCTree.PREINC;
+            return PREINC;
         case SUBSUB:
-            return JCTree.PREDEC;
+            return PREDEC;
         default:
-            return -1;
+            return NO_TAG;
         }
     }
 
     /** Return type tag of basic type represented by token,
-     *  -1 if token is not a basic type identifier.
+     *  NONE if token is not a basic type identifier.
      */
-    static int typetag(Token token) {
+    static TypeTag typetag(TokenKind token) {
         switch (token) {
         case BYTE:
-            return TypeTags.BYTE;
+            return TypeTag.BYTE;
         case CHAR:
-            return TypeTags.CHAR;
+            return TypeTag.CHAR;
         case SHORT:
-            return TypeTags.SHORT;
+            return TypeTag.SHORT;
         case INT:
-            return TypeTags.INT;
+            return TypeTag.INT;
         case LONG:
-            return TypeTags.LONG;
+            return TypeTag.LONG;
         case FLOAT:
-            return TypeTags.FLOAT;
+            return TypeTag.FLOAT;
         case DOUBLE:
-            return TypeTags.DOUBLE;
+            return TypeTag.DOUBLE;
         case BOOLEAN:
-            return TypeTags.BOOLEAN;
+            return TypeTag.BOOLEAN;
         default:
-            return -1;
+            return TypeTag.NONE;
         }
     }
 
     void checkGenerics() {
         if (!allowGenerics) {
-            error(S.pos(), "generics.not.supported.in.source", source.name);
+            error(token.pos, "generics.not.supported.in.source", source.name);
             allowGenerics = true;
         }
     }
     void checkVarargs() {
         if (!allowVarargs) {
-            error(S.pos(), "varargs.not.supported.in.source", source.name);
+            error(token.pos, "varargs.not.supported.in.source", source.name);
             allowVarargs = true;
         }
     }
     void checkForeach() {
         if (!allowForeach) {
-            error(S.pos(), "foreach.not.supported.in.source", source.name);
+            error(token.pos, "foreach.not.supported.in.source", source.name);
             allowForeach = true;
         }
     }
     void checkStaticImports() {
         if (!allowStaticImport) {
-            error(S.pos(), "static.import.not.supported.in.source", source.name);
+            error(token.pos, "static.import.not.supported.in.source", source.name);
             allowStaticImport = true;
         }
     }
     void checkAnnotations() {
         if (!allowAnnotations) {
-            error(S.pos(), "annotations.not.supported.in.source", source.name);
+            error(token.pos, "annotations.not.supported.in.source", source.name);
             allowAnnotations = true;
         }
     }
     void checkDiamond() {
         if (!allowDiamond) {
-            error(S.pos(), "diamond.not.supported.in.source", source.name);
+            error(token.pos, "diamond.not.supported.in.source", source.name);
             allowDiamond = true;
         }
     }
     void checkMulticatch() {
         if (!allowMulticatch) {
-            error(S.pos(), "multicatch.not.supported.in.source", source.name);
+            error(token.pos, "multicatch.not.supported.in.source", source.name);
             allowMulticatch = true;
         }
     }
     void checkTryWithResources() {
         if (!allowTWR) {
-            error(S.pos(), "try.with.resources.not.supported.in.source", source.name);
+            error(token.pos, "try.with.resources.not.supported.in.source", source.name);
             allowTWR = true;
         }
     }
+    void checkLambda() {
+        if (!allowLambda) {
+            log.error(token.pos, "lambda.not.supported.in.source", source.name);
+            allowLambda = true;
+        }
+    }
+    void checkMethodReferences() {
+        if (!allowMethodReferences) {
+            log.error(token.pos, "method.references.not.supported.in.source", source.name);
+            allowMethodReferences = true;
+        }
+    }
+    void checkDefaultMethods() {
+        if (!allowDefaultMethods) {
+            log.error(token.pos, "default.methods.not.supported.in.source", source.name);
+            allowDefaultMethods = true;
+        }
+    }
+    void checkIntersectionTypesInCast() {
+        if (!allowIntersectionTypesInCast) {
+            log.error(token.pos, "intersection.types.in.cast.not.supported.in.source", source.name);
+            allowIntersectionTypesInCast = true;
+        }
+    }
+    void checkStaticInterfaceMethods() {
+        if (!allowStaticInterfaceMethods) {
+            log.error(token.pos, "static.intf.methods.not.supported.in.source", source.name);
+            allowStaticInterfaceMethods = true;
+        }
+    }
+    void checkTypeAnnotations() {
+        if (!allowTypeAnnotations) {
+            log.error(token.pos, "type.annotations.not.supported.in.source", source.name);
+            allowTypeAnnotations = true;
+        }
+    }
+
+    /*
+     * a functional source tree and end position mappings
+     */
+    protected static class SimpleEndPosTable extends AbstractEndPosTable {
+
+        private final Map<JCTree, Integer> endPosMap;
+
+        protected SimpleEndPosTable(JavacParser parser) {
+            super(parser);
+            endPosMap = new HashMap<JCTree, Integer>();
+        }
+
+        protected void storeEnd(JCTree tree, int endpos) {
+            if (tree instanceof JCIdent) {
+                JCIdent i = (JCIdent) tree;
+
+                if (i.pos + i.name.length() == endpos) return ;
+            } else if (tree instanceof JCFieldAccess) {
+                JCFieldAccess f = (JCFieldAccess) tree;
+
+                if (f.pos + f.name.length() + 1 == endpos) return ;
+            }
+            endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos);
+        }
+
+        protected <T extends JCTree> T to(T t) {
+            storeEnd(t, parser.token.endPos);
+            return t;
+        }
+
+        protected <T extends JCTree> T toP(T t) {
+            storeEnd(t, parser.S.prevToken().endPos);
+            return t;
+        }
+
+        public int getEndPos(JCTree tree) {
+            Integer value = endPosMap.get(tree);
+            return (value == null) ? Position.NOPOS : value;
+        }
+
+        public int replaceTree(JCTree oldTree, JCTree newTree) {
+            Integer pos = endPosMap.remove(oldTree);
+            if (pos != null) {
+                endPosMap.put(newTree, pos);
+                return pos;
+            }
+            return Position.NOPOS;
+        }
+    }
+
+    /*
+     * a default skeletal implementation without any mapping overhead.
+     */
+    protected static class EmptyEndPosTable extends AbstractEndPosTable {
+
+        EmptyEndPosTable(JavacParser parser) {
+            super(parser);
+        }
+
+        protected void storeEnd(JCTree tree, int endpos) { /* empty */ }
+
+        protected <T extends JCTree> T to(T t) {
+            return t;
+        }
+
+        protected <T extends JCTree> T toP(T t) {
+            return t;
+        }
+
+        public int getEndPos(JCTree tree) {
+            return Position.NOPOS;
+        }
+
+        public int replaceTree(JCTree oldTree, JCTree newTree) {
+            return Position.NOPOS;
+        }
+
+    }
+
+    protected static abstract class AbstractEndPosTable implements EndPosTable {
+        /**
+         * The current parser.
+         */
+        protected JavacParser parser;
 
+        /**
+         * Store the last error position.
+         */
+        protected int errorEndPos = Position.NOPOS;
+
+        public AbstractEndPosTable(JavacParser parser) {
+            this.parser = parser;
+        }
+
+        /**
+         * Store ending position for a tree, the value of which is the greater
+         * of last error position and the given ending position.
+         * @param tree   The tree.
+         * @param endpos The ending position to associate with the tree.
+         */
+        protected abstract void storeEnd(JCTree tree, int endpos);
+
+        /**
+         * Store current token's ending position for a tree, the value of which
+         * will be the greater of last error position and the ending position of
+         * the current token.
+         * @param t The tree.
+         */
+        protected abstract <T extends JCTree> T to(T t);
+
+        /**
+         * Store current token's ending position for a tree, the value of which
+         * will be the greater of last error position and the ending position of
+         * the previous token.
+         * @param t The tree.
+         */
+        protected abstract <T extends JCTree> T toP(T t);
+
+        /**
+         * Set the error position during the parsing phases, the value of which
+         * will be set only if it is greater than the last stored error position.
+         * @param errPos The error position
+         */
+        protected void setErrorEndPos(int errPos) {
+            if (errPos > errorEndPos) {
+                errorEndPos = errPos;
+            }
+        }
+
+        protected void setParser(JavacParser parser) {
+            this.parser = parser;
+        }
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java b/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java
new file mode 100644
index 0000000..367345a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2004, 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.parser;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
+import com.sun.tools.javac.util.*;
+
+import java.nio.*;
+
+import static com.sun.tools.javac.util.LayoutCharacters.*;
+
+/** An extension to the base lexical analyzer that captures
+ *  and processes the contents of doc comments.  It does so by
+ *  translating Unicode escape sequences and by stripping the
+ *  leading whitespace and starts from each line of the comment.
+ *
+ *  <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 JavadocTokenizer extends JavaTokenizer {
+
+    /** Create a scanner from the input buffer.  buffer must implement
+     *  array() and compact(), and remaining() must be less than limit().
+     */
+    protected JavadocTokenizer(ScannerFactory fac, CharBuffer buffer) {
+        super(fac, buffer);
+    }
+
+    /** Create a scanner from the input array.  The array must have at
+     *  least a single character of extra space.
+     */
+    protected JavadocTokenizer(ScannerFactory fac, char[] input, int inputLength) {
+        super(fac, input, inputLength);
+    }
+
+    @Override
+    protected Comment processComment(int pos, int endPos, CommentStyle style) {
+        char[] buf = reader.getRawCharacters(pos, endPos);
+        return new JavadocComment(new DocReader(fac, buf, buf.length, pos), style);
+    }
+
+    /**
+     * This is a specialized version of UnicodeReader that keeps track of the
+     * column position within a given character stream (used for Javadoc processing),
+     * and which builds a table for mapping positions in the comment string to
+     * positions in the source file.
+     */
+    static class DocReader extends UnicodeReader {
+
+         int col;
+         int startPos;
+
+         /**
+          * A buffer for building a table for mapping positions in {@link #sbuf}
+          * to positions in the source buffer.
+          *
+          * The array is organized as a series of pairs of integers: the first
+          * number in each pair specifies a position in the comment text,
+          * the second number in each pair specifies the corresponding position
+          * in the source buffer. The pairs are sorted in ascending order.
+          *
+          * Since the mapping function is generally continuous, with successive
+          * positions in the string corresponding to successive positions in the
+          * source buffer, the table only needs to record discontinuities in
+          * the mapping. The values of intermediate positions can be inferred.
+          *
+          * Discontinuities may occur in a number of places: when a newline
+          * is followed by whitespace and asterisks (which are ignored),
+          * when a tab is expanded into spaces, and when unicode escapes
+          * are used in the source buffer.
+          *
+          * Thus, to find the source position of any position, p, in the comment
+          * string, find the index, i, of the pair whose string offset
+          * ({@code pbuf[i] }) is closest to but not greater than p. Then,
+          * {@code sourcePos(p) = pbuf[i+1] + (p - pbuf[i]) }.
+          */
+         int[] pbuf = new int[128];
+
+         /**
+          * The index of the next empty slot in the pbuf buffer.
+          */
+         int pp = 0;
+
+         DocReader(ScannerFactory fac, char[] input, int inputLength, int startPos) {
+             super(fac, input, inputLength);
+             this.startPos = startPos;
+         }
+
+         @Override
+         protected void convertUnicode() {
+             if (ch == '\\' && unicodeConversionBp != bp) {
+                 bp++; ch = buf[bp]; col++;
+                 if (ch == 'u') {
+                     do {
+                         bp++; ch = buf[bp]; col++;
+                     } while (ch == 'u');
+                     int limit = bp + 3;
+                     if (limit < buflen) {
+                         int d = digit(bp, 16);
+                         int code = d;
+                         while (bp < limit && d >= 0) {
+                             bp++; ch = buf[bp]; col++;
+                             d = digit(bp, 16);
+                             code = (code << 4) + d;
+                         }
+                         if (d >= 0) {
+                             ch = (char)code;
+                             unicodeConversionBp = bp;
+                             return;
+                         }
+                     }
+                     // "illegal.Unicode.esc", reported by base scanner
+                 } else {
+                     bp--;
+                     ch = '\\';
+                     col--;
+                 }
+             }
+         }
+
+         @Override
+         protected void scanCommentChar() {
+             scanChar();
+             if (ch == '\\') {
+                 if (peekChar() == '\\' && !isUnicode()) {
+                     putChar(ch, false);
+                     bp++; col++;
+                 } else {
+                     convertUnicode();
+                 }
+             }
+         }
+
+         @Override
+         protected void scanChar() {
+             bp++;
+             ch = buf[bp];
+             switch (ch) {
+             case '\r': // return
+                 col = 0;
+                 break;
+             case '\n': // newline
+                 if (bp == 0 || buf[bp-1] != '\r') {
+                     col = 0;
+                 }
+                 break;
+             case '\t': // tab
+                 col = (col / TabInc * TabInc) + TabInc;
+                 break;
+             case '\\': // possible Unicode
+                 col++;
+                 convertUnicode();
+                 break;
+             default:
+                 col++;
+                 break;
+             }
+         }
+
+         @Override
+         public void putChar(char ch, boolean scan) {
+             // At this point, bp is the position of the current character in buf,
+             // and sp is the position in sbuf where this character will be put.
+             // Record a new entry in pbuf if pbuf is empty or if sp and its
+             // corresponding source position are not equidistant from the
+             // corresponding values in the latest entry in the pbuf array.
+             // (i.e. there is a discontinuity in the map function.)
+             if ((pp == 0)
+                     || (sp - pbuf[pp - 2] != (startPos + bp) - pbuf[pp - 1])) {
+                 if (pp + 1 >= pbuf.length) {
+                     int[] new_pbuf = new int[pbuf.length * 2];
+                     System.arraycopy(pbuf, 0, new_pbuf, 0, pbuf.length);
+                     pbuf = new_pbuf;
+                 }
+                 pbuf[pp] = sp;
+                 pbuf[pp + 1] = startPos + bp;
+                 pp += 2;
+             }
+             super.putChar(ch, scan);
+         }
+     }
+
+     protected static class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
+
+        /**
+        * Translated and stripped contents of doc comment
+        */
+        private String docComment = null;
+        private int[] docPosns = null;
+
+        JavadocComment(DocReader reader, CommentStyle cs) {
+            super(reader, cs);
+        }
+
+        @Override
+        public String getText() {
+            if (!scanned && cs == CommentStyle.JAVADOC) {
+                scanDocComment();
+            }
+            return docComment;
+        }
+
+        @Override
+        public int getSourcePos(int pos) {
+            // Binary search to find the entry for which the string index is
+            // less than pos. Since docPosns is a list of pairs of integers
+            // we must make sure the index is always even.
+            // If we find an exact match for pos, the other item in the pair
+            // gives the source pos; otherwise, compute the source position
+            // relative to the best match found in the array.
+            if (pos == Position.NOPOS)
+                return Position.NOPOS;
+            if (pos < 0 || pos > docComment.length())
+                throw new StringIndexOutOfBoundsException(String.valueOf(pos));
+            if (docPosns == null)
+                return Position.NOPOS;
+            int start = 0;
+            int end = docPosns.length;
+            while (start < end - 2) {
+                // find an even index midway between start and end
+                int index = ((start  + end) / 4) * 2;
+                if (docPosns[index] < pos)
+                    start = index;
+                else if (docPosns[index] == pos)
+                    return docPosns[index + 1];
+                else
+                    end = index;
+            }
+            return docPosns[start + 1] + (pos - docPosns[start]);
+        }
+
+        @Override
+        @SuppressWarnings("fallthrough")
+        protected void scanDocComment() {
+             try {
+                 boolean firstLine = true;
+
+                 // Skip over first slash
+                 comment_reader.scanCommentChar();
+                 // Skip over first star
+                 comment_reader.scanCommentChar();
+
+                 // consume any number of stars
+                 while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '*') {
+                     comment_reader.scanCommentChar();
+                 }
+                 // is the comment in the form /**/, /***/, /****/, etc. ?
+                 if (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '/') {
+                     docComment = "";
+                     return;
+                 }
+
+                 // skip a newline on the first line of the comment.
+                 if (comment_reader.bp < comment_reader.buflen) {
+                     if (comment_reader.ch == LF) {
+                         comment_reader.scanCommentChar();
+                         firstLine = false;
+                     } else if (comment_reader.ch == CR) {
+                         comment_reader.scanCommentChar();
+                         if (comment_reader.ch == LF) {
+                             comment_reader.scanCommentChar();
+                             firstLine = false;
+                         }
+                     }
+                 }
+
+             outerLoop:
+
+                 // The outerLoop processes the doc comment, looping once
+                 // for each line.  For each line, it first strips off
+                 // whitespace, then it consumes any stars, then it
+                 // puts the rest of the line into our buffer.
+                 while (comment_reader.bp < comment_reader.buflen) {
+                     int begin_bp = comment_reader.bp;
+                     char begin_ch = comment_reader.ch;
+                     // The wsLoop consumes whitespace from the beginning
+                     // of each line.
+                 wsLoop:
+
+                     while (comment_reader.bp < comment_reader.buflen) {
+                         switch(comment_reader.ch) {
+                         case ' ':
+                             comment_reader.scanCommentChar();
+                             break;
+                         case '\t':
+                             comment_reader.col = ((comment_reader.col - 1) / TabInc * TabInc) + TabInc;
+                             comment_reader.scanCommentChar();
+                             break;
+                         case FF:
+                             comment_reader.col = 0;
+                             comment_reader.scanCommentChar();
+                             break;
+         // Treat newline at beginning of line (blank line, no star)
+         // as comment text.  Old Javadoc compatibility requires this.
+         /*---------------------------------*
+                         case CR: // (Spec 3.4)
+                             doc_reader.scanCommentChar();
+                             if (ch == LF) {
+                                 col = 0;
+                                 doc_reader.scanCommentChar();
+                             }
+                             break;
+                         case LF: // (Spec 3.4)
+                             doc_reader.scanCommentChar();
+                             break;
+         *---------------------------------*/
+                         default:
+                             // we've seen something that isn't whitespace;
+                             // jump out.
+                             break wsLoop;
+                         }
+                     }
+
+                     // Are there stars here?  If so, consume them all
+                     // and check for the end of comment.
+                     if (comment_reader.ch == '*') {
+                         // skip all of the stars
+                         do {
+                             comment_reader.scanCommentChar();
+                         } while (comment_reader.ch == '*');
+
+                         // check for the closing slash.
+                         if (comment_reader.ch == '/') {
+                             // We're done with the doc comment
+                             // scanChar() and breakout.
+                             break outerLoop;
+                         }
+                     } else if (! firstLine) {
+                         // The current line does not begin with a '*' so we will
+                         // treat it as comment
+                         comment_reader.bp = begin_bp;
+                         comment_reader.ch = begin_ch;
+                     }
+                     // The textLoop processes the rest of the characters
+                     // on the line, adding them to our buffer.
+                 textLoop:
+                     while (comment_reader.bp < comment_reader.buflen) {
+                         switch (comment_reader.ch) {
+                         case '*':
+                             // Is this just a star?  Or is this the
+                             // end of a comment?
+                             comment_reader.scanCommentChar();
+                             if (comment_reader.ch == '/') {
+                                 // This is the end of the comment,
+                                 // set ch and return our buffer.
+                                 break outerLoop;
+                             }
+                             // This is just an ordinary star.  Add it to
+                             // the buffer.
+                             comment_reader.putChar('*', false);
+                             break;
+                         case ' ':
+                         case '\t':
+                             comment_reader.putChar(comment_reader.ch, false);
+                             comment_reader.scanCommentChar();
+                             break;
+                         case FF:
+                             comment_reader.scanCommentChar();
+                             break textLoop; // treat as end of line
+                         case CR: // (Spec 3.4)
+                             comment_reader.scanCommentChar();
+                             if (comment_reader.ch != LF) {
+                                 // Canonicalize CR-only line terminator to LF
+                                 comment_reader.putChar((char)LF, false);
+                                 break textLoop;
+                             }
+                             /* fall through to LF case */
+                         case LF: // (Spec 3.4)
+                             // We've seen a newline.  Add it to our
+                             // buffer and break out of this loop,
+                             // starting fresh on a new line.
+                             comment_reader.putChar(comment_reader.ch, false);
+                             comment_reader.scanCommentChar();
+                             break textLoop;
+                         default:
+                             // Add the character to our buffer.
+                             comment_reader.putChar(comment_reader.ch, false);
+                             comment_reader.scanCommentChar();
+                         }
+                     } // end textLoop
+                     firstLine = false;
+                 } // end outerLoop
+
+                 if (comment_reader.sp > 0) {
+                     int i = comment_reader.sp - 1;
+                 trailLoop:
+                     while (i > -1) {
+                         switch (comment_reader.sbuf[i]) {
+                         case '*':
+                             i--;
+                             break;
+                         default:
+                             break trailLoop;
+                         }
+                     }
+                     comment_reader.sp = i + 1;
+
+                     // Store the text of the doc comment
+                    docComment = comment_reader.chars();
+                    docPosns = new int[comment_reader.pp];
+                    System.arraycopy(comment_reader.pbuf, 0, docPosns, 0, docPosns.length);
+                } else {
+                    docComment = "";
+                }
+            } finally {
+                scanned = true;
+                comment_reader = null;
+                if (docComment != null &&
+                        docComment.matches("(?sm).*^\\s*@deprecated( |$).*")) {
+                    deprecatedFlag = true;
+                }
+            }
+        }
+    }
+
+    @Override
+    public Position.LineMap getLineMap() {
+        char[] buf = reader.getRawCharacters();
+        return Position.makeLineMap(buf, buf.length, true);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/Keywords.java b/src/share/classes/com/sun/tools/javac/parser/Keywords.java
deleted file mode 100644
index 43386bf..0000000
--- a/src/share/classes/com/sun/tools/javac/parser/Keywords.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2002, 2010, 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.parser;
-
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Name;
-import com.sun.tools.javac.util.Names;
-
-import static com.sun.tools.javac.parser.Token.*;
-
-/**
- * Map from Name to Token and Token to String.
- *
- * <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 Keywords {
-    public static final Context.Key<Keywords> keywordsKey =
-        new Context.Key<Keywords>();
-
-    public static Keywords instance(Context context) {
-        Keywords instance = context.get(keywordsKey);
-        if (instance == null)
-            instance = new Keywords(context);
-        return instance;
-    }
-
-    private final Names names;
-
-    protected Keywords(Context context) {
-        context.put(keywordsKey, this);
-        names = Names.instance(context);
-
-        for (Token t : Token.values()) {
-            if (t.name != null)
-                enterKeyword(t.name, t);
-            else
-                tokenName[t.ordinal()] = null;
-        }
-
-        key = new Token[maxKey+1];
-        for (int i = 0; i <= maxKey; i++) key[i] = IDENTIFIER;
-        for (Token t : Token.values()) {
-            if (t.name != null)
-                key[tokenName[t.ordinal()].getIndex()] = t;
-        }
-    }
-
-
-    public Token key(Name name) {
-        return (name.getIndex() > maxKey) ? IDENTIFIER : key[name.getIndex()];
-    }
-
-    /**
-     * Keyword array. Maps name indices to Token.
-     */
-    private final Token[] key;
-
-    /**  The number of the last entered keyword.
-     */
-    private int maxKey = 0;
-
-    /** The names of all tokens.
-     */
-    private Name[] tokenName = new Name[Token.values().length];
-
-    private void enterKeyword(String s, Token token) {
-        Name n = names.fromString(s);
-        tokenName[token.ordinal()] = n;
-        if (n.getIndex() > maxKey) maxKey = n.getIndex();
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java b/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java
new file mode 100644
index 0000000..75381da
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/LazyDocCommentTable.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1999, 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.javac.parser;
+
+import com.sun.source.util.DocTrees;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DocCommentTable;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.DiagnosticSource;
+
+
+/**
+ *
+ *  <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 LazyDocCommentTable implements DocCommentTable {
+    public static class Entry {
+        final Comment comment;
+        DCDocComment tree;
+
+        Entry(Comment c) {
+            comment = c;
+        }
+    }
+
+    ParserFactory fac;
+    private final boolean breakOnError;
+    private final EndPosTable ept;
+    DiagnosticSource diagSource;
+    public Map<JCTree, Entry> table;
+
+    LazyDocCommentTable(ParserFactory fac, EndPosTable ept) {
+        this.fac = fac;
+        this.breakOnError = fac.options.getBoolean("breakDocCommentParsingOnError", true);
+        this.ept = ept;
+        diagSource = fac.log.currentSource();
+        table = new HashMap<JCTree, Entry>();
+    }
+
+    public boolean hasComment(JCTree tree) {
+        return table.containsKey(tree);
+    }
+
+    public Comment getComment(JCTree tree) {
+        Entry e = table.get(tree);
+        return (e == null) ? null : e.comment;
+    }
+
+    public String getCommentText(JCTree tree) {
+        Comment c = getComment(tree);
+        return (c == null) ? null : c.getText();
+    }
+
+    public DCDocComment getCommentTree(JCTree tree) {
+        Entry e = table.get(tree);
+        if (e == null)
+            return null;
+        if (e.tree == null)
+            e.tree = new DocCommentParser(fac, breakOnError, ept, diagSource, e.comment).parse();
+        return e.tree;
+    }
+
+    public void putComment(JCTree tree, Comment c) {
+        table.put(tree, new Entry(c));
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/Lexer.java b/src/share/classes/com/sun/tools/javac/parser/Lexer.java
index 90f6afe..20248bd 100644
--- a/src/share/classes/com/sun/tools/javac/parser/Lexer.java
+++ b/src/share/classes/com/sun/tools/javac/parser/Lexer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package com.sun.tools.javac.parser;
 
-import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.parser.Tokens.*;
 import com.sun.tools.javac.util.Position.LineMap;
 
 /**
@@ -40,22 +40,32 @@ import com.sun.tools.javac.util.Position.LineMap;
 public interface Lexer {
 
     /**
-     * Has a @deprecated been encountered in last doc comment?
-     * This needs to be reset by client with resetDeprecatedFlag.
+     * Consume the next token.
      */
-    boolean deprecatedFlag();
+    void nextToken();
 
-    void resetDeprecatedFlag();
+    /**
+     * Return current token.
+     */
+    Token token();
 
     /**
-     * Returns the documentation string of the current token.
+     * Return token with given lookahead.
      */
-    String docComment();
+    Token token(int lookahead);
 
     /**
-     * Return the last character position of the current token.
+     * Return the last character position of the previous token.
      */
-    int endPos();
+    Token prevToken();
+
+    /**
+     * Splits the current token in two and return the first (splitted) token.
+     * For instance {@literal '<<<'} is split into two tokens
+     * {@literal '<'} and {@literal '<<'} respectively,
+     * and the latter is returned.
+     */
+    Token split();
 
     /**
      * Return the position where a lexical error occurred;
@@ -74,69 +84,4 @@ public interface Lexer {
      * @return a LineMap
      */
     LineMap getLineMap();
-
-    /**
-     * Returns a copy of the input buffer, up to its inputLength.
-     * Unicode escape sequences are not translated.
-     */
-    char[] getRawCharacters();
-
-    /**
-     * Returns a copy of a character array subset of the input buffer.
-     * The returned array begins at the <code>beginIndex</code> and
-     * extends to the character at index <code>endIndex - 1</code>.
-     * Thus the length of the substring is <code>endIndex-beginIndex</code>.
-     * This behavior is like
-     * <code>String.substring(beginIndex, endIndex)</code>.
-     * Unicode escape sequences are not translated.
-     *
-     * @param beginIndex the beginning index, inclusive.
-     * @param endIndex the ending index, exclusive.
-     * @throws IndexOutOfBounds if either offset is outside of the
-     *         array bounds
-     */
-    char[] getRawCharacters(int beginIndex, int endIndex);
-
-    /**
-     * Return the name of an identifier or token for the current token.
-     */
-    Name name();
-
-    /**
-     * Read token.
-     */
-    void nextToken();
-
-    /**
-     * Return the current token's position: a 0-based
-     *  offset from beginning of the raw input stream
-     *  (before unicode translation)
-     */
-    int pos();
-
-    /**
-     * Return the last character position of the previous token.
-     */
-    int prevEndPos();
-
-    /**
-     * Return the radix of a numeric literal token.
-     */
-    int radix();
-
-    /**
-     * The value of a literal token, recorded as a string.
-     *  For integers, leading 0x and 'l' suffixes are suppressed.
-     */
-    String stringVal();
-
-    /**
-     * Return the current token, set by nextToken().
-     */
-    Token token();
-
-    /**
-     * Sets the current token.
-     */
-    void token(Token token);
 }
diff --git a/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java b/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java
index 869d6fb..d72de9d 100644
--- a/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java
+++ b/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -25,10 +25,10 @@
 
 package com.sun.tools.javac.parser;
 
-import com.sun.tools.javac.tree.JCTree;
-import java.util.Map;
+import java.util.Locale;
 
 import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.tree.DocTreeMaker;
 import com.sun.tools.javac.tree.TreeMaker;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
@@ -57,45 +57,31 @@ public class ParserFactory {
     }
 
     final TreeMaker F;
+    final DocTreeMaker docTreeMaker;
     final Log log;
-    final Keywords keywords;
+    final Tokens tokens;
     final Source source;
     final Names names;
     final Options options;
     final ScannerFactory scannerFactory;
+    final Locale locale;
 
     protected ParserFactory(Context context) {
         super();
         context.put(parserFactoryKey, this);
         this.F = TreeMaker.instance(context);
+        this.docTreeMaker = DocTreeMaker.instance(context);
         this.log = Log.instance(context);
         this.names = Names.instance(context);
-        this.keywords = Keywords.instance(context);
+        this.tokens = Tokens.instance(context);
         this.source = Source.instance(context);
         this.options = Options.instance(context);
         this.scannerFactory = ScannerFactory.instance(context);
+        this.locale = context.get(Locale.class);
     }
 
-    public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
+    public JavacParser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
         Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
-        return newParser (input, keepDocComments, keepEndPos, keepLineMap, false);
+        return new JavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos);
     }
-
-    public Parser newParser(CharSequence input, int startPos, Map<JCTree,Integer> endPos) {
-        Lexer lexer = scannerFactory.newScanner(input, true);
-        ((Scanner)lexer).seek(startPos);
-        JavacParser p = new EndPosParser(this, lexer, true, false, endPos);
-        return p;
-    }
-
-    public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap, boolean partial) {
-        Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
-        JavacParser p;
-        if (keepEndPos) {
-            p = new EndPosParser(this, lexer, keepDocComments, keepLineMap);
-        } else {
-            p = new JavacParser(this, lexer, keepDocComments, keepLineMap);
-        }
-        return p;
-    }
-}
\ No newline at end of file
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/Scanner.java b/src/share/classes/com/sun/tools/javac/parser/Scanner.java
index 9921e43..a38c0f5 100644
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,14 +26,13 @@
 package com.sun.tools.javac.parser;
 
 import java.nio.*;
+import java.util.List;
+import java.util.ArrayList;
 
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.Position.LineMap;
+import com.sun.tools.javac.parser.JavaTokenizer.*;
 
-
-import static com.sun.tools.javac.parser.Token.*;
-import static com.sun.tools.javac.util.LayoutCharacters.*;
+import static com.sun.tools.javac.parser.Tokens.*;
 
 /** The lexical analyzer maps an input stream consisting of
  *  ASCII characters and Unicode escapes into a token sequence.
@@ -45,120 +44,21 @@ import static com.sun.tools.javac.util.LayoutCharacters.*;
  */
 public class Scanner implements Lexer {
 
-    private static boolean scannerDebug = false;
-
-    /* Output variables; set by nextToken():
-     */
+    private Tokens tokens;
 
     /** The token, set by nextToken().
      */
     private Token token;
 
-    /** Allow hex floating-point literals.
-     */
-    private boolean allowHexFloats;
-
-    /** Allow binary literals.
-     */
-    private boolean allowBinaryLiterals;
-
-    /** Allow underscores in literals.
-     */
-    private boolean allowUnderscoresInLiterals;
-
-    /** The source language setting.
-     */
-    private Source source;
-
-    /** The token's position, 0-based offset from beginning of text.
-     */
-    private int pos;
-
-    /** Character position just after the last character of the token.
-     */
-    private int endPos;
-
-    /** The last character position of the previous token.
-     */
-    private int prevEndPos;
-
-    /** The position where a lexical error occurred;
-     */
-    private int errPos = Position.NOPOS;
-
-    /** The name of an identifier or token:
-     */
-    private Name name;
-
-    /** The radix of a numeric literal token.
-     */
-    private int radix;
-
-    /** Has a @deprecated been encountered in last doc comment?
-     *  this needs to be reset by client.
-     */
-    protected boolean deprecatedFlag = false;
-
-    /** A character buffer for literals.
-     */
-    private char[] sbuf = new char[128];
-    private int sp;
-
-    /** The input buffer, index of next chacter to be read,
-     *  index of one past last character in buffer.
+    /** The previous token, set by nextToken().
      */
-    private char[] buf;
-    private int bp;
-    private int buflen;
-    private int eofPos;
-    private int seek;
-    private char replacedCharacter;
+    private Token prevToken;
 
-    /** The current character.
+    /** Buffer of saved tokens (used during lookahead)
      */
-    private char ch;
+    private List<Token> savedTokens = new ArrayList<Token>();
 
-    /** The buffer index of the last converted unicode character
-     */
-    private int unicodeConversionBp = -1;
-
-    /** The log to be used for error reporting.
-     */
-    private final Log log;
-
-    /** The name table. */
-    private final Names names;
-
-    /** The keyword table. */
-    private final Keywords keywords;
-
-    /** Common code for constructors. */
-    private Scanner(ScannerFactory fac) {
-        log = fac.log;
-        names = fac.names;
-        keywords = fac.keywords;
-        source = fac.source;
-        allowBinaryLiterals = source.allowBinaryLiterals();
-        allowHexFloats = source.allowHexFloats();
-        allowUnderscoresInLiterals = source.allowUnderscoresInLiterals();
-    }
-
-    private static final boolean hexFloatsWork = hexFloatsWork();
-    private static boolean hexFloatsWork() {
-        try {
-            Float.valueOf("0x1.0p1");
-            return true;
-        } catch (NumberFormatException ex) {
-            return false;
-        }
-    }
-
-    /** Create a scanner from the input buffer.  buffer must implement
-     *  array() and compact(), and remaining() must be less than limit().
-     */
-    protected Scanner(ScannerFactory fac, CharBuffer buffer) {
-        this(fac, JavacFileManager.toArray(buffer), buffer.limit());
-    }
+    private JavaTokenizer tokenizer;
 
     /**
      * Create a scanner from the input array.  This method might
@@ -167,1002 +67,77 @@ public class Scanner implements Lexer {
      * {@code input[input.length -1]} is a white space character.
      *
      * @param fac the factory which created this Scanner
-     * @param input the input, might be modified
-     * @param inputLength the size of the input.
+     * @param buf the input, might be modified
      * Must be positive and less than or equal to input.length.
      */
-    protected Scanner(ScannerFactory fac, char[] input, int inputLength) {
-        this(fac);
-        eofPos = inputLength;
-        if (inputLength == input.length) {
-            if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) {
-                replacedCharacter = input[--inputLength];
-            } else {
-                char[] newInput = new char[inputLength + 1];
-                System.arraycopy(input, 0, newInput, 0, input.length);
-                input = newInput;
-            }
-        }
-        buf = input;
-        buflen = inputLength;
-        buf[buflen] = EOI;
-        bp = -1;
-        scanChar();
+    protected Scanner(ScannerFactory fac, CharBuffer buf) {
+        this(fac, new JavaTokenizer(fac, buf));
     }
 
-    /** Report an error at the given position using the provided arguments.
-     */
-    private void lexError(int pos, String key, Object... args) {
-        log.error(seek + pos, key, args);
-        token = ERROR;
-        errPos = pos;
+    protected Scanner(ScannerFactory fac, char[] buf, int inputLength) {
+        this(fac, new JavaTokenizer(fac, buf, inputLength));
     }
 
-    /** Report an error at the current token position using the provided
-     *  arguments.
-     */
-    private void lexError(String key, Object... args) {
-        lexError(pos, key, args);
-    }
-
-    /** Convert an ASCII digit from its base (8, 10, or 16)
-     *  to its value.
-     */
-    private int digit(int base) {
-        char c = ch;
-        int result = Character.digit(c, base);
-        if (result >= 0 && c > 0x7f) {
-            lexError(pos+1, "illegal.nonascii.digit");
-            ch = "0123456789abcdef".charAt(result);
-        }
-        return result;
+    protected Scanner(ScannerFactory fac, JavaTokenizer tokenizer) {
+        this.tokenizer = tokenizer;
+        tokens = fac.tokens;
+        token = prevToken = DUMMY;
     }
 
-    /** Convert unicode escape; bp points to initial '\' character
-     *  (Spec 3.3).
-     */
-    private void convertUnicode() {
-        if (ch == '\\' && unicodeConversionBp != bp) {
-            bp++; ch = buf[bp];
-            if (ch == 'u') {
-                do {
-                    bp++; ch = buf[bp];
-                } while (ch == 'u');
-                int limit = bp + 3;
-                if (limit < buflen) {
-                    int d = digit(16);
-                    int code = d;
-                    while (bp < limit && d >= 0) {
-                        bp++; ch = buf[bp];
-                        d = digit(16);
-                        code = (code << 4) + d;
-                    }
-                    if (d >= 0) {
-                        ch = (char)code;
-                        unicodeConversionBp = bp;
-                        return;
-                    }
-                }
-                lexError(bp, "illegal.unicode.esc");
-            } else {
-                bp--;
-                ch = '\\';
-            }
-        }
-    }
-
-    /** Read next character.
-     */
-    private void scanChar() {
-        ch = buf[++bp];
-        if (ch == '\\') {
-            convertUnicode();
-        }
-    }
-
-    /** Read next character in comment, skipping over double '\' characters.
-     */
-    private void scanCommentChar() {
-        scanChar();
-        if (ch == '\\') {
-            if (buf[bp+1] == '\\' && unicodeConversionBp != bp) {
-                bp++;
-            } else {
-                convertUnicode();
-            }
-        }
-    }
-
-    /** Append a character to sbuf.
-     */
-    private void putChar(char ch) {
-        if (sp == sbuf.length) {
-            char[] newsbuf = new char[sbuf.length * 2];
-            System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length);
-            sbuf = newsbuf;
-        }
-        sbuf[sp++] = ch;
-    }
-
-    /** Read next character in character or string literal and copy into sbuf.
-     */
-    private void scanLitChar() {
-        if (ch == '\\') {
-            if (buf[bp+1] == '\\' && unicodeConversionBp != bp) {
-                bp++;
-                putChar('\\');
-                scanChar();
-            } else {
-                scanChar();
-                switch (ch) {
-                case '0': case '1': case '2': case '3':
-                case '4': case '5': case '6': case '7':
-                    char leadch = ch;
-                    int oct = digit(8);
-                    scanChar();
-                    if ('0' <= ch && ch <= '7') {
-                        oct = oct * 8 + digit(8);
-                        scanChar();
-                        if (leadch <= '3' && '0' <= ch && ch <= '7') {
-                            oct = oct * 8 + digit(8);
-                            scanChar();
-                        }
-                    }
-                    putChar((char)oct);
-                    break;
-                case 'b':
-                    putChar('\b'); scanChar(); break;
-                case 't':
-                    putChar('\t'); scanChar(); break;
-                case 'n':
-                    putChar('\n'); scanChar(); break;
-                case 'f':
-                    putChar('\f'); scanChar(); break;
-                case 'r':
-                    putChar('\r'); scanChar(); break;
-                case '\'':
-                    putChar('\''); scanChar(); break;
-                case '\"':
-                    putChar('\"'); scanChar(); break;
-                case '\\':
-                    putChar('\\'); scanChar(); break;
-                default:
-                    lexError(bp, "illegal.esc.char");
-                }
-            }
-        } else if (bp != buflen) {
-            putChar(ch); scanChar();
-        }
-    }
-
-    private void scanDigits(int digitRadix) {
-        char saveCh;
-        int savePos;
-        do {
-            if (ch != '_') {
-                putChar(ch);
-            } else {
-                if (!allowUnderscoresInLiterals) {
-                    lexError("unsupported.underscore.lit", source.name);
-                    allowUnderscoresInLiterals = true;
-                }
-            }
-            saveCh = ch;
-            savePos = bp;
-            scanChar();
-        } while (digit(digitRadix) >= 0 || ch == '_');
-        if (saveCh == '_')
-            lexError(savePos, "illegal.underscore");
-    }
-
-    /** Read fractional part of hexadecimal floating point number.
-     */
-    private void scanHexExponentAndSuffix() {
-        if (ch == 'p' || ch == 'P') {
-            putChar(ch);
-            scanChar();
-            skipIllegalUnderscores();
-            if (ch == '+' || ch == '-') {
-                putChar(ch);
-                scanChar();
-            }
-            skipIllegalUnderscores();
-            if ('0' <= ch && ch <= '9') {
-                scanDigits(10);
-                if (!allowHexFloats) {
-                    lexError("unsupported.fp.lit", source.name);
-                    allowHexFloats = true;
-                }
-                else if (!hexFloatsWork)
-                    lexError("unsupported.cross.fp.lit");
-            } else
-                lexError("malformed.fp.lit");
-        } else {
-            lexError("malformed.fp.lit");
-        }
-        if (ch == 'f' || ch == 'F') {
-            putChar(ch);
-            scanChar();
-            token = FLOATLITERAL;
-        } else {
-            if (ch == 'd' || ch == 'D') {
-                putChar(ch);
-                scanChar();
-            }
-            token = DOUBLELITERAL;
-        }
-    }
-
-    /** Read fractional part of floating point number.
-     */
-    private void scanFraction() {
-        skipIllegalUnderscores();
-        if ('0' <= ch && ch <= '9') {
-            scanDigits(10);
-        }
-        int sp1 = sp;
-        if (ch == 'e' || ch == 'E') {
-            putChar(ch);
-            scanChar();
-            skipIllegalUnderscores();
-            if (ch == '+' || ch == '-') {
-                putChar(ch);
-                scanChar();
-            }
-            skipIllegalUnderscores();
-            if ('0' <= ch && ch <= '9') {
-                scanDigits(10);
-                return;
-            }
-            lexError("malformed.fp.lit");
-            sp = sp1;
-        }
+    public Token token() {
+        return token(0);
     }
 
-    /** Read fractional part and 'd' or 'f' suffix of floating point number.
-     */
-    private void scanFractionAndSuffix() {
-        this.radix = 10;
-        scanFraction();
-        if (ch == 'f' || ch == 'F') {
-            putChar(ch);
-            scanChar();
-            token = FLOATLITERAL;
+    public Token token(int lookahead) {
+        if (lookahead == 0) {
+            return token;
         } else {
-            if (ch == 'd' || ch == 'D') {
-                putChar(ch);
-                scanChar();
-            }
-            token = DOUBLELITERAL;
-        }
-    }
-
-    /** Read fractional part and 'd' or 'f' suffix of floating point number.
-     */
-    private void scanHexFractionAndSuffix(boolean seendigit) {
-        this.radix = 16;
-        Assert.check(ch == '.');
-        putChar(ch);
-        scanChar();
-        skipIllegalUnderscores();
-        if (digit(16) >= 0) {
-            seendigit = true;
-            scanDigits(16);
-        }
-        if (!seendigit)
-            lexError("invalid.hex.number");
-        else
-            scanHexExponentAndSuffix();
-    }
-
-    private void skipIllegalUnderscores() {
-        if (ch == '_') {
-            lexError(bp, "illegal.underscore");
-            while (ch == '_')
-                scanChar();
+            ensureLookahead(lookahead);
+            return savedTokens.get(lookahead - 1);
         }
     }
-
-    /** Read a number.
-     *  @param radix  The radix of the number; one of 2, j8, 10, 16.
-     */
-    private void scanNumber(int radix) {
-        this.radix = radix;
-        // for octal, allow base-10 digit in case it's a float literal
-        int digitRadix = (radix == 8 ? 10 : radix);
-        boolean seendigit = false;
-        if (digit(digitRadix) >= 0) {
-            seendigit = true;
-            scanDigits(digitRadix);
-        }
-        if (radix == 16 && ch == '.') {
-            scanHexFractionAndSuffix(seendigit);
-        } else if (seendigit && radix == 16 && (ch == 'p' || ch == 'P')) {
-            scanHexExponentAndSuffix();
-        } else if (digitRadix == 10 && ch == '.') {
-            putChar(ch);
-            scanChar();
-            scanFractionAndSuffix();
-        } else if (digitRadix == 10 &&
-                   (ch == 'e' || ch == 'E' ||
-                    ch == 'f' || ch == 'F' ||
-                    ch == 'd' || ch == 'D')) {
-            scanFractionAndSuffix();
-        } else {
-            if (ch == 'l' || ch == 'L') {
-                scanChar();
-                token = LONGLITERAL;
-            } else {
-                token = INTLITERAL;
+    //where
+        private void ensureLookahead(int lookahead) {
+            for (int i = savedTokens.size() ; i < lookahead ; i ++) {
+                savedTokens.add(tokenizer.readToken());
             }
         }
-    }
-
-    /** Read an identifier.
-     */
-    private void scanIdent() {
-        boolean isJavaIdentifierPart;
-        char high;
-        do {
-            if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
-            // optimization, was: putChar(ch);
 
-            scanChar();
-            switch (ch) {
-            case 'A': case 'B': case 'C': case 'D': case 'E':
-            case 'F': case 'G': case 'H': case 'I': case 'J':
-            case 'K': case 'L': case 'M': case 'N': case 'O':
-            case 'P': case 'Q': case 'R': case 'S': case 'T':
-            case 'U': case 'V': case 'W': case 'X': case 'Y':
-            case 'Z':
-            case 'a': case 'b': case 'c': case 'd': case 'e':
-            case 'f': case 'g': case 'h': case 'i': case 'j':
-            case 'k': case 'l': case 'm': case 'n': case 'o':
-            case 'p': case 'q': case 'r': case 's': case 't':
-            case 'u': case 'v': case 'w': case 'x': case 'y':
-            case 'z':
-            case '$': case '_':
-            case '0': case '1': case '2': case '3': case '4':
-            case '5': case '6': case '7': case '8': case '9':
-            case '\u0000': case '\u0001': case '\u0002': case '\u0003':
-            case '\u0004': case '\u0005': case '\u0006': case '\u0007':
-            case '\u0008': case '\u000E': case '\u000F': case '\u0010':
-            case '\u0011': case '\u0012': case '\u0013': case '\u0014':
-            case '\u0015': case '\u0016': case '\u0017':
-            case '\u0018': case '\u0019': case '\u001B':
-            case '\u007F':
-                break;
-            case '\u001A': // EOI is also a legal identifier part
-                if (bp >= buflen) {
-                    name = names.fromChars(sbuf, 0, sp);
-                    token = keywords.key(name);
-                    return;
-                }
-                break;
-            default:
-                if (ch < '\u0080') {
-                    // all ASCII range chars already handled, above
-                    isJavaIdentifierPart = false;
-                } else {
-                    high = scanSurrogates();
-                    if (high != 0) {
-                        if (sp == sbuf.length) {
-                            putChar(high);
-                        } else {
-                            sbuf[sp++] = high;
-                        }
-                        isJavaIdentifierPart = Character.isJavaIdentifierPart(
-                            Character.toCodePoint(high, ch));
-                    } else {
-                        isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
-                    }
-                }
-                if (!isJavaIdentifierPart) {
-                    name = names.fromChars(sbuf, 0, sp);
-                    token = keywords.key(name);
-                    return;
-                }
-            }
-        } while (true);
+    public Token prevToken() {
+        return prevToken;
     }
 
-    /** Are surrogates supported?
-     */
-    final static boolean surrogatesSupported = surrogatesSupported();
-    private static boolean surrogatesSupported() {
-        try {
-            Character.isHighSurrogate('a');
-            return true;
-        } catch (NoSuchMethodError ex) {
-            return false;
-        }
-    }
-
-    /** Scan surrogate pairs.  If 'ch' is a high surrogate and
-     *  the next character is a low surrogate, then put the low
-     *  surrogate in 'ch', and return the high surrogate.
-     *  otherwise, just return 0.
-     */
-    private char scanSurrogates() {
-        if (surrogatesSupported && Character.isHighSurrogate(ch)) {
-            char high = ch;
-
-            scanChar();
-
-            if (Character.isLowSurrogate(ch)) {
-                return high;
-            }
-
-            ch = high;
-        }
-
-        return 0;
-    }
-
-    /** Return true if ch can be part of an operator.
-     */
-    private boolean isSpecial(char ch) {
-        switch (ch) {
-        case '!': case '%': case '&': case '*': case '?':
-        case '+': case '-': case ':': case '<': case '=':
-        case '>': case '^': case '|': case '~':
-        case '@':
-            return true;
-        default:
-            return false;
-        }
-    }
-
-    /** Read longest possible sequence of special characters and convert
-     *  to token.
-     */
-    private void scanOperator() {
-        while (true) {
-            putChar(ch);
-            Name newname = names.fromChars(sbuf, 0, sp);
-            if (keywords.key(newname) == IDENTIFIER) {
-                sp--;
-                break;
-            }
-            name = newname;
-            token = keywords.key(newname);
-            scanChar();
-            if (!isSpecial(ch)) break;
-        }
-    }
-
-    /**
-     * Scan a documention comment; determine if a deprecated tag is present.
-     * Called once the initial /, * have been skipped, positioned at the second *
-     * (which is treated as the beginning of the first line).
-     * Stops positioned at the closing '/'.
-     */
-    @SuppressWarnings("fallthrough")
-    private void scanDocComment() {
-        boolean deprecatedPrefix = false;
-
-        forEachLine:
-        while (bp < buflen) {
-
-            // Skip optional WhiteSpace at beginning of line
-            while (bp < buflen && (ch == ' ' || ch == '\t' || ch == FF)) {
-                scanCommentChar();
-            }
-
-            // Skip optional consecutive Stars
-            while (bp < buflen && ch == '*') {
-                scanCommentChar();
-                if (ch == '/') {
-                    return;
-                }
-            }
-
-            // Skip optional WhiteSpace after Stars
-            while (bp < buflen && (ch == ' ' || ch == '\t' || ch == FF)) {
-                scanCommentChar();
-            }
-
-            deprecatedPrefix = false;
-            // At beginning of line in the JavaDoc sense.
-            if (bp < buflen && ch == '@' && !deprecatedFlag) {
-                scanCommentChar();
-                if (bp < buflen && ch == 'd') {
-                    scanCommentChar();
-                    if (bp < buflen && ch == 'e') {
-                        scanCommentChar();
-                        if (bp < buflen && ch == 'p') {
-                            scanCommentChar();
-                            if (bp < buflen && ch == 'r') {
-                                scanCommentChar();
-                                if (bp < buflen && ch == 'e') {
-                                    scanCommentChar();
-                                    if (bp < buflen && ch == 'c') {
-                                        scanCommentChar();
-                                        if (bp < buflen && ch == 'a') {
-                                            scanCommentChar();
-                                            if (bp < buflen && ch == 't') {
-                                                scanCommentChar();
-                                                if (bp < buflen && ch == 'e') {
-                                                    scanCommentChar();
-                                                    if (bp < buflen && ch == 'd') {
-                                                        deprecatedPrefix = true;
-                                                        scanCommentChar();
-                                                    }}}}}}}}}}}
-            if (deprecatedPrefix && bp < buflen) {
-                if (Character.isWhitespace(ch)) {
-                    deprecatedFlag = true;
-                } else if (ch == '*') {
-                    scanCommentChar();
-                    if (ch == '/') {
-                        deprecatedFlag = true;
-                        return;
-                    }
-                }
-            }
-
-            // Skip rest of line
-            while (bp < buflen) {
-                switch (ch) {
-                case '*':
-                    scanCommentChar();
-                    if (ch == '/') {
-                        return;
-                    }
-                    break;
-                case CR: // (Spec 3.4)
-                    scanCommentChar();
-                    if (ch != LF) {
-                        continue forEachLine;
-                    }
-                    /* fall through to LF case */
-                case LF: // (Spec 3.4)
-                    scanCommentChar();
-                    continue forEachLine;
-                default:
-                    scanCommentChar();
-                }
-            } // rest of line
-        } // forEachLine
-        return;
-    }
-
-    /** The value of a literal token, recorded as a string.
-     *  For integers, leading 0x and 'l' suffixes are suppressed.
-     */
-    public String stringVal() {
-        return new String(sbuf, 0, sp);
-    }
-
-    /** Read token.
-     */
     public void nextToken() {
-
-        if (token == EOF)
-            return;
-        try {
-            prevEndPos = endPos;
-            sp = 0;
-
-            while (true) {
-                pos = bp;
-                switch (ch) {
-                case ' ': // (Spec 3.6)
-                case '\t': // (Spec 3.6)
-                case FF: // (Spec 3.6)
-                    do {
-                        scanChar();
-                    } while (ch == ' ' || ch == '\t' || ch == FF);
-                    endPos = bp;
-                    processWhiteSpace();
-                    break;
-                case LF: // (Spec 3.4)
-                    scanChar();
-                    endPos = bp;
-                    processLineTerminator();
-                    break;
-                case CR: // (Spec 3.4)
-                    scanChar();
-                    if (ch == LF) {
-                        scanChar();
-                    }
-                    endPos = bp;
-                    processLineTerminator();
-                    break;
-                case 'A': case 'B': case 'C': case 'D': case 'E':
-                case 'F': case 'G': case 'H': case 'I': case 'J':
-                case 'K': case 'L': case 'M': case 'N': case 'O':
-                case 'P': case 'Q': case 'R': case 'S': case 'T':
-                case 'U': case 'V': case 'W': case 'X': case 'Y':
-                case 'Z':
-                case 'a': case 'b': case 'c': case 'd': case 'e':
-                case 'f': case 'g': case 'h': case 'i': case 'j':
-                case 'k': case 'l': case 'm': case 'n': case 'o':
-                case 'p': case 'q': case 'r': case 's': case 't':
-                case 'u': case 'v': case 'w': case 'x': case 'y':
-                case 'z':
-                case '$': case '_':
-                    scanIdent();
-                    return;
-                case '0':
-                    scanChar();
-                    if (ch == 'x' || ch == 'X') {
-                        scanChar();
-                        skipIllegalUnderscores();
-                        if (ch == '.') {
-                            scanHexFractionAndSuffix(false);
-                        } else if (digit(16) < 0) {
-                            lexError("invalid.hex.number");
-                        } else {
-                            scanNumber(16);
-                        }
-                    } else if (ch == 'b' || ch == 'B') {
-                        if (!allowBinaryLiterals) {
-                            lexError("unsupported.binary.lit", source.name);
-                            allowBinaryLiterals = true;
-                        }
-                        scanChar();
-                        skipIllegalUnderscores();
-                        if (digit(2) < 0) {
-                            lexError("invalid.binary.number");
-                        } else {
-                            scanNumber(2);
-                        }
-                    } else {
-                        putChar('0');
-                        if (ch == '_') {
-                            int savePos = bp;
-                            if (!allowUnderscoresInLiterals) {
-                                lexError("unsupported.underscore.lit", source.name);
-                                allowUnderscoresInLiterals = true;
-                            }
-                            do {
-                                scanChar();
-                            } while (ch == '_');
-                            if (digit(10) < 0) {
-                                lexError(savePos, "illegal.underscore");
-                            }
-                        }
-                        scanNumber(8);
-                    }
-                    return;
-                case '1': case '2': case '3': case '4':
-                case '5': case '6': case '7': case '8': case '9':
-                    scanNumber(10);
-                    return;
-                case '.':
-                    scanChar();
-                    if ('0' <= ch && ch <= '9') {
-                        putChar('.');
-                        scanFractionAndSuffix();
-                    } else if (ch == '.') {
-                        putChar('.'); putChar('.');
-                        scanChar();
-                        if (ch == '.') {
-                            scanChar();
-                            putChar('.');
-                            token = ELLIPSIS;
-                        } else {
-                            lexError("malformed.fp.lit");
-                        }
-                    } else {
-                        token = DOT;
-                    }
-                    return;
-                case ',':
-                    scanChar(); token = COMMA; return;
-                case ';':
-                    scanChar(); token = SEMI; return;
-                case '(':
-                    scanChar(); token = LPAREN; return;
-                case ')':
-                    scanChar(); token = RPAREN; return;
-                case '[':
-                    scanChar(); token = LBRACKET; return;
-                case ']':
-                    scanChar(); token = RBRACKET; return;
-                case '{':
-                    scanChar(); token = LBRACE; return;
-                case '}':
-                    scanChar(); token = RBRACE; return;
-                case '/':
-                    scanChar();
-                    if (ch == '/') {
-                        do {
-                            scanCommentChar();
-                        } while (ch != CR && ch != LF && bp < buflen);
-                        if (bp < buflen) {
-                            endPos = bp;
-                            processComment(CommentStyle.LINE);
-                        }
-                        break;
-                    } else if (ch == '*') {
-                        scanChar();
-                        CommentStyle style;
-                        if (ch == '*') {
-                            style = CommentStyle.JAVADOC;
-                            scanDocComment();
-                        } else {
-                            style = CommentStyle.BLOCK;
-                            while (bp < buflen) {
-                                if (ch == '*') {
-                                    scanChar();
-                                    if (ch == '/') break;
-                                } else {
-                                    scanCommentChar();
-                                }
-                            }
-                        }
-                        if (ch == '/') {
-                            scanChar();
-                            endPos = bp;
-                            processComment(style);
-                            break;
-                        } else {
-                            lexError("unclosed.comment");
-                            return;
-                        }
-                    } else if (ch == '=') {
-                        name = names.slashequals;
-                        token = SLASHEQ;
-                        scanChar();
-                    } else {
-                        name = names.slash;
-                        token = SLASH;
-                    }
-                    return;
-                case '\'':
-                    scanChar();
-                    if (ch == '\'') {
-                        lexError("empty.char.lit");
-                    } else {
-                        if (ch == CR || ch == LF)
-                            lexError(pos, "illegal.line.end.in.char.lit");
-                        scanLitChar();
-                        if (ch == '\'') {
-                            scanChar();
-                            token = CHARLITERAL;
-                        } else {
-                            lexError(pos, "unclosed.char.lit");
-                        }
-                    }
-                    return;
-                case '\"':
-                    scanChar();
-                    while (ch != '\"' && ch != CR && ch != LF && bp < buflen)
-                        scanLitChar();
-                    if (ch == '\"') {
-                        token = STRINGLITERAL;
-                        scanChar();
-                    } else {
-                        lexError(pos, "unclosed.str.lit");
-                    }
-                    return;
-                default:
-                    if (isSpecial(ch)) {
-                        scanOperator();
-                    } else {
-                        boolean isJavaIdentifierStart;
-                        if (ch < '\u0080') {
-                            // all ASCII range chars already handled, above
-                            isJavaIdentifierStart = false;
-                        } else {
-                            char high = scanSurrogates();
-                            if (high != 0) {
-                                if (sp == sbuf.length) {
-                                    putChar(high);
-                                } else {
-                                    sbuf[sp++] = high;
-                                }
-
-                                isJavaIdentifierStart = Character.isJavaIdentifierStart(
-                                    Character.toCodePoint(high, ch));
-                            } else {
-                                isJavaIdentifierStart = Character.isJavaIdentifierStart(ch);
-                            }
-                        }
-                        if (isJavaIdentifierStart) {
-                            scanIdent();
-                        } else if (bp == buflen || ch == EOI && bp+1 == buflen) { // JLS 3.5
-                            token = EOF;
-                            pos = bp = eofPos;
-                        } else {
-                            lexError("illegal.char", String.valueOf((int)ch));
-                            scanChar();
-                        }
-                    }
-                    return;
-                }
-            }
-        } finally {
-            endPos = bp;
-            if (scannerDebug)
-                System.out.println("nextToken(" + pos
-                                   + "," + endPos + ")=|" +
-                                   new String(getRawCharacters(pos, endPos))
-                                   + "|");
+        prevToken = token;
+        if (!savedTokens.isEmpty()) {
+            token = savedTokens.remove(0);
+        } else {
+            token = tokenizer.readToken();
         }
     }
 
-    /** Return the current token, set by nextToken().
-     */
-    public Token token() {
+    public Token split() {
+        Token[] splitTokens = token.split(tokens);
+        prevToken = splitTokens[0];
+        token = splitTokens[1];
         return token;
     }
 
-    /** Sets the current token.
-     * This method is primarily used to update the token stream when the
-     * parser is handling the end of nested type arguments such as
-     * {@code List<List<String>>} and needs to disambiguate between
-     * repeated use of ">" and relation operators such as ">>" and ">>>". Noting
-     * that this does not handle arbitrary tokens containing Unicode escape
-     * sequences.
-     */
-    public void token(Token token) {
-        pos += (this.token.name != null ? this.token.name.length() : this.sp) - token.name.length();
-        prevEndPos = pos;
-        this.token = token;
-    }
-
-    /** Return the current token's position: a 0-based
-     *  offset from beginning of the raw input stream
-     *  (before unicode translation)
-     */
-    public int pos() {
-        return seek + pos;
-    }
-
-    /** Return the last character position of the current token.
-     */
-    public int endPos() {
-        return seek + endPos;
-    }
-
-    /** Return the last character position of the previous token.
-     */
-    public int prevEndPos() {
-        return seek + prevEndPos;
+    public LineMap getLineMap() {
+        return tokenizer.getLineMap();
     }
 
-    /** Return the position where a lexical error occurred;
-     */
     public int errPos() {
-        return seek + errPos;
+        return tokenizer.errPos();
     }
 
-    /** Set the position where a lexical error occurred;
-     */
     public void errPos(int pos) {
-        errPos = pos - seek;
-    }
-
-    /** Return the name of an identifier or token for the current token.
-     */
-    public Name name() {
-        return name;
-    }
-
-    /** Return the radix of a numeric literal token.
-     */
-    public int radix() {
-        return radix;
-    }
-
-    /** Has a @deprecated been encountered in last doc comment?
-     *  This needs to be reset by client with resetDeprecatedFlag.
-     */
-    public boolean deprecatedFlag() {
-        return deprecatedFlag;
+        tokenizer.errPos(pos);
     }
-
-    public void resetDeprecatedFlag() {
-        deprecatedFlag = false;
-    }
-
-    /**
-     * Returns the documentation string of the current token.
-     */
-    public String docComment() {
-        return null;
-    }
-
-    /**
-     * Returns a copy of the input buffer, up to its inputLength.
-     * Unicode escape sequences are not translated.
-     */
-    public char[] getRawCharacters() {
-        char[] chars = new char[buflen];
-        System.arraycopy(buf, 0, chars, 0, buflen);
-        return chars;
-    }
-
-    /**for DocCommentScanner*/
-    protected char[] getVeryRawCharacters() {
-        if (buf.length == buflen) {
-            char[] chars = new char[buflen];
-            System.arraycopy(buf, 0, chars, 0, buflen);
-            return chars;
-        } else {
-            char[] chars = new char[buflen + 1];
-            System.arraycopy(buf, 0, chars, 0, buflen);
-            chars[buflen] = replacedCharacter;
-            return chars;
-        }
-    }
-
-    /**
-     * Returns a copy of a character array subset of the input buffer.
-     * The returned array begins at the <code>beginIndex</code> and
-     * extends to the character at index <code>endIndex - 1</code>.
-     * Thus the length of the substring is <code>endIndex-beginIndex</code>.
-     * This behavior is like
-     * <code>String.substring(beginIndex, endIndex)</code>.
-     * Unicode escape sequences are not translated.
-     *
-     * @param beginIndex the beginning index, inclusive.
-     * @param endIndex the ending index, exclusive.
-     * @throws IndexOutOfBounds if either offset is outside of the
-     *         array bounds
-     */
-    public char[] getRawCharacters(int beginIndex, int endIndex) {
-        int length = endIndex - beginIndex;
-        char[] chars = new char[length];
-        System.arraycopy(buf, beginIndex-seek, chars, 0, length);   //Normalize by sub seek
-        return chars;
-    }
-
-    public enum CommentStyle {
-        LINE,
-        BLOCK,
-        JAVADOC,
-    }
-
-    /**
-     * Called when a complete comment has been scanned. pos and endPos
-     * will mark the comment boundary.
-     */
-    protected void processComment(CommentStyle style) {
-        if (scannerDebug)
-            System.out.println("processComment(" + pos
-                               + "," + endPos + "," + style + ")=|"
-                               + new String(getRawCharacters(pos, endPos))
-                               + "|");
-    }
-
-    /**
-     * Called when a complete whitespace run has been scanned. pos and endPos
-     * will mark the whitespace boundary.
-     */
-    protected void processWhiteSpace() {
-        if (scannerDebug)
-            System.out.println("processWhitespace(" + pos
-                               + "," + endPos + ")=|" +
-                               new String(getRawCharacters(pos, endPos))
-                               + "|");
-    }
-
-    /**
-     * Called when a line terminator has been processed.
-     */
-    protected void processLineTerminator() {
-        if (scannerDebug)
-            System.out.println("processTerminator(" + pos
-                               + "," + endPos + ")=|" +
-                               new String(getRawCharacters(pos, endPos))
-                               + "|");
-    }
-
-    /** Build a map for translating between line numbers and
-     * positions in the input.
-     *
-     * @return a LineMap */
-    public Position.LineMap getLineMap() {
-        return Position.makeLineMap(buf, buflen, replacedCharacter, false);
-    }
-
-    public void seek (int seek) {
+    
+    public void seek(int seek) {
         assert seek >= 0;
-        this.seek = seek;
+        tokenizer.seek = seek;
+        tokenizer.reader.seek = seek;
     }
-
 }
-
diff --git a/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java b/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java
index 314afd9..2a30297 100644
--- a/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java
+++ b/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java
@@ -57,7 +57,7 @@ public class ScannerFactory {
     final Log log;
     final Names names;
     final Source source;
-    final Keywords keywords;
+    final Tokens tokens;
 
     /** Create a new scanner factory. */
     protected ScannerFactory(Context context) {
@@ -65,14 +65,14 @@ public class ScannerFactory {
         this.log = Log.instance(context);
         this.names = Names.instance(context);
         this.source = Source.instance(context);
-        this.keywords = Keywords.instance(context);
+        this.tokens = Tokens.instance(context);
     }
 
     public Scanner newScanner(CharSequence input, boolean keepDocComments) {
         if (input instanceof CharBuffer) {
             CharBuffer buf = (CharBuffer) input;
             if (keepDocComments)
-                return new DocCommentScanner(this, buf);
+                return new Scanner(this, new JavadocTokenizer(this, buf));
             else
                 return new Scanner(this, buf);
         } else {
@@ -83,7 +83,7 @@ public class ScannerFactory {
 
     public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
         if (keepDocComments)
-            return new DocCommentScanner(this, input, inputLength);
+            return new Scanner(this, new JavadocTokenizer(this, input, inputLength));
         else
             return new Scanner(this, input, inputLength);
     }
diff --git a/src/share/classes/com/sun/tools/javac/parser/Token.java b/src/share/classes/com/sun/tools/javac/parser/Token.java
deleted file mode 100644
index 8fec6f8..0000000
--- a/src/share/classes/com/sun/tools/javac/parser/Token.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 1999, 2008, 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.parser;
-
-import java.util.Locale;
-
-import com.sun.tools.javac.api.Formattable;
-import com.sun.tools.javac.api.Messages;
-
-/** An interface that defines codes for Java source tokens
- *  returned from lexical analysis.
- *
- *  <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 enum Token implements Formattable {
-    EOF,
-    ERROR,
-    IDENTIFIER,
-    ABSTRACT("abstract"),
-    ASSERT("assert"),
-    BOOLEAN("boolean"),
-    BREAK("break"),
-    BYTE("byte"),
-    CASE("case"),
-    CATCH("catch"),
-    CHAR("char"),
-    CLASS("class"),
-    CONST("const"),
-    CONTINUE("continue"),
-    DEFAULT("default"),
-    DO("do"),
-    DOUBLE("double"),
-    ELSE("else"),
-    ENUM("enum"),
-    EXTENDS("extends"),
-    FINAL("final"),
-    FINALLY("finally"),
-    FLOAT("float"),
-    FOR("for"),
-    GOTO("goto"),
-    IF("if"),
-    IMPLEMENTS("implements"),
-    IMPORT("import"),
-    INSTANCEOF("instanceof"),
-    INT("int"),
-    INTERFACE("interface"),
-    LONG("long"),
-    NATIVE("native"),
-    NEW("new"),
-    PACKAGE("package"),
-    PRIVATE("private"),
-    PROTECTED("protected"),
-    PUBLIC("public"),
-    RETURN("return"),
-    SHORT("short"),
-    STATIC("static"),
-    STRICTFP("strictfp"),
-    SUPER("super"),
-    SWITCH("switch"),
-    SYNCHRONIZED("synchronized"),
-    THIS("this"),
-    THROW("throw"),
-    THROWS("throws"),
-    TRANSIENT("transient"),
-    TRY("try"),
-    VOID("void"),
-    VOLATILE("volatile"),
-    WHILE("while"),
-    INTLITERAL,
-    LONGLITERAL,
-    FLOATLITERAL,
-    DOUBLELITERAL,
-    CHARLITERAL,
-    STRINGLITERAL,
-    TRUE("true"),
-    FALSE("false"),
-    NULL("null"),
-    LPAREN("("),
-    RPAREN(")"),
-    LBRACE("{"),
-    RBRACE("}"),
-    LBRACKET("["),
-    RBRACKET("]"),
-    SEMI(";"),
-    COMMA(","),
-    DOT("."),
-    ELLIPSIS("..."),
-    EQ("="),
-    GT(">"),
-    LT("<"),
-    BANG("!"),
-    TILDE("~"),
-    QUES("?"),
-    COLON(":"),
-    EQEQ("=="),
-    LTEQ("<="),
-    GTEQ(">="),
-    BANGEQ("!="),
-    AMPAMP("&&"),
-    BARBAR("||"),
-    PLUSPLUS("++"),
-    SUBSUB("--"),
-    PLUS("+"),
-    SUB("-"),
-    STAR("*"),
-    SLASH("/"),
-    AMP("&"),
-    BAR("|"),
-    CARET("^"),
-    PERCENT("%"),
-    LTLT("<<"),
-    GTGT(">>"),
-    GTGTGT(">>>"),
-    PLUSEQ("+="),
-    SUBEQ("-="),
-    STAREQ("*="),
-    SLASHEQ("/="),
-    AMPEQ("&="),
-    BAREQ("|="),
-    CARETEQ("^="),
-    PERCENTEQ("%="),
-    LTLTEQ("<<="),
-    GTGTEQ(">>="),
-    GTGTGTEQ(">>>="),
-    MONKEYS_AT("@"),
-    CUSTOM;
-
-    Token() {
-        this(null);
-    }
-    Token(String name) {
-        this.name = name;
-    }
-
-    public final String name;
-
-    public String toString() {
-        switch (this) {
-        case IDENTIFIER:
-            return "token.identifier";
-        case CHARLITERAL:
-            return "token.character";
-        case STRINGLITERAL:
-            return "token.string";
-        case INTLITERAL:
-            return "token.integer";
-        case LONGLITERAL:
-            return "token.long-integer";
-        case FLOATLITERAL:
-            return "token.float";
-        case DOUBLELITERAL:
-            return "token.double";
-        case ERROR:
-            return "token.bad-symbol";
-        case EOF:
-            return "token.end-of-input";
-        case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN:
-        case LBRACKET: case RBRACKET: case LBRACE: case RBRACE:
-            return "'" + name + "'";
-        default:
-            return name;
-        }
-    }
-
-    public String getKind() {
-        return "Token";
-    }
-
-    public String toString(Locale locale, Messages messages) {
-        return name != null ? toString() : messages.getLocalizedString(locale, "compiler.misc." + toString());
-    }
-}
diff --git a/src/share/classes/com/sun/tools/javac/parser/Tokens.java b/src/share/classes/com/sun/tools/javac/parser/Tokens.java
new file mode 100644
index 0000000..63a722b
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/Tokens.java
@@ -0,0 +1,481 @@
+/*
+ * Copyright (c) 1999, 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.javac.parser;
+
+import java.util.Locale;
+
+import com.sun.tools.javac.api.Formattable;
+import com.sun.tools.javac.api.Messages;
+import com.sun.tools.javac.parser.Tokens.Token.Tag;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Filter;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Names;
+
+/** A class that defines codes/utilities for Java source tokens
+ *  returned from lexical analysis.
+ *
+ *  <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 Tokens {
+
+    private final Names names;
+
+    /**
+     * Keyword array. Maps name indices to Token.
+     */
+    private final TokenKind[] key;
+
+    /**  The number of the last entered keyword.
+     */
+    private int maxKey = 0;
+
+    /** The names of all tokens.
+     */
+    private Name[] tokenName = new Name[TokenKind.values().length];
+
+    public static final Context.Key<Tokens> tokensKey =
+        new Context.Key<Tokens>();
+
+    public static Tokens instance(Context context) {
+        Tokens instance = context.get(tokensKey);
+        if (instance == null)
+            instance = new Tokens(context);
+        return instance;
+    }
+
+    protected Tokens(Context context) {
+        context.put(tokensKey, this);
+        names = Names.instance(context);
+        for (TokenKind t : TokenKind.values()) {
+            if (t.name != null)
+                enterKeyword(t.name, t);
+            else
+                tokenName[t.ordinal()] = null;
+        }
+
+        key = new TokenKind[maxKey+1];
+        for (int i = 0; i <= maxKey; i++) key[i] = TokenKind.IDENTIFIER;
+        for (TokenKind t : TokenKind.values()) {
+            if (t.name != null)
+            key[tokenName[t.ordinal()].getIndex()] = t;
+        }
+    }
+
+    private void enterKeyword(String s, TokenKind token) {
+        Name n = names.fromString(s);
+        tokenName[token.ordinal()] = n;
+        if (n.getIndex() > maxKey) maxKey = n.getIndex();
+    }
+
+    /**
+     * Create a new token given a name; if the name corresponds to a token name,
+     * a new token of the corresponding kind is returned; otherwise, an
+     * identifier token is returned.
+     */
+    TokenKind lookupKind(Name name) {
+        return (name.getIndex() > maxKey) ? TokenKind.IDENTIFIER : key[name.getIndex()];
+    }
+
+    TokenKind lookupKind(String name) {
+        return lookupKind(names.fromString(name));
+    }
+
+    /**
+     * This enum defines all tokens used by the javac scanner. A token is
+     * optionally associated with a name.
+     */
+    public enum TokenKind implements Formattable, Filter<TokenKind> {
+        EOF(),
+        ERROR(Tag.STRING),
+        IDENTIFIER(Tag.NAMED),
+        ABSTRACT("abstract"),
+        ASSERT("assert", Tag.NAMED),
+        BOOLEAN("boolean", Tag.NAMED),
+        BREAK("break"),
+        BYTE("byte", Tag.NAMED),
+        CASE("case"),
+        CATCH("catch"),
+        CHAR("char", Tag.NAMED),
+        CLASS("class"),
+        CONST("const"),
+        CONTINUE("continue"),
+        DEFAULT("default"),
+        DO("do"),
+        DOUBLE("double", Tag.NAMED),
+        ELSE("else"),
+        ENUM("enum", Tag.NAMED),
+        EXTENDS("extends"),
+        FINAL("final"),
+        FINALLY("finally"),
+        FLOAT("float", Tag.NAMED),
+        FOR("for"),
+        GOTO("goto"),
+        IF("if"),
+        IMPLEMENTS("implements"),
+        IMPORT("import"),
+        INSTANCEOF("instanceof"),
+        INT("int", Tag.NAMED),
+        INTERFACE("interface"),
+        LONG("long", Tag.NAMED),
+        NATIVE("native"),
+        NEW("new"),
+        PACKAGE("package"),
+        PRIVATE("private"),
+        PROTECTED("protected"),
+        PUBLIC("public"),
+        RETURN("return"),
+        SHORT("short", Tag.NAMED),
+        STATIC("static"),
+        STRICTFP("strictfp"),
+        SUPER("super", Tag.NAMED),
+        SWITCH("switch"),
+        SYNCHRONIZED("synchronized"),
+        THIS("this", Tag.NAMED),
+        THROW("throw"),
+        THROWS("throws"),
+        TRANSIENT("transient"),
+        TRY("try"),
+        VOID("void", Tag.NAMED),
+        VOLATILE("volatile"),
+        WHILE("while"),
+        INTLITERAL(Tag.NUMERIC),
+        LONGLITERAL(Tag.NUMERIC),
+        FLOATLITERAL(Tag.NUMERIC),
+        DOUBLELITERAL(Tag.NUMERIC),
+        CHARLITERAL(Tag.NUMERIC),
+        STRINGLITERAL(Tag.STRING),
+        TRUE("true", Tag.NAMED),
+        FALSE("false", Tag.NAMED),
+        NULL("null", Tag.NAMED),
+        UNDERSCORE("_", Tag.NAMED),
+        ARROW("->"),
+        COLCOL("::"),
+        LPAREN("("),
+        RPAREN(")"),
+        LBRACE("{"),
+        RBRACE("}"),
+        LBRACKET("["),
+        RBRACKET("]"),
+        SEMI(";"),
+        COMMA(","),
+        DOT("."),
+        ELLIPSIS("..."),
+        EQ("="),
+        GT(">"),
+        LT("<"),
+        BANG("!"),
+        TILDE("~"),
+        QUES("?"),
+        COLON(":"),
+        EQEQ("=="),
+        LTEQ("<="),
+        GTEQ(">="),
+        BANGEQ("!="),
+        AMPAMP("&&"),
+        BARBAR("||"),
+        PLUSPLUS("++"),
+        SUBSUB("--"),
+        PLUS("+"),
+        SUB("-"),
+        STAR("*"),
+        SLASH("/"),
+        AMP("&"),
+        BAR("|"),
+        CARET("^"),
+        PERCENT("%"),
+        LTLT("<<"),
+        GTGT(">>"),
+        GTGTGT(">>>"),
+        PLUSEQ("+="),
+        SUBEQ("-="),
+        STAREQ("*="),
+        SLASHEQ("/="),
+        AMPEQ("&="),
+        BAREQ("|="),
+        CARETEQ("^="),
+        PERCENTEQ("%="),
+        LTLTEQ("<<="),
+        GTGTEQ(">>="),
+        GTGTGTEQ(">>>="),
+        MONKEYS_AT("@"),
+        CUSTOM;
+
+        public final String name;
+        public final Tag tag;
+
+        TokenKind() {
+            this(null, Tag.DEFAULT);
+        }
+
+        TokenKind(String name) {
+            this(name, Tag.DEFAULT);
+        }
+
+        TokenKind(Tag tag) {
+            this(null, tag);
+        }
+
+        TokenKind(String name, Tag tag) {
+            this.name = name;
+            this.tag = tag;
+        }
+
+        public String toString() {
+            switch (this) {
+            case IDENTIFIER:
+                return "token.identifier";
+            case CHARLITERAL:
+                return "token.character";
+            case STRINGLITERAL:
+                return "token.string";
+            case INTLITERAL:
+                return "token.integer";
+            case LONGLITERAL:
+                return "token.long-integer";
+            case FLOATLITERAL:
+                return "token.float";
+            case DOUBLELITERAL:
+                return "token.double";
+            case ERROR:
+                return "token.bad-symbol";
+            case EOF:
+                return "token.end-of-input";
+            case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN:
+            case LBRACKET: case RBRACKET: case LBRACE: case RBRACE:
+                return "'" + name + "'";
+            default:
+                return name;
+            }
+        }
+
+        public String getKind() {
+            return "Token";
+        }
+
+        public String toString(Locale locale, Messages messages) {
+            return name != null ? toString() : messages.getLocalizedString(locale, "compiler.misc." + toString());
+        }
+
+        @Override
+        public boolean accepts(TokenKind that) {
+            return this == that;
+        }
+    }
+
+    public interface Comment {
+
+        enum CommentStyle {
+            LINE,
+            BLOCK,
+            JAVADOC,
+        }
+
+        String getText();
+        int getSourcePos(int index);
+        CommentStyle getStyle();
+        boolean isDeprecated();
+    }
+
+    /**
+     * This is the class representing a javac token. Each token has several fields
+     * that are set by the javac lexer (i.e. start/end position, string value, etc).
+     */
+    public static class Token {
+
+        /** tags constants **/
+        enum Tag {
+            DEFAULT,
+            NAMED,
+            STRING,
+            NUMERIC;
+        }
+
+        /** The token kind */
+        public final TokenKind kind;
+
+        /** The start position of this token */
+        public final int pos;
+
+        /** The end position of this token */
+        public final int endPos;
+
+        /** Comment reader associated with this token */
+        public final List<Comment> comments;
+
+        Token(TokenKind kind, int pos, int endPos, List<Comment> comments) {
+            this.kind = kind;
+            this.pos = pos;
+            this.endPos = endPos;
+            this.comments = comments;
+            checkKind();
+        }
+
+        Token[] split(Tokens tokens) {
+            if (kind.name.length() < 2 || kind.tag != Tag.DEFAULT) {
+                throw new AssertionError("Cant split" + kind);
+            }
+
+            TokenKind t1 = tokens.lookupKind(kind.name.substring(0, 1));
+            TokenKind t2 = tokens.lookupKind(kind.name.substring(1));
+
+            if (t1 == null || t2 == null) {
+                throw new AssertionError("Cant split - bad subtokens");
+            }
+            return new Token[] {
+                new Token(t1, pos, pos + t1.name.length(), comments),
+                new Token(t2, pos + t1.name.length(), endPos, null)
+            };
+        }
+
+        protected void checkKind() {
+            if (kind.tag != Tag.DEFAULT) {
+                throw new AssertionError("Bad token kind - expected " + Tag.STRING);
+            }
+        }
+
+        public Name name() {
+            throw new UnsupportedOperationException();
+        }
+
+        public String stringVal() {
+            throw new UnsupportedOperationException();
+        }
+
+        public int radix() {
+            throw new UnsupportedOperationException();
+        }
+
+        /**
+         * Preserve classic semantics - if multiple javadocs are found on the token
+         * the last one is returned
+         */
+        public Comment comment(Comment.CommentStyle style) {
+            List<Comment> comments = getComments(Comment.CommentStyle.JAVADOC);
+            return comments.isEmpty() ?
+                    null :
+                    comments.head;
+        }
+
+        /**
+         * Preserve classic semantics - deprecated should be set if at least one
+         * javadoc comment attached to this token contains the '@deprecated' string
+         */
+        public boolean deprecatedFlag() {
+            for (Comment c : getComments(Comment.CommentStyle.JAVADOC)) {
+                if (c.isDeprecated()) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        private List<Comment> getComments(Comment.CommentStyle style) {
+            if (comments == null) {
+                return List.nil();
+            } else {
+                ListBuffer<Comment> buf = ListBuffer.lb();
+                for (Comment c : comments) {
+                    if (c.getStyle() == style) {
+                        buf.add(c);
+                    }
+                }
+                return buf.toList();
+            }
+        }
+    }
+
+    final static class NamedToken extends Token {
+        /** The name of this token */
+        public final Name name;
+
+        public NamedToken(TokenKind kind, int pos, int endPos, Name name, List<Comment> comments) {
+            super(kind, pos, endPos, comments);
+            this.name = name;
+        }
+
+        protected void checkKind() {
+            if (kind.tag != Tag.NAMED) {
+                throw new AssertionError("Bad token kind - expected " + Tag.NAMED);
+            }
+        }
+
+        @Override
+        public Name name() {
+            return name;
+        }
+    }
+
+    static class StringToken extends Token {
+        /** The string value of this token */
+        public final String stringVal;
+
+        public StringToken(TokenKind kind, int pos, int endPos, String stringVal, List<Comment> comments) {
+            super(kind, pos, endPos, comments);
+            this.stringVal = stringVal;
+        }
+
+        protected void checkKind() {
+            if (kind.tag != Tag.STRING) {
+                throw new AssertionError("Bad token kind - expected " + Tag.STRING);
+            }
+        }
+
+        @Override
+        public String stringVal() {
+            return stringVal;
+        }
+    }
+
+    final static class NumericToken extends StringToken {
+        /** The 'radix' value of this token */
+        public final int radix;
+
+        public NumericToken(TokenKind kind, int pos, int endPos, String stringVal, int radix, List<Comment> comments) {
+            super(kind, pos, endPos, stringVal, comments);
+            this.radix = radix;
+        }
+
+        protected void checkKind() {
+            if (kind.tag != Tag.NUMERIC) {
+                throw new AssertionError("Bad token kind - expected " + Tag.NUMERIC);
+            }
+        }
+
+        @Override
+        public int radix() {
+            return radix;
+        }
+    }
+
+    public static final Token DUMMY =
+                new StringToken(TokenKind.ERROR, 0, 0, null, null);
+}
diff --git a/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java b/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java
new file mode 100644
index 0000000..302a745
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java
@@ -0,0 +1,285 @@
+/*
+ * 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
+ * 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.parser;
+
+import java.nio.CharBuffer;
+import java.util.Arrays;
+
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.ArrayUtils;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+
+import static com.sun.tools.javac.util.LayoutCharacters.*;
+
+/** The char reader used by the javac lexer/tokenizer. Returns the sequence of
+ * characters contained in the input stream, handling unicode escape accordingly.
+ * Additionally, it provides features for saving chars into a buffer and to retrieve
+ * them at a later stage.
+ *
+ *  <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 UnicodeReader {
+
+    /** The input buffer, index of next character to be read,
+     *  index of one past last character in buffer.
+     */
+    protected char[] buf;
+    protected int bp;
+    protected final int buflen;
+
+    /** The current character.
+     */
+    protected char ch;
+
+    /** The buffer index of the last converted unicode character
+     */
+    protected int unicodeConversionBp = -1;
+
+    protected Log log;
+    protected Names names;
+
+    /** A character buffer for saved chars.
+     */
+    protected char[] sbuf = new char[128];
+    private char replacedCharacter;
+    protected int realLength;
+    protected int sp;
+
+    int seek;
+    
+    /**
+     * Create a scanner from the input array.  This method might
+     * modify the array.  To avoid copying the input array, ensure
+     * that {@code inputLength < input.length} or
+     * {@code input[input.length -1]} is a white space character.
+     *
+     * @param sf the factory which created this Scanner
+     * @param buffer the input, might be modified
+     * Must be positive and less than or equal to input.length.
+     */
+    protected UnicodeReader(ScannerFactory sf, CharBuffer buffer) {
+        this(sf, JavacFileManager.toArray(buffer), buffer.limit());
+    }
+
+    protected UnicodeReader(ScannerFactory sf, char[] input, int inputLength) {
+        log = sf.log;
+        names = sf.names;
+        realLength = inputLength;
+        if (inputLength == input.length) {
+            if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) {
+                replacedCharacter = input[--inputLength];
+            } else {
+                input = Arrays.copyOf(input, inputLength + 1);
+            }
+        }
+        buf = input;
+        buflen = inputLength;
+        buf[buflen] = EOI;
+        bp = -1;
+        scanChar();
+    }
+
+    /** Read next character.
+     */
+    protected void scanChar() {
+        if (bp < buflen) {
+            ch = buf[++bp];
+            if (ch == '\\') {
+                convertUnicode();
+            }
+        }
+    }
+
+    /** Read next character in comment, skipping over double '\' characters.
+     */
+    protected void scanCommentChar() {
+        scanChar();
+        if (ch == '\\') {
+            if (peekChar() == '\\' && !isUnicode()) {
+                skipChar();
+            } else {
+                convertUnicode();
+            }
+        }
+    }
+
+    /** Append a character to sbuf.
+     */
+    protected void putChar(char ch, boolean scan) {
+        sbuf = ArrayUtils.ensureCapacity(sbuf, sp);
+        sbuf[sp++] = ch;
+        if (scan)
+            scanChar();
+    }
+
+    protected void putChar(char ch) {
+        putChar(ch, false);
+    }
+
+    protected void putChar(boolean scan) {
+        putChar(ch, scan);
+    }
+
+    Name name() {
+        return names.fromChars(sbuf, 0, sp);
+    }
+
+    String chars() {
+        return new String(sbuf, 0, sp);
+    }
+
+    /** Convert unicode escape; bp points to initial '\' character
+     *  (Spec 3.3).
+     */
+    protected void convertUnicode() {
+        int startPos = bp;
+        if (ch == '\\' && unicodeConversionBp != bp) {
+            bp++; ch = buf[bp];
+            if (ch == 'u') {
+                do {
+                    bp++; ch = buf[bp];
+                } while (ch == 'u');
+                int limit = bp + 3;
+                if (limit < buflen) {
+                    int d = digit(bp, 16);
+                    int code = d;
+                    while (bp < limit && d >= 0) {
+                        bp++; ch = buf[bp];
+                        d = digit(bp, 16);
+                        code = (code << 4) + d;
+                    }
+                    if (d >= 0) {
+                        ch = (char)code;
+                        unicodeConversionBp = bp;
+                        return;
+                    }
+                }
+                log.error(new SimpleDiagnosticPosition(startPos + seek, bp + seek), "illegal.unicode.esc");
+            } else {
+                bp--;
+                ch = '\\';
+            }
+        }
+    }
+
+    /** Are surrogates supported?
+     */
+    final static boolean surrogatesSupported = surrogatesSupported();
+    private static boolean surrogatesSupported() {
+        try {
+            Character.isHighSurrogate('a');
+            return true;
+        } catch (NoSuchMethodError ex) {
+            return false;
+        }
+    }
+
+    /** Scan surrogate pairs.  If 'ch' is a high surrogate and
+     *  the next character is a low surrogate, then put the low
+     *  surrogate in 'ch', and return the high surrogate.
+     *  otherwise, just return 0.
+     */
+    protected char scanSurrogates() {
+        if (surrogatesSupported && Character.isHighSurrogate(ch)) {
+            char high = ch;
+
+            scanChar();
+
+            if (Character.isLowSurrogate(ch)) {
+                return high;
+            }
+
+            ch = high;
+        }
+
+        return 0;
+    }
+
+    /** Convert an ASCII digit from its base (8, 10, or 16)
+     *  to its value.
+     */
+    protected int digit(int pos, int base) {
+        char c = ch;
+        int result = Character.digit(c, base);
+        if (result >= 0 && c > 0x7f) {
+            log.error(pos + 1, "illegal.nonascii.digit");
+            ch = "0123456789abcdef".charAt(result);
+        }
+        return result;
+    }
+
+    protected boolean isUnicode() {
+        return unicodeConversionBp == bp;
+    }
+
+    protected void skipChar() {
+        bp++;
+    }
+
+    protected char peekChar() {
+        return buf[bp + 1];
+    }
+
+    /**
+     * Returns a copy of the input buffer, up to its inputLength.
+     * Unicode escape sequences are not translated.
+     */
+    public char[] getRawCharacters() {
+        char[] chars = new char[realLength];
+        System.arraycopy(buf, 0, chars, 0, buflen);
+        if (buflen < chars.length) {
+            chars[buflen] = replacedCharacter;
+        }
+        return chars;
+    }
+
+    /**
+     * Returns a copy of a character array subset of the input buffer.
+     * The returned array begins at the {@code beginIndex} and
+     * extends to the character at index {@code endIndex - 1}.
+     * Thus the length of the substring is {@code endIndex-beginIndex}.
+     * This behavior is like
+     * {@code String.substring(beginIndex, endIndex)}.
+     * Unicode escape sequences are not translated.
+     *
+     * @param beginIndex the beginning index, inclusive.
+     * @param endIndex the ending index, exclusive.
+     * @throws ArrayIndexOutOfBoundsException if either offset is outside of the
+     *         array bounds
+     */
+    public char[] getRawCharacters(int beginIndex, int endIndex) {
+        int length = endIndex - beginIndex;
+        char[] chars = new char[length];
+        System.arraycopy(buf, beginIndex, chars, 0, length);
+        return chars;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java
index 641aeb2..bb37382 100644
--- a/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java
@@ -475,7 +475,7 @@ public class JavacFiler implements Filer, Closeable {
         final Set<String> result = new HashSet<String>(originatingElements.length);
         for (final Element oe : originatingElements) {
             final ClassSymbol te  = findTopLevel(oe);
-            if (te != null) {
+            if (te != null && te.classfile != null) {
                 result.add(te.classfile.toUri().toString());
             }
         }
diff --git a/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java b/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java
index 09ed9ef..bc6acc1 100644
--- a/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,6 +99,7 @@ public class JavacMessager implements Messager {
         if (treeTop != null) {
             newSource = treeTop.snd.sourcefile;
             if (newSource != null) {
+                // save the old version and reinstate it later
                 oldSource = log.useSource(newSource);
                 pos = treeTop.fst.pos();
             }
@@ -131,6 +132,7 @@ public class JavacMessager implements Messager {
                 break;
             }
         } finally {
+            // reinstate the saved version, only if it was saved earlier
             if (newSource != null)
                 log.useSource(oldSource);
         }
diff --git a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
index 7c0965b..e9a7a0a 100644
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -25,49 +25,38 @@
 
 package com.sun.tools.javac.processing;
 
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.*;
-
-import java.net.URL;
+import com.sun.source.util.JavacTask;
 import java.io.Closeable;
 import java.io.File;
 import java.io.PrintWriter;
-import java.io.IOException;
 import java.io.StringWriter;
 import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.*;
 
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
-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.element.PackageElement;
-import javax.lang.model.element.VariableElement;
+import javax.lang.model.element.*;
 import javax.lang.model.util.*;
 import javax.tools.JavaFileManager;
-import javax.tools.StandardJavaFileManager;
 import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import static javax.tools.StandardLocation.*;
 
 import com.sun.source.util.TaskEvent;
-import com.sun.source.util.TaskListener;
-import com.sun.source.util.TreePath;
+import com.sun.tools.javac.api.BasicJavacTask;
 import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.api.MultiTaskListener;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Check;
-import com.sun.tools.javac.file.FSInfo;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.jvm.ClassReader.BadClassFile;
 import com.sun.tools.javac.main.JavaCompiler;
-import com.sun.tools.javac.main.JavaCompiler.CompileState;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.model.JavacTypes;
 import com.sun.tools.javac.tree.*;
@@ -77,19 +66,18 @@ import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Convert;
-import com.sun.tools.javac.util.FatalError;
 import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Options;
-
-import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
-import static com.sun.tools.javac.main.OptionName.*;
+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;
+import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 
 /**
  * Objects of this class hold and manage the state needed to support
@@ -110,11 +98,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
     private final boolean printRounds;
     private final boolean verbose;
     private final boolean lint;
-    private final boolean procOnly;
     private final boolean fatalErrors;
     private final boolean werror;
     private final boolean showResolveErrors;
-    private boolean foundTypeProcessors;
 
     private final JavacFiler filer;
     private final JavacMessager messager;
@@ -160,20 +146,32 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
     Source source;
 
     private ClassLoader processorClassLoader;
+    private SecurityException processorClassLoaderException;
 
     /**
      * JavacMessages object used for localization
      */
     private JavacMessages messages;
 
+    private MultiTaskListener taskListener;
+    
     private Check chk;
 
     private Context context;
-
+    
     private boolean isBackgroundCompilation;
 
-    public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) {
+    /** Get the JavacProcessingEnvironment instance for this context. */
+    public static JavacProcessingEnvironment instance(Context context) {
+        JavacProcessingEnvironment instance = context.get(JavacProcessingEnvironment.class);
+        if (instance == null)
+            instance = new JavacProcessingEnvironment(context);
+        return instance;
+    }
+
+    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);
@@ -182,12 +180,14 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         printRounds = options.isSet(XPRINTROUNDS);
         verbose = options.isSet(VERBOSE);
         lint = Lint.instance(context).isEnabled(PROCESSING);
-        procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT);
+        if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
+            JavaCompiler compiler = JavaCompiler.instance(context);
+            compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
+        }
         fatalErrors = options.isSet("fatalEnterError");
         showResolveErrors = options.isSet("showResolveErrors");
         werror = options.isSet(WERROR);
         platformAnnotations = initPlatformAnnotations();
-        foundTypeProcessors = false;
 
         // Initialize services before any processors are initialized
         // in case processors use them.
@@ -200,6 +200,12 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
         messages = JavacMessages.instance(context);
         isBackgroundCompilation = options.get("backgroundCompilation") != null;     //NOI18N
+        taskListener = MultiTaskListener.instance(context);
+        initProcessorClassLoader();
+    }
+
+    public void setProcessors(Iterable<? extends Processor> processors) {
+        Assert.checkNull(discoveredProcs);
         initProcessorIterator(context, processors);
     }
 
@@ -215,6 +221,23 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         return Collections.unmodifiableSet(platformAnnotations);
     }
 
+    private void initProcessorClassLoader() {
+        JavaFileManager fileManager = context.get(JavaFileManager.class);
+        try {
+            // If processorpath is not explicitly set, use the classpath.
+            processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
+                ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
+                : fileManager.getClassLoader(CLASS_PATH);
+
+            if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
+                JavaCompiler compiler = JavaCompiler.instance(context);
+                compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
+            }
+        } catch (SecurityException e) {
+            processorClassLoaderException = e;
+        }
+    }
+
     private void initProcessorIterator(Context context, Iterable<? extends Processor> processors) {
         Log   log   = Log.instance(context);
         Iterator<? extends Processor> processorIterator;
@@ -233,13 +256,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
             processorIterator = processors.iterator();
         } else {
             String processorNames = options.get(PROCESSOR);
-            JavaFileManager fileManager = context.get(JavaFileManager.class);
-            try {
-                // If processorpath is not explicitly set, use the classpath.
-                processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
-                    ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH)
-                    : fileManager.getClassLoader(CLASS_PATH);
-
+            if (processorClassLoaderException == null) {
                 /*
                  * If the "-processor" option is used, search the appropriate
                  * path for the named class.  Otherwise, use a service
@@ -250,14 +267,15 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 } else {
                     processorIterator = new ServiceIterator(processorClassLoader, log);
                 }
-            } catch (SecurityException e) {
+            } else {
                 /*
                  * A security exception will occur if we can't create a classloader.
                  * Ignore the exception if, with hindsight, we didn't need it anyway
                  * (i.e. no processor was specified either explicitly, or implicitly,
                  * in service configuration file.) Otherwise, we cannot continue.
                  */
-                processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader", e);
+                processorIterator = handleServiceLoaderUnavailability("proc.cant.create.loader",
+                        processorClassLoaderException);
             }
         }
         discoveredProcs = new DiscoveredProcessors(processorIterator);
@@ -310,59 +328,24 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
 
     /**
      * Use a service loader appropriate for the platform to provide an
-     * iterator over annotations processors.  If
-     * java.util.ServiceLoader is present use it, otherwise, use
-     * sun.misc.Service, otherwise fail if a loader is needed.
+     * iterator over annotations processors; fails if a loader is
+     * needed but unavailable.
      */
     private class ServiceIterator implements Iterator<Processor> {
-        // The to-be-wrapped iterator.
-        private Iterator<?> iterator;
+        private Iterator<Processor> iterator;
         private Log log;
-        private Class<?> loaderClass;
-        private boolean jusl;
-        private Object loader;
+        private ServiceLoader<Processor> loader;
 
         ServiceIterator(ClassLoader classLoader, Log log) {
-            String loadMethodName;
-
             this.log = log;
             try {
                 try {
-                    loaderClass = Class.forName("java.util.ServiceLoader");
-                    loadMethodName = "load";
-                    jusl = true;
-                } catch (ClassNotFoundException cnfe) {
-                    try {
-                        loaderClass = Class.forName("sun.misc.Service");
-                        loadMethodName = "providers";
-                        jusl = false;
-                    } catch (ClassNotFoundException cnfe2) {
-                        // Fail softly if a loader is not actually needed.
-                        this.iterator = handleServiceLoaderUnavailability("proc.no.service",
-                                                                          null);
-                        return;
-                    }
-                }
-
-                // java.util.ServiceLoader.load or sun.misc.Service.providers
-                Method loadMethod = loaderClass.getMethod(loadMethodName,
-                                                          Class.class,
-                                                          ClassLoader.class);
-
-                Object result = loadMethod.invoke(null,
-                                                  Processor.class,
-                                                  classLoader);
-
-                // For java.util.ServiceLoader, we have to call another
-                // method to get the iterator.
-                if (jusl) {
-                    loader = result; // Store ServiceLoader to call reload later
-                    Method m = loaderClass.getMethod("iterator");
-                    result = m.invoke(result); // serviceLoader.iterator();
+                    loader = ServiceLoader.load(Processor.class, classLoader);
+                    this.iterator = loader.iterator();
+                } catch (Exception e) {
+                    // Fail softly if a loader is not actually needed.
+                    this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
                 }
-
-                // The result should now be an iterator.
-                this.iterator = (Iterator<?>) result;
             } catch (Throwable t) {
                 log.error("proc.service.problem");
                 throw new Abort(t);
@@ -372,25 +355,21 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         public boolean hasNext() {
             try {
                 return iterator.hasNext();
+            } catch(ServiceConfigurationError sce) {
+                log.error("proc.bad.config.file", sce.getLocalizedMessage());
+                throw new Abort(sce);
             } catch (Throwable t) {
-                if ("ServiceConfigurationError".
-                    equals(t.getClass().getSimpleName())) {
-                    log.error("proc.bad.config.file", t.getLocalizedMessage());
-                }
                 throw new Abort(t);
             }
         }
 
         public Processor next() {
             try {
-                return (Processor)(iterator.next());
+                return iterator.next();
+            } catch (ServiceConfigurationError sce) {
+                log.error("proc.bad.config.file", sce.getLocalizedMessage());
+                throw new Abort(sce);
             } catch (Throwable t) {
-                if ("ServiceConfigurationError".
-                    equals(t.getClass().getSimpleName())) {
-                    log.error("proc.bad.config.file", t.getLocalizedMessage());
-                } else {
-                    log.error("proc.processor.constructor.error", t.getLocalizedMessage());
-                }
                 throw new Abort(t);
             }
         }
@@ -400,11 +379,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         }
 
         public void close() {
-            if (jusl) {
+            if (loader != null) {
                 try {
-                    // Call java.util.ServiceLoader.reload
-                    Method reloadMethod = loaderClass.getMethod("reload");
-                    reloadMethod.invoke(loader);
+                    loader.reload();
                 } catch(Exception e) {
                     ; // Ignore problems during a call to reload.
                 }
@@ -514,7 +491,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
      * State about how a processor has been used by the tool.  If a
      * processor has been used on a prior round, its process method is
      * called on all subsequent rounds, perhaps with an empty set of
-     * annotations to process.  The {@code annotatedSupported} method
+     * annotations to process.  The {@code annotationSupported} method
      * caches the supported annotation information from the first (and
      * only) getSupportedAnnotationTypes call to the processor.
      */
@@ -744,7 +721,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 ps.removeSupportedOptions(unmatchedProcessorOptions);
 
                 if (printProcessorInfo || verbose) {
-                    log.printNoteLines("x.print.processor.info",
+                    log.printLines("x.print.processor.info",
                             ps.processor.getClass().getName(),
                             matchedNames.toString(),
                             processingResult);
@@ -781,7 +758,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
      * Leave class public for external testing purposes.
      */
     public static class ComputeAnnotationSet extends
-        ElementScanner7<Set<TypeElement>, Set<TypeElement>> {
+        ElementScanner8<Set<TypeElement>, Set<TypeElement>> {
         final Elements elements;
 
         public ComputeAnnotationSet(Elements elements) {
@@ -796,7 +773,20 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         }
 
         @Override
-        public Set<TypeElement> scan(Element e, Set<TypeElement> p) {
+        public Set<TypeElement> visitType(TypeElement e, Set<TypeElement> p) {
+            // Type parameters are not considered to be enclosed by a type
+            scan(e.getTypeParameters(), p);
+            return scan(e.getEnclosedElements(), p);
+        }
+
+        @Override
+        public Set<TypeElement> visitExecutable(ExecutableElement e, Set<TypeElement> p) {
+            // Type parameters are not considered to be enclosed by an executable
+            scan(e.getTypeParameters(), p);
+            return scan(e.getEnclosedElements(), p);
+        }
+
+        void addAnnotations(Element e, Set<TypeElement> p) {
             for (AnnotationMirror annotationMirror :
                      elements.getAllAnnotationMirrors(e) ) {
                 if (isComplete(annotationMirror)) {
@@ -804,6 +794,11 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                     p.add((TypeElement) e2);
                 }
             }
+        }
+
+        @Override
+        public Set<TypeElement> scan(Element e, Set<TypeElement> p) {
+            addAnnotations(e, p);
             return super.scan(e, p);
         }
 
@@ -870,9 +865,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         /** The set of package-info files to be processed this round. */
         List<PackageSymbol> packageInfoFiles;
 
-        /** The number of Messager errors generated in this round. */
-        int nMessagerErrors;
-
         /** Create a round (common code). */
         private Round(Context context, int number, int priorErrors, int priorWarnings) {
             this.context = context;
@@ -881,8 +873,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
             log.nerrors = priorErrors;
-            log.nwarnings += priorWarnings;
-            log.deferDiagnostics = true;
+            log.nwarnings = priorWarnings;
+            
+            if (compiler.deferredDiagnosticHandler == null)
+                compiler.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log);
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
             JavacProcessingEnvironment.this.context = context;
@@ -914,7 +908,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
             this(prev.context,
                     prev.number+1,
-                    prev.nMessagerErrors,
+                    prev.compiler.log.nerrors,
                     prev.compiler.log.nwarnings);
             this.genClassFiles = prev.genClassFiles;
 
@@ -952,13 +946,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         }
 
         /** Create the compiler to be used for the final compilation. */
-        JavaCompiler finalCompiler(boolean errorStatus) {
-            JavaCompiler c = JavaCompiler.instance(context);
-            c.log.nwarnings += compiler.log.nwarnings;
-            if (errorStatus) {
-                c.log.nerrors += compiler.log.nerrors;
-            }
-            return c;
+        JavaCompiler finalCompiler() {
+            return JavaCompiler.instance(context);
         }
 
         /** Return the number of errors found so far in this round.
@@ -978,7 +967,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
             if (messager.errorRaised())
                 return true;
 
-            for (JCDiagnostic d: log.deferredDiagnostics) {
+            for (JCDiagnostic d: compiler.deferredDiagnosticHandler.getDiagnostics()) {
                 switch (d.getKind()) {
                     case WARNING:
                         if (werror)
@@ -1043,8 +1032,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         void run(boolean lastRound, boolean errorStatus) {
             printRoundInfo(lastRound);
 
-            TaskListener taskListener = context.get(TaskListener.class);
-            if (taskListener != null)
+            if (!taskListener.isEmpty())
                 taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
 
             try {
@@ -1060,11 +1048,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                     discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
                 }
             } finally {
-                if (taskListener != null)
+                if (!taskListener.isEmpty())
                     taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
             }
-
-            nMessagerErrors = messager.errorCount();
         }
 
         void showDiagnostics(boolean showAll) {
@@ -1073,7 +1059,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 // suppress errors, which are all presumed to be transient resolve errors
                 kinds.remove(JCDiagnostic.Kind.ERROR);
             }
-            log.reportDeferredDiagnostics(kinds);
+            compiler.deferredDiagnosticHandler.reportDeferredDiagnostics(kinds);
+            log.popDiagnosticHandler(compiler.deferredDiagnosticHandler);
+            compiler.deferredDiagnosticHandler = null;                    
         }
 
         /** Update the processing state for the current context. */
@@ -1091,7 +1079,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
             if (printRounds || verbose) {
                 List<ClassSymbol> tlc = lastRound ? List.<ClassSymbol>nil() : topLevelClasses;
                 Set<TypeElement> ap = lastRound ? Collections.<TypeElement>emptySet() : annotationsPresent;
-                log.printNoteLines("x.print.rounds",
+                log.printLines("x.print.rounds",
                         number,
                         "{" + tlc.toString(", ") + "}",
                         ap,
@@ -1107,8 +1095,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                                      List<JCCompilationUnit> roots,
                                      List<ClassSymbol> classSymbols,
                                      Iterable<? extends PackageSymbol> pckSymbols) {
-
-        TaskListener taskListener = context.get(TaskListener.class);
         log = Log.instance(context);
 
         Set<PackageSymbol> specifiedPackages = new LinkedHashSet<PackageSymbol>();
@@ -1168,14 +1154,14 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects());
         roots = cleanTrees(round.roots);
 
-        JavaCompiler compiler = round.finalCompiler(errorStatus);
+        JavaCompiler compiler = round.finalCompiler();
 
         if (newSourceFiles.size() > 0)
             roots = roots.appendList(compiler.parseFiles(newSourceFiles));
 
         errorStatus = errorStatus || (compiler.errorCount() > 0);
 
-        if (taskListener != null)
+        if (!taskListener.isEmpty())
             taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
 
         try {
@@ -1191,10 +1177,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 compiler.log.nerrors++;
             return compiler;
         }
-        if (!procOnly || foundTypeProcessors) {
-            if (procOnly && foundTypeProcessors)
-                compiler.shouldStopPolicy = CompileState.FLOW;
-        }
 
         return compiler;
     }
@@ -1213,20 +1195,13 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         if (discoveredProcs != null) // Make calling close idempotent
             discoveredProcs.close();
         discoveredProcs = null;
-        if (processorClassLoader != null && processorClassLoader instanceof Closeable)
-        try {
-            ((Closeable) processorClassLoader).close();
-        } catch (IOException e) {
-            JCDiagnostic msg = diags.fragment("fatal.err.cant.close.loader");
-            throw new FatalError(msg, e);
-        }
     }
 
     private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
         List<ClassSymbol> classes = List.nil();
         for (JCCompilationUnit unit : units) {
             for (JCTree node : unit.defs) {
-                if (node.getTag() == JCTree.CLASSDEF) {
+                if (node.hasTag(JCTree.Tag.CLASSDEF)) {
                     ClassSymbol sym = ((JCClassDecl) node).sym;
                     Assert.checkNonNull(sym);
                     classes = classes.prepend(sym);
@@ -1350,7 +1325,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         return nodes;
     }
 
-    private TreeScanner treeCleaner = new TreeScanner() {
+    private final TreeScanner treeCleaner = new TreeScanner() {
             public void scan(JCTree node) {
                 super.scan(node);
                 if (node != null)
@@ -1424,6 +1399,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 node.sym = null;
                 super.visitIdent(node);
             }
+            public void visitAnnotation(JCAnnotation node) {
+                node.attribute = null;
+                super.visitAnnotation(node);
+            }
         };
 
 
@@ -1435,7 +1414,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
      * {@inheritdoc}
      *
      * Command line options suitable for presenting to annotation
-     * processors.  "-Afoo=bar" should be "-Afoo" => "bar".
+     * processors.
+     * {@literal "-Afoo=bar"} should be {@literal "-Afoo" => "bar"}.
      */
     public Map<String,String> getOptions() {
         return processorOptions;
@@ -1535,13 +1515,19 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
     }
 
     /**
-     * For internal use only.  This method will be
-     * removed without warning.
+     * For internal use only.  This method may be removed without warning.
      */
     public Context getContext() {
         return context;
     }
 
+    /**
+     * For internal use only.  This method may be removed without warning.
+     */
+    public ClassLoader getProcessorClassLoader() {
+        return processorClassLoader;
+    }
+
     public String toString() {
         return "javac ProcessingEnvironment";
     }
@@ -1559,4 +1545,9 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
             throw (Error) t;
         }
     }
+    
+    public JavacTask getJavacTask() {
+        JavacTask t = context.get(JavacTask.class);
+        return (t != null) ? t : new BasicJavacTask(context, true);
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
index 1131c67..42d9d44 100644
--- a/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -105,7 +105,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
      * Only type elements <i>included</i> in this round of annotation
      * processing, or declarations of members, parameters, or type
      * parameters declared within those, are returned.  Included type
-     * elements are {@linkplain #getSpecifiedTypeElements specified
+     * elements are {@linkplain #getRootElements specified
      * types} and any types nested within them.
      *
      * @param a  annotation type being requested
@@ -125,7 +125,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
         else
             throw new AssertionError("Bad implementation type for " + tm);
 
-        ElementScanner7<Set<Element>, DeclaredType> scanner =
+        ElementScanner8<Set<Element>, DeclaredType> scanner =
             new AnnotationSetScanner(result, typeUtil);
 
         for (Element element : rootElements)
@@ -136,7 +136,7 @@ public class JavacRoundEnvironment implements RoundEnvironment {
 
     // Could be written as a local class inside getElementsAnnotatedWith
     private class AnnotationSetScanner extends
-        ElementScanner7<Set<Element>, DeclaredType> {
+        ElementScanner8<Set<Element>, DeclaredType> {
         // Insertion-order preserving set
         Set<Element> annotatedElements = new LinkedHashSet<Element>();
         Types typeUtil;
@@ -147,6 +147,20 @@ public class JavacRoundEnvironment implements RoundEnvironment {
         }
 
         @Override
+        public Set<Element> visitType(TypeElement e, DeclaredType p) {
+            // Type parameters are not considered to be enclosed by a type
+            scan(e.getTypeParameters(), p);
+            return scan(e.getEnclosedElements(), p);
+        }
+
+        @Override
+        public Set<Element> visitExecutable(ExecutableElement e, DeclaredType p) {
+            // Type parameters are not considered to be enclosed by an executable
+            scan(e.getTypeParameters(), p);
+            return scan(e.getEnclosedElements(), p);
+        }
+
+        @Override
         public Set<Element> scan(Element e, DeclaredType p) {
             java.util.List<? extends AnnotationMirror> annotationMirrors =
                 processingEnv.getElementUtils().getAllAnnotationMirrors(e);
@@ -157,7 +171,6 @@ public class JavacRoundEnvironment implements RoundEnvironment {
             e.accept(this, p);
             return annotatedElements;
         }
-
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
index c992a9c..4a85f79 100644
--- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
+++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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,8 +48,7 @@ import java.util.*;
  * deletion without notice.</b>
  */
 @SupportedAnnotationTypes("*")
-// TODO: Change to version 7 based visitors when available
- at SupportedSourceVersion(SourceVersion.RELEASE_7)
+ at SupportedSourceVersion(SourceVersion.RELEASE_8)
 public class PrintingProcessor extends AbstractProcessor {
     PrintWriter writer;
 
@@ -83,7 +82,7 @@ public class PrintingProcessor extends AbstractProcessor {
      * Used for the -Xprint option and called by Elements.printElements
      */
     public static class PrintingElementVisitor
-        extends SimpleElementVisitor7<PrintingElementVisitor, Boolean> {
+        extends SimpleElementVisitor8<PrintingElementVisitor, Boolean> {
         int indentation; // Indentation level;
         final PrintWriter writer;
         final Elements elementUtils;
diff --git a/src/share/classes/com/sun/tools/javac/processing/ServiceProxy.java b/src/share/classes/com/sun/tools/javac/processing/ServiceProxy.java
index e3cd7ad..ea6d9a0 100644
--- a/src/share/classes/com/sun/tools/javac/processing/ServiceProxy.java
+++ b/src/share/classes/com/sun/tools/javac/processing/ServiceProxy.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -72,7 +72,7 @@ class ServiceProxy {
      *         The service class for which providers are being sought;
      *         used to construct error detail strings
      *
-     * @param  url
+     * @param  u
      *         The URL naming the configuration file to be parsed
      *
      * @return true if the name of a service is found
diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/src/share/classes/com/sun/tools/javac/resources/compiler.properties
index e0a58f2..b59cc81 100644
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2011, 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
@@ -134,15 +134,13 @@ compiler.err.array.dimension.missing=\
 compiler.err.array.req.but.found=\
     array required, but {0} found
 
-compiler.err.assignment.from.super-bound=\
-    assigning from wildcard {0}
-
-compiler.err.assignment.to.extends-bound=\
-    assigning to wildcard {0}
-
 compiler.err.attribute.value.must.be.constant=\
     attribute value must be constant
 
+# 0: statement type
+compiler.err.bad.initializer=\
+    bad initializer for {0}
+
 compiler.err.break.outside.switch.loop=\
     break outside switch or loop
 
@@ -150,26 +148,114 @@ compiler.err.break.outside.switch.loop=\
 compiler.err.call.must.be.first.stmt.in.ctor=\
     call to {0} must be first statement in constructor
 
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
 compiler.err.cant.apply.symbol=\
-    {0} {1} in {4} {5} cannot be applied to given types\n\
+    {0} {1} in {4} {5} cannot be applied to given types;\n\
     required: {2}\n\
-    found: {3}
+    found: {3}\n\
+    reason: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
+compiler.err.cant.apply.symbols=\
+    no suitable {0} found for {1}({2})
 
 # 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
-compiler.err.cant.apply.symbol.1=\
-    {0} {1} in {4} {5} cannot be applied to given types;\n\
+compiler.misc.cant.apply.symbol=\
+    {0} {1} in {4} {5} cannot be applied to given types\n\
     required: {2}\n\
     found: {3}\n\
     reason: {6}
 
 # 0: symbol kind, 1: name, 2: list of type
-compiler.err.cant.apply.symbols=\
+compiler.misc.cant.apply.symbols=\
     no suitable {0} found for {1}({2})
 
+# 0: symbol kind, 1: symbol
+compiler.misc.no.abstracts=\
+    no abstract method found in {0} {1}
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.abstracts=\
+    multiple non-overriding abstract methods found in {0} {1}
+
+compiler.err.bad.functional.intf.anno=\
+    Unexpected @FunctionalInterface annotation
+
+# 0: message segment
+compiler.err.bad.functional.intf.anno.1=\
+    Unexpected @FunctionalInterface annotation\n\
+    {0}
+
+# 0: symbol
+compiler.misc.not.a.functional.intf=\
+    {0} is not a functional interface
+
+# 0: symbol, 1: message segment
+compiler.misc.not.a.functional.intf.1=\
+    {0} is not a functional interface\n\
+    {1}
+
+# 0: symbol, 1: symbol kind, 2: symbol
+compiler.misc.invalid.generic.lambda.target=\
+    invalid functional descriptor for lambda expression\n\
+    method {0} in {1} {2} is generic
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.descs.in.functional.intf=\
+    incompatible function descriptors found in {0} {1}
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor=\
+    descriptor: {2} {0}({1})
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor.throws=\
+    descriptor: {2} {0}({1}) throws {3}
+
+# 0: type
+compiler.misc.no.suitable.functional.intf.inst=\
+    cannot infer functional interface descriptor for {0}
+
+# 0: message segment
+compiler.misc.bad.intersection.target.for.functional.expr=\
+    bad intersection type target for lambda or method reference\n\
+    {0}
+
+# 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\n\
+    {1}
+
+# 0: symbol kind, 1: message segment
+compiler.misc.invalid.mref=\
+    invalid {0} reference\n\
+    {1}
+
+compiler.misc.static.mref.with.targs=\
+    parameterized qualifier on static method reference
+
+compiler.misc.static.bound.mref=\
+    static bound method reference
+
 # 0: symbol
 compiler.err.cant.assign.val.to.final.var=\
     cannot assign a value to final variable {0}
 
+# 0: symbol, 1: message segment
+compiler.err.cant.ref.non.effectively.final.var=\
+    local variables referenced from {1} must be final or effectively final
+
+
+compiler.misc.lambda=\
+    a lambda expression
+
+compiler.misc.inner.cls=\
+    an inner class
+
 # 0: type
 compiler.err.cant.deref=\
     {0} cannot be dereferenced
@@ -185,9 +271,6 @@ compiler.err.cant.inherit.from.final=\
 compiler.err.cant.ref.before.ctor.called=\
     cannot reference {0} before supertype constructor has been called
 
-compiler.err.cant.ret.val.from.meth.decl.void=\
-    cannot return a value from method whose result type is void
-
 compiler.err.cant.select.static.class.from.param.type=\
     cannot select a static class from a parameterized type
 
@@ -202,6 +285,9 @@ compiler.err.catch.without.try=\
 compiler.err.clash.with.pkg.of.same.name=\
     {0} {1} clashes with package of same name
 
+compiler.err.class.not.allowed=\
+    class, interface or enum declaration not allowed here
+
 compiler.err.const.expr.req=\
     constant expression required
 
@@ -223,9 +309,6 @@ compiler.err.call.to.super.not.allowed.in.enum.ctor=\
 compiler.err.no.superclass=\
     {0} has no superclass
 
-compiler.err.wrong.target.for.polymorphic.signature.definition=\
-    MethodHandle API building requires -target 7 runtimes or better; current is -target {0}
-
 # 0: symbol, 1: type, 2: symbol, 3: type, 4: unused
 compiler.err.concrete.inheritance.conflict=\
     methods {0} from {1} and {2} from {3} are inherited with the same signature
@@ -240,10 +323,62 @@ compiler.err.doesnt.exist=\
 compiler.err.duplicate.annotation=\
     duplicate annotation
 
+# 0: type
+compiler.err.duplicate.annotation.invalid.repeated=\
+    annotation {0} cannot be repeated\nIt does not define a valid containing annotation.
+
 # 0: name, 1: type
 compiler.err.duplicate.annotation.member.value=\
     duplicate annotation member value {0} in {1}
 
+# 0: type, 1: type
+compiler.err.duplicate.annotation.missing.container=\
+    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: symbol or type
+compiler.err.invalid.repeatable.annotation.no.value=\
+    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
+
+# 0: type
+compiler.err.invalid.repeatable.annotation.invalid.value=\
+    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: symbol or type, 1: symbol
+compiler.err.invalid.repeatable.annotation.elem.nondefault=\
+    containing annotation {0} does not have a default value for element {1}
+
+# 0: symbol, 1: type, 2: symbol, 3: type
+compiler.err.invalid.repeatable.annotation.retention=\
+    containing annotation {0} has shorter retention ({1}) than the contained annotation {2} with retention {3}
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.documented=\
+    containing annotation type, {0}, is not @Documented while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.inherited=\
+    containing annotation type, {0}, is not @Inherited while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.incompatible.target=\
+    target of container annotation {0} is not a subset of target of repeated annotation {1}
+
+# 0: symbol
+compiler.err.invalid.repeatable.annotation.repeated.and.container.present=\
+    container {0} must not be present at the same time as the element it contains
+
 # 0: name
 compiler.err.duplicate.class=\
     duplicate class: {0}
@@ -339,7 +474,7 @@ compiler.err.icls.cant.have.static.decl=\
 
 # 0: string
 compiler.err.illegal.char=\
-    illegal character: \\{0}
+    illegal character: ''{0}''
 
 compiler.err.illegal.char.for.encoding=\
     unmappable character for encoding {0}
@@ -357,6 +492,10 @@ compiler.err.illegal.esc.char=\
 compiler.err.illegal.forward.ref=\
     illegal forward reference
 
+# 0: symbol, 1: string
+compiler.err.not.in.profile=\
+    {0} is not available in profile ''{1}''
+
 # 0: symbol
 compiler.warn.forward.ref=\
     reference to variable ''{0}'' before it has been initialized
@@ -384,6 +523,9 @@ compiler.err.illegal.nonascii.digit=\
 compiler.err.illegal.underscore=\
     illegal underscore
 
+compiler.err.illegal.dot=\
+    illegal ''.''
+
 # 0: symbol
 compiler.err.illegal.qual.not.icls=\
     illegal qualifier; {0} is not an inner class
@@ -391,6 +533,9 @@ compiler.err.illegal.qual.not.icls=\
 compiler.err.illegal.start.of.expr=\
     illegal start of expression
 
+compiler.err.illegal.start.of.stmt=\
+    illegal start of statement
+
 compiler.err.illegal.start.of.type=\
     illegal start of type
 
@@ -415,9 +560,6 @@ compiler.err.incomparable.types=\
 compiler.err.int.number.too.large=\
     integer number too large: {0}
 
-compiler.err.internal.error.cant.instantiate=\
-    internal error; cannot instantiate {0} at {1} to ({2})
-
 compiler.err.intf.annotation.members.cant.have.params=\
     @interface members may not have parameters
 
@@ -435,7 +577,7 @@ compiler.err.intf.expected.here=\
     interface expected here
 
 compiler.err.intf.meth.cant.have.body=\
-    interface methods cannot have body
+    interface abstract methods cannot have body
 
 compiler.err.invalid.annotation.member.type=\
     invalid type for annotation member
@@ -452,6 +594,15 @@ compiler.err.invalid.meth.decl.ret.type.req=\
 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
+
 # 0: name
 compiler.err.label.already.in.use=\
     label {0} already in use
@@ -516,9 +667,13 @@ compiler.err.missing.meth.body.or.decl.abstract=\
 compiler.err.missing.ret.stmt=\
     missing return statement
 
-compiler.err.missing.ret.val=\
+# 0: unused
+compiler.misc.missing.ret.val=\
     missing return value
 
+compiler.misc.unexpected.ret.val=\
+    unexpected return value
+
 # 0: set of modifier
 compiler.err.mod.not.allowed.here=\
     modifier {0} not allowed here
@@ -559,6 +714,39 @@ compiler.err.neither.conditional.subtype=\
     second operand: {0}\n\
     third operand : {1}
 
+# 0: message segment
+compiler.misc.incompatible.type.in.conditional=\
+    bad type in conditional expression\n\
+    {0}
+
+compiler.misc.conditional.target.cant.be.void=\
+    target-type for conditional expression cannot be void
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.lambda=\
+    bad return type in lambda expression\n\
+    {0}
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.mref=\
+    bad return type in method reference\n\
+    {0}
+
+# 0: list of type
+compiler.err.incompatible.thrown.types.in.mref=\
+    incompatible thrown types {0} in method reference
+
+compiler.misc.incompatible.arg.types.in.lambda=\
+    incompatible parameter types in lambda expression
+
+compiler.misc.incompatible.arg.types.in.mref=\
+    incompatible parameter types in method reference
+
+# 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}
+
 compiler.err.new.not.allowed.in.annotation=\
     ''new'' not allowed in an annotation
 
@@ -582,9 +770,22 @@ compiler.err.not.def.access.class.intf.cant.access=\
     {0} in {1} is defined in an inaccessible class or interface
 
 # 0: symbol, 1: symbol
+compiler.misc.not.def.access.class.intf.cant.access=\
+    {0} in {1} is defined in an inaccessible class or interface
+
+# 0: symbol, 1: list of type, 2: type
+compiler.misc.cant.access.inner.cls.constr=\
+    cannot access constructor {0}({1})\n\
+    an enclosing instance of type {2} is not in scope
+
+# 0: symbol, 1: symbol
 compiler.err.not.def.public.cant.access=\
     {0} is not public in {1}; cannot be accessed from outside package
 
+# 0: symbol, 1: symbol
+compiler.misc.not.def.public.cant.access=\
+    {0} is not public in {1}; cannot be accessed from outside package
+
 # 0: name
 compiler.err.not.loop.label=\
     not a loop label: {0}
@@ -644,8 +845,7 @@ compiler.err.proc.no.explicit.annotation.processing.requested=\
     Class names, ''{0}'', are only accepted if annotation processing is explicitly requested
 
 compiler.err.proc.no.service=\
-    A service loader class could not be found.\n\
-    Either java.util.ServiceLoader or sun.misc.Service must be available.
+    A ServiceLoader was not usable and is required for annotation processing.
 
 compiler.err.proc.processor.bad.option.name=\
     Bad option name ''{0}'' provided by processor ''{1}''
@@ -654,9 +854,6 @@ compiler.err.proc.processor.bad.option.name=\
 compiler.err.proc.processor.cant.instantiate=\
     Could not instantiate an instance of processor ''{0}''
 
-compiler.err.proc.processor.constructor.error=\
-    Exception thrown while constructing Processor object: {0}
-
 # 0: string
 compiler.err.proc.processor.not.found=\
     Annotation processor ''{0}'' not found
@@ -683,7 +880,13 @@ compiler.err.recursive.ctor.invocation=\
 
 # 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
 compiler.err.ref.ambiguous=\
-    reference to {0} is ambiguous, both {1} {2} in {3} and {4} {5} in {6} match
+    reference to {0} is ambiguous\n\
+    both {1} {2} in {3} and {4} {5} in {6} match
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
+compiler.misc.ref.ambiguous=\
+    reference to {0} is ambiguous\n\
+    both {1} {2} in {3} and {4} {5} in {6} match
 
 compiler.err.repeated.annotation.target=\
     repeated annotation target
@@ -760,6 +963,36 @@ compiler.err.type.var.more.than.once.in.result=\
 compiler.err.types.incompatible.diff.ret=\
     types {0} and {1} are incompatible; both define {2}, but with unrelated return types
 
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.unrelated.defaults=\
+    {0} {1} inherits unrelated defaults for {2}({3}) from types {4} and {5}
+
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.abstract.default=\
+    {0} {1} inherits abstract and default for {2}({3}) from types {4} and {5}
+
+# 0: name, 1: kind, 2: symbol
+compiler.err.default.overrides.object.member=\
+    default method {0} in {1} {2} overrides a member of java.lang.Object
+
+# 0: type
+compiler.err.illegal.static.intf.meth.call=\
+    illegal static interface method call\n\
+    the receiver expression should be replaced with the type qualifier ''{0}''
+
+# 0: type, 1: message segment
+compiler.err.illegal.default.super.call=\
+    bad type qualifier {0} in default super call\n\
+    {1}
+
+# 0: symbol, 1: type
+compiler.misc.overridden.default=\
+    method {0} is overridden in {1}
+
+# 0: symbol, 1: type or symbol
+compiler.misc.redundant.supertype=\
+    redundant interface {0} is extended by {1}
+
 compiler.err.unclosed.char.lit=\
     unclosed character literal
 
@@ -780,25 +1013,18 @@ compiler.err.io.exception=\
 compiler.err.undef.label=\
     undefined label: {0}
 
-compiler.err.undetermined.type=\
-    cannot infer type arguments for {0}
-
-# 0: type, 1: message segment
-compiler.err.undetermined.type.1=\
-    cannot infer type arguments for {0};\n\
-    reason: {1}
-
-# 0: list of type, 1: message segment
-compiler.err.invalid.inferred.types=\
-    invalid inferred types for {0}; {1}
-
 # 0: message segment, 1: unused
 compiler.err.cant.apply.diamond=\
     cannot infer type arguments for {0}
 
-# 0: message segment, 1: message segment
+# 0: message segment or type, 1: message segment
 compiler.err.cant.apply.diamond.1=\
-    cannot infer type arguments for {0};\n\
+    cannot infer type arguments for {0}\n\
+    reason: {1}
+
+# 0: message segment or type, 1: message segment
+compiler.misc.cant.apply.diamond.1=\
+    cannot infer type arguments for {0}\n\
     reason: {1}
 
 compiler.err.unreachable.stmt=\
@@ -858,7 +1084,7 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\
 compiler.misc.varargs.trustme.on.virtual.varargs=\
     Instance method {0} is not final.
 
-# 0: type, 1: kind, 2: symbol
+# 0: type, 1: symbol kind, 2: symbol
 compiler.misc.inaccessible.varargs.type=\
     formal varargs element type {0} is not accessible from {1} {2}
 
@@ -899,8 +1125,8 @@ compiler.misc.fatal.err.cant.locate.field=\
 compiler.misc.fatal.err.cant.locate.ctor=\
     Fatal Error: Unable to find constructor for {0}
 
-compiler.misc.fatal.err.cant.close.loader=\
-    Fatal Error: Cannot close class loader for annotation processors
+compiler.misc.fatal.err.cant.close=\
+    Fatal Error: Cannot close compiler resources
 
 #####
 
@@ -926,6 +1152,30 @@ compiler.misc.x.print.rounds=\
 
 ## 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.
+
+# 0: boolean, 1: symbol
+compiler.note.lambda.stat=\
+    Translating lambda expression\n\
+    alternate metafactory = {0}\n\
+    synthetic method = {1}
+
+# 0: boolean, 1: unused
+compiler.note.mref.stat=\
+    Translating method reference\n\
+    alternate metafactory = {0}\n\
+
+# 0: boolean, 1: symbol
+compiler.note.mref.stat.1=\
+    Translating method reference\n\
+    alternate metafactory = {0}\n\
+    bridge method = {1}
+
 compiler.note.note=\
     Note:\u0020
 
@@ -1463,6 +1713,9 @@ compiler.misc.bad.const.pool.tag.at=\
 compiler.misc.bad.signature=\
     bad signature: {0}
 
+compiler.misc.bad.type.annotation.value=\
+    bad type annotation target type value: {0}
+
 compiler.misc.class.file.wrong.class=\
     class file contains wrong class: {0}
 
@@ -1504,11 +1757,13 @@ compiler.err.not.within.bounds=\
 
 #####
 
-# 0: message segment, 1: type, 2: type
+# 0: message segment
 compiler.err.prob.found.req=\
-    {0}\n\
-    required: {2}\n\
-    found:    {1}
+    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=\
@@ -1516,25 +1771,13 @@ compiler.warn.prob.found.req=\
     required: {2}\n\
     found:    {1}
 
-compiler.err.prob.found.req.1=\
-    {0} {3}\n\
-    required: {2}\n\
-    found:    {1}
-
-## The following are all possible strings for the first argument ({0}) of the
-## above strings.
-compiler.misc.incompatible.types=\
-    incompatible types
-
-# 0: message segment
-compiler.misc.incompatible.types.1=\
-    incompatible types; {0}
-
+# 0: type, 1: type
 compiler.misc.inconvertible.types=\
-    inconvertible types
+    {0} cannot be converted to {1}
 
+# 0: type, 1: type
 compiler.misc.possible.loss.of.precision=\
-    possible loss of precision
+    possible lossy conversion from {0} to {1}
 
 compiler.misc.unchecked.assign=\
     unchecked conversion
@@ -1546,19 +1789,15 @@ compiler.misc.unchecked.assign=\
 compiler.misc.unchecked.cast.to.type=\
     unchecked cast
 
-compiler.misc.assignment.from.super-bound=\
-    assignment from super-bound type {0}
-
-compiler.misc.assignment.to.extends-bound=\
-    assignment to extends-bound type {0}
-
 # compiler.err.star.expected=\
 #     ''*'' expected
 # compiler.err.no.elem.type=\
 #     \[\*\] cannot have a type
 
+# 0: type
 compiler.misc.try.not.applicable.to.type=\
-    try-with-resources not applicable to variable type
+    try-with-resources not applicable to variable type\n\
+    ({0})
 
 #####
 
@@ -1593,11 +1832,6 @@ compiler.misc.type.parameter=\
 
 ## The following are all possible strings for the last argument of all those
 ## diagnostics whose key ends in ".1"
-compiler.misc.undetermined.type=\
-    undetermined type
-
-compiler.misc.type.variable.has.undetermined.type=\
-    type variable {0} has undetermined type
 
 # 0: type, 1: list of type
 compiler.misc.no.unique.maximal.instance.exists=\
@@ -1610,22 +1844,58 @@ compiler.misc.no.unique.minimal.instance.exists=\
 compiler.misc.incompatible.upper.bounds=\
     inference variable {0} has incompatible upper bounds {1}
 
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.upper.bounds=\
+    inference variable {0} has incompatible bounds\n\
+    equality constraints: {1}\n\
+    upper bounds: {2}
+
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.lower.bounds=\
+    inference variable {0} has incompatible bounds\n\
+    equality constraints: {1}\n\
+    lower bounds: {2}
+
 # 0: list of type, 1: type, 2: type
 compiler.misc.infer.no.conforming.instance.exists=\
     no instance(s) of type variable(s) {0} exist so that {1} conforms to {2}
 
-# 0: list of type, 1: type, 2: type
+# 0: list of type, 1: message segment
 compiler.misc.infer.no.conforming.assignment.exists=\
-    no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to formal parameter type {2}
+    cannot infer type-variable(s) {0}\n\
+    (argument mismatch; {1})
 
+# 0: list of type
 compiler.misc.infer.arg.length.mismatch=\
-    cannot instantiate from arguments because actual and formal argument lists differ in length
+    cannot infer type-variable(s) {0}\n\
+    (actual and formal argument lists differ in length)
+
+# 0: list of type, 1: message segment
+compiler.misc.infer.varargs.argument.mismatch=\
+    cannot infer type-variable(s) {0}\n\
+    (varargs mismatch; {1})
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.upper.bounds=\
+    inferred type does not conform to upper bound(s)\n\
+    inferred: {0}\n\
+    upper bound(s): {1}
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.lower.bounds=\
+    inferred type does not conform to lower bound(s)\n\
+    inferred: {0}\n\
+    lower bound(s): {1}
 
 # 0: type, 1: list of type
-compiler.misc.inferred.do.not.conform.to.bounds=\
-    inferred type does not conform to declared bound(s)\n\
+compiler.misc.inferred.do.not.conform.to.eq.bounds=\
+    inferred type does not conform to equality constraint(s)\n\
     inferred: {0}\n\
-    bound(s): {1}
+    equality constraints(s): {1}
+
+# 0: list of type
+compiler.misc.cyclic.inference=\
+    Cannot instantiate inference variables {0} because of an inference loop
 
 # 0: symbol
 compiler.misc.diamond=\
@@ -1635,6 +1905,7 @@ compiler.misc.diamond=\
 compiler.misc.diamond.non.generic=\
     cannot use ''<>'' with non-generic class {0}
 
+# 0: unused
 compiler.misc.diamond.and.explicit.params=\
     cannot use ''<>'' with explicit type parameters for constructor
 
@@ -1645,16 +1916,20 @@ compiler.misc.explicit.param.do.not.conform.to.bounds=\
 compiler.misc.arg.length.mismatch=\
     actual and formal argument lists differ in length
 
-# 0: type, 1: type
+# 0: message segment
 compiler.misc.no.conforming.assignment.exists=\
-    actual argument {0} cannot be converted to {1} by method invocation conversion
+    argument mismatch; {0}
 
-# 0: type, 1: type
+# 0: message segment
 compiler.misc.varargs.argument.mismatch=\
-    argument type {0} does not conform to vararg element type {1}
+    varargs mismatch; {0}
 
 #####
 
+# 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=\
@@ -1665,6 +1940,14 @@ compiler.err.abstract.cant.be.accessed.directly=\
 compiler.err.non-static.cant.be.ref=\
     non-static {0} {1} cannot be referenced from a static context
 
+# 0: symbol kind, 1: symbol
+compiler.misc.non-static.cant.be.ref=\
+    non-static {0} {1} cannot be referenced from a static context
+
+# 0: symbol kind, 1: symbol
+compiler.misc.static.method.in.unbound.lookup=\
+    static {0} {1} found in unbound lookup
+
 ## Both arguments ({0}, {1}) are "kindname"s.  {0} is a comma-separated list
 ## of kindnames (the list should be identical to that provided in source.
 compiler.err.unexpected.type=\
@@ -1672,6 +1955,12 @@ compiler.err.unexpected.type=\
     required: {0}\n\
     found:    {1}
 
+compiler.err.unexpected.lambda=\
+   lambda expression not expected here
+
+compiler.err.unexpected.mref=\
+   method reference not expected here
+
 ## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
 ## The second argument {1} is the non-resolved symbol
 ## The third argument {2} is a list of type parameters (non-empty if {1} is a method)
@@ -1711,12 +2000,26 @@ compiler.err.cant.resolve.location.args.params=\
     symbol:   {0} <{2}>{1}({3})\n\
     location: {4}
 
+### Following are replicated/used for method reference diagnostics
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
+compiler.misc.cant.resolve.location.args=\
+    cannot find symbol\n\
+    symbol:   {0} {1}({3})\n\
+    location: {4}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
+compiler.misc.cant.resolve.location.args.params=\
+    cannot find symbol\n\
+    symbol:   {0} <{2}>{1}({3})\n\
+    location: {4}
+
 ##a location subdiagnostic is composed as follows:
 ## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.)
 ## The second argument {1} is the location name
 ## The third argument {2} is the location type (only when {1} is a variable name)
 
-# 0: symbol kind, 1: symbol, 2: unused
+# 0: symbol kind, 1: type or symbol, 2: unused
 compiler.misc.location=\
     {0} {1}
 
@@ -1773,6 +2076,7 @@ compiler.misc.kindname.instance.init=\
 
 compiler.misc.kindname.error=\
     erroneous
+
 #####
 
 compiler.misc.no.args=\
@@ -1815,6 +2119,10 @@ compiler.warn.override.unchecked.thrown=\
     {0}\n\
     overridden method does not throw {1}
 
+# 0: symbol
+compiler.warn.override.equals.but.not.hashcode=\
+    Class {0} overrides equals, but neither it nor any superclass overrides hashCode method
+
 ## The following are all possible strings for the first argument ({0}) of the
 ## above strings.
 # 0: symbol, 1: symbol, 2: symbol, 3: symbol
@@ -1853,6 +2161,7 @@ compiler.misc.varargs.implement=\
 compiler.misc.varargs.clash.with=\
     {0} in {1} overrides {2} in {3}
 
+# 0: unused
 compiler.misc.diamond.and.anon.class=\
     cannot use ''<>'' with anonymous inner classes
 
@@ -1892,6 +2201,10 @@ compiler.warn.assert.as.identifier=\
     as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\
     (use -source 1.4 or higher to use ''assert'' as a keyword)
 
+compiler.warn.underscore.as.identifier=\
+    ''_'' used as an identifier\n\
+    (use of ''_'' as an identifier might not be supported in releases after Java SE 8)
+
 compiler.err.enum.as.identifier=\
     as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
     (use -source 1.4 or lower to use ''enum'' as an identifier)
@@ -1900,6 +2213,50 @@ compiler.err.assert.as.identifier=\
     as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\
     (use -source 1.3 or lower to use ''assert'' as an identifier)
 
+# TODO 308: make a better error message
+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\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
+
 # 0: string
 compiler.err.generics.not.supported.in.source=\
     generics are not supported in -source {0}\n\
@@ -1915,9 +2272,10 @@ compiler.err.annotations.not.supported.in.source=\
     annotations are not supported in -source {0}\n\
     (use -source 5 or higher to enable annotations)
 
-#308 compiler.err.type.annotations.not.supported.in.source=\
-#308     type annotations are not supported in -source {0}\n\
-#308 (use -source 7 or higher to enable type annotations)
+# 0: string
+compiler.err.type.annotations.not.supported.in.source=\
+    type annotations are not supported in -source {0}\n\
+(use -source 8 or higher to enable type annotations)
 
 # 0: string
 compiler.err.foreach.not.supported.in.source=\
@@ -1949,6 +2307,76 @@ compiler.err.string.switch.not.supported.in.source=\
     strings in switch are not supported in -source {0}\n\
     (use -source 7 or higher to enable strings in switch)
 
+# 0: string
+compiler.err.lambda.not.supported.in.source=\
+    lambda expressions are not supported in -source {0}\n\
+    (use -source 8 or higher to enable lambda expressions)
+
+# 0: string
+compiler.err.method.references.not.supported.in.source=\
+    method references are not supported in -source {0}\n\
+    (use -source 8 or higher to enable method references)
+
+# 0: string
+compiler.err.default.methods.not.supported.in.source=\
+    default methods are not supported in -source {0}\n\
+    (use -source 8 or higher to enable default methods)
+
+# 0: string
+compiler.err.intersection.types.in.cast.not.supported.in.source=\
+    intersection types in cast are not supported in -source {0}\n\
+    (use -source 8 or higher to enable default methods)
+
+# 0: string
+compiler.err.static.intf.methods.not.supported.in.source=\
+    static interface methods are not supported in -source {0}\n\
+    (use -source 8 or higher to enable static interface methods)
+
+########################################
+# Diagnostics for verbose resolution
+# used by Resolve (debug only)
+########################################
+
+# 0: number, 1: symbol, 2: unused
+compiler.misc.applicable.method.found=\
+    #{0} applicable method found: {1}
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.applicable.method.found.1=\
+    #{0} applicable method found: {1}\n\
+    ({2})
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.not.applicable.method.found=\
+    #{0} not applicable method found: {1}\n\
+    ({2})
+
+# 0: type
+compiler.misc.partial.inst.sig=\
+    partially instantiated to: {0}
+
+# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi=\
+    resolving method {0} in type {1} to candidate {2}\n\
+    phase: {3}\n\
+    with actuals: {4}\n\
+    with type-args: {5}\n\
+    candidates:
+
+# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi.1=\
+    erroneous resolution for method {0} in type {1}\n\
+    phase: {3}\n\
+    with actuals: {4}\n\
+    with type-args: {5}\n\
+    candidates:
+
+# 0: symbol, 1: type, 2: type
+compiler.note.deferred.method.inst=\
+    Deferred instantiation of method {0}\n\
+    instantiated signature: {1}\n\
+    target-type: {2}
+
 ########################################
 # Diagnostics for where clause implementation
 # used by the RichDiagnosticFormatter.
@@ -1992,9 +2420,16 @@ compiler.misc.where.typevar=\
 
 # compact where clause for type variable: contains the kindname ({2}) and location ({3})
 # in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
 compiler.misc.where.typevar.1=\
     {0} declared in {2} {3}
 
+# where clause for fresh type variable: contains upper bound(s) ('extends {1}').
+# Since a fresh type-variable is synthetic - there's no location/kindname here.
+# 0: type, 1: list of type
+compiler.misc.where.fresh.typevar=\
+    {0} extends {1}
+
 # where clause for type variable: contains all the upper bound(s) ('extends {1}')
 # of this intersection type
 # 0: type, 1: list of type
@@ -2024,6 +2459,57 @@ compiler.misc.where.description.typevar.1=\
 compiler.misc.where.description.intersection.1=\
     where {0} are intersection types:
 
+###
+# errors related to doc comments
+
+compiler.err.dc.bad.entity=\
+    bad HTML entity
+
+compiler.err.dc.bad.gt=\
+    bad use of ''>''
+
+compiler.err.dc.bad.inline.tag=\
+    incorrect use of inline tag
+
+compiler.err.dc.identifier.expected=\
+    identifier expected
+
+compiler.err.dc.malformed.html=\
+    malformed HTML
+
+compiler.err.dc.missing.semicolon=\
+    semicolon missing
+
+compiler.err.dc.no.content=\
+    no content
+
+compiler.err.dc.no.tag.name=\
+    no tag name after '@'
+
+compiler.err.dc.gt.expected=\
+    ''>'' expected
+
+compiler.err.dc.ref.bad.parens=\
+    '')'' missing in reference
+
+compiler.err.dc.ref.syntax.error=\
+    syntax error in reference
+
+compiler.err.dc.ref.unexpected.input=\
+    unexpected text
+
+compiler.err.dc.unexpected.content=\
+    unexpected content
+
+compiler.err.dc.unterminated.inline.tag=\
+    unterminated inline tag
+
+compiler.err.dc.unterminated.signature=\
+    unterminated signature
+
+compiler.err.dc.unterminated.string=\
+    unterminated string
+
 compiler.javadoc.enum.valueOf=\
     Returns the enum constant of this type with the specified name.\n\
 The string must match exactly an identifier used to declare\n\
diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties
new file mode 100644
index 0000000..bff4e9a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler_ja.properties
@@ -0,0 +1,1758 @@
+#
+# 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
+# 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.
+#
+
+# Messages in this file which use "placeholders" for values (e.g. {0}, {1})
+# are preceded by a stylized comment describing the type of the corresponding
+# values.
+# The types currently in use are
+#
+# boolean           true or false
+# file name         the name of an input file; e.g.   MyFile.java
+# message segment   a sub-message; see compiler.misc.*
+# modifier          a Java modifier; e.g. public, private, protected
+# name              a name, typically a Java identifier
+# number            an integer
+# option name       the name of a command line option
+# source version    a source version number, such as 1.5, 1.6, 1.7
+# string            a general string
+# symbol            the name of a declared type
+# symbol kind       a description of the kind of a declaration; see compiler.misc.kindname.*
+# token             the name of a non-terminal in source code; see compiler.misc.token.*
+# type              a Java type; e.g. int, X, X<T>
+# unused            the value is not used in this message
+#
+# list of X         a comma-separated list of items; e.g. list of type
+# X or Y            alternation; e.g. message segment or type
+# set of X          a comma-separated collection of items; e.g. set of modifier
+#
+# These may be composed: e.g.   list of type or message segment
+#
+# These comments are verified by the jtreg test test/tools/javac/diags/MessageInfo,
+# using info derived from the collected set of examples in test/tools/javac/diags/examples.
+# MessageInfo can also be run as a standalone utility providing more facilities
+# for manipulating this file. For more details, see MessageInfo.java.
+
+##
+## errors
+##
+
+# 0: symbol
+compiler.err.abstract.cant.be.instantiated={0}\u306Fabstract\u3067\u3059\u3002\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u751F\u6210\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.abstract.meth.cant.have.body=abstract\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.already.annotated={0} {1}\u306F\u6CE8\u91C8\u304C\u4ED8\u3044\u3066\u3044\u307E\u3059
+
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol
+compiler.err.already.defined={0} {1}\u306F\u3059\u3067\u306B{2} {3}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol kind, 4: symbol
+compiler.err.already.defined.in.clinit={0} {1}\u306F\u3059\u3067\u306B{3} {4}\u306E{2}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: string
+compiler.err.already.defined.single.import={0}\u306F\u5358\u4E00\u306E\u578B\u30A4\u30F3\u30DD\u30FC\u30C8\u5BA3\u8A00\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: string
+compiler.err.already.defined.static.single.import={0}\u306Fstatic\u306E\u5358\u4E00\u306E\u578B\u30A4\u30F3\u30DD\u30FC\u30C8\u5BA3\u8A00\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.already.defined.this.unit={0}\u306F\u30B3\u30F3\u30D1\u30A4\u30EB\u5358\u4F4D\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: type, 1: list of name
+compiler.err.annotation.missing.default.value=\u6CE8\u91C8{0}\u306B\u306F\u5C5E\u6027{1}\u306E\u5024\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: type, 1: list of name
+compiler.err.annotation.missing.default.value.1=\u6CE8\u91C8{0}\u306B\u306F\u5C5E\u6027{1}\u306E\u5024\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: type
+compiler.err.annotation.not.valid.for.type=\u6CE8\u91C8\u306F\u578B{0}\u306E\u5024\u306B\u6709\u52B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.annotation.type.not.applicable=\u6CE8\u91C8\u578B\u306F\u3053\u306E\u7A2E\u985E\u306E\u5BA3\u8A00\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.annotation.value.must.be.annotation=\u6CE8\u91C8\u306E\u5024\u306F\u6CE8\u91C8\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.annotation.value.must.be.class.literal=\u6CE8\u91C8\u306E\u5024\u306F\u30AF\u30E9\u30B9\u30FB\u30EA\u30C6\u30E9\u30EB\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.annotation.value.must.be.name.value=\u6CE8\u91C8\u306E\u5024\u306F''name=value''\u3068\u3044\u3046\u5F62\u5F0F\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.annotation.value.not.allowable.type=\u4F7F\u7528\u3067\u304D\u306A\u3044\u578B\u306E\u6CE8\u91C8\u306E\u5024\u3067\u3059
+
+compiler.err.anon.class.impl.intf.no.args=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.anon.class.impl.intf.no.typeargs=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002\u578B\u5F15\u6570\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.anon.class.impl.intf.no.qual.for.new=\u540D\u524D\u306E\u306A\u3044\u30AF\u30E9\u30B9\u304C\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u3059\u3002new\u306B\u4FEE\u98FE\u5B50\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002
+
+# 0: symbol, 1: symbol, 2: symbol
+compiler.err.array.and.varargs={2}\u3067{0}\u3068{1}\u306E\u4E21\u65B9\u3092\u5BA3\u8A00\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.array.dimension.missing=\u914D\u5217\u306E\u5927\u304D\u3055\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: type
+compiler.err.array.req.but.found=\u914D\u5217\u304C\u8981\u6C42\u3055\u308C\u307E\u3057\u305F\u304C\u3001{0}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+
+compiler.err.attribute.value.must.be.constant=\u5C5E\u6027\u306E\u5024\u306F\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: statement type
+compiler.err.bad.initializer={0}\u306E\u4E0D\u6B63\u306A\u521D\u671F\u5316\u5B50
+
+compiler.err.break.outside.switch.loop=break\u304Cswitch\u6587\u307E\u305F\u306F\u30EB\u30FC\u30D7\u306E\u5916\u306B\u3042\u308A\u307E\u3059
+
+# 0: name
+compiler.err.call.must.be.first.stmt.in.ctor={0}\u306E\u547C\u51FA\u3057\u306F\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u5148\u982D\u6587\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
+compiler.err.cant.apply.symbol={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\u3002\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}\n\u7406\u7531: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
+compiler.err.cant.apply.symbols={1}\u306B\u9069\u5207\u306A{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093({2})
+
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
+compiler.misc.cant.apply.symbol={4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}\n\u7406\u7531: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
+compiler.misc.cant.apply.symbols={1}\u306B\u9069\u5207\u306A{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093({2})
+
+# 0: symbol kind, 1: symbol
+compiler.misc.no.abstracts={0} {1}\u3067\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.abstracts={0} {1}\u3067\u8907\u6570\u306E\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u306A\u3044\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+
+compiler.err.bad.functional.intf.anno=\u4E88\u671F\u3057\u306A\u3044 at FunctionalInterface\u6CE8\u91C8
+
+# 0: message segment
+compiler.err.bad.functional.intf.anno.1=\u4E88\u671F\u3057\u306A\u3044 at FunctionalInterface\u6CE8\u91C8\n{0}
+
+# 0: symbol
+compiler.misc.not.a.functional.intf={0}\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol, 1: message segment
+compiler.misc.not.a.functional.intf.1={0}\u306F\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\n{1}
+
+# 0: symbol, 1: symbol kind, 2: symbol
+compiler.misc.invalid.generic.lambda.target=\u30E9\u30E0\u30C0\u5F0F\u306E\u6A5F\u80FD\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u7121\u52B9\u3067\u3059\n{1} {2}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306F\u6C4E\u7528\u3067\u3059
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.descs.in.functional.intf={0} {1}\u3067\u4E0D\u9069\u5408\u306A\u6A5F\u80FD\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor=\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF: {2} {0}({1})
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor.throws=\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF: {2} {0}({1})\u3067{3}\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3059
+
+# 0: type
+compiler.misc.no.suitable.functional.intf.inst={0}\u306E\u6A5F\u80FD\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30C7\u30A3\u30B9\u30AF\u30EA\u30D7\u30BF\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093
+
+# 0: message segment
+compiler.misc.bad.intersection.target.for.functional.expr=\u30E9\u30E0\u30C0\u307E\u305F\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u4EA4\u5DEE\u30BF\u30A4\u30D7\u30FB\u30BF\u30FC\u30B2\u30C3\u30C8\u304C\u4E0D\u6B63\u3067\u3059\n{0}
+
+# 0: symbol or type
+compiler.misc.not.an.intf.component=\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u30FB\u30BF\u30A4\u30D7{0}\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol kind, 1: message segment
+compiler.err.invalid.mref={0}\u53C2\u7167\u304C\u7121\u52B9\u3067\u3059\n{1}
+
+# 0: symbol kind, 1: message segment
+compiler.misc.invalid.mref={0}\u53C2\u7167\u304C\u7121\u52B9\u3067\u3059\n{1}
+
+compiler.misc.static.mref.with.targs=static\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u5316\u3055\u308C\u305F\u4FEE\u98FE\u5B50
+
+compiler.misc.static.bound.mref=static\u306E\u30D0\u30A4\u30F3\u30C7\u30A3\u30F3\u30B0\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167
+
+# 0: symbol
+compiler.err.cant.assign.val.to.final.var=final\u5909\u6570{0}\u306B\u5024\u3092\u4EE3\u5165\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: message segment
+compiler.err.cant.ref.non.effectively.final.var={1}\u304B\u3089\u53C2\u7167\u3055\u308C\u308B\u30ED\u30FC\u30AB\u30EB\u5909\u6570\u306F\u3001final\u307E\u305F\u306F\u4E8B\u5B9F\u4E0A\u306Efinal\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+
+compiler.misc.lambda=\u30E9\u30E0\u30C0\u5F0F
+
+compiler.misc.inner.cls=\u5185\u90E8\u30AF\u30E9\u30B9
+
+# 0: type
+compiler.err.cant.deref={0}\u306F\u9593\u63A5\u53C2\u7167\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.cant.extend.intf.annotation=@interfaces\u3067\u306F''extends''\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.cant.inherit.from.final=final {0}\u304B\u3089\u306F\u7D99\u627F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.cant.ref.before.ctor.called=\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u547C\u51FA\u3057\u524D\u306F{0}\u3092\u53C2\u7167\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.cant.select.static.class.from.param.type=\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3055\u308C\u305F\u578B\u304B\u3089static\u30AF\u30E9\u30B9\u3092\u9078\u629E\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: string, 2: string
+compiler.err.cant.inherit.diff.arg={0}\u3092\u7570\u306A\u308B\u5F15\u6570<{1}>\u3068<{2}>\u3067\u7D99\u627F\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.catch.without.try=''catch''\u3078\u306E''try''\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol kind, 1: symbol
+compiler.err.clash.with.pkg.of.same.name={0} {1}\u306F\u540C\u540D\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u3068\u7AF6\u5408\u3057\u307E\u3059
+
+compiler.err.class.not.allowed=\u30AF\u30E9\u30B9\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u307E\u305F\u306F\u5217\u6319\u578B\u306E\u5BA3\u8A00\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.const.expr.req=\u5B9A\u6570\u5F0F\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.cont.outside.loop=continue\u304C\u30EB\u30FC\u30D7\u306E\u5916\u306B\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.err.cyclic.inheritance={0}\u3092\u542B\u3080\u7D99\u627F\u304C\u30EB\u30FC\u30D7\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.cyclic.annotation.element=\u6CE8\u91C8\u306E\u8981\u7D20\u30BF\u30A4\u30D7\u304C\u30EB\u30FC\u30D7\u3057\u3066\u3044\u307E\u3059
+
+# 0: unused
+compiler.err.call.to.super.not.allowed.in.enum.ctor=\u5217\u6319\u578B\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u3067\u306F\u3001\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u306E\u547C\u51FA\u3057\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: type
+compiler.err.no.superclass={0}\u306B\u306F\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol, 1: type, 2: symbol, 3: type, 4: unused
+compiler.err.concrete.inheritance.conflict={1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u3068{3}\u306E{2}\u306F\u540C\u3058\u30B7\u30B0\u30CD\u30C1\u30E3\u304B\u3089\u7D99\u627F\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.default.allowed.in.intf.annotation.member=\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u306F at interface\u30E1\u30F3\u30D0\u30FC\u5185\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059
+
+# 0: symbol
+compiler.err.doesnt.exist=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F\u5B58\u5728\u3057\u307E\u305B\u3093
+
+compiler.err.duplicate.annotation=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059
+
+# 0: type
+compiler.err.duplicate.annotation.invalid.repeated=\u6CE8\u91C8{0}\u3092\u7E70\u308A\u8FD4\u305B\u307E\u305B\u3093\n\u6709\u52B9\u306A\u5305\u542B\u3059\u308B\u6CE8\u91C8\u304C\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
+
+# 0: name, 1: type
+compiler.err.duplicate.annotation.member.value={1}\u306E\u6CE8\u91C8\u30E1\u30F3\u30D0\u30FC\u306E\u5024{0}\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059
+
+# 0: type, 1: type
+compiler.err.duplicate.annotation.missing.container=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: {0}\u306E\u5BA3\u8A00\u306B\u306F\u6709\u52B9\u306A{1}\u6CE8\u91C8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: type
+compiler.err.invalid.repeatable.annotation=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: {0}\u306F\u7121\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u6CE8\u91C8\u3067\u6CE8\u91C8\u4ED8\u3051\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol or type
+compiler.err.invalid.repeatable.annotation.no.value=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: {0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u5024\u8981\u7D20\u30E1\u30BD\u30C3\u30C9\u304C\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: type, 1: number
+compiler.err.invalid.repeatable.annotation.multiple.values=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: {0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002{1}\u5024\u8981\u7D20\u30E1\u30BD\u30C3\u30C9\u304C\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: type
+compiler.err.invalid.repeatable.annotation.invalid.value=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: {0}\u306F\u6709\u52B9\u306A\u7E70\u8FD4\u3057\u53EF\u80FD\u306A\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093: \u5024\u8981\u7D20\u304C\u7121\u52B9\u3067\u3059
+
+# 0: symbol type, 1: type, 2: type
+compiler.err.invalid.repeatable.annotation.value.return=\u6CE8\u91C8\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059: \u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306E\u5024\u8981\u7D20\u306B\u306F\u578B{2}\u3092\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002{1}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+
+# 0: symbol or type, 1: symbol
+compiler.err.invalid.repeatable.annotation.elem.nondefault=\u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306B\u306F\u8981\u7D20{1}\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: symbol, 1: type, 2: symbol, 3: type
+compiler.err.invalid.repeatable.annotation.retention=\u5305\u542B\u3059\u308B\u6CE8\u91C8{0}\u306B\u306F\u3001\u4FDD\u6709{3}\u3092\u542B\u3080\u5305\u542B\u3055\u308C\u305F\u6CE8\u91C8{2}\u3088\u308A\u77ED\u3044\u4FDD\u6709({1})\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.documented=\u7E70\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8{1}\u306F at Documented\u3067\u3059\u304C\u3001\u5305\u542B\u3059\u308B\u6CE8\u91C8\u30BF\u30A4\u30D7{0}\u306F\u9055\u3044\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.inherited=\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8\u30BF\u30A4\u30D7{1}\u306F at Inherited\u3067\u3059\u304C\u3001\u5305\u542B\u3059\u308B\u6CE8\u91C8\u30BF\u30A4\u30D7{0}\u306F\u9055\u3044\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.incompatible.target=\u30B3\u30F3\u30C6\u30CA\u6CE8\u91C8{0}\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u306F\u3001\u7E70\u308A\u8FD4\u3055\u308C\u305F\u6CE8\u91C8{1}\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u306E\u30B5\u30D6\u30BB\u30C3\u30C8\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002
+
+# 0: symbol
+compiler.err.invalid.repeatable.annotation.repeated.and.container.present=\u30B3\u30F3\u30C6\u30CA{0}\u306F\u542B\u307E\u308C\u3066\u3044\u308B\u8981\u7D20\u3068\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093
+
+# 0: name
+compiler.err.duplicate.class=\u30AF\u30E9\u30B9{0}\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.duplicate.case.label=case\u30E9\u30D9\u30EB\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.duplicate.default.label=default\u30E9\u30D9\u30EB\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.else.without.if=''else''\u3078\u306E''if''\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.empty.char.lit=\u7A7A\u306E\u6587\u5B57\u30EA\u30C6\u30E9\u30EB\u3067\u3059
+
+# 0: symbol
+compiler.err.encl.class.required={0}\u3092\u542B\u3080\u56F2\u3046\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.enum.annotation.must.be.enum.constant=\u5217\u6319\u578B\u6CE8\u91C8\u5024\u306F\u3001\u5217\u6319\u578B\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.enum.cant.be.instantiated=\u5217\u6319\u578B\u306F\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.enum.label.must.be.unqualified.enum=\u5217\u6319\u578B\u306Eswitch case\u30E9\u30D9\u30EB\u306F\u5217\u6319\u578B\u5B9A\u6570\u306E\u975E\u4FEE\u98FE\u540D\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.enum.no.subclassing=\u30AF\u30E9\u30B9\u306F\u76F4\u63A5java.lang.Enum\u3092\u62E1\u5F35\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.enum.types.not.extensible=\u5217\u6319\u578B\u306F\u62E1\u5F35\u53EF\u80FD\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.enum.no.finalize=\u5217\u6319\u578B\u306Ffinalize\u30E1\u30BD\u30C3\u30C9\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: file name, 1: string
+compiler.err.error.reading.file={0}\u306E\u8AAD\u8FBC\u307F\u30A8\u30E9\u30FC\u3067\u3059\u3002{1}
+
+# 0: type
+compiler.err.except.already.caught=\u4F8B\u5916{0}\u306F\u3059\u3067\u306B\u6355\u6349\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: type
+compiler.err.except.never.thrown.in.try=\u4F8B\u5916{0}\u306F\u5BFE\u5FDC\u3059\u308Btry\u6587\u306E\u672C\u4F53\u3067\u306F\u30B9\u30ED\u30FC\u3055\u308C\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.final.parameter.may.not.be.assigned=final\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u306B\u5024\u3092\u4EE3\u5165\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.try.resource.may.not.be.assigned=\u81EA\u52D5\u30AF\u30ED\u30FC\u30BA\u53EF\u80FD\u306A\u30EA\u30BD\u30FC\u30B9{0}\u306B\u5024\u3092\u4EE3\u5165\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.multicatch.parameter.may.not.be.assigned=\u8907\u6570catch\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u306B\u5024\u3092\u4EE3\u5165\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: type, 1: type
+compiler.err.multicatch.types.must.be.disjoint=\u8907\u6570catch\u6587\u306E\u4EE3\u66FF\u3092\u30B5\u30D6\u30AF\u30E9\u30B9\u5316\u306B\u3088\u3063\u3066\u95A2\u9023\u4ED8\u3051\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n\u4EE3\u66FF{0}\u306F\u4EE3\u66FF{1}\u306E\u30B5\u30D6\u30AF\u30E9\u30B9\u3067\u3059
+
+compiler.err.finally.without.try=''finally''\u3078\u306E''try''\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: type, 1: message segment
+compiler.err.foreach.not.applicable.to.type=for-each\u306F\u5F0F\u306E\u30BF\u30A4\u30D7\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\n\u671F\u5F85\u5024: {1}\n\u691C\u51FA\u5024: {0}
+
+compiler.err.fp.number.too.large=\u6D6E\u52D5\u5C0F\u6570\u70B9\u6570\u304C\u5927\u304D\u3059\u304E\u307E\u3059
+
+compiler.err.fp.number.too.small=\u6D6E\u52D5\u5C0F\u6570\u70B9\u6570\u304C\u5C0F\u3055\u3059\u304E\u307E\u3059
+
+compiler.err.generic.array.creation=\u6C4E\u7528\u914D\u5217\u3092\u4F5C\u6210\u3057\u307E\u3059
+
+compiler.err.generic.throwable=\u6C4E\u7528\u30AF\u30E9\u30B9\u306Fjava.lang.Throwable\u3092\u62E1\u5F35\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u30AF\u30E9\u30B9{0}\u306E\u9759\u7684\u5BA3\u8A00\u304C\u4E0D\u6B63\u3067\u3059\n\u4FEE\u98FE\u5B50''static''\u306F\u5B9A\u6570\u304A\u3088\u3073\u5909\u6570\u306E\u5BA3\u8A00\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059
+
+# 0: string
+compiler.err.illegal.char=''{0}''\u306F\u4E0D\u6B63\u306A\u6587\u5B57\u3067\u3059
+
+compiler.err.illegal.char.for.encoding=\u3053\u306E\u6587\u5B57\u306F\u3001\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306B\u30DE\u30C3\u30D7\u3067\u304D\u307E\u305B\u3093
+
+# 0: set of modifier, 1: set of modifier
+compiler.err.illegal.combination.of.modifiers=\u4FEE\u98FE\u5B50{0}\u3068{1}\u306E\u7D44\u5408\u305B\u306F\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.enum.static.ref=\u521D\u671F\u5316\u5B50\u304B\u3089static\u30D5\u30A3\u30FC\u30EB\u30C9\u3078\u306E\u53C2\u7167\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.esc.char=\u30A8\u30B9\u30B1\u30FC\u30D7\u6587\u5B57\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.forward.ref=\u524D\u65B9\u53C2\u7167\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: symbol, 1: string
+compiler.err.not.in.profile={0}\u306F\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB''{1}''\u3067\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.warn.forward.ref=\u521D\u671F\u5316\u3055\u308C\u308B\u524D\u306E\u5909\u6570''{0}''\u3092\u53C2\u7167\u3057\u3088\u3046\u3068\u3057\u307E\u3057\u305F
+
+compiler.err.illegal.self.ref=\u521D\u671F\u5316\u5B50\u5185\u306E\u81EA\u5DF1\u53C2\u7167
+
+# 0: symbol
+compiler.warn.self.ref=\u521D\u671F\u5316\u5B50\u5185\u306E\u5909\u6570''{0}''\u306E\u81EA\u5DF1\u53C2\u7167
+
+compiler.err.illegal.generic.type.for.instof=instanceof\u306E\u7DCF\u79F0\u578B\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: type
+compiler.err.illegal.initializer.for.type={0}\u306E\u521D\u671F\u5316\u5B50\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.line.end.in.char.lit=\u6587\u5B57\u30EA\u30C6\u30E9\u30EB\u306E\u884C\u672B\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.nonascii.digit=\u4E0D\u6B63\u306A\u975EASCII\u6570\u5B57\u3067\u3059
+
+compiler.err.illegal.underscore=\u4E0D\u6B63\u306A\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u3067\u3059
+
+compiler.err.illegal.dot=\u4E0D\u6B63\u306A''.''\u3067\u3059
+
+# 0: symbol
+compiler.err.illegal.qual.not.icls=\u4FEE\u98FE\u5B50\u304C\u4E0D\u6B63\u3067\u3059\u3002{0}\u306F\u5185\u90E8\u30AF\u30E9\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.illegal.start.of.expr=\u5F0F\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.start.of.stmt=\u6587\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.start.of.type=\u578B\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.illegal.unicode.esc=Unicode\u30A8\u30B9\u30B1\u30FC\u30D7\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: symbol
+compiler.err.import.requires.canonical=\u30A4\u30F3\u30DD\u30FC\u30C8\u306B\u306F{0}\u306E\u6A19\u6E96\u540D\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.improperly.formed.type.param.missing=\u578B\u306E\u5F62\u5F0F\u304C\u4E0D\u9069\u5207\u3067\u3059\u3002\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u4E0D\u8DB3\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.improperly.formed.type.inner.raw.param=\u578B\u306E\u5F62\u5F0F\u304C\u4E0D\u9069\u5207\u3067\u3059\u3002raw\u578B\u306B\u6307\u5B9A\u3055\u308C\u305F\u578B\u5F15\u6570\u3067\u3059
+
+# 0: type, 1: type
+compiler.err.incomparable.types=\u578B{0}\u3068{1}\u306F\u6BD4\u8F03\u3067\u304D\u307E\u305B\u3093
+
+# 0: number
+compiler.err.int.number.too.large=\u6574\u6570{0}\u304C\u5927\u304D\u3059\u304E\u307E\u3059
+
+compiler.err.intf.annotation.members.cant.have.params=@interface\u30E1\u30F3\u30D0\u30FC\u304C\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.intf.annotation.cant.have.type.params=@interface\u304C\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.intf.annotation.members.cant.have.type.params=@interface\u30E1\u30F3\u30D0\u30FC\u304C\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: type
+compiler.err.intf.annotation.member.clash=@interface\u30E1\u30F3\u30D0\u30FC\u306F{1}\u306E\u30E1\u30BD\u30C3\u30C9''{0}''\u3068\u7AF6\u5408\u3057\u307E\u3059
+
+compiler.err.intf.expected.here=\u3053\u3053\u306B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.intf.meth.cant.have.body=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u62BD\u8C61\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.invalid.annotation.member.type=\u6CE8\u91C8\u30E1\u30F3\u30D0\u30FC\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.invalid.binary.number=2\u9032\u6570\u5B57\u306F\u5C11\u306A\u304F\u3068\u30821\u6841\u306E2\u9032\u6570\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.invalid.hex.number=16\u9032\u6570\u5B57\u306F\u5C11\u306A\u304F\u3068\u30821\u6841\u306E16\u9032\u6570\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.invalid.meth.decl.ret.type.req=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u5BA3\u8A00\u3067\u3059\u3002\u623B\u308A\u5024\u306E\u578B\u304C\u5FC5\u8981\u3067\u3059\u3002
+
+compiler.err.varargs.and.old.array.syntax=\u65E7\u5F0F\u306E\u914D\u5217\u8868\u8A18\u6CD5\u306F\u53EF\u5909\u5F15\u6570\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.varargs.and.receiver =varargs\u8868\u8A18\u306F\u53D7\u53D6\u308A\u5074\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.array.and.receiver =\u65E7\u5F0F\u306E\u914D\u5217\u8868\u8A18\u6CD5\u306F\u53D7\u53D6\u308A\u5074\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.variable.not.allowed=\u5909\u6570\u306E\u5BA3\u8A00\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: name
+compiler.err.label.already.in.use=\u30E9\u30D9\u30EB{0}\u306F\u3059\u3067\u306B\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol
+compiler.err.local.var.accessed.from.icls.needs.final=\u30ED\u30FC\u30AB\u30EB\u5909\u6570{0}\u306F\u5185\u90E8\u30AF\u30E9\u30B9\u304B\u3089\u30A2\u30AF\u30BB\u30B9\u3055\u308C\u307E\u3059\u3002final\u3067\u5BA3\u8A00\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.local.enum=\u5217\u6319\u578B\u306F\u30ED\u30FC\u30AB\u30EB\u306B\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.cannot.create.array.with.type.arguments=\u578B\u5F15\u6570\u3092\u6301\u3064\u914D\u5217\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.cannot.create.array.with.diamond=''<>''\u3092\u6301\u3064\u914D\u5217\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093
+
+#
+# limits.  We don't give the limits in the diagnostic because we expect
+# them to change, yet we want to use the same diagnostic.  These are all
+# detected during code generation.
+#
+compiler.err.limit.code=\u30B3\u30FC\u30C9\u304C\u5927\u304D\u3059\u304E\u307E\u3059
+
+compiler.err.limit.code.too.large.for.try.stmt=try\u6587\u306E\u30B3\u30FC\u30C9\u304C\u5927\u304D\u3059\u304E\u307E\u3059
+
+compiler.err.limit.dimensions=\u914D\u5217\u578B\u306E\u6B21\u5143\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.locals=\u30ED\u30FC\u30AB\u30EB\u5909\u6570\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.parameters=\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.pool=\u5B9A\u6570\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.pool.in.class=\u30AF\u30E9\u30B9{0}\u5185\u306E\u5B9A\u6570\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.stack=\u30B3\u30FC\u30C9\u304C\u8981\u6C42\u3059\u308B\u30B9\u30BF\u30C3\u30AF\u304C\u591A\u3059\u304E\u307E\u3059
+
+compiler.err.limit.string=\u5B9A\u6570\u6587\u5B57\u5217\u304C\u9577\u3059\u304E\u307E\u3059
+
+compiler.err.limit.string.overflow=\u6587\u5B57\u5217"{0}..."\u306EUTF8\u8868\u73FE\u304C\u3001\u5B9A\u6570\u30D7\u30FC\u30EB\u306B\u5BFE\u3057\u3066\u9577\u3059\u304E\u307E\u3059
+
+compiler.err.malformed.fp.lit=\u6D6E\u52D5\u5C0F\u6570\u70B9\u30EA\u30C6\u30E9\u30EB\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.method.does.not.override.superclass=\u30E1\u30BD\u30C3\u30C9\u306F\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u306E\u30E1\u30BD\u30C3\u30C9\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u307E\u305F\u306F\u5B9F\u88C5\u3057\u307E\u305B\u3093
+
+compiler.err.missing.meth.body.or.decl.abstract=\u30E1\u30BD\u30C3\u30C9\u672C\u4F53\u304C\u306A\u3044\u304B\u3001abstract\u3068\u3057\u3066\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.missing.ret.stmt=return\u6587\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: unused
+compiler.misc.missing.ret.val=\u623B\u308A\u5024\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.misc.unexpected.ret.val=\u4E88\u671F\u3057\u306A\u3044\u623B\u308A\u5024
+
+# 0: set of modifier
+compiler.err.mod.not.allowed.here=\u4FEE\u98FE\u5B50{0}\u3092\u3053\u3053\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.intf.not.allowed.here=\u3053\u3053\u3067\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093
+
+compiler.err.enums.must.be.static=\u5217\u6319\u578B\u306E\u5BA3\u8A00\u306Fstatic\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u3067\u306E\u307F\u4F7F\u7528\u3067\u304D\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.err.name.clash.same.erasure=\u540D\u524D\u304C\u7AF6\u5408\u3057\u3066\u3044\u307E\u3059\u3002{0}\u3068{1}\u306F\u524A\u9664\u5F8C\u306E\u540D\u524D\u304C\u540C\u3058\u3067\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused
+compiler.err.name.clash.same.erasure.no.override=\u540D\u524D\u304C\u7AF6\u5408\u3057\u3066\u3044\u307E\u3059\u3002{1}\u306E{0}\u3068{3}\u306E{2}\u306F\u307E\u3060\u4ED6\u65B9\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u524A\u9664\u5F8C\u306E\u540D\u524D\u304C\u540C\u3058\u3067\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol
+compiler.err.name.clash.same.erasure.no.override.1=\u540D\u524D\u304C\u7AF6\u5408\u3057\u3066\u3044\u307E\u3059\u3002{1}\u306E{0}\u306E\u3069\u3061\u3089\u3082\u3001\u4ED6\u65B9\u306E\u6700\u521D\u306E\u30E1\u30BD\u30C3\u30C9\u3092\u307E\u3060\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u524A\u9664\u5F8C\u306E\u540D\u524D\u304C\u5225\u306E\u30E1\u30BD\u30C3\u30C9\u3068\u540C\u3058\u30E1\u30BD\u30C3\u30C9\u3092\n\u30AA\u30FC\u30D0\u30FC\u30E9\ [...]
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.err.name.clash.same.erasure.no.hide=\u540D\u524D\u304C\u7AF6\u5408\u3057\u3066\u3044\u307E\u3059\u3002{1}\u306E{0}\u3068{3}\u306E{2}\u306F\u307E\u3060\u4ED6\u65B9\u3092\u975E\u8868\u793A\u306B\u3057\u3066\u3044\u307E\u305B\u3093\u304C\u3001\u524A\u9664\u5F8C\u306E\u540D\u524D\u304C\u540C\u3058\u3067\u3059
+
+compiler.err.name.reserved.for.internal.use={0}\u306F\u5185\u90E8\u3067\u306E\u4F7F\u7528\u306E\u305F\u3081\u4E88\u7D04\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.native.meth.cant.have.body=native\u30E1\u30BD\u30C3\u30C9\u304C\u672C\u4F53\u3092\u6301\u3064\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: type, 1: type
+compiler.err.neither.conditional.subtype=?\u306B\u5BFE\u3059\u308B\u4E0D\u9069\u5408\u306A\u578B : \u3069\u3061\u3089\u3082\u4ED6\u65B9\u306E\u30B5\u30D6\u30BF\u30A4\u30D7\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\n2\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {0}\n3\u756A\u76EE\u306E\u30AA\u30DA\u30E9\u30F3\u30C9 : {1}
+
+# 0: message segment
+compiler.misc.incompatible.type.in.conditional=\u6761\u4EF6\u5F0F\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0}
+
+compiler.misc.conditional.target.cant.be.void=\u6761\u4EF6\u5F0F\u306E\u30BF\u30FC\u30B2\u30C3\u30C8\u578B\u306Fvoid\u306B\u3067\u304D\u307E\u305B\u3093
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u306E\u623B\u308A\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0}
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u623B\u308A\u578B\u304C\u4E0D\u6B63\u3067\u3059\n{0}
+
+# 0: list of type
+compiler.err.incompatible.thrown.types.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u3067\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u4E0D\u9069\u5408\u3067\u3059
+
+# 0: list of type
+compiler.err.incompatible.thrown.types.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u4E0D\u9069\u5408\u3067\u3059
+
+compiler.misc.incompatible.arg.types.in.lambda=\u30E9\u30E0\u30C0\u5F0F\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u578B\u306F\u4E0D\u9069\u5408\u3067\u3059
+
+compiler.misc.incompatible.arg.types.in.mref=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u578B\u306F\u4E0D\u9069\u5408\u3067\u3059
+
+# 0: list of type, 1: message segment
+compiler.misc.bad.arg.types.in.lambda=\u63A8\u5B9A\u30D1\u30E9\u30E1\u30FC\u30BF\u578B\u3067\u306F\u30E9\u30E0\u30C0\u5F0F\u306E\u578B\u30C1\u30A7\u30C3\u30AF\u3092\u5B9F\u884C\u3067\u304D\u307E\u305B\u3093\n\u63A8\u5B9A\u578B: {0}
+
+compiler.err.new.not.allowed.in.annotation=''new''\u306F\u6CE8\u91C8\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.no.annotation.member={1}\u306E\u6CE8\u91C8\u30E1\u30F3\u30D0\u30FC{0}\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.no.encl.instance.of.type.in.scope=\u578B{0}\u306E\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u56F2\u3080\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.no.intf.expected.here=\u3053\u3053\u306B\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F\u5FC5\u8981\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.no.match.entry={0}\u306F{1}\u306E\u30A8\u30F3\u30C8\u30EA\u306B\u9069\u5408\u3057\u307E\u305B\u3093\u3002{2}\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.not.annotation.type={0}\u306F\u6CE8\u91C8\u578B\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol
+compiler.err.not.def.access.class.intf.cant.access={1}\u306E{0}\u304C\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u3044\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.class.intf.cant.access={1}\u306E{0}\u304C\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u3044\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306B\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol, 1: list of type, 2: type
+compiler.misc.cant.access.inner.cls.constr=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF{0}({1})\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u56F2\u3080\u578B{2}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u30B9\u30B3\u30FC\u30D7\u5185\u306B\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol
+compiler.err.not.def.public.cant.access={1}\u306E{0}\u306Fpublic\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u30D1\u30C3\u30B1\u30FC\u30B8\u5916\u304B\u3089\u306F\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol
+compiler.misc.not.def.public.cant.access={1}\u306E{0}\u306Fpublic\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u30D1\u30C3\u30B1\u30FC\u30B8\u5916\u304B\u3089\u306F\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093
+
+# 0: name
+compiler.err.not.loop.label={0}\u306F\u30EB\u30FC\u30D7\u30FB\u30E9\u30D9\u30EB\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.not.stmt=\u6587\u3067\u306F\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.not.encl.class={0}\u306F\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u56F2\u307F\u307E\u305B\u3093
+
+# 0: name, 1: type, 2: unused
+compiler.err.operator.cant.be.applied=\u5358\u9805\u6F14\u7B97\u5B50''{0}''\u306E\u30AA\u30DA\u30E9\u30F3\u30C9\u578B{1}\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: name, 1: type, 2: type
+compiler.err.operator.cant.be.applied.1=\u4E8C\u9805\u6F14\u7B97\u5B50''{0}''\u306E\u30AA\u30DA\u30E9\u30F3\u30C9\u578B\u304C\u4E0D\u6B63\u3067\u3059\n\u6700\u521D\u306E\u578B: {1}\n2\u756A\u76EE\u306E\u578B: {2}
+
+compiler.err.pkg.annotations.sb.in.package-info.java=\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u6CE8\u91C8\u306F\u30D5\u30A1\u30A4\u30EBpackage-info.java\u5185\u306B\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.err.pkg.clashes.with.class.of.same.name=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F\u540C\u540D\u306E\u30AF\u30E9\u30B9\u3068\u7AF6\u5408\u3057\u3066\u3044\u307E\u3059
+
+compiler.err.warnings.and.werror=\u8B66\u544A\u304C\u898B\u3064\u304B\u308A-Werror\u304C\u6307\u5B9A\u3055\u308C\u307E\u3057\u305F
+
+# Errors related to annotation processing
+
+# 0: symbol, 1: string, 2: stack-trace
+compiler.err.proc.cant.access={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1}\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n{2}
+
+# 0: symbol, 1: string
+compiler.err.proc.cant.access.1={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1}
+
+# 0: string
+compiler.err.proc.cant.find.class=''{0}''\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002
+
+# Print a client-generated error message; assumed to be localized, no translation required
+# 0: string
+compiler.err.proc.messager={0}
+
+# 0: list of string
+compiler.err.proc.no.explicit.annotation.processing.requested=\u30AF\u30E9\u30B9\u540D''{0}''\u304C\u53D7\u3051\u5165\u308C\u3089\u308C\u308B\u306E\u306F\u3001\u6CE8\u91C8\u51E6\u7406\u304C\u660E\u793A\u7684\u306B\u30EA\u30AF\u30A8\u30B9\u30C8\u3055\u308C\u305F\u5834\u5408\u306E\u307F\u3067\u3059
+
+compiler.err.proc.no.service=\u30B5\u30FC\u30D3\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u304C\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u304C\u3001\u6CE8\u91C8\u51E6\u7406\u306B\u5FC5\u8981\u3067\u3059\u3002
+
+compiler.err.proc.processor.bad.option.name=\u30D7\u30ED\u30BB\u30C3\u30B5''{1}''\u306B\u3088\u3063\u3066\u6307\u5B9A\u3055\u308C\u305F\u30AA\u30D7\u30B7\u30E7\u30F3\u540D''{0}''\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: string
+compiler.err.proc.processor.cant.instantiate=\u30D7\u30ED\u30BB\u30C3\u30B5''{0}''\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F
+
+# 0: string
+compiler.err.proc.processor.not.found=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5''{0}''\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+
+# 0: string
+compiler.err.proc.processor.wrong.type=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5''{0}''\u304Cjavax.annotation.processing.Processor\u3092\u5B9F\u88C5\u3057\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.proc.service.problem=\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u30ED\u30FC\u30C9\u3059\u308B\u305F\u3081\u306E\u30B5\u30FC\u30D3\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u3092\u4F5C\u6210\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002
+
+compiler.err.proc.bad.config.file=\u30B5\u30FC\u30D3\u30B9\u69CB\u6210\u30D5\u30A1\u30A4\u30EB\u304C\u4E0D\u6B63\u3067\u3042\u308B\u304B\u3001\u30D7\u30ED\u30BB\u30C3\u30B5\u30FB\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u69CB\u7BC9\u4E2D\u306B\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F: {0}
+
+compiler.err.proc.cant.create.loader=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u30AF\u30E9\u30B9\u30FB\u30ED\u30FC\u30C0\u30FC\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {0}
+
+# 0: unused
+compiler.err.qualified.new.of.static.class=static\u30AF\u30E9\u30B9\u306Enew\u304C\u4FEE\u98FE\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.recursive.ctor.invocation=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u547C\u51FA\u3057\u304C\u518D\u5E30\u7684\u3067\u3059
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
+compiler.err.ref.ambiguous={0}\u306E\u53C2\u7167\u306F\u3042\u3044\u307E\u3044\u3067\u3059\n{3}\u306E{1} {2}\u3068{6}\u306E{4} {5}\u306E\u4E21\u65B9\u304C\u4E00\u81F4\u3057\u307E\u3059
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
+compiler.misc.ref.ambiguous={0}\u306E\u53C2\u7167\u306F\u3042\u3044\u307E\u3044\u3067\u3059\n{3}\u306E{1} {2}\u3068{6}\u306E{4} {5}\u306E\u4E21\u65B9\u304C\u4E00\u81F4\u3057\u307E\u3059
+
+compiler.err.repeated.annotation.target=\u6CE8\u91C8\u30BF\u30FC\u30B2\u30C3\u30C8\u304C\u7E70\u308A\u8FD4\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.repeated.interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304C\u7E70\u308A\u8FD4\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.err.repeated.modifier=\u4FEE\u98FE\u5B50\u304C\u7E70\u308A\u8FD4\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol, 1: set of modifier, 2: symbol
+compiler.err.report.access={0}\u306F{2}\u3067{1}\u30A2\u30AF\u30BB\u30B9\u3055\u308C\u307E\u3059
+
+compiler.err.ret.outside.meth=\u30E1\u30BD\u30C3\u30C9\u306E\u5916\u306Ereturn\u6587\u3067\u3059
+
+compiler.err.signature.doesnt.match.supertype=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C{0}\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u4E0D\u9069\u5408\u306A\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7\u3067\u3059
+
+compiler.err.signature.doesnt.match.intf=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C{0}\u306B\u4E00\u81F4\u3057\u307E\u305B\u3093\u3002\u4E0D\u9069\u5408\u306A\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3067\u3059
+
+# 0: symbol, 1: symbol, 2: symbol
+compiler.err.does.not.override.abstract={0}\u306Fabstract\u3067\u306A\u304F\u3001{2}\u5185\u306Eabstract\u30E1\u30BD\u30C3\u30C9{1}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u305B\u3093
+
+compiler.err.source.cant.overwrite.input.file=\u30BD\u30FC\u30B9\u306E\u66F8\u8FBC\u307F\u30A8\u30E9\u30FC\u3067\u3059\u3002\u5165\u529B\u30D5\u30A1\u30A4\u30EB{0}\u3092\u4E0A\u66F8\u304D\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.stack.sim.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0}\u3067\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30B7\u30DF\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\u30FB\u30A8\u30E9\u30FC
+
+compiler.err.static.imp.only.classes.and.interfaces=static import\u306F\u30AF\u30E9\u30B9\u3068\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u304B\u3089\u306E\u307F\u3068\u306A\u308A\u307E\u3059
+
+compiler.err.string.const.req=\u5B9A\u6570\u306E\u6587\u5B57\u5217\u5F0F\u304C\u5FC5\u8981\u3067\u3059
+
+# 0: symbol, 1: symbol
+compiler.err.synthetic.name.conflict=\u30B7\u30F3\u30DC\u30EB{0}\u304C\u3001{1}\u3067\u30B3\u30F3\u30D1\u30A4\u30E9\u304C\u5408\u6210\u3057\u305F\u30B7\u30F3\u30DC\u30EB\u3068\u7AF6\u5408\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol
+compiler.warn.synthetic.name.conflict=\u30B7\u30F3\u30DC\u30EB{0}\u304C\u3001{1}\u3067\u30B3\u30F3\u30D1\u30A4\u30E9\u304C\u5408\u6210\u3057\u305F\u30B7\u30F3\u30DC\u30EB\u3068\u7AF6\u5408\u3057\u307E\u3059
+
+compiler.err.throws.not.allowed.in.intf.annotation=throws\u7BC0\u3092 at interface\u30E1\u30F3\u30D0\u30FC\u3067\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.try.without.catch.or.finally=''try''\u3078\u306E''catch''\u307E\u305F\u306F''finally''\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.try.without.catch.finally.or.resource.decls=''try''\u3078\u306E''catch''\u3001''finally''\u307E\u305F\u306F\u30EA\u30BD\u30FC\u30B9\u5BA3\u8A00\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: symbol
+compiler.err.type.doesnt.take.params=\u578B{0}\u306F\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u3068\u308A\u307E\u305B\u3093
+
+compiler.err.type.var.cant.be.deref=\u578B\u5909\u6570\u304B\u3089\u9078\u629E\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.type.var.may.not.be.followed.by.other.bounds=\u3053\u306E\u578B\u5909\u6570\u306E\u5F8C\u308D\u306B\u4ED6\u306E\u5883\u754C\u3092\u914D\u7F6E\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.type.var.more.than.once=\u578B\u5909\u6570{0}\u306F{1}\u306E\u623B\u308A\u5024\u306E\u578B\u30672\u56DE\u4EE5\u4E0A\u51FA\u73FE\u3057\u307E\u3059\u3002\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u751F\u6210\u3055\u308C\u306A\u3044\u307E\u307E\u306B\u306F\u3067\u304D\u307E\u305B\u3093
+
+compiler.err.type.var.more.than.once.in.result=\u578B\u5909\u6570{0}\u306F{1}\u306E\u578B\u30672\u56DE\u4EE5\u4E0A\u51FA\u73FE\u3057\u307E\u3059\u3002\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u751F\u6210\u3055\u308C\u306A\u3044\u307E\u307E\u306B\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: type, 1: type, 2: string
+compiler.err.types.incompatible.diff.ret=\u578B{0}\u3068\u578B{1}\u304C\u9069\u5408\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u4E21\u65B9\u3068\u3082{2}\u3092\u5B9A\u7FA9\u3057\u3066\u3044\u307E\u3059\u304C\u3001\u623B\u308A\u5024\u306E\u578B\u304C\u7121\u95A2\u4FC2\u3067\u3059
+
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.unrelated.defaults={0} {1}\u306F\u578B{4}\u3068{5}\u304B\u3089{2}({3})\u306E\u95A2\u9023\u3057\u306A\u3044\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u7D99\u627F\u3057\u307E\u3059
+
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.abstract.default={0} {1}\u306F\u578B{4}\u3068{5}\u304B\u3089{2}({3})\u306E\u62BD\u8C61\u3068\u30C7\u30D5\u30A9\u30EB\u30C8\u3092\u7D99\u627F\u3057\u307E\u3059
+
+# 0: name, 1: kind, 2: symbol
+compiler.err.default.overrides.object.member={1} {2}\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9{0}\u306Fjava.lang.Object\u306E\u30E1\u30F3\u30D0\u30FC\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059
+
+# 0: type
+compiler.err.illegal.static.intf.meth.call=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9\u30FB\u30B3\u30FC\u30EB\u304C\u4E0D\u6B63\u3067\u3059\n\u53D7\u4FE1\u5F0F\u306F\u578B\u4FEE\u98FE\u5B50''{0}''\u3067\u7F6E\u63DB\u3055\u308C\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: type, 1: message segment
+compiler.err.illegal.default.super.call=\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30B9\u30FC\u30D1\u30FC\u30FB\u30B3\u30FC\u30EB\u306E\u578B\u4FEE\u98FE\u5B50{0}\u304C\u4E0D\u6B63\u3067\u3059\n{1}
+
+# 0: symbol, 1: type
+compiler.misc.overridden.default={1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u307E\u3059
+
+# 0: symbol, 1: type or symbol
+compiler.misc.redundant.supertype=\u5197\u9577\u306A\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9{0}\u306F{1}\u306B\u3088\u3063\u3066\u62E1\u5F35\u3055\u308C\u307E\u3057\u305F
+
+compiler.err.unclosed.char.lit=\u6587\u5B57\u30EA\u30C6\u30E9\u30EB\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.unclosed.comment=\u30B3\u30E1\u30F3\u30C8\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.unclosed.str.lit=\u6587\u5B57\u5217\u30EA\u30C6\u30E9\u30EB\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: name
+compiler.err.unsupported.encoding=\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u306A\u3044\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3067\u3059: {0}
+
+compiler.err.io.exception=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u53D6\u308A\u30A8\u30E9\u30FC\u3067\u3059: {0}
+
+# 0: name
+compiler.err.undef.label=\u30E9\u30D9\u30EB{0}\u306F\u672A\u5B9A\u7FA9\u3067\u3059
+
+# 0: message segment, 1: unused
+compiler.err.cant.apply.diamond={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093
+
+# 0: message segment or type, 1: message segment
+compiler.err.cant.apply.diamond.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n\u7406\u7531: {1}
+
+# 0: message segment or type, 1: message segment
+compiler.misc.cant.apply.diamond.1={0}\u306E\u578B\u5F15\u6570\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n\u7406\u7531: {1}
+
+compiler.err.unreachable.stmt=\u3053\u306E\u6587\u306B\u5236\u5FA1\u304C\u79FB\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.initializer.must.be.able.to.complete.normally=\u521D\u671F\u5316\u5B50\u306F\u6B63\u5E38\u306B\u5B8C\u4E86\u3067\u304D\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: type
+compiler.err.unreported.exception.need.to.catch.or.throw=\u4F8B\u5916{0}\u306F\u5831\u544A\u3055\u308C\u307E\u305B\u3093\u3002\u30B9\u30ED\u30FC\u3059\u308B\u306B\u306F\u3001\u6355\u6349\u307E\u305F\u306F\u5BA3\u8A00\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: type
+compiler.err.unreported.exception.default.constructor=\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u5185\u306B\u5831\u544A\u3055\u308C\u306A\u3044\u4F8B\u5916{0}\u304C\u5B58\u5728\u3057\u307E\u3059
+
+# 0: type, 1: name
+compiler.err.unreported.exception.implicit.close=\u5831\u544A\u3055\u308C\u306A\u3044\u4F8B\u5916{0}\u306F\u3001\u30B9\u30ED\u30FC\u3059\u308B\u306B\u306F\u6355\u6349\u307E\u305F\u306F\u5BA3\u8A00\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\n\u30EA\u30BD\u30FC\u30B9\u5909\u6570''{1}''\u3067\u306Eclose()\u306E\u6697\u9ED9\u7684\u306A\u30B3\u30FC\u30EB\u304B\u3089\u4F8B\u5916\u304C\u30B9\u30ED\u30FC\u3055\u308C\u307E\u3057\u305F
+
+compiler.err.unsupported.cross.fp.lit=16\u9032\u6D6E\u52D5\u5C0F\u6570\u70B9\u30EA\u30C6\u30E9\u30EB\u306F\u3053\u306EVM\u3067\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.void.not.allowed.here=\u3053\u3053\u3067''void''\u578B\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: string
+compiler.err.wrong.number.type.args=\u578B\u5F15\u6570\u306E\u6570\u304C\u4E0D\u6B63\u3067\u3059\u3002{0}\u500B\u5FC5\u8981\u3067\u3059
+
+# 0: symbol
+compiler.err.var.might.already.be.assigned=\u5909\u6570{0}\u306F\u3059\u3067\u306B\u4EE3\u5165\u3055\u308C\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.err.var.might.not.have.been.initialized=\u5909\u6570{0}\u306F\u521D\u671F\u5316\u3055\u308C\u3066\u3044\u306A\u3044\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.err.var.might.be.assigned.in.loop=\u5909\u6570{0}\u306F\u30EB\u30FC\u30D7\u5185\u3067\u4EE3\u5165\u3055\u308C\u3066\u3044\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol, 1: message segment
+compiler.err.varargs.invalid.trustme.anno={0}\u6CE8\u91C8\u304C\u7121\u52B9\u3067\u3059\u3002{1}
+
+# 0: type
+compiler.misc.varargs.trustme.on.reifiable.varargs=\u53EF\u5909\u5F15\u6570\u8981\u7D20\u578B{0}\u306Freifiable\u578B\u3067\u3059\u3002
+
+# 0: symbol
+compiler.misc.varargs.trustme.on.non.varargs.meth=\u30E1\u30BD\u30C3\u30C9{0}\u306F\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002
+
+# 0: symbol
+compiler.misc.varargs.trustme.on.virtual.varargs=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9{0}\u306Ffinal\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002
+
+# 0: type, 1: symbol kind, 2: symbol
+compiler.misc.inaccessible.varargs.type=\u4EEE\u53EF\u5909\u5F15\u6570\u8981\u7D20\u578B{0}\u306F{1} {2}\u304B\u3089\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093
+
+# In the following string, {1} will always be the detail message from
+# java.io.IOException.
+# 0: symbol, 1: string
+compiler.err.class.cant.write={0}\u306E\u66F8\u8FBC\u307F\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {1}
+
+# In the following string, {0} is the name of the class in the Java source.
+# It really should be used two times..
+# 0: name
+compiler.err.class.public.should.be.in.file=\u30AF\u30E9\u30B9{0}\u306Fpublic\u3067\u3042\u308A\u3001\u30D5\u30A1\u30A4\u30EB{0}.java\u3067\u5BA3\u8A00\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+## All errors which do not refer to a particular line in the source code are
+## preceded by this string.
+compiler.err.error=\u30A8\u30E9\u30FC: 
+
+# The following error messages do not refer to a line in the source code.
+compiler.err.cant.read.file={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093
+
+#####
+
+# Fatal Errors
+
+compiler.misc.fatal.err.no.java.lang=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u30AF\u30E9\u30B9\u30D1\u30B9\u307E\u305F\u306F\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9\u3067\u30D1\u30C3\u30B1\u30FC\u30B8java.lang\u3092\u691C\u51FA\u3067\u304D\u307E\u305B\u3093
+
+compiler.misc.fatal.err.cant.locate.meth=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u30E1\u30BD\u30C3\u30C9{0}\u3092\u691C\u51FA\u3067\u304D\u307E\u305B\u3093
+
+compiler.misc.fatal.err.cant.locate.field=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u30D5\u30A3\u30FC\u30EB\u30C9{0}\u3092\u691C\u51FA\u3067\u304D\u307E\u305B\u3093
+
+compiler.misc.fatal.err.cant.locate.ctor=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: {0}\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u3092\u691C\u51FA\u3067\u304D\u307E\u305B\u3093
+
+compiler.misc.fatal.err.cant.close=\u81F4\u547D\u7684\u30A8\u30E9\u30FC: \u30B3\u30F3\u30D1\u30A4\u30E9\u30FB\u30EA\u30BD\u30FC\u30B9\u3092\u9589\u3058\u308B\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093
+
+#####
+
+##
+## miscellaneous strings
+##
+
+compiler.misc.source.unavailable=(\u30BD\u30FC\u30B9\u304C\u5229\u7528\u4E0D\u53EF)
+
+compiler.misc.base.membership=\u3059\u3079\u3066\u306E\u30D9\u30FC\u30B9\u30FB\u30AF\u30E9\u30B9\u304C\u30E1\u30F3\u30D0\u30FC\u3067\u3059
+
+# 0: string, 1: string, 2: boolean
+compiler.misc.x.print.processor.info=\u30D7\u30ED\u30BB\u30C3\u30B5{0}\u306F{1}\u306B\u4E00\u81F4\u3057\u3001{2}\u3092\u8FD4\u3057\u307E\u3059\u3002
+
+# 0: number, 1: string, 2: set of symbol, 3: boolean
+compiler.misc.x.print.rounds=\u5F80\u5FA9{0}:\n\t\u5165\u529B\u30D5\u30A1\u30A4\u30EB: {1}\n\t\u6CE8\u91C8: {2}\n\t\u6700\u5F8C\u306E\u5F80\u5FA9: {3}
+
+#####
+
+## The following string will appear before all messages keyed as:
+## "compiler.note".
+
+compiler.note.compressed.diags=\u4E00\u90E8\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F\u7C21\u7565\u5316\u3055\u308C\u3066\u3044\u307E\u3059\u3002-Xdiags:verbose\u3067\u518D\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u3066\u5B8C\u5168\u306A\u51FA\u529B\u3092\u53D6\u5F97\u3057\u3066\u304F\u3060\u3055\u3044
+
+compiler.note.potential.lambda.found=\u3053\u306E\u533F\u540D\u5185\u90E8\u30AF\u30E9\u30B9\u3092\u30E9\u30E0\u30C0\u5F0F\u306B\u5909\u63DB\u3067\u304D\u307E\u3059\u3002
+
+compiler.note.note=\u6CE8\u610F:
+
+# 0: file name
+compiler.note.deprecated.filename={0}\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002
+
+compiler.note.deprecated.plural=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002
+
+# The following string may appear after one of the above deprecation
+# messages.
+compiler.note.deprecated.recompile=\u8A73\u7D30\u306F\u3001-Xlint:deprecation\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u3066\u518D\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+# 0: file name
+compiler.note.deprecated.filename.additional={0}\u306B\u975E\u63A8\u5968\u306EAPI\u306E\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u304C\u3042\u308A\u307E\u3059\u3002
+
+compiler.note.deprecated.plural.additional=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u975E\u63A8\u5968\u306EAPI\u3092\u8FFD\u52A0\u4F7F\u7528\u307E\u305F\u306F\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u307E\u3059\u3002
+
+# 0: file name
+compiler.note.unchecked.filename={0}\u306E\u64CD\u4F5C\u306F\u3001\u672A\u30C1\u30A7\u30C3\u30AF\u307E\u305F\u306F\u5B89\u5168\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002
+
+compiler.note.unchecked.plural=\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u64CD\u4F5C\u306E\u3046\u3061\u3001\u672A\u30C1\u30A7\u30C3\u30AF\u307E\u305F\u306F\u5B89\u5168\u3067\u306F\u306A\u3044\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002
+
+# The following string may appear after one of the above deprecation
+# messages.
+compiler.note.unchecked.recompile=\u8A73\u7D30\u306F\u3001-Xlint:unchecked\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u3066\u518D\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+# 0: file name
+compiler.note.unchecked.filename.additional={0}\u306B\u672A\u30C1\u30A7\u30C3\u30AF\u307E\u305F\u306F\u5B89\u5168\u3067\u306F\u306A\u3044\u64CD\u4F5C\u304C\u3055\u3089\u306B\u3042\u308A\u307E\u3059\u3002
+
+compiler.note.unchecked.plural.additional=\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306E\u64CD\u4F5C\u306E\u3046\u3061\u3001\u672A\u30C1\u30A7\u30C3\u30AF\u307E\u305F\u306F\u5B89\u5168\u3067\u306F\u306A\u3044\u3082\u306E\u304C\u3055\u3089\u306B\u3042\u308A\u307E\u3059\u3002
+
+# 0: file name
+compiler.note.sunapi.filename={0}\u306F\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u5185\u90E8\u6240\u6709\u306EAPI\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059\u3002
+
+compiler.note.sunapi.plural=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u5185\u90E8\u6240\u6709\u306EAPI\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059\u3002
+
+# The following string may appear after one of the above sunapi messages.
+compiler.note.sunapi.recompile=\u8A73\u7D30\u306F\u3001-Xlint:sunapi\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u6307\u5B9A\u3057\u3066\u518D\u30B3\u30F3\u30D1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+# 0: file name
+compiler.note.sunapi.filename.additional={0}\u306F\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u8FFD\u52A0\u306E\u5185\u90E8\u6240\u6709\u306EAPI\u3092\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059\u3002
+
+compiler.note.sunapi.plural.additional=\u4E00\u90E8\u306E\u5165\u529B\u30D5\u30A1\u30A4\u30EB\u306F\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u5185\u90E8\u6240\u6709\u306EAPI\u3092\u8FFD\u52A0\u3067\u4F7F\u7528\u3057\u3066\u3044\u307E\u3059\u3002
+
+# Notes related to annotation processing
+
+# Print a client-generated note; assumed to be localized, no translation required
+# 0: string
+compiler.note.proc.messager={0}
+
+#####
+
+# 0: number
+compiler.misc.count.error=\u30A8\u30E9\u30FC{0}\u500B
+
+# 0: number
+compiler.misc.count.error.plural=\u30A8\u30E9\u30FC{0}\u500B
+
+# 0: number
+compiler.misc.count.warn=\u8B66\u544A{0}\u500B
+
+# 0: number
+compiler.misc.count.warn.plural=\u8B66\u544A{0}\u500B
+
+compiler.misc.version.not.available=(\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u304C\u3042\u308A\u307E\u305B\u3093)
+
+## extra output when using -verbose (JavaCompiler)
+
+# 0: symbol
+compiler.misc.verbose.checking.attribution=[{0}\u3092\u78BA\u8A8D\u4E2D]
+
+# 0: string
+compiler.misc.verbose.parsing.done=[{0}\u30DF\u30EA\u79D2\u3067\u69CB\u6587\u89E3\u6790\u5B8C\u4E86]
+
+# 0: file name
+compiler.misc.verbose.parsing.started=[{0}\u3092\u69CB\u6587\u89E3\u6790\u958B\u59CB]
+
+# 0: string
+compiler.misc.verbose.total=[\u5408\u8A08{0}\u30DF\u30EA\u79D2]
+
+# 0: file name
+compiler.misc.verbose.wrote.file=[{0}\u3092\u66F8\u8FBC\u307F\u5B8C\u4E86]
+
+## extra output when using -verbose (Retro)
+compiler.misc.verbose.retro=[{0}\u3092\u7D44\u66FF\u3048\u4E2D]
+
+compiler.misc.verbose.retro.with=\t{0}\u3092{1}\u3067\u7D44\u66FF\u3048\u4E2D\u3067\u3059
+
+compiler.misc.verbose.retro.with.list=\t{0}\u3092\u578B\u30D1\u30E9\u30E1\u30FC\u30BF{1}\u3001\u30B9\u30FC\u30D1\u30FC\u30BF\u30A4\u30D7{2}\u3001\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9{3}\u3067\u7D44\u66FF\u3048\u4E2D\u3067\u3059
+
+## extra output when using -verbose (code/ClassReader)
+# 0: string
+compiler.misc.verbose.loading=[{0}\u3092\u8AAD\u8FBC\u307F\u4E2D]
+
+# 0: string
+compiler.misc.verbose.sourcepath=[\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u691C\u7D22\u30D1\u30B9: {0}]
+
+# 0: string
+compiler.misc.verbose.classpath=[\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u691C\u7D22\u30D1\u30B9: {0}]
+
+## extra output when using -checkclassfile (code/ClassReader)
+compiler.misc.ccf.found.later.version=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306B\u4E88\u60F3\u5916\u306E\u65B0\u30D0\u30FC\u30B8\u30E7\u30F3\u304C\u3042\u308A\u307E\u3059
+
+compiler.misc.ccf.unrecognized.attribute={0}\u306F\u8A8D\u8B58\u3055\u308C\u306A\u3044\u5C5E\u6027\u3067\u3059
+
+## extra output when using -prompt (util/Log)
+compiler.misc.resume.abort=R)\u518D\u958B,A)\u4E2D\u6B62>
+
+#####
+
+##
+## warnings
+##
+
+## All warning messages are preceded by the following string.
+compiler.warn.warning=\u8B66\u544A: 
+
+## Warning messages may also include the following prefix to identify a
+## lint option
+# 0: option name
+compiler.warn.lintOption=[{0}] 
+
+# 0: symbol
+compiler.warn.constant.SVUID=serialVersionUID\u306F\u30AF\u30E9\u30B9{0}\u306E\u5B9A\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: file name
+compiler.warn.dir.path.element.not.found=\u4E0D\u6B63\u306A\u30D1\u30B9\u8981\u7D20"{0}": \u305D\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\u5B58\u5728\u3057\u307E\u305B\u3093
+
+compiler.warn.finally.cannot.complete=finally\u7BC0\u304C\u6B63\u5E38\u306B\u5B8C\u4E86\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol
+compiler.warn.has.been.deprecated={1}\u306E{0}\u306F\u975E\u63A8\u5968\u306B\u306A\u308A\u307E\u3057\u305F
+
+# 0: symbol
+compiler.warn.sun.proprietary={0}\u306F\u5185\u90E8\u6240\u6709\u306EAPI\u3067\u3042\u308A\u3001\u4ECA\u5F8C\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u524A\u9664\u3055\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+compiler.warn.illegal.char.for.encoding=\u3053\u306E\u6587\u5B57\u306F\u3001\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0{0}\u306B\u30DE\u30C3\u30D7\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.warn.improper.SVUID=serialVersionUID\u306F\u3001\u30AF\u30E9\u30B9{0}\u306Bstatic final\u3092\u5BA3\u8A00\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: type, 1: type
+compiler.warn.inexact.non-varargs.call=\u6700\u7D42\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u4E0D\u6B63\u78BA\u306A\u5F15\u6570\u578B\u3092\u6301\u3063\u305F\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u306E\u975E\u53EF\u5909\u5F15\u6570\u547C\u51FA\u3057\u3002\n\u53EF\u5909\u5F15\u6570\u547C\u51FA\u3057\u306B\u95A2\u3057\u3066\u306F{0}\u306B\u30AD\u30E3\u30B9\u30C8\u3057\u307E\u3059\u3002\n\u975E\u53EF\u5909\u5F15\u6570\u547C\u51FA\u3057\u306B\u95A2\u3057\u3066\u306F{1}\u306B\u30AD\u30E [...]
+
+# 0: list of type
+compiler.warn.unreachable.catch=catch\u53E5\u306B\u79FB\u3059\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093\n\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u3059\u3067\u306B\u6355\u6349\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: list of type
+compiler.warn.unreachable.catch.1=catch\u53E5\u306B\u79FB\u3059\u3053\u3068\u304C\u3067\u304D\u307E\u305B\u3093\n\u30B9\u30ED\u30FC\u3055\u308C\u305F\u30BF\u30A4\u30D7{0}\u306F\u3059\u3067\u306B\u6355\u6349\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: symbol
+compiler.warn.long.SVUID=serialVersionUID\u306F\u3001\u30AF\u30E9\u30B9{0}\u306Elong\u578B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.warn.missing.SVUID=\u76F4\u5217\u5316\u53EF\u80FD\u306A\u30AF\u30E9\u30B9{0}\u306B\u306F\u3001serialVersionUID\u304C\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: message segment
+compiler.warn.override.varargs.missing={0}\u3002\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306B\u306F''...''\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: message segment
+compiler.warn.override.varargs.extra={0}\u3002\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u3066\u3044\u308B\u30E1\u30BD\u30C3\u30C9\u306B\u306F''...''\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.warn.override.bridge={0}\u3002\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306F\u30D6\u30EA\u30C3\u30B8\u30FB\u30E1\u30BD\u30C3\u30C9\u3067\u3059
+
+# 0: symbol
+compiler.warn.pkg-info.already.seen=package-info.java\u30D5\u30A1\u30A4\u30EB\u304C\u3059\u3067\u306B\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u7528\u306B\u8868\u793A\u3055\u308C\u3066\u3044\u307E\u3059
+
+# 0: file name
+compiler.warn.path.element.not.found=\u4E0D\u6B63\u306A\u30D1\u30B9\u8981\u7D20"{0}": \u305D\u306E\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\u3042\u308A\u307E\u305B\u3093
+
+compiler.warn.possible.fall-through.into.case=case\u306Bfall-through\u3059\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+# 0: type
+compiler.warn.redundant.cast={0}\u3078\u306E\u5197\u9577\u306A\u30AD\u30E3\u30B9\u30C8\u3067\u3059
+
+# 0: number
+compiler.warn.position.overflow=\u4F4D\u7F6E\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u304C\u884C{0}\u3067\u30AA\u30FC\u30D0\u30FC\u30D5\u30ED\u30FC\u3057\u307E\u3059
+
+# 0: file name, 1: number, 2: number
+compiler.warn.big.major.version={0}: \u30E1\u30B8\u30E3\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3{1}\u306F\u3001\u3053\u306E\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u308B\u6700\u65B0\u306E\u30E1\u30B8\u30E3\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3{2}\u3088\u308A\u65B0\u3057\u3044\u3067\u3059\u3002\n\u30B3\u30F3\u30D1\u30A4\u30E9\u306E\u30A2\u30C3\u30D7\u30B0\u30EC\u30FC\u30C9\u3092\u304A\u85A6\u3081\u3057\u307E\u3059\u3002
+
+# 0: symbol kind, 1: symbol
+compiler.warn.static.not.qualified.by.type=static {0}\u306F\u5F0F\u3067\u306F\u306A\u304F\u578B\u540D{1}\u3067\u4FEE\u98FE\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: string
+compiler.warn.source.no.bootclasspath=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9\u304C-source {0}\u3068\u4E00\u7DD2\u306B\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+# 0: name, 1: number, 2: number, 3: number, 4: number
+compiler.warn.future.attr=\u30D0\u30FC\u30B8\u30E7\u30F3{1}.{2}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3067\u5C0E\u5165\u3055\u308C\u305F{0}\u5C5E\u6027\u306F\u3001\u30D0\u30FC\u30B8\u30E7\u30F3{3}.{4}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3067\u306F\u7121\u8996\u3055\u308C\u307E\u3059
+
+# Warnings related to annotation processing
+# 0: name
+compiler.warn.proc.package.does.not.exist=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F\u5B58\u5728\u3057\u307E\u305B\u3093
+
+# 0: name
+compiler.warn.proc.file.reopening=''{0}''\u7528\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u8907\u6570\u56DE\u4F5C\u6210\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059
+
+# 0: name
+compiler.warn.proc.type.already.exists=\u30BF\u30A4\u30D7''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u3059\u3067\u306B\u30BD\u30FC\u30B9\u30FB\u30D1\u30B9\u307E\u305F\u306F\u30AF\u30E9\u30B9\u30D1\u30B9\u306B\u5B58\u5728\u3057\u307E\u3059
+
+# 0: name
+compiler.warn.proc.type.recreate=\u30BF\u30A4\u30D7''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u8907\u6570\u56DE\u4F5C\u6210\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059
+
+# 0: string
+compiler.warn.proc.illegal.file.name=\u7121\u52B9\u306A\u540D\u524D''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002
+
+# 0: string, 1: string
+compiler.warn.proc.suspicious.class.name=\u540D\u524D\u304C{1}\u3067\u7D42\u308F\u308B\u578B\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ''{0}''
+
+# 0: name
+compiler.warn.proc.file.create.last.round=\u6700\u5F8C\u306B\u4F5C\u6210\u3055\u308C\u305F\u30BF\u30A4\u30D7''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u6CE8\u91C8\u51E6\u7406\u306B\u6E21\u3055\u308C\u307E\u305B\u3093\u3002
+
+# 0: string, 1: string
+compiler.warn.proc.malformed.supported.string=\u30D7\u30ED\u30BB\u30C3\u30B5''{1}''\u304C\u8FD4\u3057\u305F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u308B\u6CE8\u91C8\u578B\u306E\u6587\u5B57\u5217''{0}''\u304C\u4E0D\u6B63\u3067\u3059
+
+# 0: set of string
+compiler.warn.proc.annotations.without.processors=\u3053\u308C\u3089\u306E\u6CE8\u91C8\u3092\u8981\u6C42\u3059\u308B\u30D7\u30ED\u30BB\u30C3\u30B5\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F: {0}
+
+# 0: source version, 1: string, 2: string
+compiler.warn.proc.processor.incompatible.source.version=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5''{1}''\u304B\u3089-source ''{2}''\u3088\u308A\u5C0F\u3055\u3044\u30BD\u30FC\u30B9\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3''{0}''\u304C\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u3059
+
+compiler.warn.proc.proc-only.requested.no.procs=\u30B3\u30F3\u30D1\u30A4\u30EB\u306A\u3057\u306E\u6CE8\u91C8\u51E6\u7406\u304C\u30EA\u30AF\u30A8\u30B9\u30C8\u3055\u308C\u307E\u3057\u305F\u304C\u3001\u30D7\u30ED\u30BB\u30C3\u30B5\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002
+
+compiler.warn.proc.use.implicit=\u6697\u9ED9\u7684\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u306F\u6CE8\u91C8\u51E6\u7406\u306B\u6E21\u3055\u308C\u307E\u305B\u3093\u3002\n-implicit\u3092\u4F7F\u7528\u3057\u6697\u9ED9\u7684\u30B3\u30F3\u30D1\u30A4\u30EB\u306E\u30DD\u30EA\u30B7\u30FC\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+compiler.warn.proc.use.proc.or.implicit=\u6697\u9ED9\u7684\u306B\u30B3\u30F3\u30D1\u30A4\u30EB\u3055\u308C\u305F\u30D5\u30A1\u30A4\u30EB\u306F\u6CE8\u91C8\u51E6\u7406\u306B\u6E21\u3055\u308C\u307E\u305B\u3093\u3002\n-proc:none\u3092\u4F7F\u7528\u3057\u6CE8\u91C8\u51E6\u7406\u3092\u7121\u52B9\u306B\u3059\u308B\u304B -implicit\u3092\u4F7F\u7528\u3057\u6697\u9ED9\u7684\u30B3\u30F3\u30D1\u30A4\u30EB\u306E\u30DD\u30EA\u30B7\u30FC\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+# Print a client-generated warning; assumed to be localized, no translation required
+# 0: string
+compiler.warn.proc.messager={0}
+
+# 0: set of name
+compiler.warn.proc.unclosed.type.files=\u30BF\u30A4\u30D7''{0}''\u306E\u30D5\u30A1\u30A4\u30EB\u304C\u9589\u3058\u3089\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u3053\u308C\u3089\u306E\u30BF\u30A4\u30D7\u306F\u6CE8\u91C8\u51E6\u7406\u3055\u308C\u307E\u305B\u3093
+
+# 0: string
+compiler.warn.proc.unmatched.processor.options=\u6B21\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3069\u306E\u30D7\u30ED\u30BB\u30C3\u30B5\u3067\u3082\u8A8D\u8B58\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F: ''{0}''
+
+compiler.warn.try.explicit.close.call=\u81EA\u52D5\u30AF\u30ED\u30FC\u30BA\u53EF\u80FD\u306A\u30EA\u30BD\u30FC\u30B9\u306B\u304A\u3051\u308Bclose()\u306E\u660E\u793A\u7684\u547C\u51FA\u3057
+
+# 0: symbol
+compiler.warn.try.resource.not.referenced=\u81EA\u52D5\u30AF\u30ED\u30FC\u30BA\u53EF\u80FD\u306A\u30EA\u30BD\u30FC\u30B9{0}\u306F\u5BFE\u5FDC\u3059\u308Btry\u6587\u306E\u672C\u4F53\u3067\u306F\u53C2\u7167\u3055\u308C\u307E\u305B\u3093
+
+# 0: type
+compiler.warn.try.resource.throws.interrupted.exc=\u81EA\u52D5\u30AF\u30ED\u30FC\u30BA\u53EF\u80FD\u306A\u30EA\u30BD\u30FC\u30B9{0}\u306B\u3001InterruptedException\u3092\u30B9\u30ED\u30FC\u3059\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B\u30E1\u30F3\u30D0\u30FC\u30FB\u30E1\u30BD\u30C3\u30C9close()\u304C\u3042\u308A\u307E\u3059
+
+compiler.warn.unchecked.assign={0}\u304B\u3089{1}\u3078\u306E\u7121\u691C\u67FB\u4EE3\u5165\u3067\u3059
+
+# 0: symbol, 1: type
+compiler.warn.unchecked.assign.to.var=raw\u578B{1}\u306E\u30E1\u30F3\u30D0\u30FC\u3068\u3057\u3066\u5909\u6570{0}\u3078\u306E\u7121\u691C\u67FB\u4EE3\u5165\u3067\u3059
+
+# 0: symbol, 1: type
+compiler.warn.unchecked.call.mbr.of.raw.type=raw\u578B{1}\u306E\u30E1\u30F3\u30D0\u30FC\u3068\u3057\u3066\u306E{0}\u3078\u306E\u7121\u691C\u67FB\u547C\u51FA\u3057\u3067\u3059
+
+compiler.warn.unchecked.cast.to.type=\u578B{0}\u3078\u306E\u7121\u691C\u67FB\u30AD\u30E3\u30B9\u30C8\u3067\u3059
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type, 4: symbol kind, 5: symbol
+compiler.warn.unchecked.meth.invocation.applied=\u7121\u691C\u67FB\u30E1\u30BD\u30C3\u30C9\u547C\u51FA\u3057: {4} {5}\u306E{0} {1}\u306F\u6307\u5B9A\u3055\u308C\u305F\u578B\u306B\u9069\u7528\u3055\u308C\u307E\u3059\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024: {3}
+
+# 0: type
+compiler.warn.unchecked.generic.array.creation=\u578B{0}\u306E\u53EF\u5909\u5F15\u6570\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u5BFE\u3059\u308B\u7DCF\u79F0\u578B\u914D\u5217\u306E\u7121\u691C\u67FB\u4F5C\u6210\u3067\u3059
+
+# 0: type
+compiler.warn.unchecked.varargs.non.reifiable.type=\u30D1\u30E9\u30E1\u30FC\u30BF\u5316\u3055\u308C\u305F\u53EF\u5909\u5F15\u6570\u578B{0}\u304B\u3089\u306E\u30D2\u30FC\u30D7\u6C5A\u67D3\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.warn.varargs.unsafe.use.varargs.param=\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u306F\u3001\u578B\u60C5\u5831\u4FDD\u6301\u53EF\u80FD\u3067\u306A\u3044\u53EF\u5909\u5F15\u6570\u30D1\u30E9\u30E1\u30FC\u30BF{0}\u304B\u3089\u306E\u30D2\u30FC\u30D7\u6C5A\u67D3\u306E\u539F\u56E0\u3068\u306A\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059
+
+compiler.warn.missing.deprecated.annotation=\u975E\u63A8\u5968\u306E\u9805\u76EE\u306F at Deprecated\u3067\u6CE8\u91C8\u304C\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.warn.invalid.archive.file=\u30D1\u30B9\u4E0A\u306E\u4E88\u671F\u3057\u306A\u3044\u30D5\u30A1\u30A4\u30EB: {0}
+
+compiler.warn.unexpected.archive.file=\u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u4E88\u671F\u3057\u306A\u3044\u62E1\u5F35\u5B50: {0}
+
+compiler.warn.div.zero=\u30BC\u30ED\u3067\u9664\u7B97
+
+compiler.warn.empty.if=if\u4EE5\u964D\u304C\u7A7A\u306E\u6587\u3067\u3059
+
+compiler.warn.annotation.method.not.found=\u30BF\u30A4\u30D7''{0}''\u5185\u306B\u6CE8\u91C8\u30E1\u30BD\u30C3\u30C9''{1}()''\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+
+compiler.warn.annotation.method.not.found.reason=\u30BF\u30A4\u30D7''{0}''\u5185\u306B\u6CE8\u91C8\u30E1\u30BD\u30C3\u30C9''{1}()''\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {2}
+
+# 0: symbol, 1: name
+compiler.warn.unknown.enum.constant=\u4E0D\u660E\u306A\u5217\u6319\u578B\u5B9A\u6570\u3067\u3059{1}.{2}
+
+# 0: symbol, 1: name, 2: message segment
+compiler.warn.unknown.enum.constant.reason=\u4E0D\u660E\u306A\u5217\u6319\u578B\u5B9A\u6570\u3067\u3059{1}.{2}\n\u7406\u7531: {3}
+
+# 0: type, 1: type
+compiler.warn.raw.class.use=raw\u578B\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {0}\n\u6C4E\u7528\u30AF\u30E9\u30B9{1}\u306E\u578B\u5F15\u6570\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: unused, 1: unused
+compiler.warn.diamond.redundant.args=\u65B0\u3057\u3044\u5F0F\u306E\u578B\u5F15\u6570\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059(\u304B\u308F\u308A\u306B\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u3057\u307E\u3059)\u3002
+
+# 0: type, 1: type
+compiler.warn.diamond.redundant.args.1=\u65B0\u3057\u3044\u5F0F\u306E\u578B\u5F15\u6570\u304C\u91CD\u8907\u3057\u3066\u3044\u307E\u3059(\u304B\u308F\u308A\u306B\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u3057\u307E\u3059)\u3002\n\u660E\u793A\u7684: {0}\n\u63A8\u8AD6: {1}
+
+# 0: symbol, 1: message segment
+compiler.warn.varargs.redundant.trustme.anno={0}\u6CE8\u91C8\u304C\u5197\u9577\u3067\u3059\u3002{1}
+
+#####
+
+## The following are tokens which are non-terminals in the language. They should
+## be named as JLS3 calls them when translated to the appropriate language.
+compiler.misc.token.identifier=<identifier>
+
+compiler.misc.token.character=<character>
+
+compiler.misc.token.string=<string>
+
+compiler.misc.token.integer=<integer>
+
+compiler.misc.token.long-integer=<long integer>
+
+compiler.misc.token.float=<float>
+
+compiler.misc.token.double=<double>
+
+compiler.misc.token.bad-symbol=<bad symbol>
+
+compiler.misc.token.end-of-input=<end of input>
+
+## The argument to the following string will always be one of the following:
+## 1. one of the above non-terminals
+## 2. a keyword (JLS1.8)
+## 3. a boolean literal (JLS3.10.3)
+## 4. the null literal (JLS3.10.7)
+## 5. a Java separator (JLS3.11)
+## 6. an operator (JLS3.12)
+##
+## This is the only place these tokens will be used.
+# 0: token
+compiler.err.expected={0}\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: token, 1: token
+compiler.err.expected2={0}\u307E\u305F\u306F{1}\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: token, 1: token, 2: token
+compiler.err.expected3={0}\u3001{1}\u307E\u305F\u306F{2}\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.premature.eof=\u69CB\u6587\u89E3\u6790\u4E2D\u306B\u30D5\u30A1\u30A4\u30EB\u306E\u7D42\u308F\u308A\u306B\u79FB\u308A\u307E\u3057\u305F
+
+## The following are related in form, but do not easily fit the above paradigm.
+compiler.err.dot.class.expected=''.class''\u304C\u3042\u308A\u307E\u305B\u3093
+
+## The argument to this string will always be either 'case' or 'default'.
+# 0: token
+compiler.err.orphaned={0}\u306B\u306F\u89AA\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: name
+compiler.misc.anonymous.class=<anonymous {0}>
+
+# 0: name, 1: type
+compiler.misc.type.captureof={1}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3#{0}
+
+compiler.misc.type.captureof.1=\u30AD\u30E3\u30D7\u30C1\u30E3#{0}
+
+compiler.misc.type.none=<none>
+
+compiler.misc.unnamed.package=\u540D\u524D\u306E\u306A\u3044\u30D1\u30C3\u30B1\u30FC\u30B8
+
+#####
+
+# 0: symbol, 1: message segment
+compiler.err.cant.access={0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\n{1}
+
+compiler.misc.bad.class.file.header=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306F\u4E0D\u6B63\u3067\u3059\n{1}\n\u524A\u9664\u3059\u308B\u304B\u3001\u30AF\u30E9\u30B9\u30D1\u30B9\u306E\u6B63\u3057\u3044\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u3042\u308B\u304B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+# 0: file name, 1: message segment
+compiler.misc.bad.source.file.header=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306F\u4E0D\u6B63\u3067\u3059\n{1}\n\u524A\u9664\u3059\u308B\u304B\u3001\u30BD\u30FC\u30B9\u30FB\u30D1\u30B9\u306E\u6B63\u3057\u3044\u30B5\u30D6\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306B\u3042\u308B\u304B\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
+
+## The following are all possible strings for the second argument ({1}) of the
+## above strings.
+compiler.misc.bad.class.signature=\u30AF\u30E9\u30B9{0}\u306E\u30B7\u30B0\u30CD\u30C1\u30E3\u304C\u4E0D\u6B63\u3067\u3059
+
+#0: symbol, 1: symbol
+compiler.misc.bad.enclosing.class={0}\u306E\u5185\u90E8\u30AF\u30E9\u30B9\u304C\u4E0D\u6B63\u3067\u3059: {1}
+
+# 0: symbol
+compiler.misc.bad.enclosing.method=\u30AF\u30E9\u30B9{0}\u306E\u56F2\u3093\u3067\u3044\u308B\u30E1\u30BD\u30C3\u30C9\u5C5E\u6027\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.misc.bad.runtime.invisible.param.annotations=RuntimeInvisibleParameterAnnotations\u5C5E\u6027\u304C\u4E0D\u6B63\u3067\u3059: {0}
+
+compiler.misc.bad.const.pool.tag=\u5B9A\u6570\u30D7\u30FC\u30EB\u30FB\u30BF\u30B0{0}\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.misc.bad.const.pool.tag.at=\u5B9A\u6570\u30D7\u30FC\u30EB\u30FB\u30BF\u30B0{1}\u3067\u306E{0}\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.misc.bad.signature=\u30B7\u30B0\u30CD\u30C1\u30E3{0}\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.misc.bad.type.annotation.value=\u6CE8\u91C8\u30BF\u30FC\u30B2\u30C3\u30C8\u578B\u306E\u5024\u306E\u578B\u304C\u4E0D\u6B63\u3067\u3059: {0}
+
+compiler.misc.class.file.wrong.class=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306B\u4E0D\u6B63\u306A\u30AF\u30E9\u30B9\u304C\u3042\u308A\u307E\u3059
+
+compiler.misc.class.file.not.found={0}\u306E\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+
+# 0: name
+compiler.misc.file.doesnt.contain.class=\u30D5\u30A1\u30A4\u30EB\u306B\u30AF\u30E9\u30B9{0}\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.misc.file.does.not.contain.package=\u30D5\u30A1\u30A4\u30EB\u306B\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.misc.illegal.start.of.class.file=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u958B\u59CB\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.misc.unable.to.access.file=\u30D5\u30A1\u30A4\u30EB{0}\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093
+
+compiler.misc.unicode.str.not.supported=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u5185\u306EUnicode\u6587\u5B57\u5217\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.misc.undecl.type.var=\u578B\u5909\u6570{0}\u306F\u5BA3\u8A00\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.misc.wrong.version=\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u30D0\u30FC\u30B8\u30E7\u30F3{0}.{1}\u306F\u4E0D\u6B63\u3067\u3059\u3002{2}.{3}\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+#####
+
+# 0: type, 1: type or symbol
+compiler.err.not.within.bounds=\u578B\u5F15\u6570{0}\u306F\u578B\u5909\u6570{1}\u306E\u5883\u754C\u5185\u306B\u3042\u308A\u307E\u305B\u3093
+
+## The following are all possible strings for the second argument ({1}) of the
+## above string.
+
+## none yet...
+
+#####
+
+# 0: message segment
+compiler.err.prob.found.req=\u4E0D\u9069\u5408\u306A\u578B: {0}
+
+# 0: message segment
+compiler.misc.prob.found.req=\u4E0D\u9069\u5408\u306A\u578B: {0}
+
+# 0: message segment, 1: type, 2: type
+compiler.warn.prob.found.req={0}\n\u671F\u5F85\u5024: {2}\n\u691C\u51FA\u5024:    {1}
+
+# 0: type, 1: type
+compiler.misc.inconvertible.types={0}\u3092{1}\u306B\u5909\u63DB\u3067\u304D\u307E\u305B\u3093:
+
+# 0: type, 1: type
+compiler.misc.possible.loss.of.precision=\u7CBE\u5EA6\u304C\u5931\u308F\u308C\u308B\u53EF\u80FD\u6027\u304C\u3042\u308B{0}\u304B\u3089{1}\u3078\u306E\u5909\u63DB
+
+compiler.misc.unchecked.assign=\u7121\u691C\u67FB\u5909\u63DB
+
+# compiler.misc.storecheck=\
+#     assignment might cause later store checks to fail
+# compiler.misc.unchecked=\
+#     assigned array cannot dynamically check its stores
+compiler.misc.unchecked.cast.to.type=\u7121\u691C\u67FB\u30AD\u30E3\u30B9\u30C8
+
+# compiler.err.star.expected=\
+#     ''*'' expected
+# compiler.err.no.elem.type=\
+#     \[\*\] cannot have a type
+
+# 0: type
+compiler.misc.try.not.applicable.to.type=try-with-resource\u306F\u5909\u6570\u578B\u306B\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\n({0})
+
+#####
+
+# 0: message segment or type, 1: message segment
+compiler.err.type.found.req=\u4E88\u671F\u3057\u306A\u3044\u578B\n\u671F\u5F85\u5024: {1}\n\u691C\u51FA\u5024:    {0}
+
+## The following are all possible strings for the first argument ({0}) of the
+## above string.
+compiler.misc.type.req.class=\u30AF\u30E9\u30B9
+
+compiler.misc.type.req.class.array=\u30AF\u30E9\u30B9\u307E\u305F\u306F\u914D\u5217
+
+compiler.misc.type.req.array.or.iterable=\u914D\u5217\u307E\u305F\u306Fjava.lang.Iterable
+
+compiler.misc.type.req.ref=\u53C2\u7167
+
+compiler.misc.type.req.exact=\u5883\u754C\u306E\u306A\u3044\u30AF\u30E9\u30B9\u307E\u305F\u306F\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
+
+# 0: type
+compiler.misc.type.parameter=\u578B\u30D1\u30E9\u30E1\u30FC\u30BF{0}
+
+#####
+
+## The following are all possible strings for the last argument of all those
+## diagnostics whose key ends in ".1"
+
+# 0: type, 1: list of type
+compiler.misc.no.unique.maximal.instance.exists=\u578B\u5909\u6570{0}(\u4E0A\u9650{1})\u306E\u56FA\u6709\u306E\u6700\u5927\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u307E\u305B\u3093
+
+compiler.misc.no.unique.minimal.instance.exists=\u578B\u5909\u6570{0}(\u4E0B\u9650{1})\u306E\u56FA\u6709\u306E\u6700\u5C0F\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u307E\u305B\u3093
+
+# 0: type, 1: list of type
+compiler.misc.incompatible.upper.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u4E0A\u9650{1}\u304C\u3042\u308A\u307E\u3059
+
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.upper.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u5883\u754C\u304C\u3042\u308A\u307E\u3059\n\u7B49\u4FA1\u5236\u7D04: {1}\n\u4E0A\u9650: {2}
+
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.lower.bounds=\u63A8\u8AD6\u5909\u6570{0}\u306B\u306F\u3001\u4E0D\u9069\u5408\u306A\u5883\u754C\u304C\u3042\u308A\u307E\u3059\n\u7B49\u4FA1\u5236\u7D04: {1}\n\u4E0B\u9650: {2}
+
+# 0: list of type, 1: type, 2: type
+compiler.misc.infer.no.conforming.instance.exists=\u578B\u5909\u6570{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u304C\u5B58\u5728\u3057\u306A\u3044\u306E\u3067\u3001{1}\u306F{2}\u306B\u9069\u5408\u3057\u307E\u305B\u3093
+
+# 0: list of type, 1: message segment
+compiler.misc.infer.no.conforming.assignment.exists=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {1})
+
+# 0: list of type
+compiler.misc.infer.arg.length.mismatch=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u5B9F\u5F15\u6570\u30EA\u30B9\u30C8\u3068\u4EEE\u5F15\u6570\u30EA\u30B9\u30C8\u306E\u9577\u3055\u304C\u7570\u306A\u308A\u307E\u3059)
+
+# 0: list of type, 1: message segment
+compiler.misc.infer.varargs.argument.mismatch=\u578B\u5909\u6570{0}\u3092\u63A8\u8AD6\u3067\u304D\u307E\u305B\u3093\n(\u53EF\u5909\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {1})
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.upper.bounds=\u63A8\u8AD6\u578B\u304C\u4E0A\u9650\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u4E0A\u9650: {1}
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.lower.bounds=\u63A8\u8AD6\u578B\u304C\u4E0B\u9650\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u4E0B\u9650: {1}
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.eq.bounds=\u63A8\u8AD6\u578B\u304C\u7B49\u4FA1\u5236\u7D04\u306B\u9069\u5408\u3057\u307E\u305B\u3093\n\u63A8\u8AD6: {0}\n\u7B49\u4FA1\u5236\u7D04: {1}
+
+# 0: list of type
+compiler.misc.cyclic.inference=\u63A8\u8AD6\u306E\u30EB\u30FC\u30D7\u306E\u305F\u3081\u3001\u63A8\u8AD6\u5909\u6570{0}\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u3092\u751F\u6210\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol
+compiler.misc.diamond={0}<>
+
+# 0: type
+compiler.misc.diamond.non.generic=\u975E\u6C4E\u7528\u30AF\u30E9\u30B9{0}\u3067''<>''\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: unused
+compiler.misc.diamond.and.explicit.params=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306E\u660E\u793A\u7684\u306A\u578B\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u306F''<>''\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+# 0: type, 1: list of type
+compiler.misc.explicit.param.do.not.conform.to.bounds=\u660E\u793A\u7684\u306A\u578B\u5F15\u6570{0}\u306F\u3001\u5BA3\u8A00\u3055\u308C\u305F\u5883\u754C{1}\u306B\u9069\u5408\u3057\u307E\u305B\u3093
+
+compiler.misc.arg.length.mismatch=\u5B9F\u5F15\u6570\u30EA\u30B9\u30C8\u3068\u4EEE\u5F15\u6570\u30EA\u30B9\u30C8\u306E\u9577\u3055\u304C\u7570\u306A\u308A\u307E\u3059
+
+# 0: message segment
+compiler.misc.no.conforming.assignment.exists=\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {0}
+
+# 0: message segment
+compiler.misc.varargs.argument.mismatch=\u53EF\u5909\u5F15\u6570\u306E\u4E0D\u4E00\u81F4: {0}
+
+#####
+
+# 0: symbol or type, 1: file name
+compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file={1}\u306E\u88DC\u52A9\u30AF\u30E9\u30B9{0}\u306B\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u5916\u304B\u3089\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093
+
+## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol, 2: symbol
+compiler.err.abstract.cant.be.accessed.directly=\u62BD\u8C61{0}\u3067\u3042\u308B{1}({2}\u5185)\u306B\u76F4\u63A5\u30A2\u30AF\u30BB\u30B9\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol
+compiler.err.non-static.cant.be.ref=static\u3067\u306A\u3044{0} {1}\u3092static\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304B\u3089\u53C2\u7167\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol kind, 1: symbol
+compiler.misc.non-static.cant.be.ref=static\u3067\u306A\u3044{0} {1}\u3092static\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8\u304B\u3089\u53C2\u7167\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol kind, 1: symbol
+compiler.misc.static.method.in.unbound.lookup=\u975E\u30D0\u30A4\u30F3\u30C9\u691C\u7D22\u3067\u9759\u7684\u306A{0} {1}\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F
+
+## Both arguments ({0}, {1}) are "kindname"s.  {0} is a comma-separated list
+## of kindnames (the list should be identical to that provided in source.
+compiler.err.unexpected.type=\u4E88\u671F\u3057\u306A\u3044\u578B\n\u671F\u5F85\u5024: {0}\n\u691C\u51FA\u5024:    {1}
+
+compiler.err.unexpected.lambda=\u3053\u3053\u3067\u306F\u30E9\u30E0\u30C0\u5F0F\u306F\u4E88\u671F\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.unexpected.mref=\u3053\u3053\u3067\u306F\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306F\u4E88\u671F\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+
+## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
+## The second argument {1} is the non-resolved symbol
+## The third argument {2} is a list of type parameters (non-empty if {1} is a method)
+## The fourth argument {3} is a list of argument types (non-empty if {1} is a method)
+# 0: symbol kind, 1: name, 2: unused, 3: unused
+compiler.err.cant.resolve=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} {1}
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type
+compiler.err.cant.resolve.args=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} {1}({3})
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type
+compiler.err.cant.resolve.args.params=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB: {0} <{2}>{1}({3})
+
+## arguments from {0} to {3} have the same meaning as above
+## The fifth argument {4} is a location subdiagnostic (see below)
+# 0: symbol kind, 1: name, 2: unused, 3: unused, 4: message segment
+compiler.err.cant.resolve.location=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB:   {0} {1}\n\u5834\u6240: {4}
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
+compiler.err.cant.resolve.location.args=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB:   {0} {1}({3})\n\u5834\u6240: {4}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
+compiler.err.cant.resolve.location.args.params=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB:   {0} <{2}>{1}({3})\n\u5834\u6240: {4}
+
+### Following are replicated/used for method reference diagnostics
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
+compiler.misc.cant.resolve.location.args=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB:   {0} {1}({3})\n\u5834\u6240: {4}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
+compiler.misc.cant.resolve.location.args.params=\u30B7\u30F3\u30DC\u30EB\u3092\u898B\u3064\u3051\u3089\u308C\u307E\u305B\u3093\n\u30B7\u30F3\u30DC\u30EB:   {0} <{2}>{1}({3})\n\u5834\u6240: {4}
+
+##a location subdiagnostic is composed as follows:
+## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.)
+## The second argument {1} is the location name
+## The third argument {2} is the location type (only when {1} is a variable name)
+
+# 0: symbol kind, 1: type or symbol, 2: unused
+compiler.misc.location={0} {1}
+
+# 0: symbol kind, 1: symbol, 2: type
+compiler.misc.location.1=\u30BF\u30A4\u30D7{2}\u306E{0} {1}
+
+## The following are all possible string for "kindname".
+## They should be called whatever the JLS calls them after it been translated
+## to the appropriate language.
+# compiler.misc.kindname.constructor=\
+#     static member
+compiler.misc.kindname.annotation=@interface
+
+compiler.misc.kindname.constructor=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
+
+compiler.misc.kindname.enum=\u5217\u6319\u578B
+
+compiler.misc.kindname.interface=\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9
+
+compiler.misc.kindname.static=static
+
+compiler.misc.kindname.type.variable=\u578B\u5909\u6570
+
+compiler.misc.kindname.type.variable.bound=\u578B\u5909\u6570\u306E\u5883\u754C
+
+compiler.misc.kindname.variable=\u5909\u6570
+
+compiler.misc.kindname.value=\u5024
+
+compiler.misc.kindname.method=\u30E1\u30BD\u30C3\u30C9
+
+compiler.misc.kindname.class=\u30AF\u30E9\u30B9
+
+compiler.misc.kindname.package=\u30D1\u30C3\u30B1\u30FC\u30B8
+
+compiler.misc.kindname.static.init=static\u521D\u671F\u5316\u5B50
+
+compiler.misc.kindname.instance.init=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u521D\u671F\u5316\u5B50
+
+#####
+
+compiler.misc.no.args=\u5F15\u6570\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: message segment
+compiler.err.override.static={0}\n\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B\u30E1\u30BD\u30C3\u30C9\u304Cstatic\u3067\u3059
+
+# 0: message segment, 1: set of modifier
+compiler.err.override.meth={0}\n\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306F{1}\u3067\u3059
+
+# 0: message segment, 1: type
+compiler.err.override.meth.doesnt.throw={0}\n\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306F{1}\u3092\u30B9\u30ED\u30FC\u3057\u307E\u305B\u3093
+
+# In the following string {1} is a space separated list of Java Keywords, as
+# they would have been declared in the source code
+# 0: message segment, 1: set of modifier
+compiler.err.override.weaker.access={0}\n({1})\u3088\u308A\u5F31\u3044\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u3092\u5272\u308A\u5F53\u3066\u3088\u3046\u3068\u3057\u307E\u3057\u305F
+
+# 0: message segment, 1: type, 2: type
+compiler.err.override.incompatible.ret={0}\n\u623B\u308A\u5024\u306E\u578B{1}\u306F{2}\u3068\u4E92\u63DB\u6027\u304C\u3042\u308A\u307E\u305B\u3093
+
+# 0: message segment, 1: type, 2: type
+compiler.warn.override.unchecked.ret={0}\n\u623B\u308A\u5024\u306E\u578B\u306F{1}\u304B\u3089{2}\u3078\u306E\u7121\u691C\u67FB\u5909\u63DB\u304C\u5FC5\u8981\u3067\u3059
+
+# 0: message segment, 1: type
+compiler.warn.override.unchecked.thrown={0}\n\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3055\u308C\u305F\u30E1\u30BD\u30C3\u30C9\u306F{1}\u3092\u30B9\u30ED\u30FC\u3057\u307E\u305B\u3093
+
+# 0: symbol
+compiler.warn.override.equals.but.not.hashcode=\u30AF\u30E9\u30B9{0}\u306F\u7B49\u53F7\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059\u304C\u3001\u3053\u306E\u30AF\u30E9\u30B9\u3082\u30B9\u30FC\u30D1\u30FC\u30AF\u30E9\u30B9\u3082hashCode\u30E1\u30BD\u30C3\u30C9\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u305B\u3093
+
+## The following are all possible strings for the first argument ({0}) of the
+## above strings.
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.cant.override={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.cant.implement={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u5B9F\u88C5\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.clashes.with={1}\u306E{0}\u306F{3}\u306E{2}\u3068\u7AF6\u5408\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.override={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.implement={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u5B9F\u88C5\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.clash.with={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.override={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.implement={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u5B9F\u88C5\u3057\u307E\u3059
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.clash.with={1}\u306E{0}\u306F{3}\u306E{2}\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3057\u307E\u3059
+
+# 0: unused
+compiler.misc.diamond.and.anon.class=\u533F\u540D\u5185\u90E8\u30AF\u30E9\u30B9\u3067\u306F''<>''\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093
+
+# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
+compiler.misc.inapplicable.method={0} {1}.{2}\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093\n({3})
+
+########################################
+# Diagnostics for language feature changes
+########################################
+# 0: string
+compiler.err.unsupported.fp.lit=16\u9032\u6570\u6D6E\u52D5\u5C0F\u6570\u70B9\u30EA\u30C6\u30E9\u30EB\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(16\u9032\u6570\u6D6E\u52D5\u5C0F\u6570\u70B9\u30EA\u30C6\u30E9\u30EB\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.unsupported.binary.lit=2\u9032\u6570\u30EA\u30C6\u30E9\u30EB\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(2\u9032\u6570\u30EA\u30C6\u30E9\u30EB\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.unsupported.underscore.lit=\u30EA\u30C6\u30E9\u30EB\u5185\u306E\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30EA\u30C6\u30E9\u30EB\u5185\u306E\u30A2\u30F3\u30C0\u30FC\u30B9\u30B3\u30A2\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.try.with.resources.not.supported.in.source=try-with-resource\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(try-with-resource\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+compiler.warn.enum.as.identifier=\u30EA\u30EA\u30FC\u30B95\u304B\u3089''enum''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''enum''\u3092\u30AD\u30FC\u30EF\u30FC\u30C9\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+compiler.warn.assert.as.identifier=\u30EA\u30EA\u30FC\u30B91.4\u304B\u3089''assert''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u3001\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''assert''\u3092\u30AD\u30FC\u30EF\u30FC\u30C9\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F\u3001-source 1.4\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+compiler.warn.underscore.as.identifier=\u8B58\u5225\u5B50\u3068\u3057\u3066''_''\u304C\u4F7F\u7528\u3055\u308C\u307E\u3057\u305F\n(\u8B58\u5225\u5B50\u3068\u3057\u3066\u306E''_''\u306E\u4F7F\u7528\u306F\u3001\u5C06\u6765\u306E\u30EA\u30EA\u30FC\u30B9\u3067\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u306A\u3044\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059)
+
+compiler.err.enum.as.identifier=\u30EA\u30EA\u30FC\u30B95\u304B\u3089''enum''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''enum''\u3092\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F-source 1.4\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+compiler.err.assert.as.identifier=\u30EA\u30EA\u30FC\u30B91.4\u304B\u3089''assert''\u306F\u30AD\u30FC\u30EF\u30FC\u30C9\u306A\u306E\u3067\u3001\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\n(''assert''\u3092\u8B58\u5225\u5B50\u3068\u3057\u3066\u4F7F\u7528\u3059\u308B\u306B\u306F\u3001-source 1.3\u4EE5\u524D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# TODO 308: make a better error message
+compiler.err.this.as.identifier=\u30EA\u30EA\u30FC\u30B98\u304B\u3089''this''\u306F\u53D7\u4FE1\u30BF\u30A4\u30D7\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u540D\u3068\u3057\u3066\u306E\u307F\u8A31\u53EF\u3055\u308C\u3001\u6700\u521D\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
+
+# 0: symbol
+compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class=\u53D7\u53D6\u308A\u5074\u30D1\u30E9\u30E1\u30FC\u30BF\u306F\u6700\u4E0A\u4F4D\u30EC\u30D9\u30EB\u30FB\u30AF\u30E9\u30B9\u306E\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF\u306B\u9069\u7528\u3067\u304D\u307E\u305B\u3093
+
+# TODO 308: make a better error message
+compiler.err.cant.annotate.static.class=\u5305\u542B\u3059\u308Bstatic\u306E\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30AF\u30E9\u30B9\u306F\u6CE8\u91C8\u4ED8\u3051\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# TODO 308: make a better error message
+# 0: unused
+compiler.err.cant.annotate.nested.type=\u30CD\u30B9\u30C8\u3055\u308C\u305F\u30BF\u30A4\u30D7\u306F\u6CE8\u91C8\u4ED8\u3051\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093
+
+# 0: type, 1: type
+compiler.err.incorrect.receiver.name=\u53D7\u53D6\u308A\u5074\u306E\u540D\u524D\u304C\u3001\u5305\u542B\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30BF\u30A4\u30D7\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\n\u5FC5\u9808: {0}\n\u691C\u51FA: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.receiver.type=\u53D7\u53D6\u308A\u5074\u306E\u30BF\u30A4\u30D7\u304C\u3001\u5305\u542B\u3059\u308B\u30AF\u30E9\u30B9\u30FB\u30BF\u30A4\u30D7\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\n\u5FC5\u9808: {0}\n\u691C\u51FA: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.type=\u53D7\u53D6\u308A\u5074\u306E\u30BF\u30A4\u30D7\u304C\u3001\u5305\u542B\u3059\u308B\u5916\u90E8\u30AF\u30E9\u30B9\u30FB\u30BF\u30A4\u30D7\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\n\u5FC5\u9808: {0}\n\u691C\u51FA: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.name=\u53D7\u53D6\u308A\u5074\u306E\u540D\u524D\u304C\u3001\u5305\u542B\u3059\u308B\u5916\u90E8\u30AF\u30E9\u30B9\u30FB\u30BF\u30A4\u30D7\u3068\u4E00\u81F4\u3057\u307E\u305B\u3093\n\u5FC5\u9808: {0}\n\u691C\u51FA: {1}
+
+compiler.err.no.annotations.on.dot.class=\u6CE8\u91C8\u306F\u30AF\u30E9\u30B9\u30FB\u30EA\u30C6\u30E9\u30EB\u306E\u30BF\u30A4\u30D7\u3067\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093
+
+# 0: string
+compiler.err.generics.not.supported.in.source=\u7DCF\u79F0\u578B\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u7DCF\u79F0\u578B\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.varargs.not.supported.in.source=\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u53EF\u5909\u5F15\u6570\u30E1\u30BD\u30C3\u30C9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.annotations.not.supported.in.source=\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.type.annotations.not.supported.in.source=\u30BF\u30A4\u30D7\u6CE8\u91C8\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30BF\u30A4\u30D7\u6CE8\u91C8\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.foreach.not.supported.in.source=for-each\u30EB\u30FC\u30D7\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(for-each\u30EB\u30FC\u30D7\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.static.import.not.supported.in.source=static import\u5BA3\u8A00\u306F -source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(static import\u5BA3\u8A00\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.enums.not.supported.in.source=\u5217\u6319\u578B\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u5217\u6319\u578B\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F-source 5\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.diamond.not.supported.in.source=\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30C0\u30A4\u30E4\u30E2\u30F3\u30C9\u6F14\u7B97\u5B50\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.multicatch.not.supported.in.source=\u8907\u6570catch\u6587\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u8907\u6570catch\u6587\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.string.switch.not.supported.in.source=switch\u5185\u306E\u6587\u5B57\u5217\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(switch\u5185\u306E\u6587\u5B57\u5217\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 7\u4EE5\u964D\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.lambda.not.supported.in.source=\u30E9\u30E0\u30C0\u5F0F\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30E9\u30E0\u30C0\u5F0F\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.method.references.not.supported.in.source=\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30E1\u30BD\u30C3\u30C9\u53C2\u7167\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.default.methods.not.supported.in.source=\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.intersection.types.in.cast.not.supported.in.source=\u30AD\u30E3\u30B9\u30C8\u5185\u306Eintersection\u578B\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+# 0: string
+compiler.err.static.intf.methods.not.supported.in.source=static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u306F-source {0}\u3067\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\n(static\u30A4\u30F3\u30BF\u30D5\u30A7\u30FC\u30B9\u3092\u4F7F\u7528\u53EF\u80FD\u306B\u3059\u308B\u306B\u306F\u3001-source 8\u4EE5\u4E0A\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044)
+
+########################################
+# Diagnostics for verbose resolution
+# used by Resolve (debug only)
+########################################
+
+# 0: number, 1: symbol, 2: unused
+compiler.misc.applicable.method.found=#{0}\u500B\u306E\u4F7F\u7528\u53EF\u80FD\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1}
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.applicable.method.found.1=#{0}\u500B\u306E\u4F7F\u7528\u53EF\u80FD\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1}\n({2})
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.not.applicable.method.found=#{0}\u500B\u306E\u4F7F\u7528\u3067\u304D\u306A\u3044\u30E1\u30BD\u30C3\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F: {1}\n({2})
+
+# 0: type
+compiler.misc.partial.inst.sig=\u90E8\u5206\u7684\u306B\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3055\u308C\u307E\u3057\u305F: {0}
+
+# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi=\u578B{1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u3092\u5019\u88DC{2}\u306B\u89E3\u6C7A\u3057\u3066\u3044\u307E\u3059\n\u30D5\u30A7\u30FC\u30BA: {3}\n\u5B9F\u969B\u306E\u578B: {4}\n\u578B\u5F15\u6570: {5}\n\u5019\u88DC:
+
+# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi.1=\u578B{1}\u306E\u30E1\u30BD\u30C3\u30C9{0}\u306E\u89E3\u6C7A\u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\n\u30D5\u30A7\u30FC\u30BA: {3}\n\u5B9F\u969B\u306E\u578B: {4}\n\u578B\u5F15\u6570: {5}\n\u5019\u88DC:
+
+# 0: symbol, 1: type, 2: type
+compiler.note.deferred.method.inst=\u30E1\u30BD\u30C3\u30C9{0}\u306E\u9045\u5EF6\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\n\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u5316\u3055\u308C\u305F\u30B7\u30B0\u30CD\u30C1\u30E3: {1}\n\u30BF\u30FC\u30B2\u30C3\u30C8\u578B: {2}
+
+########################################
+# Diagnostics for where clause implementation
+# used by the RichDiagnosticFormatter.
+########################################
+
+compiler.misc.type.null=<null>
+
+# X#n (where n is an int id) is disambiguated tvar name
+# 0: name, 1: number
+compiler.misc.type.var={0}#{1}
+
+# CAP#n (where n is an int id) is an abbreviation for 'captured type'
+# 0: number
+compiler.misc.captured.type=CAP#{0}
+
+# <INT#n> (where n is an int id) is an abbreviation for 'intersection type'
+# 0: number
+compiler.misc.intersection.type=INT#{0}
+
+# where clause for captured type: contains upper ('extends {1}') and lower
+# ('super {2}') bound along with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: type, 3: type
+compiler.misc.where.captured={0}\u306F{3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089{1}\u3092\u62E1\u5F35\u3057{2}\u3092\u30B9\u30FC\u30D1\u30FC\u3057\u307E\u3059
+
+# compact where clause for captured type: contains upper ('extends {1}') along
+# with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: unused, 3: type
+compiler.misc.where.captured.1={0}\u306F{3}\u306E\u30AD\u30E3\u30D7\u30C1\u30E3\u304B\u3089{1}\u3092\u62E1\u5F35\u3057\u307E\u3059
+
+# where clause for type variable: contains upper bound(s) ('extends {1}') along with
+# the kindname ({2}) and location ({3}) in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
+compiler.misc.where.typevar={2} {3}\u3067\u5BA3\u8A00\u3055\u308C\u3066\u3044\u308B{0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059
+
+# compact where clause for type variable: contains the kindname ({2}) and location ({3})
+# in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
+compiler.misc.where.typevar.1={2} {3}\u3067\u5BA3\u8A00\u3055\u308C\u305F{0}
+
+# where clause for fresh type variable: contains upper bound(s) ('extends {1}').
+# Since a fresh type-variable is synthetic - there's no location/kindname here.
+# 0: type, 1: list of type
+compiler.misc.where.fresh.typevar={0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059
+
+# where clause for type variable: contains all the upper bound(s) ('extends {1}')
+# of this intersection type
+# 0: type, 1: list of type
+compiler.misc.where.intersection={0}\u306F{1}\u3092\u62E1\u5F35\u3057\u307E\u3059
+
+### Where clause headers ###
+compiler.misc.where.description.captured={0}\u304C\u65B0\u3057\u3044\u578B\u5909\u6570\u306E\u5834\u5408:
+
+# 0: set of type
+compiler.misc.where.description.typevar={0}\u304C\u578B\u5909\u6570\u306E\u5834\u5408:
+
+# 0: set of type
+compiler.misc.where.description.intersection={0}\u304Cintersection\u578B\u306E\u5834\u5408:
+
+# 0: set of type
+compiler.misc.where.description.captured.1={0}\u304C\u65B0\u3057\u3044\u578B\u5909\u6570\u306E\u5834\u5408:
+
+# 0: set of type
+compiler.misc.where.description.typevar.1={0}\u304C\u578B\u5909\u6570\u306E\u5834\u5408:
+
+compiler.misc.where.description.intersection.1={0}\u304Cintersection\u578B\u306E\u5834\u5408:
+
+###
+# errors related to doc comments
+
+compiler.err.dc.bad.entity=HTML\u30A8\u30F3\u30C6\u30A3\u30C6\u30A3\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.dc.bad.gt=''>''\u306E\u4F7F\u7528\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.dc.bad.inline.tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0\u306E\u4F7F\u7528\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.dc.identifier.expected=\u8B58\u5225\u5B50\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.dc.malformed.html=HTML\u304C\u4E0D\u6B63\u3067\u3059
+
+compiler.err.dc.missing.semicolon=\u30BB\u30DF\u30B3\u30ED\u30F3\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.dc.no.content=\u30B3\u30F3\u30C6\u30F3\u30C4\u306A\u3057
+
+compiler.err.dc.no.tag.name='@'\u306E\u5F8C\u306B\u30BF\u30B0\u540D\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.dc.gt.expected=''>''\u304C\u5FC5\u8981\u3067\u3059
+
+compiler.err.dc.ref.bad.parens=\u53C2\u7167\u306B'')''\u304C\u3042\u308A\u307E\u305B\u3093
+
+compiler.err.dc.ref.syntax.error=\u53C2\u7167\u306B\u69CB\u6587\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059
+
+compiler.err.dc.ref.unexpected.input=\u4E88\u671F\u3057\u306A\u3044\u30C6\u30AD\u30B9\u30C8\u3067\u3059
+
+compiler.err.dc.unexpected.content=\u4E88\u671F\u3057\u306A\u3044\u30B3\u30F3\u30C6\u30F3\u30C4\u3067\u3059
+
+compiler.err.dc.unterminated.inline.tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.dc.unterminated.signature=\u30B7\u30B0\u30CD\u30C1\u30E3\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093
+
+compiler.err.dc.unterminated.string=\u6587\u5B57\u5217\u304C\u7D42\u4E86\u3057\u3066\u3044\u307E\u305B\u3093
+
+
diff --git a/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties
new file mode 100644
index 0000000..b2e76c0
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler_zh_CN.properties
@@ -0,0 +1,1758 @@
+#
+# 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
+# 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.
+#
+
+# Messages in this file which use "placeholders" for values (e.g. {0}, {1})
+# are preceded by a stylized comment describing the type of the corresponding
+# values.
+# The types currently in use are
+#
+# boolean           true or false
+# file name         the name of an input file; e.g.   MyFile.java
+# message segment   a sub-message; see compiler.misc.*
+# modifier          a Java modifier; e.g. public, private, protected
+# name              a name, typically a Java identifier
+# number            an integer
+# option name       the name of a command line option
+# source version    a source version number, such as 1.5, 1.6, 1.7
+# string            a general string
+# symbol            the name of a declared type
+# symbol kind       a description of the kind of a declaration; see compiler.misc.kindname.*
+# token             the name of a non-terminal in source code; see compiler.misc.token.*
+# type              a Java type; e.g. int, X, X<T>
+# unused            the value is not used in this message
+#
+# list of X         a comma-separated list of items; e.g. list of type
+# X or Y            alternation; e.g. message segment or type
+# set of X          a comma-separated collection of items; e.g. set of modifier
+#
+# These may be composed: e.g.   list of type or message segment
+#
+# These comments are verified by the jtreg test test/tools/javac/diags/MessageInfo,
+# using info derived from the collected set of examples in test/tools/javac/diags/examples.
+# MessageInfo can also be run as a standalone utility providing more facilities
+# for manipulating this file. For more details, see MessageInfo.java.
+
+##
+## errors
+##
+
+# 0: symbol
+compiler.err.abstract.cant.be.instantiated={0}\u662F\u62BD\u8C61\u7684; \u65E0\u6CD5\u5B9E\u4F8B\u5316
+
+compiler.err.abstract.meth.cant.have.body=\u62BD\u8C61\u65B9\u6CD5\u4E0D\u80FD\u6709\u4E3B\u4F53
+
+compiler.err.already.annotated={0} {1}\u5DF2\u8FDB\u884C\u6CE8\u91CA
+
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol
+compiler.err.already.defined=\u5DF2\u5728{2} {3}\u4E2D\u5B9A\u4E49\u4E86{0} {1}
+
+# 0: symbol kind, 1: symbol, 2: symbol kind, 3: symbol kind, 4: symbol
+compiler.err.already.defined.in.clinit=\u5DF2\u5728{3} {4}\u7684{2}\u4E2D\u5B9A\u4E49\u4E86{0} {1}
+
+# 0: string
+compiler.err.already.defined.single.import=\u5DF2\u5728 single-type \u5BFC\u5165\u4E2D\u5B9A\u4E49{0}
+
+# 0: string
+compiler.err.already.defined.static.single.import=\u5DF2\u5728\u9759\u6001 single-type \u5BFC\u5165\u4E2D\u5B9A\u4E49{0}
+
+compiler.err.already.defined.this.unit=\u5DF2\u5728\u8BE5\u7F16\u8BD1\u5355\u5143\u4E2D\u5B9A\u4E49{0}
+
+# 0: type, 1: list of name
+compiler.err.annotation.missing.default.value=\u5BF9\u4E8E\u5C5E\u6027{1}, \u6CE8\u91CA{0}\u7F3A\u5C11\u503C
+
+# 0: type, 1: list of name
+compiler.err.annotation.missing.default.value.1=\u5BF9\u4E8E\u5C5E\u6027{1}, \u6CE8\u91CA{0}\u7F3A\u5C11\u503C
+
+# 0: type
+compiler.err.annotation.not.valid.for.type=\u5BF9\u4E8E\u7C7B\u578B\u4E3A{0}\u7684\u503C, \u6CE8\u91CA\u65E0\u6548
+
+compiler.err.annotation.type.not.applicable=\u6CE8\u91CA\u7C7B\u578B\u4E0D\u9002\u7528\u4E8E\u8BE5\u7C7B\u578B\u7684\u58F0\u660E
+
+compiler.err.annotation.value.must.be.annotation=\u6CE8\u91CA\u503C\u5FC5\u987B\u4E3A\u6CE8\u91CA
+
+compiler.err.annotation.value.must.be.class.literal=\u6CE8\u91CA\u503C\u5FC5\u987B\u4E3A\u7C7B\u6587\u5B57
+
+compiler.err.annotation.value.must.be.name.value=\u6CE8\u91CA\u503C\u5FC5\u987B\u91C7\u7528 ''name=value'' \u683C\u5F0F
+
+compiler.err.annotation.value.not.allowable.type=\u6CE8\u91CA\u503C\u4E0D\u662F\u5141\u8BB8\u7684\u7C7B\u578B
+
+compiler.err.anon.class.impl.intf.no.args=\u533F\u540D\u7C7B\u5B9E\u73B0\u63A5\u53E3; \u4E0D\u80FD\u6709\u53C2\u6570
+
+compiler.err.anon.class.impl.intf.no.typeargs=\u533F\u540D\u7C7B\u5B9E\u73B0\u63A5\u53E3; \u4E0D\u80FD\u5177\u6709\u7C7B\u578B\u53C2\u6570
+
+compiler.err.anon.class.impl.intf.no.qual.for.new=\u533F\u540D\u7C7B\u5B9E\u73B0\u63A5\u53E3; \u4E0D\u80FD\u6709\u9650\u5B9A\u7B26 - \u5BF9\u4E8E\u65B0
+
+# 0: symbol, 1: symbol, 2: symbol
+compiler.err.array.and.varargs=\u65E0\u6CD5\u5728{2}\u4E2D\u540C\u65F6\u58F0\u660E{0}\u548C{1}
+
+compiler.err.array.dimension.missing=\u7F3A\u5C11\u6570\u7EC4\u7EF4
+
+# 0: type
+compiler.err.array.req.but.found=\u9700\u8981\u6570\u7EC4, \u4F46\u627E\u5230{0}
+
+compiler.err.attribute.value.must.be.constant=\u5C5E\u6027\u503C\u5FC5\u987B\u4E3A\u5E38\u91CF
+
+# 0: statement type
+compiler.err.bad.initializer={0}\u7684\u521D\u59CB\u5316\u7A0B\u5E8F\u9519\u8BEF
+
+compiler.err.break.outside.switch.loop=\u5728 switch \u6216 loop \u5916\u90E8\u4E2D\u65AD
+
+# 0: name
+compiler.err.call.must.be.first.stmt.in.ctor=\u5BF9{0}\u7684\u8C03\u7528\u5FC5\u987B\u662F\u6784\u9020\u5668\u4E2D\u7684\u7B2C\u4E00\u4E2A\u8BED\u53E5
+
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
+compiler.err.cant.apply.symbol=\u65E0\u6CD5\u5C06{4} {5}\u4E2D\u7684{0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B;\n\u9700\u8981: {2}\n\u627E\u5230: {3}\n\u539F\u56E0: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
+compiler.err.cant.apply.symbols=\u5BF9\u4E8E{1}({2}), \u627E\u4E0D\u5230\u5408\u9002\u7684{0}
+
+# 0: symbol kind, 1: name, 2: list of type or message segment, 3: list of type or message segment, 4: symbol kind, 5: type, 6: message segment
+compiler.misc.cant.apply.symbol=\u65E0\u6CD5\u5C06 {4} {5}\u4E2D\u7684 {0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7C7B\u578B\n\u9700\u8981: {2}\n\u627E\u5230: {3}\n\u539F\u56E0: {6}
+
+# 0: symbol kind, 1: name, 2: list of type
+compiler.misc.cant.apply.symbols=\u5BF9\u4E8E{1}({2}), \u627E\u4E0D\u5230\u5408\u9002\u7684{0}
+
+# 0: symbol kind, 1: symbol
+compiler.misc.no.abstracts=\u5728 {0} {1} \u4E2D\u627E\u4E0D\u5230\u62BD\u8C61\u65B9\u6CD5
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.abstracts=\u5728 {0} {1} \u4E2D\u627E\u5230\u591A\u4E2A\u975E\u8986\u76D6\u62BD\u8C61\u65B9\u6CD5
+
+compiler.err.bad.functional.intf.anno=\u610F\u5916\u7684 @FunctionalInterface \u6CE8\u91CA
+
+# 0: message segment
+compiler.err.bad.functional.intf.anno.1=\u610F\u5916\u7684 @FunctionalInterface \u6CE8\u91CA\n{0}
+
+# 0: symbol
+compiler.misc.not.a.functional.intf={0} \u4E0D\u662F\u51FD\u6570\u63A5\u53E3
+
+# 0: symbol, 1: message segment
+compiler.misc.not.a.functional.intf.1={0} \u4E0D\u662F\u51FD\u6570\u63A5\u53E3\n{1}
+
+# 0: symbol, 1: symbol kind, 2: symbol
+compiler.misc.invalid.generic.lambda.target=lambda \u8868\u8FBE\u5F0F\u7684\u51FD\u6570\u63CF\u8FF0\u7B26\u65E0\u6548\n{1} {2} \u4E2D\u7684\u65B9\u6CD5 {0} \u4E3A\u6CDB\u578B\u65B9\u6CD5
+
+# 0: symbol kind, 1: symbol
+compiler.misc.incompatible.descs.in.functional.intf=\u5728 {0} {1} \u4E2D\u627E\u5230\u4E0D\u517C\u5BB9\u7684\u51FD\u6570\u63CF\u8FF0\u7B26
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor=\u63CF\u8FF0\u7B26: {2} {0}({1})
+
+# 0: name, 1: list of type, 2: type, 3: list of type
+compiler.misc.descriptor.throws=\u63CF\u8FF0\u7B26: {2} {0}({1}) \u629B\u51FA{3}
+
+# 0: type
+compiler.misc.no.suitable.functional.intf.inst=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u51FD\u6570\u63A5\u53E3\u63CF\u8FF0\u7B26
+
+# 0: message segment
+compiler.misc.bad.intersection.target.for.functional.expr=lambda \u6216\u65B9\u6CD5\u5F15\u7528\u7684\u4EA4\u53C9\u7C7B\u578B\u76EE\u6807\u9519\u8BEF\n{0}
+
+# 0: symbol or type
+compiler.misc.not.an.intf.component=\u7EC4\u4EF6\u7C7B\u578B{0}\u4E0D\u662F\u63A5\u53E3
+
+# 0: symbol kind, 1: message segment
+compiler.err.invalid.mref={0}\u5F15\u7528\u65E0\u6548\n{1}
+
+# 0: symbol kind, 1: message segment
+compiler.misc.invalid.mref={0}\u5F15\u7528\u65E0\u6548\n{1}
+
+compiler.misc.static.mref.with.targs=\u6709\u5173\u9759\u6001\u65B9\u6CD5\u5F15\u7528\u7684\u53C2\u6570\u5316\u9650\u5B9A\u7B26
+
+compiler.misc.static.bound.mref=\u9759\u6001\u9650\u5236\u8303\u56F4\u65B9\u6CD5\u5F15\u7528
+
+# 0: symbol
+compiler.err.cant.assign.val.to.final.var=\u65E0\u6CD5\u4E3A\u6700\u7EC8\u53D8\u91CF{0}\u5206\u914D\u503C
+
+# 0: symbol, 1: message segment
+compiler.err.cant.ref.non.effectively.final.var=\u4ECE{1}\u5F15\u7528\u7684\u672C\u5730\u53D8\u91CF\u5FC5\u987B\u662F\u6700\u7EC8\u53D8\u91CF\u6216\u5B9E\u9645\u4E0A\u7684\u6700\u7EC8\u53D8\u91CF
+
+
+compiler.misc.lambda=lambda \u8868\u8FBE\u5F0F
+
+compiler.misc.inner.cls=\u5185\u90E8\u7C7B
+
+# 0: type
+compiler.err.cant.deref=\u65E0\u6CD5\u53D6\u6D88\u5F15\u7528{0}
+
+compiler.err.cant.extend.intf.annotation=\u5BF9\u4E8E @interfaces, \u4E0D\u5141\u8BB8 ''extends''
+
+# 0: symbol
+compiler.err.cant.inherit.from.final=\u65E0\u6CD5\u4ECE\u6700\u7EC8{0}\u8FDB\u884C\u7EE7\u627F
+
+# 0: symbol
+compiler.err.cant.ref.before.ctor.called=\u65E0\u6CD5\u5728\u8C03\u7528\u8D85\u7C7B\u578B\u6784\u9020\u5668\u4E4B\u524D\u5F15\u7528{0}
+
+compiler.err.cant.select.static.class.from.param.type=\u65E0\u6CD5\u4ECE\u53C2\u6570\u5316\u7684\u7C7B\u578B\u4E2D\u9009\u62E9\u9759\u6001\u7C7B
+
+# 0: symbol, 1: string, 2: string
+compiler.err.cant.inherit.diff.arg=\u65E0\u6CD5\u4F7F\u7528\u4EE5\u4E0B\u4E0D\u540C\u7684\u53C2\u6570\u7EE7\u627F{0}: <{1}> \u548C <{2}>
+
+compiler.err.catch.without.try=\u6709 ''catch'', \u4F46\u662F\u6CA1\u6709 ''try''
+
+# 0: symbol kind, 1: symbol
+compiler.err.clash.with.pkg.of.same.name={0} {1}\u4E0E\u5E26\u6709\u76F8\u540C\u540D\u79F0\u7684\u7A0B\u5E8F\u5305\u51B2\u7A81
+
+compiler.err.class.not.allowed=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u7C7B, \u63A5\u53E3\u6216\u679A\u4E3E\u58F0\u660E
+
+compiler.err.const.expr.req=\u9700\u8981\u5E38\u91CF\u8868\u8FBE\u5F0F
+
+compiler.err.cont.outside.loop=continue \u5728 loop \u5916\u90E8
+
+# 0: symbol
+compiler.err.cyclic.inheritance=\u6D89\u53CA{0}\u7684\u5FAA\u73AF\u7EE7\u627F
+
+compiler.err.cyclic.annotation.element=\u5FAA\u73AF\u6CE8\u91CA\u5143\u7D20\u7C7B\u578B
+
+# 0: unused
+compiler.err.call.to.super.not.allowed.in.enum.ctor=\u5728\u679A\u4E3E\u6784\u9020\u5668\u4E2D\u4E0D\u5141\u8BB8\u8C03\u7528\u8D85\u7C7B
+
+# 0: type
+compiler.err.no.superclass={0}\u4E0D\u5177\u6709\u8D85\u7C7B
+
+# 0: symbol, 1: type, 2: symbol, 3: type, 4: unused
+compiler.err.concrete.inheritance.conflict={1}\u4E2D\u7684\u65B9\u6CD5{0}\u548C{3}\u4E2D\u7684\u65B9\u6CD5{2}\u662F\u4F7F\u7528\u76F8\u540C\u7684\u7B7E\u540D\u7EE7\u627F\u7684
+
+compiler.err.default.allowed.in.intf.annotation.member=\u4EC5\u5728 @interface \u6210\u5458\u4E2D\u5141\u8BB8\u4F7F\u7528\u9ED8\u8BA4\u503C
+
+# 0: symbol
+compiler.err.doesnt.exist=\u7A0B\u5E8F\u5305{0}\u4E0D\u5B58\u5728
+
+compiler.err.duplicate.annotation=\u6CE8\u91CA\u91CD\u590D
+
+# 0: type
+compiler.err.duplicate.annotation.invalid.repeated=\u65E0\u6CD5\u91CD\u590D\u6CE8\u91CA{0}\n\u5B83\u6CA1\u6709\u5B9A\u4E49\u6709\u6548\u7684\u5305\u542B\u6CE8\u91CA\u3002
+
+# 0: name, 1: type
+compiler.err.duplicate.annotation.member.value={1}\u4E2D\u7684\u6CE8\u91CA\u6210\u5458\u503C{0}\u91CD\u590D
+
+# 0: type, 1: type
+compiler.err.duplicate.annotation.missing.container=\u6CE8\u91CA\u91CD\u590D: {0}\u7684\u58F0\u660E\u6CA1\u6709\u6709\u6548\u7684{1}\u6CE8\u91CA
+
+# 0: type
+compiler.err.invalid.repeatable.annotation=\u6CE8\u91CA\u91CD\u590D: \u4F7F\u7528\u65E0\u6548\u7684 Repeatable \u6CE8\u91CA\u5BF9{0}\u8FDB\u884C\u4E86\u6CE8\u91CA
+
+# 0: symbol or type
+compiler.err.invalid.repeatable.annotation.no.value=\u6CE8\u91CA\u91CD\u590D: {0}\u4E0D\u662F\u6709\u6548\u7684 Repeatable, \u672A\u58F0\u660E\u4EFB\u4F55\u503C\u5143\u7D20\u65B9\u6CD5
+
+# 0: type, 1: number
+compiler.err.invalid.repeatable.annotation.multiple.values=\u6CE8\u91CA\u91CD\u590D: {0}\u4E0D\u662F\u6709\u6548\u7684 Repeatable, \u5DF2\u58F0\u660E {1} \u4E2A\u503C\u5143\u7D20\u65B9\u6CD5
+
+# 0: type
+compiler.err.invalid.repeatable.annotation.invalid.value=\u6CE8\u91CA\u91CD\u590D: {0}\u4E0D\u662F\u6709\u6548\u7684 Repeatable: \u503C\u5143\u7D20\u65E0\u6548
+
+# 0: symbol type, 1: type, 2: type
+compiler.err.invalid.repeatable.annotation.value.return=\u6CE8\u91CA\u91CD\u590D: \u5305\u542B\u6CE8\u91CA{0}\u7684\u503C\u5143\u7D20\u5E94\u5177\u6709\u7C7B\u578B{2}, \u4F46\u627E\u5230\u7684\u662F{1}
+
+# 0: symbol or type, 1: symbol
+compiler.err.invalid.repeatable.annotation.elem.nondefault=\u5305\u542B\u6CE8\u91CA{0}\u6CA1\u6709\u5143\u7D20 {1} \u7684\u9ED8\u8BA4\u503C
+
+# 0: symbol, 1: type, 2: symbol, 3: type
+compiler.err.invalid.repeatable.annotation.retention=\u5305\u542B\u6CE8\u91CA {0} \u7684\u4FDD\u7559\u671F ({1}) \u77ED\u4E8E\u5DF2\u5305\u542B\u6CE8\u91CA {2} \u7684\u4FDD\u7559\u671F ({3})
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.documented=\u5305\u542B\u6CE8\u91CA\u7C7B\u578B {0} \u4E0D\u662F @Documented, \u800C\u91CD\u590D\u7684\u6CE8\u91CA\u7C7B\u578B {1} \u4E3A
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.not.inherited=\u5305\u542B\u6CE8\u91CA\u7C7B\u578B {0} \u4E0D\u662F @Inherited, \u800C\u91CD\u590D\u7684\u6CE8\u91CA\u7C7B\u578B {1} \u4E3A
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.repeatable.annotation.incompatible.target=\u5BB9\u5668\u6CE8\u91CA {0} \u7684\u76EE\u6807\u4E0D\u662F\u91CD\u590D\u6CE8\u91CA {1} \u7684\u76EE\u6807\u5B50\u96C6
+
+# 0: symbol
+compiler.err.invalid.repeatable.annotation.repeated.and.container.present=\u5BB9\u5668 {0} \u4E0D\u5F97\u4E0E\u5176\u5305\u542B\u7684\u5143\u7D20\u540C\u65F6\u5B58\u5728
+
+# 0: name
+compiler.err.duplicate.class=\u7C7B\u91CD\u590D: {0}
+
+compiler.err.duplicate.case.label=case \u6807\u7B7E\u91CD\u590D
+
+compiler.err.duplicate.default.label=default \u6807\u7B7E\u91CD\u590D
+
+compiler.err.else.without.if=\u6709 ''if'', \u4F46\u662F\u6CA1\u6709 ''else''
+
+compiler.err.empty.char.lit=\u7A7A\u5B57\u7B26\u6587\u5B57
+
+# 0: symbol
+compiler.err.encl.class.required=\u9700\u8981\u5305\u542B{0}\u7684\u5C01\u95ED\u5B9E\u4F8B
+
+compiler.err.enum.annotation.must.be.enum.constant=\u679A\u4E3E\u6CE8\u91CA\u503C\u5FC5\u987B\u662F\u679A\u4E3E\u5E38\u91CF
+
+compiler.err.enum.cant.be.instantiated=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u679A\u4E3E\u7C7B\u578B
+
+compiler.err.enum.label.must.be.unqualified.enum=\u679A\u4E3E switch case \u6807\u7B7E\u5FC5\u987B\u4E3A\u679A\u4E3E\u5E38\u91CF\u7684\u975E\u9650\u5B9A\u540D\u79F0
+
+compiler.err.enum.no.subclassing=\u7C7B\u65E0\u6CD5\u76F4\u63A5\u6269\u5C55 java.lang.Enum
+
+compiler.err.enum.types.not.extensible=\u679A\u4E3E\u7C7B\u578B\u4E0D\u53EF\u7EE7\u627F
+
+compiler.err.enum.no.finalize=\u679A\u4E3E\u4E0D\u80FD\u6709 finalize \u65B9\u6CD5
+
+# 0: file name, 1: string
+compiler.err.error.reading.file=\u8BFB\u53D6{0}\u65F6\u51FA\u9519; {1}
+
+# 0: type
+compiler.err.except.already.caught=\u5DF2\u6355\u83B7\u5230\u5F02\u5E38\u9519\u8BEF{0}
+
+# 0: type
+compiler.err.except.never.thrown.in.try=\u5728\u76F8\u5E94\u7684 try \u8BED\u53E5\u4E3B\u4F53\u4E2D\u4E0D\u80FD\u629B\u51FA\u5F02\u5E38\u9519\u8BEF{0}
+
+# 0: symbol
+compiler.err.final.parameter.may.not.be.assigned=\u4E0D\u80FD\u5206\u914D\u6700\u7EC8\u53C2\u6570{0}
+
+# 0: symbol
+compiler.err.try.resource.may.not.be.assigned=\u53EF\u80FD\u672A\u5206\u914D\u53EF\u81EA\u52A8\u5173\u95ED\u7684\u8D44\u6E90{0}
+
+# 0: symbol
+compiler.err.multicatch.parameter.may.not.be.assigned=\u53EF\u80FD\u672A\u5206\u914D multi-catch \u53C2\u6570{0}
+
+# 0: type, 1: type
+compiler.err.multicatch.types.must.be.disjoint=multi-catch \u8BED\u53E5\u4E2D\u7684\u66FF\u4EE3\u65E0\u6CD5\u901A\u8FC7\u5B50\u7C7B\u5316\u5173\u8054\n\u66FF\u4EE3{0}\u662F\u66FF\u4EE3{1}\u7684\u5B50\u7C7B
+
+compiler.err.finally.without.try=\u6709 ''finally'', \u4F46\u662F\u6CA1\u6709 ''try''
+
+# 0: type, 1: message segment
+compiler.err.foreach.not.applicable.to.type=for-each \u4E0D\u9002\u7528\u4E8E\u8868\u8FBE\u5F0F\u7C7B\u578B\n\u8981\u6C42: {1}\n\u627E\u5230:    {0}
+
+compiler.err.fp.number.too.large=\u6D6E\u70B9\u6570\u8FC7\u5927
+
+compiler.err.fp.number.too.small=\u6D6E\u70B9\u6570\u8FC7\u5C0F
+
+compiler.err.generic.array.creation=\u521B\u5EFA\u6CDB\u578B\u6570\u7EC4
+
+compiler.err.generic.throwable=\u6CDB\u578B\u7C7B\u4E0D\u80FD\u6269\u5C55 java.lang.Throwable
+
+# 0: symbol
+compiler.err.icls.cant.have.static.decl=\u5185\u90E8\u7C7B{0}\u4E2D\u7684\u9759\u6001\u58F0\u660E\u975E\u6CD5\n\u4FEE\u9970\u7B26 ''static'' \u4EC5\u5141\u8BB8\u5728\u5E38\u91CF\u53D8\u91CF\u58F0\u660E\u4E2D\u4F7F\u7528
+
+# 0: string
+compiler.err.illegal.char=\u975E\u6CD5\u5B57\u7B26: ''{0}''
+
+compiler.err.illegal.char.for.encoding=\u7F16\u7801{0}\u7684\u4E0D\u53EF\u6620\u5C04\u5B57\u7B26
+
+# 0: set of modifier, 1: set of modifier
+compiler.err.illegal.combination.of.modifiers=\u975E\u6CD5\u7684\u4FEE\u9970\u7B26\u7EC4\u5408: {0}\u548C{1}
+
+compiler.err.illegal.enum.static.ref=\u521D\u59CB\u5316\u7A0B\u5E8F\u4E2D\u5BF9\u9759\u6001\u5B57\u6BB5\u7684\u5F15\u7528\u4E0D\u5408\u6CD5
+
+compiler.err.illegal.esc.char=\u975E\u6CD5\u8F6C\u4E49\u7B26
+
+compiler.err.illegal.forward.ref=\u975E\u6CD5\u524D\u5411\u5F15\u7528
+
+# 0: symbol, 1: string
+compiler.err.not.in.profile={0}\u5728\u914D\u7F6E\u6587\u4EF6 ''{1}'' \u4E2D\u4E0D\u53EF\u7528
+
+# 0: symbol
+compiler.warn.forward.ref=\u5148\u5F15\u7528\u53D8\u91CF ''{0}'', \u7136\u540E\u518D\u5BF9\u5176\u521D\u59CB\u5316
+
+compiler.err.illegal.self.ref=\u521D\u59CB\u5316\u7A0B\u5E8F\u4E2D\u5B58\u5728\u81EA\u5F15\u7528
+
+# 0: symbol
+compiler.warn.self.ref=\u53D8\u91CF ''{0}'' \u7684\u521D\u59CB\u5316\u7A0B\u5E8F\u4E2D\u5B58\u5728\u81EA\u5F15\u7528
+
+compiler.err.illegal.generic.type.for.instof=instanceof \u7684\u6CDB\u578B\u7C7B\u578B\u4E0D\u5408\u6CD5
+
+# 0: type
+compiler.err.illegal.initializer.for.type={0}\u7684\u521D\u59CB\u5316\u7A0B\u5E8F\u4E0D\u5408\u6CD5
+
+compiler.err.illegal.line.end.in.char.lit=\u5B57\u7B26\u6587\u5B57\u7684\u884C\u7ED3\u5C3E\u4E0D\u5408\u6CD5
+
+compiler.err.illegal.nonascii.digit=\u975E\u6CD5\u7684\u975E ASCII \u6570\u5B57
+
+compiler.err.illegal.underscore=\u975E\u6CD5\u4E0B\u5212\u7EBF
+
+compiler.err.illegal.dot=\u975E\u6CD5 ''.''
+
+# 0: symbol
+compiler.err.illegal.qual.not.icls=\u975E\u6CD5\u9650\u5B9A\u7B26; {0}\u4E0D\u662F\u5185\u90E8\u7C7B
+
+compiler.err.illegal.start.of.expr=\u975E\u6CD5\u7684\u8868\u8FBE\u5F0F\u5F00\u59CB
+
+compiler.err.illegal.start.of.stmt=\u975E\u6CD5\u7684\u8BED\u53E5\u5F00\u59CB
+
+compiler.err.illegal.start.of.type=\u975E\u6CD5\u7684\u7C7B\u578B\u5F00\u59CB
+
+compiler.err.illegal.unicode.esc=\u975E\u6CD5\u7684 Unicode \u8F6C\u4E49
+
+# 0: symbol
+compiler.err.import.requires.canonical=\u5BFC\u5165\u9700\u8981{0}\u7684\u89C4\u8303\u540D\u79F0
+
+compiler.err.improperly.formed.type.param.missing=\u7C7B\u578B\u7684\u683C\u5F0F\u4E0D\u6B63\u786E, \u7F3A\u5C11\u67D0\u4E9B\u53C2\u6570
+
+compiler.err.improperly.formed.type.inner.raw.param=\u7C7B\u578B\u7684\u683C\u5F0F\u4E0D\u6B63\u786E, \u7ED9\u51FA\u4E86\u539F\u59CB\u7C7B\u578B\u7684\u7C7B\u578B\u53C2\u6570
+
+# 0: type, 1: type
+compiler.err.incomparable.types=\u4E0D\u53EF\u6BD4\u8F83\u7684\u7C7B\u578B: {0}\u548C{1}
+
+# 0: number
+compiler.err.int.number.too.large=\u8FC7\u5927\u7684\u6574\u6570: {0}
+
+compiler.err.intf.annotation.members.cant.have.params=@interface \u6210\u5458\u4E0D\u80FD\u5E26\u6709\u53C2\u6570
+
+compiler.err.intf.annotation.cant.have.type.params=@interface \u4E0D\u80FD\u5E26\u6709\u7C7B\u578B\u53C2\u6570
+
+compiler.err.intf.annotation.members.cant.have.type.params=@interface \u6210\u5458\u4E0D\u80FD\u5E26\u6709\u7C7B\u578B\u53C2\u6570
+
+# 0: symbol, 1: type
+compiler.err.intf.annotation.member.clash=@interface \u6210\u5458\u4E0E{1}\u4E2D\u7684\u65B9\u6CD5 ''{0}'' \u51B2\u7A81
+
+compiler.err.intf.expected.here=\u6B64\u5904\u9700\u8981\u63A5\u53E3
+
+compiler.err.intf.meth.cant.have.body=\u63A5\u53E3\u62BD\u8C61\u65B9\u6CD5\u4E0D\u80FD\u5E26\u6709\u4E3B\u4F53
+
+compiler.err.invalid.annotation.member.type=\u6CE8\u91CA\u6210\u5458\u7684\u7C7B\u578B\u65E0\u6548
+
+compiler.err.invalid.binary.number=\u4E8C\u8FDB\u5236\u6570\u5B57\u4E2D\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u4E8C\u8FDB\u5236\u6570
+
+compiler.err.invalid.hex.number=\u5341\u516D\u8FDB\u5236\u6570\u5B57\u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4F4D\u5341\u516D\u8FDB\u5236\u6570
+
+compiler.err.invalid.meth.decl.ret.type.req=\u65B9\u6CD5\u58F0\u660E\u65E0\u6548; \u9700\u8981\u8FD4\u56DE\u7C7B\u578B
+
+compiler.err.varargs.and.old.array.syntax=variable-arity \u53C2\u6570\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u4F20\u7EDF\u6570\u7EC4\u8BB0\u53F7
+
+compiler.err.varargs.and.receiver =\u63A5\u6536\u65B9\u53C2\u6570\u4E0D\u5141\u8BB8\u4F7F\u7528 varargs \u8BB0\u53F7
+
+compiler.err.array.and.receiver =\u63A5\u6536\u65B9\u53C2\u6570\u4E0D\u5141\u8BB8\u4F7F\u7528\u4F20\u7EDF\u6570\u7EC4\u8BB0\u53F7
+
+compiler.err.variable.not.allowed=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u53D8\u91CF\u58F0\u660E
+
+# 0: name
+compiler.err.label.already.in.use=\u6807\u7B7E{0}\u5DF2\u4F7F\u7528
+
+# 0: symbol
+compiler.err.local.var.accessed.from.icls.needs.final=\u4ECE\u5185\u90E8\u7C7B\u4E2D\u8BBF\u95EE\u672C\u5730\u53D8\u91CF{0}; \u9700\u8981\u88AB\u58F0\u660E\u4E3A\u6700\u7EC8\u7C7B\u578B
+
+compiler.err.local.enum=\u679A\u4E3E\u7C7B\u578B\u4E0D\u80FD\u4E3A\u672C\u5730\u7C7B\u578B
+
+compiler.err.cannot.create.array.with.type.arguments=\u65E0\u6CD5\u521B\u5EFA\u5177\u6709\u7C7B\u578B\u53D8\u91CF\u7684\u6570\u7EC4
+
+compiler.err.cannot.create.array.with.diamond=\u65E0\u6CD5\u521B\u5EFA\u5177\u6709 ''<>'' \u7684\u6570\u7EC4
+
+#
+# limits.  We don't give the limits in the diagnostic because we expect
+# them to change, yet we want to use the same diagnostic.  These are all
+# detected during code generation.
+#
+compiler.err.limit.code=\u4EE3\u7801\u8FC7\u957F
+
+compiler.err.limit.code.too.large.for.try.stmt=try \u8BED\u53E5\u7684\u4EE3\u7801\u8FC7\u957F
+
+compiler.err.limit.dimensions=\u6570\u7EC4\u7C7B\u578B\u7EF4\u8FC7\u591A
+
+compiler.err.limit.locals=\u672C\u5730\u53D8\u91CF\u8FC7\u591A
+
+compiler.err.limit.parameters=\u53C2\u6570\u8FC7\u591A
+
+compiler.err.limit.pool=\u5E38\u91CF\u8FC7\u591A
+
+compiler.err.limit.pool.in.class=\u7C7B{0}\u4E2D\u7684\u5E38\u91CF\u8FC7\u591A
+
+compiler.err.limit.stack=\u4EE3\u7801\u9700\u8981\u8FC7\u591A\u5806\u6808
+
+compiler.err.limit.string=\u5E38\u91CF\u5B57\u7B26\u4E32\u8FC7\u957F
+
+compiler.err.limit.string.overflow=\u5BF9\u4E8E\u5E38\u91CF\u6C60\u6765\u8BF4, \u5B57\u7B26\u4E32 "{0}..." \u7684 UTF8 \u8868\u793A\u8FC7\u957F
+
+compiler.err.malformed.fp.lit=\u6D6E\u70B9\u6587\u5B57\u7684\u683C\u5F0F\u9519\u8BEF
+
+compiler.err.method.does.not.override.superclass=\u65B9\u6CD5\u4E0D\u4F1A\u8986\u76D6\u6216\u5B9E\u73B0\u8D85\u7C7B\u578B\u7684\u65B9\u6CD5
+
+compiler.err.missing.meth.body.or.decl.abstract=\u7F3A\u5C11\u65B9\u6CD5\u4E3B\u4F53, \u6216\u58F0\u660E\u62BD\u8C61
+
+compiler.err.missing.ret.stmt=\u7F3A\u5C11\u8FD4\u56DE\u8BED\u53E5
+
+# 0: unused
+compiler.misc.missing.ret.val=\u7F3A\u5C11\u8FD4\u56DE\u503C
+
+compiler.misc.unexpected.ret.val=\u610F\u5916\u7684\u8FD4\u56DE\u503C
+
+# 0: set of modifier
+compiler.err.mod.not.allowed.here=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u4FEE\u9970\u7B26{0}
+
+compiler.err.intf.not.allowed.here=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528\u63A5\u53E3
+
+compiler.err.enums.must.be.static=\u53EA\u6709\u5728\u9759\u6001\u4E0A\u4E0B\u6587\u4E2D\u624D\u5141\u8BB8\u4F7F\u7528\u679A\u4E3E\u58F0\u660E
+
+# 0: symbol, 1: symbol
+compiler.err.name.clash.same.erasure=\u540D\u79F0\u51B2\u7A81: {0}\u548C{1}\u5177\u6709\u76F8\u540C\u7591\u7B26
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused
+compiler.err.name.clash.same.erasure.no.override=\u540D\u79F0\u51B2\u7A81: {1}\u4E2D\u7684{0}\u548C{3}\u4E2D\u7684{2}\u5177\u6709\u76F8\u540C\u7591\u7B26, \u4F46\u4E24\u8005\u5747\u4E0D\u8986\u76D6\u5BF9\u65B9
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol
+compiler.err.name.clash.same.erasure.no.override.1=\u540D\u79F0\u51B2\u7A81: {1} \u4E2D\u7684 {0} \u8986\u76D6\u7684\u65B9\u6CD5\u7684\u7591\u7B26\u4E0E\u53E6\u4E00\u4E2A\u65B9\u6CD5\u7684\u76F8\u540C, \u4F46\u4E24\u8005\u5747\u4E0D\u8986\u76D6\u5BF9\u65B9\n\u7B2C\u4E00\u4E2A\u65B9\u6CD5:  {3} \u4E2D\u7684 {2}\n\u7B2C\u4E8C\u4E2A\u65B9\u6CD5: {5} \u4E2D\u7684 {4}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.err.name.clash.same.erasure.no.hide=\u540D\u79F0\u51B2\u7A81: {1} \u4E2D\u7684 {0} \u548C {3} \u4E2D\u7684 {2} \u5177\u6709\u76F8\u540C\u7591\u7B26, \u4F46\u4E24\u8005\u5747\u4E0D\u9690\u85CF\u5BF9\u65B9
+
+compiler.err.name.reserved.for.internal.use={0}\u4E3A\u5185\u90E8\u4F7F\u7528\u4FDD\u7559
+
+compiler.err.native.meth.cant.have.body=\u672C\u673A\u65B9\u6CD5\u4E0D\u80FD\u5E26\u6709\u4E3B\u4F53
+
+# 0: type, 1: type
+compiler.err.neither.conditional.subtype=? \u7684\u4E0D\u517C\u5BB9\u7C7B\u578B: \u4E24\u8005\u90FD\u4E0D\u662F\u5BF9\u65B9\u7684\u5B50\u7C7B\u578B\n\u7B2C\u4E8C\u4E2A\u64CD\u4F5C\u6570: {0}\n\u7B2C\u4E09\u4E2A\u64CD\u4F5C\u6570: {1}
+
+# 0: message segment
+compiler.misc.incompatible.type.in.conditional=\u6761\u4EF6\u8868\u8FBE\u5F0F\u4E2D\u7684\u7C7B\u578B\u9519\u8BEF\n{0}
+
+compiler.misc.conditional.target.cant.be.void=\u6761\u4EF6\u8868\u8FBE\u5F0F\u7684\u76EE\u6807\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u8FD4\u56DE\u7C7B\u578B\u9519\u8BEF\n{0}
+
+# 0: type
+compiler.misc.incompatible.ret.type.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u7684\u8FD4\u56DE\u7C7B\u578B\u9519\u8BEF\n{0}
+
+# 0: list of type
+compiler.err.incompatible.thrown.types.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u629B\u51FA\u7684\u7C7B\u578B{0}\u4E0D\u517C\u5BB9
+
+# 0: list of type
+compiler.err.incompatible.thrown.types.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u629B\u51FA\u7684\u7C7B\u578B{0}\u4E0D\u517C\u5BB9
+
+compiler.misc.incompatible.arg.types.in.lambda=lambda \u8868\u8FBE\u5F0F\u4E2D\u7684\u53C2\u6570\u7C7B\u578B\u4E0D\u517C\u5BB9
+
+compiler.misc.incompatible.arg.types.in.mref=\u65B9\u6CD5\u5F15\u7528\u4E2D\u7684\u53C2\u6570\u7C7B\u578B\u4E0D\u517C\u5BB9
+
+# 0: list of type, 1: message segment
+compiler.misc.bad.arg.types.in.lambda=\u65E0\u6CD5\u4F7F\u7528\u63A8\u65AD\u53C2\u6570\u7C7B\u578B\u5BF9 lambda \u8868\u8FBE\u5F0F\u8FDB\u884C\u7C7B\u578B\u68C0\u67E5\n\u63A8\u65AD\u7C7B\u578B: {0}
+
+compiler.err.new.not.allowed.in.annotation=\u6CE8\u91CA\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 ''new''
+
+compiler.err.no.annotation.member={1}\u4E2D\u6CA1\u6709\u6CE8\u91CA\u6210\u5458{0}
+
+compiler.err.no.encl.instance.of.type.in.scope=\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u7C7B\u578B\u4E3A{0}\u7684\u5C01\u95ED\u5B9E\u4F8B
+
+compiler.err.no.intf.expected.here=\u6B64\u5904\u4E0D\u9700\u8981\u63A5\u53E3
+
+compiler.err.no.match.entry={0}\u5728{1}\u7684\u6761\u76EE\u4E2D\u6CA1\u6709\u5339\u914D\u9879; \u9700\u8981{2}
+
+compiler.err.not.annotation.type={0}\u4E0D\u662F\u6CE8\u91CA\u7C7B\u578B
+
+# 0: symbol, 1: symbol
+compiler.err.not.def.access.class.intf.cant.access={1}\u4E2D\u7684{0}\u662F\u5728\u4E0D\u53EF\u8BBF\u95EE\u7684\u7C7B\u6216\u63A5\u53E3\u4E2D\u5B9A\u4E49\u7684
+
+# 0: symbol, 1: symbol
+compiler.misc.not.def.access.class.intf.cant.access={1}\u4E2D\u7684{0}\u662F\u5728\u4E0D\u53EF\u8BBF\u95EE\u7684\u7C7B\u6216\u63A5\u53E3\u4E2D\u5B9A\u4E49\u7684
+
+# 0: symbol, 1: list of type, 2: type
+compiler.misc.cant.access.inner.cls.constr=\u65E0\u6CD5\u8BBF\u95EE\u6784\u9020\u5668 {0}({1})\n\u4F5C\u7528\u57DF\u4E2D\u6CA1\u6709\u7C7B\u578B\u4E3A{2}\u7684\u5C01\u95ED\u5B9E\u4F8B
+
+# 0: symbol, 1: symbol
+compiler.err.not.def.public.cant.access={0}\u5728{1}\u4E2D\u4E0D\u662F\u516C\u5171\u7684; \u65E0\u6CD5\u4ECE\u5916\u90E8\u7A0B\u5E8F\u5305\u4E2D\u5BF9\u5176\u8FDB\u884C\u8BBF\u95EE
+
+# 0: symbol, 1: symbol
+compiler.misc.not.def.public.cant.access={0}\u5728{1}\u4E2D\u4E0D\u662F\u516C\u5171\u7684; \u65E0\u6CD5\u4ECE\u5916\u90E8\u7A0B\u5E8F\u5305\u4E2D\u5BF9\u5176\u8FDB\u884C\u8BBF\u95EE
+
+# 0: name
+compiler.err.not.loop.label=\u4E0D\u662F loop \u6807\u7B7E: {0}
+
+compiler.err.not.stmt=\u4E0D\u662F\u8BED\u53E5
+
+# 0: symbol
+compiler.err.not.encl.class=\u4E0D\u662F\u5C01\u95ED\u7C7B: {0}
+
+# 0: name, 1: type, 2: unused
+compiler.err.operator.cant.be.applied=\u4E00\u5143\u8FD0\u7B97\u7B26 ''{0}'' \u7684\u64CD\u4F5C\u6570\u7C7B\u578B{1}\u9519\u8BEF
+
+# 0: name, 1: type, 2: type
+compiler.err.operator.cant.be.applied.1=\u4E8C\u5143\u8FD0\u7B97\u7B26 ''{0}'' \u7684\u64CD\u4F5C\u6570\u7C7B\u578B\u9519\u8BEF\n\u7B2C\u4E00\u4E2A\u7C7B\u578B:  {1}\n\u7B2C\u4E8C\u4E2A\u7C7B\u578B: {2}
+
+compiler.err.pkg.annotations.sb.in.package-info.java=\u7A0B\u5E8F\u5305\u6CE8\u91CA\u5E94\u5728\u6587\u4EF6 package-info.java \u4E2D
+
+# 0: symbol
+compiler.err.pkg.clashes.with.class.of.same.name=\u7A0B\u5E8F\u5305{0}\u4E0E\u5E26\u6709\u76F8\u540C\u540D\u79F0\u7684\u7C7B\u51B2\u7A81
+
+compiler.err.warnings.and.werror=\u53D1\u73B0\u8B66\u544A, \u4F46\u6307\u5B9A\u4E86 -Werror
+
+# Errors related to annotation processing
+
+# 0: symbol, 1: string, 2: stack-trace
+compiler.err.proc.cant.access=\u65E0\u6CD5\u8BBF\u95EE{0}\n{1}\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n{2}
+
+# 0: symbol, 1: string
+compiler.err.proc.cant.access.1=\u65E0\u6CD5\u8BBF\u95EE{0}\n{1}
+
+# 0: string
+compiler.err.proc.cant.find.class=\u627E\u4E0D\u5230 ''{0}'' \u7684\u7C7B\u6587\u4EF6\u3002
+
+# Print a client-generated error message; assumed to be localized, no translation required
+# 0: string
+compiler.err.proc.messager={0}
+
+# 0: list of string
+compiler.err.proc.no.explicit.annotation.processing.requested=\u4EC5\u5F53\u663E\u5F0F\u8BF7\u6C42\u6CE8\u91CA\u5904\u7406\u65F6\u624D\u63A5\u53D7\u7C7B\u540D\u79F0 ''{0}''
+
+compiler.err.proc.no.service=ServiceLoader \u4E0D\u53EF\u7528, \u4F46\u5B83\u662F\u6CE8\u91CA\u5904\u7406\u6240\u5FC5\u9700\u7684\u3002
+
+compiler.err.proc.processor.bad.option.name=\u5904\u7406\u7A0B\u5E8F ''{1}'' \u63D0\u4F9B\u7684\u9009\u9879\u540D\u79F0 ''{0}'' \u9519\u8BEF
+
+# 0: string
+compiler.err.proc.processor.cant.instantiate=\u65E0\u6CD5\u5B9E\u4F8B\u5316\u5904\u7406\u7A0B\u5E8F ''{0}'' \u7684\u5B9E\u4F8B
+
+# 0: string
+compiler.err.proc.processor.not.found=\u627E\u4E0D\u5230\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F ''{0}''
+
+# 0: string
+compiler.err.proc.processor.wrong.type=\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F ''{0}'' \u672A\u5B9E\u73B0 javax.annotation.processing.Processor
+
+compiler.err.proc.service.problem=\u521B\u5EFA\u670D\u52A1\u52A0\u8F7D\u5668\u4EE5\u52A0\u8F7D\u5904\u7406\u7A0B\u5E8F\u65F6\u51FA\u9519\u3002
+
+compiler.err.proc.bad.config.file=\u670D\u52A1\u914D\u7F6E\u6587\u4EF6\u4E0D\u6B63\u786E, \u6216\u6784\u9020\u5904\u7406\u7A0B\u5E8F\u5BF9\u8C61{0}\u65F6\u629B\u51FA\u5F02\u5E38\u9519\u8BEF
+
+compiler.err.proc.cant.create.loader=\u65E0\u6CD5\u4E3A\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F{0}\u521B\u5EFA\u7C7B\u52A0\u8F7D\u5668
+
+# 0: unused
+compiler.err.qualified.new.of.static.class=\u9650\u5B9A\u7684\u65B0\u9759\u6001\u7C7B
+
+compiler.err.recursive.ctor.invocation=\u9012\u5F52\u6784\u9020\u5668\u8C03\u7528
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
+compiler.err.ref.ambiguous=\u5BF9{0}\u7684\u5F15\u7528\u4E0D\u660E\u786E\n{3} \u4E2D\u7684{1} {2} \u548C {6} \u4E2D\u7684{4} {5} \u90FD\u5339\u914D
+
+# 0: name, 1: symbol kind, 2: symbol, 3: symbol, 4: symbol kind, 5: symbol, 6: symbol
+compiler.misc.ref.ambiguous=\u5BF9{0}\u7684\u5F15\u7528\u4E0D\u660E\u786E\n{3} \u4E2D\u7684{1} {2} \u548C {6} \u4E2D\u7684{4} {5} \u90FD\u5339\u914D
+
+compiler.err.repeated.annotation.target=\u6CE8\u91CA\u76EE\u6807\u91CD\u590D
+
+compiler.err.repeated.interface=\u63A5\u53E3\u91CD\u590D
+
+compiler.err.repeated.modifier=\u4FEE\u9970\u7B26\u91CD\u590D
+
+# 0: symbol, 1: set of modifier, 2: symbol
+compiler.err.report.access={0}\u53EF\u4EE5\u5728{2}\u4E2D\u8BBF\u95EE{1}
+
+compiler.err.ret.outside.meth=\u8FD4\u56DE\u5916\u90E8\u65B9\u6CD5
+
+compiler.err.signature.doesnt.match.supertype=\u7B7E\u540D\u4E0E{0}\u4E0D\u5339\u914D; \u4E0D\u517C\u5BB9\u7684\u8D85\u7C7B\u578B
+
+compiler.err.signature.doesnt.match.intf=\u7B7E\u540D\u4E0E{0}\u4E0D\u5339\u914D; \u4E0D\u517C\u5BB9\u7684\u63A5\u53E3
+
+# 0: symbol, 1: symbol, 2: symbol
+compiler.err.does.not.override.abstract={0}\u4E0D\u662F\u62BD\u8C61\u7684, \u5E76\u4E14\u672A\u8986\u76D6{2}\u4E2D\u7684\u62BD\u8C61\u65B9\u6CD5{1}
+
+compiler.err.source.cant.overwrite.input.file=\u5199\u5165\u6E90\u65F6\u51FA\u9519; \u65E0\u6CD5\u8986\u76D6\u8F93\u5165\u6587\u4EF6{0}
+
+compiler.err.stack.sim.error=\u5185\u90E8\u9519\u8BEF: {0}\u4E2D\u7684\u5806\u6808 sim \u9519\u8BEF
+
+compiler.err.static.imp.only.classes.and.interfaces=\u4EC5\u4ECE\u7C7B\u548C\u63A5\u53E3\u9759\u6001\u5BFC\u5165
+
+compiler.err.string.const.req=\u9700\u8981\u5E38\u91CF\u5B57\u7B26\u4E32\u8868\u8FBE\u5F0F
+
+# 0: symbol, 1: symbol
+compiler.err.synthetic.name.conflict=\u7B26\u53F7{0}\u4E0E{1}\u4E2D\u7684 compiler-synthesized \u7B26\u53F7\u51B2\u7A81
+
+# 0: symbol, 1: symbol
+compiler.warn.synthetic.name.conflict=\u7B26\u53F7{0}\u4E0E{1}\u4E2D\u7684 compiler-synthesized \u7B26\u53F7\u51B2\u7A81
+
+compiler.err.throws.not.allowed.in.intf.annotation=@interface \u6210\u5458\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528 throws \u5B50\u53E5
+
+compiler.err.try.without.catch.or.finally=\u6709 ''try'', \u4F46\u662F\u6CA1\u6709 ''catch'' \u6216 ''finally''
+
+compiler.err.try.without.catch.finally.or.resource.decls=''try'' \u4E0D\u5E26\u6709 ''catch'', ''finally'' \u6216\u8D44\u6E90\u58F0\u660E
+
+# 0: symbol
+compiler.err.type.doesnt.take.params=\u7C7B\u578B{0}\u4E0D\u5E26\u6709\u53C2\u6570
+
+compiler.err.type.var.cant.be.deref=\u65E0\u6CD5\u4ECE\u7C7B\u578B\u53D8\u91CF\u4E2D\u8FDB\u884C\u9009\u62E9
+
+compiler.err.type.var.may.not.be.followed.by.other.bounds=\u7C7B\u578B\u53D8\u91CF\u540E\u9762\u4E0D\u80FD\u5E26\u6709\u5176\u4ED6\u9650\u5236\u8303\u56F4
+
+compiler.err.type.var.more.than.once=\u7C7B\u578B\u53D8\u91CF{0}\u5728{1}\u7684\u7ED3\u679C\u7C7B\u578B\u4E2D\u591A\u6B21\u51FA\u73B0; \u5FC5\u987B\u5BF9\u5176\u8FDB\u884C\u5B9E\u4F8B\u5316
+
+compiler.err.type.var.more.than.once.in.result=\u7C7B\u578B\u53D8\u91CF{0}\u5728{1}\u7684\u7C7B\u578B\u4E2D\u591A\u6B21\u51FA\u73B0; \u5FC5\u987B\u5BF9\u5176\u8FDB\u884C\u5B9E\u4F8B\u5316
+
+# 0: type, 1: type, 2: string
+compiler.err.types.incompatible.diff.ret=\u7C7B\u578B{0}\u548C{1}\u4E0D\u517C\u5BB9; \u4E24\u8005\u90FD\u5B9A\u4E49\u4E86{2}, \u4F46\u5374\u5E26\u6709\u4E0D\u76F8\u5173\u7684\u8FD4\u56DE\u7C7B\u578B
+
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.unrelated.defaults={0} {1}\u4ECE\u7C7B\u578B {4} \u548C {5} \u4E2D\u7EE7\u627F\u4E86{2}({3}) \u7684\u4E0D\u76F8\u5173\u9ED8\u8BA4\u503C
+
+# 0: kind, 1: type, 2: name, 3: list of type, 4: symbol, 5: symbol
+compiler.err.types.incompatible.abstract.default={0} {1}\u4ECE\u7C7B\u578B {4} \u548C {5} \u4E2D\u7EE7\u627F\u4E86{2}({3}) \u7684\u62BD\u8C61\u548C\u9ED8\u8BA4\u503C
+
+# 0: name, 1: kind, 2: symbol
+compiler.err.default.overrides.object.member={1} {2} \u4E2D\u7684\u9ED8\u8BA4\u65B9\u6CD5{0}\u8986\u76D6\u4E86 java.lang.Object \u7684\u6210\u5458
+
+# 0: type
+compiler.err.illegal.static.intf.meth.call=\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\u8C03\u7528\u975E\u6CD5\n\u5E94\u5C06\u63A5\u6536\u65B9\u8868\u8FBE\u5F0F\u66FF\u6362\u4E3A\u7C7B\u578B\u9650\u5B9A\u7B26 ''{0}''
+
+# 0: type, 1: message segment
+compiler.err.illegal.default.super.call=\u9ED8\u8BA4\u8D85\u7EA7\u8C03\u7528\u4E2D\u7684\u7C7B\u578B\u9650\u5B9A\u7B26{0}\u9519\u8BEF\n{1}
+
+# 0: symbol, 1: type
+compiler.misc.overridden.default=\u8986\u76D6\u4E86{1}\u4E2D\u7684\u65B9\u6CD5 {0}
+
+# 0: symbol, 1: type or symbol
+compiler.misc.redundant.supertype=\u5197\u4F59\u63A5\u53E3 {0} \u5DF2\u7531 {1} \u6269\u5C55
+
+compiler.err.unclosed.char.lit=\u672A\u7ED3\u675F\u7684\u5B57\u7B26\u6587\u5B57
+
+compiler.err.unclosed.comment=\u672A\u7ED3\u675F\u7684\u6CE8\u91CA
+
+compiler.err.unclosed.str.lit=\u672A\u7ED3\u675F\u7684\u5B57\u7B26\u4E32\u6587\u5B57
+
+# 0: name
+compiler.err.unsupported.encoding=\u4E0D\u652F\u6301\u7684\u7F16\u7801: {0}
+
+compiler.err.io.exception=\u8BFB\u53D6\u6E90\u6587\u4EF6\u65F6\u51FA\u9519: {0}
+
+# 0: name
+compiler.err.undef.label=\u672A\u5B9A\u4E49\u7684\u6807\u7B7E: {0}
+
+# 0: message segment, 1: unused
+compiler.err.cant.apply.diamond=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570
+
+# 0: message segment or type, 1: message segment
+compiler.err.cant.apply.diamond.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570\n\u539F\u56E0: {1}
+
+# 0: message segment or type, 1: message segment
+compiler.misc.cant.apply.diamond.1=\u65E0\u6CD5\u63A8\u65AD{0}\u7684\u7C7B\u578B\u53C2\u6570\n\u539F\u56E0: {1}
+
+compiler.err.unreachable.stmt=\u65E0\u6CD5\u8BBF\u95EE\u7684\u8BED\u53E5
+
+compiler.err.initializer.must.be.able.to.complete.normally=\u521D\u59CB\u5316\u7A0B\u5E8F\u5FC5\u987B\u80FD\u591F\u6B63\u5E38\u5B8C\u6210
+
+# 0: type
+compiler.err.unreported.exception.need.to.catch.or.throw=\u672A\u62A5\u544A\u7684\u5F02\u5E38\u9519\u8BEF{0}; \u5FC5\u987B\u5BF9\u5176\u8FDB\u884C\u6355\u83B7\u6216\u58F0\u660E\u4EE5\u4FBF\u629B\u51FA
+
+# 0: type
+compiler.err.unreported.exception.default.constructor=\u9ED8\u8BA4\u6784\u9020\u5668\u4E2D\u672A\u62A5\u544A\u7684\u5F02\u5E38\u9519\u8BEF{0}
+
+# 0: type, 1: name
+compiler.err.unreported.exception.implicit.close=\u672A\u62A5\u544A\u7684\u5F02\u5E38\u9519\u8BEF{0}; \u5FC5\u987B\u5BF9\u5176\u8FDB\u884C\u6355\u83B7\u6216\u58F0\u660E\u4EE5\u4FBF\u629B\u51FA\n\u5BF9\u8D44\u6E90\u53D8\u91CF ''{1}'' \u9690\u5F0F\u8C03\u7528 close() \u65F6\u629B\u51FA\u4E86\u5F02\u5E38\u9519\u8BEF
+
+compiler.err.unsupported.cross.fp.lit=\u8BE5 VM \u4E0D\u652F\u6301\u5341\u516D\u8FDB\u5236\u6D6E\u70B9\u6587\u5B57
+
+compiler.err.void.not.allowed.here=\u6B64\u5904\u4E0D\u5141\u8BB8\u4F7F\u7528 ''\u7A7A'' \u7C7B\u578B
+
+# 0: string
+compiler.err.wrong.number.type.args=\u7C7B\u578B\u53D8\u91CF\u6570\u76EE\u9519\u8BEF; \u9700\u8981{0}
+
+# 0: symbol
+compiler.err.var.might.already.be.assigned=\u53EF\u80FD\u5DF2\u5206\u914D\u53D8\u91CF{0}
+
+# 0: symbol
+compiler.err.var.might.not.have.been.initialized=\u53EF\u80FD\u5C1A\u672A\u521D\u59CB\u5316\u53D8\u91CF{0}
+
+# 0: symbol
+compiler.err.var.might.be.assigned.in.loop=\u53EF\u80FD\u5728 loop \u4E2D\u5206\u914D\u4E86\u53D8\u91CF{0}
+
+# 0: symbol, 1: message segment
+compiler.err.varargs.invalid.trustme.anno={0} \u6CE8\u91CA\u65E0\u6548\u3002{1}
+
+# 0: type
+compiler.misc.varargs.trustme.on.reifiable.varargs=Varargs \u5143\u7D20\u7C7B\u578B{0}\u53EF\u5177\u4F53\u5316\u3002
+
+# 0: symbol
+compiler.misc.varargs.trustme.on.non.varargs.meth=\u65B9\u6CD5 {0} \u4E0D\u662F varargs \u65B9\u6CD5\u3002
+
+# 0: symbol
+compiler.misc.varargs.trustme.on.virtual.varargs=\u5B9E\u4F8B\u65B9\u6CD5 {0} \u4E0D\u662F\u6700\u7EC8\u7684\u3002
+
+# 0: type, 1: symbol kind, 2: symbol
+compiler.misc.inaccessible.varargs.type=\u5F62\u5F0F varargs \u5143\u7D20\u7C7B\u578B{0}\u65E0\u6CD5\u4ECE {1} {2} \u8FDB\u884C\u8BBF\u95EE
+
+# In the following string, {1} will always be the detail message from
+# java.io.IOException.
+# 0: symbol, 1: string
+compiler.err.class.cant.write=\u5199\u5165{0}\u65F6\u51FA\u9519: {1}
+
+# In the following string, {0} is the name of the class in the Java source.
+# It really should be used two times..
+# 0: name
+compiler.err.class.public.should.be.in.file=\u7C7B{0}\u662F\u516C\u5171\u7684, \u5E94\u5728\u540D\u4E3A {0}.java \u7684\u6587\u4EF6\u4E2D\u58F0\u660E
+
+## All errors which do not refer to a particular line in the source code are
+## preceded by this string.
+compiler.err.error=\u9519\u8BEF: 
+
+# The following error messages do not refer to a line in the source code.
+compiler.err.cant.read.file=\u65E0\u6CD5\u8BFB\u53D6: {0}
+
+#####
+
+# Fatal Errors
+
+compiler.misc.fatal.err.no.java.lang=\u81F4\u547D\u9519\u8BEF: \u5728\u7C7B\u8DEF\u5F84\u6216\u5F15\u5BFC\u7C7B\u8DEF\u5F84\u4E2D\u627E\u4E0D\u5230\u7A0B\u5E8F\u5305 java.lang
+
+compiler.misc.fatal.err.cant.locate.meth=\u81F4\u547D\u9519\u8BEF: \u627E\u4E0D\u5230\u65B9\u6CD5{0}
+
+compiler.misc.fatal.err.cant.locate.field=\u81F4\u547D\u9519\u8BEF: \u627E\u4E0D\u5230\u5B57\u6BB5{0}
+
+compiler.misc.fatal.err.cant.locate.ctor=\u81F4\u547D\u9519\u8BEF: \u627E\u4E0D\u5230{0}\u7684\u6784\u9020\u5668
+
+compiler.misc.fatal.err.cant.close=\u81F4\u547D\u9519\u8BEF: \u65E0\u6CD5\u5173\u95ED\u7F16\u8BD1\u5668\u8D44\u6E90
+
+#####
+
+##
+## miscellaneous strings
+##
+
+compiler.misc.source.unavailable=(\u6E90\u4E0D\u53EF\u7528)
+
+compiler.misc.base.membership=\u60A8\u7684\u6240\u6709\u57FA\u7C7B\u90FD\u5C5E\u4E8E\u6211\u4EEC
+
+# 0: string, 1: string, 2: boolean
+compiler.misc.x.print.processor.info=\u5904\u7406\u7A0B\u5E8F{0}\u4E0E{1}\u5339\u914D\u5E76\u8FD4\u56DE{2}\u3002
+
+# 0: number, 1: string, 2: set of symbol, 3: boolean
+compiler.misc.x.print.rounds=\u5FAA\u73AF {0}:\n\t\u8F93\u5165\u6587\u4EF6: {1}\n\t\u6CE8\u91CA: {2}\n\t\u6700\u540E\u4E00\u4E2A\u5FAA\u73AF: {3}
+
+#####
+
+## The following string will appear before all messages keyed as:
+## "compiler.note".
+
+compiler.note.compressed.diags=\u67D0\u4E9B\u6D88\u606F\u5DF2\u7ECF\u8FC7\u7B80\u5316; \u8BF7\u4F7F\u7528 -Xdiags:verbose \u91CD\u65B0\u7F16\u8BD1\u4EE5\u83B7\u5F97\u5B8C\u6574\u8F93\u51FA
+
+compiler.note.potential.lambda.found=\u53EF\u5C06\u6B64\u533F\u540D\u5185\u90E8\u7C7B\u521B\u5EFA\u8F6C\u6362\u4E3A lambda \u8868\u8FBE\u5F0F\u3002
+
+compiler.note.note=\u6CE8: 
+
+# 0: file name
+compiler.note.deprecated.filename={0}\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002
+
+compiler.note.deprecated.plural=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002
+
+# The following string may appear after one of the above deprecation
+# messages.
+compiler.note.deprecated.recompile=\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -Xlint:deprecation \u91CD\u65B0\u7F16\u8BD1\u3002
+
+# 0: file name
+compiler.note.deprecated.filename.additional={0}\u8FD8\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002
+
+compiler.note.deprecated.plural.additional=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u8FD8\u4F7F\u7528\u6216\u8986\u76D6\u4E86\u5DF2\u8FC7\u65F6\u7684 API\u3002
+
+# 0: file name
+compiler.note.unchecked.filename={0}\u4F7F\u7528\u4E86\u672A\u7ECF\u68C0\u67E5\u6216\u4E0D\u5B89\u5168\u7684\u64CD\u4F5C\u3002
+
+compiler.note.unchecked.plural=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u4F7F\u7528\u4E86\u672A\u7ECF\u68C0\u67E5\u6216\u4E0D\u5B89\u5168\u7684\u64CD\u4F5C\u3002
+
+# The following string may appear after one of the above deprecation
+# messages.
+compiler.note.unchecked.recompile=\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -Xlint:unchecked \u91CD\u65B0\u7F16\u8BD1\u3002
+
+# 0: file name
+compiler.note.unchecked.filename.additional={0}\u8FD8\u6709\u672A\u7ECF\u68C0\u67E5\u6216\u4E0D\u5B89\u5168\u7684\u64CD\u4F5C\u3002
+
+compiler.note.unchecked.plural.additional=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u8FD8\u4F7F\u7528\u4E86\u672A\u7ECF\u68C0\u67E5\u6216\u4E0D\u5B89\u5168\u7684\u64CD\u4F5C\u3002
+
+# 0: file name
+compiler.note.sunapi.filename={0}\u4F7F\u7528\u4E86\u53EF\u80FD\u4F1A\u5728\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664\u7684\u5185\u90E8\u4E13\u7528 API\u3002
+
+compiler.note.sunapi.plural=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u4F7F\u7528\u4E86\u53EF\u80FD\u4F1A\u5728\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664\u7684\u5185\u90E8\u4E13\u7528 API\u3002
+
+# The following string may appear after one of the above sunapi messages.
+compiler.note.sunapi.recompile=\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -Xlint:sunapi \u91CD\u65B0\u7F16\u8BD1\u3002
+
+# 0: file name
+compiler.note.sunapi.filename.additional={0}\u4F7F\u7528\u4E86\u53EF\u80FD\u4F1A\u5728\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664\u7684\u5176\u4ED6\u5185\u90E8\u4E13\u7528 API\u3002
+
+compiler.note.sunapi.plural.additional=\u67D0\u4E9B\u8F93\u5165\u6587\u4EF6\u4F7F\u7528\u4E86\u53EF\u80FD\u4F1A\u5728\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664\u7684\u5176\u4ED6\u5185\u90E8\u4E13\u7528 API\u3002
+
+# Notes related to annotation processing
+
+# Print a client-generated note; assumed to be localized, no translation required
+# 0: string
+compiler.note.proc.messager={0}
+
+#####
+
+# 0: number
+compiler.misc.count.error={0} \u4E2A\u9519\u8BEF
+
+# 0: number
+compiler.misc.count.error.plural={0} \u4E2A\u9519\u8BEF
+
+# 0: number
+compiler.misc.count.warn={0} \u4E2A\u8B66\u544A
+
+# 0: number
+compiler.misc.count.warn.plural={0} \u4E2A\u8B66\u544A
+
+compiler.misc.version.not.available=(\u7248\u672C\u4FE1\u606F\u4E0D\u53EF\u7528)
+
+## extra output when using -verbose (JavaCompiler)
+
+# 0: symbol
+compiler.misc.verbose.checking.attribution=[\u6B63\u5728\u68C0\u67E5{0}]
+
+# 0: string
+compiler.misc.verbose.parsing.done=[\u89E3\u6790\u5DF2\u5B8C\u6210, \u7528\u65F6 {0} \u6BEB\u79D2]
+
+# 0: file name
+compiler.misc.verbose.parsing.started=[\u89E3\u6790\u5F00\u59CB\u65F6\u95F4 {0}]
+
+# 0: string
+compiler.misc.verbose.total=[\u5171 {0} \u6BEB\u79D2]
+
+# 0: file name
+compiler.misc.verbose.wrote.file=[\u5DF2\u5199\u5165{0}]
+
+## extra output when using -verbose (Retro)
+compiler.misc.verbose.retro=[\u6B63\u5728\u66F4\u65B0{0}]
+
+compiler.misc.verbose.retro.with=\t\u6B63\u5728\u4F7F\u7528{1}\u66F4\u65B0{0}
+
+compiler.misc.verbose.retro.with.list=\t\u6B63\u5728\u4F7F\u7528\u7C7B\u578B\u53C2\u6570{1}, \u8D85\u7C7B\u578B{2}\u548C\u63A5\u53E3{3}\u66F4\u65B0{0}
+
+## extra output when using -verbose (code/ClassReader)
+# 0: string
+compiler.misc.verbose.loading=[\u6B63\u5728\u52A0\u8F7D{0}]
+
+# 0: string
+compiler.misc.verbose.sourcepath=[\u6E90\u6587\u4EF6\u7684\u641C\u7D22\u8DEF\u5F84: {0}]
+
+# 0: string
+compiler.misc.verbose.classpath=[\u7C7B\u6587\u4EF6\u7684\u641C\u7D22\u8DEF\u5F84: {0}]
+
+## extra output when using -checkclassfile (code/ClassReader)
+compiler.misc.ccf.found.later.version=\u7C7B\u6587\u4EF6\u7684\u7248\u672C\u9AD8\u4E8E\u9884\u671F: {0}
+
+compiler.misc.ccf.unrecognized.attribute=\u65E0\u6CD5\u8BC6\u522B\u7684\u5C5E\u6027: {0}
+
+## extra output when using -prompt (util/Log)
+compiler.misc.resume.abort=\u7EE7\u7EED(R), \u653E\u5F03(A)>
+
+#####
+
+##
+## warnings
+##
+
+## All warning messages are preceded by the following string.
+compiler.warn.warning=\u8B66\u544A: 
+
+## Warning messages may also include the following prefix to identify a
+## lint option
+# 0: option name
+compiler.warn.lintOption=[{0}] 
+
+# 0: symbol
+compiler.warn.constant.SVUID=serialVersionUID \u5728\u7C7B{0}\u4E2D\u5FC5\u987B\u662F\u5E38\u91CF
+
+# 0: file name
+compiler.warn.dir.path.element.not.found=\u9519\u8BEF\u7684\u8DEF\u5F84\u5143\u7D20 "{0}": \u6CA1\u6709\u8FD9\u79CD\u76EE\u5F55
+
+compiler.warn.finally.cannot.complete=finally \u5B50\u53E5\u65E0\u6CD5\u6B63\u5E38\u5B8C\u6210
+
+# 0: symbol, 1: symbol
+compiler.warn.has.been.deprecated={1}\u4E2D\u7684{0}\u5DF2\u8FC7\u65F6
+
+# 0: symbol
+compiler.warn.sun.proprietary={0}\u662F\u5185\u90E8\u4E13\u7528 API, \u53EF\u80FD\u4F1A\u5728\u672A\u6765\u53D1\u884C\u7248\u4E2D\u5220\u9664
+
+compiler.warn.illegal.char.for.encoding=\u7F16\u7801{0}\u7684\u4E0D\u53EF\u6620\u5C04\u5B57\u7B26
+
+# 0: symbol
+compiler.warn.improper.SVUID=\u5FC5\u987B\u5728\u7C7B{0}\u4E2D\u5C06 serialVersionUID \u58F0\u660E\u4E3A static final
+
+# 0: type, 1: type
+compiler.warn.inexact.non-varargs.call=\u6700\u540E\u4E00\u4E2A\u53C2\u6570\u4F7F\u7528\u4E86\u4E0D\u51C6\u786E\u7684\u53D8\u91CF\u7C7B\u578B\u7684 varargs \u65B9\u6CD5\u7684\u975E varargs \u8C03\u7528; \n\u5BF9\u4E8E varargs \u8C03\u7528, \u5E94\u4F7F\u7528 {0}\n\u5BF9\u4E8E\u975E varargs \u8C03\u7528, \u5E94\u4F7F\u7528 {1}, \u8FD9\u6837\u4E5F\u53EF\u4EE5\u6291\u5236\u6B64\u8B66\u544A
+
+# 0: list of type
+compiler.warn.unreachable.catch=catch \u5B50\u53E5\u65E0\u6CD5\u8BBF\u95EE\n\u5DF2\u6355\u83B7\u5230\u629B\u51FA\u7684\u7C7B\u578B{0}
+
+# 0: list of type
+compiler.warn.unreachable.catch.1=catch \u5B50\u53E5\u65E0\u6CD5\u8BBF\u95EE\n\u5DF2\u6355\u83B7\u5230\u629B\u51FA\u7684\u7C7B\u578B{0}
+
+# 0: symbol
+compiler.warn.long.SVUID=serialVersionUID \u5728\u7C7B{0}\u4E2D\u5FC5\u987B\u662F long \u7C7B\u578B
+
+# 0: symbol
+compiler.warn.missing.SVUID=\u53EF\u5E8F\u5217\u5316\u7C7B{0}\u6CA1\u6709 serialVersionUID \u7684\u5B9A\u4E49
+
+# 0: message segment
+compiler.warn.override.varargs.missing={0}; \u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u6CA1\u6709 ''...''
+
+# 0: message segment
+compiler.warn.override.varargs.extra={0}; \u8986\u76D6\u7684\u65B9\u6CD5\u7F3A\u5C11 ''...''
+
+compiler.warn.override.bridge={0}; \u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u4E3A bridge \u65B9\u6CD5
+
+# 0: symbol
+compiler.warn.pkg-info.already.seen=\u5DF2\u627E\u5230\u7A0B\u5E8F\u5305{0}\u7684 package-info.java \u6587\u4EF6
+
+# 0: file name
+compiler.warn.path.element.not.found=\u9519\u8BEF\u7684\u8DEF\u5F84\u5143\u7D20 "{0}": \u6CA1\u6709\u8FD9\u79CD\u6587\u4EF6\u6216\u76EE\u5F55
+
+compiler.warn.possible.fall-through.into.case=\u53EF\u80FD\u65E0\u6CD5\u5B9E\u73B0 case
+
+# 0: type
+compiler.warn.redundant.cast=\u51FA\u73B0\u5197\u4F59\u7684\u5230{0}\u7684\u8F6C\u6362
+
+# 0: number
+compiler.warn.position.overflow=\u884C {0} \u5904\u7684\u4F4D\u7F6E\u7F16\u7801\u6EA2\u51FA
+
+# 0: file name, 1: number, 2: number
+compiler.warn.big.major.version={0}: \u4E3B\u7248\u672C {1} \u6BD4 {2} \u65B0, \u6B64\u7F16\u8BD1\u5668\u652F\u6301\u6700\u65B0\u7684\u4E3B\u7248\u672C\u3002\n\u5EFA\u8BAE\u5347\u7EA7\u6B64\u7F16\u8BD1\u5668\u3002
+
+# 0: symbol kind, 1: symbol
+compiler.warn.static.not.qualified.by.type=static {0}\u5E94\u7531\u7C7B\u578B\u540D\u79F0{1}\u800C\u4E0D\u662F\u8868\u8FBE\u5F0F\u9650\u5B9A
+
+# 0: string
+compiler.warn.source.no.bootclasspath=\u672A\u4E0E -source {0} \u4E00\u8D77\u8BBE\u7F6E\u5F15\u5BFC\u7C7B\u8DEF\u5F84
+
+# 0: name, 1: number, 2: number, 3: number, 4: number
+compiler.warn.future.attr={1}.{2} \u7248\u7C7B\u6587\u4EF6\u4E2D\u5F15\u5165\u7684 {0} \u5C5E\u6027\u5728 {3}.{4} \u7248\u7C7B\u6587\u4EF6\u4E2D\u88AB\u5FFD\u7565
+
+# Warnings related to annotation processing
+# 0: name
+compiler.warn.proc.package.does.not.exist=\u7A0B\u5E8F\u5305{0}\u4E0D\u5B58\u5728
+
+# 0: name
+compiler.warn.proc.file.reopening=\u5C1D\u8BD5\u591A\u6B21\u4E3A ''{0}'' \u521B\u5EFA\u6587\u4EF6
+
+# 0: name
+compiler.warn.proc.type.already.exists=\u7C7B\u578B ''{0}'' \u7684\u6587\u4EF6\u5DF2\u7ECF\u5B58\u5728\u4E8E\u6E90\u8DEF\u5F84\u6216\u7C7B\u8DEF\u5F84\u4E2D
+
+# 0: name
+compiler.warn.proc.type.recreate=\u5C1D\u8BD5\u591A\u6B21\u521B\u5EFA\u7C7B\u578B ''{0}'' \u7684\u6587\u4EF6
+
+# 0: string
+compiler.warn.proc.illegal.file.name=\u65E0\u6CD5\u521B\u5EFA\u5E26\u6709\u975E\u6CD5\u540D\u79F0 ''{0}'' \u7684\u6587\u4EF6\u3002
+
+# 0: string, 1: string
+compiler.warn.proc.suspicious.class.name=\u6B63\u5728\u4E3A\u540D\u79F0\u4EE5{1}\u7ED3\u5C3E\u7684\u7C7B\u578B\u521B\u5EFA\u6587\u4EF6: ''{0}''
+
+# 0: name
+compiler.warn.proc.file.create.last.round=\u5C06\u4E0D\u5BF9\u5728\u6700\u540E\u4E00\u4E2A\u5FAA\u73AF\u4E2D\u521B\u5EFA\u7684\u7C7B\u578B\u4E3A ''{0}'' \u7684\u6587\u4EF6\u8FDB\u884C\u6CE8\u91CA\u5904\u7406\u3002
+
+# 0: string, 1: string
+compiler.warn.proc.malformed.supported.string=\u5904\u7406\u7A0B\u5E8F ''{1}'' \u4E3A\u652F\u6301\u7684\u6CE8\u91CA\u7C7B\u578B\u8FD4\u56DE\u683C\u5F0F\u9519\u8BEF\u7684\u5B57\u7B26\u4E32 ''{0}''
+
+# 0: set of string
+compiler.warn.proc.annotations.without.processors=\u6CA1\u6709\u5904\u7406\u7A0B\u5E8F\u8981\u4F7F\u7528\u4EE5\u4E0B\u4EFB\u4F55\u6CE8\u91CA: {0}
+
+# 0: source version, 1: string, 2: string
+compiler.warn.proc.processor.incompatible.source.version=\u6765\u81EA\u6CE8\u91CA\u5904\u7406\u7A0B\u5E8F ''{1}'' \u7684\u53D7\u652F\u6301 source \u7248\u672C ''{0}'' \u4F4E\u4E8E -source ''{2}''
+
+compiler.warn.proc.proc-only.requested.no.procs=\u5728\u672A\u8BF7\u6C42\u7F16\u8BD1\u7684\u60C5\u51B5\u4E0B\u8FDB\u884C\u6CE8\u91CA\u5904\u7406, \u4F46\u627E\u4E0D\u5230\u5904\u7406\u7A0B\u5E8F\u3002
+
+compiler.warn.proc.use.implicit=\u6CE8\u91CA\u5904\u7406\u4E0D\u9002\u7528\u4E8E\u9690\u5F0F\u7F16\u8BD1\u7684\u6587\u4EF6\u3002\n\u4F7F\u7528 -implicit \u6307\u5B9A\u7528\u4E8E\u9690\u5F0F\u7F16\u8BD1\u7684\u7B56\u7565\u3002
+
+compiler.warn.proc.use.proc.or.implicit=\u6CE8\u91CA\u5904\u7406\u4E0D\u9002\u7528\u4E8E\u9690\u5F0F\u7F16\u8BD1\u7684\u6587\u4EF6\u3002\n\u4F7F\u7528 -proc:none \u7981\u7528\u6CE8\u91CA\u5904\u7406\u6216\u4F7F\u7528 -implicit \u6307\u5B9A\u7528\u4E8E\u9690\u5F0F\u7F16\u8BD1\u7684\u7B56\u7565\u3002
+
+# Print a client-generated warning; assumed to be localized, no translation required
+# 0: string
+compiler.warn.proc.messager={0}
+
+# 0: set of name
+compiler.warn.proc.unclosed.type.files=\u7C7B\u578B ''{0}'' \u7684\u6587\u4EF6\u672A\u5173\u95ED; \u5C06\u4E0D\u9488\u5BF9\u8FD9\u4E9B\u7C7B\u578B\u8FDB\u884C\u6CE8\u91CA\u5904\u7406
+
+# 0: string
+compiler.warn.proc.unmatched.processor.options=\u4EE5\u4E0B\u9009\u9879\u672A\u88AB\u4EFB\u4F55\u5904\u7406\u7A0B\u5E8F\u8BC6\u522B: ''{0}''
+
+compiler.warn.try.explicit.close.call=\u5728\u53EF\u81EA\u52A8\u7ED3\u675F\u7684\u8D44\u6E90\u4E0A\u663E\u5F0F\u8C03\u7528 close()
+
+# 0: symbol
+compiler.warn.try.resource.not.referenced=\u4E0D\u80FD\u5728\u76F8\u5E94\u7684 try \u8BED\u53E5\u7684\u6B63\u6587\u4E2D\u5F15\u7528\u53EF\u81EA\u52A8\u7ED3\u675F\u7684\u8D44\u6E90{0}
+
+# 0: type
+compiler.warn.try.resource.throws.interrupted.exc=\u53EF\u81EA\u52A8\u5173\u95ED\u7684\u8D44\u6E90{0}\u5305\u542B\u7684\u6210\u5458\u65B9\u6CD5 close() \u53EF\u80FD\u629B\u51FA InterruptedException
+
+compiler.warn.unchecked.assign=\u672A\u7ECF\u68C0\u67E5\u7684\u5206\u914D: \u5C06{0}\u5206\u914D\u7ED9{1}
+
+# 0: symbol, 1: type
+compiler.warn.unchecked.assign.to.var=\u5BF9\u4F5C\u4E3A\u539F\u59CB\u7C7B\u578B{1}\u7684\u6210\u5458\u7684\u53D8\u91CF{0}\u7684\u5206\u914D\u672A\u7ECF\u8FC7\u68C0\u67E5
+
+# 0: symbol, 1: type
+compiler.warn.unchecked.call.mbr.of.raw.type=\u5BF9\u4F5C\u4E3A\u539F\u59CB\u7C7B\u578B{1}\u7684\u6210\u5458\u7684{0}\u7684\u8C03\u7528\u672A\u7ECF\u8FC7\u68C0\u67E5
+
+compiler.warn.unchecked.cast.to.type=\u5411\u7C7B\u578B{0}\u7684\u8F6C\u6362\u672A\u7ECF\u8FC7\u68C0\u67E5
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type, 4: symbol kind, 5: symbol
+compiler.warn.unchecked.meth.invocation.applied=\u65B9\u6CD5\u8C03\u7528\u672A\u7ECF\u8FC7\u68C0\u67E5: \u5C06{4} {5}\u4E2D\u7684{0} {1}\u5E94\u7528\u5230\u7ED9\u5B9A\u7684\u7C7B\u578B\n\u9700\u8981: {2}\n\u627E\u5230: {3}
+
+# 0: type
+compiler.warn.unchecked.generic.array.creation=\u5BF9\u4E8E\u7C7B\u578B\u4E3A{0}\u7684 varargs \u53C2\u6570, \u6CDB\u578B\u6570\u7EC4\u521B\u5EFA\u672A\u7ECF\u8FC7\u68C0\u67E5
+
+# 0: type
+compiler.warn.unchecked.varargs.non.reifiable.type=\u53C2\u6570\u5316 vararg \u7C7B\u578B{0}\u7684\u5806\u53EF\u80FD\u5DF2\u53D7\u6C61\u67D3
+
+# 0: symbol
+compiler.warn.varargs.unsafe.use.varargs.param=Varargs \u65B9\u6CD5\u53EF\u80FD\u5BFC\u81F4\u6765\u81EA\u4E0D\u53EF\u5177\u4F53\u5316 varargs \u53C2\u6570 {0} \u7684\u5806\u6C61\u67D3
+
+compiler.warn.missing.deprecated.annotation=\u672A\u4F7F\u7528 @Deprecated \u5BF9\u5DF2\u8FC7\u65F6\u7684\u9879\u76EE\u8FDB\u884C\u6CE8\u91CA
+
+compiler.warn.invalid.archive.file=\u4EE5\u4E0B\u8DEF\u5F84\u4E2D\u5B58\u5728\u610F\u5916\u7684\u6587\u4EF6: {0}
+
+compiler.warn.unexpected.archive.file=\u4EE5\u4E0B\u6863\u6848\u6587\u4EF6\u5B58\u5728\u610F\u5916\u7684\u6269\u5C55\u540D: {0}
+
+compiler.warn.div.zero=\u9664\u6570\u4E3A\u96F6
+
+compiler.warn.empty.if=if \u4E4B\u540E\u6CA1\u6709\u8BED\u53E5
+
+compiler.warn.annotation.method.not.found=\u65E0\u6CD5\u627E\u5230\u7C7B\u578B ''{0}'' \u7684\u6CE8\u91CA\u65B9\u6CD5 ''{1}()''
+
+compiler.warn.annotation.method.not.found.reason=\u65E0\u6CD5\u627E\u5230\u7C7B\u578B ''{0}'' \u7684\u6CE8\u91CA\u65B9\u6CD5 ''{1}()'': {2}
+
+# 0: symbol, 1: name
+compiler.warn.unknown.enum.constant=\u672A\u77E5\u7684\u679A\u4E3E\u5E38\u91CF {1}.{2}
+
+# 0: symbol, 1: name, 2: message segment
+compiler.warn.unknown.enum.constant.reason=\u672A\u77E5\u7684\u679A\u4E3E\u5E38\u91CF {1}.{2}\n\u539F\u56E0: {3}
+
+# 0: type, 1: type
+compiler.warn.raw.class.use=\u627E\u5230\u539F\u59CB\u7C7B\u578B: {0}\n\u7F3A\u5C11\u6CDB\u578B\u7C7B{1}\u7684\u7C7B\u578B\u53C2\u6570
+
+# 0: unused, 1: unused
+compiler.warn.diamond.redundant.args=\u65B0\u8868\u8FBE\u5F0F\u4E2D\u5B58\u5728\u5197\u4F59\u7C7B\u578B\u53C2\u6570 (\u6539\u7528 diamond \u8FD0\u7B97\u7B26)\u3002
+
+# 0: type, 1: type
+compiler.warn.diamond.redundant.args.1=\u65B0\u8868\u8FBE\u5F0F\u4E2D\u5B58\u5728\u5197\u4F59\u7C7B\u578B\u53C2\u6570 (\u6539\u7528 diamond \u8FD0\u7B97\u7B26)\u3002\n\u663E\u5F0F: {0}\n\u63A8\u65AD: {1}
+
+# 0: symbol, 1: message segment
+compiler.warn.varargs.redundant.trustme.anno=\u5197\u4F59\u7684 {0} \u6CE8\u91CA\u3002{1}
+
+#####
+
+## The following are tokens which are non-terminals in the language. They should
+## be named as JLS3 calls them when translated to the appropriate language.
+compiler.misc.token.identifier=<\u6807\u8BC6\u7B26>
+
+compiler.misc.token.character=<\u5B57\u7B26>
+
+compiler.misc.token.string=<\u5B57\u7B26\u4E32>
+
+compiler.misc.token.integer=<\u6574\u578B>
+
+compiler.misc.token.long-integer=<\u957F\u6574\u578B>
+
+compiler.misc.token.float=<\u6D6E\u70B9\u578B>
+
+compiler.misc.token.double=<\u53CC\u7CBE\u5EA6\u578B>
+
+compiler.misc.token.bad-symbol=<\u9519\u8BEF\u7B26\u53F7>
+
+compiler.misc.token.end-of-input=<\u8F93\u5165\u7ED3\u675F>
+
+## The argument to the following string will always be one of the following:
+## 1. one of the above non-terminals
+## 2. a keyword (JLS1.8)
+## 3. a boolean literal (JLS3.10.3)
+## 4. the null literal (JLS3.10.7)
+## 5. a Java separator (JLS3.11)
+## 6. an operator (JLS3.12)
+##
+## This is the only place these tokens will be used.
+# 0: token
+compiler.err.expected=\u9700\u8981{0}
+
+# 0: token, 1: token
+compiler.err.expected2=\u9700\u8981{0}\u6216{1}
+
+# 0: token, 1: token, 2: token
+compiler.err.expected3=\u9700\u8981{0}, {1}\u6216{2}
+
+compiler.err.premature.eof=\u89E3\u6790\u65F6\u5DF2\u5230\u8FBE\u6587\u4EF6\u7ED3\u5C3E
+
+## The following are related in form, but do not easily fit the above paradigm.
+compiler.err.dot.class.expected=\u9700\u8981 ''.class''
+
+## The argument to this string will always be either 'case' or 'default'.
+# 0: token
+compiler.err.orphaned=\u5B64\u7ACB\u7684{0}
+
+# 0: name
+compiler.misc.anonymous.class=<\u533F\u540D{0}>
+
+# 0: name, 1: type
+compiler.misc.type.captureof=capture#{0}, \u5171 {1}
+
+compiler.misc.type.captureof.1=capture#{0}
+
+compiler.misc.type.none=<\u65E0>
+
+compiler.misc.unnamed.package=\u672A\u547D\u540D\u7A0B\u5E8F\u5305
+
+#####
+
+# 0: symbol, 1: message segment
+compiler.err.cant.access=\u65E0\u6CD5\u8BBF\u95EE{0}\n{1}
+
+compiler.misc.bad.class.file.header=\u9519\u8BEF\u7684\u7C7B\u6587\u4EF6: {0}\n{1}\n\u8BF7\u5220\u9664\u8BE5\u6587\u4EF6\u6216\u786E\u4FDD\u8BE5\u6587\u4EF6\u4F4D\u4E8E\u6B63\u786E\u7684\u7C7B\u8DEF\u5F84\u5B50\u76EE\u5F55\u4E2D\u3002
+
+# 0: file name, 1: message segment
+compiler.misc.bad.source.file.header=\u9519\u8BEF\u7684\u6E90\u6587\u4EF6: {0}\n{1}\n\u8BF7\u5220\u9664\u8BE5\u6587\u4EF6\u6216\u786E\u4FDD\u8BE5\u6587\u4EF6\u4F4D\u4E8E\u6B63\u786E\u7684\u6E90\u8DEF\u5F84\u5B50\u76EE\u5F55\u4E2D\u3002
+
+## The following are all possible strings for the second argument ({1}) of the
+## above strings.
+compiler.misc.bad.class.signature=\u9519\u8BEF\u7684\u7C7B\u7B7E\u540D: {0}
+
+#0: symbol, 1: symbol
+compiler.misc.bad.enclosing.class={0}\u7684\u5C01\u95ED\u7C7B\u9519\u8BEF: {1}
+
+# 0: symbol
+compiler.misc.bad.enclosing.method=\u7C7B {0} \u7684\u5C01\u95ED\u65B9\u6CD5\u5C5E\u6027\u9519\u8BEF
+
+compiler.misc.bad.runtime.invisible.param.annotations=\u9519\u8BEF\u7684 RuntimeInvisibleParameterAnnotations \u5C5E\u6027: {0}
+
+compiler.misc.bad.const.pool.tag=\u9519\u8BEF\u7684\u5E38\u91CF\u6C60\u6807\u8BB0: {0}
+
+compiler.misc.bad.const.pool.tag.at=\u9519\u8BEF\u7684\u5E38\u91CF\u6C60\u6807\u8BB0: {0}, \u4F4D\u4E8E{1}
+
+compiler.misc.bad.signature=\u9519\u8BEF\u7684\u7B7E\u540D: {0}
+
+compiler.misc.bad.type.annotation.value=\u9519\u8BEF\u7684\u7C7B\u578B\u6CE8\u91CA\u76EE\u6807\u7C7B\u578B\u503C: {0}
+
+compiler.misc.class.file.wrong.class=\u7C7B\u6587\u4EF6\u5305\u542B\u9519\u8BEF\u7684\u7C7B: {0}
+
+compiler.misc.class.file.not.found=\u627E\u4E0D\u5230{0}\u7684\u7C7B\u6587\u4EF6
+
+# 0: name
+compiler.misc.file.doesnt.contain.class=\u6587\u4EF6\u4E0D\u5305\u542B\u7C7B{0}
+
+compiler.misc.file.does.not.contain.package=\u6587\u4EF6\u4E0D\u5305\u542B\u7A0B\u5E8F\u5305{0}
+
+compiler.misc.illegal.start.of.class.file=\u975E\u6CD5\u7684\u7C7B\u6587\u4EF6\u5F00\u59CB
+
+compiler.misc.unable.to.access.file=\u65E0\u6CD5\u8BBF\u95EE\u6587\u4EF6: {0}
+
+compiler.misc.unicode.str.not.supported=\u4E0D\u652F\u6301\u7C7B\u6587\u4EF6\u4E2D\u7684 Unicode \u5B57\u7B26\u4E32
+
+compiler.misc.undecl.type.var=\u672A\u58F0\u660E\u7684\u7C7B\u578B\u53D8\u91CF: {0}
+
+compiler.misc.wrong.version=\u7C7B\u6587\u4EF6\u5177\u6709\u9519\u8BEF\u7684\u7248\u672C {0}.{1}, \u5E94\u4E3A {2}.{3}
+
+#####
+
+# 0: type, 1: type or symbol
+compiler.err.not.within.bounds=\u7C7B\u578B\u53C2\u6570{0}\u4E0D\u5728\u7C7B\u578B\u53D8\u91CF{1}\u7684\u8303\u56F4\u5185
+
+## The following are all possible strings for the second argument ({1}) of the
+## above string.
+
+## none yet...
+
+#####
+
+# 0: message segment
+compiler.err.prob.found.req=\u4E0D\u517C\u5BB9\u7684\u7C7B\u578B: {0}
+
+# 0: message segment
+compiler.misc.prob.found.req=\u4E0D\u517C\u5BB9\u7684\u7C7B\u578B: {0}
+
+# 0: message segment, 1: type, 2: type
+compiler.warn.prob.found.req={0}\n\u9700\u8981: {2}\n\u627E\u5230:    {1}
+
+# 0: type, 1: type
+compiler.misc.inconvertible.types={0}\u65E0\u6CD5\u8F6C\u6362\u4E3A{1}
+
+# 0: type, 1: type
+compiler.misc.possible.loss.of.precision=\u4ECE{0}\u8F6C\u6362\u5230{1}\u53EF\u80FD\u4F1A\u6709\u635F\u5931
+
+compiler.misc.unchecked.assign=\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362
+
+# compiler.misc.storecheck=\
+#     assignment might cause later store checks to fail
+# compiler.misc.unchecked=\
+#     assigned array cannot dynamically check its stores
+compiler.misc.unchecked.cast.to.type=\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362
+
+# compiler.err.star.expected=\
+#     ''*'' expected
+# compiler.err.no.elem.type=\
+#     \[\*\] cannot have a type
+
+# 0: type
+compiler.misc.try.not.applicable.to.type=try-with-resources \u4E0D\u9002\u7528\u4E8E\u53D8\u91CF\u7C7B\u578B\n({0})
+
+#####
+
+# 0: message segment or type, 1: message segment
+compiler.err.type.found.req=\u610F\u5916\u7684\u7C7B\u578B\n\u9700\u8981: {1}\n\u627E\u5230:    {0}
+
+## The following are all possible strings for the first argument ({0}) of the
+## above string.
+compiler.misc.type.req.class=\u7C7B
+
+compiler.misc.type.req.class.array=\u7C7B\u6216\u6570\u7EC4
+
+compiler.misc.type.req.array.or.iterable=\u6570\u7EC4\u6216 java.lang.Iterable
+
+compiler.misc.type.req.ref=\u5F15\u7528
+
+compiler.misc.type.req.exact=\u4E0D\u5E26\u9650\u5236\u8303\u56F4\u7684\u7C7B\u6216\u63A5\u53E3
+
+# 0: type
+compiler.misc.type.parameter=\u7C7B\u578B\u53C2\u6570{0}
+
+#####
+
+## The following are all possible strings for the last argument of all those
+## diagnostics whose key ends in ".1"
+
+# 0: type, 1: list of type
+compiler.misc.no.unique.maximal.instance.exists=\u5BF9\u4E8E\u4E0A\u9650\u4E3A{1}\u7684\u7C7B\u578B\u53D8\u91CF{0}, \u4E0D\u5B58\u5728\u552F\u4E00\u6700\u5927\u5B9E\u4F8B
+
+compiler.misc.no.unique.minimal.instance.exists=\u5BF9\u4E8E\u4E0B\u9650\u4E3A{1}\u7684\u7C7B\u578B\u53D8\u91CF{0}, \u4E0D\u5B58\u5728\u552F\u4E00\u6700\u5C0F\u5B9E\u4F8B
+
+# 0: type, 1: list of type
+compiler.misc.incompatible.upper.bounds=\u63A8\u8BBA\u53D8\u91CF {0} \u5177\u6709\u4E0D\u517C\u5BB9\u7684\u4E0A\u9650 {1}
+
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.upper.bounds=\u63A8\u8BBA\u53D8\u91CF {0} \u5177\u6709\u4E0D\u517C\u5BB9\u7684\u9650\u5236\u8303\u56F4\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1}\n\u4E0A\u9650: {2}
+
+# 0: type, 1: list of type, 2: list of type
+compiler.misc.incompatible.eq.lower.bounds=\u63A8\u8BBA\u53D8\u91CF{0}\u5177\u6709\u4E0D\u517C\u5BB9\u7684\u9650\u5236\u8303\u56F4\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1}\n\u4E0B\u9650: {2}
+
+# 0: list of type, 1: type, 2: type
+compiler.misc.infer.no.conforming.instance.exists=\u4E0D\u5B58\u5728\u7C7B\u578B\u53D8\u91CF{0}\u7684\u5B9E\u4F8B, \u4EE5\u4F7F{1}\u4E0E{2}\u4E00\u81F4
+
+# 0: list of type, 1: message segment
+compiler.misc.infer.no.conforming.assignment.exists=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(\u53C2\u6570\u4E0D\u5339\u914D; {1})
+
+# 0: list of type
+compiler.misc.infer.arg.length.mismatch=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(\u5B9E\u9645\u53C2\u6570\u5217\u8868\u548C\u5F62\u5F0F\u53C2\u6570\u5217\u8868\u957F\u5EA6\u4E0D\u540C)
+
+# 0: list of type, 1: message segment
+compiler.misc.infer.varargs.argument.mismatch=\u65E0\u6CD5\u63A8\u65AD\u7C7B\u578B\u53D8\u91CF {0}\n(varargs \u4E0D\u5339\u914D; {1})
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.upper.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u4E0A\u9650\n\u63A8\u65AD: {0}\n\u4E0A\u9650: {1}
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.lower.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u4E0B\u9650\n\u63A8\u65AD: {0}\n\u4E0B\u9650: {1}
+
+# 0: type, 1: list of type
+compiler.misc.inferred.do.not.conform.to.eq.bounds=\u63A8\u65AD\u7C7B\u578B\u4E0D\u7B26\u5408\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6\n\u63A8\u65AD: {0}\n\u7B49\u5F0F\u7EA6\u675F\u6761\u4EF6: {1}
+
+# 0: list of type
+compiler.misc.cyclic.inference=\u7531\u4E8E\u63A8\u8BBA\u5FAA\u73AF, \u65E0\u6CD5\u5B9E\u4F8B\u5316\u63A8\u8BBA\u53D8\u91CF{0}
+
+# 0: symbol
+compiler.misc.diamond={0}<>
+
+# 0: type
+compiler.misc.diamond.non.generic=\u65E0\u6CD5\u5C06 ''<>'' \u4E0E\u975E\u6CDB\u578B\u7C7B{0}\u4E00\u8D77\u4F7F\u7528
+
+# 0: unused
+compiler.misc.diamond.and.explicit.params=\u4E0D\u80FD\u5C06 ''<>'' \u4E0E\u6784\u9020\u5668\u7684\u663E\u5F0F\u7C7B\u578B\u53C2\u6570\u4E00\u8D77\u4F7F\u7528
+
+# 0: type, 1: list of type
+compiler.misc.explicit.param.do.not.conform.to.bounds=\u663E\u5F0F\u7C7B\u578B\u53C2\u6570{0}\u4E0D\u7B26\u5408\u58F0\u660E\u7684\u8303\u56F4{1}
+
+compiler.misc.arg.length.mismatch=\u5B9E\u9645\u53C2\u6570\u5217\u8868\u548C\u5F62\u5F0F\u53C2\u6570\u5217\u8868\u957F\u5EA6\u4E0D\u540C
+
+# 0: message segment
+compiler.misc.no.conforming.assignment.exists=\u53C2\u6570\u4E0D\u5339\u914D; {0}
+
+# 0: message segment
+compiler.misc.varargs.argument.mismatch=varargs \u4E0D\u5339\u914D; {0}
+
+#####
+
+# 0: symbol or type, 1: file name
+compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file={1} \u4E2D\u7684\u8F85\u52A9\u7C7B{0}\u4E0D\u5E94\u4ECE\u5176\u81EA\u8EAB\u7684\u6E90\u6587\u4EF6\u4EE5\u5916\u8BBF\u95EE
+
+## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol, 2: symbol
+compiler.err.abstract.cant.be.accessed.directly=\u65E0\u6CD5\u76F4\u63A5\u8BBF\u95EE{2}\u4E2D\u7684\u62BD\u8C61{0} {1}
+
+## The first argument ({0}) is a "kindname".
+# 0: symbol kind, 1: symbol
+compiler.err.non-static.cant.be.ref=\u65E0\u6CD5\u4ECE\u9759\u6001\u4E0A\u4E0B\u6587\u4E2D\u5F15\u7528\u975E\u9759\u6001 {0} {1}
+
+# 0: symbol kind, 1: symbol
+compiler.misc.non-static.cant.be.ref=\u65E0\u6CD5\u4ECE\u9759\u6001\u4E0A\u4E0B\u6587\u4E2D\u5F15\u7528\u975E\u9759\u6001 {0} {1}
+
+# 0: symbol kind, 1: symbol
+compiler.misc.static.method.in.unbound.lookup=\u5728\u672A\u7ED1\u5B9A\u67E5\u627E\u4E2D\u627E\u5230\u9759\u6001{0} {1}
+
+## Both arguments ({0}, {1}) are "kindname"s.  {0} is a comma-separated list
+## of kindnames (the list should be identical to that provided in source.
+compiler.err.unexpected.type=\u610F\u5916\u7684\u7C7B\u578B\n\u9700\u8981: {0}\n\u627E\u5230:    {1}
+
+compiler.err.unexpected.lambda=\u6B64\u5904\u4E0D\u5E94\u4E3A lambda \u8868\u8FBE\u5F0F
+
+compiler.err.unexpected.mref=\u6B64\u5904\u4E0D\u5E94\u4E3A\u65B9\u6CD5\u5F15\u7528
+
+## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
+## The second argument {1} is the non-resolved symbol
+## The third argument {2} is a list of type parameters (non-empty if {1} is a method)
+## The fourth argument {3} is a list of argument types (non-empty if {1} is a method)
+# 0: symbol kind, 1: name, 2: unused, 3: unused
+compiler.err.cant.resolve=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} {1}
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type
+compiler.err.cant.resolve.args=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} {1}({3})
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list of type
+compiler.err.cant.resolve.args.params=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7: {0} <{2}>{1}({3})
+
+## arguments from {0} to {3} have the same meaning as above
+## The fifth argument {4} is a location subdiagnostic (see below)
+# 0: symbol kind, 1: name, 2: unused, 3: unused, 4: message segment
+compiler.err.cant.resolve.location=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7:   {0} {1}\n\u4F4D\u7F6E: {4}
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
+compiler.err.cant.resolve.location.args=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7:   {0} {1}({3})\n\u4F4D\u7F6E: {4}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
+compiler.err.cant.resolve.location.args.params=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7:   {0} <{2}>{1}({3})\n\u4F4D\u7F6E: {4}
+
+### Following are replicated/used for method reference diagnostics
+
+# 0: symbol kind, 1: name, 2: unused, 3: list of type, 4: message segment
+compiler.misc.cant.resolve.location.args=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7:   {0} {1}({3})\n\u4F4D\u7F6E: {4}
+
+# 0: symbol kind, 1: name, 2: list of type, 3: list, 4: message segment
+compiler.misc.cant.resolve.location.args.params=\u627E\u4E0D\u5230\u7B26\u53F7\n\u7B26\u53F7:   {0} <{2}>{1}({3})\n\u4F4D\u7F6E: {4}
+
+##a location subdiagnostic is composed as follows:
+## The first argument {0} is the location "kindname" (e.g. 'constructor', 'field', etc.)
+## The second argument {1} is the location name
+## The third argument {2} is the location type (only when {1} is a variable name)
+
+# 0: symbol kind, 1: type or symbol, 2: unused
+compiler.misc.location={0} {1}
+
+# 0: symbol kind, 1: symbol, 2: type
+compiler.misc.location.1=\u7C7B\u578B\u4E3A{2}\u7684{0} {1}
+
+## The following are all possible string for "kindname".
+## They should be called whatever the JLS calls them after it been translated
+## to the appropriate language.
+# compiler.misc.kindname.constructor=\
+#     static member
+compiler.misc.kindname.annotation=@interface
+
+compiler.misc.kindname.constructor=\u6784\u9020\u5668
+
+compiler.misc.kindname.enum=\u679A\u4E3E
+
+compiler.misc.kindname.interface=\u63A5\u53E3
+
+compiler.misc.kindname.static=\u9759\u6001
+
+compiler.misc.kindname.type.variable=\u7C7B\u578B\u53D8\u91CF
+
+compiler.misc.kindname.type.variable.bound=\u7C7B\u578B\u53D8\u91CF\u7684\u9650\u5236\u8303\u56F4
+
+compiler.misc.kindname.variable=\u53D8\u91CF
+
+compiler.misc.kindname.value=\u503C
+
+compiler.misc.kindname.method=\u65B9\u6CD5
+
+compiler.misc.kindname.class=\u7C7B
+
+compiler.misc.kindname.package=\u7A0B\u5E8F\u5305
+
+compiler.misc.kindname.static.init=\u9759\u6001\u521D\u59CB\u5316\u7A0B\u5E8F
+
+compiler.misc.kindname.instance.init=\u5B9E\u4F8B\u521D\u59CB\u5316\u7A0B\u5E8F
+
+#####
+
+compiler.misc.no.args=\u6CA1\u6709\u53C2\u6570
+
+# 0: message segment
+compiler.err.override.static={0}\n\u8986\u76D6\u7684\u65B9\u6CD5\u4E3A static
+
+# 0: message segment, 1: set of modifier
+compiler.err.override.meth={0}\n\u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u4E3A{1}
+
+# 0: message segment, 1: type
+compiler.err.override.meth.doesnt.throw={0}\n\u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u672A\u629B\u51FA{1}
+
+# In the following string {1} is a space separated list of Java Keywords, as
+# they would have been declared in the source code
+# 0: message segment, 1: set of modifier
+compiler.err.override.weaker.access={0}\n\u6B63\u5728\u5C1D\u8BD5\u5206\u914D\u66F4\u4F4E\u7684\u8BBF\u95EE\u6743\u9650; \u4EE5\u524D\u4E3A{1}
+
+# 0: message segment, 1: type, 2: type
+compiler.err.override.incompatible.ret={0}\n\u8FD4\u56DE\u7C7B\u578B{1}\u4E0E{2}\u4E0D\u517C\u5BB9
+
+# 0: message segment, 1: type, 2: type
+compiler.warn.override.unchecked.ret={0}\n\u8FD4\u56DE\u7C7B\u578B\u9700\u8981\u4ECE{1}\u5230{2}\u7684\u672A\u7ECF\u68C0\u67E5\u7684\u8F6C\u6362
+
+# 0: message segment, 1: type
+compiler.warn.override.unchecked.thrown={0}\n\u88AB\u8986\u76D6\u7684\u65B9\u6CD5\u672A\u629B\u51FA{1}
+
+# 0: symbol
+compiler.warn.override.equals.but.not.hashcode=\u7C7B{0}\u8986\u76D6\u4E86\u7B49\u53F7, \u4F46\u8BE5\u7C7B\u6216\u4EFB\u4F55\u8D85\u7C7B\u90FD\u672A\u8986\u76D6 hashCode \u65B9\u6CD5
+
+## The following are all possible strings for the first argument ({0}) of the
+## above strings.
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.cant.override={1}\u4E2D\u7684{0}\u65E0\u6CD5\u8986\u76D6{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.cant.implement={1}\u4E2D\u7684{0}\u65E0\u6CD5\u5B9E\u73B0{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.clashes.with={1}\u4E2D\u7684{0}\u4E0E{3}\u4E2D\u7684{2}\u51B2\u7A81
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.override={1}\u4E2D\u7684{0}\u8986\u76D6\u4E86{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.implement={1}\u4E2D\u7684{0}\u5B9E\u73B0\u4E86{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.unchecked.clash.with={1}\u4E2D\u7684{0}\u8986\u76D6\u4E86{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.override={1}\u4E2D\u7684{0}\u8986\u76D6\u4E86{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.implement={1}\u4E2D\u7684{0}\u5B9E\u73B0\u4E86{3}\u4E2D\u7684{2}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.misc.varargs.clash.with={1}\u4E2D\u7684{0}\u8986\u76D6\u4E86{3}\u4E2D\u7684{2}
+
+# 0: unused
+compiler.misc.diamond.and.anon.class=\u65E0\u6CD5\u5C06 ''<>'' \u4E0E\u533F\u540D\u5185\u90E8\u7C7B\u4E00\u8D77\u4F7F\u7528
+
+# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
+compiler.misc.inapplicable.method={0} {1}.{2}\u4E0D\u9002\u7528\n({3})
+
+########################################
+# Diagnostics for language feature changes
+########################################
+# 0: string
+compiler.err.unsupported.fp.lit=-source {0} \u4E2D\u4E0D\u652F\u6301\u5341\u516D\u8FDB\u5236\u6D6E\u70B9\u6587\u5B57\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u5341\u516D\u8FDB\u5236\u6D6E\u70B9\u6587\u5B57)
+
+# 0: string
+compiler.err.unsupported.binary.lit=-source {0} \u4E2D\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\u6587\u5B57\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u4E8C\u8FDB\u5236\u6587\u5B57)
+
+# 0: string
+compiler.err.unsupported.underscore.lit=-source {0} \u4E2D\u4E0D\u652F\u6301\u6587\u5B57\u4E2D\u5B58\u5728\u4E0B\u5212\u7EBF\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5141\u8BB8\u6587\u5B57\u4E2D\u5B58\u5728\u4E0B\u5212\u7EBF)
+
+# 0: string
+compiler.err.try.with.resources.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 try-with-resources\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 try-with-resources)
+
+compiler.warn.enum.as.identifier=\u4ECE\u53D1\u884C\u7248 5 \u5F00\u59CB, ''enum'' \u4E3A\u5173\u952E\u5B57, \u800C\u4E0D\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5C06 ''enum'' \u7528\u4F5C\u5173\u952E\u5B57)
+
+compiler.warn.assert.as.identifier=\u4ECE\u53D1\u884C\u7248 1.4 \u5F00\u59CB, ''assert'' \u662F\u4E00\u4E2A\u5173\u952E\u5B57, \u4F46\u4E0D\u80FD\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.4 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5C06 ''assert'' \u7528\u4F5C\u5173\u952E\u5B57)
+
+compiler.warn.underscore.as.identifier=''_'' \u5DF2\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u4EE5\u540E\u7684\u53D1\u884C\u7248\u53EF\u80FD\u4E0D\u652F\u6301\u5C06 ''_'' \u7528\u4F5C\u6807\u8BC6\u7B26)
+
+compiler.err.enum.as.identifier=\u4ECE\u53D1\u884C\u7248 5 \u5F00\u59CB, ''enum'' \u4E3A\u5173\u952E\u5B57, \u800C\u4E0D\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.4 \u6216\u66F4\u4F4E\u7248\u672C\u4EE5\u5C06 ''enum'' \u7528\u4F5C\u6807\u8BC6\u7B26)
+
+compiler.err.assert.as.identifier=\u4ECE\u53D1\u884C\u7248 1.4 \u5F00\u59CB, ''assert'' \u662F\u4E00\u4E2A\u5173\u952E\u5B57, \u4F46\u4E0D\u80FD\u7528\u4F5C\u6807\u8BC6\u7B26\n(\u8BF7\u4F7F\u7528 -source 1.3 \u6216\u66F4\u4F4E\u7248\u672C\u4EE5\u5C06 ''assert'' \u7528\u4F5C\u6807\u8BC6\u7B26)
+
+# TODO 308: make a better error message
+compiler.err.this.as.identifier=\u4ECE\u53D1\u884C\u7248 8 \u5F00\u59CB, ''this'' \u53EA\u80FD\u4F5C\u4E3A\u63A5\u6536\u65B9\u7C7B\u578B\u7684\u53C2\u6570\u540D, \u8BE5\u53C2\u6570\u5FC5\u987B\u4E3A\u7B2C\u4E00\u4E2A\u53C2\u6570
+
+# 0: symbol
+compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class=\u63A5\u6536\u65B9\u53C2\u6570\u4E0D\u9002\u7528\u4E8E\u9876\u5C42\u7C7B\u7684\u6784\u9020\u5668
+
+# TODO 308: make a better error message
+compiler.err.cant.annotate.static.class=\u65E0\u6CD5\u5BF9\u5C01\u95ED\u9759\u6001\u5D4C\u5957\u7C7B\u8FDB\u884C\u6CE8\u91CA
+
+# TODO 308: make a better error message
+# 0: unused
+compiler.err.cant.annotate.nested.type=\u65E0\u6CD5\u5BF9\u5D4C\u5957\u7C7B\u578B\u8FDB\u884C\u6CE8\u91CA
+
+# 0: type, 1: type
+compiler.err.incorrect.receiver.name=\u63A5\u6536\u65B9\u540D\u79F0\u4E0E\u5C01\u95ED\u7C7B\u7C7B\u578B\u4E0D\u5339\u914D\n\u9700\u8981: {0}\n\u627E\u5230: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.receiver.type=\u63A5\u6536\u65B9\u7C7B\u578B\u4E0E\u5C01\u95ED\u7C7B\u7C7B\u578B\u4E0D\u5339\u914D\n\u9700\u8981: {0}\n\u627E\u5230: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.type=\u63A5\u6536\u65B9\u7C7B\u578B\u4E0E\u5916\u90E8\u5C01\u95ED\u7C7B\u7C7B\u578B\u4E0D\u5339\u914D\n\u9700\u8981: {0}\n\u627E\u5230: {1}
+
+# 0: type, 1: type
+compiler.err.incorrect.constructor.receiver.name=\u63A5\u6536\u65B9\u540D\u79F0\u4E0E\u5916\u90E8\u5C01\u95ED\u7C7B\u7C7B\u578B\u4E0D\u5339\u914D\n\u9700\u8981: {0}\n\u627E\u5230: {1}
+
+compiler.err.no.annotations.on.dot.class=\u7C7B\u6587\u5B57\u7C7B\u578B\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u4EFB\u4F55\u6CE8\u91CA
+
+# 0: string
+compiler.err.generics.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u6CDB\u578B\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u6CDB\u578B)
+
+# 0: string
+compiler.err.varargs.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 variable-arity \u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 variable-arity \u65B9\u6CD5)
+
+# 0: string
+compiler.err.annotations.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u6CE8\u91CA)
+
+# 0: string
+compiler.err.type.annotations.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u7C7B\u578B\u6CE8\u91CA\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u7C7B\u578B\u6CE8\u91CA)
+
+# 0: string
+compiler.err.foreach.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 for-each \u5FAA\u73AF\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 for-each \u5FAA\u73AF)
+
+# 0: string
+compiler.err.static.import.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9759\u6001\u5BFC\u5165\u58F0\u660E\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9759\u6001\u5BFC\u5165\u58F0\u660E)
+
+# 0: string
+compiler.err.enums.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u679A\u4E3E\n(\u8BF7\u4F7F\u7528 -source 5 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u679A\u4E3E)
+
+# 0: string
+compiler.err.diamond.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 diamond \u8FD0\u7B97\u7B26\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 diamond \u8FD0\u7B97\u7B26)
+
+# 0: string
+compiler.err.multicatch.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 multi-catch \u8BED\u53E5\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 multi-catch \u8BED\u53E5)
+
+# 0: string
+compiler.err.string.switch.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 switch \u4E2D\u5B58\u5728\u5B57\u7B26\u4E32\n(\u8BF7\u4F7F\u7528 -source 7 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u5141\u8BB8 switch \u4E2D\u5B58\u5728\u5B57\u7B26\u4E32)
+
+# 0: string
+compiler.err.lambda.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301 lambda \u8868\u8FBE\u5F0F\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528 lambda \u8868\u8FBE\u5F0F)
+
+# 0: string
+compiler.err.method.references.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u65B9\u6CD5\u5F15\u7528\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u65B9\u6CD5\u5F15\u7528)
+
+# 0: string
+compiler.err.default.methods.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9ED8\u8BA4\u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9ED8\u8BA4\u65B9\u6CD5)
+
+# 0: string
+compiler.err.intersection.types.in.cast.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u8F6C\u6362\u4E2D\u7684\u4EA4\u53C9\u7C7B\u578B\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9ED8\u8BA4\u65B9\u6CD5)
+
+# 0: string
+compiler.err.static.intf.methods.not.supported.in.source=-source {0} \u4E2D\u4E0D\u652F\u6301\u9759\u6001\u63A5\u53E3\u65B9\u6CD5\n(\u8BF7\u4F7F\u7528 -source 8 \u6216\u66F4\u9AD8\u7248\u672C\u4EE5\u542F\u7528\u9759\u6001\u63A5\u53E3\u65B9\u6CD5)
+
+########################################
+# Diagnostics for verbose resolution
+# used by Resolve (debug only)
+########################################
+
+# 0: number, 1: symbol, 2: unused
+compiler.misc.applicable.method.found=\u627E\u5230\u7B2C {0} \u4E2A\u9002\u7528\u65B9\u6CD5: {1}
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.applicable.method.found.1=\u627E\u5230\u7B2C {0} \u4E2A\u9002\u7528\u65B9\u6CD5: {1}\n({2})
+
+# 0: number, 1: symbol, 2: message segment
+compiler.misc.not.applicable.method.found=\u627E\u5230\u7B2C {0} \u4E2A\u4E0D\u9002\u7528\u7684\u65B9\u6CD5: {1}\n({2})
+
+# 0: type
+compiler.misc.partial.inst.sig=\u90E8\u5206\u5B9E\u4F8B\u5316\u4E3A: {0}
+
+# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi=\u5C06\u7C7B\u578B {1} \u7684\u65B9\u6CD5 {0} \u89E3\u6790\u4E3A\u5019\u9009\u9879 {2}\n\u9636\u6BB5: {3}\n\u5177\u6709\u5B9E\u9645\u503C: {4}\n\u5177\u6709\u7C7B\u578B\u53C2\u6570: {5}\n\u5019\u9009\u9879:
+
+# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
+compiler.note.verbose.resolve.multi.1=\u7C7B\u578B {1} \u7684\u65B9\u6CD5 {0} \u89E3\u6790\u9519\u8BEF\n\u9636\u6BB5: {3}\n\u5177\u6709\u5B9E\u9645\u503C: {4}\n\u5177\u6709\u7C7B\u578B\u53C2\u6570: {5}\n\u5019\u9009\u9879:
+
+# 0: symbol, 1: type, 2: type
+compiler.note.deferred.method.inst=\u65B9\u6CD5 {0} \u7684\u5EF6\u8FDF\u5B9E\u4F8B\u5316\n\u5B9E\u4F8B\u5316\u7B7E\u540D: {1}\n\u76EE\u6807\u7C7B\u578B: {2}
+
+########################################
+# Diagnostics for where clause implementation
+# used by the RichDiagnosticFormatter.
+########################################
+
+compiler.misc.type.null=<\u7A7A\u503C>
+
+# X#n (where n is an int id) is disambiguated tvar name
+# 0: name, 1: number
+compiler.misc.type.var={0}#{1}
+
+# CAP#n (where n is an int id) is an abbreviation for 'captured type'
+# 0: number
+compiler.misc.captured.type=CAP#{0}
+
+# <INT#n> (where n is an int id) is an abbreviation for 'intersection type'
+# 0: number
+compiler.misc.intersection.type=INT#{0}
+
+# where clause for captured type: contains upper ('extends {1}') and lower
+# ('super {2}') bound along with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: type, 3: type
+compiler.misc.where.captured={0}\u4ECE{3}\u7684\u6355\u83B7\u6269\u5C55{1} \u8D85 {2}
+
+# compact where clause for captured type: contains upper ('extends {1}') along
+# with the wildcard that generated this captured type ({3})
+# 0: type, 1: type, 2: unused, 3: type
+compiler.misc.where.captured.1={0}\u4ECE{3}\u7684\u6355\u83B7\u6269\u5C55{1}
+
+# where clause for type variable: contains upper bound(s) ('extends {1}') along with
+# the kindname ({2}) and location ({3}) in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
+compiler.misc.where.typevar={0}\u6269\u5C55\u5DF2\u5728{2} {3}\u4E2D\u58F0\u660E\u7684{1}
+
+# compact where clause for type variable: contains the kindname ({2}) and location ({3})
+# in which the typevar has been declared
+# 0: type, 1: list of type, 2: symbol kind, 3: symbol
+compiler.misc.where.typevar.1={0}\u5DF2\u5728{2} {3}\u4E2D\u58F0\u660E
+
+# where clause for fresh type variable: contains upper bound(s) ('extends {1}').
+# Since a fresh type-variable is synthetic - there's no location/kindname here.
+# 0: type, 1: list of type
+compiler.misc.where.fresh.typevar={0}\u6269\u5C55{1}
+
+# where clause for type variable: contains all the upper bound(s) ('extends {1}')
+# of this intersection type
+# 0: type, 1: list of type
+compiler.misc.where.intersection={0}\u6269\u5C55{1}
+
+### Where clause headers ###
+compiler.misc.where.description.captured=\u5176\u4E2D, {0}\u662F\u65B0\u7C7B\u578B\u53D8\u91CF:
+
+# 0: set of type
+compiler.misc.where.description.typevar=\u5176\u4E2D, {0}\u662F\u7C7B\u578B\u53D8\u91CF:
+
+# 0: set of type
+compiler.misc.where.description.intersection=\u5176\u4E2D, {0}\u662F\u4EA4\u53C9\u7C7B\u578B:
+
+# 0: set of type
+compiler.misc.where.description.captured.1=\u5176\u4E2D, {0}\u662F\u65B0\u7C7B\u578B\u53D8\u91CF:
+
+# 0: set of type
+compiler.misc.where.description.typevar.1=\u5176\u4E2D, {0}\u662F\u7C7B\u578B\u53D8\u91CF:
+
+compiler.misc.where.description.intersection.1=\u5176\u4E2D, {0}\u662F\u4EA4\u53C9\u7C7B\u578B:
+
+###
+# errors related to doc comments
+
+compiler.err.dc.bad.entity=HTML \u5B9E\u4F53\u9519\u8BEF
+
+compiler.err.dc.bad.gt=''>'' \u7684\u7528\u6CD5\u9519\u8BEF
+
+compiler.err.dc.bad.inline.tag=\u5185\u5D4C\u6807\u8BB0\u7684\u7528\u6CD5\u4E0D\u6B63\u786E
+
+compiler.err.dc.identifier.expected=\u9700\u8981\u6807\u8BC6\u7B26
+
+compiler.err.dc.malformed.html=\u683C\u5F0F\u9519\u8BEF\u7684 HTML
+
+compiler.err.dc.missing.semicolon=\u7F3A\u5C11\u5206\u53F7
+
+compiler.err.dc.no.content=\u65E0\u5185\u5BB9
+
+compiler.err.dc.no.tag.name='@' \u540E\u6CA1\u6709\u6807\u8BB0\u540D
+
+compiler.err.dc.gt.expected=\u9700\u8981 ''>''
+
+compiler.err.dc.ref.bad.parens=\u5F15\u7528\u4E2D\u7F3A\u5C11 '')''
+
+compiler.err.dc.ref.syntax.error=\u5F15\u7528\u4E2D\u51FA\u73B0\u8BED\u6CD5\u9519\u8BEF
+
+compiler.err.dc.ref.unexpected.input=\u610F\u5916\u7684\u6587\u672C
+
+compiler.err.dc.unexpected.content=\u610F\u5916\u7684\u5185\u5BB9
+
+compiler.err.dc.unterminated.inline.tag=\u672A\u7EC8\u6B62\u7684\u5185\u5D4C\u6807\u8BB0
+
+compiler.err.dc.unterminated.signature=\u672A\u7EC8\u6B62\u7684\u7B7E\u540D
+
+compiler.err.dc.unterminated.string=\u672A\u7EC8\u6B62\u7684\u5B57\u7B26\u4E32
+
+
diff --git a/src/share/classes/com/sun/tools/javac/resources/javac.properties b/src/share/classes/com/sun/tools/javac/resources/javac.properties
index 4370f05..f32c229 100644
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties
+++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2011, 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
@@ -55,16 +55,22 @@ javac.opt.processorpath=\
     Specify where to find annotation processors
 javac.opt.processor=\
     Names of the annotation processors to run; bypasses default discovery process
+javac.opt.parameters=\
+    Generate metadata for reflection on method parameters
 javac.opt.proc.none.only=\
     Control whether annotation processing and/or compilation is done.
 javac.opt.d=\
     Specify where to place generated class files
 javac.opt.sourceDest=\
     Specify where to place generated source files
+javac.opt.headerDest=\
+    Specify where to place generated native header files
 javac.opt.J=\
     Pass <flag> directly to the runtime system
 javac.opt.encoding=\
     Specify character encoding used by source files
+javac.opt.profile=\
+    Check that API used is available in the specified profile
 javac.opt.target=\
     Generate class files for specific VM version
 javac.opt.source=\
@@ -93,10 +99,16 @@ javac.opt.arg.directory=\
     <directory>
 javac.opt.arg.encoding=\
     <encoding>
+javac.opt.arg.profile=\
+    <profile>
 javac.opt.arg.release=\
     <release>
 javac.opt.arg.number=\
     <number>
+javac.opt.plugin=\
+    Name and optional arguments for a plug-in to be run
+javac.opt.arg.plugin=\
+    "name args"
 
 ## extended options
 
@@ -132,6 +144,18 @@ javac.opt.Xlint=\
     Enable recommended warnings
 javac.opt.Xlint.suboptlist=\
     Enable or disable specific warnings
+javac.opt.Xdoclint=\
+    Enable recommended checks for problems in javadoc comments
+# L10N: do not localize: all none
+javac.opt.Xdoclint.subopts = \
+    (all|none|[-]<group>)[/<access>]
+
+# L10N: do not localize: accessibility html missing reference syntax
+# L10N: do not localize: public protected package private
+javac.opt.Xdoclint.custom=\n\
+\        Enable or disable specific checks for problems in javadoc comments,\n\
+\        where <group> is one of accessibility, html, missing, reference, or syntax,\n\
+\        and <access> is one of public, protected, package, or private.
 javac.opt.Xstdout=\
     Redirect standard output
 javac.opt.X=\
@@ -148,6 +172,8 @@ javac.opt.prefer=\
     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
 
@@ -159,6 +185,8 @@ javac.err.invalid.A.key=\
      key in annotation processor option ''{0}'' is not a dot-separated sequence of identifiers
 javac.err.invalid.flag=\
     invalid flag: {0}
+javac.err.invalid.profile=\
+    invalid profile: {0}
 javac.err.invalid.target=\
     invalid target release: {0}
 javac.err.no.source.files=\
@@ -175,6 +203,8 @@ javac.warn.source.target.conflict=\
     source release {0} requires target release {1}
 javac.warn.target.default.source.conflict=\
     target release {0} conflicts with default source release {1}
+javac.warn.profile.target.conflict=\
+    profile {0} is not valid for target release {1}
 javac.err.dir.not.found=\
     directory not found: {0}
 javac.err.file.not.found=\
@@ -183,6 +213,8 @@ javac.err.file.not.directory=\
     not a directory: {0}
 javac.err.file.not.file=\
     not a file: {0}
+javac.msg.plugin.not.found=\
+    plug-in not found: {0}
 ## messages
 
 javac.msg.usage.header=\
@@ -210,6 +242,10 @@ javac.msg.proc.annotation.uncaught.exception=\
 \n\nAn annotation processor threw an uncaught exception.\n\
 Consult the following stack trace for details.\n
 
+javac.msg.plugin.uncaught.exception=\
+\n\nA plugin threw an uncaught exception.\n\
+Consult the following stack trace for details.\n
+
 javac.msg.resource=\
 \n\nThe system is out of resources.\n\
 Consult the following stack trace for details.\n
diff --git a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java
index 9ee550e..6ee1a18 100644
--- a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java
+++ b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java
@@ -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
@@ -33,11 +33,12 @@ import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.jvm.ClassReader;
+import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.jvm.ClassWriter;
 import com.sun.tools.javac.jvm.Pool;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Pair;
 
 import java.io.File;
@@ -46,6 +47,7 @@ import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.Enumeration;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.Set;
 
@@ -84,7 +86,10 @@ import javax.tools.ToolProvider;
  *
  * @author Peter von der Ah\u00e9
  */
- at SupportedOptions({"com.sun.tools.javac.sym.Jar","com.sun.tools.javac.sym.Dest"})
+ at SupportedOptions({
+    "com.sun.tools.javac.sym.Jar",
+    "com.sun.tools.javac.sym.Dest",
+    "com.sun.tools.javac.sym.Profiles"})
 @SupportedAnnotationTypes("*")
 public class CreateSymbols extends AbstractProcessor {
 
@@ -105,6 +110,7 @@ public class CreateSymbols extends AbstractProcessor {
             processingEnv.getMessager()
                 .printMessage(Diagnostic.Kind.ERROR, e.getLocalizedMessage());
         } catch (Throwable t) {
+            t.printStackTrace();
             Throwable cause = t.getCause();
             if (cause == null)
                 cause = t;
@@ -120,12 +126,17 @@ public class CreateSymbols extends AbstractProcessor {
         Set<String> documented = new HashSet<String>();
         Set<PackageSymbol> packages =
             ((JavacProcessingEnvironment)processingEnv).getSpecifiedPackages();
-        String jarName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Jar");
+        Map<String,String> pOptions = processingEnv.getOptions();
+        String jarName = pOptions.get("com.sun.tools.javac.sym.Jar");
         if (jarName == null)
             throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Jar=LOCATION_OF_JAR");
-        String destName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Dest");
+        String destName = pOptions.get("com.sun.tools.javac.sym.Dest");
         if (destName == null)
             throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Dest=LOCATION_OF_JAR");
+        String profileSpec=pOptions.get("com.sun.tools.javac.sym.Profiles");
+        if (profileSpec == null)
+            throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Profiles=PROFILES_SPEC");
+        Profiles profiles = Profiles.read(new File(profileSpec));
 
         for (PackageSymbol psym : packages) {
             String name = psym.getQualifiedName().toString();
@@ -165,15 +176,23 @@ public class CreateSymbols extends AbstractProcessor {
             tool.getTask(null, fm, null, options, null, null);
         com.sun.tools.javac.main.JavaCompiler compiler =
             com.sun.tools.javac.main.JavaCompiler.instance(task.getContext());
-        ClassReader reader = ClassReader.instance(task.getContext());
         ClassWriter writer = ClassWriter.instance(task.getContext());
         Symtab syms = Symtab.instance(task.getContext());
-        Attribute.Compound proprietary =
+        Names names = Names.instance(task.getContext());
+        Attribute.Compound proprietaryAnno =
             new Attribute.Compound(syms.proprietaryType,
                                    List.<Pair<Symbol.MethodSymbol,Attribute>>nil());
+        Attribute.Compound[] profileAnnos = new Attribute.Compound[profiles.getProfileCount() + 1];
+        Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().lookup(names.value).sym;
+        for (int i = 1; i < profileAnnos.length; i++) {
+            profileAnnos[i] = new Attribute.Compound(syms.profileType,
+                    List.<Pair<Symbol.MethodSymbol, Attribute>>of(
+                    new Pair<Symbol.MethodSymbol, Attribute>(profileValue, new Attribute.Constant(syms.intType, i))));
+        }
 
         Type.moreInfo = true;
-        Pool pool = new Pool();
+        Types types = Types.instance(task.getContext());
+        Pool pool = new Pool(types);
         for (JavaFileObject file : fm.list(jarLocation, "", EnumSet.of(CLASS), true)) {
             String className = fm.inferBinaryName(jarLocation, file);
             int index = className.lastIndexOf('.');
@@ -206,10 +225,11 @@ public class CreateSymbols extends AbstractProcessor {
             }
             ClassSymbol cs = (ClassSymbol) sym;
             if (addLegacyAnnotation) {
-                cs.attributes_field = (cs.attributes_field == null)
-                    ? List.of(proprietary)
-                    : cs.attributes_field.prepend(proprietary);
+                cs.prependAttributes(List.of(proprietaryAnno));
             }
+            int p = profiles.getProfile(cs.fullname.toString().replace(".", "/"));
+            if (0 < p && p < profileAnnos.length)
+                cs.prependAttributes(List.of(profileAnnos[p]));
             writeClass(pool, cs, writer);
         }
 
diff --git a/src/share/classes/com/sun/tools/javac/sym/Profiles.java b/src/share/classes/com/sun/tools/javac/sym/Profiles.java
new file mode 100644
index 0000000..8cae1dd
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/sym/Profiles.java
@@ -0,0 +1,297 @@
+/*
+ * 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.tools.javac.sym;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import com.sun.tools.javac.util.Assert;
+
+/**
+ * Provide details about profile contents.
+ *
+ * <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></p>
+ */
+public abstract class Profiles {
+    // for debugging
+    public static void main(String[] args) throws IOException {
+        Profiles p = Profiles.read(new File(args[0]));
+        if (args.length >= 2) {
+            Map<Integer,Set<String>> lists = new TreeMap<Integer,Set<String>>();
+            for (int i = 1; i <= 4; i++)
+                lists.put(i, new TreeSet<String>());
+
+            File rt_jar_lst = new File(args[1]);
+            for (String line: Files.readAllLines(rt_jar_lst.toPath(), Charset.defaultCharset())) {
+                if (line.endsWith(".class")) {
+                    String type = line.substring(0, line.length() - 6);
+                    int profile = p.getProfile(type);
+                    for (int i = profile; i <= 4; i++)
+                        lists.get(i).add(type);
+                }
+            }
+
+            for (int i = 1; i <= 4; i++) {
+                BufferedWriter out = new BufferedWriter(new FileWriter(i + ".txt"));
+                try {
+                    for (String type: lists.get(i)) {
+                        out.write(type);
+                        out.newLine();
+                    }
+                } finally {
+                    out.close();
+                }
+            }
+        }
+    }
+
+    public static Profiles read(File file) throws IOException {
+        BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
+        try {
+            Properties p = new Properties();
+            p.load(in);
+            if (p.containsKey("java/lang/Object"))
+                return new SimpleProfiles(p);
+            else
+                return new MakefileProfiles(p);
+        } finally {
+            in.close();
+        }
+    }
+
+    public abstract int getProfileCount();
+
+    public abstract int getProfile(String typeName);
+
+    public abstract Set<String> getPackages(int profile);
+
+    private static class MakefileProfiles extends Profiles {
+        static class Package {
+            final Package parent;
+            final String name;
+
+            Map<String, Package> subpackages = new TreeMap<String, Package>();
+
+            int profile;
+            Map<String, Integer> includedTypes = new TreeMap<String,Integer>();
+            Map<String, Integer> excludedTypes = new TreeMap<String,Integer>();
+
+            Package(Package parent, String name) {
+                this.parent = parent;
+                this.name = name;
+            }
+
+            int getProfile() {
+                return (parent == null) ? profile : Math.max(parent.getProfile(), profile);
+            }
+
+            int getProfile(String simpleTypeName) {
+                Integer i;
+                if ((i = includedTypes.get(simpleTypeName)) != null)
+                    return i;
+                if ((i = includedTypes.get("*")) != null)
+                    return i;
+                if ((i = excludedTypes.get(simpleTypeName)) != null)
+                    return i + 1;
+                if ((i = excludedTypes.get("*")) != null)
+                    return i + 1;
+                return getProfile();
+            }
+
+            String getName() {
+                return (parent == null) ? name : (parent.getName() + "/" + name);
+            }
+
+            void getPackages(int profile, Set<String> results) {
+                int prf = getProfile();
+                if (prf != 0 && profile >= prf)
+                    results.add(getName());
+                for (Package pkg: subpackages.values())
+                    pkg.getPackages(profile, results);
+            }
+        }
+
+        final static Map<String, Package> packages = new TreeMap<String, Package>();
+
+        final int maxProfile = 4;  // Three compact profiles plus full JRE
+
+        MakefileProfiles(Properties p) {
+            for (int profile = 1; profile <= maxProfile; profile++) {
+                String prefix = (profile < maxProfile ? "PROFILE_" + profile : "FULL_JRE");
+                String inclPackages = p.getProperty(prefix + "_RTJAR_INCLUDE_PACKAGES");
+                if (inclPackages == null)
+                    break;
+                for (String pkg: inclPackages.substring(1).trim().split("\\s+")) {
+                    if (pkg.endsWith("/"))
+                        pkg = pkg.substring(0, pkg.length() - 1);
+                    includePackage(profile, pkg);
+                }
+                String inclTypes =  p.getProperty(prefix + "_RTJAR_INCLUDE_TYPES");
+                if (inclTypes != null) {
+                    for (String type: inclTypes.replace("$$", "$").split("\\s+")) {
+                        if (type.endsWith(".class"))
+                            includeType(profile, type.substring(0, type.length() - 6));
+                    }
+                }
+                String exclTypes =  p.getProperty(prefix + "_RTJAR_EXCLUDE_TYPES");
+                if (exclTypes != null) {
+                    for (String type: exclTypes.replace("$$", "$").split("\\s+")) {
+                        if (type.endsWith(".class"))
+                            excludeType(profile, type.substring(0, type.length() - 6));
+                    }
+                }
+            }
+        }
+
+        @Override
+        public int getProfileCount() {
+            return maxProfile;
+        }
+
+        @Override
+        public int getProfile(String typeName) {
+            int sep = typeName.lastIndexOf("/");
+            String packageName = typeName.substring(0, sep);
+            String simpleName = typeName.substring(sep + 1);
+
+            Package p = getPackage(packageName);
+            return p.getProfile(simpleName);
+        }
+
+        @Override
+        public Set<String> getPackages(int profile) {
+            Set<String> results = new TreeSet<String>();
+            for (Package p: packages.values())
+                p.getPackages(profile, results);
+            return results;
+        }
+
+        private void includePackage(int profile, String packageName) {
+//            System.err.println("include package " + packageName);
+            Package p = getPackage(packageName);
+            Assert.check(p.profile == 0);
+            p.profile = profile;
+        }
+
+        private void includeType(int profile, String typeName) {
+//            System.err.println("include type " + typeName);
+            int sep = typeName.lastIndexOf("/");
+            String packageName = typeName.substring(0, sep);
+            String simpleName = typeName.substring(sep + 1);
+
+            Package p = getPackage(packageName);
+            Assert.check(!p.includedTypes.containsKey(simpleName));
+            p.includedTypes.put(simpleName, profile);
+        }
+
+        private void excludeType(int profile, String typeName) {
+//            System.err.println("exclude type " + typeName);
+            int sep = typeName.lastIndexOf("/");
+            String packageName = typeName.substring(0, sep);
+            String simpleName = typeName.substring(sep + 1);
+
+            Package p = getPackage(packageName);
+            Assert.check(!p.excludedTypes.containsKey(simpleName));
+            p.excludedTypes.put(simpleName, profile);
+        }
+
+        private Package getPackage(String packageName) {
+            int sep = packageName.lastIndexOf("/");
+            Package parent;
+            Map<String, Package> parentSubpackages;
+            String simpleName;
+            if (sep == -1) {
+                parent = null;
+                parentSubpackages = packages;
+                simpleName = packageName;
+            } else {
+                parent = getPackage(packageName.substring(0, sep));
+                parentSubpackages = parent.subpackages;
+                simpleName = packageName.substring(sep + 1);
+            }
+
+            Package p = parentSubpackages.get(simpleName);
+            if (p == null) {
+                parentSubpackages.put(simpleName, p = new Package(parent, simpleName));
+            }
+            return p;
+        }
+    }
+
+    private static class SimpleProfiles extends Profiles {
+        private final Map<String, Integer> map;
+        private final int profileCount;
+
+        SimpleProfiles(Properties p) {
+            int max = 0;
+            map = new HashMap<String, Integer>();
+            for (Map.Entry<Object,Object> e: p.entrySet()) {
+                String typeName = (String) e.getKey();
+                int profile = Integer.valueOf((String) e.getValue());
+                map.put(typeName, profile);
+                max = Math.max(max, profile);
+            }
+            profileCount = max;
+        }
+
+        @Override
+        public int getProfileCount() {
+            return profileCount;
+        }
+
+        @Override
+        public int getProfile(String typeName) {
+            return map.get(typeName);
+        }
+
+        @Override
+        public Set<String> getPackages(int profile) {
+            Set<String> results = new TreeSet<String>();
+            for (Map.Entry<String,Integer> e: map.entrySet()) {
+                String tn = e.getKey();
+                int prf = e.getValue();
+                int sep = tn.lastIndexOf("/");
+                if (sep > 0 && profile >= prf)
+                    results.add(tn);
+            }
+            return results;
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/DCTree.java b/src/share/classes/com/sun/tools/javac/tree/DCTree.java
new file mode 100644
index 0000000..7c4c966
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/tree/DCTree.java
@@ -0,0 +1,888 @@
+/*
+ * 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
+ * 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.tree;
+
+
+import javax.tools.Diagnostic;
+
+import com.sun.source.doctree.*;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Position;
+import java.io.IOException;
+import java.io.StringWriter;
+import javax.tools.JavaFileObject;
+
+/**
+ * <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 abstract class DCTree implements DocTree {
+
+    /**
+     * The position in the comment string.
+     * Use {@link #getSourcePosition getSourcePosition} to convert
+     * it to a position in the source file.
+     *
+     * TODO: why not simply translate all these values into
+     * source file positions? Is it useful to have string-offset
+     * positions as well?
+     */
+    public int pos;
+
+    public long getSourcePosition(DCDocComment dc) {
+        return dc.comment.getSourcePos(pos);
+    }
+
+    public JCDiagnostic.DiagnosticPosition pos(DCDocComment dc) {
+        return new SimpleDiagnosticPosition(dc.comment.getSourcePos(pos));
+    }
+
+    /** Convert a tree to a pretty-printed string. */
+    @Override
+    public String toString() {
+        StringWriter s = new StringWriter();
+        try {
+            new DocPretty(s).print(this);
+        }
+        catch (IOException e) {
+            // should never happen, because StringWriter is defined
+            // never to throw any IOExceptions
+            throw new AssertionError(e);
+        }
+        return s.toString();
+    }
+
+    public static abstract class DCEndPosTree<T extends DCEndPosTree<T>> extends DCTree {
+
+        private int endPos = Position.NOPOS;
+
+        public int getEndPos(DCDocComment dc) {
+            return dc.comment.getSourcePos(endPos);
+        }
+
+        @SuppressWarnings("unchecked")
+        public T setEndPos(int endPos) {
+            this.endPos = endPos;
+            return (T) this;
+        }
+
+    }
+
+    public static class DCDocComment extends DCTree implements DocCommentTree {
+        public final Comment comment; // required for the implicit source pos table
+
+        public final List<DCTree> firstSentence;
+        public final List<DCTree> body;
+        public final List<DCTree> tags;
+        
+        public List<JCDiagnostic> errors;
+
+        public DCDocComment(Comment comment,
+                List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
+            this.comment = comment;
+            this.firstSentence = firstSentence;
+            this.body = body;
+            this.tags = tags;
+        }
+
+        public Kind getKind() {
+            return Kind.DOC_COMMENT;
+        }
+
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDocComment(this, d);
+        }
+
+        public List<? extends DocTree> getFirstSentence() {
+            return firstSentence;
+        }
+
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+
+        public List<? extends DocTree> getBlockTags() {
+            return tags;
+        }
+
+    }
+
+    public static abstract class DCBlockTag extends DCTree implements BlockTagTree {
+        public String getTagName() {
+            return getKind().tagName;
+        }
+    }
+
+    public static abstract class DCInlineTag extends DCEndPosTree<DCInlineTag> implements InlineTagTree {
+        public String getTagName() {
+            return getKind().tagName;
+        }
+    }
+
+    public static class DCAttribute extends DCTree implements AttributeTree {
+        public final Name name;
+        public final ValueKind vkind;
+        public final List<DCTree> value;
+
+        DCAttribute(Name name, ValueKind vkind, List<DCTree> value) {
+            Assert.check((vkind == ValueKind.EMPTY) ? (value == null) : (value != null));
+            this.name = name;
+            this.vkind = vkind;
+            this.value = value;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ATTRIBUTE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitAttribute(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+
+        @Override
+        public ValueKind getValueKind() {
+            return vkind;
+        }
+
+        @Override
+        public List<DCTree> getValue() {
+            return value;
+        }
+    }
+
+    public static class DCAuthor extends DCBlockTag implements AuthorTree {
+        public final List<DCTree> name;
+
+        DCAuthor(List<DCTree> name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.AUTHOR;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitAuthor(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getName() {
+            return name;
+        }
+    }
+
+    public static class DCComment extends DCTree implements CommentTree {
+        public final String body;
+
+        DCComment(String body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.COMMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitComment(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return body;
+        }
+    }
+
+    public static class DCDeprecated extends DCBlockTag implements DeprecatedTree {
+        public final List<DCTree> body;
+
+        DCDeprecated(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.DEPRECATED;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDeprecated(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+    public static class DCDocRoot extends DCInlineTag implements DocRootTree {
+
+        @Override
+        public Kind getKind() {
+            return Kind.DOC_ROOT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitDocRoot(this, d);
+        }
+    }
+
+    public static class DCEndElement extends DCTree implements EndElementTree {
+        public final Name name;
+
+        DCEndElement(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.END_ELEMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitEndElement(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCEntity extends DCTree implements EntityTree {
+        public final Name name;
+
+        DCEntity(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ENTITY;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitEntity(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCErroneous extends DCTree implements ErroneousTree, JCDiagnostic.DiagnosticPosition {
+        public final String body;
+        public final JCDiagnostic diag;
+
+        DCErroneous(String body, JCDiagnostic.Factory diags, DiagnosticSource diagSource, String code, Object... args) {
+            this.body = body;
+            this.diag = diags.error(diagSource, this, code, args);
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.ERRONEOUS;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitErroneous(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return body;
+        }
+
+        @Override
+        public Diagnostic<JavaFileObject> getDiagnostic() {
+            return diag;
+        }
+
+        @Override
+        public JCTree getTree() {
+            return null;
+        }
+
+        @Override
+        public int getStartPosition() {
+            return pos;
+        }
+
+        @Override
+        public int getPreferredPosition() {
+            return pos + body.length() - 1;
+        }
+
+        @Override
+        public int getEndPosition(EndPosTable endPosTable) {
+            return pos + body.length();
+        }
+
+    }
+
+    public static class DCIdentifier extends DCTree implements IdentifierTree {
+        public final Name name;
+
+        DCIdentifier(Name name) {
+            this.name = name;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.IDENTIFIER;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitIdentifier(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+    }
+
+    public static class DCInheritDoc extends DCInlineTag implements InheritDocTree {
+        @Override
+        public Kind getKind() {
+            return Kind.INHERIT_DOC;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitInheritDoc(this, d);
+        }
+    }
+
+    public static class DCLink extends DCInlineTag implements LinkTree {
+        public final Kind kind;
+        public final DCReference ref;
+        public final List<DCTree> label;
+
+        DCLink(Kind kind, DCReference ref, List<DCTree> label) {
+            Assert.check(kind == Kind.LINK || kind == Kind.LINK_PLAIN);
+            this.kind = kind;
+            this.ref = ref;
+            this.label = label;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitLink(this, d);
+        }
+
+        @Override
+        public ReferenceTree getReference() {
+            return ref;
+        }
+
+        @Override
+        public List<? extends DocTree> getLabel() {
+            return label;
+        }
+    }
+
+    public static class DCLiteral extends DCInlineTag implements LiteralTree {
+        public final Kind kind;
+        public final DCText body;
+
+        DCLiteral(Kind kind, DCText body) {
+            Assert.check(kind == Kind.CODE || kind == Kind.LITERAL);
+            this.kind = kind;
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitLiteral(this, d);
+        }
+
+        @Override
+        public DCText getBody() {
+            return body;
+        }
+    }
+
+    public static class DCParam extends DCBlockTag implements ParamTree {
+        public final boolean isTypeParameter;
+        public final DCIdentifier name;
+        public final List<DCTree> description;
+
+        DCParam(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
+            this.isTypeParameter = isTypeParameter;
+            this.name = name;
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.PARAM;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitParam(this, d);
+        }
+
+        @Override
+        public boolean isTypeParameter() {
+            return isTypeParameter;
+        }
+
+        @Override
+        public IdentifierTree getName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCReference extends DCEndPosTree<DCReference> implements ReferenceTree {
+        public final String signature;
+
+        // The following are not directly exposed through ReferenceTree
+        // use DocTrees.getElement(TreePath,ReferenceTree)
+        public final JCTree qualifierExpression;
+        public final Name memberName;
+        public final List<JCTree> paramTypes;
+        public       boolean attributed;
+        public       Symbol sym;
+
+
+        DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
+            this.signature = signature;
+            qualifierExpression = qualExpr;
+            memberName = member;
+            this.paramTypes = paramTypes;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.REFERENCE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitReference(this, d);
+        }
+
+        @Override
+        public String getSignature() {
+            return signature;
+        }
+    }
+
+    public static class DCReturn extends DCBlockTag implements ReturnTree {
+        public final List<DCTree> description;
+
+        DCReturn(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.RETURN;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitReturn(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSee extends DCBlockTag implements SeeTree {
+        public final List<DCTree> reference;
+
+        DCSee(List<DCTree> reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SEE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSee(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getReference() {
+            return reference;
+        }
+    }
+
+    public static class DCSerial extends DCBlockTag implements SerialTree {
+        public final List<DCTree> description;
+
+        DCSerial(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerial(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSerialData extends DCBlockTag implements SerialDataTree {
+        public final List<DCTree> description;
+
+        DCSerialData(List<DCTree> description) {
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL_DATA;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerialData(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCSerialField extends DCBlockTag implements SerialFieldTree {
+        public final DCIdentifier name;
+        public final DCReference type;
+        public final List<DCTree> description;
+
+        DCSerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
+            this.description = description;
+            this.name = name;
+            this.type = type;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SERIAL_FIELD;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSerialField(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+
+        @Override
+        public IdentifierTree getName() {
+            return name;
+        }
+
+        @Override
+        public ReferenceTree getType() {
+            return type;
+        }
+    }
+
+    public static class DCSince extends DCBlockTag implements SinceTree {
+        public final List<DCTree> body;
+
+        DCSince(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.SINCE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitSince(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+    public static class DCStartElement extends DCEndPosTree<DCStartElement> implements StartElementTree {
+        public final Name name;
+        public final List<DCTree> attrs;
+        public final boolean selfClosing;
+
+        DCStartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
+            this.name = name;
+            this.attrs = attrs;
+            this.selfClosing = selfClosing;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.START_ELEMENT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitStartElement(this, d);
+        }
+
+        @Override
+        public Name getName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getAttributes() {
+            return attrs;
+        }
+
+        @Override
+        public boolean isSelfClosing() {
+            return selfClosing;
+        }
+    }
+
+    public static class DCText extends DCTree implements TextTree {
+        public final String text;
+
+        DCText(String text) {
+            this.text = text;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.TEXT;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitText(this, d);
+        }
+
+        @Override
+        public String getBody() {
+            return text;
+        }
+    }
+
+    public static class DCThrows extends DCBlockTag implements ThrowsTree {
+        public final Kind kind;
+        public final DCReference name;
+        public final List<DCTree> description;
+
+        DCThrows(Kind kind, DCReference name, List<DCTree> description) {
+            Assert.check(kind == Kind.EXCEPTION || kind == Kind.THROWS);
+            this.kind = kind;
+            this.name = name;
+            this.description = description;
+        }
+
+        @Override
+        public Kind getKind() {
+            return kind;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitThrows(this, d);
+        }
+
+        @Override
+        public ReferenceTree getExceptionName() {
+            return name;
+        }
+
+        @Override
+        public List<? extends DocTree> getDescription() {
+            return description;
+        }
+    }
+
+    public static class DCUnknownBlockTag extends DCBlockTag implements UnknownBlockTagTree {
+        public final Name name;
+        public final List<DCTree> content;
+
+        DCUnknownBlockTag(Name name, List<DCTree> content) {
+            this.name = name;
+            this.content = content;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.UNKNOWN_BLOCK_TAG;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitUnknownBlockTag(this, d);
+        }
+
+        @Override
+        public String getTagName() {
+            return name.toString();
+        }
+
+        @Override
+        public List<? extends DocTree> getContent() {
+            return content;
+        }
+    }
+
+    public static class DCUnknownInlineTag extends DCInlineTag implements UnknownInlineTagTree {
+        public final Name name;
+        public final List<DCTree> content;
+
+        DCUnknownInlineTag(Name name, List<DCTree> content) {
+            this.name = name;
+            this.content = content;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.UNKNOWN_INLINE_TAG;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitUnknownInlineTag(this, d);
+        }
+
+        @Override
+        public String getTagName() {
+            return name.toString();
+        }
+
+        @Override
+        public List<? extends DocTree> getContent() {
+            return content;
+        }
+    }
+
+    public static class DCValue extends DCInlineTag implements ValueTree {
+        public final DCReference ref;
+
+        DCValue(DCReference ref) {
+            this.ref = ref;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.VALUE;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitValue(this, d);
+        }
+
+        @Override
+        public ReferenceTree getReference() {
+            return ref;
+        }
+    }
+
+    public static class DCVersion extends DCBlockTag implements VersionTree {
+        public final List<DCTree> body;
+
+        DCVersion(List<DCTree> body) {
+            this.body = body;
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.VERSION;
+        }
+
+        @Override
+        public <R, D> R accept(DocTreeVisitor<R, D> v, D d) {
+            return v.visitVersion(this, d);
+        }
+
+        @Override
+        public List<? extends DocTree> getBody() {
+            return body;
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java b/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java
new file mode 100644
index 0000000..1d88afd
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.javac.tree;
+
+import com.sun.source.doctree.ErroneousTree;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+
+/**
+ * A table giving the doc comment, if any, for any tree node.
+ *
+ *  <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 interface DocCommentTable {
+    /**
+     * Check if a tree node has a corresponding doc comment.
+     */
+    public boolean hasComment(JCTree tree);
+
+    /**
+     * Get the Comment token containing the doc comment, if any, for a tree node.
+     */
+    public Comment getComment(JCTree tree);
+
+    /**
+     * Get the plain text of the doc comment, if any, for a tree node.
+     */
+    public String getCommentText(JCTree tree);
+
+    /**
+     * Get the parsed form of the doc comment as a DocTree. If any errors
+     * are detected during parsing, they will be reported via
+     * {@link ErroneousTree ErroneousTree} nodes within the resulting tree.
+     */
+    public DCDocComment getCommentTree(JCTree tree);
+
+    /**
+     * Set the Comment to be associated with a tree node.
+     */
+    public void putComment(JCTree tree, Comment c);
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/DocPretty.java b/src/share/classes/com/sun/tools/javac/tree/DocPretty.java
new file mode 100644
index 0000000..0b6faec
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/tree/DocPretty.java
@@ -0,0 +1,520 @@
+/*
+ * Copyright (c) 1999, 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.javac.tree;
+
+import java.io.Writer;
+
+import com.sun.source.doctree.*;
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.tools.javac.util.Convert;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Prints out a doc comment tree.
+ *
+ *  <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 DocPretty implements DocTreeVisitor<Void,Void> {
+
+    /**
+     * The output stream on which trees are printed.
+     */
+    final Writer out;
+
+    /**
+     * The left margin.
+     */
+    int lmargin = 0;
+
+    public DocPretty(Writer out) {
+        this.out = out;
+    }
+
+    /** Visitor method: print expression tree.
+     */
+    public void print(DocTree tree) throws IOException {
+        try {
+            if (tree == null)
+                print("/*missing*/");
+            else {
+                tree.accept(this, null);
+            }
+        } catch (UncheckedIOException ex) {
+            throw new IOException(ex.getMessage(), ex);
+        }
+    }
+
+    /**
+     * Print string, replacing all non-ascii character with unicode escapes.
+     */
+    protected void print(Object s) throws IOException {
+        out.write(Convert.escapeUnicode(s.toString()));
+    }
+
+    /**
+     * Print list.
+     */
+    public void print(List<? extends DocTree> list) throws IOException {
+        for (DocTree t: list) {
+            print(t);
+        }
+    }
+
+    /**
+     * Print list., with separators
+     */
+    protected void print(List<? extends DocTree> list, String sep) throws IOException {
+        if (list.isEmpty())
+            return;
+        boolean first = true;
+        for (DocTree t: list) {
+            if (!first)
+                print(sep);
+            print(t);
+            first = false;
+        }
+    }
+
+    /** Print new line.
+     */
+    protected void println() throws IOException {
+        out.write(lineSep);
+    }
+
+    protected void printTagName(DocTree node) throws IOException {
+        out.write("@");
+        out.write(node.getKind().tagName);
+    }
+
+    final String lineSep = System.getProperty("line.separator");
+
+    /**************************************************************************
+     * Traversal methods
+     *************************************************************************/
+
+    /** Exception to propagate IOException through visitXXX methods */
+    private static class UncheckedIOException extends Error {
+        static final long serialVersionUID = -4032692679158424751L;
+        UncheckedIOException(IOException e) {
+            super(e.getMessage(), e);
+        }
+    }
+
+
+    public Void visitAttribute(AttributeTree node, Void p) {
+        try {
+            print(node.getName());
+            String quote;
+            switch (node.getValueKind()) {
+                case EMPTY:
+                    quote = null;
+                    break;
+                case UNQUOTED:
+                    quote = "";
+                    break;
+                case SINGLE:
+                    quote = "'";
+                    break;
+                case DOUBLE:
+                    quote = "\"";
+                    break;
+                default:
+                    throw new AssertionError();
+            }
+            if (quote != null) {
+                print("=" + quote);
+                print(node.getValue());
+                print(quote);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitAuthor(AuthorTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getName());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitComment(CommentTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDeprecated(DeprecatedTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getBody().isEmpty()) {
+                print(" ");
+                print(node.getBody());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDocComment(DocCommentTree node, Void p) {
+        try {
+            List<? extends DocTree> fs = node.getFirstSentence();
+            List<? extends DocTree> b = node.getBody();
+            List<? extends DocTree> t = node.getBlockTags();
+            print(fs);
+            if (!fs.isEmpty() && !b.isEmpty())
+                print(" ");
+            print(b);
+            if ((!fs.isEmpty() || !b.isEmpty()) && !t.isEmpty())
+                print("\n");
+            print(t, "\n");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitDocRoot(DocRootTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitEndElement(EndElementTree node, Void p) {
+        try {
+            print("</");
+            print(node.getName());
+            print(">");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitEntity(EntityTree node, Void p) {
+        try {
+            print("&");
+            print(node.getName());
+            print(";");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitErroneous(ErroneousTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitIdentifier(IdentifierTree node, Void p) {
+        try {
+            print(node.getName());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitInheritDoc(InheritDocTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitLink(LinkTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print(" ");
+            print(node.getReference());
+            if (!node.getLabel().isEmpty()) {
+                print(" ");
+                print(node.getLabel());
+            }
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitLiteral(LiteralTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitParam(ParamTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            if (node.isTypeParameter()) print("<");
+            print(node.getName());
+            if (node.isTypeParameter()) print(">");
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitReference(ReferenceTree node, Void p) {
+        try {
+            print(node.getSignature());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitReturn(ReturnTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getDescription());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSee(SeeTree node, Void p) {
+        try {
+            printTagName(node);
+            boolean first = true;
+            boolean needSep = true;
+            for (DocTree t: node.getReference()) {
+                if (needSep) print(" ");
+                needSep = (first && (t instanceof ReferenceTree));
+                first = false;
+                print(t);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerial(SerialTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerialData(SerialDataTree node, Void p) {
+        try {
+            printTagName(node);
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSerialField(SerialFieldTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getName());
+            print(" ");
+            print(node.getType());
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitSince(SinceTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitStartElement(StartElementTree node, Void p) {
+        try {
+            print("<");
+            print(node.getName());
+            List<? extends DocTree> attrs = node.getAttributes();
+            if (!attrs.isEmpty()) {
+                print(" ");
+                print(attrs);
+                DocTree last = node.getAttributes().get(attrs.size() - 1);
+                if (node.isSelfClosing() && last instanceof AttributeTree
+                        && ((AttributeTree) last).getValueKind() == ValueKind.UNQUOTED)
+                    print(" ");
+            }
+            if (node.isSelfClosing())
+                print("/");
+            print(">");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitText(TextTree node, Void p) {
+        try {
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitThrows(ThrowsTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getExceptionName());
+            if (!node.getDescription().isEmpty()) {
+                print(" ");
+                print(node.getDescription());
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
+        try {
+            print("@");
+            print(node.getTagName());
+            print(" ");
+            print(node.getContent());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
+        try {
+            print("{");
+            print("@");
+            print(node.getTagName());
+            print(" ");
+            print(node.getContent());
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitValue(ValueTree node, Void p) {
+        try {
+            print("{");
+            printTagName(node);
+            if (node.getReference() != null) {
+                print(" ");
+                print(node.getReference());
+            }
+            print("}");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitVersion(VersionTree node, Void p) {
+        try {
+            printTagName(node);
+            print(" ");
+            print(node.getBody());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+
+    public Void visitOther(DocTree node, Void p) {
+        try {
+            print("(UNKNOWN: " + node + ")");
+            println();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        return null;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java b/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
new file mode 100644
index 0000000..1060db8
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+import com.sun.source.doctree.AttributeTree.ValueKind;
+import com.sun.source.doctree.DocTree.Kind;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DCTree.*;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.DiagnosticSource;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Position;
+
+/**
+ *
+ *  <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 DocTreeMaker {
+
+    /** The context key for the tree factory. */
+    protected static final Context.Key<DocTreeMaker> treeMakerKey =
+        new Context.Key<DocTreeMaker>();
+
+    /** Get the TreeMaker instance. */
+    public static DocTreeMaker instance(Context context) {
+        DocTreeMaker instance = context.get(treeMakerKey);
+        if (instance == null)
+            instance = new DocTreeMaker(context);
+        return instance;
+    }
+
+    /** The position at which subsequent trees will be created.
+     */
+    public int pos = Position.NOPOS;
+
+    /** Access to diag factory for ErroneousTrees. */
+    private final JCDiagnostic.Factory diags;
+
+    /** Create a tree maker with NOPOS as initial position.
+     */
+    protected DocTreeMaker(Context context) {
+        context.put(treeMakerKey, this);
+        diags = JCDiagnostic.Factory.instance(context);
+        this.pos = Position.NOPOS;
+    }
+
+    /** Reassign current position.
+     */
+    public DocTreeMaker at(int pos) {
+        this.pos = pos;
+        return this;
+    }
+
+    /** Reassign current position.
+     */
+    public DocTreeMaker at(DiagnosticPosition pos) {
+        this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition());
+        return this;
+    }
+
+    public DCAttribute Attribute(Name name, ValueKind vkind, List<DCTree> value) {
+        DCAttribute tree = new DCAttribute(name, vkind, value);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCAuthor Author(List<DCTree> name) {
+        DCAuthor tree = new DCAuthor(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLiteral Code(DCText text) {
+        DCLiteral tree = new DCLiteral(Kind.CODE, text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCComment Comment(String text) {
+        DCComment tree = new DCComment(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDeprecated Deprecated(List<DCTree> text) {
+        DCDeprecated tree = new DCDeprecated(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDocComment DocComment(Comment comment, List<DCTree> firstSentence, List<DCTree> body, List<DCTree> tags) {
+        DCDocComment tree = new DCDocComment(comment, firstSentence, body, tags);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCDocRoot DocRoot() {
+        DCDocRoot tree = new DCDocRoot();
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCEndElement EndElement(Name name) {
+        DCEndElement tree = new DCEndElement(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCEntity Entity(Name name) {
+        DCEntity tree = new DCEntity(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCErroneous Erroneous(String text, DiagnosticSource diagSource, String code, Object... args) {
+        DCErroneous tree = new DCErroneous(text, diags, diagSource, code, args);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCThrows Exception(DCReference name, List<DCTree> description) {
+        DCThrows tree = new DCThrows(Kind.EXCEPTION, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCIdentifier Identifier(Name name) {
+        DCIdentifier tree = new DCIdentifier(name);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCInheritDoc InheritDoc() {
+        DCInheritDoc tree = new DCInheritDoc();
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLink Link(DCReference ref, List<DCTree> label) {
+        DCLink tree = new DCLink(Kind.LINK, ref, label);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLink LinkPlain(DCReference ref, List<DCTree> label) {
+        DCLink tree = new DCLink(Kind.LINK_PLAIN, ref, label);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCLiteral Literal(DCText text) {
+        DCLiteral tree = new DCLiteral(Kind.LITERAL, text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCParam Param(boolean isTypeParameter, DCIdentifier name, List<DCTree> description) {
+        DCParam tree = new DCParam(isTypeParameter, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCReference Reference(String signature,
+            JCTree qualExpr, Name member, List<JCTree> paramTypes) {
+        DCReference tree = new DCReference(signature, qualExpr, member, paramTypes);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCReturn Return(List<DCTree> description) {
+        DCReturn tree = new DCReturn(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSee See(List<DCTree> reference) {
+        DCSee tree = new DCSee(reference);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerial Serial(List<DCTree> description) {
+        DCSerial tree = new DCSerial(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerialData SerialData(List<DCTree> description) {
+        DCSerialData tree = new DCSerialData(description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSerialField SerialField(DCIdentifier name, DCReference type, List<DCTree> description) {
+        DCSerialField tree = new DCSerialField(name, type, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCSince Since(List<DCTree> text) {
+        DCSince tree = new DCSince(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCStartElement StartElement(Name name, List<DCTree> attrs, boolean selfClosing) {
+        DCStartElement tree = new DCStartElement(name, attrs, selfClosing);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCText Text(String text) {
+        DCText tree = new DCText(text);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCThrows Throws(DCReference name, List<DCTree> description) {
+        DCThrows tree = new DCThrows(Kind.THROWS, name, description);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCUnknownBlockTag UnknownBlockTag(Name name, List<DCTree> content) {
+        DCUnknownBlockTag tree = new DCUnknownBlockTag(name, content);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCUnknownInlineTag UnknownInlineTag(Name name, List<DCTree> content) {
+        DCUnknownInlineTag tree = new DCUnknownInlineTag(name, content);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCValue Value(DCReference ref) {
+        DCValue tree = new DCValue(ref);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public DCVersion Version(List<DCTree> text) {
+        DCVersion tree = new DCVersion(text);
+        tree.pos = pos;
+        return tree;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/EndPosTable.java b/src/share/classes/com/sun/tools/javac/tree/EndPosTable.java
new file mode 100644
index 0000000..1f9eefa
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/tree/EndPosTable.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+/**
+ * Specifies the methods to access a mappings of syntax trees to end positions.
+ * <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></p>
+ */
+public interface EndPosTable {
+
+    /**
+     * This method will return the end position of a given tree, otherwise a
+     * Positions.NOPOS will be returned.
+     * @param tree JCTree
+     * @return position of the source tree or Positions.NOPOS for non-existent mapping
+     */
+    public int getEndPos(JCTree tree);
+
+    /**
+     * Give an old tree and a new tree, the old tree will be replaced with
+     * the new tree, the position of the new tree will be that of the old
+     * tree.
+     * not exist.
+     * @param oldtree a JCTree to be replaced
+     * @param newtree a JCTree to be replaced with
+     * @return position of the old tree or Positions.NOPOS for non-existent mapping
+     */
+    public int replaceTree(JCTree oldtree, JCTree newtree);
+}
diff --git a/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/src/share/classes/com/sun/tools/javac/tree/JCTree.java
index a320ba2..d4f65e6 100644
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,22 +25,26 @@
 
 package com.sun.tools.javac.tree;
 
-import java.util.*;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.*;
+
 import javax.lang.model.element.Modifier;
 import javax.lang.model.type.TypeKind;
 import javax.tools.JavaFileObject;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.util.List;
+
+import com.sun.source.tree.*;
+import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Scope.*;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.source.tree.*;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
-import static com.sun.tools.javac.code.BoundKind.*;
+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.tree.JCTree.Tag.*;
 
 /**
  * Root class for abstract syntax tree nodes. It provides definitions
@@ -78,252 +82,309 @@ import static com.sun.tools.javac.code.BoundKind.*;
 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
 
     /* Tree tag values, identifying kinds of trees */
+    public enum Tag {
+        /** For methods that return an invalid tag if a given condition is not met
+         */
+        NO_TAG,
 
-    /** Toplevel nodes, of type TopLevel, representing entire source files.
-     */
-    public static final int  TOPLEVEL = 1;
+        /** Toplevel nodes, of type TopLevel, representing entire source files.
+        */
+        TOPLEVEL,
 
-    /** Import clauses, of type Import.
-     */
-    public static final int IMPORT = TOPLEVEL + 1;
+        /** Import clauses, of type Import.
+         */
+        IMPORT,
 
-    /** Class definitions, of type ClassDef.
-     */
-    public static final int CLASSDEF = IMPORT + 1;
+        /** Class definitions, of type ClassDef.
+         */
+        CLASSDEF,
 
-    /** Method definitions, of type MethodDef.
-     */
-    public static final int METHODDEF = CLASSDEF + 1;
-
-    /** Variable definitions, of type VarDef.
-     */
-    public static final int VARDEF = METHODDEF + 1;
-
-    /** The no-op statement ";", of type Skip
-     */
-    public static final int SKIP = VARDEF + 1;
-
-    /** Blocks, of type Block.
-     */
-    public static final int BLOCK = SKIP + 1;
+        /** Method definitions, of type MethodDef.
+         */
+        METHODDEF,
 
-    /** Do-while loops, of type DoLoop.
-     */
-    public static final int DOLOOP = BLOCK + 1;
+        /** Variable definitions, of type VarDef.
+         */
+        VARDEF,
 
-    /** While-loops, of type WhileLoop.
-     */
-    public static final int WHILELOOP = DOLOOP + 1;
+        /** The no-op statement ";", of type Skip
+         */
+        SKIP,
 
-    /** For-loops, of type ForLoop.
-     */
-    public static final int FORLOOP = WHILELOOP + 1;
+        /** Blocks, of type Block.
+         */
+        BLOCK,
 
-    /** Foreach-loops, of type ForeachLoop.
-     */
-    public static final int FOREACHLOOP = FORLOOP + 1;
+        /** Do-while loops, of type DoLoop.
+         */
+        DOLOOP,
 
-    /** Labelled statements, of type Labelled.
-     */
-    public static final int LABELLED = FOREACHLOOP + 1;
-
-    /** Switch statements, of type Switch.
-     */
-    public static final int SWITCH = LABELLED + 1;
+        /** While-loops, of type WhileLoop.
+         */
+        WHILELOOP,
 
-    /** Case parts in switch statements, of type Case.
-     */
-    public static final int CASE = SWITCH + 1;
+        /** For-loops, of type ForLoop.
+         */
+        FORLOOP,
 
-    /** Synchronized statements, of type Synchonized.
-     */
-    public static final int SYNCHRONIZED = CASE + 1;
+        /** Foreach-loops, of type ForeachLoop.
+         */
+        FOREACHLOOP,
 
-    /** Try statements, of type Try.
-     */
-    public static final int TRY = SYNCHRONIZED + 1;
+        /** Labelled statements, of type Labelled.
+         */
+        LABELLED,
 
-    /** Catch clauses in try statements, of type Catch.
-     */
-    public static final int CATCH = TRY + 1;
+        /** Switch statements, of type Switch.
+         */
+        SWITCH,
 
-    /** Conditional expressions, of type Conditional.
-     */
-    public static final int CONDEXPR = CATCH + 1;
+        /** Case parts in switch statements, of type Case.
+         */
+        CASE,
 
-    /** Conditional statements, of type If.
-     */
-    public static final int IF = CONDEXPR + 1;
+        /** Synchronized statements, of type Synchonized.
+         */
+        SYNCHRONIZED,
 
-    /** Expression statements, of type Exec.
-     */
-    public static final int EXEC = IF + 1;
+        /** Try statements, of type Try.
+         */
+        TRY,
 
-    /** Break statements, of type Break.
-     */
-    public static final int BREAK = EXEC + 1;
+        /** Catch clauses in try statements, of type Catch.
+         */
+        CATCH,
 
-    /** Continue statements, of type Continue.
-     */
-    public static final int CONTINUE = BREAK + 1;
+        /** Conditional expressions, of type Conditional.
+         */
+        CONDEXPR,
 
-    /** Return statements, of type Return.
-     */
-    public static final int RETURN = CONTINUE + 1;
+        /** Conditional statements, of type If.
+         */
+        IF,
 
-    /** Throw statements, of type Throw.
-     */
-    public static final int THROW = RETURN + 1;
+        /** Expression statements, of type Exec.
+         */
+        EXEC,
 
-    /** Assert statements, of type Assert.
-     */
-    public static final int ASSERT = THROW + 1;
+        /** Break statements, of type Break.
+         */
+        BREAK,
 
-    /** Method invocation expressions, of type Apply.
-     */
-    public static final int APPLY = ASSERT + 1;
+        /** Continue statements, of type Continue.
+         */
+        CONTINUE,
 
-    /** Class instance creation expressions, of type NewClass.
-     */
-    public static final int NEWCLASS = APPLY + 1;
+        /** Return statements, of type Return.
+         */
+        RETURN,
 
-    /** Array creation expressions, of type NewArray.
-     */
-    public static final int NEWARRAY = NEWCLASS + 1;
+        /** Throw statements, of type Throw.
+         */
+        THROW,
 
-    /** Parenthesized subexpressions, of type Parens.
-     */
-    public static final int PARENS = NEWARRAY + 1;
+        /** Assert statements, of type Assert.
+         */
+        ASSERT,
 
-    /** Assignment expressions, of type Assign.
-     */
-    public static final int ASSIGN = PARENS + 1;
+        /** Method invocation expressions, of type Apply.
+         */
+        APPLY,
 
-    /** Type cast expressions, of type TypeCast.
-     */
-    public static final int TYPECAST = ASSIGN + 1;
+        /** Class instance creation expressions, of type NewClass.
+         */
+        NEWCLASS,
 
-    /** Type test expressions, of type TypeTest.
-     */
-    public static final int TYPETEST = TYPECAST + 1;
+        /** Array creation expressions, of type NewArray.
+         */
+        NEWARRAY,
+
+        /** Lambda expression, of type Lambda.
+         */
+        LAMBDA,
+
+        /** Parenthesized subexpressions, of type Parens.
+         */
+        PARENS,
+
+        /** Assignment expressions, of type Assign.
+         */
+        ASSIGN,
+
+        /** Type cast expressions, of type TypeCast.
+         */
+        TYPECAST,
+
+        /** Type test expressions, of type TypeTest.
+         */
+        TYPETEST,
+
+        /** Indexed array expressions, of type Indexed.
+         */
+        INDEXED,
+
+        /** Selections, of type Select.
+         */
+        SELECT,
+
+        /** Member references, of type Reference.
+         */
+        REFERENCE,
+
+        /** Simple identifiers, of type Ident.
+         */
+        IDENT,
+
+        /** Literals, of type Literal.
+         */
+        LITERAL,
+
+        /** Basic type identifiers, of type TypeIdent.
+         */
+        TYPEIDENT,
+
+        /** Array types, of type TypeArray.
+         */
+        TYPEARRAY,
+
+        /** Parameterized types, of type TypeApply.
+         */
+        TYPEAPPLY,
+
+        /** Union types, of type TypeUnion.
+         */
+        TYPEUNION,
+
+        /** Intersection types, of type TypeIntersection.
+         */
+        TYPEINTERSECTION,
+
+        /** Formal type parameters, of type TypeParameter.
+         */
+        TYPEPARAMETER,
+
+        /** Type argument.
+         */
+        WILDCARD,
+
+        /** Bound kind: extends, super, exact, or unbound
+         */
+        TYPEBOUNDKIND,
+
+        /** metadata: Annotation.
+         */
+        ANNOTATION,
+
+        /** metadata: Type annotation.
+         */
+        TYPE_ANNOTATION,
+
+        /** metadata: Modifiers
+         */
+        MODIFIERS,
 
-    /** Indexed array expressions, of type Indexed.
-     */
-    public static final int INDEXED = TYPETEST + 1;
+        /** An annotated type tree.
+         */
+        ANNOTATED_TYPE,
 
-    /** Selections, of type Select.
-     */
-    public static final int SELECT = INDEXED + 1;
+        /** Error trees, of type Erroneous.
+         */
+        ERRONEOUS,
 
-    /** Simple identifiers, of type Ident.
-     */
-    public static final int IDENT = SELECT + 1;
+        /** Unary operators, of type Unary.
+         */
+        POS,                             // +
+        NEG,                             // -
+        NOT,                             // !
+        COMPL,                           // ~
+        PREINC,                          // ++ _
+        PREDEC,                          // -- _
+        POSTINC,                         // _ ++
+        POSTDEC,                         // _ --
 
-    /** Literals, of type Literal.
-     */
-    public static final int LITERAL = IDENT + 1;
+        /** unary operator for null reference checks, only used internally.
+         */
+        NULLCHK,
 
-    /** Basic type identifiers, of type TypeIdent.
-     */
-    public static final int TYPEIDENT = LITERAL + 1;
+        /** Binary operators, of type Binary.
+         */
+        OR,                              // ||
+        AND,                             // &&
+        BITOR,                           // |
+        BITXOR,                          // ^
+        BITAND,                          // &
+        EQ,                              // ==
+        NE,                              // !=
+        LT,                              // <
+        GT,                              // >
+        LE,                              // <=
+        GE,                              // >=
+        SL,                              // <<
+        SR,                              // >>
+        USR,                             // >>>
+        PLUS,                            // +
+        MINUS,                           // -
+        MUL,                             // *
+        DIV,                             // /
+        MOD,                             // %
 
-    /** Array types, of type TypeArray.
-     */
-    public static final int TYPEARRAY = TYPEIDENT + 1;
+        /** Assignment operators, of type Assignop.
+         */
+        BITOR_ASG(BITOR),                // |=
+        BITXOR_ASG(BITXOR),              // ^=
+        BITAND_ASG(BITAND),              // &=
 
-    /** Parameterized types, of type TypeApply.
-     */
-    public static final int TYPEAPPLY = TYPEARRAY + 1;
+        SL_ASG(SL),                      // <<=
+        SR_ASG(SR),                      // >>=
+        USR_ASG(USR),                    // >>>=
+        PLUS_ASG(PLUS),                  // +=
+        MINUS_ASG(MINUS),                // -=
+        MUL_ASG(MUL),                    // *=
+        DIV_ASG(DIV),                    // /=
+        MOD_ASG(MOD),                    // %=
 
-    /** Formal type parameters, of type TypeParameter.
-     */
-    public static final int TYPEPARAMETER = TYPEAPPLY + 1;
+        /** A synthetic let expression, of type LetExpr.
+         */
+        LETEXPR;                         // ala scheme
 
-    /** Type argument.
-     */
-    public static final int WILDCARD = TYPEPARAMETER + 1;
+        private final Tag noAssignTag;
 
-    /** Bound kind: extends, super, exact, or unbound
-     */
-    public static final int TYPEBOUNDKIND = WILDCARD + 1;
+        private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
 
-    /** metadata: Annotation.
-     */
-    public static final int ANNOTATION = TYPEBOUNDKIND + 1;
+        private Tag(Tag noAssignTag) {
+            this.noAssignTag = noAssignTag;
+        }
 
-    /** metadata: Modifiers
-     */
-    public static final int MODIFIERS = ANNOTATION + 1;
+        private Tag() {
+            this(null);
+        }
 
-    /** Error trees, of type Erroneous.
-     */
-    public static final int ERRONEOUS = MODIFIERS + 1;
+        public static int getNumberOfOperators() {
+            return numberOfOperators;
+        }
 
-    /** Unary operators, of type Unary.
-     */
-    public static final int POS = ERRONEOUS + 1;             // +
-    public static final int NEG = POS + 1;                   // -
-    public static final int NOT = NEG + 1;                   // !
-    public static final int COMPL = NOT + 1;                 // ~
-    public static final int PREINC = COMPL + 1;              // ++ _
-    public static final int PREDEC = PREINC + 1;             // -- _
-    public static final int POSTINC = PREDEC + 1;            // _ ++
-    public static final int POSTDEC = POSTINC + 1;           // _ --
-
-    /** unary operator for null reference checks, only used internally.
-     */
-    public static final int NULLCHK = POSTDEC + 1;
+        public Tag noAssignOp() {
+            if (noAssignTag != null)
+                return noAssignTag;
+            throw new AssertionError("noAssignOp() method is not available for non assignment tags");
+        }
 
-    /** Binary operators, of type Binary.
-     */
-    public static final int OR = NULLCHK + 1;                // ||
-    public static final int AND = OR + 1;                    // &&
-    public static final int BITOR = AND + 1;                 // |
-    public static final int BITXOR = BITOR + 1;              // ^
-    public static final int BITAND = BITXOR + 1;             // &
-    public static final int EQ = BITAND + 1;                 // ==
-    public static final int NE = EQ + 1;                     // !=
-    public static final int LT = NE + 1;                     // <
-    public static final int GT = LT + 1;                     // >
-    public static final int LE = GT + 1;                     // <=
-    public static final int GE = LE + 1;                     // >=
-    public static final int SL = GE + 1;                     // <<
-    public static final int SR = SL + 1;                     // >>
-    public static final int USR = SR + 1;                    // >>>
-    public static final int PLUS = USR + 1;                  // +
-    public static final int MINUS = PLUS + 1;                // -
-    public static final int MUL = MINUS + 1;                 // *
-    public static final int DIV = MUL + 1;                   // /
-    public static final int MOD = DIV + 1;                   // %
-
-    /** Assignment operators, of type Assignop.
-     */
-    public static final int BITOR_ASG = MOD + 1;             // |=
-    public static final int BITXOR_ASG = BITOR_ASG + 1;      // ^=
-    public static final int BITAND_ASG = BITXOR_ASG + 1;     // &=
-
-    public static final int SL_ASG = SL + BITOR_ASG - BITOR; // <<=
-    public static final int SR_ASG = SL_ASG + 1;             // >>=
-    public static final int USR_ASG = SR_ASG + 1;            // >>>=
-    public static final int PLUS_ASG = USR_ASG + 1;          // +=
-    public static final int MINUS_ASG = PLUS_ASG + 1;        // -=
-    public static final int MUL_ASG = MINUS_ASG + 1;         // *=
-    public static final int DIV_ASG = MUL_ASG + 1;           // /=
-    public static final int MOD_ASG = DIV_ASG + 1;           // %=
-
-    /** A synthetic let expression, of type LetExpr.
-     */
-    public static final int LETEXPR = MOD_ASG + 1;           // ala scheme
+        public boolean isPostUnaryOp() {
+            return (this == POSTINC || this == POSTDEC);
+        }
 
-    public static final int ANNOTATED_TYPE = LETEXPR + 1;
+        public boolean isIncOrDecUnaryOp() {
+            return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
+        }
 
-    /** Union types, of type TypeUnion
-     */
-    public static final int TYPEUNION = ANNOTATED_TYPE + 1;
+        public boolean isAssignop() {
+            return noAssignTag != null;
+        }
 
-    /** The offset between assignment operators and normal operators.
-     */
-    public static final int ASGOffset = BITOR_ASG - BITOR;
+        public int operatorIndex() {
+            return (this.ordinal() - POS.ordinal());
+        }
+    }
 
     /* The (encoded) position in the source file. @see util.Position.
      */
@@ -335,7 +396,13 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
 
     /* The tag of this node -- one of the constants declared above.
      */
-    public abstract int getTag();
+    public abstract Tag getTag();
+
+    /* Returns true if the tag of this node is equals to tag.
+     */
+    public boolean hasTag(Tag tag) {
+        return tag == getTag();
+    }
 
     /** Convert a tree to a pretty-printed string. */
     @Override
@@ -405,39 +472,35 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     }
 
     // for default DiagnosticPosition
-    public int getEndPosition(Map<JCTree, Integer> endPosTable) {
+    public int getEndPosition(EndPosTable endPosTable) {
         return TreeInfo.getEndPos(this, endPosTable);
     }
 
     /**
-     * Everything in one source file is kept in a TopLevel structure.
-     * @param pid              The tree representing the package clause.
-     * @param sourcefile       The source file name.
-     * @param defs             All definitions in this file (ClassDef, Import, and Skip)
-     * @param packge           The package it belongs to.
-     * @param namedImportScope A scope for all named imports.
-     * @param starImportScope  A scope for all import-on-demands.
-     * @param lineMap          Line starting positions, defined only
-     *                         if option -g is set.
-     * @param docComments      A hashtable that stores all documentation comments
-     *                         indexed by the tree nodes they refer to.
-     *                         defined only if option -s is set.
-     * @param endPositions     A hashtable that stores ending positions of source
-     *                         ranges indexed by the tree nodes they belong to.
-     *                         Defined only if option -Xjcov is set.
+     * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure.
      */
     public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
         public List<JCAnnotation> packageAnnotations;
+        /** The tree representing the package clause. */
         public JCExpression pid;
+        /** All definitions in this file (ClassDef, Import, and Skip) */
         public List<JCTree> defs;
+        /* The source file name. */
         public JavaFileObject sourcefile;
+        /** The package to which this compilation unit belongs. */
         public PackageSymbol packge;
+        /** A scope for all named imports. */
         public ImportScope namedImportScope;
+        /** A scope for all import-on-demands. */
         public StarImportScope starImportScope;
-        public long flags;
+        /** Line starting positions, defined only if option -g is set. */
         public Position.LineMap lineMap = null;
-        public Map<JCTree, String> docComments = null;
-        public Map<JCTree, Integer> endPositions = null;
+        /** A table that stores all documentation comments indexed by the tree
+         * nodes they refer to. defined only if option -s is set. */
+        public DocCommentTable docComments = null;
+        /* An object encapsulating ending positions of source ranges indexed by
+         * the tree nodes they belong to. Defined only if option -Xjcov is set. */
+        public EndPosTable endPositions = null;
         protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
                         JCExpression pid,
                         List<JCTree> defs,
@@ -463,11 +526,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public List<JCImport> getImports() {
             ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
             for (JCTree tree : defs) {
-                int tag = tree.getTag();
-                if (tag == IMPORT)
+                if (tree.hasTag(IMPORT))
                     imports.append((JCImport)tree);
-                else if (tag != SKIP)
-                    break;
             }
             return imports.toList();
         }
@@ -479,11 +539,12 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return lineMap;
         }
         public List<JCTree> getTypeDecls() {
-            List<JCTree> typeDefs;
-            for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail)
-                if (typeDefs.head.getTag() != IMPORT)
-                    break;
-            return typeDefs;
+            ListBuffer<JCTree> typeDefs = new ListBuffer<JCTree>();
+            for (JCTree tree : defs) {
+                if (!tree.hasTag(IMPORT))
+                    typeDefs.append(tree);
+            }
+            return typeDefs.toList();
         }
         @Override
         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
@@ -491,17 +552,17 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TOPLEVEL;
         }
     }
 
     /**
      * An import clause.
-     * @param qualid    The imported class(es).
      */
     public static class JCImport extends JCTree implements ImportTree {
         public boolean staticImport;
+        /** The imported class(es). */
         public JCTree qualid;
         protected JCImport(JCTree qualid, boolean importStatic) {
             this.qualid = qualid;
@@ -520,7 +581,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return IMPORT;
         }
     }
@@ -552,22 +613,60 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     }
 
     /**
+     * Common supertype for all poly expression trees (lambda, method references,
+     * conditionals, method and constructor calls)
+     */
+    public static abstract class JCPolyExpression extends JCExpression {
+
+        /**
+         * A poly expression can only be truly 'poly' in certain contexts
+         */
+        public enum PolyKind {
+            /** poly expression to be treated as a standalone expression */
+            STANDALONE,
+            /** true poly expression */
+            POLY;
+        }
+
+        /** is this poly expression a 'true' poly expression? */
+        public PolyKind polyKind;
+    }
+
+    /**
+     * Common supertype for all functional expression trees (lambda and method references)
+     */
+    public static abstract class JCFunctionalExpression extends JCPolyExpression {
+
+        public JCFunctionalExpression() {
+            //a functional expression is always a 'true' poly
+            polyKind = PolyKind.POLY;
+        }
+
+        /** list of target types inferred for this functional expression. */
+        public List<Type> targets;
+
+        public Type getDescriptorType(Types types) {
+            return targets.nonEmpty() ? types.findDescriptorType(targets.head) : types.createErrorType(null);
+        }
+    }
+
+    /**
      * A class definition.
-     * @param modifiers the modifiers
-     * @param name the name of the class
-     * @param typarams formal class parameters
-     * @param extending the classes this class extends
-     * @param implementing the interfaces implemented by this class
-     * @param defs all variables and methods defined in this class
-     * @param sym the symbol
      */
     public static class JCClassDecl extends JCStatement implements ClassTree {
+        /** the modifiers */
         public JCModifiers mods;
+        /** the name of the class */
         public Name name;
+        /** formal class parameters */
         public List<JCTypeParameter> typarams;
+        /** the classes this class extends */
         public JCExpression extending;
+        /** the interfaces implemented by this class */
         public List<JCExpression> implementing;
+        /** all variables and methods defined in this class */
         public List<JCTree> defs;
+        /** the symbol */
         public ClassSymbol sym;
 
         protected JCClassDecl(JCModifiers mods,
@@ -608,7 +707,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public List<JCTypeParameter> getTypeParameters() {
             return typarams;
         }
-        public JCTree getExtendsClause() { return extending; }
+        public JCExpression getExtendsClause() { return extending; }
         public List<JCExpression> getImplementsClause() {
             return implementing;
         }
@@ -621,37 +720,41 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return CLASSDEF;
         }
     }
 
     /**
      * A method definition.
-     * @param modifiers method modifiers
-     * @param name method name
-     * @param restype type of method return value
-     * @param typarams type parameters
-     * @param params value parameters
-     * @param thrown exceptions thrown by this method
-     * @param stats statements in the method
-     * @param sym method symbol
      */
     public static class JCMethodDecl extends JCTree implements MethodTree {
+        /** method modifiers */
         public JCModifiers mods;
+        /** method name */
         public Name name;
+        /** type of method return value */
         public JCExpression restype;
+        /** type parameters */
         public List<JCTypeParameter> typarams;
+        /** receiver parameter */
+        public JCVariableDecl recvparam;
+        /** value parameters */
         public List<JCVariableDecl> params;
+        /** exceptions thrown by this method */
         public List<JCExpression> thrown;
+        /** statements in the method */
         public JCBlock body;
-        public JCExpression defaultValue; // for annotation types
+        /** default value, for annotation types */
+        public JCExpression defaultValue;
+        /** method symbol */
         public MethodSymbol sym;
         public Env<AttrContext> localEnv = null;
         protected JCMethodDecl(JCModifiers mods,
                             Name name,
                             JCExpression restype,
                             List<JCTypeParameter> typarams,
+                            JCVariableDecl recvparam,
                             List<JCVariableDecl> params,
                             List<JCExpression> thrown,
                             JCBlock body,
@@ -663,6 +766,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             this.restype = restype;
             this.typarams = typarams;
             this.params = params;
+            this.recvparam = recvparam;
+            // TODO: do something special if the given type is null?
+            // receiver != null ? receiver : List.<JCTypeAnnotation>nil());
             this.thrown = thrown;
             this.body = body;
             this.defaultValue = defaultValue;
@@ -681,6 +787,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public List<JCVariableDecl> getParameters() {
             return params;
         }
+        public JCVariableDecl getReceiverParameter() { return recvparam; }
         public List<JCExpression> getThrows() {
             return thrown;
         }
@@ -694,25 +801,28 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return METHODDEF;
         }
   }
 
     /**
      * A variable definition.
-     * @param modifiers variable modifiers
-     * @param name variable name
-     * @param vartype type of the variable
-     * @param init variables initial value
-     * @param sym symbol
      */
     public static class JCVariableDecl extends JCStatement implements VariableTree {
+        /** variable modifiers */
         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,
@@ -724,12 +834,27 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             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;
@@ -740,12 +865,12 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return VARDEF;
         }
     }
 
-      /**
+    /**
      * A no-op statement ";".
      */
     public static class JCSkip extends JCStatement implements EmptyStatementTree {
@@ -761,18 +886,18 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return SKIP;
         }
     }
 
     /**
      * A statement block.
-     * @param stats statements
-     * @param flags flags
      */
     public static class JCBlock extends JCStatement implements BlockTree {
+        /** flags */
         public long flags;
+        /** statements */
         public List<JCStatement> stats;
         /** Position of closing brace, optional. */
         public int endpos = Position.NOPOS;
@@ -794,7 +919,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return BLOCK;
         }
     }
@@ -821,7 +946,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return DOLOOP;
         }
     }
@@ -848,7 +973,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return WHILELOOP;
         }
     }
@@ -889,7 +1014,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
 
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return FORLOOP;
         }
     }
@@ -918,7 +1043,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitEnhancedForLoop(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return FOREACHLOOP;
         }
     }
@@ -943,7 +1068,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitLabeledStatement(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return LABELLED;
         }
     }
@@ -969,7 +1094,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitSwitch(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return SWITCH;
         }
     }
@@ -995,7 +1120,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitCase(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return CASE;
         }
     }
@@ -1021,7 +1146,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitSynchronized(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return SYNCHRONIZED;
         }
     }
@@ -1034,6 +1159,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public List<JCCatch> catchers;
         public JCBlock finalizer;
         public List<JCTree> resources;
+        public boolean finallyCanCompleteNormally;
         protected JCTry(List<JCTree> resources,
                         JCBlock body,
                         List<JCCatch> catchers,
@@ -1057,11 +1183,11 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitTry(this, d);
         }
         @Override
-        public List<? extends JCTree> getResources() {
+        public List<JCTree> getResources() {
             return resources;
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TRY;
         }
     }
@@ -1087,7 +1213,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitCatch(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return CATCH;
         }
     }
@@ -1095,7 +1221,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     /**
      * A ( ) ? ( ) : ( ) conditional expression
      */
-    public static class JCConditional extends JCExpression implements ConditionalExpressionTree {
+    public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree {
         public JCExpression cond;
         public JCExpression truepart;
         public JCExpression falsepart;
@@ -1119,7 +1245,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitConditionalExpression(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return CONDEXPR;
         }
     }
@@ -1151,16 +1277,16 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitIf(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return IF;
         }
     }
 
     /**
      * an expression statement
-     * @param expr expression structure
      */
     public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
+        /** expression structure */
         public JCExpression expr;
         protected JCExpressionStatement(JCExpression expr)
         {
@@ -1176,9 +1302,24 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitExpressionStatement(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return EXEC;
         }
+
+        /** Convert a expression-statement tree to a pretty-printed string. */
+        @Override
+        public String toString() {
+            StringWriter s = new StringWriter();
+            try {
+                new Pretty(s, false).printStat(this);
+            }
+            catch (IOException e) {
+                // should never happen, because StringWriter is defined
+                // never to throw any IOExceptions
+                throw new AssertionError(e);
+            }
+            return s.toString();
+        }
     }
 
     /**
@@ -1201,7 +1342,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitBreak(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return BREAK;
         }
     }
@@ -1226,7 +1367,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitContinue(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return CONTINUE;
         }
     }
@@ -1249,7 +1390,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitReturn(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return RETURN;
         }
     }
@@ -1259,8 +1400,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
      */
     public static class JCThrow extends JCStatement implements ThrowTree {
         public JCExpression expr;
-        protected JCThrow(JCTree expr) {
-            this.expr = (JCExpression)expr;
+        protected JCThrow(JCExpression expr) {
+            this.expr = expr;
         }
         @Override
         public void accept(Visitor v) { v.visitThrow(this); }
@@ -1272,7 +1413,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitThrow(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return THROW;
         }
     }
@@ -1298,7 +1439,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitAssert(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return ASSERT;
         }
     }
@@ -1306,7 +1447,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     /**
      * A method invocation
      */
-    public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree {
+    public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree {
         public List<JCExpression> typeargs;
         public JCExpression meth;
         public List<JCExpression> args;
@@ -1341,7 +1482,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return this;
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return(APPLY);
         }
     }
@@ -1349,7 +1490,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     /**
      * A new(...) operation.
      */
-    public static class JCNewClass extends JCExpression implements NewClassTree {
+    public static class JCNewClass extends JCPolyExpression implements NewClassTree {
         public JCExpression encl;
         public List<JCExpression> typeargs;
         public JCExpression clazz;
@@ -1383,7 +1524,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
         public JCExpression getIdentifier() { return clazz; }
         public List<JCExpression> getArguments() {
-            return args;
+            return encl != null && def != null ? args.tail : args;
         }
         public JCClassDecl getClassBody() { return def; }
         @Override
@@ -1391,7 +1532,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitNewClass(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return NEWCLASS;
         }
     }
@@ -1402,6 +1543,10 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
     public static class JCNewArray extends JCExpression implements NewArrayTree {
         public JCExpression elemtype;
         public List<JCExpression> dims;
+        // type annotations on inner-most component
+        public List<JCAnnotation> annotations;
+        // type annotations on dimensions
+        public List<List<JCAnnotation>> dimAnnotations;
         public List<JCExpression> elems;
         protected JCNewArray(JCExpression elemtype,
                            List<JCExpression> dims,
@@ -1409,6 +1554,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         {
             this.elemtype = elemtype;
             this.dims = dims;
+            this.annotations = List.nil();
+            this.dimAnnotations = List.nil();
             this.elems = elems;
         }
         @Override
@@ -1427,12 +1574,73 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitNewArray(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return NEWARRAY;
         }
     }
 
     /**
+     * A lambda expression.
+     */
+    public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
+
+        public enum ParameterKind {
+            IMPLICIT,
+            EXPLICIT;
+        }
+
+        public List<JCVariableDecl> params;
+        public JCTree body;
+        public boolean canCompleteNormally = true;
+        public List<Type> inferredThrownTypes;
+        public ParameterKind paramKind;
+
+        public JCLambda(List<JCVariableDecl> params,
+                        JCTree body) {
+            this.params = params;
+            this.body = body;
+            if (params.isEmpty() ||
+                params.head.vartype != null) {
+                paramKind = ParameterKind.EXPLICIT;
+            } else {
+                paramKind = ParameterKind.IMPLICIT;
+            }
+        }
+        @Override
+        public Tag getTag() {
+            return LAMBDA;
+        }
+        @Override
+        public void accept(Visitor v) {
+            v.visitLambda(this);
+        }
+        @Override
+        public <R, D> R accept(TreeVisitor<R, D> v, D d) {
+            return v.visitLambdaExpression(this, d);
+        }
+        public Kind getKind() {
+            return Kind.LAMBDA_EXPRESSION;
+        }
+        public JCTree getBody() {
+            return body;
+        }
+        public java.util.List<? extends VariableTree> getParameters() {
+            return params;
+        }
+        @Override
+        public JCLambda setType(Type type) {
+            super.setType(type);
+            return this;
+        }
+        @Override
+        public BodyKind getBodyKind() {
+            return body.hasTag(BLOCK) ?
+                    BodyKind.STATEMENT :
+                    BodyKind.EXPRESSION;
+        }
+    }
+
+    /**
      * A parenthesized subexpression ( ... )
      */
     public static class JCParens extends JCExpression implements ParenthesizedTree {
@@ -1450,7 +1658,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitParenthesized(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return PARENS;
         }
     }
@@ -1476,7 +1684,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitAssignment(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return ASSIGN;
         }
     }
@@ -1485,11 +1693,11 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
      * An assignment with "+=", "|=" ...
      */
     public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree {
-        private int opcode;
+        private Tag opcode;
         public JCExpression lhs;
         public JCExpression rhs;
         public Symbol operator;
-        protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs, Symbol operator) {
+        protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) {
             this.opcode = opcode;
             this.lhs = (JCExpression)lhs;
             this.rhs = (JCExpression)rhs;
@@ -1509,7 +1717,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitCompoundAssignment(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return opcode;
         }
     }
@@ -1518,10 +1726,10 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
      * A unary operation.
      */
     public static class JCUnary extends JCExpression implements UnaryTree {
-        private int opcode;
+        private Tag opcode;
         public JCExpression arg;
         public Symbol operator;
-        protected JCUnary(int opcode, JCExpression arg) {
+        protected JCUnary(Tag opcode, JCExpression arg) {
             this.opcode = opcode;
             this.arg = arg;
         }
@@ -1538,11 +1746,11 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitUnary(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return opcode;
         }
 
-        public void setTag(int tag) {
+        public void setTag(Tag tag) {
             opcode = tag;
         }
     }
@@ -1551,11 +1759,11 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
      * A binary operation.
      */
     public static class JCBinary extends JCExpression implements BinaryTree {
-        private int opcode;
+        private Tag opcode;
         public JCExpression lhs;
         public JCExpression rhs;
         public Symbol operator;
-        protected JCBinary(int opcode,
+        protected JCBinary(Tag opcode,
                          JCExpression lhs,
                          JCExpression rhs,
                          Symbol operator) {
@@ -1578,7 +1786,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitBinary(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return opcode;
         }
     }
@@ -1604,7 +1812,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitTypeCast(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPECAST;
         }
     }
@@ -1630,7 +1838,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitInstanceOf(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPETEST;
         }
     }
@@ -1656,20 +1864,20 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitArrayAccess(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return INDEXED;
         }
     }
 
     /**
      * Selects through packages and classes
-     * @param selected selected Tree hierarchie
-     * @param selector name of field to select thru
-     * @param sym symbol of the selected class
      */
     public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
+        /** selected Tree hierarchy */
         public JCExpression selected;
+        /** name of field to select thru */
         public Name name;
+        /** symbol of the selected class */
         public Symbol sym;
         protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
             this.selected = selected;
@@ -1687,18 +1895,97 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         }
         public Name getIdentifier() { return name; }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return SELECT;
         }
     }
 
     /**
+     * Selects a member expression.
+     */
+    public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
+        public ReferenceMode mode;
+        public ReferenceKind kind;
+        public Name name;
+        public JCExpression expr;
+        public List<JCExpression> typeargs;
+        public Symbol sym;
+        public Type varargsElement;
+        public PolyKind refPolyKind;
+        public boolean ownerAccessible;
+
+        /**
+         * Javac-dependent classification for member references, based
+         * on relevant properties w.r.t. code-generation
+         */
+        public enum ReferenceKind {
+            /** super # instMethod */
+            SUPER(ReferenceMode.INVOKE, false),
+            /** Type # instMethod */
+            UNBOUND(ReferenceMode.INVOKE, true),
+            /** Type # staticMethod */
+            STATIC(ReferenceMode.INVOKE, false),
+            /** Expr # instMethod */
+            BOUND(ReferenceMode.INVOKE, false),
+            /** Inner # new */
+            IMPLICIT_INNER(ReferenceMode.NEW, false),
+            /** Toplevel # new */
+            TOPLEVEL(ReferenceMode.NEW, false),
+            /** ArrayType # new */
+            ARRAY_CTOR(ReferenceMode.NEW, false);
+
+            final ReferenceMode mode;
+            final boolean unbound;
+
+            private ReferenceKind(ReferenceMode mode, boolean unbound) {
+                this.mode = mode;
+                this.unbound = unbound;
+            }
+
+            public boolean isUnbound() {
+                return unbound;
+            }
+        }
+
+        protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
+            this.mode = mode;
+            this.name = name;
+            this.expr = expr;
+            this.typeargs = typeargs;
+        }
+        @Override
+        public void accept(Visitor v) { v.visitReference(this); }
+
+        public Kind getKind() { return Kind.MEMBER_REFERENCE; }
+        @Override
+        public ReferenceMode getMode() { return mode; }
+        @Override
+        public JCExpression getQualifierExpression() { return expr; }
+        @Override
+        public Name getName() { return name; }
+        @Override
+        public List<JCExpression> getTypeArguments() { return typeargs; }
+
+        @Override
+        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+            return v.visitMemberReference(this, d);
+        }
+        @Override
+        public Tag getTag() {
+            return REFERENCE;
+        }
+        public boolean hasKind(ReferenceKind kind) {
+            return this.kind == kind;
+        }
+    }
+
+    /**
      * An identifier
-     * @param idname the name
-     * @param sym the symbol
      */
     public static class JCIdent extends JCExpression implements IdentifierTree {
+        /** the name */
         public Name name;
+        /** the symbol */
         public Symbol sym;
         protected JCIdent(Name name, Symbol sym) {
             this.name = name;
@@ -1713,19 +2000,20 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
             return v.visitIdentifier(this, d);
         }
-        public int getTag() {
+        @Override
+        public Tag getTag() {
             return IDENT;
         }
     }
 
     /**
      * A constant value given literally.
-     * @param value value representation
      */
     public static class JCLiteral extends JCExpression implements LiteralTree {
-        public int typetag;
+        public TypeTag typetag;
+        /** value representation */
         public Object value;
-        protected JCLiteral(int typetag, Object value) {
+        protected JCLiteral(TypeTag typetag, Object value) {
             this.typetag = typetag;
             this.value = value;
         }
@@ -1733,33 +2021,15 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public void accept(Visitor v) { v.visitLiteral(this); }
 
         public Kind getKind() {
-            switch (typetag) {
-            case TypeTags.INT:
-                return Kind.INT_LITERAL;
-            case TypeTags.LONG:
-                return Kind.LONG_LITERAL;
-            case TypeTags.FLOAT:
-                return Kind.FLOAT_LITERAL;
-            case TypeTags.DOUBLE:
-                return Kind.DOUBLE_LITERAL;
-            case TypeTags.BOOLEAN:
-                return Kind.BOOLEAN_LITERAL;
-            case TypeTags.CHAR:
-                return Kind.CHAR_LITERAL;
-            case TypeTags.CLASS:
-                return Kind.STRING_LITERAL;
-            case TypeTags.BOT:
-                return Kind.NULL_LITERAL;
-            default:
-                throw new AssertionError("unknown literal kind " + this);
-            }
+            return typetag.getKindLiteral();
         }
+
         public Object getValue() {
             switch (typetag) {
-                case TypeTags.BOOLEAN:
+                case BOOLEAN:
                     int bi = (Integer) value;
                     return (bi != 0);
-                case TypeTags.CHAR:
+                case CHAR:
                     int ci = (Integer) value;
                     char c = (char) ci;
                     if (c != ci)
@@ -1779,19 +2049,19 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return this;
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return LITERAL;
         }
     }
 
     /**
      * Identifies a basic type.
-     * @param tag the basic type id
-     * @see TypeTags
+     * @see TypeTag
      */
     public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
-        public int typetag;
-        protected JCPrimitiveTypeTree(int typetag) {
+        /** the basic type id */
+        public TypeTag typetag;
+        protected JCPrimitiveTypeTree(TypeTag typetag) {
             this.typetag = typetag;
         }
         @Override
@@ -1799,35 +2069,15 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
 
         public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
         public TypeKind getPrimitiveTypeKind() {
-            switch (typetag) {
-            case TypeTags.BOOLEAN:
-                return TypeKind.BOOLEAN;
-            case TypeTags.BYTE:
-                return TypeKind.BYTE;
-            case TypeTags.SHORT:
-                return TypeKind.SHORT;
-            case TypeTags.INT:
-                return TypeKind.INT;
-            case TypeTags.LONG:
-                return TypeKind.LONG;
-            case TypeTags.CHAR:
-                return TypeKind.CHAR;
-            case TypeTags.FLOAT:
-                return TypeKind.FLOAT;
-            case TypeTags.DOUBLE:
-                return TypeKind.DOUBLE;
-            case TypeTags.VOID:
-                return TypeKind.VOID;
-            default:
-                throw new AssertionError("unknown primitive type " + this);
-            }
+            return typetag.getPrimitiveTypeKind();
         }
+
         @Override
         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
             return v.visitPrimitiveType(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEIDENT;
         }
     }
@@ -1850,13 +2100,13 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitArrayType(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEARRAY;
         }
     }
 
     /**
-     * A parameterized type, T<...>
+     * A parameterized type, {@literal T<...>}
      */
     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
         public JCExpression clazz;
@@ -1878,7 +2128,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitParameterizedType(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEAPPLY;
         }
     }
@@ -1906,22 +2156,53 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitUnionType(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEUNION;
         }
     }
 
     /**
+     * An intersection type, T1 & T2 & ... Tn (used in cast expressions)
+     */
+    public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
+
+        public List<JCExpression> bounds;
+
+        protected JCTypeIntersection(List<JCExpression> bounds) {
+            this.bounds = bounds;
+        }
+        @Override
+        public void accept(Visitor v) { v.visitTypeIntersection(this); }
+
+        public Kind getKind() { return Kind.INTERSECTION_TYPE; }
+
+        public List<JCExpression> getBounds() {
+            return bounds;
+        }
+        @Override
+        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+            return v.visitIntersectionType(this, d);
+        }
+        @Override
+        public Tag getTag() {
+            return TYPEINTERSECTION;
+        }
+    }
+
+    /**
      * A formal class parameter.
-     * @param name name
-     * @param bounds bounds
      */
     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
+        /** name */
         public Name name;
+        /** bounds */
         public List<JCExpression> bounds;
-        protected JCTypeParameter(Name name, List<JCExpression> bounds) {
+        /** type annotations on type parameter */
+        public List<JCAnnotation> annotations;
+        protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
             this.name = name;
             this.bounds = bounds;
+            this.annotations = annotations;
         }
         @Override
         public void accept(Visitor v) { v.visitTypeParameter(this); }
@@ -1931,12 +2212,15 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public List<JCExpression> getBounds() {
             return bounds;
         }
+        public List<JCAnnotation> getAnnotations() {
+            return annotations;
+        }
         @Override
         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
             return v.visitTypeParameter(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEPARAMETER;
         }
     }
@@ -1970,8 +2254,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitWildcard(this, d);
         }
         @Override
-        public int getTag() {
-            return WILDCARD;
+        public Tag getTag() {
+            return Tag.WILDCARD;
         }
     }
 
@@ -1991,22 +2275,33 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             throw new AssertionError("TypeBoundKind is not part of a public API");
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return TYPEBOUNDKIND;
         }
     }
 
     public static class JCAnnotation extends JCExpression implements AnnotationTree {
+        // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
+        private Tag tag;
+
         public JCTree annotationType;
         public List<JCExpression> args;
-        protected JCAnnotation(JCTree annotationType, List<JCExpression> args) {
+
+        // Attribute.Compound if tag is ANNOTATION
+        // Attribute.TypeCompound if tag is TYPE_ANNOTATION
+        public Attribute.Compound attribute;
+
+        protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
+            this.tag = tag;
             this.annotationType = annotationType;
             this.args = args;
         }
+
         @Override
         public void accept(Visitor v) { v.visitAnnotation(this); }
 
-        public Kind getKind() { return Kind.ANNOTATION; }
+        public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
+
         public JCTree getAnnotationType() { return annotationType; }
         public List<JCExpression> getArguments() {
             return args;
@@ -2016,8 +2311,8 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitAnnotation(this, d);
         }
         @Override
-        public int getTag() {
-            return ANNOTATION;
+        public Tag getTag() {
+            return tag;
         }
     }
 
@@ -2043,11 +2338,40 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitModifiers(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return MODIFIERS;
         }
     }
 
+    public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
+        // type annotations
+        public List<JCAnnotation> annotations;
+        public JCExpression underlyingType;
+
+        protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
+            this.annotations = annotations;
+            this.underlyingType = underlyingType;
+        }
+        @Override
+        public void accept(Visitor v) { v.visitAnnotatedType(this); }
+
+        public Kind getKind() { return Kind.ANNOTATED_TYPE; }
+        public List<JCAnnotation> getAnnotations() {
+            return annotations;
+        }
+        public JCExpression getUnderlyingType() {
+            return underlyingType;
+        }
+        @Override
+        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+            return v.visitAnnotatedType(this, d);
+        }
+        @Override
+        public Tag getTag() {
+            return ANNOTATED_TYPE;
+        }
+    }
+
     public static class JCErroneous extends JCExpression
             implements com.sun.source.tree.ErroneousTree {
         public List<? extends JCTree> errs;
@@ -2068,7 +2392,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             return v.visitErroneous(this, d);
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return ERRONEOUS;
         }
     }
@@ -2092,7 +2416,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
             throw new AssertionError("LetExpr is not part of a public API");
         }
         @Override
-        public int getTag() {
+        public Tag getTag() {
             return LETEXPR;
         }
     }
@@ -2114,6 +2438,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
                             Name name,
                             JCExpression restype,
                             List<JCTypeParameter> typarams,
+                            JCVariableDecl recvparam,
                             List<JCVariableDecl> params,
                             List<JCExpression> thrown,
                             JCBlock body,
@@ -2149,7 +2474,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         JCBreak Break(Name label);
         JCContinue Continue(Name label);
         JCReturn Return(JCExpression expr);
-        JCThrow Throw(JCTree expr);
+        JCThrow Throw(JCExpression expr);
         JCAssert Assert(JCExpression cond, JCExpression detail);
         JCMethodInvocation Apply(List<JCExpression> typeargs,
                     JCExpression fn,
@@ -2164,16 +2489,16 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
                           List<JCExpression> elems);
         JCParens Parens(JCExpression expr);
         JCAssign Assign(JCExpression lhs, JCExpression rhs);
-        JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs);
-        JCUnary Unary(int opcode, JCExpression arg);
-        JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs);
+        JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
+        JCUnary Unary(Tag opcode, JCExpression arg);
+        JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
         JCTypeCast TypeCast(JCTree expr, JCExpression type);
         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
         JCFieldAccess Select(JCExpression selected, Name selector);
         JCIdent Ident(Name idname);
-        JCLiteral Literal(int tag, Object value);
-        JCPrimitiveTypeTree TypeIdent(int typetag);
+        JCLiteral Literal(TypeTag tag, Object value);
+        JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
         JCArrayTypeTree TypeArray(JCExpression elemtype);
         JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
         JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
@@ -2216,6 +2541,7 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
         public void visitNewClass(JCNewClass that)           { visitTree(that); }
         public void visitNewArray(JCNewArray that)           { visitTree(that); }
+        public void visitLambda(JCLambda that)               { visitTree(that); }
         public void visitParens(JCParens that)               { visitTree(that); }
         public void visitAssign(JCAssign that)               { visitTree(that); }
         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
@@ -2225,17 +2551,20 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
+        public void visitReference(JCMemberReference that)   { visitTree(that); }
         public void visitIdent(JCIdent that)                 { visitTree(that); }
         public void visitLiteral(JCLiteral that)             { visitTree(that); }
         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
         public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
         public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
         public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
+        public void visitTypeIntersection(JCTypeIntersection that)  { visitTree(that); }
         public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
         public void visitWildcard(JCWildcard that)           { visitTree(that); }
         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
         public void visitModifiers(JCModifiers that)         { visitTree(that); }
+        public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
         public void visitErroneous(JCErroneous that)         { visitTree(that); }
         public void visitLetExpr(LetExpr that)               { visitTree(that); }
 
diff --git a/src/share/classes/com/sun/tools/javac/tree/Pretty.java b/src/share/classes/com/sun/tools/javac/tree/Pretty.java
index f4123bf..adf8799 100644
--- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java
+++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -26,16 +26,15 @@
 package com.sun.tools.javac.tree;
 
 import java.io.*;
-import java.util.*;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.tools.javac.code.*;
-
-import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.JCTree.*;
-
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Flags.ANNOTATION;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Prints out a tree as an indented Java source program.
  *
@@ -74,10 +73,21 @@ public class Pretty extends JCTree.Visitor {
      */
     Name enclClassName;
 
-    /** A hashtable mapping trees to their documentation comments
+    /** A table mapping trees to their documentation comments
      *  (can be null)
      */
-    Map<JCTree, String> docComments = null;
+    DocCommentTable docComments = null;
+
+    /**
+     * A string sequence to be used when Pretty output should be constrained
+     * to fit into a given size
+     */
+    private final static String trimSequence = "[...]";
+
+    /**
+     * Max number of chars to be generated when output should fit into a single line
+     */
+    private final static int PREFERRED_LENGTH = 20;
 
     /** Align code to be indented to left margin.
      */
@@ -128,6 +138,32 @@ public class Pretty extends JCTree.Visitor {
         out.write(lineSep);
     }
 
+    public static String toSimpleString(JCTree tree) {
+        return toSimpleString(tree, PREFERRED_LENGTH);
+    }
+
+    public static String toSimpleString(JCTree tree, int maxLength) {
+        StringWriter s = new StringWriter();
+        try {
+            new Pretty(s, false).printExpr(tree);
+        }
+        catch (IOException e) {
+            // should never happen, because StringWriter is defined
+            // never to throw any IOExceptions
+            throw new AssertionError(e);
+        }
+        //we need to (i) replace all line terminators with a space and (ii) remove
+        //occurrences of 'missing' in the Pretty output (generated when types are missing)
+        String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
+        if (res.length() < maxLength) {
+            return res;
+        } else {
+            int head = (maxLength - trimSequence.length()) * 2 / 3;
+            int tail = maxLength - trimSequence.length() - head;
+            return res.substring(0, head) + trimSequence + res.substring(res.length() - tail);
+        }
+    }
+
     String lineSep = System.getProperty("line.separator");
 
     /**************************************************************************
@@ -213,7 +249,7 @@ public class Pretty extends JCTree.Visitor {
     public void printFlags(long flags) throws IOException {
         if ((flags & SYNTHETIC) != 0) print("/*synthetic*/ ");
         print(TreeInfo.flagNames(flags));
-        if ((flags & StandardFlags) != 0) print(" ");
+        if ((flags & ExtendedStandardFlags) != 0) print(" ");
         if ((flags & ANNOTATION) != 0) print("@");
     }
 
@@ -225,12 +261,19 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
+    public void printTypeAnnotations(List<JCAnnotation> trees) throws IOException {
+        for (List<JCAnnotation> l = trees; l.nonEmpty(); l = l.tail) {
+            printExpr(l.head);
+            print(" ");
+        }
+    }
+
     /** Print documentation comment, if it exists
      *  @param tree    The tree for which a documentation comment should be printed.
      */
     public void printDocComment(JCTree tree) throws IOException {
         if (docComments != null) {
-            String dc = docComments.get(tree);
+            String dc = docComments.getCommentText(tree);
             if (dc != null) {
                 print("/**"); println();
                 int pos = 0;
@@ -255,7 +298,8 @@ public class Pretty extends JCTree.Visitor {
         return pos;
     }
 
-    /** If type parameter list is non-empty, print it enclosed in "<...>" brackets.
+    /** If type parameter list is non-empty, print it enclosed in
+     *  {@literal "<...>"} brackets.
      */
     public void printTypeParameters(List<JCTypeParameter> trees) throws IOException {
         if (trees.nonEmpty()) {
@@ -311,7 +355,7 @@ public class Pretty extends JCTree.Visitor {
 
     /** Is the given tree an enumerator definition? */
     boolean isEnumerator(JCTree t) {
-        return t.getTag() == JCTree.VARDEF && (((JCVariableDecl) t).mods.flags & ENUM) != 0;
+        return t.hasTag(VARDEF) && (((JCVariableDecl) t).mods.flags & ENUM) != 0;
     }
 
     /** Print unit consisting of package clause and import statements in toplevel,
@@ -332,9 +376,9 @@ public class Pretty extends JCTree.Visitor {
         }
         boolean firstImport = true;
         for (List<JCTree> l = tree.defs;
-        l.nonEmpty() && (cdef == null || l.head.getTag() == JCTree.IMPORT);
+        l.nonEmpty() && (cdef == null || l.head.hasTag(IMPORT));
         l = l.tail) {
-            if (l.head.getTag() == JCTree.IMPORT) {
+            if (l.head.hasTag(IMPORT)) {
                 JCImport imp = (JCImport)l.head;
                 Name name = TreeInfo.name(imp.qualid);
                 if (name == name.table.names.asterisk ||
@@ -454,6 +498,12 @@ public class Pretty extends JCTree.Visitor {
                 print(" " + tree.name);
             }
             print("(");
+            if (tree.recvparam!=null) {
+                printExpr(tree.recvparam);
+                if (tree.params.size() > 0) {
+                    print(", ");
+                }
+            }
             printExprs(tree.params);
             print(")");
             if (tree.thrown.nonEmpty()) {
@@ -477,7 +527,7 @@ public class Pretty extends JCTree.Visitor {
 
     public void visitVarDef(JCVariableDecl tree) {
         try {
-            if (docComments != null && docComments.get(tree) != null) {
+            if (docComments != null && docComments.hasComment(tree)) {
                 println(); align();
             }
             printDocComment(tree);
@@ -485,7 +535,7 @@ public class Pretty extends JCTree.Visitor {
                 print("/*public static final*/ ");
                 print(tree.name);
                 if (tree.init != null) {
-                    if (sourceOutput && tree.init.getTag() == JCTree.NEWCLASS) {
+                    if (sourceOutput && tree.init.hasTag(NEWCLASS)) {
                         print(" /*enum*/ ");
                         JCNewClass init = (JCNewClass) tree.init;
                         if (init.args != null && init.args.nonEmpty()) {
@@ -506,7 +556,17 @@ public class Pretty extends JCTree.Visitor {
             } else {
                 printExpr(tree.mods);
                 if ((tree.mods.flags & VARARGS) != 0) {
-                    printExpr(((JCArrayTypeTree) tree.vartype).elemtype);
+                    JCTree vartype = tree.vartype;
+                    List<JCAnnotation> tas = null;
+                    if (vartype instanceof JCAnnotatedType) {
+                        tas = ((JCAnnotatedType)vartype).annotations;
+                        vartype = ((JCAnnotatedType)vartype).underlyingType;
+                    }
+                    printExpr(((JCArrayTypeTree) vartype).elemtype);
+                    if (tas != null) {
+                        print(' ');
+                        printTypeAnnotations(tas);
+                    }
                     print("... " + tree.name);
                 } else {
                     printExpr(tree.vartype);
@@ -546,7 +606,7 @@ public class Pretty extends JCTree.Visitor {
             printStat(tree.body);
             align();
             print(" while ");
-            if (tree.cond.getTag() == JCTree.PARENS) {
+            if (tree.cond.hasTag(PARENS)) {
                 printExpr(tree.cond);
             } else {
                 print("(");
@@ -562,7 +622,7 @@ public class Pretty extends JCTree.Visitor {
     public void visitWhileLoop(JCWhileLoop tree) {
         try {
             print("while ");
-            if (tree.cond.getTag() == JCTree.PARENS) {
+            if (tree.cond.hasTag(PARENS)) {
                 printExpr(tree.cond);
             } else {
                 print("(");
@@ -580,7 +640,7 @@ public class Pretty extends JCTree.Visitor {
         try {
             print("for (");
             if (tree.init.nonEmpty()) {
-                if (tree.init.head.getTag() == JCTree.VARDEF) {
+                if (tree.init.head.hasTag(VARDEF)) {
                     printExpr(tree.init.head);
                     for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
                         JCVariableDecl vdef = (JCVariableDecl)l.head;
@@ -627,7 +687,7 @@ public class Pretty extends JCTree.Visitor {
     public void visitSwitch(JCSwitch tree) {
         try {
             print("switch ");
-            if (tree.selector.getTag() == JCTree.PARENS) {
+            if (tree.selector.hasTag(PARENS)) {
                 printExpr(tree.selector);
             } else {
                 print("(");
@@ -666,7 +726,7 @@ public class Pretty extends JCTree.Visitor {
     public void visitSynchronized(JCSynchronized tree) {
         try {
             print("synchronized ");
-            if (tree.lock.getTag() == JCTree.PARENS) {
+            if (tree.lock.hasTag(PARENS)) {
                 printExpr(tree.lock);
             } else {
                 print("(");
@@ -737,7 +797,7 @@ public class Pretty extends JCTree.Visitor {
     public void visitIf(JCIf tree) {
         try {
             print("if ");
-            if (tree.cond.getTag() == JCTree.PARENS) {
+            if (tree.cond.hasTag(PARENS)) {
                 printExpr(tree.cond);
             } else {
                 print("(");
@@ -824,7 +884,7 @@ public class Pretty extends JCTree.Visitor {
     public void visitApply(JCMethodInvocation tree) {
         try {
             if (!tree.typeargs.isEmpty()) {
-                if (tree.meth.getTag() == JCTree.SELECT) {
+                if (tree.meth.hasTag(SELECT)) {
                     JCFieldAccess left = (JCFieldAccess)tree.meth;
                     printExpr(left.selected);
                     print(".<");
@@ -859,6 +919,9 @@ public class Pretty extends JCTree.Visitor {
                 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);
@@ -882,21 +945,35 @@ public class Pretty extends JCTree.Visitor {
         try {
             if (tree.elemtype != null) {
                 print("new ");
+                printTypeAnnotations(tree.annotations);
                 JCTree elem = tree.elemtype;
-                if (elem.getTag() == JCTree.TYPEARRAY)
-                    printBaseElementType((JCArrayTypeTree) elem);
-                else
-                    printExpr(elem);
+                printBaseElementType(elem);
+                boolean isElemAnnoType = elem instanceof JCAnnotatedType;
+                int i = 0;
+                List<List<JCAnnotation>> da = tree.dimAnnotations;
                 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
+                    if (da.size() > i && !da.get(i).isEmpty()) {
+                        print(' ');
+                        printTypeAnnotations(da.get(i));
+                    }
                     print("[");
+                    i++;
                     printExpr(l.head);
                     print("]");
                 }
+                if (tree.elems != null) {
+                    if (isElemAnnoType) {
+                        print(' ');
+                        printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations);
+                    }
+                    print("[]");
+                }
+                if (isElemAnnoType)
+                    elem = ((JCAnnotatedType)elem).underlyingType;
                 if (elem instanceof JCArrayTypeTree)
                     printBrackets((JCArrayTypeTree) elem);
             }
             if (tree.elems != null) {
-                if (tree.elemtype != null) print("[]");
                 print("{");
                 printExprs(tree.elems);
                 print("}");
@@ -906,6 +983,26 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
+    public void visitLambda(JCLambda tree) {
+        try {
+            print("(");
+            if (tree.paramKind == JCLambda.ParameterKind.EXPLICIT) {
+                printExprs(tree.params);
+            } else {
+                String sep = "";
+                for (JCVariableDecl param : tree.params) {
+                    print(sep);
+                    print(param.name);
+                    sep = ",";
+                }
+            }
+            print(")->");
+            printExpr(tree.body);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitParens(JCParens tree) {
         try {
             print("(");
@@ -928,36 +1025,36 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
-    public String operatorName(int tag) {
+    public String operatorName(JCTree.Tag tag) {
         switch(tag) {
-            case JCTree.POS:     return "+";
-            case JCTree.NEG:     return "-";
-            case JCTree.NOT:     return "!";
-            case JCTree.COMPL:   return "~";
-            case JCTree.PREINC:  return "++";
-            case JCTree.PREDEC:  return "--";
-            case JCTree.POSTINC: return "++";
-            case JCTree.POSTDEC: return "--";
-            case JCTree.NULLCHK: return "<*nullchk*>";
-            case JCTree.OR:      return "||";
-            case JCTree.AND:     return "&&";
-            case JCTree.EQ:      return "==";
-            case JCTree.NE:      return "!=";
-            case JCTree.LT:      return "<";
-            case JCTree.GT:      return ">";
-            case JCTree.LE:      return "<=";
-            case JCTree.GE:      return ">=";
-            case JCTree.BITOR:   return "|";
-            case JCTree.BITXOR:  return "^";
-            case JCTree.BITAND:  return "&";
-            case JCTree.SL:      return "<<";
-            case JCTree.SR:      return ">>";
-            case JCTree.USR:     return ">>>";
-            case JCTree.PLUS:    return "+";
-            case JCTree.MINUS:   return "-";
-            case JCTree.MUL:     return "*";
-            case JCTree.DIV:     return "/";
-            case JCTree.MOD:     return "%";
+            case POS:     return "+";
+            case NEG:     return "-";
+            case NOT:     return "!";
+            case COMPL:   return "~";
+            case PREINC:  return "++";
+            case PREDEC:  return "--";
+            case POSTINC: return "++";
+            case POSTDEC: return "--";
+            case NULLCHK: return "<*nullchk*>";
+            case OR:      return "||";
+            case AND:     return "&&";
+            case EQ:      return "==";
+            case NE:      return "!=";
+            case LT:      return "<";
+            case GT:      return ">";
+            case LE:      return "<=";
+            case GE:      return ">=";
+            case BITOR:   return "|";
+            case BITXOR:  return "^";
+            case BITAND:  return "&";
+            case SL:      return "<<";
+            case SR:      return ">>";
+            case USR:     return ">>>";
+            case PLUS:    return "+";
+            case MINUS:   return "-";
+            case MUL:     return "*";
+            case DIV:     return "/";
+            case MOD:     return "%";
             default: throw new Error();
         }
     }
@@ -966,7 +1063,7 @@ public class Pretty extends JCTree.Visitor {
         try {
             open(prec, TreeInfo.assignopPrec);
             printExpr(tree.lhs, TreeInfo.assignopPrec + 1);
-            print(" " + operatorName(tree.getTag() - JCTree.ASGOffset) + "= ");
+            print(" " + operatorName(tree.getTag().noAssignOp()) + "= ");
             printExpr(tree.rhs, TreeInfo.assignopPrec);
             close(prec, TreeInfo.assignopPrec);
         } catch (IOException e) {
@@ -979,7 +1076,7 @@ public class Pretty extends JCTree.Visitor {
             int ownprec = TreeInfo.opPrec(tree.getTag());
             String opname = operatorName(tree.getTag());
             open(prec, ownprec);
-            if (tree.getTag() <= JCTree.PREDEC) {
+            if (!tree.getTag().isPostUnaryOp()) {
                 print(opname);
                 printExpr(tree.arg, ownprec);
             } else {
@@ -1051,6 +1148,21 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
+    public void visitReference(JCMemberReference tree) {
+        try {
+            printExpr(tree.expr);
+            print("::");
+            if (tree.typeargs != null) {
+                print("<");
+                printExprs(tree.typeargs);
+                print(">");
+            }
+            print(tree.getMode() == ReferenceMode.INVOKE ? tree.name : "new");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitIdent(JCIdent tree) {
         try {
             print(tree.name);
@@ -1062,28 +1174,28 @@ public class Pretty extends JCTree.Visitor {
     public void visitLiteral(JCLiteral tree) {
         try {
             switch (tree.typetag) {
-                case TypeTags.INT:
+                case INT:
                     print(tree.value.toString());
                     break;
-                case TypeTags.LONG:
+                case LONG:
                     print(tree.value + "L");
                     break;
-                case TypeTags.FLOAT:
+                case FLOAT:
                     print(tree.value + "F");
                     break;
-                case TypeTags.DOUBLE:
+                case DOUBLE:
                     print(tree.value.toString());
                     break;
-                case TypeTags.CHAR:
+                case CHAR:
                     print("\'" +
                             Convert.quote(
                             String.valueOf((char)((Number)tree.value).intValue())) +
                             "\'");
                     break;
-                case TypeTags.BOOLEAN:
+                case BOOLEAN:
                     print(((Number)tree.value).intValue() == 1 ? "true" : "false");
                     break;
-                case TypeTags.BOT:
+                case BOT:
                     print("null");
                     break;
                 default:
@@ -1098,31 +1210,31 @@ public class Pretty extends JCTree.Visitor {
     public void visitTypeIdent(JCPrimitiveTypeTree tree) {
         try {
             switch(tree.typetag) {
-                case TypeTags.BYTE:
+                case BYTE:
                     print("byte");
                     break;
-                case TypeTags.CHAR:
+                case CHAR:
                     print("char");
                     break;
-                case TypeTags.SHORT:
+                case SHORT:
                     print("short");
                     break;
-                case TypeTags.INT:
+                case INT:
                     print("int");
                     break;
-                case TypeTags.LONG:
+                case LONG:
                     print("long");
                     break;
-                case TypeTags.FLOAT:
+                case FLOAT:
                     print("float");
                     break;
-                case TypeTags.DOUBLE:
+                case DOUBLE:
                     print("double");
                     break;
-                case TypeTags.BOOLEAN:
+                case BOOLEAN:
                     print("boolean");
                     break;
-                case TypeTags.VOID:
+                case VOID:
                     print("void");
                     break;
                 default:
@@ -1153,8 +1265,15 @@ public class Pretty extends JCTree.Visitor {
         JCTree elem;
         while (true) {
             elem = tree.elemtype;
+            if (elem.hasTag(ANNOTATED_TYPE)) {
+                JCAnnotatedType atype = (JCAnnotatedType) elem;
+                elem = atype.underlyingType;
+                if (!elem.hasTag(TYPEARRAY)) break;
+                print(' ');
+                printTypeAnnotations(atype.annotations);
+            }
             print("[]");
-            if (elem.getTag() != JCTree.TYPEARRAY) break;
+            if (!elem.hasTag(TYPEARRAY)) break;
             tree = (JCArrayTypeTree) elem;
         }
     }
@@ -1178,8 +1297,19 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
+    public void visitTypeIntersection(JCTypeIntersection tree) {
+        try {
+            printExprs(tree.bounds, " & ");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitTypeParameter(JCTypeParameter tree) {
         try {
+            if (tree.annotations.nonEmpty()) {
+                this.printTypeAnnotations(tree.annotations);
+            }
             print(tree.name);
             if (tree.bounds.nonEmpty()) {
                 print(" extends ");
@@ -1247,6 +1377,33 @@ public class Pretty extends JCTree.Visitor {
         }
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        try {
+            if (tree.underlyingType.getKind() == JCTree.Kind.MEMBER_SELECT) {
+                JCFieldAccess access = (JCFieldAccess) tree.underlyingType;
+                printExpr(access.selected, TreeInfo.postfixPrec);
+                print(".");
+                printTypeAnnotations(tree.annotations);
+                print(access.name);
+            } 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;
+                if (elem.hasTag(TYPEARRAY)) {
+                    printBrackets((JCArrayTypeTree) elem);
+                }
+            } else {
+                printTypeAnnotations(tree.annotations);
+                printExpr(tree.underlyingType);
+            }
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitTree(JCTree tree) {
         try {
             print("(UNKNOWN: " + tree + ")");
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
index d50d55e..1ccbb53 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2011, 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
@@ -71,11 +71,26 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         return lb.toList();
     }
 
+    public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
+        JCAnnotatedType t = (JCAnnotatedType) node;
+        List<JCAnnotation> annotations = copy(t.annotations, p);
+        JCExpression underlyingType = copy(t.underlyingType, p);
+        return M.at(t.pos).AnnotatedType(annotations, underlyingType);
+    }
+
     public JCTree visitAnnotation(AnnotationTree node, P p) {
         JCAnnotation t = (JCAnnotation) node;
         JCTree annotationType = copy(t.annotationType, p);
         List<JCExpression> args = copy(t.args, p);
-        return M.at(t.pos).Annotation(annotationType, args);
+        if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) {
+            JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args);
+            newTA.attribute = t.attribute;
+            return newTA;
+        } else {
+            JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args);
+            newT.attribute = t.attribute;
+            return newT;
+        }
     }
 
     public JCTree visitAssert(AssertTree node, P p) {
@@ -233,10 +248,11 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         JCExpression restype = copy(t.restype, p);
         List<JCTypeParameter> typarams = copy(t.typarams, p);
         List<JCVariableDecl> params = copy(t.params, p);
+        JCVariableDecl recvparam = copy(t.recvparam, p);
         List<JCExpression> thrown = copy(t.thrown, p);
         JCBlock body = copy(t.body, p);
         JCExpression defaultValue = copy(t.defaultValue, p);
-        return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue);
+        return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue);
     }
 
     public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
@@ -271,6 +287,13 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
     }
 
+    public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
+        JCLambda t = (JCLambda) node;
+        List<JCVariableDecl> params = copy(t.params, p);
+        JCTree body = copy(t.body, p);
+        return M.at(t.pos).Lambda(params, body);
+    }
+
     public JCTree visitParenthesized(ParenthesizedTree node, P p) {
         JCParens t = (JCParens) node;
         JCExpression expr = copy(t.expr, p);
@@ -289,6 +312,13 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         return M.at(t.pos).Select(selected, t.name);
     }
 
+    public JCTree visitMemberReference(MemberReferenceTree node, P p) {
+        JCMemberReference t = (JCMemberReference) node;
+        JCExpression expr = copy(t.expr, p);
+        List<JCExpression> typeargs = copy(t.typeargs, p);
+        return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
+    }
+
     public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
         JCSkip t = (JCSkip) node;
         return M.at(t.pos).Skip();
@@ -310,7 +340,7 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
 
     public JCTree visitThrow(ThrowTree node, P p) {
         JCThrow t = (JCThrow) node;
-        JCTree expr = copy(t.expr, p);
+        JCExpression expr = copy(t.expr, p);
         return M.at(t.pos).Throw(expr);
     }
 
@@ -344,6 +374,12 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         return M.at(t.pos).TypeUnion(components);
     }
 
+    public JCTree visitIntersectionType(IntersectionTypeTree node, P p) {
+        JCTypeIntersection t = (JCTypeIntersection) node;
+        List<JCExpression> bounds = copy(t.bounds, p);
+        return M.at(t.pos).TypeIntersection(bounds);
+    }
+
     public JCTree visitArrayType(ArrayTypeTree node, P p) {
         JCArrayTypeTree t = (JCArrayTypeTree) node;
         JCExpression elemtype = copy(t.elemtype, p);
@@ -364,8 +400,9 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
 
     public JCTree visitTypeParameter(TypeParameterTree node, P p) {
         JCTypeParameter t = (JCTypeParameter) node;
+        List<JCAnnotation> annos = copy(t.annotations, p);
         List<JCExpression> bounds = copy(t.bounds, p);
-        return M.at(t.pos).TypeParameter(t.name, bounds);
+        return M.at(t.pos).TypeParameter(t.name, bounds, annos);
     }
 
     public JCTree visitInstanceOf(InstanceOfTree node, P p) {
@@ -385,8 +422,13 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
         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) {
@@ -406,7 +448,7 @@ public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
     public JCTree visitOther(Tree node, P p) {
         JCTree tree = (JCTree) node;
         switch (tree.getTag()) {
-            case JCTree.LETEXPR: {
+            case LETEXPR: {
                 LetExpr t = (LetExpr) node;
                 List<JCVariableDecl> defs = copy(t.defs, p);
                 JCTree expr = copy(t.expr, p);
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index 4ae0de7..e87fae7 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,18 +25,21 @@
 
 package com.sun.tools.javac.tree;
 
+
+
 import com.sun.source.tree.Tree;
+import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
-import java.util.Map;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.JCTree.JCPolyExpression.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.tree.JCTree.*;
-
 import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.TypeTag.BOT;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
+import static com.sun.tools.javac.tree.JCTree.Tag.SYNCHRONIZED;
 
 /** Utility class containing inspector methods for trees.
  *
@@ -58,53 +61,73 @@ public class TreeInfo {
 
     /** The names of all operators.
      */
-    private Name[] opname = new Name[JCTree.MOD - JCTree.POS + 1];
+    private Name[] opname = new Name[Tag.getNumberOfOperators()];
+
+    private void setOpname(Tag tag, String name, Names names) {
+         setOpname(tag, names.fromString(name));
+     }
+     private void setOpname(Tag tag, Name name) {
+         opname[tag.operatorIndex()] = name;
+     }
 
     private TreeInfo(Context context) {
         context.put(treeInfoKey, this);
 
         Names names = Names.instance(context);
-        opname[JCTree.POS     - JCTree.POS] = names.fromString("+");
-        opname[JCTree.NEG     - JCTree.POS] = names.hyphen;
-        opname[JCTree.NOT     - JCTree.POS] = names.fromString("!");
-        opname[JCTree.COMPL   - JCTree.POS] = names.fromString("~");
-        opname[JCTree.PREINC  - JCTree.POS] = names.fromString("++");
-        opname[JCTree.PREDEC  - JCTree.POS] = names.fromString("--");
-        opname[JCTree.POSTINC - JCTree.POS] = names.fromString("++");
-        opname[JCTree.POSTDEC - JCTree.POS] = names.fromString("--");
-        opname[JCTree.NULLCHK - JCTree.POS] = names.fromString("<*nullchk*>");
-        opname[JCTree.OR      - JCTree.POS] = names.fromString("||");
-        opname[JCTree.AND     - JCTree.POS] = names.fromString("&&");
-        opname[JCTree.EQ      - JCTree.POS] = names.fromString("==");
-        opname[JCTree.NE      - JCTree.POS] = names.fromString("!=");
-        opname[JCTree.LT      - JCTree.POS] = names.fromString("<");
-        opname[JCTree.GT      - JCTree.POS] = names.fromString(">");
-        opname[JCTree.LE      - JCTree.POS] = names.fromString("<=");
-        opname[JCTree.GE      - JCTree.POS] = names.fromString(">=");
-        opname[JCTree.BITOR   - JCTree.POS] = names.fromString("|");
-        opname[JCTree.BITXOR  - JCTree.POS] = names.fromString("^");
-        opname[JCTree.BITAND  - JCTree.POS] = names.fromString("&");
-        opname[JCTree.SL      - JCTree.POS] = names.fromString("<<");
-        opname[JCTree.SR      - JCTree.POS] = names.fromString(">>");
-        opname[JCTree.USR     - JCTree.POS] = names.fromString(">>>");
-        opname[JCTree.PLUS    - JCTree.POS] = names.fromString("+");
-        opname[JCTree.MINUS   - JCTree.POS] = names.hyphen;
-        opname[JCTree.MUL     - JCTree.POS] = names.asterisk;
-        opname[JCTree.DIV     - JCTree.POS] = names.slash;
-        opname[JCTree.MOD     - JCTree.POS] = names.fromString("%");
+        /*  Internally we use +++, --- for unary +, - to reduce +, - operators
+         *  overloading
+         */
+        setOpname(POS, "+++", names);
+        setOpname(NEG, "---", names);
+        setOpname(NOT, "!", names);
+        setOpname(COMPL, "~", names);
+        setOpname(PREINC, "++", names);
+        setOpname(PREDEC, "--", names);
+        setOpname(POSTINC, "++", names);
+        setOpname(POSTDEC, "--", names);
+        setOpname(NULLCHK, "<*nullchk*>", names);
+        setOpname(OR, "||", names);
+        setOpname(AND, "&&", names);
+        setOpname(EQ, "==", names);
+        setOpname(NE, "!=", names);
+        setOpname(LT, "<", names);
+        setOpname(GT, ">", names);
+        setOpname(LE, "<=", names);
+        setOpname(GE, ">=", names);
+        setOpname(BITOR, "|", names);
+        setOpname(BITXOR, "^", names);
+        setOpname(BITAND, "&", names);
+        setOpname(SL, "<<", names);
+        setOpname(SR, ">>", names);
+        setOpname(USR, ">>>", names);
+        setOpname(PLUS, "+", names);
+        setOpname(MINUS, names.hyphen);
+        setOpname(MUL, names.asterisk);
+        setOpname(DIV, names.slash);
+        setOpname(MOD, "%", names);
     }
 
+    public static List<JCExpression> args(JCTree t) {
+        switch (t.getTag()) {
+            case APPLY:
+                return ((JCMethodInvocation)t).args;
+            case NEWCLASS:
+                return ((JCNewClass)t).args;
+            default:
+                return null;
+        }
+    }
 
     /** Return name of operator with given tree tag.
      */
-    public Name operatorName(int tag) {
-        return opname[tag - JCTree.POS];
+    public Name operatorName(JCTree.Tag tag) {
+        return opname[tag.operatorIndex()];
     }
 
     /** Is tree a constructor declaration?
      */
     public static boolean isConstructor(JCTree tree) {
-        if (tree.getTag() == JCTree.METHODDEF) {
+        if (tree.hasTag(METHODDEF)) {
             Name name = ((JCMethodDecl) tree).name;
             return name == name.table.names.init;
         } else {
@@ -121,17 +144,17 @@ public class TreeInfo {
     }
 
     public static boolean isMultiCatch(JCCatch catchClause) {
-        return catchClause.param.vartype.getTag() == JCTree.TYPEUNION;
+        return catchClause.param.vartype.hasTag(TYPEUNION);
     }
 
     /** Is statement an initializer for a synthetic field?
      */
     public static boolean isSyntheticInit(JCTree stat) {
-        if (stat.getTag() == JCTree.EXEC) {
+        if (stat.hasTag(EXEC)) {
             JCExpressionStatement exec = (JCExpressionStatement)stat;
-            if (exec.expr.getTag() == JCTree.ASSIGN) {
+            if (exec.expr.hasTag(ASSIGN)) {
                 JCAssign assign = (JCAssign)exec.expr;
-                if (assign.lhs.getTag() == JCTree.SELECT) {
+                if (assign.lhs.hasTag(SELECT)) {
                     JCFieldAccess select = (JCFieldAccess)assign.lhs;
                     if (select.sym != null &&
                         (select.sym.flags() & SYNTHETIC) != 0) {
@@ -148,9 +171,9 @@ public class TreeInfo {
     /** If the expression is a method call, return the method name, null
      *  otherwise. */
     public static Name calledMethodName(JCTree tree) {
-        if (tree.getTag() == JCTree.EXEC) {
+        if (tree.hasTag(EXEC)) {
             JCExpressionStatement exec = (JCExpressionStatement)tree;
-            if (exec.expr.getTag() == JCTree.APPLY) {
+            if (exec.expr.hasTag(APPLY)) {
                 Name mname = TreeInfo.name(((JCMethodInvocation) exec.expr).meth);
                 return mname;
             }
@@ -194,7 +217,7 @@ public class TreeInfo {
 
     /** Return the first call in a constructor definition. */
     public static JCMethodInvocation firstConstructorCall(JCTree tree) {
-        if (tree.getTag() != JCTree.METHODDEF) return null;
+        if (!tree.hasTag(METHODDEF)) return null;
         JCMethodDecl md = (JCMethodDecl) tree;
         Names names = md.name.table.names;
         if (md.name != names.init) return null;
@@ -204,34 +227,141 @@ public class TreeInfo {
         while (stats.nonEmpty() && isSyntheticInit(stats.head))
             stats = stats.tail;
         if (stats.isEmpty()) return null;
-        if (stats.head.getTag() != JCTree.EXEC) return null;
+        if (!stats.head.hasTag(EXEC)) return null;
         JCExpressionStatement exec = (JCExpressionStatement) stats.head;
-        if (exec.expr.getTag() != JCTree.APPLY) return null;
+        if (!exec.expr.hasTag(APPLY)) return null;
         return (JCMethodInvocation)exec.expr;
     }
 
     /** Return true if a tree represents a diamond new expr. */
     public static boolean isDiamond(JCTree tree) {
         switch(tree.getTag()) {
-            case JCTree.TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
-            case JCTree.NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
+            case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
+            case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
+            case ANNOTATED_TYPE: return isDiamond(((JCAnnotatedType)tree).underlyingType);
             default: return false;
         }
     }
 
+    public static boolean isEnumInit(JCTree tree) {
+        switch (tree.getTag()) {
+            case VARDEF:
+                return (((JCVariableDecl)tree).mods.flags & ENUM) != 0;
+            default:
+                return false;
+        }
+    }
+
+    /** set 'polyKind' on given tree */
+    public static void setPolyKind(JCTree tree, PolyKind pkind) {
+        switch (tree.getTag()) {
+            case APPLY:
+                ((JCMethodInvocation)tree).polyKind = pkind;
+                break;
+            case NEWCLASS:
+                ((JCNewClass)tree).polyKind = pkind;
+                break;
+            case REFERENCE:
+                ((JCMemberReference)tree).refPolyKind = pkind;
+                break;
+            default:
+                throw new AssertionError("Unexpected tree: " + tree);
+        }
+    }
+
+    /** set 'varargsElement' on given tree */
+    public static void setVarargsElement(JCTree tree, Type varargsElement) {
+        switch (tree.getTag()) {
+            case APPLY:
+                ((JCMethodInvocation)tree).varargsElement = varargsElement;
+                break;
+            case NEWCLASS:
+                ((JCNewClass)tree).varargsElement = varargsElement;
+                break;
+            case REFERENCE:
+                ((JCMemberReference)tree).varargsElement = varargsElement;
+                break;
+            default:
+                throw new AssertionError("Unexpected tree: " + tree);
+        }
+    }
+
+    /** Return true if the tree corresponds to an expression statement */
+    public static boolean isExpressionStatement(JCExpression tree) {
+        switch(tree.getTag()) {
+            case PREINC: case PREDEC:
+            case POSTINC: case POSTDEC:
+            case ASSIGN:
+            case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG:
+            case SL_ASG: case SR_ASG: case USR_ASG:
+            case PLUS_ASG: case MINUS_ASG:
+            case MUL_ASG: case DIV_ASG: case MOD_ASG:
+            case APPLY: case NEWCLASS:
+            case ERRONEOUS:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    /**
+     * Return true if the AST corresponds to a static select of the kind A.B
+     */
+    public static boolean isStaticSelector(JCTree base, Names names) {
+        if (base == null)
+            return false;
+        switch (base.getTag()) {
+            case IDENT:
+                JCIdent id = (JCIdent)base;
+                return id.name != names._this &&
+                        id.name != names._super &&
+                        isStaticSym(base);
+            case SELECT:
+                return isStaticSym(base) &&
+                    isStaticSelector(((JCFieldAccess)base).selected, names);
+            case TYPEAPPLY:
+            case TYPEARRAY:
+                return true;
+            case ANNOTATED_TYPE:
+                return isStaticSelector(((JCAnnotatedType)base).underlyingType, names);
+            default:
+                return false;
+        }
+    }
+    //where
+        private static boolean isStaticSym(JCTree tree) {
+            Symbol sym = symbol(tree);
+            return (sym.kind == Kinds.TYP ||
+                    sym.kind == Kinds.PCK);
+        }
+
     /** Return true if a tree represents the null literal. */
     public static boolean isNull(JCTree tree) {
-        if (tree.getTag() != JCTree.LITERAL)
+        if (!tree.hasTag(LITERAL))
             return false;
         JCLiteral lit = (JCLiteral) tree;
-        return (lit.typetag == TypeTags.BOT);
+        return (lit.typetag == BOT);
+    }
+
+    public static String getCommentText(Env<?> env, JCTree tree) {
+        DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL))
+                ? ((JCCompilationUnit) tree).docComments
+                : env.toplevel.docComments;
+        return (docComments == null) ? null : docComments.getCommentText(tree);
+    }
+
+    public static DCTree.DCDocComment getCommentTree(Env<?> env, JCTree tree) {
+        DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL))
+                ? ((JCCompilationUnit) tree).docComments
+                : env.toplevel.docComments;
+        return (docComments == null) ? null : docComments.getCommentTree(tree);
     }
 
     /** The position of the first statement in a block, or the position of
      *  the block itself if it is empty.
      */
     public static int firstStatPos(JCTree tree) {
-        if (tree.getTag() == JCTree.BLOCK && ((JCBlock) tree).stats.nonEmpty())
+        if (tree.hasTag(BLOCK) && ((JCBlock) tree).stats.nonEmpty())
             return ((JCBlock) tree).stats.head.pos;
         else
             return tree.pos;
@@ -241,15 +371,14 @@ public class TreeInfo {
      *  defined endpos.
      */
     public static int endPos(JCTree tree) {
-        if (tree.getTag() == JCTree.BLOCK && ((JCBlock) tree).endpos != Position.NOPOS)
+        if (tree.hasTag(BLOCK) && ((JCBlock) tree).endpos != Position.NOPOS)
             return ((JCBlock) tree).endpos;
-        else if (tree.getTag() == JCTree.SYNCHRONIZED)
+        else if (tree.hasTag(SYNCHRONIZED))
             return endPos(((JCSynchronized) tree).body);
-        else if (tree.getTag() == JCTree.TRY) {
+        else if (tree.hasTag(TRY)) {
             JCTry t = (JCTry) tree;
-            return endPos((t.finalizer != null)
-                          ? t.finalizer
-                          : (t.catchers.isEmpty()? t.body : t.catchers.last().body));
+            return endPos((t.finalizer != null) ? t.finalizer
+                          : (t.catchers.nonEmpty() ? t.catchers.last().body : t.body));
         } else
             return tree.pos;
     }
@@ -265,178 +394,202 @@ public class TreeInfo {
             return Position.NOPOS;
 
         switch(tree.getTag()) {
-        case(JCTree.APPLY):
-            return getStartPos(((JCMethodInvocation) tree).meth);
-        case(JCTree.ASSIGN):
-            return getStartPos(((JCAssign) tree).lhs);
-        case(JCTree.BITOR_ASG): case(JCTree.BITXOR_ASG): case(JCTree.BITAND_ASG):
-        case(JCTree.SL_ASG): case(JCTree.SR_ASG): case(JCTree.USR_ASG):
-        case(JCTree.PLUS_ASG): case(JCTree.MINUS_ASG): case(JCTree.MUL_ASG):
-        case(JCTree.DIV_ASG): case(JCTree.MOD_ASG):
-            return getStartPos(((JCAssignOp) tree).lhs);
-        case(JCTree.OR): case(JCTree.AND): case(JCTree.BITOR):
-        case(JCTree.BITXOR): case(JCTree.BITAND): case(JCTree.EQ):
-        case(JCTree.NE): case(JCTree.LT): case(JCTree.GT):
-        case(JCTree.LE): case(JCTree.GE): case(JCTree.SL):
-        case(JCTree.SR): case(JCTree.USR): case(JCTree.PLUS):
-        case(JCTree.MINUS): case(JCTree.MUL): case(JCTree.DIV):
-        case(JCTree.MOD):
-            return getStartPos(((JCBinary) tree).lhs);
-        case(JCTree.MODIFIERS): {
-            JCModifiers node = (JCModifiers)tree;
-            if (node.annotations.nonEmpty())
-                return Math.min(node.pos, getStartPos(node.annotations.head));
-            return node.pos;
-        }
-        case(JCTree.CLASSDEF): {
-            JCClassDecl node = (JCClassDecl)tree;
-            int pos = getStartPos(node.mods);
-            if (pos != Position.NOPOS)
-                return pos;
-            break;
-        }
-        case(JCTree.CONDEXPR):
-            return getStartPos(((JCConditional) tree).cond);
-        case(JCTree.EXEC):
-            return getStartPos(((JCExpressionStatement) tree).expr);
-        case(JCTree.INDEXED):
-            return getStartPos(((JCArrayAccess) tree).indexed);
-        case(JCTree.METHODDEF): {
-            JCMethodDecl node = (JCMethodDecl)tree;
-            int pos = getStartPos(node.mods);
-            if (pos != Position.NOPOS)
-                return pos;
-            if (node.typarams.nonEmpty()) // List.nil() used for no typarams
-                return getStartPos(node.typarams.head);
-            return node.restype == null ? node.pos : getStartPos(node.restype);
-        }
-        case(JCTree.SELECT):
-            return getStartPos(((JCFieldAccess) tree).selected);
-        case(JCTree.TYPEAPPLY):
-            return getStartPos(((JCTypeApply) tree).clazz);
-        case(JCTree.TYPEARRAY):
-            return getStartPos(((JCArrayTypeTree) tree).elemtype);
-        case(JCTree.TYPETEST):
-            return getStartPos(((JCInstanceOf) tree).expr);
-        case(JCTree.POSTINC):
-        case(JCTree.POSTDEC):
-            return getStartPos(((JCUnary) tree).arg);
-        case(JCTree.NEWCLASS): {
-            JCNewClass node = (JCNewClass)tree;
-            if (node.encl != null)
-                return getStartPos(node.encl);
-            break;
-        }
-        case(JCTree.VARDEF): {
-            JCVariableDecl node = (JCVariableDecl)tree;
-            int pos = getStartPos(node.mods);
-            if (pos != Position.NOPOS) {
-                return pos;
-            } else if (node.vartype.getTag() == JCTree.IDENT && ((JCIdent)node.vartype).pos == Position.NOPOS) {
+            case APPLY:
+                return getStartPos(((JCMethodInvocation) tree).meth);
+            case ASSIGN:
+                return getStartPos(((JCAssign) tree).lhs);
+            case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG:
+            case SL_ASG: case SR_ASG: case USR_ASG:
+            case PLUS_ASG: case MINUS_ASG: case MUL_ASG:
+            case DIV_ASG: case MOD_ASG:
+                return getStartPos(((JCAssignOp) tree).lhs);
+            case OR: case AND: case BITOR:
+            case BITXOR: case BITAND: case EQ:
+            case NE: case LT: case GT:
+            case LE: case GE: case SL:
+            case SR: case USR: case PLUS:
+            case MINUS: case MUL: case DIV:
+            case MOD:
+                return getStartPos(((JCBinary) tree).lhs);
+            case MODIFIERS: {
+                JCModifiers node = (JCModifiers)tree;
+                if (node.annotations.nonEmpty())
+                    return Math.min(node.pos, getStartPos(node.annotations.head));
                 return node.pos;
-            } else {
-                return getStartPos(node.vartype);
             }
-        }
-        case(JCTree.ERRONEOUS): {
-            JCErroneous node = (JCErroneous)tree;
-            for (List<? extends JCTree> l = node.errs; l.nonEmpty(); l = l.tail) {
-                int pos = getStartPos(node.errs.head);
+            case CLASSDEF: {
+                JCClassDecl node = (JCClassDecl)tree;
+                int pos = getStartPos(node.mods);
                 if (pos != Position.NOPOS)
                     return pos;
+                break;
+            }
+            case CONDEXPR:
+                return getStartPos(((JCConditional) tree).cond);
+            case EXEC:
+                return getStartPos(((JCExpressionStatement) tree).expr);
+            case INDEXED:
+                return getStartPos(((JCArrayAccess) tree).indexed);
+            case METHODDEF: {
+                JCMethodDecl node = (JCMethodDecl)tree;
+                int pos = getStartPos(node.mods);
+                if (pos != Position.NOPOS)
+                    return pos;
+                if (node.typarams != null && node.typarams.nonEmpty())
+                    return getStartPos(node.typarams.head);
+                return node.restype == null ? node.pos : getStartPos(node.restype);
+            }
+            case SELECT:
+                return getStartPos(((JCFieldAccess) tree).selected);
+            case TYPEAPPLY:
+                return getStartPos(((JCTypeApply) tree).clazz);
+            case TYPEARRAY:
+                return getStartPos(((JCArrayTypeTree) tree).elemtype);
+            case TYPETEST:
+                return getStartPos(((JCInstanceOf) tree).expr);
+            case POSTINC:
+            case POSTDEC:
+                return getStartPos(((JCUnary) tree).arg);
+            case ANNOTATED_TYPE: {
+                JCAnnotatedType node = (JCAnnotatedType) tree;
+                if (node.annotations.nonEmpty()) {
+                    if (node.underlyingType.hasTag(TYPEARRAY) ||
+                            node.underlyingType.hasTag(SELECT)) {
+                        return getStartPos(node.underlyingType);
+                    } else {
+                        return getStartPos(node.annotations.head);
+                    }
+                } else {
+                    return getStartPos(node.underlyingType);
+                }
+            }
+            case NEWCLASS: {
+                JCNewClass node = (JCNewClass)tree;
+                if (node.encl != null)
+                    return getStartPos(node.encl);
+                break;
+            }
+            case VARDEF: {
+                JCVariableDecl node = (JCVariableDecl)tree;
+                int pos = getStartPos(node.mods);
+                if (pos != Position.NOPOS) {
+                    return pos;
+                } else if (node.vartype == null || node.vartype.pos == Position.NOPOS) {
+                    //if there's no type (partially typed lambda parameter)
+                    //simply return node position
+                    return node.pos;
+                } else {
+                    return getStartPos(node.vartype);
+                }
+            }
+            case ERRONEOUS: {
+                JCErroneous node = (JCErroneous)tree;
+                if (node.errs != null && node.errs.nonEmpty()) {
+                    int pos = getStartPos(node.errs.head);
+                    if (pos != Position.NOPOS)
+                        return pos;
+                }
             }
-        }
         }
         return tree.pos;
     }
 
     /** The end position of given tree, given  a table of end positions generated by the parser
      */
-    public static int getEndPos(JCTree tree, Map<JCTree, Integer> endPositions) {
+    public static int getEndPos(JCTree tree, EndPosTable endPosTable) {
         if (tree == null)
             return Position.NOPOS;
 
-        if (endPositions == null) {
+        if (endPosTable == null) {
             // fall back on limited info in the tree
             return endPos(tree);
         }
 
-        Integer mapPos = endPositions.get(tree);
-        if (mapPos != null)
+        int mapPos = endPosTable.getEndPos(tree);
+        if (mapPos != Position.NOPOS)
             return mapPos;
 
         switch(tree.getTag()) {
-        case(JCTree.BITOR_ASG): case(JCTree.BITXOR_ASG): case(JCTree.BITAND_ASG):
-        case(JCTree.SL_ASG): case(JCTree.SR_ASG): case(JCTree.USR_ASG):
-        case(JCTree.PLUS_ASG): case(JCTree.MINUS_ASG): case(JCTree.MUL_ASG):
-        case(JCTree.DIV_ASG): case(JCTree.MOD_ASG):
-            return getEndPos(((JCAssignOp) tree).rhs, endPositions);
-        case(JCTree.OR): case(JCTree.AND): case(JCTree.BITOR):
-        case(JCTree.BITXOR): case(JCTree.BITAND): case(JCTree.EQ):
-        case(JCTree.NE): case(JCTree.LT): case(JCTree.GT):
-        case(JCTree.LE): case(JCTree.GE): case(JCTree.SL):
-        case(JCTree.SR): case(JCTree.USR): case(JCTree.PLUS):
-        case(JCTree.MINUS): case(JCTree.MUL): case(JCTree.DIV):
-        case(JCTree.MOD):
-            return getEndPos(((JCBinary) tree).rhs, endPositions);
-        case(JCTree.CASE):
-            return getEndPos(((JCCase) tree).stats.last(), endPositions);
-        case(JCTree.CATCH):
-            return getEndPos(((JCCatch) tree).body, endPositions);
-        case(JCTree.CONDEXPR):
-            return getEndPos(((JCConditional) tree).falsepart, endPositions);
-        case(JCTree.FORLOOP):
-            return getEndPos(((JCForLoop) tree).body, endPositions);
-        case(JCTree.FOREACHLOOP):
-            return getEndPos(((JCEnhancedForLoop) tree).body, endPositions);
-        case(JCTree.IF): {
-            JCIf node = (JCIf)tree;
-            if (node.elsepart == null) {
-                return getEndPos(node.thenpart, endPositions);
-            } else {
-                return getEndPos(node.elsepart, endPositions);
+            case ASSIGN:
+                return getEndPos(((JCAssign) tree).rhs, endPosTable);
+            case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG:
+            case SL_ASG: case SR_ASG: case USR_ASG:
+            case PLUS_ASG: case MINUS_ASG: case MUL_ASG:
+            case DIV_ASG: case MOD_ASG:
+                return getEndPos(((JCAssignOp) tree).rhs, endPosTable);
+            case OR: case AND: case BITOR:
+            case BITXOR: case BITAND: case EQ:
+            case NE: case LT: case GT:
+            case LE: case GE: case SL:
+            case SR: case USR: case PLUS:
+            case MINUS: case MUL: case DIV:
+            case MOD:
+                return getEndPos(((JCBinary) tree).rhs, endPosTable);
+            case CASE:
+                return getEndPos(((JCCase) tree).stats.last(), endPosTable);
+            case CATCH:
+                return getEndPos(((JCCatch) tree).body, endPosTable);
+            case CONDEXPR:
+                return getEndPos(((JCConditional) tree).falsepart, endPosTable);
+            case FORLOOP:
+                return getEndPos(((JCForLoop) tree).body, endPosTable);
+            case FOREACHLOOP:
+                return getEndPos(((JCEnhancedForLoop) tree).body, endPosTable);
+            case IF: {
+                JCIf node = (JCIf)tree;
+                if (node.elsepart == null) {
+                    return getEndPos(node.thenpart, endPosTable);
+                } else {
+                    return getEndPos(node.elsepart, endPosTable);
+                }
             }
-        }
-        case(JCTree.LABELLED):
-            return getEndPos(((JCLabeledStatement) tree).body, endPositions);
-        case(JCTree.MODIFIERS):
-            return getEndPos(((JCModifiers) tree).annotations.last(), endPositions);
-        case(JCTree.SYNCHRONIZED):
-            return getEndPos(((JCSynchronized) tree).body, endPositions);
-        case(JCTree.TOPLEVEL):
-            return getEndPos(((JCCompilationUnit) tree).defs.last(), endPositions);
-        case(JCTree.TRY): {
-            JCTry node = (JCTry)tree;
-            if (node.finalizer != null) {
-                return getEndPos(node.finalizer, endPositions);
-            } else if (!node.catchers.isEmpty()) {
-                return getEndPos(node.catchers.last(), endPositions);
-            } else {
-                return getEndPos(node.body, endPositions);
+            case LABELLED:
+                return getEndPos(((JCLabeledStatement) tree).body, endPosTable);
+            case MODIFIERS:
+                return getEndPos(((JCModifiers) tree).annotations.last(), endPosTable);
+            case SYNCHRONIZED:
+                return getEndPos(((JCSynchronized) tree).body, endPosTable);
+            case TOPLEVEL:
+                return getEndPos(((JCCompilationUnit) tree).defs.last(), endPosTable);
+            case TRY: {
+                JCTry node = (JCTry)tree;
+                if (node.finalizer != null) {
+                    return getEndPos(node.finalizer, endPosTable);
+                } else if (!node.catchers.isEmpty()) {
+                    return getEndPos(node.catchers.last(), endPosTable);
+                } else {
+                    return getEndPos(node.body, endPosTable);
+                }
             }
-        }
-        case(JCTree.WILDCARD):
-            return getEndPos(((JCWildcard) tree).inner, endPositions);
-        case(JCTree.TYPECAST):
-            return getEndPos(((JCTypeCast) tree).expr, endPositions);
-        case(JCTree.TYPETEST):
-            return getEndPos(((JCInstanceOf) tree).clazz, endPositions);
-        case(JCTree.POS):
-        case(JCTree.NEG):
-        case(JCTree.NOT):
-        case(JCTree.COMPL):
-        case(JCTree.PREINC):
-        case(JCTree.PREDEC):
-            return getEndPos(((JCUnary) tree).arg, endPositions);
-        case(JCTree.WHILELOOP):
-            return getEndPos(((JCWhileLoop) tree).body, endPositions);
-        case(JCTree.ASSIGN):
-            return getEndPos(((JCAssign) tree).rhs, endPositions);
-        case(JCTree.ERRONEOUS): {
-            JCErroneous node = (JCErroneous)tree;
-            if (node.errs != null && node.errs.nonEmpty())
-                return getEndPos(node.errs.last(), endPositions);
-        }
+            case WILDCARD:
+                return getEndPos(((JCWildcard) tree).inner, endPosTable);
+            case TYPECAST:
+                return getEndPos(((JCTypeCast) tree).expr, endPosTable);
+            case TYPETEST:
+                return getEndPos(((JCInstanceOf) tree).clazz, endPosTable);
+            case POS:
+            case NEG:
+            case NOT:
+            case COMPL:
+            case PREINC:
+            case PREDEC:
+                return getEndPos(((JCUnary) tree).arg, endPosTable);
+            case WHILELOOP:
+                return getEndPos(((JCWhileLoop) tree).body, endPosTable);
+            case ANNOTATED_TYPE:
+                return getEndPos(((JCAnnotatedType) tree).underlyingType, endPosTable);
+            case ERRONEOUS: {
+                JCErroneous node = (JCErroneous)tree;
+                if (node.errs != null && node.errs.nonEmpty())
+                    return getEndPos(node.errs.last(), endPosTable);
+                break;
+            }
+            case IDENT:
+                JCIdent i = (JCIdent) tree;
+                return i.pos + i.name.length();
+            case SELECT:
+                JCFieldAccess s = (JCFieldAccess) tree;
+                return s.pos + s.name.length() + 1;
         }
         return Position.NOPOS;
     }
@@ -452,7 +605,7 @@ public class TreeInfo {
             public JCTree getTree() { return tree; }
             public int getStartPosition() { return TreeInfo.getStartPos(tree); }
             public int getPreferredPosition() { return endPos; }
-            public int getEndPosition(Map<JCTree, Integer> endPosTable) {
+            public int getEndPosition(EndPosTable endPosTable) {
                 return TreeInfo.getEndPos(tree, endPosTable);
             }
         };
@@ -461,11 +614,11 @@ public class TreeInfo {
     /** The position of the finalizer of given try/synchronized statement.
      */
     public static int finalizerPos(JCTree tree) {
-        if (tree.getTag() == JCTree.TRY) {
+        if (tree.hasTag(TRY)) {
             JCTry t = (JCTry) tree;
             Assert.checkNonNull(t.finalizer);
             return firstStatPos(t.finalizer);
-        } else if (tree.getTag() == JCTree.SYNCHRONIZED) {
+        } else if (tree.hasTag(SYNCHRONIZED)) {
             return endPos(((JCSynchronized) tree).body);
         } else {
             throw new AssertionError();
@@ -569,9 +722,9 @@ public class TreeInfo {
     public static JCTree referencedStatement(JCLabeledStatement tree) {
         JCTree t = tree;
         do t = ((JCLabeledStatement) t).body;
-        while (t.getTag() == JCTree.LABELLED);
+        while (t.hasTag(LABELLED));
         switch (t.getTag()) {
-        case JCTree.DOLOOP: case JCTree.WHILELOOP: case JCTree.FORLOOP: case JCTree.FOREACHLOOP: case JCTree.SWITCH:
+        case DOLOOP: case WHILELOOP: case FORLOOP: case FOREACHLOOP: case SWITCH:
             return t;
         default:
             return tree;
@@ -581,7 +734,7 @@ public class TreeInfo {
     /** Skip parens and return the enclosed expression
      */
     public static JCExpression skipParens(JCExpression tree) {
-        while (tree.getTag() == JCTree.PARENS) {
+        while (tree.hasTag(PARENS)) {
             tree = ((JCParens) tree).expr;
         }
         return tree;
@@ -590,7 +743,7 @@ public class TreeInfo {
     /** Skip parens and return the enclosed expression
      */
     public static JCTree skipParens(JCTree tree) {
-        if (tree.getTag() == JCTree.PARENS)
+        if (tree.hasTag(PARENS))
             return skipParens((JCParens)tree);
         else
             return tree;
@@ -610,11 +763,11 @@ public class TreeInfo {
      */
     public static Name name(JCTree tree) {
         switch (tree.getTag()) {
-        case JCTree.IDENT:
+        case IDENT:
             return ((JCIdent) tree).name;
-        case JCTree.SELECT:
+        case SELECT:
             return ((JCFieldAccess) tree).name;
-        case JCTree.TYPEAPPLY:
+        case TYPEAPPLY:
             return name(((JCTypeApply) tree).clazz);
         default:
             return null;
@@ -627,9 +780,9 @@ public class TreeInfo {
     public static Name fullName(JCTree tree) {
         tree = skipParens(tree);
         switch (tree.getTag()) {
-        case JCTree.IDENT:
+        case IDENT:
             return ((JCIdent) tree).name;
-        case JCTree.SELECT:
+        case SELECT:
             Name sname = fullName(((JCFieldAccess) tree).selected);
             return sname == null ? null : sname.append('.', name(tree));
         default:
@@ -638,53 +791,40 @@ public class TreeInfo {
     }
 
     public static Symbol symbolFor(JCTree node) {
-        Symbol s = symbolForImpl(node);
-
-        //see MethodInvocationAttributionTest and IZ#121163
-        if (s instanceof MethodSymbol) {
-            MethodSymbol ms = (MethodSymbol) s;
-
-            if (ms.originalMethod != null) {
-                return ms.originalMethod;
-            }
-        }
-
-        if (s instanceof VarSymbol) {
-            VarSymbol vs = (VarSymbol) s;
-
-            if (vs.originalVar != null) {
-                return vs.originalVar;
-            }
-        }
+        Symbol sym = symbolForImpl(node);
 
-        return s;
+        return sym != null ? sym.baseSymbol() : null;
     }
 
     private static Symbol symbolForImpl(JCTree node) {
         node = skipParens(node);
         switch (node.getTag()) {
-        case JCTree.TOPLEVEL:
+        case TOPLEVEL:
             return ((JCCompilationUnit) node).packge;
-        case JCTree.CLASSDEF:
+        case CLASSDEF:
             return ((JCClassDecl) node).sym;
-        case JCTree.METHODDEF:
+        case METHODDEF:
             return ((JCMethodDecl) node).sym;
-        case JCTree.VARDEF:
+        case VARDEF:
             return ((JCVariableDecl) node).sym;
-        case JCTree.IDENT:
+        case IDENT:
             return ((JCIdent) node).sym;
-        case JCTree.SELECT:
+        case SELECT:
             return ((JCFieldAccess) node).sym;
-        case JCTree.NEWCLASS:
+        case REFERENCE:
+            return ((JCMemberReference) node).sym;
+        case NEWCLASS:
             return ((JCNewClass) node).constructor;
-        case JCTree.APPLY:
+        case APPLY:
             return symbolFor(((JCMethodInvocation) node).meth);
-        case JCTree.TYPEAPPLY:
+        case TYPEAPPLY:
             return symbolFor(((JCTypeApply) node).clazz);
-        case JCTree.ANNOTATION:
-        case JCTree.TYPEPARAMETER:
+        case ANNOTATION:
+        case TYPE_ANNOTATION:
+        case TYPEPARAMETER:
             if (node.type != null)
                 return node.type.tsym;
+            return null;
         default:
             return null;
         }
@@ -693,9 +833,9 @@ public class TreeInfo {
     public static boolean isDeclaration(JCTree node) {
         node = skipParens(node);
         switch (node.getTag()) {
-        case JCTree.CLASSDEF:
-        case JCTree.METHODDEF:
-        case JCTree.VARDEF:
+        case CLASSDEF:
+        case METHODDEF:
+        case VARDEF:
             return true;
         default:
             return false;
@@ -708,12 +848,14 @@ public class TreeInfo {
     public static Symbol symbol(JCTree tree) {
         tree = skipParens(tree);
         switch (tree.getTag()) {
-        case JCTree.IDENT:
+        case IDENT:
             return ((JCIdent) tree).sym;
-        case JCTree.SELECT:
+        case SELECT:
             return ((JCFieldAccess) tree).sym;
-        case JCTree.TYPEAPPLY:
+        case TYPEAPPLY:
             return symbol(((JCTypeApply) tree).clazz);
+        case ANNOTATED_TYPE:
+            return symbol(((JCAnnotatedType) tree).underlyingType);
         default:
             return null;
         }
@@ -722,7 +864,7 @@ public class TreeInfo {
     /** Return true if this is a nonstatic selection. */
     public static boolean nonstaticSelect(JCTree tree) {
         tree = skipParens(tree);
-        if (tree.getTag() != JCTree.SELECT) return false;
+        if (!tree.hasTag(SELECT)) return false;
         JCFieldAccess s = (JCFieldAccess) tree;
         Symbol e = symbol(s.selected);
         return e == null || (e.kind != Kinds.PCK && e.kind != Kinds.TYP);
@@ -733,9 +875,9 @@ public class TreeInfo {
     public static void setSymbol(JCTree tree, Symbol sym) {
         tree = skipParens(tree);
         switch (tree.getTag()) {
-        case JCTree.IDENT:
+        case IDENT:
             ((JCIdent) tree).sym = sym; break;
-        case JCTree.SELECT:
+        case SELECT:
             ((JCFieldAccess) tree).sym = sym; break;
         default:
         }
@@ -746,13 +888,13 @@ public class TreeInfo {
      */
     public static long flags(JCTree tree) {
         switch (tree.getTag()) {
-        case JCTree.VARDEF:
+        case VARDEF:
             return ((JCVariableDecl) tree).mods.flags;
-        case JCTree.METHODDEF:
+        case METHODDEF:
             return ((JCMethodDecl) tree).mods.flags;
-        case JCTree.CLASSDEF:
+        case CLASSDEF:
             return ((JCClassDecl) tree).mods.flags;
-        case JCTree.BLOCK:
+        case BLOCK:
             return ((JCBlock) tree).flags;
         default:
             return 0;
@@ -763,8 +905,8 @@ public class TreeInfo {
      *  pre: flags != 0
      */
     public static long firstFlag(long flags) {
-        int flag = 1;
-        while ((flag & StandardFlags) != 0 && (flag & flags) == 0)
+        long flag = 1;
+        while ((flag & flags & ExtendedStandardFlags) == 0)
             flag = flag << 1;
         return flag;
     }
@@ -772,7 +914,7 @@ public class TreeInfo {
     /** Return flags as a string, separated by " ".
      */
     public static String flagNames(long flags) {
-        return Flags.toString(flags & StandardFlags).trim();
+        return Flags.toString(flags & ExtendedStandardFlags).trim();
     }
 
     /** Operator precedences values.
@@ -800,189 +942,239 @@ public class TreeInfo {
 
     /** Map operators to their precedence levels.
      */
-    public static int opPrec(int op) {
+    public static int opPrec(JCTree.Tag op) {
         switch(op) {
-        case JCTree.POS:
-        case JCTree.NEG:
-        case JCTree.NOT:
-        case JCTree.COMPL:
-        case JCTree.PREINC:
-        case JCTree.PREDEC: return prefixPrec;
-        case JCTree.POSTINC:
-        case JCTree.POSTDEC:
-        case JCTree.NULLCHK: return postfixPrec;
-        case JCTree.ASSIGN: return assignPrec;
-        case JCTree.BITOR_ASG:
-        case JCTree.BITXOR_ASG:
-        case JCTree.BITAND_ASG:
-        case JCTree.SL_ASG:
-        case JCTree.SR_ASG:
-        case JCTree.USR_ASG:
-        case JCTree.PLUS_ASG:
-        case JCTree.MINUS_ASG:
-        case JCTree.MUL_ASG:
-        case JCTree.DIV_ASG:
-        case JCTree.MOD_ASG: return assignopPrec;
-        case JCTree.OR: return orPrec;
-        case JCTree.AND: return andPrec;
-        case JCTree.EQ:
-        case JCTree.NE: return eqPrec;
-        case JCTree.LT:
-        case JCTree.GT:
-        case JCTree.LE:
-        case JCTree.GE: return ordPrec;
-        case JCTree.BITOR: return bitorPrec;
-        case JCTree.BITXOR: return bitxorPrec;
-        case JCTree.BITAND: return bitandPrec;
-        case JCTree.SL:
-        case JCTree.SR:
-        case JCTree.USR: return shiftPrec;
-        case JCTree.PLUS:
-        case JCTree.MINUS: return addPrec;
-        case JCTree.MUL:
-        case JCTree.DIV:
-        case JCTree.MOD: return mulPrec;
-        case JCTree.TYPETEST: return ordPrec;
+        case POS:
+        case NEG:
+        case NOT:
+        case COMPL:
+        case PREINC:
+        case PREDEC: return prefixPrec;
+        case POSTINC:
+        case POSTDEC:
+        case NULLCHK: return postfixPrec;
+        case ASSIGN: return assignPrec;
+        case BITOR_ASG:
+        case BITXOR_ASG:
+        case BITAND_ASG:
+        case SL_ASG:
+        case SR_ASG:
+        case USR_ASG:
+        case PLUS_ASG:
+        case MINUS_ASG:
+        case MUL_ASG:
+        case DIV_ASG:
+        case MOD_ASG: return assignopPrec;
+        case OR: return orPrec;
+        case AND: return andPrec;
+        case EQ:
+        case NE: return eqPrec;
+        case LT:
+        case GT:
+        case LE:
+        case GE: return ordPrec;
+        case BITOR: return bitorPrec;
+        case BITXOR: return bitxorPrec;
+        case BITAND: return bitandPrec;
+        case SL:
+        case SR:
+        case USR: return shiftPrec;
+        case PLUS:
+        case MINUS: return addPrec;
+        case MUL:
+        case DIV:
+        case MOD: return mulPrec;
+        case TYPETEST: return ordPrec;
         default: throw new AssertionError();
         }
     }
 
-    static Tree.Kind tagToKind(int tag) {
+    static Tree.Kind tagToKind(JCTree.Tag tag) {
         switch (tag) {
         // Postfix expressions
-        case JCTree.POSTINC:           // _ ++
+        case POSTINC:           // _ ++
             return Tree.Kind.POSTFIX_INCREMENT;
-        case JCTree.POSTDEC:           // _ --
+        case POSTDEC:           // _ --
             return Tree.Kind.POSTFIX_DECREMENT;
 
         // Unary operators
-        case JCTree.PREINC:            // ++ _
+        case PREINC:            // ++ _
             return Tree.Kind.PREFIX_INCREMENT;
-        case JCTree.PREDEC:            // -- _
+        case PREDEC:            // -- _
             return Tree.Kind.PREFIX_DECREMENT;
-        case JCTree.POS:               // +
+        case POS:               // +
             return Tree.Kind.UNARY_PLUS;
-        case JCTree.NEG:               // -
+        case NEG:               // -
             return Tree.Kind.UNARY_MINUS;
-        case JCTree.COMPL:             // ~
+        case COMPL:             // ~
             return Tree.Kind.BITWISE_COMPLEMENT;
-        case JCTree.NOT:               // !
+        case NOT:               // !
             return Tree.Kind.LOGICAL_COMPLEMENT;
 
         // Binary operators
 
         // Multiplicative operators
-        case JCTree.MUL:               // *
+        case MUL:               // *
             return Tree.Kind.MULTIPLY;
-        case JCTree.DIV:               // /
+        case DIV:               // /
             return Tree.Kind.DIVIDE;
-        case JCTree.MOD:               // %
+        case MOD:               // %
             return Tree.Kind.REMAINDER;
 
         // Additive operators
-        case JCTree.PLUS:              // +
+        case PLUS:              // +
             return Tree.Kind.PLUS;
-        case JCTree.MINUS:             // -
+        case MINUS:             // -
             return Tree.Kind.MINUS;
 
         // Shift operators
-        case JCTree.SL:                // <<
+        case SL:                // <<
             return Tree.Kind.LEFT_SHIFT;
-        case JCTree.SR:                // >>
+        case SR:                // >>
             return Tree.Kind.RIGHT_SHIFT;
-        case JCTree.USR:               // >>>
+        case USR:               // >>>
             return Tree.Kind.UNSIGNED_RIGHT_SHIFT;
 
         // Relational operators
-        case JCTree.LT:                // <
+        case LT:                // <
             return Tree.Kind.LESS_THAN;
-        case JCTree.GT:                // >
+        case GT:                // >
             return Tree.Kind.GREATER_THAN;
-        case JCTree.LE:                // <=
+        case LE:                // <=
             return Tree.Kind.LESS_THAN_EQUAL;
-        case JCTree.GE:                // >=
+        case GE:                // >=
             return Tree.Kind.GREATER_THAN_EQUAL;
 
         // Equality operators
-        case JCTree.EQ:                // ==
+        case EQ:                // ==
             return Tree.Kind.EQUAL_TO;
-        case JCTree.NE:                // !=
+        case NE:                // !=
             return Tree.Kind.NOT_EQUAL_TO;
 
         // Bitwise and logical operators
-        case JCTree.BITAND:            // &
+        case BITAND:            // &
             return Tree.Kind.AND;
-        case JCTree.BITXOR:            // ^
+        case BITXOR:            // ^
             return Tree.Kind.XOR;
-        case JCTree.BITOR:             // |
+        case BITOR:             // |
             return Tree.Kind.OR;
 
         // Conditional operators
-        case JCTree.AND:               // &&
+        case AND:               // &&
             return Tree.Kind.CONDITIONAL_AND;
-        case JCTree.OR:                // ||
+        case OR:                // ||
             return Tree.Kind.CONDITIONAL_OR;
 
         // Assignment operators
-        case JCTree.MUL_ASG:           // *=
+        case MUL_ASG:           // *=
             return Tree.Kind.MULTIPLY_ASSIGNMENT;
-        case JCTree.DIV_ASG:           // /=
+        case DIV_ASG:           // /=
             return Tree.Kind.DIVIDE_ASSIGNMENT;
-        case JCTree.MOD_ASG:           // %=
+        case MOD_ASG:           // %=
             return Tree.Kind.REMAINDER_ASSIGNMENT;
-        case JCTree.PLUS_ASG:          // +=
+        case PLUS_ASG:          // +=
             return Tree.Kind.PLUS_ASSIGNMENT;
-        case JCTree.MINUS_ASG:         // -=
+        case MINUS_ASG:         // -=
             return Tree.Kind.MINUS_ASSIGNMENT;
-        case JCTree.SL_ASG:            // <<=
+        case SL_ASG:            // <<=
             return Tree.Kind.LEFT_SHIFT_ASSIGNMENT;
-        case JCTree.SR_ASG:            // >>=
+        case SR_ASG:            // >>=
             return Tree.Kind.RIGHT_SHIFT_ASSIGNMENT;
-        case JCTree.USR_ASG:           // >>>=
+        case USR_ASG:           // >>>=
             return Tree.Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT;
-        case JCTree.BITAND_ASG:        // &=
+        case BITAND_ASG:        // &=
             return Tree.Kind.AND_ASSIGNMENT;
-        case JCTree.BITXOR_ASG:        // ^=
+        case BITXOR_ASG:        // ^=
             return Tree.Kind.XOR_ASSIGNMENT;
-        case JCTree.BITOR_ASG:         // |=
+        case BITOR_ASG:         // |=
             return Tree.Kind.OR_ASSIGNMENT;
 
         // Null check (implementation detail), for example, __.getClass()
-        case JCTree.NULLCHK:
+        case NULLCHK:
             return Tree.Kind.OTHER;
 
+        case ANNOTATION:
+            return Tree.Kind.ANNOTATION;
+        case TYPE_ANNOTATION:
+            return Tree.Kind.TYPE_ANNOTATION;
+
         default:
             return null;
         }
     }
 
     /**
-     * Returns the underlying type of the tree if it is annotated type,
-     * or the tree itself otherwise
+     * Returns the underlying type of the tree if it is an annotated type,
+     * or the tree itself otherwise.
      */
     public static JCExpression typeIn(JCExpression tree) {
         switch (tree.getTag()) {
-        case JCTree.IDENT: /* simple names */
-        case JCTree.TYPEIDENT: /* primitive name */
-        case JCTree.SELECT: /* qualified name */
-        case JCTree.TYPEARRAY: /* array types */
-        case JCTree.WILDCARD: /* wild cards */
-        case JCTree.TYPEPARAMETER: /* type parameters */
-        case JCTree.TYPEAPPLY: /* parameterized types */
+        case ANNOTATED_TYPE:
+            return ((JCAnnotatedType)tree).underlyingType;
+        case IDENT: /* simple names */
+        case TYPEIDENT: /* primitive name */
+        case SELECT: /* qualified name */
+        case TYPEARRAY: /* array types */
+        case WILDCARD: /* wild cards */
+        case TYPEPARAMETER: /* type parameters */
+        case TYPEAPPLY: /* parameterized types */
+        case ERRONEOUS: /* error tree TODO: needed for BadCast JSR308 test case. Better way? */
             return tree;
         default:
             throw new AssertionError("Unexpected type tree: " + tree);
         }
     }
 
+    /* Return the inner-most type of a type tree.
+     * For an array that contains an annotated type, return that annotated type.
+     * TODO: currently only used by Pretty. Describe behavior better.
+     */
     public static JCTree innermostType(JCTree type) {
-        switch (type.getTag()) {
-        case JCTree.TYPEARRAY:
-            return innermostType(((JCArrayTypeTree)type).elemtype);
-        case JCTree.WILDCARD:
-            return innermostType(((JCWildcard)type).inner);
-        default:
-            return type;
+        JCTree lastAnnotatedType = null;
+        JCTree cur = type;
+        loop: while (true) {
+            switch (cur.getTag()) {
+            case TYPEARRAY:
+                lastAnnotatedType = null;
+                cur = ((JCArrayTypeTree)cur).elemtype;
+                break;
+            case WILDCARD:
+                lastAnnotatedType = null;
+                cur = ((JCWildcard)cur).inner;
+                break;
+            case ANNOTATED_TYPE:
+                lastAnnotatedType = cur;
+                cur = ((JCAnnotatedType)cur).underlyingType;
+                break;
+            default:
+                break loop;
+            }
         }
+        if (lastAnnotatedType!=null) {
+            return lastAnnotatedType;
+        } else {
+            return cur;
+        }
+    }
+
+    private static class TypeAnnotationFinder extends TreeScanner {
+        public boolean foundTypeAnno = false;
+
+        @Override
+        public void scan(JCTree tree) {
+            if (foundTypeAnno || tree == null)
+                return;
+            super.scan(tree);
+        }
+
+        public void visitAnnotation(JCAnnotation tree) {
+            foundTypeAnno = foundTypeAnno || tree.hasTag(TYPE_ANNOTATION);
+        }
+    }
+
+    public static boolean containsTypeAnnotation(JCTree e) {
+        TypeAnnotationFinder finder = new TypeAnnotationFinder();
+        finder.scan(e);
+        return finder.foundTypeAnno;
     }
 }
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
index d8eac9a..7095a77 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -35,7 +35,8 @@ import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
+import com.sun.tools.javac.jvm.ClassReader;
 
 /** Factory class for trees.
  *
@@ -78,6 +79,8 @@ public class TreeMaker implements JCTree.Factory {
      */
     protected TreeMaker(Context context) {
         context.put(treeMakerKey, this);
+        //ClassReader needs to be instantiated before Symtab:
+        ClassReader.instance(context);
         this.pos = Position.NOPOS;
         this.toplevel = null;
         this.names = Names.instance(context);
@@ -169,10 +172,26 @@ public class TreeMaker implements JCTree.Factory {
                                List<JCExpression> thrown,
                                JCBlock body,
                                JCExpression defaultValue) {
+        return MethodDef(
+                mods, name, restype, typarams, null, params,
+                thrown, body, defaultValue);
+    }
+
+    public JCMethodDecl MethodDef(JCModifiers mods,
+                               Name name,
+                               JCExpression restype,
+                               List<JCTypeParameter> typarams,
+                               JCVariableDecl recvparam,
+                               List<JCVariableDecl> params,
+                               List<JCExpression> thrown,
+                               JCBlock body,
+                               JCExpression defaultValue)
+    {
         JCMethodDecl tree = new JCMethodDecl(mods,
                                        name,
                                        restype,
                                        typarams,
+                                       recvparam,
                                        params,
                                        thrown,
                                        body,
@@ -188,6 +207,12 @@ public class TreeMaker implements JCTree.Factory {
         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;
@@ -310,7 +335,7 @@ public class TreeMaker implements JCTree.Factory {
         return tree;
     }
 
-    public JCThrow Throw(JCTree expr) {
+    public JCThrow Throw(JCExpression expr) {
         JCThrow tree = new JCThrow(expr);
         tree.pos = pos;
         return tree;
@@ -351,6 +376,14 @@ public class TreeMaker implements JCTree.Factory {
         return tree;
     }
 
+    public JCLambda Lambda(List<JCVariableDecl> params,
+                           JCTree body)
+    {
+        JCLambda tree = new JCLambda(params, body);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCParens Parens(JCExpression expr) {
         JCParens tree = new JCParens(expr);
         tree.pos = pos;
@@ -363,19 +396,19 @@ public class TreeMaker implements JCTree.Factory {
         return tree;
     }
 
-    public JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs) {
+    public JCAssignOp Assignop(JCTree.Tag opcode, JCTree lhs, JCTree rhs) {
         JCAssignOp tree = new JCAssignOp(opcode, lhs, rhs, null);
         tree.pos = pos;
         return tree;
     }
 
-    public JCUnary Unary(int opcode, JCExpression arg) {
+    public JCUnary Unary(JCTree.Tag opcode, JCExpression arg) {
         JCUnary tree = new JCUnary(opcode, arg);
         tree.pos = pos;
         return tree;
     }
 
-    public JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs) {
+    public JCBinary Binary(JCTree.Tag opcode, JCExpression lhs, JCExpression rhs) {
         JCBinary tree = new JCBinary(opcode, lhs, rhs, null);
         tree.pos = pos;
         return tree;
@@ -405,19 +438,26 @@ public class TreeMaker implements JCTree.Factory {
         return tree;
     }
 
+    public JCMemberReference Reference(JCMemberReference.ReferenceMode mode, Name name,
+            JCExpression expr, List<JCExpression> typeargs) {
+        JCMemberReference tree = new JCMemberReference(mode, name, expr, typeargs);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCIdent Ident(Name name) {
         JCIdent tree = new JCIdent(name, null);
         tree.pos = pos;
         return tree;
     }
 
-    public JCLiteral Literal(int tag, Object value) {
+    public JCLiteral Literal(TypeTag tag, Object value) {
         JCLiteral tree = new JCLiteral(tag, value);
         tree.pos = pos;
         return tree;
     }
 
-    public JCPrimitiveTypeTree TypeIdent(int typetag) {
+    public JCPrimitiveTypeTree TypeIdent(TypeTag typetag) {
         JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag);
         tree.pos = pos;
         return tree;
@@ -441,8 +481,18 @@ public class TreeMaker implements JCTree.Factory {
         return tree;
     }
 
+    public JCTypeIntersection TypeIntersection(List<JCExpression> components) {
+        JCTypeIntersection tree = new JCTypeIntersection(components);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) {
-        JCTypeParameter tree = new JCTypeParameter(name, bounds);
+        return TypeParameter(name, bounds, List.<JCAnnotation>nil());
+    }
+
+    public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annos) {
+        JCTypeParameter tree = new JCTypeParameter(name, bounds, annos);
         tree.pos = pos;
         return tree;
     }
@@ -460,14 +510,20 @@ public class TreeMaker implements JCTree.Factory {
     }
 
     public JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args) {
-        JCAnnotation tree = new JCAnnotation(annotationType, args);
+        JCAnnotation tree = new JCAnnotation(Tag.ANNOTATION, annotationType, args);
+        tree.pos = pos;
+        return tree;
+    }
+
+    public JCAnnotation TypeAnnotation(JCTree annotationType, List<JCExpression> args) {
+        JCAnnotation tree = new JCAnnotation(Tag.TYPE_ANNOTATION, annotationType, args);
         tree.pos = pos;
         return tree;
     }
 
     public JCModifiers Modifiers(long flags, List<JCAnnotation> annotations) {
         JCModifiers tree = new JCModifiers(flags, annotations);
-        boolean noFlags = (flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0;
+        boolean noFlags = (flags & (Flags.ModifierFlags | Flags.ANNOTATION | Flags.DEFAULT)) == 0;
         tree.pos = (noFlags && annotations.isEmpty()) ? Position.NOPOS : pos;
         return tree;
     }
@@ -476,6 +532,12 @@ public class TreeMaker implements JCTree.Factory {
         return Modifiers(flags, List.<JCAnnotation>nil());
     }
 
+    public JCAnnotatedType AnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
+        JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCErroneous Erroneous() {
         return Erroneous(List.<JCTree>nil());
     }
@@ -614,10 +676,10 @@ public class TreeMaker implements JCTree.Factory {
     public JCExpression Type(Type t) {
         if (t == null) return null;
         JCExpression tp;
-        switch (t.tag) {
+        switch (t.getTag()) {
         case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT:
         case DOUBLE: case BOOLEAN: case VOID:
-            tp = TypeIdent(t.tag);
+            tp = TypeIdent(t.getTag());
             break;
         case TYPEVAR:
             tp = Ident(t.tsym);
@@ -631,7 +693,7 @@ public class TreeMaker implements JCTree.Factory {
         }
         case CLASS:
             Type outer = t.getEnclosingType();
-            JCExpression clazz = outer.tag == CLASS && t.tsym.owner.kind == TYP
+            JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP
                 ? Select(Type(outer), t.tsym)
                 : QualIdent(t.tsym);
             tp = t.getTypeArguments().isEmpty()
@@ -642,7 +704,7 @@ public class TreeMaker implements JCTree.Factory {
             tp = TypeArray(Type(types.elemtype(t)));
             break;
         case ERROR:
-            tp = TypeIdent(ERROR);
+            tp = QualIdent(t.tsym);
             break;
         default:
             throw new AssertionError("unexpected type: " + t);
@@ -665,7 +727,7 @@ public class TreeMaker implements JCTree.Factory {
     public JCVariableDecl VarDef(VarSymbol v, JCExpression init) {
         return (JCVariableDecl)
             new JCVariableDecl(
-                Modifiers(v.flags(), Annotations(v.getAnnotationMirrors())),
+                Modifiers(v.flags(), Annotations(v.getRawAttributes())),
                 v.name,
                 Type(v.type),
                 init,
@@ -727,7 +789,7 @@ public class TreeMaker implements JCTree.Factory {
             result = Literal(v.value);
         }
         public void visitClass(Attribute.Class clazz) {
-            result = ClassLiteral(clazz.type).setType(syms.classType);
+            result = ClassLiteral(clazz.classType).setType(syms.classType);
         }
         public void visitEnum(Attribute.Enum e) {
             result = QualIdent(e.value);
@@ -736,7 +798,11 @@ public class TreeMaker implements JCTree.Factory {
             result = Erroneous();
         }
         public void visitCompound(Attribute.Compound compound) {
-            result = visitCompoundInternal(compound);
+            if (compound instanceof Attribute.TypeCompound) {
+                result = visitTypeCompoundInternal((Attribute.TypeCompound) compound);
+            } else {
+                result = visitCompoundInternal(compound);
+            }
         }
         public JCAnnotation visitCompoundInternal(Attribute.Compound compound) {
             ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
@@ -747,6 +813,15 @@ public class TreeMaker implements JCTree.Factory {
             }
             return Annotation(Type(compound.type), args.toList());
         }
+        public JCAnnotation visitTypeCompoundInternal(Attribute.TypeCompound compound) {
+            ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+            for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) {
+                Pair<MethodSymbol,Attribute> pair = values.head;
+                JCExpression valueTree = translate(pair.snd);
+                args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type));
+            }
+            return TypeAnnotation(Type(compound.type), args.toList());
+        }
         public void visitArray(Attribute.Array array) {
             ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>();
             for (int i = 0; i < array.values.length; i++)
@@ -760,7 +835,11 @@ public class TreeMaker implements JCTree.Factory {
         JCAnnotation translate(Attribute.Compound a) {
             return visitCompoundInternal(a);
         }
+        JCAnnotation translate(Attribute.TypeCompound a) {
+            return visitTypeCompoundInternal(a);
+        }
     }
+
     AnnotationBuilder annotationBuilder = new AnnotationBuilder();
 
     /** Create an annotation tree from an attribute.
@@ -769,6 +848,10 @@ public class TreeMaker implements JCTree.Factory {
         return annotationBuilder.translate((Attribute.Compound)a);
     }
 
+    public JCAnnotation TypeAnnotation(Attribute a) {
+        return annotationBuilder.translate((Attribute.TypeCompound) a);
+    }
+
     /** Create a method definition from a method symbol and a method body.
      */
     public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) {
@@ -781,10 +864,11 @@ public class TreeMaker implements JCTree.Factory {
     public JCMethodDecl MethodDef(MethodSymbol m, Type mtype, JCBlock body) {
         return (JCMethodDecl)
             new JCMethodDecl(
-                Modifiers(m.flags(), Annotations(m.getAnnotationMirrors())),
+                Modifiers(m.flags(), Annotations(m.getRawAttributes())),
                 m.name,
                 Type(mtype.getReturnType()),
                 TypeParams(mtype.getTypeArguments()),
+                null, // receiver type
                 Params(mtype.getParameterTypes(), m),
                 Types(mtype.getThrownTypes()),
                 body,
@@ -803,7 +887,6 @@ public class TreeMaker implements JCTree.Factory {
      */
     public List<JCTypeParameter> TypeParams(List<Type> typarams) {
         ListBuffer<JCTypeParameter> tparams = new ListBuffer<JCTypeParameter>();
-        int i = 0;
         for (List<Type> l = typarams; l.nonEmpty(); l = l.tail)
             tparams.append(TypeParam(l.head.tsym.name, (TypeVar)l.head));
         return tparams.toList();
@@ -836,15 +919,15 @@ public class TreeMaker implements JCTree.Factory {
      *  depending on whether the method invocation expression's type is void.
      */
     public JCStatement Call(JCExpression apply) {
-        return apply.type.tag == VOID ? Exec(apply) : Return(apply);
+        return apply.type.hasTag(VOID) ? Exec(apply) : Return(apply);
     }
 
     /** Construct an assignment from a variable symbol and a right hand side.
      */
     public JCStatement Assignment(Symbol v, JCExpression rhs) {
-        if (rhs.getTag() == JCTree.ERRONEOUS) {
+        if (rhs.hasTag(JCTree.Tag.ERRONEOUS)) {
             JCErroneous err = (JCErroneous)rhs;
-            if (err.errs.head != null && err.errs.head.getTag() == JCTree.THROW)
+            if (err.errs.head != null && err.errs.head.hasTag(JCTree.Tag.THROW))
                 return (JCThrow)err.errs.head;
         }
         return Exec(Assign(Ident(v), rhs).setType(v.type));
@@ -874,7 +957,8 @@ public class TreeMaker implements JCTree.Factory {
         if (sym.name == names.empty ||
             sym.owner == null ||
             sym.owner.kind == MTH || sym.owner.kind == VAR
-            || (sym.owner.kind == PCK && sym.owner.name == names.empty)) {
+            || (sym.owner.kind == PCK && sym.owner.name == names.empty)
+            || (sym.owner.kind == NIL && sym.owner.name == names.empty)) {
             return true;
         } else if (sym.kind == TYP && toplevel != null) {
             Scope.Entry e;
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
index 1961966..626f70a 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, 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
@@ -84,6 +84,7 @@ public class TreeScanner extends Visitor {
         scan(tree.mods);
         scan(tree.restype);
         scan(tree.typarams);
+        scan(tree.recvparam);
         scan(tree.params);
         scan(tree.thrown);
         scan(tree.defaultValue);
@@ -93,6 +94,7 @@ public class TreeScanner extends Visitor {
     public void visitVarDef(JCVariableDecl tree) {
         scan(tree.mods);
         scan(tree.vartype);
+        scan(tree.nameexpr);
         scan(tree.init);
     }
 
@@ -200,18 +202,26 @@ public class TreeScanner extends Visitor {
 
     public void visitNewClass(JCNewClass tree) {
         scan(tree.encl);
-        scan(tree.clazz);
         scan(tree.typeargs);
+        scan(tree.clazz);
         scan(tree.args);
         scan(tree.def);
     }
 
     public void visitNewArray(JCNewArray tree) {
+        scan(tree.annotations);
         scan(tree.elemtype);
         scan(tree.dims);
+        for (List<JCAnnotation> annos : tree.dimAnnotations)
+            scan(annos);
         scan(tree.elems);
     }
 
+    public void visitLambda(JCLambda tree) {
+        scan(tree.body);
+        scan(tree.params);
+    }
+
     public void visitParens(JCParens tree) {
         scan(tree.expr);
     }
@@ -254,6 +264,11 @@ public class TreeScanner extends Visitor {
         scan(tree.selected);
     }
 
+    public void visitReference(JCMemberReference tree) {
+        scan(tree.expr);
+        scan(tree.typeargs);
+    }
+
     public void visitIdent(JCIdent tree) {
     }
 
@@ -276,7 +291,12 @@ public class TreeScanner extends Visitor {
         scan(tree.alternatives);
     }
 
+    public void visitTypeIntersection(JCTypeIntersection tree) {
+        scan(tree.bounds);
+    }
+
     public void visitTypeParameter(JCTypeParameter tree) {
+        scan(tree.annotations);
         scan(tree.bounds);
     }
 
@@ -300,6 +320,11 @@ public class TreeScanner extends Visitor {
         scan(tree.args);
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        scan(tree.annotations);
+        scan(tree.underlyingType);
+    }
+
     public void visitErroneous(JCErroneous tree) {
     }
 
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
index f024a28..b290ac8 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -139,6 +139,7 @@ public class TreeTranslator extends JCTree.Visitor {
         tree.mods = translate(tree.mods);
         tree.restype = translate(tree.restype);
         tree.typarams = translateTypeParams(tree.typarams);
+        tree.recvparam = translate(tree.recvparam);
         tree.params = translateVarDefs(tree.params);
         tree.thrown = translate(tree.thrown);
         tree.body = translate(tree.body);
@@ -147,6 +148,7 @@ public class TreeTranslator extends JCTree.Visitor {
 
     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;
@@ -282,7 +284,18 @@ public class TreeTranslator extends JCTree.Visitor {
         result = tree;
     }
 
+    public void visitLambda(JCLambda tree) {
+        tree.params = translate(tree.params);
+        tree.body = translate(tree.body);
+        result = tree;
+    }
+
     public void visitNewArray(JCNewArray tree) {
+        tree.annotations = translate(tree.annotations);
+        List<List<JCAnnotation>> dimAnnos = List.nil();
+        for (List<JCAnnotation> origDimAnnos : tree.dimAnnotations)
+            dimAnnos = dimAnnos.append(translate(origDimAnnos));
+        tree.dimAnnotations = dimAnnos;
         tree.elemtype = translate(tree.elemtype);
         tree.dims = translate(tree.dims);
         tree.elems = translate(tree.elems);
@@ -340,6 +353,11 @@ public class TreeTranslator extends JCTree.Visitor {
         result = tree;
     }
 
+    public void visitReference(JCMemberReference tree) {
+        tree.expr = translate(tree.expr);
+        result = tree;
+    }
+
     public void visitIdent(JCIdent tree) {
         result = tree;
     }
@@ -368,7 +386,13 @@ public class TreeTranslator extends JCTree.Visitor {
         result = tree;
     }
 
+    public void visitTypeIntersection(JCTypeIntersection tree) {
+        tree.bounds = translate(tree.bounds);
+        result = tree;
+    }
+
     public void visitTypeParameter(JCTypeParameter tree) {
+        tree.annotations = translate(tree.annotations);
         tree.bounds = translate(tree.bounds);
         result = tree;
     }
@@ -406,6 +430,12 @@ public class TreeTranslator extends JCTree.Visitor {
         result = tree;
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        tree.annotations = translate(tree.annotations);
+        tree.underlyingType = translate(tree.underlyingType);
+        result = tree;
+    }
+
     public void visitTree(JCTree tree) {
         throw new AssertionError(tree);
     }
diff --git a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
index ebac8b2..93d043d 100644
--- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -31,6 +31,7 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
@@ -43,8 +44,10 @@ import com.sun.tools.javac.code.Printer;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.CapturedType;
-
 import com.sun.tools.javac.file.BaseFileObject;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.Pretty;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
 
 /**
@@ -182,6 +185,9 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
             }
             return s;
         }
+        else if (arg instanceof JCExpression) {
+            return expr2String((JCExpression)arg);
+        }
         else if (arg instanceof Iterable<?>) {
             return formatIterable(d, (Iterable<?>)arg, l);
         }
@@ -194,6 +200,9 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
         else if (arg instanceof JavaFileObject) {
             return ((JavaFileObject)arg).getName();
         }
+        else if (arg instanceof Profile) {
+            return ((Profile)arg).name;
+        }
         else if (arg instanceof Formattable) {
             return ((Formattable)arg).toString(l, messages);
         }
@@ -201,6 +210,20 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
             return String.valueOf(arg);
         }
     }
+    //where
+            private String expr2String(JCExpression tree) {
+                switch(tree.getTag()) {
+                    case PARENS:
+                        return expr2String(((JCParens)tree).expr);
+                    case LAMBDA:
+                    case REFERENCE:
+                    case CONDEXPR:
+                        return Pretty.toSimpleString(tree);
+                    default:
+                        Assert.error("unexpected tree kind " + tree.getKind());
+                        return null;
+                }
+            }
 
     /**
      * Format an iterable argument of a given diagnostic.
@@ -467,7 +490,7 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
         /**
          * Tells whether the caret display is active or not.
          *
-         * @param caretEnabled if true the caret is enabled
+         * @return true if the caret is enabled
          */
         public boolean isCaretEnabled() {
             return caretEnabled;
@@ -492,6 +515,7 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
      * lead to infinite loops.
      */
     protected Printer printer = new Printer() {
+
         @Override
         protected String localize(Locale locale, String key, Object... args) {
             return AbstractDiagnosticFormatter.this.localize(locale, key, args);
diff --git a/src/share/classes/com/sun/tools/javac/util/AbstractLog.java b/src/share/classes/com/sun/tools/javac/util/AbstractLog.java
index 89ecab0..28440dc 100644
--- a/src/share/classes/com/sun/tools/javac/util/AbstractLog.java
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractLog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -132,7 +132,6 @@ public abstract class AbstractLog {
 
     /** Report a warning, unless suppressed by the  -nowarn option or the
      *  maximum number of warnings has been reached.
-     *  @param pos    The source position at which to report the warning.
      *  @param key    The key for the localized warning message.
      *  @param args   Fields of the warning message.
      */
diff --git a/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java b/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java
new file mode 100644
index 0000000..67a0236
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java
@@ -0,0 +1,88 @@
+/*
+ * 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
+ * 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.lang.reflect.Array;
+
+/** <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 ArrayUtils {
+
+    private static int calculateNewLength(int currentLength, int maxIndex) {
+        while (currentLength < maxIndex + 1)
+            currentLength = currentLength * 2;
+        return currentLength;
+    }
+
+    public static <T> T[] ensureCapacity(T[] array, int maxIndex) {
+        if (maxIndex < array.length) {
+            return array;
+        } else {
+            int newLength = calculateNewLength(array.length, maxIndex);
+            @SuppressWarnings("unchecked")
+            T[] result = (T[]) Array.newInstance(array.getClass().getComponentType(), newLength);
+            System.arraycopy(array, 0, result, 0, array.length);
+            return result;
+        }
+    }
+
+    public static byte[] ensureCapacity(byte[] array, int maxIndex) {
+        if (maxIndex < array.length) {
+            return array;
+        } else {
+            int newLength = calculateNewLength(array.length, maxIndex);
+            byte[] result = new byte[newLength];
+            System.arraycopy(array, 0, result, 0, array.length);
+            return result;
+        }
+    }
+
+    public static char[] ensureCapacity(char[] array, int maxIndex) {
+        if (maxIndex < array.length) {
+            return array;
+        } else {
+            int newLength = calculateNewLength(array.length, maxIndex);
+            char[] result = new char[newLength];
+            System.arraycopy(array, 0, result, 0, array.length);
+            return result;
+        }
+    }
+
+    public static int[] ensureCapacity(int[] array, int maxIndex) {
+        if (maxIndex < array.length) {
+            return array;
+        } else {
+            int newLength = calculateNewLength(array.length, maxIndex);
+            int[] result = new int[newLength];
+            System.arraycopy(array, 0, result, 0, array.length);
+            return result;
+        }
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java b/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
index c9d7d8b..a1df37f 100644
--- a/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
+++ b/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, 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
@@ -25,11 +25,6 @@
 
 package com.sun.tools.javac.util;
 
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.main.JavacOption;
-import com.sun.tools.javac.main.OptionName;
-import com.sun.tools.javac.main.RecognizedOptions;
-import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
 import java.io.IOException;
@@ -51,9 +46,19 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileObject.Kind;
 
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.file.FSInfo;
+import com.sun.tools.javac.file.Locations;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+
 /**
  * Utility methods for building a filemanager.
  * There are no references here to file-system specific objects such as
@@ -63,15 +68,21 @@ public abstract class BaseFileManager {
     protected BaseFileManager(Charset charset) {
         this.charset = charset;
         byteBufferCache = new ByteBufferCache();
+        locations = createLocations();
     }
 
     /**
      * Set the context for JavacPathFileManager.
      */
-    protected void setContext(Context context) {
+    public void setContext(Context context) {
         log = Log.instance(context);
         options = Options.instance(context);
         classLoaderClass = options.get("procloader");
+        locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
+    }
+
+    protected Locations createLocations() {
+        return new Locations();
     }
 
     /**
@@ -88,8 +99,10 @@ public abstract class BaseFileManager {
 
     protected String classLoaderClass;
 
+    protected Locations locations;
+
     protected Source getSource() {
-        String sourceName = options.get(OptionName.SOURCE);
+        String sourceName = options.get(Option.SOURCE);
         Source source = null;
         if (sourceName != null)
             source = Source.lookup(sourceName);
@@ -99,9 +112,8 @@ public abstract class BaseFileManager {
     protected ClassLoader getClassLoader(URL[] urls) {
         ClassLoader thisClassLoader = getClass().getClassLoader();
 
-        // Bug: 6558476
-        // Ideally, ClassLoader should be Closeable, but before JDK7 it is not.
-        // On older versions, try the following, to get a closeable classloader.
+        // Allow the following to specify a closeable classloader
+        // other than URLClassLoader.
 
         // 1: Allow client to specify the class to use via hidden option
         if (classLoaderClass != null) {
@@ -115,33 +127,36 @@ public abstract class BaseFileManager {
                 // ignore errors loading user-provided class loader, fall through
             }
         }
-
-        // 2: If URLClassLoader implements Closeable, use that.
-        if (Closeable.class.isAssignableFrom(URLClassLoader.class))
-            return new URLClassLoader(urls, thisClassLoader);
-
-        // 3: Try using private reflection-based CloseableURLClassLoader
-        try {
-            return new CloseableURLClassLoader(urls, thisClassLoader);
-        } catch (Throwable t) {
-            // ignore errors loading workaround class loader, fall through
-        }
-
-        // 4: If all else fails, use plain old standard URLClassLoader
         return new URLClassLoader(urls, thisClassLoader);
     }
 
     // <editor-fold defaultstate="collapsed" desc="Option handling">
     public boolean handleOption(String current, Iterator<String> remaining) {
-        for (JavacOption o: javacFileManagerOptions) {
+        OptionHelper helper = new GrumpyHelper(log) {
+            @Override
+            public String get(Option option) {
+                return options.get(option.getText());
+            }
+
+            @Override
+            public void put(String name, String value) {
+                options.put(name, value);
+            }
+
+            @Override
+            public void remove(String name) {
+                options.remove(name);
+            }
+        };
+        for (Option o: javacFileManagerOptions) {
             if (o.matches(current))  {
                 if (o.hasArg()) {
                     if (remaining.hasNext()) {
-                        if (!o.process(options, current, remaining.next()))
+                        if (!o.process(helper, current, remaining.next()))
                             return true;
                     }
                 } else {
-                    if (!o.process(options, current))
+                    if (!o.process(helper, current))
                         return true;
                 }
                 // operand missing, or process returned false
@@ -152,12 +167,11 @@ public abstract class BaseFileManager {
         return false;
     }
     // where
-        private static JavacOption[] javacFileManagerOptions =
-            RecognizedOptions.getJavacFileManagerOptions(
-            new RecognizedOptions.GrumpyHelper());
+        private static final Set<Option> javacFileManagerOptions =
+            Option.getJavacFileManagerOptions();
 
     public int isSupportedOption(String option) {
-        for (JavacOption o : javacFileManagerOptions) {
+        for (Option o : javacFileManagerOptions) {
             if (o.matches(option))
                 return o.hasArg() ? 1 : 0;
         }
@@ -179,7 +193,7 @@ public abstract class BaseFileManager {
     }
 
     public String getEncodingName() {
-        String encName = options.get(OptionName.ENCODING);
+        String encName = options.get(Option.ENCODING);
         if (encName == null)
             return getDefaultEncodingName();
         else
diff --git a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
index cec4b95..7b12009 100644
--- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
+++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
     /**
      * Create a basic formatter based on the supplied options.
      *
-     * @param opts list of command-line options
+     * @param options list of command-line options
      * @param msgs JavacMessages object used for i18n
      */
     public BasicDiagnosticFormatter(Options options, JavacMessages msgs) {
@@ -329,7 +329,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
          * Set the indentation level for various element of a given diagnostic -
          * this might lead to more readable diagnostics
          *
-         * @param indentationKind kind of indentation to be set
+         * @param diagPart
          * @param nSpaces amount of spaces for the specified diagnostic part
          */
         public void setIndentation(DiagnosticPart diagPart, int nSpaces) {
@@ -384,7 +384,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
         /**
          * Get a metachar string for a specific format
          *
-         * @param sourcePos a positioning value for source line
+         * @param kind the format kind for which to get the metachar string
          */
         public String getFormat(BasicFormatKind kind) {
             return availableFormats.get(kind);
diff --git a/src/share/classes/com/sun/tools/javac/util/Bits.java b/src/share/classes/com/sun/tools/javac/util/Bits.java
index 2fe9ea0..272bf0f 100644
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java
+++ b/src/share/classes/com/sun/tools/javac/util/Bits.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -25,6 +25,10 @@
 
 package com.sun.tools.javac.util;
 
+import java.util.Arrays;
+
+import static com.sun.tools.javac.util.Bits.BitsOpKind.*;
+
 /** A class for extensible, mutable bit sets.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -34,134 +38,296 @@ package com.sun.tools.javac.util;
  */
 public class Bits {
 
+    public enum BitsOpKind {
+        INIT,
+        CLEAR,
+        INCL_BIT,
+        EXCL_BIT,
+        ASSIGN,
+        AND_SET,
+        OR_SET,
+        DIFF_SET,
+        XOR_SET,
+        INCL_RANGE,
+        EXCL_RANGE,
+    }
+
+    //       ____________      reset    _________
+    //      /  UNKNOWN   \   <-------- / UNINIT  \
+    //      \____________/       |     \_________/
+    //            |              |          |
+    //            |assign        |          | any
+    //            |        ___________      |
+    //            ------> /  NORMAL   \ <----
+    //                    \___________/     |
+    //                            |         |
+    //                            |         |
+    //                            -----------
+    //                               any
+    private enum BitsState {
+        /*  A Bits instance is in UNKNOWN state if it has been explicitly reset.
+         *  It is possible to get to this state from any other by calling the
+         *  reset method. An instance in the UNKNOWN state can pass to the
+         *  NORMAL state after being assigned another Bits instance.
+         */
+        UNKNOWN,
+        /*  A Bits instance is in UNINIT when it is created with the default
+         *  constructor but it isn't explicitly reset. The main objective of this
+         *  internal state is to save some memory.
+         */
+        UNINIT,
+        /*  The normal state is reached after creating a Bits instance from an
+         *  existing one or after applying any operation to an instance on UNINIT
+         *  or NORMAL state. From this state a bits instance can pass to the
+         *  UNKNOWN state by calling the reset method.
+         */
+        NORMAL;
+
+        static BitsState getState(int[] someBits, boolean reset) {
+            if (reset) {
+                return UNKNOWN;
+            } else {
+                if (someBits != unassignedBits) {
+                    return NORMAL;
+                } else {
+                    return UNINIT;
+                }
+            }
+        }
+
+    }
 
     private final static int wordlen = 32;
     private final static int wordshift = 5;
     private final static int wordmask = wordlen - 1;
 
-    private int[] bits;
+    public int[] bits = null;
+    // This field will store last version of bits after every change.
+    public int[] oldBits = null;
+
+    public BitsOpKind lastOperation = null;
+
+    private static final int[] unassignedBits = new int[0];
+
+    private BitsState currentState;
 
     /** Construct an initially empty set.
      */
     public Bits() {
-        this(new int[1]);
+        this(false);
+    }
+
+    public Bits(Bits someBits) {
+        this(someBits.dup().bits, BitsState.getState(someBits.bits, false));
+    }
+
+    public Bits(boolean reset) {
+        this(unassignedBits, BitsState.getState(unassignedBits, reset));
     }
 
     /** Construct a set consisting initially of given bit vector.
      */
-    public Bits(int[] bits) {
+    private Bits(int[] bits, BitsState initState) {
         this.bits = bits;
+        this.currentState = initState;
+        switch (initState) {
+            case UNKNOWN:
+                reset(); //this will also set current state;
+                break;
+            case NORMAL:
+                Assert.check(bits != unassignedBits);
+                lastOperation = INIT;
+                break;
+        }
     }
 
-    /** Construct a set consisting initially of given range.
+    /** This method will be called after any operation that causes a change to
+     *  the bits. Subclasses can thus override it in order to extract information
+     *  from the changes produced to the bits by the given operation.
      */
-    public Bits(int start, int limit) {
-        this();
-        inclRange(start, limit);
-    }
+    public void changed() {}
 
     private void sizeTo(int len) {
         if (bits.length < len) {
-            int[] newbits = new int[len];
-            System.arraycopy(bits, 0, newbits, 0, bits.length);
-            bits = newbits;
+            bits = Arrays.copyOf(bits, len);
         }
     }
 
     /** This set = {}.
      */
     public void clear() {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = CLEAR;
         for (int i = 0; i < bits.length; i++) bits[i] = 0;
+        changed();
+        currentState = BitsState.NORMAL;
+    }
+
+    public void reset() {
+        bits = null;
+        oldBits = null;
+        currentState = BitsState.UNKNOWN;
+    }
+
+    public boolean isReset() {
+        return currentState == BitsState.UNKNOWN;
+    }
+
+    public Bits assign(Bits someBits) {
+        lastOperation = ASSIGN;
+        oldBits = bits;
+        bits = someBits.dup().bits;
+        changed();
+        currentState = BitsState.NORMAL;
+        return this;
     }
 
     /** Return a copy of this set.
      */
-    public Bits dup() {
-        int[] newbits = new int[bits.length];
-        System.arraycopy(bits, 0, newbits, 0, bits.length);
-        return new Bits(newbits);
+    private Bits dup() {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        Bits tmp = new Bits();
+        if (currentState != BitsState.NORMAL) {
+            tmp.bits = bits;
+        } else {
+            tmp.bits = new int[bits.length];
+            System.arraycopy(bits, 0, tmp.bits, 0, bits.length);
+        }
+        currentState = BitsState.NORMAL;
+        return tmp;
     }
 
     /** Include x in this set.
      */
     public void incl(int x) {
+        Assert.check(currentState != BitsState.UNKNOWN);
         Assert.check(x >= 0);
+        oldBits = bits;
+        lastOperation = INCL_BIT;
         sizeTo((x >>> wordshift) + 1);
         bits[x >>> wordshift] = bits[x >>> wordshift] |
             (1 << (x & wordmask));
+        changed();
+        currentState = BitsState.NORMAL;
     }
 
 
     /** Include [start..limit) in this set.
      */
     public void inclRange(int start, int limit) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = INCL_RANGE;
         sizeTo((limit >>> wordshift) + 1);
-        for (int x = start; x < limit; x++)
+        for (int x = start; x < limit; x++) {
             bits[x >>> wordshift] = bits[x >>> wordshift] |
                 (1 << (x & wordmask));
+        }
+        changed();
+        currentState = BitsState.NORMAL;
     }
 
     /** Exclude [start...end] from this set.
      */
     public void excludeFrom(int start) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = EXCL_RANGE;
         Bits temp = new Bits();
         temp.sizeTo(bits.length);
         temp.inclRange(0, start);
-        andSet(temp);
+        internalAndSet(temp);
+        changed();
+        currentState = BitsState.NORMAL;
     }
 
     /** Exclude x from this set.
      */
     public void excl(int x) {
+        Assert.check(currentState != BitsState.UNKNOWN);
         Assert.check(x >= 0);
+        oldBits = bits;
+        lastOperation = EXCL_BIT;
         sizeTo((x >>> wordshift) + 1);
         bits[x >>> wordshift] = bits[x >>> wordshift] &
             ~(1 << (x & wordmask));
+        changed();
+        currentState = BitsState.NORMAL;
     }
 
     /** Is x an element of this set?
      */
     public boolean isMember(int x) {
+        Assert.check(currentState != BitsState.UNKNOWN);
         return
             0 <= x && x < (bits.length << wordshift) &&
             (bits[x >>> wordshift] & (1 << (x & wordmask))) != 0;
     }
 
-    /** this set = this set & xs.
+    /** {@literal this set = this set & xs}.
      */
     public Bits andSet(Bits xs) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = AND_SET;
+        internalAndSet(xs);
+        changed();
+        currentState = BitsState.NORMAL;
+        return this;
+    }
+
+    private void internalAndSet(Bits xs) {
+        Assert.check(currentState != BitsState.UNKNOWN);
         sizeTo(xs.bits.length);
-        for (int i = 0; i < xs.bits.length; i++)
+        for (int i = 0; i < xs.bits.length; i++) {
             bits[i] = bits[i] & xs.bits[i];
-        return this;
+        }
     }
 
     /** this set = this set | xs.
      */
     public Bits orSet(Bits xs) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = OR_SET;
         sizeTo(xs.bits.length);
-        for (int i = 0; i < xs.bits.length; i++)
+        for (int i = 0; i < xs.bits.length; i++) {
             bits[i] = bits[i] | xs.bits[i];
+        }
+        changed();
+        currentState = BitsState.NORMAL;
         return this;
     }
 
     /** this set = this set \ xs.
      */
     public Bits diffSet(Bits xs) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = DIFF_SET;
         for (int i = 0; i < bits.length; i++) {
             if (i < xs.bits.length) {
                 bits[i] = bits[i] & ~xs.bits[i];
             }
         }
+        changed();
+        currentState = BitsState.NORMAL;
         return this;
     }
 
     /** this set = this set ^ xs.
      */
     public Bits xorSet(Bits xs) {
+        Assert.check(currentState != BitsState.UNKNOWN);
+        oldBits = bits;
+        lastOperation = XOR_SET;
         sizeTo(xs.bits.length);
-        for (int i = 0; i < xs.bits.length; i++)
+        for (int i = 0; i < xs.bits.length; i++) {
             bits[i] = bits[i] ^ xs.bits[i];
+        }
+        changed();
+        currentState = BitsState.NORMAL;
         return this;
     }
 
@@ -179,14 +345,15 @@ public class Bits {
         return n - (x&1);
     }
 
-    /** Return the index of the least bit position >= x that is set.
+    /** Return the index of the least bit position ≥ x that is set.
      *  If none are set, returns -1.  This provides a nice way to iterate
      *  over the members of a bit set:
-     *  <pre>
+     *  <pre>{@code
      *  for (int i = bits.nextBit(0); i>=0; i = bits.nextBit(i+1)) ...
-     *  </pre>
+     *  }</pre>
      */
     public int nextBit(int x) {
+        Assert.check(currentState != BitsState.UNKNOWN);
         int windex = x >>> wordshift;
         if (windex >= bits.length) return -1;
         int word = bits[windex] & ~((1 << (x & wordmask))-1);
@@ -202,17 +369,20 @@ public class Bits {
     /** a string representation of this set.
      */
     public String toString() {
-        char[] digits = new char[bits.length * wordlen];
-        for (int i = 0; i < bits.length * wordlen; i++)
-            digits[i] = isMember(i) ? '1' : '0';
-        return new String(digits);
+        if (bits.length > 0) {
+            char[] digits = new char[bits.length * wordlen];
+            for (int i = 0; i < bits.length * wordlen; i++)
+                digits[i] = isMember(i) ? '1' : '0';
+            return new String(digits);
+        } else {
+            return "[]";
+        }
     }
 
     /** Test Bits.nextBit(int). */
     public static void main(String[] args) {
         java.util.Random r = new java.util.Random();
         Bits bits = new Bits();
-        int dupCount = 0;
         for (int i=0; i<125; i++) {
             int k;
             do {
diff --git a/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java b/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java
index 509abac..65a8c36 100644
--- a/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java
+++ b/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -60,16 +60,10 @@ public class ByteBuffer {
         length = 0;
     }
 
-    private void copy(int size) {
-        byte[] newelems = new byte[size];
-        System.arraycopy(elems, 0, newelems, 0, elems.length);
-        elems = newelems;
-    }
-
     /** Append byte to this buffer.
      */
     public void appendByte(int b) {
-        if (length >= elems.length) copy(elems.length * 2);
+        elems = ArrayUtils.ensureCapacity(elems, length);
         elems[length++] = (byte)b;
     }
 
@@ -77,7 +71,7 @@ public class ByteBuffer {
      *  starting at given `start' offset.
      */
     public void appendBytes(byte[] bs, int start, int len) {
-        while (length + len > elems.length) copy(elems.length * 2);
+        elems = ArrayUtils.ensureCapacity(elems, length + len);
         System.arraycopy(bs, start, elems, length, len);
         length += len;
     }
@@ -91,7 +85,7 @@ public class ByteBuffer {
     /** Append a character as a two byte number.
      */
     public void appendChar(int x) {
-        while (length + 1 >= elems.length) copy(elems.length * 2);
+        elems = ArrayUtils.ensureCapacity(elems, length + 1);
         elems[length  ] = (byte)((x >>  8) & 0xFF);
         elems[length+1] = (byte)((x      ) & 0xFF);
         length = length + 2;
@@ -100,7 +94,7 @@ public class ByteBuffer {
     /** Append an integer as a four byte number.
      */
     public void appendInt(int x) {
-        while (length + 3 >= elems.length) copy(elems.length * 2);
+        elems = ArrayUtils.ensureCapacity(elems, length + 3);
         elems[length  ] = (byte)((x >> 24) & 0xFF);
         elems[length+1] = (byte)((x >> 16) & 0xFF);
         elems[length+2] = (byte)((x >>  8) & 0xFF);
diff --git a/src/share/classes/com/sun/tools/javac/util/CloseableURLClassLoader.java b/src/share/classes/com/sun/tools/javac/util/CloseableURLClassLoader.java
deleted file mode 100644
index 9072036..0000000
--- a/src/share/classes/com/sun/tools/javac/util/CloseableURLClassLoader.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2007, 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.Closeable;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.jar.JarFile;
-
-/**
- * A URLClassLoader that also implements Closeable.
- * Reflection is used to access internal data structures in the URLClassLoader,
- * since no public API exists for this purpose. Therefore this code is somewhat
- * fragile. Caveat emptor.
- * @throws Error if the internal data structures are not as expected.
- *
- *  <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 CloseableURLClassLoader
-        extends URLClassLoader implements Closeable {
-    public CloseableURLClassLoader(URL[] urls, ClassLoader parent) throws Error {
-        super(urls, parent);
-        try {
-            getLoaders(); //proactive check that URLClassLoader is as expected
-        } catch (Throwable t) {
-            throw new Error("cannot create CloseableURLClassLoader", t);
-        }
-    }
-
-    /**
-     * Close any jar files that may have been opened by the class loader.
-     * Reflection is used to access the jar files in the URLClassLoader's
-     * internal data structures.
-     * @throws java.io.IOException if the jar files cannot be found for any
-     * reson, or if closing the jar file itself causes an IOException.
-     */
-    @Override
-    public void close() throws IOException {
-        try {
-            for (Object l: getLoaders()) {
-                if (l.getClass().getName().equals("sun.misc.URLClassPath$JarLoader")) {
-                    Field jarField = l.getClass().getDeclaredField("jar");
-                    JarFile jar = (JarFile) getField(l, jarField);
-                    if (jar != null) {
-                        //System.err.println("CloseableURLClassLoader: closing " + jar);
-                        jar.close();
-                    }
-                }
-            }
-        } catch (Throwable t) {
-            IOException e = new IOException("cannot close class loader");
-            e.initCause(t);
-            throw e;
-        }
-    }
-
-    private ArrayList<?> getLoaders()
-            throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException
-    {
-        Field ucpField = URLClassLoader.class.getDeclaredField("ucp");
-        Object urlClassPath = getField(this, ucpField);
-        if (urlClassPath == null)
-            throw new AssertionError("urlClassPath not set in URLClassLoader");
-        Field loadersField = urlClassPath.getClass().getDeclaredField("loaders");
-        return (ArrayList<?>) getField(urlClassPath, loadersField);
-    }
-
-    private Object getField(Object o, Field f)
-            throws IllegalArgumentException, IllegalAccessException {
-        boolean prev = f.isAccessible();
-        try {
-            f.setAccessible(true);
-            return f.get(o);
-        } finally {
-            f.setAccessible(prev);
-        }
-    }
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/util/Constants.java b/src/share/classes/com/sun/tools/javac/util/Constants.java
index 36a473d..30753d7 100644
--- a/src/share/classes/com/sun/tools/javac/util/Constants.java
+++ b/src/share/classes/com/sun/tools/javac/util/Constants.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,6 @@ package com.sun.tools.javac.util;
 
 import com.sun.tools.javac.code.Type;
 
-import static com.sun.tools.javac.code.TypeTags.*;
-
 /**
  * Utilities for operating on constant values.
  *
@@ -48,7 +46,7 @@ public class Constants {
     public static Object decode(Object value, Type type) {
         if (value instanceof Integer) {
             int i = (Integer) value;
-            switch (type.tag) {
+            switch (type.getTag()) {
             case BOOLEAN:  return i != 0;
             case CHAR:     return (char) i;
             case BYTE:     return (byte) i;
@@ -64,7 +62,7 @@ public class Constants {
      */
     public static String format(Object value, Type type) {
         value = decode(value, type);
-        switch (type.tag) {
+        switch (type.getTag()) {
         case BYTE:      return formatByte((Byte) value);
         case LONG:      return formatLong((Long) value);
         case FLOAT:     return formatFloat((Float) value);
diff --git a/src/share/classes/com/sun/tools/javac/util/Context.java b/src/share/classes/com/sun/tools/javac/util/Context.java
index 8a993d1..9302663 100644
--- a/src/share/classes/com/sun/tools/javac/util/Context.java
+++ b/src/share/classes/com/sun/tools/javac/util/Context.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -44,7 +44,7 @@ import java.util.*;
  * instance method that is overridden in extended components.  A base
  * phase supporting extension would look something like this:
  *
- * <p><pre>
+ * <p><pre>{@code
  * public class Phase {
  *     protected static final Context.Key<Phase> phaseKey =
  *         new Context.Key<Phase>();
@@ -62,7 +62,7 @@ import java.util.*;
  *         // other intitialization follows...
  *     }
  * }
- * </pre>
+ * }</pre>
  *
  * <p>In the compiler, we simply use Phase.instance(context) to get
  * the reference to the phase.  But in extensions of the compiler, we
@@ -70,7 +70,7 @@ import java.util.*;
  * and this must be done before any reference to the phase is accessed
  * using Phase.instance().  An extended phase might be declared thus:
  *
- * <p><pre>
+ * <p><pre>{@code
  * public class NewPhase extends Phase {
  *     protected NewPhase(Context context) {
  *         super(context);
@@ -83,7 +83,7 @@ import java.util.*;
  *         });
  *     }
  * }
- * </pre>
+ * }</pre>
  *
  * <p>And is registered early in the extended compiler like this
  *
@@ -115,7 +115,10 @@ public class Context {
      * The underlying map storing the data.
      * We maintain the invariant that this table contains only
      * mappings of the form
-     * Key<T> -> T or Key<T> -> Factory<T> */
+     * {@literal Key<T> -> T }
+     * or
+     * {@literal Key<T> -> Factory<T> }
+     */
     private Map<Key<?>,Object> ht = new HashMap<Key<?>,Object>();
 
     /** Set the factory for the key in this context. */
diff --git a/src/share/classes/com/sun/tools/javac/util/Convert.java b/src/share/classes/com/sun/tools/javac/util/Convert.java
index 0c9f254..c4725f3 100644
--- a/src/share/classes/com/sun/tools/javac/util/Convert.java
+++ b/src/share/classes/com/sun/tools/javac/util/Convert.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, 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
@@ -28,6 +28,24 @@ package com.sun.tools.javac.util;
 /** Utility class for static conversion methods between numbers
  *  and strings in various formats.
  *
+ *  <p>Note regarding UTF-8.
+ *  The JVMS defines its own version of the UTF-8 format so that it
+ *  contains no zero bytes (modified UTF-8). This is not actually the same
+ *  as Charset.forName("UTF-8").
+ *
+ *  <p>
+ *  See also:
+ *  <ul>
+ *  <li><a href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.7">
+ *    JVMS 4.4.7 </a></li>
+ *  <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html#modified-utf-8">
+      java.io.DataInput: Modified UTF-8 </a></li>
+    <li><a href="https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">
+      Modified UTF-8 (wikipedia) </a></li>
+ *  </ul>
+ *
+ *  The methods here support modified UTF-8.
+ *
  *  <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
@@ -260,7 +278,7 @@ public class Convert {
         while (i < len) {
             char ch = s.charAt(i);
             if (ch > 255) {
-                StringBuffer buf = new StringBuffer();
+                StringBuilder buf = new StringBuilder();
                 buf.append(s.substring(0, i));
                 while (i < len) {
                     ch = s.charAt(i);
diff --git a/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java b/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java
index 502b312..a6cc105 100644
--- a/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java
+++ b/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -28,11 +28,10 @@ package com.sun.tools.javac.util;
 import java.io.IOException;
 import java.lang.ref.SoftReference;
 import java.nio.CharBuffer;
-import java.util.Map;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.EndPosTable;
 
 import static com.sun.tools.javac.util.LayoutCharacters.*;
 
@@ -128,11 +127,11 @@ public class DiagnosticSource {
         }
     }
 
-    public Map<JCTree, Integer> getEndPosTable() {
+    public EndPosTable getEndPosTable() {
         return endPosTable;
     }
 
-    public void setEndPosTable(Map<JCTree, Integer> t) {
+    public void setEndPosTable(EndPosTable t) {
         if (endPosTable != null && endPosTable != t)
             throw new IllegalStateException("endPosTable already set for : " + fileObject.toUri(), thr);
         endPosTable = t;
@@ -200,7 +199,7 @@ public class DiagnosticSource {
     /** The underlying file object. */
     protected JavaFileObject fileObject;
 
-    protected Map<JCTree, Integer> endPosTable;
+    protected EndPosTable endPosTable;
 
     /** A soft reference to the content of the file object. */
     protected SoftReference<char[]> refBuf;
diff --git a/src/share/classes/com/sun/tools/javac/util/GraphUtils.java b/src/share/classes/com/sun/tools/javac/util/GraphUtils.java
new file mode 100644
index 0000000..c15f1ec
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/util/GraphUtils.java
@@ -0,0 +1,145 @@
+/*
+ * 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
+ * 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;
+
+/** <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 GraphUtils {
+
+    /**
+     * This class is a basic abstract class for representing a node.
+     * A node is associated with a given data.
+     */
+    public static abstract class Node<D> {
+        public final D data;
+
+        public Node(D data) {
+            this.data = data;
+        }
+
+        public abstract Iterable<? extends Node<D>> getDependencies();
+
+        public abstract String printDependency(Node<D> to);
+
+        @Override
+        public String toString() {
+            return data.toString();
+        }
+    }
+
+    /**
+     * This class specialized Node, by adding elements that are required in order
+     * to perform Tarjan computation of strongly connected components.
+     */
+    public static abstract class TarjanNode<D> extends Node<D> implements Comparable<TarjanNode<D>> {
+        int index = -1;
+        int lowlink;
+        boolean active;
+
+        public TarjanNode(D data) {
+            super(data);
+        }
+
+        public abstract Iterable<? extends TarjanNode<D>> getDependencies();
+
+        public int compareTo(TarjanNode<D> o) {
+            return (index < o.index) ? -1 : (index == o.index) ? 0 : 1;
+        }
+    }
+
+    /**
+     * Tarjan's algorithm to determine strongly connected components of a
+     * directed graph in linear time. Works on TarjanNode.
+     */
+    public static <D, N extends TarjanNode<D>> List<? extends List<? extends N>> tarjan(Iterable<? extends N> nodes) {
+        ListBuffer<List<N>> cycles = ListBuffer.lb();
+        ListBuffer<N> stack = ListBuffer.lb();
+        int index = 0;
+        for (N node: nodes) {
+            if (node.index == -1) {
+                index += tarjan(node, index, stack, cycles);
+            }
+        }
+        return cycles.toList();
+    }
+
+    private static <D, N extends TarjanNode<D>> int tarjan(N v, int index, ListBuffer<N> stack, ListBuffer<List<N>> cycles) {
+        v.index = index;
+        v.lowlink = index;
+        index++;
+        stack.prepend(v);
+        v.active = true;
+        for (TarjanNode<D> nd: v.getDependencies()) {
+            @SuppressWarnings("unchecked")
+            N n = (N)nd;
+            if (n.index == -1) {
+                tarjan(n, index, stack, cycles);
+                v.lowlink = Math.min(v.lowlink, n.lowlink);
+            } else if (stack.contains(n)) {
+                v.lowlink = Math.min(v.lowlink, n.index);
+            }
+        }
+        if (v.lowlink == v.index) {
+            N n;
+            ListBuffer<N> cycle = ListBuffer.lb();
+            do {
+                n = stack.remove();
+                n.active = false;
+                cycle.add(n);
+            } while (n != v);
+            cycles.add(cycle.toList());
+        }
+        return index;
+    }
+
+    /**
+     * Debugging: dot representation of a set of connected nodes. The resulting
+     * dot representation will use {@code Node.toString} to display node labels
+     * and {@code Node.printDependency} to display edge labels. The resulting
+     * representation is also customizable with a graph name and a header.
+     */
+    public static <D> String toDot(Iterable<? extends TarjanNode<D>> nodes, String name, String header) {
+        StringBuilder buf = new StringBuilder();
+        buf.append(String.format("digraph %s {\n", name));
+        buf.append(String.format("label = \"%s\";\n", header));
+        //dump nodes
+        for (TarjanNode<D> n : nodes) {
+            buf.append(String.format("%s [label = \"%s\"];\n", n.hashCode(), n.toString()));
+        }
+        //dump arcs
+        for (TarjanNode<D> from : nodes) {
+            for (TarjanNode<D> to : from.getDependencies()) {
+                buf.append(String.format("%s -> %s [label = \" %s \"];\n",
+                        from.hashCode(), to.hashCode(), from.printDependency(to)));
+            }
+        }
+        buf.append("}\n");
+        return buf.toString();
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
index 7fed93f..39c2337 100644
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
@@ -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
@@ -27,7 +27,6 @@ package com.sun.tools.javac.util;
 
 import java.util.EnumSet;
 import java.util.Locale;
-import java.util.Map;
 import java.util.Set;
 
 import javax.tools.Diagnostic;
@@ -35,6 +34,7 @@ import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.code.Lint.LintCategory;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
@@ -70,7 +70,16 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
             this(JavacMessages.instance(context), "compiler");
             context.put(diagnosticFactoryKey, this);
 
-            Options options = Options.instance(context);
+            final Options options = Options.instance(context);
+            initOptions(options);
+            options.addListener(new Runnable() {
+               public void run() {
+                   initOptions(options);
+               }
+            });
+        }
+
+        private void initOptions(Options options) {
             if (options.isSet("onlySyntaxErrorsUnrecoverable"))
                 defaultErrorFlags.add(DiagnosticFlag.RECOVERABLE);
         }
@@ -204,7 +213,6 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
          * Create a new diagnostic of the given kind, which is not mandatory and which has
          * no lint category.
          *  @param kind        The diagnostic kind
-         *  @param ls          The lint category, if applicable, or null
          *  @param source      The source of the compilation unit, if any, in which to report the message.
          *  @param pos         The source position at which to report the message.
          *  @param key         The key for the localized message.
@@ -219,7 +227,7 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
          * Create a new diagnostic of the given kind.
          *  @param kind        The diagnostic kind
          *  @param lc          The lint category, if applicable, or null
-         *  @param isMandatory is diagnostic mandatory?
+         *  @param flags       The set of flags for the diagnostic
          *  @param source      The source of the compilation unit, if any, in which to report the message.
          *  @param pos         The source position at which to report the message.
          *  @param key         The key for the localized message.
@@ -304,7 +312,7 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
         /** If there is a tree node, and if endPositions are available, get
          *  the end position of the tree node. Otherwise, just returns the
          *  same as getPreferredPosition(). */
-        int getEndPosition(Map<JCTree, Integer> endPosTable);
+        int getEndPosition(EndPosTable endPosTable);
     }
 
     /**
@@ -312,8 +320,12 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
      * tree node, as the location for a diagnostic. Used for scanner and parser
      * diagnostics. */
     public static class SimpleDiagnosticPosition implements DiagnosticPosition {
+        public SimpleDiagnosticPosition(int startPos, int endPos) {
+            this.startPos = startPos;
+            this.endPos = endPos;
+        }
         public SimpleDiagnosticPosition(int pos) {
-            this.pos = pos;
+            this(pos, pos);
         }
 
         public JCTree getTree() {
@@ -321,25 +333,28 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
         }
 
         public int getStartPosition() {
-            return pos;
+            return startPos;
         }
 
         public int getPreferredPosition() {
-            return pos;
+            return startPos;
         }
 
-        public int getEndPosition(Map<JCTree, Integer> endPosTable) {
-            return pos;
+        public int getEndPosition(EndPosTable endPosTable) {
+            return endPos;
         }
 
-        private final int pos;
-        }
+        private final int startPos;
+        private final int endPos;
+    }
 
     public enum DiagnosticFlag {
         MANDATORY,
         RESOLVE_ERROR,
         SYNTAX,
-        RECOVERABLE
+        RECOVERABLE,
+        NON_DEFERRABLE,
+        COMPRESSED
     }
 
     private final DiagnosticType type;
@@ -354,7 +369,7 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
 
     /**
      * Create a diagnostic object.
-     * @param fomatter the formatter to use for the diagnostic
+     * @param formatter the formatter to use for the diagnostic
      * @param dt the type of diagnostic
      * @param lc     the lint category for the diagnostic
      * @param source the name of the source file, or null if none.
@@ -390,6 +405,10 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
             column = source.getColumnNumber(n, true);
         }
     }
+    
+    protected JCDiagnostic(JCDiagnostic original) {
+        this(original.defaultFormatter, original.type, original.lintCategory, original.flags, original.source, original.position, original.key, original.args);
+    }
 
     /**
      * Get the type of this diagnostic.
@@ -480,6 +499,10 @@ public class JCDiagnostic implements Diagnostic<JavaFileObject> {
         return position == null ? null : position.getTree();
     }
 
+    public DiagnosticPosition getDiagnosticPosition() {
+        return position;
+    }
+
     /**
      * Get the line number within the source referred to by this diagnostic.
      * @return  the line number within the source referred to by this diagnostic
diff --git a/src/share/classes/com/sun/tools/javac/util/JavacMessages.java b/src/share/classes/com/sun/tools/javac/util/JavacMessages.java
index dbd6993..77d2ac8 100644
--- a/src/share/classes/com/sun/tools/javac/util/JavacMessages.java
+++ b/src/share/classes/com/sun/tools/javac/util/JavacMessages.java
@@ -82,14 +82,14 @@ public class JavacMessages implements Messages {
     }
 
     /** Creates a JavacMessages object.
-     * @param bundleName the name to identify the resource buundle of localized messages.
+     * @param bundleName the name to identify the resource bundle of localized messages.
      */
     public JavacMessages(String bundleName) throws MissingResourceException {
         this(bundleName, null);
     }
 
     /** Creates a JavacMessages object.
-     * @param bundleName the name to identify the resource buundle of localized messages.
+     * @param bundleName the name to identify the resource bundle of localized messages.
      */
     public JavacMessages(String bundleName, Locale locale) throws MissingResourceException {
         bundleNames = List.nil();
diff --git a/src/share/classes/com/sun/tools/javac/util/List.java b/src/share/classes/com/sun/tools/javac/util/List.java
index baad763..611798d 100644
--- a/src/share/classes/com/sun/tools/javac/util/List.java
+++ b/src/share/classes/com/sun/tools/javac/util/List.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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 @@ import java.util.NoSuchElementException;
 /** 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
@@ -74,7 +74,7 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
         return (List<A>)EMPTY_LIST;
     }
 
-    private static List<?> EMPTY_LIST = new List<Object>(null,null) {
+    private static final List<?> EMPTY_LIST = new List<Object>(null,null) {
         public List<Object> setTail(List<Object> tail) {
             throw new UnsupportedOperationException();
         }
@@ -83,6 +83,39 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
         }
     };
 
+    /** Returns the list obtained from 'l' after removing all elements 'elem'
+     */
+    public static <A> List<A> filter(List<A> l, A elem) {
+        Assert.checkNonNull(elem);
+        List<A> res = List.nil();
+        for (A a : l) {
+            if (a != null && !a.equals(elem)) {
+                res = res.prepend(a);
+            }
+        }
+        return res.reverse();
+    }
+
+    public List<A> intersect(List<A> that) {
+        ListBuffer<A> buf = ListBuffer.lb();
+        for (A el : this) {
+            if (that.contains(el)) {
+                buf.append(el);
+            }
+        }
+        return buf.toList();
+    }
+
+    public List<A> diff(List<A> that) {
+        ListBuffer<A> buf = ListBuffer.lb();
+        for (A el : this) {
+            if (!that.contains(el)) {
+                buf.append(el);
+            }
+        }
+        return buf.toList();
+    }
+
     /** Construct a list consisting of given element.
      */
     public static <A> List<A> of(A x1) {
@@ -120,6 +153,14 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
         return xs;
     }
 
+    public static <A> List<A> from(Iterable<? extends A> coll) {
+        ListBuffer<A> xs = ListBuffer.lb();
+        for (A a : coll) {
+            xs.append(a);
+        }
+        return xs.toList();
+    }
+
     /** Construct a list consisting of a given number of identical elements.
      *  @param len    The number of elements in the list.
      *  @param init   The value of each element.
@@ -266,7 +307,7 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
         if (isEmpty()) {
             return "";
         } else {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             buf.append(head);
             for (List<A> l = tail; l.nonEmpty(); l = l.tail) {
                 buf.append(sep);
@@ -370,7 +411,7 @@ public class List<A> extends AbstractCollection<A> implements java.util.List<A>
         return (List<T>)list;
     }
 
-    private static Iterator<?> EMPTYITERATOR = new Iterator<Object>() {
+    private static final Iterator<?> EMPTYITERATOR = new Iterator<Object>() {
             public boolean hasNext() {
                 return false;
             }
diff --git a/src/share/classes/com/sun/tools/javac/util/Log.java b/src/share/classes/com/sun/tools/javac/util/Log.java
index a9dcd9e..bf59467 100644
--- a/src/share/classes/com/sun/tools/javac/util/Log.java
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -30,19 +30,20 @@ import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
-import com.sun.tools.javac.main.OptionName;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** A class for error logs. Reports errors and warnings, and
  *  keeps track of error numbers and positions.
@@ -61,19 +62,147 @@ public class Log extends AbstractLog {
     public static final Context.Key<PrintWriter> outKey =
         new Context.Key<PrintWriter>();
 
-    //@Deprecated
-    public final PrintWriter errWriter;
+    /* TODO: Should unify this with prefix handling in JCDiagnostic.Factory. */
+    public enum PrefixKind {
+        JAVAC("javac."),
+        COMPILER_MISC("compiler.misc.");
+        PrefixKind(String v) {
+            value = v;
+        }
+        public String key(String k) {
+            return value + k;
+        }
+        final String value;
+    }
+
+    /**
+     * DiagnosticHandler's provide the initial handling for diagnostics.
+     * When a diagnostic handler is created and has been initialized, it
+     * should install itself as the current diagnostic handler. When a
+     * client has finished using a handler, the client should call
+     * {@code log.removeDiagnosticHandler();}
+     *
+     * Note that javax.tools.DiagnosticListener (if set) is called later in the
+     * diagnostic pipeline.
+     */
+    public static abstract class DiagnosticHandler {
+        /**
+         * The previously installed diagnostic handler.
+         */
+        protected DiagnosticHandler prev;
+
+        /**
+         * Install this diagnostic handler as the current one,
+         * recording the previous one.
+         */
+        protected void install(Log log) {
+            prev = log.diagnosticHandler;
+            log.diagnosticHandler = this;
+        }
+
+        /**
+         * Handle a diagnostic.
+         */
+        public abstract void report(JCDiagnostic diag);
+    }
+
+    /**
+     * A DiagnosticHandler that discards all diagnostics.
+     */
+    public static class DiscardDiagnosticHandler extends DiagnosticHandler {
+        public DiscardDiagnosticHandler(Log log) {
+            install(log);
+        }
+
+        public void report(JCDiagnostic diag) { }
+    }
+
+    /**
+     * A DiagnosticHandler that can defer some or all diagnostics,
+     * by buffering them for later examination and/or reporting.
+     * If a diagnostic is not deferred, or is subsequently reported
+     * with reportAllDiagnostics(), it will be reported to the previously
+     * active diagnostic handler.
+     */
+    public static class DeferredDiagnosticHandler extends DiagnosticHandler {
+        private Queue<JCDiagnostic> deferred = ListBuffer.lb();
+        private final Log log;
+        private final Filter<JCDiagnostic> filter;
+
+        public DeferredDiagnosticHandler(Log log) {
+            this(log, null);
+        }
+
+        public DeferredDiagnosticHandler(Log log, Filter<JCDiagnostic> filter) {
+            this.log = log;
+            this.filter = filter;
+            install(log);
+        }
+
+        public void report(JCDiagnostic diag) {
+            if (!diag.isFlagSet(JCDiagnostic.DiagnosticFlag.NON_DEFERRABLE) &&
+                (filter == null || filter.accepts(diag))) {
+                if (log.multipleErrors) {
+                    diag = new DeferredMultiDiagnostic(diag);
+                }
+                deferred.add(diag);
+            } else {
+                prev.report(diag);
+            }
+        }
+
+        public Queue<JCDiagnostic> getDiagnostics() {
+            return deferred;
+        }
+
+        /** Report all deferred diagnostics. */
+        public void reportDeferredDiagnostics() {
+            reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
+        }
+
+        /** Report selected deferred diagnostics. */
+        public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
+            JCDiagnostic d;
+            while ((d = deferred.poll()) != null) {
+                if (kinds.contains(d.getKind())) {
+                    boolean orig = log.multipleErrors;
+                    try {
+                        if (d instanceof DeferredMultiDiagnostic) {
+                            log.multipleErrors = true;
+                            d = ((DeferredMultiDiagnostic)d).original;
+                        }
+                        prev.report(d);
+                    } finally {
+                        log.multipleErrors = orig;
+                    }
+                }
+            }
+            deferred = null; // prevent accidental ongoing use
+        }
+
+        private static class DeferredMultiDiagnostic extends JCDiagnostic {
+
+            final JCDiagnostic original;
+
+            private DeferredMultiDiagnostic(JCDiagnostic original) {
+                super(original);
+                this.original = original;
+            }
+        }
+    }
+
+    public enum WriterKind { NOTICE, WARNING, ERROR };
 
-    //@Deprecated
-    public final PrintWriter warnWriter;
+    protected PrintWriter errWriter;
 
-    //@Deprecated
-    public final PrintWriter noticeWriter;
+    protected PrintWriter warnWriter;
+
+    protected PrintWriter noticeWriter;
 
     /** The maximum number of errors/warnings that are reported.
      */
-    public final int MaxErrors;
-    public final int MaxWarnings;
+    protected int MaxErrors;
+    protected int MaxWarnings;
 
     /** Switch: prompt user on each error.
      */
@@ -87,8 +216,6 @@ public class Log extends AbstractLog {
      */
     public boolean suppressNotes;
 
-    public boolean suppressErrorsAndWarnings;
-
     /** Print stack trace on errors?
      */
     public boolean dumpOnError;
@@ -114,23 +241,27 @@ public class Log extends AbstractLog {
     public Set<String> expectDiagKeys;
 
     /**
+     * Set to true if a compressed diagnostic is reported
+     */
+    public boolean compressedOutput;
+
+    /**
      * JavacMessages object used for localization.
      */
     private JavacMessages messages;
 
     /**
-     * Deferred diagnostics
+     * Handler for initial dispatch of diagnostics.
      */
-    public boolean deferDiagnostics;
-    public Queue<JCDiagnostic> deferredDiagnostics = new ListBuffer<JCDiagnostic>();
+    private DiagnosticHandler diagnosticHandler;
+
     private boolean partialReparse;
 
     private final Set<Pair<JavaFileObject, Integer>> partialReparseRecorded = new HashSet<Pair<JavaFileObject,Integer>>();
-    private final Map<JCTree, JCDiagnostic> errTrees = new HashMap<JCTree, JCDiagnostic>();
+    private final HashMap<JCTree, JCDiagnostic> errTrees = new HashMap<JCTree, JCDiagnostic>();
 
     /** Construct a log with given I/O redirections.
      */
-    @Deprecated
     protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
         super(JCDiagnostic.Factory.instance(context));
         context.put(logKey, this);
@@ -138,30 +269,44 @@ public class Log extends AbstractLog {
         this.warnWriter = warnWriter;
         this.noticeWriter = noticeWriter;
 
-        Options options = Options.instance(context);
-        this.dumpOnError = options.isSet(DOE);
-        this.promptOnError = options.isSet(PROMPT);
-        this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none");
-        this.suppressNotes = options.isSet("suppressNotes");
-        this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors());
-        this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings());
-
-        boolean rawDiagnostics = options.isSet("rawDiagnostics");
-        messages = JavacMessages.instance(context);
-        this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
-                                              new BasicDiagnosticFormatter(options, messages);
         @SuppressWarnings("unchecked") // FIXME
         DiagnosticListener<? super JavaFileObject> dl =
             context.get(DiagnosticListener.class);
         this.diagListener = dl;
 
-        String ek = options.get("expectKeys");
-        if (ek != null)
-            expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
+        diagnosticHandler = new DefaultDiagnosticHandler();
+
+        messages = JavacMessages.instance(context);
+        messages.add(Main.javacBundleName);
+
+        final Options options = Options.instance(context);
+        initOptions(options);
+        options.addListener(new Runnable() {
+            public void run() {
+                initOptions(options);
+            }
+        });
     }
     // where
-        private int getIntOption(Options options, OptionName optionName, int defaultValue) {
-            String s = options.get(optionName);
+        private void initOptions(Options options) {
+            this.dumpOnError = options.isSet(DOE);
+            this.promptOnError = options.isSet(PROMPT);
+            this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none");
+            this.suppressNotes = options.isSet("suppressNotes");
+            this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors());
+            this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings());
+
+            boolean rawDiagnostics = options.isSet("rawDiagnostics");
+            this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
+                                                  new BasicDiagnosticFormatter(options, messages);
+
+            String ek = options.get("expectKeys");
+            if (ek != null)
+                expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
+        }
+
+        private int getIntOption(Options options, Option option, int defaultValue) {
+            String s = options.get(option);
             try {
                 if (s != null) {
                     int n = Integer.parseInt(s);
@@ -187,7 +332,7 @@ public class Log extends AbstractLog {
 
     /** The default writer for diagnostics
      */
-    static final PrintWriter defaultWriter(Context context) {
+    static PrintWriter defaultWriter(Context context) {
         PrintWriter result = context.get(outKey);
         if (result == null)
             context.put(outKey, result = new PrintWriter(System.err));
@@ -232,9 +377,9 @@ public class Log extends AbstractLog {
         return diagListener != null;
     }
 
-    public void setEndPosTable(JavaFileObject name, Map<JCTree, Integer> table) {
+    public void setEndPosTable(JavaFileObject name, EndPosTable endPosTable) {
         name.getClass(); // null check
-        getSource(name).setEndPosTable(table);
+        getSource(name).setEndPosTable(endPosTable);
     }
 
     public void startPartialReparse () {
@@ -275,6 +420,54 @@ public class Log extends AbstractLog {
         this.diagFormatter = diagFormatter;
     }
 
+    public PrintWriter getWriter(WriterKind kind) {
+        switch (kind) {
+            case NOTICE:    return noticeWriter;
+            case WARNING:   return warnWriter;
+            case ERROR:     return errWriter;
+            default:        throw new IllegalArgumentException();
+        }
+    }
+
+    public void setWriter(WriterKind kind, PrintWriter pw) {
+        pw.getClass();
+        switch (kind) {
+            case NOTICE:    noticeWriter = pw;  break;
+            case WARNING:   warnWriter = pw;    break;
+            case ERROR:     errWriter = pw;     break;
+            default:        throw new IllegalArgumentException();
+        }
+    }
+
+    public void setWriters(PrintWriter pw) {
+        pw.getClass();
+        noticeWriter = warnWriter = errWriter = pw;
+    }
+
+    /**
+     * Propagate the previous log's information.
+     */
+    public void initRound(Log other) {
+        this.noticeWriter = other.noticeWriter;
+        this.warnWriter = other.warnWriter;
+        this.errWriter = other.errWriter;
+        this.sourceMap = other.sourceMap;
+        this.recorded = other.recorded;
+        this.nerrors = other.nerrors;
+        this.nwarnings = other.nwarnings;
+    }
+
+    /**
+     * Replace the specified diagnostic handler with the
+     * handler that was current at the time this handler was created.
+     * The given handler must be the currently installed handler;
+     * it must be specified explicitly for clarity and consistency checking.
+     */
+    public void popDiagnosticHandler(DiagnosticHandler h) {
+        Assert.check(diagnosticHandler == h, "Wrong diagnostic handler: " + diagnosticHandler);
+        diagnosticHandler = h.prev;
+    }
+
     /** Flush the logs
      */
     public void flush() {
@@ -283,6 +476,10 @@ public class Log extends AbstractLog {
         noticeWriter.flush();
     }
 
+    public void flush(WriterKind kind) {
+        getWriter(kind).flush();
+    }
+
     /** Returns true if an error needs to be reported for a given
      * source name and pos.
      */
@@ -312,7 +509,6 @@ public class Log extends AbstractLog {
     public void prompt() {
         if (promptOnError) {
             System.err.println(localize("resume.abort"));
-            char ch;
             try {
                 while (true) {
                     switch (System.in.read()) {
@@ -339,7 +535,7 @@ public class Log extends AbstractLog {
             return;
         int col = source.getColumnNumber(pos, false);
 
-        printLines(writer, line);
+        printRawLines(writer, line);
         for (int i = 0; i < col - 1; i++) {
             writer.print((line.charAt(i) == '\t') ? "\t" : " ");
         }
@@ -347,30 +543,54 @@ public class Log extends AbstractLog {
         writer.flush();
     }
 
+    public void printNewline() {
+        noticeWriter.println();
+    }
+
+    public void printNewline(WriterKind wk) {
+        getWriter(wk).println();
+    }
+
+    public void printLines(String key, Object... args) {
+        printRawLines(noticeWriter, localize(key, args));
+    }
+
+    public void printLines(PrefixKind pk, String key, Object... args) {
+        printRawLines(noticeWriter, localize(pk, key, args));
+    }
+
+    public void printLines(WriterKind wk, String key, Object... args) {
+        printRawLines(getWriter(wk), localize(key, args));
+    }
+
+    public void printLines(WriterKind wk, PrefixKind pk, String key, Object... args) {
+        printRawLines(getWriter(wk), localize(pk, key, args));
+    }
+
     /** Print the text of a message, translating newlines appropriately
      *  for the platform.
      */
-    public static void printLines(PrintWriter writer, String msg) {
-        int nl;
-        while ((nl = msg.indexOf('\n')) != -1) {
-            writer.println(msg.substring(0, nl));
-            msg = msg.substring(nl+1);
-        }
-        if (msg.length() != 0) writer.println(msg);
+    public void printRawLines(String msg) {
+        printRawLines(noticeWriter, msg);
     }
 
-    /** Print the text of a message to the errWriter stream,
-     *  translating newlines appropriately for the platform.
+    /** Print the text of a message, translating newlines appropriately
+     *  for the platform.
      */
-    public void printErrLines(String key, Object... args) {
-        printLines(errWriter, localize(key, args));
+    public void printRawLines(WriterKind kind, String msg) {
+        printRawLines(getWriter(kind), msg);
     }
 
-    /** Print the text of a message to the noticeWriter stream,
-     *  translating newlines appropriately for the platform.
+    /** Print the text of a message, translating newlines appropriately
+     *  for the platform.
      */
-    public void printNoteLines(String key, Object... args) {
-        printLines(noticeWriter, localize(key, args));
+    public static void printRawLines(PrintWriter writer, String msg) {
+        int nl;
+        while ((nl = msg.indexOf('\n')) != -1) {
+            writer.println(msg.substring(0, nl));
+            msg = msg.substring(nl+1);
+        }
+        if (msg.length() != 0) writer.println(msg);
     }
 
     /**
@@ -378,11 +598,11 @@ public class Log extends AbstractLog {
      * noticeWriter stream.
      */
     public void printVerbose(String key, Object... args) {
-        printLines(noticeWriter, localize("verbose." + key, args));
+        printRawLines(noticeWriter, localize("verbose." + key, args));
     }
 
     protected void directError(String key, Object... args) {
-        printErrLines(key, args);
+        printRawLines(errWriter, localize(key, args));
         errWriter.flush();
     }
 
@@ -396,69 +616,60 @@ public class Log extends AbstractLog {
         nwarnings++;
     }
 
-    /** Report all deferred diagnostics, and clear the deferDiagnostics flag. */
-    public void reportDeferredDiagnostics() {
-        reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
-    }
-
-    /** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */
-    public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
-        deferDiagnostics = false;
-        JCDiagnostic d;
-        while ((d = deferredDiagnostics.poll()) != null) {
-            if (kinds.contains(d.getKind()))
-                report(d);
-        }
-    }
+    /**
+     * Primary method to report a diagnostic.
+     * @param diagnostic
+     */
+    public void report(JCDiagnostic diagnostic) {
+        diagnosticHandler.report(diagnostic);
+     }
 
     /**
      * Common diagnostic handling.
      * The diagnostic is counted, and depending on the options and how many diagnostics have been
      * reported so far, the diagnostic may be handed off to writeDiagnostic.
      */
-    public void report(JCDiagnostic diagnostic) {
-        if (deferDiagnostics) {
-            deferredDiagnostics.add(diagnostic);
-            return;
-        }
-
-        if (expectDiagKeys != null)
-            expectDiagKeys.remove(diagnostic.getCode());
+    private class DefaultDiagnosticHandler extends DiagnosticHandler {
+        public void report(JCDiagnostic diagnostic) {
+            if (expectDiagKeys != null)
+                expectDiagKeys.remove(diagnostic.getCode());
 
-        switch (diagnostic.getType()) {
-        case FRAGMENT:
-            throw new IllegalArgumentException();
-
-        case NOTE:
-            // Print out notes only when we are permitted to report warnings
-            // Notes are only generated at the end of a compilation, so should be small
-            // in number.
-            if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) {
-                writeDiagnostic(diagnostic);
-            }
-            break;
+            switch (diagnostic.getType()) {
+            case FRAGMENT:
+                throw new IllegalArgumentException();
 
-        case WARNING:
-            if ((emitWarnings || diagnostic.isMandatory()) && !suppressErrorsAndWarnings) {
-                if (nwarnings < MaxWarnings) {
+            case NOTE:
+                // Print out notes only when we are permitted to report warnings
+                // Notes are only generated at the end of a compilation, so should be small
+                // in number.
+                if ((emitWarnings || diagnostic.isMandatory()) && !suppressNotes) {
                     writeDiagnostic(diagnostic);
-                    nwarnings++;
                 }
-            }
-            break;
+                break;
 
-        case ERROR:
-            if (!suppressErrorsAndWarnings) {
+            case WARNING:
+                if (emitWarnings || diagnostic.isMandatory()) {
+                    if (nwarnings < MaxWarnings) {
+                        writeDiagnostic(diagnostic);
+                        nwarnings++;
+                    }
+                }
+                break;
+
+            case ERROR:
                 if (diagnostic.getTree() != null && !errTrees.containsKey(diagnostic.getTree())) {
                     errTrees.put(diagnostic.getTree(), diagnostic);
                 }
                 if (nerrors < MaxErrors
-                    && ("compiler.err.proc.messager".equals(diagnostic.getCode()) || shouldReport(diagnostic.getSource(), diagnostic.getIntPosition()))) {
+                    && shouldReport(diagnostic.getSource(), diagnostic.getIntPosition())) {
                     writeDiagnostic(diagnostic);
                     nerrors++;
                 }
+                break;
+            }
+            if (diagnostic.isFlagSet(JCDiagnostic.DiagnosticFlag.COMPRESSED)) {
+                compressedOutput = true;
             }
-            break;
         }
     }
 
@@ -473,7 +684,7 @@ public class Log extends AbstractLog {
 
         PrintWriter writer = getWriterForDiagnosticType(diag.getType());
 
-        printLines(writer, diagFormatter.format(diag, messages.getCurrentLocale()));
+        printRawLines(writer, diagFormatter.format(diag, messages.getCurrentLocale()));
 
         if (promptOnError) {
             switch (diag.getType()) {
@@ -516,7 +727,7 @@ public class Log extends AbstractLog {
      *  @param args   Fields to substitute into the string.
      */
     public static String getLocalizedString(String key, Object ... args) {
-        return JavacMessages.getDefaultLocalizedString("compiler.misc." + key, args);
+        return JavacMessages.getDefaultLocalizedString(PrefixKind.COMPILER_MISC.key(key), args);
     }
 
     /** Find a localized string in the resource bundle.
@@ -524,8 +735,22 @@ public class Log extends AbstractLog {
      *  @param args   Fields to substitute into the string.
      */
     public String localize(String key, Object... args) {
-        return messages.getLocalizedString("compiler.misc." + key, args);
+        return localize(PrefixKind.COMPILER_MISC, key, args);
+    }
+
+    /** Find a localized string in the resource bundle.
+     *  @param key    The key for the localized string.
+     *  @param args   Fields to substitute into the string.
+     */
+    public String localize(PrefixKind pk, String key, Object... args) {
+        if (useRawMessages)
+            return pk.key(key);
+        else
+            return messages.getLocalizedString(pk.key(key), args);
     }
+    // where
+        // backdoor hook for testing, should transition to use -XDrawDiagnostics
+        private static boolean useRawMessages = false;
 
 /***************************************************************************
  * raw error messages without internationalization; used for experimentation
@@ -536,12 +761,12 @@ public class Log extends AbstractLog {
      */
     private void printRawError(int pos, String msg) {
         if (source == null || pos == Position.NOPOS) {
-            printLines(errWriter, "error: " + msg);
+            printRawLines(errWriter, "error: " + msg);
         } else {
             int line = source.getLineNumber(pos);
             JavaFileObject file = source.getFile();
             if (file != null)
-                printLines(errWriter,
+                printRawLines(errWriter,
                            file.getName() + ":" +
                            line + ": " + msg);
             printErrLine(pos, errWriter);
diff --git a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
index bb2dd56..1cf0e60 100644
--- a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
+++ b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,7 @@ public class MandatoryWarningHandler {
         DeferredDiagnosticKind(String v) { value = v; }
         String getKey(String prefix) { return prefix + value; }
 
-        private String value;
+        private final String value;
     }
 
 
diff --git a/src/share/classes/com/sun/tools/javac/util/Name.java b/src/share/classes/com/sun/tools/javac/util/Name.java
index 149f243..eeb739e 100644
--- a/src/share/classes/com/sun/tools/javac/util/Name.java
+++ b/src/share/classes/com/sun/tools/javac/util/Name.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -45,28 +45,28 @@ public abstract class Name implements javax.lang.model.element.Name {
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
     public boolean contentEquals(CharSequence cs) {
         return toString().equals(cs.toString());
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
     public int length() {
         return toString().length();
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
     public char charAt(int index) {
         return toString().charAt(index);
     }
 
     /**
-     * @inheritDoc
+     * {@inheritDoc}
      */
     public CharSequence subSequence(int start, int end) {
         return toString().subSequence(start, end);
diff --git a/src/share/classes/com/sun/tools/javac/util/Names.java b/src/share/classes/com/sun/tools/javac/util/Names.java
index 4e81f0d..7d6d171 100644
--- a/src/share/classes/com/sun/tools/javac/util/Names.java
+++ b/src/share/classes/com/sun/tools/javac/util/Names.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -47,236 +47,272 @@ public class Names {
         return instance;
     }
 
-    public final Name slash;
-    public final Name hyphen;
-    public final Name T;
-    public final Name slashequals;
-    public final Name deprecated;
-    public final Name init;
-    public final Name clinit;
-    public final Name error;
-    public final Name any;
+    // operators and punctuation
+    public final Name asterisk;
+    public final Name comma;
     public final Name empty;
+    public final Name hyphen;
     public final Name one;
     public final Name period;
-    public final Name comma;
     public final Name semicolon;
-    public final Name asterisk;
-    public final Name _this;
-    public final Name _super;
-    public final Name _default;
+    public final Name slash;
+    public final Name slashequals;
+
+    // keywords
     public final Name _class;
-    public final Name java_lang;
-    public final Name java_lang_Object;
+    public final Name _default;
+    public final Name _super;
+    public final Name _this;
+
+    // field and method names
+    public final Name _name;
+    public final Name addSuppressed;
+    public final Name addSuppressedException;
+    public final Name any;
+    public final Name append;
+    public final Name clinit;
+    public final Name clone;
+    public final Name close;
+    public final Name compareTo;
+    public final Name deserializeLambda;
+    public final Name desiredAssertionStatus;
+    public final Name equals;
+    public final Name error;
+    public final Name family;
+    public final Name finalize;
+    public final Name forName;
+    public final Name getClass;
+    public final Name getClassLoader;
+    public final Name getComponentType;
+    public final Name getDeclaringClass;
+    public final Name getMessage;
+    public final Name hasNext;
+    public final Name hashCode;
+    public final Name init;
+    public final Name initCause;
+    public final Name iterator;
+    public final Name length;
+    public final Name next;
+    public final Name ordinal;
+    public final Name serialVersionUID;
+    public final Name toString;
+    public final Name value;
+    public final Name valueOf;
+    public final Name values;
+
+    // class names
+    public final Name java_io_Serializable;
+    public final Name java_lang_AutoCloseable;
     public final Name java_lang_Class;
     public final Name java_lang_Cloneable;
-    public final Name java_io_Serializable;
-    public final Name serialVersionUID;
     public final Name java_lang_Enum;
-    public final Name transient_java_dyn_MethodHandle; // transient - 292
+    public final Name java_lang_Object;
     public final Name java_lang_invoke_MethodHandle;
-    public final Name package_info;
-    public final Name ConstantValue;
-    public final Name LineNumberTable;
-    public final Name LocalVariableTable;
-    public final Name LocalVariableTypeTable;
+
+    // names of builtin classes
+    public final Name Array;
+    public final Name Bound;
+    public final Name Method;
+
+    // package names
+    public final Name java_lang;
+
+    // attribute names
+    public final Name Annotation;
+    public final Name AnnotationDefault;
+    public final Name BootstrapMethods;
+    public final Name Bridge;
     public final Name CharacterRangeTable;
-    public final Name StackMap;
-    public final Name StackMapTable;
-    public final Name SourceID;
-    public final Name CompilationID;
     public final Name Code;
-    public final Name Exceptions;
-    public final Name SourceFile;
-    public final Name InnerClasses;
-    public final Name Synthetic;
-    public final Name Bridge;
+    public final Name CompilationID;
+    public final Name ConstantValue;
     public final Name Deprecated;
+    public final Name EnclosingMethod;
     public final Name Enum;
-    public final Name _name;
-    public final Name Signature;
-    public final Name Varargs;
-    public final Name Annotation;
-    public final Name RuntimeVisibleAnnotations;
+    public final Name Exceptions;
+    public final Name InnerClasses;
+    public final Name LineNumberTable;
+    public final Name LocalVariableTable;
+    public final Name LocalVariableTypeTable;
+    public final Name MethodParameters;
     public final Name RuntimeInvisibleAnnotations;
-    public final Name RuntimeVisibleTypeAnnotations;
+    public final Name RuntimeInvisibleParameterAnnotations;
     public final Name RuntimeInvisibleTypeAnnotations;
+    public final Name RuntimeVisibleAnnotations;
     public final Name RuntimeVisibleParameterAnnotations;
-    public final Name RuntimeInvisibleParameterAnnotations;
+    public final Name RuntimeVisibleTypeAnnotations;
+    public final Name Signature;
+    public final Name SourceFile;
+    public final Name SourceID;
+    public final Name StackMap;
+    public final Name StackMapTable;
+    public final Name Synthetic;
     public final Name Value;
-    public final Name EnclosingMethod;
-    public final Name _org_netbeans_TypeSignature;
-    public final Name _org_netbeans_ParameterNames;
-    public final Name _org_netbeans_SourceLevelAnnotations;
-    public final Name _org_netbeans_SourceLevelParameterAnnotations;
-    public final Name desiredAssertionStatus;
-    public final Name append;
-    public final Name family;
-    public final Name forName;
-    public final Name toString;
-    public final Name length;
-    public final Name valueOf;
-    public final Name value;
-    public final Name getMessage;
-    public final Name getClass;
-    public final Name TYPE;
-    public final Name TYPE_USE;
-    public final Name TYPE_PARAMETER;
-    public final Name FIELD;
-    public final Name METHOD;
-    public final Name PARAMETER;
+    public final Name Varargs;
+
+    // members of java.lang.annotation.ElementType
+    public final Name ANNOTATION_TYPE;
     public final Name CONSTRUCTOR;
+    public final Name FIELD;
     public final Name LOCAL_VARIABLE;
-    public final Name ANNOTATION_TYPE;
+    public final Name METHOD;
     public final Name PACKAGE;
-    public final Name SOURCE;
+    public final Name PARAMETER;
+    public final Name TYPE;
+    public final Name TYPE_PARAMETER;
+    public final Name TYPE_USE;
+
+    // members of java.lang.annotation.RetentionPolicy
     public final Name CLASS;
     public final Name RUNTIME;
-    public final Name Array;
-    public final Name Method;
-    public final Name Bound;
-    public final Name clone;
-    public final Name getComponentType;
-    public final Name getClassLoader;
-    public final Name initCause;
-    public final Name values;
-    public final Name iterator;
-    public final Name hasNext;
-    public final Name next;
-    public final Name AnnotationDefault;
-    public final Name ordinal;
-    public final Name equals;
-    public final Name hashCode;
-    public final Name compareTo;
-    public final Name getDeclaringClass;
+    public final Name SOURCE;
+
+    // other identifiers
+    public final Name T;
+    public final Name deprecated;
     public final Name ex;
-    public final Name finalize;
-    public final Name java_lang_AutoCloseable;
-    public final Name close;
-    public final Name addSuppressed;
-    public final Name addSuppressedException;
+    public final Name package_info;
+
+    //lambda-related
+    public final Name lambda;
+    public final Name metafactory;
+    public final Name altMetafactory;
 
     public final Name.Table table;
 
     public Names(Context context) {
         table = createTable(context);
 
-        slash = fromString("/");
-        hyphen = fromString("-");
-        T = fromString("T");
-        slashequals = fromString("/=");
-        deprecated = fromString("deprecated");
-
-        init = fromString("<init>");
-        clinit = fromString("<clinit>");
-        error = fromString("<error>");
-        any = fromString("<any>");
+        // operators and punctuation
+        asterisk = fromString("*");
+        comma = fromString(",");
         empty = fromString("");
+        hyphen = fromString("-");
         one = fromString("1");
         period = fromString(".");
-        comma = fromString(",");
         semicolon = fromString(";");
-        asterisk = fromString("*");
-        _this = fromString("this");
-        _super = fromString("super");
-        _default = fromString("default");
+        slash = fromString("/");
+        slashequals = fromString("/=");
 
+        // keywords
         _class = fromString("class");
-        java_lang = fromString("java.lang");
-        java_lang_Object = fromString("java.lang.Object");
+        _default = fromString("default");
+        _super = fromString("super");
+        _this = fromString("this");
+
+        // field and method names
+        _name = fromString("name");
+        addSuppressed = fromString("addSuppressed");
+        addSuppressedException = fromString("addSuppressedException");
+        any = fromString("<any>");
+        append = fromString("append");
+        clinit = fromString("<clinit>");
+        clone = fromString("clone");
+        close = fromString("close");
+        compareTo = fromString("compareTo");
+        deserializeLambda = fromString("$deserializeLambda$");
+        desiredAssertionStatus = fromString("desiredAssertionStatus");
+        equals = fromString("equals");
+        error = fromString("<error>");
+        family = fromString("family");
+        finalize = fromString("finalize");
+        forName = fromString("forName");
+        getClass = fromString("getClass");
+        getClassLoader = fromString("getClassLoader");
+        getComponentType = fromString("getComponentType");
+        getDeclaringClass = fromString("getDeclaringClass");
+        getMessage = fromString("getMessage");
+        hasNext = fromString("hasNext");
+        hashCode = fromString("hashCode");
+        init = fromString("<init>");
+        initCause = fromString("initCause");
+        iterator = fromString("iterator");
+        length = fromString("length");
+        next = fromString("next");
+        ordinal = fromString("ordinal");
+        serialVersionUID = fromString("serialVersionUID");
+        toString = fromString("toString");
+        value = fromString("value");
+        valueOf = fromString("valueOf");
+        values = fromString("values");
+
+        // class names
+        java_io_Serializable = fromString("java.io.Serializable");
+        java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
         java_lang_Class = fromString("java.lang.Class");
         java_lang_Cloneable = fromString("java.lang.Cloneable");
-        java_io_Serializable = fromString("java.io.Serializable");
         java_lang_Enum = fromString("java.lang.Enum");
-        transient_java_dyn_MethodHandle = fromString("java.dyn.MethodHandle"); //transient - 292
+        java_lang_Object = fromString("java.lang.Object");
         java_lang_invoke_MethodHandle = fromString("java.lang.invoke.MethodHandle");
-        package_info = fromString("package-info");
-        serialVersionUID = fromString("serialVersionUID");
-        ConstantValue = fromString("ConstantValue");
-        LineNumberTable = fromString("LineNumberTable");
-        LocalVariableTable = fromString("LocalVariableTable");
-        LocalVariableTypeTable = fromString("LocalVariableTypeTable");
+
+        // names of builtin classes
+        Array = fromString("Array");
+        Bound = fromString("Bound");
+        Method = fromString("Method");
+
+        // package names
+        java_lang = fromString("java.lang");
+
+        // attribute names
+        Annotation = fromString("Annotation");
+        AnnotationDefault = fromString("AnnotationDefault");
+        BootstrapMethods = fromString("BootstrapMethods");
+        Bridge = fromString("Bridge");
         CharacterRangeTable = fromString("CharacterRangeTable");
-        StackMap = fromString("StackMap");
-        StackMapTable = fromString("StackMapTable");
-        SourceID = fromString("SourceID");
-        CompilationID = fromString("CompilationID");
         Code = fromString("Code");
-        Exceptions = fromString("Exceptions");
-        SourceFile = fromString("SourceFile");
-        InnerClasses = fromString("InnerClasses");
-        Synthetic = fromString("Synthetic");
-        Bridge = fromString("Bridge");
+        CompilationID = fromString("CompilationID");
+        ConstantValue = fromString("ConstantValue");
         Deprecated = fromString("Deprecated");
+        EnclosingMethod = fromString("EnclosingMethod");
         Enum = fromString("Enum");
-        _name = fromString("name");
-        Signature = fromString("Signature");
-        Varargs = fromString("Varargs");
-        Annotation = fromString("Annotation");
-        RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
+        Exceptions = fromString("Exceptions");
+        InnerClasses = fromString("InnerClasses");
+        LineNumberTable = fromString("LineNumberTable");
+        LocalVariableTable = fromString("LocalVariableTable");
+        LocalVariableTypeTable = fromString("LocalVariableTypeTable");
+        MethodParameters = fromString("MethodParameters");
         RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
-        RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
+        RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
         RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
+        RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
         RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
-        RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
+        RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
+        Signature = fromString("Signature");
+        SourceFile = fromString("SourceFile");
+        SourceID = fromString("SourceID");
+        StackMap = fromString("StackMap");
+        StackMapTable = fromString("StackMapTable");
+        Synthetic = fromString("Synthetic");
         Value = fromString("Value");
-        EnclosingMethod = fromString("EnclosingMethod");
-        _org_netbeans_TypeSignature = fromString("org.netbeans.TypeSignature");
-        _org_netbeans_ParameterNames = fromString("org.netbeans.ParameterNames");
-        _org_netbeans_SourceLevelAnnotations = fromString("org.netbeans.SourceLevelAnnotations");
-        _org_netbeans_SourceLevelParameterAnnotations = fromString("org.netbeans.SourceLevelParameterAnnotations");
-
-        desiredAssertionStatus = fromString("desiredAssertionStatus");
-
-        append = fromString("append");
-        family = fromString("family");
-        forName = fromString("forName");
-        toString = fromString("toString");
-        length = fromString("length");
-        valueOf = fromString("valueOf");
-        value = fromString("value");
-        getMessage = fromString("getMessage");
-        getClass = fromString("getClass");
+        Varargs = fromString("Varargs");
 
-        TYPE = fromString("TYPE");
-        TYPE_USE = fromString("TYPE_USE");
-        TYPE_PARAMETER = fromString("TYPE_PARAMETER");
-        FIELD = fromString("FIELD");
-        METHOD = fromString("METHOD");
-        PARAMETER = fromString("PARAMETER");
+        // members of java.lang.annotation.ElementType
+        ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
         CONSTRUCTOR = fromString("CONSTRUCTOR");
+        FIELD = fromString("FIELD");
         LOCAL_VARIABLE = fromString("LOCAL_VARIABLE");
-        ANNOTATION_TYPE = fromString("ANNOTATION_TYPE");
+        METHOD = fromString("METHOD");
         PACKAGE = fromString("PACKAGE");
+        PARAMETER = fromString("PARAMETER");
+        TYPE = fromString("TYPE");
+        TYPE_PARAMETER = fromString("TYPE_PARAMETER");
+        TYPE_USE = fromString("TYPE_USE");
 
-        SOURCE = fromString("SOURCE");
+        // members of java.lang.annotation.RetentionPolicy
         CLASS = fromString("CLASS");
         RUNTIME = fromString("RUNTIME");
+        SOURCE = fromString("SOURCE");
 
-        Array = fromString("Array");
-        Method = fromString("Method");
-        Bound = fromString("Bound");
-        clone = fromString("clone");
-        getComponentType = fromString("getComponentType");
-        getClassLoader = fromString("getClassLoader");
-        initCause = fromString("initCause");
-        values = fromString("values");
-        iterator = fromString("iterator");
-        hasNext = fromString("hasNext");
-        next = fromString("next");
-        AnnotationDefault = fromString("AnnotationDefault");
-        ordinal = fromString("ordinal");
-        equals = fromString("equals");
-        hashCode = fromString("hashCode");
-        compareTo = fromString("compareTo");
-        getDeclaringClass = fromString("getDeclaringClass");
+        // other identifiers
+        T = fromString("T");
+        deprecated = fromString("deprecated");
         ex = fromString("ex");
-        finalize = fromString("finalize");
+        package_info = fromString("package-info");
 
-        java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
-        close = fromString("close");
-        addSuppressed = fromString("addSuppressed");
-        addSuppressedException = fromString("addSuppressedException");
+        //lambda-related
+        lambda = fromString("lambda$");
+        metafactory = fromString("metafactory");
+        altMetafactory = fromString("altMetafactory");
     }
 
     protected Name.Table createTable(Context context) {
diff --git a/src/share/classes/com/sun/tools/javac/util/Options.java b/src/share/classes/com/sun/tools/javac/util/Options.java
index db13b65..c3bd4d5 100644
--- a/src/share/classes/com/sun/tools/javac/util/Options.java
+++ b/src/share/classes/com/sun/tools/javac/util/Options.java
@@ -26,8 +26,8 @@
 package com.sun.tools.javac.util;
 
 import java.util.*;
-import com.sun.tools.javac.main.OptionName;
-import static com.sun.tools.javac.main.OptionName.*;
+import com.sun.tools.javac.main.Option;
+import static com.sun.tools.javac.main.Option.*;
 
 /** A table of all command-line options.
  *  If an option has an argument, the option name is mapped to the argument.
@@ -71,8 +71,8 @@ public class Options {
     /**
      * Get the value for an option.
      */
-    public String get(OptionName name) {
-        return values.get(name.optionName);
+    public String get(Option option) {
+        return values.get(option.text);
     }
 
     /**
@@ -101,15 +101,15 @@ public class Options {
     /**
      * Check if the value for an option has been set.
      */
-    public boolean isSet(OptionName name) {
-        return (values.get(name.optionName) != null);
+    public boolean isSet(Option option) {
+        return (values.get(option.text) != null);
     }
 
     /**
      * Check if the value for a choice option has been set to a specific value.
      */
-    public boolean isSet(OptionName name, String value) {
-        return (values.get(name.optionName + value) != null);
+    public boolean isSet(Option option, String value) {
+        return (values.get(option.text + value) != null);
     }
 
     /**
@@ -122,23 +122,23 @@ public class Options {
     /**
      * Check if the value for an option has not been set.
      */
-    public boolean isUnset(OptionName name) {
-        return (values.get(name.optionName) == null);
+    public boolean isUnset(Option option) {
+        return (values.get(option.text) == null);
     }
 
     /**
      * Check if the value for a choice option has not been set to a specific value.
      */
-    public boolean isUnset(OptionName name, String value) {
-        return (values.get(name.optionName + value) == null);
+    public boolean isUnset(Option option, String value) {
+        return (values.get(option.text + value) == null);
     }
 
     public void put(String name, String value) {
         values.put(name, value);
     }
 
-    public void put(OptionName name, String value) {
-        values.put(name.optionName, value);
+    public void put(Option option, String value) {
+        values.put(option.text, value);
     }
 
     public void putAll(Options options) {
@@ -157,6 +157,19 @@ public class Options {
         return values.size();
     }
 
+    // light-weight notification mechanism
+
+    private List<Runnable> listeners = List.nil();
+
+    public void addListener(Runnable listener) {
+        listeners = listeners.prepend(listener);
+    }
+
+    public void notifyListeners() {
+        for (Runnable r: listeners)
+            r.run();
+    }
+
     /** Check for a lint suboption. */
     public boolean lint(String s) {
         // return true if either the specific option is enabled, or
diff --git a/src/share/classes/com/sun/tools/javac/util/Pair.java b/src/share/classes/com/sun/tools/javac/util/Pair.java
index 2f5d266..b538ee3 100644
--- a/src/share/classes/com/sun/tools/javac/util/Pair.java
+++ b/src/share/classes/com/sun/tools/javac/util/Pair.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2005, 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
@@ -25,6 +25,8 @@
 
 package com.sun.tools.javac.util;
 
+import java.util.Objects;
+
 /** A generic class for pairs.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -46,15 +48,11 @@ public class Pair<A, B> {
         return "Pair[" + fst + "," + snd + "]";
     }
 
-    private static boolean equals(Object x, Object y) {
-        return (x == null && y == null) || (x != null && x.equals(y));
-    }
-
     public boolean equals(Object other) {
         return
             other instanceof Pair<?,?> &&
-            equals(fst, ((Pair<?,?>)other).fst) &&
-            equals(snd, ((Pair<?,?>)other).snd);
+            Objects.equals(fst, ((Pair<?,?>)other).fst) &&
+            Objects.equals(snd, ((Pair<?,?>)other).snd);
     }
 
     public int hashCode() {
diff --git a/src/share/classes/com/sun/tools/javac/util/Position.java b/src/share/classes/com/sun/tools/javac/util/Position.java
index 1b64118..444b1b7 100644
--- a/src/share/classes/com/sun/tools/javac/util/Position.java
+++ b/src/share/classes/com/sun/tools/javac/util/Position.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -71,20 +71,20 @@ public class Position {
      * @param   max         Number of characters to read
      * @param   expandTabs  If true, expand tabs when calculating columns
      */
-    public static LineMap makeLineMap(char[] src, int max, char replacedCharacter, boolean expandTabs) {
+    public static LineMap makeLineMap(char[] src, int max, boolean expandTabs) {
         LineMapImpl lineMap = expandTabs ?
-            new LineTabMapImpl(src.length) : new LineMapImpl();
-        lineMap.build(src, max, replacedCharacter);
+            new LineTabMapImpl(max) : new LineMapImpl();
+        lineMap.build(src, max);
         return lineMap;
     }
 
     /** Encode line and column numbers in an integer as:
-     *  line-number << LINESHIFT + column-number
-     *  {@link Position.NOPOS represents an undefined position.
+     *  {@code line-number << LINESHIFT + column-number }.
+     *  {@link Position#NOPOS} represents an undefined position.
      *
      * @param  line  number of line (first is 1)
      * @param  col   number of character on line (first is 1)
-     * @return       an encoded position or {@link Position.NOPOS
+     * @return       an encoded position or {@link Position#NOPOS}
      *               if the line or column number is too big to
      *               represent in the encoded format
      * @throws IllegalArgumentException if line or col is less than 1
@@ -107,8 +107,8 @@ public class Position {
          * @param line number of line (first is 1)
          * @return     position of first character in line
          * @throws  ArrayIndexOutOfBoundsException
-         *           if <tt>lineNumber < 1</tt>
-         *           if <tt>lineNumber > no. of lines</tt>
+         *           if {@code lineNumber < 1}
+         *           if {@code lineNumber > no. of lines}
          */
         int getStartPosition(int line);
 
@@ -119,8 +119,8 @@ public class Position {
          *
          * @return  position of character
          * @throws  ArrayIndexOutOfBoundsException
-         *           if <tt>line < 1</tt>
-         *           if <tt>line > no. of lines</tt>
+         *           if {@code line < 1}
+         *           if {@code line > no. of lines}
          */
         int getPosition(int line, int column);
 
@@ -147,16 +147,16 @@ public class Position {
 
         protected LineMapImpl() {}
 
-        public void build(char[] src, int max, char replacedCharacter) {
+        public void build(char[] src, int max) {
             int c = 0;
             int i = 0;
             int[] linebuf = new int[src.length + 1];
             linebuf[c++] = i;
             while (i < src.length) {
                 do {
-                    char ch = i == max ? replacedCharacter : src[i];
+                    char ch = src[i];
                     if (ch == '\r' || ch == '\n') {
-                        if (ch == '\r' && (i+1) < src.length && (i == max ? replacedCharacter : src[i+1]) == '\n')
+                        if (ch == '\r' && (i+1) < src.length && src[i+1] == '\n')
                             i += 2;
                         else
                             ++i;
diff --git a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
index 1e915c7..00e0b1f 100644
--- a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
+++ b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -32,6 +32,7 @@ import javax.tools.JavaFileObject;
 import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.*;
 import com.sun.tools.javac.api.Formattable;
 import com.sun.tools.javac.file.BaseFileObject;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
 
 import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
@@ -51,7 +52,7 @@ public final class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
 
     /**
      * Create a formatter based on the supplied options.
-     * @param msgs
+     * @param options
      */
     public RawDiagnosticFormatter(Options options) {
         super(null, new SimpleConfiguration(options,
@@ -117,16 +118,17 @@ public final class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
     @Override
     protected String formatArgument(JCDiagnostic diag, Object arg, Locale l) {
         String s;
-        if (arg instanceof Formattable)
+        if (arg instanceof Formattable) {
             s = arg.toString();
-        else if (arg instanceof BaseFileObject)
+        } else if (arg instanceof JCExpression) {
+            JCExpression tree = (JCExpression)arg;
+            s = "@" + tree.getStartPosition();
+        } else if (arg instanceof BaseFileObject) {
             s = ((BaseFileObject) arg).getShortName();
-        else
+        } else {
             s = super.formatArgument(diag, arg, null);
-        if (arg instanceof JCDiagnostic)
-            return "(" + s + ")";
-        else
-            return s;
+        }
+        return (arg instanceof JCDiagnostic) ? "(" + s + ")" : s;
     }
 
     @Override
diff --git a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
index 24861c2..c592b16 100644
--- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
+++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -24,6 +24,7 @@
  */
 package com.sun.tools.javac.util;
 
+import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -39,7 +40,7 @@ import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Types;
 
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.util.LayoutCharacters.*;
 import static com.sun.tools.javac.util.RichDiagnosticFormatter.RichConfiguration.*;
@@ -96,7 +97,7 @@ public class RichDiagnosticFormatter extends
         this.diags = JCDiagnostic.Factory.instance(context);
         this.types = Types.instance(context);
         this.messages = JavacMessages.instance(context);
-        whereClauses = new LinkedHashMap<WhereClauseKind, Map<Type, JCDiagnostic>>();
+        whereClauses = new EnumMap<WhereClauseKind, Map<Type, JCDiagnostic>>(WhereClauseKind.class);
         configuration = new RichConfiguration(Options.instance(context), formatter);
         for (WhereClauseKind kind : WhereClauseKind.values())
             whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>());
@@ -124,6 +125,13 @@ public class RichDiagnosticFormatter extends
         return sb.toString();
     }
 
+    @Override
+    public String formatMessage(JCDiagnostic diag, Locale l) {
+        nameSimplifier = new ClassNameSimplifier();
+        preprocessDiagnostic(diag);
+        return super.formatMessage(diag, l);
+    }
+
     /**
      * Sets the type/symbol printer used by this formatter.
      * @param printer the rich printer to be set
@@ -249,7 +257,7 @@ public class RichDiagnosticFormatter extends
         INTERSECTION("where.description.intersection");
 
         /** resource key for this where clause kind */
-        private String key;
+        private final String key;
 
         WhereClauseKind(String key) {
             this.key = key;
@@ -288,15 +296,16 @@ public class RichDiagnosticFormatter extends
 
         public String simplify(Symbol s) {
             String name = s.getQualifiedName().toString();
-            if (!s.type.isCompound()) {
+            if (!s.type.isCompound() && !s.type.isPrimitive() && !s.type.hasTag(VOID)) {
                 List<Symbol> conflicts = nameClashes.get(s.getSimpleName());
                 if (conflicts == null ||
                     (conflicts.size() == 1 &&
                     conflicts.contains(s))) {
                     List<Name> l = List.nil();
                     Symbol s2 = s;
-                    while (s2.type.getEnclosingType().tag == CLASS
-                            && s2.owner.kind == Kinds.TYP) {
+                    while (s2.type != null && s2.type.hasTag(CLASS) &&
+                            s2.type.getEnclosingType() != null && s2.type.getEnclosingType().hasTag(CLASS) &&
+                            s2.owner != null && s2.owner.kind == Kinds.TYP) {
                         l = l.prepend(s2.getSimpleName());
                         s2 = s2.owner;
                     }
@@ -393,12 +402,10 @@ public class RichDiagnosticFormatter extends
         }
 
         @Override
-        protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
-            return super.printMethodArgs(args, varArgs, locale);
-        }
-
-        @Override
         public String visitClassSymbol(ClassSymbol s, Locale locale) {
+            if (s.type.isCompound()) {
+                return visit(s.type, locale);
+            }
             String name = nameSimplifier.simplify(s);
             if (name.length() == 0 ||
                     !getConfiguration().isEnabled(RichFormatterFeature.SIMPLE_NAMES)) {
@@ -419,7 +426,7 @@ public class RichDiagnosticFormatter extends
                     ? ownerName
                     : s.name.toString();
                 if (s.type != null) {
-                    if (s.type.tag == FORALL) {
+                    if (s.type.hasTag(FORALL)) {
                         ms = "<" + visitTypes(s.type.getTypeArguments(), locale) + ">" + ms;
                     }
                     ms += "(" + printMethodArgs(
@@ -513,6 +520,16 @@ public class RichDiagnosticFormatter extends
                     visit(supertype);
                     visit(interfaces);
                 }
+            } else if (t.tsym.name.isEmpty()) {
+                //anon class
+                ClassType norm = (ClassType) t.tsym.type;
+                if (norm != null) {
+                    if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
+                        visit(norm.interfaces_field.head);
+                    } else {
+                        visit(norm.supertype_field);
+                    }
+                }
             }
             nameSimplifier.addUsage(t.tsym);
             visit(t.getTypeArguments());
@@ -530,23 +547,33 @@ public class RichDiagnosticFormatter extends
                     bound = ((ErrorType)bound).getOriginalType();
                 //retrieve the bound list - if the type variable
                 //has not been attributed the bound is not set
-                List<Type> bounds = bound != null ?
+                List<Type> bounds = (bound != null) &&
+                        (bound.hasTag(CLASS) || bound.hasTag(TYPEVAR)) ?
                     types.getBounds(t) :
                     List.<Type>nil();
 
                 nameSimplifier.addUsage(t.tsym);
 
                 boolean boundErroneous = bounds.head == null ||
-                                         bounds.head.tag == NONE ||
-                                         bounds.head.tag == ERROR;
+                                         bounds.head.hasTag(NONE) ||
+                                         bounds.head.hasTag(ERROR);
 
-
-                JCDiagnostic d = diags.fragment("where.typevar" +
+                if ((t.tsym.flags() & SYNTHETIC) == 0) {
+                    //this is a true typevar
+                    JCDiagnostic d = diags.fragment("where.typevar" +
                         (boundErroneous ? ".1" : ""), t, bounds,
                         Kinds.kindName(t.tsym.location()), t.tsym.location());
-                whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
-                symbolPreprocessor.visit(t.tsym.location(), null);
-                visit(bounds);
+                    whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
+                    symbolPreprocessor.visit(t.tsym.location(), null);
+                    visit(bounds);
+                } else {
+                    Assert.check(!boundErroneous);
+                    //this is a fresh (synthetic) tvar
+                    JCDiagnostic d = diags.fragment("where.fresh.typevar", t, bounds);
+                    whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
+                    visit(bounds);
+                }
+
             }
             return null;
         }
@@ -556,7 +583,7 @@ public class RichDiagnosticFormatter extends
     // <editor-fold defaultstate="collapsed" desc="symbol scanner">
     /**
      * Preprocess a given symbol looking for (i) additional info (where clauses) to be
-     * asdded to the main diagnostic (ii) names to be compacted
+     * added to the main diagnostic (ii) names to be compacted
      */
     protected void preprocessSymbol(Symbol s) {
         symbolPreprocessor.visit(s, null);
@@ -567,7 +594,11 @@ public class RichDiagnosticFormatter extends
 
         @Override
         public Void visitClassSymbol(ClassSymbol s, Void ignored) {
-            nameSimplifier.addUsage(s);
+            if (s.type.isCompound()) {
+                typePreprocessor.visit(s.type);
+            } else {
+                nameSimplifier.addUsage(s);
+            }
             return null;
         }
 
diff --git a/src/share/classes/com/sun/tools/javac/util/ServiceLoader.java b/src/share/classes/com/sun/tools/javac/util/ServiceLoader.java
new file mode 100644
index 0000000..f24f1fb
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javac/util/ServiceLoader.java
@@ -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() + "]";
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java b/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java
index 80d1505..38666cd 100644
--- a/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java
+++ b/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -93,13 +93,7 @@ public class SharedNameTable extends Name.Table {
     @Override
     public Name fromChars(char[] cs, int start, int len) {
         int nc = this.nc;
-        byte[] bytes = this.bytes;
-        while (nc + len * 3 >= bytes.length) {
-            //          System.err.println("doubling name buffer of length " + names.length + " to fit " + len + " chars");//DEBUG
-            byte[] newnames = new byte[bytes.length * 2];
-            System.arraycopy(bytes, 0, newnames, 0, bytes.length);
-            bytes = this.bytes = newnames;
-        }
+        byte[] bytes = this.bytes = ArrayUtils.ensureCapacity(this.bytes, nc + len * 3);
         int nbytes = Convert.chars2utf(cs, start, bytes, nc, len) - nc;
         int h = hashValue(bytes, nc, nbytes) & hashMask;
         NameImpl n = hashes[h];
@@ -133,12 +127,7 @@ public class SharedNameTable extends Name.Table {
         }
         if (n == null) {
             int nc = this.nc;
-            while (nc + len > names.length) {
-                //              System.err.println("doubling name buffer of length + " + names.length + " to fit " + len + " bytes");//DEBUG
-                byte[] newnames = new byte[names.length * 2];
-                System.arraycopy(names, 0, newnames, 0, names.length);
-                names = this.bytes = newnames;
-            }
+            names = this.bytes = ArrayUtils.ensureCapacity(names, nc + len);
             System.arraycopy(cs, start, names, nc, len);
             n = new NameImpl(this);
             n.index = nc;
diff --git a/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java b/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java
index 5e8abb0..b0a8ab4 100644
--- a/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java
+++ b/src/share/classes/com/sun/tools/javac/util/UnsharedNameTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, 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
@@ -125,8 +125,6 @@ public class UnsharedNameTable extends Name.Table {
         System.arraycopy(cs, start, bytes, 0, len);
         n = new NameImpl(this, bytes, index++);
 
-        System.arraycopy(cs, start, n.bytes, 0, len);
-
         HashEntry newEntry = new HashEntry(n);
 
         if (previousNonNullTableEntry == null) { // We are not the first name with that hashCode.
diff --git a/src/share/classes/com/sun/tools/javac/util/Warner.java b/src/share/classes/com/sun/tools/javac/util/Warner.java
index 8b76439..7b993c1 100644
--- a/src/share/classes/com/sun/tools/javac/util/Warner.java
+++ b/src/share/classes/com/sun/tools/javac/util/Warner.java
@@ -39,7 +39,6 @@ import java.util.EnumSet;
  * deletion without notice.</b>
  */
 public class Warner {
-    public static final Warner noWarnings = new Warner();
 
     private DiagnosticPosition pos = null;
     protected boolean warned = false;
diff --git a/src/share/classes/com/sun/tools/javadoc/AbstractTypeImpl.java b/src/share/classes/com/sun/tools/javadoc/AbstractTypeImpl.java
index deaf6a1..856cd55 100644
--- a/src/share/classes/com/sun/tools/javadoc/AbstractTypeImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/AbstractTypeImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, 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,7 +25,6 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Type;
@@ -36,6 +35,11 @@ import com.sun.tools.javac.code.Type;
  * defaults for the methods in <code>Type</code> (and a couple from
  * <code>ProgramElementDoc</code>).
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -57,6 +61,10 @@ abstract class AbstractTypeImpl implements com.sun.javadoc.Type {
         return type.tsym.getQualifiedName().toString();
     }
 
+    public com.sun.javadoc.Type getElementType() {
+        return null;
+    }
+
     public String simpleTypeName() {
         return type.tsym.name.toString();
     }
@@ -100,4 +108,8 @@ abstract class AbstractTypeImpl implements com.sun.javadoc.Type {
     public AnnotationTypeDoc asAnnotationTypeDoc() {
         return null;
     }
+
+    public AnnotatedType asAnnotatedType() {
+        return null;
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java b/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java
new file mode 100644
index 0000000..a49dc8a
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotatedTypeImpl.java
@@ -0,0 +1,125 @@
+/*
+ * 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.javadoc;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.util.List;
+
+/**
+ * Implementation of <code>AnnotatedType</code>, which
+ * represents an annotated type.
+ *
+ * @author Mahmood Ali
+ * @since 1.8
+ */
+public class AnnotatedTypeImpl
+        extends AbstractTypeImpl implements AnnotatedType {
+
+    AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type.AnnotatedType type) {
+        super(env, type);
+    }
+
+    /**
+     * Get the annotations of this program element.
+     * Return an empty array if there are none.
+     */
+    @Override
+    public AnnotationDesc[] annotations() {
+        List<TypeCompound> tas = ((com.sun.tools.javac.code.Type.AnnotatedType)type).typeAnnotations;
+        if (tas == null ||
+                tas.isEmpty()) {
+            return new AnnotationDesc[0];
+        }
+        AnnotationDesc res[] = new AnnotationDesc[tas.length()];
+        int i = 0;
+        for (Attribute.Compound a : tas) {
+            res[i++] = new AnnotationDescImpl(env, a);
+        }
+        return res;
+    }
+
+    @Override
+    public com.sun.javadoc.Type underlyingType() {
+        return TypeMaker.getType(env, ((com.sun.tools.javac.code.Type.AnnotatedType)type).underlyingType, true, false);
+    }
+
+    @Override
+    public AnnotatedType asAnnotatedType() {
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return typeName();
+    }
+
+    @Override
+    public String typeName() {
+        return this.underlyingType().typeName();
+    }
+
+    @Override
+    public String qualifiedTypeName() {
+        return this.underlyingType().qualifiedTypeName();
+    }
+
+    @Override
+    public String simpleTypeName() {
+        return this.underlyingType().simpleTypeName();
+    }
+
+    @Override
+    public String dimension() {
+        return this.underlyingType().dimension();
+    }
+
+    @Override
+    public boolean isPrimitive() {
+        return this.underlyingType().isPrimitive();
+    }
+
+    @Override
+    public ClassDoc asClassDoc() {
+        return this.underlyingType().asClassDoc();
+    }
+
+    @Override
+    public TypeVariable asTypeVariable() {
+        return this.underlyingType().asTypeVariable();
+    }
+
+    @Override
+    public WildcardType asWildcardType() {
+        return this.underlyingType().asWildcardType();
+    }
+
+    @Override
+    public ParameterizedType asParameterizedType() {
+        return this.underlyingType().asParameterizedType();
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java
index 8e8f70c..166089d 100644
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Attribute;
@@ -40,6 +39,11 @@ import com.sun.tools.javac.util.Pair;
  * Sure it ought to be called "Annotation", but that clashes with
  * java.lang.annotation.Annotation.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -85,6 +89,15 @@ public class AnnotationDescImpl implements AnnotationDesc {
     }
 
     /**
+     * Check for the synthesized bit on the annotation.
+     *
+     * @return true if the annotation is synthesized.
+     */
+    public boolean isSynthesized() {
+        return annotation.isSynthesized();
+    }
+
+    /**
      * Returns a string representation of this annotation.
      * String is of one of the forms:
      *     @com.example.foo(name1=val1, name2=val2)
diff --git a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java
index 3c2efa3..032b5f7 100644
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java
@@ -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
@@ -27,18 +27,20 @@ package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
 
-
+import com.sun.source.util.TreePath;
 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;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Represents an annotation type.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -47,12 +49,11 @@ public class AnnotationTypeDocImpl
         extends ClassDocImpl implements AnnotationTypeDoc {
 
     public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
-        this(env, sym, null, null, null);
+        this(env, sym, null);
     }
 
-    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
-                          String doc, JCClassDecl tree, Position.LineMap lineMap) {
-        super(env, sym, doc, tree, lineMap);
+    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
     }
 
     /**
@@ -89,7 +90,6 @@ public class AnnotationTypeDocImpl
      * 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) {
diff --git a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java
index e5632dc..2305429 100644
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java
@@ -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
@@ -27,17 +27,17 @@ package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
 
-import static com.sun.javadoc.LanguageVersion.*;
-
+import com.sun.source.util.TreePath;
 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.Name;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Represents an element of an annotation type.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -49,9 +49,8 @@ public class AnnotationTypeElementDocImpl
         super(env, sym);
     }
 
-    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym,
-                                 String doc, JCMethodDecl tree, Position.LineMap lineMap) {
-        super(env, sym, doc, tree, lineMap);
+    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java
index dae37c4..b79a19c 100644
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java
@@ -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
@@ -25,17 +25,20 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Attribute;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.TypeTags;
 
+import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 
 /**
  * Represents a value of an annotation type element.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -72,7 +75,7 @@ public class AnnotationValueImpl implements AnnotationValue {
         public Object value;
 
         public void visitConstant(Attribute.Constant c) {
-            if (c.type.tag == TypeTags.BOOLEAN) {
+            if (c.type.hasTag(BOOLEAN)) {
                 // javac represents false and true as integers 0 and 1
                 value = Boolean.valueOf(
                                 ((Integer)c.value).intValue() != 0);
@@ -83,7 +86,7 @@ public class AnnotationValueImpl implements AnnotationValue {
 
         public void visitClass(Attribute.Class c) {
             value = TypeMaker.getType(env,
-                                      env.types.erasure(c.type));
+                                      env.types.erasure(c.classType));
         }
 
         public void visitEnum(Attribute.Enum e) {
@@ -129,7 +132,7 @@ public class AnnotationValueImpl implements AnnotationValue {
         }
 
         public void visitConstant(Attribute.Constant c) {
-            if (c.type.tag == TypeTags.BOOLEAN) {
+            if (c.type.hasTag(BOOLEAN)) {
                 // javac represents false and true as integers 0 and 1
                 sb.append(((Integer)c.value).intValue() != 0);
             } else {
diff --git a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
index cad4141..d06fec3 100644
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -31,13 +31,14 @@ import java.lang.reflect.Modifier;
 import java.net.URI;
 import java.util.HashSet;
 import java.util.Set;
+
 import javax.tools.FileObject;
 import javax.tools.JavaFileManager.Location;
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 
 import com.sun.javadoc.*;
-
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Scope;
@@ -45,24 +46,22 @@ import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.code.TypeTags;
-
+import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
-
 import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
 import com.sun.tools.javac.tree.JCTree.JCImport;
 import com.sun.tools.javac.tree.TreeInfo;
-
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Position;
-
 import static com.sun.tools.javac.code.Kinds.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
+import static com.sun.tools.javac.code.TypeTag.ERROR;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
  * Represents a java class and provides access to information
@@ -73,6 +72,11 @@ import static com.sun.tools.javac.code.Kinds.*;
  * referred to using Type (which can be converted to ClassDocImpl,
  * if possible).
  *
+ *  <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>
+ *
  * @see Type
  *
  * @since 1.2
@@ -94,19 +98,22 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * Constructor
      */
     public ClassDocImpl(DocEnv env, ClassSymbol sym) {
-        this(env, sym, null, null, null);
+        this(env, sym, null);
     }
 
     /**
      * Constructor
      */
-    public ClassDocImpl(DocEnv env, ClassSymbol sym, String documentation,
-                        JCClassDecl tree, Position.LineMap lineMap) {
-        super(env, sym, documentation, tree, lineMap);
+    public ClassDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
         this.type = (ClassType)sym.type;
         this.tsym = sym;
     }
 
+    public com.sun.javadoc.Type getElementType() {
+        return null;
+    }
+
     /**
      * Returns the flags in terms of javac's flags
      */
@@ -158,7 +165,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
         }
-        for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) {
+        for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) {
             if (t.tsym == env.syms.errorType.tsym ||
                 t.tsym == env.syms.exceptionType.tsym) {
                 return false;
@@ -195,7 +202,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
         }
-        for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) {
+        for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) {
             if (t.tsym == env.syms.exceptionType.tsym) {
                 return true;
             }
@@ -211,7 +218,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
         }
-        for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) {
+        for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) {
             if (t.tsym == env.syms.errorType.tsym) {
                 return true;
             }
@@ -226,7 +233,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
         }
-        for (Type t = type; t.tag == TypeTags.CLASS; t = env.types.supertype(t)) {
+        for (Type t = type; t.hasTag(CLASS); t = env.types.supertype(t)) {
             if (t.tsym == env.syms.throwableType.tsym) {
                 return true;
             }
@@ -275,6 +282,10 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         return false;
     }
 
+    public boolean isFunctionalInterface() {
+        return env.types.isFunctionalInterface(tsym);
+    }
+
     /**
      * Return the package that this class is contained in.
      */
@@ -332,9 +343,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * </pre>
      */
     public String name() {
-        return getClassName(tsym, false);
+        if (name == null) {
+            name = getClassName(tsym, false);
+        }
+        return name;
     }
 
+    private String name;
+
     /**
      * Return the qualified class name as a String.
      * <pre>
@@ -345,9 +361,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * </pre>
      */
     public String qualifiedName() {
-        return getClassName(tsym, true);
+        if (qualifiedName == null) {
+            qualifiedName = getClassName(tsym, true);
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Return unqualified name of type excluding any dimension information.
      * <p>
@@ -371,9 +392,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * Return the simple name of this type.
      */
     public String simpleTypeName() {
-        return tsym.name.toString();
+        if (simpleTypeName == null) {
+            simpleTypeName = tsym.name.toString();
+        }
+        return simpleTypeName;
     }
 
+    private String simpleTypeName;
+
     /**
      * Return the qualified name and any type parameters.
      * Each parameter is a type variable with optional bounds.
@@ -492,7 +518,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
             return null;
         Type sup = env.types.supertype(type);
         return TypeMaker.getType(env,
-                (sup != type && (sup.tag == TypeTags.CLASS || sup.tag == TypeTags.ERROR)) ? sup : env.syms.objectType);
+                                 (sup.hasTag(TypeTag.NONE)) ? env.syms.objectType : sup);
     }
 
     /**
@@ -843,7 +869,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * Note that this is not necessarily what the compiler would do!
      *
      * @param methodName the unqualified name to search for.
-     * @param paramTypeArray the array of Strings for method parameter types.
+     * @param paramTypes the array of Strings for method parameter types.
      * @return the first MethodDocImpl which matches, null if not found.
      */
     public MethodDocImpl findMethod(String methodName, String[] paramTypes) {
@@ -970,7 +996,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
      * Find constructor in this class.
      *
      * @param constrName the unqualified name to search for.
-     * @param paramTypeArray the array of Strings for constructor parameters.
+     * @param paramTypes the array of Strings for constructor parameters.
      * @return the first ConstructorDocImpl which matches, null if not found.
      */
     public ConstructorDoc findConstructor(String constrName,
@@ -1081,7 +1107,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
 
         Name asterisk = tsym.name.table.names.asterisk;
         for (JCTree t : compenv.toplevel.defs) {
-            if (t.getTag() == JCTree.IMPORT) {
+            if (t.hasTag(IMPORT)) {
                 JCTree imp = ((JCImport) t).qualid;
                 if ((TreeInfo.name(imp) != asterisk) &&
                         (imp.type.tsym.kind & Kinds.TYP) != 0) {
@@ -1122,7 +1148,7 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
         if (compenv == null) return new PackageDocImpl[0];
 
         for (JCTree t : compenv.toplevel.defs) {
-            if (t.getTag() == JCTree.IMPORT) {
+            if (t.hasTag(IMPORT)) {
                 JCTree imp = ((JCImport) t).qualid;
                 if (TreeInfo.name(imp) == names.asterisk) {
                     JCFieldAccess sel = (JCFieldAccess)imp;
@@ -1181,6 +1207,13 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
     }
 
     /**
+     * Returns null, as this is not an annotated type.
+     */
+    public AnnotatedType asAnnotatedType() {
+        return null;
+    }
+
+    /**
      * Return false, as this is not a primitive type.
      */
     public boolean isPrimitive() {
diff --git a/src/share/classes/com/sun/tools/javadoc/Comment.java b/src/share/classes/com/sun/tools/javadoc/Comment.java
index 8d1031c..a153631 100644
--- a/src/share/classes/com/sun/tools/javadoc/Comment.java
+++ b/src/share/classes/com/sun/tools/javadoc/Comment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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;
 
@@ -33,6 +35,11 @@ import com.sun.tools.javac.util.ListBuffer;
  *      It allows users to get first sentence of this comment, get
  *      comment for different tags...
  *
+ *  <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 Kaiyang Liu (original)
  * @author Robert Field (rewrite)
  * @author Atul M Dambalkar
@@ -291,6 +298,7 @@ class Comment {
     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) {
@@ -304,6 +312,7 @@ class Comment {
                                            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);
@@ -314,18 +323,20 @@ class Comment {
                      }
                 }
                 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",
@@ -362,6 +373,17 @@ class Comment {
         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.
@@ -387,7 +409,7 @@ class Comment {
     }
 
     /**
-     * Recursively search for the string "{@" followed by
+     * Recursively search for the characters '{', '@', followed by
      * name of inline tag and white space,
      * if found
      *    return the index of the text following the white space.
diff --git a/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java b/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java
index 980bd8b..1753a31 100644
--- a/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ConstructorDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,14 +27,18 @@ package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
 
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Represents a constructor of a java class.
  *
+ *  <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.2
  * @author Robert Field
  * @author Neal Gafter (rewrite)
@@ -53,9 +57,8 @@ public class ConstructorDocImpl
     /**
      * constructor.
      */
-    public ConstructorDocImpl(DocEnv env, MethodSymbol sym,
-                              String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
-        super(env, sym, docComment, tree, lineMap);
+    public ConstructorDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/javadoc/DocEnv.java b/src/share/classes/com/sun/tools/javadoc/DocEnv.java
index 5887c50..3a1c891 100644
--- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java
+++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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,18 +27,22 @@ package com.sun.tools.javadoc;
 
 import java.lang.reflect.Modifier;
 import java.util.*;
+
 import javax.tools.JavaFileManager;
 
 import com.sun.javadoc.*;
-
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.javac.api.BasicJavacTask;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.ClassType;
 import com.sun.tools.javac.comp.Check;
+import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Holds the environment for a run of javadoc.
@@ -46,6 +50,11 @@ import com.sun.tools.javac.util.Position;
  * run and not the compiler info that could be GC'ed
  * or ported.
  *
+ *  <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.4
  * @author Robert Field
  * @author Neal Gafter (rewrite)
@@ -97,6 +106,10 @@ public class DocEnv {
     Check chk;
     Types types;
     JavaFileManager fileManager;
+    Context context;
+    DocLint doclint;
+
+    WeakHashMap<JCTree, TreePath> treePaths = new WeakHashMap<JCTree, TreePath>();
 
     /** Allow documenting from class files? */
     boolean docClasses = false;
@@ -117,6 +130,7 @@ public class DocEnv {
      */
     protected DocEnv(Context context) {
         context.put(docEnvKey, this);
+        this.context = context;
 
         messager = Messager.instance0(context);
         syms = Symtab.instance(context);
@@ -204,8 +218,8 @@ public class DocEnv {
     public void setLocale(String localeName) {
         // create locale specifics
         doclocale = new DocLocale(this, localeName, breakiterator);
-        // reset Messager if locale has changed.
-        messager.reset();
+        // update Messager if locale has changed.
+        messager.setLocale(doclocale.locale);
     }
 
     /** Check whether this member should be documented. */
@@ -389,6 +403,9 @@ public class DocEnv {
     public void warning(DocImpl doc, String key, String a1) {
         if (silent)
             return;
+        // suppress messages that have (probably) been covered by doclint
+        if (doclint != null && doc != null && key.startsWith("tag"))
+            return;
         messager.warning(doc==null ? null : doc.position(), key, a1);
     }
 
@@ -533,13 +550,12 @@ public class DocEnv {
     /**
      * Create the PackageDoc (or a subtype) for a package symbol.
      */
-    void makePackageDoc(PackageSymbol pack, String docComment, JCCompilationUnit tree) {
+    void makePackageDoc(PackageSymbol pack, TreePath treePath) {
         PackageDocImpl result = packageMap.get(pack);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
         } else {
-            result = new PackageDocImpl(this, pack, docComment, tree);
+            result = new PackageDocImpl(this, pack, treePath);
             packageMap.put(pack, result);
         }
     }
@@ -565,17 +581,16 @@ public class DocEnv {
     /**
      * Create the ClassDoc (or a subtype) for a class symbol.
      */
-    protected void makeClassDoc(ClassSymbol clazz, String docComment, JCClassDecl tree, Position.LineMap lineMap) {
+    protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
         ClassDocImpl result = classMap.get(clazz);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
             return;
         }
-        if (isAnnotationType(tree)) {   // flags of clazz may not yet be set
-            result = new AnnotationTypeDocImpl(this, clazz, docComment, tree, lineMap);
+        if (isAnnotationType((JCClassDecl) treePath.getLeaf())) {   // flags of clazz may not yet be set
+            result = new AnnotationTypeDocImpl(this, clazz, treePath);
         } else {
-            result = new ClassDocImpl(this, clazz, docComment, tree, lineMap);
+            result = new ClassDocImpl(this, clazz, treePath);
         }
         classMap.put(clazz, result);
     }
@@ -603,13 +618,12 @@ public class DocEnv {
     /**
      * Create a FieldDoc for a var symbol.
      */
-    protected void makeFieldDoc(VarSymbol var, String docComment, JCVariableDecl tree, Position.LineMap lineMap) {
+    protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
         FieldDocImpl result = fieldMap.get(var);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
         } else {
-            result = new FieldDocImpl(this, var, docComment, tree, lineMap);
+            result = new FieldDocImpl(this, var, treePath);
             fieldMap.put(var, result);
         }
     }
@@ -620,14 +634,12 @@ public class DocEnv {
      * Create a MethodDoc for this MethodSymbol.
      * Should be called only on symbols representing methods.
      */
-    protected void makeMethodDoc(MethodSymbol meth, String docComment,
-                       JCMethodDecl tree, Position.LineMap lineMap) {
+    protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
         MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
         } else {
-            result = new MethodDocImpl(this, meth, docComment, tree, lineMap);
+            result = new MethodDocImpl(this, meth, treePath);
             methodMap.put(meth, result);
         }
     }
@@ -649,14 +661,12 @@ public class DocEnv {
      * Create the ConstructorDoc for a MethodSymbol.
      * Should be called only on symbols representing constructors.
      */
-    protected void makeConstructorDoc(MethodSymbol meth, String docComment,
-                            JCMethodDecl tree, Position.LineMap lineMap) {
+    protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
         ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
         } else {
-            result = new ConstructorDocImpl(this, meth, docComment, tree, lineMap);
+            result = new ConstructorDocImpl(this, meth, treePath);
             methodMap.put(meth, result);
         }
     }
@@ -678,16 +688,14 @@ public class DocEnv {
      * Create the AnnotationTypeElementDoc for a MethodSymbol.
      * Should be called only on symbols representing annotation type elements.
      */
-    protected void makeAnnotationTypeElementDoc(MethodSymbol meth,
-                                      String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
+    protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
         AnnotationTypeElementDocImpl result =
             (AnnotationTypeElementDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (docComment != null) result.setRawCommentText(docComment);
-            if (tree != null) result.setTree(tree);
+            if (treePath != null) result.setTreePath(treePath);
         } else {
             result =
-                new AnnotationTypeElementDocImpl(this, meth, docComment, tree, lineMap);
+                new AnnotationTypeElementDocImpl(this, meth, treePath);
             methodMap.put(meth, result);
         }
     }
@@ -723,6 +731,24 @@ public class DocEnv {
 //      return result;
     }
 
+    TreePath getTreePath(JCCompilationUnit tree) {
+        TreePath p = treePaths.get(tree);
+        if (p == null)
+            treePaths.put(tree, p = new TreePath(tree));
+        return p;
+    }
+
+    TreePath getTreePath(JCCompilationUnit toplevel, JCClassDecl tree) {
+        TreePath p = treePaths.get(tree);
+        if (p == null)
+            treePaths.put(tree, p = new TreePath(getTreePath(toplevel), tree));
+        return p;
+    }
+
+    TreePath getTreePath(JCCompilationUnit toplevel, JCClassDecl cdecl, JCTree tree) {
+        return new TreePath(getTreePath(toplevel, cdecl), tree);
+    }
+
     /**
      * Set the encoding.
      */
@@ -767,4 +793,29 @@ public class DocEnv {
             result |= Modifier.VOLATILE;
         return result;
     }
+
+    void initDoclint(Collection<String> opts) {
+        ArrayList<String> doclintOpts = new ArrayList<String>();
+
+        for (String opt: opts) {
+            doclintOpts.add(opt == null ? DocLint.XMSGS_OPTION : DocLint.XMSGS_CUSTOM_PREFIX + opt);
+        }
+
+        if (doclintOpts.isEmpty()) {
+            doclintOpts.add(DocLint.XMSGS_OPTION);
+        } else if (doclintOpts.size() == 1
+                && doclintOpts.get(0).equals(DocLint.XMSGS_CUSTOM_PREFIX + "none")) {
+            return;
+        }
+
+        JavacTask t = BasicJavacTask.instance(context);
+        doclint = new DocLint();
+        // standard doclet normally generates H1, H2
+        doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
+        doclint.init(t, doclintOpts.toArray(new String[doclintOpts.size()]), false);
+    }
+
+    boolean showTagMessages() {
+        return (doclint == null);
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/DocImpl.java b/src/share/classes/com/sun/tools/javadoc/DocImpl.java
index b3dbcab..8bae53d 100644
--- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,16 +26,19 @@
 package com.sun.tools.javadoc;
 
 import java.io.DataInputStream;
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.text.CollationKey;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import javax.tools.FileObject;
 
 import com.sun.javadoc.*;
-
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.util.Position;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * abstract base class of all Doc classes.  Doc item's are representations
@@ -43,6 +46,11 @@ import java.util.regex.Pattern;
  * comments and have been processed by this run of javadoc.  All Doc items
  * are unique, that is, they are == comparable.
  *
+ *  <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.2
  * @author Robert Field
  * @author Atul M Dambalkar
@@ -56,6 +64,12 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
     protected final DocEnv env;   //### Rename this everywhere to 'docenv' ?
 
     /**
+     * Back pointer to the tree node for this doc item.
+     * May be null if there is no associated tree.
+     */
+    protected TreePath treePath;
+
+    /**
      *  The complex comment object, lazily initialized.
      */
     private Comment comment;
@@ -83,11 +97,21 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
     /**
      * Constructor.
      */
-    DocImpl(DocEnv env, String documentation) {
-        this.documentation = documentation;
+    DocImpl(DocEnv env, TreePath treePath) {
+        this.treePath = treePath;
+        this.documentation = getCommentText(treePath);
         this.env = env;
     }
 
+    private static String getCommentText(TreePath p) {
+        if (p == null)
+            return null;
+
+        JCCompilationUnit topLevel = (JCCompilationUnit) p.getCompilationUnit();
+        JCTree tree = (JCTree) p.getLeaf();
+        return topLevel.docComments.getCommentText(tree);
+    }
+
     /**
      * So subclasses have the option to do lazy initialization of
      * "documentation" string.
@@ -102,7 +126,13 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
      */
     Comment comment() {
         if (comment == null) {
-            comment = new Comment(this, documentation());
+            String d = documentation();
+            if (env.doclint != null
+                    && treePath != null
+                    && d.equals(getCommentText(treePath))) {
+                env.doclint.scan(treePath);
+            }
+            comment = new Comment(this, d);
         }
         return comment;
     }
@@ -138,7 +168,7 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
     /**
      * Return the see also tags in this Doc item.
      *
-     * @return an array of SeeTag containing all &#64see tags.
+     * @return an array of SeeTag containing all @see tags.
      */
     public SeeTag[] seeTags() {
         return comment().seeTags();
@@ -208,11 +238,21 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
      * operations like internalization.
      */
     public void setRawCommentText(String rawDocumentation) {
+        treePath = null;
         documentation = rawDocumentation;
         comment = null;
     }
 
     /**
+     * Set the full unprocessed text of the comment and tree path.
+     */
+    void setTreePath(TreePath treePath) {
+        this.treePath = treePath;
+        documentation = getCommentText(treePath);
+        comment = null;
+    }
+
+    /**
      * return a key for sorting.
      */
     CollationKey key() {
@@ -262,7 +302,7 @@ public abstract class DocImpl implements Doc, Comparable<Object> {
      * <p>
      * Included so that Doc item are java.lang.Comparable.
      *
-     * @param   o the <code>Object</code> to be compared.
+     * @param   obj the {@code Object} to be compared.
      * @return  a negative integer, zero, or a positive integer as this Object
      *          is less than, equal to, or greater than the given Object.
      * @exception ClassCastException the specified Object's type prevents it
diff --git a/src/share/classes/com/sun/tools/javadoc/DocLocale.java b/src/share/classes/com/sun/tools/javadoc/DocLocale.java
index 6ac6a1e..2be308d 100644
--- a/src/share/classes/com/sun/tools/javadoc/DocLocale.java
+++ b/src/share/classes/com/sun/tools/javadoc/DocLocale.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -25,14 +25,18 @@
 
 package com.sun.tools.javadoc;
 
-import java.util.Locale;
-import java.util.HashSet;
-import java.text.Collator;
 import java.text.BreakIterator;
+import java.text.Collator;
+import java.util.Locale;
 
 /**
  * This class holds the information about locales.
  *
+ *  <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.4
  * @author Robert Field
  */
@@ -45,7 +49,7 @@ class DocLocale {
     final String localeName;
 
     /**
-     * The locale to be used. If user doesen't provide this,
+     * The locale to be used. If user doesn't provide this,
      * then set it to default locale value.
      */
     final Locale locale;
@@ -94,7 +98,7 @@ class DocLocale {
         if (locale == null) {
             docenv.exit();
         } else {
-            Locale.setDefault(locale);
+            Locale.setDefault(locale); // NOTE: updating global state
         }
         collator = Collator.getInstance(locale);
         sentenceBreaker = BreakIterator.getSentenceInstance(locale);
diff --git a/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java b/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
index 07402f9..3fedeee 100644
--- a/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
+++ b/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,22 +25,31 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.javadoc.*;
-
-import static com.sun.javadoc.LanguageVersion.*;
-
-import com.sun.tools.javac.util.List;
-
 import java.io.File;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.net.URLClassLoader;
 
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+
+import com.sun.javadoc.*;
+import com.sun.tools.javac.file.Locations;
+import com.sun.tools.javac.util.ClientCodeException;
+import com.sun.tools.javac.util.List;
+import static com.sun.javadoc.LanguageVersion.*;
+
 
 /**
  * Class creates, controls and invokes doclets.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
  * @author Neal Gafter (rewrite)
  */
 public class DocletInvoker {
@@ -53,6 +62,12 @@ public class DocletInvoker {
 
     private final Messager messager;
 
+    /**
+     * In API mode, exceptions thrown while calling the doclet are
+     * propagated using ClientCodeException.
+     */
+    private final boolean apiMode;
+
     private static class DocletInvokeException extends Exception {
         private static final long serialVersionUID = 0;
     }
@@ -67,31 +82,45 @@ public class DocletInvoker {
         }
     }
 
-    public DocletInvoker(Messager messager,
+    public DocletInvoker(Messager messager, Class<?> docletClass, boolean apiMode) {
+        this.messager = messager;
+        this.docletClass = docletClass;
+        docletClassName = docletClass.getName();
+        appClassLoader = null;
+        this.apiMode = apiMode;
+    }
+
+    public DocletInvoker(Messager messager, JavaFileManager fileManager,
                          String docletClassName, String docletPath,
-                         ClassLoader docletParentClassLoader) {
+                         ClassLoader docletParentClassLoader,
+                         boolean apiMode) {
         this.messager = messager;
         this.docletClassName = docletClassName;
+        this.apiMode = apiMode;
 
-        // construct class loader
-        String cpString = null;   // make sure env.class.path defaults to dot
+        if (fileManager != null && fileManager.hasLocation(DocumentationTool.Location.DOCLET_PATH)) {
+            appClassLoader = fileManager.getClassLoader(DocumentationTool.Location.DOCLET_PATH);
+        } else {
+            // construct class loader
+            String cpString = null;   // make sure env.class.path defaults to dot
 
-        // do prepends to get correct ordering
-        cpString = appendPath(System.getProperty("env.class.path"), cpString);
-        cpString = appendPath(System.getProperty("java.class.path"), cpString);
-        cpString = appendPath(docletPath, cpString);
-        URL[] urls = com.sun.tools.javac.file.Paths.pathToURLs(cpString);
-        if (docletParentClassLoader == null)
-            appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
-        else
-            appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
+            // do prepends to get correct ordering
+            cpString = appendPath(System.getProperty("env.class.path"), cpString);
+            cpString = appendPath(System.getProperty("java.class.path"), cpString);
+            cpString = appendPath(docletPath, cpString);
+            URL[] urls = Locations.pathToURLs(cpString);
+            if (docletParentClassLoader == null)
+                appClassLoader = new URLClassLoader(urls, getDelegationClassLoader(docletClassName));
+            else
+                appClassLoader = new URLClassLoader(urls, docletParentClassLoader);
+        }
 
         // attempt to find doclet
         Class<?> dc = null;
         try {
             dc = appClassLoader.loadClass(docletClassName);
         } catch (ClassNotFoundException exc) {
-            messager.error(null, "main.doclet_class_not_found", docletClassName);
+            messager.error(Messager.NOPOS, "main.doclet_class_not_found", docletClassName);
             messager.exit();
         }
         docletClass = dc;
@@ -164,7 +193,7 @@ public class DocletInvoker {
         if (retVal instanceof Boolean) {
             return ((Boolean)retVal).booleanValue();
         } else {
-            messager.error(null, "main.must_return_boolean",
+            messager.error(Messager.NOPOS, "main.must_return_boolean",
                            docletClassName, methodName);
             return false;
         }
@@ -188,7 +217,7 @@ public class DocletInvoker {
         if (retVal instanceof Integer) {
             return ((Integer)retVal).intValue();
         } else {
-            messager.error(null, "main.must_return_int",
+            messager.error(Messager.NOPOS, "main.must_return_int",
                            docletClassName, methodName);
             return -1;
         }
@@ -213,7 +242,7 @@ public class DocletInvoker {
         if (retVal instanceof Boolean) {
             return ((Boolean)retVal).booleanValue();
         } else {
-            messager.error(null, "main.must_return_boolean",
+            messager.error(Messager.NOPOS, "main.must_return_boolean",
                            docletClassName, methodName);
             return false;
         }
@@ -237,7 +266,7 @@ public class DocletInvoker {
             if (retVal instanceof LanguageVersion) {
                 return (LanguageVersion)retVal;
             } else {
-                messager.error(null, "main.must_return_languageversion",
+                messager.error(Messager.NOPOS, "main.must_return_languageversion",
                                docletClassName, methodName);
                 return JAVA_1_1;
             }
@@ -257,45 +286,48 @@ public class DocletInvoker {
                 meth = docletClass.getMethod(methodName, paramTypes);
             } catch (NoSuchMethodException exc) {
                 if (returnValueIfNonExistent == null) {
-                    messager.error(null, "main.doclet_method_not_found",
+                    messager.error(Messager.NOPOS, "main.doclet_method_not_found",
                                    docletClassName, methodName);
                     throw new DocletInvokeException();
                 } else {
                     return returnValueIfNonExistent;
                 }
             } catch (SecurityException exc) {
-                messager.error(null, "main.doclet_method_not_accessible",
+                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             }
             if (!Modifier.isStatic(meth.getModifiers())) {
-                messager.error(null, "main.doclet_method_must_be_static",
+                messager.error(Messager.NOPOS, "main.doclet_method_must_be_static",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             }
             ClassLoader savedCCL =
                 Thread.currentThread().getContextClassLoader();
             try {
-                Thread.currentThread().setContextClassLoader(appClassLoader);
+                if (appClassLoader != null) // will be null if doclet class provided via API
+                    Thread.currentThread().setContextClassLoader(appClassLoader);
                 return meth.invoke(null , params);
             } catch (IllegalArgumentException exc) {
-                messager.error(null, "main.internal_error_exception_thrown",
+                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                                docletClassName, methodName, exc.toString());
                 throw new DocletInvokeException();
             } catch (IllegalAccessException exc) {
-                messager.error(null, "main.doclet_method_not_accessible",
+                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                                docletClassName, methodName);
                 throw new DocletInvokeException();
             } catch (NullPointerException exc) {
-                messager.error(null, "main.internal_error_exception_thrown",
+                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                                docletClassName, methodName, exc.toString());
                 throw new DocletInvokeException();
             } catch (InvocationTargetException exc) {
                 Throwable err = exc.getTargetException();
+                if (apiMode)
+                    throw new ClientCodeException(err);
                 if (err instanceof java.lang.OutOfMemoryError) {
-                    messager.error(null, "main.out.of.memory");
+                    messager.error(Messager.NOPOS, "main.out.of.memory");
                 } else {
-                messager.error(null, "main.exception_thrown",
+                    messager.error(Messager.NOPOS, "main.exception_thrown",
                                docletClassName, methodName, exc.toString());
                     exc.getTargetException().printStackTrace();
                 }
diff --git a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java
index e024cc0..820e72d 100644
--- a/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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
@@ -30,17 +30,21 @@ import java.text.CollationKey;
 
 import com.sun.javadoc.*;
 
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Represents a method or constructor of a java class.
  *
+ *  <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.2
  * @author Robert Field
  * @author Neal Gafter (rewrite)
@@ -55,9 +59,8 @@ public abstract class ExecutableMemberDocImpl
     /**
      * Constructor.
      */
-    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym,
-                                   String rawDocs, JCMethodDecl tree, Position.LineMap lineMap) {
-        super(env, sym, rawDocs, tree, lineMap);
+    public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
         this.sym = sym;
     }
 
@@ -65,7 +68,7 @@ public abstract class ExecutableMemberDocImpl
      * Constructor.
      */
     public ExecutableMemberDocImpl(DocEnv env, MethodSymbol sym) {
-        this(env, sym, null, null, null);
+        this(env, sym, null);
     }
 
     /**
@@ -193,6 +196,17 @@ public abstract class ExecutableMemberDocImpl
     }
 
     /**
+     * Get the receiver type of this executable element.
+     *
+     * @return the receiver type of this executable element.
+     * @since 1.8
+     */
+    public com.sun.javadoc.Type receiverType() {
+        Type recvtype = sym.type.asMethodType().recvtype;
+        return (recvtype != null) ? TypeMaker.getType(env, recvtype, false, true) : null;
+    }
+
+    /**
      * Return the formal type parameters of this method or constructor.
      * Return an empty array if there are none.
      */
diff --git a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java
index 3a86558..8317128 100644
--- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,24 +25,25 @@
 
 package com.sun.tools.javadoc;
 
+import com.sun.source.util.TreePath;
 import java.lang.reflect.Modifier;
 
 import com.sun.javadoc.*;
 
-import static com.sun.javadoc.LanguageVersion.*;
-
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.TypeTags;
-
-import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
 
-import com.sun.tools.javac.util.Position;
+import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
 
 /**
  * Represents a field in a java class.
  *
+ *  <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>
+ *
  * @see MemberDocImpl
  *
  * @since 1.2
@@ -57,9 +58,8 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
     /**
      * Constructor.
      */
-    public FieldDocImpl(DocEnv env, VarSymbol sym,
-                        String rawDocs, JCVariableDecl tree, Position.LineMap lineMap) {
-        super(env, sym, rawDocs, tree, lineMap);
+    public FieldDocImpl(DocEnv env, VarSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
         this.sym = sym;
     }
 
@@ -67,7 +67,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
      * Constructor.
      */
     public FieldDocImpl(DocEnv env, VarSymbol sym) {
-        this(env, sym, null, null, null);
+        this(env, sym, null);
     }
 
     /**
@@ -100,7 +100,7 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
      */
     public Object constantValue() {
         Object result = sym.getConstValue();
-        if (result != null && sym.type.tag == TypeTags.BOOLEAN)
+        if (result != null && sym.type.hasTag(BOOLEAN))
             // javac represents false and true as Integers 0 and 1
             result = Boolean.valueOf(((Integer)result).intValue() != 0);
         return result;
@@ -241,20 +241,30 @@ public class FieldDocImpl extends MemberDocImpl implements FieldDoc {
      * Return the serialField tags in this FieldDocImpl item.
      *
      * @return an array of <tt>SerialFieldTagImpl</tt> containing all
-     *         <code>&#64serialField</code> tags.
+     *         <code>@serialField</code> tags.
      */
     public SerialFieldTag[] serialFieldTags() {
         return comment().serialFieldTags();
     }
 
     public String name() {
-        return sym.name.toString();
+        if (name == null) {
+            name = sym.name.toString();
+        }
+        return name;
     }
 
+    private String name;
+
     public String qualifiedName() {
-        return sym.enclClass().getQualifiedName() + "." + name();
+        if (qualifiedName == null) {
+            qualifiedName = sym.enclClass().getQualifiedName() + "." + name();
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Return the source position of the entity, or null if
      * no position is available.
diff --git a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java
index eb610c9..9cde12c 100644
--- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -33,6 +33,12 @@ import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.util.Context;
 
 /** Javadoc uses an extended class reader that records package.html entries
+ *
+ *  <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 Neal Gafter
  */
 public class JavadocClassReader extends ClassReader {
diff --git a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
index bb9f72d..cc0f212 100644
--- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, 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,18 +25,25 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.util.List;
+import javax.tools.JavaFileObject;
+
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.tree.JCTree.*;
-import javax.tools.JavaFileObject;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
 
 /**
  *  Javadoc's own enter phase does a few things above and beyond that
  *  done by javac.
+ *
+ *  <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 Neal Gafter
  */
 public class JavadocEnter extends Enter {
@@ -77,8 +84,7 @@ public class JavadocEnter extends Enter {
     public void visitTopLevel(JCCompilationUnit tree) {
         super.visitTopLevel(tree);
         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
-            String comment = tree.docComments.get(tree);
-            docenv.makePackageDoc(tree.packge, comment, tree);
+            docenv.makePackageDoc(tree.packge, docenv.getTreePath(tree));
         }
     }
 
@@ -87,9 +93,8 @@ public class JavadocEnter extends Enter {
         super.visitClassDef(tree);
         if (tree.sym == null) return;
         if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
-            String comment = env.toplevel.docComments.get(tree);
             ClassSymbol c = tree.sym;
-            docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
+            docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree));
         }
     }
 
diff --git a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
index 11cf105..0919b2a 100644
--- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
@@ -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
@@ -25,17 +25,22 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Position;
-import com.sun.tools.javac.code.Flags;
+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.MemberEnter;
 import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.util.Context;
 
 /**
  *  Javadoc's own memberEnter phase does a few things above and beyond that
  *  done by javac.
+ *
+ *  <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 Neal Gafter
  */
 public class JavadocMemberEnter extends MemberEnter {
@@ -61,35 +66,30 @@ public class JavadocMemberEnter extends MemberEnter {
         docenv = DocEnv.instance(context);
     }
 
+    @Override
     public void visitMethodDef(JCMethodDecl tree) {
         super.visitMethodDef(tree);
         MethodSymbol meth = tree.sym;
         if (meth == null || meth.kind != Kinds.MTH) return;
-        String docComment = env.toplevel.docComments.get(tree);
-        Position.LineMap lineMap = env.toplevel.lineMap;
+        TreePath treePath = docenv.getTreePath(env.toplevel, env.enclClass, tree);
         if (meth.isConstructor())
-            docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
+            docenv.makeConstructorDoc(meth, treePath);
         else if (isAnnotationTypeElement(meth))
-            docenv.makeAnnotationTypeElementDoc(meth, docComment, tree, lineMap);
+            docenv.makeAnnotationTypeElementDoc(meth, treePath);
         else
-            docenv.makeMethodDoc(meth, docComment, tree, lineMap);
+            docenv.makeMethodDoc(meth, treePath);
     }
 
+    @Override
     public void visitVarDef(JCVariableDecl tree) {
         super.visitVarDef(tree);
         if (tree.sym != null &&
                 tree.sym.getKind().isField()) {
-            String docComment = env.toplevel.docComments.get(tree);
-            Position.LineMap lineMap = env.toplevel.lineMap;
-            docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
+            docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, env.enclClass, tree));
         }
     }
 
     private static boolean isAnnotationTypeElement(MethodSymbol meth) {
         return ClassDocImpl.isAnnotationType(meth.enclClass());
     }
-
-    private static boolean isParameter(VarSymbol var) {
-        return (var.flags() & Flags.PARAMETER) != 0;
-    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java b/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java
index 6d69172..cbeaf69 100644
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,6 +31,12 @@ import com.sun.tools.javac.util.*;
 /**
  *  Javadoc's own todo queue doesn't queue its inputs, as javadoc
  *  doesn't perform attribution of method bodies or semantic checking.
+ *
+ *  <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 Neal Gafter
  */
 public class JavadocTodo extends Todo {
diff --git a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java
index 1209686..1cc3de3 100644
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -38,8 +38,6 @@ import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
-import com.sun.tools.javac.comp.Annotate;
-import com.sun.tools.javac.parser.DocCommentScanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
@@ -55,16 +53,20 @@ import com.sun.tools.javac.util.Position;
  *  component in a larger software system. It provides operations to
  *  construct a new javadoc processor, and to run it on a set of source
  *  files.
+ *
+ *  <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 Neal Gafter
  */
 public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
     DocEnv docenv;
 
-    final Context context;
     final Messager messager;
-    final JavadocClassReader reader;
-    final JavadocEnter enter;
-    final Annotate annotate;
+    final JavadocClassReader javadocReader;
+    final JavadocEnter javadocEnter;
 
     /**
      * Construct a new JavaCompiler processor, using appropriately
@@ -72,11 +74,9 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
      */
     protected JavadocTool(Context context) {
         super(context);
-        this.context = context;
         messager = Messager.instance0(context);
-        reader = JavadocClassReader.instance0(context);
-        enter = JavadocEnter.instance0(context);
-        annotate = Annotate.instance(context);
+        javadocReader = JavadocClassReader.instance0(context);
+        javadocEnter = JavadocEnter.instance0(context);
     }
 
     /**
@@ -119,6 +119,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
                                       ModifierFilter filter,
                                       List<String> javaNames,
                                       List<String[]> options,
+                                      Iterable<? extends JavaFileObject> fileObjects,
                                       boolean breakiterator,
                                       List<String> subPackages,
                                       List<String> excludedPackages,
@@ -133,17 +134,18 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
         docenv.setEncoding(encoding);
         docenv.docClasses = docClasses;
         docenv.legacyDoclet = legacyDoclet;
-        reader.sourceCompleter = docClasses ? null : this;
+        javadocReader.sourceCompleter = docClasses ? null : this;
 
         ListBuffer<String> names = new ListBuffer<String>();
         ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<JCCompilationUnit>();
         ListBuffer<JCCompilationUnit> packTrees = new ListBuffer<JCCompilationUnit>();
 
         try {
-            StandardJavaFileManager fm = (StandardJavaFileManager) docenv.fileManager;
+            StandardJavaFileManager fm = docenv.fileManager instanceof StandardJavaFileManager
+                    ? (StandardJavaFileManager) docenv.fileManager : null;
             for (List<String> it = javaNames; it.nonEmpty(); it = it.tail) {
                 String name = it.head;
-                if (!docClasses && name.endsWith(".java") && new File(name).exists()) {
+                if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) {
                     JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
                     docenv.notice("main.Loading_source_file", name);
                     JCCompilationUnit tree = parse(fo);
@@ -151,11 +153,19 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
                 } else if (isValidPackageName(name)) {
                     names = names.append(name);
                 } else if (name.endsWith(".java")) {
-                    docenv.error(null, "main.file_not_found", name);
+                    if (fm == null)
+                        throw new IllegalArgumentException();
+                    else
+                        docenv.error(null, "main.file_not_found", name);
                 } else {
                     docenv.error(null, "main.illegal_package_name", name);
                 }
             }
+            for (JavaFileObject fo: fileObjects) {
+                docenv.notice("main.Loading_source_file", fo.getName());
+                JCCompilationUnit tree = parse(fo);
+                classTrees.append(tree);
+            }
 
             if (!docClasses) {
                 // Recursively search given subpackages.  If any packages
@@ -174,7 +184,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
 
                 // Enter symbols for all files
                 docenv.notice("main.Building_tree");
-                enter.main(classTrees.toList().appendList(packTrees.toList()));
+                javadocEnter.main(classTrees.toList().appendList(packTrees.toList()));
             }
         } catch (Abort ex) {}
 
@@ -235,7 +245,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
         }
 
         if (!hasFiles) {
-            messager.warning(null, "main.no_source_files_for_package",
+            messager.warning(Messager.NOPOS, "main.no_source_files_for_package",
                     name.replace(File.separatorChar, '.'));
         }
     }
@@ -387,7 +397,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
     /**
      * Return true if given file name is a valid class name
      * (including "package-info").
-     * @param clazzname the name of the class to check.
+     * @param s the name of the class to check.
      * @return true if given class name is a valid class name
      * and false otherwise.
      */
@@ -420,7 +430,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
         ListBuffer<JCClassDecl> result = new ListBuffer<JCClassDecl>();
         for (JCCompilationUnit t : trees) {
             for (JCTree def : t.defs) {
-                if (def.getTag() == JCTree.CLASSDEF)
+                if (def.hasTag(JCTree.Tag.CLASSDEF))
                     result.append((JCClassDecl)def);
             }
         }
diff --git a/src/share/classes/com/sun/tools/javadoc/Main.java b/src/share/classes/com/sun/tools/javadoc/Main.java
index 086e13d..dfc21b2 100644
--- a/src/share/classes/com/sun/tools/javadoc/Main.java
+++ b/src/share/classes/com/sun/tools/javadoc/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -31,6 +31,11 @@ import java.io.PrintWriter;
  * Provides external entry points (tool and programmatic)
  * for the javadoc program.
  *
+ *  <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.4
  */
 public class Main {
diff --git a/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java b/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java
index 8dcd375..37c7c66 100644
--- a/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/MemberDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -27,9 +27,8 @@ package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
 
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.util.Position;
 
 /**
  * Represents a member of a java class: field, constructor, or method.
@@ -37,6 +36,11 @@ import com.sun.tools.javac.util.Position;
  * method, constructor and field members. Class members of a class
  * (nested classes) are represented instead by ClassDocImpl.
  *
+ *  <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>
+ *
  * @see MethodDocImpl
  * @see FieldDocImpl
  * @see ClassDocImpl
@@ -52,8 +56,8 @@ public abstract class MemberDocImpl
     /**
      * constructor.
      */
-    public MemberDocImpl(DocEnv env, Symbol sym, String doc, JCTree tree, Position.LineMap lineMap) {
-        super(env, sym, doc, tree, lineMap);
+    public MemberDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
+        super(env, sym, treePath);
     }
 
     /**
diff --git a/src/share/classes/com/sun/tools/javadoc/Messager.java b/src/share/classes/com/sun/tools/javadoc/Messager.java
index 5994e76..8de85bf 100644
--- a/src/share/classes/com/sun/tools/javadoc/Messager.java
+++ b/src/share/classes/com/sun/tools/javadoc/Messager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,15 +26,14 @@
 package com.sun.tools.javadoc;
 
 import java.io.PrintWriter;
-import java.text.MessageFormat;
-import java.util.ResourceBundle;
-import java.util.MissingResourceException;
+import java.util.Locale;
 
 import com.sun.javadoc.*;
-
 import com.sun.tools.javac.util.Context;
-
-import com.sun.tools.javac.util.Log;  // Access to 'javac' output streams
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
+import com.sun.tools.javac.util.JavacMessages;
+import com.sun.tools.javac.util.Log;
 
 /**
  * Utility for integrating with javadoc tools and for localization.
@@ -43,11 +42,17 @@ import com.sun.tools.javac.util.Log;  // Access to 'javac' output streams
  * <br>
  * Also provides implementation for DocErrorReporter.
  *
+ *  <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>
+ *
  * @see java.util.ResourceBundle
  * @see java.text.MessageFormat
  * @author Neal Gafter (rewrite)
  */
 public class Messager extends Log implements DocErrorReporter {
+    public static final SourcePosition NOPOS = null;
 
     /** Get the current messager, which is also the compiler log. */
     public static Messager instance0(Context context) {
@@ -88,7 +93,9 @@ public class Messager extends Log implements DocErrorReporter {
 
     final String programName;
 
-    private ResourceBundle messageRB = null;
+    private Locale locale;
+    private final JavacMessages messages;
+    private final JCDiagnostic.Factory javadocDiags;
 
     /** The default writer for diagnostics
      */
@@ -118,107 +125,24 @@ public class Messager extends Log implements DocErrorReporter {
                        PrintWriter warnWriter,
                        PrintWriter noticeWriter) {
         super(context, errWriter, warnWriter, noticeWriter);
+        messages = JavacMessages.instance(context);
+        messages.add("com.sun.tools.javadoc.resources.javadoc");
+        javadocDiags = new JCDiagnostic.Factory(messages, "javadoc");
         this.programName = programName;
     }
 
-    @Override
-    protected int getDefaultMaxErrors() {
-        return Integer.MAX_VALUE;
-    }
-
-    @Override
-    protected int getDefaultMaxWarnings() {
-        return Integer.MAX_VALUE;
-    }
-
-    /**
-     * Reset resource bundle, eg. locale has changed.
-     */
-    public void reset() {
-        messageRB = null;
-    }
-
-    /**
-     * Get string from ResourceBundle, initialize ResourceBundle
-     * if needed.
-     */
-    private String getString(String key) {
-        if (messageRB == null) {
-            try {
-                messageRB = ResourceBundle.getBundle(
-                          "com.sun.tools.javadoc.resources.javadoc");
-            } catch (MissingResourceException e) {
-                throw new Error("Fatal: Resource for javadoc is missing");
-            }
-        }
-        return messageRB.getString(key);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     */
-    String getText(String key) {
-        return getText(key, (String)null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    String getText(String key, String a1) {
-        return getText(key, a1, null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    String getText(String key, String a1, String a2) {
-        return getText(key, a1, a2, null);
-    }
-
-    /**
-     * get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    String getText(String key, String a1, String a2, String a3) {
-        return getText(key, a1, a2, a3, null);
+    public void setLocale(Locale locale) {
+        this.locale = locale;
     }
 
     /**
      * get and format message string from resource
      *
      * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     * @param a4 fourth argument
+     * @param args arguments for the message
      */
-    String getText(String key, String a1, String a2, String a3,
-                          String a4) {
-        try {
-            String message = getString(key);
-            String[] args = new String[4];
-            args[0] = a1;
-            args[1] = a2;
-            args[2] = a3;
-            args[3] = a4;
-            return MessageFormat.format(message, (Object[])args);
-        } catch (MissingResourceException e) {
-            return "********** Resource for javadoc is broken. There is no " +
-                key + " key in resource.";
-        }
+    String getText(String key, Object... args) {
+        return messages.getLocalizedString(locale, key, args);
     }
 
     /**
@@ -239,6 +163,11 @@ public class Messager extends Log implements DocErrorReporter {
      * @param msg message to print
      */
     public void printError(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.ERROR, pos, msg);
+            return;
+        }
+
         if (nerrors < MaxErrors) {
             String prefix = (pos == null) ? programName : pos.toString();
             errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
@@ -266,6 +195,11 @@ public class Messager extends Log implements DocErrorReporter {
      * @param msg message to print
      */
     public void printWarning(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.WARNING, pos, msg);
+            return;
+        }
+
         if (nwarnings < MaxWarnings) {
             String prefix = (pos == null) ? programName : pos.toString();
             warnWriter.println(prefix +  ": " + getText("javadoc.warning") +" - " + msg);
@@ -292,6 +226,11 @@ public class Messager extends Log implements DocErrorReporter {
      * @param msg message to print
      */
     public void printNotice(SourcePosition pos, String msg) {
+        if (diagListener != null) {
+            report(DiagnosticType.NOTE, pos, msg);
+            return;
+        }
+
         if (pos == null)
             noticeWriter.println(msg);
         else
@@ -304,138 +243,26 @@ public class Messager extends Log implements DocErrorReporter {
      *
      * @param key selects message from resource
      */
-    public void error(SourcePosition pos, String key) {
-        printError(pos, getText(key));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    public void error(SourcePosition pos, String key, String a1) {
-        printError(pos, getText(key, a1));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2) {
-        printError(pos, getText(key, a1, a2));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void error(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printError(pos, getText(key, a1, a2, a3));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     */
-    public void warning(SourcePosition pos, String key) {
-        printWarning(pos, getText(key));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     */
-    public void warning(SourcePosition pos, String key, String a1) {
-        printWarning(pos, getText(key, a1));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2) {
-        printWarning(pos, getText(key, a1, a2));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2, String a3) {
-        printWarning(pos, getText(key, a1, a2, a3));
+    public void error(SourcePosition pos, String key, Object... args) {
+        printError(pos, getText(key, args));
     }
 
     /**
      * Print warning message, increment warning count.
      *
      * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void warning(SourcePosition pos, String key, String a1, String a2, String a3,
-                        String a4) {
-        printWarning(pos, getText(key, a1, a2, a3, a4));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
      */
-    public void notice(String key) {
-        printNotice(getText(key));
+    public void warning(SourcePosition pos, String key, Object... args) {
+        printWarning(pos, getText(key, args));
     }
 
     /**
      * Print a message.
      *
      * @param key selects message from resource
-     * @param a1 first argument
      */
-    public void notice(String key, String a1) {
-        printNotice(getText(key, a1));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     */
-    public void notice(String key, String a1, String a2) {
-        printNotice(getText(key, a1, a2));
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param a1 first argument
-     * @param a2 second argument
-     * @param a3 third argument
-     */
-    public void notice(String key, String a1, String a2, String a3) {
-        printNotice(getText(key, a1, a2, a3));
+    public void notice(String key, Object... args) {
+        printNotice(getText(key, args));
     }
 
     /**
@@ -473,4 +300,21 @@ public class Messager extends Log implements DocErrorReporter {
         throw new ExitJavadoc();
     }
 
+    private void report(DiagnosticType type, SourcePosition pos, String msg) {
+        switch (type) {
+            case ERROR:
+            case WARNING:
+                Object prefix = (pos == null) ? programName : pos;
+                report(javadocDiags.create(type, null, null, "msg", prefix, msg));
+                break;
+
+            case NOTE:
+                String key = (pos == null) ? "msg" : "pos.msg";
+                report(javadocDiags.create(type, null, null, key, pos, msg));
+                break;
+
+            default:
+                throw new IllegalArgumentException(type.toString());
+        }
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
index 72ed86d..4d5d191 100644
--- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, 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,20 +25,23 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.javadoc.*;
+import java.lang.reflect.Modifier;
 
+import com.sun.javadoc.*;
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.TypeTags;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
-import com.sun.tools.javac.util.Position;
-
-import java.lang.reflect.Modifier;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
 
 /**
  * Represents a method of a java class.
  *
+ *  <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.2
  * @author Robert Field
  * @author Neal Gafter (rewrite)
@@ -57,9 +60,8 @@ public class MethodDocImpl
     /**
      * constructor.
      */
-    public MethodDocImpl(DocEnv env, MethodSymbol sym,
-                         String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
-        super(env, sym, docComment, tree, lineMap);
+    public MethodDocImpl(DocEnv env, MethodSymbol sym, TreePath treePath) {
+        super(env, sym, treePath);
     }
 
     /**
@@ -74,19 +76,17 @@ public class MethodDocImpl
     }
 
     /**
+     * Return true if this method is default
+     */
+    public boolean isDefault() {
+        return (sym.flags() & Flags.DEFAULT) != 0;
+    }
+
+    /**
      * Return true if this method is abstract
      */
     public boolean isAbstract() {
-        //### This is dubious, but old 'javadoc' apparently does it.
-        //### I regard this as a bug and an obstacle to treating the
-        //### doclet API as a proper compile-time reflection facility.
-        //### (maddox 09/26/2000)
-        if (containingClass().isInterface()) {
-            //### Don't force creation of ClassDocImpl for super here.
-            // Abstract modifier is implicit.  Strip/canonicalize it.
-            return false;
-        }
-        return Modifier.isAbstract(getModifiers());
+        return (Modifier.isAbstract(getModifiers()) && !isDefault());
     }
 
     /**
@@ -125,7 +125,7 @@ public class MethodDocImpl
 
         ClassSymbol origin = (ClassSymbol)sym.owner;
         for (Type t = env.types.supertype(origin.type);
-             t.tag == TypeTags.CLASS;
+             t.hasTag(CLASS);
              t = env.types.supertype(t)) {
             ClassSymbol c = (ClassSymbol)t.tsym;
             for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
@@ -157,7 +157,7 @@ public class MethodDocImpl
 
         ClassSymbol origin = (ClassSymbol)sym.owner;
         for (Type t = env.types.supertype(origin.type);
-             t.tag == TypeTags.CLASS;
+             t.hasTag(CLASS);
              t = env.types.supertype(t)) {
             ClassSymbol c = (ClassSymbol)t.tsym;
             for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
@@ -203,13 +203,23 @@ public class MethodDocImpl
 
 
     public String name() {
-        return sym.name.toString();
+        if (name == null) {
+            name = sym.name.toString();
+        }
+        return name;
     }
 
+    private String name;
+
     public String qualifiedName() {
-        return sym.enclClass().getQualifiedName() + "." + sym.name;
+        if (qualifiedName == null) {
+            qualifiedName =  sym.enclClass().getQualifiedName() + "." + sym.name;
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * Returns a string representation of this method.  Includes the
      * qualified signature, the qualified method name, and any type
diff --git a/src/share/classes/com/sun/tools/javadoc/ModifierFilter.java b/src/share/classes/com/sun/tools/javadoc/ModifierFilter.java
index 5e96372..40a9040 100644
--- a/src/share/classes/com/sun/tools/javadoc/ModifierFilter.java
+++ b/src/share/classes/com/sun/tools/javadoc/ModifierFilter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -32,7 +32,13 @@ import static com.sun.tools.javac.code.Flags.*;
  *   Filtering is done by returning boolean values.
  *   Classes, methods and fields can be filtered, or filtering
  *   can be done directly on modifier bits.
- *   @see com.sun.tools.javac.code.Flags;
+ *
+ *  <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>
+ *
+ *   @see com.sun.tools.javac.code.Flags
  *   @author Robert Field
  */
 
diff --git a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java
index 4c7e472..2f11b81 100644
--- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,12 +25,13 @@
 
 package com.sun.tools.javadoc;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
+
 import javax.tools.FileObject;
 
 import com.sun.javadoc.*;
-
+import com.sun.source.util.TreePath;
 import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
@@ -47,6 +48,11 @@ import com.sun.tools.javac.util.Position;
  * about the package, the package's comment and tags, and the
  * classes in the package.
  *
+ *  <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.2
  * @author Kaiyang Liu (original)
  * @author Robert Field (rewrite)
@@ -70,17 +76,16 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
      * Constructor
      */
     public PackageDocImpl(DocEnv env, PackageSymbol sym) {
-        this(env, sym, null, null);
+        this(env, sym, null);
     }
 
     /**
      * Constructor
      */
-    public PackageDocImpl(DocEnv env, PackageSymbol sym,
-                          String documentation, JCTree tree) {
-        super(env, documentation);
+    public PackageDocImpl(DocEnv env, PackageSymbol sym, TreePath treePath) {
+        super(env, treePath);
         this.sym = sym;
-        this.tree = (JCCompilationUnit) tree;
+        this.tree = (treePath == null) ? null : (JCCompilationUnit) treePath.getCompilationUnit();
         foundDoc = (documentation != null);
     }
 
@@ -88,8 +93,8 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
         this.tree = (JCCompilationUnit) tree;
     }
 
-    public void setRawCommentText(String rawDocumentation) {
-        super.setRawCommentText(rawDocumentation);
+    public void setTreePath(TreePath treePath) {
+        super.setTreePath(treePath);
         checkDoc();
     }
 
@@ -283,9 +288,9 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
      * Return an empty array if there are none.
      */
     public AnnotationDesc[] annotations() {
-        AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
+        AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
         int i = 0;
-        for (Attribute.Compound a : sym.getAnnotationMirrors()) {
+        for (Attribute.Compound a : sym.getRawAttributes()) {
             res[i++] = new AnnotationDescImpl(env, a);
         }
         return res;
@@ -329,12 +334,17 @@ public class PackageDocImpl extends DocImpl implements PackageDoc {
      * Get package name.
      */
     public String qualifiedName() {
-        Name fullname = sym.getQualifiedName();
-        // Some bogus tests depend on the interned "" being returned.
-        // See 6457276.
-        return fullname.isEmpty() ? "" : fullname.toString();
+        if (qualifiedName == null) {
+            Name fullname = sym.getQualifiedName();
+            // Some bogus tests depend on the interned "" being returned.
+            // See 6457276.
+            qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
+        }
+        return qualifiedName;
     }
 
+    private String qualifiedName;
+
     /**
      * set doc path for an unzipped directory
      */
diff --git a/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java b/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java
index 60809bb..e877539 100644
--- a/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -33,12 +33,17 @@ import com.sun.javadoc.*;
  * Represents an @param documentation tag.
  * Parses and stores the name and comment parts of the parameter tag.
  *
+ *  <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 Robert Field
  *
  */
 class ParamTagImpl extends TagImpl implements ParamTag {
 
-    private static Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
+    private static final Pattern typeParamRE = Pattern.compile("<([^<>]+)>");
 
     private final String parameterName;
     private final String parameterComment;
@@ -101,8 +106,8 @@ class ParamTagImpl extends TagImpl implements ParamTag {
      * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
      *
      * @return TagImpl[] Array of tags with inline SeeTagImpls.
-     * @see TagImpl#inlineTagImpls()
-     * @see ThrowsTagImpl#inlineTagImpls()
+     * @see TagImpl#inlineTags()
+     * @see ThrowsTagImpl#inlineTags()
      */
     @Override
     public Tag[] inlineTags() {
diff --git a/src/share/classes/com/sun/tools/javadoc/ParameterImpl.java b/src/share/classes/com/sun/tools/javadoc/ParameterImpl.java
index 9ac19a1..14de4a2 100644
--- a/src/share/classes/com/sun/tools/javadoc/ParameterImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ParameterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -29,12 +29,16 @@ import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.code.Type;
 
 /**
  * ParameterImpl information.
  * This includes a parameter type and parameter name.
  *
+ *  <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 Kaiyang Liu (original)
  * @author Robert Field (rewrite)
  * @author Scott Seligman (generics, annotations)
@@ -95,9 +99,9 @@ class ParameterImpl implements Parameter {
      * Return an empty array if there are none.
      */
     public AnnotationDesc[] annotations() {
-        AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
+        AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
         int i = 0;
-        for (Attribute.Compound a : sym.getAnnotationMirrors()) {
+        for (Attribute.Compound a : sym.getRawAttributes()) {
             res[i++] = new AnnotationDescImpl(env, a);
         }
         return res;
diff --git a/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java
index 838994f..2fac111 100644
--- a/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,13 +31,18 @@ import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
 
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.CLASS;
 
 
 /**
  * Implementation of <code>ParameterizedType</code>, which
  * represents an invocation of a generic class or interface.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -90,7 +95,7 @@ public class ParameterizedTypeImpl
      * Return null is this is a top-level type.
      */
     public com.sun.javadoc.Type containingType() {
-        if (type.getEnclosingType().tag == CLASS) {
+        if (type.getEnclosingType().hasTag(CLASS)) {
             // This is the type of an inner class.
             return TypeMaker.getType(env, type.getEnclosingType());
         }
@@ -129,7 +134,7 @@ public class ParameterizedTypeImpl
             return TypeMaker.getTypeName(cl, full);
         }
         StringBuilder s = new StringBuilder();
-        if (cl.getEnclosingType().tag != CLASS) {               // if not an inner class...
+        if (!(cl.getEnclosingType().hasTag(CLASS))) {               // if not an inner class...
             s.append(TypeMaker.getTypeName(cl, full));
         } else {
             ClassType encl = (ClassType)cl.getEnclosingType();
diff --git a/src/share/classes/com/sun/tools/javadoc/PrimitiveType.java b/src/share/classes/com/sun/tools/javadoc/PrimitiveType.java
index be61228..a3a8198 100644
--- a/src/share/classes/com/sun/tools/javadoc/PrimitiveType.java
+++ b/src/share/classes/com/sun/tools/javadoc/PrimitiveType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2003, 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,13 +27,12 @@ package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
 
-import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
-
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.code.TypeTags;
-import com.sun.tools.javac.code.Type.ClassType;
-
+/**
+ *  <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>
+ */
 class PrimitiveType implements com.sun.javadoc.Type {
 
     private final String name;
@@ -64,6 +63,10 @@ class PrimitiveType implements com.sun.javadoc.Type {
         return name;
     }
 
+    public com.sun.javadoc.Type getElementType() {
+        return null;
+    }
+
     /**
      * Return qualified name of type excluding any dimension information.
      *<p>
@@ -122,13 +125,20 @@ class PrimitiveType implements com.sun.javadoc.Type {
     }
 
     /**
-     * Return null, as this is not a wildcard type;
+     * Return null, as this is not a wildcard type.
      */
     public WildcardType asWildcardType() {
         return null;
     }
 
     /**
+     * Return null, as this is not an annotated type.
+     */
+    public AnnotatedType asAnnotatedType() {
+        return null;
+    }
+
+    /**
      * Returns a string representation of the type.
      *
      * Return name of type including any dimension information.
diff --git a/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java b/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java
index e6cd0e8..f623e72 100644
--- a/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ProgramElementDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -25,26 +25,29 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.javadoc.*;
+import java.lang.reflect.Modifier;
+import java.text.CollationKey;
 
+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.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
-
 import com.sun.tools.javac.tree.JCTree;
-
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.util.Position;
 
-import java.lang.reflect.Modifier;
-import java.text.CollationKey;
-
 /**
  * Represents a java program element: class, interface, field,
  * constructor, or method.
  * This is an abstract class dealing with information common to
  * these elements.
  *
+ *  <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>
+ *
  * @see MemberDocImpl
  * @see ClassDocImpl
  *
@@ -65,16 +68,20 @@ public abstract class ProgramElementDocImpl
     // Cache for getModifiers().
     private int modifiers = -1;
 
-    protected ProgramElementDocImpl(DocEnv env, Symbol sym,
-                                    String doc, JCTree tree, Position.LineMap lineMap) {
-        super(env, doc);
+    protected ProgramElementDocImpl(DocEnv env, Symbol sym, TreePath treePath) {
+        super(env, treePath);
         this.sym = sym;
-        this.tree = tree;
-        this.lineMap = lineMap;
+        if (treePath != null) {
+            tree = (JCTree) treePath.getLeaf();
+            lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
+        }
     }
 
-    void setTree(JCTree tree) {
-        this.tree = tree;
+    @Override
+    public void setTreePath(TreePath treePath) {
+        super.setTreePath(treePath);
+        this.tree = (JCTree) treePath.getLeaf();
+        this.lineMap = ((JCCompilationUnit) treePath.getCompilationUnit()).lineMap;
     }
 
     /**
@@ -157,9 +164,9 @@ public abstract class ProgramElementDocImpl
      * Return an empty array if there are none.
      */
     public AnnotationDesc[] annotations() {
-        AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
+        AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
         int i = 0;
-        for (Attribute.Compound a : sym.getAnnotationMirrors()) {
+        for (Attribute.Compound a : sym.getRawAttributes()) {
             res[i++] = new AnnotationDescImpl(env, a);
         }
         return res;
diff --git a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
index 5f107fa..89a086a 100644
--- a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,12 +26,14 @@
 package com.sun.tools.javadoc;
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.Locale;
+
+import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
 
 import com.sun.javadoc.*;
-
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
@@ -40,7 +42,12 @@ import com.sun.tools.javac.util.Position;
 /**
  * This class holds the information from one run of javadoc.
  * Particularly the packages, classes and options specified
- * by the user..
+ * by the user.
+ *
+ *  <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.2
  * @author Robert Field
@@ -325,7 +332,6 @@ public class RootDocImpl extends DocImpl implements RootDoc {
     @Override
     protected String documentation() {
         if (documentation == null) {
-            int cnt = options.length();
             JavaFileObject overviewPath = getOverviewPath();
             if (overviewPath == null) {
                 // no doc file to be had
@@ -363,4 +369,19 @@ public class RootDocImpl extends DocImpl implements RootDoc {
     public Locale getLocale() {
         return env.doclocale.locale;
     }
+
+    /**
+     * Return the current file manager.
+     */
+    public JavaFileManager getFileManager() {
+        return env.fileManager;
+    }
+
+    public void initDocLint(Collection<String> opts) {
+        env.initDoclint(opts);
+    }
+
+    public boolean showTagMessages() {
+        return env.showTagMessages();
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java
index 9c61e0b..488dccd 100644
--- a/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -25,14 +25,25 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.tools.javac.util.*;
+import java.io.File;
+import java.util.Locale;
 
 import com.sun.javadoc.*;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Printer;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type.CapturedType;
+import com.sun.tools.javac.util.*;
 
 /**
  * Represents a see also documentation tag.
  * The @see tag can be plain text, or reference a class or member.
  *
+ *  <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 Kaiyang Liu (original)
  * @author Robert Field (rewrite)
  * @author Atul M Dambalkar
@@ -71,9 +82,63 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters {
                 container = (ClassDocImpl)holder;
             }
             findReferenced(container);
+            if (showRef) showRef();
         }
     }
 
+    private static final boolean showRef = false;
+
+    private void showRef() {
+        Symbol sym;
+        if (referencedMember != null) {
+            if (referencedMember instanceof MethodDocImpl)
+                sym = ((MethodDocImpl) referencedMember).sym;
+            else if (referencedMember instanceof FieldDocImpl)
+                sym = ((FieldDocImpl) referencedMember).sym;
+            else
+                sym = ((ConstructorDocImpl) referencedMember).sym;
+        } else if (referencedClass != null) {
+            sym = ((ClassDocImpl) referencedClass).tsym;
+        } else if (referencedPackage != null) {
+            sym = ((PackageDocImpl) referencedPackage).sym;
+        } else
+            return;
+
+        final JavacMessages messages = JavacMessages.instance(docenv().context);
+        Locale locale = Locale.getDefault();
+        Printer printer = new Printer() {
+            int count;
+            @Override
+            protected String localize(Locale locale, String key, Object... args) {
+                return messages.getLocalizedString(locale, key, args);
+            }
+            @Override
+            protected String capturedVarId(CapturedType t, Locale locale) {
+                return "CAP#" + (++count);
+            }
+        };
+
+        String s = text.replaceAll("\\s+", " ");  // normalize white space
+        int sp = s.indexOf(" ");
+        int lparen = s.indexOf("(");
+        int rparen = s.indexOf(")");
+        String seetext = (sp == -1) ? s
+                : (lparen == -1 || sp < lparen) ? s.substring(0, sp)
+                : s.substring(0, rparen + 1);
+
+        File file = new File(holder.position().file().getAbsoluteFile().toURI().normalize());
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("+++ ").append(file).append(": ")
+                .append(name()).append(" ").append(seetext).append(": ");
+        sb.append(sym.getKind()).append(" ");
+        if (sym.kind == Kinds.MTH || sym.kind == Kinds.VAR)
+            sb.append(printer.visit(sym.owner, locale)).append(".");
+        sb.append(printer.visit(sym, locale));
+
+        System.err.println(sb);
+    }
+
     /**
      * get the class name part of @see, For instance,
      * if the comment is @see String#startsWith(java.lang.String) .
@@ -263,8 +328,6 @@ class SeeTagImpl extends TagImpl implements SeeTag, LayoutCharacters {
             }
 
             if (referencedClass == null) { /* may just not be in this run */
-//                docenv().warning(holder, "tag.see.class_not_found",
-//                                 where, text);
                 // check if it's a package name
                 referencedPackage = docenv().lookupPackage(where);
                 return;
diff --git a/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java b/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java
index c429ba7..e89866d 100644
--- a/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,11 @@ import com.sun.javadoc.*;
  * This tag is only allowed in the javadoc for the special member
  * serialPersistentFields.
  *
+ *  <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 Joe Fialli
  * @author Neal Gafter
  *
diff --git a/src/share/classes/com/sun/tools/javadoc/SerializedForm.java b/src/share/classes/com/sun/tools/javadoc/SerializedForm.java
index e8b147f..76dc6a0 100644
--- a/src/share/classes/com/sun/tools/javadoc/SerializedForm.java
+++ b/src/share/classes/com/sun/tools/javadoc/SerializedForm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,15 +26,14 @@
 package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
-
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Scope;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 
 /**
@@ -59,6 +58,11 @@ import com.sun.tools.javac.util.Names;
  *    b. For Externalizable, data layout is described by 2(b).
  * </pre>
  *
+ *  <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.2
  * @author Joe Fialli
  * @author Neal Gafter (rewrite but not too proud)
@@ -233,6 +237,9 @@ class SerializedForm {
 
         SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
         for (int i = 0; i < sfTag.length; i++) {
+            if (sfTag[i].fieldName() == null || sfTag[i].fieldType() == null) // ignore malformed @serialField tags
+                continue;
+
             Name fieldName = names.fromString(sfTag[i].fieldName());
 
             // Look for a FieldDocImpl that is documented by serialFieldTagImpl.
diff --git a/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java b/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java
index d20b579..89106de 100644
--- a/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/SourcePositionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -34,6 +34,11 @@ import com.sun.tools.javac.util.Position;
 /**
  * A source position: filename, line number, and column number.
  *
+ *  <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 J2SE1.4
  * @author Neal M Gafter
  * @author Michael Van De Vanter (position representation changed to char offsets)
diff --git a/src/share/classes/com/sun/tools/javadoc/Start.java b/src/share/classes/com/sun/tools/javadoc/Start.java
index ef65296..7cee9aa 100644
--- a/src/share/classes/com/sun/tools/javadoc/Start.java
+++ b/src/share/classes/com/sun/tools/javadoc/Start.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,32 +25,43 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.javadoc.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
 
+import com.sun.javadoc.*;
 import com.sun.tools.javac.main.CommandLine;
+import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Options;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-
-import java.util.StringTokenizer;
-
 import static com.sun.tools.javac.code.Flags.*;
 
 /**
  * Main program of Javadoc.
  * Previously named "Main".
  *
+ *  <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.2
  * @author Robert Field
  * @author Neal Gafter (rewrite)
  */
-class Start {
+public class Start extends ToolOption.Helper {
+    /** Context for this invocation. */
+    private final Context context;
 
     private final String defaultDocletClassName;
     private final ClassLoader docletParentClassLoader;
@@ -60,27 +71,17 @@ class Start {
     private static final String standardDocletClassName =
         "com.sun.tools.doclets.standard.Standard";
 
-    private ListBuffer<String[]> options = new ListBuffer<String[]>();
-
-    private ModifierFilter showAccess = null;
-
     private long defaultFilter = PUBLIC | PROTECTED;
 
-    private Messager messager;
-
-    String docLocale = "";
-
-    boolean breakiterator = false;
-    boolean quiet = false;
-    String encoding = null;
+    private final Messager messager;
 
     private DocletInvoker docletInvoker;
 
-    private static final int F_VERBOSE = 1 << 0;
-    private static final int F_WARNINGS = 1 << 2;
-
-    /* Treat warnings as errors. */
-    private boolean rejectWarnings = false;
+    /**
+     * In API mode, exceptions thrown while calling the doclet are
+     * propagated using ClientCodeException.
+     */
+    private boolean apiMode;
 
     Start(String programName,
           PrintWriter errWriter,
@@ -96,8 +97,8 @@ class Start {
           PrintWriter noticeWriter,
           String defaultDocletClassName,
           ClassLoader docletParentClassLoader) {
-        Context tempContext = new Context(); // interim context until option decoding completed
-        messager = new Messager(tempContext, programName, errWriter, warnWriter, noticeWriter);
+        context = new Context();
+        messager = new Messager(context, programName, errWriter, warnWriter, noticeWriter);
         this.defaultDocletClassName = defaultDocletClassName;
         this.docletParentClassLoader = docletParentClassLoader;
     }
@@ -108,8 +109,8 @@ class Start {
 
     Start(String programName, String defaultDocletClassName,
           ClassLoader docletParentClassLoader) {
-        Context tempContext = new Context(); // interim context until option decoding completed
-        messager = new Messager(tempContext, programName);
+        context = new Context();
+        messager = new Messager(context, programName);
         this.defaultDocletClassName = defaultDocletClassName;
         this.docletParentClassLoader = docletParentClassLoader;
     }
@@ -130,23 +131,63 @@ class Start {
         this(javadocName);
     }
 
+    public Start(Context context) {
+        context.getClass(); // null check
+        this.context = context;
+        apiMode = true;
+        defaultDocletClassName = standardDocletClassName;
+        docletParentClassLoader = null;
+
+        Log log = context.get(Log.logKey);
+        if (log instanceof Messager)
+            messager = (Messager) log;
+        else {
+            PrintWriter out = context.get(Log.outKey);
+            messager = (out == null) ? new Messager(context, javadocName)
+                    : new Messager(context, javadocName, out, out, out);
+        }
+    }
+
     /**
      * Usage
      */
-    private void usage() {
-        messager.notice("main.usage");
+    @Override
+    void usage() {
+        usage(true);
+    }
+
+    void usage(boolean exit) {
+        usage("main.usage", "-help", null, exit);
+    }
+
+    @Override
+    void Xusage() {
+        Xusage(true);
+    }
+
+    void Xusage(boolean exit) {
+        usage("main.Xusage", "-X", "main.Xusage.foot", exit);
+    }
+
+    private void usage(String main, String doclet, String foot, boolean exit) {
+        // RFE: it would be better to replace the following with code to
+        // write a header, then help for each option, then a footer.
+        messager.notice(main);
 
         // let doclet print usage information (does nothing on error)
         if (docletInvoker != null) {
-            docletInvoker.optionLength("-help");
+            // RFE: this is a pretty bad way to get the doclet to show
+            // help info. Moreover, the output appears on stdout,
+            // and <i>not</i> on any of the standard streams passed
+            // to javadoc, and in particular, not to the noticeWriter
+            // But, to fix this, we need to fix the Doclet API.
+            docletInvoker.optionLength(doclet);
         }
-    }
 
-    /**
-     * Usage
-     */
-    private void Xusage() {
-        messager.notice("main.Xusage");
+        if (foot != null)
+            messager.notice(foot);
+
+        if (exit) exit();
     }
 
     /**
@@ -161,22 +202,36 @@ class Start {
      * Main program - external wrapper
      */
     int begin(String... argv) {
+        boolean ok = begin(null, argv, Collections.<JavaFileObject> emptySet());
+        return ok ? 0 : 1;
+    }
+
+    public boolean begin(Class<?> docletClass, Iterable<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+        Collection<String> opts = new ArrayList<String>();
+        for (String opt: options) opts.add(opt);
+        return begin(docletClass, opts.toArray(new String[opts.size()]), fileObjects);
+    }
+
+    private boolean begin(Class<?> docletClass, String[] options, Iterable<? extends JavaFileObject> fileObjects) {
         boolean failed = false;
 
         try {
-            failed = !parseAndExecute(argv);
-        } catch(Messager.ExitJavadoc exc) {
+            failed = !parseAndExecute(docletClass, options, fileObjects);
+        } catch (Messager.ExitJavadoc exc) {
             // ignore, we just exit this way
         } catch (OutOfMemoryError ee) {
-            messager.error(null, "main.out.of.memory");
+            messager.error(Messager.NOPOS, "main.out.of.memory");
             failed = true;
+        } catch (ClientCodeException e) {
+            // simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl
+            throw e;
         } catch (Error ee) {
-            ee.printStackTrace();
-            messager.error(null, "main.fatal.error");
+            ee.printStackTrace(System.err);
+            messager.error(Messager.NOPOS, "main.fatal.error");
             failed = true;
         } catch (Exception ee) {
-            ee.printStackTrace();
-            messager.error(null, "main.fatal.exception");
+            ee.printStackTrace(System.err);
+            messager.error(Messager.NOPOS, "main.fatal.exception");
             failed = true;
         } finally {
             messager.exitNotice();
@@ -184,22 +239,16 @@ class Start {
         }
         failed |= messager.nerrors() > 0;
         failed |= rejectWarnings && messager.nwarnings() > 0;
-        return failed ? 1 : 0;
-    }
-
-    private void addToList(ListBuffer<String> list, String str){
-        StringTokenizer st = new StringTokenizer(str, ":");
-        String current;
-        while(st.hasMoreTokens()){
-            current = st.nextToken();
-            list.append(current);
-        }
+        return !failed;
     }
 
     /**
      * Main program - internal
      */
-    private boolean parseAndExecute(String... argv) throws IOException {
+    private boolean parseAndExecute(
+            Class<?> docletClass,
+            String[] argv,
+            Iterable<? extends JavaFileObject> fileObjects) throws IOException {
         long tm = System.currentTimeMillis();
 
         ListBuffer<String> javaNames = new ListBuffer<String>();
@@ -208,132 +257,39 @@ class Start {
         try {
             argv = CommandLine.parse(argv);
         } catch (FileNotFoundException e) {
-            messager.error(null, "main.cant.read", e.getMessage());
+            messager.error(Messager.NOPOS, "main.cant.read", e.getMessage());
             exit();
         } catch (IOException e) {
-            e.printStackTrace();
+            e.printStackTrace(System.err);
             exit();
         }
 
-        setDocletInvoker(argv);
-        ListBuffer<String> subPackages = new ListBuffer<String>();
-        ListBuffer<String> excludedPackages = new ListBuffer<String>();
 
-        Context context = new Context();
-        // Setup a new Messager, using the same initial parameters as the
-        // existing Messager, except that this one will be able to use any
-        // options that may be set up below.
-        Messager.preRegister(context,
-                messager.programName,
-                messager.errWriter, messager.warnWriter, messager.noticeWriter);
+        JavaFileManager fileManager = context.get(JavaFileManager.class);
+        setDocletInvoker(docletClass, fileManager, argv);
 
-        Options compOpts = Options.instance(context);
-        boolean docClasses = false;
+        compOpts = Options.instance(context);
 
         // Parse arguments
         for (int i = 0 ; i < argv.length ; i++) {
             String arg = argv[i];
-            if (arg.equals("-subpackages")) {
-                oneArg(argv, i++);
-                addToList(subPackages, argv[i]);
-            } else if (arg.equals("-exclude")){
-                oneArg(argv, i++);
-                addToList(excludedPackages, argv[i]);
-            } else if (arg.equals("-verbose")) {
-                setOption(arg);
-                compOpts.put("-verbose", "");
-            } else if (arg.equals("-encoding")) {
-                oneArg(argv, i++);
-                encoding = argv[i];
-                compOpts.put("-encoding", argv[i]);
-            } else if (arg.equals("-breakiterator")) {
-                breakiterator = true;
-                setOption("-breakiterator");
-            } else if (arg.equals("-quiet")) {
-                quiet = true;
-                setOption("-quiet");
-            } else if (arg.equals("-help")) {
-                usage();
-                exit();
-            } else if (arg.equals("-Xclasses")) {
-                setOption(arg);
-                docClasses = true;
-            } else if (arg.equals("-Xwerror")) {
-                setOption(arg);
-                rejectWarnings = true;
-            } else if (arg.equals("-private")) {
-                setOption(arg);
-                setFilter(ModifierFilter.ALL_ACCESS);
-            } else if (arg.equals("-package")) {
-                setOption(arg);
-                setFilter(PUBLIC | PROTECTED |
-                          ModifierFilter.PACKAGE );
-            } else if (arg.equals("-protected")) {
-                setOption(arg);
-                setFilter(PUBLIC | PROTECTED );
-            } else if (arg.equals("-public")) {
-                setOption(arg);
-                setFilter(PUBLIC);
-            } else if (arg.equals("-source")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-source") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-source", argv[i]);
-            } else if (arg.equals("-prompt")) {
-                compOpts.put("-prompt", "-prompt");
-                messager.promptOnError = true;
-            } else if (arg.equals("-sourcepath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-sourcepath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-sourcepath", argv[i]);
-            } else if (arg.equals("-classpath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-classpath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-classpath", argv[i]);
-            } else if (arg.equals("-sysclasspath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-bootclasspath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-bootclasspath", argv[i]);
-            } else if (arg.equals("-bootclasspath")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-bootclasspath") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-bootclasspath", argv[i]);
-            } else if (arg.equals("-extdirs")) {
-                oneArg(argv, i++);
-                if (compOpts.get("-extdirs") != null) {
-                    usageError("main.option.already.seen", arg);
-                }
-                compOpts.put("-extdirs", argv[i]);
-            } else if (arg.equals("-overview")) {
-                oneArg(argv, i++);
-            } else if (arg.equals("-doclet")) {
-                i++;  // handled in setDocletInvoker
-            } else if (arg.equals("-docletpath")) {
-                i++;  // handled in setDocletInvoker
-            } else if (arg.equals("-locale")) {
-                if (i != 0)
+
+            ToolOption o = ToolOption.get(arg);
+            if (o != null) {
+                // hack: this restriction should be removed
+                if (o == ToolOption.LOCALE && i > 0)
                     usageError("main.locale_first");
-                oneArg(argv, i++);
-                docLocale = argv[i];
-            } else if (arg.equals("-Xmaxerrs") || arg.equals("-Xmaxwarns")) {
-                oneArg(argv, i++);
-                if (compOpts.get(arg) != null) {
-                    usageError("main.option.already.seen", arg);
+
+                if (o.hasArg) {
+                    oneArg(argv, i++);
+                    o.process(this, argv[i]);
+                } else {
+                    setOption(arg);
+                    o.process(this);
                 }
-                compOpts.put(arg, argv[i]);
-            } else if (arg.equals("-X")) {
-                Xusage();
-                exit();
+
             } else if (arg.startsWith("-XD")) {
+                // hidden javac options
                 String s = arg.substring("-XD".length());
                 int eq = s.indexOf('=');
                 String key = (eq < 0) ? s : s.substring(0, eq);
@@ -342,7 +298,7 @@ class Start {
             }
             // call doclet for its options
             // other arg starts with - is invalid
-            else if ( arg.startsWith("-") ) {
+            else if (arg.startsWith("-")) {
                 int optionLength;
                 optionLength = docletInvoker.optionLength(arg);
                 if (optionLength < 0) {
@@ -366,8 +322,9 @@ class Start {
                 javaNames.append(arg);
             }
         }
+        compOpts.notifyListeners();
 
-        if (javaNames.isEmpty() && subPackages.isEmpty()) {
+        if (javaNames.isEmpty() && subPackages.isEmpty() && isEmpty(fileObjects)) {
             usageError("main.No_packages_or_classes_specified");
         }
 
@@ -385,21 +342,27 @@ class Start {
 
         LanguageVersion languageVersion = docletInvoker.languageVersion();
         RootDocImpl root = comp.getRootDocImpl(
-                docLocale, encoding, showAccess,
-                javaNames.toList(), options.toList(), breakiterator,
-                subPackages.toList(), excludedPackages.toList(),
+                docLocale,
+                encoding,
+                showAccess,
+                javaNames.toList(),
+                options.toList(),
+                fileObjects,
+                breakiterator,
+                subPackages.toList(),
+                excludedPackages.toList(),
                 docClasses,
                 // legacy?
-                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1, quiet);
+                languageVersion == null || languageVersion == LanguageVersion.JAVA_1_1,
+                quiet);
+
+        // release resources
+        comp = null;
 
         // pass off control to the doclet
         boolean ok = root != null;
         if (ok) ok = docletInvoker.start(root);
 
-        Messager docletMessager = Messager.instance0(context);
-        messager.nwarnings += docletMessager.nwarnings;
-        messager.nerrors += docletMessager.nerrors;
-
         // We're done.
         if (compOpts.get("-verbose") != null) {
             tm = System.currentTimeMillis() - tm;
@@ -409,21 +372,43 @@ class Start {
         return ok;
     }
 
-    private void setDocletInvoker(String[] argv) {
+    private <T> boolean isEmpty(Iterable<T> iter) {
+        return !iter.iterator().hasNext();
+    }
+
+    /**
+     * Init the doclet invoker.
+     * The doclet class may be given explicitly, or via the -doclet option in
+     * argv.
+     * If the doclet class is not given explicitly, it will be loaded from
+     * the file manager's DOCLET_PATH location, if available, or via the
+     * -doclet path option in argv.
+     * @param docletClass The doclet class. May be null.
+     * @param fileManager The file manager used to get the class loader to load
+     * the doclet class if required. May be null.
+     * @param argv Args containing -doclet and -docletpath, in case they are required.
+     */
+    private void setDocletInvoker(Class<?> docletClass, JavaFileManager fileManager, String[] argv) {
+        if (docletClass != null) {
+            docletInvoker = new DocletInvoker(messager, docletClass, apiMode);
+            // TODO, check no -doclet, -docletpath
+            return;
+        }
+
         String docletClassName = null;
         String docletPath = null;
 
         // Parse doclet specifying arguments
         for (int i = 0 ; i < argv.length ; i++) {
             String arg = argv[i];
-            if (arg.equals("-doclet")) {
+            if (arg.equals(ToolOption.DOCLET.opt)) {
                 oneArg(argv, i++);
                 if (docletClassName != null) {
                     usageError("main.more_than_one_doclet_specified_0_and_1",
                                docletClassName, argv[i]);
                 }
                 docletClassName = argv[i];
-            } else if (arg.equals("-docletpath")) {
+            } else if (arg.equals(ToolOption.DOCLETPATH.opt)) {
                 oneArg(argv, i++);
                 if (docletPath == null) {
                     docletPath = argv[i];
@@ -438,18 +423,10 @@ class Start {
         }
 
         // attempt to find doclet
-        docletInvoker = new DocletInvoker(messager,
-                                          docletClassName, docletPath,
-                                          docletParentClassLoader);
-    }
-
-    private void setFilter(long filterBits) {
-        if (showAccess != null) {
-            messager.error(null, "main.incompatible.access.flags");
-            usage();
-            exit();
-        }
-        showAccess = new ModifierFilter(filterBits);
+        docletInvoker = new DocletInvoker(messager, fileManager,
+                docletClassName, docletPath,
+                docletParentClassLoader,
+                apiMode);
     }
 
     /**
@@ -464,22 +441,10 @@ class Start {
         }
     }
 
-    private void usageError(String key) {
-        messager.error(null, key);
-        usage();
-        exit();
-    }
-
-    private void usageError(String key, String a1) {
-        messager.error(null, key, a1);
-        usage();
-        exit();
-    }
-
-    private void usageError(String key, String a1, String a2) {
-        messager.error(null, key, a1, a2);
-        usage();
-        exit();
+    @Override
+    void usageError(String key, Object... args) {
+        messager.error(Messager.NOPOS, key, args);
+        usage(true);
     }
 
     /**
@@ -508,7 +473,6 @@ class Start {
         for (List<String> i = arguments; i.nonEmpty(); i=i.tail) {
             args[k++] = i.head;
         }
-        options = options.append(args);
+        options.append(args);
     }
-
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/TagImpl.java b/src/share/classes/com/sun/tools/javadoc/TagImpl.java
index 10a2764..a106bb6 100644
--- a/src/share/classes/com/sun/tools/javadoc/TagImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/TagImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -34,6 +34,11 @@ import com.sun.javadoc.*;
  * special processing are handled by subclasses (ParamTagImpl, SeeTagImpl,
  * and ThrowsTagImpl
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @author Neal M Gafter
diff --git a/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java b/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java
index f63ffec..6da454f 100644
--- a/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -33,6 +33,11 @@ import com.sun.javadoc.*;
  * The exception name my be the name of a type variable.
  * Note: @exception is a backwards compatible synonymy for @throws.
  *
+ *  <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 Robert Field
  * @author Atul M Dambalkar
  * @see ExecutableMemberDocImpl#throwsTags()
@@ -108,8 +113,8 @@ class ThrowsTagImpl extends TagImpl implements ThrowsTag {
      * TagImpls consisting of SeeTagImpl(s) and text containing TagImpl(s).
      *
      * @return TagImpl[] Array of tags with inline SeeTagImpls.
-     * @see TagImpl#inlineTagImpls()
-     * @see ParamTagImpl#inlineTagImpls()
+     * @see TagImpl#inlineTags()
+     * @see ParamTagImpl#inlineTags()
      */
     @Override
     public Tag[] inlineTags() {
diff --git a/src/share/classes/com/sun/tools/javadoc/ToolOption.java b/src/share/classes/com/sun/tools/javadoc/ToolOption.java
new file mode 100644
index 0000000..2bd68ed
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javadoc/ToolOption.java
@@ -0,0 +1,332 @@
+/*
+ * 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.  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.javadoc;
+
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Options;
+import java.util.StringTokenizer;
+
+
+/**
+ * javadoc tool options.
+ *
+ *  <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 enum ToolOption {
+    // ----- options for underlying compiler -----
+
+    BOOTCLASSPATH("-bootclasspath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    CLASSPATH("-classpath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    CP("-cp", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    EXTDIRS("-extdirs", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SOURCEPATH("-sourcepath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SYSCLASSPATH("-sysclasspath", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt("-bootclasspath", arg);
+        }
+    },
+
+    ENCODING("-encoding", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.encoding = arg;
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    SOURCE("-source", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    XMAXERRS("-Xmaxerrs", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    XMAXWARNS("-Xmaxwarns", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt(opt, arg);
+        }
+    },
+
+    // ----- doclet options -----
+
+    DOCLET("-doclet", true), // handled in setDocletInvoker
+
+    DOCLETPATH("-docletpath", true), // handled in setDocletInvoker
+
+    // ----- selection options -----
+
+    SUBPACKAGES("-subpackages", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.addToList(helper.subPackages, arg);
+        }
+    },
+
+    EXCLUDE("-exclude", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.addToList(helper.excludedPackages, arg);
+        }
+    },
+
+    // ----- filtering options -----
+
+    PACKAGE("-package") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(
+                    Flags.PUBLIC | Flags.PROTECTED | ModifierFilter.PACKAGE);
+        }
+    },
+
+    PRIVATE("-private") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(ModifierFilter.ALL_ACCESS);
+        }
+    },
+
+    PROTECTED("-protected") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(Flags.PUBLIC | Flags.PROTECTED);
+        }
+    },
+
+    PUBLIC("-public") {
+        @Override
+        public void process(Helper helper) {
+            helper.setFilter(Flags.PUBLIC);
+        }
+    },
+
+    // ----- output control options -----
+
+    PROMPT("-prompt") {
+        @Override
+        public void process(Helper helper) {
+            helper.compOpts.put("-prompt", "-prompt");
+            helper.promptOnError = true;
+        }
+    },
+
+    QUIET("-quiet") {
+        @Override
+        public void process(Helper helper) {
+            helper.quiet = true;
+        }
+    },
+
+    VERBOSE("-verbose") {
+        @Override
+        public void process(Helper helper) {
+            helper.compOpts.put("-verbose", "");
+        }
+    },
+
+    XWERROR("-Xwerror") {
+        @Override
+        public void process(Helper helper) {
+            helper.rejectWarnings = true;
+
+        }
+    },
+
+    // ----- other options -----
+
+    BREAKITERATOR("-breakiterator") {
+        @Override
+        public void process(Helper helper) {
+            helper.breakiterator = true;
+        }
+    },
+
+    LOCALE("-locale", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.docLocale = arg;
+        }
+    },
+
+    OVERVIEW("-overview", true),
+
+    XCLASSES("-Xclasses") {
+        @Override
+        public void process(Helper helper) {
+            helper.docClasses = true;
+
+        }
+    },
+
+    // ----- help options -----
+
+    HELP("-help") {
+        @Override
+        public void process(Helper helper) {
+            helper.usage();
+        }
+    },
+
+    X("-X") {
+        @Override
+        public void process(Helper helper) {
+            helper.Xusage();
+        }
+    };
+
+    public final String opt;
+    public final boolean hasArg;
+
+    ToolOption(String opt) {
+        this(opt, false);
+    }
+
+    ToolOption(String opt, boolean hasArg) {
+        this.opt = opt;
+        this.hasArg = hasArg;
+    }
+
+    void process(Helper helper, String arg) { }
+
+    void process(Helper helper) { }
+
+    static ToolOption get(String name) {
+        for (ToolOption o: values()) {
+            if (name.equals(o.opt))
+                return o;
+        }
+        return null;
+    }
+
+    static abstract class Helper {
+        /** List of decoded options. */
+        final ListBuffer<String[]> options = new ListBuffer<String[]>();
+
+        /** Selected packages, from -subpackages. */
+        final ListBuffer<String> subPackages = new ListBuffer<String>();
+
+        /** Excluded packages, from -exclude. */
+        final ListBuffer<String> excludedPackages = new ListBuffer<String>();
+
+        /** javac options, set by various options. */
+        Options compOpts; // = Options.instance(context)
+
+        /* Encoding for javac, and files written? set by -encoding. */
+        String encoding = null;
+
+        /** Set by -breakiterator. */
+        boolean breakiterator = false;
+
+        /** Set by -quiet. */
+        boolean quiet = false;
+
+        /** Set by -Xclasses. */
+        boolean docClasses = false;
+
+        /** Set by -Xwerror. */
+        boolean rejectWarnings = false;
+
+        /** Set by -prompt. */
+        boolean promptOnError;
+
+        /** Set by -locale. */
+        String docLocale = "";
+
+        /** Set by -public, private, -protected, -package. */
+        ModifierFilter showAccess = null;
+
+        abstract void usage();
+        abstract void Xusage();
+
+        abstract void usageError(String msg, Object... args);
+
+        protected void addToList(ListBuffer<String> list, String str){
+            StringTokenizer st = new StringTokenizer(str, ":");
+            String current;
+            while(st.hasMoreTokens()){
+                current = st.nextToken();
+                list.append(current);
+            }
+        }
+
+        protected void setFilter(long filterBits) {
+            if (showAccess != null) {
+                usageError("main.incompatible.access.flags");
+            }
+            showAccess = new ModifierFilter(filterBits);
+        }
+
+        private void setCompilerOpt(String opt, String arg) {
+            if (compOpts.get(opt) != null) {
+                usageError("main.option.already.seen", opt);
+            }
+            compOpts.put(opt, arg);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
index 8f7f77c..721d33b 100644
--- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
+++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, 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,18 +26,21 @@
 package com.sun.tools.javadoc;
 
 import com.sun.javadoc.*;
-
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ArrayType;
 import com.sun.tools.javac.code.Type.ClassType;
 import com.sun.tools.javac.code.Type.TypeVar;
-import com.sun.tools.javac.code.Type.ArrayType;
 import com.sun.tools.javac.util.List;
+import static com.sun.tools.javac.code.TypeTag.ARRAY;
 
-import static com.sun.tools.javac.code.TypeTags.*;
-
-
+/**
+ *  <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 TypeMaker {
 
     public static com.sun.javadoc.Type getType(DocEnv env, Type t) {
@@ -48,13 +51,25 @@ public class TypeMaker {
      * @param errToClassDoc  if true, ERROR type results in a ClassDoc;
      *          false preserves legacy behavior
      */
+    public static com.sun.javadoc.Type getType(DocEnv env, Type t,
+            boolean errorToClassDoc) {
+        return getType(env, t, errorToClassDoc, true);
+    }
+
     @SuppressWarnings("fallthrough")
     public static com.sun.javadoc.Type getType(DocEnv env, Type t,
-                                               boolean errToClassDoc) {
+            boolean errToClassDoc, boolean considerAnnotations) {
         if (env.legacyDoclet) {
             t = env.types.erasure(t);
         }
-        switch (t.tag) {
+
+        if (considerAnnotations &&
+                t.isAnnotated()) {
+            Type.AnnotatedType at = (Type.AnnotatedType) t;
+            return new AnnotatedTypeImpl(env, at);
+        }
+
+        switch (t.getTag()) {
         case CLASS:
             if (ClassDocImpl.isGeneric((ClassSymbol)t.tsym)) {
                 return env.getParameterizedType((ClassType)t);
@@ -104,10 +119,10 @@ public class TypeMaker {
     }
 
     public static String getTypeName(Type t, boolean full) {
-        switch (t.tag) {
+        switch (t.getTag()) {
         case ARRAY:
             StringBuilder s = new StringBuilder();
-            while (t.tag == ARRAY) {
+            while (t.hasTag(ARRAY)) {
                 s.append("[]");
                 t = ((ArrayType)t).elemtype;
             }
@@ -126,10 +141,15 @@ public class TypeMaker {
      * Class names are qualified if "full" is true.
      */
     static String getTypeString(DocEnv env, Type t, boolean full) {
-        switch (t.tag) {
+        // TODO: should annotations be included here?
+        if (t.isAnnotated()) {
+            Type.AnnotatedType at = (Type.AnnotatedType)t;
+            t = at.underlyingType;
+        }
+        switch (t.getTag()) {
         case ARRAY:
             StringBuilder s = new StringBuilder();
-            while (t.tag == ARRAY) {
+            while (t.hasTag(ARRAY)) {
                 s.append("[]");
                 t = env.types.elemtype(t);
             }
@@ -197,10 +217,14 @@ public class TypeMaker {
 
         private com.sun.javadoc.Type skipArraysCache = null;
 
+        public com.sun.javadoc.Type getElementType() {
+            return TypeMaker.getType(env, env.types.elemtype(arrayType));
+        }
+
         private com.sun.javadoc.Type skipArrays() {
             if (skipArraysCache == null) {
                 Type t;
-                for (t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) { }
+                for (t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) { }
                 skipArraysCache = TypeMaker.getType(env, t);
             }
             return skipArraysCache;
@@ -213,7 +237,7 @@ public class TypeMaker {
          */
         public String dimension() {
             StringBuilder dimension = new StringBuilder();
-            for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
+            for (Type t = arrayType; t.hasTag(ARRAY); t = env.types.elemtype(t)) {
                 dimension.append("[]");
             }
             return dimension.toString();
@@ -279,6 +303,13 @@ public class TypeMaker {
         }
 
         /**
+         * Return null, as there are no annotations of the type
+         */
+        public AnnotatedType asAnnotatedType() {
+            return null;
+        }
+
+        /**
          * Return this type as an <code>AnnotationTypeDoc</code> if it
          * represents an annotation type.  Array dimensions are ignored.
          */
diff --git a/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java
index 55660ac..3840c91 100644
--- a/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java
@@ -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
@@ -25,9 +25,10 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
@@ -42,6 +43,11 @@ import com.sun.tools.javac.util.Names;
  * Implementation of <code>TypeVariable</code>, which
  * represents a type variable.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
@@ -116,11 +122,30 @@ public class TypeVariableImpl extends AbstractTypeImpl implements TypeVariable {
      * Get the bounds of a type variable as listed in the "extends" clause.
      */
     private static List<Type> getBounds(TypeVar v, DocEnv env) {
-        Name boundname = v.getUpperBound().tsym.getQualifiedName();
-        if (boundname == boundname.table.names.java_lang_Object) {
+        final Type upperBound = v.getUpperBound();
+        Name boundname = upperBound.tsym.getQualifiedName();
+        if (boundname == boundname.table.names.java_lang_Object
+            && !upperBound.isAnnotated()) {
             return List.nil();
         } else {
             return env.types.getBounds(v);
         }
     }
+
+    /**
+     * Get the annotations of this program element.
+     * Return an empty array if there are none.
+     */
+    public AnnotationDesc[] annotations() {
+        if (!type.isAnnotated()) {
+            return new AnnotationDesc[0];
+        }
+        List<TypeCompound> tas = ((com.sun.tools.javac.code.Type.AnnotatedType) type).typeAnnotations;
+        AnnotationDesc res[] = new AnnotationDesc[tas.length()];
+        int i = 0;
+        for (Attribute.Compound a : tas) {
+            res[i++] = new AnnotationDescImpl(env, a);
+        }
+        return res;
+    }
 }
diff --git a/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java b/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java
index dace0e8..cf458d2 100644
--- a/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
@@ -37,6 +36,11 @@ import com.sun.tools.javac.util.List;
  * Implementation of <code>WildcardType</code>, which
  * represents a wildcard type.
  *
+ *  <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 Scott Seligman
  * @since 1.5
  */
diff --git a/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java b/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java
new file mode 100644
index 0000000..ae1fc06
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javadoc/api/JavadocTaskImpl.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.javadoc.api;
+
+import com.sun.tools.javac.util.ClientCodeException;
+import java.util.Locale;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.Start;
+import java.util.Collections;
+
+/**
+ * Provides access to functionality specific to the JDK documentation tool,
+ * javadoc.
+ *
+ * <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></p>
+ */
+public class JavadocTaskImpl implements DocumentationTask {
+    private final AtomicBoolean used = new AtomicBoolean();
+
+    private final Context context;
+    private Class<?> docletClass;
+    private Iterable<String> options;
+    private Iterable<? extends JavaFileObject> fileObjects;
+    private Locale locale;
+
+    public JavadocTaskImpl(Context context, Class<?> docletClass,
+            Iterable<String> options, Iterable<? extends JavaFileObject> fileObjects) {
+        this.context = context;
+        this.docletClass = docletClass;
+
+        this.options = (options == null) ? Collections.<String>emptySet()
+                : nullCheck(options);
+        this.fileObjects = (fileObjects == null) ? Collections.<JavaFileObject>emptySet()
+                : nullCheck(fileObjects);
+        setLocale(Locale.getDefault());
+    }
+
+    public void setLocale(Locale locale) {
+        if (used.get())
+            throw new IllegalStateException();
+        this.locale = locale;
+    }
+
+    public Boolean call() {
+        if (!used.getAndSet(true)) {
+            initContext();
+            Start jdoc = new Start(context);
+            try {
+                return jdoc.begin(docletClass, options, fileObjects);
+            } catch (ClientCodeException e) {
+                throw new RuntimeException(e.getCause());
+            }
+        } else {
+            throw new IllegalStateException("multiple calls to method 'call'");
+        }
+    }
+
+    private void initContext() {
+        //initialize compiler's default locale
+        context.put(Locale.class, locale);
+    }
+
+    private static <T> Iterable<T> nullCheck(Iterable<T> items) {
+        for (T item: items) {
+            if (item == null)
+                throw new NullPointerException();
+        }
+        return items;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java b/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java
new file mode 100644
index 0000000..5df9280
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javadoc/api/JavadocTool.java
@@ -0,0 +1,172 @@
+/*
+ * 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.  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.javadoc.api;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+import javax.tools.DiagnosticListener;
+import javax.tools.DocumentationTool;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.ClientCodeException;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javadoc.ToolOption;
+
+/**
+ * Provides access to functionality specific to the JDK documentation tool,
+ * javadoc.
+ *
+ * <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></p>
+ */
+public class JavadocTool implements DocumentationTool {
+    @Override
+    public DocumentationTask getTask(
+            Writer out,
+            JavaFileManager fileManager,
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Class<?> docletClass,
+            Iterable<String> options,
+            Iterable<? extends JavaFileObject> compilationUnits) {
+        Context context = new Context();
+        return getTask(out, fileManager, diagnosticListener,
+                docletClass, options, compilationUnits, context);
+    }
+
+    public DocumentationTask getTask(
+            Writer out,
+            JavaFileManager fileManager,
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Class<?> docletClass,
+            Iterable<String> options,
+            Iterable<? extends JavaFileObject> compilationUnits,
+            Context context) {
+        try {
+            ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
+
+            if (options != null) {
+                for (String option : options)
+                    option.getClass(); // null check
+            }
+
+            if (compilationUnits != null) {
+                compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
+                for (JavaFileObject cu : compilationUnits) {
+                    if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
+                        final String kindMsg = "All compilation units must be of SOURCE kind";
+                        throw new IllegalArgumentException(kindMsg);
+                    }
+                }
+            }
+
+            if (diagnosticListener != null)
+                context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
+
+            if (out == null)
+                context.put(Log.outKey, new PrintWriter(System.err, true));
+            else if (out instanceof PrintWriter)
+                context.put(Log.outKey, ((PrintWriter) out));
+            else
+                context.put(Log.outKey, new PrintWriter(out, true));
+
+            if (fileManager == null)
+                fileManager = getStandardFileManager(diagnosticListener, null, null);
+            fileManager = ccw.wrap(fileManager);
+            context.put(JavaFileManager.class, fileManager);
+
+            return new JavadocTaskImpl(context, docletClass, options, compilationUnits);
+        } catch (ClientCodeException ex) {
+            throw new RuntimeException(ex.getCause());
+        }
+    }
+
+    // TODO: used shared static method in JavacFileManager
+    @Override
+    public StandardJavaFileManager getStandardFileManager(
+            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+            Locale locale,
+            Charset charset) {
+        Context context = new Context();
+        context.put(Locale.class, locale);
+        if (diagnosticListener != null)
+            context.put(DiagnosticListener.class, diagnosticListener);
+        PrintWriter pw = (charset == null)
+                ? new PrintWriter(System.err, true)
+                : new PrintWriter(new OutputStreamWriter(System.err, charset), true);
+        context.put(Log.outKey, pw);
+        return new JavacFileManager(context, true, charset);
+    }
+
+    @Override
+    public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {
+        PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true);
+        PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
+        try {
+            String standardDocletName = "com.sun.tools.doclets.standard.Standard";
+            ClassLoader cl = getClass().getClassLoader();
+            return com.sun.tools.javadoc.Main.execute(
+                    "javadoc", err_pw, err_pw, out_pw, standardDocletName, cl, arguments);
+        } finally {
+            err_pw.flush();
+            out_pw.flush();
+        }
+    }
+
+    @Override
+    public Set<SourceVersion> getSourceVersions() {
+        return Collections.unmodifiableSet(
+                EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest()));
+    }
+
+    @Override
+    public int isSupportedOption(String option) {
+        if (option == null)
+            throw new NullPointerException();
+        for (ToolOption o: ToolOption.values()) {
+            if (o.opt.equals(option))
+                return o.hasArg ? 1 : 0;
+        }
+        return -1;
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties
index ba6142c..8ac2c34 100644
--- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties
+++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2011, 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
@@ -27,35 +27,40 @@ main.errors={0} errors
 main.error={0} error
 main.warnings={0} warnings
 main.warning={0} warning
-main.usage=usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
-  -overview <file>          Read overview documentation from HTML file\n\
-  -public                   Show only public classes and members\n\
-  -protected                Show protected/public classes and members (default)\n\
-  -package                  Show package/protected/public classes and members\n\
-  -private                  Show all classes and members\n\
-  -help                     Display command line options and exit\n\
-  -doclet <class>           Generate output via alternate doclet\n\
-  -docletpath <path>        Specify where to find doclet class files\n\
-  -sourcepath <pathlist>    Specify where to find source files\n\
-  -classpath <pathlist>     Specify where to find user class files\n\
-  -exclude <pkglist>        Specify a list of packages to exclude\n\
-  -subpackages <subpkglist> Specify subpackages to recursively load\n\
-  -breakiterator            Compute 1st sentence with BreakIterator\n\
-  -bootclasspath <pathlist> Override location of class files loaded\n\
-\t\t\t  by the bootstrap class loader\n\
-  -source <release>         Provide source compatibility with specified release\n\
-  -extdirs <dirlist>        Override location of installed extensions\n\
-  -verbose                  Output messages about what Javadoc is doing\n\
-  -locale <name>            Locale to be used, e.g. en_US or en_US_WIN\n\
-  -encoding <name>          Source file encoding name\n\
-  -quiet                    Do not display status messages\n\
-  -J<flag>                  Pass <flag> directly to the runtime system\n\
-  -X                        Print a synopsis of nonstandard options\n
+
+main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
+\  -overview <file>                 Read overview documentation from HTML file\n\
+\  -public                          Show only public classes and members\n\
+\  -protected                       Show protected/public classes and members (default)\n\
+\  -package                         Show package/protected/public classes and members\n\
+\  -private                         Show all classes and members\n\
+\  -help                            Display command line options and exit\n\
+\  -doclet <class>                  Generate output via alternate doclet\n\
+\  -docletpath <path>               Specify where to find doclet class files\n\
+\  -sourcepath <pathlist>           Specify where to find source files\n\
+\  -classpath <pathlist>            Specify where to find user class files\n\
+\  -cp <pathlist>                   Specify where to find user class files\n\
+\  -exclude <pkglist>               Specify a list of packages to exclude\n\
+\  -subpackages <subpkglist>        Specify subpackages to recursively load\n\
+\  -breakiterator                   Compute first sentence with BreakIterator\n\
+\  -bootclasspath <pathlist>        Override location of class files loaded\n\
+\                                   by the bootstrap class loader\n\
+\  -source <release>                Provide source compatibility with specified release\n\
+\  -extdirs <dirlist>               Override location of installed extensions\n\
+\  -verbose                         Output messages about what Javadoc is doing\n\
+\  -locale <name>                   Locale to be used, e.g. en_US or en_US_WIN\n\
+\  -encoding <name>                 Source file encoding name\n\
+\  -quiet                           Do not display status messages\n\
+\  -J<flag>                         Pass <flag> directly to the runtime system\n\
+\  -X                               Print a synopsis of nonstandard options and exit\n
+
 main.Xusage=\
-  -Xmaxerrs <number>        Set the maximum number of errors to print\n\
-  -Xmaxwarns <number>       Set the maximum number of warnings to print\n\
-\n\
+\  -Xmaxerrs <number>               Set the maximum number of errors to print\n\
+\  -Xmaxwarns <number>              Set the maximum number of warnings to print\n
+
+main.Xusage.foot=\
 These options are non-standard and subject to change without notice.
+
 main.option.already.seen=The {0} option may be specified no more than once.
 main.requires_argument=option {0} requires an argument.
 main.locale_first=option -locale must be first on the command line.
@@ -64,7 +69,6 @@ main.No_packages_or_classes_specified=No packages or classes specified.
 main.incompatible.access.flags=More than one of -public, -private, -package, or -protected specified.
 main.cant.read=cannot read {0}
 main.Loading_source_files_for_package=Loading source files for package {0}...
-main.Loading_source_file_for_class=Loading source file for class {0}...
 main.Loading_source_file=Loading source file {0}...
 main.Building_tree=Constructing Javadoc information...
 main.no_source_files_for_package=No source files for package {0}
@@ -96,13 +100,12 @@ tag.see.missing_sharp=Tag {0}: missing ''#'': "{1}"
 tag.see.can_not_find_member=Tag {0}: can''t find {1} in {2}
 tag.see.no_close_bracket_on_url=Tag {0}: missing final ''>'': "{1}"
 tag.see.no_close_quote=Tag {0}: no final close quote: "{1}"
-tag.see.class_not_found=class {0} not found for @see tag: "{1}"
 tag.see.class_not_specified=Tag {0}: class not specified: "{1}"
 tag.see.illegal_character=Tag {0}:illegal character: "{1}" in "{2}"
 tag.see.malformed_see_tag=Tag {0}: malformed: "{1}"
-tag.throws.exception_not_found={0} tag, class {1} not found.
 tag.End_delimiter_missing_for_possible_SeeTag=End Delimiter } missing for possible See Tag in comment string: "{0}"
 tag.Improper_Use_Of_Link_Tag=Missing closing ''}'' character for inline tag: "{0}"
+tag.serialField.illegal_character=illegal character {0} in @serialField tag: {1}.
 javadoc.File_Read_Error=Error while reading file {0}
 javadoc.Body_missing_from_html_file=Body tag missing from HTML file
 javadoc.End_body_missing_from_html_file=Close body tag missing from HTML file
@@ -110,4 +113,8 @@ javadoc.Multiple_package_comments=Multiple sources of package comments found for
 javadoc.class_not_found=Class {0} not found.
 javadoc.error=error
 javadoc.warning=warning
-tag.serialField.illegal_character=illegal character {0} in @serialField tag: {1}.
+
+javadoc.error.msg={0}: error - {1}
+javadoc.warning.msg={0}: warning - {1}
+javadoc.note.msg = {1}
+javadoc.note.pos.msg= {0}: {1}
diff --git a/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties
index 72a9992..a31ba59 100644
--- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties
+++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_ja.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 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
@@ -27,7 +27,7 @@ main.errors=\u30A8\u30E9\u30FC{0}\u500B
 main.error=\u30A8\u30E9\u30FC{0}\u500B
 main.warnings=\u8B66\u544A{0}\u500B
 main.warning=\u8B66\u544A{0}\u500B
-main.usage=\u4F7F\u7528\u65B9\u6CD5: javadoc [options] [packagenames] [sourcefiles] [@files]\n-overview<file>      HTML\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6982\u8981\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3080\n-public            public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u793A\u3059\n-protected          protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059(\u30C7\u30D5\u30A9\u30EB\u30C8)\n-package         [...]
+main.usage=\u4F7F\u7528\u65B9\u6CD5: javadoc [options] [packagenames] [sourcefiles] [@files]\n-overview <file>          HTML\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6982\u8981\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3080\n-public                   public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u793A\u3059\n-protected                protected/public\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u793A\u3059(\u30C7\u30D5\u30A9\u30EB\u30C8) [...]
 main.Xusage=-Xmaxerrs <number>        \u51FA\u529B\u3059\u308B\u30A8\u30E9\u30FC\u306E\u6700\u5927\u6570\u3092\u8A2D\u5B9A\u3059\u308B\n-Xmaxwarns <number>       \u51FA\u529B\u3059\u308B\u8B66\u544A\u306E\u6700\u5927\u6570\u3092\u8A2D\u5B9A\u3059\u308B\n\n\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002
 main.option.already.seen={0}\u30AA\u30D7\u30B7\u30E7\u30F3\u304C\u8907\u6570\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u3059\u3002
 main.requires_argument=\u30AA\u30D7\u30B7\u30E7\u30F3{0}\u306B\u306F\u5F15\u6570\u304C\u5FC5\u8981\u3067\u3059\u3002
@@ -37,7 +37,6 @@ main.No_packages_or_classes_specified=\u30D1\u30C3\u30B1\u30FC\u30B8\u307E\u305F
 main.incompatible.access.flags=-public\u3001-private\u3001-package\u307E\u305F\u306F-protected\u306E\u3046\u3061\u306E2\u3064\u4EE5\u4E0A\u3092\u6307\u5B9A\u3057\u307E\u3057\u305F\u3002
 main.cant.read={0}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093
 main.Loading_source_files_for_package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...
-main.Loading_source_file_for_class=\u30AF\u30E9\u30B9{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...
 main.Loading_source_file=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...
 main.Building_tree=Javadoc\u60C5\u5831\u3092\u69CB\u7BC9\u3057\u3066\u3044\u307E\u3059...
 main.no_source_files_for_package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306E\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u3042\u308A\u307E\u305B\u3093
@@ -67,13 +66,12 @@ tag.see.missing_sharp=\u30BF\u30B0{0}: ''#''\u304C\u3042\u308A\u307E\u305B\u3093
 tag.see.can_not_find_member=\u30BF\u30B0{0}: {2}\u3067{1}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
 tag.see.no_close_bracket_on_url=\u30BF\u30B0{0}: \u9589\u3058\u30BF\u30B0''>''\u304C\u3042\u308A\u307E\u305B\u3093: "{1}"
 tag.see.no_close_quote=\u30BF\u30B0{0}: \u9589\u3058\u5F15\u7528\u7B26\u304C\u3042\u308A\u307E\u305B\u3093: "{1}"
-tag.see.class_not_found=@see\u30BF\u30B0\u7528\u306E\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: "{1}"
 tag.see.class_not_specified=\u30BF\u30B0{0}: \u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093: "{1}"
 tag.see.illegal_character=\u30BF\u30B0{0}: "{2}"\u306B\u4E0D\u6B63\u306A\u6587\u5B57"{1}"\u304C\u3042\u308A\u307E\u3059
 tag.see.malformed_see_tag=\u30BF\u30B0{0}: \u66F8\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093: "{1}"
-tag.throws.exception_not_found={0}\u30BF\u30B0\u3001\u30AF\u30E9\u30B9{1}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
 tag.End_delimiter_missing_for_possible_SeeTag=\u30B3\u30E1\u30F3\u30C8\u6587\u5B57\u5217"{0}"\u3067\u3001\u6709\u52B9\u306Asee\u30BF\u30B0\u306B\u7D42\u7AEF\u30C7\u30EA\u30DF\u30BF}\u304C\u3042\u308A\u307E\u305B\u3093
 tag.Improper_Use_Of_Link_Tag=\u30A4\u30F3\u30E9\u30A4\u30F3\u30FB\u30BF\u30B0"{0}"\u306B\u7D42\u4E86\u6587\u5B57''}''\u304C\u3042\u308A\u307E\u305B\u3093
+tag.serialField.illegal_character=@serialField\u30BF\u30B0\u306B\u4E0D\u6B63\u306A\u6587\u5B57{0}\u304C\u3042\u308A\u307E\u3059: {1}\u3002
 javadoc.File_Read_Error=\u30D5\u30A1\u30A4\u30EB{0}\u306E\u8AAD\u8FBC\u307F\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F
 javadoc.Body_missing_from_html_file=HTML\u306Bbody\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093
 javadoc.End_body_missing_from_html_file=HTML\u30D5\u30A1\u30A4\u30EB\u306Bbody\u306E\u9589\u3058\u30BF\u30B0\u304C\u3042\u308A\u307E\u305B\u3093
@@ -81,4 +79,8 @@ javadoc.Multiple_package_comments=\u30D1\u30C3\u30B1\u30FC\u30B8"{0}"\u306B\u890
 javadoc.class_not_found=\u30AF\u30E9\u30B9{0}\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002
 javadoc.error=\u30A8\u30E9\u30FC
 javadoc.warning=\u8B66\u544A
-tag.serialField.illegal_character=@serialField\u30BF\u30B0\u306B\u4E0D\u6B63\u306A\u6587\u5B57{0}\u304C\u3042\u308A\u307E\u3059: {1}\u3002
+
+javadoc.error.msg={0}: \u30A8\u30E9\u30FC - {1}
+javadoc.warning.msg={0}: \u8B66\u544A - {1}
+javadoc.note.msg = {1}
+javadoc.note.pos.msg= {0}: {1}
diff --git a/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties
index 1e66cd1..bb16ec2 100644
--- a/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc_zh_CN.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 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
@@ -37,7 +37,6 @@ main.No_packages_or_classes_specified=\u672A\u6307\u5B9A\u7A0B\u5E8F\u5305\u6216
 main.incompatible.access.flags=\u6307\u5B9A\u4E86\u591A\u4E2A -public, -private, -package \u6216 -protected\u3002
 main.cant.read=\u65E0\u6CD5\u8BFB\u53D6{0}
 main.Loading_source_files_for_package=\u6B63\u5728\u52A0\u8F7D\u7A0B\u5E8F\u5305{0}\u7684\u6E90\u6587\u4EF6...
-main.Loading_source_file_for_class=\u6B63\u5728\u52A0\u8F7D\u7C7B{0}\u7684\u6E90\u6587\u4EF6...
 main.Loading_source_file=\u6B63\u5728\u52A0\u8F7D\u6E90\u6587\u4EF6{0}...
 main.Building_tree=\u6B63\u5728\u6784\u9020 Javadoc \u4FE1\u606F...
 main.no_source_files_for_package=\u6CA1\u6709\u7A0B\u5E8F\u5305{0}\u7684\u6E90\u6587\u4EF6
@@ -67,13 +66,12 @@ tag.see.missing_sharp=\u6807\u8BB0{0}: \u7F3A\u5C11 ''#'': "{1}"
 tag.see.can_not_find_member=\u6807\u8BB0{0}: \u5728{2}\u4E2D\u627E\u4E0D\u5230{1}
 tag.see.no_close_bracket_on_url=\u6807\u8BB0{0}: \u7F3A\u5C11\u6700\u540E\u7684 ''>'': "{1}"
 tag.see.no_close_quote=\u6807\u8BB0{0}: \u65E0\u53F3\u5F15\u53F7: "{1}"
-tag.see.class_not_found=\u627E\u4E0D\u5230 @see \u6807\u8BB0\u7684\u7C7B{0}: "{1}"
 tag.see.class_not_specified=\u6807\u8BB0{0}: \u672A\u6307\u5B9A\u7C7B: "{1}"
 tag.see.illegal_character=\u6807\u8BB0{0}: "{2}" \u4E2D\u7684 "{1}" \u4E3A\u975E\u6CD5\u5B57\u7B26
 tag.see.malformed_see_tag=\u6807\u8BB0{0}: \u683C\u5F0F\u9519\u8BEF: "{1}"
-tag.throws.exception_not_found=\u6807\u8BB0{0}: \u627E\u4E0D\u5230\u7C7B{1}\u3002
 tag.End_delimiter_missing_for_possible_SeeTag=\u6CE8\u91CA\u5B57\u7B26\u4E32\u4E2D\u53EF\u80FD\u51FA\u73B0\u7684 See \u6807\u8BB0\u7F3A\u5C11\u7ED3\u675F\u5206\u9694\u7B26 }: "{0}"
 tag.Improper_Use_Of_Link_Tag=\u5185\u5D4C\u6807\u8BB0\u7F3A\u5C11\u7ED3\u675F ''}'' \u5B57\u7B26: "{0}"
+tag.serialField.illegal_character=@serialField \u6807\u8BB0\u4E2D\u7684\u975E\u6CD5\u5B57\u7B26 {0}: {1}\u3002
 javadoc.File_Read_Error=\u8BFB\u53D6\u6587\u4EF6{0}\u65F6\u51FA\u9519
 javadoc.Body_missing_from_html_file=HTML \u6587\u4EF6\u4E2D\u7F3A\u5C11\u4E3B\u4F53\u6807\u8BB0
 javadoc.End_body_missing_from_html_file=HTML \u6587\u4EF6\u4E2D\u7F3A\u5C11\u4E3B\u4F53\u7ED3\u675F\u6807\u8BB0
@@ -81,4 +79,8 @@ javadoc.Multiple_package_comments=\u627E\u5230\u7A0B\u5E8F\u5305 "{0}" \u7684\u5
 javadoc.class_not_found=\u627E\u4E0D\u5230\u7C7B{0}\u3002
 javadoc.error=\u9519\u8BEF
 javadoc.warning=\u8B66\u544A
-tag.serialField.illegal_character=@serialField \u6807\u8BB0\u4E2D\u7684\u975E\u6CD5\u5B57\u7B26 {0}: {1}\u3002
+
+javadoc.error.msg={0}: \u9519\u8BEF - {1}
+javadoc.warning.msg={0}: \u8B66\u544A - {1}
+javadoc.note.msg = {1}
+javadoc.note.pos.msg= {0}: {1}
diff --git a/src/share/classes/com/sun/tools/javah/Gen.java b/src/share/classes/com/sun/tools/javah/Gen.java
index 5682986..dc50bae 100644
--- a/src/share/classes/com/sun/tools/javah/Gen.java
+++ b/src/share/classes/com/sun/tools/javah/Gen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -287,7 +287,7 @@ public abstract class Gen {
                         constString = value.toString();
                 }
                 if (constString != null) {
-                    StringBuffer s = new StringBuffer("#undef ");
+                    StringBuilder s = new StringBuilder("#undef ");
                     s.append(cname); s.append("_"); s.append(fname); s.append(lineSep);
                     s.append("#define "); s.append(cname); s.append("_");
                     s.append(fname); s.append(" "); s.append(constString);
@@ -370,7 +370,7 @@ public abstract class Gen {
 
     // c.f. MethodDoc.signature
     String signature(ExecutableElement e) {
-        StringBuffer sb = new StringBuffer("(");
+        StringBuilder sb = new StringBuilder("(");
         String sep = "";
         for (VariableElement p: e.getParameters()) {
             sb.append(sep);
diff --git a/src/share/classes/com/sun/tools/javah/JavahFileManager.java b/src/share/classes/com/sun/tools/javah/JavahFileManager.java
index 72160c5..e27eff2 100644
--- a/src/share/classes/com/sun/tools/javah/JavahFileManager.java
+++ b/src/share/classes/com/sun/tools/javah/JavahFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -44,7 +44,7 @@ import com.sun.tools.javac.util.Context;
 class JavahFileManager extends JavacFileManager {
     private JavahFileManager(Context context, Charset charset) {
         super(context, true, charset);
-        setIgnoreSymbolFile(true);
+        setSymbolFileEnabled(false);
     }
 
     static JavahFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
@@ -56,8 +56,4 @@ class JavahFileManager extends JavacFileManager {
 
         return new JavahFileManager(javac_context, null);
     }
-
-    void setIgnoreSymbolFile(boolean b) {
-        ignoreSymbolFile = b;
-    }
 }
diff --git a/src/share/classes/com/sun/tools/javah/JavahTask.java b/src/share/classes/com/sun/tools/javah/JavahTask.java
index e1cf29c..84b7c2b 100644
--- a/src/share/classes/com/sun/tools/javah/JavahTask.java
+++ b/src/share/classes/com/sun/tools/javah/JavahTask.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, 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
@@ -60,7 +60,7 @@ import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.TypeVisitor;
 import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.SimpleTypeVisitor7;
+import javax.lang.model.util.SimpleTypeVisitor8;
 import javax.lang.model.util.Types;
 
 import javax.tools.Diagnostic;
@@ -79,7 +79,7 @@ import com.sun.tools.javac.main.CommandLine;
 
 /**
  * Javah generates support files for native methods.
- * Parse commandline options & Invokes javadoc to execute those commands.
+ * Parse commandline options and invokes javadoc to execute those commands.
  *
  * <p><b>This is NOT part of any supported API.
  * If you write code that depends on this, you do so at your own
@@ -147,7 +147,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
         }
     }
 
-    static Option[] recognizedOptions = {
+    static final Option[] recognizedOptions = {
         new Option(true, "-o") {
             void process(JavahTask task, String opt, String arg) {
                 task.ofile = new File(arg);
@@ -220,12 +220,6 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
             }
         },
 
-        new HiddenOption(false, "-old") {
-            void process(JavahTask task, String opt, String arg) {
-                task.old = true;
-            }
-        },
-
         new HiddenOption(false, "-llni", "-Xllni") {
             void process(JavahTask task, String opt, String arg) {
                 task.llni = true;
@@ -500,7 +494,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
         g.setForce(force);
 
         if (fileManager instanceof JavahFileManager)
-            ((JavahFileManager) fileManager).setIgnoreSymbolFile(true);
+            ((JavahFileManager) fileManager).setSymbolFileEnabled(false);
 
         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
         List<String> opts = new ArrayList<String>();
@@ -537,7 +531,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
             String name = o.aliases[0].substring(1); // there must always be at least one name
             log.println(getMessage("main.opt." + name));
         }
-        String[] fmOptions = { "-classpath", "-bootclasspath" };
+        String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
@@ -663,7 +657,6 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
     boolean llni;
     boolean doubleAlign;
     boolean force;
-    boolean old;
     Set<String> javac_extras = new LinkedHashSet<String>();
 
     PrintWriter log;
@@ -745,7 +738,7 @@ public class JavahTask implements NativeHeaderTool.NativeHeaderTask {
         }
 
         private TypeVisitor<Void,Types> checkMethodParametersVisitor =
-                new SimpleTypeVisitor7<Void,Types>() {
+                new SimpleTypeVisitor8<Void,Types>() {
             @Override
             public Void visitArray(ArrayType t, Types types) {
                 visit(t.getComponentType(), types);
diff --git a/src/share/classes/com/sun/tools/javah/LLNI.java b/src/share/classes/com/sun/tools/javah/LLNI.java
index b011fba..783648a 100644
--- a/src/share/classes/com/sun/tools/javah/LLNI.java
+++ b/src/share/classes/com/sun/tools/javah/LLNI.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -45,7 +45,7 @@ import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.TypeVisitor;
 import javax.lang.model.util.ElementFilter;
-import javax.lang.model.util.SimpleTypeVisitor7;
+import javax.lang.model.util.SimpleTypeVisitor8;
 
 /*
  * <p><b>This is NOT part of any supported API.
@@ -628,7 +628,7 @@ public class LLNI extends Gen {
     }
 
     protected final boolean isLongOrDouble(TypeMirror t) {
-        TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor7<Boolean,Void>() {
+        TypeVisitor<Boolean,Void> v = new SimpleTypeVisitor8<Boolean,Void>() {
             public Boolean defaultAction(TypeMirror t, Void p){
                 return false;
             }
@@ -647,7 +647,7 @@ public class LLNI extends Gen {
        %%% This may not be right, but should be called more often. */
     protected final String nameToIdentifier(String name) {
         int len = name.length();
-        StringBuffer buf = new StringBuffer(len);
+        StringBuilder buf = new StringBuilder(len);
         for (int i = 0; i < len; i++) {
             char c = name.charAt(i);
             if (isASCIILetterOrDigit(c))
diff --git a/src/share/classes/com/sun/tools/javah/Mangle.java b/src/share/classes/com/sun/tools/javah/Mangle.java
index 616bb74..2cc74f5 100644
--- a/src/share/classes/com/sun/tools/javah/Mangle.java
+++ b/src/share/classes/com/sun/tools/javah/Mangle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -66,7 +66,7 @@ public class Mangle {
     }
 
     public final String mangle(CharSequence name, int mtype) {
-        StringBuffer result = new StringBuffer(100);
+        StringBuilder result = new StringBuilder(100);
         int length = name.length();
 
         for (int i = 0; i < length; i++) {
@@ -115,7 +115,7 @@ public class Mangle {
 
     public String mangleMethod(ExecutableElement method, TypeElement clazz,
                                       int mtype) throws TypeSignature.SignatureException {
-        StringBuffer result = new StringBuffer(100);
+        StringBuilder result = new StringBuilder(100);
         result.append("Java_");
 
         if (mtype == Mangle.Type.METHOD_JDK_1) {
@@ -164,7 +164,7 @@ public class Mangle {
 
     // Warning: duplicated in Gen
     private String signature(ExecutableElement e) {
-        StringBuffer sb = new StringBuffer();
+        StringBuilder sb = new StringBuilder();
         String sep = "(";
         for (VariableElement p: e.getParameters()) {
             sb.append(sep);
diff --git a/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java b/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java
index 5107dd1..1f4adc0 100644
--- a/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java
+++ b/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,13 @@ import java.io.Writer;
 import java.nio.charset.Charset;
 import java.util.Locale;
 import java.util.concurrent.Callable;
+import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.OptionChecker;
 import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
 import javax.tools.Tool;
 
 /**
diff --git a/src/share/classes/com/sun/tools/javah/TypeSignature.java b/src/share/classes/com/sun/tools/javah/TypeSignature.java
index 0c0c542..ecd0636 100644
--- a/src/share/classes/com/sun/tools/javah/TypeSignature.java
+++ b/src/share/classes/com/sun/tools/javah/TypeSignature.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -38,7 +38,7 @@ import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.TypeVariable;
 import javax.lang.model.type.TypeVisitor;
 import javax.lang.model.util.Elements;
-import javax.lang.model.util.SimpleTypeVisitor7;
+import javax.lang.model.util.SimpleTypeVisitor8;
 
 /**
  * Returns internal type signature.
@@ -245,7 +245,7 @@ public class TypeSignature {
 
 
     String qualifiedTypeName(TypeMirror type) {
-        TypeVisitor<Name, Void> v = new SimpleTypeVisitor7<Name, Void>() {
+        TypeVisitor<Name, Void> v = new SimpleTypeVisitor8<Name, Void>() {
             @Override
             public Name visitArray(ArrayType t, Void p) {
                 return t.getComponentType().accept(this, p);
diff --git a/src/share/classes/com/sun/tools/javah/Util.java b/src/share/classes/com/sun/tools/javah/Util.java
index 36dcf22..20736e6 100644
--- a/src/share/classes/com/sun/tools/javah/Util.java
+++ b/src/share/classes/com/sun/tools/javah/Util.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, 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
@@ -144,10 +144,6 @@ public class Util {
         throw new Exit(15);
     }
 
-    private void fatal(String msg) throws Exit {
-        fatal(msg, null);
-    }
-
     private void fatal(String msg, Exception e) throws Exit {
         dl.report(createDiagnostic(Diagnostic.Kind.ERROR, "", msg));
         throw new Exit(10, e);
diff --git a/src/share/classes/com/sun/tools/javah/resources/l10n.properties b/src/share/classes/com/sun/tools/javah/resources/l10n.properties
index 632cd15..875816b 100644
--- a/src/share/classes/com/sun/tools/javah/resources/l10n.properties
+++ b/src/share/classes/com/sun/tools/javah/resources/l10n.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2010, 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
@@ -77,6 +77,7 @@ where [options] include:\n\
 \n\t\
 -help                 Print this help message and exit\n\t\
 -classpath <path>     Path from which to load classes\n\t\
+-cp <path>            Path from which to load classes\n\t\
 -bootclasspath <path> Path from which to load bootstrap classes\n\t\
 -d <dir>              Output directory\n\t\
 -o <file>             Output file (only one of -d or -o may be used)\n\t\
@@ -108,6 +109,8 @@ main.opt.force=\
 \  -force                   Always write output files
 main.opt.classpath=\
 \  -classpath <path>        Path from which to load classes
+main.opt.cp=\
+\  -cp <path>               Path from which to load classes
 main.opt.bootclasspath=\
 \  -bootclasspath <path>    Path from which to load bootstrap classes
 main.usage.foot=\
diff --git a/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties b/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties
index 07deaf2..6a5e90e 100644
--- a/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties
+++ b/src/share/classes/com/sun/tools/javah/resources/l10n_ja.properties
@@ -33,10 +33,10 @@ at.args.io.exception=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u306E@\u5F15\u65
 old.jni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-old\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
 old.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-old\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
 old.not.supported=\u3053\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306Ejavah\u3067\u306F\u30AA\u30D7\u30B7\u30E7\u30F3-old\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002
-invalid.method.signature=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u30FB\u30B7\u30B0\u30CB\u30C1\u30E3: {0}
+invalid.method.signature=\u7121\u52B9\u306A\u30E1\u30BD\u30C3\u30C9\u30FB\u30B7\u30B0\u30CD\u30C1\u30E3: {0}
 jni.llni.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-jni\u3068-llni\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
 jni.no.stubs=JNI\u306F\u30B9\u30BF\u30D6\u3092\u5FC5\u8981\u3068\u3057\u307E\u305B\u3093\u3002JNI\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
-jni.sigerror={0}\u306E\u7F72\u540D\u3092\u5224\u5B9A\u3067\u304D\u307E\u305B\u3093
+jni.sigerror={0}\u306E\u30B7\u30B0\u30CD\u30C1\u30E3\u3092\u5224\u5225\u3067\u304D\u307E\u305B\u3093
 dir.file.mixed=\u30AA\u30D7\u30B7\u30E7\u30F3-d\u3068-o\u3092\u540C\u6642\u306B\u4F7F\u7528\u3059\u308B\u3053\u3068\u306F\u3067\u304D\u307E\u305B\u3093\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
 no.classes.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
 no.outputfile.specified=\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u3067\u51FA\u529B\u30D5\u30A1\u30A4\u30EB\u304C\u6307\u5B9A\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F\u3002-help\u3067\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
@@ -51,7 +51,7 @@ tracing.not.supported=\u8B66\u544A: \u30C8\u30EC\u30FC\u30B9\u306F\u73FE\u5728\u
 #
 usage=\u4F7F\u7528\u65B9\u6CD5: javah [options] <classes>\n\n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002\n\n\t-help           \u30D8\u30EB\u30D7\u30FB\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u3066\u7D42\u4E86\u3059\u308B\n\t-classpath <path>   \u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u308B\u30D1\u30B9\n\t-bootclasspath <path> \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u3092\u30ED\u30FC\u30C9\u3059\u [...]
 
-main.usage=\u4F7F\u7528\u65B9\u6CD5: \n\  javah [options] <classes>\n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002
+main.usage=\u4F7F\u7528\u65B9\u6CD5: \n  javah [options] <classes>\n[options]\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059\u3002
 main.opt.o=\  -o <file>                \u51FA\u529B\u30D5\u30A1\u30A4\u30EB(-d\u304B-o\u306E\u3069\u3061\u3089\u304B\u4E00\u65B9\u3092\u4F7F\u7528\u3059\u308B)
 main.opt.d=\  -d <dir>                 \u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA
 main.opt.v=\  -v  -verbose             \u8A73\u7D30\u306A\u51FA\u529B\u3092\u884C\u3046
diff --git a/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties b/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties
index 5aedc94..995b1ca 100644
--- a/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/javah/resources/l10n_zh_CN.properties
@@ -51,7 +51,7 @@ tracing.not.supported=\u8B66\u544A: \u4E0D\u518D\u652F\u6301\u8DDF\u8E2A\u3002\u
 #
 usage=\u7528\u6CD5: javah [options] <classes>\n\n\u5176\u4E2D, [options] \u5305\u62EC:\n\n\t-help                 \u8F93\u51FA\u6B64\u5E2E\u52A9\u6D88\u606F\u5E76\u9000\u51FA\n\t-classpath <path>     \u4ECE\u4E2D\u52A0\u8F7D\u7C7B\u7684\u8DEF\u5F84\n\t-bootclasspath <path> \u4ECE\u4E2D\u52A0\u8F7D\u5F15\u5BFC\u7C7B\u7684\u8DEF\u5F84\n\t-d <dir>              \u8F93\u51FA\u76EE\u5F55\n\t-o <file>             \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00)\n\t- [...]
 
-main.usage=\u7528\u6CD5: \n\  javah [options] <classes>\n\u5176\u4E2D, [options] \u5305\u62EC:
+main.usage=\u7528\u6CD5: \n  javah [options] <classes>\n\u5176\u4E2D, [options] \u5305\u62EC:
 main.opt.o=\  -o <file>                \u8F93\u51FA\u6587\u4EF6 (\u53EA\u80FD\u4F7F\u7528 -d \u6216 -o \u4E4B\u4E00)
 main.opt.d=\  -d <dir>                 \u8F93\u51FA\u76EE\u5F55
 main.opt.v=\  -v  -verbose             \u542F\u7528\u8BE6\u7EC6\u8F93\u51FA
diff --git a/src/share/classes/com/sun/tools/javap/AnnotationWriter.java b/src/share/classes/com/sun/tools/javap/AnnotationWriter.java
index 37ec6b2..99aa17a 100644
--- a/src/share/classes/com/sun/tools/javap/AnnotationWriter.java
+++ b/src/share/classes/com/sun/tools/javap/AnnotationWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -26,6 +26,7 @@
 package com.sun.tools.javap;
 
 import com.sun.tools.classfile.Annotation;
+import com.sun.tools.classfile.TypeAnnotation;
 import com.sun.tools.classfile.Annotation.Annotation_element_value;
 import com.sun.tools.classfile.Annotation.Array_element_value;
 import com.sun.tools.classfile.Annotation.Class_element_value;
@@ -76,6 +77,123 @@ public class AnnotationWriter extends BasicWriter {
             print(")");
     }
 
+    public void write(TypeAnnotation annot) {
+        write(annot, true, false);
+    }
+
+    public void write(TypeAnnotation annot, boolean showOffsets, boolean resolveIndices) {
+        write(annot.annotation, resolveIndices);
+        print(": ");
+        write(annot.position, showOffsets);
+    }
+
+    public void write(TypeAnnotation.Position pos, boolean showOffsets) {
+        print(pos.type);
+
+        switch (pos.type) {
+        // instanceof
+        case INSTANCEOF:
+        // new expression
+        case NEW:
+        // constructor/method reference receiver
+        case CONSTRUCTOR_REFERENCE:
+        case METHOD_REFERENCE:
+            if (showOffsets) {
+                print(", offset=");
+                print(pos.offset);
+            }
+            break;
+        // local variable
+        case LOCAL_VARIABLE:
+        // resource variable
+        case RESOURCE_VARIABLE:
+            if (pos.lvarOffset == null) {
+                print(", lvarOffset is Null!");
+                break;
+            }
+            print(", {");
+            for (int i = 0; i < pos.lvarOffset.length; ++i) {
+                if (i != 0) print("; ");
+                if (showOffsets) {
+                    print("start_pc=");
+                    print(pos.lvarOffset[i]);
+                }
+                print(", length=");
+                print(pos.lvarLength[i]);
+                print(", index=");
+                print(pos.lvarIndex[i]);
+            }
+            print("}");
+            break;
+        // exception parameter
+        case EXCEPTION_PARAMETER:
+            print(", exception_index=");
+            print(pos.exception_index);
+            break;
+        // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameter
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            print(", param_index=");
+            print(pos.parameter_index);
+            break;
+        // type parameter bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND:
+            print(", param_index=");
+            print(pos.parameter_index);
+            print(", bound_index=");
+            print(pos.bound_index);
+            break;
+        // class extends or implements clause
+        case CLASS_EXTENDS:
+            print(", type_index=");
+            print(pos.type_index);
+            break;
+        // throws
+        case THROWS:
+            print(", type_index=");
+            print(pos.type_index);
+            break;
+        // method parameter
+        case METHOD_FORMAL_PARAMETER:
+            print(", param_index=");
+            print(pos.parameter_index);
+            break;
+        // type cast
+        case CAST:
+        // method/constructor/reference type argument
+        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
+        case METHOD_INVOCATION_TYPE_ARGUMENT:
+        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
+        case METHOD_REFERENCE_TYPE_ARGUMENT:
+            if (showOffsets) {
+                print(", offset=");
+                print(pos.offset);
+            }
+            print(", type_index=");
+            print(pos.type_index);
+            break;
+        // We don't need to worry about these
+        case METHOD_RETURN:
+        case FIELD:
+            break;
+        case UNKNOWN:
+            throw new AssertionError("AnnotationWriter: UNKNOWN target type should never occur!");
+        default:
+            throw new AssertionError("AnnotationWriter: Unknown target type for position: " + pos);
+        }
+
+        // Append location data for generics/arrays.
+        if (!pos.location.isEmpty()) {
+            print(", location=");
+            print(pos.location);
+        }
+    }
+
     public void write(Annotation.element_value_pair pair) {
         write(pair, false);
     }
diff --git a/src/share/classes/com/sun/tools/javap/AttributeWriter.java b/src/share/classes/com/sun/tools/javap/AttributeWriter.java
index 6263fc8..02795a5 100644
--- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java
+++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -46,10 +46,13 @@ import com.sun.tools.classfile.InnerClasses_attribute;
 import com.sun.tools.classfile.LineNumberTable_attribute;
 import com.sun.tools.classfile.LocalVariableTable_attribute;
 import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
+import com.sun.tools.classfile.MethodParameters_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
 import com.sun.tools.classfile.Signature_attribute;
 import com.sun.tools.classfile.SourceDebugExtension_attribute;
 import com.sun.tools.classfile.SourceFile_attribute;
@@ -111,6 +114,9 @@ public class AttributeWriter extends BasicWriter
     }
 
     public Void visitDefault(DefaultAttribute attr, Void ignore) {
+        if (attr.reason != null) {
+            report(attr.reason);
+        }
         byte[] data = attr.info;
         int i = 0;
         int j = 0;
@@ -362,8 +368,7 @@ public class AttributeWriter extends BasicWriter
         indent(+1);
         println("Start  Length  Slot  Name   Signature");
         for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
-            Formatter formatter = new Formatter();
-            println(formatter.format("%8d %7d %5d %5s   %s",
+            println(String.format("%5d %7d %5d %5s   %s",
                     entry.start_pc, entry.length, entry.index,
                     constantWriter.stringValue(entry.name_index),
                     constantWriter.stringValue(entry.descriptor_index)));
@@ -386,6 +391,30 @@ public class AttributeWriter extends BasicWriter
         return null;
     }
 
+    private static final String format = "%-31s%s";
+
+    public Void visitMethodParameters(MethodParameters_attribute attr,
+                                      Void ignore) {
+
+        final String header = String.format(format, "Name", "Flags");
+        println("MethodParameters:");
+        indent(+1);
+        println(header);
+        for (MethodParameters_attribute.Entry entry :
+                 attr.method_parameter_table) {
+            String namestr =
+                entry.name_index != 0 ?
+                constantWriter.stringValue(entry.name_index) : "<no name>";
+            String flagstr =
+                (0 != (entry.flags & ACC_FINAL) ? "final " : "") +
+                (0 != (entry.flags & ACC_MANDATED) ? "mandated " : "") +
+                (0 != (entry.flags & ACC_SYNTHETIC) ? "synthetic" : "");
+            println(String.format(format, namestr, flagstr));
+        }
+        indent(-1);
+        return null;
+    }
+
     public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
         println("RuntimeVisibleAnnotations:");
         indent(+1);
@@ -410,6 +439,30 @@ public class AttributeWriter extends BasicWriter
         return null;
     }
 
+    public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) {
+        println("RuntimeVisibleTypeAnnotations:");
+        indent(+1);
+        for (int i = 0; i < attr.annotations.length; i++) {
+            print(i + ": ");
+            annotationWriter.write(attr.annotations[i]);
+            println();
+        }
+        indent(-1);
+        return null;
+    }
+
+    public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) {
+        println("RuntimeInvisibleTypeAnnotations:");
+        indent(+1);
+        for (int i = 0; i < attr.annotations.length; i++) {
+            print(i + ": ");
+            annotationWriter.write(attr.annotations[i]);
+            println();
+        }
+        indent(-1);
+        return null;
+    }
+
     public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
         println("RuntimeVisibleParameterAnnotations:");
         indent(+1);
@@ -460,7 +513,12 @@ public class AttributeWriter extends BasicWriter
     }
 
     public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
-        println("SourceDebugExtension: " + attr.getValue());
+        println("SourceDebugExtension:");
+        indent(+1);
+        for (String s: attr.getValue().split("[\r\n]+")) {
+            println(s);
+        }
+        indent(-1);
         return null;
     }
 
@@ -558,7 +616,8 @@ public class AttributeWriter extends BasicWriter
         public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
             printHeader(frame);
             println(" /* append */");
-            println("     offset_delta = " + frame.offset_delta);
+            indent(+1);
+            println("offset_delta = " + frame.offset_delta);
             printMap("locals", frame.locals);
             return null;
         }
diff --git a/src/share/classes/com/sun/tools/javap/ClassWriter.java b/src/share/classes/com/sun/tools/javap/ClassWriter.java
index 331a7b9..14a9258 100644
--- a/src/share/classes/com/sun/tools/javap/ClassWriter.java
+++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -206,7 +206,7 @@ public class ClassWriter extends BasicWriter {
             println("minor version: " + cf.minor_version);
             println("major version: " + cf.major_version);
             if (!options.compat)
-              writeList("flags: ", flags.getClassFlags(), NEWLINE);
+              writeList("flags: ", flags.getClassFlags(), "\n");
             indent(-1);
             constantWriter.writeConstantPool();
         } else {
@@ -379,11 +379,11 @@ public class ClassWriter extends BasicWriter {
 
         indent(+1);
 
-        if (options.showInternalSignatures)
-            println("Signature: " + getValue(f.descriptor));
+        if (options.showDescriptors)
+            println("descriptor: " + getValue(f.descriptor));
 
         if (options.verbose && !options.compat)
-            writeList("flags: ", flags.getFieldFlags(), NEWLINE);
+            writeList("flags: ", flags.getFieldFlags(), "\n");
 
         if (options.showAllAttrs) {
             for (Attribute attr: f.attributes)
@@ -475,12 +475,12 @@ public class ClassWriter extends BasicWriter {
 
         indent(+1);
 
-        if (options.showInternalSignatures) {
-            println("Signature: " + getValue(m.descriptor));
+        if (options.showDescriptors) {
+            println("descriptor: " + getValue(m.descriptor));
         }
 
         if (options.verbose && !options.compat) {
-            writeList("flags: ", flags.getMethodFlags(), NEWLINE);
+            writeList("flags: ", flags.getMethodFlags(), "\n");
         }
 
         Code_attribute code = null;
@@ -520,7 +520,7 @@ public class ClassWriter extends BasicWriter {
         setPendingNewline(
                 options.showDisassembled ||
                 options.showAllAttrs ||
-                options.showInternalSignatures ||
+                options.showDescriptors ||
                 options.showLineAndLocalVariableTables ||
                 options.verbose);
     }
@@ -749,5 +749,4 @@ public class ClassWriter extends BasicWriter {
     private int size;
     private ConstantPool constant_pool;
     private Method method;
-    private static final String NEWLINE = System.getProperty("line.separator", "\n");
 }
diff --git a/src/share/classes/com/sun/tools/javap/CodeWriter.java b/src/share/classes/com/sun/tools/javap/CodeWriter.java
index da8bdde..657194d 100644
--- a/src/share/classes/com/sun/tools/javap/CodeWriter.java
+++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -64,6 +64,7 @@ public class CodeWriter extends BasicWriter {
         stackMapWriter = StackMapWriter.instance(context);
         localVariableTableWriter = LocalVariableTableWriter.instance(context);
         localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context);
+        typeAnnotationWriter = TypeAnnotationWriter.instance(context);
         options = Options.instance(context);
     }
 
@@ -265,6 +266,11 @@ public class CodeWriter extends BasicWriter {
             detailWriters.add(tryBlockWriter);
         }
 
+        if (options.details.contains(InstructionDetailWriter.Kind.TYPE_ANNOS)) {
+            typeAnnotationWriter.reset(attr);
+            detailWriters.add(typeAnnotationWriter);
+        }
+
         return detailWriters;
     }
 
@@ -273,6 +279,7 @@ public class CodeWriter extends BasicWriter {
     private ConstantWriter constantWriter;
     private LocalVariableTableWriter localVariableTableWriter;
     private LocalVariableTypeTableWriter localVariableTypeTableWriter;
+    private TypeAnnotationWriter typeAnnotationWriter;
     private SourceWriter sourceWriter;
     private StackMapWriter stackMapWriter;
     private TryBlockWriter tryBlockWriter;
diff --git a/src/share/classes/com/sun/tools/javap/ConstantWriter.java b/src/share/classes/com/sun/tools/javap/ConstantWriter.java
index fad08ac..2a3544a 100644
--- a/src/share/classes/com/sun/tools/javap/ConstantWriter.java
+++ b/src/share/classes/com/sun/tools/javap/ConstantWriter.java
@@ -239,7 +239,7 @@ public class ConstantWriter extends BasicWriter {
         }
     }
 
-    String stringValue(int constant_pool_index) {
+    public String stringValue(int constant_pool_index) {
         ClassFile classFile = classWriter.getClassFile();
         try {
             return stringValue(classFile.constant_pool.get(constant_pool_index));
diff --git a/src/share/classes/com/sun/tools/javap/DisassemblerTool.java b/src/share/classes/com/sun/tools/javap/DisassemblerTool.java
index 356fc9a..8f7a588 100644
--- a/src/share/classes/com/sun/tools/javap/DisassemblerTool.java
+++ b/src/share/classes/com/sun/tools/javap/DisassemblerTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,13 @@ import java.io.Writer;
 import java.nio.charset.Charset;
 import java.util.Locale;
 import java.util.concurrent.Callable;
+import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.OptionChecker;
 import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
 import javax.tools.Tool;
 
 /**
@@ -69,9 +71,7 @@ public interface DisassemblerTool extends Tool, OptionChecker {
      * @param options compiler options, {@code null} means no options
      * @param classes class names (for annotation processing), {@code
      * null} means no class names
-     * @param compilationUnits the compilation units to compile, {@code
-     * null} means no compilation units
-     * @return an object representing the compilation
+     * @return a task to perform the disassembly
      * @throws RuntimeException if an unrecoverable error
      * occurred in a user supplied component.  The
      * {@linkplain Throwable#getCause() cause} will be the error in
diff --git a/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java b/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java
index 7459d6c..8a828b8 100644
--- a/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java
+++ b/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, 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
@@ -42,10 +42,13 @@ public abstract class InstructionDetailWriter extends BasicWriter {
         LOCAL_VAR_TYPES("localVariableTypes"),
         SOURCE("source"),
         STACKMAPS("stackMaps"),
-        TRY_BLOCKS("tryBlocks");
+        TRY_BLOCKS("tryBlocks"),
+        TYPE_ANNOS("typeAnnotations");
+
         Kind(String option) {
             this.option = option;
         }
+
         final String option;
     }
 
diff --git a/src/share/classes/com/sun/tools/javap/JavapFileManager.java b/src/share/classes/com/sun/tools/javap/JavapFileManager.java
index 8fa7579..cf491bf 100644
--- a/src/share/classes/com/sun/tools/javap/JavapFileManager.java
+++ b/src/share/classes/com/sun/tools/javap/JavapFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -44,7 +44,7 @@ import com.sun.tools.javac.util.Context;
 public class JavapFileManager extends JavacFileManager {
     private JavapFileManager(Context context, Charset charset) {
         super(context, true, charset);
-        setIgnoreSymbolFile(true);
+        setSymbolFileEnabled(false);
     }
 
     public static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
@@ -56,8 +56,4 @@ public class JavapFileManager extends JavacFileManager {
 
         return new JavapFileManager(javac_context, null);
     }
-
-    void setIgnoreSymbolFile(boolean b) {
-        ignoreSymbolFile = b;
-    }
 }
diff --git a/src/share/classes/com/sun/tools/javap/JavapTask.java b/src/share/classes/com/sun/tools/javap/JavapTask.java
index 6ef621c..0cafe02 100644
--- a/src/share/classes/com/sun/tools/javap/JavapTask.java
+++ b/src/share/classes/com/sun/tools/javap/JavapTask.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2009, 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
@@ -117,7 +117,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
         final String[] aliases;
     }
 
-    static Option[] recognizedOptions = {
+    static final Option[] recognizedOptions = {
 
         new Option(false, "-help", "--help", "-?") {
             void process(JavapTask task, String opt, String arg) {
@@ -140,6 +140,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
         new Option(false, "-v", "-verbose", "-all") {
             void process(JavapTask task, String opt, String arg) {
                 task.options.verbose = true;
+                task.options.showDescriptors = true;
                 task.options.showFlags = true;
                 task.options.showAllAttrs = true;
             }
@@ -190,7 +191,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
 
         new Option(false, "-s") {
             void process(JavapTask task, String opt, String arg) {
-                task.options.showInternalSignatures = true;
+                task.options.showDescriptors = true;
             }
         },
 
@@ -362,7 +363,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
         }
 
         try {
-            handleOptions(options, false);
+            if (options != null)
+                handleOptions(options, false);
         } catch (BadArgs e) {
             throw new IllegalArgumentException(e.getMessage());
         }
@@ -374,8 +376,8 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
         task_locale = locale;
     }
 
-    public void setLog(PrintWriter log) {
-        this.log = log;
+    public void setLog(Writer log) {
+        this.log = getPrintWriterForWriter(log);
     }
 
     public void setLog(OutputStream s) {
@@ -383,7 +385,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
     }
 
     private static PrintWriter getPrintWriterForStream(OutputStream s) {
-        return new PrintWriter(s, true);
+        return new PrintWriter(s == null ? System.err : s, true);
     }
 
     private static PrintWriter getPrintWriterForWriter(Writer w) {
@@ -450,8 +452,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
             }
 
             try {
-                boolean ok = run();
-                return ok ? EXIT_OK : EXIT_ERROR;
+                return run();
             } finally {
                 if (defaultFileManager != null) {
                     try {
@@ -567,12 +568,13 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
     }
 
     public Boolean call() {
-        return run();
+        return run() == 0;
     }
 
-    public boolean run() {
-        if (classes == null || classes.size() == 0)
-            return false;
+    public int run() {
+        if (classes == null || classes.isEmpty()) {
+            return EXIT_ERROR;
+        }
 
         context.put(PrintWriter.class, log);
         ClassWriter classWriter = ClassWriter.instance(context);
@@ -581,54 +583,55 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
 
         attributeFactory.setCompat(options.compat);
 
-        boolean ok = true;
+        int result = EXIT_OK;
 
         for (String className: classes) {
-            JavaFileObject fo;
             try {
-                writeClass(classWriter, className);
+                result = writeClass(classWriter, className);
             } catch (ConstantPoolException e) {
                 reportError("err.bad.constant.pool", className, e.getLocalizedMessage());
-                ok = false;
+                result = EXIT_ERROR;
             } catch (EOFException e) {
                 reportError("err.end.of.file", className);
-                ok = false;
+                result = EXIT_ERROR;
             } catch (FileNotFoundException e) {
                 reportError("err.file.not.found", e.getLocalizedMessage());
-                ok = false;
+                result = EXIT_ERROR;
             } catch (IOException e) {
                 //e.printStackTrace();
                 Object msg = e.getLocalizedMessage();
-                if (msg == null)
+                if (msg == null) {
                     msg = e;
+                }
                 reportError("err.ioerror", className, msg);
-                ok = false;
+                result = EXIT_ERROR;
             } catch (Throwable t) {
                 StringWriter sw = new StringWriter();
                 PrintWriter pw = new PrintWriter(sw);
                 t.printStackTrace(pw);
                 pw.close();
                 reportError("err.crash", t.toString(), sw.toString());
-                ok = false;
+                result = EXIT_ABNORMAL;
             }
         }
 
-        return ok;
+        return result;
     }
 
-    protected boolean writeClass(ClassWriter classWriter, String className)
+    protected int writeClass(ClassWriter classWriter, String className)
             throws IOException, ConstantPoolException {
         JavaFileObject fo = open(className);
         if (fo == null) {
             reportError("err.class.not.found", className);
-            return false;
+            return EXIT_ERROR;
         }
 
         ClassFileInfo cfInfo = read(fo);
         if (!className.endsWith(".class")) {
             String cfName = cfInfo.cf.getName();
-            if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", ".")))
+            if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", "."))) {
                 reportWarning("warn.unexpected.class", className, cfName.replace('/', '.'));
+            }
         }
         write(cfInfo);
 
@@ -638,7 +641,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
             if (a instanceof InnerClasses_attribute) {
                 InnerClasses_attribute inners = (InnerClasses_attribute) a;
                 try {
-                    boolean ok = true;
+                    int result = EXIT_OK;
                     for (int i = 0; i < inners.classes.length; i++) {
                         int outerIndex = inners.classes[i].outer_class_info_index;
                         ConstantPool.CONSTANT_Class_info outerClassInfo = cf.constant_pool.getClassInfo(outerIndex);
@@ -649,21 +652,22 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
                             String innerClassName = innerClassInfo.getName();
                             classWriter.println("// inner class " + innerClassName.replaceAll("[/$]", "."));
                             classWriter.println();
-                            ok = ok & writeClass(classWriter, innerClassName);
+                            result = writeClass(classWriter, innerClassName);
+                            if (result != EXIT_OK) return result;
                         }
                     }
-                    return ok;
+                    return result;
                 } catch (ConstantPoolException e) {
                     reportError("err.bad.innerclasses.attribute", className);
-                    return false;
+                    return EXIT_ERROR;
                 }
             } else if (a != null) {
                 reportError("err.bad.innerclasses.attribute", className);
-                return false;
+                return EXIT_ERROR;
             }
         }
 
-        return true;
+        return EXIT_OK;
     }
 
     protected JavaFileObject open(String className) throws IOException {
@@ -881,7 +885,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
                 continue;
             log.println(getMessage("main.opt." + name));
         }
-        String[] fmOptions = { "-classpath", "-bootclasspath" };
+        String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
diff --git a/src/share/classes/com/sun/tools/javap/Options.java b/src/share/classes/com/sun/tools/javap/Options.java
index 0a05d3b..97e02d1 100644
--- a/src/share/classes/com/sun/tools/javap/Options.java
+++ b/src/share/classes/com/sun/tools/javap/Options.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 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
@@ -81,7 +81,7 @@ public class Options {
     public Set<String> accessOptions = new HashSet<String>();
     public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class);
     public boolean showDisassembled;
-    public boolean showInternalSignatures;
+    public boolean showDescriptors;
     public boolean showAllAttrs;
     public boolean showConstants;
     public boolean sysInfo;
diff --git a/src/share/classes/com/sun/tools/javap/StackMapWriter.java b/src/share/classes/com/sun/tools/javap/StackMapWriter.java
index aedcf31..bed0485 100644
--- a/src/share/classes/com/sun/tools/javap/StackMapWriter.java
+++ b/src/share/classes/com/sun/tools/javap/StackMapWriter.java
@@ -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
@@ -25,10 +25,11 @@
 
 package com.sun.tools.javap;
 
-import com.sun.tools.classfile.AccessFlags;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.sun.tools.classfile.AccessFlags;
 import com.sun.tools.classfile.Attribute;
 import com.sun.tools.classfile.Code_attribute;
 import com.sun.tools.classfile.ConstantPool;
@@ -233,8 +234,7 @@ public class StackMapWriter extends InstructionDetailWriter {
             StackMap prev = map.get(pc);
             assert (prev != null);
             int k = 251 - frame.frame_type;
-            verification_type_info[] new_locals = new verification_type_info[prev.locals.length - k];
-            System.arraycopy(prev.locals, 0, new_locals, 0, new_locals.length);
+            verification_type_info[] new_locals = Arrays.copyOf(prev.locals, prev.locals.length - k);
             StackMap m = new StackMap(new_locals, empty);
             map.put(new_pc, m);
             return new_pc;
@@ -269,7 +269,7 @@ public class StackMapWriter extends InstructionDetailWriter {
 
     }
 
-    class StackMap {
+    static class StackMap {
         StackMap(verification_type_info[] locals, verification_type_info[] stack) {
             this.locals = locals;
             this.stack = stack;
@@ -279,7 +279,7 @@ public class StackMapWriter extends InstructionDetailWriter {
         private final verification_type_info[] stack;
     }
 
-    class CustomVerificationTypeInfo extends verification_type_info {
+    static class CustomVerificationTypeInfo extends verification_type_info {
         public CustomVerificationTypeInfo(String text) {
             super(-1);
             this.text = text;
diff --git a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java
new file mode 100644
index 0000000..e5a3a68
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java
@@ -0,0 +1,126 @@
+/*
+ * 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.  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.javap;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.TypeAnnotation;
+import com.sun.tools.classfile.TypeAnnotation.Position;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeTypeAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Annotate instructions with details about type annotations.
+ *
+ *  <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 TypeAnnotationWriter extends InstructionDetailWriter {
+    public enum NoteKind { VISIBLE, INVISIBLE };
+    public static class Note {
+        Note(NoteKind kind, TypeAnnotation anno) {
+            this.kind = kind;
+            this.anno = anno;
+        }
+        public final NoteKind kind;
+        public final TypeAnnotation anno;
+    }
+
+    static TypeAnnotationWriter instance(Context context) {
+        TypeAnnotationWriter instance = context.get(TypeAnnotationWriter.class);
+        if (instance == null)
+            instance = new TypeAnnotationWriter(context);
+        return instance;
+    }
+
+    protected TypeAnnotationWriter(Context context) {
+        super(context);
+        context.put(TypeAnnotationWriter.class, this);
+        annotationWriter = AnnotationWriter.instance(context);
+        classWriter = ClassWriter.instance(context);
+    }
+
+    public void reset(Code_attribute attr) {
+        Method m = classWriter.getMethod();
+        pcMap = new HashMap<Integer, List<Note>>();
+        check(NoteKind.VISIBLE, (RuntimeVisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeVisibleTypeAnnotations));
+        check(NoteKind.INVISIBLE, (RuntimeInvisibleTypeAnnotations_attribute) m.attributes.get(Attribute.RuntimeInvisibleTypeAnnotations));
+    }
+
+    private void check(NoteKind kind, RuntimeTypeAnnotations_attribute attr) {
+        if (attr == null)
+            return;
+
+        for (TypeAnnotation anno: attr.annotations) {
+            Position p = anno.position;
+            Note note = null;
+            if (p.offset != -1)
+                addNote(p.offset, note = new Note(kind, anno));
+            if (p.lvarOffset != null) {
+                for (int i = 0; i < p.lvarOffset.length; i++) {
+                    if (note == null)
+                        note = new Note(kind, anno);
+                    addNote(p.lvarOffset[i], note);
+                }
+            }
+        }
+    }
+
+    private void addNote(int pc, Note note) {
+        List<Note> list = pcMap.get(pc);
+        if (list == null)
+            pcMap.put(pc, list = new ArrayList<Note>());
+        list.add(note);
+    }
+
+    @Override
+    void writeDetails(Instruction instr) {
+        String indent = space(2); // get from Options?
+        int pc = instr.getPC();
+        List<Note> notes = pcMap.get(pc);
+        if (notes != null) {
+            for (Note n: notes) {
+                print(indent);
+                print("@");
+                annotationWriter.write(n.anno, false, true);
+                print(", ");
+                println(n.kind.toString().toLowerCase());
+            }
+        }
+    }
+
+    private AnnotationWriter annotationWriter;
+    private ClassWriter classWriter;
+    private Map<Integer, List<Note>> pcMap;
+}
diff --git a/src/share/classes/com/sun/tools/javap/resources/javap.properties b/src/share/classes/com/sun/tools/javap/resources/javap.properties
index 4a13d60..c77024f 100644
--- a/src/share/classes/com/sun/tools/javap/resources/javap.properties
+++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties
@@ -1,5 +1,5 @@
 
-err.prefix=Error: 
+err.prefix=Error:
 
 err.bad.constant.pool=error while reading constant pool for {0}: {1}
 err.class.not.found=class not found: {0}
@@ -73,6 +73,9 @@ main.opt.s=\
 main.opt.classpath=\
 \  -classpath <path>        Specify where to find user class files
 
+main.opt.cp=\
+\  -cp <path>               Specify where to find user class files
+
 main.opt.bootclasspath=\
 \  -bootclasspath <path>    Override location of bootstrap class files
 
diff --git a/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties b/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties
new file mode 100644
index 0000000..e5b9605
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javap/resources/javap_ja.properties
@@ -0,0 +1,63 @@
+
+err.prefix=\u30A8\u30E9\u30FC: 
+
+err.bad.constant.pool={0}\u306E\u5B9A\u6570\u30D7\u30FC\u30EB\u306E\u8AAD\u53D6\u308A\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {1}
+err.class.not.found=\u30AF\u30E9\u30B9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}
+err.crash=\u91CD\u5927\u306A\u5185\u90E8\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {0}\n\u6B21\u306E\u60C5\u5831\u3092\u542B\u3080\u30D0\u30B0\u30FB\u30EC\u30DD\u30FC\u30C8\u3092\u30D5\u30A1\u30A4\u30EB\u3057\u3066\u304F\u3060\u3055\u3044:\n{1}
+err.end.of.file={0}\u306E\u8AAD\u53D6\u308A\u4E2D\u306B\u4E88\u671F\u3057\u306A\u3044\u30D5\u30A1\u30A4\u30EB\u306E\u7D42\u308F\u308A\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F
+err.file.not.found=\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: {0}
+err.h.not.supported=-h\u306F\u4F7F\u7528\u53EF\u80FD\u3067\u306A\u304F\u306A\u308A\u307E\u3057\u305F - 'javah'\u30D7\u30ED\u30B0\u30E9\u30E0\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044
+err.incompatible.options=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u7D44\u5408\u305B\u304C\u4E0D\u6B63\u3067\u3059: {0}
+err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2}
+err.invalid.arg.for.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059: {0}
+err.ioerror={0}\u306E\u8AAD\u53D6\u308A\u4E2D\u306BIO\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F: {1}
+err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+err.no.classes.specified=\u30AF\u30E9\u30B9\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+err.not.standard.file.manager=\u6A19\u6E96\u30D5\u30A1\u30A4\u30EB\u30FB\u30DE\u30CD\u30FC\u30B8\u30E3\u3092\u4F7F\u7528\u3057\u3066\u3044\u308B\u5834\u5408\u306F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u307F\u6307\u5B9A\u3067\u304D\u307E\u3059
+err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}
+err.verify.not.supported=-verify\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+err.no.SourceFile.attribute=SourceFile\u5C5E\u6027\u304C\u3042\u308A\u307E\u305B\u3093
+err.source.file.not.found=\u30BD\u30FC\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
+err.bad.innerclasses.attribute={0}\u306EInnerClasses\u5C5E\u6027\u304C\u4E0D\u6B63\u3067\u3059
+warn.Xold.not.supported=-Xold\u306F\u4F7F\u7528\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3057\u305F
+
+main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-help\u3092\u4F7F\u7528\u3057\u307E\u3059
+
+warn.prefix=\u8B66\u544A:
+warn.unexpected.class=\u30D0\u30A4\u30CA\u30EA\u30FB\u30D5\u30A1\u30A4\u30EB{0}\u306B{1}\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059
+
+note.prefix=\u6CE8:
+
+main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-help\u3092\u4F7F\u7528\u3057\u307E\u3059
+
+main.usage=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306B\u306F\u6B21\u306E\u3082\u306E\u304C\u3042\u308A\u307E\u3059:
+
+
+main.opt.help=\  -help  --help  -?        \u3053\u306E\u4F7F\u7528\u65B9\u6CD5\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.version=\  -version                 \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831
+
+main.opt.v=\  -v  -verbose             \u8FFD\u52A0\u60C5\u5831\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.l=\  -l                       \u884C\u756A\u53F7\u3068\u30ED\u30FC\u30AB\u30EB\u5909\u6570\u8868\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.public=\  -public                  public\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u8868\u793A\u3059\u308B
+
+main.opt.protected=\  -protected               protected/public\u30AF\u30E9\u30B9\u304A\u3088\u3073\u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u8868\u793A\u3059\u308B
+
+main.opt.package=\  -package                 package/protected/public\u30AF\u30E9\u30B9\u304A\u3088\u3073\n                           \u30E1\u30F3\u30D0\u30FC\u306E\u307F\u3092\u8868\u793A\u3059\u308B(\u30C7\u30D5\u30A9\u30EB\u30C8)
+
+main.opt.p=\  -p  -private             \u3059\u3079\u3066\u306E\u30AF\u30E9\u30B9\u3068\u30E1\u30F3\u30D0\u30FC\u3092\u8868\u793A\u3059\u308B
+
+main.opt.c=\  -c                       \u30B3\u30FC\u30C9\u3092\u9006\u30A2\u30BB\u30F3\u30D6\u30EB\u3059\u308B
+
+main.opt.s=\  -s                       \u5185\u90E8\u30BF\u30A4\u30D7\u7F72\u540D\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.classpath=\  -classpath <path>        \u30E6\u30FC\u30B6\u30FC\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B
+
+main.opt.bootclasspath=\  -bootclasspath <path>    \u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u4F4D\u7F6E\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B
+
+main.opt.constants=\  -constants               \u9759\u7684final\u5B9A\u6570\u3092\u8868\u793A\u3059\u308B
+
+
+main.opt.sysinfo=\  -sysinfo                 \u51E6\u7406\u3057\u3066\u3044\u308B\u30AF\u30E9\u30B9\u306E\u30B7\u30B9\u30C6\u30E0\u60C5\u5831(\u30D1\u30B9\u3001\u30B5\u30A4\u30BA\u3001\u65E5\u4ED8\u3001MD5\u30CF\u30C3\u30B7\u30E5)\n                           \u3092\u8868\u793A\u3059\u308B
diff --git a/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties b/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties
new file mode 100644
index 0000000..97e4f5c
--- /dev/null
+++ b/src/share/classes/com/sun/tools/javap/resources/javap_zh_CN.properties
@@ -0,0 +1,63 @@
+
+err.prefix=\u9519\u8BEF: 
+
+err.bad.constant.pool=\u8BFB\u53D6{0}\u7684\u5E38\u91CF\u6C60\u65F6\u51FA\u9519: {1}
+err.class.not.found=\u627E\u4E0D\u5230\u7C7B: {0}
+err.crash=\u51FA\u73B0\u4E25\u91CD\u7684\u5185\u90E8\u9519\u8BEF: {0}\n\u8BF7\u5EFA\u7ACB Bug \u62A5\u544A, \u5E76\u5305\u62EC\u4EE5\u4E0B\u4FE1\u606F:\n{1}
+err.end.of.file=\u8BFB\u53D6{0}\u65F6\u51FA\u73B0\u610F\u5916\u7684\u6587\u4EF6\u7ED3\u5C3E
+err.file.not.found=\u627E\u4E0D\u5230\u6587\u4EF6: {0}
+err.h.not.supported=-h \u4E0D\u518D\u53EF\u7528 - \u8BF7\u4F7F\u7528 'javah' \u7A0B\u5E8F
+err.incompatible.options=\u9009\u9879\u7EC4\u5408\u9519\u8BEF: {0}
+err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2}
+err.invalid.arg.for.option=\u9009\u9879\u7684\u53C2\u6570\u65E0\u6548: {0}
+err.ioerror=\u8BFB\u53D6{0}\u65F6\u51FA\u73B0 IO \u9519\u8BEF: {1}
+err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C
+err.no.classes.specified=\u672A\u6307\u5B9A\u7C7B
+err.not.standard.file.manager=\u4F7F\u7528\u6807\u51C6\u6587\u4EF6\u7BA1\u7406\u5668\u65F6\u53EA\u80FD\u6307\u5B9A\u7C7B\u6587\u4EF6
+err.unknown.option=\u672A\u77E5\u9009\u9879: {0}
+err.verify.not.supported=\u4E0D\u652F\u6301 -verify
+err.no.SourceFile.attribute=\u6CA1\u6709 SourceFile \u5C5E\u6027
+err.source.file.not.found=\u627E\u4E0D\u5230\u6E90\u6587\u4EF6
+err.bad.innerclasses.attribute={0}\u7684 InnerClasses \u5C5E\u6027\u9519\u8BEF
+warn.Xold.not.supported=-Xold \u4E0D\u518D\u53EF\u7528
+
+main.usage.summary=\u7528\u6CD5: {0} <options> <classes>\n\u4F7F\u7528 -help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879
+
+warn.prefix=\u8B66\u544A:
+warn.unexpected.class=\u4E8C\u8FDB\u5236\u6587\u4EF6{0}\u5305\u542B{1}
+
+note.prefix=\u6CE8:
+
+main.usage.summary=\u7528\u6CD5: {0} <options> <classes>\n\u4F7F\u7528 -help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879
+
+main.usage=\u7528\u6CD5: {0} <options> <classes>\n\u5176\u4E2D, \u53EF\u80FD\u7684\u9009\u9879\u5305\u62EC:
+
+
+main.opt.help=\  -help  --help  -?        \u8F93\u51FA\u6B64\u7528\u6CD5\u6D88\u606F
+
+main.opt.version=\  -version                 \u7248\u672C\u4FE1\u606F
+
+main.opt.v=\  -v  -verbose             \u8F93\u51FA\u9644\u52A0\u4FE1\u606F
+
+main.opt.l=\  -l                       \u8F93\u51FA\u884C\u53F7\u548C\u672C\u5730\u53D8\u91CF\u8868
+
+main.opt.public=\  -public                  \u4EC5\u663E\u793A\u516C\u5171\u7C7B\u548C\u6210\u5458
+
+main.opt.protected=\  -protected               \u663E\u793A\u53D7\u4FDD\u62A4\u7684/\u516C\u5171\u7C7B\u548C\u6210\u5458
+
+main.opt.package=\  -package                 \u663E\u793A\u7A0B\u5E8F\u5305/\u53D7\u4FDD\u62A4\u7684/\u516C\u5171\u7C7B\n                           \u548C\u6210\u5458 (\u9ED8\u8BA4)
+
+main.opt.p=\  -p  -private             \u663E\u793A\u6240\u6709\u7C7B\u548C\u6210\u5458
+
+main.opt.c=\  -c                       \u5BF9\u4EE3\u7801\u8FDB\u884C\u53CD\u6C47\u7F16
+
+main.opt.s=\  -s                       \u8F93\u51FA\u5185\u90E8\u7C7B\u578B\u7B7E\u540D
+
+main.opt.classpath=\  -classpath <path>        \u6307\u5B9A\u67E5\u627E\u7528\u6237\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E
+
+main.opt.bootclasspath=\  -bootclasspath <path>    \u8986\u76D6\u5F15\u5BFC\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E
+
+main.opt.constants=\  -constants               \u663E\u793A\u9759\u6001\u6700\u7EC8\u5E38\u91CF
+
+
+main.opt.sysinfo=\  -sysinfo                 \u663E\u793A\u6B63\u5728\u5904\u7406\u7684\u7C7B\u7684\n                           \u7CFB\u7EDF\u4FE1\u606F (\u8DEF\u5F84, \u5927\u5C0F, \u65E5\u671F, MD5 \u6563\u5217)
diff --git a/src/share/classes/com/sun/tools/jdeps/Analyzer.java b/src/share/classes/com/sun/tools/jdeps/Analyzer.java
new file mode 100644
index 0000000..ca086e3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java
@@ -0,0 +1,238 @@
+/*
+ * 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.
+ */
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.Dependency.Location;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Dependency Analyzer.
+ */
+public class Analyzer {
+    /**
+     * Type of the dependency analysis.  Appropriate level of data
+     * will be stored.
+     */
+    public enum Type {
+        SUMMARY,
+        PACKAGE,
+        CLASS,
+        VERBOSE
+    };
+
+    private final Type type;
+    private final List<ArchiveDeps> results = new ArrayList<ArchiveDeps>();
+    private final Map<String, Archive> map = new HashMap<String, Archive>();
+    private final Archive NOT_FOUND
+        = new Archive(JdepsTask.getMessage("artifact.not.found"));
+
+    /**
+     * Constructs an Analyzer instance.
+     *
+     * @param type Type of the dependency analysis
+     */
+    public Analyzer(Type type) {
+        this.type = type;
+    }
+
+    /**
+     * Performs the dependency analysis on the given archives.
+     */
+    public void run(List<Archive> archives) {
+        for (Archive archive : archives) {
+            ArchiveDeps deps;
+            if (type == Type.CLASS || type == Type.VERBOSE) {
+                deps = new ClassVisitor(archive);
+            } else {
+                deps = new PackageVisitor(archive);
+            }
+            archive.visit(deps);
+            results.add(deps);
+        }
+
+        // set the required dependencies
+        for (ArchiveDeps result: results) {
+            for (Set<String> set : result.deps.values()) {
+                for (String target : set) {
+                    Archive source = getArchive(target);
+                    if (result.archive != source) {
+                        if (!result.requiredArchives.contains(source)) {
+                            result.requiredArchives.add(source);
+                        }
+                        // either a profile name or the archive name
+                        String tname = result.getTargetProfile(target);
+                        if (tname.isEmpty()) {
+                            tname = PlatformClassPath.contains(source)
+                                        ? "JDK internal API (" + source.getFileName() + ")"
+                                        : source.toString();
+                        }
+                        if (!result.targetNames.contains(tname)) {
+                            result.targetNames.add(tname);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public interface Visitor {
+        /**
+         * Visits a recorded dependency from origin to target which can be
+         * a fully-qualified classname, a package name, a profile or
+         * archive name depending on the Analyzer's type.
+         */
+        void visit(String origin, String target, String profile);
+        /**
+         * Visits the source archive to its destination archive of
+         * a recorded dependency.
+         */
+        void visit(Archive source, Archive dest);
+    }
+
+    public void visitSummary(Visitor v) {
+        for (ArchiveDeps r : results) {
+            for (Archive a : r.requiredArchives) {
+                v.visit(r.archive, a);
+            }
+            for (String name : r.targetNames) {
+                v.visit(r.archive.getFileName(), name, name);
+            }
+        }
+    }
+
+    public void visit(Visitor v) {
+        for (ArchiveDeps r: results) {
+            for (Archive a : r.requiredArchives) {
+                v.visit(r.archive, a);
+            }
+            for (String origin : r.deps.keySet()) {
+                for (String target : r.deps.get(origin)) {
+                    // filter intra-dependency unless in verbose mode
+                    if (type == Type.VERBOSE || getArchive(origin) != getArchive(target)) {
+                        v.visit(origin, target, r.getTargetProfile(target));
+                    }
+                }
+            }
+        }
+    }
+
+    public Archive getArchive(String name) {
+        return map.containsKey(name) ? map.get(name) : NOT_FOUND;
+    }
+
+    /**
+     * Returns the file name of the archive for non-JRE class or
+     * internal JRE classes.  It returns empty string for SE API.
+     */
+    public String getArchiveName(String target, String profile) {
+        Archive source = getArchive(target);
+        String name = source.getFileName();
+        if (PlatformClassPath.contains(source))
+            return profile.isEmpty() ? "JDK internal API (" + name + ")" : "";
+        return name;
+    }
+
+    private abstract class ArchiveDeps implements Archive.Visitor {
+        final Archive archive;
+        final Set<Archive> requiredArchives;
+        final SortedSet<String> targetNames;
+        final SortedMap<String, SortedSet<String>> deps;
+
+        ArchiveDeps(Archive archive) {
+            this.archive = archive;
+            this.requiredArchives = new HashSet<Archive>();
+            this.targetNames = new TreeSet<String>();
+            this.deps = new TreeMap<String, SortedSet<String>>();
+        }
+
+        void add(String loc) {
+            Archive a = map.get(loc);
+            if (a == null) {
+                map.put(loc, archive);
+            } else if (a != archive) {
+                // duplicated class warning?
+            }
+        }
+
+        void add(String origin, String target) {
+            SortedSet<String> set = deps.get(origin);
+            if (set == null) {
+                set = new TreeSet<String>();
+                deps.put(origin, set);
+            }
+            if (!set.contains(target)) {
+                set.add(target);
+            }
+        }
+
+        public abstract void visit(Location o, Location t);
+        public abstract String getTargetProfile(String target);
+
+    }
+
+    private class ClassVisitor extends ArchiveDeps {
+        ClassVisitor(Archive archive) {
+            super(archive);
+        }
+        public void visit(Location l) {
+            add(l.getClassName());
+        }
+        public void visit(Location o, Location t) {
+            add(o.getClassName(), t.getClassName());
+        }
+        public String getTargetProfile(String target) {
+            int i = target.lastIndexOf('.');
+            return (i > 0) ? Profiles.getProfileName(target.substring(0, i)) : "";
+        }
+    }
+
+    private class PackageVisitor extends ArchiveDeps {
+        PackageVisitor(Archive archive) {
+            super(archive);
+        }
+        public void visit(Location o, Location t) {
+            add(packageOf(o), packageOf(t));
+        }
+        public void visit(Location l) {
+            add(packageOf(l));
+        }
+        private String packageOf(Location loc) {
+            String pkg = loc.getPackageName();
+            return pkg.isEmpty() ? "<unnamed>" : pkg;
+        }
+        public String getTargetProfile(String target) {
+            return Profiles.getProfileName(target);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/Archive.java b/src/share/classes/com/sun/tools/jdeps/Archive.java
new file mode 100644
index 0000000..46cd07e
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/Archive.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.Dependency.Location;
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Represents the source of the class files.
+ */
+public class Archive {
+    private final File file;
+    private final String filename;
+    private final ClassFileReader reader;
+    private final Map<Location, Set<Location>> deps
+        = new HashMap<Location, Set<Location>>();
+
+    public Archive(String name) {
+        this.file = null;
+        this.filename = name;
+        this.reader = null;
+    }
+
+    public Archive(File f, ClassFileReader reader) {
+        this.file = f;
+        this.filename = f.getName();
+        this.reader = reader;
+    }
+
+    public ClassFileReader reader() {
+        return reader;
+    }
+
+    public String getFileName() {
+        return filename;
+    }
+
+    public void addClass(Location origin) {
+        Set<Location> set = deps.get(origin);
+        if (set == null) {
+            set = new HashSet<Location>();
+            deps.put(origin, set);
+        }
+    }
+    public void addClass(Location origin, Location target) {
+        Set<Location> set = deps.get(origin);
+        if (set == null) {
+            set = new HashSet<Location>();
+            deps.put(origin, set);
+        }
+        set.add(target);
+    }
+
+    public void visit(Visitor v) {
+        for (Map.Entry<Location,Set<Location>> e: deps.entrySet()) {
+            v.visit(e.getKey());
+            for (Location target : e.getValue()) {
+                v.visit(e.getKey(), target);
+            }
+        }
+    }
+
+    public String toString() {
+        return file != null ? file.getPath() : filename;
+    }
+
+    interface Visitor {
+        void visit(Location loc);
+        void visit(Location origin, Location target);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
new file mode 100644
index 0000000..8c947e3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Dependencies.ClassFileError;
+import java.io.*;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.*;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * ClassFileReader reads ClassFile(s) of a given path that can be
+ * a .class file, a directory, or a JAR file.
+ */
+public class ClassFileReader {
+    /**
+     * Returns a ClassFileReader instance of a given path.
+     */
+    public static ClassFileReader newInstance(File path) throws IOException {
+        if (!path.exists()) {
+            throw new FileNotFoundException(path.getAbsolutePath());
+        }
+
+        if (path.isDirectory()) {
+            return new DirectoryReader(path.toPath());
+        } else if (path.getName().endsWith(".jar")) {
+            return new JarFileReader(path.toPath());
+        } else {
+            return new ClassFileReader(path.toPath());
+        }
+    }
+
+    /**
+     * Returns a ClassFileReader instance of a given JarFile.
+     */
+    public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
+        return new JarFileReader(path, jf);
+    }
+
+    protected final Path path;
+    protected final String baseFileName;
+    private ClassFileReader(Path path) {
+        this.path = path;
+        this.baseFileName = path.getFileName() != null
+                                ? path.getFileName().toString()
+                                : path.toString();
+    }
+
+    public String getFileName() {
+        return baseFileName;
+    }
+
+    /**
+     * Returns the ClassFile matching the given binary name
+     * or a fully-qualified class name.
+     */
+    public ClassFile getClassFile(String name) throws IOException {
+        if (name.indexOf('.') > 0) {
+            int i = name.lastIndexOf('.');
+            String pathname = name.replace('.', File.separatorChar) + ".class";
+            if (baseFileName.equals(pathname) ||
+                    baseFileName.equals(pathname.substring(0, i) + "$" +
+                                        pathname.substring(i+1, pathname.length()))) {
+                return readClassFile(path);
+            }
+        } else {
+            if (baseFileName.equals(name.replace('/', File.separatorChar) + ".class")) {
+                return readClassFile(path);
+            }
+        }
+        return null;
+    }
+
+    public Iterable<ClassFile> getClassFiles() throws IOException {
+        return new Iterable<ClassFile>() {
+            public Iterator<ClassFile> iterator() {
+                return new FileIterator();
+            }
+        };
+    }
+
+    protected ClassFile readClassFile(Path p) throws IOException {
+        InputStream is = null;
+        try {
+            is = Files.newInputStream(p);
+            return ClassFile.read(is);
+        } catch (ConstantPoolException e) {
+            throw new ClassFileError(e);
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+        }
+    }
+
+    class FileIterator implements Iterator<ClassFile> {
+        int count;
+        FileIterator() {
+            this.count = 0;
+        }
+        public boolean hasNext() {
+            return count == 0 && baseFileName.endsWith(".class");
+        }
+
+        public ClassFile next() {
+            if (!hasNext()) {
+                throw new NoSuchElementException();
+            }
+            try {
+                ClassFile cf = readClassFile(path);
+                count++;
+                return cf;
+            } catch (IOException e) {
+                throw new ClassFileError(e);
+            }
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+    public String toString() {
+        return path.toString();
+    }
+
+    private static class DirectoryReader extends ClassFileReader {
+        DirectoryReader(Path path) throws IOException {
+            super(path);
+        }
+
+        public ClassFile getClassFile(String name) throws IOException {
+            if (name.indexOf('.') > 0) {
+                int i = name.lastIndexOf('.');
+                String pathname = name.replace('.', File.separatorChar) + ".class";
+                Path p = path.resolve(pathname);
+                if (!p.toFile().exists()) {
+                    p = path.resolve(pathname.substring(0, i) + "$" +
+                                     pathname.substring(i+1, pathname.length()));
+                }
+                if (p.toFile().exists()) {
+                    return readClassFile(p);
+                }
+            } else {
+                Path p = path.resolve(name + ".class");
+                if (p.toFile().exists()) {
+                    return readClassFile(p);
+                }
+            }
+            return null;
+        }
+
+        public Iterable<ClassFile> getClassFiles() throws IOException {
+            final Iterator<ClassFile> iter = new DirectoryIterator();
+            return new Iterable<ClassFile>() {
+                public Iterator<ClassFile> iterator() {
+                    return iter;
+                }
+            };
+        }
+
+        private List<Path> walkTree(Path dir) throws IOException {
+            final List<Path> files = new ArrayList<Path>();
+            Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+                        throws IOException {
+                    if (file.toFile().getName().endsWith(".class")) {
+                        files.add(file);
+                    }
+                    return FileVisitResult.CONTINUE;
+                }
+            });
+            return files;
+        }
+
+        class DirectoryIterator implements Iterator<ClassFile> {
+            private List<Path> entries;
+            private int index = 0;
+            DirectoryIterator() throws IOException {
+                entries = walkTree(path);
+                index = 0;
+            }
+
+            public boolean hasNext() {
+                return index != entries.size();
+            }
+
+            public ClassFile next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
+                Path path = entries.get(index++);
+                try {
+                    return readClassFile(path);
+                } catch (IOException e) {
+                    throw new ClassFileError(e);
+                }
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+        }
+    }
+
+    private static class JarFileReader extends ClassFileReader {
+        final JarFile jarfile;
+        JarFileReader(Path path) throws IOException {
+            this(path, new JarFile(path.toFile()));
+        }
+        JarFileReader(Path path, JarFile jf) throws IOException {
+            super(path);
+            this.jarfile = jf;
+        }
+
+        public ClassFile getClassFile(String name) throws IOException {
+            if (name.indexOf('.') > 0) {
+                int i = name.lastIndexOf('.');
+                String entryName = name.replace('.', '/') + ".class";
+                JarEntry e = jarfile.getJarEntry(entryName);
+                if (e == null) {
+                    e = jarfile.getJarEntry(entryName.substring(0, i) + "$"
+                            + entryName.substring(i + 1, entryName.length()));
+                }
+                if (e != null) {
+                    return readClassFile(e);
+                }
+            } else {
+                JarEntry e = jarfile.getJarEntry(name + ".class");
+                if (e != null) {
+                    return readClassFile(e);
+                }
+            }
+            return null;
+        }
+
+        private ClassFile readClassFile(JarEntry e) throws IOException {
+            InputStream is = null;
+            try {
+                is = jarfile.getInputStream(e);
+                return ClassFile.read(is);
+            } catch (ConstantPoolException ex) {
+                throw new ClassFileError(ex);
+            } finally {
+                if (is != null)
+                    is.close();
+            }
+        }
+
+        public Iterable<ClassFile> getClassFiles() throws IOException {
+            final Iterator<ClassFile> iter = new JarFileIterator();
+            return new Iterable<ClassFile>() {
+                public Iterator<ClassFile> iterator() {
+                    return iter;
+                }
+            };
+        }
+
+        class JarFileIterator implements Iterator<ClassFile> {
+            private Enumeration<JarEntry> entries;
+            private JarEntry nextEntry;
+            JarFileIterator() {
+                this.entries = jarfile.entries();
+                while (entries.hasMoreElements()) {
+                    JarEntry e = entries.nextElement();
+                    String name = e.getName();
+                    if (name.endsWith(".class")) {
+                        this.nextEntry = e;
+                        break;
+                    }
+                }
+            }
+
+            public boolean hasNext() {
+                return nextEntry != null;
+            }
+
+            public ClassFile next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
+
+                ClassFile cf;
+                try {
+                    cf = readClassFile(nextEntry);
+                } catch (IOException ex) {
+                    throw new ClassFileError(ex);
+                }
+                JarEntry entry = nextEntry;
+                nextEntry = null;
+                while (entries.hasMoreElements()) {
+                    JarEntry e = entries.nextElement();
+                    String name = e.getName();
+                    if (name.endsWith(".class")) {
+                        nextEntry = e;
+                        break;
+                    }
+                }
+                return cf;
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
new file mode 100644
index 0000000..c606d96
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -0,0 +1,575 @@
+/*
+ * 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.  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.jdeps;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Dependencies;
+import com.sun.tools.classfile.Dependencies.ClassFileError;
+import com.sun.tools.classfile.Dependency;
+import java.io.*;
+import java.text.MessageFormat;
+import java.util.*;
+import java.util.regex.Pattern;
+
+/**
+ * Implementation for the jdeps tool for static class dependency analysis.
+ */
+class JdepsTask {
+    static class BadArgs extends Exception {
+        static final long serialVersionUID = 8765093759964640721L;
+        BadArgs(String key, Object... args) {
+            super(JdepsTask.getMessage(key, args));
+            this.key = key;
+            this.args = args;
+        }
+
+        BadArgs showUsage(boolean b) {
+            showUsage = b;
+            return this;
+        }
+        final String key;
+        final Object[] args;
+        boolean showUsage;
+    }
+
+    static abstract class Option {
+        Option(boolean hasArg, String... aliases) {
+            this.hasArg = hasArg;
+            this.aliases = aliases;
+        }
+
+        boolean isHidden() {
+            return false;
+        }
+
+        boolean matches(String opt) {
+            for (String a : aliases) {
+                if (a.equals(opt)) {
+                    return true;
+                } else if (opt.startsWith("--") && hasArg && opt.startsWith(a + "=")) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        boolean ignoreRest() {
+            return false;
+        }
+
+        abstract void process(JdepsTask task, String opt, String arg) throws BadArgs;
+        final boolean hasArg;
+        final String[] aliases;
+    }
+
+    static abstract class HiddenOption extends Option {
+        HiddenOption(boolean hasArg, String... aliases) {
+            super(hasArg, aliases);
+        }
+
+        boolean isHidden() {
+            return true;
+        }
+    }
+
+    static Option[] recognizedOptions = {
+        new Option(false, "-h", "-?", "--help") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.help = true;
+            }
+        },
+        new Option(false, "-s", "--summary") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.showSummary = true;
+                task.options.verbose = Analyzer.Type.SUMMARY;
+            }
+        },
+        new Option(false, "-v", "--verbose") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.verbose = Analyzer.Type.VERBOSE;
+            }
+        },
+        new Option(true, "-V", "--verbose-level") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if ("package".equals(arg)) {
+                    task.options.verbose = Analyzer.Type.PACKAGE;
+                } else if ("class".equals(arg)) {
+                    task.options.verbose = Analyzer.Type.CLASS;
+                } else {
+                    throw new BadArgs("err.invalid.arg.for.option", opt);
+                }
+            }
+        },
+        new Option(true, "-c", "--classpath") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.classpath = arg;
+            }
+        },
+        new Option(true, "-p", "--package") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.packageNames.add(arg);
+            }
+        },
+        new Option(true, "-e", "--regex") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.regex = arg;
+            }
+        },
+        new Option(false, "-P", "--profile") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                task.options.showProfile = true;
+                if (Profiles.getProfileCount() == 0) {
+                    throw new BadArgs("err.option.unsupported", opt, getMessage("err.profiles.msg"));
+                }
+            }
+        },
+        new Option(false, "-R", "--recursive") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.depth = 0;
+            }
+        },
+        new HiddenOption(true, "-d", "--depth") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                try {
+                    task.options.depth = Integer.parseInt(arg);
+                } catch (NumberFormatException e) {
+                    throw new BadArgs("err.invalid.arg.for.option", opt);
+                }
+            }
+        },
+        new Option(false, "--version") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.version = true;
+            }
+        },
+        new HiddenOption(false, "--fullversion") {
+            void process(JdepsTask task, String opt, String arg) {
+                task.options.fullVersion = true;
+            }
+        },
+    };
+
+    private static final String PROGNAME = "jdeps";
+    private final Options options = new Options();
+    private final List<String> classes = new ArrayList<String>();
+
+    private PrintWriter log;
+    void setLog(PrintWriter out) {
+        log = out;
+    }
+
+    /**
+     * Result codes.
+     */
+    static final int EXIT_OK = 0, // Completed with no errors.
+                     EXIT_ERROR = 1, // Completed but reported errors.
+                     EXIT_CMDERR = 2, // Bad command-line arguments
+                     EXIT_SYSERR = 3, // System error or resource exhaustion.
+                     EXIT_ABNORMAL = 4;// terminated abnormally
+
+    int run(String[] args) {
+        if (log == null) {
+            log = new PrintWriter(System.out);
+        }
+        try {
+            handleOptions(args);
+            if (options.help) {
+                showHelp();
+            }
+            if (options.version || options.fullVersion) {
+                showVersion(options.fullVersion);
+            }
+            if (classes.isEmpty() && !options.wildcard) {
+                if (options.help || options.version || options.fullVersion) {
+                    return EXIT_OK;
+                } else {
+                    showHelp();
+                    return EXIT_CMDERR;
+                }
+            }
+            if (options.regex != null && options.packageNames.size() > 0) {
+                showHelp();
+                return EXIT_CMDERR;
+            }
+            if (options.showSummary && options.verbose != Analyzer.Type.SUMMARY) {
+                showHelp();
+                return EXIT_CMDERR;
+            }
+            boolean ok = run();
+            return ok ? EXIT_OK : EXIT_ERROR;
+        } catch (BadArgs e) {
+            reportError(e.key, e.args);
+            if (e.showUsage) {
+                log.println(getMessage("main.usage.summary", PROGNAME));
+            }
+            return EXIT_CMDERR;
+        } catch (IOException e) {
+            return EXIT_ABNORMAL;
+        } finally {
+            log.flush();
+        }
+    }
+
+    private final List<Archive> sourceLocations = new ArrayList<Archive>();
+    private boolean run() throws IOException {
+        findDependencies();
+        Analyzer analyzer = new Analyzer(options.verbose);
+        analyzer.run(sourceLocations);
+        if (options.verbose == Analyzer.Type.SUMMARY) {
+            printSummary(log, analyzer);
+        } else {
+            printDependencies(log, analyzer);
+        }
+        return true;
+    }
+
+    private boolean isValidClassName(String name) {
+        if (!Character.isJavaIdentifierStart(name.charAt(0))) {
+            return false;
+        }
+        for (int i=1; i < name.length(); i++) {
+            char c = name.charAt(i);
+            if (c != '.'  && !Character.isJavaIdentifierPart(c)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void findDependencies() throws IOException {
+        Dependency.Finder finder = Dependencies.getClassDependencyFinder();
+        Dependency.Filter filter;
+        if (options.regex != null) {
+            filter = Dependencies.getRegexFilter(Pattern.compile(options.regex));
+        } else if (options.packageNames.size() > 0) {
+            filter = Dependencies.getPackageFilter(options.packageNames, false);
+        } else {
+            filter = new Dependency.Filter() {
+                public boolean accepts(Dependency dependency) {
+                    return !dependency.getOrigin().equals(dependency.getTarget());
+                }
+            };
+        }
+
+        List<Archive> archives = new ArrayList<Archive>();
+        Deque<String> roots = new LinkedList<String>();
+        for (String s : classes) {
+            File f = new File(s);
+            if (f.exists()) {
+                archives.add(new Archive(f, ClassFileReader.newInstance(f)));
+            } else {
+                if (isValidClassName(s)) {
+                    roots.add(s);
+                } else {
+                    warning("warn.invalid.arg", s);
+                }
+            }
+        }
+
+        List<Archive> classpaths = new ArrayList<Archive>(); // for class file lookup
+        if (options.wildcard) {
+            // include all archives from classpath to the initial list
+            archives.addAll(getClassPathArchives(options.classpath));
+        } else {
+            classpaths.addAll(getClassPathArchives(options.classpath));
+        }
+        classpaths.addAll(PlatformClassPath.getArchives());
+
+        // add all archives to the source locations for reporting
+        sourceLocations.addAll(archives);
+        sourceLocations.addAll(classpaths);
+
+        // Work queue of names of classfiles to be searched.
+        // Entries will be unique, and for classes that do not yet have
+        // dependencies in the results map.
+        Deque<String> deque = new LinkedList<String>();
+        Set<String> doneClasses = new HashSet<String>();
+
+        // get the immediate dependencies of the input files
+        for (Archive a : archives) {
+            for (ClassFile cf : a.reader().getClassFiles()) {
+                String classFileName;
+                try {
+                    classFileName = cf.getName();
+                } catch (ConstantPoolException e) {
+                    throw new ClassFileError(e);
+                }
+
+                if (!doneClasses.contains(classFileName)) {
+                    doneClasses.add(classFileName);
+                }
+                for (Dependency d : finder.findDependencies(cf)) {
+                    if (filter.accepts(d)) {
+                        String cn = d.getTarget().getName();
+                        if (!doneClasses.contains(cn) && !deque.contains(cn)) {
+                            deque.add(cn);
+                        }
+                        a.addClass(d.getOrigin(), d.getTarget());
+                    }
+                }
+            }
+        }
+
+        // add Archive for looking up classes from the classpath
+        // for transitive dependency analysis
+        Deque<String> unresolved = roots;
+        int depth = options.depth > 0 ? options.depth : Integer.MAX_VALUE;
+        do {
+            String name;
+            while ((name = unresolved.poll()) != null) {
+                if (doneClasses.contains(name)) {
+                    continue;
+                }
+                ClassFile cf = null;
+                for (Archive a : classpaths) {
+                    cf = a.reader().getClassFile(name);
+                    if (cf != null) {
+                        String classFileName;
+                        try {
+                            classFileName = cf.getName();
+                        } catch (ConstantPoolException e) {
+                            throw new ClassFileError(e);
+                        }
+                        if (!doneClasses.contains(classFileName)) {
+                            // if name is a fully-qualified class name specified
+                            // from command-line, this class might already be parsed
+                            doneClasses.add(classFileName);
+                            for (Dependency d : finder.findDependencies(cf)) {
+                                if (depth == 0) {
+                                    // ignore the dependency
+                                    a.addClass(d.getOrigin());
+                                    break;
+                                } else if (filter.accepts(d)) {
+                                    a.addClass(d.getOrigin(), d.getTarget());
+                                    String cn = d.getTarget().getName();
+                                    if (!doneClasses.contains(cn) && !deque.contains(cn)) {
+                                        deque.add(cn);
+                                    }
+                                }
+                            }
+                        }
+                        break;
+                    }
+                }
+                if (cf == null) {
+                    doneClasses.add(name);
+                }
+            }
+            unresolved = deque;
+            deque = new LinkedList<String>();
+        } while (!unresolved.isEmpty() && depth-- > 0);
+    }
+
+    private void printSummary(final PrintWriter out, final Analyzer analyzer) {
+        Analyzer.Visitor visitor = new Analyzer.Visitor() {
+            public void visit(String origin, String target, String profile) {
+                if (options.showProfile) {
+                    out.format("%-30s -> %s%n", origin, target);
+                }
+            }
+            public void visit(Archive origin, Archive target) {
+                if (!options.showProfile) {
+                    out.format("%-30s -> %s%n", origin, target);
+                }
+            }
+        };
+        analyzer.visitSummary(visitor);
+    }
+
+    private void printDependencies(final PrintWriter out, final Analyzer analyzer) {
+        Analyzer.Visitor visitor = new Analyzer.Visitor() {
+            private String pkg = "";
+            public void visit(String origin, String target, String profile) {
+                if (!origin.equals(pkg)) {
+                    pkg = origin;
+                    out.format("   %s (%s)%n", origin, analyzer.getArchive(origin).getFileName());
+                }
+                out.format("      -> %-50s %s%n", target,
+                           (options.showProfile && !profile.isEmpty())
+                               ? profile
+                               : analyzer.getArchiveName(target, profile));
+            }
+            public void visit(Archive origin, Archive target) {
+                out.format("%s -> %s%n", origin, target);
+            }
+        };
+        analyzer.visit(visitor);
+    }
+
+    public void handleOptions(String[] args) throws BadArgs {
+        // process options
+        for (int i=0; i < args.length; i++) {
+            if (args[i].charAt(0) == '-') {
+                String name = args[i];
+                Option option = getOption(name);
+                String param = null;
+                if (option.hasArg) {
+                    if (name.startsWith("--") && name.indexOf('=') > 0) {
+                        param = name.substring(name.indexOf('=') + 1, name.length());
+                    } else if (i + 1 < args.length) {
+                        param = args[++i];
+                    }
+                    if (param == null || param.isEmpty() || param.charAt(0) == '-') {
+                        throw new BadArgs("err.missing.arg", name).showUsage(true);
+                    }
+                }
+                option.process(this, name, param);
+                if (option.ignoreRest()) {
+                    i = args.length;
+                }
+            } else {
+                // process rest of the input arguments
+                for (; i < args.length; i++) {
+                    String name = args[i];
+                    if (name.charAt(0) == '-') {
+                        throw new BadArgs("err.option.after.class", name).showUsage(true);
+                    }
+                    if (name.equals("*") || name.equals("\"*\"")) {
+                        options.wildcard = true;
+                    } else {
+                        classes.add(name);
+                    }
+                }
+            }
+        }
+    }
+
+    private Option getOption(String name) throws BadArgs {
+        for (Option o : recognizedOptions) {
+            if (o.matches(name)) {
+                return o;
+            }
+        }
+        throw new BadArgs("err.unknown.option", name).showUsage(true);
+    }
+
+    private void reportError(String key, Object... args) {
+        log.println(getMessage("error.prefix") + " " + getMessage(key, args));
+    }
+
+    private void warning(String key, Object... args) {
+        log.println(getMessage("warn.prefix") + " " + getMessage(key, args));
+    }
+
+    private void showHelp() {
+        log.println(getMessage("main.usage", PROGNAME));
+        for (Option o : recognizedOptions) {
+            String name = o.aliases[0].substring(1); // there must always be at least one name
+            name = name.charAt(0) == '-' ? name.substring(1) : name;
+            if (o.isHidden() || name.equals("h")) {
+                continue;
+            }
+            log.println(getMessage("main.opt." + name));
+        }
+    }
+
+    private void showVersion(boolean full) {
+        log.println(version(full ? "full" : "release"));
+    }
+
+    private String version(String key) {
+        // key=version:  mm.nn.oo[-milestone]
+        // key=full:     mm.mm.oo[-milestone]-build
+        if (ResourceBundleHelper.versionRB == null) {
+            return System.getProperty("java.version");
+        }
+        try {
+            return ResourceBundleHelper.versionRB.getString(key);
+        } catch (MissingResourceException e) {
+            return getMessage("version.unknown", System.getProperty("java.version"));
+        }
+    }
+
+    static String getMessage(String key, Object... args) {
+        try {
+            return MessageFormat.format(ResourceBundleHelper.bundle.getString(key), args);
+        } catch (MissingResourceException e) {
+            throw new InternalError("Missing message: " + key);
+        }
+    }
+
+    private static class Options {
+        boolean help;
+        boolean version;
+        boolean fullVersion;
+        boolean showProfile;
+        boolean showSummary;
+        boolean wildcard;
+        String regex;
+        String classpath = "";
+        int depth = 1;
+        Analyzer.Type verbose = Analyzer.Type.PACKAGE;
+        Set<String> packageNames = new HashSet<String>();
+    }
+
+    private static class ResourceBundleHelper {
+        static final ResourceBundle versionRB;
+        static final ResourceBundle bundle;
+
+        static {
+            Locale locale = Locale.getDefault();
+            try {
+                bundle = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.jdeps", locale);
+            } catch (MissingResourceException e) {
+                throw new InternalError("Cannot find jdeps resource bundle for locale " + locale);
+            }
+            try {
+                versionRB = ResourceBundle.getBundle("com.sun.tools.jdeps.resources.version");
+            } catch (MissingResourceException e) {
+                throw new InternalError("version.resource.missing");
+            }
+        }
+    }
+
+    private List<Archive> getArchives(List<String> filenames) throws IOException {
+        List<Archive> result = new ArrayList<Archive>();
+        for (String s : filenames) {
+            File f = new File(s);
+            if (f.exists()) {
+                result.add(new Archive(f, ClassFileReader.newInstance(f)));
+            } else {
+                warning("warn.file.not.exist", s);
+            }
+        }
+        return result;
+    }
+
+    private List<Archive> getClassPathArchives(String paths) throws IOException {
+        List<Archive> result = new ArrayList<Archive>();
+        if (paths.isEmpty()) {
+            return result;
+        }
+        for (String p : paths.split(File.pathSeparator)) {
+            if (p.length() > 0) {
+                File f = new File(p);
+                if (f.exists()) {
+                    result.add(new Archive(f, ClassFileReader.newInstance(f)));
+                }
+            }
+        }
+        return result;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/Main.java b/src/share/classes/com/sun/tools/jdeps/Main.java
new file mode 100644
index 0000000..863815f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/Main.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.jdeps;
+
+import java.io.*;
+
+/**
+ *
+ * Usage:
+ *    jdeps [options] files ...
+ * where options include:
+ *    -p package-name   restrict analysis to classes in this package
+ *                      (may be given multiple times)
+ *    -e regex          restrict analysis to packages matching pattern
+ *                      (-p and -e are exclusive)
+ *    -v                show class-level dependencies
+ *                      default: package-level dependencies
+ *    -r --recursive    transitive dependencies analysis
+ *    -classpath paths  Classpath to locate class files
+ *    -all              process all class files in the given classpath
+ */
+public class Main {
+    public static void main(String... args) throws Exception {
+        JdepsTask t = new JdepsTask();
+        int rc = t.run(args);
+        System.exit(rc);
+    }
+
+
+    /**
+     * Entry point that does <i>not</i> call System.exit.
+     *
+     * @param args command line arguments
+     * @param out output stream
+     * @return an exit code. 0 means success, non-zero means an error occurred.
+     */
+    public static int run(String[] args, PrintWriter out) {
+        JdepsTask t = new JdepsTask();
+        t.setLog(out);
+        return t.run(args);
+    }
+}
+
diff --git a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
new file mode 100644
index 0000000..14e2583
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
@@ -0,0 +1,107 @@
+/*
+ * 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.  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.jdeps;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.*;
+
+/**
+ * ClassPath for Java SE and JDK
+ */
+class PlatformClassPath {
+    private final static List<Archive> javaHomeArchives = init();
+    static List<Archive> getArchives() {
+        return javaHomeArchives;
+    }
+
+    static boolean contains(Archive archive) {
+        return javaHomeArchives.contains(archive);
+    }
+
+    private static List<Archive> init() {
+        List<Archive> result = new ArrayList<Archive>();
+        String javaHome = System.getProperty("java.home");
+        File jre = new File(javaHome, "jre");
+        File lib = new File(javaHome, "lib");
+
+        try {
+            if (jre.exists() && jre.isDirectory()) {
+                result.addAll(addJarFiles(new File(jre, "lib")));
+                result.addAll(addJarFiles(lib));
+            } else if (lib.exists() && lib.isDirectory()) {
+                // either a JRE or a jdk build image
+                File classes = new File(javaHome, "classes");
+                if (classes.exists() && classes.isDirectory()) {
+                    // jdk build outputdir
+                    result.add(new Archive(classes, ClassFileReader.newInstance(classes)));
+                }
+                // add other JAR files
+                result.addAll(addJarFiles(lib));
+            } else {
+                throw new RuntimeException("\"" + javaHome + "\" not a JDK home");
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return result;
+    }
+
+    private static List<Archive> addJarFiles(File f) throws IOException {
+        final List<Archive> result = new ArrayList<Archive>();
+        final Path root = f.toPath();
+        final Path ext = root.resolve("ext");
+        Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
+            @Override
+            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+                throws IOException
+            {
+                if (dir.equals(root) || dir.equals(ext)) {
+                    return FileVisitResult.CONTINUE;
+                } else {
+                    // skip other cobundled JAR files
+                    return FileVisitResult.SKIP_SUBTREE;
+                }
+            }
+            @Override
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+                throws IOException
+            {
+                File f = file.toFile();
+                String fn = f.getName();
+                if (fn.endsWith(".jar") && !fn.equals("alt-rt.jar")) {
+                    result.add(new Archive(f, ClassFileReader.newInstance(f)));
+                }
+                return FileVisitResult.CONTINUE;
+            }
+        });
+        return result;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/Profiles.java b/src/share/classes/com/sun/tools/jdeps/Profiles.java
new file mode 100644
index 0000000..0c7b4cc
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/Profiles.java
@@ -0,0 +1,241 @@
+/*
+ * 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.
+ */
+package com.sun.tools.jdeps;
+
+import com.sun.tools.classfile.Annotation;
+import com.sun.tools.classfile.Annotation.*;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.RuntimeAnnotations_attribute;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.jar.JarFile;
+
+/**
+ * Build the profile information from ct.sym if exists.
+ */
+class Profiles {
+    private static final Map<String,Profile> map = initProfiles();
+    /**
+     * Returns the name of the profile for the given package name.
+     * It returns an empty string if the given package is not in any profile.
+     */
+    public static String getProfileName(String pn) {
+        Profile profile = map.get(pn);
+        return (profile != null && profile.packages.contains(pn))
+                    ? profile.name : "";
+    }
+
+    public static int getProfileCount() {
+        return new HashSet<Profile>(map.values()).size();
+    }
+
+    private static Map<String,Profile> initProfiles() {
+        List<Profile> profiles = new ArrayList<Profile>();
+        try {
+            String profilesProps = System.getProperty("jdeps.profiles");
+            if (profilesProps != null) {
+                // for testing for JDK development build where ct.sym doesn't exist
+                initProfilesFromProperties(profiles, profilesProps);
+            } else {
+                Path home = Paths.get(System.getProperty("java.home"));
+                if (home.endsWith("jre")) {
+                    home = home.getParent();
+                }
+                Path ctsym = home.resolve("lib").resolve("ct.sym");
+                if (ctsym.toFile().exists()) {
+                    // add a default Full JRE
+                    profiles.add(0, new Profile("Full JRE", 0));
+                    // parse ct.sym and load information about profiles
+                    try (JarFile jf = new JarFile(ctsym.toFile())) {
+                        ClassFileReader reader = ClassFileReader.newInstance(ctsym, jf);
+                        for (ClassFile cf : reader.getClassFiles()) {
+                            findProfile(profiles, cf);
+                        }
+                    }
+
+                    // merge the last Profile with the "Full JRE"
+                    if (profiles.size() > 1) {
+                        Profile fullJRE = profiles.get(0);
+                        Profile p = profiles.remove(profiles.size() - 1);
+                        for (String pn : fullJRE.packages) {
+                            // The last profile contains the packages determined from ct.sym.
+                            // Move classes annotated profile==0 or no attribute that are
+                            // added in the fullJRE profile to either supported or proprietary
+                            // packages appropriately
+                            if (p.proprietaryPkgs.contains(pn)) {
+                                p.proprietaryPkgs.add(pn);
+                            } else {
+                                p.packages.add(pn);
+                            }
+                        }
+                        fullJRE.packages.clear();
+                        fullJRE.proprietaryPkgs.clear();
+                        fullJRE.packages.addAll(p.packages);
+                        fullJRE.proprietaryPkgs.addAll(p.proprietaryPkgs);
+                    }
+                }
+            }
+        } catch (IOException | ConstantPoolException e) {
+            throw new Error(e);
+        }
+        HashMap<String,Profile> map = new HashMap<String,Profile>();
+        for (Profile profile : profiles) {
+            // Inner classes are not annotated with the profile annotation
+            // packages may be in one profile but also appear in the Full JRE
+            // Full JRE is always the first element in profiles list and
+            // so the map will contain the appropriate Profile
+            for (String pn : profile.packages) {
+                map.put(pn, profile);
+            }
+            for (String pn : profile.proprietaryPkgs) {
+                map.put(pn, profile);
+            }
+        }
+        return map;
+    }
+
+    private static final String PROFILE_ANNOTATION = "Ljdk/Profile+Annotation;";
+    private static final String PROPRIETARY_ANNOTATION = "Lsun/Proprietary+Annotation;";
+    private static Profile findProfile(List<Profile> profiles, ClassFile cf)
+            throws ConstantPoolException
+    {
+        RuntimeAnnotations_attribute attr = (RuntimeAnnotations_attribute)
+            cf.attributes.get(Attribute.RuntimeInvisibleAnnotations);
+        int index = 0;
+        boolean proprietary = false;
+        if (attr != null) {
+            for (int i = 0; i < attr.annotations.length; i++) {
+                Annotation ann = attr.annotations[i];
+                String annType = cf.constant_pool.getUTF8Value(ann.type_index);
+                if (PROFILE_ANNOTATION.equals(annType)) {
+                    for (int j = 0; j < ann.num_element_value_pairs; j++) {
+                        Annotation.element_value_pair pair = ann.element_value_pairs[j];
+                        Primitive_element_value ev = (Primitive_element_value)pair.value;
+                        CONSTANT_Integer_info info = (CONSTANT_Integer_info)
+                             cf.constant_pool.get(ev.const_value_index);
+                        index = info.value;
+                        break;
+                    }
+                } else if (PROPRIETARY_ANNOTATION.equals(annType)) {
+                    proprietary = true;
+                }
+            }
+            if (index >= profiles.size()) {
+                Profile p = null;
+                for (int i = profiles.size(); i <= index; i++) {
+                    p = new Profile(i);
+                    profiles.add(p);
+                }
+            }
+        }
+
+        Profile p = profiles.get(index);
+        String name = cf.getName();
+        int i = name.lastIndexOf('/');
+        name = (i > 0) ? name.substring(0, i).replace('/','.') : "";
+        if (proprietary) {
+            p.proprietaryPkgs.add(name);
+        } else {
+            p.packages.add(name);
+        }
+        return p;
+    }
+
+    private static void initProfilesFromProperties(List<Profile> profiles, String path)
+            throws IOException
+    {
+        Properties props = new Properties();
+        try (FileReader reader = new FileReader(path)) {
+            props.load(reader);
+        }
+        int i=1;
+        String key;
+        while (props.containsKey((key = "profile." + i + ".name"))) {
+            Profile profile = new Profile(props.getProperty(key), i);
+            profiles.add(profile);
+            String n = props.getProperty("profile." + i + ".packages");
+            String[] pkgs = n.split("\\s+");
+            for (String p : pkgs) {
+                if (p.isEmpty()) continue;
+                profile.packages.add(p);
+            }
+            i++;
+        }
+    }
+
+    private static class Profile {
+        final String name;
+        final int profile;
+        final Set<String> packages;
+        final Set<String> proprietaryPkgs;
+        Profile(int profile) {
+            this("compact" + profile, profile);
+        }
+        Profile(String name, int profile) {
+            this.name = name;
+            this.profile = profile;
+            this.packages = new HashSet<String>();
+            this.proprietaryPkgs = new HashSet<String>();
+        }
+        public String toString() {
+            return name;
+        }
+    }
+
+    // for debugging
+    public static void main(String[] args) {
+        if (args.length == 0) {
+            Profile[] profiles = new Profile[getProfileCount()];
+            for (Profile p : map.values()) {
+                // move the zeroth profile to the last
+                int index = p.profile == 0 ? profiles.length-1 : p.profile-1;
+                profiles[index] = p;
+            }
+            for (Profile p : profiles) {
+                String profileName = p.name;
+                SortedSet<String> set = new TreeSet<String>(p.packages);
+                for (String s : set) {
+                    // filter out the inner classes that are not annotated with
+                    // the profile annotation
+                    if (map.get(s) == p) {
+                        System.out.format("%-10s  %s%n", profileName, s);
+                        profileName = "";
+                    }
+                }
+            }
+        }
+        for (String pn : args) {
+            System.out.format("%s in %s%n", pn, getProfileName(pn));
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
new file mode 100644
index 0000000..7a01d8f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties
@@ -0,0 +1,59 @@
+main.usage.summary=\
+Usage: {0} <options> <classes...>\n\
+use -h, -? or --help for a list of possible options
+
+main.usage=\
+Usage: {0} <options> <classes...>\n\
+where <classes> can be a pathname to a .class file, a directory, a JAR file,\n\
+or a fully-qualified classname or wildcard "*".  Possible options include:
+
+error.prefix=Error:
+warn.prefix=Warning:
+
+main.opt.h=\
+\  -h -?      --help                    Print this usage message
+
+main.opt.version=\
+\             --version                 Version information
+
+main.opt.V=\
+\  -V <level> --verbose-level=<level>   Print package-level or class-level dependencies\n\
+\                                       Valid levels are: "package" and "class"
+
+main.opt.v=\
+\  -v         --verbose                 Print additional information
+
+main.opt.s=\
+\  -s         --summary                 Print dependency summary only
+
+main.opt.p=\
+\  -p <pkg name> --package=<pkg name>   Restrict analysis to classes in this package\n\
+\                                       (may be given multiple times)
+
+main.opt.e=\
+\  -e <regex> --regex=<regex>           Restrict analysis to packages matching pattern\n\
+\                                       (-p and -e are exclusive)
+
+main.opt.P=\
+\  -P         --profile                 Show profile or the file containing a package
+
+main.opt.c=\
+\  -c <path>  --classpath=<path>        Specify where to find class files
+
+main.opt.R=\
+\  -R         --recursive               Recursively traverse all dependencies
+
+main.opt.d=\
+\  -d <depth> --depth=<depth>           Specify the depth of the transitive dependency analysis
+
+err.unknown.option=unknown option: {0}
+err.missing.arg=no value given for {0}
+err.internal.error=internal error: {0} {1} {2}
+err.invalid.arg.for.option=invalid argument for option: {0}
+err.option.after.class=option must be specified before classes: {0}
+err.option.unsupported={0} not supported: {1}
+err.profiles.msg=No profile information
+warn.invalid.arg=Invalid classname or pathname not exist: {0}
+warn.split.package=package {0} defined in {1} {2}
+
+artifact.not.found=not found
diff --git a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties
new file mode 100644
index 0000000..8b1fcee
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_ja.properties
@@ -0,0 +1,40 @@
+main.usage.summary=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528\u53EF\u80FD\u306A\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u30EA\u30B9\u30C8\u306B\u3064\u3044\u3066\u306F\u3001-h\u3001-?\u307E\u305F\u306F--help\u3092\u4F7F\u7528\u3057\u307E\u3059
+
+main.usage=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <classes...>\n<classes>\u306B\u306F\u3001.class\u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9\u540D\u3001\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3001JAR\u30D5\u30A1\u30A4\u30EB\u3001\u5B8C\u5168\u4FEE\u98FE\u30AF\u30E9\u30B9\u540D\n\u307E\u305F\u306F\u30EF\u30A4\u30EB\u30C9\u30AB\u30FC\u30C9"*"\u3092\u6307\u5B9A\u3067\u304D\u307E\u3059\u3002\u4F7F\u7528\u3067\u304D\u308B\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059:
+
+error.prefix=\u30A8\u30E9\u30FC:
+warn.prefix=\u8B66\u544A:
+
+main.opt.h=\  -h -?      --help                    \u3053\u306E\u4F7F\u7528\u65B9\u6CD5\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.version=\             --version                 \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831
+
+main.opt.V=\  -V <level> --verbose-level=<level>   \u30D1\u30C3\u30B1\u30FC\u30B8\u30FB\u30EC\u30D9\u30EB\u307E\u305F\u306F\u30AF\u30E9\u30B9\u30FB\u30EC\u30D9\u30EB\u306E\u4F9D\u5B58\u6027\u3092\u51FA\u529B\u3059\u308B\n                                       \u6709\u52B9\u306A\u30EC\u30D9\u30EB: "package"\u304A\u3088\u3073"class"
+
+main.opt.v=\  -v         --verbose                 \u8FFD\u52A0\u60C5\u5831\u3092\u51FA\u529B\u3059\u308B
+
+main.opt.s=\  -s         --summary                 \u4F9D\u5B58\u6027\u306E\u8981\u7D04\u306E\u307F\u51FA\u529B\u3059\u308B
+
+main.opt.p=\  -p <pkg name> --package=<pkg name>   \u5206\u6790\u3092\u3053\u306E\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u30AF\u30E9\u30B9\u306B\u5236\u9650\u3059\u308B\n                                       (\u8907\u6570\u56DE\u6307\u5B9A\u53EF\u80FD)
+
+main.opt.e=\  -e <regex> --regex=<regex>           \u5206\u6790\u3092\u30D1\u30BF\u30FC\u30F3\u306B\u4E00\u81F4\u3059\u308B\u30D1\u30C3\u30B1\u30FC\u30B8\u306B\u5236\u9650\u3059\u308B\n                                       (-p\u3068-e\u306F\u6392\u4ED6\u7684)
+
+main.opt.P=\  -P         --profile                 \u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u542B\u3080\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u307E\u305F\u306F\u30D5\u30A1\u30A4\u30EB\u3092\u8868\u793A\u3059\u308B
+
+main.opt.c=\  -c <path>  --classpath=<path>        \u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u5834\u6240\u3092\u6307\u5B9A\u3059\u308B
+
+main.opt.R=\  -R         --recursive               \u3059\u3079\u3066\u306E\u4F9D\u5B58\u6027\u3092\u53CD\u5FA9\u7684\u306B\u8D70\u67FB\u3059\u308B
+
+main.opt.d=\  -d <depth> --depth=<depth>           \u63A8\u79FB\u7684\u306A\u4F9D\u5B58\u6027\u5206\u6790\u306E\u6DF1\u3055\u3092\u6307\u5B9A\u3059\u308B
+
+err.unknown.option=\u4E0D\u660E\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: {0}
+err.missing.arg={0}\u306B\u5024\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093
+err.internal.error=\u5185\u90E8\u30A8\u30E9\u30FC: {0} {1} {2}
+err.invalid.arg.for.option=\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5F15\u6570\u304C\u7121\u52B9\u3067\u3059: {0}
+err.option.after.class=\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u30AF\u30E9\u30B9\u306E\u524D\u306B\u6307\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059: {0}
+err.option.unsupported={0}\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093: {1}
+err.profiles.msg=\u30D7\u30ED\u30D5\u30A1\u30A4\u30EB\u60C5\u5831\u304C\u3042\u308A\u307E\u305B\u3093
+warn.invalid.arg=\u7121\u52B9\u306A\u30AF\u30E9\u30B9\u540D\u307E\u305F\u306F\u30D1\u30B9\u540D\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0}
+warn.split.package=\u30D1\u30C3\u30B1\u30FC\u30B8{0}\u306F{1} {2}\u3067\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u3059
+
+artifact.not.found=\u898B\u3064\u304B\u308A\u307E\u305B\u3093
diff --git a/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties
new file mode 100644
index 0000000..54e8aee
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/resources/jdeps_zh_CN.properties
@@ -0,0 +1,40 @@
+main.usage.summary=\u7528\u6CD5: {0} <options> <classes...>\n\u4F7F\u7528 -h, -? \u6216 --help \u5217\u51FA\u53EF\u80FD\u7684\u9009\u9879
+
+main.usage=\u7528\u6CD5: {0} <options> <classes...>\n\u5176\u4E2D, <classes> \u53EF\u4EE5\u662F .class \u6587\u4EF6, \u76EE\u5F55, JAR \u6587\u4EF6\u7684\u8DEF\u5F84\u540D,\n\u4E5F\u53EF\u4EE5\u662F\u5168\u9650\u5B9A\u7C7B\u540D\u6216\u901A\u914D\u7B26 "*"\u3002\u53EF\u80FD\u7684\u9009\u9879\u5305\u62EC:
+
+error.prefix=\u9519\u8BEF:
+warn.prefix=\u8B66\u544A:
+
+main.opt.h=\  -h -?      --help                    \u8F93\u51FA\u6B64\u7528\u6CD5\u6D88\u606F
+
+main.opt.version=\             --version                 \u7248\u672C\u4FE1\u606F
+
+main.opt.V=\  -V <level> --verbose-level=<level>   \u8F93\u51FA\u7A0B\u5E8F\u5305\u7EA7\u522B\u6216\u7C7B\u7EA7\u522B\u88AB\u4F9D\u8D56\u5BF9\u8C61\n                                       \u6709\u6548\u7EA7\u522B\u4E3A: "\u7A0B\u5E8F\u5305" \u548C "\u7C7B"
+
+main.opt.v=\  -v         --verbose                 \u8F93\u51FA\u9644\u52A0\u4FE1\u606F
+
+main.opt.s=\  -s         --summary                 \u4EC5\u8F93\u51FA\u88AB\u4F9D\u8D56\u5BF9\u8C61\u6982\u8981
+
+main.opt.p=\  -p <pkg name> --package=<pkg name>   \u5C06\u5206\u6790\u9650\u5236\u4E3A\u6B64\u7A0B\u5E8F\u5305\u4E2D\u7684\u7C7B\n                                       (\u53EF\u4EE5\u6307\u5B9A\u591A\u6B21)
+
+main.opt.e=\  -e <regex> --regex=<regex>           \u5C06\u5206\u6790\u9650\u5236\u4E3A\u4E0E\u6A21\u5F0F\u5339\u914D\u7684\u7A0B\u5E8F\u5305\n                                       (-p \u548C -e \u4E92\u65A5)
+
+main.opt.P=\  -P         --profile                 \u663E\u793A\u914D\u7F6E\u6587\u4EF6\u6216\u5305\u542B\u7A0B\u5E8F\u5305\u7684\u6587\u4EF6
+
+main.opt.c=\  -c <path>  --classpath=<path>        \u6307\u5B9A\u67E5\u627E\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E
+
+main.opt.R=\  -R         --recursive               \u9012\u5F52\u904D\u5386\u6240\u6709\u88AB\u4F9D\u8D56\u5BF9\u8C61
+
+main.opt.d=\  -d <depth> --depth=<depth>           \u6307\u5B9A\u8FC7\u6E21\u88AB\u4F9D\u8D56\u5BF9\u8C61\u5206\u6790\u7684\u6DF1\u5EA6
+
+err.unknown.option=\u672A\u77E5\u9009\u9879: {0}
+err.missing.arg=\u6CA1\u6709\u4E3A{0}\u6307\u5B9A\u503C
+err.internal.error=\u5185\u90E8\u9519\u8BEF: {0} {1} {2}
+err.invalid.arg.for.option=\u9009\u9879\u7684\u53C2\u6570\u65E0\u6548: {0}
+err.option.after.class=\u5FC5\u987B\u5728\u7C7B\u4E4B\u524D\u6307\u5B9A\u9009\u9879: {0}
+err.option.unsupported=\u4E0D\u652F\u6301{0}: {1}
+err.profiles.msg=\u6CA1\u6709\u914D\u7F6E\u6587\u4EF6\u4FE1\u606F
+warn.invalid.arg=\u7C7B\u540D\u65E0\u6548\u6216\u8DEF\u5F84\u540D\u4E0D\u5B58\u5728: {0}
+warn.split.package=\u5DF2\u5728{1} {2}\u4E2D\u5B9A\u4E49\u7A0B\u5E8F\u5305{0}
+
+artifact.not.found=\u627E\u4E0D\u5230
diff --git a/src/share/classes/com/sun/tools/jdeps/resources/version.properties-template b/src/share/classes/com/sun/tools/jdeps/resources/version.properties-template
new file mode 100644
index 0000000..9e4fa62
--- /dev/null
+++ b/src/share/classes/com/sun/tools/jdeps/resources/version.properties-template
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+jdk=$(JDK_VERSION)
+full=$(FULL_VERSION)
+release=$(RELEASE)
diff --git a/src/share/classes/com/sun/tools/sjavac/BuildState.java b/src/share/classes/com/sun/tools/sjavac/BuildState.java
new file mode 100644
index 0000000..9b90950
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/BuildState.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The build state class captures the source code and generated artifacts
+ * from a build. There are usually two build states, the previous one (prev),
+ * loaded from the javac_state file, and the current one (now).
+ *
+ * <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></p>
+ */
+public class BuildState {
+    private Map<String,Module> modules = new HashMap<String,Module>();
+    private Map<String,Package> packages = new HashMap<String,Package>();
+    private Map<String,Source> sources = new HashMap<String,Source>();
+    private Map<String,File> artifacts = new HashMap<String,File>();
+    // Map from package to a set of packages that depend on said package.
+    private Map<String,Set<String>> dependents = new HashMap<String,Set<String>>();
+
+    public  Map<String,Module> modules() { return modules; }
+    public  Map<String,Package> packages() { return packages; }
+    public  Map<String,Source> sources() { return sources; }
+    public  Map<String,File> artifacts() { return artifacts; }
+    public  Map<String,Set<String>> dependents() { return dependents; }
+
+    /**
+     * Lookup a module from a name. Create the module if it does
+     * not exist yet.
+     */
+    public Module lookupModule(String mod) {
+        Module m = modules.get(mod);
+        if (m == null) {
+            m = new Module(mod, "???");
+            modules.put(mod, m);
+        }
+        return m;
+    }
+
+    /**
+     * Find a module from a given package name. For example:
+     * The package name "base:java.lang" will fetch the module named "base".
+     * The package name ":java.net" will fetch the default module.
+     */
+    Module findModuleFromPackageName(String pkg) {
+        int cp = pkg.indexOf(':');
+        assert(cp != -1);
+        String mod = pkg.substring(0, cp);
+        return lookupModule(mod);
+    }
+
+    /**
+     * Collect all packages, sources and artifacts for all modules
+     * into the build state.
+     *
+     * @param m The set of modules.
+     */
+    public void collectPackagesSourcesAndArtifacts(Map<String,Module> m) {
+        modules = m;
+        // Extract all the found packages.
+        for (Module i : modules.values()) {
+            for (Map.Entry<String,Package> j : i.packages().entrySet()) {
+                Package p = packages.get(j.getKey());
+                // Check that no two different packages are stored under same name.
+                assert(p == null || p == j.getValue());
+                if (p == null) {
+                    p = j.getValue();
+                    packages.put(j.getKey(),j.getValue());
+                }
+                for (Map.Entry<String,Source> k : p.sources().entrySet()) {
+                    Source s = sources.get(k.getKey());
+                    // Check that no two different sources are stored under same name.
+                    assert(s == null || s == k.getValue());
+                    if (s == null) {
+                        s = k.getValue();
+                        sources.put(k.getKey(), k.getValue());
+                    }
+                }
+                for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
+                    File f = artifacts.get(g.getKey());
+                    // Check that no two artifacts are stored under the same file.
+                    assert(f == null || f == g.getValue());
+                    if (f == null) {
+                        f = g.getValue();
+                        artifacts.put(g.getKey(), g.getValue());
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Collect all the artifacts of all modules and packages.
+     *
+     * @param m The set of modules.
+     */
+    public void collectArtifacts(Map<String,Module> m) {
+        modules = m;
+        // Extract all the found packages.
+        for (Module i : modules.values()) {
+            for (Map.Entry<String,Package> j : i.packages().entrySet()) {
+                Package p = packages.get(j.getKey());
+                // Check that no two different packages are stored under same name.
+                assert(p == null || p == j.getValue());
+                p = j.getValue();
+                packages.put(j.getKey(),j.getValue());
+                for (Map.Entry<String,File> g : p.artifacts().entrySet()) {
+                    File f = artifacts.get(g.getKey());
+                    // Check that no two artifacts are stored under the same file.
+                    assert(f == null || f == g.getValue());
+                    artifacts.put(g.getKey(), g.getValue());
+                }
+            }
+        }
+    }
+
+    /**
+     * Calculate the package dependents (ie the reverse of the dependencies).
+     */
+    public void calculateDependents() {
+        dependents = new HashMap<String,Set<String>>();
+        for (String s : packages.keySet()) {
+            Package p = packages.get(s);
+            for (String d : p.dependencies()) {
+                Set<String> ss = dependents.get(d);
+                if (ss == null) {
+                    ss = new HashSet<String>();
+                    dependents.put(d, ss);
+                }
+                // Add the dependent information to the global dependent map.
+                ss.add(s);
+                Package dp = packages.get(d);
+                // Also add the dependent information to the package specific map.
+                // Normally, you do not compile java.lang et al. Therefore
+                // there are several packages that p depends upon that you
+                // do not have in your state database. This is perfectly fine.
+                if (dp != null) {
+                    // But this package did exist in the state database.
+                    dp.addDependent(p.name());
+                }
+            }
+        }
+    }
+
+    /**
+     * Verify that the setModules method above did the right thing when
+     * running through the module->package->source structure.
+     */
+    public void checkInternalState(String msg, boolean linkedOnly, Map<String,Source> srcs) {
+        boolean baad = false;
+        Map<String,Source> original = new HashMap<String,Source>();
+        Map<String,Source> calculated = new HashMap<String,Source>();
+
+        for (String s : sources.keySet()) {
+            Source ss = sources.get(s);
+            if (ss.isLinkedOnly() == linkedOnly) {
+                calculated.put(s,ss);
+            }
+        }
+        for (String s : srcs.keySet()) {
+            Source ss = srcs.get(s);
+            if (ss.isLinkedOnly() == linkedOnly) {
+                original.put(s,ss);
+            }
+        }
+        if (original.size() != calculated.size()) {
+            Log.error("INTERNAL ERROR "+msg+" original and calculated are not the same size!");
+            baad = true;
+        }
+        if (!original.keySet().equals(calculated.keySet())) {
+            Log.error("INTERNAL ERROR "+msg+" original and calculated do not have the same domain!");
+            baad = true;
+        }
+        if (!baad) {
+            for (String s : original.keySet()) {
+                Source s1 = original.get(s);
+                Source s2 = calculated.get(s);
+                if (s1 == null || s2 == null || !s1.equals(s2)) {
+                    Log.error("INTERNAL ERROR "+msg+" original and calculated have differing elements for "+s);
+                }
+                baad = true;
+            }
+        }
+        if (baad) {
+            for (String s : original.keySet()) {
+                Source ss = original.get(s);
+                Source sss = calculated.get(s);
+                if (sss == null) {
+                    Log.error("The file "+s+" does not exist in calculated tree of sources.");
+                }
+            }
+            for (String s : calculated.keySet()) {
+                Source ss = calculated.get(s);
+                Source sss = original.get(s);
+                if (sss == null) {
+                    Log.error("The file "+s+" does not exist in original set of found sources.");
+                }
+            }
+        }
+    }
+
+    /**
+     * Load a module from the javac state file.
+     */
+    public Module loadModule(String l) {
+        Module m = Module.load(l);
+        modules.put(m.name(), m);
+        return m;
+    }
+
+    /**
+     * Load a package from the javac state file.
+     */
+    public Package loadPackage(Module lastModule, String l) {
+        Package p = Package.load(lastModule, l);
+        lastModule.addPackage(p);
+        packages.put(p.name(), p);
+        return p;
+    }
+
+    /**
+     * Load a source from the javac state file.
+     */
+    public Source loadSource(Package lastPackage, String l, boolean is_generated) {
+        Source s = Source.load(lastPackage, l, is_generated);
+        lastPackage.addSource(s);
+        sources.put(s.name(), s);
+        return s;
+    }
+
+    /**
+     * During an incremental compile we need to copy the old javac state
+     * information about packages that were not recompiled.
+     */
+    public void copyPackagesExcept(BuildState prev, Set<String> recompiled, Set<String> removed) {
+        for (String pkg : prev.packages().keySet()) {
+            // Do not copy recompiled or removed packages.
+            if (recompiled.contains(pkg) || removed.contains(pkg)) continue;
+            Module mnew = findModuleFromPackageName(pkg);
+            Package pprev = prev.packages().get(pkg);
+            mnew.addPackage(pprev);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/CleanProperties.java b/src/share/classes/com/sun/tools/sjavac/CleanProperties.java
new file mode 100644
index 0000000..a46cd71
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/CleanProperties.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2001, 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.sjavac;
+
+import java.io.*;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The clean properties transform should not be necessary.
+ * Eventually we will cleanup the property file sources in the OpenJDK instead.
+ *
+ * <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></p>
+ */
+public class CleanProperties implements Transformer
+{
+    public void setExtra(String e) {
+        // Any extra information is ignored for clean properties.
+    }
+
+    public void setExtra(String[] a) {
+        // Any extra information is ignored for clean properties.
+    }
+
+    public boolean transform(Map<String,Set<URI>> pkgSrcs,
+                             Set<URI>             visibleSrcs,
+                             Map<URI,Set<String>> visibleClasses,
+                             Map<String,Set<String>> oldPackageDependencies,
+                             URI destRoot,
+                             Map<String,Set<URI>>    packageArtifacts,
+                             Map<String,Set<String>> packageDependencies,
+                             Map<String,String>      packagePublicApis,
+                             int debugLevel,
+                             boolean incremental,
+                             int numCores,
+                             PrintStream out,
+                             PrintStream err)
+    {
+        boolean rc = true;
+        for (String pkgName : pkgSrcs.keySet()) {
+            String pkgNameF = pkgName.replace('.',File.separatorChar);
+            for (URI u : pkgSrcs.get(pkgName)) {
+                File src = new File(u);
+                boolean r = clean(pkgName, pkgNameF, src, new File(destRoot), debugLevel,
+                                  packageArtifacts);
+                if (r == false) {
+                    rc = false;
+                }
+            }
+        }
+        return rc;
+    }
+
+    boolean clean(String pkgName, String pkgNameF, File src, File destRoot, int debugLevel,
+                  Map<String,Set<URI>> packageArtifacts)
+    {
+        // Load the properties file.
+        Properties p = new Properties();
+        try {
+            p.load(new FileInputStream(src));
+        } catch (IOException e) {
+            Log.error("Error reading file "+src.getPath());
+            return false;
+        }
+
+        // Sort the properties in increasing key order.
+        List<String> sortedKeys = new ArrayList<String>();
+        for (Object key : p.keySet()) {
+            sortedKeys.add((String)key);
+        }
+        Collections.sort(sortedKeys);
+        Iterator<String> keys = sortedKeys.iterator();
+
+        // Collect the properties into a string buffer.
+        StringBuilder data = new StringBuilder();
+        while (keys.hasNext()) {
+            String key = keys.next();
+            data.append(CompileProperties.escape(key)+":"+CompileProperties.escape((String)p.get(key))+"\n");
+        }
+
+        String destFilename = destRoot.getPath()+File.separator+pkgNameF+File.separator+src.getName();
+        File dest = new File(destFilename);
+
+        // Make sure the dest directories exist.
+        if (!dest.getParentFile().isDirectory()) {
+            if (!dest.getParentFile().mkdirs()) {
+                Log.error("Could not create the directory "+dest.getParentFile().getPath());
+                return false;
+            }
+        }
+
+        Set<URI> as = packageArtifacts.get(pkgName);
+        if (as == null) {
+            as = new HashSet<URI>();
+            packageArtifacts.put(pkgName, as);
+        }
+        as.add(dest.toURI());
+
+        if (dest.exists() && dest.lastModified() > src.lastModified()) {
+            // A cleaned property file exists, and its timestamp is newer than the source.
+            // Assume that we do not need to clean!
+            // Thus we are done.
+            return true;
+        }
+
+        Log.info("Cleaning property file "+pkgNameF+File.separator+src.getName());
+        try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest)))) {
+            writer.write(data.toString());
+        } catch ( IOException e ) {
+            Log.error("Could not write file "+dest.getPath());
+            return false;
+        }
+        return true;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/CompileChunk.java b/src/share/classes/com/sun/tools/sjavac/CompileChunk.java
new file mode 100644
index 0000000..54d5658
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/CompileChunk.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A compile chunk is a list of sources/packages to be compiled. Possibly a subset of
+ * the total number of sources/packages to be compiled for this sjavac invocation.
+ *
+ * <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></p>
+ */
+public class CompileChunk implements Comparable<CompileChunk> {
+    public int numPackages;
+    public int numDependents;
+    public Set<URI> srcs = new HashSet<URI>();
+    public StringBuilder pkgNames = new StringBuilder();
+    public String pkgFromTos = "";
+
+    public int compareTo(CompileChunk c) {
+        if (numDependents == c.numDependents) return 0;
+        if (numDependents > c.numDependents) return -1;
+        return -1;
+    }
+
+    boolean equal(CompileChunk c) {
+        return numDependents == c.numDependents;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java b/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java
new file mode 100644
index 0000000..d3e8769
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java
@@ -0,0 +1,345 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Random;
+import java.util.Set;
+import java.util.Map;
+
+import com.sun.tools.sjavac.server.JavacServer;
+import com.sun.tools.sjavac.server.SysInfo;
+import java.io.PrintStream;
+
+/**
+ * This transform compiles a set of packages containing Java sources.
+ * The compile request is divided into separate sets of source files.
+ * For each set a separate request thread is dispatched to a javac server
+ * and the meta data is accumulated. The number of sets correspond more or
+ * less to the number of cores. Less so now, than it will in the future.
+ *
+ * <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></p>
+ */
+public class CompileJavaPackages implements Transformer {
+
+    // The current limited sharing of data between concurrent JavaCompilers
+    // in the server will not give speedups above 3 cores. Thus this limit.
+    // We hope to improve this in the future.
+    final static int limitOnConcurrency = 3;
+
+    String serverSettings;
+    public void setExtra(String e) {
+        serverSettings = e;
+    }
+
+    String[] args;
+    public void setExtra(String[] a) {
+        args = a;
+    }
+
+    public boolean transform(Map<String,Set<URI>> pkgSrcs,
+                             Set<URI>             visibleSources,
+                             Map<URI,Set<String>> visibleClasses,
+                             Map<String,Set<String>> oldPackageDependents,
+                             URI destRoot,
+                             final Map<String,Set<URI>>    packageArtifacts,
+                             final Map<String,Set<String>> packageDependencies,
+                             final Map<String,String>      packagePubapis,
+                             int debugLevel,
+                             boolean incremental,
+                             int numCores,
+                             PrintStream out,
+                             PrintStream err)
+    {
+        boolean rc = true;
+        boolean concurrentCompiles = true;
+
+        // Fetch the id.
+        String id = Util.extractStringOption("id", serverSettings);
+        if (id == null || id.equals("")) {
+            // No explicit id set. Create a random id so that the requests can be
+            // grouped properly in the server.
+            id = "id"+(((new Random()).nextLong())&Long.MAX_VALUE);
+        }
+        // Only keep portfile and sjavac settings..
+        String psServerSettings = Util.cleanSubOptions("--server:", Util.set("portfile","sjavac","background","keepalive"), serverSettings);
+
+        // Get maximum heap size from the server!
+        SysInfo sysinfo = JavacServer.connectGetSysInfo(psServerSettings, out, err);
+        if (sysinfo.numCores == -1) {
+            Log.error("Could not query server for sysinfo!");
+            return false;
+        }
+        int numMBytes = (int)(sysinfo.maxMemory / ((long)(1024*1024)));
+        Log.debug("Server reports "+numMBytes+"MiB of memory and "+sysinfo.numCores+" cores");
+
+        if (numCores <= 0) {
+            // Set the requested number of cores to the number of cores on the server.
+            numCores = sysinfo.numCores;
+            Log.debug("Number of jobs not explicitly set, defaulting to "+sysinfo.numCores);
+        } else if (sysinfo.numCores < numCores) {
+            // Set the requested number of cores to the number of cores on the server.
+            Log.debug("Limiting jobs from explicitly set "+numCores+" to cores available on server: "+sysinfo.numCores);
+            numCores = sysinfo.numCores;
+        } else {
+            Log.debug("Number of jobs explicitly set to "+numCores);
+        }
+        // More than three concurrent cores does not currently give a speedup, at least for compiling the jdk
+        // in the OpenJDK. This will change in the future.
+        int numCompiles = numCores;
+        if (numCores > limitOnConcurrency) numCompiles = limitOnConcurrency;
+        // Split the work up in chunks to compiled.
+
+        int numSources = 0;
+        for (String s : pkgSrcs.keySet()) {
+            Set<URI> ss = pkgSrcs.get(s);
+            numSources += ss.size();
+        }
+
+        int sourcesPerCompile = numSources / numCompiles;
+
+        // For 64 bit Java, it seems we can compile the OpenJDK 8800 files with a 1500M of heap
+        // in a single chunk, with reasonable performance.
+        // For 32 bit java, it seems we need 1G of heap.
+        // Number experimentally determined when compiling the OpenJDK.
+        // Includes space for reasonably efficient garbage collection etc,
+        // Calculating backwards gives us a requirement of
+        // 1500M/8800 = 175 KiB for 64 bit platforms
+        // and 1G/8800 = 119 KiB for 32 bit platform
+        // for each compile.....
+        int kbPerFile = 175;
+        String osarch = System.getProperty("os.arch");
+        String dataModel = System.getProperty("sun.arch.data.model");
+        if ("32".equals(dataModel)) {
+            // For 32 bit platforms, assume it is slightly smaller
+            // because of smaller object headers and pointers.
+            kbPerFile = 119;
+        }
+        int numRequiredMBytes = (kbPerFile*numSources)/1024;
+        Log.debug("For os.arch "+osarch+" the empirically determined heap required per file is "+kbPerFile+"KiB");
+        Log.debug("Server has "+numMBytes+"MiB of heap.");
+        Log.debug("Heuristics say that we need "+numRequiredMBytes+"MiB of heap for all source files.");
+        // Perform heuristics to see how many cores we can use,
+        // or if we have to the work serially in smaller chunks.
+        if (numMBytes < numRequiredMBytes) {
+            // Ouch, cannot fit even a single compile into the heap.
+            // Split it up into several serial chunks.
+            concurrentCompiles = false;
+            // Limit the number of sources for each compile to 500.
+            if (numSources < 500) {
+                numCompiles = 1;
+                sourcesPerCompile = numSources;
+                Log.debug("Compiling as a single source code chunk to stay within heap size limitations!");
+            } else if (sourcesPerCompile > 500) {
+                // This number is very low, and tuned to dealing with the OpenJDK
+                // where the source is >very< circular! In normal application,
+                // with less circularity the number could perhaps be increased.
+                numCompiles = numSources / 500;
+                sourcesPerCompile = numSources/numCompiles;
+                Log.debug("Compiling source as "+numCompiles+" code chunks serially to stay within heap size limitations!");
+            }
+        } else {
+            if (numCompiles > 1) {
+                // Ok, we can fit at least one full compilation on the heap.
+                float usagePerCompile = (float)numRequiredMBytes / ((float)numCompiles * (float)0.7);
+                int usage = (int)(usagePerCompile * (float)numCompiles);
+                Log.debug("Heuristics say that for "+numCompiles+" concurrent compiles we need "+usage+"MiB");
+                if (usage > numMBytes) {
+                    // Ouch it does not fit. Reduce to a single chunk.
+                    numCompiles = 1;
+                    sourcesPerCompile = numSources;
+                    // What if the relationship betweem number of compile_chunks and num_required_mbytes
+                    // is not linear? Then perhaps 2 chunks would fit where 3 does not. Well, this is
+                    // something to experiment upon in the future.
+                    Log.debug("Limiting compile to a single thread to stay within heap size limitations!");
+                }
+            }
+        }
+
+        Log.debug("Compiling sources in "+numCompiles+" chunk(s)");
+
+        // Create the chunks to be compiled.
+        final CompileChunk[] compileChunks = createCompileChunks(pkgSrcs, oldPackageDependents,
+                numCompiles, sourcesPerCompile);
+
+        if (Log.isDebugging()) {
+            int cn = 1;
+            for (CompileChunk cc : compileChunks) {
+                Log.debug("Chunk "+cn+" for "+id+" ---------------");
+                cn++;
+                for (URI u : cc.srcs) {
+                    Log.debug(""+u);
+                }
+            }
+        }
+
+        // The return values for each chunked compile.
+        final int[] rn = new int[numCompiles];
+        // The requets, might or might not run as a background thread.
+        final Thread[] requests  = new Thread[numCompiles];
+
+        final Set<URI>             fvisible_sources = visibleSources;
+        final Map<URI,Set<String>> fvisible_classes = visibleClasses;
+
+        long start = System.currentTimeMillis();
+
+        for (int i=0; i<numCompiles; ++i) {
+            final int ii = i;
+            final CompileChunk cc = compileChunks[i];
+
+            // Pass the num_cores and the id (appended with the chunk number) to the server.
+            final String cleanedServerSettings = psServerSettings+",poolsize="+numCores+",id="+id+"-"+ii;
+            final PrintStream fout = out;
+            final PrintStream ferr = err;
+
+            requests[ii] = new Thread() {
+                @Override
+                public void run() {
+                                        rn[ii] = JavacServer.useServer(cleanedServerSettings,
+                                                           Main.removeWrapperArgs(args),
+                                                               cc.srcs,
+                                                           fvisible_sources,
+                                                           fvisible_classes,
+                                                           packageArtifacts,
+                                                           packageDependencies,
+                                                           packagePubapis,
+                                                           null,
+                                                           fout, ferr);
+                }
+            };
+
+            if (cc.srcs.size() > 0) {
+                String numdeps = "";
+                if (cc.numDependents > 0) numdeps = "(with "+cc.numDependents+" dependents) ";
+                if (!incremental || cc.numPackages > 16) {
+                    String info = "("+cc.pkgFromTos+")";
+                    if (info.equals("( to )")) {
+                        info = "";
+                    }
+                    Log.info("Compiling "+cc.srcs.size()+" files "+numdeps+"in "+cc.numPackages+" packages "+info);
+                } else {
+                    Log.info("Compiling "+cc.pkgNames+numdeps);
+                }
+                if (concurrentCompiles) {
+                    requests[ii].start();
+                }
+                else {
+                    requests[ii].run();
+                    // If there was an error, then stop early when running single threaded.
+                    if (rn[i] != 0) {
+                        return false;
+                    }
+                }
+            }
+        }
+        if (concurrentCompiles) {
+            // If there are background threads for the concurrent compiles, then join them.
+            for (int i=0; i<numCompiles; ++i) {
+                try { requests[i].join(); } catch (InterruptedException e) { }
+            }
+        }
+
+        // Check the return values.
+        for (int i=0; i<numCompiles; ++i) {
+            if (compileChunks[i].srcs.size() > 0) {
+                if (rn[i] != 0) {
+                    rc = false;
+                }
+            }
+        }
+        long duration = System.currentTimeMillis() - start;
+        long minutes = duration/60000;
+        long seconds = (duration-minutes*60000)/1000;
+        Log.debug("Compilation of "+numSources+" source files took "+minutes+"m "+seconds+"s");
+
+        return rc;
+    }
+
+
+    /**
+     * Split up the sources into compile chunks. If old package dependents information
+     * is available, sort the order of the chunks into the most dependent first!
+     * (Typically that chunk contains the java.lang package.) In the future
+     * we could perhaps improve the heuristics to put the sources into even more sensible chunks.
+     * Now the package are simple sorted in alphabetical order and chunked, then the chunks
+     * are sorted on how dependent they are.
+     *
+     * @param pkgSrcs The sources to compile.
+     * @param oldPackageDependents Old package dependents, if non-empty, used to sort the chunks.
+     * @param numCompiles The number of chunks.
+     * @param sourcesPerCompile The number of sources per chunk.
+     * @return
+     */
+    CompileChunk[] createCompileChunks(Map<String,Set<URI>> pkgSrcs,
+                                 Map<String,Set<String>> oldPackageDependents,
+                                 int numCompiles,
+                                 int sourcesPerCompile) {
+
+        CompileChunk[] compileChunks = new CompileChunk[numCompiles];
+        for (int i=0; i<compileChunks.length; ++i) {
+            compileChunks[i] = new CompileChunk();
+        }
+
+        // Now go through the packages and spread out the source on the different chunks.
+        int ci = 0;
+        // Sort the packages
+        String[] packageNames = pkgSrcs.keySet().toArray(new String[0]);
+        Arrays.sort(packageNames);
+        String from = null;
+        for (String pkgName : packageNames) {
+            CompileChunk cc = compileChunks[ci];
+            Set<URI> s = pkgSrcs.get(pkgName);
+            if (cc.srcs.size()+s.size() > sourcesPerCompile && ci < numCompiles-1) {
+                from = null;
+                ci++;
+                cc = compileChunks[ci];
+            }
+            cc.numPackages++;
+            cc.srcs.addAll(s);
+
+            // Calculate nice package names to use as information when compiling.
+            String justPkgName = Util.justPackageName(pkgName);
+            // Fetch how many packages depend on this package from the old build state.
+            Set<String> ss = oldPackageDependents.get(pkgName);
+            if (ss != null) {
+                // Accumulate this information onto this chunk.
+                cc.numDependents += ss.size();
+            }
+            if (from == null || from.trim().equals("")) from = justPkgName;
+            cc.pkgNames.append(justPkgName+"("+s.size()+") ");
+            cc.pkgFromTos = from+" to "+justPkgName;
+        }
+        // If we are compiling serially, sort the chunks, so that the chunk (with the most dependents) (usually the chunk
+        // containing java.lang.Object, is to be compiled first!
+        // For concurrent compilation, this does not matter.
+        Arrays.sort(compileChunks);
+        return compileChunks;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/CompileProperties.java b/src/share/classes/com/sun/tools/sjavac/CompileProperties.java
new file mode 100644
index 0000000..ce04381
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/CompileProperties.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.*;
+import java.net.URI;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * Compile properties transform a properties file into a Java source file.
+ * Java has built in support for reading properties from either a text file
+ * in the source or a compiled java source file.
+ *
+ * <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></p>
+ */
+public class CompileProperties implements Transformer
+{
+    // Any extra information passed from the command line, for example if:
+    // -tr .proppp=com.sun.tools.javac.smart.CompileProperties,sun.util.resources.LocaleNamesBundle
+    // then extra will be "sun.util.resources.LocaleNamesBundle"
+    String extra;
+
+    public void setExtra(String e) {
+        extra = e;
+    }
+
+    public void setExtra(String[] a) {
+    }
+
+    public boolean transform(Map<String,Set<URI>> pkgSrcs,
+                             Set<URI>             visibleSrcs,
+                             Map<URI,Set<String>> visibleClasses,
+                             Map<String,Set<String>> oldPackageDependents,
+                             URI destRoot,
+                             Map<String,Set<URI>>    packageArtifacts,
+                             Map<String,Set<String>> packageDependencies,
+                             Map<String,String>      packagePublicApis,
+                             int debugLevel,
+                             boolean incremental,
+                             int numCores,
+                             PrintStream out,
+                             PrintStream err) {
+        boolean rc = true;
+        for (String pkgName : pkgSrcs.keySet()) {
+            String pkgNameF = Util.toFileSystemPath(pkgName);
+            for (URI u : pkgSrcs.get(pkgName)) {
+                File src = new File(u);
+                boolean r = compile(pkgName, pkgNameF, src, new File(destRoot), debugLevel,
+                                    packageArtifacts);
+                if (r == false) {
+                    rc = false;
+                }
+            }
+        }
+        return rc;
+    }
+
+    boolean compile(String pkgName, String pkgNameF, File src, File destRoot, int debugLevel,
+                    Map<String,Set<URI>> packageArtifacts)
+    {
+        String superClass = "java.util.ListResourceBundle";
+
+        if (extra != null) {
+            superClass = extra;
+        }
+        // Load the properties file.
+        Properties p = new Properties();
+        try {
+            p.load(new FileInputStream(src));
+        } catch (IOException e) {
+            Log.error("Error reading file "+src.getPath());
+            return false;
+        }
+
+        // Calculate the name of the Java source file to be generated.
+        int dp = src.getName().lastIndexOf(".");
+        String classname = src.getName().substring(0,dp);
+
+        // Sort the properties in increasing key order.
+        List<String> sortedKeys = new ArrayList<String>();
+        for (Object key : p.keySet()) {
+            sortedKeys.add((String)key);
+        }
+        Collections.sort(sortedKeys);
+        Iterator<String> keys = sortedKeys.iterator();
+
+        // Collect the properties into a string buffer.
+        StringBuilder data = new StringBuilder();
+        while (keys.hasNext()) {
+            String key = keys.next();
+            data.append("            { \"" + escape(key) + "\", \"" +
+                        escape((String)p.get(key)) + "\" },\n");
+        }
+
+        // Create dest file name. It is derived from the properties file name.
+        String destFilename = destRoot.getPath()+File.separator+pkgNameF+File.separator+classname+".java";
+        File dest = new File(destFilename);
+
+        // Make sure the dest directories exist.
+        if (!dest.getParentFile().isDirectory()) {
+            if (!dest.getParentFile().mkdirs()) {
+                Log.error("Could not create the directory "+dest.getParentFile().getPath());
+                return false;
+            }
+        }
+
+        Set<URI> as = packageArtifacts.get(pkgName);
+        if (as == null) {
+            as = new HashSet<URI>();
+            packageArtifacts.put(pkgName, as);
+        }
+        as.add(dest.toURI());
+
+        if (dest.exists() && dest.lastModified() > src.lastModified()) {
+            // A generated file exists, and its timestamp is newer than the source.
+            // Assume that we do not need to regenerate the dest file!
+            // Thus we are done.
+            return true;
+        }
+
+        String packageString = "package " + pkgNameF.replace(File.separatorChar,'.') + ";\n\n";
+
+        Log.info("Compiling property file "+pkgNameF+File.separator+src.getName());
+        try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest)))) {
+            MessageFormat format = new MessageFormat(FORMAT);
+            writer.write(format.format(new Object[] { packageString, classname, superClass, data }));
+        } catch ( IOException e ) {
+            Log.error("Could not write file "+dest.getPath());
+            return false;
+        }
+        return true;
+    }
+
+    private static final String FORMAT =
+            "{0}" +
+            "public final class {1} extends {2} '{'\n" +
+            "    protected final Object[][] getContents() '{'\n" +
+            "        return new Object[][] '{'\n" +
+            "{3}" +
+            "        };\n" +
+            "    }\n" +
+            "}\n";
+
+    public static String escape(String theString) {
+        int len = theString.length();
+        StringBuilder outBuffer = new StringBuilder(len*2);
+
+        for(int x=0; x<len; x++) {
+            char aChar = theString.charAt(x);
+            switch(aChar) {
+                case '\\':outBuffer.append('\\'); outBuffer.append('\\');
+                break;
+                case '\t':outBuffer.append('\\'); outBuffer.append('t');
+                break;
+                case '\n':outBuffer.append('\\'); outBuffer.append('n');
+                break;
+                case '\r':outBuffer.append('\\'); outBuffer.append('r');
+                break;
+                case '\f':outBuffer.append('\\'); outBuffer.append('f');
+                break;
+                default:
+                    if ((aChar < 0x0020) || (aChar > 0x007e)) {
+                        outBuffer.append('\\');
+                        outBuffer.append('u');
+                        outBuffer.append(toHex((aChar >> 12) & 0xF));
+                        outBuffer.append(toHex((aChar >>  8) & 0xF));
+                        outBuffer.append(toHex((aChar >>  4) & 0xF));
+                        outBuffer.append(toHex( aChar        & 0xF));
+                    } else {
+                        if (aChar == '"') {
+                            outBuffer.append('\\');
+                        }
+                        outBuffer.append(aChar);
+                    }
+            }
+        }
+        return outBuffer.toString();
+    }
+
+    private static char toHex(int nibble) {
+        return hexDigit[(nibble & 0xF)];
+    }
+
+    private static final char[] hexDigit = {
+        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
+    };
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/CopyFile.java b/src/share/classes/com/sun/tools/sjavac/CopyFile.java
new file mode 100644
index 0000000..c131ed3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/CopyFile.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.*;
+import java.net.URI;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+
+/**
+ * The copy file transform simply copies a matching file from -src to -d .
+ * Such files are typically images, xml documents and other data files.
+ *
+ * <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></p>
+ */
+public class CopyFile implements Transformer {
+
+    public void setExtra(String e) {
+    }
+
+    public void setExtra(String[] a) {
+    }
+
+    public boolean transform(Map<String,Set<URI>> pkgSrcs,
+                             Set<URI> visibleSrcs,
+                             Map<URI,Set<String>> visibleClasses,
+                             Map<String,Set<String>> oldPackageDependents,
+                             URI destRoot,
+                             Map<String,Set<URI>>    packageArtifacts,
+                             Map<String,Set<String>> packageDependencies,
+                             Map<String,String>      packagePubapis,
+                             int debugLevel,
+                             boolean incremental,
+                             int numCores,
+                             PrintStream out,
+                             PrintStream err)
+    {
+        boolean rc = true;
+        String dest_filename;
+        File dest;
+
+        for (String pkgName : pkgSrcs.keySet()) {
+            String pkgNameF = Util.toFileSystemPath(pkgName);
+            for (URI u : pkgSrcs.get(pkgName)) {
+                File src = new File(u);
+                File destDir;
+                destDir = new File(destRoot.getPath()+File.separator+pkgNameF);
+                dest_filename = destRoot.getPath()+File.separator+pkgNameF+File.separator+src.getName();
+                dest = new File(dest_filename);
+
+                if (!destDir.isDirectory()) {
+                    if (!destDir.mkdirs()) {
+                       Log.error("Error: The copier could not create the directory "+
+                                           destDir.getPath());
+                        return false;
+                    }
+                }
+
+                Set<URI> as = packageArtifacts.get(pkgName);
+                if (as == null) {
+                    as = new HashSet<URI>();
+                    packageArtifacts.put(pkgName, as);
+                }
+                as.add(dest.toURI());
+
+                if (dest.exists() && dest.lastModified() > src.lastModified()) {
+                    // A copied file exists, and its timestamp is newer than the source.
+                    continue;
+                }
+
+                Log.info("Copying "+pkgNameF+File.separator+src.getName());
+
+                try (InputStream fin = new FileInputStream(src);
+                     OutputStream fout = new FileOutputStream(dest)) {
+                    byte[] buf = new byte[1024];
+                    int len;
+                    while ((len = fin.read(buf)) > 0){
+                        fout.write(buf, 0, len);
+                    }
+                }
+                catch(IOException e){
+                    Log.error("Could not copy the file "+src.getPath()+" to "+dest.getPath());
+                    rc = false;
+                }
+            }
+        }
+        return rc;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/JavacState.java b/src/share/classes/com/sun/tools/sjavac/JavacState.java
new file mode 100644
index 0000000..7e1af20
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/JavacState.java
@@ -0,0 +1,857 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.*;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.text.SimpleDateFormat;
+import java.net.URI;
+import java.util.*;
+
+/**
+ * The javac state class maintains the previous (prev) and the current (now)
+ * build states and everything else that goes into the javac_state file.
+ *
+ * <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></p>
+ */
+public class JavacState
+{
+    // The arguments to the compile. If not identical, then it cannot
+    // be an incremental build!
+    String theArgs;
+    // The number of cores limits how many threads are used for heavy concurrent work.
+    int numCores;
+
+    // The bin_dir/javac_state
+    private String javacStateFilename;
+    private File javacState;
+
+    // The previous build state is loaded from javac_state
+    private BuildState prev;
+    // The current build state is constructed during the build,
+    // then saved as the new javac_state.
+    private BuildState now;
+
+    // Something has changed in the javac_state. It needs to be saved!
+    private boolean needsSaving;
+    // If this is a new javac_state file, then do not print unnecessary messages.
+    private boolean newJavacState;
+
+    // These are packages where something has changed and the package
+    // needs to be recompiled. Actions that trigger recompilation:
+    // * source belonging to the package has changed
+    // * artifact belonging to the package is lost, or its timestamp has been changed.
+    // * an unknown artifact has appeared, we simply delete it, but we also trigger a recompilation.
+    // * a package that is tainted, taints all packages that depend on it.
+    private Set<String> taintedPackages;
+    // After a compile, the pubapis are compared with the pubapis stored in the javac state file.
+    // Any packages where the pubapi differ are added to this set.
+    // Later we use this set and the dependency information to taint dependent packages.
+    private Set<String> packagesWithChangedPublicApis;
+    // When a module-info.java file is changed, taint the module,
+    // then taint all modules that depend on that that module.
+    // A module dependency can occur directly through a require, or
+    // indirectly through a module that does a public export for the first tainted module.
+    // When all modules are tainted, then taint all packages belonging to these modules.
+    // Then rebuild. It is perhaps possible (and valuable?) to do a more finegrained examination of the
+    // change in module-info.java, but that will have to wait.
+    private Set<String> taintedModules;
+    // The set of all packages that has been recompiled.
+    // Copy over the javac_state for the packages that did not need recompilation,
+    // verbatim from the previous (prev) to the new (now) build state.
+    private Set<String> recompiledPackages;
+
+    // The output directories filled with tasty artifacts.
+    private File binDir, gensrcDir, headerDir;
+
+    // The current status of the file system.
+    private Set<File> binArtifacts;
+    private Set<File> gensrcArtifacts;
+    private Set<File> headerArtifacts;
+
+    // The status of the sources.
+    Set<Source> removedSources = null;
+    Set<Source> addedSources = null;
+    Set<Source> modifiedSources = null;
+
+    // Visible sources for linking. These are the only
+    // ones that -sourcepath is allowed to see.
+    Set<URI> visibleSrcs;
+
+    // Visible classes for linking. These are the only
+    // ones that -classpath is allowed to see.
+    // It maps from a classpath root to the set of visible classes for that root.
+    // If the set is empty, then all classes are visible for that root.
+    // It can also map from a jar file to the set of visible classes for that jar file.
+    Map<URI,Set<String>> visibleClasses;
+
+    // Setup two transforms that always exist.
+    private CopyFile            copyFiles = new CopyFile();
+    private CompileJavaPackages compileJavaPackages = new CompileJavaPackages();
+
+    // Where to send stdout and stderr.
+    private PrintStream out, err;
+
+    JavacState(String[] args, File bd, File gd, File hd, boolean permitUnidentifiedArtifacts, boolean removeJavacState,
+            PrintStream o, PrintStream e) {
+        out = o;
+        err = e;
+        numCores = Main.findNumberOption(args, "-j");
+        theArgs = "";
+        for (String a : removeArgsNotAffectingState(args)) {
+            theArgs = theArgs+a+" ";
+        }
+        binDir = bd;
+        gensrcDir = gd;
+        headerDir = hd;
+        javacStateFilename = binDir.getPath()+File.separator+"javac_state";
+        javacState = new File(javacStateFilename);
+        if (removeJavacState && javacState.exists()) {
+            javacState.delete();
+        }
+        newJavacState = false;
+        if (!javacState.exists()) {
+            newJavacState = true;
+            // If there is no javac_state then delete the contents of all the artifact dirs!
+            // We do not want to risk building a broken incremental build.
+            // BUT since the makefiles still copy things straight into the bin_dir et al,
+            // we avoid deleting files here, if the option --permit-unidentified-classes was supplied.
+            if (!permitUnidentifiedArtifacts) {
+                deleteContents(binDir);
+                deleteContents(gensrcDir);
+                deleteContents(headerDir);
+            }
+            needsSaving = true;
+        }
+        prev = new BuildState();
+        now = new BuildState();
+        taintedPackages = new HashSet<String>();
+        recompiledPackages = new HashSet<String>();
+        packagesWithChangedPublicApis = new HashSet<String>();
+    }
+
+    public BuildState prev() { return prev; }
+    public BuildState now() { return now; }
+
+    /**
+     * Remove args not affecting the state.
+     */
+    static String[] removeArgsNotAffectingState(String[] args) {
+        String[] out = new String[args.length];
+        int j = 0;
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-j")) {
+                // Just skip it and skip following value
+                i++;
+            } else if (args[i].startsWith("--server:")) {
+                // Just skip it.
+            } else if (args[i].startsWith("--log=")) {
+                // Just skip it.
+            } else if (args[i].equals("--compare-found-sources")) {
+                // Just skip it and skip verify file name
+                i++;
+            } else {
+                // Copy argument.
+                out[j] = args[i];
+                j++;
+            }
+        }
+        String[] ret = new String[j];
+        System.arraycopy(out, 0, ret, 0, j);
+        return ret;
+    }
+
+    /**
+     * Specify which sources are visible to the compiler through -sourcepath.
+     */
+    public void setVisibleSources(Map<String,Source> vs) {
+        visibleSrcs = new HashSet<URI>();
+        for (String s : vs.keySet()) {
+            Source src = vs.get(s);
+            visibleSrcs.add(src.file().toURI());
+        }
+    }
+
+    /**
+     * Specify which classes are visible to the compiler through -classpath.
+     */
+    public void setVisibleClasses(Map<String,Source> vs) {
+        visibleSrcs = new HashSet<URI>();
+        for (String s : vs.keySet()) {
+            Source src = vs.get(s);
+            visibleSrcs.add(src.file().toURI());
+        }
+    }
+    /**
+     * Returns true if this is an incremental build.
+     */
+    public boolean isIncremental() {
+        return !prev.sources().isEmpty();
+    }
+
+    /**
+     * Find all artifacts that exists on disk.
+     */
+    public void findAllArtifacts() {
+        binArtifacts = findAllFiles(binDir);
+        gensrcArtifacts = findAllFiles(gensrcDir);
+        headerArtifacts = findAllFiles(headerDir);
+    }
+
+    /**
+     * Lookup the artifacts generated for this package in the previous build.
+     */
+    private Map<String,File> fetchPrevArtifacts(String pkg) {
+        Package p = prev.packages().get(pkg);
+        if (p != null) {
+            return p.artifacts();
+        }
+        return new HashMap<String,File>();
+    }
+
+    /**
+     * Delete all prev artifacts in the currently tainted packages.
+     */
+    public void deleteClassArtifactsInTaintedPackages() {
+        for (String pkg : taintedPackages) {
+            Map<String,File> arts = fetchPrevArtifacts(pkg);
+            for (File f : arts.values()) {
+                if (f.exists() && f.getName().endsWith(".class")) {
+                    f.delete();
+                }
+            }
+        }
+    }
+
+    /**
+     * Mark the javac_state file to be in need of saving and as a side effect,
+     * it gets a new timestamp.
+     */
+    private void needsSaving() {
+        needsSaving = true;
+    }
+
+    /**
+     * Save the javac_state file.
+     */
+    public void save() throws IOException {
+        if (!needsSaving) return;
+        try (FileWriter out = new FileWriter(javacStateFilename)) {
+            StringBuilder b = new StringBuilder();
+            long millisNow = System.currentTimeMillis();
+            Date d = new Date(millisNow);
+            SimpleDateFormat df =
+                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
+            b.append("# javac_state ver 0.3 generated "+millisNow+" "+df.format(d)+"\n");
+            b.append("# This format might change at any time. Please do not depend on it.\n");
+            b.append("# M module\n");
+            b.append("# P package\n");
+            b.append("# S C source_tobe_compiled timestamp\n");
+            b.append("# S L link_only_source timestamp\n");
+            b.append("# G C generated_source timestamp\n");
+            b.append("# A artifact timestamp\n");
+            b.append("# D dependency\n");
+            b.append("# I pubapi\n");
+            b.append("# R arguments\n");
+            b.append("R ").append(theArgs).append("\n");
+
+            // Copy over the javac_state for the packages that did not need recompilation.
+            now.copyPackagesExcept(prev, recompiledPackages, new HashSet<String>());
+            // Save the packages, ie package names, dependencies, pubapis and artifacts!
+            // I.e. the lot.
+            Module.saveModules(now.modules(), b);
+
+            String s = b.toString();
+            out.write(s, 0, s.length());
+        }
+    }
+
+    /**
+     * Load a javac_state file.
+     */
+    public static JavacState load(String[] args, File binDir, File gensrcDir, File headerDir,
+            boolean permitUnidentifiedArtifacts, PrintStream out, PrintStream err) {
+        JavacState db = new JavacState(args, binDir, gensrcDir, headerDir, permitUnidentifiedArtifacts, false, out, err);
+        Module  lastModule = null;
+        Package lastPackage = null;
+        Source  lastSource = null;
+        boolean noFileFound = false;
+        boolean foundCorrectVerNr = false;
+        boolean newCommandLine = false;
+        boolean syntaxError = false;
+
+        try (BufferedReader in = new BufferedReader(new FileReader(db.javacStateFilename))) {
+            for (;;) {
+                String l = in.readLine();
+                if (l==null) break;
+                if (l.length()>=3 && l.charAt(1) == ' ') {
+                    char c = l.charAt(0);
+                    if (c == 'M') {
+                        lastModule = db.prev.loadModule(l);
+                    } else
+                    if (c == 'P') {
+                        if (lastModule == null) { syntaxError = true; break; }
+                        lastPackage = db.prev.loadPackage(lastModule, l);
+                    } else
+                    if (c == 'D') {
+                        if (lastModule == null || lastPackage == null) { syntaxError = true; break; }
+                        lastPackage.loadDependency(l);
+                    } else
+                    if (c == 'I') {
+                        if (lastModule == null || lastPackage == null) { syntaxError = true; break; }
+                        lastPackage.loadPubapi(l);
+                    } else
+                    if (c == 'A') {
+                        if (lastModule == null || lastPackage == null) { syntaxError = true; break; }
+                        lastPackage.loadArtifact(l);
+                    } else
+                    if (c == 'S') {
+                        if (lastModule == null || lastPackage == null) { syntaxError = true; break; }
+                        lastSource = db.prev.loadSource(lastPackage, l, false);
+                    } else
+                    if (c == 'G') {
+                        if (lastModule == null || lastPackage == null) { syntaxError = true; break; }
+                        lastSource = db.prev.loadSource(lastPackage, l, true);
+                    } else
+                    if (c == 'R') {
+                        String ncmdl = "R "+db.theArgs;
+                        if (!l.equals(ncmdl)) {
+                            newCommandLine = true;
+                        }
+                    } else
+                         if (c == '#') {
+                        if (l.startsWith("# javac_state ver ")) {
+                            int sp = l.indexOf(" ", 18);
+                            if (sp != -1) {
+                                String ver = l.substring(18,sp);
+                                if (!ver.equals("0.3")) {
+                    break;
+                                 }
+                foundCorrectVerNr = true;
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (FileNotFoundException e) {
+            // Silently create a new javac_state file.
+            noFileFound = true;
+        } catch (IOException e) {
+            Log.info("Dropping old javac_state because of errors when reading it.");
+            db = new JavacState(args, binDir, gensrcDir, headerDir, permitUnidentifiedArtifacts, true, out, err);
+            foundCorrectVerNr = true;
+            newCommandLine = false;
+            syntaxError = false;
+    }
+        if (foundCorrectVerNr == false && !noFileFound) {
+            Log.info("Dropping old javac_state since it is of an old version.");
+            db = new JavacState(args, binDir, gensrcDir, headerDir, permitUnidentifiedArtifacts, true, out, err);
+        } else
+        if (newCommandLine == true && !noFileFound) {
+            Log.info("Dropping old javac_state since a new command line is used!");
+            db = new JavacState(args, binDir, gensrcDir, headerDir, permitUnidentifiedArtifacts, true, out, err);
+        } else
+        if (syntaxError == true) {
+            Log.info("Dropping old javac_state since it contains syntax errors.");
+            db = new JavacState(args, binDir, gensrcDir, headerDir, permitUnidentifiedArtifacts, true, out, err);
+        }
+        db.prev.calculateDependents();
+        return db;
+    }
+
+    /**
+     * Mark a java package as tainted, ie it needs recompilation.
+     */
+    public void taintPackage(String name, String because) {
+        if (!taintedPackages.contains(name)) {
+            if (because != null) Log.debug("Tainting "+Util.justPackageName(name)+" because "+because);
+            // It has not been tainted before.
+            taintedPackages.add(name);
+            needsSaving();
+            Package nowp = now.packages().get(name);
+            if (nowp != null) {
+                for (String d : nowp.dependents()) {
+                    taintPackage(d, because);
+                }
+            }
+        }
+    }
+
+    /**
+     * This packages need recompilation.
+     */
+    public Set<String> taintedPackages() {
+        return taintedPackages;
+    }
+
+    /**
+     * Clean out the tainted package set, used after the first round of compiles,
+     * prior to propagating dependencies.
+     */
+    public void clearTaintedPackages() {
+        taintedPackages = new HashSet<String>();
+    }
+
+    /**
+     * Go through all sources and check which have been removed, added or modified
+     * and taint the corresponding packages.
+     */
+    public void checkSourceStatus(boolean check_gensrc) {
+        removedSources = calculateRemovedSources();
+        for (Source s : removedSources) {
+            if (!s.isGenerated() || check_gensrc) {
+                taintPackage(s.pkg().name(), "source "+s.name()+" was removed");
+            }
+        }
+
+        addedSources = calculateAddedSources();
+        for (Source s : addedSources) {
+            String msg = null;
+            if (isIncremental()) {
+                // When building from scratch, there is no point
+                // printing "was added" for every file since all files are added.
+                // However for an incremental build it makes sense.
+                msg = "source "+s.name()+" was added";
+            }
+            if (!s.isGenerated() || check_gensrc) {
+                taintPackage(s.pkg().name(), msg);
+            }
+        }
+
+        modifiedSources = calculateModifiedSources();
+        for (Source s : modifiedSources) {
+            if (!s.isGenerated() || check_gensrc) {
+                taintPackage(s.pkg().name(), "source "+s.name()+" was modified");
+            }
+        }
+    }
+
+    /**
+     * Acquire the compile_java_packages suffix rule for .java files.
+     */
+    public Map<String,Transformer> getJavaSuffixRule() {
+        Map<String,Transformer> sr = new HashMap<String,Transformer>();
+        sr.put(".java", compileJavaPackages);
+        return sr;
+    }
+
+    /**
+     * Acquire the copying transform.
+     */
+    public Transformer getCopier() {
+        return copyFiles;
+    }
+
+    /**
+     * If artifacts have gone missing, force a recompile of the packages
+     * they belong to.
+     */
+    public void taintPackagesThatMissArtifacts() {
+        for (Package pkg : prev.packages().values()) {
+            for (File f : pkg.artifacts().values()) {
+                if (!f.exists()) {
+                    // Hmm, the artifact on disk does not exist! Someone has removed it....
+                    // Lets rebuild the package.
+                    taintPackage(pkg.name(), ""+f+" is missing.");
+                }
+            }
+        }
+    }
+
+    /**
+     * Propagate recompilation through the dependency chains.
+     * Avoid re-tainting packages that have already been compiled.
+     */
+    public void taintPackagesDependingOnChangedPackages(Set<String> pkgs, Set<String> recentlyCompiled) {
+        for (Package pkg : prev.packages().values()) {
+            for (String dep : pkg.dependencies()) {
+                if (pkgs.contains(dep) && !recentlyCompiled.contains(pkg.name())) {
+                    taintPackage(pkg.name(), " its depending on "+dep);
+                }
+            }
+        }
+    }
+
+    /**
+     * Scan all output dirs for artifacts and remove those files (artifacts?)
+     * that are not recognized as such, in the javac_state file.
+     */
+    public void removeUnidentifiedArtifacts() {
+        Set<File> allKnownArtifacts = new HashSet<File>();
+        for (Package pkg : prev.packages().values()) {
+            for (File f : pkg.artifacts().values()) {
+                allKnownArtifacts.add(f);
+            }
+        }
+        // Do not forget about javac_state....
+        allKnownArtifacts.add(javacState);
+
+        for (File f : binArtifacts) {
+            if (!allKnownArtifacts.contains(f)) {
+                Log.debug("Removing "+f.getPath()+" since it is unknown to the javac_state.");
+                f.delete();
+            }
+        }
+        for (File f : headerArtifacts) {
+            if (!allKnownArtifacts.contains(f)) {
+                Log.debug("Removing "+f.getPath()+" since it is unknown to the javac_state.");
+                f.delete();
+            }
+        }
+        for (File f : gensrcArtifacts) {
+            if (!allKnownArtifacts.contains(f)) {
+                Log.debug("Removing "+f.getPath()+" since it is unknown to the javac_state.");
+                f.delete();
+            }
+        }
+    }
+
+    /**
+     * Remove artifacts that are no longer produced when compiling!
+     */
+    public void removeSuperfluousArtifacts(Set<String> recentlyCompiled) {
+        // Nothing to do, if nothing was recompiled.
+        if (recentlyCompiled.size() == 0) return;
+
+        for (String pkg : now.packages().keySet()) {
+            // If this package has not been recompiled, skip the check.
+            if (!recentlyCompiled.contains(pkg)) continue;
+            Collection<File> arts = now.artifacts().values();
+            for (File f : fetchPrevArtifacts(pkg).values()) {
+                if (!arts.contains(f)) {
+                    Log.debug("Removing "+f.getPath()+" since it is now superfluous!");
+                    if (f.exists()) f.delete();
+                }
+            }
+        }
+    }
+
+    /**
+     * Return those files belonging to prev, but not now.
+     */
+    private Set<Source> calculateRemovedSources() {
+        Set<Source> removed = new HashSet<Source>();
+        for (String src : prev.sources().keySet()) {
+            if (now.sources().get(src) == null) {
+                removed.add(prev.sources().get(src));
+            }
+        }
+        return removed;
+    }
+
+    /**
+     * Return those files belonging to now, but not prev.
+     */
+    private Set<Source> calculateAddedSources() {
+        Set<Source> added = new HashSet<Source>();
+        for (String src : now.sources().keySet()) {
+            if (prev.sources().get(src) == null) {
+                added.add(now.sources().get(src));
+            }
+        }
+        return added;
+    }
+
+    /**
+     * Return those files where the timestamp is newer.
+     * If a source file timestamp suddenly is older than what is known
+     * about it in javac_state, then consider it modified, but print
+     * a warning!
+     */
+    private Set<Source> calculateModifiedSources() {
+        Set<Source> modified = new HashSet<Source>();
+        for (String src : now.sources().keySet()) {
+            Source n = now.sources().get(src);
+            Source t = prev.sources().get(src);
+            if (prev.sources().get(src) != null) {
+                if (t != null) {
+                    if (n.lastModified() > t.lastModified()) {
+                        modified.add(n);
+                    } else if (n.lastModified() < t.lastModified()) {
+                        modified.add(n);
+                        Log.warn("The source file "+n.name()+" timestamp has moved backwards in time.");
+                    }
+                }
+            }
+        }
+        return modified;
+    }
+
+    /**
+     * Recursively delete a directory and all its contents.
+     */
+    private static void deleteContents(File dir) {
+        if (dir != null && dir.exists()) {
+            for (File f : dir.listFiles()) {
+                if (f.isDirectory()) {
+                    deleteContents(f);
+                }
+                f.delete();
+            }
+        }
+    }
+
+    /**
+     * Run the copy translator only.
+     */
+    public void performCopying(File binDir, Map<String,Transformer> suffixRules) {
+        Map<String,Transformer> sr = new HashMap<String,Transformer>();
+        for (Map.Entry<String,Transformer> e : suffixRules.entrySet()) {
+            if (e.getValue() == copyFiles) {
+                sr.put(e.getKey(), e.getValue());
+            }
+        }
+        perform(binDir, sr);
+    }
+
+    /**
+     * Run all the translators that translate into java source code.
+     * I.e. all translators that are not copy nor compile_java_source.
+     */
+    public void performTranslation(File gensrcDir, Map<String,Transformer> suffixRules) {
+        Map<String,Transformer> sr = new HashMap<String,Transformer>();
+        for (Map.Entry<String,Transformer> e : suffixRules.entrySet()) {
+            if (e.getValue() != copyFiles &&
+                e.getValue() != compileJavaPackages) {
+                sr.put(e.getKey(), e.getValue());
+            }
+        }
+        perform(gensrcDir, sr);
+    }
+
+    /**
+     * Compile all the java sources. Return true, if it needs to be called again!
+     */
+    public boolean performJavaCompilations(File binDir,
+                                           String serverSettings,
+                                           String[] args,
+                                           Set<String> recentlyCompiled,
+                                           boolean[] rcValue) {
+        Map<String,Transformer> suffixRules = new HashMap<String,Transformer>();
+        suffixRules.put(".java", compileJavaPackages);
+        compileJavaPackages.setExtra(serverSettings);
+        compileJavaPackages.setExtra(args);
+
+        rcValue[0] = perform(binDir, suffixRules);
+        recentlyCompiled.addAll(taintedPackages());
+        clearTaintedPackages();
+        boolean again = !packagesWithChangedPublicApis.isEmpty();
+        taintPackagesDependingOnChangedPackages(packagesWithChangedPublicApis, recentlyCompiled);
+        packagesWithChangedPublicApis = new HashSet<String>();
+        return again && rcValue[0];
+    }
+
+    /**
+     * Store the source into the set of sources belonging to the given transform.
+     */
+    private void addFileToTransform(Map<Transformer,Map<String,Set<URI>>> gs, Transformer t, Source s) {
+        Map<String,Set<URI>> fs = gs.get(t);
+        if (fs == null) {
+            fs = new HashMap<String,Set<URI>>();
+            gs.put(t, fs);
+        }
+        Set<URI> ss = fs.get(s.pkg().name());
+        if (ss == null) {
+            ss = new HashSet<URI>();
+            fs.put(s.pkg().name(), ss);
+        }
+        ss.add(s.file().toURI());
+    }
+
+    /**
+     * For all packages, find all sources belonging to the package, group the sources
+     * based on their transformers and apply the transformers on each source code group.
+     */
+    private boolean perform(File outputDir, Map<String,Transformer> suffixRules)
+    {
+        boolean rc = true;
+        // Group sources based on transforms. A source file can only belong to a single transform.
+        Map<Transformer,Map<String,Set<URI>>> groupedSources = new HashMap<Transformer,Map<String,Set<URI>>>();
+        for (Source src : now.sources().values()) {
+            Transformer t = suffixRules.get(src.suffix());
+               if (t != null) {
+                if (taintedPackages.contains(src.pkg().name()) && !src.isLinkedOnly()) {
+                    addFileToTransform(groupedSources, t, src);
+                }
+            }
+        }
+        // Go through the transforms and transform them.
+        for (Map.Entry<Transformer,Map<String,Set<URI>>> e : groupedSources.entrySet()) {
+            Transformer t = e.getKey();
+            Map<String,Set<URI>> srcs = e.getValue();
+            // These maps need to be synchronized since multiple threads will be writing results into them.
+            Map<String,Set<URI>> packageArtifacts = Collections.synchronizedMap(new HashMap<String,Set<URI>>());
+            Map<String,Set<String>> packageDependencies = Collections.synchronizedMap(new HashMap<String,Set<String>>());
+            Map<String,String> packagePublicApis = Collections.synchronizedMap(new HashMap<String,String>());
+
+            boolean  r = t.transform(srcs,
+                                     visibleSrcs,
+                                     visibleClasses,
+                                     prev.dependents(),
+                                     outputDir.toURI(),
+                                     packageArtifacts,
+                                     packageDependencies,
+                                     packagePublicApis,
+                                     0,
+                                     isIncremental(),
+                                     numCores,
+                                     out,
+                                     err);
+            if (!r) rc = false;
+
+            for (String p : srcs.keySet()) {
+                recompiledPackages.add(p);
+            }
+            // The transform is done! Extract all the artifacts and store the info into the Package objects.
+            for (Map.Entry<String,Set<URI>> a : packageArtifacts.entrySet()) {
+                Module mnow = now.findModuleFromPackageName(a.getKey());
+                mnow.addArtifacts(a.getKey(), a.getValue());
+            }
+            // Extract all the dependencies and store the info into the Package objects.
+            for (Map.Entry<String,Set<String>> a : packageDependencies.entrySet()) {
+                Set<String> deps = a.getValue();
+                Module mnow = now.findModuleFromPackageName(a.getKey());
+                mnow.setDependencies(a.getKey(), deps);
+            }
+            // Extract all the pubapis and store the info into the Package objects.
+            for (Map.Entry<String,String> a : packagePublicApis.entrySet()) {
+                Module mprev = prev.findModuleFromPackageName(a.getKey());
+                List<String> pubapi = Package.pubapiToList(a.getValue());
+                Module mnow = now.findModuleFromPackageName(a.getKey());
+                mnow.setPubapi(a.getKey(), pubapi);
+                if (mprev.hasPubapiChanged(a.getKey(), pubapi)) {
+                    // Aha! The pubapi of this package has changed!
+                    // It can also be a new compile from scratch.
+                    if (mprev.lookupPackage(a.getKey()).existsInJavacState()) {
+                        // This is an incremental compile! The pubapi
+                        // did change. Trigger recompilation of dependents.
+                        packagesWithChangedPublicApis.add(a.getKey());
+                        Log.info("The pubapi of "+Util.justPackageName(a.getKey())+" has changed!");
+                    }
+                }
+            }
+        }
+        return rc;
+    }
+
+    /**
+     * Utility method to recursively find all files below a directory.
+     */
+    private static Set<File> findAllFiles(File dir) {
+        Set<File> foundFiles = new HashSet<File>();
+        if (dir == null) {
+            return foundFiles;
+        }
+        recurse(dir, foundFiles);
+        return foundFiles;
+    }
+
+    private static void recurse(File dir, Set<File> foundFiles) {
+        for (File f : dir.listFiles()) {
+            if (f.isFile()) {
+                foundFiles.add(f);
+            } else if (f.isDirectory()) {
+                recurse(f, foundFiles);
+            }
+        }
+    }
+
+    /**
+     * Compare the calculate source list, with an explicit list, usually supplied from the makefile.
+     * Used to detect bugs where the makefile and sjavac have different opinions on which files
+     * should be compiled.
+     */
+    public void compareWithMakefileList(File makefileSourceList)
+            throws ProblemException
+    {
+        // If we are building on win32 using for example cygwin the paths in the makefile source list
+        // might be /cygdrive/c/.... which does not match c:\....
+        // We need to adjust our calculated sources to be identical, if necessary.
+        boolean mightNeedRewriting = File.pathSeparatorChar == ';';
+
+        if (makefileSourceList == null) return;
+
+        Set<String> calculatedSources = new HashSet<String>();
+        Set<String> listedSources = new HashSet<String>();
+
+        // Create a set of filenames with full paths.
+        for (Source s : now.sources().values()) {
+            calculatedSources.add(s.file().getPath());
+        }
+        // Read in the file and create another set of filenames with full paths.
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(makefileSourceList));
+            for (;;) {
+                String l = in.readLine();
+                if (l==null) break;
+                l = l.trim();
+                if (mightNeedRewriting) {
+                    if (l.indexOf(":") == 1 && l.indexOf("\\") == 2) {
+                        // Everything a-ok, the format is already C:\foo\bar
+                    } else if (l.indexOf(":") == 1 && l.indexOf("/") == 2) {
+                        // The format is C:/foo/bar, rewrite into the above format.
+                        l = l.replaceAll("/","\\\\");
+                    } else if (l.charAt(0) == '/' && l.indexOf("/",1) != -1) {
+                        // The format might be: /cygdrive/c/foo/bar, rewrite into the above format.
+                        // Do not hardcode the name cygdrive here.
+                        int slash = l.indexOf("/",1);
+                        l = l.replaceAll("/","\\\\");
+                        l = ""+l.charAt(slash+1)+":"+l.substring(slash+2);
+                    }
+                    if (Character.isLowerCase(l.charAt(0))) {
+                        l = Character.toUpperCase(l.charAt(0))+l.substring(1);
+                    }
+                }
+                listedSources.add(l);
+            }
+        } catch (FileNotFoundException e) {
+            throw new ProblemException("Could not open "+makefileSourceList.getPath()+" since it does not exist!");
+        } catch (IOException e) {
+            throw new ProblemException("Could not read "+makefileSourceList.getPath());
+        }
+
+        for (String s : listedSources) {
+            if (!calculatedSources.contains(s)) {
+                 throw new ProblemException("The makefile listed source "+s+" was not calculated by the smart javac wrapper!");
+            }
+        }
+
+        for (String s : calculatedSources) {
+            if (!listedSources.contains(s)) {
+                throw new ProblemException("The smart javac wrapper calculated source "+s+" was not listed by the makefiles!");
+            }
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Log.java b/src/share/classes/com/sun/tools/sjavac/Log.java
new file mode 100644
index 0000000..99bd29f
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Log.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.PrintStream;
+
+/**
+ * Utility class only for sjavac logging.
+ * The log level can be set using for example --log=DEBUG on the sjavac command line.
+ *
+ * <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></p>
+ */
+public class Log {
+    private static PrintStream out, err;
+
+    public final static int WARN = 1;
+    public final static int INFO = 2;
+    public final static int DEBUG = 3;
+    public final static int TRACE = 4;
+    private static int level = WARN;
+
+    static public void trace(String msg) {
+        if (level >= TRACE) {
+            out.println(msg);
+        }
+    }
+
+    static public void debug(String msg) {
+        if (level >= DEBUG) {
+            out.println(msg);
+        }
+    }
+
+    static public void info(String msg) {
+        if (level >= INFO) {
+            out.println(msg);
+        }
+    }
+
+    static public void warn(String msg) {
+        err.println(msg);
+    }
+
+    static public void error(String msg) {
+        err.println(msg);
+    }
+
+    static public void setLogLevel(String l, PrintStream o, PrintStream e)
+        throws ProblemException {
+        out = o;
+        err = e;
+        if (l.equals("warn")) level = WARN;
+        else if (l.equals("info")) level = INFO;
+        else if (l.equals("debug")) level = DEBUG;
+        else if (l.equals("trace")) level = TRACE;
+        else throw new ProblemException("No such log level \""+l+"\"");
+    }
+
+    static public boolean isTracing() {
+        return level >= TRACE;
+    }
+
+    static public boolean isDebugging() {
+        return level >= DEBUG;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Main.java b/src/share/classes/com/sun/tools/sjavac/Main.java
new file mode 100644
index 0000000..14c65f3
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Main.java
@@ -0,0 +1,966 @@
+/*
+ * 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.  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.sjavac;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.sun.tools.sjavac.server.JavacServer;
+
+/**
+ * The main class of the smart javac wrapper tool.
+ *
+ * <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></p>
+ */
+public class Main {
+
+    /*  This is a smart javac wrapper primarily used when building the OpenJDK,
+        though other projects are welcome to use it too. But please be aware
+        that it is not an official api and will change in the future.
+        (We really mean it!)
+
+        Goals:
+
+        ** Create a state file, containing information about the build, so
+           that incremental builds only rebuild what is necessary. Also the
+           state file can be used by make/ant to detect when to trigger
+           a call to the smart javac wrapper.
+
+           This file is called bin/javac_state (assuming that you specified "-d bin")
+           Thus the simplest makefile is:
+
+           SJAVAC=java -cp .../tools.jar com.sun.tools.sjavac.Main
+           SRCS=$(shell find src -name "*.java")
+           bin/javac_state : $(SRCS)
+                  $(SJAVAC) src -d bin
+
+           This makefile will run very fast and detect properly when Java code needs to
+           be recompiled. The smart javac wrapper will then use the information in java_state
+           to do an efficient incremental compile.
+
+           Previously it was near enough impossible to write an efficient makefile for Java
+           with support for incremental builds and dependency tracking.
+
+        ** Separate java sources to be compiled from java
+           sources used >only< for linking. The options:
+
+           "dir" points to root dir with sources to be compiled
+           "-sourcepath dir" points to root dir with sources used only for linking
+           "-classpath dir" points to dir with classes used only for linking (as before)
+
+        ** Use all cores for compilation by default.
+           "-j 4" limit the number of cores to 4.
+           For the moment, the sjavac server additionally limits the number of cores to three.
+           This will improve in the future when more sharing is performed between concurrent JavaCompilers.
+
+        ** Basic translation support from other sources to java, and then compilation of the generated java.
+           This functionality might be moved into annotation processors instead.
+           Again this is driven by the OpenJDK sources where properties and a few other types of files
+           are converted into Java sources regularily. The javac_state embraces copy and tr, and perform
+           incremental recompiles and copying for these as well. META-INF will be a special copy rule
+           that will copy any files found below any META-INF dir in src to the bin/META-INF dir.
+           "-copy .gif"
+           "-copy META-INF"
+           "-tr .prop=com.sun.tools.javac.smart.CompileProperties
+           "-tr .propp=com.sun.tools.javac.smart.CompileProperties,java.util.ListResourceBundle
+           "-tr .proppp=com.sun.tools.javac.smart.CompileProperties,sun.util.resources.LocaleNamesBundle
+
+        ** Control which classes in the src,sourcepath and classpath that javac is allowed to see.
+           Again, this is necessary to deal with the source code structure of the OpenJDK which is
+           intricate (read messy).
+
+           "-i tools.*" to include the tools package and all its subpackages in the build.
+           "-x tools.net.aviancarrier.*" to exclude the aviancarrier package and all its sources and subpackages.
+           "-x tools.net.drums" to exclude the drums package only, keep its subpackages.
+           "-xf tools/net/Bar.java" // Do not compile this file...
+           "-xf *Bor.java" // Do not compile Bor.java wherever it is found, BUT do compile ABor.java!
+           "-if tools/net/Bor.java" // Only compile this file...odd, but sometimes used.
+
+        ** The smart javac wrapper is driven by the modification time on the source files and compared
+           to the modification times written into the javac_state file.
+
+           It does not compare the modification time of the source with the modification time of the artifact.
+           However it will detect if the modification time of an artifact has changed compared to the java_state,
+           and this will trigger a delete of the artifact and a subsequent recompile of the source.
+
+           The smart javac wrapper is not a generic makefile/ant system. Its purpose is to compile java source
+           as the final step before the output dir is finalized and immediately jared, or jmodded. The output
+           dir should be considered opaque. Do not write into the outputdir yourself!
+           Any artifacts found in the outputdir that javac_state does not know of, will be deleted!
+           This can however be prevented, using the switch --permit-unidentified-artifacts
+           This switch is necessary when build the OpenJDK because its makefiles still write directly to
+           the output classes dirs.
+
+           Any makefile/ant rules that want to put contents into the outputdir should put the content
+           in one of several source roots. Static content that is under version control, can be put in the same source
+           code tree as the Java sources. Dynamic content that is generated by make/ant on the fly, should
+           be put in a separate gensrc_stuff root. The smart javac wrapper call will then take the arguments:
+           "gensrc_stuff src -d bin"
+
+        The command line:
+        java -cp tools.jar com.sun.tools.sjavac.Main \
+             -i "com.bar.*" -x "com.bar.foo.*" \
+             first_root \
+             -i "com.bar.foo.*" \
+             second_root \
+             -x "org.net.*" \
+             -sourcepath link_root_sources \
+             -classpath link_root_classes \
+             -d bin
+
+        Will compile all sources for package com.bar and its subpackages, found below first_root,
+        except the package com.bar.foo (and its subpackages), for which the sources are picked
+        from second_root instead. It will link against classes in link_root_classes and against
+        sources in link_root_sources, but will not see (try to link against) sources matching org.net.*
+        but will link against org.net* classes (if they exist) in link_root_classes.
+
+        (If you want a set of complex filter rules to be applied to several source directories, without
+         having to repeat the the filter rules for each root. You can use the explicit -src option. For example:
+         sjavac -x "com.foo.*" -src root1:root2:root3  )
+
+        The resulting classes are written into bin.
+    */
+
+    // This is the final destination for classes and copied files.
+    private File bin_dir;
+    // This is where the annotation process will put generated sources.
+    private File gensrc_dir;
+    // This is where javac -h puts the generated c-header files.
+    private File header_dir;
+
+    // This file contains the list of sources genereated by the makefile.
+    // We double check that our calculated list of sources matches this list,
+    // if not, then we terminate with an error!
+    private File makefile_source_list;
+    // The challenging task to manage an incremental build is done by javac_state.
+    private JavacState javac_state;
+
+    // The suffix rules tells you for example, that .java files should be compiled,
+    // and .html files should be copied and .properties files be translated.
+    Map<String,Transformer> suffix_rules;
+
+    public static void main(String... args)  {
+        if (args.length > 0 && args[0].startsWith("--startserver:")) {
+            if (args.length>1) {
+                Log.error("When spawning a background server, only a single --startserver argument is allowed.");
+                return;
+            }
+            // Spawn a background server.
+            int rc = JavacServer.startServer(args[0], System.err);
+            System.exit(rc);
+        }
+        Main main = new Main();
+        int rc = main.go(args, System.out, System.err);
+        // Remove the portfile, but only if this background=false was used.
+        JavacServer.cleanup(args);
+        System.exit(rc);
+    }
+
+    private void printHelp() {
+        System.out.println("Usage: sjavac <options>\n"+
+                           "where required options are:\n"+
+                           "dir                        Compile all sources in dir recursively\n"+
+                           "-d dir                     Store generated classes here and the javac_state file\n"+
+                           "--server:portfile=/tmp/abc Use a background sjavac server\n\n"+
+                           "All other arguments as javac, except -implicit:none which is forced by default.\n"+
+                           "No java source files can be supplied on the command line, nor can an @file be supplied.\n\n"+
+                           "Warning!\n"+
+                           "This tool might disappear at any time, and its command line options might change at any time!");
+    }
+
+    public int go(String[] args, PrintStream out, PrintStream err) {
+        try {
+            if (args.length == 0 || findJavaSourceFiles(args) || findAtFile(args) || null==Util.findServerSettings(args)) {
+                printHelp();
+                return 0;
+            }
+
+            Log.setLogLevel(findLogLevel(args), out, err);
+            String server_settings = Util.findServerSettings(args);
+            args = verifyImplicitOption(args);
+            // Find the source root directories, and add the -src option before these, if not there already.
+            args = addSrcBeforeDirectories(args);
+            // Check that there is at least one -src supplied.
+            checkSrcOption(args);
+            // Check that there is one -d supplied.
+            bin_dir = findDirectoryOption(args,"-d","output", true, false, true);
+            gensrc_dir = findDirectoryOption(args,"-s","gensrc", false, false, true);
+            header_dir = findDirectoryOption(args,"-h","headers", false, false, true);
+            makefile_source_list = findFileOption(args,"--compare-found-sources","makefile source list", false);
+
+            // Load the prev build state database.
+            javac_state = JavacState.load(args, bin_dir, gensrc_dir, header_dir,
+                    findBooleanOption(args, "--permit-unidentified-artifacts"), out, err);
+
+            // Setup the suffix rules from the command line.
+            suffix_rules = javac_state.getJavaSuffixRule();
+            findTranslateOptions(args, suffix_rules);
+            if (suffix_rules.keySet().size() > 1 && gensrc_dir == null) {
+                Log.error("You have translators but no gensrc dir (-s) specified!");
+                return -1;
+            }
+            findCopyOptions(args, suffix_rules);
+
+            // All found modules are put here.
+            Map<String,Module> modules = new HashMap<String,Module>();
+            // We start out in the legacy empty no-name module.
+            // As soon as we stumble on a module-info.java file we change to that module.
+            Module current_module = new Module("", "");
+            modules.put("", current_module);
+
+            // Find all sources, use the suffix rules to know which files are sources.
+            Map<String,Source> sources = new HashMap<String,Source>();
+            // Find the files, this will automatically populate the found modules
+            // with found packages where the sources are found!
+            findFiles(args, "-src", suffix_rules.keySet(), sources, modules, current_module, false);
+
+            if (sources.isEmpty()) {
+                Log.error("Found nothing to compile!");
+                return -1;
+            }
+
+            // Find all source files allowable for linking.
+            // We might find more modules here as well.
+            Map<String,Source> sources_to_link_to = new HashMap<String,Source>();
+            // Always reuse -src for linking as well! This means that we might
+            // get two -sourcepath on the commandline after the rewrite, which is
+            // fine. We can have as many as we like. You need to have separate -src/-sourcepath/-classpath
+            // if you need different filtering rules for different roots. If you have the same filtering
+            // rules for all sourcepath roots, you can concatenate them using :(;) as before.
+              rewriteOptions(args, "-src", "-sourcepath");
+            findFiles(args, "-sourcepath", Util.set(".java"), sources_to_link_to, modules, current_module, true);
+
+            // Find all class files allowable for linking.
+            // And pickup knowledge of all modules found here.
+            // This cannot currently filter classes inside jar files.
+//          Map<String,Source> classes_to_link_to = new HashMap<String,Source>();
+//          findFiles(args, "-classpath", Util.set(".class"), classes_to_link_to, modules, current_module, true);
+
+            // Find all module sources allowable for linking.
+//          Map<String,Source> modules_to_link_to = new HashMap<String,Source>();
+//          findFiles(args, "-modulepath", Util.set(".class"), modules_to_link_to, modules, current_module, true);
+
+            // Add the set of sources to the build database.
+            javac_state.now().collectPackagesSourcesAndArtifacts(modules);
+            javac_state.now().checkInternalState("checking sources", false, sources);
+            javac_state.now().checkInternalState("checking linked sources", true, sources_to_link_to);
+            javac_state.setVisibleSources(sources_to_link_to);
+
+            // If there is any change in the source files, taint packages
+            // and mark the database in need of saving.
+            javac_state.checkSourceStatus(false);
+
+            // Find all existing artifacts. Their timestamp will match the last modified timestamps stored
+            // in javac_state, simply because loading of the JavacState will clean out all artifacts
+            // that do not match the javac_state database.
+            javac_state.findAllArtifacts();
+
+            // Remove unidentified artifacts from the bin, gensrc and header dirs.
+            // (Unless we allow them to be there.)
+            // I.e. artifacts that are not known according to the build database (javac_state).
+            // For examples, files that have been manually copied into these dirs.
+            // Artifacts with bad timestamps (ie the on disk timestamp does not match the timestamp
+            // in javac_state) have already been removed when the javac_state was loaded.
+            if (!findBooleanOption(args, "--permit-unidentified-artifacts")) {
+                javac_state.removeUnidentifiedArtifacts();
+            }
+            // Go through all sources and taint all packages that miss artifacts.
+            javac_state.taintPackagesThatMissArtifacts();
+
+            // Now clean out all known artifacts belonging to tainted packages.
+            javac_state.deleteClassArtifactsInTaintedPackages();
+            // Copy files, for example property files, images files, xml files etc etc.
+            javac_state.performCopying(bin_dir, suffix_rules);
+            // Translate files, for example compile properties or compile idls.
+            javac_state.performTranslation(gensrc_dir, suffix_rules);
+            // Add any potentially generated java sources to the tobe compiled list.
+            // (Generated sources must always have a package.)
+            Map<String,Source> generated_sources = new HashMap<String,Source>();
+            Source.scanRoot(gensrc_dir, Util.set(".java"), null, null, null, null,
+                   generated_sources, modules, current_module, false, true, false);
+            javac_state.now().collectPackagesSourcesAndArtifacts(modules);
+            // Recheck the the source files and their timestamps again.
+            javac_state.checkSourceStatus(true);
+
+            // Now do a safety check that the list of source files is identical
+            // to the list Make believes we are compiling. If we do not get this
+            // right, then incremental builds will fail with subtility.
+            // If any difference is detected, then we will fail hard here.
+            // This is an important safety net.
+            javac_state.compareWithMakefileList(makefile_source_list);
+
+            // Do the compilations, repeatedly until no tainted packages exist.
+            boolean again;
+            // Collect the name of all compiled packages.
+            Set<String> recently_compiled = new HashSet<String>();
+            boolean[] rc = new boolean[1];
+            do {
+                // Clean out artifacts in tainted packages.
+                javac_state.deleteClassArtifactsInTaintedPackages();
+                again = javac_state.performJavaCompilations(bin_dir, server_settings, args, recently_compiled, rc);
+                if (!rc[0]) break;
+            } while (again);
+            // Only update the state if the compile went well.
+            if (rc[0]) {
+                javac_state.save();
+                // Collect all the artifacts.
+                javac_state.now().collectArtifacts(modules);
+                // Remove artifacts that were generated during the last compile, but not this one.
+                javac_state.removeSuperfluousArtifacts(recently_compiled);
+            }
+            return rc[0] ? 0 : -1;
+        } catch (ProblemException e) {
+            Log.error(e.getMessage());
+            return -1;
+        } catch (Exception e) {
+            e.printStackTrace(err);
+            return -1;
+        }
+    }
+
+    /**
+     * Are java source files passed on the command line?
+     */
+    private boolean findJavaSourceFiles(String[] args) {
+        String prev = "";
+        for (String s : args) {
+            if (s.endsWith(".java") && !prev.equals("-xf") && !prev.equals("-if")) {
+                return true;
+            }
+            prev = s;
+        }
+        return false;
+    }
+
+    /**
+     * Is an at file passed on the command line?
+     */
+    private boolean findAtFile(String[] args) {
+        for (String s : args) {
+            if (s.startsWith("@")) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Find the log level setting.
+     */
+    private String findLogLevel(String[] args) {
+        for (String s : args) {
+            if (s.startsWith("--log=") && s.length()>6) {
+                return s.substring(6);
+            }
+            if (s.equals("-verbose")) {
+                return "info";
+            }
+        }
+        return "info";
+    }
+
+    /**
+     * Remove smart javac wrapper arguments, before feeding
+     * the args to the plain javac.
+     */
+    static String[] removeWrapperArgs(String[] args) {
+        String[] out = new String[args.length];
+        // The first source path index is remembered
+        // here. So that all following can be concatenated to it.
+        int source_path = -1;
+        // The same for class path.
+        int class_path = -1;
+        // And module path.
+        int module_path = -1;
+        int j = 0;
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-src") ||
+                args[i].equals("-x") ||
+                args[i].equals("-i") ||
+                args[i].equals("-xf") ||
+                args[i].equals("-if") ||
+                args[i].equals("-copy") ||
+                args[i].equals("-tr") ||
+                args[i].equals("-j")) {
+                // Just skip it and skip following value
+                i++;
+            } else if (args[i].startsWith("--server:")) {
+                // Just skip it.
+            } else if (args[i].startsWith("--log=")) {
+                // Just skip it.
+            } else if (args[i].equals("--permit-unidentified-artifacts")) {
+                // Just skip it.
+            } else if (args[i].equals("--permit-sources-without-package")) {
+                // Just skip it.
+            } else if (args[i].equals("--compare-found-sources")) {
+                // Just skip it and skip verify file name
+                i++;
+            } else if (args[i].equals("-sourcepath")) {
+                if (source_path == -1) {
+                    source_path = j;
+                    out[j] = args[i];
+                    out[j+1] = args[i+1];
+                    j+=2;
+                    i++;
+                } else {
+                    // Skip this and its argument, but
+                    // append argument to found sourcepath.
+                    out[source_path+1] = out[source_path+1]+File.pathSeparatorChar+args[i+1];
+                    i++;
+                }
+            } else if (args[i].equals("-classpath") || args[i].equals("-cp")) {
+                if (class_path == -1) {
+                    class_path = j;
+                    out[j] = args[i];
+                    out[j+1] = args[i+1];
+                    j+=2;
+                    i++;
+                } else {
+                    // Skip this and its argument, but
+                    // append argument to found sourcepath.
+                    out[class_path+1] = out[class_path+1]+File.pathSeparatorChar+args[i+1];
+                    i++;
+                }
+            } else if (args[i].equals("-modulepath")) {
+                if (module_path == -1) {
+                    module_path = j;
+                    out[j] = args[i];
+                    out[j+1] = args[i+1];
+                    j+=2;
+                    i++;
+                } else {
+                    // Skip this and its argument, but
+                    // append argument to found sourcepath.
+                    out[module_path+1] = out[module_path+1]+File.pathSeparatorChar+args[i+1];
+                    i++;
+                }
+             } else {
+                // Copy argument.
+                out[j] = args[i];
+                j++;
+            }
+        }
+        String[] ret = new String[j];
+        System.arraycopy(out, 0, ret, 0, j);
+        return ret;
+    }
+
+    /**
+     * Make sure directory exist, create it if not.
+     */
+    private static boolean makeSureExists(File dir) {
+        // Make sure the dest directories exist.
+        if (!dir.exists()) {
+            if (!dir.mkdirs()) {
+                Log.error("Could not create the directory "+dir.getPath());
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Verify that a package pattern is valid.
+     */
+    private static void checkPattern(String s) throws ProblemException {
+        // Package names like foo.bar.gamma are allowed, and
+        // package names suffixed with .* like foo.bar.* are
+        // also allowed.
+        Pattern p = Pattern.compile("[a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*(\\.\\*)?+");
+        Matcher m = p.matcher(s);
+        if (!m.matches()) {
+            throw new ProblemException("The string \""+s+"\" is not a proper package name pattern.");
+        }
+    }
+
+    /**
+     * Verify that a translate pattern is valid.
+     */
+    private static void checkTranslatePattern(String s) throws ProblemException {
+        // .prop=com.sun.tools.javac.smart.CompileProperties
+        // .idl=com.sun.corba.CompileIdl
+        // .g3=antlr.CompileGrammar,debug=true
+        Pattern p = Pattern.compile(
+            "\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*=[a-z_]{1}[a-z0-9_]*(\\.[a-z_]{1}[a-z0-9_]*)*"+
+            "(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)(,.*)?");
+        Matcher m = p.matcher(s);
+        if (!m.matches()) {
+            throw new ProblemException("The string \""+s+"\" is not a proper translate pattern.");
+        }
+    }
+
+    /**
+     * Verify that a copy pattern is valid.
+     */
+    private static void checkCopyPattern(String s) throws ProblemException {
+        // .gif
+        // .html
+        Pattern p = Pattern.compile(
+            "\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*");
+        Matcher m = p.matcher(s);
+        if (!m.matches()) {
+            throw new ProblemException("The string \""+s+"\" is not a proper suffix.");
+        }
+    }
+
+    /**
+     * Verify that a source file name is valid.
+     */
+    private static void checkFilePattern(String s) throws ProblemException {
+        // File names like foo/bar/gamma/Bar.java are allowed,
+        // as well as /bar/jndi.properties as well as,
+        // */bar/Foo.java
+        Pattern p = null;
+        if (File.separatorChar == '\\') {
+            p = Pattern.compile("\\*?(.+\\\\)*.+");
+        }
+        else if (File.separatorChar == '/') {
+            p = Pattern.compile("\\*?(.+/)*.+");
+        } else {
+            throw new ProblemException("This platform uses the unsupported "+File.separatorChar+
+                                      " as file separator character. Please add support for it!");
+        }
+        Matcher m = p.matcher(s);
+        if (!m.matches()) {
+            throw new ProblemException("The string \""+s+"\" is not a proper file name.");
+        }
+    }
+
+    /**
+     * Scan the arguments to find an option is used.
+     */
+    private static boolean hasOption(String[] args, String option) {
+        for (String a : args) {
+            if (a.equals(option)) return true;
+        }
+        return false;
+    }
+
+    /**
+     * Check if -implicit is supplied, if so check that it is none.
+     * If -implicit is not supplied, supply -implicit:none
+     * Only implicit:none is allowed because otherwise the multicore compilations
+     * and dependency tracking will be tangled up.
+     */
+    private static String[] verifyImplicitOption(String[] args)
+        throws ProblemException {
+
+        boolean foundImplicit = false;
+        for (String a : args) {
+            if (a.startsWith("-implicit:")) {
+                foundImplicit = true;
+                if (!a.equals("-implicit:none")) {
+                    throw new ProblemException("The only allowed setting for sjavac is -implicit:none, it is also the default.");
+                }
+            }
+        }
+        if (foundImplicit) {
+            return args;
+        }
+        // -implicit:none not found lets add it.
+        String[] newargs = new String[args.length+1];
+        System.arraycopy(args,0, newargs, 0, args.length);
+        newargs[args.length] = "-implicit:none";
+        return newargs;
+    }
+
+    /**
+     * Rewrite a single option into something else.
+     */
+    private static void rewriteOptions(String[] args, String option, String new_option) {
+        for (int i=0; i<args.length; ++i) {
+            if (args[i].equals(option)) {
+                args[i] = new_option;
+            }
+        }
+    }
+
+    /**
+     * Scan the arguments to find an option that specifies a directory.
+     * Create the directory if necessary.
+     */
+    private static File findDirectoryOption(String[] args, String option, String name, boolean needed, boolean allow_dups, boolean create)
+        throws ProblemException, ProblemException {
+        File dir = null;
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals(option)) {
+                if (dir != null) {
+                    throw new ProblemException("You have already specified the "+name+" dir!");
+                }
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a directory following "+option+".");
+                }
+                if (args[i+1].indexOf(File.pathSeparatorChar) != -1) {
+                    throw new ProblemException("You must only specify a single directory for "+option+".");
+                }
+                dir = new File(args[i+1]);
+                if (!dir.exists()) {
+                    if (!create) {
+                         throw new ProblemException("This directory does not exist: "+dir.getPath());
+                    } else
+                    if (!makeSureExists(dir)) {
+                        throw new ProblemException("Cannot create directory "+dir.getPath());
+                    }
+                }
+                if (!dir.isDirectory()) {
+                    throw new ProblemException("\""+args[i+1]+"\" is not a directory.");
+                }
+            }
+        }
+        if (dir == null && needed) {
+            throw new ProblemException("You have to specify "+option);
+        }
+        try {
+            if (dir != null)
+                return dir.getCanonicalFile();
+        } catch (IOException e) {
+            throw new ProblemException(""+e);
+        }
+        return null;
+    }
+
+    /**
+     * Option is followed by path.
+     */
+    private static boolean shouldBeFollowedByPath(String o) {
+        return o.equals("-s") ||
+               o.equals("-h") ||
+               o.equals("-d") ||
+               o.equals("-sourcepath") ||
+               o.equals("-classpath") ||
+               o.equals("-cp") ||
+               o.equals("-bootclasspath") ||
+               o.equals("-src");
+    }
+
+    /**
+     * Add -src before source root directories if not already there.
+     */
+    private static String[] addSrcBeforeDirectories(String[] args) {
+        List<String> newargs = new ArrayList<String>();
+        for (int i = 0; i<args.length; ++i) {
+            File dir = new File(args[i]);
+            if (dir.exists() && dir.isDirectory()) {
+                if (i == 0 || !shouldBeFollowedByPath(args[i-1])) {
+                    newargs.add("-src");
+                }
+            }
+            newargs.add(args[i]);
+        }
+        return newargs.toArray(new String[0]);
+    }
+
+    /**
+     * Check the -src options.
+     */
+    private static void checkSrcOption(String[] args)
+        throws ProblemException {
+        Set<File> dirs = new HashSet<File>();
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-src")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a directory following -src.");
+                }
+                StringTokenizer st = new StringTokenizer(args[i+1], File.pathSeparator);
+                while (st.hasMoreElements()) {
+                    File dir = new File(st.nextToken());
+                    if (!dir.exists()) {
+                        throw new ProblemException("This directory does not exist: "+dir.getPath());
+                    }
+                    if (!dir.isDirectory()) {
+                        throw new ProblemException("\""+dir.getPath()+"\" is not a directory.");
+                    }
+                    if (dirs.contains(dir)) {
+                        throw new ProblemException("The src directory \""+dir.getPath()+"\" is specified more than once!");
+                    }
+                    dirs.add(dir);
+                }
+            }
+        }
+        if (dirs.isEmpty()) {
+            throw new ProblemException("You have to specify -src.");
+        }
+    }
+
+    /**
+     * Scan the arguments to find an option that specifies a file.
+     */
+    private static File findFileOption(String[] args, String option, String name, boolean needed)
+        throws ProblemException, ProblemException {
+        File file = null;
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals(option)) {
+                if (file != null) {
+                    throw new ProblemException("You have already specified the "+name+" file!");
+                }
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a file following "+option+".");
+                }
+                file = new File(args[i+1]);
+                if (file.isDirectory()) {
+                    throw new ProblemException("\""+args[i+1]+"\" is not a file.");
+                }
+                if (!file.exists() && needed) {
+                    throw new ProblemException("The file \""+args[i+1]+"\" does not exist.");
+                }
+
+            }
+        }
+        if (file == null && needed) {
+            throw new ProblemException("You have to specify "+option);
+        }
+        return file;
+    }
+
+    /**
+     * Look for a specific switch, return true if found.
+     */
+    public static boolean findBooleanOption(String[] args, String option) {
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals(option)) return true;
+        }
+        return false;
+    }
+
+    /**
+     * Scan the arguments to find an option that specifies a number.
+     */
+    public static int findNumberOption(String[] args, String option) {
+        int rc = 0;
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals(option)) {
+                if (args.length > i+1) {
+                    rc = Integer.parseInt(args[i+1]);
+                }
+            }
+        }
+        return rc;
+    }
+
+    /**
+     * Scan the arguments to find the option (-tr) that setup translation rules to java source
+     * from different sources. For example: .properties are translated using CompileProperties
+     * The found translators are stored as suffix rules.
+     */
+    private static void findTranslateOptions(String[] args, Map<String,Transformer> suffix_rules)
+        throws ProblemException, ProblemException {
+
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-tr")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a translate rule following -tr.");
+                }
+                String s = args[i+1];
+                checkTranslatePattern(s);
+                int ep = s.indexOf("=");
+                String suffix = s.substring(0,ep);
+                String classname = s.substring(ep+1);
+                if (suffix_rules.get(suffix) != null) {
+                    throw new ProblemException("You have already specified a "+
+                                              "rule for the suffix "+suffix);
+                }
+                if (s.equals(".class")) {
+                    throw new ProblemException("You cannot have a translator for .class files!");
+                }
+                if (s.equals(".java")) {
+                    throw new ProblemException("You cannot have a translator for .java files!");
+                }
+                String extra = null;
+                int exp = classname.indexOf(",");
+                if (exp != -1) {
+                    extra = classname.substring(exp+1);
+                    classname = classname.substring(0,exp);
+                }
+                try {
+                    Class<?> cl = Class.forName(classname);
+                    Transformer t = (Transformer)cl.newInstance();
+                    t.setExtra(extra);
+                    suffix_rules.put(suffix, t);
+                }
+                catch (Exception e) {
+                    throw new ProblemException("Cannot use "+classname+" as a translator!");
+                }
+            }
+        }
+    }
+
+    /**
+     * Scan the arguments to find the option (-copy) that setup copying rules into the bin dir.
+     * For example: -copy .html
+     * The found copiers are stored as suffix rules as well. No translation is done, just copying.
+     */
+    private void findCopyOptions(String[] args, Map<String,Transformer> suffix_rules)
+        throws ProblemException, ProblemException {
+
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-copy")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a translate rule following -tr.");
+                }
+                String s = args[i+1];
+                checkCopyPattern(s);
+                if (suffix_rules.get(s) != null) {
+                    throw new ProblemException("You have already specified a "+
+                                              "rule for the suffix "+s);
+                }
+                if (s.equals(".class")) {
+                    throw new ProblemException("You cannot have a copy rule for .class files!");
+                }
+                if (s.equals(".java")) {
+                    throw new ProblemException("You cannot have a copy rule for .java files!");
+                }
+                suffix_rules.put(s, javac_state.getCopier());
+            }
+        }
+    }
+
+    /**
+     * Rewrite a / separated path into \ separated, but only
+     * if we are running on a platform were File.separatorChar=='\', ie winapi.
+     */
+    private String fixupSeparator(String p) {
+        if (File.separatorChar == '/') return p;
+        return p.replaceAll("/", "\\\\");
+    }
+
+    /**
+     * Scan the arguments for -i -x -xf -if followed by the option
+     * -src, -sourcepath, -modulepath or -classpath and produce a map of all the
+     * files to referenced for that particular option.
+     *
+     * Store the found sources and the found modules in the supplied maps.
+     */
+    private boolean findFiles(String[] args, String option, Set<String> suffixes,
+                              Map<String,Source> found_files, Map<String, Module> found_modules,
+                              Module current_module, boolean inLinksrc)
+        throws ProblemException, ProblemException
+    {
+        // Track which source roots, source path roots and class path roots have been added.
+        Set<File> roots = new HashSet<File>();
+        // Track the current set of package includes,excludes as well as excluded source files,
+        // to be used in the next -src/-sourcepath/-classpath
+        List<String> includes = new LinkedList<String>();
+        List<String> excludes = new LinkedList<String>();
+        List<String> excludefiles = new LinkedList<String>();
+        List<String> includefiles = new LinkedList<String>();
+        // This include is used to find all modules in the source.
+        List<String> moduleinfo = new LinkedList<String>();
+        moduleinfo.add("module-info.java");
+
+        for (int i = 0; i<args.length; ++i) {
+            if (args[i].equals("-i")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a package pattern following -i");
+                }
+                String incl = args[i+1];
+                checkPattern(incl);
+                includes.add(incl);
+            }
+            if (args[i].equals("-x")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a package pattern following -x");
+                }
+                String excl = args[i+1];
+                checkPattern(excl);
+                excludes.add(excl);
+            }
+            if (args[i].equals("-xf")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a file following -xf");
+                }
+                String exclf = args[i+1];
+                checkFilePattern(exclf);
+                exclf = Util.normalizeDriveLetter(exclf);
+                excludefiles.add(fixupSeparator(exclf));
+            }
+            if (args[i].equals("-if")) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a file following -xf");
+                }
+                String inclf = args[i+1];
+                checkFilePattern(inclf);
+                inclf = Util.normalizeDriveLetter(inclf);
+                includefiles.add(fixupSeparator(inclf));
+            }
+            if (args[i].equals(option)) {
+                if (i+1 >= args.length) {
+                    throw new ProblemException("You have to specify a directory following "+option);
+                }
+                String[] root_dirs = args[i+1].split(File.pathSeparator);
+                for (String r : root_dirs) {
+                    File root = new File(r);
+                    if (!root.isDirectory()) {
+                        throw new ProblemException("\""+r+"\" is not a directory.");
+                    }
+                    try {
+                        root = root.getCanonicalFile();
+                    } catch (IOException e) {
+                        throw new ProblemException(""+e);
+                    }
+                    if (roots.contains(root)) {
+                        throw new ProblemException("\""+r+"\" has already been used for "+option);
+                    }
+                    if (root.equals(bin_dir)) {
+                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -d");
+                    }
+                    if (root.equals(gensrc_dir)) {
+                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -s");
+                    }
+                    if (root.equals(header_dir)) {
+                        throw new ProblemException("\""+r+"\" cannot be used both for "+option+" and -h");
+                    }
+                    roots.add(root);
+                    Source.scanRoot(root, suffixes, excludes, includes, excludefiles, includefiles,
+                                    found_files, found_modules, current_module,
+                                    findBooleanOption(args, "--permit-sources-without-package"),
+                                    false, inLinksrc);
+                }
+            }
+            if (args[i].equals("-src") ||
+                args[i].equals("-sourcepath") ||
+                args[i].equals("-modulepath") ||
+                args[i].equals("-classpath") ||
+                args[i].equals("-cp"))
+            {
+                // Reset the includes,excludes and excludefiles after they have been used.
+                includes = new LinkedList<String>();
+                excludes = new LinkedList<String>();
+                excludefiles = new LinkedList<String>();
+                includefiles = new LinkedList<String>();
+            }
+        }
+        return true;
+    }
+
+}
+
diff --git a/src/share/classes/com/sun/tools/sjavac/Module.java b/src/share/classes/com/sun/tools/sjavac/Module.java
new file mode 100644
index 0000000..db84a40
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Module.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.File;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The module is the root of a set of packages/sources/artifacts.
+ * At the moment there is only one module in use, the empty/no-name/default module.
+ *
+ * <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></p>
+ */
+public class Module implements Comparable<Module> {
+    private String name;
+    private String dirname;
+    private Map<String,Package> packages = new HashMap<String,Package>();
+    private Map<String,Source> sources = new HashMap<String,Source>();
+    private Map<String,File> artifacts = new HashMap<String,File>();
+
+    public Module(String n, String dn) {
+        name = n;
+        dirname = n;
+    }
+
+    public String name() { return name; }
+    public String dirname() { return dirname; }
+    public Map<String,Package> packages() { return packages; }
+    public Map<String,Source> sources() { return sources; }
+    public Map<String,File> artifacts() { return artifacts; }
+
+    @Override
+    public boolean equals(Object o) {
+        return (o instanceof Module) && name.equals(((Module)o).name);
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public int compareTo(Module o) {
+        return name.compareTo(o.name);
+    }
+
+    public void save(StringBuilder b) {
+        b.append("M ").append(name).append(":").append("\n");
+        Package.savePackages(packages, b);
+    }
+
+    public static Module load(String l) {
+        int cp = l.indexOf(':',2);
+        if (cp == -1) return null;
+        String name = l.substring(2,cp);
+        return new Module(name, "");
+    }
+
+    public static void saveModules(Map<String,Module> ms, StringBuilder b)
+    {
+        for (Module m : ms.values()) {
+            m.save(b);
+        }
+    }
+
+    public void addPackage(Package p) {
+        packages.put(p.name(), p);
+    }
+
+    public Package lookupPackage(String pkg) {
+        Package p = packages.get(pkg);
+        if (p == null) {
+            p = new Package(this, pkg);
+            packages.put(pkg, p);
+        }
+        return p;
+    }
+
+    public void addSource(String pkg, Source src) {
+        Package p = lookupPackage(pkg);
+        src.setPackage(p);
+        p.addSource(src);
+        sources.put(src.file().getPath(), src);
+    }
+
+    public Source lookupSource(String path) {
+        return sources.get(path);
+    }
+
+    public void addArtifacts(String pkg, Set<URI> as) {
+        Package p = lookupPackage(pkg);
+        for (URI u : as) {
+            p.addArtifact(new File(u));
+        }
+    }
+
+    public void setDependencies(String pkg, Set<String> deps) {
+        Package p = lookupPackage(pkg);
+        p.setDependencies(deps);
+    }
+
+    public void setPubapi(String pkg, List<String> ps) {
+        Package p = lookupPackage(pkg);
+        p.setPubapi(ps);
+    }
+
+    public boolean hasPubapiChanged(String pkg, List<String> ps) {
+        Package p = lookupPackage(pkg);
+        return p.hasPubapiChanged(ps);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Package.java b/src/share/classes/com/sun/tools/sjavac/Package.java
new file mode 100644
index 0000000..9305485
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Package.java
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The Package class maintains meta information about a package.
+ * For example its sources, dependents,its pubapi and its artifacts.
+ *
+ * It might look odd that we track dependents/pubapi/artifacts on
+ * a package level, but it makes sense since recompiling a full package
+ * takes as long as recompiling a single java file in that package,
+ * if you take into account the startup time of the jvm.
+ *
+ * Also the dependency information will be much smaller (good for the javac_state file size)
+ * and it simplifies tracking artifact generation, you do not always know from which
+ * source a class file was generated, but you always know which package it belongs to.
+ *
+ * It is also educational to see package dependencies triggering recompilation of
+ * other packages. Even though the recompilation was perhaps not necessary,
+ * the visible recompilation of the dependent packages indicates how much circular
+ * dependencies your code has.
+ *
+ * <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></p>
+ */
+public class Package implements Comparable<Package> {
+    // The module this package belongs to. (There is a legacy module with an empty string name,
+    // used for all legacy sources.)
+    private Module mod;
+    // Name of this package, module:pkg
+    // ex1 jdk.base:java.lang
+    // ex2 :java.lang (when in legacy mode)
+    private String name;
+    // The directory path to the package. If the package belongs to a module,
+    // then that module's file system name is part of the path.
+    private String dirname;
+    // This package depends on these packages.
+    private Set<String> dependencies = new HashSet<String>();
+    // This package has the following dependents, that depend on this package.
+    private Set<String> dependents = new HashSet<String>();
+    // This is the public api of this package.
+    private List<String> pubapi = new ArrayList<String>();
+    // Map from source file name to Source info object.
+    private Map<String,Source> sources = new HashMap<String,Source>();
+    // This package generated these artifacts.
+    private Map<String,File> artifacts = new HashMap<String,File>();
+
+    public Package(Module m, String n) {
+        int c = n.indexOf(":");
+        assert(c != -1);
+        String mn = n.substring(0,c);
+        assert(m.name().equals(m.name()));
+        name = n;
+        dirname = n.replace('.', File.separatorChar);
+        if (m.name().length() > 0) {
+            // There is a module here, prefix the module dir name to the path.
+            dirname = m.dirname()+File.separatorChar+dirname;
+        }
+    }
+
+    public Module mod() { return mod; }
+    public String name() { return name; }
+    public String dirname() { return dirname; }
+    public Map<String,Source> sources() { return sources; }
+    public Map<String,File> artifacts() { return artifacts; }
+    public List<String> pubapi() { return pubapi; }
+
+    public Set<String> dependencies() { return dependencies; }
+    public Set<String> dependents() { return dependents; }
+
+    @Override
+    public boolean equals(Object o) {
+        return (o instanceof Package) && name.equals(((Package)o).name);
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public int compareTo(Package o) {
+        return name.compareTo(o.name);
+    }
+
+    public void addSource(Source s) {
+        sources.put(s.file().getPath(), s);
+    }
+
+    public void addDependency(String d) {
+        dependencies.add(d);
+    }
+
+    public void addDependent(String d) {
+        dependents.add(d);
+    }
+
+    public void addPubapi(String p) {
+        pubapi.add(p);
+    }
+
+    /**
+     * Check if we have knowledge in the javac state that
+     * describe the results of compiling this package before.
+     */
+    public boolean existsInJavacState() {
+        return artifacts.size() > 0 || pubapi.size() > 0;
+    }
+
+    public static List<String> pubapiToList(String ps)
+    {
+        String[] lines = ps.split("\n");
+        List<String> r = new ArrayList<String>();
+        for (String l : lines) {
+            r.add(l);
+        }
+        return r;
+    }
+
+    public boolean hasPubapiChanged(List<String> ps) {
+        Iterator<String> i = ps.iterator();
+        Iterator<String> j = pubapi.iterator();
+        int line = 0;
+        while (i.hasNext() && j.hasNext()) {
+            String is = i.next();
+            String js = j.next();
+            if (!is.equals(js)) {
+                Log.debug("Change in pubapi for package "+name+" line "+line);
+                Log.debug("Old: "+js);
+                Log.debug("New: "+is);
+                return true;
+            }
+            line++;
+        }
+        if ((i.hasNext() && !j.hasNext() ) ||
+            (!i.hasNext() && j.hasNext())) {
+            Log.debug("Change in pubapi for package "+name);
+            if (i.hasNext()) {
+                Log.debug("New has more lines!");
+            } else {
+                Log.debug("Old has more lines!");
+            }
+            return true;
+        }
+        return false;
+    }
+
+    public void setPubapi(List<String> ps) {
+        pubapi = ps;
+    }
+
+    public void setDependencies(Set<String> ds) {
+        dependencies = ds;
+    }
+
+    public void save(StringBuilder b) {
+        b.append("P ").append(name).append("\n");
+        Source.saveSources(sources, b);
+        saveDependencies(b);
+        savePubapi(b);
+        saveArtifacts(b);
+    }
+
+    static public Package load(Module module, String l) {
+        String name = l.substring(2);
+        return new Package(module, name);
+    }
+
+    public void loadDependency(String l) {
+        String n = l.substring(2);
+        addDependency(n);
+    }
+
+    public void loadPubapi(String l) {
+        String pi = l.substring(2);
+        addPubapi(pi);
+    }
+
+    public void saveDependencies(StringBuilder b) {
+        List<String> sorted_dependencies = new ArrayList<String>();
+        for (String key : dependencies) {
+            sorted_dependencies.add(key);
+        }
+        Collections.sort(sorted_dependencies);
+        for (String a : sorted_dependencies) {
+            b.append("D "+a+"\n");
+        }
+    }
+
+    public void savePubapi(StringBuilder b) {
+        for (String l : pubapi) {
+            b.append("I "+l+"\n");
+        }
+    }
+
+    public static void savePackages(Map<String,Package> packages, StringBuilder b) {
+        List<String> sorted_packages = new ArrayList<String>();
+        for (String key : packages.keySet() ) {
+            sorted_packages.add(key);
+        }
+        Collections.sort(sorted_packages);
+        for (String s : sorted_packages) {
+            Package p = packages.get(s);
+            p.save(b);
+        }
+    }
+
+    public void addArtifact(String a) {
+        artifacts.put(a, new File(a));
+    }
+
+    public void addArtifact(File f) {
+        artifacts.put(f.getPath(), f);
+    }
+
+    public void addArtifacts(Set<URI> as) {
+        for (URI u : as) {
+            addArtifact(new File(u));
+        }
+    }
+
+    public void setArtifacts(Set<URI> as) {
+        assert(!artifacts.isEmpty());
+        artifacts = new HashMap<String,File>();
+        addArtifacts(as);
+    }
+
+    public void loadArtifact(String l) {
+        // Find next space after "A ".
+        int dp = l.indexOf(' ',2);
+        String fn = l.substring(2,dp);
+        long last_modified = Long.parseLong(l.substring(dp+1));
+        File f = new File(fn);
+        if (f.exists() && f.lastModified() != last_modified) {
+            // Hmm, the artifact on disk does not have the same last modified
+            // timestamp as the information from the build database.
+            // We no longer trust the artifact on disk. Delete it.
+            // The smart javac wrapper will then rebuild the artifact.
+            Log.debug("Removing "+f.getPath()+" since its timestamp does not match javac_state.");
+            f.delete();
+        }
+        artifacts.put(f.getPath(), f);
+    }
+
+    public void saveArtifacts(StringBuilder b) {
+        List<File> sorted_artifacts = new ArrayList<File>();
+        for (File f : artifacts.values()) {
+            sorted_artifacts.add(f);
+        }
+        Collections.sort(sorted_artifacts);
+        for (File f : sorted_artifacts) {
+            // The last modified information is only used
+            // to detect tampering with the output dir.
+            // If the outputdir has been modified, not by javac,
+            // then a mismatch will be detected in the last modified
+            // timestamps stored in the build database compared
+            // to the timestamps on disk and the artifact will be deleted.
+
+            b.append("A "+f.getPath()+" "+f.lastModified()+"\n");
+        }
+    }
+
+    /**
+     * Always clean out a tainted package before it is recompiled.
+     */
+    public void deleteArtifacts() {
+        for (File a : artifacts.values()) {
+            a.delete();
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/ProblemException.java b/src/share/classes/com/sun/tools/sjavac/ProblemException.java
new file mode 100644
index 0000000..53f7016
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/ProblemException.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+/**
+ * Used to signal serious problems when running sjavac.
+ *
+ * <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></p>
+ */
+public class ProblemException extends Exception {
+    static final long serialVersionUID = -3387516993124229949L;
+    public ProblemException(String s) {
+        super(s);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Source.java b/src/share/classes/com/sun/tools/sjavac/Source.java
new file mode 100644
index 0000000..927bbf1
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Source.java
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.File;
+import java.util.Set;
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+
+/** A Source object maintains information about a source file.
+ * For example which package it belongs to and kind of source it is.
+ * The class also knows how to find source files (scanRoot) given include/exclude
+ * patterns and a root.
+ *
+ * <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></p>
+ */
+public class Source implements Comparable<Source> {
+    // The package the source belongs to.
+   private Package pkg;
+    // Name of this source file, relative its source root.
+    // For example: java/lang/Object.java
+    // Or if the source file is inside a module:
+    // jdk.base/java/lang/Object.java
+    private String name;
+    // What kind of file is this.
+    private String suffix;
+    // When this source file was last_modified
+    private long lastModified;
+    // The source File.
+    private File file;
+    // The source root under which file resides.
+    private File root;
+    // If the source is generated.
+    private boolean isGenerated;
+    // If the source is only linked to, not compiled.
+    private boolean linkedOnly;
+
+    @Override
+    public boolean equals(Object o) {
+        return (o instanceof Source) && name.equals(((Source)o).name);
+    }
+
+    @Override
+    public int compareTo(Source o) {
+        return name.compareTo(o.name);
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    public Source(Module m, String n, File f, File r) {
+        name = n;
+        int dp = n.lastIndexOf(".");
+        if (dp != -1) {
+            suffix = n.substring(dp);
+        } else {
+            suffix = "";
+        }
+        file = f;
+        root = r;
+        lastModified = f.lastModified();
+        linkedOnly = false;
+    }
+
+    public Source(Package p, String n, long lm) {
+        pkg = p;
+        name = n;
+        int dp = n.lastIndexOf(".");
+        if (dp != -1) {
+            suffix = n.substring(dp);
+        } else {
+            suffix = "";
+        }
+        file = null;
+        root = null;
+        lastModified = lm;
+        linkedOnly = false;
+        int ls = n.lastIndexOf('/');
+    }
+
+    public String name() { return name; }
+    public String suffix() { return suffix; }
+    public Package pkg() { return pkg; }
+    public File   file() { return file; }
+    public File   root() { return root; }
+    public long lastModified() {
+        return lastModified;
+    }
+
+    public void setPackage(Package p) {
+        pkg = p;
+    }
+
+    public void markAsGenerated() {
+        isGenerated = true;
+    }
+
+    public boolean isGenerated() {
+        return isGenerated;
+    }
+
+    public void markAsLinkedOnly() {
+        linkedOnly = true;
+    }
+
+    public boolean isLinkedOnly() {
+        return linkedOnly;
+    }
+
+    private void save(StringBuilder b) {
+        String CL = linkedOnly?"L":"C";
+        String GS = isGenerated?"G":"S";
+        b.append(GS+" "+CL+" "+name+" "+file.lastModified()+"\n");
+    }
+    // Parse a line that looks like this:
+    // S C /code/alfa/A.java 1357631228000
+    static public Source load(Package lastPackage, String l, boolean isGenerated) {
+        int sp = l.indexOf(' ',4);
+        if (sp == -1) return null;
+        String name = l.substring(4,sp);
+        long last_modified = Long.parseLong(l.substring(sp+1));
+
+        boolean isLinkedOnly = false;
+        if (l.charAt(2) == 'L') {
+            isLinkedOnly = true;
+        } else if (l.charAt(2) == 'C') {
+            isLinkedOnly = false;
+        } else return null;
+
+        Source s = new Source(lastPackage, name, last_modified);
+        s.file = new File(name);
+        if (isGenerated) s.markAsGenerated();
+        if (isLinkedOnly) s.markAsLinkedOnly();
+        return s;
+    }
+
+    public static void saveSources(Map<String,Source> sources, StringBuilder b) {
+        List<String> sorted_sources = new ArrayList<String>();
+        for (String key : sources.keySet()) {
+            sorted_sources.add(key);
+        }
+        Collections.sort(sorted_sources);
+        for (String key : sorted_sources) {
+            Source s = sources.get(key);
+            s.save(b);
+        }
+    }
+
+    /**
+     * Recurse into the directory root and find all files matchine the excl/incl/exclfiles/inclfiles rules.
+     * Detects the existence of module-info.java files and presumes that the directory it resides in
+     * is the name of the current module.
+     */
+    static public void scanRoot(File root,
+                                Set<String> suffixes,
+                                List<String> excludes, List<String> includes,
+                                List<String> excludeFiles, List<String> includeFiles,
+                                Map<String,Source> foundFiles,
+                                Map<String,Module> foundModules,
+                                Module currentModule,
+                                boolean permitSourcesWithoutPackage,
+                                boolean inGensrc,
+                                boolean inLinksrc)
+        throws ProblemException {
+
+        if (root == null) return;
+        int root_prefix = root.getPath().length()+1;
+        // This is the root source directory, it must not contain any Java sources files
+        // because we do not allow Java source files without a package.
+        // (Unless of course --permit-sources-without-package has been specified.)
+        // It might contain other source files however, (for -tr and -copy) these will
+        // always be included, since no package pattern can match the root directory.
+        currentModule = addFilesInDir(root, root_prefix, root, suffixes, permitSourcesWithoutPackage,
+                                       excludeFiles, includeFiles, false,
+                                       foundFiles, foundModules, currentModule,
+                                       inGensrc, inLinksrc);
+
+        File[] dirfiles = root.listFiles();
+        for (File d : dirfiles) {
+            if (d.isDirectory()) {
+                // Descend into the directory structure.
+                scanDirectory(d, root_prefix, root, suffixes,
+                              excludes, includes, excludeFiles, includeFiles,
+                              false, foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
+            }
+        }
+    }
+
+    /**
+     * Test if a path matches any of the patterns given.
+     * The pattern foo.bar matches only foo.bar
+     * The pattern foo.* matches foo.bar and foo.bar.zoo etc
+     */
+    static private boolean hasMatch(String path, List<String> patterns) {
+        for (String p : patterns) {
+            // Exact match
+            if (p.equals(path)) {
+                return true;
+            }
+            // Single dot the end matches this package and all its subpackages.
+            if (p.endsWith(".*")) {
+                // Remove the wildcard
+                String patprefix = p.substring(0,p.length()-2);
+                // Does the path start with the pattern prefix?
+                if (path.startsWith(patprefix)) {
+                    // If the path has the same length as the pattern prefix, then it is a match.
+                    // If the path is longer, then make sure that
+                    // the next part of the path starts with a dot (.) to prevent
+                    // wildcard matching in the middle of a package name.
+                    if (path.length()==patprefix.length() || path.charAt(patprefix.length())=='.') {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Matches patterns with the asterisk first. */
+     // The pattern foo/bar.java only matches foo/bar.java
+     // The pattern */bar.java matches foo/bar.java and zoo/bar.java etc
+    static private boolean hasFileMatch(String path, List<String> patterns) {
+        path = Util.normalizeDriveLetter(path);
+        for (String p : patterns) {
+            // Exact match
+            if (p.equals(path)) {
+                return true;
+            }
+            // Single dot the end matches this package and all its subpackages.
+            if (p.startsWith("*")) {
+                // Remove the wildcard
+                String patsuffix = p.substring(1);
+                // Does the path start with the pattern prefix?
+                if (path.endsWith(patsuffix)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Add the files in the directory, assuming that the file has not been excluded.
+     * Returns a fresh Module object, if this was a dir with a module-info.java file.
+     */
+    static private Module addFilesInDir(File dir, int rootPrefix, File root,
+                                        Set<String> suffixes, boolean allow_javas,
+                                        List<String> excludeFiles, List<String> includeFiles, boolean all,
+                                        Map<String,Source> foundFiles,
+                                        Map<String,Module> foundModules,
+                                        Module currentModule,
+                                        boolean inGensrc,
+                                        boolean inLinksrc)
+        throws ProblemException
+    {
+        for (File f : dir.listFiles()) {
+            if (f.isFile()) {
+                boolean should_add =
+                    (excludeFiles == null || excludeFiles.isEmpty() || !hasFileMatch(f.getPath(), excludeFiles))
+                    && (includeFiles == null || includeFiles.isEmpty() || hasFileMatch(f.getPath(), includeFiles));
+
+                if (should_add) {
+                    if (!allow_javas && f.getName().endsWith(".java")) {
+                        throw new ProblemException("No .java files are allowed in the source root "+dir.getPath()+
+                                                   ", please remove "+f.getName());
+                    }
+                    // Extract the file name relative the root.
+                    String fn = f.getPath().substring(rootPrefix);
+                    // Extract the package name.
+                    int sp = fn.lastIndexOf(File.separatorChar);
+                    String pkg = "";
+                    if (sp != -1) {
+                        pkg = fn.substring(0,sp).replace(File.separatorChar,'.');
+                    }
+                    // Is this a module-info.java file?
+                    if (fn.endsWith("module-info.java")) {
+                        // Aha! We have recursed into a module!
+                        if (!currentModule.name().equals("")) {
+                            throw new ProblemException("You have an extra module-info.java inside a module! Please remove "+fn);
+                        }
+                        String module_name = fn.substring(0,fn.length()-16);
+                        currentModule = new Module(module_name, f.getPath());
+                        foundModules.put(module_name, currentModule);
+                    }
+                    // Extract the suffix.
+                    int dp = fn.lastIndexOf(".");
+                    String suffix = "";
+                    if (dp > 0) {
+                        suffix = fn.substring(dp);
+                    }
+                    // Should the file be added?
+                    if (all || suffixes.contains(suffix)) {
+                        Source of = foundFiles.get(f.getPath());
+                        if (of != null) {
+                            throw new ProblemException("You have already added the file "+fn+" from "+of.file().getPath());
+                        }
+                        of = currentModule.lookupSource(f.getPath());
+                        if (of != null) {
+                            // Oups, the source is already added, could be ok, could be not, lets check.
+                            if (inLinksrc) {
+                                // So we are collecting sources for linking only.
+                                if (of.isLinkedOnly()) {
+                                    // Ouch, this one is also for linking only. Bad.
+                                    throw new ProblemException("You have already added the link only file "+fn+" from "+of.file().getPath());
+                                }
+                                // Ok, the existing source is to be compiled. Thus this link only is redundant
+                                // since all compiled are also linked to. Continue to the next source.
+                                // But we need to add the source, so that it will be visible to linking,
+                                // if not the multi core compile will fail because a JavaCompiler cannot
+                                // find the necessary dependencies for its part of the source.
+                                foundFiles.put(f.getPath(), of);
+                                continue;
+                            } else {
+                                // We are looking for sources to compile, if we find an existing to be compiled
+                                // source with the same name, it is an internal error, since we must
+                                // find the sources to be compiled before we find the sources to be linked to.
+                                throw new ProblemException("Internal error: Double add of file "+fn+" from "+of.file().getPath());
+                            }
+                        }
+                        Source s = new Source(currentModule, f.getPath(), f, root);
+                        if (inGensrc) s.markAsGenerated();
+                        if (inLinksrc) {
+                            s.markAsLinkedOnly();
+                        }
+                        pkg = currentModule.name()+":"+pkg;
+                        foundFiles.put(f.getPath(), s);
+                        currentModule.addSource(pkg, s);
+                    }
+                }
+            }
+        }
+        return currentModule;
+    }
+
+    private static boolean gurka = false;
+
+    static private void scanDirectory(File dir, int rootPrefix, File root,
+                                      Set<String> suffixes,
+                                      List<String> excludes, List<String> includes,
+                                      List<String> excludeFiles, List<String> includeFiles, boolean all,
+                                      Map<String,Source> foundFiles,
+                                      Map<String,Module> foundModules,
+                                      Module currentModule, boolean inGensrc, boolean inLinksrc)
+        throws ProblemException {
+
+        String pkg_name = "";
+        // Remove the root prefix from the dir path, and replace file separator with dots
+        // to get the package name.
+        if (dir.getPath().length() > rootPrefix) {
+            pkg_name = dir.getPath().substring(rootPrefix).replace(File.separatorChar,'.');
+        }
+        // Should this package directory be included and not excluded?
+        if (all || ((includes==null || includes.isEmpty() || hasMatch(pkg_name, includes)) &&
+                    (excludes==null || excludes.isEmpty() || !hasMatch(pkg_name, excludes)))) {
+            // Add the source files.
+            currentModule = addFilesInDir(dir, rootPrefix, root, suffixes, true, excludeFiles, includeFiles, all,
+                                          foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
+        }
+
+        for (File d : dir.listFiles()) {
+            if (d.isDirectory()) {
+                // Descend into the directory structure.
+                scanDirectory(d, rootPrefix, root, suffixes,
+                              excludes, includes, excludeFiles, includeFiles, all,
+                              foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
+            }
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Transformer.java b/src/share/classes/com/sun/tools/sjavac/Transformer.java
new file mode 100644
index 0000000..4285cdc
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Transformer.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.PrintStream;
+import java.net.URI;
+import java.util.Set;
+import java.util.Map;
+
+/**
+ * The transform interface is used to transform content inside a package, from one form to another.
+ * Usually the output form is an unpredictable number of output files. (eg class files)
+ * but can also be an unpredictable number of generated source files (eg idl2java)
+ * or a single predictable output file (eg when copying,cleaning or compiling a properties file).
+ *
+ * <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></p>
+ */
+public interface Transformer
+{
+    /**
+     * The transform method takes a set of package names, mapped to their source files and to the
+     * pubapis of the packages.
+     *
+     * The transform implementation must:
+     *    store the names of the generated artifacts for each package into package_artifacts
+     *    store found dependencies to other packages into the supplied set package_dependencies
+     *    store the public api for a package into the supplied set package_pubapis
+     *
+     * Any benign messages as a result of running the transform
+     * are written into stdout, and errors are written to stderr.
+     *
+     * The debug_level can be 0=silent (only warnings and errors) 1=normal 2=verbose 3 or greater=debug
+     * setExtra is used to set the extra information information that can be passed on
+     * the command line to the smart javac wrapper.
+     *
+     * If sjavac is building incrementally from an existing javac_state, the var incremental is true.
+     *
+     * The transformer will only be called if some source in the package (or dependency) has
+     * a modified timestamp. Thus the transformer might get called with many sources, of which
+     * only one has changed. The transformer is allowed to regenerate all artifacts but
+     * a better transformer will only write those artifacts that need updating.
+     *
+     * However the transformer must verify that the existing artifacts really are there!
+     * and it must always update package_artifacts, package_dependencies, and package_pubapis correctly.
+     * This means that at least for Java source, it will always have to recompile the sources.
+     *
+     * The transformer is allowed to put files anywhere in the dest_root.
+     * An example of this is, can be the META-INF transformer that copy files
+     * below META-INF directories to the single META-INF directory below dest_root.
+     *
+     * False is returned if there was an error that prevented the transform.
+     * I.e. something was printed on stderr.
+     *
+     * If num_cores is set to a non-zero value. The transform should attempt to use no more than these
+     * number of threads for heavy work.
+     */
+    boolean transform(Map<String,Set<URI>> pkgSrcs,
+                      Set<URI>             visibleSources,
+                      Map<URI,Set<String>> visibleClasses,
+                      Map<String,Set<String>> oldPackageDependencies,
+                      URI destRoot,
+                      Map<String,Set<URI>>    packageArtifacts,
+                      Map<String,Set<String>> packageDependencies,
+                      Map<String,String>      packagePublicApis,
+                      int debugLevel,
+                      boolean incremental,
+                      int numCores,
+                      PrintStream out,
+                      PrintStream err);
+
+    void setExtra(String e);
+    void setExtra(String[] args);
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/Util.java b/src/share/classes/com/sun/tools/sjavac/Util.java
new file mode 100644
index 0000000..1570314
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/Util.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Utilities.
+ *
+ * <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></p>
+ */
+public class Util {
+
+    public static String toFileSystemPath(String pkgId) {
+        if (pkgId == null || pkgId.length()==0) return null;
+        String pn;
+        if (pkgId.charAt(0) == ':') {
+            // When the module is the default empty module.
+            // Do not prepend the module directory, because there is none.
+            // Thus :java.foo.bar translates to java/foo/bar (or \)
+            pn = pkgId.substring(1).replace('.',File.separatorChar);
+        } else {
+            // There is a module. Thus jdk.base:java.foo.bar translates
+            // into jdk.base/java/foo/bar
+            int cp = pkgId.indexOf(':');
+            String mn = pkgId.substring(0,cp);
+            pn = mn+File.separatorChar+pkgId.substring(cp+1).replace('.',File.separatorChar);
+        }
+        return pn;
+    }
+
+    public static String justPackageName(String pkgName) {
+        int c = pkgName.indexOf(":");
+        assert(c != -1);
+        return pkgName.substring(c+1);
+    }
+
+    public static String extractStringOption(String opName, String s) {
+        int p = s.indexOf(opName+"=");
+        if (p == -1) return null;
+        p+=opName.length()+1;
+        int pe = s.indexOf(',', p);
+        if (pe == -1) pe = s.length();
+        return s.substring(p, pe);
+    }
+
+    public static int extractIntOption(String opName, String s) {
+        int p = s.indexOf(opName+"=");
+        if (p == -1) return 0;
+        p+=opName.length()+1;
+        int pe = s.indexOf(',', p);
+        if (pe == -1) pe = s.length();
+        int v = 0;
+        try {
+            v = Integer.parseInt(s.substring(p, pe));
+        } catch (Exception e) {}
+        return v;
+    }
+
+    /**
+     * Clean out unwanted sub options supplied inside a primary option.
+     * For example to only had portfile remaining from:
+     *    settings="--server:id=foo,portfile=bar"
+     * do settings = cleanOptions("--server:",Util.set("-portfile"),settings);
+     *    now settings equals "--server:portfile=bar"
+     *
+     * @param optionPrefix The option name, including colon, eg --server:
+     * @param allowsSubOptions A set of the allowed sub options, id portfile etc.
+     * @param s The option settings string.
+     */
+    public static String cleanSubOptions(String optionPrefix, Set<String> allowedSubOptions, String s) {
+        StringBuilder sb = new StringBuilder();
+        if (!s.startsWith(optionPrefix)) return "";
+        StringTokenizer st = new StringTokenizer(s.substring(optionPrefix.length()), ",");
+        while (st.hasMoreTokens()) {
+            String o = st.nextToken();
+            int p = o.indexOf('=');
+            if (p>0) {
+                String key = o.substring(0,p);
+                String val = o.substring(p+1);
+                if (allowedSubOptions.contains(key)) {
+                    if (sb.length() > 0) sb.append(',');
+                    sb.append(key+"="+val);
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Convenience method to create a set with strings.
+     */
+    public static Set<String> set(String... ss) {
+        Set<String> set = new HashSet<String>();
+        set.addAll(Arrays.asList(ss));
+        return set;
+    }
+
+    /**
+     * Normalize windows drive letter paths to upper case to enable string
+     * comparison.
+     *
+     * @param file File name to normalize
+     * @return The normalized string if file has a drive letter at the beginning,
+     *         otherwise the original string.
+     */
+    public static String normalizeDriveLetter(String file) {
+        if (file.length() > 2 && file.charAt(1) == ':') {
+            return Character.toUpperCase(file.charAt(0)) + file.substring(1);
+        } else if (file.length() > 3 && file.charAt(0) == '*'
+                   && file.charAt(2) == ':') {
+            // Handle a wildcard * at the beginning of the string.
+            return file.substring(0, 1) + Character.toUpperCase(file.charAt(1))
+                   + file.substring(2);
+        }
+        return file;
+    }
+
+    /**
+     * Locate the setting for the server properties.
+     */
+    public static String findServerSettings(String[] args) {
+        for (String s : args) {
+            if (s.startsWith("--server:")) {
+                return s;
+            }
+        }
+        return null;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java b/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java
new file mode 100644
index 0000000..1fc8146
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java
@@ -0,0 +1,185 @@
+/*
+ * 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
+ * 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.sjavac.comp;
+
+import javax.lang.model.element.Element;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Name;
+
+/** Utility class containing dependency information between packages
+ *  and the pubapi for a package.
+ *
+ * <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></p>
+ */
+public class Dependencies {
+    protected static final Context.Key<Dependencies> dependenciesKey =
+        new Context.Key<Dependencies>();
+
+    // The log to be used for error reporting.
+    protected Log log;
+    // Map from package name to packages that the package depends upon.
+    protected Map<Name,Set<Name>> deps;
+    // This is the set of all packages that are supplied
+    // through the java files at the command line.
+    protected Set<Name> explicitPackages;
+
+    // Map from a package name to its public api.
+    // Will the Name encode the module in the future?
+    // If not, this will have to change to map from Module+Name to public api.
+    protected Map<Name,StringBuffer> publicApiPerClass;
+
+    public static Dependencies instance(Context context) {
+        Dependencies instance = context.get(dependenciesKey);
+        if (instance == null)
+            instance = new Dependencies(context);
+        return instance;
+    }
+
+    private Dependencies(Context context) {
+        context.put(dependenciesKey, this);
+        log = Log.instance(context);
+    }
+
+    public void reset()
+    {
+        deps = new HashMap<Name, Set<Name>>();
+        explicitPackages = new HashSet<Name>();
+        publicApiPerClass = new HashMap<Name,StringBuffer>();
+    }
+
+    /**
+     * Fetch the set of dependencies that are relevant to the compile
+     * that has just been performed. I.e. we are only interested in
+     * dependencies for classes that were explicitly compiled.
+     * @return
+     */
+    public Map<String,Set<String>> getDependencies() {
+        Map<String,Set<String>> new_deps = new HashMap<String,Set<String>>();
+        if (explicitPackages == null) return new_deps;
+        for (Name pkg : explicitPackages) {
+            Set<Name> set = deps.get(pkg);
+            if (set != null) {
+                Set<String> new_set = new_deps.get(pkg.toString());
+                if (new_set == null) {
+                    new_set = new HashSet<String>();
+                    // Modules beware....
+                    new_deps.put(":"+pkg.toString(), new_set);
+                }
+                for (Name d : set) {
+                    new_set.add(":"+d.toString());
+                }
+            }
+        }
+        return new_deps;
+    }
+
+    static class CompareNames implements Comparator<Name> {
+         public int compare(Name a, Name b) {
+             return a.toString().compareTo(b.toString());
+         }
+
+    }
+
+    /**
+     * Convert the map from class names to their pubapi to a map
+     * from package names to their pubapi (which is the sorted concatenation
+     * of all the class pubapis)
+     */
+    public Map<String,String> getPubapis() {
+        Map<String,String> publicApiPerPackage = new HashMap<String,String>();
+        if (publicApiPerClass == null) return publicApiPerPackage;
+        Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
+        Arrays.sort(keys, new CompareNames());
+        StringBuffer newPublicApi = new StringBuffer();
+        int i=0;
+        String prevPkg = "";
+        for (Name k : keys) {
+            String cn = k.toString();
+            String pn = "";
+            int dp = cn.lastIndexOf('.');
+            if (dp != -1) {
+                pn = cn.substring(0,dp);
+            }
+            if (!pn.equals(prevPkg)) {
+                if (!prevPkg.equals("")) {
+                    // Add default module name ":"
+                    publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
+                }
+                newPublicApi = new StringBuffer();
+                prevPkg = pn;
+            }
+            newPublicApi.append(publicApiPerClass.get(k));
+            i++;
+        }
+        if (!prevPkg.equals(""))
+            publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
+        return publicApiPerPackage;
+    }
+
+    /**
+     * Visit the api of a class and construct a pubapi string and
+     * store it into the pubapi_perclass map.
+     */
+    public void visitPubapi(Element e) {
+        Name n = ((ClassSymbol)e).fullname;
+        Name p = ((ClassSymbol)e).packge().fullname;
+        StringBuffer sb = publicApiPerClass.get(n);
+        assert(sb == null);
+        sb = new StringBuffer();
+        PubapiVisitor v = new PubapiVisitor(sb);
+        v.visit(e);
+        if (sb.length()>0) {
+            publicApiPerClass.put(n, sb);
+        }
+        explicitPackages.add(p);
+     }
+
+    /**
+     * Collect a dependency. curr_pkg is marked as depending on dep_pkg.
+     */
+    public void collect(Name currPkg, Name depPkg) {
+        if (!currPkg.equals(depPkg)) {
+            Set<Name> theset = deps.get(currPkg);
+            if (theset==null) {
+                theset = new HashSet<Name>();
+                deps.put(currPkg, theset);
+            }
+            theset.add(depPkg);
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java b/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java
new file mode 100644
index 0000000..d3dceeb
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.sjavac.comp;
+
+import java.util.StringTokenizer;
+
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.sjavac.server.CompilerThread;
+import java.io.File;
+
+/** Subclass to Resolve that overrides collect.
+ *
+ * <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></p>
+ */
+public class JavaCompilerWithDeps extends JavaCompiler {
+
+    /** The dependency database
+     */
+    protected Dependencies deps;
+    protected CompilerThread compilerThread;
+
+    public JavaCompilerWithDeps(Context context, CompilerThread t) {
+        super(context);
+        deps = Dependencies.instance(context);
+        compilerThread = t;
+        needRootClasses = true;
+    }
+
+    public static void preRegister(Context context, final CompilerThread t) {
+        context.put(compilerKey, new Context.Factory<JavaCompiler>() {
+            public JavaCompiler make(Context c) {
+                JavaCompiler instance = new JavaCompilerWithDeps(c, t);
+                c.put(JavaCompiler.class, instance);
+                return instance;
+            }
+        });
+    }
+
+    /** Collect the public apis of classes supplied explicitly for compilation.
+     * @param sym The class to visit.
+     */
+    @Override
+    public void reportPublicApi(ClassSymbol sym) {
+        // The next test will catch when source files are located in the wrong directory!
+        // This ought to be moved into javac as a new warning, or perhaps as part
+        // of the auxiliary class warning.
+
+        // For example if sun.swing.BeanInfoUtils
+        // is in fact stored in: /mybuild/jdk/gensrc/javax/swing/beaninfo/BeanInfoUtils.java
+
+        // We do not need to test that BeanInfoUtils is stored in a file named BeanInfoUtils
+        // since this is checked earlier.
+        if (sym.sourcefile != null) {
+            // Rewrite sun.swing.BeanInfoUtils into /sun/swing/
+            StringBuilder pathb = new StringBuilder();
+            StringTokenizer qn = new StringTokenizer(sym.packge().toString(), ".");
+            boolean first = true;
+            while (qn.hasMoreTokens()) {
+                String o = qn.nextToken();
+                pathb.append("/");
+                pathb.append(o);
+                first = false;
+            }
+            pathb.append("/");
+            String path = pathb.toString();
+
+            // Now cut the uri to be: file:///mybuild/jdk/gensrc/javax/swing/beaninfo/
+            String p = sym.sourcefile.toUri().getPath();
+            // Do not use File.separatorChar here, a URI always uses slashes /.
+            int i = p.lastIndexOf("/");
+            String pp = p.substring(0,i+1);
+
+            // Now check if the truncated uri ends with the path. (It does not == failure!)
+            if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) {
+                compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+
+                                        " is located in the wrong package directory, because it contains the class "+
+                                        sym.getQualifiedName());
+            }
+        }
+        deps.visitPubapi(sym);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java b/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java
new file mode 100644
index 0000000..0b5512d
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/PubapiVisitor.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2011, 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.sjavac.comp;
+
+import java.util.Iterator;
+import java.util.List;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementScanner6;
+
+/** Utility class that constructs a textual representation
+ * of the public api of a class.
+ *
+ * <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></p>
+ */
+public class PubapiVisitor extends ElementScanner6<Void, Void> {
+
+    StringBuffer sb;
+    // Important that it is 1! Part of protocol over wire, silly yes.
+    // Fix please.
+    int indent = 1;
+
+    public PubapiVisitor(StringBuffer sb) {
+        this.sb = sb;
+    }
+
+    String depth(int l) {
+        return "                                              ".substring(0, l);
+    }
+
+    @Override
+    public Void visitType(TypeElement e, Void p) {
+        if (e.getModifiers().contains(Modifier.PUBLIC)
+            || e.getModifiers().contains(Modifier.PROTECTED))
+        {
+            sb.append(depth(indent) + "TYPE " + e.getQualifiedName() + "\n");
+            indent += 2;
+            Void v = super.visitType(e, p);
+            indent -= 2;
+            return v;
+        }
+        return null;
+    }
+
+    @Override
+    public Void visitVariable(VariableElement e, Void p) {
+        if (e.getModifiers().contains(Modifier.PUBLIC)
+            || e.getModifiers().contains(Modifier.PROTECTED)) {
+            sb.append(depth(indent)).append("VAR ")
+                    .append(makeVariableString(e)).append("\n");
+        }
+        // Safe to not recurse here, because the only thing
+        // to visit here is the constructor of a variable declaration.
+        // If it happens to contain an anonymous inner class (which it might)
+        // then this class is never visible outside of the package anyway, so
+        // we are allowed to ignore it here.
+        return null;
+    }
+
+    @Override
+    public Void visitExecutable(ExecutableElement e, Void p) {
+        if (e.getModifiers().contains(Modifier.PUBLIC)
+            || e.getModifiers().contains(Modifier.PROTECTED)) {
+            sb.append(depth(indent)).append("METHOD ")
+                    .append(makeMethodString(e)).append("\n");
+        }
+        return null;
+    }
+
+    /**
+     * Creates a String representation of a method element with everything
+     * necessary to track all public aspects of it in an API.
+     * @param e Element to create String for.
+     * @return String representation of element.
+     */
+    protected String makeMethodString(ExecutableElement e) {
+        StringBuilder result = new StringBuilder();
+        for (Modifier modifier : e.getModifiers()) {
+            result.append(modifier.toString());
+            result.append(" ");
+        }
+        result.append(e.getReturnType().toString());
+        result.append(" ");
+        result.append(e.toString());
+
+        List<? extends TypeMirror> thrownTypes = e.getThrownTypes();
+        if (!thrownTypes.isEmpty()) {
+            result.append(" throws ");
+            for (Iterator<? extends TypeMirror> iterator = thrownTypes
+                    .iterator(); iterator.hasNext();) {
+                TypeMirror typeMirror = iterator.next();
+                result.append(typeMirror.toString());
+                if (iterator.hasNext()) {
+                    result.append(", ");
+                }
+            }
+        }
+        return result.toString();
+    }
+
+    /**
+     * Creates a String representation of a variable element with everything
+     * necessary to track all public aspects of it in an API.
+     * @param e Element to create String for.
+     * @return String representation of element.
+     */
+    protected String makeVariableString(VariableElement e) {
+        StringBuilder result = new StringBuilder();
+        for (Modifier modifier : e.getModifiers()) {
+            result.append(modifier.toString());
+            result.append(" ");
+        }
+        result.append(e.asType().toString());
+        result.append(" ");
+        result.append(e.toString());
+        Object value = e.getConstantValue();
+        if (value != null) {
+            result.append(" = ");
+            if (e.asType().toString().equals("char")) {
+                int v = (int)value.toString().charAt(0);
+                result.append("'\\u"+Integer.toString(v,16)+"'");
+            } else {
+                result.append(value.toString());
+            }
+        }
+        return result.toString();
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/ResolveWithDeps.java b/src/share/classes/com/sun/tools/sjavac/comp/ResolveWithDeps.java
new file mode 100644
index 0000000..19c62e9
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/ResolveWithDeps.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.sjavac.comp;
+
+import com.sun.tools.javac.comp.Resolve;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.code.Symbol;
+
+/** Subclass to Resolve that overrides collect.
+ *
+ * <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></p>
+ */
+public class ResolveWithDeps extends Resolve {
+
+    /** The dependency database
+     */
+    protected Dependencies deps;
+
+    protected ResolveWithDeps(Context context) {
+        super(context);
+        deps = Dependencies.instance(context);
+    }
+
+    public static void preRegister(Context context) {
+        context.put(resolveKey, new Context.Factory<Resolve>() {
+            public Resolve make(Context c) {
+                Resolve instance = new ResolveWithDeps(c);
+                c.put(Resolve.class, instance);
+                return instance;
+            }
+        });
+    }
+    /** Collect dependencies in the enclosing class
+     * @param from The enclosing class sym
+     * @param to   The enclosing classes references this sym.
+     * */
+    @Override
+    public void reportDependence(Symbol from, Symbol to) {
+        // Capture dependencies between the packages.
+        deps.collect(from.packge().fullname, to.packge().fullname);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java b/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java
new file mode 100644
index 0000000..eeaf9b0
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac.comp;
+
+import com.sun.tools.javac.util.ListBuffer;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+import javax.tools.*;
+import javax.tools.JavaFileObject.Kind;
+
+/**
+ * Intercepts reads and writes to the file system to gather
+ * information about what artifacts are generated.
+ *
+ * Traps writes to certain files, if the content written is identical
+ * to the existing file.
+ *
+ * Can also blind out the filemanager from seeing certain files in the file system.
+ * Necessary to prevent javac from seeing some sources where the source path points.
+ *
+ * <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></p>
+ */
+public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager> {
+
+    // Set of sources that can be seen by javac.
+    Set<URI> visibleSources = new HashSet<URI>();
+    // Map from modulename:packagename to artifacts.
+    Map<String,Set<URI>> packageArtifacts = new HashMap<String,Set<URI>>();
+    // Where to print informational messages.
+    PrintWriter stdout;
+
+    public SmartFileManager(JavaFileManager fileManager) {
+        super(fileManager);
+    }
+
+    public void setVisibleSources(Set<URI> s) {
+        visibleSources = s;
+    }
+
+    public void cleanArtifacts() {
+        packageArtifacts = new HashMap<String,Set<URI>>();
+    }
+
+    public void setLog(PrintWriter pw) {
+        stdout = pw;
+    }
+
+    public Map<String,Set<URI>> getPackageArtifacts() {
+        return packageArtifacts;
+    }
+
+    @Override
+    public Iterable<JavaFileObject> list(Location location,
+                                         String packageName,
+                                         Set<Kind> kinds,
+                                         boolean recurse)
+        throws IOException
+    {
+        // Acquire the list of files.
+        Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse);
+        if (visibleSources.isEmpty()) {
+            return files;
+        }
+        // Now filter!
+        ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<JavaFileObject>();
+        for (JavaFileObject f : files) {
+            URI uri = f.toUri();
+            String t = uri.toString();
+            if (t.startsWith("jar:")
+                || t.endsWith(".class")
+                || visibleSources.contains(uri))
+            {
+                filteredFiles.add(f);
+            }
+        }
+        return filteredFiles;
+    }
+
+    @Override
+    public boolean hasLocation(Location location) {
+        return super.hasLocation(location);
+    }
+
+    @Override
+    public JavaFileObject getJavaFileForInput(Location location,
+                                              String className,
+                                              Kind kind)
+        throws IOException
+    {
+        JavaFileObject file = super.getJavaFileForInput(location, className, kind);
+        if (file == null || visibleSources.isEmpty()) {
+            return file;
+        }
+
+        if (visibleSources.contains(file.toUri())) {
+            return file;
+        }
+        return null;
+    }
+
+    @Override
+    public JavaFileObject getJavaFileForOutput(Location location,
+                                               String className,
+                                               Kind kind,
+                                               FileObject sibling)
+        throws IOException
+    {
+        JavaFileObject file = super.getJavaFileForOutput(location, className, kind, sibling);
+        if (file == null) return file;
+        int dp = className.lastIndexOf('.');
+        String pkg_name = "";
+        if (dp != -1) {
+            pkg_name = className.substring(0, dp);
+        }
+        // When modules are in use, then the mod_name might be something like "jdk_base"
+        String mod_name = "";
+        addArtifact(mod_name+":"+pkg_name, file.toUri());
+        return file;
+    }
+
+    @Override
+    public FileObject getFileForInput(Location location,
+                                      String packageName,
+                                      String relativeName)
+        throws IOException
+    {
+        FileObject file =  super.getFileForInput(location, packageName, relativeName);
+        if (file == null || visibleSources.isEmpty()) {
+            return file;
+        }
+
+        if (visibleSources.contains(file.toUri())) {
+            return file;
+        }
+        return null;
+    }
+
+    @Override
+    public FileObject getFileForOutput(Location location,
+                                       String packageName,
+                                       String relativeName,
+                                       FileObject sibling)
+        throws IOException
+    {
+        FileObject file = super.getFileForOutput(location, packageName, relativeName, sibling);
+        if (file == null) return file;
+        if (location.equals(StandardLocation.NATIVE_HEADER_OUTPUT) &&
+                file instanceof JavaFileObject) {
+           file = new SmartFileObject((JavaFileObject)file, stdout);
+           packageName = ":" + packageNameFromFileName(relativeName);
+        }
+        if (packageName.equals("")) {
+            packageName = ":";
+        }
+        addArtifact(packageName, file.toUri());
+        return file;
+    }
+
+    private String packageNameFromFileName(String fn) {
+        StringBuilder sb = new StringBuilder();
+        int p = fn.indexOf('_'), pp = 0;
+        while (p != -1) {
+            if (sb.length() > 0) sb.append('.');
+            sb.append(fn.substring(pp,p));
+            if (p == fn.length()-1) break;
+            pp = p+1;
+            p = fn.indexOf('_',pp);
+        }
+        return sb.toString();
+    }
+
+    @Override
+    public void flush() throws IOException {
+        super.flush();
+    }
+
+    @Override
+    public void close() throws IOException {
+        super.close();
+    }
+
+    void addArtifact(String pkgName, URI art) {
+        Set<URI> s = packageArtifacts.get(pkgName);
+        if (s == null) {
+            s = new HashSet<URI>();
+            packageArtifacts.put(pkgName, s);
+        }
+        s.add(art);
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java b/src/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java
new file mode 100644
index 0000000..17c22ed
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac.comp;
+
+import java.io.*;
+import java.net.URI;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.NestingKind;
+import javax.tools.JavaFileObject;
+
+/**
+ * The SmartFileObject will return an outputstream that cache the written data
+ * and compare the new content with the old content on disk. Only if they differ,
+ * will the file be updated.
+ *
+ * <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></p>
+ */
+public class SmartFileObject implements JavaFileObject {
+
+    JavaFileObject file;
+    PrintWriter stdout;
+
+    public SmartFileObject(JavaFileObject r, PrintWriter pw) {
+        file = r;
+        stdout = pw;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        return file.equals(other);
+    }
+
+    @Override
+    public int hashCode() {
+        return file.hashCode();
+    }
+
+    public Kind getKind() {
+        return file.getKind();
+    }
+
+    public boolean isNameCompatible(String simpleName, Kind kind) {
+        return file.isNameCompatible(simpleName, kind);
+    }
+
+    public URI toUri() {
+        return file.toUri();
+    }
+
+    public String getName() {
+        return file.getName();
+    }
+
+    public InputStream openInputStream() throws IOException {
+        return file.openInputStream();
+    }
+
+    public OutputStream openOutputStream() throws IOException {
+        return file.openOutputStream();
+    }
+
+    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+        return file.getCharContent(ignoreEncodingErrors);
+    }
+
+    static String lineseparator = System.getProperty("line.separator");
+
+    public Writer openWriter() throws IOException {
+        StringBuilder s = new StringBuilder();
+        try (BufferedReader r = new BufferedReader(file.openReader(true))) {
+            while (r.ready()) {
+                s.append(r.readLine()+lineseparator);
+            }
+        } catch (FileNotFoundException e) {
+            // Perfectly ok.
+        }
+        return new SmartWriter(file, s.toString(), file.getName(), stdout);
+    }
+
+    public long getLastModified() {
+        return file.getLastModified();
+    }
+
+    public boolean delete() {
+        return file.delete();
+    }
+
+    public Modifier getAccessLevel() {
+        return file.getAccessLevel();
+    }
+
+    public NestingKind getNestingKind() {
+        return file.getNestingKind();
+    }
+
+    public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
+        return file.openReader(ignoreEncodingErrors);
+    }
+
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/comp/SmartWriter.java b/src/share/classes/com/sun/tools/sjavac/comp/SmartWriter.java
new file mode 100644
index 0000000..45bccfa
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/comp/SmartWriter.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.sjavac.comp;
+
+import java.io.*;
+import javax.tools.JavaFileObject;
+
+/**
+ * The SmartWriter will cache the written data and when the writer is closed,
+ * then it will compare the cached data with the old_content string.
+ * If different, then it will write all the new content to the file.
+ * If not, the file is not touched.
+ *
+ *  <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></p>
+ */
+public class SmartWriter extends Writer {
+
+    String name;
+    JavaFileObject file;
+    String oldContent;
+    StringWriter newContent = new StringWriter();
+    PrintWriter stdout;
+    boolean closed;
+    public SmartWriter(JavaFileObject f, String s, String n, PrintWriter pw) {
+        name = n;
+        file = f;
+        oldContent = s;
+        newContent = new StringWriter();
+        stdout = pw;
+        closed = false;
+    }
+
+    public void write(char[] chars, int i, int i1)
+    {
+        newContent.write(chars, i, i1);
+    }
+
+    public void close() throws IOException {
+        if (closed) return;
+        closed = true;
+        String s = newContent.toString();
+        if (!oldContent.equals(s)) {
+            int p = file.getName().lastIndexOf(File.separatorChar);
+            try (Writer writer = file.openWriter()) {
+                writer.write(s);
+            }
+            stdout.println("Writing "+file.getName().substring(p+1));
+        }
+    }
+
+    public void flush() throws IOException {
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java b/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java
new file mode 100644
index 0000000..f0f0dcf
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac.server;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
+import java.util.Stack;
+import java.util.concurrent.Future;
+
+/** The compiler pool maintains compiler threads.
+ *
+ * <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></p>
+ */
+public class CompilerPool {
+    // The javac server that created this pool.
+    private JavacServer javacServer;
+    // A semaphore protecting the poolsize number of threads.
+    private Semaphore available;
+    // The stack of compiler threads.
+    private Stack<CompilerThread> compilers = new Stack<CompilerThread>();
+    // And the executor server to spawn threads.
+    private final ExecutorService executorPool;
+    // How many requests are active right now?
+    private int concurrentRequests = 0;
+    // When was the last request finished?
+    private long lastRequestFinished = 0;
+    // The total number of requests to this pool.
+    private int numRequests = 0;
+    // Protect access to the three above values.
+    private static final Object conc = new Object();
+
+    /**
+     * Return the javac server that this pool belongs to.
+     */
+    public JavacServer getJavacServer() {
+        return javacServer;
+    }
+
+    /**
+     * Return how many threads are running at this very moment.
+     */
+    public int numActiveRequests()
+    {
+        synchronized (conc) {
+            return concurrentRequests;
+        }
+    }
+
+    /**
+     * Return when the last request was finished.
+     * I.e. the pool has been idle since.
+     */
+    public long lastRequestFinished()
+    {
+        synchronized (conc) {
+            return lastRequestFinished;
+        }
+    }
+
+    /**
+     * Up the number of active requests.
+     */
+    public int startRequest() {
+        int n;
+        synchronized (conc) {
+            concurrentRequests++;
+            numRequests++;
+            n = numRequests;
+        }
+        return n;
+    }
+
+    /**
+     * Down the number of active requests. Return the current time.
+     */
+    public long stopRequest() {
+        synchronized (conc) {
+            concurrentRequests--;
+            lastRequestFinished = System.currentTimeMillis();
+        }
+        return lastRequestFinished;
+    }
+
+    /**
+     * Create a new compiler pool.
+     */
+    CompilerPool(int poolsize, JavacServer server) {
+        available = new Semaphore(poolsize, true);
+        javacServer = server;
+        executorPool = Executors.newFixedThreadPool(poolsize);
+        lastRequestFinished = System.currentTimeMillis();
+    }
+
+    /**
+     * Execute a compiler thread.
+     */
+    public void execute(CompilerThread ct) {
+        executorPool.execute(ct);
+    }
+
+    /**
+     * Execute a minor task, for example generating bytecodes and writing them to disk,
+     * that belong to a major compiler thread task.
+     */
+    public Future<?> executeSubtask(CompilerThread t, Runnable r) {
+        return executorPool.submit(r);
+    }
+
+    /**
+     * Shutdown the pool.
+     */
+    public void shutdown() {
+        executorPool.shutdown();
+    }
+
+    /**
+     * Acquire a compiler thread from the pool, or block until a thread is available.
+     * If the pools is empty, create a new thread, but never more than is "available".
+     */
+    public CompilerThread grabCompilerThread() throws InterruptedException {
+        available.acquire();
+        if (compilers.empty()) {
+            return new CompilerThread(this);
+        }
+        return compilers.pop();
+    }
+
+    /**
+     * Return the specified compiler thread to the pool.
+     */
+    public void returnCompilerThread(CompilerThread h) {
+        compilers.push(h);
+        available.release();
+    }
+}
+
diff --git a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
new file mode 100644
index 0000000..aa9b3ba
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
@@ -0,0 +1,420 @@
+/*
+ * 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.  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.sjavac.server;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.Socket;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Map;
+import java.util.concurrent.Future;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.sjavac.comp.Dependencies;
+import com.sun.tools.sjavac.comp.JavaCompilerWithDeps;
+import com.sun.tools.sjavac.comp.SmartFileManager;
+import com.sun.tools.sjavac.comp.ResolveWithDeps;
+
+/**
+ * The compiler thread maintains a JavaCompiler instance and
+ * can receive a request from the client, perform the compilation
+ * requested and report back the results.
+ *
+ *  * <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></p>
+ */
+public class CompilerThread implements Runnable {
+    private JavacServer javacServer;
+    private CompilerPool compilerPool;
+    private List<Future<?>> subTasks;
+
+    // Communicating over this socket.
+    private Socket socket;
+
+    // The necessary classes to do a compilation.
+    private com.sun.tools.javac.api.JavacTool compiler;
+    private StandardJavaFileManager fileManager;
+    private BaseFileManager fileManagerBase;
+    private SmartFileManager smartFileManager;
+    private Context context;
+
+    // If true, then this thread is serving a request.
+    private boolean inUse = false;
+
+    CompilerThread(CompilerPool cp) {
+        compilerPool = cp;
+        javacServer = cp.getJavacServer();
+    }
+
+    /**
+     * Execute a minor task, for example generating bytecodes and writing them to disk,
+     * that belong to a major compiler thread task.
+     */
+    public synchronized void executeSubtask(Runnable r) {
+        subTasks.add(compilerPool.executeSubtask(this, r));
+    }
+
+    /**
+     * Count the number of active sub tasks.
+     */
+    public synchronized int numActiveSubTasks() {
+        int c = 0;
+        for (Future<?> f : subTasks) {
+            if (!f.isDone() && !f.isCancelled()) {
+                c++;
+            }
+        }
+        return c;
+    }
+
+    /**
+     * Use this socket for the upcoming request.
+     */
+    public void setSocket(Socket s) {
+        socket = s;
+    }
+
+    /**
+     * Prepare the compiler thread for use. It is not yet started.
+     * It will be started by the executor service.
+     */
+    public synchronized void use() {
+        assert(!inUse);
+        inUse = true;
+        compiler = com.sun.tools.javac.api.JavacTool.create();
+        fileManager = compiler.getStandardFileManager(null, null, null);
+        fileManagerBase = (BaseFileManager)fileManager;
+        smartFileManager = new SmartFileManager(fileManager);
+        context = new Context();
+        context.put(JavaFileManager.class, smartFileManager);
+        ResolveWithDeps.preRegister(context);
+        JavaCompilerWithDeps.preRegister(context, this);
+        subTasks = new ArrayList<Future<?>>();
+    }
+
+    /**
+     * Prepare the compiler thread for idleness.
+     */
+    public synchronized void unuse() {
+        assert(inUse);
+        inUse = false;
+        compiler = null;
+        fileManager = null;
+        fileManagerBase = null;
+        smartFileManager = null;
+        context = null;
+        subTasks = null;
+    }
+
+    /**
+     * Expect this key on the next line read from the reader.
+     */
+    private static boolean expect(BufferedReader in, String key) throws IOException {
+        String s = in.readLine();
+        if (s != null && s.equals(key)) {
+            return true;
+        }
+        return false;
+    }
+
+    // The request identifier, for example GENERATE_NEWBYTECODE
+    String id = "";
+
+    public String currentRequestId() {
+        return id;
+    }
+
+    PrintWriter stdout;
+    PrintWriter stderr;
+    int forcedExitCode = 0;
+
+    public void logError(String msg) {
+        stderr.println(msg);
+        forcedExitCode = -1;
+    }
+
+    /**
+     * Invoked by the executor service.
+     */
+    public void run() {
+        // Unique nr that identifies this request.
+        int thisRequest = compilerPool.startRequest();
+        long start = System.currentTimeMillis();
+        int numClasses = 0;
+        StringBuilder compiledPkgs = new StringBuilder();
+        use();
+
+        PrintWriter out = null;
+        try {
+            javacServer.log("<"+thisRequest+"> Connect from "+socket.getRemoteSocketAddress()+" activethreads="+compilerPool.numActiveRequests());
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                                                       socket.getInputStream()));
+            out = new PrintWriter(new OutputStreamWriter(
+                                                  socket.getOutputStream()));
+            if (!expect(in, JavacServer.PROTOCOL_COOKIE_VERSION)) {
+                javacServer.log("<"+thisRequest+"> Bad protocol from ip "+socket.getRemoteSocketAddress());
+                return;
+            }
+
+            String cookie = in.readLine();
+            if (cookie == null || !cookie.equals(""+javacServer.getCookie())) {
+                javacServer.log("<"+thisRequest+"> Bad cookie from ip "+socket.getRemoteSocketAddress());
+                return;
+            }
+            if (!expect(in, JavacServer.PROTOCOL_CWD)) {
+                return;
+            }
+            String cwd = in.readLine();
+            if (cwd == null)
+                return;
+            if (!expect(in, JavacServer.PROTOCOL_ID)) {
+                return;
+            }
+            id = in.readLine();
+            if (id == null)
+                return;
+            if (!expect(in, JavacServer.PROTOCOL_ARGS)) {
+                return;
+            }
+            ArrayList<String> the_options = new ArrayList<String>();
+            ArrayList<File> the_classes = new ArrayList<File>();
+            Iterable<File> path = Arrays.<File> asList(new File(cwd));
+
+            for (;;) {
+                String l = in.readLine();
+                if (l == null)
+                    return;
+                if (l.equals(JavacServer.PROTOCOL_SOURCES_TO_COMPILE))
+                    break;
+                if (l.startsWith("--server:"))
+                    continue;
+                if (!l.startsWith("-") && l.endsWith(".java")) {
+                    the_classes.add(new File(l));
+                    numClasses++;
+                } else {
+                    the_options.add(l);
+                }
+                continue;
+            }
+
+            // Load sources to compile
+            Set<URI> sourcesToCompile = new HashSet<URI>();
+            for (;;) {
+                String l = in.readLine();
+                if (l == null)
+                    return;
+                if (l.equals(JavacServer.PROTOCOL_VISIBLE_SOURCES))
+                    break;
+                try {
+                    sourcesToCompile.add(new URI(l));
+                    numClasses++;
+                } catch (URISyntaxException e) {
+                    return;
+                }
+            }
+            // Load visible sources
+            Set<URI> visibleSources = new HashSet<URI>();
+            boolean fix_drive_letter_case =
+                System.getProperty("os.name").toLowerCase().startsWith("windows");
+            for (;;) {
+                String l = in.readLine();
+                if (l == null)
+                    return;
+                if (l.equals(JavacServer.PROTOCOL_END))
+                    break;
+                try {
+                    URI u = new URI(l);
+                    if (fix_drive_letter_case) {
+                        // Make sure the driver letter is lower case.
+                        String s = u.toString();
+                        if (s.startsWith("file:/") &&
+                            Character.isUpperCase(s.charAt(6))) {
+                            u = new URI("file:/"+Character.toLowerCase(s.charAt(6))+s.substring(7));
+                        }
+                    }
+                    visibleSources.add(u);
+                } catch (URISyntaxException e) {
+                    return;
+                }
+            }
+
+            // A completed request has been received.
+
+            // Now setup the actual compilation....
+            // First deal with explicit source files on cmdline and in at file.
+            com.sun.tools.javac.util.ListBuffer<JavaFileObject> compilationUnits =
+                new com.sun.tools.javac.util.ListBuffer<JavaFileObject>();
+            for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(the_classes)) {
+                compilationUnits.append(i);
+            }
+            // Now deal with sources supplied as source_to_compile.
+            com.sun.tools.javac.util.ListBuffer<File> sourcesToCompileFiles =
+                new com.sun.tools.javac.util.ListBuffer<File>();
+            for (URI u : sourcesToCompile) {
+                sourcesToCompileFiles.append(new File(u));
+            }
+            for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) {
+                compilationUnits.append(i);
+            }
+            // Log the options to be used.
+            StringBuilder options = new StringBuilder();
+            for (String s : the_options) {
+                options.append(">").append(s).append("< ");
+            }
+            javacServer.log(id+" <"+thisRequest+"> options "+options.toString());
+
+            forcedExitCode = 0;
+            // Create a new logger.
+            StringWriter stdoutLog = new StringWriter();
+            StringWriter stderrLog = new StringWriter();
+            stdout = new PrintWriter(stdoutLog);
+            stderr = new PrintWriter(stderrLog);
+            com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK;
+            try {
+                if (compilationUnits.size() > 0) {
+                    // Bind the new logger to the existing context.
+                    context.put(Log.outKey, stderr);
+                    Log.instance(context).setWriter(Log.WriterKind.NOTICE, stdout);
+                    Log.instance(context).setWriter(Log.WriterKind.WARNING, stderr);
+                    Log.instance(context).setWriter(Log.WriterKind.ERROR, stderr);
+                    // Process the options.
+                    com.sun.tools.javac.api.JavacTool.processOptions(context, smartFileManager, the_options);
+                    fileManagerBase.setContext(context);
+                    smartFileManager.setVisibleSources(visibleSources);
+                    smartFileManager.cleanArtifacts();
+                    smartFileManager.setLog(stdout);
+                    Dependencies.instance(context).reset();
+
+                    com.sun.tools.javac.main.Main ccompiler = new com.sun.tools.javac.main.Main("javacTask", stderr);
+                    String[] aa = the_options.toArray(new String[0]);
+
+                    // Do the compilation!
+                    rc = ccompiler.compile(aa, context, compilationUnits.toList(), null);
+
+                    while (numActiveSubTasks()>0) {
+                        try { Thread.sleep(1000); } catch (InterruptedException e) { }
+                    }
+
+                    smartFileManager.flush();
+                }
+            } catch (Exception e) {
+                stderr.println(e.getMessage());
+                forcedExitCode = -1;
+            }
+
+            // Send the response..
+            out.println(JavacServer.PROTOCOL_STDOUT);
+            out.print(stdoutLog);
+            out.println(JavacServer.PROTOCOL_STDERR);
+            out.print(stderrLog);
+            // The compilation is complete! And errors will have already been printed on out!
+            out.println(JavacServer.PROTOCOL_PACKAGE_ARTIFACTS);
+            Map<String,Set<URI>> pa = smartFileManager.getPackageArtifacts();
+            for (String aPkgName : pa.keySet()) {
+                out.println("+"+aPkgName);
+                Set<URI> as = pa.get(aPkgName);
+                for (URI a : as) {
+                    out.println(" "+a.toString());
+                }
+            }
+            Dependencies deps = Dependencies.instance(context);
+            out.println(JavacServer.PROTOCOL_PACKAGE_DEPENDENCIES);
+            Map<String,Set<String>> pd = deps.getDependencies();
+            for (String aPkgName : pd.keySet()) {
+                out.println("+"+aPkgName);
+                Set<String> ds = pd.get(aPkgName);
+                    // Everything depends on java.lang
+                    if (!ds.contains(":java.lang")) ds.add(":java.lang");
+                for (String d : ds) {
+                    out.println(" "+d);
+                }
+            }
+            out.println(JavacServer.PROTOCOL_PACKAGE_PUBLIC_APIS);
+            Map<String,String> pp = deps.getPubapis();
+            for (String aPkgName : pp.keySet()) {
+                out.println("+"+aPkgName);
+                String ps = pp.get(aPkgName);
+                // getPubapis added a space to each line!
+                out.println(ps);
+                compiledPkgs.append(aPkgName+" ");
+            }
+            out.println(JavacServer.PROTOCOL_SYSINFO);
+            out.println("num_cores=" + Runtime.getRuntime().availableProcessors());
+            out.println("max_memory=" + Runtime.getRuntime().maxMemory());
+            out.println(JavacServer.PROTOCOL_RETURN_CODE);
+
+            // Errors from sjavac that affect compilation status!
+            int rcv = rc.exitCode;
+            if (rcv == 0 && forcedExitCode != 0) {
+                rcv = forcedExitCode;
+            }
+            out.println("" + rcv);
+            out.println(JavacServer.PROTOCOL_END);
+            out.flush();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (out != null) out.close();
+                if (!socket.isClosed()) {
+                    socket.close();
+                }
+                socket = null;
+            } catch (Exception e) {
+                javacServer.log("ERROR "+e);
+                e.printStackTrace();
+            }
+            compilerPool.stopRequest();
+            long duration = System.currentTimeMillis()-start;
+            javacServer.addBuildTime(duration);
+            float classpersec = ((float)numClasses)*(((float)1000.0)/((float)duration));
+            javacServer.log(id+" <"+thisRequest+"> "+compiledPkgs+" duration " + duration+ " ms    num_classes="+numClasses+
+                             "     classpersec="+classpersec+" subtasks="+subTasks.size());
+            javacServer.flushLog();
+            unuse();
+            compilerPool.returnCompilerThread(this);
+        }
+    }
+}
+
diff --git a/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java b/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
new file mode 100644
index 0000000..2e59f27
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java
@@ -0,0 +1,751 @@
+/*
+ * Copyright (c) 2011-2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.sjavac.server;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.ArrayList;
+import java.util.Random;
+
+import com.sun.tools.sjavac.Util;
+import com.sun.tools.sjavac.ProblemException;
+import java.io.*;
+import java.util.*;
+
+/**
+ * The JavacServer class contains methods both to setup a server that responds to requests and methods to connect to this server.
+ *
+ * <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></p>
+ */
+public class JavacServer {
+    // Responding to this tcp/ip port on localhost.
+
+    private final ServerSocket serverSocket;
+    // The secret cookie shared between server and client through the port file.
+    private final long myCookie;
+    // When the server was started.
+    private long serverStart;
+    // Accumulated build time for all requests, not counting idle time.
+    private long totalBuildTime;
+    // The javac server specific log file.
+    PrintWriter theLog;
+    // The compiler pool that maintains the compiler threads.
+    CompilerPool compilerPool;
+    // For the client, all port files fetched, one per started javac server.
+    // Though usually only one javac server is started by a client.
+    private static Map<String, PortFile> allPortFiles;
+    private static Map<String, Long> maxServerMemory;
+    final static int ERROR_FATAL = -1;
+    final static int ERROR_BUT_TRY_AGAIN = -4712;
+    final static String PROTOCOL_COOKIE_VERSION = "----THE-COOKIE-V2----";
+    final static String PROTOCOL_CWD = "----THE-CWD----";
+    final static String PROTOCOL_ID = "----THE-ID----";
+    final static String PROTOCOL_ARGS = "----THE-ARGS----";
+    final static String PROTOCOL_SOURCES_TO_COMPILE = "----THE-SOURCES-TO-COMPILE----";
+    final static String PROTOCOL_VISIBLE_SOURCES = "----THE-VISIBLE-SOURCES----";
+    final static String PROTOCOL_END = "----THE-END----";
+    final static String PROTOCOL_STDOUT = "----THE-STDOUT----";
+    final static String PROTOCOL_STDERR = "----THE-STDERR----";
+    final static String PROTOCOL_PACKAGE_ARTIFACTS = "----THE-PACKAGE_ARTIFACTS----";
+    final static String PROTOCOL_PACKAGE_DEPENDENCIES = "----THE-PACKAGE_DEPENDENCIES----";
+    final static String PROTOCOL_PACKAGE_PUBLIC_APIS = "----THE-PACKAGE-PUBLIC-APIS----";
+    final static String PROTOCOL_SYSINFO = "----THE-SYSINFO----";
+    final static String PROTOCOL_RETURN_CODE = "----THE-RETURN-CODE----";
+    // Check if the portfile is gone, every 5 seconds.
+    static int CHECK_PORTFILE_INTERVAL = 5;
+    // Wait 2 seconds for response, before giving up on javac server.
+    static int CONNECTION_TIMEOUT = 2;
+    static int WAIT_BETWEEN_CONNECT_ATTEMPTS = 1;
+    static int MAX_NUM_CONNECT_ATTEMPTS = 3;
+
+    /**
+     * Acquire the port file. Synchronized since several threads inside an smart javac wrapper client acquires the same port file at the same time.
+     */
+    private static synchronized PortFile getPortFile(String filename) throws FileNotFoundException {
+        if (allPortFiles == null) {
+            allPortFiles = new HashMap<String, PortFile>();
+        }
+        PortFile pf = allPortFiles.get(filename);
+        if (pf == null) {
+            pf = new PortFile(filename);
+            allPortFiles.put(filename, pf);
+        }
+        return pf;
+    }
+
+    /**
+     * Get the cookie used for this server.
+     */
+    long getCookie() {
+        return myCookie;
+    }
+
+    /**
+     * Get the port used for this server.
+     */
+    int getPort() {
+        return serverSocket.getLocalPort();
+    }
+
+    /**
+     * Sum up the total build time for this javac server.
+     */
+    public void addBuildTime(long inc) {
+        totalBuildTime += inc;
+    }
+
+    /**
+     * Log this message.
+     */
+    public void log(String msg) {
+        if (theLog != null) {
+            theLog.println(msg);
+        } else {
+            System.err.println(msg);
+        }
+    }
+
+    /**
+     * Make sure the log is flushed.
+     */
+    public void flushLog() {
+        if (theLog != null) {
+            theLog.flush();
+        }
+    }
+
+    /**
+     * Start a server using a settings string. Typically: "--startserver:portfile=/tmp/myserver,poolsize=3" and the string "portfile=/tmp/myserver,poolsize=3"
+     * is sent as the settings parameter. Returns 0 on success, -1 on failure.
+     */
+    public static int startServer(String settings, PrintStream err) {
+        try {
+            String portfile = Util.extractStringOption("portfile", settings);
+            // The log file collects more javac server specific log information.
+            String logfile = Util.extractStringOption("logfile", settings);
+            // The stdouterr file collects all the System.out and System.err writes to disk.
+            String stdouterrfile = Util.extractStringOption("stdouterrfile", settings);
+            // We could perhaps use System.setOut and setErr here.
+            // But for the moment we rely on the client to spawn a shell where stdout
+            // and stderr are redirected already.
+            // The pool size is a limit the number of concurrent compiler threads used.
+            // The server might use less than these to avoid memory problems.
+            int poolsize = Util.extractIntOption("poolsize", settings);
+            if (poolsize <= 0) {
+                // If not set, default to the number of cores.
+                poolsize = Runtime.getRuntime().availableProcessors();
+            }
+
+            // How many seconds of inactivity will the server accept before quitting?
+            int keepalive = Util.extractIntOption("keepalive", settings);
+            if (keepalive <= 0) {
+                keepalive = 120;
+            }
+            // The port file is locked and the server port and cookie is written into it.
+            PortFile portFile = getPortFile(portfile);
+            JavacServer s;
+
+            synchronized (portFile) {
+                portFile.lock();
+                portFile.getValues();
+                if (portFile.containsPortInfo()) {
+                    err.println("Javac server not started because portfile exists!");
+                    portFile.unlock();
+                    return -1;
+                }
+                s = new JavacServer(poolsize, logfile);
+                portFile.setValues(s.getPort(), s.getCookie());
+                portFile.unlock();
+            }
+
+            // Run the server. Will delete the port file when shutting down.
+            // It will shut down automatically when no new requests have come in
+            // during the last 125 seconds.
+            s.run(portFile, err, keepalive);
+            // The run loop for the server has exited.
+            return 0;
+        } catch (Exception e) {
+            e.printStackTrace(err);
+            return -1;
+        }
+    }
+
+    /**
+     * Dispatch a compilation request to a javac server.
+     *
+     * @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac.
+     *
+     * The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk.
+     *
+     * @param sources_to_compile The sources to compile.
+     *
+     * @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see!
+     * (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath
+     *
+     * @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server
+     * can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar.
+     *
+     * The server return meta data about the build in the following parameters.
+     * @param package_artifacts, map from package name to set of created artifacts for that package.
+     * @param package_dependencies, map from package name to set of packages that it depends upon.
+     * @param package_pubapis, map from package name to unique string identifying its pub api.
+     */
+    public static int useServer(String settings, String[] args,
+            Set<URI> sourcesToCompile,
+            Set<URI> visibleSources,
+            Map<URI, Set<String>> visibleClasses,
+            Map<String, Set<URI>> packageArtifacts,
+            Map<String, Set<String>> packageDependencies,
+            Map<String, String> packagePubapis,
+            SysInfo sysinfo,
+            PrintStream out,
+            PrintStream err) {
+        try {
+            // The id can perhaps be used in the future by the javac server to reuse the
+            // JavaCompiler instance for several compiles using the same id.
+            String id = Util.extractStringOption("id", settings);
+            String portfile = Util.extractStringOption("portfile", settings);
+            String logfile = Util.extractStringOption("logfile", settings);
+            String stdouterrfile = Util.extractStringOption("stdouterrfile", settings);
+            String background = Util.extractStringOption("background", settings);
+            if (background == null || !background.equals("false")) {
+                background = "true";
+            }
+            // The sjavac option specifies how the server part of sjavac is spawned.
+            // If you have the experimental sjavac in your path, you are done. If not, you have
+            // to point to a com.sun.tools.sjavac.Main that supports --startserver
+            // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main
+            String sjavac = Util.extractStringOption("sjavac", settings);
+            int poolsize = Util.extractIntOption("poolsize", settings);
+            int keepalive = Util.extractIntOption("keepalive", settings);
+
+            if (keepalive <= 0) {
+                // Default keepalive for server is 120 seconds.
+                // I.e. it will accept 120 seconds of inactivity before quitting.
+                keepalive = 120;
+            }
+            if (portfile == null) {
+                err.println("No portfile was specified!");
+                return -1;
+            }
+            if (logfile == null) {
+                logfile = portfile + ".javaclog";
+            }
+            if (stdouterrfile == null) {
+                stdouterrfile = portfile + ".stdouterr";
+            }
+            // Default to sjavac and hope it is in the path.
+            if (sjavac == null) {
+                sjavac = "sjavac";
+            }
+
+            int attempts = 0;
+            int rc = -1;
+            do {
+                PortFile port_file = getPortFile(portfile);
+                synchronized (port_file) {
+                    port_file.lock();
+                    port_file.getValues();
+                    port_file.unlock();
+                }
+                if (!port_file.containsPortInfo()) {
+                    String cmd = fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, err, stdouterrfile, background);
+
+                    if (background.equals("true") && !port_file.waitForValidValues()) {
+                        // Ouch the server did not start! Lets print its stdouterrfile and the command used.
+                        printFailedAttempt(cmd, stdouterrfile, err);
+                        // And give up.
+                        return -1;
+                    }
+                }
+                rc = connectAndCompile(port_file, id, args, sourcesToCompile, visibleSources,
+                        packageArtifacts, packageDependencies, packagePubapis, sysinfo,
+                        out, err);
+                // Try again until we manage to connect. Any error after that
+                // will cause the compilation to fail.
+                if (rc == ERROR_BUT_TRY_AGAIN) {
+                    // We could not connect to the server. Try again.
+                    attempts++;
+                    try {
+                        Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS);
+                    } catch (InterruptedException e) {
+                    }
+                }
+            } while (rc == ERROR_BUT_TRY_AGAIN && attempts < MAX_NUM_CONNECT_ATTEMPTS);
+            return rc;
+        } catch (Exception e) {
+            e.printStackTrace(err);
+            return -1;
+        }
+    }
+
+    private static void printFailedAttempt(String cmd, String f, PrintStream err) {
+        err.println("---- Failed to start javac server with this command -----");
+        err.println(cmd);
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(f));
+            err.println("---- stdout/stderr output from attempt to start javac server -----");
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    break;
+                }
+                err.println(l);
+            }
+            err.println("------------------------------------------------------------------");
+        } catch (Exception e) {
+            err.println("The stdout/stderr output in file " + f + " does not exist and the server did not start.");
+        }
+    }
+
+    /**
+     * Spawn the server instance.
+     */
+
+    private JavacServer(int poolSize, String logfile) throws IOException {
+        serverStart = System.currentTimeMillis();
+        // Create a server socket on a random port that is bound to the localhost/127.0.0.1 interface.
+        // I.e only local processes can connect to this port.
+        serverSocket = new ServerSocket(0, 128, InetAddress.getByName(null));
+        compilerPool = new CompilerPool(poolSize, this);
+        Random rnd = new Random();
+        myCookie = rnd.nextLong();
+        theLog = new PrintWriter(logfile);
+        log("Javac server started. port=" + getPort() + " date=" + (new java.util.Date()) + " with poolsize=" + poolSize);
+        flushLog();
+    }
+
+    /**
+     * Fork a background process. Returns the command line used that can be printed if something failed.
+     */
+    private static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive,
+            final PrintStream err, String stdouterrfile, String background)
+            throws IOException, ProblemException {
+        if (stdouterrfile != null && stdouterrfile.trim().equals("")) {
+            stdouterrfile = null;
+        }
+        final String startserver = "--startserver:portfile=" + portfile + ",logfile=" + logfile + ",stdouterrfile=" + stdouterrfile + ",poolsize=" + poolsize + ",keepalive="+ keepalive;
+
+        if (background.equals("true")) {
+            sjavac += "%20" + startserver;
+            sjavac = sjavac.replaceAll("%20", " ");
+            sjavac = sjavac.replaceAll("%2C", ",");
+            // If the java/sh/cmd launcher fails the failure will be captured by stdouterr because of the redirection here.
+            String[] cmd = {"/bin/sh", "-c", sjavac + " >> " + stdouterrfile + " 2>&1"};
+            if (!(new File("/bin/sh")).canExecute()) {
+                ArrayList<String> wincmd = new ArrayList<String>();
+                wincmd.add("cmd");
+                wincmd.add("/c");
+                wincmd.add("start");
+                wincmd.add("cmd");
+                wincmd.add("/c");
+                wincmd.add(sjavac + " >> " + stdouterrfile + " 2>&1");
+                cmd = wincmd.toArray(new String[wincmd.size()]);
+            }
+            Process pp = null;
+            try {
+                pp = Runtime.getRuntime().exec(cmd);
+            } catch (Exception e) {
+                e.printStackTrace(err);
+                e.printStackTrace(new PrintWriter(stdouterrfile));
+            }
+            StringBuilder rs = new StringBuilder();
+            for (String s : cmd) {
+                rs.append(s + " ");
+            }
+            return rs.toString();
+        }
+
+        // Do not spawn a background server, instead run it within the same JVM.
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                try {
+                    JavacServer.startServer(startserver, err);
+                } catch (Throwable t) {
+                    t.printStackTrace(err);
+                }
+            }
+        };
+        t.start();
+        return "";
+    }
+
+    /**
+     * Expect this key on the next line read from the reader.
+     */
+    private static boolean expect(BufferedReader in, String key) throws IOException {
+        String s = in.readLine();
+        if (s != null && s.equals(key)) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Make a request to the server only to get the maximum possible heap size to use for compilations.
+     *
+     * @param port_file The port file used to synchronize creation of this server.
+     * @param id The identify of the compilation.
+     * @param out Standard out information.
+     * @param err Standard err information.
+     * @return The maximum heap size in bytes.
+     */
+    public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) {
+        SysInfo sysinfo = new SysInfo(-1, -1);
+        String id = Util.extractStringOption("id", serverSettings);
+        String portfile = Util.extractStringOption("portfile", serverSettings);
+        try {
+            PortFile pf = getPortFile(portfile);
+            useServer(serverSettings, new String[0],
+                    new HashSet<URI>(),
+                    new HashSet<URI>(),
+                    new HashMap<URI, Set<String>>(),
+                    new HashMap<String, Set<URI>>(),
+                    new HashMap<String, Set<String>>(),
+                    new HashMap<String, String>(),
+                    sysinfo, out, err);
+        } catch (Exception e) {
+            e.printStackTrace(err);
+        }
+        return sysinfo;
+    }
+
+    /**
+     * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are
+     * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis.
+     */
+    private static int connectAndCompile(PortFile portFile, String id, String[] args,
+            Set<URI> sourcesToCompile,
+            Set<URI> visibleSources,
+            Map<String, Set<URI>> packageArtifacts,
+            Map<String, Set<String>> packageDependencies,
+            Map<String, String> packagePublicApis,
+            SysInfo sysinfo,
+            PrintStream out,
+            PrintStream err) {
+        int rc = -3;
+        try {
+            int port = portFile.getPort();
+            if (port == 0) {
+                return ERROR_BUT_TRY_AGAIN;
+            }
+            long cookie = portFile.getCookie();
+
+            // Acquire the localhost/127.0.0.1 address.
+            InetAddress addr = InetAddress.getByName(null);
+            SocketAddress sockaddr = new InetSocketAddress(addr, port);
+            Socket sock = new Socket();
+            int timeoutMs = CONNECTION_TIMEOUT * 1000;
+            try {
+                sock.connect(sockaddr, timeoutMs);
+            } catch (java.net.ConnectException e) {
+                err.println("Could not connect to javac server found in portfile: " + portFile.getFilename() + " " + e);
+                return ERROR_BUT_TRY_AGAIN;
+            }
+            if (!sock.isConnected()) {
+                err.println("Could not connect to javac server found in portfile: " + portFile.getFilename());
+                return ERROR_BUT_TRY_AGAIN;
+            }
+            BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
+            PrintWriter sockout = new PrintWriter(sock.getOutputStream());
+
+            sockout.println(PROTOCOL_COOKIE_VERSION);
+            sockout.println("" + cookie);
+            sockout.println(PROTOCOL_CWD);
+            sockout.println(System.getProperty("user.dir"));
+            sockout.println(PROTOCOL_ID);
+            sockout.println(id);
+            sockout.println(PROTOCOL_ARGS);
+            for (String s : args) {
+                StringBuffer buf = new StringBuffer();
+                String[] paths = s.split(File.pathSeparator);
+                int c = 0;
+                for (String path : paths) {
+                    File f = new File(path);
+                    if (f.isFile() || f.isDirectory()) {
+                        buf.append(f.getAbsolutePath());
+                        c++;
+                        if (c < paths.length) {
+                            buf.append(File.pathSeparator);
+                        }
+                    } else {
+                        buf = new StringBuffer(s);
+                        break;
+                    }
+                }
+                sockout.println(buf.toString());
+            }
+            sockout.println(PROTOCOL_SOURCES_TO_COMPILE);
+            for (URI uri : sourcesToCompile) {
+                sockout.println(uri.toString());
+            }
+            sockout.println(PROTOCOL_VISIBLE_SOURCES);
+            for (URI uri : visibleSources) {
+                sockout.println(uri.toString());
+            }
+            sockout.println(PROTOCOL_END);
+            sockout.flush();
+
+            StringBuffer stdout = new StringBuffer();
+            StringBuffer stderr = new StringBuffer();
+
+            if (!expect(in, PROTOCOL_STDOUT)) {
+                return ERROR_FATAL;
+            }
+            // Load stdout
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_STDERR)) {
+                    break;
+                }
+                stdout.append(l);
+                stdout.append('\n');
+            }
+            // Load stderr
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_PACKAGE_ARTIFACTS)) {
+                    break;
+                }
+                stderr.append(l);
+                stderr.append('\n');
+            }
+            // Load the package artifacts
+            Set<URI> lastUriSet = null;
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_PACKAGE_DEPENDENCIES)) {
+                    break;
+                }
+                if (l.length() > 1 && l.charAt(0) == '+') {
+                    String pkg = l.substring(1);
+                    lastUriSet = new HashSet<URI>();
+                    packageArtifacts.put(pkg, lastUriSet);
+                } else if (l.length() > 1 && lastUriSet != null) {
+                    lastUriSet.add(new URI(l.substring(1)));
+                }
+            }
+            // Load package dependencies
+            Set<String> lastPackageSet = null;
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_PACKAGE_PUBLIC_APIS)) {
+                    break;
+                }
+                if (l.length() > 1 && l.charAt(0) == '+') {
+                    String pkg = l.substring(1);
+                    lastPackageSet = new HashSet<String>();
+                    packageDependencies.put(pkg, lastPackageSet);
+                } else if (l.length() > 1 && lastPackageSet != null) {
+                    lastPackageSet.add(l.substring(1));
+                }
+            }
+            // Load package pubapis
+            Map<String, StringBuffer> tmp = new HashMap<String, StringBuffer>();
+            StringBuffer lastPublicApi = null;
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_SYSINFO)) {
+                    break;
+                }
+                if (l.length() > 1 && l.charAt(0) == '+') {
+                    String pkg = l.substring(1);
+                    lastPublicApi = new StringBuffer();
+                    tmp.put(pkg, lastPublicApi);
+                } else if (l.length() > 1 && lastPublicApi != null) {
+                    lastPublicApi.append(l.substring(1));
+                    lastPublicApi.append("\n");
+                }
+            }
+            for (String p : tmp.keySet()) {
+                assert (packagePublicApis.get(p) == null);
+                String api = tmp.get(p).toString();
+                packagePublicApis.put(p, api);
+            }
+            // Now reading the max memory possible.
+            for (;;) {
+                String l = in.readLine();
+                if (l == null) {
+                    return ERROR_FATAL;
+                }
+                if (l.equals(PROTOCOL_RETURN_CODE)) {
+                    break;
+                }
+                if (l.startsWith("num_cores=") && sysinfo != null) {
+                    sysinfo.numCores = Integer.parseInt(l.substring(10));
+                }
+                if (l.startsWith("max_memory=") && sysinfo != null) {
+                    sysinfo.maxMemory = Long.parseLong(l.substring(11));
+                }
+            }
+            String l = in.readLine();
+            if (l == null) {
+                err.println("No return value from the server!");
+                return ERROR_FATAL;
+            }
+            rc = Integer.parseInt(l);
+            out.print(stdout);
+            err.print(stderr);
+        } catch (Exception e) {
+            e.printStackTrace(err);
+        }
+        return rc;
+    }
+
+    /**
+     * Run the server thread until it exits. Either because of inactivity or because the port file has been deleted by someone else, or overtaken by some other
+     * javac server.
+     */
+    private void run(PortFile portFile, PrintStream err, int keepalive) {
+        boolean fileDeleted = false;
+        long timeSinceLastCompile;
+        try {
+            // Every 5 second (check_portfile_interval) we test if the portfile has disappeared => quit
+            // Or if the last request was finished more than 125 seconds ago => quit
+            // 125 = seconds_of_inactivity_before_shutdown+check_portfile_interval
+            serverSocket.setSoTimeout(CHECK_PORTFILE_INTERVAL*1000);
+            for (;;) {
+                try {
+                    Socket s = serverSocket.accept();
+                    CompilerThread ct = compilerPool.grabCompilerThread();
+                    ct.setSocket(s);
+                    compilerPool.execute(ct);
+                    flushLog();
+                } catch (java.net.SocketTimeoutException e) {
+                    if (compilerPool.numActiveRequests() > 0) {
+                        // Never quit while there are active requests!
+                        continue;
+                    }
+                    // If this is the timeout after the portfile
+                    // has been deleted by us. Then we truly stop.
+                    if (fileDeleted) {
+                        log("Quitting because of "+(keepalive+CHECK_PORTFILE_INTERVAL)+" seconds of inactivity!");
+                        break;
+                    }
+                    // Check if the portfile is still there.
+                    if (!portFile.exists()) {
+                        // Time to quit because the portfile was deleted by another
+                        // process, probably by the makefile that is done building.
+                        log("Quitting because portfile was deleted!");
+                        flushLog();
+                        break;
+                    }
+                    // Check if portfile.stop is still there.
+                    if (portFile.markedForStop()) {
+                        // Time to quit because another process touched the file
+                        // server.port.stop to signal that the server should stop.
+                        // This is necessary on some operating systems that lock
+                        // the port file hard!
+                        log("Quitting because a portfile.stop file was found!");
+                        portFile.delete();
+                        flushLog();
+                        break;
+                    }
+                    // Does the portfile still point to me?
+                    if (!portFile.stillMyValues()) {
+                        // Time to quit because another build has started.
+                        log("Quitting because portfile is now owned by another javac server!");
+                        flushLog();
+                        break;
+                    }
+
+                    // Check how long since the last request finished.
+                    long diff = System.currentTimeMillis() - compilerPool.lastRequestFinished();
+                    if (diff < keepalive * 1000) {
+                        // Do not quit if we have waited less than 120 seconds.
+                        continue;
+                    }
+                    // Ok, time to quit because of inactivity. Perhaps the build
+                    // was killed and the portfile not cleaned up properly.
+                    portFile.delete();
+                    fileDeleted = true;
+                    log("" + keepalive + " seconds of inactivity quitting in "
+                        + CHECK_PORTFILE_INTERVAL + " seconds!");
+                    flushLog();
+                    // Now we have a second 5 second grace
+                    // period where javac remote requests
+                    // that have loaded the data from the
+                    // recently deleted portfile can connect
+                    // and complete their requests.
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace(err);
+            e.printStackTrace(theLog);
+            flushLog();
+        } finally {
+            compilerPool.shutdown();
+        }
+        long realTime = System.currentTimeMillis() - serverStart;
+        log("Shutting down.");
+        log("Total wall clock time " + realTime + "ms build time " + totalBuildTime + "ms");
+        flushLog();
+    }
+
+    public static void cleanup(String... args) {
+        String settings = Util.findServerSettings(args);
+        if (settings == null) return;
+        String portfile = Util.extractStringOption("portfile", settings);
+        String background = Util.extractStringOption("background", settings);
+        if (background != null && background.equals("false")) {
+            // If the server runs within this jvm, then delete the portfile,
+            // since this jvm is about to exit soon.
+            File f = new File(portfile);
+            f.delete();
+        }
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/server/PortFile.java b/src/share/classes/com/sun/tools/sjavac/server/PortFile.java
new file mode 100644
index 0000000..fa5b369
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/server/PortFile.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.sjavac.server;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.channels.FileLockInterruptionException;
+import com.sun.tools.sjavac.Log;
+
+/**
+ * The PortFile class mediates access to a short binary file containing the tcp/ip port (for the localhost)
+ * and a cookie necessary for the server answering on that port. The file can be locked using file system
+ * primitives to avoid race conditions when several javac clients are started at the same. Note that file
+ * system locking is not always supported on a all operating systems and/or file systems.
+ *
+ * <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></p>
+ */
+class PortFile {
+
+    // Port file format:
+    // byte ordering: high byte first = big endian
+    // Magic nr, 4 byte int, first in file.
+    private final static int magicNr = 0x1174;
+    // Followed by a 4 byte int, with the port nr.
+    // Followed by a 8 byte long, with cookie nr.
+
+    private String filename;
+    private File file;
+    private File stopFile;
+    private RandomAccessFile rwfile;
+    private FileChannel channel;
+    private FileLock lock;
+
+    private boolean containsPortInfo;
+    private int serverPort;
+    private long serverCookie;
+    private int myServerPort;
+    private long myServerCookie;
+
+    /**
+     * Create a new portfile.
+     * @param filename is the path to the file.
+     */
+    public PortFile(String fn) throws FileNotFoundException
+    {
+        filename = fn;
+        file = new File(filename);
+        stopFile = new File(filename+".stop");
+        rwfile = new RandomAccessFile(file, "rw");
+        // The rwfile should only be readable by the owner of the process
+        // and no other! How do we do that on a RandomAccessFile?
+        channel = rwfile.getChannel();
+        containsPortInfo = false;
+        lock = null;
+    }
+
+    /**
+     * Lock the port file.
+     */
+    void lock() throws IOException {
+        lock = channel.lock();
+    }
+
+    /**
+     * Read the values from the port file in the file system.
+     * Expects the port file to be locked.
+     */
+    public void getValues()  {
+        containsPortInfo = false;
+        if (lock == null) {
+            // Not locked, remain ignorant about port file contents.
+            return;
+        }
+        try {
+            if (rwfile.length()>0) {
+                rwfile.seek(0);
+                int nr = rwfile.readInt();
+                serverPort = rwfile.readInt();
+                serverCookie = rwfile.readLong();
+
+                if (nr == magicNr) {
+                    containsPortInfo = true;
+                } else {
+                    containsPortInfo = false;
+                }
+            }
+        } catch (Exception e) {
+            containsPortInfo = false;
+        }
+    }
+
+    /**
+     * Did the locking and getValues succeed?
+     */
+    public boolean containsPortInfo() {
+        return containsPortInfo;
+    }
+
+    /**
+     * If so, then we can acquire the tcp/ip port on localhost.
+     */
+    public int getPort() {
+        assert(containsPortInfo);
+        return serverPort;
+    }
+
+    /**
+     * If so, then we can acquire the server cookie.
+     */
+    public long getCookie() {
+        assert(containsPortInfo);
+        return serverCookie;
+    }
+
+    /**
+     * Store the values into the locked port file.
+     */
+    public void setValues(int port, long cookie) throws IOException {
+        assert(lock != null);
+        rwfile.seek(0);
+        // Write the magic nr that identifes a port file.
+        rwfile.writeInt(magicNr);
+        rwfile.writeInt(port);
+        rwfile.writeLong(cookie);
+        myServerPort = port;
+        myServerCookie = cookie;
+    }
+
+    /**
+     * Delete the port file.
+     */
+    public void delete() throws IOException {
+        // Access to file must be closed before deleting.
+        rwfile.close();
+        // Now delete.
+        file.delete();
+    }
+
+    /**
+     * Is the port file still there?
+     */
+    public boolean exists() throws IOException {
+        return file.exists();
+    }
+
+    /**
+     * Is a stop file there?
+     */
+    public boolean markedForStop() throws IOException {
+        if (stopFile.exists()) {
+            try {
+                stopFile.delete();
+            } catch (Exception e)
+            {}
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Unlock the port file.
+     */
+    public void unlock() throws IOException {
+        assert(lock != null);
+        lock.release();
+        lock = null;
+    }
+
+    /**
+     * Wait for the port file to contain values that look valid.
+     * Return true, if a-ok, false if the valid values did not materialize within 5 seconds.
+     */
+    public synchronized boolean waitForValidValues() throws IOException, FileNotFoundException {
+        for (int tries = 0; tries < 50; tries++) {
+            lock();
+            getValues();
+            unlock();
+            if (containsPortInfo) {
+                Log.debug("Found valid values in port file after waiting "+(tries*100)+"ms");
+                return true;
+            }
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e)
+            {}
+        }
+        Log.debug("Gave up waiting for valid values in port file");
+        return false;
+    }
+
+    /**
+     * Check if the portfile still contains my values, assuming that I am the server.
+     */
+    public synchronized boolean stillMyValues() throws IOException, FileNotFoundException {
+        for (;;) {
+            try {
+                lock();
+                getValues();
+                unlock();
+                if (containsPortInfo) {
+                    if (serverPort == myServerPort &&
+                        serverCookie == myServerCookie) {
+                        // Everything is ok.
+                        return true;
+                    }
+                    // Someone has overwritten the port file.
+                    // Probably another javac server, lets quit.
+                    return false;
+                }
+                // Something else is wrong with the portfile. Lets quit.
+                return false;
+            } catch (FileLockInterruptionException e) {
+                continue;
+            }
+            catch (ClosedChannelException e) {
+                // The channel has been closed since sjavac is exiting.
+                return false;
+            }
+        }
+    }
+
+    /**
+     * Return the name of the port file.
+     */
+    public String getFilename() {
+        return filename;
+    }
+}
diff --git a/src/share/classes/com/sun/tools/sjavac/server/SysInfo.java b/src/share/classes/com/sun/tools/sjavac/server/SysInfo.java
new file mode 100644
index 0000000..3a79246
--- /dev/null
+++ b/src/share/classes/com/sun/tools/sjavac/server/SysInfo.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+/**
+ * A utility class used to report information about the system
+ * where the javac server is running.
+ *
+ * <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></p>
+ */
+package com.sun.tools.sjavac.server;
+
+public class SysInfo {
+    public int numCores;
+    public long maxMemory;
+
+    public SysInfo(int nc, long mm) {
+        numCores = nc;
+        maxMemory = mm;
+    }
+}
diff --git a/src/share/classes/javax/annotation/processing/AbstractProcessor.java b/src/share/classes/javax/annotation/processing/AbstractProcessor.java
index db7053a..0ec4b71 100644
--- a/src/share/classes/javax/annotation/processing/AbstractProcessor.java
+++ b/src/share/classes/javax/annotation/processing/AbstractProcessor.java
@@ -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
@@ -28,6 +28,7 @@ package javax.annotation.processing;
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Collections;
+import java.util.Objects;
 import javax.lang.model.element.*;
 import javax.lang.model.SourceVersion;
 import javax.tools.Diagnostic;
@@ -37,7 +38,7 @@ import javax.tools.Diagnostic;
  * superclass for most concrete annotation processors.  This class
  * examines annotation values to compute the {@linkplain
  * #getSupportedOptions options}, {@linkplain
- * #getSupportedAnnotationTypes annotations}, and {@linkplain
+ * #getSupportedAnnotationTypes annotation types}, and {@linkplain
  * #getSupportedSourceVersion source version} supported by its
  * subtypes.
  *
@@ -146,8 +147,7 @@ public abstract class AbstractProcessor implements Processor {
     public synchronized void init(ProcessingEnvironment processingEnv) {
         if (initialized)
             throw new IllegalStateException("Cannot call init more than once.");
-        if (processingEnv == null)
-            throw new NullPointerException("Tool provided null ProcessingEnvironment");
+        Objects.requireNonNull(processingEnv, "Tool provided null ProcessingEnvironment");
 
         this.processingEnv = processingEnv;
         initialized = true;
diff --git a/src/share/classes/javax/annotation/processing/Completions.java b/src/share/classes/javax/annotation/processing/Completions.java
index 3d96204..044ae20 100644
--- a/src/share/classes/javax/annotation/processing/Completions.java
+++ b/src/share/classes/javax/annotation/processing/Completions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,8 +25,6 @@
 
 package javax.annotation.processing;
 
-import java.util.Arrays;
-
 /**
  * Utility class for assembling {@link Completion} objects.
  *
diff --git a/src/share/classes/javax/annotation/processing/FilerException.java b/src/share/classes/javax/annotation/processing/FilerException.java
index d33b631..30a1388 100644
--- a/src/share/classes/javax/annotation/processing/FilerException.java
+++ b/src/share/classes/javax/annotation/processing/FilerException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package javax.annotation.processing;
 
 import java.io.IOException;
-import javax.annotation.processing.Filer;
 
 /**
  * Indicates a {@link Filer} detected an attempt to open a file that
diff --git a/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java b/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java
index 6924564..5ade776 100644
--- a/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java
+++ b/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,12 +26,10 @@
 package javax.annotation.processing;
 
 import java.util.Map;
-import java.util.List;
 import java.util.Locale;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
-import java.io.File;
 
 /**
  * An annotation processing tool framework will {@linkplain
diff --git a/src/share/classes/javax/annotation/processing/Processor.java b/src/share/classes/javax/annotation/processing/Processor.java
index a466bdd..c898e74 100644
--- a/src/share/classes/javax/annotation/processing/Processor.java
+++ b/src/share/classes/javax/annotation/processing/Processor.java
@@ -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
@@ -26,6 +26,8 @@
 package javax.annotation.processing;
 
 import java.util.Set;
+import javax.lang.model.util.Elements;
+import javax.lang.model.AnnotatedConstruct;
 import javax.lang.model.element.*;
 import javax.lang.model.SourceVersion;
 
@@ -88,23 +90,52 @@ import javax.lang.model.SourceVersion;
  * configuration mechanisms, such as command line options; for
  * details, refer to the particular tool's documentation.  Which
  * processors the tool asks to {@linkplain #process run} is a function
- * of what annotations are present on the {@linkplain
+ * of the types of the annotations <em>{@linkplain AnnotatedConstruct present}</em>
+ * on the {@linkplain
  * RoundEnvironment#getRootElements root elements}, what {@linkplain
  * #getSupportedAnnotationTypes annotation types a processor
- * processes}, and whether or not a processor {@linkplain #process
- * claims the annotations it processes}.  A processor will be asked to
+ * supports}, and whether or not a processor {@linkplain #process
+ * claims the annotation types it processes}.  A processor will be asked to
  * process a subset of the annotation types it supports, possibly an
  * empty set.
  *
- * For a given round, the tool computes the set of annotation types on
- * the root elements.  If there is at least one annotation type
- * present, as processors claim annotation types, they are removed
- * from the set of unmatched annotations.  When the set is empty or no
- * more processors are available, the round has run to completion.  If
+ * For a given round, the tool computes the set of annotation types
+ * that are present on the elements enclosed within the root elements.
+ * If there is at least one annotation type present, then as
+ * processors claim annotation types, they are removed from the set of
+ * unmatched annotation types.  When the set is empty or no more
+ * processors are available, the round has run to completion.  If
  * there are no annotation types present, annotation processing still
  * occurs but only <i>universal processors</i> which support
- * processing {@code "*"} can claim the (empty) set of annotation
- * types.
+ * processing all annotation types, {@code "*"}, can claim the (empty)
+ * set of annotation types.
+ *
+ * <p>An annotation type is considered present if there is at least
+ * one annotation of that type present on an element enclosed within
+ * the root elements of a round. For this purpose, a type parameter is
+ * considered to be enclosed by its {@linkplain
+ * TypeParameterElement#getGenericElement generic
+ * element}. Annotations on {@linkplain
+ * java.lang.annotation.ElementType#TYPE_USE type uses}, as opposed to
+ * annotations on elements, are ignored when computing whether or not
+ * an annotation type is present.
+ *
+ * <p>An annotation is present if it meets the definition of being
+ * present given in {@link AnnotatedConstruct}. In brief, an
+ * annotation is considered present for the purposes of discovery if
+ * it is directly present or present via inheritance. An annotation is
+ * <em>not</em> considered present by virtue of being wrapped by a
+ * container annotation. Operationally, this is equivalent to an
+ * annotation being present on an element if and only if it would be
+ * included in the results of {@link
+ * Elements#getAllAnnotationMirrors(Element)} called on that element. Since
+ * annotations inside container annotations are not considered
+ * present, to properly process {@linkplain
+ * java.lang.annotation.Repeatable repeatable annotation types},
+ * processors are advised to include both the repeatable annotation
+ * type and its containing annotation type in the set of {@linkplain
+ * #getSupportedAnnotationTypes() supported annotation types} of a
+ * processor.
  *
  * <p>Note that if a processor supports {@code "*"} and returns {@code
  * true}, all annotations are claimed.  Therefore, a universal
@@ -257,10 +288,10 @@ public interface Processor {
     /**
      * Processes a set of annotation types on type elements
      * originating from the prior round and returns whether or not
-     * these annotations are claimed by this processor.  If {@code
-     * true} is returned, the annotations are claimed and subsequent
+     * these annotation types are claimed by this processor.  If {@code
+     * true} is returned, the annotation types are claimed and subsequent
      * processors will not be asked to process them; if {@code false}
-     * is returned, the annotations are unclaimed and subsequent
+     * is returned, the annotation types are unclaimed and subsequent
      * processors may be asked to process them.  A processor may
      * always return the same boolean value or may vary the result
      * based on chosen criteria.
@@ -271,7 +302,7 @@ public interface Processor {
      *
      * @param annotations the annotation types requested to be processed
      * @param roundEnv  environment for information about the current and prior round
-     * @return whether or not the set of annotations are claimed by this processor
+     * @return whether or not the set of annotation types are claimed by this processor
      */
     boolean process(Set<? extends TypeElement> annotations,
                     RoundEnvironment roundEnv);
diff --git a/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java b/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java
index 8afc71f..fe3ee8d 100644
--- a/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java
+++ b/src/share/classes/javax/annotation/processing/SupportedAnnotationTypes.java
@@ -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 @@ import static java.lang.annotation.ElementType.*;
 @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();
 }
diff --git a/src/share/classes/javax/annotation/processing/SupportedOptions.java b/src/share/classes/javax/annotation/processing/SupportedOptions.java
index 5d6017d..3a9dd29 100644
--- a/src/share/classes/javax/annotation/processing/SupportedOptions.java
+++ b/src/share/classes/javax/annotation/processing/SupportedOptions.java
@@ -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 @@ import static java.lang.annotation.ElementType.*;
 @Target(TYPE)
 @Retention(RUNTIME)
 public @interface SupportedOptions {
-  String [] value();
+    /**
+     * Returns the supported options.
+     * @return the supported options
+     */
+    String [] value();
 }
diff --git a/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java b/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java
index c28a1da..59c861c 100644
--- a/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java
+++ b/src/share/classes/javax/annotation/processing/SupportedSourceVersion.java
@@ -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 @@ import javax.lang.model.SourceVersion;
 @Target(TYPE)
 @Retention(RUNTIME)
 public @interface SupportedSourceVersion {
+    /**
+     * Returns the latest supported source version.
+     * @return the latest supported source version
+     */
     SourceVersion value();
 }
diff --git a/src/share/classes/javax/lang/model/AnnotatedConstruct.java b/src/share/classes/javax/lang/model/AnnotatedConstruct.java
new file mode 100644
index 0000000..f02f5cd
--- /dev/null
+++ b/src/share/classes/javax/lang/model/AnnotatedConstruct.java
@@ -0,0 +1,235 @@
+/*
+ * 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.
+ */
+
+package javax.lang.model;
+
+import java.lang.annotation.*;
+import java.util.List;
+import javax.lang.model.element.*;
+import javax.lang.model.type.*;
+
+/**
+ * Represents a construct that can be annotated.
+ *
+ * A construct is either an {@linkplain
+ * javax.lang.model.element.Element element} or a {@linkplain
+ * javax.lang.model.type.TypeMirror type}.  Annotations on an element
+ * are on a <em>declaration</em>, whereas annotations on a type are on
+ * a specific <em>use</em> of a type name.
+ *
+ * The terms <em>directly present</em>, <em>present</em>,
+ * <em>indirectly present</em>, and <em>associated </em> are used
+ * throughout this interface to describe precisely which annotations
+ * are returned by the methods defined herein.
+ *
+ * <p>In the definitions below, an annotation <i>A</i> has an
+ * annotation type <i>AT</i>. If <i>AT</i> is a repeatable annotation
+ * type, the type of the containing annotation is <i>ATC</i>.
+ *
+ * <p>Annotation <i>A</i> is <em>directly present</em> on a construct
+ * <i>C</i> if either:
+ *
+ * <ul>
+ *
+ * <li><i>A</i> is explicitly or implicitly declared as applying to
+ * the source code representation of <i>C</i>.
+ *
+ * <p>Typically, if exactly one annotation of type <i>AT</i> appears in
+ * the source code of representation of <i>C</i>, then <i>A</i> is
+ * explicitly declared as applying to <i>C</i>.
+ *
+ * If there are multiple annotations of type <i>AT</i> present on
+ * <i>C</i>, then if <i>AT</i> is repeatable annotation type, an
+ * annotation of type <i>ATC</i> is implicitly declared on <i>C</i>.
+ *
+ * <li> A representation of <i>A</i> appears in the executable output
+ * for <i>C</i>, such as the {@code RuntimeVisibleAnnotations} or
+ * {@code RuntimeVisibleParameterAnnotations} attributes of a class
+ * file.
+ *
+ * </ul>
+ *
+ * <p>An annotation <i>A</i> is <em>present</em> on a
+ * construct <i>C</i> if either:
+ * <ul>
+ *
+ * <li><i>A</i> is directly present on <i>C</i>.
+ *
+ * <li>No annotation of type <i>AT</i> is directly present on
+ * <i>C</i>, and <i>C</i> is a class and <i>AT</i> is inheritable
+ * and <i>A</i> is present on the superclass of <i>C</i>.
+ *
+ * </ul>
+ *
+ * An annotation <i>A</i> is <em>indirectly present</em> on a construct
+ * <i>C</i> if both:
+ *
+ * <ul>
+ *
+ * <li><i>AT</i> is a repeatable annotation type with a containing
+ * annotation type <i>ATC</i>.
+ *
+ * <li>An annotation of type <i>ATC</i> is directly present on
+ * <i>C</i> and <i>A</i> is an annotation included in the result of
+ * calling the {@code value} method of the directly present annotation
+ * of type <i>ATC</i>.
+ *
+ * </ul>
+ *
+ * An annotation <i>A</i> is <em>associated</em> with a construct
+ * <i>C</i> if either:
+ *
+ * <ul>
+ *
+ * <li> <i>A</i> is directly or indirectly present on <i>C</i>.
+ *
+ * <li> No annotation of type <i>AT</i> is directly or indirectly
+ * present on <i>C</i>, and <i>C</i> is a class, and <i>AT</i> is
+ * inheritable, and <i>A</i> is associated with the superclass of
+ * <i>C</i>.
+ *
+ * </ul>
+ *
+ * @since 1.8
+ * @jls 9.6 Annotation Types
+ * @jls 9.6.3.3 @Inherited
+ */
+public interface AnnotatedConstruct {
+    /**
+     * Returns the annotations that are <em>directly present</em> on
+     * this construct.
+     *
+     * @return the annotations <em>directly present</em> on this
+     * construct; an empty list if there are none
+     */
+    List<? extends AnnotationMirror> getAnnotationMirrors();
+
+    /**
+     * Returns this construct's annotation of the specified type if
+     * such an annotation is <em>present</em>, else {@code null}.
+     *
+     * <p> The annotation returned by this method could contain an element
+     * whose value is of type {@code Class}.
+     * This value cannot be returned directly:  information necessary to
+     * locate and load a class (such as the class loader to use) is
+     * not available, and the class might not be loadable at all.
+     * Attempting to read a {@code Class} object by invoking the relevant
+     * method on the returned annotation
+     * will result in a {@link MirroredTypeException},
+     * from which the corresponding {@link TypeMirror} may be extracted.
+     * Similarly, attempting to read a {@code Class[]}-valued element
+     * will result in a {@link MirroredTypesException}.
+     *
+     * <blockquote>
+     * <i>Note:</i> This method is unlike others in this and related
+     * interfaces.  It operates on runtime reflective information —
+     * representations of annotation types currently loaded into the
+     * VM — rather than on the representations defined by and used
+     * throughout these interfaces.  Consequently, calling methods on
+     * the returned annotation object can throw many of the exceptions
+     * that can be thrown when calling methods on an annotation object
+     * returned by core reflection.  This method is intended for
+     * callers that are written to operate on a known, fixed set of
+     * annotation types.
+     * </blockquote>
+     *
+     * @param <A>  the annotation type
+     * @param annotationType  the {@code Class} object corresponding to
+     *          the annotation type
+     * @return this construct's annotation for the specified
+     * annotation type if present, else {@code null}
+     *
+     * @see #getAnnotationMirrors()
+     * @see java.lang.reflect.AnnotatedElement#getAnnotation
+     * @see EnumConstantNotPresentException
+     * @see AnnotationTypeMismatchException
+     * @see IncompleteAnnotationException
+     * @see MirroredTypeException
+     * @see MirroredTypesException
+     * @jls 9.6.1 Annotation Type Elements
+     */
+    <A extends Annotation> A getAnnotation(Class<A> annotationType);
+
+    /**
+     * Returns annotations that are <em>associated</em> with this construct.
+     *
+     * If there are no annotations associated with this construct, the
+     * return value is an array of length 0.
+     *
+     * The order of annotations which are directly or indirectly
+     * present on a construct <i>C</i> is computed as if indirectly present
+     * annotations on <i>C</i> are directly present on <i>C</i> in place of their
+     * container annotation, in the order in which they appear in the
+     * value element of the container annotation.
+     *
+     * The difference between this method and {@link #getAnnotation(Class)}
+     * is that this method detects if its argument is a <em>repeatable
+     * annotation type</em>, and if so, attempts to find one or more
+     * annotations of that type by "looking through" a container annotation.
+     *
+     * <p> The annotations returned by this method could contain an element
+     * whose value is of type {@code Class}.
+     * This value cannot be returned directly:  information necessary to
+     * locate and load a class (such as the class loader to use) is
+     * not available, and the class might not be loadable at all.
+     * Attempting to read a {@code Class} object by invoking the relevant
+     * method on the returned annotation
+     * will result in a {@link MirroredTypeException},
+     * from which the corresponding {@link TypeMirror} may be extracted.
+     * Similarly, attempting to read a {@code Class[]}-valued element
+     * will result in a {@link MirroredTypesException}.
+     *
+     * <blockquote>
+     * <i>Note:</i> This method is unlike others in this and related
+     * interfaces.  It operates on runtime reflective information —
+     * representations of annotation types currently loaded into the
+     * VM — rather than on the representations defined by and used
+     * throughout these interfaces.  Consequently, calling methods on
+     * the returned annotation object can throw many of the exceptions
+     * that can be thrown when calling methods on an annotation object
+     * returned by core reflection.  This method is intended for
+     * callers that are written to operate on a known, fixed set of
+     * annotation types.
+     * </blockquote>
+     *
+     * @param <A>  the annotation type
+     * @param annotationType  the {@code Class} object corresponding to
+     *          the annotation type
+     * @return this construct's annotations for the specified annotation
+     *         type if present on this construct, else an empty array
+     *
+     * @see #getAnnotationMirrors()
+     * @see #getAnnotation(java.lang.Class)
+     * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType
+     * @see EnumConstantNotPresentException
+     * @see AnnotationTypeMismatchException
+     * @see IncompleteAnnotationException
+     * @see MirroredTypeException
+     * @see MirroredTypesException
+     * @jls 9.6 Annotation Types
+     * @jls 9.6.1 Annotation Type Elements
+     */
+    <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType);
+}
diff --git a/src/share/classes/javax/lang/model/SourceVersion.java b/src/share/classes/javax/lang/model/SourceVersion.java
index 5097672..ecb079d 100644
--- a/src/share/classes/javax/lang/model/SourceVersion.java
+++ b/src/share/classes/javax/lang/model/SourceVersion.java
@@ -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,13 +46,15 @@ import java.util.HashSet;
  */
 public enum SourceVersion {
     /*
-     * Summary of language evoluation
+     * Summary of language evolution
      * 1.1: nested classes
      * 1.2: strictfp
      * 1.3: no changes
      * 1.4: assert
      * 1.5: annotations, generics, autoboxing, var-args...
      * 1.6: no changes
+     * 1.7: diamond syntax, try-with-resources, etc.
+     * 1.8: lambda expressions and default methods
      */
 
     /**
@@ -122,9 +124,21 @@ public enum SourceVersion {
      * The version recognized by the Java Platform, Standard Edition
      * 7.
      *
+     * Additions in this release include, diamond syntax for
+     * constructors, {@code try}-with-resources, strings in switch,
+     * binary literals, and multi-catch.
      * @since 1.7
      */
-    RELEASE_7;
+    RELEASE_7,
+
+    /**
+     * The version recognized by the Java Platform, Standard Edition
+     * 8.
+     *
+     * Additions in this release include lambda expressions and default methods.
+     * @since 1.8
+     */
+    RELEASE_8;
 
     // Note that when adding constants for newer releases, the
     // behavior of latest() and latestSupported() must be updated too.
@@ -135,7 +149,7 @@ public enum SourceVersion {
      * @return the latest source version that can be modeled
      */
     public static SourceVersion latest() {
-        return RELEASE_7;
+        return RELEASE_8;
     }
 
     private static final SourceVersion latestSupported = getLatestSupported();
@@ -143,9 +157,12 @@ public enum SourceVersion {
     private static SourceVersion getLatestSupported() {
         try {
             String specVersion = System.getProperty("java.specification.version");
-            if ("1.7".equals(specVersion))
+
+            if ("1.8".equals(specVersion))
+                return RELEASE_8;
+            else if("1.7".equals(specVersion))
                 return RELEASE_7;
-            else if ("1.6".equals(specVersion))
+            else if("1.6".equals(specVersion))
                 return RELEASE_6;
         } catch (SecurityException se) {}
 
diff --git a/src/share/classes/javax/lang/model/element/AnnotationValue.java b/src/share/classes/javax/lang/model/element/AnnotationValue.java
index 3b66bad..68b5421 100644
--- a/src/share/classes/javax/lang/model/element/AnnotationValue.java
+++ b/src/share/classes/javax/lang/model/element/AnnotationValue.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,6 @@
 
 package javax.lang.model.element;
 
-
-import java.util.List;
-import javax.lang.model.type.*;
-
 /**
  * Represents a value of an annotation type element.
  * A value is of one of the following types:
diff --git a/src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java b/src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java
index 888ab35..6d01d0f 100644
--- a/src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java
+++ b/src/share/classes/javax/lang/model/element/AnnotationValueVisitor.java
@@ -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
@@ -61,6 +61,18 @@ import javax.lang.model.type.TypeMirror;
  * parameters, return type, etc. rather than one of the abstract
  * classes.
  *
+ * <p>Note that methods to accommodate new language constructs could
+ * be added in a source <em>compatible</em> way if they were added as
+ * <em>default methods</em>.  However, default methods are only
+ * available on Java SE 8 and higher releases and the {@code
+ * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * also be runnable on Java SE 7.  Therefore, default methods
+ * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * to cover Java SE 8 language features.  However, default methods may
+ * be used in subsequent revisions of the {@code javax.lang.model.*}
+ * packages that are only required to run on Java SE 8 and higher
+ * platform versions.
+ *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  * @author Joseph D. Darcy
diff --git a/src/share/classes/javax/lang/model/element/Element.java b/src/share/classes/javax/lang/model/element/Element.java
index 06500d2..bc007cf 100644
--- a/src/share/classes/javax/lang/model/element/Element.java
+++ b/src/share/classes/javax/lang/model/element/Element.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -32,7 +32,6 @@ import java.lang.annotation.IncompleteAnnotationException;
 import java.util.List;
 import java.util.Set;
 
-import javax.lang.model.element.Modifier;
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
@@ -61,8 +60,7 @@ import javax.lang.model.util.*;
  * @see TypeMirror
  * @since 1.6
  */
-public interface Element {
-
+public interface Element extends javax.lang.model.AnnotatedConstruct {
     /**
      * Returns the type defined by this element.
      *
@@ -90,66 +88,6 @@ public interface Element {
     ElementKind getKind();
 
     /**
-     * Returns the annotations that are directly present on this element.
-     *
-     * <p> To get inherited annotations as well, use
-     * {@link Elements#getAllAnnotationMirrors(Element) getAllAnnotationMirrors}.
-     *
-     * @see ElementFilter
-     *
-     * @return the annotations directly present on this element;
-     *          an empty list if there are none
-     */
-    List<? extends AnnotationMirror> getAnnotationMirrors();
-
-    /**
-     * Returns this element's annotation for the specified type if
-     * such an annotation is present, else {@code null}.  The
-     * annotation may be either inherited or directly present on this
-     * element.
-     *
-     * <p> The annotation returned by this method could contain an element
-     * whose value is of type {@code Class}.
-     * This value cannot be returned directly:  information necessary to
-     * locate and load a class (such as the class loader to use) is
-     * not available, and the class might not be loadable at all.
-     * Attempting to read a {@code Class} object by invoking the relevant
-     * method on the returned annotation
-     * will result in a {@link MirroredTypeException},
-     * from which the corresponding {@link TypeMirror} may be extracted.
-     * Similarly, attempting to read a {@code Class[]}-valued element
-     * will result in a {@link MirroredTypesException}.
-     *
-     * <blockquote>
-     * <i>Note:</i> This method is unlike others in this and related
-     * interfaces.  It operates on runtime reflective information —
-     * representations of annotation types currently loaded into the
-     * VM — rather than on the representations defined by and used
-     * throughout these interfaces.  Consequently, calling methods on
-     * the returned annotation object can throw many of the exceptions
-     * that can be thrown when calling methods on an annotation object
-     * returned by core reflection.  This method is intended for
-     * callers that are written to operate on a known, fixed set of
-     * annotation types.
-     * </blockquote>
-     *
-     * @param <A>  the annotation type
-     * @param annotationType  the {@code Class} object corresponding to
-     *          the annotation type
-     * @return this element's annotation for the specified annotation
-     *         type if present on this element, else {@code null}
-     *
-     * @see #getAnnotationMirrors()
-     * @see java.lang.reflect.AnnotatedElement#getAnnotation
-     * @see EnumConstantNotPresentException
-     * @see AnnotationTypeMismatchException
-     * @see IncompleteAnnotationException
-     * @see MirroredTypeException
-     * @see MirroredTypesException
-     */
-    <A extends Annotation> A getAnnotation(Class<A> annotationType);
-
-    /**
      * Returns the modifiers of this element, excluding annotations.
      * Implicit modifiers, such as the {@code public} and {@code static}
      * modifiers of interface members, are included.
@@ -180,6 +118,10 @@ public interface Element {
      * instance initializer}, an empty name is returned.
      *
      * @return the simple name of this element
+     * @see PackageElement#getSimpleName
+     * @see ExecutableElement#getSimpleName
+     * @see TypeElement#getSimpleName
+     * @see VariableElement#getSimpleName
      */
     Name getSimpleName();
 
@@ -203,6 +145,11 @@ public interface Element {
      * {@linkplain TypeParameterElement#getGenericElement the
      * generic element} of the type parameter is returned.
      *
+     * <li> If this is a {@linkplain
+     * VariableElement#getEnclosingElement method or constructor
+     * parameter}, {@linkplain ExecutableElement the executable
+     * element} which declares the parameter is returned.
+     *
      * </ul>
      *
      * @return the enclosing element, or {@code null} if there is none
@@ -214,14 +161,13 @@ public interface Element {
      * Returns the elements that are, loosely speaking, directly
      * enclosed by this element.
      *
-     * A class or interface is considered to enclose the fields,
-     * methods, constructors, and member types that it directly
-     * declares.  This includes any (implicit) default constructor and
-     * the implicit {@code values} and {@code valueOf} methods of an
-     * enum type.
+     * A {@linkplain TypeElement#getEnclosedElements class or
+     * interface} is considered to enclose the fields, methods,
+     * constructors, and member types that it directly declares.
      *
-     * A package encloses the top-level classes and interfaces within
-     * it, but is not considered to enclose subpackages.
+     * A {@linkplain PackageElement#getEnclosedElements package}
+     * encloses the top-level classes and interfaces within it, but is
+     * not considered to enclose subpackages.
      *
      * Other kinds of elements are not currently considered to enclose
      * any elements; however, that may change as this API or the
@@ -231,6 +177,8 @@ public interface Element {
      * methods in {@link ElementFilter}.
      *
      * @return the enclosed elements, or an empty list if none
+     * @see PackageElement#getEnclosedElements
+     * @see TypeElement#getEnclosedElements
      * @see Elements#getAllMembers
      * @jls 8.8.9 Default Constructor
      * @jls 8.9 Enums
@@ -263,6 +211,19 @@ public interface Element {
      */
     int hashCode();
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p> To get inherited annotations as well, use {@link
+     * Elements#getAllAnnotationMirrors(Element)
+     * getAllAnnotationMirrors}.
+     *
+     * @see ElementFilter
+     * @since 1.6
+     */
+    @Override
+    List<? extends AnnotationMirror> getAnnotationMirrors();
     /**
      * Applies a visitor to this element.
      *
diff --git a/src/share/classes/javax/lang/model/element/ElementVisitor.java b/src/share/classes/javax/lang/model/element/ElementVisitor.java
index 34fb932..56c07bd 100644
--- a/src/share/classes/javax/lang/model/element/ElementVisitor.java
+++ b/src/share/classes/javax/lang/model/element/ElementVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -52,6 +52,18 @@ import javax.lang.model.util.*;
  * parameters, return type, etc. rather than one of the abstract
  * classes.
  *
+ * <p>Note that methods to accommodate new language constructs could
+ * be added in a source <em>compatible</em> way if they were added as
+ * <em>default methods</em>.  However, default methods are only
+ * available on Java SE 8 and higher releases and the {@code
+ * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * also be runnable on Java SE 7.  Therefore, default methods
+ * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * to cover Java SE 8 language features.  However, default methods may
+ * be used in subsequent revisions of the {@code javax.lang.model.*}
+ * packages that are only required to run on Java SE 8 and higher
+ * platform versions.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
diff --git a/src/share/classes/javax/lang/model/element/ExecutableElement.java b/src/share/classes/javax/lang/model/element/ExecutableElement.java
index 9d514f2..ec72899 100644
--- a/src/share/classes/javax/lang/model/element/ExecutableElement.java
+++ b/src/share/classes/javax/lang/model/element/ExecutableElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -26,7 +26,6 @@
 package javax.lang.model.element;
 
 import java.util.List;
-import javax.lang.model.util.Types;
 import javax.lang.model.type.*;
 
 /**
@@ -70,6 +69,25 @@ public interface ExecutableElement extends Element, Parameterizable {
     List<? extends VariableElement> getParameters();
 
     /**
+     * Returns the receiver type of this executable,
+     * or {@link javax.lang.model.type.NoType NoType} with
+     * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
+     * if the executable has no receiver type.
+     *
+     * An executable which is an instance method, or a constructor of an
+     * inner class, has a receiver type derived from the {@linkplain
+     * #getEnclosingElement declaring type}.
+     *
+     * An executable which is a static method, or a constructor of a
+     * non-inner class, or an initializer (static or instance), has no
+     * receiver type.
+     *
+     * @return the receiver type of this executable
+     * @since 1.8
+     */
+    TypeMirror getReceiverType();
+
+    /**
      * Returns {@code true} if this method or constructor accepts a variable
      * number of arguments and returns {@code false} otherwise.
      *
@@ -79,6 +97,16 @@ public interface ExecutableElement extends Element, Parameterizable {
     boolean isVarArgs();
 
     /**
+     * Returns {@code true} if this method is a default method and
+     * returns {@code false} otherwise.
+     *
+     * @return {@code true} if this method is a default method and
+     * {@code false} otherwise
+     * @since 1.8
+     */
+    boolean isDefault();
+
+    /**
      * Returns the exceptions and other throwables listed in this
      * method or constructor's {@code throws} clause in declaration
      * order.
diff --git a/src/share/classes/javax/lang/model/element/Modifier.java b/src/share/classes/javax/lang/model/element/Modifier.java
index 2b6d8ac..6a804b2 100644
--- a/src/share/classes/javax/lang/model/element/Modifier.java
+++ b/src/share/classes/javax/lang/model/element/Modifier.java
@@ -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
@@ -53,6 +53,11 @@ public enum Modifier {
     /** The modifier {@code protected} */       PROTECTED,
     /** The modifier {@code private} */         PRIVATE,
     /** The modifier {@code abstract} */        ABSTRACT,
+    /**
+     * The modifier {@code default}
+     * @since 1.8
+     */
+     DEFAULT,
     /** The modifier {@code static} */          STATIC,
     /** The modifier {@code final} */           FINAL,
     /** The modifier {@code transient} */       TRANSIENT,
@@ -61,16 +66,10 @@ public enum Modifier {
     /** The modifier {@code native} */          NATIVE,
     /** The modifier {@code strictfp} */        STRICTFP;
 
-
-    private String lowercase = null;    // modifier name in lowercase
-
     /**
      * Returns this modifier's name in lowercase.
      */
     public String toString() {
-        if (lowercase == null) {
-           lowercase = name().toLowerCase(java.util.Locale.US);
-        }
-        return lowercase;
+        return name().toLowerCase(java.util.Locale.US);
     }
 }
diff --git a/src/share/classes/javax/lang/model/element/NestingKind.java b/src/share/classes/javax/lang/model/element/NestingKind.java
index 5e89aaf..b618c48 100644
--- a/src/share/classes/javax/lang/model/element/NestingKind.java
+++ b/src/share/classes/javax/lang/model/element/NestingKind.java
@@ -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 @@ package javax.lang.model.element;
  * @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 @@ public enum NestingKind {
      * 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;
diff --git a/src/share/classes/javax/lang/model/element/PackageElement.java b/src/share/classes/javax/lang/model/element/PackageElement.java
index 66f1386..1aafd34 100644
--- a/src/share/classes/javax/lang/model/element/PackageElement.java
+++ b/src/share/classes/javax/lang/model/element/PackageElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
 
 package javax.lang.model.element;
 
+import java.util.List;
+
 /**
  * Represents a package program element.  Provides access to information
  * about the package and its members.
@@ -49,7 +51,7 @@ public interface PackageElement extends Element, QualifiedNameable {
 
     /**
      * Returns the simple name of this package.  For an unnamed
-     * package, an empty name is returned
+     * package, an empty name is returned.
      *
      * @return the simple name of this package or an empty name if
      * this is an unnamed package
@@ -58,6 +60,18 @@ public interface PackageElement extends Element, QualifiedNameable {
     Name getSimpleName();
 
     /**
+     * Returns the {@linkplain NestingKind#TOP_LEVEL top-level}
+     * classes and interfaces within this package.  Note that
+     * subpackages are <em>not</em> considered to be enclosed by a
+     * package.
+     *
+     * @return the top-level classes and interfaces within this
+     * package
+     */
+    @Override
+    List<? extends Element> getEnclosedElements();
+
+    /**
      * Returns {@code true} is this is an unnamed package and {@code
      * false} otherwise.
      *
diff --git a/src/share/classes/javax/lang/model/element/TypeElement.java b/src/share/classes/javax/lang/model/element/TypeElement.java
index d73adfe..d25c2e3 100644
--- a/src/share/classes/javax/lang/model/element/TypeElement.java
+++ b/src/share/classes/javax/lang/model/element/TypeElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,12 @@ import javax.lang.model.util.*;
  */
 public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
     /**
-     * {@inheritDoc}
+     * Returns the fields, methods, constructors, and member types
+     * that are directly declared in this class or interface.
+     *
+     * This includes any (implicit) default constructor and
+     * the implicit {@code values} and {@code valueOf} methods of an
+     * enum type.
      *
      * <p> Note that as a particular instance of the {@linkplain
      * javax.lang.model.element general accuracy requirements} and the
@@ -75,6 +80,7 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
      *
      * @return the enclosed elements in proper order, or an empty list if none
      */
+    @Override
     List<? extends Element> getEnclosedElements();
 
     /**
@@ -105,7 +111,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
      */
     Name getQualifiedName();
 
-
     /**
      * Returns the simple name of this type element.
      *
@@ -146,7 +151,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
      */
     List<? extends TypeParameterElement> getTypeParameters();
 
-
     /**
      * Returns the package of a top-level type and returns the
      * immediately lexically enclosing element for a {@linkplain
diff --git a/src/share/classes/javax/lang/model/element/VariableElement.java b/src/share/classes/javax/lang/model/element/VariableElement.java
index 77451fa..cc26626 100644
--- a/src/share/classes/javax/lang/model/element/VariableElement.java
+++ b/src/share/classes/javax/lang/model/element/VariableElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package javax.lang.model.element;
 
-import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
 
 /**
@@ -63,4 +62,29 @@ public interface VariableElement extends Element {
      * @jls 4.12.4 final Variables
      */
     Object getConstantValue();
+
+    /**
+     * Returns the simple name of this variable element.
+     *
+     * <p>For method and constructor parameters, the name of each
+     * parameter must be distinct from the names of all other
+     * parameters of the same executable.  If the original source
+     * names are not available, an implementation may synthesize names
+     * subject to the distinctness requirement above.
+     *
+     * @return the simple name of this variable element
+     */
+    @Override
+    Name getSimpleName();
+
+    /**
+     * Returns the enclosing element of this variable.
+     *
+     * The enclosing element of a method or constructor parameter is
+     * the executable declaring the parameter.
+     *
+     * @return the enclosing element of this variable
+     */
+    @Override
+    Element getEnclosingElement();
 }
diff --git a/src/share/classes/javax/lang/model/element/package-info.java b/src/share/classes/javax/lang/model/element/package-info.java
index 73c0a7d..2c49768 100644
--- a/src/share/classes/javax/lang/model/element/package-info.java
+++ b/src/share/classes/javax/lang/model/element/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,9 +48,12 @@
  * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
  * {@linkplain java.lang.annotation.Retention retention} cannot be
  * recovered from class files and class files might not be able to
- * provide source position information.  The {@linkplain
- * javax.lang.model.element.Modifier modifiers} on an element may
- * differ in some cases including
+ * provide source position information.
+ *
+ * Names of parameters may not be recoverable from class files.
+ *
+ * The {@linkplain javax.lang.model.element.Modifier modifiers} on an
+ * element may differ in some cases including:
  *
  * <ul>
  * <li> {@code strictfp} on a class or interface
diff --git a/src/share/classes/javax/lang/model/type/ExecutableType.java b/src/share/classes/javax/lang/model/type/ExecutableType.java
index 7b2e63a..41132dc 100644
--- a/src/share/classes/javax/lang/model/type/ExecutableType.java
+++ b/src/share/classes/javax/lang/model/type/ExecutableType.java
@@ -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
@@ -30,7 +30,6 @@ import java.util.List;
 
 import javax.lang.model.element.ExecutableElement;
 
-
 /**
  * Represents the type of an executable.  An <i>executable</i>
  * is a method, constructor, or initializer.
@@ -78,6 +77,25 @@ public interface ExecutableType extends TypeMirror {
     List<? extends TypeMirror> getParameterTypes();
 
     /**
+     * Returns the receiver type of this executable,
+     * or {@link javax.lang.model.type.NoType NoType} with
+     * kind {@link javax.lang.model.type.TypeKind#NONE NONE}
+     * if the executable has no receiver type.
+     *
+     * An executable which is an instance method, or a constructor of an
+     * inner class, has a receiver type derived from the {@linkplain
+     * ExecutableElement#getEnclosingElement declaring type}.
+     *
+     * An executable which is a static method, or a constructor of a
+     * non-inner class, or an initializer (static or instance), has no
+     * receiver type.
+     *
+     * @return the receiver type of this executable
+     * @since 1.8
+     */
+    TypeMirror getReceiverType();
+
+    /**
      * Returns the exceptions and other throwables listed in this
      * executable's {@code throws} clause.
      *
diff --git a/src/share/classes/javax/lang/model/type/IntersectionType.java b/src/share/classes/javax/lang/model/type/IntersectionType.java
new file mode 100644
index 0000000..80dca49
--- /dev/null
+++ b/src/share/classes/javax/lang/model/type/IntersectionType.java
@@ -0,0 +1,47 @@
+/*
+ * 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.lang.model.type;
+
+import java.util.List;
+
+/**
+ * Represents an intersection type.
+ *
+ * As of the {@link javax.lang.model.SourceVersion#RELEASE_8
+ * RELEASE_8} source version, intersection types can appear as the target type
+ * of a cast expression.
+ *
+ * @since 1.8
+ */
+public interface IntersectionType extends TypeMirror {
+
+    /**
+     * Return the bounds comprising this intersection type.
+     *
+     * @return the bounds of this intersection types.
+     */
+    List<? extends TypeMirror> getBounds();
+}
diff --git a/src/share/classes/javax/lang/model/type/MirroredTypeException.java b/src/share/classes/javax/lang/model/type/MirroredTypeException.java
index 8f01bed..fd79f04 100644
--- a/src/share/classes/javax/lang/model/type/MirroredTypeException.java
+++ b/src/share/classes/javax/lang/model/type/MirroredTypeException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@ package javax.lang.model.type;
 
 import java.io.ObjectInputStream;
 import java.io.IOException;
-import java.lang.annotation.Annotation;
 import javax.lang.model.element.Element;
 
 
diff --git a/src/share/classes/javax/lang/model/type/MirroredTypesException.java b/src/share/classes/javax/lang/model/type/MirroredTypesException.java
index de3e163..96209df 100644
--- a/src/share/classes/javax/lang/model/type/MirroredTypesException.java
+++ b/src/share/classes/javax/lang/model/type/MirroredTypesException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package javax.lang.model.type;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Collections;
diff --git a/src/share/classes/javax/lang/model/type/TypeKind.java b/src/share/classes/javax/lang/model/type/TypeKind.java
index 7177376..cd974ce 100644
--- a/src/share/classes/javax/lang/model/type/TypeKind.java
+++ b/src/share/classes/javax/lang/model/type/TypeKind.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -144,7 +144,14 @@ public enum TypeKind {
       *
       * @since 1.7
       */
-    UNION;
+    UNION,
+
+    /**
+      * An intersection type.
+      *
+      * @since 1.8
+      */
+    INTERSECTION;
 
     /**
      * Returns {@code true} if this kind corresponds to a primitive
diff --git a/src/share/classes/javax/lang/model/type/TypeMirror.java b/src/share/classes/javax/lang/model/type/TypeMirror.java
index 49495f2..5e5358b 100644
--- a/src/share/classes/javax/lang/model/type/TypeMirror.java
+++ b/src/share/classes/javax/lang/model/type/TypeMirror.java
@@ -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
@@ -25,6 +25,8 @@
 
 package javax.lang.model.type;
 
+import java.lang.annotation.Annotation;
+import java.util.List;
 import javax.lang.model.element.*;
 import javax.lang.model.util.Types;
 
@@ -55,7 +57,7 @@ import javax.lang.model.util.Types;
  * @see Types
  * @since 1.6
  */
-public interface TypeMirror {
+public interface TypeMirror extends javax.lang.model.AnnotatedConstruct {
 
     /**
      * Returns the {@code kind} of this type.
diff --git a/src/share/classes/javax/lang/model/type/TypeVisitor.java b/src/share/classes/javax/lang/model/type/TypeVisitor.java
index 58f6363..f51d843 100644
--- a/src/share/classes/javax/lang/model/type/TypeVisitor.java
+++ b/src/share/classes/javax/lang/model/type/TypeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -52,6 +52,18 @@ import javax.lang.model.element.*;
  * parameters, return type, etc. rather than one of the abstract
  * classes.
  *
+ * <p>Note that methods to accommodate new language constructs could
+ * be added in a source <em>compatible</em> way if they were added as
+ * <em>default methods</em>.  However, default methods are only
+ * available on Java SE 8 and higher releases and the {@code
+ * javax.lang.model.*} packages bundled in Java SE 8 are required to
+ * also be runnable on Java SE 7.  Therefore, default methods
+ * <em>cannot</em> be used when extending {@code javax.lang.model.*}
+ * to cover Java SE 8 language features.  However, default methods may
+ * be used in subsequent revisions of the {@code javax.lang.model.*}
+ * packages that are only required to run on Java SE 8 and higher
+ * platform versions.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -172,4 +184,14 @@ public interface TypeVisitor<R, P> {
      * @since 1.7
      */
     R visitUnion(UnionType t, P p);
+
+    /**
+     * Visits an intersection type.
+     *
+     * @param t the type to visit
+     * @param p a visitor-specified parameter
+     * @return  a visitor-specified result
+     * @since 1.8
+     */
+    R visitIntersection(IntersectionType t, P p);
 }
diff --git a/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java
index 0ed30ef..2d4d6b4 100644
--- a/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,10 +26,8 @@
 package javax.lang.model.util;
 
 
-import java.util.List;
 import javax.lang.model.element.*;
 
-import javax.lang.model.type.TypeMirror;
 import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
 import javax.annotation.processing.SupportedSourceVersion;
@@ -56,6 +54,15 @@ import javax.annotation.processing.SupportedSourceVersion;
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
@@ -64,6 +71,7 @@ import javax.annotation.processing.SupportedSourceVersion;
  * @author Peter von der Ahé
  *
  * @see AbstractAnnotationValueVisitor7
+ * @see AbstractAnnotationValueVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java
index f728c1a..ae2438e 100644
--- a/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java
@@ -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
@@ -25,10 +25,6 @@
 
 package javax.lang.model.util;
 
-import java.util.List;
-import javax.lang.model.element.*;
-
-import javax.lang.model.type.TypeMirror;
 import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
 import javax.annotation.processing.SupportedSourceVersion;
@@ -55,10 +51,20 @@ import javax.annotation.processing.SupportedSourceVersion;
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
  * @see AbstractAnnotationValueVisitor6
+ * @see AbstractAnnotationValueVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java
new file mode 100644
index 0000000..47c2559
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.SourceVersion;
+import javax.annotation.processing.SupportedSourceVersion;
+
+/**
+ * A skeletal visitor for annotation values with default behavior
+ * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.
+ *
+ * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new abstract annotation
+ * value visitor class will also be introduced to correspond to the
+ * new language level; this visitor will have different default
+ * behavior for the visit method in question.  When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods
+ * @param <P> the type of the additional parameter to this visitor's methods.
+ *
+ * @see AbstractAnnotationValueVisitor6
+ * @see AbstractAnnotationValueVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public abstract class AbstractAnnotationValueVisitor8<R, P> extends AbstractAnnotationValueVisitor7<R, P> {
+
+    /**
+     * Constructor for concrete subclasses to call.
+     */
+    protected AbstractAnnotationValueVisitor8() {
+        super();
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java b/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java
index 7c1d687..2ce7465 100644
--- a/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/AbstractElementVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -25,13 +25,10 @@
 
 package javax.lang.model.util;
 
-
-import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
-import static javax.lang.model.element.ElementKind.*;
 import static javax.lang.model.SourceVersion.*;
-import javax.lang.model.SourceVersion;
 
 
 /**
@@ -56,6 +53,15 @@ import javax.lang.model.SourceVersion;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -67,6 +73,7 @@ import javax.lang.model.SourceVersion;
  * @author Peter von der Ahé
  *
  * @see AbstractElementVisitor7
+ * @see AbstractElementVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java b/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java
index badcb58..f5c87e4 100644
--- a/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/AbstractElementVisitor7.java
@@ -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
@@ -25,12 +25,9 @@
 
 package javax.lang.model.util;
 
-import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.element.*;
-import static javax.lang.model.element.ElementKind.*;
-import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
 
 
 /**
@@ -55,6 +52,15 @@ import javax.lang.model.SourceVersion;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -62,6 +68,7 @@ import javax.lang.model.SourceVersion;
  *            additional parameter.
  *
  * @see AbstractElementVisitor6
+ * @see AbstractElementVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java b/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java
new file mode 100644
index 0000000..fb99d18
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/AbstractElementVisitor8.java
@@ -0,0 +1,82 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+
+/**
+ * A skeletal visitor of program elements with default behavior
+ * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new abstract element visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question.  When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see AbstractElementVisitor6
+ * @see AbstractElementVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public abstract class AbstractElementVisitor8<R, P> extends AbstractElementVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses to call.
+     */
+    protected AbstractElementVisitor8(){
+        super();
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
index 33793c4..148cc83 100644
--- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -49,6 +49,15 @@ import javax.lang.model.type.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -60,6 +69,7 @@ import javax.lang.model.type.*;
  * @author Peter von der Ahé
  *
  * @see AbstractTypeVisitor7
+ * @see AbstractTypeVisitor8
  * @since 1.6
  */
 public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
@@ -110,6 +120,20 @@ public abstract class AbstractTypeVisitor6<R, P> implements TypeVisitor<R, P> {
     }
 
     /**
+     * Visits an {@code IntersectionType} element by calling {@code
+     * visitUnknown}.
+
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of {@code visitUnknown}
+     *
+     * @since 1.8
+     */
+    public R visitIntersection(IntersectionType t, P p) {
+        return visitUnknown(t, p);
+    }
+
+    /**
      * {@inheritDoc}
      *
      * <p> The default implementation of this method in {@code
diff --git a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
index a0988e9..3fe08dc 100644
--- a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -49,6 +49,15 @@ import javax.lang.model.type.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -56,6 +65,7 @@ import javax.lang.model.type.*;
  *            additional parameter.
  *
  * @see AbstractTypeVisitor6
+ * @see AbstractTypeVisitor8
  * @since 1.7
  */
 public abstract class AbstractTypeVisitor7<R, P> extends AbstractTypeVisitor6<R, P> {
diff --git a/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java
new file mode 100644
index 0000000..a23b6e7
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java
@@ -0,0 +1,87 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.lang.model.type.*;
+
+/**
+ * A skeletal visitor of types with default behavior appropriate for
+ * the {@link javax.lang.model.SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new abstract type visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question.  When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see AbstractTypeVisitor6
+ * @see AbstractTypeVisitor7
+ * @since 1.8
+ */
+public abstract class AbstractTypeVisitor8<R, P> extends AbstractTypeVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses to call.
+     */
+    protected AbstractTypeVisitor8() {
+        super();
+    }
+
+    /**
+     * Visits an {@code IntersectionType} in a manner defined by a subclass.
+     *
+     * @param t  {@inheritDoc}
+     * @param p  {@inheritDoc}
+     * @return the result of the visit as defined by a subclass
+     */
+    public abstract R visitIntersection(IntersectionType t, P p);
+}
diff --git a/src/share/classes/javax/lang/model/util/ElementFilter.java b/src/share/classes/javax/lang/model/util/ElementFilter.java
index c95ff5f..7743f40 100644
--- a/src/share/classes/javax/lang/model/util/ElementFilter.java
+++ b/src/share/classes/javax/lang/model/util/ElementFilter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,14 @@
 
 package javax.lang.model.util;
 
-import java.lang.Iterable;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.EnumSet;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
-import java.util.NoSuchElementException;
 
 import javax.lang.model.element.*;
-import javax.lang.model.type.*;
 
 
 /**
@@ -70,19 +66,19 @@ import javax.lang.model.type.*;
 public class ElementFilter {
     private ElementFilter() {} // Do not instantiate.
 
-    private static Set<ElementKind> CONSTRUCTOR_KIND =
+    private static final Set<ElementKind> CONSTRUCTOR_KIND =
         Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
 
-    private static Set<ElementKind> FIELD_KINDS =
+    private static final Set<ElementKind> FIELD_KINDS =
         Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
                                                ElementKind.ENUM_CONSTANT));
-    private static Set<ElementKind> METHOD_KIND =
+    private static final Set<ElementKind> METHOD_KIND =
         Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
 
-    private static Set<ElementKind> PACKAGE_KIND =
+    private static final Set<ElementKind> PACKAGE_KIND =
         Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
 
-    private static Set<ElementKind> TYPE_KINDS =
+    private static final Set<ElementKind> TYPE_KINDS =
         Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
                                                ElementKind.ENUM,
                                                ElementKind.INTERFACE,
diff --git a/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java b/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
index 93d8073..9925955 100644
--- a/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -67,6 +67,15 @@ import javax.lang.model.SourceVersion;
  * for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -78,6 +87,7 @@ import javax.lang.model.SourceVersion;
  * @author Peter von der Ahé
  *
  * @see ElementKindVisitor7
+ * @see ElementKindVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java b/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java
index 7e8974f..ebaeb6b 100644
--- a/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -25,11 +25,10 @@
 
 package javax.lang.model.util;
 
-import javax.lang.model.element.*;
-import static javax.lang.model.element.ElementKind.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import static javax.lang.model.SourceVersion.*;
 
 /**
  * A visitor of program elements based on their {@linkplain
@@ -66,6 +65,15 @@ import javax.lang.model.SourceVersion;
  * for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -73,6 +81,7 @@ import javax.lang.model.SourceVersion;
  *            additional parameter.
  *
  * @see ElementKindVisitor6
+ * @see ElementKindVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java b/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java
new file mode 100644
index 0000000..61ccc78
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/ElementKindVisitor8.java
@@ -0,0 +1,106 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.lang.model.element.*;
+import javax.annotation.processing.SupportedSourceVersion;
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.SourceVersion;
+
+/**
+ * A visitor of program elements based on their {@linkplain
+ * ElementKind kind} with default behavior appropriate for the {@link
+ * SourceVersion#RELEASE_8 RELEASE_8} source version.  For {@linkplain
+ * Element elements} <tt><i>XYZ</i></tt> that may have more than one
+ * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
+ * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
+ * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * call {@link #defaultAction defaultAction}, passing their arguments
+ * to {@code defaultAction}'s corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it or the
+ * {@code ElementKind} {@code enum} used in this case may have
+ * constants added to it in the future to accommodate new, currently
+ * unknown, language structures added to future versions of the
+ * Java™ programming language.  Therefore, methods whose names
+ * begin with {@code "visit"} may be added to this class in the
+ * future; to avoid incompatibilities, classes which extend this class
+ * should not declare any instance methods with names beginning with
+ * {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new abstract element kind
+ * visitor class will also be introduced to correspond to the new
+ * language level; this visitor will have different default behavior
+ * for the visit method in question.  When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see ElementKindVisitor6
+ * @see ElementKindVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class ElementKindVisitor8<R, P> extends ElementKindVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses; uses {@code null} for the
+     * default value.
+     */
+    protected ElementKindVisitor8() {
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses; uses the argument for the
+     * default value.
+     *
+     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+     */
+    protected ElementKindVisitor8(R defaultValue) {
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/ElementScanner6.java b/src/share/classes/javax/lang/model/util/ElementScanner6.java
index 1438fdf..1f9955f 100644
--- a/src/share/classes/javax/lang/model/util/ElementScanner6.java
+++ b/src/share/classes/javax/lang/model/util/ElementScanner6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -27,7 +27,6 @@ package javax.lang.model.util;
 
 import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
@@ -90,6 +89,7 @@ import static javax.lang.model.SourceVersion.*;
  * @author Peter von der Ahé
  *
  * @see ElementScanner7
+ * @see ElementScanner8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
@@ -110,6 +110,8 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
     /**
      * Constructor for concrete subclasses; uses the argument for the
      * default value.
+     *
+     * @param defaultValue the default value
      */
     protected ElementScanner6(R defaultValue){
         DEFAULT_VALUE = defaultValue;
@@ -135,6 +137,9 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
     /**
      * 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 +148,8 @@ public class ElementScanner6<R, P> extends AbstractElementVisitor6<R, P> {
 
     /**
      * 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) {
diff --git a/src/share/classes/javax/lang/model/util/ElementScanner7.java b/src/share/classes/javax/lang/model/util/ElementScanner7.java
index e525e86..deee40f 100644
--- a/src/share/classes/javax/lang/model/util/ElementScanner7.java
+++ b/src/share/classes/javax/lang/model/util/ElementScanner7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -27,7 +27,6 @@ package javax.lang.model.util;
 
 import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
@@ -86,6 +85,7 @@ import static javax.lang.model.SourceVersion.*;
  *            additional parameter.
  *
  * @see ElementScanner6
+ * @see ElementScanner8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
@@ -101,6 +101,8 @@ public class ElementScanner7<R, P> extends ElementScanner6<R, P> {
     /**
      * Constructor for concrete subclasses; uses the argument for the
      * default value.
+     *
+     * @param defaultValue the default value
      */
     protected ElementScanner7(R defaultValue){
         super(defaultValue);
diff --git a/src/share/classes/javax/lang/model/util/ElementScanner8.java b/src/share/classes/javax/lang/model/util/ElementScanner8.java
new file mode 100644
index 0000000..f687136
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/ElementScanner8.java
@@ -0,0 +1,110 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.lang.model.element.*;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+
+/**
+ * A scanning visitor of program elements with default behavior
+ * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.  The <tt>visit<i>XYZ</i></tt> methods in this
+ * class scan their component elements by calling {@code scan} on
+ * their {@linkplain Element#getEnclosedElements enclosed elements},
+ * {@linkplain ExecutableElement#getParameters parameters}, etc., as
+ * indicated in the individual method specifications.  A subclass can
+ * control the order elements are visited by overriding the
+ * <tt>visit<i>XYZ</i></tt> methods.  Note that clients of a scanner
+ * may get the desired behavior be invoking {@code v.scan(e, p)} rather
+ * than {@code v.visit(e, p)} on the root objects of interest.
+ *
+ * <p>When a subclass overrides a <tt>visit<i>XYZ</i></tt> method, the
+ * new method can cause the enclosed elements to be scanned in the
+ * default way by calling <tt>super.visit<i>XYZ</i></tt>.  In this
+ * fashion, the concrete visitor can control the ordering of traversal
+ * over the component elements with respect to the additional
+ * processing; for example, consistently calling
+ * <tt>super.visit<i>XYZ</i></tt> at the start of the overridden
+ * methods will yield a preorder traversal, etc.  If the component
+ * elements should be traversed in some other order, instead of
+ * calling <tt>super.visit<i>XYZ</i></tt>, an overriding visit method
+ * should call {@code scan} with the elements in the desired order.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new element scanner visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question.  When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see ElementScanner6
+ * @see ElementScanner7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class ElementScanner8<R, P> extends ElementScanner7<R, P> {
+    /**
+     * Constructor for concrete subclasses; uses {@code null} for the
+     * default value.
+     */
+    protected ElementScanner8(){
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses; uses the argument for the
+     * default value.
+     *
+     * @param defaultValue the default value
+     */
+    protected ElementScanner8(R defaultValue){
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/Elements.java b/src/share/classes/javax/lang/model/util/Elements.java
index 035fcfb..bc4eb28 100644
--- a/src/share/classes/javax/lang/model/util/Elements.java
+++ b/src/share/classes/javax/lang/model/util/Elements.java
@@ -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
@@ -79,12 +79,12 @@ public interface Elements {
      *
      * <p> A documentation comment of an element is a comment that
      * begins with "{@code /**}" , ends with a separate
-     * "<code>*&#47</code>", and immediately precedes the element,
+     * "<code>*/</code>", and immediately precedes the element,
      * ignoring white space.  Therefore, a documentation comment
      * contains at least three"{@code *}" characters.  The text
      * returned for the documentation comment is a processed form of
      * the comment as it appears in source code.  The leading "{@code
-     * /**}" and trailing "<code>*&#47</code>" are removed.  For lines
+     * /**}" and trailing "<code>*/</code>" are removed.  For lines
      * of the comment starting after the initial "{@code /**}",
      * leading white space characters are discarded as are any
      * consecutive "{@code *}" characters appearing after the white
@@ -143,12 +143,13 @@ public interface Elements {
     List<? extends Element> getAllMembers(TypeElement type);
 
     /**
-     * Returns all annotations of an element, whether
-     * inherited or directly present.
+     * Returns all annotations <i>present</i> on an element, whether
+     * directly present or present via inheritance.
      *
      * @param e  the element being examined
      * @return all annotations of the element
      * @see Element#getAnnotationMirrors
+     * @see javax.lang.model.AnnotatedConstruct
      */
     List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
 
@@ -247,6 +248,17 @@ public interface Elements {
      * 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);
+
+    /**
+     * Returns {@code true} if the type element is a functional interface, {@code false} otherwise.
+     *
+     * @param type the type element being examined
+     * @return {@code true} if the element is a functional interface, {@code false} otherwise
+     * @jls 9.8 Functional Interfaces
+     * @since 1.8
+     */
+    boolean isFunctionalInterface(TypeElement type);
 }
diff --git a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java
index f5f9d43..1bb58b9 100644
--- a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -63,6 +63,15 @@ import javax.annotation.processing.SupportedSourceVersion;
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
@@ -71,6 +80,7 @@ import javax.annotation.processing.SupportedSourceVersion;
  * @author Peter von der Ahé
  *
  * @see SimpleAnnotationValueVisitor7
+ * @see SimpleAnnotationValueVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
index 0e3f449..0a44211 100644
--- a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -25,13 +25,9 @@
 
 package javax.lang.model.util;
 
-import java.util.List;
-import javax.lang.model.element.*;
-
-import javax.lang.model.type.TypeMirror;
-import static javax.lang.model.SourceVersion.*;
-import javax.lang.model.SourceVersion;
 import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
 
 /**
  * A simple visitor for annotation values with default behavior
@@ -62,10 +58,20 @@ import javax.annotation.processing.SupportedSourceVersion;
  * behavior for the visit method in question.  When the new visitor is
  * introduced, all or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods
  * @param <P> the type of the additional parameter to this visitor's methods.
  *
  * @see SimpleAnnotationValueVisitor6
+ * @see SimpleAnnotationValueVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java
new file mode 100644
index 0000000..1b84d32
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java
@@ -0,0 +1,96 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A simple visitor for annotation values with default behavior
+ * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.  Visit methods call {@link #defaultAction
+ * defaultAction} passing their arguments to {@code defaultAction}'s
+ * corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new simple annotation
+ * value visitor class will also be introduced to correspond to the
+ * new language level; this visitor will have different default
+ * behavior for the visit method in question.  When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods
+ * @param <P> the type of the additional parameter to this visitor's methods.
+ *
+ * @see SimpleAnnotationValueVisitor6
+ * @see SimpleAnnotationValueVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class SimpleAnnotationValueVisitor8<R, P> extends SimpleAnnotationValueVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses; uses {@code null} for the
+     * default value.
+     */
+    protected SimpleAnnotationValueVisitor8() {
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses; uses the argument for the
+     * default value.
+     *
+     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+     */
+    protected SimpleAnnotationValueVisitor8(R defaultValue) {
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java b/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
index f43fa2d..8c7ff87 100644
--- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -27,7 +27,6 @@ package javax.lang.model.util;
 
 import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
@@ -66,6 +65,15 @@ import static javax.lang.model.SourceVersion.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@code Void}
  *             for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
@@ -76,6 +84,7 @@ import static javax.lang.model.SourceVersion.*;
  * @author Peter von der Ahé
  *
  * @see SimpleElementVisitor7
+ * @see SimpleElementVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java b/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
index a02d2a1..b9df9c4 100644
--- a/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -27,7 +27,6 @@ package javax.lang.model.util;
 
 import javax.lang.model.element.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
 import javax.lang.model.SourceVersion;
 import static javax.lang.model.SourceVersion.*;
 
@@ -63,12 +62,22 @@ import static javax.lang.model.SourceVersion.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@code Void}
  *             for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
  *              for visitors that do not need an additional parameter.
  *
  * @see SimpleElementVisitor6
+ * @see SimpleElementVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java b/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java
new file mode 100644
index 0000000..f0cb871
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/SimpleElementVisitor8.java
@@ -0,0 +1,101 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A simple visitor of program elements with default behavior
+ * appropriate for the {@link SourceVersion#RELEASE_8 RELEASE_8}
+ * source version.
+ *
+ * Visit methods corresponding to {@code RELEASE_7} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new simple element visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question.  When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@code Void}
+ *             for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's methods.  Use {@code Void}
+ *              for visitors that do not need an additional parameter.
+ *
+ * @see SimpleElementVisitor6
+ * @see SimpleElementVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class SimpleElementVisitor8<R, P> extends SimpleElementVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses; uses {@code null} for the
+     * default value.
+     */
+    protected SimpleElementVisitor8(){
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses; uses the argument for the
+     * default value.
+     *
+     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+     */
+    protected SimpleElementVisitor8(R defaultValue){
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
index c68688b..4b2af1f 100644
--- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -64,6 +64,15 @@ import static javax.lang.model.SourceVersion.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -75,6 +84,7 @@ import static javax.lang.model.SourceVersion.*;
  * @author Peter von der Ahé
  *
  * @see SimpleTypeVisitor7
+ * @see SimpleTypeVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
@@ -108,6 +118,10 @@ public class SimpleTypeVisitor6<R, P> extends AbstractTypeVisitor6<R, P> {
      * The default action for visit methods.  The implementation in
      * this class just returns {@link #DEFAULT_VALUE}; subclasses will
      * commonly override this method.
+     *
+     * @param e the type to process
+     * @param p a visitor-specified parameter
+     * @return {@code DEFAULT_VALUE} unless overridden
      */
     protected R defaultAction(TypeMirror e, P p) {
         return DEFAULT_VALUE;
diff --git a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
index 2cc37ac..66eb20a 100644
--- a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -61,6 +61,15 @@ import static javax.lang.model.SourceVersion.*;
  * visit method in question.  When the new visitor is introduced, all
  * or portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -68,6 +77,7 @@ import static javax.lang.model.SourceVersion.*;
  *            additional parameter.
  *
  * @see SimpleTypeVisitor6
+ * @see SimpleTypeVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java
new file mode 100644
index 0000000..c4faae9
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java
@@ -0,0 +1,101 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A simple visitor of types with default behavior appropriate for the
+ * {@link SourceVersion#RELEASE_7 RELEASE_7} source version.
+ *
+ * Visit methods corresponding to {@code RELEASE_8} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new simple type visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question.  When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see SimpleTypeVisitor6
+ * @see SimpleTypeVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class SimpleTypeVisitor8<R, P> extends SimpleTypeVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses; uses {@code null} for the
+     * default value.
+     */
+    protected SimpleTypeVisitor8(){
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses; uses the argument for the
+     * default value.
+     *
+     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+     */
+    protected SimpleTypeVisitor8(R defaultValue){
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java b/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java
index bc0e5ca..3add039 100644
--- a/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java
+++ b/src/share/classes/javax/lang/model/util/TypeKindVisitor6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -25,12 +25,10 @@
 
 package javax.lang.model.util;
 
-
-import javax.lang.model.type.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
-import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
+import javax.lang.model.type.*;
+import static javax.lang.model.SourceVersion.*;
 
 /**
  * A visitor of types based on their {@linkplain TypeKind kind} with
@@ -65,6 +63,15 @@ import javax.lang.model.SourceVersion;
  * method in question.  When the new visitor is introduced, all or
  * portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -76,6 +83,7 @@ import javax.lang.model.SourceVersion;
  * @author Peter von der Ahé
  *
  * @see TypeKindVisitor7
+ * @see TypeKindVisitor8
  * @since 1.6
  */
 @SupportedSourceVersion(RELEASE_6)
diff --git a/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java b/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
index 3fe0654..a0a0c12 100644
--- a/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
+++ b/src/share/classes/javax/lang/model/util/TypeKindVisitor7.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -27,7 +27,6 @@ package javax.lang.model.util;
 
 import javax.lang.model.type.*;
 import javax.annotation.processing.SupportedSourceVersion;
-import static javax.lang.model.element.ElementKind.*;
 import static javax.lang.model.SourceVersion.*;
 import javax.lang.model.SourceVersion;
 
@@ -64,6 +63,15 @@ import javax.lang.model.SourceVersion;
  * method in question.  When the new visitor is introduced, all or
  * portions of this visitor may be deprecated.
  *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
  * @param <R> the return type of this visitor's methods.  Use {@link
  *            Void} for visitors that do not need to return results.
  * @param <P> the type of the additional parameter to this visitor's
@@ -71,6 +79,7 @@ import javax.lang.model.SourceVersion;
  *            additional parameter.
  *
  * @see TypeKindVisitor6
+ * @see TypeKindVisitor8
  * @since 1.7
  */
 @SupportedSourceVersion(RELEASE_7)
diff --git a/src/share/classes/javax/lang/model/util/TypeKindVisitor8.java b/src/share/classes/javax/lang/model/util/TypeKindVisitor8.java
new file mode 100644
index 0000000..60b3b61
--- /dev/null
+++ b/src/share/classes/javax/lang/model/util/TypeKindVisitor8.java
@@ -0,0 +1,104 @@
+/*
+ * 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
+ * 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.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.type.*;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A visitor of types based on their {@linkplain TypeKind kind} with
+ * default behavior appropriate for the {@link SourceVersion#RELEASE_8
+ * RELEASE_8} source version.  For {@linkplain
+ * TypeMirror types} <tt><i>XYZ</i></tt> that may have more than one
+ * kind, the <tt>visit<i>XYZ</i></tt> methods in this class delegate
+ * to the <tt>visit<i>XYZKind</i></tt> method corresponding to the
+ * first argument's kind.  The <tt>visit<i>XYZKind</i></tt> methods
+ * call {@link #defaultAction defaultAction}, passing their arguments
+ * to {@code defaultAction}'s corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method.  A new type kind visitor class
+ * will also be introduced to correspond to the new language level;
+ * this visitor will have different default behavior for the visit
+ * method in question.  When the new visitor is introduced, all or
+ * portions of this visitor may be deprecated.
+ *
+ * <p>Note that adding a default implementation of a new visit method
+ * in a visitor class will occur instead of adding a <em>default
+ * method</em> directly in the visitor interface since a Java SE 8
+ * language feature cannot be used to this version of the API since
+ * this version is required to be runnable on Java SE 7
+ * implementations.  Future versions of the API that are only required
+ * to run on Java SE 8 and later may take advantage of default methods
+ * in this situation.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @see TypeKindVisitor6
+ * @see TypeKindVisitor7
+ * @since 1.8
+ */
+ at SupportedSourceVersion(RELEASE_8)
+public class TypeKindVisitor8<R, P> extends TypeKindVisitor7<R, P> {
+    /**
+     * Constructor for concrete subclasses to call; uses {@code null}
+     * for the default value.
+     */
+    protected TypeKindVisitor8() {
+        super(null);
+    }
+
+    /**
+     * Constructor for concrete subclasses to call; uses the argument
+     * for the default value.
+     *
+     * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+     */
+    protected TypeKindVisitor8(R defaultValue) {
+        super(defaultValue);
+    }
+}
diff --git a/src/share/classes/javax/lang/model/util/Types.java b/src/share/classes/javax/lang/model/util/Types.java
index a53e66a..2e50b50 100644
--- a/src/share/classes/javax/lang/model/util/Types.java
+++ b/src/share/classes/javax/lang/model/util/Types.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -25,6 +25,9 @@
 
 package javax.lang.model.util;
 
+import java.lang.annotation.Annotation;
+import java.lang.annotation.AnnotationTypeMismatchException;
+import java.lang.annotation.IncompleteAnnotationException;
 import java.util.List;
 import javax.lang.model.element.*;
 import javax.lang.model.type.*;
@@ -49,6 +52,7 @@ public interface Types {
      * 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);
@@ -56,6 +60,13 @@ public interface Types {
     /**
      * Tests whether two {@code TypeMirror} objects represent the same type.
      *
+     * <p>Since annotations are only meta-data associated with a type,
+     * the set of annotations on either argument is <em>not</em> taken
+     * into account when computing whether or not two {@code
+     * TypeMirror} objects are the same type. In particular, two
+     * {@code TypeMirror} objects can have different annotations and
+     * still be considered the same.
+     *
      * <p>Caveat: if either of the arguments to this method represents a
      * wildcard, this method will return false.  As a consequence, a wildcard
      * is not the same type as itself.  This might be surprising at first,
diff --git a/src/share/classes/javax/tools/DocumentationTool.java b/src/share/classes/javax/tools/DocumentationTool.java
new file mode 100644
index 0000000..63158ed
--- /dev/null
+++ b/src/share/classes/javax/tools/DocumentationTool.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package javax.tools;
+
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.Locale;
+import java.util.concurrent.Callable;
+
+/**
+ * Interface to invoke Java™ programming language documentation tools from
+ * programs.
+ */
+public interface DocumentationTool extends Tool, OptionChecker {
+    /**
+     * Creates a future for a documentation task with the given
+     * components and arguments.  The task might not have
+     * completed as described in the DocumentationTask interface.
+     *
+     * <p>If a file manager is provided, it must be able to handle all
+     * locations defined in {@link DocumentationTool.Location},
+     * as well as
+     * {@link StandardLocation#SOURCE_PATH},
+     * {@link StandardLocation#CLASS_PATH}, and
+     * {@link StandardLocation#PLATFORM_CLASS_PATH}.
+     *
+     * @param out a Writer for additional output from the tool;
+     * use {@code System.err} if {@code null}
+     *
+     * @param fileManager a file manager; if {@code null} use the
+     * tool's standard filemanager
+     *
+     * @param diagnosticListener a diagnostic listener; if {@code null}
+     * use the tool's default method for reporting diagnostics
+     *
+     * @param docletClass a class providing the necessary methods required
+     * of a doclet
+     *
+     * @param options documentation tool options and doclet options,
+     * {@code null} means no options
+     *
+     * @param compilationUnits the compilation units to compile, {@code
+     * null} means no compilation units
+     *
+     * @return an object representing the compilation
+     *
+     * @throws RuntimeException if an unrecoverable error
+     * occurred in a user supplied component.  The
+     * {@linkplain Throwable#getCause() cause} will be the error in
+     * user code.
+     *
+     * @throws IllegalArgumentException if any of the given
+     * compilation units are of other kind than
+     * {@linkplain JavaFileObject.Kind#SOURCE source}
+     */
+    DocumentationTask getTask(Writer out,
+                            JavaFileManager fileManager,
+                            DiagnosticListener<? super JavaFileObject> diagnosticListener,
+                            Class<?> docletClass,
+                            Iterable<String> options,
+                            Iterable<? extends JavaFileObject> compilationUnits);
+
+    /**
+     * Gets a new instance of the standard file manager implementation
+     * for this tool.  The file manager will use the given diagnostic
+     * listener for producing any non-fatal diagnostics.  Fatal errors
+     * will be signaled with the appropriate exceptions.
+     *
+     * <p>The standard file manager will be automatically reopened if
+     * it is accessed after calls to {@code flush} or {@code close}.
+     * The standard file manager must be usable with other tools.
+     *
+     * @param diagnosticListener a diagnostic listener for non-fatal
+     * diagnostics; if {@code null} use the compiler's default method
+     * for reporting diagnostics
+     *
+     * @param locale the locale to apply when formatting diagnostics;
+     * {@code null} means the {@linkplain Locale#getDefault() default locale}.
+     *
+     * @param charset the character set used for decoding bytes; if
+     * {@code null} use the platform default
+     *
+     * @return the standard file manager
+     */
+    StandardJavaFileManager getStandardFileManager(
+        DiagnosticListener<? super JavaFileObject> diagnosticListener,
+        Locale locale,
+        Charset charset);
+
+    /**
+     * Interface representing a future for a documentation task.  The
+     * task has not yet started.  To start the task, call
+     * the {@linkplain #call call} method.
+     *
+     * <p>Before calling the call method, additional aspects of the
+     * task can be configured, for example, by calling the
+     * {@linkplain #setLocale setLocale} method.
+     */
+    interface DocumentationTask extends Callable<Boolean> {
+        /**
+         * Set the locale to be applied when formatting diagnostics and
+         * other localized data.
+         *
+         * @param locale the locale to apply; {@code null} means apply no
+         * locale
+         * @throws IllegalStateException if the task has started
+         */
+        void setLocale(Locale locale);
+
+        /**
+         * Performs this documentation task.  The task may only
+         * be performed once.  Subsequent calls to this method throw
+         * IllegalStateException.
+         *
+         * @return true if and only all the files were processed without errors;
+         * false otherwise
+         *
+         * @throws RuntimeException if an unrecoverable error occurred
+         * in a user-supplied component.  The
+         * {@linkplain Throwable#getCause() cause} will be the error
+         * in user code.
+         *
+         * @throws IllegalStateException if called more than once
+         */
+        Boolean call();
+    }
+
+    /**
+     * Locations specific to {@link DocumentationTool}.
+     *
+     * @see StandardLocation
+     */
+    enum Location implements JavaFileManager.Location {
+        /**
+         * Location of new documentation files.
+         */
+        DOCUMENTATION_OUTPUT,
+
+        /**
+         * Location to search for doclets.
+         */
+        DOCLET_PATH,
+
+        /**
+         * Location to search for taglets.
+         */
+        TAGLET_PATH;
+
+        public String getName() { return name(); }
+
+        public boolean isOutputLocation() {
+            switch (this) {
+                case DOCUMENTATION_OUTPUT:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+    }
+
+}
diff --git a/src/share/classes/javax/tools/ForwardingJavaFileManager.java b/src/share/classes/javax/tools/ForwardingJavaFileManager.java
index f875b94..9bf3405 100644
--- a/src/share/classes/javax/tools/ForwardingJavaFileManager.java
+++ b/src/share/classes/javax/tools/ForwardingJavaFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package javax.tools;
 
 import java.io.IOException;
-import java.net.URI;
 import java.util.Iterator;
 import java.util.Set;
 import javax.tools.JavaFileObject.Kind;
diff --git a/src/share/classes/javax/tools/JavaCompiler.java b/src/share/classes/javax/tools/JavaCompiler.java
index 126719b..5588c80 100644
--- a/src/share/classes/javax/tools/JavaCompiler.java
+++ b/src/share/classes/javax/tools/JavaCompiler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,8 +108,8 @@ import javax.annotation.processing.Processor;
  *     example a recommended coding pattern:
  *
  *     <pre>
- *       Files[] files1 = ... ; // input for first compilation task
- *       Files[] files2 = ... ; // input for second compilation task
+ *       File[] files1 = ... ; // input for first compilation task
+ *       File[] files2 = ... ; // input for second compilation task
  *
  *       JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  *       StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
@@ -137,7 +137,7 @@ import javax.annotation.processing.Processor;
  *       StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
  *       compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
  *
- *       for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics())
+ *       for ({@code Diagnostic<? extends JavaFileObject>} diagnostic : diagnostics.getDiagnostics())
  *           System.out.format("Error on line %d in %s%n",
  *                             diagnostic.getLineNumber(),
  *                             diagnostic.getSource().toUri());
@@ -165,7 +165,7 @@ import javax.annotation.processing.Processor;
  *       JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
  *       StandardJavaFileManager stdFileManager = compiler.getStandardFileManager(null, null, null);
  *       JavaFileManager fileManager = new ForwardingJavaFileManager(stdFileManager) {
- *           public void flush() {
+ *           public void flush() throws IOException {
  *               logger.entering(StandardJavaFileManager.class.getName(), "flush");
  *               super.flush();
  *               logger.exiting(StandardJavaFileManager.class.getName(), "flush");
@@ -266,7 +266,7 @@ public interface JavaCompiler extends Tool, OptionChecker {
      * Gets a new instance of the standard file manager implementation
      * for this tool.  The file manager will use the given diagnostic
      * listener for producing any non-fatal diagnostics.  Fatal errors
-     * will be signalled with the appropriate exceptions.
+     * will be signaled with the appropriate exceptions.
      *
      * <p>The standard file manager will be automatically reopened if
      * it is accessed after calls to {@code flush} or {@code close}.
diff --git a/src/share/classes/javax/tools/JavaFileObject.java b/src/share/classes/javax/tools/JavaFileObject.java
index 9e84b3c..ea9dd75 100644
--- a/src/share/classes/javax/tools/JavaFileObject.java
+++ b/src/share/classes/javax/tools/JavaFileObject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,6 @@
 
 package javax.tools;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.nio.CharBuffer;
 import javax.lang.model.element.NestingKind;
 import javax.lang.model.element.Modifier;
 
diff --git a/src/share/classes/javax/tools/StandardLocation.java b/src/share/classes/javax/tools/StandardLocation.java
index dce44d5..9c6184d 100644
--- a/src/share/classes/javax/tools/StandardLocation.java
+++ b/src/share/classes/javax/tools/StandardLocation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -66,7 +66,13 @@ public enum StandardLocation implements Location {
      * Location to search for platform classes.  Sometimes called
      * the boot class path.
      */
-    PLATFORM_CLASS_PATH;
+    PLATFORM_CLASS_PATH,
+
+    /**
+     * Location of new native header files.
+     * @since 1.8
+     */
+    NATIVE_HEADER_OUTPUT;
 
     /**
      * Gets a location object with the given name.  The following
@@ -91,12 +97,19 @@ public enum StandardLocation implements Location {
         return locations.get(name);
     }
     //where
-        private static ConcurrentMap<String,Location> locations
+        private static final ConcurrentMap<String,Location> locations
             = new ConcurrentHashMap<String,Location>();
 
     public String getName() { return name(); }
 
     public boolean isOutputLocation() {
-        return this == CLASS_OUTPUT || this == SOURCE_OUTPUT;
+        switch (this) {
+            case CLASS_OUTPUT:
+            case SOURCE_OUTPUT:
+            case NATIVE_HEADER_OUTPUT:
+                return true;
+            default:
+                return false;
+        }
     }
 }
diff --git a/src/share/classes/javax/tools/ToolProvider.java b/src/share/classes/javax/tools/ToolProvider.java
index 792fc9c..aa03eb5 100644
--- a/src/share/classes/javax/tools/ToolProvider.java
+++ b/src/share/classes/javax/tools/ToolProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -102,6 +102,19 @@ public class ToolProvider {
         return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName);
     }
 
+    private static final String defaultDocumentationToolName
+        = "com.sun.tools.javadoc.api.JavadocTool";
+
+    /**
+     * Gets the Java™ programming language documentation tool provided
+     * with this platform.
+     * @return the documentation tool provided with this platform or
+     * {@code null} if no documentation tool is provided
+     */
+    public static DocumentationTool getSystemDocumentationTool() {
+        return instance().getSystemTool(DocumentationTool.class, defaultDocumentationToolName);
+    }
+
     /**
      * Returns the class loader for tools provided with this platform.
      * This does not include user-installed tools.  Use the
diff --git a/src/share/classes/jdk/Supported.java b/src/share/classes/jdk/Supported.java
new file mode 100644
index 0000000..01bbbff
--- /dev/null
+++ b/src/share/classes/jdk/Supported.java
@@ -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.  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 jdk;
+
+import java.lang.annotation.*;
+
+/**
+  * Indicates whether or not a JDK specific type or package is a
+  * supported part of the JDK.
+  *
+  * This annotation should only be applied to types and packages
+  * <em>outside</em> of the Java SE namespaces of {@code java.*} and
+  * {@code javax.*} packages.  For example, certain portions of {@code
+  * com.sun.*} are official parts of the JDK meant to be generally
+  * usable while other portions of {@code com.sun.*} are not.  This
+  * annotation type allows those portions to be easily and
+  * programmaticly distinguished.
+  *
+  * @since 1.8
+  */
+ at Documented
+ at Retention(RetentionPolicy.SOURCE)
+ at Target({ElementType.TYPE, ElementType.PACKAGE})
+ at Supported
+public @interface Supported {
+    /**
+     * Whether or not this package or type is a supported part of the JDK.
+     */
+    boolean value() default true;
+}
diff --git a/src/share/sample/javac/processing/src/CheckNamesProcessor.java b/src/share/sample/javac/processing/src/CheckNamesProcessor.java
index dc224f0..8f9ee06 100644
--- a/src/share/sample/javac/processing/src/CheckNamesProcessor.java
+++ b/src/share/sample/javac/processing/src/CheckNamesProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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
@@ -138,7 +138,7 @@ public class CheckNamesProcessor extends AbstractProcessor {
     public SourceVersion getSupportedSourceVersion() {
         /*
          * Return latest source version instead of a fixed version
-         * like RELEASE_7.  To return a fixed version, this class
+         * like RELEASE_8.  To return a fixed version, this class
          * could be annotated with a SupportedSourceVersion
          * annotation.
          *
@@ -192,7 +192,7 @@ public class CheckNamesProcessor extends AbstractProcessor {
         /**
          * Visitor to implement name checks.
          */
-        private class NameCheckScanner extends ElementScanner7<Void, Void> {
+        private class NameCheckScanner extends ElementScanner8<Void, Void> {
             // The visitor could be enhanced to return true/false if
             // there were warnings reported or a count of the number
             // of warnings.  This could be facilitated by using
diff --git a/src/share/sample/language/model/CoreReflectionFactory.java b/src/share/sample/language/model/CoreReflectionFactory.java
new file mode 100644
index 0000000..033765f
--- /dev/null
+++ b/src/share/sample/language/model/CoreReflectionFactory.java
@@ -0,0 +1,3767 @@
+/*
+ * 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
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        java.lang.reflect.TypeVariable<?> 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 java.lang.reflect.TypeVariable<?> getSource() {
+            return sourceTypeVar;
+        }
+
+        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;
+            }
+        }
+    }
+}
diff --git a/test/Makefile b/test/Makefile
index 6f8300b..35313f1 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -19,6 +19,7 @@
 # Get OS/ARCH specifics
 OSNAME = $(shell uname -s)
 ifeq ($(OSNAME), SunOS)
+  SLASH_JAVA = /java
   PLATFORM = solaris
   JT_PLATFORM = solaris
   ARCH = $(shell uname -p)
@@ -27,6 +28,7 @@ ifeq ($(OSNAME), SunOS)
   endif
 endif
 ifeq ($(OSNAME), Linux)
+  SLASH_JAVA = /java
   PLATFORM = linux
   JT_PLATFORM = linux
   ARCH = $(shell uname -m)
@@ -43,7 +45,16 @@ ifeq ($(OSNAME), Darwin)
   endif
 endif
 ifeq ($(OSNAME), Windows_NT)
+  # MKS
+  PLATFORM=windows
+endif
+ifeq ($(PLATFORM),)
   PLATFORM = windows
+  CYGPATH = | cygpath -m -s -f -
+endif
+
+ifeq ($(PLATFORM), windows)
+  SLASH_JAVA = J:
   JT_PLATFORM = win32
   ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
     ARCH=ia64
@@ -62,7 +73,7 @@ ifeq ($(OSNAME), Windows_NT)
 endif
 
 # Root of this test area (important to use full paths in some places)
-TEST_ROOT := $(shell pwd)
+TEST_ROOT := $(shell pwd $(CYGPATH) )
 
 # Default bundle of all test results (passed or not) (JPRT only)
 ifdef JPRT_JOB_ID
@@ -80,7 +91,7 @@ endif
 ifdef JPRT_JTREG_HOME
   JTREG_HOME = $(JPRT_JTREG_HOME)
 else
-  JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg
+  JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg
 endif
 JTREG = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtreg
 JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff
@@ -89,7 +100,7 @@ JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff
 ifdef JPRT_JCK_HOME
   JCK_HOME = $(JPRT_JCK_HOME)
 else
-  JCK_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries
+  JCK_HOME = $(SLASH_JAVA)/re/jck/8/promoted/latest/binaries
 endif
 
 # Default JDK for JTREG and JCK
@@ -101,7 +112,7 @@ endif
 ifdef JPRT_JAVA_HOME
   JT_JAVA = $(JPRT_JAVA_HOME)
 else
-  JT_JAVA = $(SLASH_JAVA)/re/jdk/1.6.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
+  JT_JAVA = $(SLASH_JAVA)/re/jdk/1.7.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
 endif
 
 # Default JDK to test
@@ -135,10 +146,15 @@ ifdef TESTBOOTCLASSPATH
 endif
 
 # Concurrency is the number of tests that can execute at once. 
-# Supported for JCK, not supported for jtreg.
 # On an otherwise empty machine, suggest setting to (#cpus + 2)
 # If unset, the default is (#cpus)
 ### RFE: determine and use #cpus
+ifdef CONCURRENCY
+  JTREG_OPTIONS += -agentvm -concurrency:$(CONCURRENCY)
+else
+  JTREG_OPTIONS += -samevm
+endif
+
 ifdef JCK_CONCURRENCY
   JCK_OPTIONS += -concurrency:$(JCK_CONCURRENCY)
 endif
@@ -203,7 +219,7 @@ TEST_OUTPUT_DIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools
 ABS_TEST_OUTPUT_DIR := \
 	$(shell mkdir -p $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \
 		cd  $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \
-		pwd )
+		pwd $(CYGPATH))
 # Subdirectories for different test runs
 JTREG_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jtreg
 JCK_COMPILER_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-compiler
@@ -213,7 +229,7 @@ JCK_RUNTIME_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-runtime-Xcompile
 all: $(JPRT_CLEAN) jtreg-tests jck-compiler-tests jck-runtime-tests $(JPRT_ARCHIVE_BUNDLE) all-summary
 	@echo "Testing completed successfully"
 
-jtreg apt javac javadoc javah javap: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
+jtreg apt javac javadoc javah javap jdeps: $(JPRT_CLEAN) jtreg-tests $(JPRT_ARCHIVE_BUNDLE) jtreg-summary
 	@echo "Testing completed successfully"
 
 jck-compiler: $(JPRT_CLEAN) jck-compiler-tests $(JPRT_ARCHIVE_BUNDLE) jck-compiler-summary
@@ -230,6 +246,7 @@ javac: 		JTREG_TESTDIRS = tools/javac
 javadoc:	JTREG_TESTDIRS = tools/javadoc com/sun/javadoc
 javah:		JTREG_TESTDIRS = tools/javah
 javap:		JTREG_TESTDIRS = tools/javap
+jdeps:		JTREG_TESTDIRS = tools/jdeps
 
 # Run jtreg tests
 #
@@ -255,7 +272,8 @@ jtreg-tests: check-jtreg FRC
 	@mkdir -p $(JTREG_OUTPUT_DIR)
 	JT_JAVA=$(JT_JAVA) $(JTREG) \
 	  -J-Xmx512m \
-	  -a -samevm -ignore:quiet -v:fail,error,nopass \
+	  -vmoption:-Xmx768m \
+	  -a -ignore:quiet -v:fail,error,nopass \
           -r:$(JTREG_OUTPUT_DIR)/JTreport \
           -w:$(JTREG_OUTPUT_DIR)/JTwork \
           -jdk:$(TESTJAVA) \
@@ -281,15 +299,17 @@ jtreg-summary: FRC
 	fi
 
 # Check to make sure these directories exist
-check-jtreg: $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
+check-jtreg: $(PRODUCT_HOME) $(JTREG)
 
 
 # Run JCK-compiler tests
 #
 # JCK_HOME
 #	Installed location of JCK: should include JCK-compiler, and JCK-extras
+#       Default is JCK 8.
 # JT_JAVA
 #	Version of java used to run JCK.  Should normally be the same as TESTJAVA
+#       Default is JDK 7
 # TESTJAVA
 # 	Version of java to be tested.  
 # JCK_COMPILER_OPTIONS
@@ -306,7 +326,7 @@ jck-compiler-tests: check-jck FRC
 	    $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt
 	@mkdir -p $(JCK_COMPILER_OUTPUT_DIR)
 	$(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \
-	    -jar $(JCK_HOME)/JCK-compiler-7/lib/jtjck.jar \
+	    -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \
 	    -v:non-pass \
             -r:$(JCK_COMPILER_OUTPUT_DIR)/report \
             -w:$(JCK_COMPILER_OUTPUT_DIR)/work \
@@ -355,7 +375,7 @@ jck-runtime-tests: check-jck FRC
 	    $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt
 	@mkdir -p $(JCK_RUNTIME_OUTPUT_DIR)
 	$(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \
-	    -jar $(JCK_HOME)/JCK-runtime-7/lib/jtjck.jar \
+	    -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \
 	    -v:non-pass \
             -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \
             -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \
@@ -382,7 +402,7 @@ jck-runtime-summary: FRC
 	fi
 
 # Check to make sure these directories exist
-check-jck: $(JT_HOME) $(JCK_HOME) $(PRODUCT_HOME)
+check-jck: $(JCK_HOME) $(PRODUCT_HOME)
 
 all-summary: FRC
 	if [ -n "`find $(TEST_OUTPUT_DIR) -name status.txt`" ]; then
@@ -408,7 +428,7 @@ FRC:
 
 # Phony targets (e.g. these are not filenames)
 .PHONY: all clean \
-	jtreg javac javadoc javah javap jtreg-tests jtreg-summary check-jtreg \
+	jtreg javac javadoc javah javap jdeps jtreg-tests jtreg-summary check-jtreg \
 	jck-compiler jck-compiler-tests jck-compiler-summary \
 	jck-runtime jck-runtime-tests jck-runtime-summary check-jck
 
diff --git a/test/com/sun/javadoc/5093723/T5093723.java b/test/com/sun/javadoc/5093723/T5093723.java
index cab8c1d..4fb3f90 100644
--- a/test/com/sun/javadoc/5093723/T5093723.java
+++ b/test/com/sun/javadoc/5093723/T5093723.java
@@ -36,7 +36,7 @@ public class T5093723 extends JavadocTester {
     private static final String BUG_ID = "5093723";
 
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID + ".out", "-source", "5",
+        "-d", BUG_ID + ".out", "-source", "5", "-Xdoclint:none",
         SRC_DIR + "/DocumentedClass.java",
         SRC_DIR + "/UndocumentedClass.java"
     };
diff --git a/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/test/com/sun/javadoc/AuthorDD/AuthorDD.java
index c238abf..e65f81a 100644
--- a/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+++ b/test/com/sun/javadoc/AuthorDD/AuthorDD.java
@@ -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 @@ public class AuthorDD
 
              // 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" },
 
         };
diff --git a/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java b/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java
index 0324817..75562bd 100644
--- a/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java
+++ b/test/com/sun/javadoc/DocRootSlash/DocRootSlash.java
@@ -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
@@ -60,6 +60,7 @@ public class DocRootSlash
         String srcdir = System.getProperty("test.src", ".");
 
         runJavadoc(new String[] {"-d", TMPDIR_STRING1,
+                                 "-Xdoclint:none",
                                  "-overview", (srcdir + FS + "overview.html"),
                                  "-header", "<A HREF=\"{@docroot}/package-list\">{@docroot}</A> <A HREF=\"{@docRoot}/help-doc\">{@docRoot}</A>",
                                  "-sourcepath", srcdir,
diff --git a/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java b/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java
new file mode 100644
index 0000000..04d77e3
--- /dev/null
+++ b/test/com/sun/javadoc/InheritDocForUserTags/DocTest.java
@@ -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() {
+    }
+}
+
diff --git a/test/com/sun/javadoc/MetaTag/MetaTag.java b/test/com/sun/javadoc/MetaTag/MetaTag.java
index 6e0e726..c2a43b5 100644
--- a/test/com/sun/javadoc/MetaTag/MetaTag.java
+++ b/test/com/sun/javadoc/MetaTag/MetaTag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -24,9 +24,6 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
-import com.sun.tools.doclets.formats.html.ConfigurationImpl;
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-
 /*
  * @test
  * @bug      4034096 4764726 6235799
@@ -135,13 +132,7 @@ public class MetaTag extends JavadocTester {
      */
     public static void main(String[] args) {
         MetaTag tester = new MetaTag();
-        Configuration config = ConfigurationImpl.getInstance();
-        boolean defaultKeywordsSetting = config.keywords;
-        boolean defaultTimestampSetting = config.notimestamp;
         run(tester, ARGS, TEST, NEGATED_TEST);
-        //Variable needs to be reset because Configuration is a singleton.
-        config.keywords = defaultKeywordsSetting;
-        config.notimestamp = defaultTimestampSetting;
         run(tester, ARGS_NO_TIMESTAMP_NO_KEYWORDS, TEST2, NEGATED_TEST2);
         tester.printSummary();
     }
diff --git a/test/com/sun/javadoc/T6735320/T6735320.java b/test/com/sun/javadoc/T6735320/T6735320.java
index 9646557..19b1df4 100644
--- a/test/com/sun/javadoc/T6735320/T6735320.java
+++ b/test/com/sun/javadoc/T6735320/T6735320.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -47,8 +47,8 @@ public class T6735320 extends JavadocTester {
 
     public static void main(String... args) {
         T6735320 tester = new T6735320();
-        if (tester.runJavadoc(ARGS) != 0) {
-            throw new AssertionError("non-zero return code from javadoc");
+        if (tester.runJavadoc(ARGS) == 0) {
+            throw new AssertionError("zero return code from javadoc");
         }
         if (tester.getErrorOutput().contains("StringIndexOutOfBoundsException")) {
             throw new AssertionError("javadoc threw StringIndexOutOfBoundsException");
diff --git a/test/com/sun/javadoc/VersionNumber/VersionNumber.java b/test/com/sun/javadoc/VersionNumber/VersionNumber.java
index eadf1ca..e4cb010 100644
--- a/test/com/sun/javadoc/VersionNumber/VersionNumber.java
+++ b/test/com/sun/javadoc/VersionNumber/VersionNumber.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -84,7 +84,7 @@ public class VersionNumber {
 
             // Test the proper DOCTYPE element is present:
             {
-                 "<!-- Generated by javadoc (version",
+                 "<!-- Generated by javadoc (",
                      TMPDEST_DIR1 + "p1" + FS + "C.html"  },
 
         };
diff --git a/test/com/sun/javadoc/_template/Template.java b/test/com/sun/javadoc/_template/Template.java
index 4598ce7..484a1ad 100644
--- a/test/com/sun/javadoc/_template/Template.java
+++ b/test/com/sun/javadoc/_template/Template.java
@@ -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 {
diff --git a/test/com/sun/javadoc/_template/TemplateComplete.java b/test/com/sun/javadoc/_template/TemplateComplete.java
index 0aeb472..5c63487 100644
--- a/test/com/sun/javadoc/_template/TemplateComplete.java
+++ b/test/com/sun/javadoc/_template/TemplateComplete.java
@@ -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 {
diff --git a/test/com/sun/javadoc/testAbstractMethod/TestAbstractMethod.java b/test/com/sun/javadoc/testAbstractMethod/TestAbstractMethod.java
new file mode 100644
index 0000000..75a662d
--- /dev/null
+++ b/test/com/sun/javadoc/testAbstractMethod/TestAbstractMethod.java
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ *
+ * 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      8004891
+ * @summary  Make sure that the abstract method is identified correctly
+ *           if the abstract modifier is present explicitly or implicitly.
+ * @author   bpatel
+ * @library  ../lib/
+ * @build    JavadocTester TestAbstractMethod
+ * @run main TestAbstractMethod
+ */
+
+public class TestAbstractMethod extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8004891";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<td class=\"colFirst\"><code>default void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
+            "All Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span><span id=\"t3\" " +
+            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\"> </span>" +
+            "</span><span id=\"t5\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span></caption>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
+            "All Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span><span id=\"t3\" " +
+            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">Abstract " +
+            "Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(8);\">Concrete Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span></caption>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<td class=\"colFirst\"><code>abstract void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
+            "All Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t5\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span></caption>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<td class=\"colFirst\"><code>default void</code></td>"}
+    };
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<td class=\"colFirst\"><code>abstract void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<span><a href=\"javascript:show(16);\">Default Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<td class=\"colFirst\"><code>default void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<span><a href=\"javascript:show(4);\">Abstract Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span>"}
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestAbstractMethod tester = new TestAbstractMethod();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testAbstractMethod/pkg/A.java b/test/com/sun/javadoc/testAbstractMethod/pkg/A.java
new file mode 100644
index 0000000..c52f249
--- /dev/null
+++ b/test/com/sun/javadoc/testAbstractMethod/pkg/A.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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 interface A {
+
+    public void method1();
+
+    public default void defaultMethod() { }
+}
diff --git a/test/com/sun/javadoc/testAbstractMethod/pkg/B.java b/test/com/sun/javadoc/testAbstractMethod/pkg/B.java
new file mode 100644
index 0000000..ccc58e1
--- /dev/null
+++ b/test/com/sun/javadoc/testAbstractMethod/pkg/B.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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 abstract class B {
+
+    public abstract void method1();
+
+    public void method2() { }
+}
diff --git a/test/com/sun/javadoc/testAbstractMethod/pkg/C.java b/test/com/sun/javadoc/testAbstractMethod/pkg/C.java
new file mode 100644
index 0000000..a348a69
--- /dev/null
+++ b/test/com/sun/javadoc/testAbstractMethod/pkg/C.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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 interface C {
+
+    public default void onlyMethod() { }
+}
diff --git a/test/com/sun/javadoc/testAnnotationOptional/TestAnnotationOptional.java b/test/com/sun/javadoc/testAnnotationOptional/TestAnnotationOptional.java
new file mode 100644
index 0000000..b85f300
--- /dev/null
+++ b/test/com/sun/javadoc/testAnnotationOptional/TestAnnotationOptional.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2009, 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  Make sure that annotations types with optional elements has
+ *           element headers
+ * @author   Mahmood Ali
+ * @library  ../lib/
+ * @build    JavadocTester
+ * @build    TestAnnotationOptional
+ * @run main TestAnnotationOptional
+ */
+
+public class TestAnnotationOptional extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "NO_BUG_ID_YET";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-source", "1.5", "pkg"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg" + FS + "AnnotationOptional.html",
+            "<a name=\"annotation_type_element_detail\">"
+        }
+    };
+
+    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) {
+        TestAnnotationOptional tester = new TestAnnotationOptional();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testAnnotationOptional/pkg/AnnotationOptional.java b/test/com/sun/javadoc/testAnnotationOptional/pkg/AnnotationOptional.java
new file mode 100644
index 0000000..3894f01
--- /dev/null
+++ b/test/com/sun/javadoc/testAnnotationOptional/pkg/AnnotationOptional.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2009, 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This is just a test annotation type with optional value element.
+ *
+ * @author Mahmood Ali
+ * @since 1.5
+ */
+ at Documented public @interface AnnotationOptional {
+    String value() default "";
+}
diff --git a/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java b/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
index 9f92854..266aafd 100644
--- a/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
+++ b/test/com/sun/javadoc/testBadSourceFile/TestBadSourceFile.java
@@ -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
@@ -40,7 +40,7 @@ public class TestBadSourceFile extends JavadocTester {
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, SRC_DIR + FS + "C2.java"
+        "-Xdoclint:none", "-d", BUG_ID, SRC_DIR + FS + "C2.java"
     };
 
     //Input for string search tests.
diff --git a/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
index 17b3462..2742285 100644
--- a/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+++ b/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
@@ -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 @@ public class TestConstructorIndent extends JavadocTester {
     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;
diff --git a/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java b/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java
new file mode 100644
index 0000000..e11976a
--- /dev/null
+++ b/test/com/sun/javadoc/testDocEncoding/TestDocEncoding.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug      8000743
+ * @summary  Run tests on -docencoding to see if the value is
+             used for stylesheet as well.
+ * @author   jayashree viswanathan
+ * @library  ../lib/
+ * @build    JavadocTester TestDocEncoding
+ * @run main TestDocEncoding
+ */
+
+public class TestDocEncoding extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8000743";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-docencoding", "Cp930",
+        "-sourcepath", SRC_DIR, "pkg"
+    };
+
+    private static final String[][] TEST = NO_TEST;
+
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "stylesheet.css",
+            "body {" + NL + "    background-color:#ffffff;"}
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestDocEncoding tester = new TestDocEncoding();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
+
diff --git a/test/com/sun/javadoc/testDocEncoding/pkg/Test.java b/test/com/sun/javadoc/testDocEncoding/pkg/Test.java
new file mode 100644
index 0000000..134fda2
--- /dev/null
+++ b/test/com/sun/javadoc/testDocEncoding/pkg/Test.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+package pkg;
+
+public class Test {}
+
diff --git a/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java b/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java
index dcedab6..c5dd346 100644
--- a/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java
+++ b/test/com/sun/javadoc/testDocFileDir/TestDocFileDir.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -77,17 +77,19 @@ public class TestDocFileDir extends JavadocTester {
     //Output dir = Input Dir
     private static final String[] ARGS1 =
         new String[] {
-            "-d", BUG_ID + "-1", "-sourcepath",
-            "blah" + String.valueOf(File.pathSeparatorChar) +
-                BUG_ID + "-1" + String.valueOf(File.pathSeparatorChar) +
-                "blah", "pkg"};
+            "-d", BUG_ID + "-1",
+            "-sourcepath",
+                "blah" + File.pathSeparator + BUG_ID + "-1" + File.pathSeparator + "blah",
+            "pkg"};
 
     //Exercising -docfilessubdirs and -excludedocfilessubdir
     private static final String[] ARGS2 =
         new String[] {
-            "-d", BUG_ID + "-2", "-sourcepath", SRC_DIR,
-            "-docfilessubdirs", "-excludedocfilessubdir",
-            "subdir-excluded1:subdir-excluded2", "pkg"};
+            "-d", BUG_ID + "-2",
+            "-sourcepath", SRC_DIR,
+            "-docfilessubdirs",
+            "-excludedocfilessubdir", "subdir-excluded1:subdir-excluded2",
+            "pkg"};
 
     //Output dir = "", Input dir = ""
     private static final String[] ARGS0 =
diff --git a/test/com/sun/javadoc/testDocFiles/TestDocFiles.java b/test/com/sun/javadoc/testDocFiles/TestDocFiles.java
new file mode 100644
index 0000000..e2a9c56
--- /dev/null
+++ b/test/com/sun/javadoc/testDocFiles/TestDocFiles.java
@@ -0,0 +1,67 @@
+/*
+ * 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 8008949
+ * @summary verify that doc-files get copied
+ * @library ../lib/
+ * @build JavadocTester
+ * @build TestDocFiles
+ * @run main TestDocFiles
+ */
+
+public class TestDocFiles extends JavadocTester {
+
+    private static final String BUG_ID = "8008949";
+    private static final String[][] TEST = {
+        {"tmp" + FS + "pkg" + FS + "doc-files" + FS + "test.txt", "test file"}};
+
+    private static final String[] ARGS =
+        new String[] {
+            "-d", "tmp", "-sourcepath", SRC_DIR, "pkg"};
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestDocFiles tester = new TestDocFiles();
+        run(tester, ARGS, TEST, NO_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testDocFiles/pkg/Test.java b/test/com/sun/javadoc/testDocFiles/pkg/Test.java
new file mode 100644
index 0000000..708a284
--- /dev/null
+++ b/test/com/sun/javadoc/testDocFiles/pkg/Test.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+package pkg;
+
+public class Test { }
+
diff --git a/test/com/sun/javadoc/testDocFiles/pkg/doc-files/test.txt b/test/com/sun/javadoc/testDocFiles/pkg/doc-files/test.txt
new file mode 100644
index 0000000..ec25cd3
--- /dev/null
+++ b/test/com/sun/javadoc/testDocFiles/pkg/doc-files/test.txt
@@ -0,0 +1,2 @@
+this is a test file
+
diff --git a/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java b/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java
new file mode 100644
index 0000000..162105e
--- /dev/null
+++ b/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ *
+ * 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 8000418
+ * @summary Verify that files use a common Generated By string
+ * @library ../lib/
+ * @build JavadocTester TestGeneratedBy
+ * @run main TestGeneratedBy
+ */
+
+public class TestGeneratedBy extends JavadocTester {
+
+    private static final String OUTPUT_DIR = "tmp";
+
+    private static final String[] FILES = {
+        "pkg/MyClass.html",
+        "pkg/package-summary.html",
+        "pkg/package-frame.html",
+        "pkg/package-tree.html",
+        "allclasses-noframe.html",
+        "constant-values.html",
+        "allclasses-frame.html",
+        "overview-tree.html",
+        "deprecated-list.html",
+        "serialized-form.html",
+        "help-doc.html",
+        "index-all.html",
+        "index.html"
+    };
+
+    private static final String[] ARGS =
+        new String[] {
+            "-d", OUTPUT_DIR,
+            "-sourcepath", SRC_DIR,
+            "pkg"
+        };
+    private static final String BUG_ID = "8000418";
+
+    private static String[][] getTests() {
+        String version = System.getProperty("java.version");
+        String[][] tests = new String[FILES.length][];
+        for (int i = 0; i < FILES.length; i++) {
+            tests[i] = new String[] {
+                OUTPUT_DIR + FS + FILES[i],
+                "Generated by javadoc (" + version + ") on "
+            };
+        }
+        return tests;
+    }
+
+    private static String[][] getNegatedTests() {
+        String[][] tests = new String[FILES.length][];
+        for (int i = 0; i < FILES.length; i++) {
+            tests[i] = new String[] {
+                OUTPUT_DIR + FS + FILES[i],
+                "Generated by javadoc (version",
+                "Generated by javadoc on"
+            };
+        }
+        return tests;
+    }
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestGeneratedBy tester = new TestGeneratedBy();
+        int exitCode = run(tester, ARGS, getTests(), getNegatedTests());
+        tester.printSummary();
+        if (exitCode != 0) {
+            throw new Error("Error found while executing Javadoc");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
+
diff --git a/test/com/sun/javadoc/testGeneratedBy/pkg/MyClass.java b/test/com/sun/javadoc/testGeneratedBy/pkg/MyClass.java
new file mode 100644
index 0000000..b3b699b
--- /dev/null
+++ b/test/com/sun/javadoc/testGeneratedBy/pkg/MyClass.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.io.Serializable;
+
+public class MyClass implements Serializable {
+}
diff --git a/test/com/sun/javadoc/testHelpOption/TestHelpOption.java b/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
index f817596..e85ffd7 100644
--- a/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
+++ b/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
@@ -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
@@ -78,7 +78,6 @@ public class TestHelpOption extends JavadocTester {
         {STANDARD_OUTPUT, "-tag "},
         {STANDARD_OUTPUT, "-taglet "},
         {STANDARD_OUTPUT, "-tagletpath "},
-        {STANDARD_OUTPUT, "-Xdocrootparent "},
         {STANDARD_OUTPUT, "-charset "},
         {STANDARD_OUTPUT, "-helpfile "},
         {STANDARD_OUTPUT, "-linksource "},
diff --git a/test/com/sun/javadoc/testHref/TestHref.java b/test/com/sun/javadoc/testHref/TestHref.java
index d7952f6..297ddc6 100644
--- a/test/com/sun/javadoc/testHref/TestHref.java
+++ b/test/com/sun/javadoc/testHref/TestHref.java
@@ -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 @@ public class TestHref extends JavadocTester {
         },
         //@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.
diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
index 508175a..80d3797 100644
--- a/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+++ b/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, 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
@@ -53,64 +53,64 @@ public class TestHtmlDefinitionListTag extends JavadocTester {
     // 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>" +
                  " <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 + " " + 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 + " " + 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>" +
                  " <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>" +
                  " </div>" + NL +
                  "<div class=\"block\">The name for this class.</div>"}};
@@ -121,55 +121,55 @@ public class TestHtmlDefinitionListTag extends JavadocTester {
     // 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>" +
                  " <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 + " " + 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 + " " + 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>" +
                  " <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>" +
                  " </div>" + NL + "<div class=\"block\">" +
                  "The name for this class.</div>"}};
@@ -222,19 +222,19 @@ public class TestHtmlDefinitionListTag extends JavadocTester {
 
     private static final String[] ARGS1 =
         new String[] {
-            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
+            "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
 
     private static final String[] ARGS2 =
         new String[] {
-            "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
+            "-Xdoclint:none", "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
 
     private static final String[] ARGS3 =
         new String[] {
-            "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
+            "-Xdoclint:none", "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
 
     private static final String[] ARGS4 =
         new String[] {
-            "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
+            "-Xdoclint:none", "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
 
     /**
      * The entry point of the test.
diff --git a/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java b/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
index d6e16e0..724630b 100644
--- a/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
+++ b/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -60,7 +60,7 @@ public class TestHtmlDocument {
     // Generate the HTML output using the HTML document generation within doclet.
     public static String generateHtmlTree() {
         // Document type for the HTML document
-        DocType htmlDocType = DocType.Transitional();
+        DocType htmlDocType = DocType.TRANSITIONAL;
         HtmlTree html = new HtmlTree(HtmlTag.HTML);
         HtmlTree head = new HtmlTree(HtmlTag.HEAD);
         HtmlTree title = new HtmlTree(HtmlTag.TITLE);
diff --git a/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java b/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
index df87249..c6b14e0 100644
--- a/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
+++ b/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -201,7 +201,15 @@ public class TestHtmlTableTags extends JavadocTester {
             "<caption><span>Fields</span><span class=\"tabEnd\"> </span></caption>"
         },
         {BUG_ID + FS + "pkg1" + FS + "C1.html",
-            "<caption><span>Methods</span><span class=\"tabEnd\"> </span></caption>"
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "</caption>"
         },
         {BUG_ID + FS + "pkg2" + FS + "C2.html",
             "<caption><span>Nested Classes</span><span class=\"tabEnd\"> </span></caption>"
diff --git a/test/com/sun/javadoc/testIndentation/TestIndentation.java b/test/com/sun/javadoc/testIndentation/TestIndentation.java
new file mode 100644
index 0000000..09a31cd
--- /dev/null
+++ b/test/com/sun/javadoc/testIndentation/TestIndentation.java
@@ -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 <T> void m(T t1," },
+        { BUG_ID + FS + "p" + FS + "Indent.html",
+          NL + "                  T 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();
+    }
+}
diff --git a/test/com/sun/javadoc/testIndentation/p/Indent.java b/test/com/sun/javadoc/testIndentation/p/Indent.java
new file mode 100644
index 0000000..888ad91
--- /dev/null
+++ b/test/com/sun/javadoc/testIndentation/p/Indent.java
@@ -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 { }
+}
diff --git a/test/com/sun/javadoc/testIndex/TestIndex.java b/test/com/sun/javadoc/testIndex/TestIndex.java
index f389828..ae916ba 100644
--- a/test/com/sun/javadoc/testIndex/TestIndex.java
+++ b/test/com/sun/javadoc/testIndex/TestIndex.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -53,28 +53,28 @@ public class TestIndex extends JavadocTester {
 
         //Test index-all.html
         {BUG_ID + FS + "index-all.html",
-            "<a href=\"./pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" +
-            " - Class in <a href=\"./pkg/package-summary.html\">pkg</a>"},
+            "<a href=\"pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" +
+            " - Class in <a href=\"pkg/package-summary.html\">pkg</a>"},
         {BUG_ID + FS + "index-all.html",
-            "<a href=\"./pkg/Interface.html\" title=\"interface in pkg\">" +
+            "<a href=\"pkg/Interface.html\" title=\"interface in pkg\">" +
             "<span class=\"strong\">Interface</span></a> - Interface in " +
-            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+            "<a href=\"pkg/package-summary.html\">pkg</a>"},
         {BUG_ID + FS + "index-all.html",
-            "<a href=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
+            "<a href=\"pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
             "<span class=\"strong\">AnnotationType</span></a> - Annotation Type in " +
-            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+            "<a href=\"pkg/package-summary.html\">pkg</a>"},
         {BUG_ID + FS + "index-all.html",
-            "<a href=\"./pkg/Coin.html\" title=\"enum in pkg\">" +
+            "<a href=\"pkg/Coin.html\" title=\"enum in pkg\">" +
             "<span class=\"strong\">Coin</span></a> - Enum in " +
-            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+            "<a href=\"pkg/package-summary.html\">pkg</a>"},
         {BUG_ID + FS + "index-all.html",
-            "Class in <a href=\"./package-summary.html\"><Unnamed></a>"},
+            "Class in <a href=\"package-summary.html\"><Unnamed></a>"},
         {BUG_ID + FS + "index-all.html",
-            "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"./pkg/C.html#Java\">" +
-            "Java</a></span> - Static variable in class pkg.<a href=\"./pkg/C.html\" " +
+            "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"pkg/C.html#Java\">" +
+            "Java</a></span> - Static variable in class pkg.<a href=\"pkg/C.html\" " +
             "title=\"class in pkg\">C</a></dt>" + NL + "<dd> </dd>" + NL +
-            "<dt><span class=\"strong\"><a href=\"./pkg/C.html#JDK\">JDK</a></span> " +
-            "- Static variable in class pkg.<a href=\"./pkg/C.html\" title=\"class in pkg\">" +
+            "<dt><span class=\"strong\"><a href=\"pkg/C.html#JDK\">JDK</a></span> " +
+            "- Static variable in class pkg.<a href=\"pkg/C.html\" title=\"class in pkg\">" +
             "C</a></dt>" + NL + "<dd> </dd>" + NL + "</dl>"},
     };
     private static final String[][] NEGATED_TEST = NO_TEST;
diff --git a/test/com/sun/javadoc/testJavaFX/C.java b/test/com/sun/javadoc/testJavaFX/C.java
index 5cab58c..7005185 100644
--- a/test/com/sun/javadoc/testJavaFX/C.java
+++ b/test/com/sun/javadoc/testJavaFX/C.java
@@ -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
@@ -57,6 +57,7 @@ public class C {
      * Defines the direction/speed at which the {@code Timeline} is expected to
      * be played.
      * @defaultValue 11
+     * @since JavaFX 8.0
      */
     private DoubleProperty rate;
 
diff --git a/test/com/sun/javadoc/testJavaFX/D.java b/test/com/sun/javadoc/testJavaFX/D.java
index 73e2576..a48bd6a 100644
--- a/test/com/sun/javadoc/testJavaFX/D.java
+++ b/test/com/sun/javadoc/testJavaFX/D.java
@@ -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
diff --git a/test/com/sun/javadoc/testJavaFX/TestJavaFX.java b/test/com/sun/javadoc/testJavaFX/TestJavaFX.java
index 745ca78..18d77db 100644
--- a/test/com/sun/javadoc/testJavaFX/TestJavaFX.java
+++ b/test/com/sun/javadoc/testJavaFX/TestJavaFX.java
@@ -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 7112427
+ * @bug 7112427 8012295
  * @summary Test of the JavaFX doclet features.
  * @author jvalenta
  * @library ../lib/
@@ -38,27 +38,28 @@ public class TestJavaFX extends JavadocTester {
     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 void setRate(double 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 double 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>"},
+                "<span class=\"strong\">Since:</span></dt>" + NL + "<dd>JavaFX 8.0</dd>" },
+            {"./" + BUG_ID + "/C.html",
+                "<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",
@@ -79,7 +80,7 @@ public class TestJavaFX extends JavadocTester {
 
 
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private",
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-javafx",
         SRC_DIR + FS + "C.java", SRC_DIR + FS + "D.java"
     };
 
@@ -88,7 +89,6 @@ public class TestJavaFX extends JavadocTester {
      * @param args the array of command line arguments.
      */
     public static void main(String[] args) {
-        System.setProperty("javafx.javadoc", "true");
         TestJavaFX tester = new TestJavaFX();
         run(tester, ARGS, TEST, NO_TEST);
         tester.printSummary();
diff --git a/test/com/sun/javadoc/testJavascript/TestJavascript.java b/test/com/sun/javadoc/testJavascript/TestJavascript.java
index b1293bf..763566a 100644
--- a/test/com/sun/javadoc/testJavascript/TestJavascript.java
+++ b/test/com/sun/javadoc/testJavascript/TestJavascript.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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      4665566 4855876 7025314
+ * @bug      4665566 4855876 7025314 8012375 8015997
  * @summary  Verify that the output has the right javascript.
  * @author   jamieh
  * @library  ../lib/
@@ -35,7 +35,7 @@
 public class TestJavascript extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4665566-4855876";
+    private static final String BUG_ID = "4665566-4855876-8012375";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -53,8 +53,42 @@ public class TestJavascript extends JavadocTester {
                         "    targetPage = \"\" + window.location.search;" + NL +
             "    if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
             "        targetPage = targetPage.substring(1);" + NL +
-            "    if (targetPage.indexOf(\":\") != -1)" + NL +
+            "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + NL +
             "        targetPage = \"undefined\";" + NL +
+            "    function validURL(url) {" + NL +
+            "        var pos = url.indexOf(\".html\");" + NL +
+            "        if (pos == -1 || pos != url.length - 5)" + NL +
+            "            return false;" + NL +
+            "        var allowNumber = false;" + NL +
+            "        var allowSep = false;" + NL +
+            "        var seenDot = false;" + NL +
+            "        for (var i = 0; i < url.length - 5; i++) {" + NL +
+            "            var ch = url.charAt(i);" + NL +
+            "            if ('a' <= ch && ch <= 'z' ||" + NL +
+            "                    'A' <= ch && ch <= 'Z' ||" + NL +
+            "                    ch == '$' ||" + NL +
+            "                    ch == '_') {" + NL +
+            "                allowNumber = true;" + NL +
+            "                allowSep = true;" + NL +
+            "            } else if ('0' <= ch && ch <= '9'" + NL +
+            "                    || ch == '-') {" + NL +
+            "                if (!allowNumber)" + NL +
+            "                     return false;" + NL +
+            "            } else if (ch == '/' || ch == '.') {" + NL +
+            "                if (!allowSep)" + NL +
+            "                    return false;" + NL +
+            "                allowNumber = false;" + NL +
+            "                allowSep = false;" + NL +
+            "                if (ch == '.')" + NL +
+            "                     seenDot = true;" + NL +
+            "                if (ch == '/' && seenDot)" + NL +
+            "                     return false;" + NL +
+            "            } else {" + NL +
+            "                return false;" + NL +
+            "            }" + NL +
+            "        }" + NL +
+            "        return true;" + NL +
+            "    }" + NL +
             "    function loadFrames() {" + NL +
             "        if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
             "             top.classFrame.location = top.targetPage;" + NL +
diff --git a/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java b/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java
new file mode 100644
index 0000000..7a157ff
--- /dev/null
+++ b/test/com/sun/javadoc/testLambdaFeature/TestLambdaFeature.java
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ *
+ * 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      8004893
+ * @summary  Make sure that the lambda feature changes work fine in
+ *           javadoc.
+ * @author   bpatel
+ * @library  ../lib/
+ * @build    JavadocTester TestLambdaFeature
+ * @run main TestLambdaFeature
+ */
+
+public class TestLambdaFeature extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8004893";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<td class=\"colFirst\"><code>default void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<pre>default void defaultMethod()</pre>"},
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>" +
+            "All Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(2);\">Instance Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span><span id=\"t3\" " +
+            "class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\"> </span>" +
+            "</span><span id=\"t5\" class=\"tableTab\"><span>" +
+            "<a href=\"javascript:show(16);\">Default Methods</a></span>" +
+            "<span class=\"tabEnd\"> </span></span></caption>"},
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<dl>" + NL + "<dt>Functional Interface:</dt>" + NL +
+            "<dd>This is a functional interface and can therefore be used as " +
+            "the assignment target for a lambda expression or method " +
+            "reference.</dd>" + NL + "</dl>"}
+    };
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<td class=\"colFirst\"><code>default default void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "A.html",
+            "<pre>default default void defaultMethod()</pre>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<td class=\"colFirst\"><code>default void</code></td>"},
+        {BUG_ID + FS + "pkg" + FS + "B.html",
+            "<dl>" + NL + "<dt>Functional Interface:</dt>"}
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestLambdaFeature tester = new TestLambdaFeature();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testLambdaFeature/pkg/A.java b/test/com/sun/javadoc/testLambdaFeature/pkg/A.java
new file mode 100644
index 0000000..c52f249
--- /dev/null
+++ b/test/com/sun/javadoc/testLambdaFeature/pkg/A.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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 interface A {
+
+    public void method1();
+
+    public default void defaultMethod() { }
+}
diff --git a/test/com/sun/javadoc/testLambdaFeature/pkg/B.java b/test/com/sun/javadoc/testLambdaFeature/pkg/B.java
new file mode 100644
index 0000000..ccc58e1
--- /dev/null
+++ b/test/com/sun/javadoc/testLambdaFeature/pkg/B.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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 abstract class B {
+
+    public abstract void method1();
+
+    public void method2() { }
+}
diff --git a/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java b/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java
new file mode 100644
index 0000000..bce27a9
--- /dev/null
+++ b/test/com/sun/javadoc/testLiteralCodeInPre/TestLiteralCodeInPre.java
@@ -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 <T> 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 <T> 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 <T> 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();
+    }
+}
diff --git a/test/com/sun/javadoc/testLiteralCodeInPre/pkg/Test.java b/test/com/sun/javadoc/testLiteralCodeInPre/pkg/Test.java
new file mode 100644
index 0000000..3d6fffb
--- /dev/null
+++ b/test/com/sun/javadoc/testLiteralCodeInPre/pkg/Test.java
@@ -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() { }
+}
diff --git a/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java b/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java
new file mode 100644
index 0000000..634ee4e
--- /dev/null
+++ b/test/com/sun/javadoc/testMethodTypes/TestMethodTypes.java
@@ -0,0 +1,139 @@
+/*
+ * 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.
+ *
+ * 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      8002304
+ * @summary  Test for various method types in the method summary table
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestMethodTypes
+ * @run main TestMethodTypes
+ */
+
+public class TestMethodTypes extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8002304";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
+    };
+
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "var methods = {"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t1\" class=\"tableTab\"><span><a href=\"javascript:show(1);\">" +
+            "Static Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<tr id=\"i0\" class=\"altColor\">"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "B.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "var methods = {"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "<caption><span id=\"t0\" class=\"activeTableTab\"><span>All " +
+            "Methods</span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t2\" class=\"tableTab\"><span><a href=\"javascript:show(2);\">" +
+            "Instance Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t3\" class=\"tableTab\"><span><a href=\"javascript:show(4);\">" +
+            "Abstract Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t4\" class=\"tableTab\"><span><a href=\"javascript:show(8);\">" +
+            "Concrete Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "<span id=\"t6\" class=\"tableTab\"><span><a href=\"javascript:show(32);\">" +
+            "Deprecated Methods</a></span><span class=\"tabEnd\"> </span></span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "D.html",
+            "<tr id=\"i0\" class=\"altColor\">"
+        },
+    };
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg1" + FS + "A.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\"> </span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg1" + FS + "B.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\"> </span>" +
+            "</caption>"
+        },
+
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<caption><span>Methods</span><span class=\"tabEnd\"> </span>" +
+            "</caption>"
+        },
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestMethodTypes tester = new TestMethodTypes();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testMethodTypes/pkg1/A.java b/test/com/sun/javadoc/testMethodTypes/pkg1/A.java
new file mode 100644
index 0000000..6a75d86
--- /dev/null
+++ b/test/com/sun/javadoc/testMethodTypes/pkg1/A.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+/**
+ * This class has a mixture of different types of methods. The methods summary
+ * table should appear with "All Methods", "Static Methods", "Instance Methods",
+ * "Concrete Methods" and "Deprecated Methods".
+ */
+public class A {
+
+    /**
+     * This is the first concrete instance method.
+     */
+    public void readObject() {
+    }
+
+    /**
+     * This is the second concrete instance method.
+     */
+    public final void setStub() {
+    }
+
+    /**
+     * This is the third concrete instance method.
+     */
+    public String getParameter() {
+         return "test";
+     }
+
+    /**
+     * This is the first concrete instance deprecated method.
+     * @deprecated This is a deprecated method that should appear in the tab.
+     */
+    public void resize() {
+    }
+
+    /**
+     * This is the fourth concrete instance method.
+     */
+    public void showStatus() {
+    }
+
+    /**
+     * This is the first concrete static method.
+     */
+    public final static void staticMethod() {
+    }
+
+    /**
+     * This is the second concrete instance deprecated method.
+     */
+    @Deprecated
+    public void init() {
+    }
+}
diff --git a/test/com/sun/javadoc/testMethodTypes/pkg1/B.java b/test/com/sun/javadoc/testMethodTypes/pkg1/B.java
new file mode 100644
index 0000000..1404e09
--- /dev/null
+++ b/test/com/sun/javadoc/testMethodTypes/pkg1/B.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+/**
+ * This interface has different types of methods such as "Instance Methods" and
+ * "Abstract Methods". All the tabs will display same list of methods.
+ */
+public interface B {
+
+    /**
+     * This is the first abstract instance method.
+     */
+    public void setName();
+
+    /**
+     * This is the second abstract instance method.
+     */
+    public String getName();
+
+    /**
+     * This is the third abstract instance method.
+     */
+    public boolean addEntry();
+
+    /**
+     * This is the fourth abstract instance method.
+     */
+    public boolean removeEntry();
+
+    /**
+     * This is the fifth abstract instance method.
+     */
+    public String getPermissions();
+}
diff --git a/test/com/sun/javadoc/testMethodTypes/pkg1/D.java b/test/com/sun/javadoc/testMethodTypes/pkg1/D.java
new file mode 100644
index 0000000..2d6b36c
--- /dev/null
+++ b/test/com/sun/javadoc/testMethodTypes/pkg1/D.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+/**
+ * This class is marked as deprecated and has a mixture of different types of
+ * methods such as "Instance Methods", "Abstract Methods" and "Concrete
+ * Methods". None of the methods are marked as deprecated but since the class is
+ * deprecated, the methods will also be deprecated and "Deprecated Methods" tab
+ * will also be shown with all the methods.
+ */
+ at Deprecated
+public abstract class D {
+
+    /**
+     * This is the first abstract instance method.
+     */
+    public abstract void readObject();
+
+    /**
+     * This is the first concrete instance method.
+     */
+    public final void setStub() {
+    }
+
+    /**
+     * This is the second concrete instance method.
+     */
+    public String getParameter() {
+         return "test";
+     }
+}
diff --git a/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java b/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java
index 2f8e8f6..b72d6fb 100644
--- a/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java
+++ b/test/com/sun/javadoc/testNestedInlineTag/TestNestedInlineTag.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2002, 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
@@ -21,10 +21,8 @@
  * questions.
  */
 
-/**
- * This should be green, underlined and bold (Class): {@underline {@bold {@green My test}}} .
+/*
  * @test
- * @bug 0000000
  * @summary Test for nested inline tags. *
  * @author jamieh
  * @library ../lib/
@@ -36,6 +34,9 @@
  * @run main TestNestedInlineTag
  */
 
+/**
+ * This should be green, underlined and bold (Class): {@underline {@bold {@green My test}}} .
+ */
 public class TestNestedInlineTag extends JavadocTester {
 
     /**
diff --git a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java
index c5d4912..d77ec0c 100644
--- a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java
+++ b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/BoldTaglet.java
@@ -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 @@ public class BoldTaglet extends BaseInlineTaglet {
     /**
      * {@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()));
diff --git a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java
index 129c020..719d01c 100644
--- a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java
+++ b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/GreenTaglet.java
@@ -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 @@ public class GreenTaglet extends BaseInlineTaglet {
     /**
      * {@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()));
diff --git a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java
index 2cee071..ad422bc 100644
--- a/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java
+++ b/test/com/sun/javadoc/testNestedInlineTag/testtaglets/UnderlineTaglet.java
@@ -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 @@ public class UnderlineTaglet extends BaseInlineTaglet {
     /**
      * {@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()));
diff --git a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
index 0593937..db5c2f2 100644
--- a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+++ b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
@@ -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
@@ -40,7 +40,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, "-use", "-source", "1.5", "-sourcepath", SRC_DIR, "pkg", "pkg1", "pkg2"
+        "-Xdoclint:none", "-d", BUG_ID, "-use", "-source", "1.5", "-sourcepath", SRC_DIR, "pkg", "pkg1", "pkg2"
     };
 
     //Input for string search tests.
@@ -80,21 +80,21 @@ public class TestNewLanguageFeatures extends JavadocTester {
                 "Class TypeParameters<E></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> 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 @@ public class TestNewLanguageFeatures extends JavadocTester {
                 "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
                 "optional</a>=\"Parameter Annotation\",<a " +
                 "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
-                "                    int documented," + NL +
-                "                    int undocmented)</pre>"},
+                "                             int documented," + NL +
+                "                             int undocmented)</pre>"},
 
             //CONSTRUCTOR PARAMS
             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
@@ -245,8 +245,8 @@ public class TestNewLanguageFeatures extends JavadocTester {
                 "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
                 "optional</a>=\"Constructor Param Annotation\",<a " +
                 "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
-                "                   int documented," + NL +
-                "                   int undocmented)</pre>"},
+                "                           int documented," + NL +
+                "                           int undocmented)</pre>"},
 
             //=================================
             // ANNOTATION TYPE USAGE TESTING (All Different Types).
@@ -306,7 +306,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
             // Handle multiple bounds.
             //==============================================================
             {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html",
-                "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"},
+                "public <T extends java.lang.Number & java.lang.Runnable> T foo(T t)"},
 
             //==============================================================
             // Test Class-Use Documenation for Type Parameters.
@@ -323,7 +323,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                      "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
                      "title=\"class in pkg2\">ClassUseTest1</a><T extends " +
                      "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
-                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
+                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
                      "Foo2</a>></strong></code> </td>"
             },
             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
@@ -375,7 +375,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                     "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/ClassUseTest1.html\" " +
                      "title=\"class in pkg2\">ClassUseTest1</a><T extends " +
                      "<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo" +
-                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
+                     "</a> & <a href=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">" +
                      "Foo2</a>></strong></code> </td>"
            },
            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
@@ -443,7 +443,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                      "<td class=\"colFirst\"><code><T extends <a href=\"../" +
                      "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest" +
                      "</a><<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
-                     "pkg2\">Foo3</a>>> <br><a href=\"../../pkg2/" +
+                     "pkg2\">Foo3</a>>><br><a href=\"../../pkg2/" +
                      "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>" +
                      "<<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
                      "pkg2\">Foo3</a>></code></td>"
@@ -486,7 +486,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                      "<td class=\"colFirst\"><code><T extends <a href=\"../../" +
                      "pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</a><" +
                      "<a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3" +
-                     "</a>>> <br><a href=\"../../pkg2/ParamTest.html\" " +
+                     "</a>>><br><a href=\"../../pkg2/ParamTest.html\" " +
                      "title=\"class in pkg2\">ParamTest</a><<a href=\"../../pkg2/" +
                      "Foo3.html\" title=\"class in pkg2\">Foo3</a>></code></td>"
             },
@@ -524,7 +524,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                      "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
                      "ParamTest2</a><java.util.List<? extends <a href=\".." +
                      "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>>" +
-                     ">> <br><a href=\"../../pkg2/ParamTest2.html\" " +
+                     ">><br><a href=\"../../pkg2/ParamTest2.html\" " +
                      "title=\"class in pkg2\">ParamTest2</a><java.util.List" +
                      "<? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
                      "class in pkg2\">Foo4</a>>></code></td>"
@@ -569,7 +569,7 @@ public class TestNewLanguageFeatures extends JavadocTester {
                      "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
                      "ParamTest2</a><java.util.List<? extends <a href=\".." +
                      "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>>" +
-                     ">> <br><a href=\"../../pkg2/ParamTest2.html\" " +
+                     ">><br><a href=\"../../pkg2/ParamTest2.html\" " +
                      "title=\"class in pkg2\">ParamTest2</a><java.util.List" +
                      "<? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
                      "class in pkg2\">Foo4</a>>></code></td>"
@@ -663,14 +663,14 @@ public class TestNewLanguageFeatures extends JavadocTester {
             // TYPE PARAMETER IN INDEX
             //=================================
             {BUG_ID + FS + "index-all.html",
-                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
+                "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" +
                 "method(Vector<Object>)</a></span>"
             },
             //=================================
             // TYPE PARAMETER IN INDEX
             //=================================
             {BUG_ID + FS + "index-all.html",
-                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
+                "<span class=\"strong\"><a href=\"pkg2/Foo.html#method(java.util.Vector)\">" +
                 "method(Vector<Object>)</a></span>"
             },
         };
diff --git a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
index da0a87f..06cb6ee 100644
--- a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+++ b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -52,7 +52,7 @@ public class TestPackagePage extends JavadocTester {
             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
         },
         {BUG_ID + "-1" + FS + "index-all.html",
-            "<li><a href=\"./com/pkg/package-summary.html\">Package</a></li>"
+            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
         },
         {BUG_ID + "-1" + FS + "help-doc.html",
             "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
diff --git a/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java b/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
index 3def6b8..2271539 100644
--- a/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+++ b/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
@@ -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 @@ public class TestParamTaglet extends JavadocTester {
     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.
diff --git a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
index f0cf05d..9ff91c2 100644
--- a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+++ b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4780441 4874845 4978816
+ * @bug      4780441 4874845 4978816 8014017
  * @summary  Make sure that when the -private flag is not used, members
  *           inherited from package private class are documented in the child.
  *
@@ -33,17 +33,19 @@
  *
  *           Make sure that when a private interface method with generic parameters
  *           is implemented, the comments can be inherited properly.
+ *
+ *           Make sure when no modifier appear in the class signature, the
+ *           signature is displayed correctly without extra space at the beginning.
  * @author   jamieh
  * @library  ../lib/
- * @build    JavadocTester
- * @build    TestPrivateClasses
+ * @build    JavadocTester TestPrivateClasses
  * @run main TestPrivateClasses
  */
 
 public class TestPrivateClasses extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4780441-4874845-4978816";
+    private static final String BUG_ID = "4780441-4874845-4978816-8014017";
 
     //Javadoc arguments.
     private static final String[] ARGS1 = new String[] {
@@ -234,8 +236,19 @@ public class TestPrivateClasses extends JavadocTester {
             " in interface <code>" +
             "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
             "<java.lang.String></code></dd>"},
+
+      //Make sure when no modifier appear in the class signature, the
+      //signature is displayed correctly without extra space at the beginning.
+      {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html",
+            "<pre>class <span class=\"strong\">PrivateParent</span>"},
+
+      {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+            "<pre>public class <span class=\"strong\">PublicChild</span>"},
+    };
+    private static final String[][] NEGATED_TEST2 = {
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateParent.html",
+            "<pre> class <span class=\"strong\">PrivateParent</span>"},
     };
-    private static final String[][] NEGATED_TEST2 = NO_TEST;
 
     /**
      * The entry point of the test.
diff --git a/test/com/sun/javadoc/testProfiles/TestProfiles.java b/test/com/sun/javadoc/testProfiles/TestProfiles.java
new file mode 100644
index 0000000..a52d3cc
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/TestProfiles.java
@@ -0,0 +1,190 @@
+/*
+ * 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      8006124 8009684
+ * @summary  Test javadoc support for profiles.
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestProfiles
+ * @run main TestProfiles
+ */
+public class TestProfiles extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8006124-8009684";
+    private static final String PROFILE_BUG_ID = BUG_ID + "-1";
+    private static final String PACKAGE_BUG_ID = BUG_ID + "-2";
+    //Javadoc arguments.
+    private static final String[] ARGS1 = new String[]{
+        "-d", PROFILE_BUG_ID, "-sourcepath", SRC_DIR, "-Xprofilespath", SRC_DIR + FS
+        + "profile-rtjar-includes.txt", "pkg1", "pkg2", "pkg3", "pkg4", "pkg5"
+    };
+    private static final String[] ARGS2 = new String[]{
+        "-d", PACKAGE_BUG_ID, "-sourcepath", SRC_DIR, "pkg1", "pkg2", "pkg3", "pkg4", "pkg5"
+    };
+    //Input for string tests for profiles.
+    private static final String[][] PROFILES_TEST = {
+        // Tests for profile-overview-frame.html listing all profiles.
+        {PROFILE_BUG_ID + FS + "profile-overview-frame.html",
+            "<span><a href=\"overview-frame.html\" "
+            + "target=\"packageListFrame\">All Packages</a></span>"
+        },
+        {PROFILE_BUG_ID + FS + "profile-overview-frame.html",
+            "<li><a href=\"compact1-frame.html\" target=\"packageListFrame\">"
+            + "compact1</a></li>"
+        },
+        // Tests for profileName-frame.html listing all packages in a profile.
+        {PROFILE_BUG_ID + FS + "compact2-frame.html",
+            "<span><a href=\"overview-frame.html\" target=\"packageListFrame\">"
+            + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" "
+            + "target=\"packageListFrame\">All Profiles</a></span>"
+        },
+        {PROFILE_BUG_ID + FS + "compact2-frame.html",
+            "<li><a href=\"pkg4/compact2-package-frame.html\" "
+            + "target=\"packageFrame\">pkg4</a></li>"
+        },
+        // Test for profileName-package-frame.html listing all types in a
+        // package of a profile.
+        {PROFILE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html",
+            "<a href=\"../compact2-summary.html\" target=\"classFrame\">"
+            + "compact2</a> - <a href=\"../pkg2/compact2-package-summary.html\" "
+            + "target=\"classFrame\">pkg2</a>"
+        },
+        // Tests for profileName-summary.html listing the summary for a profile.
+        {PROFILE_BUG_ID + FS + "compact2-summary.html",
+            "<li><a href=\"compact1-summary.html\">Prev Profile</a></li>" + NL
+            + "<li><a href=\"compact3-summary.html\">Next Profile</a></li>"
+        },
+        {PROFILE_BUG_ID + FS + "compact2-summary.html",
+            "<h1 title=\"Profile\" class=\"title\">Profile compact2</h1>"
+        },
+        {PROFILE_BUG_ID + FS + "compact2-summary.html",
+            "<h3><a href=\"pkg2/compact2-package-summary.html\" "
+            + "target=\"classFrame\">pkg2</a></h3>"
+        },
+        // Tests for profileName-package-summary.html listing the summary for a
+        // package in a profile.
+        {PROFILE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html",
+            "<li><a href=\"../pkg4/compact3-package-summary.html\">Prev Package"
+            + "</a></li>"
+        },
+        {PROFILE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html",
+            "<div class=\"subTitle\">compact3</div>"
+        },
+        //Test for "overview-frame.html" showing the "All Profiles" link.
+        {PROFILE_BUG_ID + FS + "overview-frame.html",
+            "<span><a href=\"profile-overview-frame.html\" "
+            + "target=\"packageListFrame\">All Profiles</a></span>"
+        },
+        //Test for "className.html" showing the profile information for the type.
+        {PROFILE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html",
+            "<div class=\"subTitle\">compact1, compact2, compact3</div>"
+        },
+        {PROFILE_BUG_ID + FS + "index.html",
+            "<frame src=\"overview-frame.html\" name=\"packageListFrame\" " +
+            "title=\"All Packages\">"
+        }
+    };
+    private static final String[][] PROFILES_NEGATED_TEST = {
+        {PROFILE_BUG_ID + FS + "pkg3" + FS + "Class2Pkg3.html",
+            "<div class=\"subTitle\">compact1"
+        },
+        {PROFILE_BUG_ID + FS + "pkg3" + FS + "Interface1Pkg3.html",
+            "<div class=\"subTitle\">compact1"
+        },
+        {PROFILE_BUG_ID + FS + "pkg4" + FS + "compact2-package-frame.html",
+            "<li><a href=\"Anno1Pkg4.html\" title=\"annotation in pkg4\" "
+            + "target=\"classFrame\">Anno1Pkg4</a></li>"
+        }
+    };
+    private static final String[][] PACKAGES_TEST = {
+        {PACKAGE_BUG_ID + FS + "overview-frame.html",
+            "<h2 title=\"Packages\">Packages</h2>"
+        },
+        {PACKAGE_BUG_ID + FS + "pkg4" + FS + "package-frame.html",
+            "<h1 class=\"bar\"><a href=\"../pkg4/package-summary.html\" "
+            + "target=\"classFrame\">pkg4</a></h1>"
+        },
+        {PACKAGE_BUG_ID + FS + "pkg4" + FS + "package-summary.html",
+            "<div class=\"header\">" + NL + "<h1 title=\"Package\" "
+            + "class=\"title\">Package pkg4</h1>" + NL + "</div>"
+        }
+    };
+    private static final String[][] PACKAGES_NEGATED_TEST = {
+        {PACKAGE_BUG_ID + FS + "profile-overview-frame.html",
+            "<span><a href=\"overview-frame.html\" "
+            + "target=\"packageListFrame\">All Packages</a></span>"
+        },
+        {PACKAGE_BUG_ID + FS + "compact2-frame.html",
+            "<span><a href=\"overview-frame.html\" target=\"packageListFrame\">"
+            + "All Packages</a></span><span><a href=\"profile-overview-frame.html\" "
+            + "target=\"packageListFrame\">All Profiles</a></span>"
+        },
+        {PACKAGE_BUG_ID + FS + "pkg2" + FS + "compact2-package-frame.html",
+            "<a href=\"../compact2-summary.html\" target=\"classFrame\">"
+            + "compact2</a> - <a href=\"../pkg2/compact2-package-summary.html\" "
+            + "target=\"classFrame\">pkg2</a>"
+        },
+        {PACKAGE_BUG_ID + FS + "compact2-summary.html",
+            "<h1 title=\"Profile\" class=\"title\">Profile compact2</h1>"
+        },
+        {PACKAGE_BUG_ID + FS + "pkg5" + FS + "compact3-package-summary.html",
+            "<div class=\"subTitle\">compact3</div>"
+        },
+        {PACKAGE_BUG_ID + FS + "overview-frame.html",
+            "<span><a href=\"profile-overview-frame.html\" "
+            + "target=\"packageListFrame\">All Profiles</a></span>"
+        },
+        {PACKAGE_BUG_ID + FS + "pkg2" + FS + "Class1Pkg2.html",
+            "<div class=\"subTitle\">compact1, compact2, compact3</div>"
+        }
+    };
+
+    /**
+     * The entry point of the test.
+     *
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestProfiles tester = new TestProfiles();
+        run(tester, ARGS1, PROFILES_TEST, PROFILES_NEGATED_TEST);
+        run(tester, ARGS2, PACKAGES_TEST, PACKAGES_NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg1/Class1Pkg1.java b/test/com/sun/javadoc/testProfiles/pkg1/Class1Pkg1.java
new file mode 100644
index 0000000..dc5c50d
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg1/Class1Pkg1.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg1;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class1Pkg1 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg1/Class2Pkg1.java b/test/com/sun/javadoc/testProfiles/pkg1/Class2Pkg1.java
new file mode 100644
index 0000000..33ecb01
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg1/Class2Pkg1.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg1;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class2Pkg1 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg1/Class3Pkg1.java b/test/com/sun/javadoc/testProfiles/pkg1/Class3Pkg1.java
new file mode 100644
index 0000000..162cbfb
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg1/Class3Pkg1.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg1;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class3Pkg1 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg1/Interface1Pkg1.java b/test/com/sun/javadoc/testProfiles/pkg1/Interface1Pkg1.java
new file mode 100644
index 0000000..e2a4337
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg1/Interface1Pkg1.java
@@ -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.
+ */
+
+package pkg1;
+
+/**
+ * A sample interface.
+ *
+ * @author Bhavesh Patel
+ */
+public interface Interface1Pkg1 {
+
+    /**
+     * A test method.
+     *
+     * @param a blah.
+     * @param b blah.
+     */
+    void method1(int a, int b);
+
+    /**
+     * Another test method.
+     *
+     * @param c blah.
+     */
+    void method2(int c);
+
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg2/Anno1Pkg2.java b/test/com/sun/javadoc/testProfiles/pkg2/Anno1Pkg2.java
new file mode 100644
index 0000000..9ef89fc
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg2/Anno1Pkg2.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package pkg2;
+
+import java.lang.annotation.*;
+
+/**
+ * Test Annotation class.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface Anno1Pkg2 {
+    /**
+     * Comment.
+     */
+    String[] value();
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg2/Anno2Pkg2.java b/test/com/sun/javadoc/testProfiles/pkg2/Anno2Pkg2.java
new file mode 100644
index 0000000..204fbc4
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg2/Anno2Pkg2.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package pkg2;
+
+import java.lang.annotation.*;
+
+/*
+ * A sample interface.
+ */
+public @interface Anno2Pkg2 {
+    boolean value() default true;
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg2/Class1Pkg2.java b/test/com/sun/javadoc/testProfiles/pkg2/Class1Pkg2.java
new file mode 100644
index 0000000..afa13d8
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg2/Class1Pkg2.java
@@ -0,0 +1,51 @@
+/*
+ * 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 pkg2;
+
+/**
+ * Another test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class1Pkg2 {
+
+    /**
+     * A sample enum.
+     */
+    public static enum ModalExclusionType {
+        /**
+         * Test comment.
+         */
+        NO_EXCLUDE,
+        /**
+         * Another comment.
+         */
+        APPLICATION_EXCLUDE
+    };
+
+    /**
+     * A string constant.
+     */
+    public static final String CONSTANT1 = "C2";
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg3/Class1Pkg3.java b/test/com/sun/javadoc/testProfiles/pkg3/Class1Pkg3.java
new file mode 100644
index 0000000..ec340af
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg3/Class1Pkg3.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg3;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class1Pkg3 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg3/Class2Pkg3.java b/test/com/sun/javadoc/testProfiles/pkg3/Class2Pkg3.java
new file mode 100644
index 0000000..45272d0
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg3/Class2Pkg3.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg3;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class2Pkg3 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg3/Interface1Pkg3.java b/test/com/sun/javadoc/testProfiles/pkg3/Interface1Pkg3.java
new file mode 100644
index 0000000..09db1af
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg3/Interface1Pkg3.java
@@ -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.
+ */
+
+package pkg3;
+
+/**
+ * A sample interface.
+ *
+ * @author Bhavesh Patel
+ */
+public interface Interface1Pkg3 {
+
+    /**
+     * A test method.
+     *
+     * @param a blah.
+     * @param b blah.
+     */
+    void method1(int a, int b);
+
+    /**
+     * Another test method.
+     *
+     * @param c blah.
+     */
+    void method2(int c);
+
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg4/Anno1Pkg4.java b/test/com/sun/javadoc/testProfiles/pkg4/Anno1Pkg4.java
new file mode 100644
index 0000000..f9816d3
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg4/Anno1Pkg4.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package pkg4;
+
+import java.lang.annotation.*;
+
+/**
+ * Test Annotation class.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface Anno1Pkg4 {
+    /**
+     * Comment.
+     */
+    String[] value();
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg4/Class1Pkg4.java b/test/com/sun/javadoc/testProfiles/pkg4/Class1Pkg4.java
new file mode 100644
index 0000000..7c9966b
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg4/Class1Pkg4.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg4;
+
+/**
+ * Another test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class1Pkg4 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg5/Class1Pkg5.java b/test/com/sun/javadoc/testProfiles/pkg5/Class1Pkg5.java
new file mode 100644
index 0000000..606d838
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg5/Class1Pkg5.java
@@ -0,0 +1,32 @@
+/*
+ * 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 pkg5;
+
+/**
+ * A test class.
+ *
+ * @author Bhavesh Patel
+ */
+public class Class1Pkg5 {
+}
diff --git a/test/com/sun/javadoc/testProfiles/pkg5/Interface1Pkg5.java b/test/com/sun/javadoc/testProfiles/pkg5/Interface1Pkg5.java
new file mode 100644
index 0000000..4660a30
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/pkg5/Interface1Pkg5.java
@@ -0,0 +1,40 @@
+/*
+ * 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 pkg5;
+
+/**
+ * A sample interface.
+ *
+ * @author Bhavesh Patel
+ */
+public interface Interface1Pkg5 {
+
+    /**
+     * A test method.
+     *
+     * @param a blah.
+     * @param b blah.
+     */
+    void method1(int a, int b);
+}
diff --git a/test/com/sun/javadoc/testProfiles/profile-rtjar-includes.txt b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes.txt
new file mode 100644
index 0000000..9460b3f
--- /dev/null
+++ b/test/com/sun/javadoc/testProfiles/profile-rtjar-includes.txt
@@ -0,0 +1,42 @@
+PROFILE_1_RTJAR_INCLUDE_PACKAGES := \
+    pkg2 
+
+PROFILE_1_RTJAR_INCLUDE_TYPES := \
+    pkg3/Class1Pkg3.class
+
+PROFILE_1_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_1_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_2_RTJAR_INCLUDE_PACKAGES := \
+    pkg4 
+
+PROFILE_2_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_2_RTJAR_EXCLUDE_TYPES := \
+    pkg4/Anno1Pkg4.class 
+
+PROFILE_2_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
+    pkg5 
+
+PROFILE_3_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_3_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_3_INCLUDE_METAINF_SERVICES := 
+
+
+PROFILE_4_RTJAR_INCLUDE_PACKAGES := \
+    pkg1 
+
+PROFILE_4_RTJAR_INCLUDE_TYPES := 
+
+PROFILE_4_RTJAR_EXCLUDE_TYPES := 
+
+PROFILE_4_INCLUDE_METAINF_SERVICES :=  
+
+
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java b/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java
new file mode 100644
index 0000000..709b2ef
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/TestRepeatedAnnotations.java
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ *
+ * 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      8005092
+ * @summary  Test repeated annotations output.
+ * @author   bpatel
+ * @library  ../lib/
+ * @build    JavadocTester TestRepeatedAnnotations
+ * @run main TestRepeatedAnnotations
+ */
+
+public class TestRepeatedAnnotations extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8005092";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "pkg1"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/ContaineeRegDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeRegDoc</a> " +
+            "<a href=\"../pkg/ContaineeRegDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeRegDoc</a>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/RegContainerDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContainerDoc</a>" +
+            "(<a href=\"../pkg/RegContainerDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
+            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/ContainerSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContainerSynthDoc</a>(" +
+            "<a href=\"../pkg/ContainerSynthDoc.html#value()\">value</a>=" +
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>)"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a> " +
+            "<a href=\"../pkg/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg\">@ContaineeSynthDoc</a>"},
+
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<a href=\"../pkg/RegDoc.html\" title=\"annotation in pkg\">@RegDoc</a>" +
+            "(<a href=\"../pkg/RegDoc.html#x()\">x</a>=1)"},
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
+            "(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>=1)"},
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>" +
+            "(<a href=\"../pkg/RegArryDoc.html#y()\">y</a>={1,2})"},
+        {BUG_ID + FS + "pkg" + FS + "D.html",
+            "<a href=\"../pkg/NonSynthDocContainer.html\" " +
+            "title=\"annotation in pkg\">@NonSynthDocContainer</a>" +
+            "(<a href=\"../pkg/NonSynthDocContainer.html#value()\">value</a>=" +
+            "<a href=\"../pkg/RegArryDoc.html\" title=\"annotation in pkg\">@RegArryDoc</a>)"},
+
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/RegContainerValDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContainerValDoc</a>" +
+            "(<a href=\"../pkg1/RegContainerValDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContaineeNotDoc</a>," +
+            "<a href=\"../pkg1/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContaineeNotDoc</a>}," +
+            "<a href=\"../pkg1/RegContainerValDoc.html#y()\">y</a>=3)"},
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/ContainerValDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContainerValDoc</a>" +
+            "(<a href=\"../pkg1/ContainerValDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
+            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
+            "<a href=\"../pkg1/ContainerValDoc.html#x()\">x</a>=1)"}
+    };
+
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/RegContaineeDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeDoc</a> " +
+            "<a href=\"../pkg/RegContaineeDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeDoc</a>"},
+        {BUG_ID + FS + "pkg" + FS + "C.html",
+            "<a href=\"../pkg/RegContainerNotDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContainerNotDoc</a>" +
+            "(<a href=\"../pkg/RegContainerNotDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>," +
+            "<a href=\"../pkg/RegContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg\">@RegContaineeNotDoc</a>})"},
+
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a> " +
+            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a>"},
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/RegContainerValNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContainerValNotDoc</a>" +
+            "(<a href=\"../pkg1/RegContainerValNotDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg1/RegContaineeDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContaineeDoc</a>," +
+            "<a href=\"../pkg1/RegContaineeDoc.html\" " +
+            "title=\"annotation in pkg1\">@RegContaineeDoc</a>}," +
+            "<a href=\"../pkg1/RegContainerValNotDoc.html#y()\">y</a>=4)"},
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/ContainerValNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContainerValNotDoc</a>" +
+            "(<a href=\"../pkg1/ContainerValNotDoc.html#value()\">value</a>={" +
+            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>," +
+            "<a href=\"../pkg1/ContaineeNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeNotDoc</a>}," +
+            "<a href=\"../pkg1/ContainerValNotDoc.html#x()\">x</a>=2)"},
+        {BUG_ID + FS + "pkg1" + FS + "C.html",
+            "<a href=\"../pkg1/ContainerSynthNotDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContainerSynthNotDoc</a>(" +
+            "<a href=\"../pkg1/ContainerSynthNotDoc.html#value()\">value</a>=" +
+            "<a href=\"../pkg1/ContaineeSynthDoc.html\" " +
+            "title=\"annotation in pkg1\">@ContaineeSynthDoc</a>)"}
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestRepeatedAnnotations tester = new TestRepeatedAnnotations();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/C.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/C.java
new file mode 100644
index 0000000..aa88549
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/C.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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;
+
+ at ContainerSynthDoc(value={@ContaineeSynthDoc, at ContaineeSynthDoc})
+ at ContainerRegDoc(value={@ContaineeRegDoc, at ContaineeRegDoc})
+ at RegContainerDoc(value={@RegContaineeNotDoc, at RegContaineeNotDoc})
+ at ContainerRegNotDoc(value={@RegContaineeDoc, at RegContaineeDoc})
+ at RegContainerNotDoc(value={@RegContaineeNotDoc, at RegContaineeNotDoc})
+ at ContaineeSynthDoc @ContaineeSynthDoc @ContaineeSynthDoc
+public class C {
+
+    @ContainerSynthDoc(value={@ContaineeSynthDoc})
+    public void test1() {}
+
+    @ContaineeSynthDoc @ContaineeSynthDoc
+    public void test2() {}
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeRegDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeRegDoc.java
new file mode 100644
index 0000000..9f3a6b9
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeRegDoc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation contained by ContainerRegDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface ContaineeRegDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java
new file mode 100644
index 0000000..a0208e2
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContaineeSynthDoc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package pkg;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented synthesized annotation contained by ContainerSynthDoc.
+ * It will be used to annotate Class C and a method in the class using a synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+ at Repeatable(ContainerSynthDoc.class)
+public @interface ContaineeSynthDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegDoc.java
new file mode 100644
index 0000000..fc52ac9
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegDoc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation container for ContaineeRegDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface ContainerRegDoc {
+
+    ContaineeRegDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegNotDoc.java
new file mode 100644
index 0000000..949349e
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerRegNotDoc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation container for RegContaineeDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface ContainerRegNotDoc {
+
+    RegContaineeDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java
new file mode 100644
index 0000000..bdf86ee
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/ContainerSynthDoc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+package pkg;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented synthesized annotation container for ContaineeSynthDoc.
+ * It will be used to annotate Class C and a method in the class using a synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface ContainerSynthDoc {
+
+    ContaineeSynthDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/D.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/D.java
new file mode 100644
index 0000000..6ce1590
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/D.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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;
+
+ at RegDoc(x=1)
+public class D {
+
+    @RegArryDoc(y={1})
+    public void test1() {}
+
+    @RegArryDoc(y={1,2})
+    public void test2() {}
+
+    @NonSynthDocContainer(value={@RegArryDoc})
+    public void test3() {}
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/NonSynthDocContainer.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/NonSynthDocContainer.java
new file mode 100644
index 0000000..838063b
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/NonSynthDocContainer.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation.
+ * It will be used to annotate methods in class D.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface NonSynthDocContainer {
+
+    RegArryDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegArryDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegArryDoc.java
new file mode 100644
index 0000000..ec96fc0
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegArryDoc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation.
+ * It will be used to annotate methods in Class D.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegArryDoc {
+
+    int[] y();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeDoc.java
new file mode 100644
index 0000000..06ec88f
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeDoc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation contained by ContainerRegNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegContaineeDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeNotDoc.java
new file mode 100644
index 0000000..0d96d1c
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContaineeNotDoc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation contained by RegContainerNotDoc
+ * and RegContainerDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface RegContaineeNotDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerDoc.java
new file mode 100644
index 0000000..30b952e
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerDoc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation container for RegContainerDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegContainerDoc {
+
+    RegContaineeNotDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerNotDoc.java
new file mode 100644
index 0000000..c26fec4
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegContainerNotDoc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation container for RegContaineeNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface RegContainerNotDoc {
+
+    RegContaineeNotDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegDoc.java
new file mode 100644
index 0000000..289c353
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg/RegDoc.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation.
+ * It will be used to annotate Class D.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegDoc {
+
+    int x();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/C.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/C.java
new file mode 100644
index 0000000..de10e08
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/C.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+ at ContainerSynthNotDoc(value={@ContaineeSynthDoc, at ContaineeSynthDoc})
+ at RegContainerValDoc(value={@RegContaineeNotDoc, at RegContaineeNotDoc},y=3)
+ at ContainerValDoc(value={@ContaineeNotDoc, at ContaineeNotDoc},x=1)
+ at RegContainerValNotDoc(value={@RegContaineeDoc, at RegContaineeDoc},y=4)
+ at ContainerValNotDoc(value={@ContaineeNotDoc, at ContaineeNotDoc},x=2)
+public class C {
+
+    @ContainerSynthNotDoc(value={@ContaineeSynthDoc})
+    public void test1() {}
+
+    @ContaineeSynthDoc @ContaineeSynthDoc
+    public void test2() {}
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeNotDoc.java
new file mode 100644
index 0000000..73b1b06
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeNotDoc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation contained by ContainerValNotDoc
+ * and ContainerValDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface ContaineeNotDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java
new file mode 100644
index 0000000..a321109
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContaineeSynthDoc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented synthesized annotation contained by ContainerSynthNotDoc.
+ * It will be used to annotate Class C and methods in the class using a synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+ at Repeatable(ContainerSynthNotDoc.class)
+public @interface ContaineeSynthDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java
new file mode 100644
index 0000000..247dd1e
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerSynthNotDoc.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+package pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented synthesized annotation container for ContaineeSynthDoc.
+ * It will be used to annotate Class C and methods in the class using a synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface ContainerSynthNotDoc {
+
+    ContaineeSynthDoc[] value();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValDoc.java
new file mode 100644
index 0000000..0f39182
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValDoc.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation container for ContaineeNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface ContainerValDoc {
+
+    ContaineeNotDoc[] value();
+
+    int x();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValNotDoc.java
new file mode 100644
index 0000000..8e0b2b0
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/ContainerValNotDoc.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation container for ContaineeNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface ContainerValNotDoc {
+
+    ContaineeNotDoc[] value();
+
+    int x();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeDoc.java
new file mode 100644
index 0000000..41d8db3
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeDoc.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation contained by RegContainerValNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegContaineeDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeNotDoc.java
new file mode 100644
index 0000000..ecda767
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContaineeNotDoc.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation contained by RegContainerValDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface RegContaineeNotDoc {
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValDoc.java
new file mode 100644
index 0000000..c9f2120
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValDoc.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a documented annotation container for RegContaineeNotDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+ at Documented
+public @interface RegContainerValDoc {
+
+    RegContaineeNotDoc[] value();
+
+    int y();
+}
diff --git a/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValNotDoc.java b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValNotDoc.java
new file mode 100644
index 0000000..ce67af7
--- /dev/null
+++ b/test/com/sun/javadoc/testRepeatedAnnotations/pkg1/RegContainerValNotDoc.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 pkg1;
+
+import java.lang.annotation.*;
+
+/**
+ * This annotation is a non-documented annotation container for RegContaineeDoc.
+ * It will be used to annotate Class C using a non-synthesized form.
+ *
+ * @author Bhavesh Patel
+ */
+public @interface RegContainerValNotDoc {
+
+    RegContaineeDoc[] value();
+
+    int y();
+}
diff --git a/test/com/sun/javadoc/testReturnTag/TestReturnTag.java b/test/com/sun/javadoc/testReturnTag/TestReturnTag.java
index eab8f02..b731974 100644
--- a/test/com/sun/javadoc/testReturnTag/TestReturnTag.java
+++ b/test/com/sun/javadoc/testReturnTag/TestReturnTag.java
@@ -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
@@ -39,7 +39,7 @@ public class TestReturnTag extends JavadocTester {
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, "-sourcepath", SRC_DIR, SRC_DIR + FS + "TestReturnTag.java"
+        "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, SRC_DIR + FS + "TestReturnTag.java"
     };
 
     //Input for string search tests.
diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
index 4a2a1cc..fd026b9 100644
--- a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+++ b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
@@ -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 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester {
     // 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>" +
                  " <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 + " " + 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>" +
                  " <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>" +
                  " </div>" + NL + "<div class=\"block\">" +
                  "The name for this class.</div>"}};
diff --git a/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java b/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java
new file mode 100644
index 0000000..4b5ac23
--- /dev/null
+++ b/test/com/sun/javadoc/testSimpleTagInherit/TestSimpleTagInherit.java
@@ -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();
+    }
+}
diff --git a/test/com/sun/javadoc/testSimpleTagInherit/p/BaseClass.java b/test/com/sun/javadoc/testSimpleTagInherit/p/BaseClass.java
new file mode 100644
index 0000000..c7a6e17
--- /dev/null
+++ b/test/com/sun/javadoc/testSimpleTagInherit/p/BaseClass.java
@@ -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() { }
+}
diff --git a/test/com/sun/javadoc/testSimpleTagInherit/p/TestClass.java b/test/com/sun/javadoc/testSimpleTagInherit/p/TestClass.java
new file mode 100644
index 0000000..80c1001
--- /dev/null
+++ b/test/com/sun/javadoc/testSimpleTagInherit/p/TestClass.java
@@ -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() { }
+}
diff --git a/test/com/sun/javadoc/testSinceTag/TestSinceTag.java b/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
index c340431..531047c 100644
--- a/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
+++ b/test/com/sun/javadoc/testSinceTag/TestSinceTag.java
@@ -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 @@ public class TestSinceTag extends JavadocTester {
     //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>"
         }
     };
 
diff --git a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
index 404fc1f..c4044a5 100644
--- a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
+++ b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug      4494033 7028815 7052425
+ * @bug      4494033 7028815 7052425 8007338
  * @summary  Run tests on doclet stylesheet.
  * @author   jamieh
  * @library  ../lib/
@@ -34,7 +34,7 @@
 public class TestStylesheet extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4494033-7028815-7052425";
+    private static final String BUG_ID = "4494033-7028815-7052425-8007338";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
@@ -44,29 +44,45 @@ public class TestStylesheet extends JavadocTester {
     //Input for string search tests.
     private static final String[][] TEST = {
         {BUG_ID + FS + "stylesheet.css",
-                "/* Javadoc style sheet */"},
+            "/* Javadoc style sheet */"},
         {BUG_ID + FS + "stylesheet.css",
-                "/*" + NL + "Overall document style" + NL + "*/"},
+            "/*" + NL + "Overall document style" + NL + "*/"},
         {BUG_ID + FS + "stylesheet.css",
-                "/*" + NL + "Heading styles" + NL + "*/"},
+            "/*" + NL + "Heading styles" + NL + "*/"},
         {BUG_ID + FS + "stylesheet.css",
-                "/*" + NL + "Navigation bar styles" + NL + "*/"},
+            "/*" + NL + "Navigation bar styles" + NL + "*/"},
         {BUG_ID + FS + "stylesheet.css",
-                "body {" + NL + "    background-color:#ffffff;" + NL +
-                "    color:#353833;" + NL +
-                "    font-family:Arial, Helvetica, sans-serif;" + NL +
-                "    font-size:76%;" + NL + "    margin:0;" + NL + "}"},
+            "body {" + NL + "    background-color:#ffffff;" + NL +
+            "    color:#353833;" + NL +
+            "    font-family:Arial, Helvetica, sans-serif;" + NL +
+            "    font-size:76%;" + NL + "    margin:0;" + NL + "}"},
         {BUG_ID + FS + "stylesheet.css",
-                "ul {" + NL + "    list-style-type:disc;" + NL + "}"},
+            "ul {" + NL + "    list-style-type:disc;" + NL + "}"},
+        {BUG_ID + FS + "stylesheet.css",
+            ".overviewSummary caption, .packageSummary caption, " +
+            ".contentContainer ul.blockList li.blockList caption, " +
+            ".summary caption, .classUseContainer caption, " +
+            ".constantValuesContainer caption {" + NL +
+            "    position:relative;" + NL +
+            "    text-align:left;" + NL +
+            "    background-repeat:no-repeat;" + NL +
+            "    color:#FFFFFF;" + NL +
+            "    font-weight:bold;" + NL +
+            "    clear:none;" + NL +
+            "    overflow:hidden;" + NL +
+            "    padding:0px;" + NL +
+            "    margin:0px;" + NL +
+            "    white-space:pre;" + NL +
+            "}"},
         // Test whether a link to the stylesheet file is inserted properly
         // in the class documentation.
         {BUG_ID + FS + "pkg" + FS + "A.html",
-                "<link rel=\"stylesheet\" type=\"text/css\" " +
-                "href=\"../stylesheet.css\" title=\"Style\">"}
+            "<link rel=\"stylesheet\" type=\"text/css\" " +
+            "href=\"../stylesheet.css\" title=\"Style\">"}
     };
     private static final String[][] NEGATED_TEST = {
         {BUG_ID + FS + "stylesheet.css",
-                "* {" + NL + "    margin:0;" + NL + "    padding:0;" + NL + "}"}
+            "* {" + NL + "    margin:0;" + NL + "    padding:0;" + NL + "}"}
     };
 
     /**
diff --git a/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java b/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
index ca6f4c0..194d10e 100644
--- a/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
+++ b/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
@@ -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
@@ -36,7 +36,7 @@ public class TestTagInheritence extends JavadocTester {
 
     private static final String BUG_ID = "4496223-4496270-4618686-4720974-4812240-6253614-6253604";
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "firstSentence", "firstSentence2"
+        "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg", "firstSentence", "firstSentence2"
     };
 
     /**
diff --git a/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java b/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
index b80c4ca..77cc778 100644
--- a/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
+++ b/test/com/sun/javadoc/testTagMisuse/TestTagMisuse.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2002, 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
@@ -21,9 +21,8 @@
  * questions.
  */
 
-/**
+/*
  * @test
- * @bug 0000000
  * @summary Determine if proper warning messages are printed when know.
  * @author jamieh
  * @library ../lib/
@@ -42,7 +41,7 @@ public class TestTagMisuse extends JavadocTester {
     };
     private static final String[][] NEGATED_TEST = NO_TEST;
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, SRC_DIR + FS + "TestTagMisuse.java"
+        "-Xdoclint:none", "-d", BUG_ID, SRC_DIR + FS + "TestTagMisuse.java"
     };
 
     /**
diff --git a/test/com/sun/javadoc/testTaglets/taglets/Foo.java b/test/com/sun/javadoc/testTaglets/taglets/Foo.java
index e28c452..b0b7e47 100644
--- a/test/com/sun/javadoc/testTaglets/taglets/Foo.java
+++ b/test/com/sun/javadoc/testTaglets/taglets/Foo.java
@@ -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 @@ public class Foo extends BaseTaglet {
     /**
      * {@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()));
diff --git a/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
new file mode 100644
index 0000000..61d5758
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java
@@ -0,0 +1,401 @@
+/*
+ * 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      8005091 8009686
+ * @summary  Make sure that type annotations are displayed correctly
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestTypeAnnotations
+ * @run main TestTypeAnnotations
+ */
+
+public class TestTypeAnnotations extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8005091-8009686";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-private", "typeannos"
+    };
+
+    //Input for string search tests.
+    private static final String[][] NEGATED_TEST = NO_TEST;
+    private static final String[][] TEST = {
+        // Test for type annotations on Class Extends (ClassExtends.java).
+        {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
+            "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
+            "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/ParameterizedClass.html\" " +
+            "title=\"class in typeannos\">ParameterizedClass</a><<a href=\"" +
+            "../typeannos/ClassExtB.html\" title=\"annotation in typeannos\">" +
+            "@ClassExtB</a> java.lang.String>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MyClass.html",
+            "implements <a href=\"../typeannos/ClassExtB.html\" title=\"" +
+            "annotation in typeannos\">@ClassExtB</a> java.lang.CharSequence, " +
+            "<a href=\"../typeannos/ClassExtA.html\" title=\"annotation in " +
+            "typeannos\">@ClassExtA</a> <a href=\"../typeannos/ParameterizedInterface.html\" " +
+            "title=\"interface in typeannos\">ParameterizedInterface</a><" +
+            "<a href=\"../typeannos/ClassExtB.html\" title=\"annotation in " +
+            "typeannos\">@ClassExtB</a> java.lang.String></pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MyInterface.html",
+            "extends <a href=\"../typeannos/ClassExtA.html\" title=\"annotation " +
+            "in typeannos\">@ClassExtA</a> <a href=\"../typeannos/" +
+            "ParameterizedInterface.html\" title=\"interface in typeannos\">" +
+            "ParameterizedInterface</a><<a href=\"../typeannos/ClassExtA.html\" " +
+            "title=\"annotation in typeannos\">@ClassExtA</a> java.lang.String>, " +
+            "<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",
+            "class <span class=\"strong\">ExtendsBound<K extends <a " +
+            "href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
+            "typeannos\">@ClassParamA</a> java.lang.String></span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ExtendsGeneric.html",
+            "<pre>class <span class=\"strong\">ExtendsGeneric<K extends " +
+            "<a href=\"../typeannos/ClassParamA.html\" title=\"annotation in " +
+            "typeannos\">@ClassParamA</a> <a href=\"../typeannos/Unannotated.html\" " +
+            "title=\"class in typeannos\">Unannotated</a><<a href=\"" +
+            "../typeannos/ClassParamB.html\" title=\"annotation in typeannos\">" +
+            "@ClassParamB</a> java.lang.String>></span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "TwoBounds.html",
+            "<pre>class <span class=\"strong\">TwoBounds<K extends <a href=\"" +
+            "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
+            "@ClassParamA</a> java.lang.String,V extends <a href=\"../typeannos/" +
+            "ClassParamB.html\" title=\"annotation in typeannos\">@ClassParamB" +
+            "</a> java.lang.String></span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Complex1.html",
+            "class <span class=\"strong\">Complex1<K extends <a href=\"../" +
+            "typeannos/ClassParamA.html\" title=\"annotation in typeannos\">" +
+            "@ClassParamA</a> java.lang.String & java.lang.Runnable></span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Complex2.html",
+            "class <span class=\"strong\">Complex2<K extends java.lang." +
+            "String & <a href=\"../typeannos/ClassParamB.html\" title=\"" +
+            "annotation in typeannos\">@ClassParamB</a> java.lang.Runnable></span>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ComplexBoth.html",
+            "class <span class=\"strong\">ComplexBoth<K extends <a href=\"" +
+            "../typeannos/ClassParamA.html\" title=\"annotation in typeannos\"" +
+            ">@ClassParamA</a> java.lang.String & <a href=\"../typeannos/" +
+            "ClassParamA.html\" title=\"annotation in typeannos\">@ClassParamA" +
+            "</a> java.lang.Runnable></span>"
+        },
+
+        // Test for type annotations on fields (Fields.java).
+        {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
+            "<pre><a href=\"../typeannos/Parameterized.html\" title=\"class in " +
+            "typeannos\">Parameterized</a><<a href=\"../typeannos/FldA.html\" " +
+            "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " +
+            "href=\"../typeannos/FldB.html\" title=\"annotation in typeannos\">" +
+            "@FldB</a> java.lang.String> 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/" +
+            "FldB.html\" title=\"annotation in typeannos\">@FldB</a> [] " +
+            "array1Deep</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
+            "<pre>java.lang.String[] <a href=\"../typeannos/FldB.html\" " +
+            "title=\"annotation in typeannos\">@FldB</a> [] array2SecondOld</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultScope.html",
+            "<pre><a href=\"../typeannos/FldD.html\" title=\"annotation in " +
+            "typeannos\">@FldD</a> java.lang.String <a href=\"../typeannos/" +
+            "FldC.html\" title=\"annotation in typeannos\">@FldC</a> <a href=\"" +
+            "../typeannos/FldA.html\" title=\"annotation in typeannos\">@FldA" +
+            "</a> [] <a href=\"../typeannos/FldC.html\" title=\"annotation in " +
+            "typeannos\">@FldC</a> <a href=\"../typeannos/FldB.html\" title=\"" +
+            "annotation in typeannos\">@FldB</a> [] array2Deep</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
+            "<pre>public final <a href=\"../typeannos/Parameterized.html\" " +
+            "title=\"class in typeannos\">Parameterized</a><<a href=\"../" +
+            "typeannos/FldA.html\" title=\"annotation in typeannos\">@FldA</a> " +
+            "<a href=\"../typeannos/Parameterized.html\" title=\"class in " +
+            "typeannos\">Parameterized</a><<a href=\"../typeannos/FldA.html\" " +
+            "title=\"annotation in typeannos\">@FldA</a> java.lang.String,<a " +
+            "href=\"../typeannos/FldB.html\" title=\"annotation in typeannos\">" +
+            "@FldB</a> java.lang.String>,<a href=\"../typeannos/FldB.html\" " +
+            "title=\"annotation in typeannos\">@FldB</a> java.lang.String> " +
+            "nestedParameterized</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ModifiedScoped.html",
+            "<pre>public final <a href=\"../typeannos/FldA.html\" " +
+            "title=\"annotation in typeannos\">@FldA</a> java.lang.String[][] " +
+            "array2</pre>"
+        },
+
+        // Test for type annotations on method return types (MethodReturnType.java).
+        {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
+            "<pre>public <T> <a href=\"../typeannos/MRtnA.html\" " +
+            "title=\"annotation in typeannos\">@MRtnA</a> java.lang.String" +
+            " method()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
+            "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in " +
+            "typeannos\">@MRtnA</a> java.lang.String <a href=\"../typeannos/" +
+            "MRtnA.html\" title=\"annotation in typeannos\">@MRtnA</a> [] <a " +
+            "href=\"../typeannos/MRtnB.html\" title=\"annotation in typeannos\">" +
+            "@MRtnB</a> [] array2Deep()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MtdDefaultScope.html",
+            "<pre><a href=\"../typeannos/MRtnA.html\" title=\"annotation in " +
+            "typeannos\">@MRtnA</a> java.lang.String[][] array2()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "MtdModifiedScoped.html",
+            "<pre>public final <a href=\"../typeannos/MtdParameterized.html\" " +
+            "title=\"class in typeannos\">MtdParameterized</a><<a href=\"../" +
+            "typeannos/MRtnA.html\" title=\"annotation in typeannos\">@MRtnA</a> " +
+            "<a href=\"../typeannos/MtdParameterized.html\" title=\"class in " +
+            "typeannos\">MtdParameterized</a><<a href=\"../typeannos/MRtnA." +
+            "html\" title=\"annotation in typeannos\">@MRtnA</a> java.lang." +
+            "String,<a href=\"../typeannos/MRtnB.html\" title=\"annotation in " +
+            "typeannos\">@MRtnB</a> java.lang.String>,<a href=\"../typeannos/" +
+            "MRtnB.html\" title=\"annotation in typeannos\">@MRtnB</a> java." +
+            "lang.String> nestedMtdParameterized()</pre>"
+        },
+
+        // Test for type annotations on method type parameters (MethodTypeParameters.java).
+        {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
+            "<pre><K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
+            "annotation in typeannos\">@MTyParamA</a> java.lang.String>" +
+            " void methodExtends()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "UnscopedUnmodified.html",
+            "<pre><K extends <a href=\"../typeannos/MTyParamA.html\" title=\"" +
+            "annotation in typeannos\">@MTyParamA</a> <a href=\"../typeannos/" +
+            "MtdTyParameterized.html\" title=\"class in typeannos\">" +
+            "MtdTyParameterized</a><<a href=\"../typeannos/MTyParamB.html\" " +
+            "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
+            ">> void nestedExtends()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
+            "<pre>public final <K extends <a href=\"../typeannos/" +
+            "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
+            "java.lang.String> void methodExtends()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModifiedMethods.html",
+            "<pre>public final <K extends <a href=\"../typeannos/" +
+            "MTyParamA.html\" title=\"annotation in typeannos\">@MTyParamA</a> " +
+            "java.lang.String,V extends <a href=\"../typeannos/MTyParamA.html\" " +
+            "title=\"annotation in typeannos\">@MTyParamA</a> <a href=\"../" +
+            "typeannos/MtdTyParameterized.html\" title=\"class in typeannos\">" +
+            "MtdTyParameterized</a><<a href=\"../typeannos/MTyParamB.html\" " +
+            "title=\"annotation in typeannos\">@MTyParamB</a> java.lang.String" +
+            ">> void dual()</pre>"
+        },
+
+        // Test for type annotations on parameters (Parameters.java).
+        {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
+            "<pre>void unannotated(<a href=\"../typeannos/" +
+            "ParaParameterized.html\" title=\"class in typeannos\">" +
+            "ParaParameterized</a><java.lang.String,java.lang.String>" +
+            " a)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
+            "<pre>void nestedParaParameterized(<a href=\"../typeannos/" +
+            "ParaParameterized.html\" title=\"class in typeannos\">" +
+            "ParaParameterized</a><<a href=\"../typeannos/ParamA.html\" " +
+            "title=\"annotation in typeannos\">@ParamA</a> <a href=\"../" +
+            "typeannos/ParaParameterized.html\" title=\"class in typeannos\">" +
+            "ParaParameterized</a><<a href=\"../typeannos/ParamA.html\" " +
+            "title=\"annotation in typeannos\">@ParamA</a> java.lang.String," +
+            "<a href=\"../typeannos/ParamB.html\" title=\"annotation in " +
+            "typeannos\">@ParamB</a> java.lang.String>,<a href=\"../" +
+            "typeannos/ParamB.html\" title=\"annotation in typeannos\">@ParamB" +
+            "</a> java.lang.String> a)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Parameters.html",
+            "<pre>void array2Deep(<a href=\"../typeannos/ParamA.html\" " +
+            "title=\"annotation in typeannos\">@ParamA</a> java.lang.String " +
+            "<a href=\"../typeannos/ParamA.html\" title=\"annotation in " +
+            "typeannos\">@ParamA</a> [] <a href=\"../typeannos/ParamB.html\" " +
+            "title=\"annotation in typeannos\">@ParamB</a> [] a)</pre>"
+        },
+
+        // Test for type annotations on throws (Throws.java).
+        {BUG_ID + FS + "typeannos" + FS + "ThrDefaultUnmodified.html",
+            "<pre>void oneException()" + NL +
+            "           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 twoExceptions()" + NL +
+            "            throws <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
+            "                   <a href=\"../typeannos/ThrA.html\" title=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
+            "<pre>public final void oneException(java.lang.String a)" + NL +
+            "                        throws <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrPublicModified.html",
+            "<pre>public final void twoExceptions(java.lang.String a)" + NL +
+            "                         throws <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.RuntimeException," + NL +
+            "                                <a href=\"../typeannos/ThrA.html\" " +
+            "title=\"annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "ThrWithValue.html",
+            "<pre>void oneException()" + NL +
+            "           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 twoExceptions()" + NL +
+            "            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=\"" +
+            "annotation in typeannos\">@ThrA</a> java.lang.Exception</pre>"
+        },
+
+        // Test for type annotations on type parameters (TypeParameters.java).
+        {BUG_ID + FS + "typeannos" + FS + "TestMethods.html",
+            "<pre><K,V extends <a href=\"../typeannos/TyParaA.html\" title=\"" +
+            "annotation in typeannos\">@TyParaA</a> java.lang.String> " +
+            "void secondAnnotated()</pre>"
+        },
+
+        // Test for type annotations on wildcard type (Wildcards.java).
+        {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
+            "<pre>void wcExtends(<a href=\"../typeannos/MyList.html\" " +
+            "title=\"class in typeannos\">MyList</a><? extends <a href=\"" +
+            "../typeannos/WldA.html\" title=\"annotation in typeannos\">@WldA" +
+            "</a> java.lang.String> l)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundTest.html",
+            "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
+            "typeannos\">MyList</a><? super <a href=\"../typeannos/WldA.html\" " +
+            "title=\"annotation in typeannos\">@WldA</a> java.lang.String>" +
+            " returnWcSuper()</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
+            "<pre>void wcSuper(<a href=\"../typeannos/MyList.html\" title=\"" +
+            "class in typeannos\">MyList</a><? super <a href=\"../typeannos/" +
+            "WldB.html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"" +
+            "../typeannos/WldB.html#value()\">value</a>=\"m\") java.lang." +
+            "String> l)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "BoundWithValue.html",
+            "<pre><a href=\"../typeannos/MyList.html\" title=\"class in " +
+            "typeannos\">MyList</a><? extends <a href=\"../typeannos/WldB." +
+            "html\" title=\"annotation in typeannos\">@WldB</a>(<a href=\"../" +
+            "typeannos/WldB.html#value()\">value</a>=\"m\") java.lang.String" +
+            "> returnWcExtends()</pre>"
+        },
+
+        // Test for receiver annotations (Receivers.java).
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre>void withException(<a href=\"../typeannos/RcvrA.html\" " +
+            "title=\"annotation in typeannos\">@RcvrA</a> " +
+            "DefaultUnmodified this)" + NL + "            throws java." +
+            "lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre>java.lang.String nonVoid(<a href=\"../typeannos/RcvrA." +
+            "html\" title=\"annotation in typeannos\">@RcvrA</a> <a href=\"../" +
+            "typeannos/RcvrB.html\" title=\"annotation in typeannos\">@RcvrB" +
+            "</a>(<a href=\"../typeannos/RcvrB.html#value()\">value</a>=\"m\")" +
+            " DefaultUnmodified this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "DefaultUnmodified.html",
+            "<pre><T extends java.lang.Runnable> void accept(" +
+            "<a href=\"../typeannos/RcvrA.html\" title=\"annotation in " +
+            "typeannos\">@RcvrA</a> DefaultUnmodified this," + NL +
+            "                                           T r)" + NL +
+            "                                    throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
+            "<pre>public final java.lang.String nonVoid(<a href=\"" +
+            "../typeannos/RcvrA.html\" title=\"annotation in typeannos\">" +
+            "@RcvrA</a> PublicModified this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "PublicModified.html",
+            "<pre>public final <T extends java.lang.Runnable> " +
+            "void accept(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a> PublicModified this," + NL +
+            "                                                        T r)" + NL +
+            "                                                 throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithValue.html",
+            "<pre><T extends java.lang.Runnable> void accept(" +
+            "<a href=\"../typeannos/RcvrB.html\" title=\"annotation in " +
+            "typeannos\">@RcvrB</a>(<a href=\"../typeannos/RcvrB.html#value()\">" +
+            "value</a>=\"m\") WithValue this," + NL +
+            "                                           T r)" + NL +
+            "                                    throws java.lang.Exception</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithFinal.html",
+            "<pre>java.lang.String nonVoid(<a href=\"../typeannos/RcvrB." +
+            "html\" title=\"annotation in typeannos\">@RcvrB</a>(<a href=\"../" +
+            "typeannos/RcvrB.html#value()\">value</a>=\"m\") WithFinal" +
+            " this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "WithBody.html",
+            "<pre>void field(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a> WithBody this)</pre>"
+        },
+        {BUG_ID + FS + "typeannos" + FS + "Generic2.html",
+            "<pre>void test2(<a href=\"../typeannos/RcvrA.html\" title=\"" +
+            "annotation in typeannos\">@RcvrA</a> Generic2<X> this)</pre>"
+        }
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestTypeAnnotations tester = new TestTypeAnnotations();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassExtends.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassExtends.java
new file mode 100644
index 0000000..995c625
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassExtends.java
@@ -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.
+ */
+
+package typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+abstract class MyClass extends @ClassExtA ParameterizedClass<@ClassExtB String>
+  implements @ClassExtB CharSequence, @ClassExtA ParameterizedInterface<@ClassExtB String> { }
+
+interface MyInterface extends @ClassExtA ParameterizedInterface<@ClassExtA String>,
+                              @ClassExtB CharSequence { }
+
+class ParameterizedClass<K> {}
+interface ParameterizedInterface<K> {}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ClassExtA {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ClassExtB {}
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassParameters.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassParameters.java
new file mode 100644
index 0000000..d3b556a
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/ClassParameters.java
@@ -0,0 +1,60 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Unannotated<K> { }
+
+class ExtendsBound<K extends @ClassParamA String> { }
+class ExtendsGeneric<K extends @ClassParamA Unannotated<@ClassParamB String>> { }
+class TwoBounds<K extends @ClassParamA String, V extends @ClassParamB String> { }
+
+class Complex1<K extends @ClassParamA String&Runnable> { }
+class Complex2<K extends String & @ClassParamB Runnable> { }
+class ComplexBoth<K extends @ClassParamA String & @ClassParamA Runnable> { }
+
+class ClassParamOuter {
+    void inner() {
+        class LUnannotated<K> { }
+
+        class LExtendsBound<K extends @ClassParamA String> { }
+        class LExtendsGeneric<K extends @ClassParamA LUnannotated<@ClassParamB String>> { }
+        class LTwoBounds<K extends @ClassParamA String, V extends @ClassParamB String> { }
+
+        class LComplex1<K extends @ClassParamA String&Runnable> { }
+        class LComplex2<K extends String & @ClassParamB Runnable> { }
+        class LComplexBoth<K extends @ClassParamA String & @ClassParamA Runnable> { }
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ClassParamA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ClassParamB { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Fields.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Fields.java
new file mode 100644
index 0000000..359562c
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Fields.java
@@ -0,0 +1,82 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class DefaultScope {
+    Parameterized<String, String> unannotated;
+    Parameterized<@FldA String, String> firstTypeArg;
+    Parameterized<String, @FldA String> secondTypeArg;
+    Parameterized<@FldA String, @FldB String> bothTypeArgs;
+
+    Parameterized<@FldA Parameterized<@FldA String, @FldB String>, @FldB String>
+    nestedParameterized;
+
+    @FldA String [] array1;
+    @FldA String @FldB [] array1Deep;
+    @FldA String [] [] array2;
+    @FldD String @FldC @FldA [] @FldC @FldB [] array2Deep;
+    String @FldA [] [] array2First;
+    String [] @FldB [] array2Second;
+
+    // Old-style array syntax
+    String array2FirstOld @FldA [];
+    String array2SecondOld [] @FldB [];
+}
+
+class ModifiedScoped {
+    public final Parameterized<String, String> unannotated = null;
+    public final Parameterized<@FldA String, String> firstTypeArg = null;
+    public final Parameterized<String, @FldA String> secondTypeArg = null;
+    public final Parameterized<@FldA String, @FldB String> bothTypeArgs = null;
+
+    public final Parameterized<@FldA Parameterized<@FldA String, @FldB String>, @FldB String>
+    nestedParameterized = null;
+
+    public final @FldA String [] array1 = null;
+    public final @FldA String @FldB [] array1Deep = null;
+    public final @FldA String [] [] array2 = null;
+    public final @FldA String @FldA [] @FldB [] array2Deep = null;
+    public final String @FldA [] [] array2First = null;
+    public final String [] @FldB [] array2Second = null;
+}
+
+class Parameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface FldA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface FldB { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface FldC { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface FldD { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodReturnType.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodReturnType.java
new file mode 100644
index 0000000..fbfb978
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodReturnType.java
@@ -0,0 +1,78 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class MtdDefaultScope {
+    MtdParameterized<String, String> unannotated() { return null; }
+    MtdParameterized<@MRtnA String, String> firstTypeArg() { return null; }
+    MtdParameterized<String, @MRtnA String> secondTypeArg() { return null; }
+    MtdParameterized<@MRtnA String, @MRtnB String> bothTypeArgs() { return null; }
+
+    MtdParameterized<@MRtnA MtdParameterized<@MRtnA String, @MRtnB String>, @MRtnB String>
+    nestedMtdParameterized() { return null; }
+
+    public <T> @MRtnA String method() { return null; }
+
+    @MRtnA String [] array1() { return null; }
+    @MRtnA String @MRtnB [] array1Deep() { return null; }
+    @MRtnA String [] [] array2() { return null; }
+    @MRtnA String @MRtnA [] @MRtnB [] array2Deep() { return null; }
+    String @MRtnA [] [] array2First() { return null; }
+    String [] @MRtnB [] array2Second() { return null; }
+
+    // Old-style array syntax
+    String array2FirstOld() @MRtnA [] { return null; }
+    String array2SecondOld() [] @MRtnB [] { return null; }
+}
+
+class MtdModifiedScoped {
+    public final MtdParameterized<String, String> unannotated() { return null; }
+    public final MtdParameterized<@MRtnA String, String> firstTypeArg() { return null; }
+    public final MtdParameterized<String, @MRtnA String> secondTypeArg() { return null; }
+    public final MtdParameterized<@MRtnA String, @MRtnB String> bothTypeArgs() { return null; }
+
+    public final MtdParameterized<@MRtnA MtdParameterized<@MRtnA String, @MRtnB String>, @MRtnB String>
+    nestedMtdParameterized() { return null; }
+
+    public final @MRtnA String [] array1() { return null; }
+    public final @MRtnA String @MRtnB [] array1Deep() { return null; }
+    public final @MRtnA String [] [] array2() { return null; }
+    public final @MRtnA String @MRtnA [] @MRtnB [] array2Deep() { return null; }
+    public final String @MRtnA [] [] array2First() { return null; }
+    public final String [] @MRtnB [] array2Second() { return null; }
+}
+
+class MtdParameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface MRtnA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface MRtnB { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodTypeParameters.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodTypeParameters.java
new file mode 100644
index 0000000..dbfe286
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/MethodTypeParameters.java
@@ -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.
+ */
+
+package typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class UnscopedUnmodified {
+    <K extends @MTyParamA String> void methodExtends() {}
+    <K extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void nestedExtends() {}
+    <K extends @MTyParamA String, V extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void dual() {}
+    <K extends String, V extends MtdTyParameterized<@MTyParamB String>> void dualOneAnno() {}
+}
+
+class PublicModifiedMethods {
+    public final <K extends @MTyParamA String> void methodExtends() {}
+    public final <K extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void nestedExtends() {}
+    public final <K extends @MTyParamA String, V extends @MTyParamA MtdTyParameterized<@MTyParamB String>> void dual() {}
+    public final <K extends String, V extends MtdTyParameterized<@MTyParamB String>> void dualOneAnno() {}
+}
+
+class MtdTyParameterized<K> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface MTyParamA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface MTyParamB { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Parameters.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Parameters.java
new file mode 100644
index 0000000..6fe8dfc
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Parameters.java
@@ -0,0 +1,54 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Parameters {
+    void unannotated(ParaParameterized<String, String> a) {}
+    void firstTypeArg(ParaParameterized<@ParamA String, String> a) {}
+    void secondTypeArg(ParaParameterized<String, @ParamA String> a) {}
+    void bothTypeArgs(ParaParameterized<@ParamA String, @ParamB String> both) {}
+
+    void nestedParaParameterized(ParaParameterized<@ParamA ParaParameterized<@ParamA String, @ParamB String>, @ParamB String> a) {}
+
+    void array1(@ParamA String [] a) {}
+    void array1Deep(@ParamA String @ParamB [] a) {}
+    void array2(@ParamA String [] [] a) {}
+    void array2Deep(@ParamA String @ParamA [] @ParamB [] a) {}
+    void array2First(String @ParamA [] [] a) {}
+    void array2Second(String [] @ParamB [] a) {}
+}
+
+class ParaParameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ParamA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ParamB { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Receivers.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Receivers.java
new file mode 100644
index 0000000..a46dd39
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Receivers.java
@@ -0,0 +1,131 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class DefaultUnmodified {
+    void plain(@RcvrA DefaultUnmodified this) { }
+    <T> void generic(@RcvrA DefaultUnmodified this) { }
+    void withException(@RcvrA DefaultUnmodified this) throws Exception { }
+    String nonVoid(@RcvrA @RcvrB("m") DefaultUnmodified this) { return null; }
+    <T extends Runnable> void accept(@RcvrA DefaultUnmodified this, T r) throws Exception { }
+}
+
+class PublicModified {
+    public final void plain(@RcvrA PublicModified this) { }
+    public final <T> void generic(@RcvrA PublicModified this) { }
+    public final void withException(@RcvrA PublicModified this) throws Exception { }
+    public final String nonVoid(@RcvrA PublicModified this) { return null; }
+    public final <T extends Runnable> void accept(@RcvrA PublicModified this, T r) throws Exception { }
+}
+
+class WithValue {
+    void plain(@RcvrB("m") WithValue this) { }
+    <T> void generic(@RcvrB("m") WithValue this) { }
+    void withException(@RcvrB("m") WithValue this) throws Exception { }
+    String nonVoid(@RcvrB("m") WithValue this) { return null; }
+    <T extends Runnable> void accept(@RcvrB("m") WithValue this, T r) throws Exception { }
+}
+
+class WithFinal {
+    void plain(final @RcvrB("m") WithFinal this) { }
+    <T> void generic(final @RcvrB("m") WithFinal this) { }
+    void withException(final @RcvrB("m") WithFinal this) throws Exception { }
+    String nonVoid(final @RcvrB("m") WithFinal this) { return null; }
+    <T extends Runnable> void accept(final @RcvrB("m") WithFinal this, T r) throws Exception { }
+}
+
+class WithBody {
+    Object f;
+
+    void field(@RcvrA WithBody this) {
+        this.f = null;
+    }
+    void meth(@RcvrA WithBody this) {
+        this.toString();
+    }
+}
+
+class Generic1<X> {
+    void test1(Generic1<X> this) {}
+    void test2(@RcvrA Generic1<X> this) {}
+    void test3(Generic1<@RcvrA X> this) {}
+    void test4(@RcvrA Generic1<@RcvrA X> this) {}
+}
+
+class Generic2<@RcvrA X> {
+    void test1(Generic2<X> this) {}
+    void test2(@RcvrA Generic2<X> this) {}
+    void test3(Generic2<@RcvrA X> this) {}
+    void test4(@RcvrA Generic2<@RcvrA X> this) {}
+}
+
+class Generic3<X extends @RcvrA Object> {
+    void test1(Generic3<X> this) {}
+    void test2(@RcvrA Generic3<X> this) {}
+    void test3(Generic3<@RcvrA X> this) {}
+    void test4(@RcvrA Generic3<@RcvrA X> this) {}
+}
+
+class Generic4<X extends @RcvrA Object> {
+    <Y> void test1(Generic4<X> this) {}
+    <Y> void test2(@RcvrA Generic4<X> this) {}
+    <Y> void test3(Generic4<@RcvrA X> this) {}
+    <Y> void test4(@RcvrA Generic4<@RcvrA X> this) {}
+}
+
+class Outer {
+    class Inner {
+        void none(Outer.Inner this) {}
+        void outer(@RcvrA Outer.Inner this) {}
+        void inner(Outer. @RcvrB("i") Inner this) {}
+        void both(@RcvrA Outer. at RcvrB("i") Inner this) {}
+
+        void innerOnlyNone(Inner this) {}
+        void innerOnly(@RcvrA Inner this) {}
+    }
+}
+
+class GenericOuter<S, T> {
+    class GenericInner<U, V> {
+        void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
+        void outer(@RcvrA GenericOuter<S, T>.GenericInner<U, V> this) {}
+        void inner(GenericOuter<S, T>. @RcvrB("i") GenericInner<U, V> this) {}
+        void both(@RcvrA GenericOuter<S, T>. at RcvrB("i") GenericInner<U, V> this) {}
+
+        void innerOnlyNone(GenericInner<U, V> this) {}
+        void innerOnly(@RcvrA GenericInner<U, V> this) {}
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface RcvrA {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface RcvrB { String value(); }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Throws.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Throws.java
new file mode 100644
index 0000000..75a31dd
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Throws.java
@@ -0,0 +1,51 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class ThrDefaultUnmodified {
+    void oneException() throws @ThrA Exception {}
+    void twoExceptions() throws @ThrA RuntimeException, @ThrA Exception {}
+}
+
+class ThrPublicModified {
+    public final void oneException(String a) throws @ThrA Exception {}
+    public final void twoExceptions(String a) throws @ThrA RuntimeException, @ThrA Exception {}
+}
+
+class ThrWithValue {
+    void oneException() throws @ThrB("m") Exception {}
+    void twoExceptions() throws @ThrB(value="m") RuntimeException, @ThrA Exception {}
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ThrA {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface ThrB { String value(); }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/TypeParameters.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/TypeParameters.java
new file mode 100644
index 0000000..057bfad
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/TypeParameters.java
@@ -0,0 +1,60 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class TypUnannotated<K> { }
+class OneAnnotated<@TyParaA K> { }
+class TwoAnnotated<@TyParaA K, @TyParaA V> { }
+class SecondAnnotated<K, @TyParaA V extends String> { }
+
+class TestMethods {
+    <K> void unannotated() { }
+    <@TyParaA K> void oneAnnotated() { }
+    <@TyParaA K, @TyParaB("m") V> void twoAnnotated() { }
+    <K, @TyParaA V extends @TyParaA String> void secondAnnotated() { }
+}
+
+class UnannotatedB<K> { }
+class OneAnnotatedB<@TyParaB("m") K> { }
+class TwoAnnotatedB<@TyParaB("m") K, @TyParaB("m") V> { }
+class SecondAnnotatedB<K, @TyParaB("m") V extends @TyParaB("m") String> { }
+
+class OneAnnotatedC<@TyParaC K> { }
+class TwoAnnotatedC<@TyParaC K, @TyParaC V> { }
+class SecondAnnotatedC<K, @TyParaC V extends String> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface TyParaA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface TyParaB { String value(); }
+ at Target(ElementType.TYPE_USE)
+ at Documented
+ at interface TyParaC { }
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Varargs.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Varargs.java
new file mode 100644
index 0000000..bb956e8
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Varargs.java
@@ -0,0 +1,42 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface VarArgA {}
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class Varargs {
+
+    // Handle annotations on a varargs element type
+    void varargPlain(Object @VarArgA... objs) {
+    }
+
+    void varargGeneric(Class<?> @VarArgA ... clz) {
+    }
+}
diff --git a/test/com/sun/javadoc/testTypeAnnotations/typeannos/Wildcards.java b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Wildcards.java
new file mode 100644
index 0000000..593115c
--- /dev/null
+++ b/test/com/sun/javadoc/testTypeAnnotations/typeannos/Wildcards.java
@@ -0,0 +1,74 @@
+/*
+ * 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 typeannos;
+
+import java.lang.annotation.*;
+
+/*
+ * This class is replicated from test/tools/javac/annotations/typeAnnotations/newlocations.
+ */
+class BoundTest {
+    void wcExtends(MyList<? extends @WldA String> l) { }
+    void wcSuper(MyList<? super @WldA String> l) { }
+
+    MyList<? extends @WldA String> returnWcExtends() { return null; }
+    MyList<? super @WldA String> returnWcSuper() { return null; }
+    MyList<? extends @WldA MyList<? super @WldB("m") String>> complex() { return null; }
+}
+
+class BoundWithValue {
+    void wcExtends(MyList<? extends @WldB("m") String> l) { }
+    void wcSuper(MyList<? super @WldB(value="m") String> l) { }
+
+    MyList<? extends @WldB("m") String> returnWcExtends() { return null; }
+    MyList<? super @WldB(value="m") String> returnWcSuper() { return null; }
+    MyList<? extends @WldB("m") MyList<? super @WldB("m") String>> complex() { return null; }
+}
+
+class SelfTest {
+    void wcExtends(MyList<@WldA ?> l) { }
+    void wcSuper(MyList<@WldA ?> l) { }
+
+    MyList<@WldA ?> returnWcExtends() { return null; }
+    MyList<@WldA ?> returnWcSuper() { return null; }
+    MyList<@WldA ? extends @WldA MyList<@WldB("m") ?>> complex() { return null; }
+}
+
+class SelfWithValue {
+    void wcExtends(MyList<@WldB("m") ?> l) { }
+    void wcSuper(MyList<@WldB(value="m") ?> l) { }
+
+    MyList<@WldB("m") ?> returnWcExtends() { return null; }
+    MyList<@WldB(value="m") ?> returnWcSuper() { return null; }
+    MyList<@WldB("m") ? extends MyList<@WldB("m") ? super String>> complex() { return null; }
+}
+
+class MyList<K> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface WldA { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at Documented
+ at interface WldB { String value(); }
diff --git a/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java b/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
index cef99f1..ee352a1 100644
--- a/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
+++ b/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
@@ -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 @@ public class TestTypeParameters extends JavadocTester {
     private static final String[][] TEST1 = {
         {BUG_ID + FS + "pkg" + FS + "C.html",
             "<td class=\"colFirst\"><code><W extends java.lang.String,V extends " +
-            "java.util.List> <br>java.lang.Object</code></td>"
+            "java.util.List><br>java.lang.Object</code></td>"
         },
         {BUG_ID + FS + "pkg" + FS + "C.html",
             "<code><T> java.lang.Object</code>"
diff --git a/test/com/sun/javadoc/testValueTag/TestValueTag.java b/test/com/sun/javadoc/testValueTag/TestValueTag.java
index 08780aa..ba0f291 100644
--- a/test/com/sun/javadoc/testValueTag/TestValueTag.java
+++ b/test/com/sun/javadoc/testValueTag/TestValueTag.java
@@ -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
@@ -41,6 +41,7 @@ public class TestValueTag extends JavadocTester {
     //Javadoc arguments.
     private static final String[] ARGS =
         new String[] {
+            "-Xdoclint:none",
             "-d", BUG_ID, "-sourcepath", SRC_DIR, "-tag",
             "todo", "pkg1", "pkg2"
         };
@@ -89,7 +90,7 @@ public class TestValueTag extends JavadocTester {
         //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."
diff --git a/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java b/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
index de23e99..1d58351 100644
--- a/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
+++ b/test/com/sun/javadoc/testWarnBadParamNames/TestWarnBadParamNames.java
@@ -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
@@ -43,7 +43,7 @@ public class TestWarnBadParamNames extends JavadocTester {
     };
     private static final String[][] NEGATED_TEST = NO_TEST;
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, SRC_DIR + FS + "C.java"
+        "-Xdoclint:none", "-d", BUG_ID, SRC_DIR + FS + "C.java"
     };
 
     /**
diff --git a/test/com/sun/javadoc/testWarnings/TestWarnings.java b/test/com/sun/javadoc/testWarnings/TestWarnings.java
index bf21f3f..d5f697a 100644
--- a/test/com/sun/javadoc/testWarnings/TestWarnings.java
+++ b/test/com/sun/javadoc/testWarnings/TestWarnings.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -43,11 +43,11 @@ public class TestWarnings extends JavadocTester {
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
-        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
+        "-Xdoclint:none", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg"
     };
 
     private static final String[] ARGS2 = new String[] {
-        "-d", BUG_ID, "-private", "-sourcepath", SRC_DIR, "pkg"
+        "-Xdoclint:none", "-d", BUG_ID, "-private", "-sourcepath", SRC_DIR, "pkg"
     };
 
     //Input for string search tests.
diff --git a/test/com/sun/javadoc/testXOption/TestXOption.java b/test/com/sun/javadoc/testXOption/TestXOption.java
new file mode 100644
index 0000000..c66c84d
--- /dev/null
+++ b/test/com/sun/javadoc/testXOption/TestXOption.java
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ *
+ * 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      8007687
+ * @summary  Make sure that the -X option works properly.
+ * @library  ../lib/
+ * @build    JavadocTester TestXOption
+ * @run main TestXOption
+ */
+
+public class TestXOption extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8007687";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-X",
+            SRC_DIR + FS + "TestXOption.java"
+    };
+
+    private static final String[] ARGS2 = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR,
+            SRC_DIR + FS + "TestXOption.java"
+    };
+
+    private static final String[][] TEST = {
+        {NOTICE_OUTPUT, "-Xmaxerrs "},
+        {NOTICE_OUTPUT, "-Xmaxwarns "},
+        {STANDARD_OUTPUT, "-Xdocrootparent "},
+        {STANDARD_OUTPUT, "-Xdoclint "},
+        {STANDARD_OUTPUT, "-Xdoclint:"},
+    };
+    private static final String[][] NEGATED_TEST = NO_TEST;
+
+    //The help option should not crash the doclet.
+    private static final int EXPECTED_EXIT_CODE = 0;
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestXOption tester = new TestXOption();
+        int actualExitCode = run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.checkExitCode(EXPECTED_EXIT_CODE, actualExitCode);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java b/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java
new file mode 100644
index 0000000..f90c196
--- /dev/null
+++ b/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java
@@ -0,0 +1,133 @@
+/*
+ * 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 8006735
+ * @summary  Smoke test for ensuring that annotations are emitted to javadoc
+ *
+ * @author   Mahmood Ali <mali>
+ * @library  ../../lib/
+ * @build    JavadocTester
+ * @build    TestSmoke
+ * @run main TestSmoke
+ */
+
+public class TestSmoke extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "8006735";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-private", "-sourcepath", SRC_DIR, "pkg"
+    };
+
+    //Input for string search tests.
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg" + FS + "T0x1C.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x1D.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x0D.html", "@DA"},
+        {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"},
+        {BUG_ID + FS + "pkg" + FS + "T0x11.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x13.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x15.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x14.html", "@DA"},
+        {BUG_ID + FS + "pkg" + FS + "T0x16.html", "@DA"}
+    };
+
+    private static final String[][] NEGATED_TEST = {
+        {BUG_ID + FS + "pkg" + FS + "T0x1C.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x1D.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x00.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x01.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x02.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x04.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x08.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x0D.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x06.html", "@A"},
+        {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"},
+        {BUG_ID + FS + "pkg" + FS + "T0x11.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x13.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x15.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x14.html", "@A"},
+        {BUG_ID + FS + "pkg" + FS + "T0x16.html", "@A"}
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestSmoke tester = new TestSmoke();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
diff --git a/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java b/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java
new file mode 100644
index 0000000..104b74a
--- /dev/null
+++ b/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+package pkg;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.util.*;
+import java.io.*;
+
+/*
+ * @summary compiler accepts all values
+ * @author Mahmood Ali
+ * @author Yuri Gaevsky
+ */
+
+ at Target(TYPE_USE)
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface A {}
+
+ at Target(TYPE_USE)
+ at Retention(RetentionPolicy.RUNTIME)
+ at Documented
+ at interface DA {}
+
+ at Target(TYPE_PARAMETER)
+ at Retention(RetentionPolicy.RUNTIME)
+ at Documented
+ at interface DTPA {}
+
+/** typecast */
+class T0x00 {
+    void m0x00(Long l1) {
+        Object l2 = (@A @DA Long) l1;
+    }
+}
+
+/** typecast generic/array */
+class T0x01<T> {
+    void m0x01(List<T> list) {
+        List<T> l = (List<@A @DA T>) list;
+    }
+}
+
+/** instanceof */
+class T0x02 {
+    boolean m0x02(String s) {
+        return (s instanceof @A @DA String);
+    }
+}
+
+/** 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() {
+        new @A @DA ArrayList<String>();
+    }
+}
+
+/** object creation (new) generic/array */
+class T0x05<T> {
+    void m0x05() {
+        new ArrayList<@A @DA T>();
+    }
+}
+
+/** method receiver */
+class T0x06 {
+    void m0x06(@A @DA T0x06 this) {}
+}
+
+/** local variable */
+class T0x08 {
+    void m0x08() {
+      @A @DA String s = null;
+    }
+}
+
+/** local variable generic/array */
+class T0x09<T> {
+    void g() {
+        List<@A @DA String> l = null;
+    }
+
+    void a() {
+        String @A @DA [] as = null;
+    }
+}
+
+/** 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;
+}
+
+/** 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;
+    }
+}
+
+/** 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 */
+class T0x18<T> {
+    <T> T0x18() {}
+
+    void m() {
+        new <@A @DA Integer> T0x18();
+    }
+}
+
+/** 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; }
+    static void m0x1A() {
+        T0x1A.<@A @DA Integer, @A @DA Short>m();
+    }
+}
+
+/** 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) {}
+}
+
+/** 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;
+}
diff --git a/test/tools/apt/Basics/Aggregate.java b/test/tools/apt/Basics/Aggregate.java
deleted file mode 100644
index d74342b..0000000
--- a/test/tools/apt/Basics/Aggregate.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public class Aggregate {
-    static {
-        System.out.println("xxyzzy");
-    }
-
-    private Aggregate() {}
-
-    private static double hypot(double Berkeley, double SantaCruz) {
-        return 0.0;
-    }
-
-    public int hashcode() {return 42;}
-    public boolean equals(Aggregate a) {return this == a;}
-
-    public static void main(String[] argv) {
-        System.out.println("Hello World.");
-    }
-}
diff --git a/test/tools/apt/Basics/CheckAptIsRemovedTest.java b/test/tools/apt/Basics/CheckAptIsRemovedTest.java
new file mode 100644
index 0000000..44bc737
--- /dev/null
+++ b/test/tools/apt/Basics/CheckAptIsRemovedTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
+ * @summary Make sure apt is removed and doesn't come back
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckAptIsRemovedTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/apt/Basics/apt.sh
+public class CheckAptIsRemovedTest {
+    //I think this class can be let with the imports only and that should be enough for as test's purpose
+    private static final String NullAPFSrc =
+        "import com.sun.mirror.apt.*;\n" +
+        "import com.sun.mirror.declaration.*;\n" +
+        "import com.sun.mirror.type.*;\n" +
+        "import com.sun.mirror.util.*;\n" +
+        "import java.util.Collection;\n" +
+        "import java.util.Set;\n\n" +
+
+        "public class NullAPF implements AnnotationProcessorFactory {\n" +
+        "    static class NullAP implements AnnotationProcessor {\n" +
+        "        NullAP(AnnotationProcessorEnvironment ape) {}\n" +
+        "        public void process() {return;}\n" +
+        "    }\n\n" +
+
+        "    static Collection<String> supportedTypes;\n\n" +
+        "    static {\n" +
+        "        String types[] = {\"*\"};\n" +
+        "        supportedTypes = java.util.Arrays.asList(types);\n" +
+        "    }\n\n" +
+
+        "    public Collection<String> supportedOptions() {\n" +
+        "        return java.util.Collections.emptySet();\n" +
+        "    }\n\n" +
+
+        "    public Collection<String> supportedAnnotationTypes() {\n" +
+        "        return supportedTypes;\n" +
+        "    }\n\n" +
+
+        "    public AnnotationProcessor getProcessorFor(" +
+        "        Set<AnnotationTypeDeclaration> atds,\n" +
+        "        AnnotationProcessorEnvironment env) {\n" +
+        "        return new NullAP(env);\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String[] args) throws Exception {
+        String testJDK = System.getProperty("test.jdk");
+        Path aptLin = Paths.get(testJDK, "bin", "apt");
+        Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
+
+//        if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
+        if (Files.exists(aptLin) || Files.exists(aptWin)) {
+            throw new AssertionError("apt executable should not exist");
+        }
+
+//        JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
+//        $JAVAC ${TESTSRC}/NullAPF.java
+        Path classpath = Paths.get(testJDK, "lib", "tools.jar");
+        ToolBox.JavaToolArgs javacArgs =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setOptions("-source", "1.5", "-sourcepath", ".",
+                    "-classpath", classpath.toString())
+                .setSources(NullAPFSrc);
+        ToolBox.javac(javacArgs);
+    }
+
+}
diff --git a/test/tools/apt/Basics/ClassAnnotations.java b/test/tools/apt/Basics/ClassAnnotations.java
deleted file mode 100644
index 97d28ca..0000000
--- a/test/tools/apt/Basics/ClassAnnotations.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
- at MySimple("value") @MyMarker
- at AnnotMarker @AnnotSimple("foo")
- at AnnotMarker2 @AnnotSimple2("bar")
-public class ClassAnnotations {
-    static double d;
-
-    public void foo() {
-        return;
-    }
-
-    private double bar(int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/FreshnessApf.java b/test/tools/apt/Basics/FreshnessApf.java
deleted file mode 100644
index 100c4fe..0000000
--- a/test/tools/apt/Basics/FreshnessApf.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Indirect test of whether source or class files are used to provide
- * declaration information.
- */
-public class FreshnessApf implements AnnotationProcessorFactory {
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new FreshnessAp(env);
-    }
-
-    private static class FreshnessAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        FreshnessAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            System.out.println("Testing for freshness.");
-            boolean empty = true;
-            for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) {
-                for (FieldDeclaration fieldDecl: typeDecl.getFields() ) {
-                    empty = false;
-                    System.out.println(typeDecl.getQualifiedName() +
-                                       "." + fieldDecl.getSimpleName());
-
-                    // Verify the declaration for the type of the
-                    // field is a class with an annotation.
-                    System.out.println(((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors());
-                    if (((DeclaredType) fieldDecl.getType()).getDeclaration().getAnnotationMirrors().size() == 0)
-                        env.getMessager().printError("Expected an annotation.");
-                }
-            }
-
-            if (empty)
-                env.getMessager().printError("No fields encountered.");
-        }
-    }
-}
diff --git a/test/tools/apt/Basics/GenClass.java b/test/tools/apt/Basics/GenClass.java
deleted file mode 100644
index ad3a7a2..0000000
--- a/test/tools/apt/Basics/GenClass.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/*
- * A trivial generic class to test the fix for 5018369.
- */
-
-class GenClass<T> {
-}
diff --git a/test/tools/apt/Basics/Indirect.java b/test/tools/apt/Basics/Indirect.java
deleted file mode 100644
index 0f59bef..0000000
--- a/test/tools/apt/Basics/Indirect.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/*
- * Class that is used to provide a pointer to another class
- * declaration.
- */
-public class Indirect {
-    Milk skim = null;
-}
diff --git a/test/tools/apt/Basics/Lacuna.java b/test/tools/apt/Basics/Lacuna.java
deleted file mode 100644
index cc0bfd3..0000000
--- a/test/tools/apt/Basics/Lacuna.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-class Lacuna extends Missing {}
diff --git a/test/tools/apt/Basics/MethodAnnotations.java b/test/tools/apt/Basics/MethodAnnotations.java
deleted file mode 100644
index 53aee9e..0000000
--- a/test/tools/apt/Basics/MethodAnnotations.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
-public class MethodAnnotations {
-    static double d;
-
-    @MySimple("value") @MyMarker
-    @AnnotMarker @AnnotSimple("foo")
-    @AnnotMarker2 @AnnotSimple2("bar")
-    public void foo() {
-        return;
-    }
-
-    private double bar(int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/Milk.java b/test/tools/apt/Basics/Milk.java
deleted file mode 100644
index 03bbfcf..0000000
--- a/test/tools/apt/Basics/Milk.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.*;
-
- at Fresh
-public class Milk {
-    // Moo.
-}
-
- at Retention(RetentionPolicy.SOURCE)
- at interface Fresh {
-}
diff --git a/test/tools/apt/Basics/MisMatch.java b/test/tools/apt/Basics/MisMatch.java
deleted file mode 100644
index ee942ce..0000000
--- a/test/tools/apt/Basics/MisMatch.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-
-/**
- * Class that uses constructs whose language and vm interpretation
- * differ.
- */
-public class MisMatch {
-    static final int constant = 3;
-    static int notConstant = 4;
-    private static strictfp class NestedClass {
-    }
-
-    protected abstract class AbstractNestedClass {
-        /**
-         * Another doc comment.
-         *
-         * This one has multiple lines.
-         */
-        void myMethod() throws RuntimeException , Error {}
-
-        abstract void myAbstractMethod();
-    }
-
-    void VarArgsMethod1(Number... num) {
-        ;
-    }
-
-    void VarArgsMethod2(float f, double d, Number... num) {
-        ;
-    }
-}
-
- at interface Colors {
-}
-
-interface Inter {
-    void interfaceMethod();
-}
-
-enum MyEnum {
-    RED,
-    GREEN,
-    BLUE;
-}
diff --git a/test/tools/apt/Basics/Misc.java b/test/tools/apt/Basics/Misc.java
deleted file mode 100644
index a119c03..0000000
--- a/test/tools/apt/Basics/Misc.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/*
- * Class with miscellaneous structures to exercise printing.
- */
-
-import java.util.Collection;
-
-public final class  Misc<T> implements Marker2, Marker3 {
-    private static final long longConstant = Long.MAX_VALUE;
-
-    private static final String asciispecials = "\t\n\u0007";
-
-    public void covar(Collection<? extends T> s) {return;}
-
-    public void contravar(Collection<? super T> s) {return;}
-
-    public <S> S varUse(int i) {return null;}
-
-    Object o = (new Object() {});       // verify fix for 5019108
-}
-
-interface Marker1 {}
-
-interface Marker2 extends Marker1 {}
-
-interface Marker3 {}
diff --git a/test/tools/apt/Basics/MyMarker.java b/test/tools/apt/Basics/MyMarker.java
deleted file mode 100644
index 4cec4f1..0000000
--- a/test/tools/apt/Basics/MyMarker.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-
-public @interface MyMarker {
-}
diff --git a/test/tools/apt/Basics/MySimple.java b/test/tools/apt/Basics/MySimple.java
deleted file mode 100644
index 882519e..0000000
--- a/test/tools/apt/Basics/MySimple.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-
-public @interface MySimple {
-    String value() default "default";
-}
diff --git a/test/tools/apt/Basics/NestedClassAnnotations.java b/test/tools/apt/Basics/NestedClassAnnotations.java
deleted file mode 100644
index 2e6473a..0000000
--- a/test/tools/apt/Basics/NestedClassAnnotations.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
-public class NestedClassAnnotations {
-    static double d;
-
-    public void foo() {
-        return;
-    }
-
-    public static void baz() {
-    }
-
-    private double bar(int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    @MySimple("value") @MyMarker
-    @AnnotMarker @AnnotSimple("foo")
-    @AnnotMarker2 @AnnotSimple2("bar")
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/NullAPF.java b/test/tools/apt/Basics/NullAPF.java
deleted file mode 100644
index ef8bb8e..0000000
--- a/test/tools/apt/Basics/NullAPF.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-
-public class NullAPF implements AnnotationProcessorFactory {
-    static class NullAP implements AnnotationProcessor {
-        NullAP(AnnotationProcessorEnvironment ape) {
-        }
-
-        public void process() {
-            return;
-        }
-    }
-
-    static Collection<String> supportedTypes;
-
-    static {
-        String types[] = {"*"};
-        supportedTypes = java.util.Arrays.asList(types);
-    }
-
-    /*
-     * Processor doesn't examine any options.
-     */
-    public Collection<String> supportedOptions() {
-        return java.util.Collections.emptySet();
-    }
-
-    /*
-     * All annotation types are supported.
-     */
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new NullAP(env);
-    }
-}
diff --git a/test/tools/apt/Basics/ParameterAnnotations.java b/test/tools/apt/Basics/ParameterAnnotations.java
deleted file mode 100644
index 81907eb..0000000
--- a/test/tools/apt/Basics/ParameterAnnotations.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
-public class ParameterAnnotations {
-    static double d;
-
-    public void foo() {
-        return;
-    }
-
-    private double bar(@MySimple("value") @MyMarker
-                       @AnnotMarker @AnnotSimple("foo")
-                       @AnnotMarker2 @AnnotSimple2("bar")
-                       int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/StaticFieldAnnotations.java b/test/tools/apt/Basics/StaticFieldAnnotations.java
deleted file mode 100644
index 5169ba0..0000000
--- a/test/tools/apt/Basics/StaticFieldAnnotations.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
-public class StaticFieldAnnotations {
-    @MySimple("value") @MyMarker
-    @AnnotMarker @AnnotSimple("foo")
-    @AnnotMarker2 @AnnotSimple2("bar")
-    static double d;
-
-    public void foo() {
-        return;
-    }
-
-    private double bar(int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/StaticMethodAnnotations.java b/test/tools/apt/Basics/StaticMethodAnnotations.java
deleted file mode 100644
index 838c607..0000000
--- a/test/tools/apt/Basics/StaticMethodAnnotations.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.*;
-import annot.annot2.*;
-
-public class StaticMethodAnnotations {
-    static double d;
-
-    public void foo() {
-        return;
-    }
-
-    @MySimple("value") @MyMarker
-    @AnnotMarker @AnnotSimple("foo")
-    @AnnotMarker2 @AnnotSimple2("bar")
-    public static void baz() {
-    }
-
-    private double bar(int baz) {
-        @AnnotShangri_la
-        int local = 0;
-        return (double) baz;
-    }
-
-    static class NestedClass {
-        protected int field;
-    }
-}
diff --git a/test/tools/apt/Basics/TestGetPackageApf.java b/test/tools/apt/Basics/TestGetPackageApf.java
deleted file mode 100644
index cc169ce..0000000
--- a/test/tools/apt/Basics/TestGetPackageApf.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * This class is used to test getPackage on classes that are
- * not already loaded.
- */
-public class TestGetPackageApf implements AnnotationProcessorFactory {
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new TestGetPackageAp(env);
-    }
-
-    private static class TestGetPackageAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        TestGetPackageAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            boolean failed = false;
-            String packageNames[] = {
-                "", // unnamed package
-                "java.lang.annotation",
-                "java.lang",
-                "java.util",
-                "java.awt.image.renderable",
-                "foo.bar",
-                "foo",
-                "p1",
-                // "p1.p2", // class p1.p2 obscures package p1.p2
-            };
-
-            for(String packageName: packageNames) {
-                PackageDeclaration p = env.getPackage(packageName);
-                if (p == null) {
-                    failed = true;
-                    System.err.println("ERROR: No declaration found for ``" + packageName + "''.");
-                }
-                else if (!packageName.equals(p.getQualifiedName())) {
-                    failed = true;
-                    System.err.println("ERROR: Unexpected package name; expected " + packageName +
-                                       "got " + p.getQualifiedName());
-                }
-            }
-
-            String notPackageNames[] = {
-                "XXYZZY",
-                "java.lang.String",
-                "1",
-                "1.2",
-                "3.14159",
-                "To be or not to be is a tautology",
-                "1+2=3",
-            };
-
-            for(String notPackageName: notPackageNames) {
-                PackageDeclaration p = env.getPackage(notPackageName);
-                if (p != null) {
-                    failed = true;
-                    System.err.println("ERROR: Unexpected declaration: ``" + p + "''.");
-                }
-            }
-
-            if (failed)
-                throw new RuntimeException("Errors found testing getPackage.");
-        }
-    }
-}
diff --git a/test/tools/apt/Basics/TestGetTypeDeclarationApf.java b/test/tools/apt/Basics/TestGetTypeDeclarationApf.java
deleted file mode 100644
index 21d2a7a..0000000
--- a/test/tools/apt/Basics/TestGetTypeDeclarationApf.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * This class is used to test getTypeDeclaration on classes that are
- * not already loaded.
- */
-public class TestGetTypeDeclarationApf implements AnnotationProcessorFactory {
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new TestGetTypeDeclarationAp(env);
-    }
-
-    private static class TestGetTypeDeclarationAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        TestGetTypeDeclarationAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            String classNames[] = {
-                "java.lang.String",             // should be already available
-                "java.lang.Thread.State",       // should be already available
-                "java.util.Collection",
-                "java.util.Map.Entry",
-                "foo.bar.Baz.Xxyzzy.Wombat",
-                "foo.bar.Baz.Xxyzzy",
-                "foo.bar.Baz",
-                "foo.bar.Quux",
-                "foo.bar.Quux.Xxyzzy",
-                "foo.bar.Quux.Xxyzzy.Wombat",
-                "NestedClassAnnotations",
-                "NestedClassAnnotations.NestedClass",
-            };
-
-            for(String className: classNames) {
-                TypeDeclaration t = env.getTypeDeclaration(className);
-                if (t == null)
-                    throw new RuntimeException("No declaration found for " + className);
-                if (! t.getQualifiedName().equals(className))
-                    throw new RuntimeException("Class with wrong name found for " + className);
-            }
-
-            // Test obscuring behavior; i.e. nested class C1 in class
-            // p1 where p1 is member of package p2 should be favored
-            // over class C1 in package p1.p2.
-            String nonuniqueCanonicalNames[] = {
-                "p1.p2.C1",
-            };
-            for(String className: nonuniqueCanonicalNames) {
-                ClassDeclaration c1 = (ClassDeclaration) env.getTypeDeclaration(className);
-                ClassDeclaration c2 = (ClassDeclaration) c1.getDeclaringType();
-                PackageDeclaration p     = env.getPackage("p1");
-
-                if (!p.equals(c1.getPackage())  ||
-                    c2 == null ||
-                    !"C1".equals(c1.getSimpleName())) {
-                    throw new RuntimeException("Bad class declaration");
-                }
-            }
-
-            String notClassNames[] = {
-                "",
-                "XXYZZY",
-                "java",
-                "java.lang",
-                "java.lang.Bogogogous",
-                "1",
-                "1.2",
-                "3.14159",
-                "To be or not to be is a tautology",
-                "1+2=3",
-                "foo+.x",
-                "foo+x",
-                "+",
-                "?",
-                "***",
-                "java.*",
-            };
-
-            for(String notClassName: notClassNames) {
-                Declaration t = env.getTypeDeclaration(notClassName);
-                if (t != null) {
-                    System.err.println("Unexpected declaration:" + t);
-                    throw new RuntimeException("Declaration found for ``" + notClassName + "''.");
-                }
-            }
-
-        }
-    }
-}
diff --git a/test/tools/apt/Basics/annot/AnnotMarker.java b/test/tools/apt/Basics/annot/AnnotMarker.java
deleted file mode 100644
index ae6f72e..0000000
--- a/test/tools/apt/Basics/annot/AnnotMarker.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot;
-
-public @interface AnnotMarker {
-}
diff --git a/test/tools/apt/Basics/annot/AnnotShangri_la.java b/test/tools/apt/Basics/annot/AnnotShangri_la.java
deleted file mode 100644
index a87ae2f..0000000
--- a/test/tools/apt/Basics/annot/AnnotShangri_la.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot;
-
-/*
- * This annotation is used by the tests only to annotate local
- * variables; therefore, this annotation should not affect the
- * discovery process and should not appear in the list printed by
- * -XListAnnotationTypes.
- */
-public @interface AnnotShangri_la {
-}
diff --git a/test/tools/apt/Basics/annot/AnnotSimple.java b/test/tools/apt/Basics/annot/AnnotSimple.java
deleted file mode 100644
index 99ec142..0000000
--- a/test/tools/apt/Basics/annot/AnnotSimple.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot;
-
-public @interface AnnotSimple {
-    String value() default "default";
-}
diff --git a/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java b/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java
deleted file mode 100644
index cc7dbe0..0000000
--- a/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.annot2;
-
-public @interface AnnotMarker2 {
-}
diff --git a/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java b/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java
deleted file mode 100644
index abdbcfb..0000000
--- a/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 annot.annot2;
-
-public @interface AnnotSimple2 {
-    String value() default "default";
-}
diff --git a/test/tools/apt/Basics/apt.sh b/test/tools/apt/Basics/apt.sh
deleted file mode 100644
index e76c5fb..0000000
--- a/test/tools/apt/Basics/apt.sh
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059
-# @run shell ../verifyVariables.sh
-# @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations 
-# @run shell apt.sh
-# @summary test consistency of annotation discovery
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        CYGWIN* )
-                DIFFOPTS="--strip-trailing-cr"
-        ;;
-
-	* )
-	;;
-esac
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message "
-
-printf "%s\n" "-classpath ${TESTCLASSES}"                    > options
-printf "%s\n" "-factorypath ./nullap.jar"                   >> options
-printf "%s\n" "-sourcepath ${TESTSRC} "                     >> options
-printf "%s\n" "-nocompile"                                  >> options
-printf "%s\n" "-XListAnnotationTypes"                       >> options
-
-printf "%s\n" "-classpath ${TESTCLASSES}"                    > options1
-printf "%s\n" "-factorypath ./nullap.jar"                   >> options1
-printf "%s\n" "-sourcepath ${TESTSRC} "                     >> options1
-printf "%s\n" "-nocompile"                                  >> options1
-printf "%s\n" "-XListAnnotationTypes"                       >> options1
-printf "%s\n" "-XclassesAsDecls"                            >> options1
-
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-JAR="${TESTJAVA}/bin/jar "
-
-$JAVAC ${TESTSRC}/NullAPF.java \
-${TESTSRC}/FreshnessApf.java  \
-${TESTSRC}/TestGetTypeDeclarationApf.java \
-${TESTSRC}/TestGetPackageApf.java
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        ;;
-
-        * )
-        echo "Compilation failed."
-        exit 1
-esac
-
-echo "Making services directory and copying services information."
-mkdir -p META-INF/services
-cp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services
-$JAR cvf0 nullap.jar NullAPF*.class META-INF
-
-ANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \
-${TESTSRC}/MethodAnnotations.java \
-${TESTSRC}/NestedClassAnnotations.java \
-${TESTSRC}/StaticFieldAnnotations.java \
-${TESTSRC}/StaticMethodAnnotations.java \
-${TESTSRC}/ParameterAnnotations.java"
-
-for i in ${ANNOTATION_FILES}
-do
-	printf "%s\n" "Testing annotations on source file ${i}"
-	${APT} @options ${i} 2> result.txt
-	diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt
-
-	RESULT=$?
-	case "$RESULT" in
-	        0  )
-	        ;;
-
-	        * )
-	        echo "Unexpected set of annotations on source files found."
-	        exit 1
-	esac
-
-	CLASS=`basename ${i} .java`
-	printf "%s\n" "Testing annotations on class file ${CLASS}"
-	${APT} @options1 ${CLASS} 2> result2.txt
-	diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt
-
-	RESULT=$?
-	case "$RESULT" in
-	        0  )
-	        ;;
-
-	        * )
-	        echo "Unexpected set of annotations on class files found."
-	        exit 1
-	esac
-done
-
-# Verify source files are favored over class files
-
-printf "%s\n" "-factorypath ."			 > options2
-printf "%s\n" "-factory FreshnessApf"		>> options2
-printf "%s\n" "-sourcepath ${TESTSRC}"		>> options2
-printf "%s\n" "-classpath  ${TESTCLASSES}"	>> options2
-printf "%s\n" "-nocompile"			>> options2
-
-${APT} @options2 ${TESTSRC}/Indirect.java
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-        ;;
-
-        * )
-        exit 1
-esac
-
-# Verify new classes can be loaded by getTypeDeclaration
-
-printf "%s\n" "-factorypath ."			 	> options3
-printf "%s\n" "-factory TestGetTypeDeclarationApf"	>> options3
-printf "%s\n" "-sourcepath ${TESTSRC}"			>> options3
-
-# ${APT} @options3
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-        ;;
-
-        * )
-        exit 1
-esac
-
-# Verify packages can be loaded by getPackage
-
-printf "%s\n" "-factorypath ."			 	> options4
-printf "%s\n" "-factory TestGetPackageApf"		>> options4
-printf "%s\n" "-sourcepath ${TESTSRC}"			>> options4
-
-${APT} @options4
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-        ;;
-
-        * )
-        exit 1
-esac
-exit 0
diff --git a/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory b/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory
deleted file mode 100644
index ba88580..0000000
--- a/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory
+++ /dev/null
@@ -1 +0,0 @@
-NullAPF
diff --git a/test/tools/apt/Basics/foo/bar/Baz.java b/test/tools/apt/Basics/foo/bar/Baz.java
deleted file mode 100644
index c411a05..0000000
--- a/test/tools/apt/Basics/foo/bar/Baz.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 foo.bar;
-
-public class Baz {
-    public class Xxyzzy {
-        public class Wombat {
-        }
-    }
-
-}
diff --git a/test/tools/apt/Basics/foo/bar/Quux.java b/test/tools/apt/Basics/foo/bar/Quux.java
deleted file mode 100644
index 8c4dad6..0000000
--- a/test/tools/apt/Basics/foo/bar/Quux.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 foo.bar;
-
-public class Quux {
-    public class Xxyzzy {
-        public class Wombat {
-        }
-    }
-
-}
diff --git a/test/tools/apt/Basics/golden.txt b/test/tools/apt/Basics/golden.txt
deleted file mode 100644
index 9d3f419..0000000
--- a/test/tools/apt/Basics/golden.txt
+++ /dev/null
@@ -1 +0,0 @@
-Set of annotations found:[MyMarker, MySimple, annot.AnnotMarker, annot.AnnotSimple, annot.annot2.AnnotMarker2, annot.annot2.AnnotSimple2]
diff --git a/test/tools/apt/Basics/goldenAggregate.txt b/test/tools/apt/Basics/goldenAggregate.txt
deleted file mode 100644
index 207cc92..0000000
--- a/test/tools/apt/Basics/goldenAggregate.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-
-public class Aggregate {
-
-  private Aggregate();
-
-  private static double hypot(double arg0,
-    double arg1);
-
-  public static void main(java.lang.String[] arg0);
-
-  public boolean equals(Aggregate arg0);
-
-  public int hashcode();
-}
diff --git a/test/tools/apt/Basics/p1/p2.java b/test/tools/apt/Basics/p1/p2.java
deleted file mode 100644
index d447094..0000000
--- a/test/tools/apt/Basics/p1/p2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 p1;
-
-public class p2 {
-    public static class C1 {}
-}
diff --git a/test/tools/apt/Basics/p1/p2/C1.java b/test/tools/apt/Basics/p1/p2/C1.java
deleted file mode 100644
index ec56749..0000000
--- a/test/tools/apt/Basics/p1/p2/C1.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 p1.p2;
-
-public class C1 {
-}
diff --git a/test/tools/apt/Basics/print.sh b/test/tools/apt/Basics/print.sh
deleted file mode 100644
index c5f168d..0000000
--- a/test/tools/apt/Basics/print.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 5008759 4998341 5018369 5032476 5060121 5096932 5096931
-# @run shell ../verifyVariables.sh
-# @run shell print.sh
-# @summary test availabilty of print option
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        CYGWIN* )
-                DIFFOPTS="--strip-trailing-cr"
-        ;;
-
-	* )
-	;;
-esac
-
-# Compile file directly, without TESTJAVACOPTS
-# Don't use @build or @compile as these implicitly use jtreg -javacoption values
-# and it is important that this file be compiled as expected, for later comparison
-# against a golden file.
-"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTSRC}/Aggregate.java
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} \
--print "
-
-printf "%s\n" "APT = ${APT}"
-
-PRINT_FILES="${TESTSRC}/MisMatch.java \
-${TESTSRC}/GenClass.java \
-${TESTSRC}/Misc.java \
-${TESTSRC}/Lacuna.java"
-
-for i in ${PRINT_FILES}
-do
-	# Delete any existing class file
-        FILENAME=`basename $i .java`
-	rm -f ${FILENAME}.class
-
-        printf "%s\n" "Printing ${i}"
-        ${APT} ${i}
-
-        RESULT=$?
-        case "$RESULT" in
-                0  )
-                ;;
-
-                * )
-                echo "Problem printing file ${i}."
-                exit 1
-        esac
-
-        # Verify compilation did not occur
-	if [ -f ${FILENAME}.class ]; then
-		printf "Improper compilation occured for %s.\n" ${i}
-		exit 1
-	fi
-	
-done
-
-# check for mutliple methods and no static initializer
-
-${APT} -XclassesAsDecls -cp ${TESTCLASSES} -print Aggregate > aggregate.txt
-diff ${DIFFOPTS} aggregate.txt ${TESTSRC}/goldenAggregate.txt
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-        ;;
-
-        * )
-        echo "Expected output not received"
-        exit 1
-esac
-
-exit 0
diff --git a/test/tools/apt/Compile/ClassDeclApf.java b/test/tools/apt/Compile/ClassDeclApf.java
deleted file mode 100644
index 9851e06..0000000
--- a/test/tools/apt/Compile/ClassDeclApf.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import java.io.*;
-
-import static java.util.Collections.*;
-
-/*
- * This class is used to test the ability to store static state across
- * apt rounds.
- */
-public class ClassDeclApf implements AnnotationProcessorFactory {
-    static int round = -1;
-
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new ClassDeclAp(env);
-    }
-
-    private static class ClassDeclAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        ClassDeclAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        // Simple inefficient drain
-        void drain(InputStream is, OutputStream os) {
-            try {
-            while (is.available() > 0 )
-                os.write(is.read());
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-
-        }
-
-        public void process() {
-            int size = env.getSpecifiedTypeDeclarations().size();
-
-            try {
-                round++;
-                switch (size) {
-                case 0:
-                    if (round == 0) {
-                        drain(new FileInputStream("./tmp/classes/Round1Class.class"),
-                              env.getFiler().createClassFile("Round1Class"));
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-
-                case 1:
-                    if (round == 1) {
-                        drain(new FileInputStream("./tmp/classes/AhOneClass.class"),
-                              env.getFiler().createClassFile("AhOneClass"));
-
-                        drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"),
-                              env.getFiler().createClassFile("AndAhTwoClass"));
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-                case 2:
-                    if (round != 2) {
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    }
-                    break;
-                }
-
-            } catch (java.io.IOException ioe) {
-                    throw new RuntimeException();
-                }
-
-            }
-
-    }
-}
diff --git a/test/tools/apt/Compile/ClassDeclApf2.java b/test/tools/apt/Compile/ClassDeclApf2.java
deleted file mode 100644
index e9e8346..0000000
--- a/test/tools/apt/Compile/ClassDeclApf2.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import java.io.*;
-
-import static java.util.Collections.*;
-
-/*
- * This class is used to test the the interaction of -XclassesAsDecls
- * with command line options handling.
- */
-public class ClassDeclApf2 implements AnnotationProcessorFactory {
-    static int round = -1;
-
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new ClassDeclAp(env);
-    }
-
-    private static class ClassDeclAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        ClassDeclAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        // Simple inefficient drain
-        void drain(InputStream is, OutputStream os) {
-            try {
-            while (is.available() > 0 )
-                os.write(is.read());
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-        }
-
-        public void process() {
-            int size = env.getSpecifiedTypeDeclarations().size();
-            Filer f = env.getFiler();
-
-            try {
-                round++;
-                switch (size) {
-                case 3:
-                    if (round == 0) {
-                        drain(new FileInputStream("./tmp/classes/Round1Class.class"),
-                              f.createClassFile("Round1Class"));
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-
-                case 1:
-                    if (round == 1) {
-                        f.createSourceFile("AhOne").println("public class AhOne {}");
-                        System.out.println("Before writing AndAhTwoClass");
-                        drain(new FileInputStream("./tmp/classes/AndAhTwoClass.class"),
-                              f.createClassFile("AndAhTwoClass"));
-                        System.out.println("After writing AndAhTwoClass");
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-
-                case 2:
-                    if (round != 2) {
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    }
-                    break;
-                default:
-                    throw new RuntimeException("Unexpected number of declarations:" + size +
-                                               "\n Specified:" + env.getSpecifiedTypeDeclarations() +
-                                               "\n Included:" + env.getTypeDeclarations() );
-                }
-
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-        }
-    }
-}
diff --git a/test/tools/apt/Compile/Dummy1.java b/test/tools/apt/Compile/Dummy1.java
deleted file mode 100644
index 2ff1e12..0000000
--- a/test/tools/apt/Compile/Dummy1.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
- at Round1 class Dummy1{}
diff --git a/test/tools/apt/Compile/ErrorAPF.java b/test/tools/apt/Compile/ErrorAPF.java
deleted file mode 100644
index 4db5cbd..0000000
--- a/test/tools/apt/Compile/ErrorAPF.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Construct a processor that does nothing but report an error.
- */
-public class ErrorAPF implements AnnotationProcessorFactory {
-    static class ErrorAP implements AnnotationProcessor {
-        AnnotationProcessorEnvironment env;
-        ErrorAP(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            Messager messager = env.getMessager();
-            messager.printError("It's a mad, mad, mad, mad world");
-            messager.printError("Something wicked this way comes");
-
-            for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations())
-                messager.printError(typeDecl.getPosition(), "Boring class name");
-        }
-    }
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new ErrorAP(env);
-    }
-}
diff --git a/test/tools/apt/Compile/HelloAnnotation.java b/test/tools/apt/Compile/HelloAnnotation.java
deleted file mode 100644
index 2350e4c..0000000
--- a/test/tools/apt/Compile/HelloAnnotation.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/* /nodynamiccopyright/ */
-import java.lang.annotation.*;
- at Target(ElementType.ANNOTATION_TYPE)
- at Retention(RetentionPolicy.RUNTIME)
- at HelloAnnotation
- at interface HelloAnnotation {
-    Target value() default @Target(ElementType.METHOD);
-}
diff --git a/test/tools/apt/Compile/HelloWorld.java b/test/tools/apt/Compile/HelloWorld.java
deleted file mode 100644
index a6883ce..0000000
--- a/test/tools/apt/Compile/HelloWorld.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/* /nodynamiccopyright/ */
-public class HelloWorld {
-    public static void main(String argv[]) {
-        System.out.println("Hello World.");
-    }
-}
diff --git a/test/tools/apt/Compile/Round1Apf.java b/test/tools/apt/Compile/Round1Apf.java
deleted file mode 100644
index e8d5f28..0000000
--- a/test/tools/apt/Compile/Round1Apf.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import java.io.File;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Factory to help test updated discovery policy.
- */
-public class Round1Apf implements AnnotationProcessorFactory {
-    // Process @Round1
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("Round1"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    private static int round = 0;
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new Round1Ap(env, atds.size() == 0);
-    }
-
-    private static class Round1Ap implements AnnotationProcessor, RoundCompleteListener {
-        private final AnnotationProcessorEnvironment env;
-        private final boolean empty;
-
-        Round1Ap(AnnotationProcessorEnvironment env, boolean empty) {
-            this.env = env;
-            this.empty = empty;
-        }
-
-        public void process() {
-            Round1Apf.round++;
-            try {
-                if (!empty) {
-                    Filer f = env.getFiler();
-                    f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}");
-                    f.createTextFile(Filer.Location.SOURCE_TREE,
-                                     "",
-                                     new File("foo.txt"),
-                                     null).println("xxyzzy");
-                    f.createClassFile("Vacant");
-                    f.createBinaryFile(Filer.Location.CLASS_TREE,
-                                       "",
-                                       new File("onezero"));
-                }
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-
-            System.out.println("Round1Apf: " + round);
-            env.addListener(this);
-        }
-
-        public void roundComplete(RoundCompleteEvent event) {
-            RoundState rs = event.getRoundState();
-
-            if (event.getSource() != this.env)
-                throw new RuntimeException("Wrong source!");
-
-            Filer f = env.getFiler();
-            try {
-                f.createSourceFile("AfterTheBell").println("@Round2 class AfterTheBell{}");
-                throw new RuntimeException("Inappropriate source file creation.");
-            } catch (java.io.IOException ioe) {}
-
-
-            System.out.printf("\t[final round: %b, error raised: %b, "+
-                              "source files created: %b, class files created: %b]%n",
-                              rs.finalRound(),
-                              rs.errorRaised(),
-                              rs.sourceFilesCreated(),
-                              rs.classFilesCreated());
-
-            System.out.println("Round1Apf: " + round + " complete");
-        }
-    }
-}
diff --git a/test/tools/apt/Compile/Round2Apf.java b/test/tools/apt/Compile/Round2Apf.java
deleted file mode 100644
index 719a735..0000000
--- a/test/tools/apt/Compile/Round2Apf.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import java.io.IOException;
-import java.io.File;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Factory to help test updated discovery policy.
- */
-public class Round2Apf implements AnnotationProcessorFactory {
-    // Process @Round2
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("Round2"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    private static int round = 0;
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new Round2Ap(env, atds.size() == 0);
-    }
-
-    private static class Round2Ap implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        private final boolean empty;
-
-        Round2Ap(AnnotationProcessorEnvironment env, boolean empty) {
-            this.env = env;
-            this.empty = empty;
-        }
-
-        public void process() {
-            Round2Apf.round++;
-            Filer f = env.getFiler();
-            try {
-                f.createSourceFile("Dummy2").println("@Round2 class Dummy2{}");
-                throw new RuntimeException("Duplicate file creation allowed");
-            } catch (IOException io) {}
-
-            try {
-                f.createTextFile(Filer.Location.SOURCE_TREE,
-                                 "",
-                                 new File("foo.txt"),
-                                 null).println("xxyzzy");
-                throw new RuntimeException("Duplicate file creation allowed");
-            } catch (IOException io) {}
-
-            try {
-                f.createClassFile("Vacant");
-                throw new RuntimeException("Duplicate file creation allowed");
-            } catch (IOException io) {}
-
-            try {
-                f.createBinaryFile(Filer.Location.CLASS_TREE,
-                                   "",
-                                   new File("onezero"));
-                throw new RuntimeException("Duplicate file creation allowed");
-            } catch (IOException io) {}
-
-
-
-            try {
-                if (!empty) {
-                    // Create corresponding files of opposite kind to
-                    // the files created by Round1Apf; these should
-                    // only generate warnings
-                    f.createClassFile("Dummy2");
-                    f.createSourceFile("Vacant").println("class Vacant{}");
-
-                    f.createSourceFile("Dummy3").println("@Round3 class Dummy3{}");
-
-                    // This should generated a warning too
-                    f.createClassFile("Dummy3");
-                }
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-
-            System.out.println("Round2Apf: " + round);
-        }
-    }
-}
diff --git a/test/tools/apt/Compile/Round3Apf.java b/test/tools/apt/Compile/Round3Apf.java
deleted file mode 100644
index 65c30a4..0000000
--- a/test/tools/apt/Compile/Round3Apf.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Factory to help test updated discovery policy.
- */
-public class Round3Apf implements AnnotationProcessorFactory {
-    // Process @Round3
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("Round3"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    private static int round = 0;
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new Round3Ap(env, atds.size() == 0);
-    }
-
-    private static class Round3Ap implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        private final boolean empty;
-
-        Round3Ap(AnnotationProcessorEnvironment env, boolean empty) {
-            this.env = env;
-            this.empty = empty;
-        }
-
-        public void process() {
-            Round3Apf.round++;
-            try {
-                if (!empty)
-                    env.getFiler().createSourceFile("Dummy4").println("@Round4 class Dummy4{}");
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-
-            System.out.println("Round3Apf: " + round);
-        }
-    }
-}
diff --git a/test/tools/apt/Compile/Round4Apf.java b/test/tools/apt/Compile/Round4Apf.java
deleted file mode 100644
index 425e326..0000000
--- a/test/tools/apt/Compile/Round4Apf.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Factory to help test updated discovery policy.
- */
-public class Round4Apf implements AnnotationProcessorFactory {
-    // Process @Round4
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("Round4"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    private static int round = 0;
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new Round4Ap(env, atds.size() == 0);
-    }
-
-    private static class Round4Ap implements AnnotationProcessor, RoundCompleteListener {
-        private final AnnotationProcessorEnvironment env;
-        private final boolean empty;
-
-        Round4Ap(AnnotationProcessorEnvironment env, boolean empty) {
-            this.env = env;
-            this.empty = empty;
-        }
-
-        public void process() {
-            Round4Apf.round++;
-            try {
-                if (!empty)
-                    env.getFiler().createSourceFile("Dummy5").println("@Round5 class Dummy5{}");
-            } catch (java.io.IOException ioe) {
-                throw new RuntimeException(ioe);
-            }
-
-            System.out.println("Round4Apf: " + round);
-            env.addListener(this);
-        }
-
-        public void roundComplete(RoundCompleteEvent event) {
-            RoundState rs = event.getRoundState();
-
-            System.out.println("\t" + rs.toString());
-
-            System.out.println("Round4Apf: " + round + " complete");
-
-            if (rs.finalRound()) {
-                System.out.println("Valediction");
-            }
-        }
-    }
-}
diff --git a/test/tools/apt/Compile/Rounds.java b/test/tools/apt/Compile/Rounds.java
deleted file mode 100644
index daabd41..0000000
--- a/test/tools/apt/Compile/Rounds.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
- at interface Round1{}
-
- at interface Round2{}
-
- at interface Round3{}
-
- at interface Round4{}
-
- at interface Round5{}
diff --git a/test/tools/apt/Compile/StaticApf.java b/test/tools/apt/Compile/StaticApf.java
deleted file mode 100644
index 7301616..0000000
--- a/test/tools/apt/Compile/StaticApf.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-
-/*
- * This class is used to test the ability to store static state across
- * apt rounds.
- */
-public class StaticApf implements AnnotationProcessorFactory {
-    static int round = -1;
-
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new StaticAp(env);
-    }
-
-    private static class StaticAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        StaticAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            int size = env.getSpecifiedTypeDeclarations().size();
-
-            try {
-                round++;
-                switch (size) {
-                case 0:
-                    if (round == 0) {
-                        env.getFiler().createSourceFile("Round1").print("class Round1 {}");
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-
-                case 1:
-                    if (round == 1) {
-                        env.getFiler().createSourceFile("AhOne").print("class AhOne {}");
-                        env.getFiler().createSourceFile("AndAhTwo").print("class AndAhTwo {}");
-                        env.getFiler().createClassFile("Foo");
-                    } else
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    break;
-                case 2:
-                    if (round != 2) {
-                        throw new RuntimeException("Got " + size + " decl's in round " + round);
-                    }
-                    break;
-                }
-
-            } catch (java.io.IOException ioe) {
-                    throw new RuntimeException();
-                }
-
-            }
-
-    }
-}
diff --git a/test/tools/apt/Compile/WarnAPF.java b/test/tools/apt/Compile/WarnAPF.java
deleted file mode 100644
index 0d7b474..0000000
--- a/test/tools/apt/Compile/WarnAPF.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Map;
-import java.util.Arrays;
-
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Construct a processor that does nothing but report a warning.
- */
-public class WarnAPF implements AnnotationProcessorFactory {
-    static class WarnAP implements AnnotationProcessor {
-        AnnotationProcessorEnvironment env;
-        WarnAP(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            Messager messager = env.getMessager();
-            messager.printWarning("Beware the ides of March!");
-
-            for(TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) {
-                messager.printNotice(typeDecl.getPosition(),  "You are about to be warned");
-                messager.printWarning(typeDecl.getPosition(), "Strange class name");
-
-                for(AnnotationMirror annotMirror : typeDecl.getAnnotationMirrors()) {
-                    messager.printNotice("MIRROR " + annotMirror.getPosition().toString());
-
-                     Map<AnnotationTypeElementDeclaration,AnnotationValue> map =
-                         annotMirror.getElementValues();
-                     if (map.keySet().size() > 0)
-                         for(AnnotationTypeElementDeclaration key : map.keySet() ) {
-                             AnnotationValue annotValue = map.get(key);
-                             Object o = annotValue.getValue();
-                             // asserting getPosition is non-null
-                             messager.printNotice("VALUE " + annotValue.getPosition().toString());
-                         }
-                     else {
-                         Collection<AnnotationTypeElementDeclaration> ateds =
-                         annotMirror.getAnnotationType().getDeclaration().getMethods();
-                         for(AnnotationTypeElementDeclaration ated : ateds ) {
-                             AnnotationValue annotValue = ated.getDefaultValue();
-                             Object o = annotValue.getValue();
-                             messager.printNotice("VALUE " + "HelloAnnotation.java:5");
-                         }
-                     }
-                }
-            }
-        }
-    }
-
-    static final Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = unmodifiableCollection(Arrays.asList(types));
-    }
-    public Collection<String> supportedAnnotationTypes() {return supportedTypes;}
-
-    static final Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = unmodifiableCollection(Arrays.asList(options));
-    }
-    public Collection<String> supportedOptions() {return supportedOptions;}
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new WarnAP(env);
-    }
-}
diff --git a/test/tools/apt/Compile/WrappedStaticApf.java b/test/tools/apt/Compile/WrappedStaticApf.java
deleted file mode 100644
index d55bc53..0000000
--- a/test/tools/apt/Compile/WrappedStaticApf.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.AnnotationProcessorFactory;
-
-/*
- * Pass an instantiated StaticApf object to the
- * com.sun.tools.apt.Main.process entry point.
- */
-public class WrappedStaticApf {
-    public static void main(String argv[]) {
-        AnnotationProcessorFactory factory = new StaticApf();
-        System.exit(com.sun.tools.apt.Main.process(factory, argv));
-    }
-}
diff --git a/test/tools/apt/Compile/compile.sh b/test/tools/apt/Compile/compile.sh
deleted file mode 100644
index bba4130..0000000
--- a/test/tools/apt/Compile/compile.sh
+++ /dev/null
@@ -1,533 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 5033855 4990902 5023880 5043516 5048534 5048535 5041279 5048539 5067261 5068145 5023881 4996963 5095716 6191667 6433634
-# @run shell ../verifyVariables.sh
-# @build ErrorAPF
-# @build WarnAPF
-# @build StaticApf
-# @build ClassDeclApf
-# @build ClassDeclApf2
-# @build Rounds
-# @build Round1Apf Round2Apf Round3Apf Round4Apf
-# @build WrappedStaticApf
-# @run shell compile.sh
-# @summary Test simple usages of apt, including delegating to javac
-# @author Joseph D. Darcy
-
-# If the file *does* exist, exit with an error
-TestNoFile() {
-        if [ -f ${1} ]; then
-                printf "%s\n" "File ${1} found."
-                exit 1
-        fi
-}
-
-# If the file does not exist, exit with an error
-TestFile() {
-        if [ ! -f ${1} ]; then
-                printf "%s\n" "File ${1} not found."
-                exit 1
-        fi
-}
-
-
-OS=`uname -s`;
-case "${OS}" in
-        Windows* )
-                SEP=";"
-        ;;
-
-        CYGWIN* )
-		DIFFOPTS="--strip-trailing-cr"
-                SEP=";"
-        ;;
-
-        * )
-        SEP=":"
-        ;;
-esac
-
-
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message "
-JAVA="${TESTJAVA}/bin/java ${TESTVMOPTS} "
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} "
-
-unset CLASSPATH
-
-
-# ---------------------------------------------------------------
-echo "Verify that source 1.6 is not supported
-rm -f HelloWorld.class
-
-printf "%s\n" "-source 1.6"     > options0
-printf "%s\n" "${TESTSRC}/HelloWorld.java"  >> options0
-${APT} @options0
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        echo "FAILED: accepted source 1.6"
-	exit 1
-        ;;
-esac
-
-TestNoFile "HelloWorld.class"
-
-# ---------------------------------------------------------------
-
-echo "Verify that target 1.6 is not supported
-rm -f HelloWorld.class
-
-printf "%s\n" "-target 1.6"     > options00
-printf "%s\n" "${TESTSRC}/HelloWorld.java"  >> options00
-${APT} @options00
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        echo "FAILED: accepted target 1.6"
-	exit 1
-        ;;
-esac
-
-TestNoFile "HelloWorld.class"
-
-# ---------------------------------------------------------------
-
-echo "Testing javac pass-through with -A in options file"
-rm -f HelloWorld.class
-
-printf "%s\n" "-A"     > options1
-printf "%s\n" "-d ."     >> options1
-printf "%s\n" "${TESTSRC}/HelloWorld.java"  >> options1
-${APT} @options1
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: javac with -A in options file did not compile"
-        exit 1
-esac
-TestFile "HelloWorld.class"
-
-
-# ---------------------------------------------------------------
-
-echo "Verifying reporting an error will prevent compilation"
-rm -f HelloWorld.class
-if [ ! -f HelloWorld.java ]; then
-	cp ${TESTSRC}/HelloWorld.java .
-fi
-
-
-printf "%s\n" "-factory ErrorAPF"            > options2
-printf "%s\n" "-d ."                        >> options2
-printf "%s\n" "-cp ${TESTCLASSES}"          >> options2
-printf "%s\n" "HelloWorld.java"             >> options2
-${APT} @options2 2> output
-
-TestNoFile "HelloWorld.class"
-
-diff ${DIFFOPTS} output ${TESTSRC}/golden.txt
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: did not record expected error messages"
-        exit 1
-esac
-
-
-
-# ---------------------------------------------------------------
-
-echo "Verifying reporting a warning *won't* prevent compilation"
-
-rm -f HelloAnnotation.class
-if [ ! -f HelloAnnotation.java ]; then
-	cp ${TESTSRC}/HelloAnnotation.java .
-fi
-
-
-printf "%s\n" "-factory WarnAPF"             > options3
-printf "%s\n" "-d ."                        >> options3
-printf "%s\n" "-cp ${TESTCLASSES}"          >> options3
-printf "%s\n" "HelloAnnotation.java"        >> options3
-${APT} @options3 2> output
-
-diff ${DIFFOPTS} output ${TESTSRC}/goldenWarn.txt
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: did not record expected warning messages"
-        exit 1
-esac
-
-TestFile "HelloAnnotation.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying static state is available across apt rounds; -factory, -cp"
-
-mkdir -p ./src
-mkdir -p ./class
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-printf "%s\n" "-factory StaticApf"           > options4
-printf "%s\n" "-s ./src"                    >> options4
-printf "%s\n" "-d ./class"                  >> options4
-printf "%s\n" "-cp ${TESTCLASSES}"          >> options4
-# printf "%s\n" "-XPrintAptRounds"            >> options4
-${APT} @options4
-
-TestFile "./class/AndAhTwo.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying static state is available across apt rounds; -factory, -factorypath"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-printf "%s\n" "-factory StaticApf"           > options5
-printf "%s\n" "-s ./src"                    >> options5
-printf "%s\n" "-d ./class"                  >> options5
-printf "%s\n" "-factorypath ${TESTCLASSES}" >> options5
-# printf "%s\n" "-XPrintAptRounds"          >> options5
-${APT} @options5
-
-TestFile "./class/AndAhTwo.class"
-
-# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-# Create jar file for StaticApf
-JAR="${TESTJAVA}/bin/jar "
-mkdir -p META-INF/services
-cp ${TESTSRC}/servicesStaticApf META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTCLASSES}/StaticApf*.class .
-${JAR} cf0 staticApf.jar StaticApf*.class META-INF
-
-# ---------------------------------------------------------------
-
-echo "Verifying static state is available across apt rounds; -cp"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-printf "%s\n" "-cp staticApf.jar"           > options6
-printf "%s\n" "-s ./src"                    >> options6
-printf "%s\n" "-d ./class"                  >> options6
-printf "%s\n" "-XPrintAptRounds"          >> options6
-${APT} @options6
-
-TestFile "./class/AndAhTwo.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying static state is available across apt rounds; -factorypath"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-printf "%s\n" "-factorypath staticApf.jar"   > options7
-printf "%s\n" "-s ./src"                    >> options7
-printf "%s\n" "-d ./class"                  >> options7
-printf "%s\n" "-XPrintAptRounds"            >> options7
-${APT} @options7
-
-TestFile "./class/AndAhTwo.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying -XclassesAsDecls handles class files properly"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-mkdir -p ./tmp/classes
-
-${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AhOneClass.java ${TESTSRC}/src/AndAhTwoClass.java
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: javac failed to succesfully compile."
-        exit 1
-esac
-
-printf "%s\n" "-factorypath ${TESTCLASSES}"  > options7a
-printf "%s\n" "-factory ClassDeclApf"       >> options7a
-printf "%s\n" "-s ./src"                    >> options7a
-printf "%s\n" "-d ./class"                  >> options7a
-printf "%s\n" "-XPrintAptRounds"            >> options7a
-printf "%s\n" "-XclassesAsDecls"            >> options7a
-${APT} @options7a
-
-TestFile "./class/AndAhTwoClass.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying -XclassesAsDecls works with command-line arguments"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-rm -Rf ./tmp/classes
-
-mkdir -p ./tmp/classes
-
-${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: javac failed to succesfully compile."
-        exit 1
-esac
-
-printf "%s\n" "-factorypath ${TESTCLASSES}"  > options7b
-printf "%s\n" "-factory ClassDeclApf2"       >> options7b
-printf "%s\n" "-XPrintAptRounds"            >> options7b
-printf "%s\n" "-XclassesAsDecls"            >> options7b
-printf "%s\n" "-cp ${TESTCLASSES}"          >> options7b
-printf "%s\n" "ErrorAPF"                    >> options7b
-printf "%s\n" "WarnAPF"                     >> options7b
-printf "%s\n" "-s ./src"                    >> options7b
-printf "%s\n" "-d ./class"                  >> options7b
-printf "%s\n" "ClassDeclApf"                >> options7b
-${APT} @options7b
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: apt exited with an error code."
-        exit 1
-esac
-
-TestFile "./class/AndAhTwoClass.class"
-TestFile "./class/AhOne.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying -XclassesAsDecls works with all source files"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-rm -Rf ./tmp/classes
-
-mkdir -p ./tmp/classes
-
-${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: javac failed to succesfully compile."
-        exit 1
-esac
-
-printf "%s\n" "-factorypath ${TESTCLASSES}"      > options7c
-printf "%s\n" "-factory ClassDeclApf2"          >> options7c
-printf "%s\n" "-s ./src"                        >> options7c
-printf "%s\n" "-d ./class"                      >> options7c
-printf "%s\n" "-sourcepath ${TESTSRC}"          >> options7c
-printf "%s\n" "${TESTSRC}/HelloAnnotation.java" >> options7c
-printf "%s\n" "${TESTSRC}/HelloWorld.java"      >> options7c
-printf "%s\n" "${TESTSRC}/Dummy1.java"          >> options7c
-printf "%s\n" "-XPrintAptRounds"                >> options7c
-printf "%s\n" "-XclassesAsDecls"                >> options7c
-printf "%s\n" "-cp ${TESTCLASSES}"              >> options7c
-${APT} @options7c
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: apt exited with an error code."
-        exit 1
-esac
-
-TestFile "./class/AndAhTwoClass.class"
-TestFile "./class/AhOne.class"
-TestFile "./class/HelloWorld.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying -XclassesAsDecls works with mixed class and source files"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-rm -Rf ./tmp/classes
-
-mkdir -p ./tmp/classes
-
-${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AndAhTwoClass.java
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: javac failed to succesfully compile."
-        exit 1
-esac
-
-printf "%s\n" "-factorypath ${TESTCLASSES}"  > options7d
-printf "%s\n" "-factory ClassDeclApf2"      >> options7d
-printf "%s\n" "-s ./src"                    >> options7d
-printf "%s\n" "-XclassesAsDecls"            >> options7d
-printf "%s\n" "ClassDeclApf"                >> options7d
-printf "%s\n" "-d ./class"                  >> options7d
-printf "%s\n" "ErrorAPF"                    >> options7d
-printf "%s\n" "-XPrintAptRounds"            >> options7d
-printf "%s\n" "${TESTSRC}/HelloWorld.java"  >> options7d
-printf "%s\n" "-cp ${TESTCLASSES}"          >> options7d
-${APT} @options7d
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: apt exited with an error code."
-        exit 1
-esac
-
-TestFile "./class/AndAhTwoClass.class"
-TestFile "./class/AhOne.class"
-TestFile "./class/HelloWorld.class"
-
-# ---------------------------------------------------------------
-
-echo "Testing productive factories are called on subsequent rounds"
-
-rm -Rf ./src/*
-rm -Rf ./class/*
-
-rm -Rf META-INF/services/*
-cp ${TESTSRC}/servicesRound1 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTCLASSES}/Round1Apf*.class .
-${JAR} cf0 round1Apf.jar Round1Apf*.class META-INF
-
-rm -Rf META-INF/services/*
-cp ${TESTSRC}/servicesRound2 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTCLASSES}/Round2Apf*.class .
-${JAR} cf0 round2Apf.jar Round2Apf*.class META-INF
-
-rm -Rf META-INF/services/*
-cp ${TESTSRC}/servicesRound3 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTCLASSES}/Round3Apf*.class .
-${JAR} cf0 round3Apf.jar Round3Apf*.class META-INF
-
-rm -Rf META-INF/services/*
-cp ${TESTSRC}/servicesRound4 META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTCLASSES}/Round4Apf*.class .
-${JAR} cf0 round4Apf.jar Round4Apf*.class META-INF
-
-cp ${TESTCLASSES}/Round?.class .
-${JAR} cf0 rounds.jar Round?.class
-
-# cleanup file to prevent accidental discovery in current directory
-rm -Rf META-INF/services/*
-
-printf "%s\n" "-factorypath round1Apf.jar${SEP}round2Apf.jar${SEP}round3Apf.jar${SEP}round4Apf.jar"   > options8
-printf "%s\n" "-classpath rounds.jar"  >> options8
-printf "%s\n" "-s ./src"               >> options8
-printf "%s\n" "-d ./class"             >> options8
-#printf "%s\n" "-XPrintFactoryInfo"     >> options8
-#printf "%s\n" "-XPrintAptRounds"       >> options8
-printf "%s\n" "${TESTSRC}/Dummy1.java" >> options8
-${APT} @options8 > multiRoundOutput 2> multiRoundError
-
-diff ${DIFFOPTS} multiRoundOutput  ${TESTSRC}/goldenFactory.txt
-
-RESULT=$?
-case "$RESULT" in
-	0  )
-        ;;
-
-        * )
-        echo "FAILED: unexpected factory state"
-        exit 1
-esac
-
-TestFile "./class/Dummy5.class"
-
-# ---------------------------------------------------------------
-
-echo "Verifying static state with programmatic apt entry; no factory options"
-rm -Rf ./src/*
-rm -Rf ./class/*
-${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -s ./src -d ./class -XPrintAptRounds
-TestFile "./class/AndAhTwo.class"
-
-echo "Verifying static state with programmatic apt entry; -factory"
-rm -Rf ./src/*
-rm -Rf ./class/*
-${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factory ErrorAPF -s ./src -d ./class -XPrintAptRounds
-TestFile "./class/AndAhTwo.class"
-
-echo "Verifying static state with programmatic apt entry; -factorypath"
-rm -Rf ./src/*
-rm -Rf ./class/*
-${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -s ./src -d ./class -XPrintAptRounds
-TestFile "./class/AndAhTwo.class"
-
-echo "Verifying static state with programmatic apt entry; -factory and -factorypath"
-rm -Rf ./src/*
-rm -Rf ./class/*
-${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -factory Round1Apf -s ./src -d ./class -XPrintAptRounds
-TestFile "./class/AndAhTwo.class"
-
-exit 0
diff --git a/test/tools/apt/Compile/golden.txt b/test/tools/apt/Compile/golden.txt
deleted file mode 100644
index 180efe2..0000000
--- a/test/tools/apt/Compile/golden.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-error: It's a mad, mad, mad, mad world
-error: Something wicked this way comes
-HelloWorld.java:2: error: Boring class name
-public class HelloWorld {
-       ^
-3 errors
diff --git a/test/tools/apt/Compile/goldenFactory.txt b/test/tools/apt/Compile/goldenFactory.txt
deleted file mode 100644
index b849898..0000000
--- a/test/tools/apt/Compile/goldenFactory.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-Round1Apf: 1
-	[final round: false, error raised: false, source files created: true, class files created: true]
-Round1Apf: 1 complete
-Round1Apf: 2
-Round2Apf: 1
-	[final round: false, error raised: false, source files created: true, class files created: true]
-Round1Apf: 2 complete
-Round1Apf: 3
-Round2Apf: 2
-Round3Apf: 1
-	[final round: false, error raised: false, source files created: true, class files created: false]
-Round1Apf: 3 complete
-Round1Apf: 4
-Round2Apf: 3
-Round3Apf: 2
-Round4Apf: 1
-	[final round: false, error raised: false, source files created: true, class files created: false]
-Round1Apf: 4 complete
-	[final round: false, error raised: false, source files created: true, class files created: false]
-Round4Apf: 1 complete
-Round1Apf: 5
-Round2Apf: 4
-Round3Apf: 3
-Round4Apf: 2
-	[final round: true, error raised: false, source files created: false, class files created: false]
-Round1Apf: 5 complete
-	[final round: true, error raised: false, source files created: false, class files created: false]
-Round4Apf: 2 complete
-Valediction
diff --git a/test/tools/apt/Compile/goldenWarn.txt b/test/tools/apt/Compile/goldenWarn.txt
deleted file mode 100644
index 05544cd..0000000
--- a/test/tools/apt/Compile/goldenWarn.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-warning: Beware the ides of March!
-HelloAnnotation.java:6: Note: You are about to be warned
- at interface HelloAnnotation {
- ^
-HelloAnnotation.java:6: warning: Strange class name
- at interface HelloAnnotation {
- ^
-Note: MIRROR HelloAnnotation.java:6
-Note: VALUE HelloAnnotation.java:6
-Note: MIRROR HelloAnnotation.java:6
-Note: VALUE HelloAnnotation.java:6
-Note: MIRROR HelloAnnotation.java:6
-Note: VALUE HelloAnnotation.java:5
-2 warnings
diff --git a/test/tools/apt/Compile/servicesRound1 b/test/tools/apt/Compile/servicesRound1
deleted file mode 100644
index 91ccf42..0000000
--- a/test/tools/apt/Compile/servicesRound1
+++ /dev/null
@@ -1 +0,0 @@
-Round1Apf
diff --git a/test/tools/apt/Compile/servicesRound2 b/test/tools/apt/Compile/servicesRound2
deleted file mode 100644
index bc27b2b..0000000
--- a/test/tools/apt/Compile/servicesRound2
+++ /dev/null
@@ -1 +0,0 @@
-Round2Apf
diff --git a/test/tools/apt/Compile/servicesRound3 b/test/tools/apt/Compile/servicesRound3
deleted file mode 100644
index ac0b2ee..0000000
--- a/test/tools/apt/Compile/servicesRound3
+++ /dev/null
@@ -1 +0,0 @@
-Round3Apf
diff --git a/test/tools/apt/Compile/servicesRound4 b/test/tools/apt/Compile/servicesRound4
deleted file mode 100644
index ced1da3..0000000
--- a/test/tools/apt/Compile/servicesRound4
+++ /dev/null
@@ -1 +0,0 @@
-Round4Apf
diff --git a/test/tools/apt/Compile/servicesStaticApf b/test/tools/apt/Compile/servicesStaticApf
deleted file mode 100644
index 08cf898..0000000
--- a/test/tools/apt/Compile/servicesStaticApf
+++ /dev/null
@@ -1 +0,0 @@
-StaticApf
diff --git a/test/tools/apt/Compile/src/AhOneClass.java b/test/tools/apt/Compile/src/AhOneClass.java
deleted file mode 100644
index f7d7e7e..0000000
--- a/test/tools/apt/Compile/src/AhOneClass.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public class AhOneClass {}
diff --git a/test/tools/apt/Compile/src/AndAhTwoClass.java b/test/tools/apt/Compile/src/AndAhTwoClass.java
deleted file mode 100644
index be404b0..0000000
--- a/test/tools/apt/Compile/src/AndAhTwoClass.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public class AndAhTwoClass {}
diff --git a/test/tools/apt/Compile/src/Round1Class.java b/test/tools/apt/Compile/src/Round1Class.java
deleted file mode 100644
index 40719d0..0000000
--- a/test/tools/apt/Compile/src/Round1Class.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public class Round1Class {}
diff --git a/test/tools/apt/Discovery/Dee.java b/test/tools/apt/Discovery/Dee.java
deleted file mode 100644
index bbf57a9..0000000
--- a/test/tools/apt/Discovery/Dee.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class Dee implements AnnotationProcessorFactory {
-    static class DeeProc implements AnnotationProcessor {
-        DeeProc(AnnotationProcessorEnvironment ape) {}
-
-        public void process() {
-            return;
-        }
-    }
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"dum"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new DeeProc(env);
-    }
-}
diff --git a/test/tools/apt/Discovery/Dum.java b/test/tools/apt/Discovery/Dum.java
deleted file mode 100644
index e81dd0b..0000000
--- a/test/tools/apt/Discovery/Dum.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class Dum implements AnnotationProcessorFactory {
-    static class DumProc implements AnnotationProcessor {
-        DumProc(AnnotationProcessorEnvironment ape) {}
-
-        public void process() {
-            return;
-        }
-    }
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"dee"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new DumProc(env);
-    }
-}
diff --git a/test/tools/apt/Discovery/Empty.java b/test/tools/apt/Discovery/Empty.java
deleted file mode 100644
index b46f194..0000000
--- a/test/tools/apt/Discovery/Empty.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public class Empty {
-}
diff --git a/test/tools/apt/Discovery/PhantomTouch.java b/test/tools/apt/Discovery/PhantomTouch.java
deleted file mode 100644
index 276c935..0000000
--- a/test/tools/apt/Discovery/PhantomTouch.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Collections;
-import java.io.*;
-
-public class PhantomTouch implements AnnotationProcessorFactory {
-    static class PhantomTouchProc implements AnnotationProcessor {
-        AnnotationProcessorEnvironment ape;
-        PhantomTouchProc(AnnotationProcessorEnvironment ape) {
-            this.ape = ape;
-        }
-
-        public void process() {
-            // Only run the processor on the initial apt invocation
-            if (ape.getSpecifiedTypeDeclarations().size() == 0) {
-                boolean result;
-                try {
-                    // Create temporary file
-                    java.io.File f = new java.io.File("touched");
-                    result = f.createNewFile();
-
-                    if (result) {
-                        // Create new source file
-                        PrintWriter pw = ape.getFiler().createSourceFile("HelloWorld");
-                        pw.println("public class HelloWorld {");
-                        pw.println("  // Phantom hello world");
-                        pw.println("  public static void main(String argv[]) {");
-                        pw.println("    System.out.println(\"Hello World\");");
-                        pw.println("  }");
-                        pw.println("}");
-                    } else
-                        throw new RuntimeException("touched file already exists!");
-                } catch (java.io.IOException e) {
-                    result = false;
-                }
-            }
-        }
-    }
-
-    static final Collection<String> supportedOptions;
-    static final Collection<String> supportedTypes;
-
-    static {
-        String options[] = {""};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-
-        String types[] = {"*"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    public Collection<String> supportedAnnotationTypes() {return supportedTypes;}
-    public Collection<String> supportedOptions() {return supportedOptions;}
-
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new PhantomTouchProc(env);
-    }
-}
diff --git a/test/tools/apt/Discovery/PhantomUpdate.java b/test/tools/apt/Discovery/PhantomUpdate.java
deleted file mode 100644
index 6d92358..0000000
--- a/test/tools/apt/Discovery/PhantomUpdate.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 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.
- */
-
-
-/*
- * JSR 269 annotation processor to test combined apt + JSR 269
- * annotation processor file generation and option passing.
- */
-
-import javax.annotation.processing.*;
-import static  javax.lang.model.SourceVersion.*;
-import javax.lang.model.element.*;
-import javax.lang.model.type.*;
-import javax.lang.model.util.*;
-import java.util.*;
-import java.io.*;
-
- at SupportedAnnotationTypes("*")  // Process all annotations
- at SupportedSourceVersion(RELEASE_6)
-public class PhantomUpdate extends AbstractProcessor {
-    boolean firstRound = true;
-
-    public boolean process(Set<? extends TypeElement> annotations,
-                           RoundEnvironment roundEnv) {
-        if (firstRound) {
-            verifyOptions();
-            printGoodbyeWorld();
-            firstRound = false;
-        }
-        return true; // Claim all annotations
-    }
-
-    /*
-     * Expected options are "foo" and "bar=baz".
-     */
-    private void verifyOptions() {
-        Map<String, String> actualOptions = processingEnv.getOptions();
-        Map<String, String> expectedOptions = new LinkedHashMap<String, String>();
-        expectedOptions.put("foo", null);
-        expectedOptions.put("bar", "baz");
-
-        if (!actualOptions.equals(expectedOptions) ) {
-            System.err.println("Expected options " + expectedOptions +
-                               "\n but got " + actualOptions);
-            throw new RuntimeException("Options mismatch");
-        }
-    }
-
-    private void printGoodbyeWorld() {
-        try {
-            // Create new source file
-            PrintWriter pw = new PrintWriter(processingEnv.getFiler().createSourceFile("GoodbyeWorld").openWriter());
-            pw.println("public class GoodbyeWorld {");
-            pw.println("  // PhantomUpdate Goodbye world");
-            pw.println("  public static void main(String argv[]) {");
-            pw.println("    System.out.println(\"Goodbye World\");");
-            pw.println("  }");
-            pw.println("}");
-            pw.close();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-}
diff --git a/test/tools/apt/Discovery/Touch.java b/test/tools/apt/Discovery/Touch.java
deleted file mode 100644
index 923ba55..0000000
--- a/test/tools/apt/Discovery/Touch.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Collections;
-import java.io.*;
-
-public class Touch implements AnnotationProcessorFactory {
-    static class TouchProc implements AnnotationProcessor {
-        AnnotationProcessorEnvironment ape;
-        TouchProc(AnnotationProcessorEnvironment ape) {
-            this.ape = ape;
-        }
-
-        public void process() {
-            boolean result;
-            // Only run the processor on the initial apt invocation
-            Collection<TypeDeclaration> tdecls = ape.getSpecifiedTypeDeclarations();
-
-            if (tdecls.size() == 1) {
-                for(TypeDeclaration decl: tdecls) {
-                    if (! decl.getSimpleName().equals("Touch") )
-                        return;
-                }
-
-                try {
-                    // Create temporary file
-                    java.io.File f = new java.io.File("touched");
-                    result = f.createNewFile();
-
-
-                    Filer filer = ape.getFiler();
-
-                    // Create new source file
-                    PrintWriter pw = filer.createSourceFile("HelloWorld");
-                    pw.println("public class HelloWorld {");
-                    pw.println("  public static void main(String argv[]) {");
-                    pw.println("    System.out.println(\"Hello World\");");
-                    pw.println("  }");
-                    pw.println("}");
-
-                    // Create new class file and copy Empty.class
-                    OutputStream os = filer.createClassFile("Empty");
-                    FileInputStream fis = new FileInputStream("Empty.clazz");
-                    int datum;
-                    while((datum = fis.read()) != -1)
-                        os.write(datum);
-
-                } catch (java.io.IOException e) {
-                    result = false;
-                }
-                if (!result)
-                    throw new RuntimeException("touched file already exists or other error");
-            }
-
-        }
-
-    }
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new TouchProc(env);
-    }
-}
diff --git a/test/tools/apt/Discovery/discovery.sh b/test/tools/apt/Discovery/discovery.sh
deleted file mode 100644
index 657b273..0000000
--- a/test/tools/apt/Discovery/discovery.sh
+++ /dev/null
@@ -1,410 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2008, 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 4984412 4985113 4908512 4990905 4998007 4998218 5002340 5023882 6370261 6363481
-# @run shell ../verifyVariables.sh
-# @compile PhantomUpdate.java
-# @run shell discovery.sh
-# @summary Test consistency of annotation discovery
-# @author Joseph D. Darcy
-
-
-# If the file does not exist, exit with an error
-TestFile() {
-	if [ ! -f ${1} ]; then
-		printf "%s\n" "File ${1} not found."
-		exit 1
-	fi
-}
-
-OS=`uname -s`;
-case "${OS}" in
-        Windows* | CYGWIN* )
-                SEP=";"
-        ;;
-
-	* )
-	SEP=":"
-	;;
-esac
-
-TOOLSJAR=${TESTJAVA}/lib/tools.jar
-
-OLDCP=${CLASSPATH}
-
-JARCP=tweedle.jar${SEP}touch.jar${SEP}${TOOLSJAR}
-SOURCEP=${TESTSRC}
-FULLCP=${JARCP}${SEP}${SOURCEP}
-BADCP=tweedle.jar${SEP}badTouch.jar${SEP}${TOOLSJAR}
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} "
-
-
-# Construct path to apt executable, no compilation
-APTNC="${APT} -nocompile "
-
-
-printf "%s\n" "APT = ${APT}"
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TOOLSJAR} -d . "
-JAR="${TESTJAVA}/bin/jar "
-
-$JAVAC ${TESTSRC}/Dee.java ${TESTSRC}/Dum.java ${TESTSRC}/Touch.java ${TESTSRC}/PhantomTouch.java ${TESTSRC}/Empty.java
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        ;;
-
-        * )
-        echo "Compilation failed."
-        exit 1
-esac
-
-mv Empty.class Empty.clazz
-
-echo "Making services directory and copying services information."
-mkdir -p META-INF/services
-mkdir -p phantom
-
-rm -f touch.jar
-rm -f badTouch.jar
-
-cp ${TESTSRC}/servicesTweedle META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 tweedle.jar Dee*.class Dum*.class META-INF
-
-rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTSRC}/servicesTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 touch.jar Touch*.class META-INF
-
-rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTSRC}/servicesPhantomTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 phantom/phantom.jar PhantomTouch*.class META-INF
-
-# cleanup file to prevent accidental discovery in current directory
-rm -f META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-# Jar files created; verify right output file is touched
-
-#---------------------------------------------------------
-
-# Test different combinations of classpath, sourcepath, and
-# destination directories
-
-
-#
-# Classpath on commandline; no output directories
-#
-
-rm -f touched 
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-classpath ${JARCP}"     > options1
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options1
-printf "%s\n" "${TESTSRC}/Touch.java"  >> options1
-
-${APTNC} @options1
-
-echo "Testing case 1"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# Class path set through environment variable
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-CLASSPATH=${JARCP}
-export CLASSPATH
-printf "%s\n" "-sourcepath ${SOURCEP}" > options2
-printf "%s\n" "${TESTSRC}/Touch.java" >> options2
-
-${APTNC} @options2
-
-echo "Testing case 2"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# No explicit source path
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-CLASSPATH=${FULLCP}
-export CLASSPATH
-printf "%s\n" "${TESTSRC}/Touch.java"  > options3
-
-${APTNC} @options3
-
-echo "Testing case 3"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-
-#
-# Classpath on commandline; class output directory
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -Rf classes/Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-classpath ${JARCP}"     > options4
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options4
-printf "%s\n" "-d classes"             >> options4
-printf "%s\n" "${TESTSRC}/Touch.java"  >> options4
-
-${APTNC} @options4
-
-echo "Testing case 4"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "classes/Empty.class"
-
-#
-# Classpath on commandline; source output directory
-#
-
-rm -f touched
-rm -Rf src
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-classpath ${JARCP}"     > options5
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options5
-printf "%s\n" "-s src"                 >> options5
-printf "%s\n" "${TESTSRC}/Touch.java"  >> options5
-
-${APTNC} @options5
-
-echo "Testing case 5"
-TestFile "touched"
-TestFile "src/HelloWorld.java"
-TestFile "Empty.class"
-
-
-#
-# Classpath on commandline; class and source output directory
-#
-
-rm -f touched
-rm -Rf src
-rm -Rf classes
-
-unset CLASSPATH
-printf "%s\n" "-classpath ${JARCP}"     > options6
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options6
-printf "%s\n" "-d classes"             >> options6
-printf "%s\n" "-s src"                 >> options6
-printf "%s\n" "${TESTSRC}/Touch.java"  >> options6
-
-${APTNC} @options6
-
-echo "Testing case 6"
-TestFile "touched"
-TestFile "src/HelloWorld.java"
-TestFile "classes/Empty.class"
-
-#
-# Classpath appended to bootclasspath; no output directories
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-Xbootclasspath/a:${JARCP}" > options7
-printf "%s\n" "-classpath /dev/null"      >> options7
-printf "%s\n" "${TESTSRC}/Touch.java"     >> options7
-
-${APTNC} @options7
-
-echo "Testing case 7"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# Classpath in extdirs; no output directories
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-extdirs ."              > options8
-printf "%s\n" "-classpath ${TOOLSJAR}" >> options8
-printf "%s\n" "${TESTSRC}/Touch.java"  >> options8
-
-${APTNC} @options8
-
-echo "Testing case 8"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# Classpath in extdirs, take 2; no output directories
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-Djava.ext.dirs=."        > options9
-printf "%s\n" "-classpath ${TOOLSJAR}"  >> options9
-printf "%s\n" "${TESTSRC}/Touch.java"   >> options9
-
-${APTNC} @options9
-
-echo "Testing case 9"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# Classpath in -endorseddirs; no output directories
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-printf "%s\n" "-endorseddirs ."          > options10
-printf "%s\n" "-classpath ${TOOLSJAR}"  >> options10
-printf "%s\n" "${TESTSRC}/Touch.java"   >> options10
-
-${APTNC} @options10
-
-echo "Testing case 10"
-TestFile "touched"
-TestFile "HelloWorld.java"
-TestFile "Empty.class"
-
-#
-# Testing apt invocation with no command line options
-#
-
-rm -f touched
-rm -f HelloWorld.java
-rm -f Empty.class
-
-unset CLASSPATH
-CLASSPATH=./phantom/phantom.jar
-export CLASSPATH
-
-${APT}
-
-echo "Testing empty command line"
-TestFile "touched"
-TestFile "HelloWorld.java"
-
-
-#
-# Verify apt and JSR 269 annotation processors can be run from same
-# invocation and both use the output directories
-#
-
-rm -f touched
-rm -f src/HelloWorld.java
-rm -f src/GoodbyeWorld.java
-rm -f classes/HelloWorld.class
-rm -f classes/GoodbyeWorld.class
-
-unset CLASSPATH
-
-
-printf "%s\n" "-classpath ./phantom/phantom.jar" > options11
-printf "%s\n" "-sourcepath ${SOURCEP}"          >> options11
-printf "%s\n" "-factory PhantomTouch "          >> options11
-printf "%s\n" "-s src"                          >> options11
-printf "%s\n" "-d classes"                      >> options11
-printf "%s\n" "-A"             	                >> options11
-printf "%s\n" "-Afoo"          	                >> options11
-printf "%s\n" "-Abar=baz"      	                >> options11
-printf "%s\n" "-processorpath $TESTCLASSES"     >> options11
-printf "%s\n" "-processor PhantomUpdate"        >> options11
-
-${APT} @options11
-
-echo "Testing combined apt and JSR 269 processing"
-TestFile touched
-TestFile "src/HelloWorld.java"
-TestFile "src/GoodbyeWorld.java"
-TestFile "classes/HelloWorld.class"
-TestFile "classes/GoodbyeWorld.class"
-
-#
-# Verify running with badTouch doesn't exit successfully
-#
-
-rm -f ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-cp ${TESTSRC}/servicesBadTouch ./META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 badTouch.jar Touch*.class META-INF
-
-
-unset CLASSPATH
-printf "%s\n" "-classpath ${BADCP}"     > optionsBad
-printf "%s\n" "-sourcepath ${SOURCEP}" >> optionsBad
-printf "%s\n" "${TESTSRC}/Touch.java"  >> optionsBad
-
-${APTNC} @optionsBad 2> /dev/null
-
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-	echo "Improper exit zero with bad services information."
-	exit 1
-        ;;
-esac
-
-
-exit 0;
diff --git a/test/tools/apt/Discovery/servicesBadTouch b/test/tools/apt/Discovery/servicesBadTouch
deleted file mode 100644
index ebb545f..0000000
--- a/test/tools/apt/Discovery/servicesBadTouch
+++ /dev/null
@@ -1 +0,0 @@
-Touche
diff --git a/test/tools/apt/Discovery/servicesPhantomTouch b/test/tools/apt/Discovery/servicesPhantomTouch
deleted file mode 100644
index 2a25069..0000000
--- a/test/tools/apt/Discovery/servicesPhantomTouch
+++ /dev/null
@@ -1 +0,0 @@
-PhantomTouch
diff --git a/test/tools/apt/Discovery/servicesTouch b/test/tools/apt/Discovery/servicesTouch
deleted file mode 100644
index b0d2d43..0000000
--- a/test/tools/apt/Discovery/servicesTouch
+++ /dev/null
@@ -1 +0,0 @@
-Touch
diff --git a/test/tools/apt/Discovery/servicesTweedle b/test/tools/apt/Discovery/servicesTweedle
deleted file mode 100644
index b2e6b8e..0000000
--- a/test/tools/apt/Discovery/servicesTweedle
+++ /dev/null
@@ -1,2 +0,0 @@
-Dee
-Dum
diff --git a/test/tools/apt/Misc/Marked.java b/test/tools/apt/Misc/Marked.java
deleted file mode 100644
index d7f73f0..0000000
--- a/test/tools/apt/Misc/Marked.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-class Marked {
-
-    @Marker
-        class marked1 {};
-
-
-    class Unmarked1 {};
-
-    @Marker
-        class marked2 {};
-
-
-    class Unmarked2 {};
-
-    @Marker
-        class marked3 {};
-
-
-    class Unmarked3 {};
-
-    @Marker
-        class marked4 {};
-
-
-    class Unmarked4 {};
-
-}
diff --git a/test/tools/apt/Misc/Marker.java b/test/tools/apt/Misc/Marker.java
deleted file mode 100644
index 9631bd8..0000000
--- a/test/tools/apt/Misc/Marker.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public @interface Marker {}
diff --git a/test/tools/apt/Misc/Misc.java b/test/tools/apt/Misc/Misc.java
deleted file mode 100644
index f18c4ab..0000000
--- a/test/tools/apt/Misc/Misc.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class Misc implements AnnotationProcessorFactory {
-    static class MiscCheck implements AnnotationProcessor {
-        AnnotationProcessorEnvironment ape;
-        MiscCheck(AnnotationProcessorEnvironment ape) {
-            this.ape = ape;
-        }
-
-        public void process() {
-            Collection<Declaration> decls = ape.
-                getDeclarationsAnnotatedWith((AnnotationTypeDeclaration)
-                                             ape.getTypeDeclaration("Marker"));
-
-            // Should write more robust test that examines the
-            // annotation mirrors for the declaration in question.
-            for(Declaration decl: decls) {
-                if (!decl.getSimpleName().startsWith("marked") )
-                    throw new RuntimeException();
-            }
-        }
-    }
-
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    Collection<String> supportedOptions =
-        Collections.unmodifiableCollection(new HashSet<String>());
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment ape) {
-        return new MiscCheck(ape);
-    }
-}
diff --git a/test/tools/apt/Misc/misc.sh b/test/tools/apt/Misc/misc.sh
deleted file mode 100644
index 51303e6..0000000
--- a/test/tools/apt/Misc/misc.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2007, 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 5007250
-# @run shell ../verifyVariables.sh
-# @run shell misc.sh
-# @summary Miscelleneous tests
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        Windows* | CYGWIN* )
-                SEP=";"
-        ;;
-
-	* )
-	SEP=":"
-	;;
-esac
-
-JARCP=misc.jar
-SOURCEP=${TESTSRC}
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile "
-
-printf "%s\n" "APT = ${APT}"
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-JAR="${TESTJAVA}/bin/jar "
-
-${JAVAC} ${TESTSRC}/Misc.java ${TESTSRC}/Marked.java 
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        ;;
-
-        * )
-        echo "Compilation failed."
-        exit 1
-esac
-
-
-echo "Making services directory and copying services information."
-mkdir -p META-INF/services
-
-cp ${TESTSRC}/servicesMisc META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 misc.jar Misc*.class META-INF
-
-# Jar files created; verify options properly present on both initial
-# and recursive apt runs
-
-#---------------------------------------------------------
-
-unset CLASSPATH
-
-printf "%s\n" "-classpath ${JARCP}"     > options
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options
-printf "%s\n" "${TESTSRC}/Marked.java" >> options
-
-${APT} @options
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	;;	
-	
-	* )
-	echo "Problem with result"
-	exit 1
-        ;;
-esac
-
-exit 0;
diff --git a/test/tools/apt/Misc/servicesMisc b/test/tools/apt/Misc/servicesMisc
deleted file mode 100644
index 62e7db4..0000000
--- a/test/tools/apt/Misc/servicesMisc
+++ /dev/null
@@ -1,2 +0,0 @@
-Misc
-
diff --git a/test/tools/apt/Options/Marked.java b/test/tools/apt/Options/Marked.java
deleted file mode 100644
index ae0e6b5..0000000
--- a/test/tools/apt/Options/Marked.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
- at Marker
-class Marked {
-}
diff --git a/test/tools/apt/Options/Marker.java b/test/tools/apt/Options/Marker.java
deleted file mode 100644
index 9631bd8..0000000
--- a/test/tools/apt/Options/Marker.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public @interface Marker {}
diff --git a/test/tools/apt/Options/OptionChecker.java b/test/tools/apt/Options/OptionChecker.java
deleted file mode 100644
index 9d0a324..0000000
--- a/test/tools/apt/Options/OptionChecker.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Map;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class OptionChecker implements AnnotationProcessorFactory {
-    static class OptionCheck implements AnnotationProcessor {
-        AnnotationProcessorEnvironment ape;
-        OptionCheck(AnnotationProcessorEnvironment ape) {
-            this.ape = ape;
-        }
-
-        public void process() {
-            Map<String, String> options = ape.getOptions();
-            if (options.containsKey("-Afoo") &&
-                options.containsKey("-Abar") &&
-                options.containsKey("-classpath") ) {
-                System.out.println("Expected options found.");
-                return;  // All is well
-            } else {
-                System.err.println("Unexpected options values: " + options);
-                throw new RuntimeException();
-            }
-        }
-    }
-
-    static class HelloWorld implements AnnotationProcessor {
-        AnnotationProcessorEnvironment ape;
-        HelloWorld(AnnotationProcessorEnvironment ape) {
-            this.ape = ape;
-        }
-
-        public void process() {
-            java.io.PrintWriter pw;
-            try {
-                pw = ape.getFiler().createSourceFile("HelloWorld");
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-
-            pw.println("public class HelloWorld {");
-            pw.println("  public static void main (String argv[]) {");
-            pw.println("    System.out.println(\"Hello apt world.\");");
-            pw.println("  }");
-            pw.println("}");
-        }
-    }
-
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {"-Afoo", "-Abar"};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment ape) {
-
-        if (atds.contains(ape.getTypeDeclaration("Marker"))) {
-            System.out.println("Returning composite processor.");
-            return AnnotationProcessors.getCompositeAnnotationProcessor(new OptionCheck(ape),
-                                                                        new HelloWorld(ape));
-        }
-        else {
-            System.out.println("Returning single processor.");
-            return new OptionCheck(ape);
-        }
-    }
-}
diff --git a/test/tools/apt/Options/options.sh b/test/tools/apt/Options/options.sh
deleted file mode 100644
index 4f1aba1..0000000
--- a/test/tools/apt/Options/options.sh
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2007, 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 4993950 4993277
-# @run shell ../verifyVariables.sh
-# @run shell options.sh
-# @summary Test availabilty of command line options in processors
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        Windows* | CYGWIN* )
-                SEP=";"
-        ;;
-
-	* )
-	SEP=":"
-	;;
-esac
-
-JARCP=option.jar
-SOURCEP=${TESTSRC}
-
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile "
-
-printf "%s\n" "APT = ${APT}"
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-JAR="${TESTJAVA}/bin/jar "
-
-${JAVAC} ${TESTSRC}/OptionChecker.java
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        ;;
-
-        * )
-        echo "Compilation failed."
-        exit 1
-esac
-
-
-echo "Making services directory and copying services information."
-mkdir -p META-INF/services
-
-cp ${TESTSRC}/servicesOptions META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 option.jar OptionChecker*.class META-INF
-
-# Jar files created; verify options properly present on both initial
-# and recursive apt runs
-
-#---------------------------------------------------------
-
-unset CLASSPATH
-
-printf "%s\n" "-classpath ${JARCP}"     > options
-printf "%s\n" "-sourcepath ${SOURCEP}" >> options
-printf "%s\n" "${TESTSRC}/Marked.java" >> options
-
-${APT} @options
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	echo "Failed to indentify missing options"
-	exit 1
-	;;	
-	
-	* )
-        ;;
-esac
-
-printf "%s\n" "-Afoo -Abar" >> options
-
-${APT} @options
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	;;	
-	
-	* )
-	echo "Options not found properly."
-	exit 1
-        ;;
-esac
-
-exit 0;
diff --git a/test/tools/apt/Options/servicesOptions b/test/tools/apt/Options/servicesOptions
deleted file mode 100644
index 8cf2db2..0000000
--- a/test/tools/apt/Options/servicesOptions
+++ /dev/null
@@ -1 +0,0 @@
-OptionChecker
diff --git a/test/tools/apt/Scanners/Counter.java b/test/tools/apt/Scanners/Counter.java
deleted file mode 100644
index e7b4e69..0000000
--- a/test/tools/apt/Scanners/Counter.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * Used to verify counts from different kinds of declaration scanners.
- */
-public class Counter implements AnnotationProcessorFactory {
-    static class CounterProc implements AnnotationProcessor {
-        static class CountingVisitor extends SimpleDeclarationVisitor {
-            int count;
-            int count() {
-                return count;
-            }
-
-            CountingVisitor() {
-                count = 0;
-            }
-
-            public void visitDeclaration(Declaration d) {
-                count++;
-                System.out.println(d.getSimpleName());
-            }
-        }
-
-        AnnotationProcessorEnvironment env;
-        CounterProc(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        public void process() {
-            for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) {
-                CountingVisitor sourceOrder = new CountingVisitor();
-                CountingVisitor someOrder = new CountingVisitor();
-
-                System.out.println("Source Order Scanner");
-                td.accept(getSourceOrderDeclarationScanner(sourceOrder,
-                                                           NO_OP));
-
-                System.out.println("\nSome Order Scanner");
-                td.accept(getDeclarationScanner(someOrder,
-                                                NO_OP));
-
-                if (sourceOrder.count() != someOrder.count() )
-                    throw new RuntimeException("Counts from different scanners don't agree");
-            }
-
-        }
-    }
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                               AnnotationProcessorEnvironment env) {
-        return new CounterProc(env);
-    }
-
-}
diff --git a/test/tools/apt/Scanners/MemberOrderApf.java b/test/tools/apt/Scanners/MemberOrderApf.java
deleted file mode 100644
index 51108ae..0000000
--- a/test/tools/apt/Scanners/MemberOrderApf.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Arrays;
-
-import static java.util.Collections.*;
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-/*
- * The processor of this factory verifies class members are returned
- * in source-code order.
- */
-public class MemberOrderApf implements AnnotationProcessorFactory {
-    // Process any set of annotations
-    private static final Collection<String> supportedAnnotations
-        = unmodifiableCollection(Arrays.asList("*"));
-
-    // No supported options
-    private static final Collection<String> supportedOptions = emptySet();
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedAnnotations;
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public AnnotationProcessor getProcessorFor(
-            Set<AnnotationTypeDeclaration> atds,
-            AnnotationProcessorEnvironment env) {
-        return new MemberOrderAp(env);
-    }
-
-    private static class MemberOrderAp implements AnnotationProcessor {
-        private final AnnotationProcessorEnvironment env;
-        MemberOrderAp(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        private void verifyOrder(Collection<? extends Declaration> decls) {
-            int count = 0;
-            for(Declaration decl: decls) {
-                VisitOrder order = decl.getAnnotation(VisitOrder.class);
-                if (order.value() <= count)
-                    throw new RuntimeException("Out of order declarations");
-                count = order.value();
-            }
-        }
-
-        public void process() {
-            for(TypeDeclaration td: env.getSpecifiedTypeDeclarations()) {
-                verifyOrder(td.getFields());
-                verifyOrder(td.getMethods());
-            }
-        }
-    }
-}
diff --git a/test/tools/apt/Scanners/Order.java b/test/tools/apt/Scanners/Order.java
deleted file mode 100644
index e2a8852..0000000
--- a/test/tools/apt/Scanners/Order.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-
- at VisitOrder(1)
-public class Order {
-    @VisitOrder(2)
-    static double d;
-
-    @VisitOrder(3)
-    private Order() {}
-
-    @VisitOrder(4)
-    int i;
-
-    @VisitOrder(5)
-    static class InnerOrder {
-        @VisitOrder(6)
-        InnerOrder(){}
-
-        @VisitOrder(7)
-        String toString() {return "";}
-    }
-
-    @VisitOrder(8)
-    String toString() {return "";}
-
-    @VisitOrder(9)
-    InnerOrder io;
-
-    @VisitOrder(10)
-    String foo() {return toString();}
-}
diff --git a/test/tools/apt/Scanners/Scanner.java b/test/tools/apt/Scanners/Scanner.java
deleted file mode 100644
index f9e8434..0000000
--- a/test/tools/apt/Scanners/Scanner.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.Map;
-import java.util.Arrays;
-import java.util.Collections;
-
-
-public class Scanner implements AnnotationProcessorFactory {
-    static class ScannerProc implements AnnotationProcessor {
-        AnnotationProcessorEnvironment env;
-        ScannerProc(AnnotationProcessorEnvironment env) {
-            this.env = env;
-        }
-
-        static class CountingVisitor extends SimpleDeclarationVisitor {
-            int count;
-            CountingVisitor() {
-                count = 0;
-            }
-
-            public void visitDeclaration(Declaration d) {
-                count++;
-
-                Collection<AnnotationMirror> ams = d.getAnnotationMirrors();
-                if (ams == null)
-                    throw new RuntimeException("Declaration " + d +
-                                               " not annotated with visit order.");
-                else {
-                    if (ams.size() != 1)
-                        throw new RuntimeException("Declaration " + d +
-                                                   " has wrong number of declarations.");
-                    else {
-                        for(AnnotationMirror am: ams) {
-                            Map<AnnotationTypeElementDeclaration,AnnotationValue> elementValues = am.getElementValues();
-                            for(AnnotationTypeElementDeclaration atmd: elementValues.keySet()) {
-                                if (!atmd.getDeclaringType().toString().equals("VisitOrder"))
-                                    throw new RuntimeException("Annotation " + atmd +
-                                                               " is the wrong type.");
-                                else {
-                                    AnnotationValue av =
-                                        elementValues.get(atmd);
-                                    Integer value = (Integer) av.getValue();
-                                    if (value.intValue() != count)
-                                        throw new RuntimeException("Expected declaration " + d +
-                                                                   " to be in position " + count +
-                                                                   " instead of " + value.intValue());
-
-                                    System.out.println("Declaration " + d +
-                                                       ": visit order " + value.intValue());
-                                }
-                            }
-
-                        }
-                    }
-                }
-
-            }
-        }
-
-        public void process() {
-            for(TypeDeclaration td: env.getSpecifiedTypeDeclarations() ) {
-                td.accept(DeclarationVisitors.getSourceOrderDeclarationScanner(new CountingVisitor(),
-                                                                               DeclarationVisitors.NO_OP));
-            }
-        }
-    }
-
-
-    static Collection<String> supportedTypes;
-    static {
-        String types[] = {"*"};
-        supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
-    }
-
-    static Collection<String> supportedOptions;
-    static {
-        String options[] = {""};
-        supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-    }
-
-    public Collection<String> supportedOptions() {
-        return supportedOptions;
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new ScannerProc(env);
-    }
-
-}
diff --git a/test/tools/apt/Scanners/TestEnum.java b/test/tools/apt/Scanners/TestEnum.java
deleted file mode 100644
index 0c61565..0000000
--- a/test/tools/apt/Scanners/TestEnum.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-public enum TestEnum {
-    QUIZ,
-    EXAM,
-    MIDTERM,
-    FINAL,
-    QUALIFIER;
-}
diff --git a/test/tools/apt/Scanners/VisitOrder.java b/test/tools/apt/Scanners/VisitOrder.java
deleted file mode 100644
index 584b447..0000000
--- a/test/tools/apt/Scanners/VisitOrder.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/*
- * Integer to indicate what order a declaration is expected to be
- * visited in by a DeclarationScanner.
- */
-
- at interface VisitOrder {
-    int value();
-}
diff --git a/test/tools/apt/Scanners/scanner.sh b/test/tools/apt/Scanners/scanner.sh
deleted file mode 100644
index 71fe799..0000000
--- a/test/tools/apt/Scanners/scanner.sh
+++ /dev/null
@@ -1,146 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2007, 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 4989093 5009164 5023880 5029482 6206786
-# @run shell ../verifyVariables.sh
-# @run shell scanner.sh
-# @summary Test source order scanner
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        Windows* | CYGWIN* )
-                SEP=";"
-        ;;
-
-	* )
-	SEP=":"
-	;;
-esac
-
-JARCP=scanner.jar
-
-# Construct path to apt executable
-APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile "
-
-printf "%s\n" "APT = ${APT}"
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-JAR="${TESTJAVA}/bin/jar "
-
-${JAVAC} ${TESTSRC}/Scanner.java ${TESTSRC}/VisitOrder.java ${TESTSRC}/Counter.java ${TESTSRC}/MemberOrderApf.java
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        ;;
-
-        * )
-        echo "Compilation failed."
-        exit 1
-esac
-
-
-echo "Making services directory and copying services information."
-mkdir -p META-INF/services
-
-cp ${TESTSRC}/servicesScanner META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
-
-${JAR} cf0 scanner.jar Scanner*.class META-INF
-
-# Jar files created; verify options properly present on both initial
-# and recursive apt runs
-
-#---------------------------------------------------------
-
-unset CLASSPATH
-
-printf "%s\n" "-classpath ${JARCP}"     > options
-printf "%s\n" "-sourcepath ${TESTSRC}" >> options
-printf "%s\n" "${TESTSRC}/Order.java"  >> options
-
-${APT} @options
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	;;	
-	
-	* )
-	echo "Program elements visited in wrong order"
-	exit 1
-        ;;
-esac
-
-#---------------------------------------------------------
-
-# Verify that plain decl' scanner and source order decl' scanner
-# record the same number of elements for an enum
-
-printf "%s\n" "-factorypath ."            > options2
-printf "%s\n" "-factory Counter"         >> options2
-printf "%s\n" "-sourcepath ${TESTSRC}"   >> options2
-printf "%s\n" "${TESTSRC}/TestEnum.java" >> options2
-
-
-$APT @options2
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	;;	
-	
-	* )
-	echo "Improper counts"
-	exit 1
-        ;;
-esac
-
-#---------------------------------------------------------
-
-# Verify that members happen to be returned in source order
-
-printf "%s\n" "-factorypath ."            > options3
-printf "%s\n" "-factory MemberOrderApf"  >> options3
-printf "%s\n" "-sourcepath ${TESTSRC}"   >> options3
-printf "%s\n" "${TESTSRC}/Order.java"    >> options3
-
-$APT @options3
-
-RESULT=$?
-case "${RESULT}" in
-        0  )
-	;;	
-	
-	* )
-	echo "Improper counts"
-	exit 1
-        ;;
-esac
-
-
-exit 0;
diff --git a/test/tools/apt/Scanners/servicesScanner b/test/tools/apt/Scanners/servicesScanner
deleted file mode 100644
index 6ac6c38..0000000
--- a/test/tools/apt/Scanners/servicesScanner
+++ /dev/null
@@ -1 +0,0 @@
-Scanner
diff --git a/test/tools/apt/lib/Ignore.java b/test/tools/apt/lib/Ignore.java
deleted file mode 100644
index 8aac427..0000000
--- a/test/tools/apt/lib/Ignore.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.*;
-
-/**
- * An annotation used to indicate that a test -- a method annotated
- * with @Test -- should not be executed.
- *
- * @author Scott Seligman
- */
- at Target(ElementType.METHOD)
- at Retention(RetentionPolicy.RUNTIME)
-public @interface Ignore {
-
-    /**
-     * Reason for ignoring this test.
-     */
-    String value() default "";
-}
diff --git a/test/tools/apt/lib/Test.java b/test/tools/apt/lib/Test.java
deleted file mode 100644
index 301ae87..0000000
--- a/test/tools/apt/lib/Test.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.*;
-
-/**
- * An annotation used to indicate that a method constitutes a test,
- * and which provides the expected result.  The method must take no parameters.
- *
- * @author Scott Seligman
- */
- at Target(ElementType.METHOD)
- at Retention(RetentionPolicy.RUNTIME)
-public @interface Test {
-
-    /**
-     * An array containing the method's expected result (or
-     * elements of the result if the return type is a Collection).
-     * Value is ignored if return type is void.
-     * Entries are converted to strings via {@link String#valueOf(Object)}.
-     */
-    String[] result() default {};
-
-    /**
-     * True if the order of the elements in result() is significant.
-     */
-    boolean ordered() default false;
-}
diff --git a/test/tools/apt/lib/TestProcessor.java b/test/tools/apt/lib/TestProcessor.java
deleted file mode 100644
index 920d049..0000000
--- a/test/tools/apt/lib/TestProcessor.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.reflect.Method;
-import java.util.*;
-import com.sun.mirror.apt.*;
-
-
-/**
- * Annotation processor for the @Test annotation.
- * Invokes each method so annotated, and verifies the result.
- * Throws an Error on failure.
- *
- * @author Scott Seligman
- */
-public class TestProcessor implements AnnotationProcessor {
-
-    AnnotationProcessorEnvironment env;
-
-    // The tester that's running.
-    Tester tester = Tester.activeTester;
-
-    TestProcessor(AnnotationProcessorEnvironment env,
-                  Tester tester) {
-        this.env = env;
-        this.tester = tester;
-    }
-
-
-    /**
-     * Reflectively invoke the @Test-annotated methods of the live
-     * tester.  Those methods perform the actual exercising of the
-     * mirror API.  Then back here to verify the results by
-     * reading the live annotations.  Convoluted, you say?
-     */
-    public void process() {
-        System.out.printf("\n> Processing %s\n", tester.getClass());
-
-        boolean failed = false;         // true if a test returns wrong result
-
-        for (Method m : tester.getClass().getDeclaredMethods()) {
-            Test anno = m.getAnnotation(Test.class);
-            Ignore ignore = m.getAnnotation(Ignore.class);
-            if (anno != null) {
-                if (ignore == null) {
-                    System.out.println(">> Invoking test " + m.getName());
-                    Object result;
-                    try {
-                        result = m.invoke(tester);
-                    } catch (Exception e) {
-                        throw new Error("Test invocation failed", e);
-                    }
-                    boolean ok = true;  // result of this test
-                    if (Collection.class.isAssignableFrom(m.getReturnType())) {
-                        ok = verifyResults((Collection) result,
-                                           anno.result(), anno.ordered());
-                    } else if (m.getReturnType() != void.class) {
-                        ok = verifyResult(result, anno.result());
-                    }
-                    if (!ok) {
-                        System.out.println(">>> Expected: " + anno);
-                        System.out.println(">>> Got: " + result);
-                        failed = true;
-                    }
-                } else {
-                    System.out.println(">> Ignoring test " + m.getName());
-                    if (ignore.value().length() > 0) {
-                        System.out.println(">>> Reason: " + ignore.value());
-                    }
-                }
-            }
-        }
-        if (failed) {
-            throw new Error("Test(s) returned unexpected result");
-        }
-    }
-
-    /**
-     * Verify that a single-valued (non-Collection) result matches
-     * its expected value.
-     */
-    private boolean verifyResult(Object result, String[] expected) {
-        assert expected.length == 1 :
-            "Single-valued test expecting " + expected.length + " results";
-        return expected[0].equals(String.valueOf(result));
-    }
-
-    /**
-     * Verify that a multi-valued result (a Collection) matches
-     * its expected values.
-     */
-    private boolean verifyResults(Collection result,
-                                  String[] expected, boolean ordered) {
-        if (result.size() != expected.length) {
-            return false;
-        }
-
-        // Convert result to an array of strings.
-        String[] res = new String[result.size()];
-        int i = 0;
-        for (Object e : result) {
-            res[i++] = String.valueOf(e);
-        }
-
-        if (!ordered) {
-            Arrays.sort(res);
-            Arrays.sort(expected);
-        }
-        return Arrays.equals(res, expected);
-    }
-}
diff --git a/test/tools/apt/lib/TestProcessorFactory.java b/test/tools/apt/lib/TestProcessorFactory.java
deleted file mode 100644
index 4079512..0000000
--- a/test/tools/apt/lib/TestProcessorFactory.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.util.*;
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * A factory for generating the TestProcessor annotation processor, which
- * processes the @Test annotation.
- *
- * @author Scott Seligman
- */
-public class TestProcessorFactory implements AnnotationProcessorFactory {
-
-    public Collection<String> supportedOptions() {
-        return new ArrayList<String>();
-    }
-
-    public Collection<String> supportedAnnotationTypes() {
-        ArrayList<String> res = new ArrayList<String>();
-        res.add("Test");
-        res.add("Ignore");
-        return res;
-    }
-
-    public AnnotationProcessor getProcessorFor(
-                                        Set<AnnotationTypeDeclaration> as,
-                                        AnnotationProcessorEnvironment env) {
-        // The tester that's running.
-        Tester tester = Tester.activeTester;
-
-        try {
-            // Find the tester's class declaration.
-            ClassDeclaration testerDecl = null;
-            for (TypeDeclaration decl : env.getSpecifiedTypeDeclarations()) {
-                if (decl.getQualifiedName().equals(
-                                               tester.getClass().getName())) {
-                    testerDecl = (ClassDeclaration) decl;
-                    break;
-                }
-            }
-
-            // Give the tester access to its own declaration and to the env.
-            tester.thisClassDecl = testerDecl;
-            tester.env = env;
-
-            // Initializer the tester.
-            tester.init();
-
-            return new TestProcessor(env, tester);
-
-        } catch (Exception e) {
-            throw new Error("Couldn't create test annotation processor", e);
-        }
-    }
-}
diff --git a/test/tools/apt/lib/Tester.java b/test/tools/apt/lib/Tester.java
deleted file mode 100644
index 34630c7..0000000
--- a/test/tools/apt/lib/Tester.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/*
- * A utility used to invoke and test the apt tool.
- * Tests should subclass Tester, and invoke run().
- *
- * @author Scott Seligman
- */
-
-import java.io.*;
-import java.util.*;
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-
-
-public abstract class Tester {
-
-    /**
-     * The declaration corresponding to this tester's class.  Set by
-     * TestProcessorFactory after the constructor completes, and
-     * before init() is invoked.
-     */
-    ClassDeclaration thisClassDecl;
-
-    /**
-     * The environment for this apt run.  Set by TestProcessorFactory
-     * after the constructor completes, and before init() is invoked.
-     */
-    AnnotationProcessorEnvironment env;
-
-
-    // TestProcessorFactory looks here to find the tester that's running
-    // when it's invoked.
-    static Tester activeTester;
-
-    private static final String[] DEFAULT_ARGS = {
-        "-nocompile",
-        "-XPrintAptRounds",
-        "-XListDeclarations",
-    };
-    private static final String[] NO_STRINGS = {};
-
-    // Force processor and factory to be compiled
-    private static Class dummy = TestProcessorFactory.class;
-
-    private final String testSrc =     System.getProperty("test.src",     ".");
-    private final String testClasses = System.getProperty("test.classes", ".");
-
-    // apt command-line args
-    private String[] args;
-
-
-    static {
-        // Enable assertions in the unnamed package.
-        ClassLoader loader = Tester.class.getClassLoader();
-        if (loader != null) {
-            loader.setPackageAssertionStatus(null, true);
-        }
-    }
-
-
-    protected Tester(String... additionalArgs) {
-        String sourceFile = testSrc + File.separator +
-                            getClass().getName() + ".java";
-
-        ArrayList<String> as = new ArrayList<String>();
-        Collections.addAll(as, DEFAULT_ARGS);
-        as.add("-sourcepath");  as.add(testSrc);
-        as.add("-factory");     as.add(TestProcessorFactory.class.getName());
-        Collections.addAll(as, additionalArgs);
-        as.add(sourceFile);
-        args = as.toArray(NO_STRINGS);
-    }
-
-    /**
-     * Run apt.
-     */
-    protected void run() {
-        activeTester = this;
-        if (com.sun.tools.apt.Main.process(args) != 0) {
-            throw new Error("apt errors encountered.");
-        }
-    }
-
-    /**
-     * Called after thisClassDecl and env have been set, but before any
-     * tests are run, to allow the tester subclass to perform any
-     * needed initialization.
-     */
-    protected void init() {
-    }
-
-    /**
-     * Returns the declaration of a named method in this class.  If this
-     * method name is overloaded, one method is chosen arbitrarily.
-     * Returns null if no method is found.
-     */
-    protected MethodDeclaration getMethod(String methodName) {
-        for (MethodDeclaration m : thisClassDecl.getMethods()) {
-            if (methodName.equals(m.getSimpleName())) {
-                return m;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns the declaration of a named field in this class.
-     * Returns null if no field is found.
-     */
-    protected FieldDeclaration getField(String fieldName) {
-        for (FieldDeclaration f : thisClassDecl.getFields()) {
-            if (fieldName.equals(f.getSimpleName())) {
-                return f;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns the annotation mirror of a given type on a named method
-     * in this class.  If this method name is overloaded, one method is
-     * chosen arbitrarily.  Returns null if no appropriate annotation
-     * is found.
-     */
-    protected AnnotationMirror getAnno(String methodName, String annoType) {
-        MethodDeclaration m = getMethod(methodName);
-        if (m != null) {
-            TypeDeclaration at = env.getTypeDeclaration(annoType);
-            for (AnnotationMirror a : m.getAnnotationMirrors()) {
-                if (at == a.getAnnotationType().getDeclaration()) {
-                    return a;
-                }
-            }
-        }
-        return null;
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/AnnoMirror.java b/test/tools/apt/mirror/declaration/AnnoMirror.java
deleted file mode 100644
index 42d02e6..0000000
--- a/test/tools/apt/mirror/declaration/AnnoMirror.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5014539
- * @summary Tests AnnotationMirror and AnnotationValue methods.
- * @library ../../lib
- * @compile -source 1.5 AnnoMirror.java
- * @run main/othervm AnnoMirror
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-
-
-public class AnnoMirror extends Tester {
-
-    public static void main(String[] args) {
-        (new AnnoMirror()).run();
-    }
-
-
-    @Test(result={"AT1"})
-    @AT1
-    AnnotationType getAnnotationType() {
-        AnnotationMirror anno = getAnno("getAnnotationType", "AT1");
-        return anno.getAnnotationType();
-    }
-
-    @Test(result={})
-    @AT1
-    Set getElementValuesNone() {
-        AnnotationMirror anno = getAnno("getElementValuesNone", "AT1");
-        return anno.getElementValues().entrySet();
-    }
-
-
-    // The seemingly out-of-place parens in the following "result"
-    // entry are needed due to the shortcut of having the test return
-    // the entry set directly.
-    @Test(result={"i()=2",
-                  "b()=true",
-                  "k()=java.lang.Boolean.class",
-                  "a()=@AT1"})
-    @AT2(i = 1+1,
-         b = true,
-         k = Boolean.class,
-         a = @AT1)
-    Set getElementValues() {
-        AnnotationMirror anno = getAnno("getElementValues", "AT2");
-        return anno.getElementValues().entrySet();
-    }
-
-    @Test(result={"@AT1(\"zax\")",
-                  "@AT2(i=2, b=true, k=java.lang.Boolean.class, a=@AT1)",
-                  "@AT3(arr={1})",
-                  "@AT4({2, 3, 4})"})
-    Collection<AnnotationMirror> toStringTests() {
-        for (MethodDeclaration m : thisClassDecl.getMethods()) {
-            if (m.getSimpleName().equals("toStringTestsHelper")) {
-                return m.getAnnotationMirrors();
-            }
-        }
-        throw new AssertionError();
-    }
-
-    @AT1("zax")
-    @AT2(i = 1+1,
-         b = true,
-         k = Boolean.class,
-         a = @AT1)
-    @AT3(arr={1})
-    @AT4({2,3,4})
-    private void toStringTestsHelper() {
-    }
-}
-
-
-/*
- * Annotations used for testing.
- */
-
- at interface AT1 {
-    String value() default "";
-}
-
- at interface AT2 {
-    int i();
-    boolean b();
-    Class k();
-    AT1 a();
-}
-
- at interface AT3 {
-    int[] arr();
-}
-
- at interface AT4 {
-    int[] value();
-}
diff --git a/test/tools/apt/mirror/declaration/AnnoTypeDecl.java b/test/tools/apt/mirror/declaration/AnnoTypeDecl.java
deleted file mode 100644
index 5ee53ce..0000000
--- a/test/tools/apt/mirror/declaration/AnnoTypeDecl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5014539
- * @summary AnnotationTypeDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 AnnoTypeDecl.java
- * @run main/othervm AnnoTypeDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class AnnoTypeDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new AnnoTypeDecl()).run();
-    }
-
-
-    private AnnotationTypeDeclaration at;
-
-    protected void init() {
-        at = (AnnotationTypeDeclaration) env.getTypeDeclaration("AT");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="annotation type")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        at.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitClassDeclaration(ClassDeclaration c) {
-                res.add("class");
-            }
-            public void visitInterfaceDeclaration(InterfaceDeclaration i) {
-                res.add("interface");
-            }
-            public void visitAnnotationTypeDeclaration(
-                                                AnnotationTypeDeclaration a) {
-                res.add("annotation type");
-            }
-        });
-        return res;
-    }
-
-
-    // AnnotationTypeDeclaration methods
-
-    @Test(result={"s()"})
-    Collection<AnnotationTypeElementDeclaration> getMethods() {
-        return at.getMethods();
-    }
-}
-
-
-// An annotation type to use for testing.
-
- at interface AT {
-    String s();
-}
diff --git a/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java b/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java
deleted file mode 100644
index cbbfe4f..0000000
--- a/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 4993299 5010385 5014539
- * @summary AnnotationTypeElementDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 AnnoTypeElemDecl.java
- * @run main/othervm AnnoTypeElemDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class AnnoTypeElemDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new AnnoTypeElemDecl()).run();
-    }
-
-
-    // Some annotation type elements to use.
-    private AnnotationTypeElementDeclaration elem1 = null;      // s()
-    private AnnotationTypeElementDeclaration elem2 = null;      // i()
-    private AnnotationTypeElementDeclaration elem3 = null;      // b()
-
-    protected void init() {
-        for (TypeDeclaration at : thisClassDecl.getNestedTypes()) {
-            for (MethodDeclaration meth : at.getMethods()) {
-                AnnotationTypeElementDeclaration elem =
-                    (AnnotationTypeElementDeclaration) meth;
-                if (elem.getSimpleName().equals("s")) {
-                    elem1 = elem;       // s()
-                } else if (elem.getSimpleName().equals("i")) {
-                    elem2 = elem;       // i()
-                } else {
-                    elem3 = elem;       // b()
-                }
-            }
-        }
-    }
-
-
-    // Declaration methods
-
-    @Test(result="anno type element")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        elem1.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitExecutableDeclaration(ExecutableDeclaration e) {
-                res.add("executable");
-            }
-            public void visitMethodDeclaration(MethodDeclaration m) {
-                res.add("method");
-            }
-            public void visitAnnotationTypeElementDeclaration(
-                                        AnnotationTypeElementDeclaration a) {
-                res.add("anno type element");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@AnnoTypeElemDecl.AT2"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return elem1.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return elem1.getDocComment();
-    }
-
-    @Test(result={"public", "abstract"})
-    Collection<Modifier> getModifiers() {
-        return elem1.getModifiers();
-    }
-
-    @Test(result="AnnoTypeElemDecl.java")
-    String getPosition() {
-        return elem1.getPosition().file().getName();
-    }
-
-    @Test(result="s")
-    String getSimpleName() {
-        return elem1.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="AnnoTypeElemDecl.AT1")
-    TypeDeclaration getDeclaringType() {
-        return elem1.getDeclaringType();
-    }
-
-
-    // ExecutableDeclaration methods
-
-    @Test(result={})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters() {
-        return elem1.getFormalTypeParameters();
-    }
-
-    @Test(result={})
-    Collection<ParameterDeclaration> getParameters() {
-        return elem1.getParameters();
-    }
-
-    @Test(result={})
-    Collection<ReferenceType> getThrownTypes() {
-        return elem1.getThrownTypes();
-    }
-
-    @Test(result="false")
-    Boolean isVarArgs() {
-        return elem1.isVarArgs();
-    }
-
-
-    // AnnotationTypeElementDeclaration method
-
-    @Test(result="\"default\"")
-    AnnotationValue getDefaultValue1() {
-        return elem1.getDefaultValue();
-    }
-
-    @Test(result="null")
-    AnnotationValue getDefaultValue2() {
-        return elem2.getDefaultValue();
-    }
-
-    // 5010385: getValue() returns null for boolean type elements
-    @Test(result="false")
-    Boolean getDefaultValue3() {
-        return (Boolean) elem3.getDefaultValue().getValue();
-    }
-
-
-    // toString
-
-    @Test(result="s()")
-    String toStringTest() {
-        return elem1.toString();
-    }
-
-
-    // Declarations used by tests.
-
-    @interface AT1 {
-        /**
-         * Sed Quis custodiet ipsos custodes?
-         */
-        @AT2
-        String s() default "default";
-
-        int i();
-
-        boolean b() default false;
-    }
-
-    @interface AT2 {
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/AnnoVal.java b/test/tools/apt/mirror/declaration/AnnoVal.java
deleted file mode 100644
index 0fc796a..0000000
--- a/test/tools/apt/mirror/declaration/AnnoVal.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5014539 5034991
- * @summary Tests AnnotationValue methods.
- * @library ../../lib
- * @compile -source 1.5 AnnoVal.java
- * @run main/othervm AnnoVal
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-
-
-public class AnnoVal extends Tester {
-
-    public static void main(String[] args) {
-        (new AnnoVal()).run();
-    }
-
-    @Test(result={
-        "i Integer 2",
-        "l Long 4294967296",
-        "d Double 3.14",
-        "b Boolean true",
-        "c Character @",
-        "s String sigh",
-        // The following results reflect some implementation details.
-        "k ClassTypeImpl java.lang.Boolean",
-        "kb PrimitiveTypeImpl boolean",
-        "ka ArrayTypeImpl java.lang.Boolean[]",
-        "kab ArrayTypeImpl int[][]",
-        "w ClassTypeImpl java.lang.Long",
-        "e EnumConstantDeclarationImpl TYPE",
-        "sa ArrayList [\"up\", \"down\"]",
-        "a AnnotationMirrorImpl @AT1"})
-    @AT2(i = 1 + 1,
-         l = 1024 * 1024 * 1024 * 4L,
-         d = 3.14,
-         b = true,
-         c = '@',
-         s = "sigh",
-         k = Boolean.class,
-         kb = boolean.class,
-         ka = Boolean[].class,          // bugid 5020899
-         kab = int[][].class,           //      "
-         w = Long.class,
-         e = java.lang.annotation.ElementType.TYPE,
-         sa = {"up", "down"},
-         a = @AT1)
-    Collection<String> getValue() {
-        Collection<String> res = new ArrayList<String>();
-        AnnotationMirror anno = getAnno("getValue", "AT2");
-
-        for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> e :
-                 anno.getElementValues().entrySet()) {
-            Object val = e.getValue().getValue();
-            res.add(String.format("%s %s %s",
-                                  e.getKey().getSimpleName(),
-                                  simpleClassName(val),
-                                  val));
-        }
-        return res;
-    }
-
-    @Test(result={
-        "int i 2",
-        "long l 4294967296L",
-        "double d 3.14",
-        "boolean b true",
-        "char c '@'",
-        "java.lang.String s \"sigh\"",
-        "java.lang.Class k java.lang.Boolean.class",
-        "java.lang.Class kb boolean.class",
-        "java.lang.Class ka java.lang.Boolean[].class",
-        "java.lang.Class kab int[][].class",
-        "java.lang.Class<? extends java.lang.Number> w java.lang.Long.class",
-        "java.lang.annotation.ElementType e java.lang.annotation.ElementType.TYPE",
-        "java.lang.String[] sa {\"up\", \"down\"}",
-        "AT1 a @AT1"})
-    Collection<String> toStringTests() {
-        Collection<String> res = new ArrayList<String>();
-        AnnotationMirror anno = getAnno("getValue", "AT2");
-
-        for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> e :
-                 anno.getElementValues().entrySet()) {
-            res.add(String.format("%s %s %s",
-                                  e.getKey().getReturnType(),
-                                  e.getKey().getSimpleName(),
-                                  e.getValue().toString()));
-        }
-        return res;
-    }
-
-    @Test(result={
-        "byte b 0x0b",
-        "float f 3.0f",
-        "double nan 0.0/0.0",
-        "double hi 1.0/0.0",
-        "float lo -1.0f/0.0f",
-        "char newline '\\n'",
-        "char ff '\\u00ff'",
-        "java.lang.String s \"\\\"high\\tlow\\\"\"",
-        "java.lang.String smiley \"\\u263a\""})
-    @AT3(b = 11,
-         f = 3,
-         nan = 0.0/0.0,
-         hi = 1.0/0.0,
-         lo = -1.0f/0.0f,
-         newline = '\n',
-         ff = '\u00FF',
-         s = "\"high\tlow\"",
-         smiley = "\u263A")
-    Collection<String> toStringFancy() {
-        Collection<String> res = new ArrayList<String>();
-        AnnotationMirror anno = getAnno("toStringFancy", "AT3");
-
-        for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> e :
-                 anno.getElementValues().entrySet()) {
-            res.add(String.format("%s %s %s",
-                                  e.getKey().getReturnType(),
-                                  e.getKey().getSimpleName(),
-                                  e.getValue().toString()));
-        }
-        return res;
-    }
-
-
-    /**
-     * Returns the simple name of an object's class.
-     */
-    private String simpleClassName(Object o) {
-        return (o == null)
-            ? "null"
-            : o.getClass().getName().replaceFirst(".*\\.", "");
-    }
-}
-
-
-/*
- * Annotations used for testing.
- */
-
- at interface AT1 {
-    String value() default "";
-}
-
- at interface AT2 {
-    int i();
-    long l();
-    double d();
-    boolean b();
-    char c();
-    String s();
-    Class k();
-    Class kb();
-    Class ka();
-    Class kab();
-    Class<? extends Number> w();
-    java.lang.annotation.ElementType e();
-    String[] sa();
-    AT1 a();
-}
-
- at interface AT3 {
-    byte b();
-    float f();
-    double nan();
-    double hi();
-    float lo();
-    char newline();
-    char ff();
-    String s();
-    String smiley();
-}
diff --git a/test/tools/apt/mirror/declaration/ClassDecl.java b/test/tools/apt/mirror/declaration/ClassDecl.java
deleted file mode 100644
index 7c4c13f..0000000
--- a/test/tools/apt/mirror/declaration/ClassDecl.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 4997614
- * @summary ClassDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 ClassDecl.java
- * @run main/othervm ClassDecl
- */
-
-
-import java.io.Serializable;
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * Sed Quis custodiet ipsos custodes?
- */
- at AT1
- at AT2
-public class ClassDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new ClassDecl()).run();
-    }
-
-
-    private ClassDeclaration nested = null;     // a nested type
-    private ClassDeclaration object = null;     // java.lang.object
-
-    // A constructor to be found
-    private ClassDecl() {
-    }
-
-    // Another constructor to be found
-    private ClassDecl(int i) {
-        this();
-    }
-
-    // An extra field to be found
-    static int i;
-
-    // Static initializer isn't among this class's methods.
-    static {
-        i = 7;
-    }
-
-    // A nested class with some accoutrements
-    private static strictfp class NestedClass<T> implements Serializable {
-        void m1() {}
-        void m2() {}
-        void m2(int i) {}
-    }
-
-    protected void init() {
-        nested = (ClassDeclaration)
-            thisClassDecl.getNestedTypes().iterator().next();
-        object = (ClassDeclaration)
-            env.getTypeDeclaration("java.lang.Object");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="class")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        thisClassDecl.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitClassDeclaration(ClassDeclaration c) {
-                res.add("class");
-            }
-            public void visitEnumDeclaration(EnumDeclaration e) {
-                res.add("enum");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@AT1", "@AT2"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return thisClassDecl.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return thisClassDecl.getDocComment();
-    }
-
-    @Test(result={"public"})
-    Collection<Modifier> getModifiers1() {
-        return thisClassDecl.getModifiers();
-    }
-
-    // Check that static nested class has "static" modifier, even though
-    // the VM doesn't set that bit.
-    @Test(result={"private", "static", "strictfp"})
-    Collection<Modifier> getModifiers2() {
-        return nested.getModifiers();
-    }
-
-    @Test(result="ClassDecl.java")
-    String getPosition() {
-        return thisClassDecl.getPosition().file().getName();
-    }
-
-    @Test(result="ClassDecl")
-    String getSimpleName1() {
-        return thisClassDecl.getSimpleName();
-    }
-
-    @Test(result="NestedClass")
-    String getSimpleName2() {
-        return nested.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="null")
-    TypeDeclaration getDeclaringType1() {
-        return thisClassDecl.getDeclaringType();
-    }
-
-    @Test(result="ClassDecl")
-    TypeDeclaration getDeclaringType2() {
-        return nested.getDeclaringType();
-    }
-
-
-    // TypeDeclaration methods
-
-    @Test(result={"nested", "object", "i"})
-    Collection<FieldDeclaration> getFields() {
-        return thisClassDecl.getFields();
-    }
-
-    @Test(result={})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
-        return thisClassDecl.getFormalTypeParameters();
-    }
-
-    @Test(result="T")
-    Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
-        return nested.getFormalTypeParameters();
-    }
-
-    @Test(result="ClassDecl.NestedClass<T>")
-    Collection<TypeDeclaration> getNestedTypes() {
-        return thisClassDecl.getNestedTypes();
-    }
-
-    @Test(result="")
-    PackageDeclaration getPackage1() {
-        return thisClassDecl.getPackage();
-    }
-
-    @Test(result="java.lang")
-    PackageDeclaration getPackage2() {
-        return object.getPackage();
-    }
-
-    @Test(result="ClassDecl")
-    String getQualifiedName1() {
-        return thisClassDecl.getQualifiedName();
-    }
-
-    @Test(result="ClassDecl.NestedClass")
-    String getQualifiedName2() {
-        return nested.getQualifiedName();
-    }
-
-    @Test(result="java.lang.Object")
-    String getQualifiedName3() {
-        return object.getQualifiedName();
-    }
-
-    @Test(result="java.io.Serializable")
-    Collection<InterfaceType> getSuperinterfaces() {
-        return nested.getSuperinterfaces();
-    }
-
-
-    // ClassDeclaration methods
-
-    @Test(result={"ClassDecl()", "ClassDecl(int)"})
-    Collection<ConstructorDeclaration> getConstructors1() {
-        return thisClassDecl.getConstructors();
-    }
-
-    // Check for default constructor.
-    // 4997614: visitConstructionDeclaration reports info when there is no ctor
-    @Test(result={"NestedClass()"})
-    Collection<ConstructorDeclaration> getConstructors2() {
-        return nested.getConstructors();
-    }
-
-    @Test(result={"m1()", "m2()", "m2(int)"})
-    Collection<MethodDeclaration> getMethods() {
-        return nested.getMethods();
-    }
-
-    @Test(result={"Tester"})
-    ClassType getSuperclass() {
-        return thisClassDecl.getSuperclass();
-    }
-
-    @Test(result={"null"})
-    ClassType objectHasNoSuperclass() {
-        return object.getSuperclass();
-    }
-}
-
-
-// Annotations used for testing.
-
- at interface AT1 {
-}
-
- at interface AT2 {
-}
diff --git a/test/tools/apt/mirror/declaration/ConstExpr.java b/test/tools/apt/mirror/declaration/ConstExpr.java
deleted file mode 100644
index 400f090..0000000
--- a/test/tools/apt/mirror/declaration/ConstExpr.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 5027675 5048535
- * @summary Tests FieldDeclaration.getConstantExpression method
- * @library ../../lib
- * @compile -source 1.5 ConstExpr.java
- * @run main/othervm ConstExpr
- */
-
-
-import java.math.RoundingMode;
-import java.util.*;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import static java.math.RoundingMode.UP;
-
-import static com.sun.mirror.util.DeclarationVisitors.*;
-
-
-public class ConstExpr extends Tester {
-
-    public static void main(String[] args) {
-        (new ConstExpr()).run();
-    }
-
-
-    // Declarations used by tests
-
-    public static final byte B = (byte) 0xBE;
-    public static final short S = (short) 32767;
-    public static final int I = -4;
-    public static final long l = 4294967296L;
-    public static final float f = 3.5f;
-    public static final double PI = Math.PI;
-    public static final char C = 'C';
-    public static final String STR = "cheese";
-
-    public static final char SMILEY = '\u263A';
-    public static final String TWOLINES = "ab\ncd";
-
-    public static final double D1 = Double.POSITIVE_INFINITY;
-    public static final double D2 = Double.NEGATIVE_INFINITY;
-    public static final double D3 = Double.NaN;
-    public static final float  F1 = Float.POSITIVE_INFINITY;
-    public static final float  F2 = Float.NEGATIVE_INFINITY;
-    public static final float  F3 = Float.NaN;
-
-    public static final String NOSTR = null;    // not a compile-time constant
-    public static final RoundingMode R = UP;    // not a compile-time constant
-
-
-    @Test(result={
-              "0xbe",
-              "32767",
-              "-4",
-              "4294967296L",
-              "3.5f",
-              "3.141592653589793",
-              "'C'",
-              "\"cheese\"",
-
-              "'\\u263a'",
-              "\"ab\\ncd\"",
-
-              "1.0/0.0",
-              "-1.0/0.0",
-              "0.0/0.0",
-              "1.0f/0.0f",
-              "-1.0f/0.0f",
-              "0.0f/0.0f",
-
-              "null",
-              "null"
-          },
-          ordered=true)
-    Collection<String> getConstantExpression() {
-        final Collection<String> res = new ArrayList<String>();
-
-        thisClassDecl.accept(
-            DeclarationVisitors.getSourceOrderDeclarationScanner(
-                NO_OP,
-                new SimpleDeclarationVisitor() {
-                    public void visitFieldDeclaration(FieldDeclaration f) {
-                        res.add(f.getConstantExpression());
-                    }
-                }));
-        return res;
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/ConstructorDecl.java b/test/tools/apt/mirror/declaration/ConstructorDecl.java
deleted file mode 100644
index 065598b..0000000
--- a/test/tools/apt/mirror/declaration/ConstructorDecl.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 4993299
- * @summary ConstructorDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 ConstructorDecl.java
- * @run main/othervm ConstructorDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class ConstructorDecl extends Tester {
-
-    /**
-     * Sed Quis custodiet ipsos custodes?
-     */
-    @AT1
-    public ConstructorDecl() {
-    }
-
-
-    public static void main(String[] args) {
-        (new ConstructorDecl()).run();
-    }
-
-
-    private ConstructorDeclaration ctor = null;         // a constructor
-    private ConstructorDeclaration ctorDef = null;      // a default c'tor
-    private ConstructorDeclaration ctorInner = null;    // an inner class c'tor
-
-    protected void init() {
-        ctor = getAConstructor(thisClassDecl);
-        ctorDef = getAConstructor((ClassDeclaration)
-                                  env.getTypeDeclaration("C1"));
-        ctorInner = getAConstructor((ClassDeclaration)
-                                    env.getTypeDeclaration("C1.C2"));
-    }
-
-    // Return a constructor of a class.
-    private ConstructorDeclaration getAConstructor(ClassDeclaration c) {
-        return c.getConstructors().iterator().next();
-    }
-
-
-    // Declaration methods
-
-    @Test(result="constructor")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        ctor.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitExecutableDeclaration(ExecutableDeclaration e) {
-                res.add("executable");
-            }
-            public void visitConstructorDeclaration(ConstructorDeclaration c) {
-                res.add("constructor");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@AT1"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return ctor.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return ctor.getDocComment();
-    }
-
-    @Test(result={"public"})
-    Collection<Modifier> getModifiers() {
-        return ctor.getModifiers();
-    }
-
-    @Test(result="ConstructorDecl.java")
-    String getPosition() {
-        return ctor.getPosition().file().getName();
-    }
-
-    @Test(result="ConstructorDecl.java")
-    String getPositionDefault() {
-        return ctorDef.getPosition().file().getName();
-    }
-
-    @Test(result="ConstructorDecl")
-    String getSimpleName() {
-        return ctor.getSimpleName();
-    }
-
-    @Test(result="C2")
-    String getSimpleNameInner() {
-        return ctorInner.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="ConstructorDecl")
-    TypeDeclaration getDeclaringType() {
-        return ctor.getDeclaringType();
-    }
-
-
-    // ExecutableDeclaration methods
-
-    @Test(result={})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
-        return ctor.getFormalTypeParameters();
-    }
-
-    @Test(result={"N extends java.lang.Number"})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
-        return ctorInner.getFormalTypeParameters();
-    }
-
-    @Test(result={})
-    Collection<ParameterDeclaration> getParameters1() {
-        return ctor.getParameters();
-    }
-
-    // 4993299: verify synthetic parameters to inner class constructors
-    //          aren't visible
-    @Test(result={"N n1", "N n2", "java.lang.String[] ss"},
-          ordered=true)
-    Collection<ParameterDeclaration> getParameters2() {
-        return ctorInner.getParameters();
-    }
-
-    @Test(result={"java.lang.Throwable"})
-    Collection<ReferenceType> getThrownTypes() {
-        return ctorInner.getThrownTypes();
-    }
-
-    @Test(result="false")
-    Boolean isVarArgs1() {
-        return ctor.isVarArgs();
-    }
-
-    @Test(result="true")
-    Boolean isVarArgs2() {
-        return ctorInner.isVarArgs();
-    }
-
-
-    // toString
-
-    @Test(result="<N extends java.lang.Number> C2(N, N, String...)")
-    @Ignore("This is what it would be nice to see.")
-    String toStringTest() {
-        return ctorInner.toString();
-    }
-}
-
-
-// Classes and interfaces used for testing.
-
-class C1 {
-    class C2 {
-        <N extends Number> C2(N n1, N n2, String... ss) throws Throwable {
-        }
-    }
-}
-
- at interface AT1 {
-}
diff --git a/test/tools/apt/mirror/declaration/EnumDecl.java b/test/tools/apt/mirror/declaration/EnumDecl.java
deleted file mode 100644
index 08563a8..0000000
--- a/test/tools/apt/mirror/declaration/EnumDecl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 4989987 5010050
- * @summary EnumDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 EnumDecl.java
- * @run main/othervm EnumDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class EnumDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new EnumDecl()).run();
-    }
-
-
-    private EnumDeclaration eDecl;
-
-    protected void init() {
-        eDecl = (EnumDeclaration) env.getTypeDeclaration("E");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="enum")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        eDecl.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitClassDeclaration(ClassDeclaration c) {
-                res.add("class");
-            }
-            public void visitEnumDeclaration(EnumDeclaration e) {
-                res.add("enum");
-            }
-        });
-        return res;
-    }
-
-
-    // ClassDeclaration methods
-
-    // 4989987: Verify synthetic enum constructor parameters are not visible
-    @Test(result={"E(java.lang.String)"})
-    Collection<ConstructorDeclaration> getConstructors() {
-        return eDecl.getConstructors();
-    }
-
-    // 4989987: Verify synthetic enum constructor parameters are not visible
-    @Test(result={"java.lang.String color"})
-    Collection<ParameterDeclaration> getConstructorParams() {
-        return eDecl.getConstructors().iterator().next().getParameters();
-    }
-
-    @Test(result={"values()", "valueOf(java.lang.String)"})
-    Collection<MethodDeclaration> getMethods() {
-        return eDecl.getMethods();
-    }
-
-    // 5010050: Cannot find parameter names for valueOf(String name) method...
-    @Test(result={"java.lang.String name"})
-    Collection<ParameterDeclaration> getMethodParams() {
-        for (MethodDeclaration m : eDecl.getMethods()) {
-            if (m.getSimpleName().equals("valueOf")) {
-                return m.getParameters();
-            }
-        }
-        throw new AssertionError();
-    }
-
-
-    // EnumDeclaration methods
-
-    @Test(result={"stop", "slow", "go"})
-    Collection<EnumConstantDeclaration> getEnumConstants() {
-        return eDecl.getEnumConstants();
-    }
-}
-
-
-// An enum to use for testing.
-
-enum E {
-    stop("red"),
-    slow("amber"),
-    go("green");
-
-    private String color;
-    E(String color) {
-        this.color = color;
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/FieldDecl.java b/test/tools/apt/mirror/declaration/FieldDecl.java
deleted file mode 100644
index 321e263..0000000
--- a/test/tools/apt/mirror/declaration/FieldDecl.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5008309
- * @summary FieldDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 FieldDecl.java
- * @run main/othervm FieldDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class FieldDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new FieldDecl()).run();
-    }
-
-
-    private FieldDeclaration f1 = null;         // a field
-    private FieldDeclaration f2 = null;         // a static field
-    private FieldDeclaration f3 = null;         // a constant field
-
-    protected void init() {
-        f1 = getField("aField");
-        f2 = getField("aStaticField");
-        f3 = getField("aConstantField");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="field")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        f1.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitFieldDeclaration(FieldDeclaration f) {
-                res.add("field");
-            }
-            public void visitEnumConstantDeclaration(
-                                                EnumConstantDeclaration e) {
-                res.add("enum const");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@FieldDecl.AT1"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return f1.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return f1.getDocComment();
-    }
-
-    @Test(result={"public"})
-    Collection<Modifier> getModifiers() {
-        return f1.getModifiers();
-    }
-
-    @Test(result="FieldDecl.java")
-    String getPosition() {
-        return f1.getPosition().file().getName();
-    }
-
-    @Test(result="aField")
-    String getSimpleName() {
-        return f1.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="FieldDecl")
-    TypeDeclaration getDeclaringType() {
-        return f1.getDeclaringType();
-    }
-
-
-    // FieldDeclaration methods
-
-    @Test(result="java.util.List<java.lang.String>")
-    TypeMirror getType1() {
-        return f1.getType();
-    }
-
-    @Test(result="int")
-    TypeMirror getType2() {
-        return f2.getType();
-    }
-
-    @Test(result="null")
-    Object getConstantValue1() {
-        return f1.getConstantValue();
-    }
-
-    // 5008309: FieldDeclaration.getConstantValue() doesn't return anything
-    @Test(result="true")
-    Object getConstantValue2() {
-        return f3.getConstantValue();
-    }
-
-
-    // toString
-
-    @Test(result="aField")
-    String toStringTest() {
-        return f1.toString();
-    }
-
-
-    // Declarations used by tests.
-
-    /**
-     * Sed Quis custodiet ipsos custodes?
-     */
-    @AT1
-    public List<String> aField = new ArrayList<String>();
-
-    static int aStaticField;
-
-    public static final boolean aConstantField = true;
-
-
-    @interface AT1 {
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/GetAnno.java b/test/tools/apt/mirror/declaration/GetAnno.java
deleted file mode 100644
index f219335..0000000
--- a/test/tools/apt/mirror/declaration/GetAnno.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4989091 5050782 5051962
- * @summary Tests Declaration.getAnnotation method
- * @library ../../lib
- * @compile -source 1.5 GetAnno.java
- * @run main/othervm GetAnno
- */
-
-
-import java.lang.annotation.*;
-import java.util.*;
-
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-
-import static java.lang.annotation.RetentionPolicy.*;
-
-
-public class GetAnno extends Tester {
-
-    public static void main(String[] args) {
-        (new GetAnno()).run();
-    }
-
-
-    // Annotations used by tests
-
-    @Retention(RUNTIME)
-    @interface AT1 {
-        long l();
-        String s();
-        RetentionPolicy e();
-        String[] sa();
-        AT2 a();
-    }
-
-    @Inherited
-    @interface AT2 {
-    }
-
-    @interface AT3 {
-        Class value() default String.class;
-    }
-
-    // Array-valued elements of various kinds.
-    @interface AT4 {
-        boolean[] bs();
-        long[] ls();
-        String[] ss();
-        RetentionPolicy[] es();
-        AT2[] as();
-    }
-
-
-    @Test(result="@GetAnno$AT1(l=7, s=sigh, e=CLASS, sa=[in, out], " +
-                              "a=@GetAnno$AT2())")
-    @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2)
-    public Annotation getAnnotation() {
-        MethodDeclaration m = getMethod("getAnnotation");
-        AT1 a = m.getAnnotation(AT1.class);
-        if (a.l() != 7 || !a.s().equals("sigh") || a.e() != CLASS)
-            throw new AssertionError();
-        return a;
-    }
-
-    @Test(result="null")
-    public Annotation getAnnotationNotThere() {
-        return thisClassDecl.getAnnotation(Deprecated.class);
-    }
-
-    @Test(result="@GetAnno$AT4(bs=[true, false], " +
-                              "ls=[9, 8], " +
-                              "ss=[black, white], " +
-                              "es=[CLASS, SOURCE], " +
-                              "as=[@GetAnno$AT2(), @GetAnno$AT2()])")
-    @AT4(bs={true, false},
-         ls={9, 8},
-         ss={"black", "white"},
-         es={CLASS, SOURCE},
-         as={@AT2, @AT2})
-    public AT4 getAnnotationArrayValues() {
-        MethodDeclaration m = getMethod("getAnnotationArrayValues");
-        return m.getAnnotation(AT4.class);
-    }
-
-    @Test(result="@GetAnno$AT3(value=java.lang.String)")
-    @AT3(String.class)
-    public AT3 getAnnotationWithClass1() {
-        MethodDeclaration m = getMethod("getAnnotationWithClass1");
-        return m.getAnnotation(AT3.class);
-    }
-
-    @Test(result="java.lang.String")
-    public TypeMirror getAnnotationWithClass2() {
-        AT3 a = getAnnotationWithClass1();
-        try {
-            Class c = a.value();
-            throw new AssertionError();
-        } catch (MirroredTypeException e) {
-            return e.getTypeMirror();
-        }
-    }
-
-    @Test(result="boolean")
-    @AT3(boolean.class)
-    public TypeMirror getAnnotationWithPrim() {
-        MethodDeclaration m = getMethod("getAnnotationWithPrim");
-        AT3 a = m.getAnnotation(AT3.class);
-        try {
-            Class c = a.value();
-            throw new AssertionError();
-        } catch (MirroredTypeException e) {
-            return e.getTypeMirror();
-        }
-    }
-
-    // 5050782
-    @Test(result="null")
-    public AT2 getInheritedAnnotation() {
-        return thisClassDecl.getAnnotation(AT2.class);
-    }
-
-    /**
-     * Verify that an annotation created by Declaration.getAnnotation()
-     * has the same hash code as a like annotation created by core
-     * reflection.
-     */
-    @Test(result="true")
-    @AT1(l=7, s="sigh", e=CLASS, sa={"in", "out"}, a=@AT2)
-    public boolean getAnnotationHashCode() {
-        MethodDeclaration m1 = getMethod("getAnnotationHashCode");
-        AT1 a1 = m1.getAnnotation(AT1.class);
-        java.lang.reflect.Method m2 = null;
-        try {
-            m2 = this.getClass().getMethod("getAnnotationHashCode");
-        } catch (NoSuchMethodException e) {
-            assert false;
-        }
-        AT1 a2 = m2.getAnnotation(AT1.class);
-        return a1.hashCode() == a2.hashCode();
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/InterfaceDecl.java b/test/tools/apt/mirror/declaration/InterfaceDecl.java
deleted file mode 100644
index f0552f3..0000000
--- a/test/tools/apt/mirror/declaration/InterfaceDecl.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 4993303 5004618 5010746
- * @summary InterfaceDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 InterfaceDecl.java
- * @run main/othervm InterfaceDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-/**
- * Sed Quis custodiet ipsos custodes?
- */
- at AT1
- at AT2
-public class InterfaceDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new InterfaceDecl()).run();
-    }
-
-
-    private InterfaceDeclaration iDecl = null;          // an interface
-    private InterfaceDeclaration nested = null;         // a nested interface
-
-    protected void init() {
-        iDecl = (InterfaceDeclaration) env.getTypeDeclaration("I");
-        nested = (InterfaceDeclaration)
-            iDecl.getNestedTypes().iterator().next();
-    }
-
-
-    // Declaration methods
-
-    @Test(result="interface")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        iDecl.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitClassDeclaration(ClassDeclaration c) {
-                res.add("class");
-            }
-            public void visitInterfaceDeclaration(InterfaceDeclaration e) {
-                res.add("interface");
-            }
-            public void visitAnnotationTypeDeclaration(
-                                        AnnotationTypeDeclaration e) {
-                res.add("annotation type");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="true")
-    boolean equals1() {
-        return iDecl.equals(iDecl);
-    }
-
-    @Test(result="false")
-    boolean equals2() {
-        return iDecl.equals(nested);
-    }
-
-    @Test(result="true")
-    boolean equals3() {
-        return iDecl.equals(env.getTypeDeclaration("I"));
-    }
-
-
-    @Test(result={"@AT1", "@AT2"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return iDecl.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return iDecl.getDocComment();
-    }
-
-    // Check that interface has "abstract" modifier, even though it's implict
-    // in the source code.
-    @Test(result={"abstract"})
-    Collection<Modifier> getModifiers1() {
-        return iDecl.getModifiers();
-    }
-
-    // Check that nested interface has "static" modifier, even though
-    // it's implicit in the source code and the VM doesn't set that bit.
-    @Test(result={"public", "abstract", "static"})
-    Collection<Modifier> getModifiers2() {
-        return nested.getModifiers();
-    }
-
-    @Test(result="InterfaceDecl.java")
-    String getPosition() {
-        return iDecl.getPosition().file().getName();
-    }
-
-    @Test(result="I")
-    String getSimpleName1() {
-        return iDecl.getSimpleName();
-    }
-
-    @Test(result="Nested")
-    String getSimpleName2() {
-        return nested.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="null")
-    TypeDeclaration getDeclaringType1() {
-        return iDecl.getDeclaringType();
-    }
-
-    @Test(result="I<T extends java.lang.Number>")
-    TypeDeclaration getDeclaringType2() {
-        return nested.getDeclaringType();
-    }
-
-
-    // TypeDeclaration methods
-
-    @Test(result={"i"})
-    Collection<FieldDeclaration> getFields() {
-        return iDecl.getFields();
-    }
-
-    @Test(result={"T extends java.lang.Number"})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
-        return iDecl.getFormalTypeParameters();
-    }
-
-    @Test(result={})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
-        return nested.getFormalTypeParameters();
-    }
-
-    // 4993303: verify policy on Object methods being visible
-    @Test(result={"m()", "toString()"})
-    Collection<? extends MethodDeclaration> getMethods() {
-        return nested.getMethods();
-    }
-
-    @Test(result="I.Nested")
-    Collection<TypeDeclaration> getNestedTypes() {
-        return iDecl.getNestedTypes();
-    }
-
-    @Test(result="")
-    PackageDeclaration getPackage1() {
-        return iDecl.getPackage();
-    }
-
-    @Test(result="java.util")
-    PackageDeclaration getPackage2() {
-        InterfaceDeclaration set =
-            (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set");
-        return set.getPackage();
-    }
-
-    @Test(result="I")
-    String getQualifiedName1() {
-        return iDecl.getQualifiedName();
-    }
-
-    @Test(result="I.Nested")
-    String getQualifiedName2() {
-        return nested.getQualifiedName();
-    }
-
-    @Test(result="java.util.Set")
-    String getQualifiedName3() {
-        InterfaceDeclaration set =
-            (InterfaceDeclaration) env.getTypeDeclaration("java.util.Set");
-        return set.getQualifiedName();
-    }
-
-    @Test(result="java.lang.Runnable")
-    Collection<InterfaceType> getSuperinterfaces() {
-        return iDecl.getSuperinterfaces();
-    }
-}
-
-
-// Interfaces used for testing.
-
-/**
- * Sed Quis custodiet ipsos custodes?
- */
- at AT1
- at AT2
-interface I<T extends Number> extends Runnable {
-    int i = 6;
-    void m1();
-    void m2();
-    void m2(int j);
-
-    interface Nested {
-        void m();
-        String toString();
-    }
-}
-
- at interface AT1 {
-}
-
- at interface AT2 {
-}
diff --git a/test/tools/apt/mirror/declaration/MethodDecl.java b/test/tools/apt/mirror/declaration/MethodDecl.java
deleted file mode 100644
index 9164c76..0000000
--- a/test/tools/apt/mirror/declaration/MethodDecl.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5010746
- * @summary MethodDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 MethodDecl.java
- * @run main/othervm MethodDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class MethodDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new MethodDecl()).run();
-    }
-
-
-    private MethodDeclaration meth1 = null;             // a method
-    private MethodDeclaration meth2 = null;             // another method
-
-    protected void init() {
-        meth1 = getMethod("m1");
-        meth2 = getMethod("m2");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="method")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        meth1.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitExecutableDeclaration(ExecutableDeclaration e) {
-                res.add("executable");
-            }
-            public void visitMethodDeclaration(MethodDeclaration m) {
-                res.add("method");
-            }
-            public void visitAnnotationTypeElementDeclaration(
-                                        AnnotationTypeElementDeclaration a) {
-                res.add("anno type element");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@AT1"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return meth1.getAnnotationMirrors();
-    }
-
-    @Test(result=" Sed Quis custodiet ipsos custodes?\n")
-    String getDocComment() {
-        return meth1.getDocComment();
-    }
-
-    @Test(result={"private", "static", "strictfp"})
-    Collection<Modifier> getModifiers() {
-        return meth1.getModifiers();
-    }
-
-    // Interface methods are implicitly public and abstract.
-    @Test(result={"public", "abstract"})
-    Collection<Modifier> getModifiersInterface() {
-        for (TypeDeclaration t : thisClassDecl.getNestedTypes()) {
-            for (MethodDeclaration m : t.getMethods()) {
-                return m.getModifiers();
-            }
-        }
-        throw new AssertionError();
-    }
-
-    @Test(result="MethodDecl.java")
-    String getPosition() {
-        return meth1.getPosition().file().getName();
-    }
-
-    @Test(result="m2")
-    String getSimpleName() {
-        return meth2.getSimpleName();
-    }
-
-
-    // MemberDeclaration method
-
-    @Test(result="MethodDecl")
-    TypeDeclaration getDeclaringType() {
-        return meth1.getDeclaringType();
-    }
-
-
-    // ExecutableDeclaration methods
-
-    @Test(result={})
-    Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
-        return meth1.getFormalTypeParameters();
-    }
-
-    @Test(result={"T", "N extends java.lang.Number"},
-          ordered=true)
-    Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
-        return meth2.getFormalTypeParameters();
-    }
-
-    @Test(result={})
-    Collection<ParameterDeclaration> getParameters1() {
-        return meth1.getParameters();
-    }
-
-    @Test(result={"N n", "java.lang.String[] ss"},
-          ordered=true)
-    Collection<ParameterDeclaration> getParameters2() {
-        return meth2.getParameters();
-    }
-
-    @Test(result="true")
-    boolean parameterEquals1() {
-        ParameterDeclaration p1 =
-            getMethod("m3").getParameters().iterator().next();
-        ParameterDeclaration p2 =
-            getMethod("m3").getParameters().iterator().next();
-        return p1.equals(p2);
-    }
-
-    @Test(result="false")
-    boolean parameterEquals2() {
-        ParameterDeclaration p1 =
-            getMethod("m3").getParameters().iterator().next();
-        ParameterDeclaration p2 =
-            getMethod("m4").getParameters().iterator().next();
-        return p1.equals(p2);
-    }
-
-    @Test(result="true")
-    boolean parameterHashCode() {
-        ParameterDeclaration p1 =
-            getMethod("m3").getParameters().iterator().next();
-        ParameterDeclaration p2 =
-            getMethod("m3").getParameters().iterator().next();
-        return p1.hashCode() == p2.hashCode();
-    }
-
-    @Test(result={"java.lang.Throwable"})
-    Collection<ReferenceType> getThrownTypes() {
-        return meth2.getThrownTypes();
-    }
-
-    @Test(result="false")
-    Boolean isVarArgs1() {
-        return meth1.isVarArgs();
-    }
-
-    @Test(result="true")
-    Boolean isVarArgs2() {
-        return meth2.isVarArgs();
-    }
-
-
-    // MethodDeclaration methods
-
-    @Test(result="void")
-    TypeMirror getReturnType1() {
-        return meth1.getReturnType();
-    }
-
-    @Test(result="N")
-    TypeMirror getReturnType2() {
-        return meth2.getReturnType();
-    }
-
-
-    // toString
-
-    @Test(result="<T, N extends java.lang.Number> m2(N, java.lang.String...)")
-    @Ignore("This is what it would be nice to see.")
-    String toStringTest() {
-        return meth2.toString();
-    }
-
-
-    // Declarations used by tests.
-
-    /**
-     * Sed Quis custodiet ipsos custodes?
-     */
-    @AT1
-    private static strictfp void m1() {
-    }
-
-    private <T, N extends Number> N m2(N n, String... ss) throws Throwable {
-        return null;
-    }
-
-    private void m3(String s) {
-    }
-
-    private void m4(String s) {
-    }
-
-    // A nested interface
-    interface I {
-        void m();
-    }
-}
-
-
-// Annotation type used by tests.
-
- at interface AT1 {
-}
diff --git a/test/tools/apt/mirror/declaration/PackageDecl.java b/test/tools/apt/mirror/declaration/PackageDecl.java
deleted file mode 100644
index e6755d7..0000000
--- a/test/tools/apt/mirror/declaration/PackageDecl.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5031168
- * @summary PackageDeclaration tests
- * @library ../../lib
- * @compile -source 1.5 PackageDecl.java
- * @run main/othervm PackageDecl
- */
-
-
-import java.io.File;
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import pkg1.pkg2.*;
-
-
-/**
- * Sed Quis custodiet ipsos custodes?
- */
-public class PackageDecl extends Tester {
-
-    public PackageDecl() {
-        super(System.getProperty("test.src", ".") + File.separator +
-              "pkg1" + File.separator + "package-info.java");
-    }
-
-    public static void main(String[] args) {
-        (new PackageDecl()).run();
-    }
-
-
-    private PackageDeclaration pkg1 = null;             // a package
-    private PackageDeclaration pkg2 = null;             // a subpackage
-
-    protected void init() {
-        pkg1 = env.getPackage("pkg1");
-        pkg2 = env.getPackage("pkg1.pkg2");
-    }
-
-
-    // Declaration methods
-
-    @Test(result="package")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        pkg1.accept(new SimpleDeclarationVisitor() {
-            public void visitTypeDeclaration(TypeDeclaration t) {
-                res.add("type");
-            }
-            public void visitPackageDeclaration(PackageDeclaration p) {
-                res.add("package");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@pkg1.AnAnnoType"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return pkg1.getAnnotationMirrors();
-    }
-
-    @Test(result=" Herein lieth the package comment.\n" +
-                 " A doc comment it be, and wonderous to behold.\n")
-    String getDocCommentFromPackageInfoFile() {
-        return pkg1.getDocComment();
-    }
-
-    @Test(result="\nHerein lieth the package comment.\n" +
-                 "An HTML file it be, and wonderous to behold.\n\n")
-    @Ignore("Not yet supported")
-    String getDocCommentFromHtmlFile() {
-        return pkg2.getDocComment();
-    }
-
-    @Test(result={})
-    Collection<Modifier> getModifiers() {
-        return pkg1.getModifiers();
-    }
-
-    @Test(result="null")
-    SourcePosition getPosition() {
-        return thisClassDecl.getPackage().getPosition();
-    }
-
-    @Test(result="package-info.java")
-    String getPositionFromPackageInfoFile() {
-        return pkg1.getPosition().file().getName();
-    }
-
-    @Test(result="pkg1/pkg2/package.html")
-    @Ignore("Not yet supported")
-    String getPositionFromHtmlFile() {
-        return pkg2.getPosition().file().getName()
-                                            .replace(File.separatorChar, '/');
-    }
-
-    @Test(result="pkg1")
-    String getSimpleName1() {
-        return pkg1.getSimpleName();
-    }
-
-    @Test(result="pkg2")
-    String getSimpleName2() {
-        return pkg2.getSimpleName();
-    }
-
-
-    // PackageDeclaration methods
-
-    @Test(result="pkg1.AnAnnoType")
-    Collection<AnnotationTypeDeclaration> getAnnotationTypes() {
-        return pkg1.getAnnotationTypes();
-    }
-
-    @Test(result={"pkg1.AClass", "pkg1.AnEnum"})
-    Collection<ClassDeclaration> getClasses() {
-        return pkg1.getClasses();
-    }
-
-    @Test(result="pkg1.AnEnum")
-    Collection<EnumDeclaration> getEnums() {
-        return pkg1.getEnums();
-    }
-
-    @Test(result={"pkg1.AnInterface", "pkg1.AnAnnoType"})
-    Collection<InterfaceDeclaration> getInterfaces() {
-        return pkg1.getInterfaces();
-    }
-
-    @Test(result="pkg1")
-    String getQualifiedName1() {
-        return pkg1.getQualifiedName();
-    }
-
-    @Test(result="pkg1.pkg2")
-    String getQualifiedName2() {
-        return pkg2.getQualifiedName();
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/ParameterDecl.java b/test/tools/apt/mirror/declaration/ParameterDecl.java
deleted file mode 100644
index 16ba605..0000000
--- a/test/tools/apt/mirror/declaration/ParameterDecl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5031171
- * @summary ParameterDeclaration tests
- * @library ../../lib
- * @run main/othervm ParameterDecl
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class ParameterDecl extends Tester {
-
-    public static void main(String[] args) {
-        (new ParameterDecl()).run();
-    }
-
-
-    // Declarations used by tests
-
-    @interface AT1 {
-    }
-
-    @interface AT2 {
-        boolean value();
-    }
-
-    private void m1(@AT1 @AT2(true) final int p1) {
-    }
-
-    private void m2(int p1) {
-    }
-
-
-    private ParameterDeclaration p1 = null;     // a parameter
-
-    protected void init() {
-        p1 = getMethod("m1").getParameters().iterator().next();
-    }
-
-
-    // Declaration methods
-
-    @Test(result="param")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        p1.accept(new SimpleDeclarationVisitor() {
-            public void visitFieldDeclaration(FieldDeclaration f) {
-                res.add("field");
-            }
-            public void visitParameterDeclaration(ParameterDeclaration p) {
-                res.add("param");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={"@ParameterDecl.AT1", "@ParameterDecl.AT2(true)"})
-    Collection<AnnotationMirror> getAnnotationMirrors() {
-        return p1.getAnnotationMirrors();
-    }
-
-    @Test(result={"final"})
-    Collection<Modifier> getModifiers() {
-        return p1.getModifiers();
-    }
-
-    @Test(result="ParameterDecl.java")
-    String getPosition() {
-        return p1.getPosition().file().getName();
-    }
-
-    @Test(result="p1")
-    String getSimpleName() {
-        return p1.getSimpleName();
-    }
-
-
-    // ParameterDeclaration methods
-
-    @Test(result="int")
-    TypeMirror getType() {
-        return p1.getType();
-    }
-
-
-    // toString, equals
-
-    @Test(result="int p1")
-    String toStringTest() {
-        return p1.toString();
-    }
-
-    @Test(result="true")
-    boolean equalsTest1() {
-        ParameterDeclaration p =
-            getMethod("m1").getParameters().iterator().next();
-        return p1.equals(p);
-    }
-
-    // Not all p1's are equal.
-    @Test(result="false")
-    boolean equalsTest2() {
-        ParameterDeclaration p2 =
-            getMethod("m2").getParameters().iterator().next();
-        return p1.equals(p2);
-    }
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/AClass.java b/test/tools/apt/mirror/declaration/pkg1/AClass.java
deleted file mode 100644
index 649f225..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/AClass.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 pkg1;
-
-public class AClass {
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java b/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java
deleted file mode 100644
index 81f9287..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 pkg1;
-
-public @interface AnAnnoType {
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/AnEnum.java b/test/tools/apt/mirror/declaration/pkg1/AnEnum.java
deleted file mode 100644
index 4981470..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/AnEnum.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 pkg1;
-
-enum AnEnum {
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/AnInterface.java b/test/tools/apt/mirror/declaration/pkg1/AnInterface.java
deleted file mode 100644
index 8bab6fe..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/AnInterface.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 pkg1;
-
-public interface AnInterface {
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/package-info.java b/test/tools/apt/mirror/declaration/pkg1/package-info.java
deleted file mode 100644
index cb84fa3..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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.
- */
-
-
-/**
- * Herein lieth the package comment.
- * A doc comment it be, and wonderous to behold.
- */
- at AnAnnoType
-package pkg1;
diff --git a/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java b/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java
deleted file mode 100644
index fcee5d1..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2004, 2007, 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 pkg1.pkg2;
-
-public interface AnInterface {
-}
diff --git a/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html b/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html
deleted file mode 100644
index f3a82a1..0000000
--- a/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-Copyright (c) 2004, 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.
--->
-
-</head>
-<body bgcolor="white">
-
-Herein lieth the package comment.
-An HTML file it be, and wonderous to behold.
-
-</body>
-</html>
diff --git a/test/tools/apt/mirror/type/AnnoTyp.java b/test/tools/apt/mirror/type/AnnoTyp.java
deleted file mode 100644
index b064b46..0000000
--- a/test/tools/apt/mirror/type/AnnoTyp.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450
- * @summary AnnotationType tests
- * @library ../../lib
- * @compile -source 1.5 AnnoTyp.java
- * @run main/othervm AnnoTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class AnnoTyp extends Tester {
-
-    public static void main(String[] args) {
-        (new AnnoTyp()).run();
-    }
-
-
-    // Declaration used by tests
-
-    @interface AT {
-    }
-
-
-    private AnnotationType at;  // an annotation type
-
-    @AT
-    protected void init() {
-        at = getAnno("init", "AnnoTyp.AT").getAnnotationType();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="anno type")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        at.accept(new SimpleTypeVisitor() {
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitClassType(ClassType t) {
-                res.add("class");
-            }
-            public void visitInterfaceType(InterfaceType t) {
-                res.add("interface");
-            }
-            public void visitAnnotationType(AnnotationType t) {
-                res.add("anno type");
-            }
-        });
-        return res;
-    }
-
-
-    // AnnotationType method
-
-    @Test(result="AnnoTyp.AT")
-    AnnotationTypeDeclaration getDeclaration() {
-        return at.getDeclaration();
-    }
-}
diff --git a/test/tools/apt/mirror/type/ArrayTyp.java b/test/tools/apt/mirror/type/ArrayTyp.java
deleted file mode 100644
index b2cbba7..0000000
--- a/test/tools/apt/mirror/type/ArrayTyp.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5009357
- * @summary ArrayType tests
- * @library ../../lib
- * @compile -source 1.5 ArrayTyp.java
- * @run main/othervm ArrayTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class ArrayTyp extends Tester {
-
-    public static void main(String[] args) {
-        (new ArrayTyp()).run();
-    }
-
-
-    // Declaration used by tests
-
-    private boolean[] bs;
-    private String[][] bss;
-
-
-    private ArrayType arr;              // an array type
-    private ArrayType arrarr;           // a multi-dimensional array type
-
-    protected void init() {
-        arr = (ArrayType) getField("bs").getType();
-        arrarr = (ArrayType) getField("bss").getType();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="array")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        arr.accept(new SimpleTypeVisitor() {
-            public void visitTypeMirror(TypeMirror t) {
-                res.add("type");
-            }
-            public void visitArrayType(ArrayType t) {
-                res.add("array");
-            }
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="boolean[]")
-    String toStringTest() {
-        return arr.toString();
-    }
-
-    @Test(result="java.lang.String[][]")
-    String toStringTestMulti() {
-        return arrarr.toString();
-    }
-
-
-    // ArrayType method
-
-    @Test(result="boolean")
-    TypeMirror getComponentType() {
-        return (PrimitiveType) arr.getComponentType();
-    }
-
-    @Test(result="java.lang.String[]")
-    TypeMirror getComponentTypeMulti() {
-        return (ArrayType) arrarr.getComponentType();
-    }
-}
diff --git a/test/tools/apt/mirror/type/ClassTyp.java b/test/tools/apt/mirror/type/ClassTyp.java
deleted file mode 100644
index fadafb9..0000000
--- a/test/tools/apt/mirror/type/ClassTyp.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5009360 5055963
- * @summary ClassType tests
- * @library ../../lib
- * @run main/othervm ClassTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class ClassTyp<T1,T2> extends Tester {
-
-    public static void main(String[] args) {
-        (new ClassTyp()).run();
-    }
-
-
-    // Declarations used by tests
-
-    static class C1<S> extends AbstractSet<S> implements Set<S> {
-        class C2<R> {
-        }
-
-        static class C3<R> {
-            class C4<Q> {
-            }
-        }
-
-        public Iterator<S> iterator() {
-            return null;
-        }
-
-        public int size() {
-            return 0;
-        }
-    }
-
-
-    // Generate some class types to test.
-    private C1<T1> f0;
-    private C1<String> f1;
-    private C1 f2;
-    private C1.C3<T2> f3;
-    private C1<T1>.C2<T2> f4;
-    private C1.C2 f5;
-    private C1<T1> f6;
-    private C1.C3<T2>.C4<T1> f7;
-    private static final int NUMTYPES = 8;
-
-    // Type mirrors corresponding to the types of the above fields
-    private ClassType[] t = new ClassType[NUMTYPES];
-
-    // One more type:  our own.
-    private ClassTyp<T1,T2> me = this;
-
-
-    protected void init() {
-        for (int i = 0; i < t.length; i++) {
-            t[i] = (ClassType) getField("f"+i).getType();
-        }
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="class")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        t[0].accept(new SimpleTypeVisitor() {
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitClassType(ClassType t) {
-                res.add("class");
-            }
-            public void visitInterfaceType(InterfaceType t) {
-                res.add("interface");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="true")
-    boolean equals1() {
-        return t[0].equals(t[0]);
-    }
-
-    @Test(result="false")
-    boolean equals2() {
-        return t[0].equals(t[1]);
-    }
-
-    // Raw type is not same as type instantiated with unbounded type var.
-    @Test(result="false")
-    boolean equals3() {
-        return t[0].equals(t[2]);
-    }
-
-    // C1<T1> is same type as C1<T1>
-    @Test(result="true")
-    boolean equals4() {
-        return t[0].equals(t[6]);
-    }
-
-    @Test(result={
-              "ClassTyp.C1<T1>",
-              "ClassTyp.C1<java.lang.String>",
-              "ClassTyp.C1",
-              "ClassTyp.C1.C3<T2>",
-              "ClassTyp.C1<T1>.C2<T2>",
-              "ClassTyp.C1.C2",
-              "ClassTyp.C1<T1>",
-              "ClassTyp.C1.C3<T2>.C4<T1>"
-          },
-          ordered=true)
-    Collection<String> toStringTests() {
-        Collection<String> res = new ArrayList<String>();
-        for (ClassType c : t) {
-            res.add(c.toString());
-        }
-        return res;
-    }
-
-
-    // DeclaredType methods
-
-    @Test(result={"T1"})
-    Collection<TypeMirror> getActualTypeArguments1() {
-        return t[0].getActualTypeArguments();
-    }
-
-    @Test(result={})
-    Collection<TypeMirror> getActualTypeArguments2() {
-        return t[2].getActualTypeArguments();
-    }
-
-    @Test(result={"T2"})
-    Collection<TypeMirror> getActualTypeArguments3() {
-        return t[3].getActualTypeArguments();
-    }
-
-    @Test(result="null")
-    DeclaredType getContainingType1() {
-        ClassType thisType = (ClassType) getField("me").getType();
-        return thisType.getContainingType();
-    }
-
-    @Test(result="ClassTyp")
-    DeclaredType getContainingType2() {
-        return t[0].getContainingType();
-    }
-
-    @Test(result="ClassTyp.C1")
-    DeclaredType getContainingType3() {
-        return t[3].getContainingType();
-    }
-
-    @Test(result="ClassTyp.C1<T1>")
-    DeclaredType getContainingType4() {
-        return t[4].getContainingType();
-    }
-
-    @Test(result={"java.util.Set<T1>"})
-    Collection<InterfaceType> getSuperinterfaces() {
-        return t[0].getSuperinterfaces();
-    }
-
-
-    // ClassType methods
-
-    @Test(result="ClassTyp.C1<S>")
-    ClassDeclaration getDeclaration1() {
-        return t[0].getDeclaration();
-    }
-
-    @Test(result="ClassTyp.C1.C3<R>")
-    ClassDeclaration getDeclaration2() {
-        return t[3].getDeclaration();
-    }
-
-    @Test(result="ClassTyp.C1<S>.C2<R>")
-    ClassDeclaration getDeclaration3a() {
-        return t[4].getDeclaration();
-    }
-
-    @Test(result="ClassTyp.C1<S>.C2<R>")
-    ClassDeclaration getDeclaration3b() {
-        return t[5].getDeclaration();
-    }
-
-    @Test(result="true")
-    boolean getDeclarationEq() {
-        return t[0].getDeclaration() == t[6].getDeclaration();
-    }
-
-    @Test(result="java.util.AbstractSet<T1>")
-    ClassType getSuperclass1() {
-        return t[0].getSuperclass();
-    }
-
-    @Test(result="java.lang.Object")
-    ClassType getSuperclass2() {
-        return t[4].getSuperclass();
-    }
-
-    @Test(result="null")
-    ClassType getSuperclassOfObject() {
-        return t[4].getSuperclass().getSuperclass();
-    }
-}
diff --git a/test/tools/apt/mirror/type/EnumTyp.java b/test/tools/apt/mirror/type/EnumTyp.java
deleted file mode 100644
index 5eac088..0000000
--- a/test/tools/apt/mirror/type/EnumTyp.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450
- * @summary EnumType tests
- * @library ../../lib
- * @compile -source 1.5 EnumTyp.java
- * @run main/othervm EnumTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class EnumTyp extends Tester {
-
-    public static void main(String[] args) {
-        (new EnumTyp()).run();
-    }
-
-
-    // Declarations used by tests
-
-    enum Suit {
-        CIVIL,
-        CRIMINAL
-    }
-
-    private Suit s;
-
-
-    private EnumType e;         // an enum type
-
-    protected void init() {
-        e = (EnumType) getField("s").getType();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="enum")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        e.accept(new SimpleTypeVisitor() {
-            public void visitTypeMirror(TypeMirror t) {
-                res.add("type");
-            }
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitClassType(ClassType t) {
-                res.add("class");
-            }
-            public void visitEnumType(EnumType t) {
-                res.add("enum");
-            }
-            public void visitInterfaceType(InterfaceType t) {
-                res.add("interface");
-            }
-        });
-        return res;
-    }
-
-
-    // EnumType method
-
-    @Test(result="EnumTyp.Suit")
-    EnumDeclaration getDeclaration() {
-        return e.getDeclaration();
-    }
-}
diff --git a/test/tools/apt/mirror/type/InterfaceTyp.java b/test/tools/apt/mirror/type/InterfaceTyp.java
deleted file mode 100644
index d001449..0000000
--- a/test/tools/apt/mirror/type/InterfaceTyp.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5055963
- * @summary InterfaceType tests
- * @library ../../lib
- * @run main/othervm InterfaceTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class InterfaceTyp<T1,T2> extends Tester {
-
-    public static void main(String[] args) {
-        (new InterfaceTyp()).run();
-    }
-
-
-    // Declarations used by tests
-
-    interface I1<S> extends Set<String> {
-        interface I2<R> {
-        }
-    }
-
-
-    // Generate some interface types to test
-    private I1<T1> f0;
-    private I1<String> f1;
-    private I1 f2;
-    private I1.I2<String> f3;
-    private I1.I2 f4;
-    private I1<T1> f5;
-    private I3<T1> f6;
-    private static final int NUMTYPES = 7;
-
-    // Type mirrors corresponding to the types of the above fields
-    private InterfaceType[] t = new InterfaceType[NUMTYPES];
-
-    protected void init() {
-        for (int i = 0; i < t.length; i++) {
-            t[i] = (InterfaceType) getField("f"+i).getType();
-        }
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="interface")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        t[0].accept(new SimpleTypeVisitor() {
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitClassType(ClassType t) {
-                res.add("class");
-            }
-            public void visitInterfaceType(InterfaceType t) {
-                res.add("interface");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="true")
-    boolean equals1() {
-        return t[0].equals(t[0]);
-    }
-
-    @Test(result="false")
-    boolean equals2() {
-        return t[0].equals(t[1]);
-    }
-
-    // Raw type is not same as type instantiated with unbounded type var.
-    @Test(result="false")
-    boolean equals3() {
-        return t[0].equals(t[2]);
-    }
-
-    // I1<T1> is same type as I1<T1>
-    @Test(result="true")
-    boolean equals4() {
-        return t[0].equals(t[5]);
-    }
-
-    @Test(result={
-              "InterfaceTyp.I1<T1>",
-              "InterfaceTyp.I1<java.lang.String>",
-              "InterfaceTyp.I1",
-              "InterfaceTyp.I1.I2<java.lang.String>",
-              "InterfaceTyp.I1.I2",
-              "InterfaceTyp.I1<T1>",
-              "I3<T1>"
-          },
-          ordered=true)
-    Collection<String> toStringTests() {
-        Collection<String> res = new ArrayList<String>();
-        for (InterfaceType i : t) {
-            res.add(i.toString());
-        }
-        return res;
-    }
-
-
-    // DeclaredType methods
-
-    @Test(result={"T1"})
-    Collection<TypeMirror> getActualTypeArguments1() {
-        return t[0].getActualTypeArguments();
-    }
-
-    @Test(result={})
-    Collection<TypeMirror> getActualTypeArguments2() {
-        return t[2].getActualTypeArguments();
-    }
-
-    @Test(result={"java.lang.String"})
-    Collection<TypeMirror> getActualTypeArguments3() {
-        return t[3].getActualTypeArguments();
-    }
-
-    @Test(result="InterfaceTyp")
-    DeclaredType getContainingType1() {
-        return t[0].getContainingType();
-    }
-
-    @Test(result="InterfaceTyp.I1")
-    DeclaredType getContainingType2() {
-        return t[3].getContainingType();
-    }
-
-    @Test(result="null")
-    DeclaredType getContainingTypeTopLevel() {
-        return t[6].getContainingType();
-    }
-
-    @Test(result={"java.util.Set<java.lang.String>"})
-    Collection<InterfaceType> getSuperinterfaces() {
-        return t[0].getSuperinterfaces();
-    }
-
-
-
-    // InterfaceType method
-
-    @Test(result="InterfaceTyp.I1<S>")
-    InterfaceDeclaration getDeclaration1() {
-        return t[0].getDeclaration();
-    }
-
-    @Test(result="InterfaceTyp.I1.I2<R>")
-    InterfaceDeclaration getDeclaration2a() {
-        return t[3].getDeclaration();
-    }
-
-    @Test(result="InterfaceTyp.I1.I2<R>")
-    InterfaceDeclaration getDeclaration2b() {
-        return t[4].getDeclaration();
-    }
-
-    @Test(result="true")
-    boolean getDeclarationCaching() {
-        return t[0].getDeclaration() == t[5].getDeclaration();
-    }
-}
-
-
-// A top-level interface used by tests.
-
-interface I3<T> {
-}
diff --git a/test/tools/apt/mirror/type/PrimitiveTyp.java b/test/tools/apt/mirror/type/PrimitiveTyp.java
deleted file mode 100644
index befb4d8..0000000
--- a/test/tools/apt/mirror/type/PrimitiveTyp.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450
- * @summary PrimitiveType tests
- * @library ../../lib
- * @compile -source 1.5 PrimitiveTyp.java
- * @run main/othervm PrimitiveTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class PrimitiveTyp extends Tester {
-
-    public static void main(String[] args) {
-        (new PrimitiveTyp()).run();
-    }
-
-
-    // Declaration used by tests
-
-    private boolean b;
-
-
-    private PrimitiveType prim;         // a primitive type
-
-    protected void init() {
-        prim = (PrimitiveType) getField("b").getType();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="primitive")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        prim.accept(new SimpleTypeVisitor() {
-            public void visitTypeMirror(TypeMirror t) {
-                res.add("type");
-            }
-            public void visitPrimitiveType(PrimitiveType t) {
-                res.add("primitive");
-            }
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="boolean")
-    String toStringTest() {
-        return prim.toString();
-    }
-
-
-    // PrimitiveType method
-
-    @Test(result="BOOLEAN")
-    PrimitiveType.Kind getKind() {
-        return prim.getKind();
-    }
-}
diff --git a/test/tools/apt/mirror/type/TypeVar.java b/test/tools/apt/mirror/type/TypeVar.java
deleted file mode 100644
index d2acd33..0000000
--- a/test/tools/apt/mirror/type/TypeVar.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450
- * @summary TypeVariable tests
- * @library ../../lib
- * @compile -source 1.5 TypeVar.java
- * @run main/othervm TypeVar
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class TypeVar<T, S extends Number & Runnable> extends Tester {
-
-    public static void main(String[] args) {
-        (new TypeVar()).run();
-    }
-
-
-    // Declarations used by tests
-
-    private T t;
-    private S s;
-
-
-    private TypeVariable tvT;   // type variable T
-    private TypeVariable tvS;   // type variable S
-
-    protected void init() {
-        tvT = (TypeVariable) getField("t").getType();
-        tvS = (TypeVariable) getField("s").getType();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="type var")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        tvT.accept(new SimpleTypeVisitor() {
-            public void visitTypeMirror(TypeMirror t) {
-                res.add("type");
-            }
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitTypeVariable(TypeVariable t) {
-                res.add("type var");
-            }
-        });
-        return res;
-    }
-
-    @Test(result="T")
-    String toStringTest1() {
-        return tvT.toString();
-    }
-
-    @Test(result="S")
-    String toStringTest2() {
-        return tvS.toString();
-    }
-
-
-    // TypeVariable method
-
-    @Test(result="S extends java.lang.Number & java.lang.Runnable")
-    TypeParameterDeclaration getDeclaration() {
-        return tvS.getDeclaration();
-    }
-}
diff --git a/test/tools/apt/mirror/type/WildcardTyp.java b/test/tools/apt/mirror/type/WildcardTyp.java
deleted file mode 100644
index cae97b1..0000000
--- a/test/tools/apt/mirror/type/WildcardTyp.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 4853450 5009396 5010636 5031156
- * @summary WildcardType tests
- * @library ../../lib
- * @compile -source 1.5 WildcardTyp.java
- * @run main/othervm WildcardTyp
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class WildcardTyp extends Tester {
-
-    public static void main(String[] args) {
-        (new WildcardTyp()).run();
-    }
-
-
-    // Declarations to use for testing
-
-    interface G<T> {
-    }
-
-    interface G1<N extends Number & Runnable> {
-    }
-
-    interface G2<T extends G2<T>> {
-    }
-
-    // Some wildcard types to test.
-    private G<?> f0;                    // unbound
-    private G<? extends Number> f1;     // covariant
-    private G<? super Number> f2;       // contravariant
-    private G<? extends Object> f3;     // <sigh>
-    private G1<?> f4;   // "true" upper bound is an intersection type
-    private G2<?> f5;   // 'true" upper bound is a recursive F-bound and
-                        // not expressible
-    private static final int NUMTYPES = 6;
-
-    // Type mirrors corresponding to the wildcard types of the above fields
-    private WildcardType[] t = new WildcardType[NUMTYPES];
-
-
-    protected void init() {
-        for (int i = 0; i < t.length; i++) {
-            DeclaredType type = (DeclaredType) getField("f"+i).getType();
-            t[i] = (WildcardType)
-                type.getActualTypeArguments().iterator().next();
-        }
-    }
-
-    private WildcardType wildcardFor(String field) {
-        DeclaredType d = (DeclaredType) getField(field).getType();
-        return (WildcardType) d.getActualTypeArguments().iterator().next();
-    }
-
-
-    // TypeMirror methods
-
-    @Test(result="wild thing")
-    Collection<String> accept() {
-        final Collection<String> res = new ArrayList<String>();
-
-        t[0].accept(new SimpleTypeVisitor() {
-            public void visitTypeMirror(TypeMirror t) {
-                res.add("type");
-            }
-            public void visitReferenceType(ReferenceType t) {
-                res.add("ref type");
-            }
-            public void visitWildcardType(WildcardType t) {
-                res.add("wild thing");
-            }
-        });
-        return res;
-    }
-
-    @Test(result={
-                "?",
-                "? extends java.lang.Number",
-                "? super java.lang.Number",
-                "? extends java.lang.Object",
-                "?",
-                "?"
-          },
-          ordered=true)
-    Collection<String> toStringTests() {
-        Collection<String> res = new ArrayList<String>();
-        for (WildcardType w : t) {
-            res.add(w.toString());
-        }
-        return res;
-    }
-
-
-    // WildcardType methods
-
-    @Test(result={
-                "null",
-                "null",
-                "java.lang.Number",
-                "null",
-                "null",
-                "null"
-          },
-          ordered=true)
-    Collection<ReferenceType> getLowerBounds() {
-        Collection<ReferenceType> res = new ArrayList<ReferenceType>();
-        for (WildcardType w : t) {
-            Collection<ReferenceType> bounds = w.getLowerBounds();
-            int num = bounds.size();
-            if (num > 1) {
-                throw new AssertionError("Bounds abound");
-            }
-            res.add((num > 0) ? bounds.iterator().next() : null);
-        }
-        return res;
-    }
-
-    @Test(result={
-                "null",
-                "java.lang.Number",
-                "null",
-                "java.lang.Object",
-                "null",
-                "null"
-          },
-          ordered=true)
-    Collection<ReferenceType> getUpperBounds() {
-        Collection<ReferenceType> res = new ArrayList<ReferenceType>();
-        for (WildcardType w : t) {
-            Collection<ReferenceType> bounds = w.getUpperBounds();
-            int num = bounds.size();
-            if (num > 1) {
-                throw new AssertionError("Bounds abound");
-            }
-            res.add((num > 0) ? bounds.iterator().next() : null);
-        }
-        return res;
-    }
-}
diff --git a/test/tools/apt/mirror/util/Overrides.java b/test/tools/apt/mirror/util/Overrides.java
deleted file mode 100644
index 30ce92c..0000000
--- a/test/tools/apt/mirror/util/Overrides.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 5037165
- * @summary Test the Declarations.overrides method
- * @library ../../lib
- * @run main/othervm Overrides
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-
-public class Overrides extends Tester {
-
-    public static void main(String[] args) {
-        (new Overrides()).run();
-    }
-
-
-    // Declarations used by tests
-
-    static class A {
-        void m1(int i) {};              // does not override itself
-        void m2(int i) {};
-        static void m3(int i) {};
-    }
-
-        static class B extends A {
-            void m1(int j) {};          // overrides A.m1
-            void m1(String i) {};       // does not override A.m1
-            void m4(int i) {};          // does not override A.m1
-        }
-
-            static class C extends B {
-                void m1(int i) {};      // overrides A.m1 and B.m1
-                void m2(int i) {};      // overrides A.m2
-            }
-
-        static class D extends A {
-            static void m3(int i) {};   // does not override A.m3
-        }
-
-    static class E {
-        void m1(int i) {};              // does not override A.m1
-    }
-
-
-
-    private Declarations decls;
-
-    private TypeDeclaration A;
-    private TypeDeclaration B;
-    private TypeDeclaration C;
-    private TypeDeclaration D;
-    private TypeDeclaration E;
-    private MethodDeclaration Am1;
-    private MethodDeclaration Am2;
-    private MethodDeclaration Am3;
-    private MethodDeclaration Bm1;
-    private MethodDeclaration Bm1b;
-    private MethodDeclaration Bm4;
-    private MethodDeclaration Cm1;
-    private MethodDeclaration Cm2;
-    private MethodDeclaration Dm3;
-    private MethodDeclaration Em1;
-
-    protected void init() {
-        decls = env.getDeclarationUtils();
-
-        A = env.getTypeDeclaration("Overrides.A");
-        B = env.getTypeDeclaration("Overrides.B");
-        C = env.getTypeDeclaration("Overrides.C");
-        D = env.getTypeDeclaration("Overrides.D");
-        E = env.getTypeDeclaration("Overrides.E");
-
-        Am1  = getMethod(A, "m1", "i");
-        Am2  = getMethod(A, "m2", "i");
-        Am3  = getMethod(A, "m3", "i");
-        Bm1  = getMethod(B, "m1", "j");
-        Bm1b = getMethod(B, "m1", "i");
-        Bm4  = getMethod(B, "m4", "i");
-        Cm1  = getMethod(C, "m1", "i");
-        Cm2  = getMethod(C, "m2", "i");
-        Dm3  = getMethod(D, "m3", "i");
-        Em1  = getMethod(E, "m1", "i");
-    }
-
-    private MethodDeclaration getMethod(TypeDeclaration t,
-                                        String methodName, String paramName) {
-        for (MethodDeclaration m : t.getMethods()) {
-            if (methodName.equals(m.getSimpleName()) &&
-                    paramName.equals(m.getParameters().iterator().next()
-                                                        .getSimpleName())) {
-                return m;
-            }
-        }
-        throw new AssertionError();
-    }
-
-
-    // Declarations methods
-
-    @Test(result={"false",
-                  "true",
-                  "false",
-                  "false",
-                  "true",
-                  "true",
-                  "true",
-                  "false",
-                  "false"},
-          ordered=true)
-    List<Boolean> overrides() {
-        return Arrays.asList(
-                decls.overrides(Am1, Am1),
-                decls.overrides(Bm1, Am1),
-                decls.overrides(Bm1b,Am1),
-                decls.overrides(Bm4, Am1),
-                decls.overrides(Cm1, Am1),
-                decls.overrides(Cm1, Bm1),
-                decls.overrides(Cm2, Am2),
-                decls.overrides(Dm3, Am3),
-                decls.overrides(Em1, Am1));
-    }
-}
diff --git a/test/tools/apt/mirror/util/TypeCreation.java b/test/tools/apt/mirror/util/TypeCreation.java
deleted file mode 100644
index 699e812..0000000
--- a/test/tools/apt/mirror/util/TypeCreation.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004, 2008, 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 5033381
- * @summary Test the type creation methods in Types.
- * @library ../../lib
- * @run main/othervm TypeCreation
- */
-
-
-import java.util.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import static com.sun.mirror.type.PrimitiveType.Kind.*;
-
-
-public class TypeCreation extends Tester {
-
-    public static void main(String[] args) {
-        (new TypeCreation()).run();
-    }
-
-
-    // Declarations used by tests
-
-    class A {
-    }
-
-    class O<T> {
-        class I<S> {
-        }
-    }
-
-
-    private Types types;
-
-    private TypeDeclaration A;
-    private TypeDeclaration O;
-    private TypeDeclaration I;
-
-    private DeclaredType AType;
-
-    protected void init() {
-        types = env.getTypeUtils();
-        A = env.getTypeDeclaration("TypeCreation.A");
-        O = env.getTypeDeclaration("TypeCreation.O");
-        I = env.getTypeDeclaration("TypeCreation.O.I");
-
-        AType = types.getDeclaredType(A);
-    }
-
-
-    @Test(result="boolean")
-    PrimitiveType getPrimitiveType() {
-        return types.getPrimitiveType(BOOLEAN);
-    }
-
-    @Test(result="void")
-    VoidType getVoidType() {
-        return types.getVoidType();
-    }
-
-    @Test(result="boolean[]")
-    ArrayType getArrayType1() {
-        return types.getArrayType(
-                types.getPrimitiveType(BOOLEAN));
-    }
-
-    @Test(result="TypeCreation.A[]")
-    ArrayType getArrayType2() {
-        return types.getArrayType(AType);
-    }
-
-    @Test(result="? extends TypeCreation.A")
-    WildcardType getWildcardType() {
-        Collection<ReferenceType> uppers = new ArrayList<ReferenceType>();
-        Collection<ReferenceType> downers = new ArrayList<ReferenceType>();
-        uppers.add(AType);
-        return types.getWildcardType(uppers, downers);
-    }
-
-    @Test(result="TypeCreation.O<java.lang.String>")
-    DeclaredType getDeclaredType1() {
-        TypeDeclaration stringDecl = env.getTypeDeclaration("java.lang.String");
-        DeclaredType stringType = types.getDeclaredType(stringDecl);
-        return types.getDeclaredType(O, stringType);
-    }
-
-    @Test(result="TypeCreation.O<java.lang.String>.I<java.lang.Number>")
-    DeclaredType getDeclaredType2() {
-        TypeDeclaration numDecl = env.getTypeDeclaration("java.lang.Number");
-        DeclaredType numType = types.getDeclaredType(numDecl);
-        DeclaredType OType = getDeclaredType1();
-        return types.getDeclaredType(OType, I, numType);
-    }
-}
diff --git a/test/tools/apt/verifyVariables.sh b/test/tools/apt/verifyVariables.sh
deleted file mode 100644
index 153e164..0000000
--- a/test/tools/apt/verifyVariables.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2002, 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.
-#
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-exit 0
diff --git a/test/tools/doclint/AccessTest.java b/test/tools/doclint/AccessTest.java
new file mode 100644
index 0000000..4723e15
--- /dev/null
+++ b/test/tools/doclint/AccessTest.java
@@ -0,0 +1,65 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -ref AccessTest.protected.out AccessTest.java
+ * @run main DocLintTester -Xmsgs -ref AccessTest.private.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref AccessTest.private.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:syntax/public -ref AccessTest.public.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:syntax/protected -ref AccessTest.protected.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:syntax/package -ref AccessTest.package.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:syntax/private -ref AccessTest.private.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:all,-syntax AccessTest.java
+ * @run main DocLintTester -Xmsgs:all,-syntax/public AccessTest.java
+ * @run main DocLintTester -Xmsgs:all,-syntax/protected -ref AccessTest.public.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:all,-syntax/package -ref AccessTest.protected.out AccessTest.java
+ * @run main DocLintTester -Xmsgs:all,-syntax/private -ref AccessTest.package.out AccessTest.java
+ */
+
+/** */
+public class AccessTest {
+    /**
+     * public a < b
+     */
+    public void public_syntax_error() { }
+
+    /**
+     * protected a < b
+     */
+    protected void protected_syntax_error() { }
+
+    /**
+     * package-private a < b
+     */
+    void syntax_error() { }
+
+    /**
+     * private a < b
+     */
+    private void private_syntax_error() { }
+}
+
+/** */
+class AccessTest2 {
+    /**
+     * public a < b
+     */
+    public void public_syntax_error() { }
+
+    /**
+     * protected a < b
+     */
+    protected void protected_syntax_error() { }
+
+    /**
+     * package-private a < b
+     */
+    void syntax_error() { }
+
+    /**
+     * private a < b
+     */
+    private void private_syntax_error() { }
+}
+
diff --git a/test/tools/doclint/AccessTest.package.out b/test/tools/doclint/AccessTest.package.out
new file mode 100644
index 0000000..7bd5eaf
--- /dev/null
+++ b/test/tools/doclint/AccessTest.package.out
@@ -0,0 +1,20 @@
+AccessTest.java:23: error: malformed HTML
+     * public a < b
+                ^
+AccessTest.java:28: error: malformed HTML
+     * protected a < b
+                   ^
+AccessTest.java:33: error: malformed HTML
+     * package-private a < b
+                         ^
+AccessTest.java:46: error: malformed HTML
+     * public a < b
+                ^
+AccessTest.java:51: error: malformed HTML
+     * protected a < b
+                   ^
+AccessTest.java:56: error: malformed HTML
+     * package-private a < b
+                         ^
+6 errors
+
diff --git a/test/tools/doclint/AccessTest.private.out b/test/tools/doclint/AccessTest.private.out
new file mode 100644
index 0000000..db01a84
--- /dev/null
+++ b/test/tools/doclint/AccessTest.private.out
@@ -0,0 +1,27 @@
+AccessTest.java:23: error: malformed HTML
+     * public a < b
+                ^
+AccessTest.java:28: error: malformed HTML
+     * protected a < b
+                   ^
+AccessTest.java:33: error: malformed HTML
+     * package-private a < b
+                         ^
+AccessTest.java:38: error: malformed HTML
+     * private a < b
+                 ^
+AccessTest.java:46: error: malformed HTML
+     * public a < b
+                ^
+AccessTest.java:51: error: malformed HTML
+     * protected a < b
+                   ^
+AccessTest.java:56: error: malformed HTML
+     * package-private a < b
+                         ^
+AccessTest.java:61: error: malformed HTML
+     * private a < b
+                 ^
+8 errors
+
+
diff --git a/test/tools/doclint/AccessTest.protected.out b/test/tools/doclint/AccessTest.protected.out
new file mode 100644
index 0000000..8aabbee
--- /dev/null
+++ b/test/tools/doclint/AccessTest.protected.out
@@ -0,0 +1,8 @@
+AccessTest.java:23: error: malformed HTML
+     * public a < b
+                ^
+AccessTest.java:28: error: malformed HTML
+     * protected a < b
+                   ^
+2 errors
+
diff --git a/test/tools/doclint/AccessTest.public.out b/test/tools/doclint/AccessTest.public.out
new file mode 100644
index 0000000..6968590
--- /dev/null
+++ b/test/tools/doclint/AccessTest.public.out
@@ -0,0 +1,5 @@
+AccessTest.java:23: error: malformed HTML
+     * public a < b
+                ^
+1 error
+
diff --git a/test/tools/doclint/AccessibilityTest.java b/test/tools/doclint/AccessibilityTest.java
new file mode 100644
index 0000000..e49d680
--- /dev/null
+++ b/test/tools/doclint/AccessibilityTest.java
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-accessibility AccessibilityTest.java
+ * @run main DocLintTester -ref AccessibilityTest.out AccessibilityTest.java
+ */
+
+/** */
+public class AccessibilityTest {
+
+    /**
+     * <h2> ... </h2>
+     */
+    public void missing_h1() { }
+
+    /**
+     * <h1> ... </h1>
+     * <h3> ... </h3>
+     */
+    public void missing_h2() { }
+
+    /**
+     * <img src="x.jpg">
+     */
+    public void missing_alt() { }
+
+    /**
+     * <table summary="ok"><tr><th>head<tr><td>data</table>
+     */
+    public void table_with_summary() { }
+
+    /**
+     * <table><caption>ok</caption><tr><th>head<tr><td>data</table>
+     */
+    public void table_with_caption() { }
+
+    /**
+     * <table><tr><th>head<tr><td>data</table>
+     */
+    public void table_without_summary_and_caption() { }
+}
+
diff --git a/test/tools/doclint/AccessibilityTest.out b/test/tools/doclint/AccessibilityTest.out
new file mode 100644
index 0000000..b489b46
--- /dev/null
+++ b/test/tools/doclint/AccessibilityTest.out
@@ -0,0 +1,13 @@
+AccessibilityTest.java:14: error: header used out of sequence: <H2>
+     * <h2> ... </h2>
+       ^
+AccessibilityTest.java:20: error: header used out of sequence: <H3>
+     * <h3> ... </h3>
+       ^
+AccessibilityTest.java:25: error: no "alt" attribute for image
+     * <img src="x.jpg">
+       ^
+AccessibilityTest.java:40: error: no summary or caption for table
+     * <table><tr><th>head<tr><td>data</table>
+                                      ^
+4 errors
diff --git a/test/tools/doclint/AnchorTest.java b/test/tools/doclint/AnchorTest.java
new file mode 100644
index 0000000..08e1903
--- /dev/null
+++ b/test/tools/doclint/AnchorTest.java
@@ -0,0 +1,93 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -ref AnchorTest.out AnchorTest.java
+ */
+
+/** */
+public class AnchorTest {
+    // tests for <a name=value>
+
+    /**
+     * <a name=foo></a>
+     */
+    public void a_name_foo() { }
+
+    /**
+     * <a name=foo></a>
+     */
+    public void a_name_already_defined() { }
+
+    /**
+     * <a name=></a>
+     */
+    public void a_name_empty() { }
+
+    /**
+     * <a name=123 ></a>
+     */
+    public void a_name_invalid() { }
+
+    /**
+     * <a name ></a>
+     */
+    public void a_name_missing() { }
+
+    // tests for <a id=value>
+
+    /**
+     * <a id=a_id_foo></a>
+     */
+    public void a_id_foo() { }
+
+    /**
+     * <a id=foo></a>
+     */
+    public void a_id_already_defined() { }
+
+    /**
+     * <a id=></a>
+     */
+    public void a_id_empty() { }
+
+    /**
+     * <a id=123 ></a>
+     */
+    public void a_id_invalid() { }
+
+    /**
+     * <a id ></a>
+     */
+    public void a_id_missing() { }
+
+    // tests for id=value on non-<a> tags
+
+    /**
+     * <p id=p_id_foo>text</p>
+     */
+    public void p_id_foo() { }
+
+    /**
+     * <p id=foo>text</p>
+     */
+    public void p_id_already_defined() { }
+
+    /**
+     * <p id=>text</p>
+     */
+    public void p_id_empty() { }
+
+    /**
+     * <p id=123 >text</p>
+     */
+    public void p_id_invalid() { }
+
+    /**
+     * <p id >text</p>
+     */
+    public void p_id_missing() { }
+
+
+}
diff --git a/test/tools/doclint/AnchorTest.out b/test/tools/doclint/AnchorTest.out
new file mode 100644
index 0000000..562be5b
--- /dev/null
+++ b/test/tools/doclint/AnchorTest.out
@@ -0,0 +1,37 @@
+AnchorTest.java:19: error: anchor already defined: foo
+     * <a name=foo></a>
+          ^
+AnchorTest.java:24: error: invalid name for anchor: ""
+     * <a name=></a>
+          ^
+AnchorTest.java:29: error: invalid name for anchor: "123"
+     * <a name=123 ></a>
+          ^
+AnchorTest.java:34: error: no value given for anchor
+     * <a name ></a>
+          ^
+AnchorTest.java:46: error: anchor already defined: foo
+     * <a id=foo></a>
+          ^
+AnchorTest.java:51: error: invalid name for anchor: ""
+     * <a id=></a>
+          ^
+AnchorTest.java:56: error: invalid name for anchor: "123"
+     * <a id=123 ></a>
+          ^
+AnchorTest.java:61: error: no value given for anchor
+     * <a id ></a>
+          ^
+AnchorTest.java:73: error: anchor already defined: foo
+     * <p id=foo>text</p>
+          ^
+AnchorTest.java:78: error: invalid name for anchor: ""
+     * <p id=>text</p>
+          ^
+AnchorTest.java:83: error: invalid name for anchor: "123"
+     * <p id=123 >text</p>
+          ^
+AnchorTest.java:88: error: no value given for anchor
+     * <p id >text</p>
+          ^
+12 errors
diff --git a/test/tools/doclint/BadPackageCommentTest.java b/test/tools/doclint/BadPackageCommentTest.java
new file mode 100644
index 0000000..a3f71f0
--- /dev/null
+++ b/test/tools/doclint/BadPackageCommentTest.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8020278
+ * @summary NPE in javadoc (bad handling of bad tag in package-info.java)
+ * @build DocLintTester
+ * @run main DocLintTester -ref BadPackageCommentTest.out BadPackageCommentTest.java
+ */
+
+/**
+ * abc.
+ * @@@
+ */
+package p;
diff --git a/test/tools/doclint/BadPackageCommentTest.out b/test/tools/doclint/BadPackageCommentTest.out
new file mode 100644
index 0000000..57b4db9
--- /dev/null
+++ b/test/tools/doclint/BadPackageCommentTest.out
@@ -0,0 +1,10 @@
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+   ^
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+    ^
+BadPackageCommentTest.java:11: error: no tag name after @
+ * @@@
+     ^
+3 errors
diff --git a/test/tools/doclint/CoverageExtras.java b/test/tools/doclint/CoverageExtras.java
new file mode 100644
index 0000000..e083d70
--- /dev/null
+++ b/test/tools/doclint/CoverageExtras.java
@@ -0,0 +1,71 @@
+/*
+ * 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 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.tools.doclint.Checker;
+import com.sun.tools.doclint.Entity;
+import com.sun.tools.doclint.HtmlTag;
+import com.sun.tools.doclint.Messages;
+import java.util.Objects;
+
+public class CoverageExtras {
+    public static void main(String... args) {
+        new CoverageExtras().run();
+    }
+
+    void run() {
+        check(HtmlTag.A, HtmlTag.valueOf("A"), HtmlTag.values());
+        check(HtmlTag.Attr.ABBR, HtmlTag.Attr.valueOf("ABBR"), HtmlTag.Attr.values());
+        check(HtmlTag.AttrKind.INVALID, HtmlTag.AttrKind.valueOf("INVALID"), HtmlTag.AttrKind.values());
+        check(HtmlTag.BlockType.BLOCK, HtmlTag.BlockType.valueOf("BLOCK"), HtmlTag.BlockType.values());
+        check(HtmlTag.EndKind.NONE, HtmlTag.EndKind.valueOf("NONE"), HtmlTag.EndKind.values());
+        check(HtmlTag.Flag.EXPECT_CONTENT, HtmlTag.Flag.valueOf("EXPECT_CONTENT"), HtmlTag.Flag.values());
+
+        check(Checker.Flag.TABLE_HAS_CAPTION, Checker.Flag.valueOf("TABLE_HAS_CAPTION"), Checker.Flag.values());
+
+        check(Entity.nbsp, Entity.valueOf("nbsp"), Entity.values());
+
+        check(Messages.Group.ACCESSIBILITY, Messages.Group.valueOf("ACCESSIBILITY"), Messages.Group.values());
+    }
+
+    <T extends Enum<T>> void check(T expect, T value, T[] values) {
+        if (!Objects.equals(expect, value)) {
+            error("Mismatch: '" + expect + "', '" + value + "'");
+        }
+        if (!Objects.equals(expect, values[0])) {
+            error("Mismatch: '" + expect + "', '" + values[0] + "'");
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/doclint/DocLintTester.java b/test/tools/doclint/DocLintTester.java
new file mode 100644
index 0000000..848e284
--- /dev/null
+++ b/test/tools/doclint/DocLintTester.java
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class DocLintTester {
+
+    public static void main(String... args) throws Exception {
+        new DocLintTester().run(args);
+    }
+
+    public void run(String... args) throws Exception {
+        String testSrc = System.getProperty("test.src");
+
+        boolean badArgs = false;
+        File refFile = null;
+        List<String> opts = new ArrayList<String>();
+        List<File> files = new ArrayList<File>();
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.equals("-ref")) {
+                refFile = new File(testSrc, args[++i]);
+            } else if (arg.equals("-badargs")) {
+                badArgs = true;
+            } else if (arg.startsWith("-Xmsgs")) {
+                opts.add(arg);
+            } else if (arg.startsWith("-")) {
+                opts.add(arg);
+                if (i < args.length - 1 && !args[i+1].startsWith("-"))
+                    opts.add(args[++i]);
+            } else
+                files.add(new File(testSrc, arg));
+        }
+
+        check(opts, files, badArgs, refFile);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void check(List<String> opts, List<File> files, boolean expectBadArgs, File refFile) throws Exception {
+        List<String> args = new ArrayList<String>();
+        args.addAll(opts);
+        for (File file: files)
+            args.add(file.getPath());
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        try {
+            new DocLint().run(pw, args.toArray(new String[args.size()]));
+            if (expectBadArgs)
+                error("expected exception not thrown");
+        } catch (BadArgs e) {
+            if (!expectBadArgs)
+                error("unexpected exception caught: " + e);
+        }
+        pw.flush();
+        String out = normalizeNewlines(removeFileNames(sw.toString())).trim();
+        if (out != null)
+            System.err.println("Output:\n" + out);
+
+        if (refFile == null) {
+            if (!out.isEmpty())
+                error("unexpected output");
+        } else {
+            String expect = readFile(refFile);
+            if (!expect.equals(out)) {
+                error("expected output not found");
+                System.err.println("EXPECT>>" + expect + "<<");
+                System.err.println(" FOUND>>" + out    + "<<");
+            }
+        }
+    }
+
+    String readFile(File file) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        Reader in = new BufferedReader(new FileReader(file));
+        try {
+            char[] buf = new char[1024];
+            int n;
+            while ((n = in.read(buf)) != -1)
+                sb.append(buf, 0, n);
+        } finally {
+            in.close();
+        }
+        return sb.toString().trim();
+    }
+
+    private static final Pattern dirFileLine = Pattern.compile(
+            "(?m)"                          // multi-line mode
+            + "^(.*?)"                      // directory part of file name
+            + "([A-Za-z0-9.]+:[0-9]+:)");   // file name and line number
+
+    String removeFileNames(String s) {
+        Matcher m = dirFileLine.matcher(s);
+        StringBuffer sb = new StringBuffer();
+        while (m.find()) {
+            m.appendReplacement(sb, "$2");
+        }
+        m.appendTail(sb);
+        return sb.toString();
+    }
+
+    private static final String nl = System.getProperty("line.separator");
+    String normalizeNewlines(String s) {
+        return (nl.equals("\n") ? s : s.replace(nl, "\n"));
+    }
+
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/doclint/EmptyAuthorTest.java b/test/tools/doclint/EmptyAuthorTest.java
new file mode 100644
index 0000000..6188f7a
--- /dev/null
+++ b/test/tools/doclint/EmptyAuthorTest.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptyAuthorTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptyAuthorTest.out EmptyAuthorTest.java
+ */
+
+/** @author */
+public class EmptyAuthorTest {
+}
diff --git a/test/tools/doclint/EmptyAuthorTest.out b/test/tools/doclint/EmptyAuthorTest.out
new file mode 100644
index 0000000..f2858d0
--- /dev/null
+++ b/test/tools/doclint/EmptyAuthorTest.out
@@ -0,0 +1,5 @@
+EmptyAuthorTest.java:10: warning: no description for @author
+/** @author */
+    ^
+1 warning
+
diff --git a/test/tools/doclint/EmptyExceptionTest.java b/test/tools/doclint/EmptyExceptionTest.java
new file mode 100644
index 0000000..8ffc7aa
--- /dev/null
+++ b/test/tools/doclint/EmptyExceptionTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptyExceptionTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptyExceptionTest.out EmptyExceptionTest.java
+ */
+
+/** . */
+public class EmptyExceptionTest {
+    /** @exception NullPointerException */
+    int emptyException() throws NullPointerException { }
+}
diff --git a/test/tools/doclint/EmptyExceptionTest.out b/test/tools/doclint/EmptyExceptionTest.out
new file mode 100644
index 0000000..118a085
--- /dev/null
+++ b/test/tools/doclint/EmptyExceptionTest.out
@@ -0,0 +1,4 @@
+EmptyExceptionTest.java:12: warning: no description for @exception
+    /** @exception NullPointerException */
+        ^
+1 warning
diff --git a/test/tools/doclint/EmptyParamTest.java b/test/tools/doclint/EmptyParamTest.java
new file mode 100644
index 0000000..ba21ca9
--- /dev/null
+++ b/test/tools/doclint/EmptyParamTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptyParamTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptyParamTest.out EmptyParamTest.java
+ */
+
+/** . */
+public class EmptyParamTest {
+    /** @param i */
+    int emptyParam(int i) { }
+}
diff --git a/test/tools/doclint/EmptyParamTest.out b/test/tools/doclint/EmptyParamTest.out
new file mode 100644
index 0000000..9e96df3
--- /dev/null
+++ b/test/tools/doclint/EmptyParamTest.out
@@ -0,0 +1,5 @@
+EmptyParamTest.java:12: warning: no description for @param
+    /** @param i */
+        ^
+1 warning
+
diff --git a/test/tools/doclint/EmptyPreTest.java b/test/tools/doclint/EmptyPreTest.java
new file mode 100644
index 0000000..ada4995
--- /dev/null
+++ b/test/tools/doclint/EmptyPreTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8010317
+ * @summary DocLint incorrectly reports some <pre> tags as empty
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:html EmptyPreTest.java
+ */
+
+public class EmptyPreTest {
+    /** <pre> {@code xyzzy} </pre> */
+    public void m1() { }
+
+    /** <pre> {@docRoot} </pre> */
+    public void m2() { }
+
+    /** <pre> {@link java.lang.String} </pre> */
+    public void m3() { }
+
+    /** <pre> {@value} </pre> */
+    public static final int v1 = 1;
+}
diff --git a/test/tools/doclint/EmptyReturnTest.java b/test/tools/doclint/EmptyReturnTest.java
new file mode 100644
index 0000000..3cc850d
--- /dev/null
+++ b/test/tools/doclint/EmptyReturnTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptyReturnTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptyReturnTest.out EmptyReturnTest.java
+ */
+
+/** . */
+public class EmptyReturnTest {
+    /** @return */
+    int emptyReturn() { }
+}
diff --git a/test/tools/doclint/EmptyReturnTest.out b/test/tools/doclint/EmptyReturnTest.out
new file mode 100644
index 0000000..5576c9e
--- /dev/null
+++ b/test/tools/doclint/EmptyReturnTest.out
@@ -0,0 +1,5 @@
+EmptyReturnTest.java:12: warning: no description for @return
+    /** @return */
+        ^
+1 warning
+
diff --git a/test/tools/doclint/EmptySerialDataTest.java b/test/tools/doclint/EmptySerialDataTest.java
new file mode 100644
index 0000000..8abca70
--- /dev/null
+++ b/test/tools/doclint/EmptySerialDataTest.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptySerialDataTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptySerialDataTest.out EmptySerialDataTest.java
+ */
+
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+/** . */
+public class EmptySerialDataTest implements Serializable {
+    /** @serialData */
+    private void writeObject(ObjectOutputStream s) { }
+}
diff --git a/test/tools/doclint/EmptySerialDataTest.out b/test/tools/doclint/EmptySerialDataTest.out
new file mode 100644
index 0000000..d53e566
--- /dev/null
+++ b/test/tools/doclint/EmptySerialDataTest.out
@@ -0,0 +1,5 @@
+EmptySerialDataTest.java:15: warning: no description for @serialData
+    /** @serialData */
+        ^
+1 warning
+
diff --git a/test/tools/doclint/EmptySerialFieldTest.java b/test/tools/doclint/EmptySerialFieldTest.java
new file mode 100644
index 0000000..34782fe
--- /dev/null
+++ b/test/tools/doclint/EmptySerialFieldTest.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptySerialFieldTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptySerialFieldTest.out EmptySerialFieldTest.java
+ */
+
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+
+/** . */
+public class EmptySerialFieldTest implements Serializable {
+
+    /**
+     * @serialField empty    String
+     */
+    private static final ObjectStreamField[] serialPersistentFields = {
+        new ObjectStreamField("empty", String.class),
+    };
+}
diff --git a/test/tools/doclint/EmptySerialFieldTest.out b/test/tools/doclint/EmptySerialFieldTest.out
new file mode 100644
index 0000000..6d959f3
--- /dev/null
+++ b/test/tools/doclint/EmptySerialFieldTest.out
@@ -0,0 +1,5 @@
+EmptySerialFieldTest.java:17: warning: no description for @serialField
+     * @serialField empty    String
+       ^
+1 warning
+
diff --git a/test/tools/doclint/EmptySinceTest.java b/test/tools/doclint/EmptySinceTest.java
new file mode 100644
index 0000000..f950462
--- /dev/null
+++ b/test/tools/doclint/EmptySinceTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptySinceTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptySinceTest.out EmptySinceTest.java
+ */
+
+/** . */
+public class EmptySinceTest {
+    /** @since */
+    int emptySince() { }
+}
diff --git a/test/tools/doclint/EmptySinceTest.out b/test/tools/doclint/EmptySinceTest.out
new file mode 100644
index 0000000..3bf463e
--- /dev/null
+++ b/test/tools/doclint/EmptySinceTest.out
@@ -0,0 +1,5 @@
+EmptySinceTest.java:12: warning: no description for @since
+    /** @since */
+        ^
+1 warning
+
diff --git a/test/tools/doclint/EmptyVersionTest.java b/test/tools/doclint/EmptyVersionTest.java
new file mode 100644
index 0000000..473ab73
--- /dev/null
+++ b/test/tools/doclint/EmptyVersionTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax EmptyVersionTest.java
+ * @run main DocLintTester -Xmsgs:syntax -ref EmptyVersionTest.out EmptyVersionTest.java
+ */
+
+/** . */
+public class EmptyVersionTest {
+    /** @version */
+    int missingVersion() { }
+}
diff --git a/test/tools/doclint/EmptyVersionTest.out b/test/tools/doclint/EmptyVersionTest.out
new file mode 100644
index 0000000..ebd5710
--- /dev/null
+++ b/test/tools/doclint/EmptyVersionTest.out
@@ -0,0 +1,4 @@
+EmptyVersionTest.java:12: warning: no description for @version
+    /** @version */
+        ^
+1 warning
diff --git a/test/tools/doclint/EndTagsTest.java b/test/tools/doclint/EndTagsTest.java
new file mode 100644
index 0000000..154f516
--- /dev/null
+++ b/test/tools/doclint/EndTagsTest.java
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006236
+ * @summary doclint: structural issue hidden
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html EndTagsTest.java
+ * @run main DocLintTester -ref EndTagsTest.out EndTagsTest.java
+ */
+
+/** */
+public class EndTagsTest {
+    /** <p>  <a name="a1"> text <img alt="image" src="image.png"> </a> </p> */
+    public void valid_all() { }
+
+    /** <p>  <a name="a2"> text <img alt="image" src="image.png"> </a> */
+    public void valid_omit_optional_close() { }
+
+    /** </a> */
+    public void invalid_missing_start() { }
+
+    /** <p> </a> */
+    public void invalid_missing_start_2() { }
+
+    /** <p> text </p> </a> */
+    public void invalid_missing_start_3() { }
+
+    /** <img alt="image" src="image.png"> </img> */
+    public void invalid_end() { }
+
+    /** <invalid> </invalid> */
+    public void unknown_start_end() { }
+
+    /** <invalid> */
+    public void unknown_start() { }
+
+    /** </invalid> */
+    public void unknown_end() { }
+}
+
diff --git a/test/tools/doclint/EndTagsTest.out b/test/tools/doclint/EndTagsTest.out
new file mode 100644
index 0000000..61af632
--- /dev/null
+++ b/test/tools/doclint/EndTagsTest.out
@@ -0,0 +1,25 @@
+EndTagsTest.java:18: error: unexpected end tag: </a>
+    /** </a> */
+        ^
+EndTagsTest.java:21: error: unexpected end tag: </a>
+    /** <p> </a> */
+            ^
+EndTagsTest.java:24: error: unexpected end tag: </a>
+    /** <p> text </p> </a> */
+                      ^
+EndTagsTest.java:27: error: invalid end tag: </img>
+    /** <img alt="image" src="image.png"> </img> */
+                                          ^
+EndTagsTest.java:30: error: unknown tag: invalid
+    /** <invalid> </invalid> */
+        ^
+EndTagsTest.java:30: error: unknown tag: invalid
+    /** <invalid> </invalid> */
+                  ^
+EndTagsTest.java:33: error: unknown tag: invalid
+    /** <invalid> */
+        ^
+EndTagsTest.java:36: error: unknown tag: invalid
+    /** </invalid> */
+        ^
+8 errors
diff --git a/test/tools/doclint/EndWithIdentifierTest.java b/test/tools/doclint/EndWithIdentifierTest.java
new file mode 100644
index 0000000..afd20a3
--- /dev/null
+++ b/test/tools/doclint/EndWithIdentifierTest.java
@@ -0,0 +1,32 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007096
+ * @summary DocLint parsing problems with some comments
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html EndWithIdentifierTest.java
+ * @run main DocLintTester -Xmsgs -ref EndWithIdentifierTest.out EndWithIdentifierTest.java
+ * @author jlahoda
+ */
+
+/**@deprecated*/
+public class EndWithIdentifierTest {
+
+    /**{@link*/
+    private void unfinishedInlineTagName() {}
+
+    /**@see List*/
+    private void endsWithIdentifier() {}
+
+    /**&amp*/
+    private void entityName() {}
+
+    /**<a*/
+    private void tag() {}
+
+    /**</a*/
+    private void tagEnd() {}
+
+    /**<a name*/
+    private void attribute() {}
+}
+
diff --git a/test/tools/doclint/EndWithIdentifierTest.out b/test/tools/doclint/EndWithIdentifierTest.out
new file mode 100644
index 0000000..4f8896e
--- /dev/null
+++ b/test/tools/doclint/EndWithIdentifierTest.out
@@ -0,0 +1,20 @@
+EndWithIdentifierTest.java:14: error: syntax error in reference
+    /**{@link*/
+       ^
+EndWithIdentifierTest.java:17: error: reference not found
+    /**@see List*/
+            ^
+EndWithIdentifierTest.java:20: error: semicolon missing
+    /**&amp*/
+       ^
+EndWithIdentifierTest.java:23: error: malformed HTML
+    /**<a*/
+       ^
+EndWithIdentifierTest.java:26: error: malformed HTML
+    /**</a*/
+       ^
+EndWithIdentifierTest.java:29: error: malformed HTML
+    /**<a name*/
+       ^
+6 errors
+
diff --git a/test/tools/doclint/HtmlAttrsTest.java b/test/tools/doclint/HtmlAttrsTest.java
new file mode 100644
index 0000000..66d6445
--- /dev/null
+++ b/test/tools/doclint/HtmlAttrsTest.java
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html HtmlAttrsTest.java
+ * @run main DocLintTester -ref HtmlAttrsTest.out HtmlAttrsTest.java
+ */
+
+/** */
+public class HtmlAttrsTest {
+    /**
+     * <p xyz>
+     */
+    public void unknown() { }
+
+    /**
+     * <img name="x" alt="alt">
+     */
+    public void obsolete() { }
+
+    /**
+     * <font size="3"> text </font>
+     */
+    public void obsolete_use_css() { }
+}
+
diff --git a/test/tools/doclint/HtmlAttrsTest.out b/test/tools/doclint/HtmlAttrsTest.out
new file mode 100644
index 0000000..ec735e2
--- /dev/null
+++ b/test/tools/doclint/HtmlAttrsTest.out
@@ -0,0 +1,12 @@
+HtmlAttrsTest.java:13: error: unknown attribute: xyz
+     * <p xyz>
+          ^
+HtmlAttrsTest.java:18: warning: attribute obsolete: name
+     * <img name="x" alt="alt">
+            ^
+HtmlAttrsTest.java:23: warning: attribute obsolete, use CSS instead: size
+     * <font size="3"> text </font>
+             ^
+1 error
+2 warnings
+
diff --git a/test/tools/doclint/HtmlTagsTest.java b/test/tools/doclint/HtmlTagsTest.java
new file mode 100644
index 0000000..7ff2c36
--- /dev/null
+++ b/test/tools/doclint/HtmlTagsTest.java
@@ -0,0 +1,70 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html HtmlTagsTest.java
+ * @run main DocLintTester -ref HtmlTagsTest.out HtmlTagsTest.java
+ */
+
+/** */
+public class HtmlTagsTest {
+    /**
+     * <xyz> ... </xyz>
+     */
+    public void unknownTag1() { }
+
+    /**
+     * <div> <xyz> </div>
+     */
+    public void unknownTag2() { }
+
+    /**
+     * <br/>
+     */
+    public void selfClosingTag() { }
+
+    /**
+     * <html>
+     */
+    public void not_allowed() { }
+
+    /**
+     * <span> <p> </span>
+     */
+    public void not_allowed_inline() { }
+
+    /**
+     * {@link java.lang.String <p> }
+     * {@link java.lang.String <p> }
+     */
+    public void not_allowed_inline_2() { }
+
+    /**
+     * <img src="any.jpg" alt="alt"> </img>
+     */
+    public void end_not_allowed() { }
+
+    /**
+     * <i> <b> </i>
+     */
+    public void start_not_matched() { }
+
+    /**
+     * <i> </b> </i>
+     */
+    public void end_unexpected() { }
+
+    /**
+     * <ul> text <li> ... </li> </ul>
+     */
+    public void text_not_allowed() { }
+
+    /**
+     * <ul> <b>text</b> <li> ... </li> </ul>
+     */
+    public void inline_not_allowed() { }
+
+
+}
+
diff --git a/test/tools/doclint/HtmlTagsTest.out b/test/tools/doclint/HtmlTagsTest.out
new file mode 100644
index 0000000..19be723
--- /dev/null
+++ b/test/tools/doclint/HtmlTagsTest.out
@@ -0,0 +1,44 @@
+HtmlTagsTest.java:13: error: unknown tag: xyz
+     * <xyz> ... </xyz>
+       ^
+HtmlTagsTest.java:13: error: unknown tag: xyz
+     * <xyz> ... </xyz>
+                 ^
+HtmlTagsTest.java:18: error: unknown tag: xyz
+     * <div> <xyz> </div>
+             ^
+HtmlTagsTest.java:23: error: self-closing element not allowed
+     * <br/>
+       ^
+HtmlTagsTest.java:28: error: element not allowed in documentation comments: <html>
+     * <html>
+       ^
+HtmlTagsTest.java:33: error: block element not allowed within inline element <span>: p
+     * <span> <p> </span>
+              ^
+HtmlTagsTest.java:38: error: block element not allowed within @link: p
+     * {@link java.lang.String <p> }
+                               ^
+HtmlTagsTest.java:39: error: block element not allowed within @link: p
+     * {@link java.lang.String <p> }
+                               ^
+HtmlTagsTest.java:44: error: invalid end tag: </img>
+     * <img src="any.jpg" alt="alt"> </img>
+                                     ^
+HtmlTagsTest.java:49: error: end tag missing: </b>
+     * <i> <b> </i>
+           ^
+HtmlTagsTest.java:54: error: unexpected end tag: </b>
+     * <i> </b> </i>
+           ^
+HtmlTagsTest.java:54: warning: empty <i> tag
+     * <i> </b> </i>
+                ^
+HtmlTagsTest.java:59: error: text not allowed in <ul> element
+     * <ul> text <li> ... </li> </ul>
+           ^
+HtmlTagsTest.java:64: error: tag not allowed here: <b>
+     * <ul> <b>text</b> <li> ... </li> </ul>
+            ^
+13 errors
+1 warning
diff --git a/test/tools/doclint/LiteralTest.java b/test/tools/doclint/LiteralTest.java
new file mode 100644
index 0000000..008246e
--- /dev/null
+++ b/test/tools/doclint/LiteralTest.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006228
+ * @summary Doclint doesn't detect <code> {@code nested inline} </code>
+ * @build DocLintTester
+ * @run main DocLintTester -ref LiteralTest.out LiteralTest.java
+ */
+
+/** */
+public class LiteralTest {
+    /** <code> abc {@literal < & > } def </code> */
+    public void ok_literal_in_code() { }
+
+    /** <code> abc {@code < & > } def </code> */
+    public void bad_code_in_code() { }
+}
diff --git a/test/tools/doclint/LiteralTest.out b/test/tools/doclint/LiteralTest.out
new file mode 100644
index 0000000..4cb41d9
--- /dev/null
+++ b/test/tools/doclint/LiteralTest.out
@@ -0,0 +1,4 @@
+LiteralTest.java:14: warning: {@code} within <code>
+    /** <code> abc {@code < & > } def </code> */
+                   ^
+1 warning
diff --git a/test/tools/doclint/MissingCommentTest.java b/test/tools/doclint/MissingCommentTest.java
new file mode 100644
index 0000000..165ff31
--- /dev/null
+++ b/test/tools/doclint/MissingCommentTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-missing MissingCommentTest.java
+ * @run main DocLintTester -Xmsgs:missing -ref MissingCommentTest.out MissingCommentTest.java
+ */
+
+public class MissingCommentTest {
+    MissingCommentTest() { }
+
+    int missingComment;
+
+    void missingComment() { }
+}
diff --git a/test/tools/doclint/MissingCommentTest.out b/test/tools/doclint/MissingCommentTest.out
new file mode 100644
index 0000000..8739f14
--- /dev/null
+++ b/test/tools/doclint/MissingCommentTest.out
@@ -0,0 +1,14 @@
+MissingCommentTest.java:8: warning: no comment
+public class MissingCommentTest {
+       ^
+MissingCommentTest.java:9: warning: no comment
+    MissingCommentTest() { }
+    ^
+MissingCommentTest.java:11: warning: no comment
+    int missingComment;
+        ^
+MissingCommentTest.java:13: warning: no comment
+    void missingComment() { }
+         ^
+4 warnings
+
diff --git a/test/tools/doclint/MissingParamsTest.java b/test/tools/doclint/MissingParamsTest.java
new file mode 100644
index 0000000..0dcbeb3
--- /dev/null
+++ b/test/tools/doclint/MissingParamsTest.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-missing MissingParamsTest.java
+ * @run main DocLintTester -Xmsgs:missing -ref MissingParamsTest.out MissingParamsTest.java
+ */
+
+/** . */
+public class MissingParamsTest {
+    /** */
+    MissingParamsTest(int param) { }
+
+    /** */
+    <T> MissingParamsTest() { }
+
+    /** */
+    void missingParam(int param) { }
+
+    /** */
+    <T> void missingTyparam() { }
+}
diff --git a/test/tools/doclint/MissingParamsTest.out b/test/tools/doclint/MissingParamsTest.out
new file mode 100644
index 0000000..c052767
--- /dev/null
+++ b/test/tools/doclint/MissingParamsTest.out
@@ -0,0 +1,14 @@
+MissingParamsTest.java:13: warning: no @param for param
+    MissingParamsTest(int param) { }
+    ^
+MissingParamsTest.java:16: warning: no @param for <T>
+    <T> MissingParamsTest() { }
+        ^
+MissingParamsTest.java:19: warning: no @param for param
+    void missingParam(int param) { }
+         ^
+MissingParamsTest.java:22: warning: no @param for <T>
+    <T> void missingTyparam() { }
+             ^
+4 warnings
+
diff --git a/test/tools/doclint/MissingReturnTest.java b/test/tools/doclint/MissingReturnTest.java
new file mode 100644
index 0000000..f7871a4
--- /dev/null
+++ b/test/tools/doclint/MissingReturnTest.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-missing MissingReturnTest.java
+ * @run main DocLintTester -Xmsgs:missing -ref MissingReturnTest.out MissingReturnTest.java
+ */
+
+/** . */
+public class MissingReturnTest {
+    /** no return allowed */
+    MissingReturnTest() { }
+
+    /** no return allowed */
+    void return_void() { }
+
+    /** no return required */
+    Void return_Void() { }
+
+    /** */
+    int missingReturn() { }
+}
diff --git a/test/tools/doclint/MissingReturnTest.out b/test/tools/doclint/MissingReturnTest.out
new file mode 100644
index 0000000..2e04dc4
--- /dev/null
+++ b/test/tools/doclint/MissingReturnTest.out
@@ -0,0 +1,5 @@
+MissingReturnTest.java:22: warning: no @return
+    int missingReturn() { }
+        ^
+1 warning
+
diff --git a/test/tools/doclint/MissingThrowsTest.java b/test/tools/doclint/MissingThrowsTest.java
new file mode 100644
index 0000000..93e1409
--- /dev/null
+++ b/test/tools/doclint/MissingThrowsTest.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-missing MissingThrowsTest.java
+ * @run main DocLintTester -Xmsgs:missing -ref MissingThrowsTest.out MissingThrowsTest.java
+ */
+
+/** */
+public class MissingThrowsTest {
+    /** */
+    void missingThrows() throws Exception { }
+}
diff --git a/test/tools/doclint/MissingThrowsTest.out b/test/tools/doclint/MissingThrowsTest.out
new file mode 100644
index 0000000..bf2eb3a
--- /dev/null
+++ b/test/tools/doclint/MissingThrowsTest.out
@@ -0,0 +1,4 @@
+MissingThrowsTest.java:13: warning: no @throws for java.lang.Exception
+    void missingThrows() throws Exception { }
+         ^
+1 warning
diff --git a/test/tools/doclint/OptionTest.java b/test/tools/doclint/OptionTest.java
new file mode 100644
index 0000000..570bc60
--- /dev/null
+++ b/test/tools/doclint/OptionTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ *
+ * 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 8004832
+ * @summary Add new doclint package
+ */
+
+import com.sun.tools.doclint.DocLint;
+
+public class OptionTest {
+    public static void main(String... args) throws Exception {
+        new OptionTest().run();
+    }
+
+    String[] positiveTests = {
+        "-Xmsgs",
+        "-Xmsgs:all",
+        "-Xmsgs:none",
+        "-Xmsgs:accessibility",
+        "-Xmsgs:html",
+        "-Xmsgs:missing",
+        "-Xmsgs:reference",
+        "-Xmsgs:syntax",
+        "-Xmsgs:html/public",
+        "-Xmsgs:html/protected",
+        "-Xmsgs:html/package",
+        "-Xmsgs:html/private",
+        "-Xmsgs:-html/public",
+        "-Xmsgs:-html/protected",
+        "-Xmsgs:-html/package",
+        "-Xmsgs:-html/private",
+        "-Xmsgs:html,syntax",
+        "-Xmsgs:html,-syntax",
+        "-Xmsgs:-html,syntax",
+        "-Xmsgs:-html,-syntax",
+        "-Xmsgs:html/public,syntax",
+        "-Xmsgs:html,syntax/public",
+        "-Xmsgs:-html/public,syntax/public"
+    };
+
+    String[] negativeTests = {
+        "-typo",
+        "-Xmsgs:-all",
+        "-Xmsgs:-none",
+        "-Xmsgs:typo",
+        "-Xmsgs:html/typo",
+        "-Xmsgs:html/public,typo",
+        "-Xmsgs:html/public,syntax/typo",
+    };
+
+    void run() throws Exception {
+        test(positiveTests, true);
+        test(negativeTests, false);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(String[] tests, boolean expect) {
+        for (String test: tests) {
+            System.err.println("test: " + test);
+            boolean found = DocLint.isValidOption(test);
+            if (found != expect)
+                error("Unexpected result: " + found + ",expected: " + expect);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/doclint/OverridesTest.java b/test/tools/doclint/OverridesTest.java
new file mode 100644
index 0000000..b7a0c09
--- /dev/null
+++ b/test/tools/doclint/OverridesTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ *
+ * 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 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:all OverridesTest.java
+ */
+
+/*
+ * This is a test that missing comments on methods may be inherited
+ * from overridden methods. As such, there should be no errors due
+ * to missing comments (or any other types of error) in this test.
+ */
+
+/** An interface. */
+interface I1 {
+    /**
+     * A method
+     * @param p a param
+     * @throws Exception an exception
+     * @return an int
+     */
+    int m(int p) throws Exception;
+}
+
+/** An extending interface. */
+interface I2 extends I1 { }
+
+/** An abstract class. */
+abstract class C1 {
+    /**
+     * A method
+     * @param p a param
+     * @throws Exception an exception
+     * @return an int
+     */
+    int m(int p) throws Exception;
+}
+
+/** An implementing class. */
+class C2 implements I1 {
+    int m(int  p) throws Exception { return p; }
+}
+
+/** An extending class. */
+class C3 extends C1 {
+    int m(int  p) throws Exception { return p; }
+}
+
+/** An extending and implementing class. */
+class C4 extends C1 implements I1 {
+    int m(int  p) throws Exception { return p; }
+}
+
+/** An implementing class using inheritdoc. */
+class C5 implements I1 {
+    /** {@inheritDoc} */
+    int m(int  p) throws Exception { return p; }
+}
+
+/** An implementing class with incomplete documentation. */
+class C6 implements I1 {
+    /** Overriding method */
+    int m(int  p) throws Exception { return p; }
+}
+
+/** A class implementing an inherited interface. */
+class C7 implements I2 {
+    int m(int  p) throws Exception { return p; }
+}
diff --git a/test/tools/doclint/ParaTagTest.java b/test/tools/doclint/ParaTagTest.java
new file mode 100644
index 0000000..eb7a0a5
--- /dev/null
+++ b/test/tools/doclint/ParaTagTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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 8007566
+ * @summary DocLint too aggressive with not allowed here: <p>
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs ParaTagTest.java
+ */
+
+/**
+ * First line.
+ * <p> Para c1.</p>
+ * <p> Para c2.
+ * <p> Para c3.</p>
+ */
+public class ParaTagTest {
+    /**
+     * m1 <code>code </code>.
+     * <p> Para m1.
+     * <p> Para m2.
+     */
+    public void m() {}
+
+    /**
+     * m2.
+     * <p> Para z1.
+     * <p> Para z2.
+     * <pre>
+     *    Preformat 1.
+     * </pre>
+     */
+    public void z() {}
+}
diff --git a/test/tools/doclint/ReferenceTest.java b/test/tools/doclint/ReferenceTest.java
new file mode 100644
index 0000000..e25c56c
--- /dev/null
+++ b/test/tools/doclint/ReferenceTest.java
@@ -0,0 +1,52 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-reference ReferenceTest.java
+ * @run main DocLintTester -ref ReferenceTest.out ReferenceTest.java
+ */
+
+/** */
+public class ReferenceTest {
+    /**
+     * @param x description
+     */
+    public int invalid_param;
+
+    /**
+     * @param x description
+     */
+    public class InvalidParam { }
+
+    /**
+     * @param x description
+     */
+    public void param_name_not_found(int a) { }
+
+    /**
+     * @param <X> description
+     */
+    public class typaram_name_not_found { }
+
+    /**
+     * @see Object#tooStrong()
+     */
+    public void ref_not_found() { }
+
+    /**
+     * @return x description
+     */
+    public int invalid_return;
+
+    /**
+     * @return x description
+     */
+    public void invalid_return();
+
+    /**
+     * @throws Exception description
+     */
+    public void exception_not_thrown() { }
+}
+
diff --git a/test/tools/doclint/ReferenceTest.out b/test/tools/doclint/ReferenceTest.out
new file mode 100644
index 0000000..df21e5e
--- /dev/null
+++ b/test/tools/doclint/ReferenceTest.out
@@ -0,0 +1,30 @@
+ReferenceTest.java:13: error: invalid use of @param
+     * @param x description
+       ^
+ReferenceTest.java:18: error: invalid use of @param
+     * @param x description
+       ^
+ReferenceTest.java:23: error: @param name not found
+     * @param x description
+              ^
+ReferenceTest.java:25: warning: no @param for a
+    public void param_name_not_found(int a) { }
+                ^
+ReferenceTest.java:28: error: @param name not found
+     * @param <X> description
+               ^
+ReferenceTest.java:33: error: reference not found
+     * @see Object#tooStrong()
+            ^
+ReferenceTest.java:38: error: invalid use of @return
+     * @return x description
+       ^
+ReferenceTest.java:43: error: invalid use of @return
+     * @return x description
+       ^
+ReferenceTest.java:48: error: exception not thrown: java.lang.Exception
+     * @throws Exception description
+               ^
+8 errors
+1 warning
+
diff --git a/test/tools/doclint/ResourceTest.java b/test/tools/doclint/ResourceTest.java
new file mode 100644
index 0000000..46f79ad
--- /dev/null
+++ b/test/tools/doclint/ResourceTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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 8006615
+ * @summary move remaining messages into resource bundle
+ */
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+
+import com.sun.tools.doclint.DocLint;
+
+public class ResourceTest {
+    public static void main(String... args) throws Exception {
+        Locale prev = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            new ResourceTest().run();
+        } finally {
+           Locale.setDefault(prev);
+        }
+    }
+
+    public void run() throws Exception {
+        test(Arrays.asList("-help"),
+                Arrays.asList("Usage:", "Options"));
+        test(Arrays.asList("-foo"),
+                Arrays.asList("bad option: -foo"));
+    }
+
+    void test(List<String> opts, List<String> expects) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        try {
+            new DocLint().run(pw, opts.toArray(new String[opts.size()]));
+        } catch (DocLint.BadArgs e) {
+            pw.println("BadArgs: " + e.getMessage());
+        } catch (IOException e) {
+            pw.println("IOException: " + e.getMessage());
+        } finally {
+            pw.close();
+        }
+
+        String out = sw.toString();
+        if (!out.isEmpty()) {
+            System.err.println(out);
+        }
+
+        for (String e: expects) {
+            if (!out.contains(e))
+                throw new Exception("expected string not found: " + e);
+        }
+    }
+}
+
diff --git a/test/tools/doclint/RunTest.java b/test/tools/doclint/RunTest.java
new file mode 100644
index 0000000..99662e7
--- /dev/null
+++ b/test/tools/doclint/RunTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+/* @test
+ * @bug 8004832 8000103
+ * @summary Add new doclint package
+ * @summary Create doclint utility
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+
+/** javadoc error on toplevel:  a & b. */
+public class RunTest {
+    /** javadoc error on member: a < b */
+    public static void main(String... args) throws Exception {
+        new RunTest().run();
+    }
+
+
+    File testSrc = new File(System.getProperty("test.src"));
+    File thisFile = new File(testSrc, RunTest.class.getSimpleName() + ".java");
+
+    void run() throws Exception {
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                System.err.println("test: " + m.getName());
+                try {
+                    StringWriter sw = new StringWriter();
+                    PrintWriter pw = new PrintWriter(sw);;
+                    m.invoke(this, new Object[] { pw });
+                    String out = sw.toString();
+                    System.err.println(">>> " + out.replace("\n", "\n>>> "));
+                    if (!out.contains("a < b"))
+                        error("\"a < b\" not found");
+                    if (!out.contains("a & b"))
+                        error("\"a & b\" not found");
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                System.err.println();
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    @Test
+    void testMain(PrintWriter pw) throws BadArgs, IOException {
+        String[] args = { "-Xmsgs", thisFile.getPath() };
+        DocLint d = new DocLint();
+        d.run(pw, args);
+    }
+}
+
+
diff --git a/test/tools/doclint/SyntaxTest.java b/test/tools/doclint/SyntaxTest.java
new file mode 100644
index 0000000..8e50a7d
--- /dev/null
+++ b/test/tools/doclint/SyntaxTest.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-syntax SyntaxTest.java
+ * @run main DocLintTester -ref SyntaxTest.out SyntaxTest.java
+ */
+
+/** */
+public class SyntaxTest {
+    /**
+     * a < b
+     */
+    public void syntax_error() { }
+}
+
diff --git a/test/tools/doclint/SyntaxTest.out b/test/tools/doclint/SyntaxTest.out
new file mode 100644
index 0000000..246b636
--- /dev/null
+++ b/test/tools/doclint/SyntaxTest.out
@@ -0,0 +1,5 @@
+SyntaxTest.java:13: error: malformed HTML
+     * a < b
+         ^
+1 error
+
diff --git a/test/tools/doclint/SyntheticTest.java b/test/tools/doclint/SyntheticTest.java
new file mode 100644
index 0000000..8236292
--- /dev/null
+++ b/test/tools/doclint/SyntheticTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ * 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 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:all SyntheticTest.java
+ */
+
+/**
+ * This is a test that messages are not generated for synthesized elements
+ * such as default constructors and enum methods.
+ */
+public class SyntheticTest {
+    // No explicit constructor implies a default constructor
+
+    /** enum E */
+    enum E {
+        /** enum member E1 */
+        E1,
+        /** enum member E2 */
+        E2,
+        /** enum member E3 */
+        E3
+    }
+}
+
+
diff --git a/test/tools/doclint/UnfinishedInlineTagTest.java b/test/tools/doclint/UnfinishedInlineTagTest.java
new file mode 100644
index 0000000..7b43455
--- /dev/null
+++ b/test/tools/doclint/UnfinishedInlineTagTest.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007096
+ * @summary DocLint parsing problems with some comments
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html UnfinishedInlineTagTest.java
+ * @run main DocLintTester -Xmsgs -ref UnfinishedInlineTagTest.out UnfinishedInlineTagTest.java
+ * @author jlahoda
+ */
+
+import java.util.List;
+
+/**{@link List
+ */
+public class UnfinishedInlineTagTest {
+}
+
diff --git a/test/tools/doclint/UnfinishedInlineTagTest.out b/test/tools/doclint/UnfinishedInlineTagTest.out
new file mode 100644
index 0000000..eb70f3a
--- /dev/null
+++ b/test/tools/doclint/UnfinishedInlineTagTest.out
@@ -0,0 +1,5 @@
+UnfinishedInlineTagTest.java:14: error: unterminated inline tag
+ */
+^
+1 error
+
diff --git a/test/tools/doclint/ValidTest.java b/test/tools/doclint/ValidTest.java
new file mode 100644
index 0000000..5189f9c
--- /dev/null
+++ b/test/tools/doclint/ValidTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ *
+ * 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 8004832
+ * @summary Add new doclint package
+ * @build DocLintTester
+ * @run main DocLintTester ValidTest.java
+ */
+
+class ValidTest {
+    /**
+     * < > & (
+     */
+    void entities() { }
+
+    /**
+     * <h1> ... </h1>
+     * <h2> ... </h2>
+     * <h3> ... </h3>
+     * <h4> ... </h4>
+     * <h5> ... </h5>
+     * <h6> ... </h6>
+     */
+    void all_headers() { }
+
+    /**
+     * <h1> ... </h1>
+     * <h2> ... </h2>
+     * <h3> ... </h3>
+     * <h1> ... </h1>
+     * <h2> ... </h2>
+     * <h3> ... </h3>
+     * <h2> ... </h2>
+     */
+    void header_series() { }
+
+    /**
+     * <div> <p>   </div>
+     */
+    void autoclose_tags() { }
+
+    /**
+     * @param x
+     */
+    void method_param(int x) { }
+
+    /**
+     * @param <T>
+     */
+    <T> T method_typaram(T t) { return t; }
+
+    /**
+     * @param <T>
+     */
+    class ClassTyparam<T> { }
+
+    /**
+     * @param <T>
+     */
+    interface InterfaceTyparam<T> { }
+
+    /**
+     * @return x
+     */
+    int return_int() { return 0; }
+
+    /**
+     * @exception Exception
+     */
+    void throws_Exception1() throws Exception { }
+
+    /**
+     * @throws Exception
+     */
+    void throws_Exception2() throws Exception { }
+
+    class X {
+        /**
+         * @param x
+         */
+        X(int x) { } // constructor parameter
+
+        /**
+         * @param <T>
+         */
+        <T> X(T t) { } // constructor type parameter
+    }
+
+}
+
diff --git a/test/tools/doclint/html/AAA.java b/test/tools/doclint/html/AAA.java
new file mode 100644
index 0000000..3880733
--- /dev/null
+++ b/test/tools/doclint/html/AAA.java
@@ -0,0 +1,35 @@
+/*
+ * 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 8006728
+ * @summary temporarily workaround jtreg problems for doclint tests in othervm
+ */
+
+// dummy test/class to be compiled before other tests in this directory
+// see JDK-8006730
+public class AAA {
+    public static void main(String... args) { }
+}
+
diff --git a/test/tools/doclint/html/BlockTagsTest.java b/test/tools/doclint/html/BlockTagsTest.java
new file mode 100644
index 0000000..aaddc06
--- /dev/null
+++ b/test/tools/doclint/html/BlockTagsTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 8006251
+ * @summary test block tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs BlockTagsTest.java
+ */
+
+/** */
+public class BlockTagsTest {
+    /**
+     *  <blockquote> abc </blockquote>
+     *  <center> abc </center>
+     *  <div> abc </div>
+     *  <dl> <dt> abc <dd> def </dl>
+     *  <div> abc </div>
+     *  <h1> abc </h1>
+     *  <h2> abc </h2>
+     *  <h3> abc </h3>
+     *  <h4> abc </h4>
+     *  <h5> abc </h5>
+     *  <h6> abc </h6>
+     *  <hr>
+     *  <menu> <li> abc </menu>
+     *  <noscript> </noscript>
+     *  <ol> <li> abc </ol>
+     *  <p> abc </p>
+     *  <pre> abc </pre>
+     *  <table summary="abc"> <tr> <td> </table>
+     *  <ul> <li> abc </ul>
+     */
+    public void supportedTags() { }
+}
diff --git a/test/tools/doclint/html/EntitiesTest.java b/test/tools/doclint/html/EntitiesTest.java
new file mode 100644
index 0000000..3c05f42
--- /dev/null
+++ b/test/tools/doclint/html/EntitiesTest.java
@@ -0,0 +1,317 @@
+/*
+ * 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 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html EntitiesTest.java
+ * @run main DocLintTester -Xmsgs:html -ref EntitiesTest.out EntitiesTest.java
+ */
+
+/** */
+class EntitiesTest {
+
+    /**
+     *    &#x20;
+     * ࡎ &#x84e; &#x84E;
+     */
+    void range_test() { }
+
+    /**
+    *    
+    * ¡ ¡
+    * ¢ ¢
+    * £ £
+    * ¤ ¤
+    * ¥ ¥
+    * ¦ ¦
+    * § §
+    * ¨ ¨
+    * © ©
+    * ª ª
+    * « «
+    * ¬ ¬
+    * ­ ­
+    * ® ®
+    * ¯ ¯
+    * ° °
+    * ± ±
+    * &sup2; ²
+    * &sup3; ³
+    * ´ ´
+    * µ µ
+    * ¶ ¶
+    * · ·
+    * ¸ ¸
+    * &sup1; ¹
+    * º º
+    * » »
+    * &frac14; ¼
+    * &frac12; ½
+    * &frac34; ¾
+    * ¿ ¿
+    * À À
+    * Á Á
+    * Â Â
+    * Ã Ã
+    * Ä Ä
+    * Å Å
+    * Æ Æ
+    * Ç Ç
+    * È È
+    * É É
+    * Ê Ê
+    * Ë Ë
+    * Ì Ì
+    * Í Í
+    * Î Î
+    * Ï Ï
+    * Ð Ð
+    * Ñ Ñ
+    * Ò Ò
+    * Ó Ó
+    * Ô Ô
+    * Õ Õ
+    * Ö Ö
+    * × ×
+    * Ø Ø
+    * Ù Ù
+    * Ú Ú
+    * Û Û
+    * Ü Ü
+    * Ý Ý
+    * Þ Þ
+    * ß ß
+    * à à
+    * á á
+    * â â
+    * ã ã
+    * ä ä
+    * å å
+    * æ æ
+    * ç ç
+    * è è
+    * é é
+    * ê ê
+    * ë ë
+    * ì ì
+    * í í
+    * î î
+    * ï ï
+    * ð ð
+    * ñ ñ
+    * ò ò
+    * ó ó
+    * ô ô
+    * õ õ
+    * ö ö
+    * ÷ ÷
+    * ø ø
+    * ù ù
+    * ú ú
+    * û û
+    * ü ü
+    * ý ý
+    * þ þ
+    * ÿ ÿ
+    * ƒ ƒ
+    * Α Α
+    * Β Β
+    * Γ Γ
+    * Δ Δ
+    * Ε Ε
+    * Ζ Ζ
+    * Η Η
+    * Θ Θ
+    * Ι Ι
+    * Κ Κ
+    * Λ Λ
+    * Μ Μ
+    * Ν Ν
+    * Ξ Ξ
+    * Ο Ο
+    * Π Π
+    * Ρ Ρ
+    * Σ Σ
+    * Τ Τ
+    * Υ Υ
+    * Φ Φ
+    * Χ Χ
+    * Ψ Ψ
+    * Ω Ω
+    * α α
+    * β β
+    * γ γ
+    * δ δ
+    * ε ε
+    * ζ ζ
+    * η η
+    * θ θ
+    * ι ι
+    * κ κ
+    * λ λ
+    * μ μ
+    * ν ν
+    * ξ ξ
+    * ο ο
+    * π π
+    * ρ ρ
+    * ς ς
+    * σ σ
+    * τ τ
+    * υ υ
+    * φ φ
+    * χ χ
+    * ψ ψ
+    * ω ω
+    * ϑ ϑ
+    * ϒ ϒ
+    * ϖ ϖ
+    * • •
+    * … …
+    * ′ ′
+    * ″ ″
+    * ‾ ‾
+    * ⁄ ⁄
+    * ℘ ℘
+    * ℑ ℑ
+    * ℜ ℜ
+    * ™ ™
+    * ℵ ℵ
+    * ← ←
+    * ↑ ↑
+    * → →
+    * ↓ ↓
+    * ↔ ↔
+    * ↵ ↵
+    * ⇐ ⇐
+    * ⇑ ⇑
+    * ⇒ ⇒
+    * ⇓ ⇓
+    * ⇔ ⇔
+    * ∀ ∀
+    * ∂ ∂
+    * ∃ ∃
+    * ∅ ∅
+    * ∇ ∇
+    * ∈ ∈
+    * ∉ ∉
+    * ∋ ∋
+    * ∏ ∏
+    * ∑ ∑
+    * − −
+    * ∗ ∗
+    * √ √
+    * ∝ ∝
+    * ∞ ∞
+    * ∠ ∠
+    * ∧ ∧
+    * ∨ ∨
+    * ∩ ∩
+    * ∪ ∪
+    * &_int; ∫
+    * &there4; ∴
+    * ∼ ∼
+    * ≅ ≅
+    * ≈ ≈
+    * ≠ ≠
+    * ≡ ≡
+    * ≤ ≤
+    * ≥ ≥
+    * ⊂ ⊂
+    * ⊃ ⊃
+    * ⊄ ⊄
+    * ⊆ ⊆
+    * ⊇ ⊇
+    * ⊕ ⊕
+    * ⊗ ⊗
+    * ⊥ ⊥
+    * ⋅ ⋅
+    * ⌈ ⌈
+    * ⌉ ⌉
+    * ⌊ ⌊
+    * ⌋ ⌋
+    * ⟨ 〈
+    * ⟩ 〉
+    * ◊ ◊
+    * ♠ ♠
+    * ♣ ♣
+    * ♥ ♥
+    * ♦ ♦
+    * " "
+    * & &
+    * < <
+    * > >
+    * Œ Œ
+    * œ œ
+    * Š Š
+    * š š
+    * Ÿ Ÿ
+    * ˆ ˆ
+    * ˜ ˜
+    *    
+    *    
+    *    
+    * ‌ ‌
+    * ‍ ‍
+    * ‎ ‎
+    * ‏ ‏
+    * – –
+    * — —
+    * ‘ ‘
+    * ’ ’
+    * ‚ ‚
+    * “ “
+    * ” ”
+    * „ „
+    * † †
+    * ‡ ‡
+    * ‰ ‰
+    * ‹ ‹
+    * › ›
+    * € €
+    */
+    void symbolic_entities() { }
+
+    /**
+     * &bad;
+     */
+    void bad_name() { }
+
+    /**
+     * 
+     * ࡏ
+     */
+    void out_of_range() { }
+
+    /**
+     * ―
+     * ⌫
+     * &#xffff;
+     */
+    void sparse_negative() { }
+}
+
diff --git a/test/tools/doclint/html/EntitiesTest.out b/test/tools/doclint/html/EntitiesTest.out
new file mode 100644
index 0000000..98a20d4
--- /dev/null
+++ b/test/tools/doclint/html/EntitiesTest.out
@@ -0,0 +1,19 @@
+EntitiesTest.java:300: error: invalid entity &bad;
+     * &bad;
+       ^
+EntitiesTest.java:305: error: invalid entity 
+     * 
+       ^
+EntitiesTest.java:306: error: invalid entity ࡏ
+     * ࡏ
+       ^
+EntitiesTest.java:311: error: invalid entity ―
+     * ―
+       ^
+EntitiesTest.java:312: error: invalid entity ⌫
+     * ⌫
+       ^
+EntitiesTest.java:313: error: invalid entity &#xffff;
+     * &#xffff;
+       ^
+6 errors
diff --git a/test/tools/doclint/html/InlineTagsTest.java b/test/tools/doclint/html/InlineTagsTest.java
new file mode 100644
index 0000000..4835b36
--- /dev/null
+++ b/test/tools/doclint/html/InlineTagsTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 8006251
+ * @summary test inline tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs InlineTagsTest.java
+ */
+
+/** */
+public class InlineTagsTest {
+    /**
+     *  <a href="#abc"> abc </a>
+     *  <b> abc </b>
+     *  <big> abc </big>
+     *  <br>
+     *  <cite> abc </cite>
+     *  <code> abc </code>
+     *  <em> abc </em>
+     *  <font> abc </font>
+     *  <i> abc </i>
+     *  <img alt="image" src="image.png">
+     *  <small> abc </small>
+     *  <span> abc </span>
+     *  <strong> abc </strong>
+     *  <sub> abc </sub>
+     *  <sup> abc </sup>
+     *  <tt> abc </tt>
+     *  <u> abc </u>
+     *  <var> abc </var>
+     */
+    public void supportedTags() { }
+}
+
diff --git a/test/tools/doclint/html/ListTagsTest.java b/test/tools/doclint/html/ListTagsTest.java
new file mode 100644
index 0000000..571c8f9
--- /dev/null
+++ b/test/tools/doclint/html/ListTagsTest.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006251 8013405
+ * @summary test list tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs -ref ListTagsTest.out ListTagsTest.java
+ */
+
+/** */
+public class ListTagsTest {
+    /**
+     *  <dl> <dt> abc <dd> def </dl>
+     *  <ol> <li> abc </ol>
+     *  <ol> <li value="1"> abc </ol>
+     *  <ol> <li value> bad </ol>
+     *  <ol> <li value="a"> bad </ol>
+     *  <ul> <li> abc </ul>
+     */
+    public void supportedTags() { }
+}
diff --git a/test/tools/doclint/html/ListTagsTest.out b/test/tools/doclint/html/ListTagsTest.out
new file mode 100644
index 0000000..2b61919
--- /dev/null
+++ b/test/tools/doclint/html/ListTagsTest.out
@@ -0,0 +1,7 @@
+ListTagsTest.java:16: error: attribute lacks value
+     *  <ol> <li value> bad </ol>
+                 ^
+ListTagsTest.java:17: error: attribute value is not a number
+     *  <ol> <li value="a"> bad </ol>
+                 ^
+2 errors
diff --git a/test/tools/doclint/html/OtherTagsTest.java b/test/tools/doclint/html/OtherTagsTest.java
new file mode 100644
index 0000000..ce6af82
--- /dev/null
+++ b/test/tools/doclint/html/OtherTagsTest.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006251
+ * @summary test other tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs -ref OtherTagsTest.out OtherTagsTest.java
+ */
+
+/** */
+public class OtherTagsTest {
+    /**
+     *  <body> <p> abc </body>
+     *  <frame>
+     *  <frameset> </frameset>
+     *  <head> </head>
+     *  <link>
+     *  <meta>
+     *  <noframes> </noframes>
+     *  <script> </script>
+     *  <title> </title>
+     */
+    public void knownInvalidTags() { }
+}
diff --git a/test/tools/doclint/html/OtherTagsTest.out b/test/tools/doclint/html/OtherTagsTest.out
new file mode 100644
index 0000000..0ead88e
--- /dev/null
+++ b/test/tools/doclint/html/OtherTagsTest.out
@@ -0,0 +1,28 @@
+OtherTagsTest.java:13: error: element not allowed in documentation comments: <body>
+     *  <body> <p> abc </body>
+        ^
+OtherTagsTest.java:14: error: element not allowed in documentation comments: <frame>
+     *  <frame>
+        ^
+OtherTagsTest.java:15: error: element not allowed in documentation comments: <frameset>
+     *  <frameset> </frameset>
+        ^
+OtherTagsTest.java:16: error: element not allowed in documentation comments: <head>
+     *  <head> </head>
+        ^
+OtherTagsTest.java:17: error: element not allowed in documentation comments: <link>
+     *  <link>
+        ^
+OtherTagsTest.java:18: error: element not allowed in documentation comments: <meta>
+     *  <meta>
+        ^
+OtherTagsTest.java:19: error: element not allowed in documentation comments: <noframes>
+     *  <noframes> </noframes>
+        ^
+OtherTagsTest.java:20: error: element not allowed in documentation comments: <script>
+     *  <script> </script>
+        ^
+OtherTagsTest.java:21: error: element not allowed in documentation comments: <title>
+     *  <title> </title>
+        ^
+9 errors
diff --git a/test/tools/doclint/html/TableTagsTest.java b/test/tools/doclint/html/TableTagsTest.java
new file mode 100644
index 0000000..7cea1b3
--- /dev/null
+++ b/test/tools/doclint/html/TableTagsTest.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8006251
+ * @summary test table tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs TableTagsTest.java
+ */
+
+/** */
+public class TableTagsTest {
+    /**
+     *  <table summary="abc"> <tr> <td> </table>
+     *  <table summary="abc"> <tr> <th> </table>
+     *  <table> <caption> abc </caption> <tr> <td> </table>
+     *  <table summary="abc"> <thead> <tr> </thead> <tr> <td> </table>
+     *  <table summary="abc"> <tbody> <tr> <td> </tbody> </table>
+     *  <table summary="abc"> <tr> <td> <tfoot> <tr> </tfoot></table>
+     */
+    public void supportedTags() { }
+}
diff --git a/test/tools/doclint/html/TagNotAllowed.java b/test/tools/doclint/html/TagNotAllowed.java
new file mode 100644
index 0000000..65a0bcc
--- /dev/null
+++ b/test/tools/doclint/html/TagNotAllowed.java
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TagNotAllowed.out TagNotAllowed.java
+ */
+
+/**
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+ *
+ * <table summary=description> <b>abc</b> </table>
+ * <table summary=description> <thead> <b>abc</b> </thead> </table>
+ * <table summary=description> <tbody> <b>abc</b> </tbody> </table>
+ * <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
+ * <table summary=description> <tr> <b>abc</b> </tr> </table>
+ *
+ * <pre>
+ *   <img alt="image" src="image.png">
+ *   <p> para </p>
+ *   <big> text </big>
+ *   <small> text </small>
+ *   <sub> text </sub>
+ *   <sup> text </sup>
+ * </pre>
+ */
+public class TagNotAllowed { }
diff --git a/test/tools/doclint/html/TagNotAllowed.out b/test/tools/doclint/html/TagNotAllowed.out
new file mode 100644
index 0000000..fa65f85
--- /dev/null
+++ b/test/tools/doclint/html/TagNotAllowed.out
@@ -0,0 +1,61 @@
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+        ^
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+                                   ^
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+                                                                     ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+        ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+                                   ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+                                                              ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+        ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+                                   ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+                                                              ^
+TagNotAllowed.java:15: error: tag not allowed here: <b>
+ * <table summary=description> <b>abc</b> </table>
+                               ^
+TagNotAllowed.java:16: error: tag not allowed here: <b>
+ * <table summary=description> <thead> <b>abc</b> </thead> </table>
+                                       ^
+TagNotAllowed.java:17: error: tag not allowed here: <b>
+ * <table summary=description> <tbody> <b>abc</b> </tbody> </table>
+                                       ^
+TagNotAllowed.java:18: error: tag not allowed here: <b>
+ * <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
+                                       ^
+TagNotAllowed.java:19: error: tag not allowed here: <b>
+ * <table summary=description> <tr> <b>abc</b> </tr> </table>
+                                    ^
+TagNotAllowed.java:22: error: tag not allowed here: <img>
+ *   <img alt="image" src="image.png">
+     ^
+TagNotAllowed.java:23: error: tag not allowed here: <p>
+ *   <p> para </p>
+     ^
+TagNotAllowed.java:24: error: tag not allowed here: <big>
+ *   <big> text </big>
+     ^
+TagNotAllowed.java:25: error: tag not allowed here: <small>
+ *   <small> text </small>
+     ^
+TagNotAllowed.java:26: error: tag not allowed here: <sub>
+ *   <sub> text </sub>
+     ^
+TagNotAllowed.java:27: error: tag not allowed here: <sup>
+ *   <sup> text </sup>
+     ^
+20 errors
diff --git a/test/tools/doclint/html/TextNotAllowed.java b/test/tools/doclint/html/TextNotAllowed.java
new file mode 100644
index 0000000..6030a97
--- /dev/null
+++ b/test/tools/doclint/html/TextNotAllowed.java
@@ -0,0 +1,32 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TextNotAllowed.out TextNotAllowed.java
+ */
+
+/**
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+ *
+ * <table summary=description> abc </table>
+ * <table summary=description> <thead> abc </thead> </table>
+ * <table summary=description> <tbody> abc </tbody> </table>
+ * <table summary=description> <tfoot> abc </tfoot> </table>
+ * <table summary=description> <tr> abc </tr> </table>
+ *
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+ *
+ * <table summary=description> & </table>
+ * <table summary=description> <thead> & </thead> </table>
+ * <table summary=description> <tbody> & </tbody> </table>
+ * <table summary=description> <tfoot> & </tfoot> </table>
+ * <table summary=description> <tr> & </tr> </table>
+ *
+ */
+public class TextNotAllowed { }
diff --git a/test/tools/doclint/html/TextNotAllowed.out b/test/tools/doclint/html/TextNotAllowed.out
new file mode 100644
index 0000000..af5efa2
--- /dev/null
+++ b/test/tools/doclint/html/TextNotAllowed.out
@@ -0,0 +1,85 @@
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+       ^
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+                           ^
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+                                                      ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+       ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+                           ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+                                               ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+       ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+                           ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+                                               ^
+TextNotAllowed.java:15: error: text not allowed in <table> element
+ * <table summary=description> abc </table>
+                              ^
+TextNotAllowed.java:16: error: text not allowed in <thead> element
+ * <table summary=description> <thead> abc </thead> </table>
+                                      ^
+TextNotAllowed.java:17: error: text not allowed in <tbody> element
+ * <table summary=description> <tbody> abc </tbody> </table>
+                                      ^
+TextNotAllowed.java:18: error: text not allowed in <tfoot> element
+ * <table summary=description> <tfoot> abc </tfoot> </table>
+                                      ^
+TextNotAllowed.java:19: error: text not allowed in <tr> element
+ * <table summary=description> <tr> abc </tr> </table>
+                                   ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+        ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+                              ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+                                                          ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+        ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+                              ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+                                                   ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+        ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+                              ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+                                                   ^
+TextNotAllowed.java:25: error: text not allowed in <table> element
+ * <table summary=description> & </table>
+                               ^
+TextNotAllowed.java:26: error: text not allowed in <thead> element
+ * <table summary=description> <thead> & </thead> </table>
+                                       ^
+TextNotAllowed.java:27: error: text not allowed in <tbody> element
+ * <table summary=description> <tbody> & </tbody> </table>
+                                       ^
+TextNotAllowed.java:28: error: text not allowed in <tfoot> element
+ * <table summary=description> <tfoot> & </tfoot> </table>
+                                       ^
+TextNotAllowed.java:29: error: text not allowed in <tr> element
+ * <table summary=description> <tr> & </tr> </table>
+                                    ^
+28 errors
diff --git a/test/tools/doclint/tidy/AAA.java b/test/tools/doclint/tidy/AAA.java
new file mode 100644
index 0000000..3880733
--- /dev/null
+++ b/test/tools/doclint/tidy/AAA.java
@@ -0,0 +1,35 @@
+/*
+ * 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 8006728
+ * @summary temporarily workaround jtreg problems for doclint tests in othervm
+ */
+
+// dummy test/class to be compiled before other tests in this directory
+// see JDK-8006730
+public class AAA {
+    public static void main(String... args) { }
+}
+
diff --git a/test/tools/doclint/tidy/AnchorAlreadyDefined.java b/test/tools/doclint/tidy/AnchorAlreadyDefined.java
new file mode 100644
index 0000000..f5ad174
--- /dev/null
+++ b/test/tools/doclint/tidy/AnchorAlreadyDefined.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref AnchorAlreadyDefined.out AnchorAlreadyDefined.java
+ */
+
+// tidy: Warning: <.*> anchor ".*" already defined
+
+/**
+ * <a name="here">valid</a>
+ * <a name="here">duplicate</a>
+ * <h1 id="here">duplicate</h1>
+ */
+public class AnchorAlreadyDefined { }
diff --git a/test/tools/doclint/tidy/AnchorAlreadyDefined.out b/test/tools/doclint/tidy/AnchorAlreadyDefined.out
new file mode 100644
index 0000000..569fa1e
--- /dev/null
+++ b/test/tools/doclint/tidy/AnchorAlreadyDefined.out
@@ -0,0 +1,7 @@
+AnchorAlreadyDefined.java:14: error: anchor already defined: here
+ * <a name="here">duplicate</a>
+      ^
+AnchorAlreadyDefined.java:15: error: anchor already defined: here
+ * <h1 id="here">duplicate</h1>
+       ^
+2 errors
diff --git a/test/tools/doclint/tidy/BadEnd.java b/test/tools/doclint/tidy/BadEnd.java
new file mode 100644
index 0000000..74c1427
--- /dev/null
+++ b/test/tools/doclint/tidy/BadEnd.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref BadEnd.out BadEnd.java
+ */
+
+// tidy: Warning: <.*> is probably intended as </.*>
+
+/**
+ * <a name="here"> text <a>
+ * <code> text <code>
+ */
+public class BadEnd { }
diff --git a/test/tools/doclint/tidy/BadEnd.out b/test/tools/doclint/tidy/BadEnd.out
new file mode 100644
index 0000000..1be1068
--- /dev/null
+++ b/test/tools/doclint/tidy/BadEnd.out
@@ -0,0 +1,17 @@
+BadEnd.java:14: warning: nested tag not allowed: <code>
+ * <code> text <code>
+               ^
+BadEnd.java:14: error: element not closed: code
+ * <code> text <code>
+               ^
+BadEnd.java:14: error: element not closed: code
+ * <code> text <code>
+   ^
+BadEnd.java:13: error: element not closed: a
+ * <a name="here"> text <a>
+                        ^
+BadEnd.java:13: error: element not closed: a
+ * <a name="here"> text <a>
+   ^
+4 errors
+1 warning
diff --git a/test/tools/doclint/tidy/InsertImplicit.java b/test/tools/doclint/tidy/InsertImplicit.java
new file mode 100644
index 0000000..e361082
--- /dev/null
+++ b/test/tools/doclint/tidy/InsertImplicit.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref InsertImplicit.out InsertImplicit.java
+ */
+
+// tidy: Warning: inserting implicit <.*>
+
+/**
+ * </p>
+ * <i> <blockquote> abc </blockquote> </i>
+ */
+public class InsertImplicit { }
diff --git a/test/tools/doclint/tidy/InsertImplicit.out b/test/tools/doclint/tidy/InsertImplicit.out
new file mode 100644
index 0000000..853654d
--- /dev/null
+++ b/test/tools/doclint/tidy/InsertImplicit.out
@@ -0,0 +1,7 @@
+InsertImplicit.java:13: error: unexpected end tag: </p>
+ * </p>
+   ^
+InsertImplicit.java:14: error: block element not allowed within inline element <i>: blockquote
+ * <i> <blockquote> abc </blockquote> </i>
+       ^
+2 errors
diff --git a/test/tools/doclint/tidy/InvalidEntity.java b/test/tools/doclint/tidy/InvalidEntity.java
new file mode 100644
index 0000000..c6ee3aa
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidEntity.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref InvalidEntity.out InvalidEntity.java
+ */
+
+// tidy: Warning: replacing invalid numeric character reference .*
+
+// See
+// http://www.w3.org/TR/html4/sgml/entities.html
+// http://stackoverflow.com/questions/631406/what-is-the-difference-between-em-dash-151-and-8212
+
+/**
+ * 
+ * &#x01;
+ * &splodge;
+ *
+ */
+public class InvalidEntity { }
diff --git a/test/tools/doclint/tidy/InvalidEntity.out b/test/tools/doclint/tidy/InvalidEntity.out
new file mode 100644
index 0000000..bd4527a
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidEntity.out
@@ -0,0 +1,10 @@
+InvalidEntity.java:17: error: invalid entity 
+ * 
+   ^
+InvalidEntity.java:18: error: invalid entity &#x01;
+ * &#x01;
+   ^
+InvalidEntity.java:19: error: invalid entity &splodge;
+ * &splodge;
+   ^
+3 errors
diff --git a/test/tools/doclint/tidy/InvalidName.java b/test/tools/doclint/tidy/InvalidName.java
new file mode 100644
index 0000000..fe87ee8
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidName.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref InvalidName.out InvalidName.java
+ */
+
+// tidy: Warning: <a> cannot copy name attribute to id
+
+/**
+ * <a name="abc">valid</a>
+ * <a name="abc123">valid</a>
+ * <a name="a.1:2-3_4">valid</a>
+ * <a name="foo()">invalid</a>
+ */
+public class InvalidName { }
diff --git a/test/tools/doclint/tidy/InvalidName.out b/test/tools/doclint/tidy/InvalidName.out
new file mode 100644
index 0000000..8b50a6f
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidName.out
@@ -0,0 +1,4 @@
+InvalidName.java:16: error: invalid name for anchor: "foo()"
+ * <a name="foo()">invalid</a>
+      ^
+1 error
diff --git a/test/tools/doclint/tidy/InvalidTag.java b/test/tools/doclint/tidy/InvalidTag.java
new file mode 100644
index 0000000..8651382
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidTag.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref InvalidTag.out InvalidTag.java
+ */
+
+// tidy: Error: <.*> is not recognized!
+
+/**
+ * List<String> list = new ArrayList<>();
+ */
+public class InvalidTag { }
diff --git a/test/tools/doclint/tidy/InvalidTag.out b/test/tools/doclint/tidy/InvalidTag.out
new file mode 100644
index 0000000..5422e72
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidTag.out
@@ -0,0 +1,10 @@
+InvalidTag.java:13: error: unknown tag: String
+ * List<String> list = new ArrayList<>();
+       ^
+InvalidTag.java:13: error: malformed HTML
+ * List<String> list = new ArrayList<>();
+                                    ^
+InvalidTag.java:13: error: bad use of '>'
+ * List<String> list = new ArrayList<>();
+                                     ^
+3 errors
diff --git a/test/tools/doclint/tidy/InvalidURI.java b/test/tools/doclint/tidy/InvalidURI.java
new file mode 100644
index 0000000..ba9e70a
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidURI.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref InvalidURI.out InvalidURI.java
+ */
+
+// tidy: Warning: <a> escaping malformed URI reference
+// tidy: Warning: <.*> attribute ".*" lacks value
+
+/**
+ * <a href="abc">valid</a>
+ * <a href="abc%20def">valid</a>
+ * <a href="abc def">invalid</a>
+ * <a href>no value</a>
+ * <a href= >no value</a>
+ * <a href="" >no value</a>
+ */
+public class InvalidURI { }
diff --git a/test/tools/doclint/tidy/InvalidURI.out b/test/tools/doclint/tidy/InvalidURI.out
new file mode 100644
index 0000000..294c592
--- /dev/null
+++ b/test/tools/doclint/tidy/InvalidURI.out
@@ -0,0 +1,13 @@
+InvalidURI.java:16: error: invalid uri: "abc def"
+ * <a href="abc def">invalid</a>
+      ^
+InvalidURI.java:17: error: attribute lacks value
+ * <a href>no value</a>
+      ^
+InvalidURI.java:18: error: attribute lacks value
+ * <a href= >no value</a>
+      ^
+InvalidURI.java:19: error: attribute lacks value
+ * <a href="" >no value</a>
+      ^
+4 errors
diff --git a/test/tools/doclint/tidy/MissingGT.java b/test/tools/doclint/tidy/MissingGT.java
new file mode 100644
index 0000000..8e787aa
--- /dev/null
+++ b/test/tools/doclint/tidy/MissingGT.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref MissingGT.out MissingGT.java
+ */
+
+// tidy: Warning: <.*> missing '>' for end of tag
+
+/**
+ * <img src="image.gif"
+ * <i>  text </i>
+ */
+public class MissingGT { }
diff --git a/test/tools/doclint/tidy/MissingGT.out b/test/tools/doclint/tidy/MissingGT.out
new file mode 100644
index 0000000..28455db
--- /dev/null
+++ b/test/tools/doclint/tidy/MissingGT.out
@@ -0,0 +1,4 @@
+MissingGT.java:13: error: malformed HTML
+ * <img src="image.gif"
+   ^
+1 error
diff --git a/test/tools/doclint/tidy/MissingTag.java b/test/tools/doclint/tidy/MissingTag.java
new file mode 100644
index 0000000..2e26adc
--- /dev/null
+++ b/test/tools/doclint/tidy/MissingTag.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref MissingTag.out MissingTag.java
+ */
+
+// tidy: Warning: missing <.*>
+// tidy: Warning: missing </.*> before </.*>
+
+/**
+ * </p>
+ * <h1> <b> text </h1>
+ */
+public class MissingTag { }
diff --git a/test/tools/doclint/tidy/MissingTag.out b/test/tools/doclint/tidy/MissingTag.out
new file mode 100644
index 0000000..152bfe3
--- /dev/null
+++ b/test/tools/doclint/tidy/MissingTag.out
@@ -0,0 +1,7 @@
+MissingTag.java:14: error: unexpected end tag: </p>
+ * </p>
+   ^
+MissingTag.java:15: error: end tag missing: </b>
+ * <h1> <b> text </h1>
+        ^
+2 errors
diff --git a/test/tools/doclint/tidy/NestedTag.java b/test/tools/doclint/tidy/NestedTag.java
new file mode 100644
index 0000000..7d1d077
--- /dev/null
+++ b/test/tools/doclint/tidy/NestedTag.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref NestedTag.out NestedTag.java
+ */
+
+// tidy: Warning: nested emphasis <.*>
+
+/**
+ * <b><b> text </b></b>
+ * {@link java.lang.String <code>String</code>}
+ */
+public class NestedTag { }
diff --git a/test/tools/doclint/tidy/NestedTag.out b/test/tools/doclint/tidy/NestedTag.out
new file mode 100644
index 0000000..4a8a8dc
--- /dev/null
+++ b/test/tools/doclint/tidy/NestedTag.out
@@ -0,0 +1,7 @@
+NestedTag.java:13: warning: nested tag not allowed: <b>
+ * <b><b> text </b></b>
+      ^
+NestedTag.java:14: warning: nested tag not allowed: <code>
+ * {@link java.lang.String <code>String</code>}
+                           ^
+2 warnings
diff --git a/test/tools/doclint/tidy/ParaInPre.java b/test/tools/doclint/tidy/ParaInPre.java
new file mode 100644
index 0000000..e877d5e
--- /dev/null
+++ b/test/tools/doclint/tidy/ParaInPre.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref ParaInPre.out ParaInPre.java
+ */
+
+// tidy: Warning: replacing <p> by <br>
+// tidy: Warning: using <br> in place of <p>
+
+/**
+ * <pre>
+ *     text
+ *     <p>
+ *     more text
+ * </pre>
+ */
+public class ParaInPre { }
diff --git a/test/tools/doclint/tidy/ParaInPre.out b/test/tools/doclint/tidy/ParaInPre.out
new file mode 100644
index 0000000..ff96781
--- /dev/null
+++ b/test/tools/doclint/tidy/ParaInPre.out
@@ -0,0 +1,4 @@
+ParaInPre.java:16: error: tag not allowed here: <p>
+ *     <p>
+       ^
+1 error
diff --git a/test/tools/doclint/tidy/README.txt b/test/tools/doclint/tidy/README.txt
new file mode 100644
index 0000000..662d654
--- /dev/null
+++ b/test/tools/doclint/tidy/README.txt
@@ -0,0 +1,21 @@
+The utilities in this directory can be used to determine
+common issues in javadoc comments by running the standard
+"tidy" program on the output of javadoc, and analysing
+the messages that are reported.
+
+tidy.sh is a script that will run the "tidy" program on
+the files in a directory, writing the results to a new
+directroy.
+
+tidystats.Main is a Java program that can analyze the 
+files produced by the tidy.sh script to generate a 
+summary report about the warnings that were found.
+
+
+The tests is this directory are focussed on verifying
+that doclint detects issues in javadoc comments that will
+give rise to issues detected by "tidy" in the output
+generated by javadoc. 
+
+For more information on the "tidy" program, see the HTML Tidy
+Library Project page at http://tidy.sourceforge.net/.
diff --git a/test/tools/doclint/tidy/RepeatedAttr.java b/test/tools/doclint/tidy/RepeatedAttr.java
new file mode 100644
index 0000000..f16e7c9
--- /dev/null
+++ b/test/tools/doclint/tidy/RepeatedAttr.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref RepeatedAttr.out RepeatedAttr.java
+ */
+
+// tidy: Warning: <.*> dropping value ".*" for repeated attribute ".*"
+
+/**
+ * <img src="image.gif" alt alt="summary">
+ */
+public class RepeatedAttr { }
diff --git a/test/tools/doclint/tidy/RepeatedAttr.out b/test/tools/doclint/tidy/RepeatedAttr.out
new file mode 100644
index 0000000..0ed1e9f
--- /dev/null
+++ b/test/tools/doclint/tidy/RepeatedAttr.out
@@ -0,0 +1,4 @@
+RepeatedAttr.java:13: error: repeated attribute: alt
+ * <img src="image.gif" alt alt="summary">
+                            ^
+1 error
diff --git a/test/tools/doclint/tidy/TextNotAllowed.java b/test/tools/doclint/tidy/TextNotAllowed.java
new file mode 100644
index 0000000..c5123c5
--- /dev/null
+++ b/test/tools/doclint/tidy/TextNotAllowed.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TextNotAllowed.out TextNotAllowed.java
+ */
+
+// tidy: Warning: plain text isn't allowed in <.*> elements
+
+/**
+ * <table summary=description> abc </table>
+ * <table summary=description> <tbody> abc </tbody> </table>
+ * <table summary=description> <tr> abc </tr> </table>
+ *
+ * <dl> abc </dl>
+ * <ol> abc </ol>
+ * <ul> abc </ul>
+ *
+ * <ul>
+ *     <li> item
+ *     <li> item
+ * </ul>
+ */
+public class TextNotAllowed { }
diff --git a/test/tools/doclint/tidy/TextNotAllowed.out b/test/tools/doclint/tidy/TextNotAllowed.out
new file mode 100644
index 0000000..cc6442f
--- /dev/null
+++ b/test/tools/doclint/tidy/TextNotAllowed.out
@@ -0,0 +1,19 @@
+TextNotAllowed.java:13: error: text not allowed in <table> element
+ * <table summary=description> abc </table>
+                              ^
+TextNotAllowed.java:14: error: text not allowed in <tbody> element
+ * <table summary=description> <tbody> abc </tbody> </table>
+                                      ^
+TextNotAllowed.java:15: error: text not allowed in <tr> element
+ * <table summary=description> <tr> abc </tr> </table>
+                                   ^
+TextNotAllowed.java:17: error: text not allowed in <dl> element
+ * <dl> abc </dl>
+       ^
+TextNotAllowed.java:18: error: text not allowed in <ol> element
+ * <ol> abc </ol>
+       ^
+TextNotAllowed.java:19: error: text not allowed in <ul> element
+ * <ul> abc </ul>
+       ^
+6 errors
diff --git a/test/tools/doclint/tidy/TrimmingEmptyTag.java b/test/tools/doclint/tidy/TrimmingEmptyTag.java
new file mode 100644
index 0000000..e795d62
--- /dev/null
+++ b/test/tools/doclint/tidy/TrimmingEmptyTag.java
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TrimmingEmptyTag.out TrimmingEmptyTag.java
+ */
+
+// tidy: Warning: trimming empty <.*>
+
+/**
+ * <b></b>
+ * <table summary=description></table>
+ * <table><caption></caption></table>
+ * <code></code>
+ * <dl></dl>
+ * <dl><dt></dt><dd></dd></dl>
+ * <font></font>
+ * <i></i>
+ * <ol></ol>
+ * <p></p>
+ * <pre></pre>
+ * <span></span>
+ * <tt></tt>
+ * <ul></ul>
+ * <ul><li></li></ul>
+ */
+public class TrimmingEmptyTag { }
diff --git a/test/tools/doclint/tidy/TrimmingEmptyTag.out b/test/tools/doclint/tidy/TrimmingEmptyTag.out
new file mode 100644
index 0000000..68ca290
--- /dev/null
+++ b/test/tools/doclint/tidy/TrimmingEmptyTag.out
@@ -0,0 +1,46 @@
+TrimmingEmptyTag.java:13: warning: empty <b> tag
+ * <b></b>
+      ^
+TrimmingEmptyTag.java:14: warning: empty <table> tag
+ * <table summary=description></table>
+                              ^
+TrimmingEmptyTag.java:15: warning: empty <caption> tag
+ * <table><caption></caption></table>
+                   ^
+TrimmingEmptyTag.java:16: warning: empty <code> tag
+ * <code></code>
+         ^
+TrimmingEmptyTag.java:17: warning: empty <dl> tag
+ * <dl></dl>
+       ^
+TrimmingEmptyTag.java:18: warning: empty <dt> tag
+ * <dl><dt></dt><dd></dd></dl>
+           ^
+TrimmingEmptyTag.java:18: warning: empty <dd> tag
+ * <dl><dt></dt><dd></dd></dl>
+                    ^
+TrimmingEmptyTag.java:19: warning: empty <font> tag
+ * <font></font>
+         ^
+TrimmingEmptyTag.java:20: warning: empty <i> tag
+ * <i></i>
+      ^
+TrimmingEmptyTag.java:21: warning: empty <ol> tag
+ * <ol></ol>
+       ^
+TrimmingEmptyTag.java:22: warning: empty <p> tag
+ * <p></p>
+      ^
+TrimmingEmptyTag.java:23: warning: empty <pre> tag
+ * <pre></pre>
+        ^
+TrimmingEmptyTag.java:24: warning: empty <span> tag
+ * <span></span>
+         ^
+TrimmingEmptyTag.java:25: warning: empty <tt> tag
+ * <tt></tt>
+       ^
+TrimmingEmptyTag.java:26: warning: empty <ul> tag
+ * <ul></ul>
+       ^
+15 warnings
diff --git a/test/tools/doclint/tidy/UnescapedOrUnknownEntity.java b/test/tools/doclint/tidy/UnescapedOrUnknownEntity.java
new file mode 100644
index 0000000..c15d55a
--- /dev/null
+++ b/test/tools/doclint/tidy/UnescapedOrUnknownEntity.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref UnescapedOrUnknownEntity.out UnescapedOrUnknownEntity.java
+ */
+
+// tidy: Warning: unescaped & or unknown entity ".*"
+// tidy: Warning: unescaped & which should be written as &
+// tidy: Warning: entity ".*" doesn't end in ';'
+
+/**
+ * L&F
+ * Drag&Drop
+ * if (a & b);
+ */
+public class UnescapedOrUnknownEntity { }
diff --git a/test/tools/doclint/tidy/UnescapedOrUnknownEntity.out b/test/tools/doclint/tidy/UnescapedOrUnknownEntity.out
new file mode 100644
index 0000000..94bddc3
--- /dev/null
+++ b/test/tools/doclint/tidy/UnescapedOrUnknownEntity.out
@@ -0,0 +1,11 @@
+UnescapedOrUnknownEntity.java:15: error: semicolon missing
+ * L&F
+    ^
+UnescapedOrUnknownEntity.java:16: error: semicolon missing
+ * Drag&Drop
+       ^
+UnescapedOrUnknownEntity.java:17: error: bad HTML entity
+ * if (a & b);
+         ^
+3 errors
+
diff --git a/test/tools/doclint/tidy/util/Main.java b/test/tools/doclint/tidy/util/Main.java
new file mode 100644
index 0000000..62a559b
--- /dev/null
+++ b/test/tools/doclint/tidy/util/Main.java
@@ -0,0 +1,182 @@
+package tidystats;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Main {
+    public static void main(String... args) throws IOException {
+        new Main().run(args);
+    }
+
+    void run(String... args) throws IOException {
+        FileSystem fs = FileSystems.getDefault();
+        List<Path> paths = new ArrayList<>();
+
+        int i;
+        for (i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.startsWith("-"))
+                throw new IllegalArgumentException(arg);
+            else
+                break;
+        }
+
+        for ( ; i < args.length; i++) {
+            Path p = fs.getPath(args[i]);
+            paths.add(p);
+        }
+
+        for (Path p: paths) {
+            scan(p);
+        }
+
+        print("%6d files read", files);
+        print("%6d files had no errors or warnings", ok);
+        print("%6d files reported \"Not all warnings/errors were shown.\"", overflow);
+        print("%6d errors found", errs);
+        print("%6d warnings found", warns);
+        print("%6d recommendations to use CSS", css);
+        print("");
+
+        Map<Integer, Set<String>> sortedCounts = new TreeMap<>(
+                new Comparator<Integer>() {
+                    @Override
+                    public int compare(Integer o1, Integer o2) {
+                        return o2.compareTo(o1);
+                    }
+                });
+
+        for (Map.Entry<Pattern, Integer> e: counts.entrySet()) {
+            Pattern p = e.getKey();
+            Integer n = e.getValue();
+            Set<String> set = sortedCounts.get(n);
+            if (set == null)
+                sortedCounts.put(n, (set = new TreeSet<>()));
+            set.add(p.toString());
+        }
+
+        for (Map.Entry<Integer, Set<String>> e: sortedCounts.entrySet()) {
+            for (String p: e.getValue()) {
+                if (p.startsWith(".*")) p = p.substring(2);
+                print("%6d: %s", e.getKey(), p);
+            }
+        }
+    }
+
+    void scan(Path p) throws IOException {
+        if (Files.isDirectory(p)) {
+            for (Path c: Files.newDirectoryStream(p)) {
+                scan(c);
+            }
+        } else if (isTidyFile(p)) {
+            scan(Files.readAllLines(p, Charset.defaultCharset()));
+        }
+    }
+
+    boolean isTidyFile(Path p) {
+        return Files.isRegularFile(p) && p.getFileName().toString().endsWith(".tidy");
+    }
+
+    void scan(List<String> lines) {
+        Matcher m;
+        files++;
+        for (String line: lines) {
+            if (okPattern.matcher(line).matches()) {
+                ok++;
+            } else if ((m = countPattern.matcher(line)).matches()) {
+                warns += Integer.valueOf(m.group(1));
+                errs += Integer.valueOf(m.group(2));
+                if (m.group(3) != null)
+                    overflow++;
+            } else if ((m = guardPattern.matcher(line)).matches()) {
+                boolean found = false;
+                for (Pattern p: patterns) {
+                    if ((m = p.matcher(line)).matches()) {
+                        found = true;
+                        count(p);
+                        break;
+                    }
+                }
+                if (!found)
+                    System.err.println("Unrecognized line: " + line);
+            } else if (cssPattern.matcher(line).matches()) {
+                css++;
+            }
+        }
+    }
+
+    Map<Pattern, Integer> counts = new HashMap<>();
+    void count(Pattern p) {
+        Integer i = counts.get(p);
+        counts.put(p, (i == null) ? 1 : i + 1);
+    }
+
+    void print(String format, Object... args) {
+        System.out.println(String.format(format, args));
+    }
+
+    Pattern okPattern = Pattern.compile("No warnings or errors were found.");
+    Pattern countPattern = Pattern.compile("([0-9]+) warnings, ([0-9]+) errors were found!.*?(Not all warnings/errors were shown.)?");
+    Pattern cssPattern = Pattern.compile("You are recommended to use CSS.*");
+    Pattern guardPattern = Pattern.compile("line [0-9]+ column [0-9]+ - (Error|Warning):.*");
+
+    Pattern[] patterns = {
+        Pattern.compile(".*Error: <.*> is not recognized!"),
+        Pattern.compile(".*Error: missing quote mark for attribute value"),
+        Pattern.compile(".*Warning: <.*> anchor \".*\" already defined"),
+        Pattern.compile(".*Warning: <.*> attribute \".*\" has invalid value \".*\""),
+        Pattern.compile(".*Warning: <.*> attribute \".*\" lacks value"),
+        Pattern.compile(".*Warning: <.*> attribute \".*\" lacks value"),
+        Pattern.compile(".*Warning: <.*> attribute with missing trailing quote mark"),
+        Pattern.compile(".*Warning: <.*> dropping value \".*\" for repeated attribute \".*\""),
+        Pattern.compile(".*Warning: <.*> inserting \".*\" attribute"),
+        Pattern.compile(".*Warning: <.*> is probably intended as </.*>"),
+        Pattern.compile(".*Warning: <.*> isn't allowed in <.*> elements"),
+        Pattern.compile(".*Warning: <.*> lacks \".*\" attribute"),
+        Pattern.compile(".*Warning: <.*> missing '>' for end of tag"),
+        Pattern.compile(".*Warning: <.*> proprietary attribute \".*\""),
+        Pattern.compile(".*Warning: <.*> unexpected or duplicate quote mark"),
+        Pattern.compile(".*Warning: <a> cannot copy name attribute to id"),
+        Pattern.compile(".*Warning: <a> escaping malformed URI reference"),
+        Pattern.compile(".*Warning: <blockquote> proprietary attribute \"pre\""),
+        Pattern.compile(".*Warning: discarding unexpected <.*>"),
+        Pattern.compile(".*Warning: discarding unexpected </.*>"),
+        Pattern.compile(".*Warning: entity \".*\" doesn't end in ';'"),
+        Pattern.compile(".*Warning: inserting implicit <.*>"),
+        Pattern.compile(".*Warning: inserting missing 'title' element"),
+        Pattern.compile(".*Warning: missing <!DOCTYPE> declaration"),
+        Pattern.compile(".*Warning: missing <.*>"),
+        Pattern.compile(".*Warning: missing </.*> before <.*>"),
+        Pattern.compile(".*Warning: nested emphasis <.*>"),
+        Pattern.compile(".*Warning: plain text isn't allowed in <.*> elements"),
+        Pattern.compile(".*Warning: replacing <p> by <br>"),
+        Pattern.compile(".*Warning: replacing invalid numeric character reference .*"),
+        Pattern.compile(".*Warning: replacing unexpected .* by </.*>"),
+        Pattern.compile(".*Warning: trimming empty <.*>"),
+        Pattern.compile(".*Warning: unescaped & or unknown entity \".*\""),
+        Pattern.compile(".*Warning: unescaped & which should be written as &"),
+        Pattern.compile(".*Warning: using <br> in place of <p>")
+    };
+
+    int files;
+    int ok;
+    int warns;
+    int errs;
+    int css;
+    int overflow;
+}
+
diff --git a/test/tools/doclint/tidy/util/tidy.sh b/test/tools/doclint/tidy/util/tidy.sh
new file mode 100644
index 0000000..711d320
--- /dev/null
+++ b/test/tools/doclint/tidy/util/tidy.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# 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.
+#
+# 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.
+#
+
+# Run the "tidy" program over the files in a directory.
+#
+# Usage:
+#   sh tidy.sh <dir>
+#
+# The "tidy" program will be run on each HTML file in <dir>,
+# and the output placed in the corresponding location in a new
+# directory <dir>.tidy.  The console output from running "tidy" will
+# be saved in a corresponding file with an additional .tidy extension.
+#
+# Non-HTML files will be copied without modification from <dir> to
+# <dir>.tidy, so that relative links within the directory tree are
+# unaffected.
+
+dir=$1
+odir=$dir.tidy
+
+( cd $dir ; find . -type f ) | \
+    while read file ; do
+        mkdir -p $odir/$(dirname $file)
+        case $file in
+            *.html )
+                cat $dir/$file | tidy 1>$odir/$file 2>$odir/$file.tidy
+                ;;
+            * ) cp $dir/$file $odir/$file
+                ;;
+        esac
+    done
diff --git a/test/tools/doclint/tool/AAA.java b/test/tools/doclint/tool/AAA.java
new file mode 100644
index 0000000..3880733
--- /dev/null
+++ b/test/tools/doclint/tool/AAA.java
@@ -0,0 +1,35 @@
+/*
+ * 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 8006728
+ * @summary temporarily workaround jtreg problems for doclint tests in othervm
+ */
+
+// dummy test/class to be compiled before other tests in this directory
+// see JDK-8006730
+public class AAA {
+    public static void main(String... args) { }
+}
+
diff --git a/test/tools/doclint/tool/HelpTest.java b/test/tools/doclint/tool/HelpTest.java
new file mode 100644
index 0000000..936964a
--- /dev/null
+++ b/test/tools/doclint/tool/HelpTest.java
@@ -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 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref HelpTest.out
+ * @run main DocLintTester -ref HelpTest.out -h
+ * @run main DocLintTester -ref HelpTest.out -help
+ * @run main DocLintTester -ref HelpTest.out --help
+ * @run main DocLintTester -ref HelpTest.out -usage
+ * @run main DocLintTester -ref HelpTest.out -?
+ */
+
+
diff --git a/test/tools/doclint/tool/HelpTest.out b/test/tools/doclint/tool/HelpTest.out
new file mode 100644
index 0000000..0d7d402
--- /dev/null
+++ b/test/tools/doclint/tool/HelpTest.out
@@ -0,0 +1,43 @@
+Usage:
+    doclint [options] source-files...
+
+Options:
+  -Xmsgs  
+    Same as -Xmsgs:all
+  -Xmsgs:values
+    Specify categories of issues to be checked, where 'values'
+    is a comma-separated list of any of the following:
+      reference      show places where comments contain incorrect
+                     references to Java source code elements
+      syntax         show basic syntax errors within comments
+      html           show issues with HTML tags and attributes
+      accessibility  show issues for accessibility
+      missing        show issues with missing documentation
+      all            all of the above
+    Precede a value with '-' to negate it
+    Categories may be qualified by one of:
+      /public /protected /package /private
+    For positive categories (not beginning with '-')
+    the qualifier applies to that access level and above.
+    For negative categories (beginning with '-')
+    the qualifier applies to that access level and below.
+    If a qualifier is missing, the category applies to
+    all access levels.
+    For example, -Xmsgs:all,-syntax/private
+    This will enable all messages, except syntax errors
+    in the doc comments of private methods.
+    If no -Xmsgs options are provided, the default is
+    equivalent to -Xmsgs:all/protected, meaning that
+    all messages are reported for protected and public
+    declarations only. 
+  -stats
+    Report statistics on the reported issues.
+  -h -help --help -usage -?
+    Show this message.
+
+The following javac options are also supported
+  -bootclasspath, -classpath, -cp, -sourcepath, -Xmaxerrs, -Xmaxwarns
+
+To run doclint on part of a project, put the compiled classes for your
+project on the classpath (or bootclasspath), then specify the source files
+to be checked on the command line.
diff --git a/test/tools/doclint/tool/MaxDiagsTest.java b/test/tools/doclint/tool/MaxDiagsTest.java
new file mode 100644
index 0000000..0327ceb
--- /dev/null
+++ b/test/tools/doclint/tool/MaxDiagsTest.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref MaxDiagsTest.out -Xmaxerrs 2 -Xmaxwarns 2 MaxDiagsTest.java
+ * @run main DocLintTester -badargs -Xmaxerrs
+ * @run main DocLintTester -badargs -Xmaxwarns
+ * @run main DocLintTester -badargs -Xmaxerrs two -Xmaxwarns two MaxDiagsTest.java
+ */
+
+public class MaxDiagsTest {
+    /**
+     * � � � �
+     */
+    public void errors() { }
+
+    /** 4 undocumented signature items */
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+}
diff --git a/test/tools/doclint/tool/MaxDiagsTest.out b/test/tools/doclint/tool/MaxDiagsTest.out
new file mode 100644
index 0000000..ff5c9c8
--- /dev/null
+++ b/test/tools/doclint/tool/MaxDiagsTest.out
@@ -0,0 +1,14 @@
+MaxDiagsTest.java:13: warning: no comment
+public class MaxDiagsTest {
+       ^
+MaxDiagsTest.java:15: error: invalid entity �
+     * � � � �
+       ^
+MaxDiagsTest.java:15: error: invalid entity �
+     * � � � �
+            ^
+MaxDiagsTest.java:20: warning: no @param for a1
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+               ^
+2 errors
+2 warnings
diff --git a/test/tools/doclint/tool/PathsTest.java b/test/tools/doclint/tool/PathsTest.java
new file mode 100644
index 0000000..e4cb2e2
--- /dev/null
+++ b/test/tools/doclint/tool/PathsTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+public class PathsTest {
+    public static void main(String... args) throws Exception {
+        new PathsTest().run();
+    }
+
+    void run() throws Exception {
+        String PS = File.pathSeparator;
+        writeFile("src1/p/A.java",
+                "package p; public class A { }");
+        compile("-d", "classes1", "src1/p/A.java");
+
+        writeFile("src2/q/B.java",
+                "package q; public class B extends p.A { }");
+        compile("-d", "classes2", "-classpath", "classes1", "src2/q/B.java");
+
+        writeFile("src/Test.java",
+                "/** &0; */ class Test extends q.B { }");
+
+        test("src/Test.java", "-sourcepath", "src1" + PS + "src2");
+        test("src/Test.java", "-classpath", "classes1" + PS + "classes2");
+        String sysBootClassPath = System.getProperty("sun.boot.class.path");
+        test("src/Test.java", "-bootclasspath",
+                sysBootClassPath + PS + "classes1" + PS + "classes2");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    Pattern pkgNotFound = Pattern.compile("package [a-z]+ does not exist");
+    Pattern badHtmlEntity = Pattern.compile("bad HTML entity");
+
+    void test(String file, String pathOpt, String path) throws BadArgs, IOException {
+        System.err.println("test " + pathOpt);
+        String out1 = doclint("-Xmsgs", file);
+        if (!pkgNotFound.matcher(out1).find())
+            error("message not found: " + pkgNotFound);
+
+        String out2 = doclint("-Xmsgs", pathOpt, path, file);
+        if (pkgNotFound.matcher(out2).find())
+            error("unexpected message found: " + pkgNotFound);
+        if (!badHtmlEntity.matcher(out1).find())
+            error("message not found: " + badHtmlEntity);
+
+        try {
+            doclint("-Xmsgs", pathOpt);
+            error("expected exception not thrown");
+        } catch (BadArgs e) {
+            System.err.println(e);
+        }
+    }
+
+    void compile(String... args) {
+        for (int i = 0; i < args.length; i++) {
+            if (args[i].equals("-d")) {
+                new File(args[++i]).mkdirs();
+                break;
+            }
+        }
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            error("compilation failed: rc=" + rc);
+    }
+
+    String doclint(String... args) throws BadArgs, IOException {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocLint dl = new DocLint();
+        dl.run(pw, args);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        return out;
+    }
+
+    File writeFile(String path, String body) throws IOException {
+        File f = new File(path);
+        f.getParentFile().mkdirs();
+        try (FileWriter fw = new FileWriter(path)) {
+            fw.write(body);
+        }
+        return f;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/doclint/tool/RunTest.java b/test/tools/doclint/tool/RunTest.java
new file mode 100644
index 0000000..5f357f0
--- /dev/null
+++ b/test/tools/doclint/tool/RunTest.java
@@ -0,0 +1,200 @@
+/*
+ * 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 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+import com.sun.tools.javac.api.JavacTool;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.security.Permission;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+public class RunTest {
+    static class SimpleSecurityManager extends SecurityManager {
+        boolean allowExit = false;
+
+        @Override
+        public void checkExit(int status) {
+            if (!allowExit)
+                throw new SecurityException("System.exit(" + status + ")");
+        }
+        @Override
+        public void checkPermission(Permission perm) { }
+
+    }
+
+    public static void main(String... args) throws Exception {
+        // if no security manager already installed, install one to
+        // prevent System.exit
+        SimpleSecurityManager secmgr = null;
+        if (System.getSecurityManager() == null) {
+            System.setSecurityManager(secmgr = new SimpleSecurityManager() { });
+        }
+
+        try {
+            new RunTest().run();
+        } finally {
+            if (secmgr != null)
+                secmgr.allowExit = true;
+        }
+    }
+
+    void run() throws Exception {
+        testMain();
+        testRun();
+        testInit();
+        testArgsNoFiles();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void testMain() {
+        System.err.println("test main(String[])");
+        testMain(true, "-help");
+        testMain(false, "-unknownOption");
+    }
+
+    void testMain(boolean expectOK, String... args) {
+        try {
+            DocLint.main(args);
+            if (!expectOK)
+                error("expected SecurityException (from System.exit) not thrown");
+        } catch (SecurityException e) {
+            System.err.println(e);
+            if (expectOK)
+                error("unexpected SecurityException caught");
+        }
+    }
+
+    void testRun() throws BadArgs, IOException {
+        System.err.println("test run(String[])");
+        DocLint dl = new DocLint();
+        String[] args = { "-help" };
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(baos);
+        PrintStream prev = System.out;
+        try {
+            System.setOut(ps);
+            dl.run(args);
+        } finally {
+            System.setOut(prev);
+        }
+        ps.close();
+        String stdout = baos.toString();
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        dl.run(pw, args);
+        pw.close();
+        String direct = sw.toString();
+
+        if (!stdout.equals(direct)) {
+            error("unexpected output");
+            System.err.println("EXPECT>>" + direct + "<<");
+            System.err.println("FOUND>>" + stdout + "<<");
+        }
+    }
+
+    void testInit() {
+        System.err.println("test init");
+        DocLint dl = new DocLint();
+        String name = dl.getName();
+        if (!Objects.equals(name, "doclint"))
+            error("unexpected result for DocLint.getName()");
+
+        List<? extends JavaFileObject> files =
+                Arrays.asList(createFile("Test.java", "/** &0; */ class Test{ }"));
+        String[] goodArgs = { "-Xmsgs" };
+        testInit(true, goodArgs, files);
+
+        String[] badArgs = { "-unknown" };
+        testInit(false, badArgs, files);
+    }
+
+    void testInit(boolean expectOK, String[] args, List<? extends JavaFileObject> files) {
+        JavacTool javac = JavacTool.create();
+        JavacTask task = javac.getTask(null, null, null, null, null, files);
+        try {
+            DocLint dl = new DocLint();
+            dl.init(task, args, true);
+            if (!expectOK)
+                error("expected IllegalArgumentException not thrown");
+            task.call();
+        } catch (IllegalArgumentException e) {
+            System.err.println(e);
+            if (expectOK)
+                error("unexpected IllegalArgumentException caught");
+        }
+    }
+
+    void testArgsNoFiles() throws BadArgs, IOException {
+        System.err.println("test args, no files");
+        DocLint dl = new DocLint();
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        dl.run(pw, "-Xmsgs");
+        pw.close();
+        String out = sw.toString();
+
+        String expect = "No files given";
+        if (!Objects.equals(out.trim(), expect)) {
+            error("unexpected output");
+            System.err.println("EXPECT>>" + expect + "<<");
+            System.err.println("FOUND>>" + out + "<<");
+        }
+
+    }
+
+    JavaFileObject createFile(String name, final String body) {
+        return new SimpleJavaFileObject(URI.create(name), JavaFileObject.Kind.SOURCE) {
+            @Override
+            public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                return body;
+            }
+        };
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/doclint/tool/StatsTest.java b/test/tools/doclint/tool/StatsTest.java
new file mode 100644
index 0000000..fd7077c
--- /dev/null
+++ b/test/tools/doclint/tool/StatsTest.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref StatsTest.out -stats -Xmsgs:all StatsTest.java
+ */
+
+// warning: missing comment
+public class StatsTest {
+    /**
+     * � � � �
+     */
+    public void errors() { }
+
+    /** 4 undocumented signature items */
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+}
diff --git a/test/tools/doclint/tool/StatsTest.out b/test/tools/doclint/tool/StatsTest.out
new file mode 100644
index 0000000..01d8fd2
--- /dev/null
+++ b/test/tools/doclint/tool/StatsTest.out
@@ -0,0 +1,43 @@
+StatsTest.java:11: warning: no comment
+public class StatsTest {
+       ^
+StatsTest.java:13: error: invalid entity �
+     * � � � �
+       ^
+StatsTest.java:13: error: invalid entity �
+     * � � � �
+            ^
+StatsTest.java:13: error: invalid entity �
+     * � � � �
+                 ^
+StatsTest.java:13: error: invalid entity �
+     * � � � �
+                      ^
+StatsTest.java:18: warning: no @param for a1
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+               ^
+StatsTest.java:18: warning: no @param for a2
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+               ^
+StatsTest.java:18: warning: no @return
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+               ^
+StatsTest.java:18: warning: no @throws for java.lang.Exception
+    public int warnings(int a1, int a2) throws Exception { return 0; }
+               ^
+By group...
+     5: missing
+     4: html
+
+By diagnostic kind...
+     5: warning
+     4: error
+
+By message kind...
+     4: invalid entity &{0};
+     2: no @param for {0}
+     1: no @return
+     1: no @throws for {0}
+     1: no comment
+4 errors
+5 warnings
diff --git a/test/tools/javac/4846262/CheckEBCDICLocaleTest.java b/test/tools/javac/4846262/CheckEBCDICLocaleTest.java
new file mode 100644
index 0000000..6dd2179
--- /dev/null
+++ b/test/tools/javac/4846262/CheckEBCDICLocaleTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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 4846262
+ * @summary check that javac operates correctly in EBCDIC locale
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckEBCDICLocaleTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+public class CheckEBCDICLocaleTest {
+
+    private static final String TestSrc =
+        "public class Test {\n" +
+        "    public void test() {\n" +
+        "        abcdefg\n" +
+        "    }\n" +
+        "}";
+
+    private static final String TestOutTemplate =
+        "output%1$sTest.java:3: error: not a statement\n" +
+        "        abcdefg\n" +
+        "        ^\n" +
+        "output%1$sTest.java:3: error: ';' expected\n" +
+        "        abcdefg\n" +
+        "               ^\n" +
+        "2 errors\n";
+
+    public static void main(String[] args) throws Exception {
+        new CheckEBCDICLocaleTest().test();
+    }
+
+    public void test() throws Exception {
+        String native2asciiBinary = Paths.get(
+                System.getProperty("test.jdk"),"bin", "native2ascii").toString();
+
+        ToolBox.createJavaFileFromSource(TestSrc);
+        Files.createDirectory(Paths.get("output"));
+
+        ToolBox.AnyToolArgs nativeCmdParams =
+                new ToolBox.AnyToolArgs()
+                .appendArgs(native2asciiBinary)
+                .appendArgs(ToolBox.testToolVMOpts)
+                .appendArgs("-reverse", "-encoding", "IBM1047", "Test.java",
+                "output/Test.java");
+        ToolBox.executeCommand(nativeCmdParams);
+
+        ToolBox.AnyToolArgs javacParams =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(ToolBox.javacBinary)
+                .appendArgs(ToolBox.testToolVMOpts)
+                .appendArgs("-J-Duser.language=en",
+                "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",
+                "output/Test.java")
+                .setErrOutput(new File("Test.tmp"));
+        ToolBox.executeCommand(javacParams);
+
+        nativeCmdParams = new ToolBox.AnyToolArgs()
+                .appendArgs(native2asciiBinary)
+                .appendArgs(ToolBox.testToolVMOpts)
+                .appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out");
+        ToolBox.executeCommand(nativeCmdParams);
+
+        String goldenFile = String.format(TestOutTemplate, File.separator);
+        ToolBox.compareLines(Paths.get("Test.out"),
+                Arrays.asList(goldenFile.split("\n")), null, true);
+    }
+
+}
diff --git a/test/tools/javac/4846262/Test.java b/test/tools/javac/4846262/Test.java
deleted file mode 100644
index 510e3d8..0000000
--- a/test/tools/javac/4846262/Test.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/* /nodynamiccopyright/ */
-public class Test {
-    public void test() {
-        abcdefg
-    }
-}
diff --git a/test/tools/javac/4846262/Test.out b/test/tools/javac/4846262/Test.out
deleted file mode 100644
index 175101f..0000000
--- a/test/tools/javac/4846262/Test.out
+++ /dev/null
@@ -1,7 +0,0 @@
-Test.java:4: error: not a statement
-        abcdefg
-        ^
-Test.java:4: error: ';' expected
-        abcdefg
-               ^
-2 errors
diff --git a/test/tools/javac/4846262/Test.sh b/test/tools/javac/4846262/Test.sh
deleted file mode 100644
index 5d3d3f2..0000000
--- a/test/tools/javac/4846262/Test.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh -f
-
-#
-# Copyright (c) 2005, 2009, 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 4846262
-# @summary check that javac operates correctly in EBCDIC locale
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-rm -f Test.java Test.out
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
-
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
-result=$?
-
-if [ $result -eq o ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/5045412/Bar.java b/test/tools/javac/5045412/Bar.java
index 9225d54..867a313 100644
--- a/test/tools/javac/5045412/Bar.java
+++ b/test/tools/javac/5045412/Bar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, 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
@@ -24,12 +24,6 @@
 /**
  * @test
  * @bug 5045412 6627366
- * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java
- */
-
-/**
- * @test
- * @bug 5045412 6627366
  * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Bar.java Foo.java
  */
 
diff --git a/test/tools/javac/5045412/Foo.java b/test/tools/javac/5045412/Foo.java
index a797566..dbbc618 100644
--- a/test/tools/javac/5045412/Foo.java
+++ b/test/tools/javac/5045412/Foo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, 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
@@ -25,11 +25,6 @@
  * @test
  * @bug 5045412 6627366
  * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java
- */
-
-/**
- * @test
- * @bug 5045412 6627366
  * @compile -Xlint:serial -XDfailcomplete=java.io.Serializable Foo.java Bar.java
  */
 
diff --git a/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java b/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java
new file mode 100644
index 0000000..0bfffaa
--- /dev/null
+++ b/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java
@@ -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 6302184 6350124 6357979
+ * @summary javac hidden options that generate source should use the given
+ * encoding, if available
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -encoding iso-8859-1 -XD-printsource T6302184.java
+ * @run main HiddenOptionsShouldUseGivenEncodingTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/6302184/T6302184.sh
+public class HiddenOptionsShouldUseGivenEncodingTest {
+
+    public static void main(String[] args) throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
+//diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
+        Path path1 = Paths.get(System.getProperty("test.classes"), "T6302184.java");
+        Path path2 = Paths.get(System.getProperty("test.src"), "T6302184.out");
+        ToolBox.compareLines(path1, path2, "iso-8859-1");
+    }
+
+}
diff --git a/test/tools/javac/6302184/T6302184.sh b/test/tools/javac/6302184/T6302184.sh
deleted file mode 100644
index 5a1c333..0000000
--- a/test/tools/javac/6302184/T6302184.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2009, 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 6302184 6350124 6357979
-# @summary javac hidden options that generate source should use the given encoding, if available
-# @run shell T6302184.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
-diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
-result=$?
-
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/6304921/TestLog.java b/test/tools/javac/6304921/TestLog.java
index 32217a4..0d9a845 100644
--- a/test/tools/javac/6304921/TestLog.java
+++ b/test/tools/javac/6304921/TestLog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@ import javax.tools.SimpleJavaFileObject;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.parser.Parser;
 import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Context;
@@ -97,9 +98,9 @@ public class TestLog
     }
 
     private static class LogTester extends TreeScanner {
-        LogTester(Log log, java.util.Map<JCTree, Integer> endPositions) {
+        LogTester(Log log, EndPosTable endPosTable) {
             this.log = log;
-            this.endPositions = endPositions;
+            this.endPosTable = endPosTable;
         }
 
         public void visitIf(JCTree.JCIf tree) {
@@ -117,7 +118,7 @@ public class TestLog
         }
 
         private Log log;
-        private java.util.Map<JCTree, Integer> endPositions;
+        private EndPosTable endPosTable;
     }
 
     private static class StringJavaFileObject extends SimpleJavaFileObject {
diff --git a/test/tools/javac/6330997/T6330997.java b/test/tools/javac/6330997/T6330997.java
index 8b13351..f321525 100644
--- a/test/tools/javac/6330997/T6330997.java
+++ b/test/tools/javac/6330997/T6330997.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,12 +23,12 @@
 
 /**
  * @test
- * @bug     6330997
+ * @bug     6330997 7025789
  * @summary javac should accept class files with major version of the next release
  * @author  Wei Tao
  * @clean T1 T2
- * @compile -target 7 T1.java
- * @compile -target 7 T2.java
+ * @compile -target 8 T1.java
+ * @compile -target 8 T2.java
  * @run main/othervm T6330997
  */
 
diff --git a/test/tools/javac/6360970/T6360970.java b/test/tools/javac/6360970/T6360970.java
new file mode 100644
index 0000000..58936f4
--- /dev/null
+++ b/test/tools/javac/6360970/T6360970.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6360970
+ * @summary javac erroneously accept ambiguous field reference
+ * @compile/fail/ref=T6360970.out -XDrawDiagnostics T6360970.java
+ */
+class T6360970 {
+    interface A {
+        int i = 1;
+    }
+
+    interface B {
+        int i = 2;
+    }
+
+    interface C extends A, B { }
+
+    static class D {
+        public static final int i = 0;
+    }
+
+    static class E extends D implements C { }
+
+    int i = E.i; //ambiguous
+}
diff --git a/test/tools/javac/6360970/T6360970.out b/test/tools/javac/6360970/T6360970.out
new file mode 100644
index 0000000..fa81e93
--- /dev/null
+++ b/test/tools/javac/6360970/T6360970.out
@@ -0,0 +1,2 @@
+T6360970.java:24:14: compiler.err.ref.ambiguous: i, kindname.variable, i, T6360970.D, kindname.variable, i, T6360970.A
+1 error
diff --git a/test/tools/javac/6402516/CheckLocalElements.java b/test/tools/javac/6402516/CheckLocalElements.java
index 0b80876..1693873 100644
--- a/test/tools/javac/6402516/CheckLocalElements.java
+++ b/test/tools/javac/6402516/CheckLocalElements.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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
@@ -95,7 +95,7 @@ public class CheckLocalElements extends Checker {
         return encl == null ? "" : encl.accept(qualNameVisitor, null);
     }
 
-    private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor7<String,Void>() {
+    private ElementVisitor<String,Void> qualNameVisitor = new SimpleElementVisitor8<String,Void>() {
         protected String defaultAction(Element e, Void ignore) {
             return "";
         }
diff --git a/test/tools/javac/6402516/TestLocalElements.java b/test/tools/javac/6402516/TestLocalElements.java
index c9faa64..7e2d64f 100644
--- a/test/tools/javac/6402516/TestLocalElements.java
+++ b/test/tools/javac/6402516/TestLocalElements.java
@@ -43,9 +43,9 @@ class Test {
 
     boolean b = new Object() {
             public boolean equals(Object other) {
-                String p = "p, other, super, this; super, this; List, Test2, Test; java.io.*, java.lang.*";
-                String q = "q, p, other, super, this; super, this; List, Test2, Test; java.io.*, java.lang.*";
-                String r = "r, q, p, other, super, this; super, this; List, Test2, Test; java.io.*, java.lang.*";
+                String p = "p, other, super, this; -, super, this; List, Test2, Test; java.io.*, java.lang.*";
+                String q = "q, p, other, super, this; -, super, this; List, Test2, Test; java.io.*, java.lang.*";
+                String r = "r, q, p, other, super, this; -, super, this; List, Test2, Test; java.io.*, java.lang.*";
                 return (this == other);
             }
 
diff --git a/test/tools/javac/6410653/T6410653.java b/test/tools/javac/6410653/T6410653.java
index b1acfad..29d63ed 100644
--- a/test/tools/javac/6410653/T6410653.java
+++ b/test/tools/javac/6410653/T6410653.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,7 @@
  * @author  Peter von der Ah\u00e9
  */
 
-import java.lang.reflect.Method;
+import java.lang.reflect.Field;
 import java.io.File;
 import java.io.ByteArrayOutputStream;
 import javax.tools.*;
@@ -39,12 +39,13 @@ public class T6410653 {
         String source = new File(testSrc, "T6410653.java").getPath();
         ClassLoader cl = ToolProvider.getSystemToolClassLoader();
         Tool compiler = ToolProvider.getSystemJavaCompiler();
-        Class<?> main = Class.forName("com.sun.tools.javac.main.Main", true, cl);
-        Method useRawMessages = main.getMethod("useRawMessages", boolean.class);
-        useRawMessages.invoke(null, true);
+        Class<?> log = Class.forName("com.sun.tools.javac.util.Log", true, cl);
+        Field useRawMessages = log.getDeclaredField("useRawMessages");
+        useRawMessages.setAccessible(true);
+        useRawMessages.setBoolean(null, true);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         compiler.run(null, null, out, "-d", source, source);
-        useRawMessages.invoke(null, false);
+        useRawMessages.setBoolean(null, false);
         if (!out.toString().equals(String.format("%s%n%s%n",
                                                  "javac: javac.err.file.not.directory",
                                                  "javac.msg.usage"))) {
diff --git a/test/tools/javac/6563143/EqualsHashCodeWarningTest.java b/test/tools/javac/6563143/EqualsHashCodeWarningTest.java
new file mode 100644
index 0000000..2c30c46
--- /dev/null
+++ b/test/tools/javac/6563143/EqualsHashCodeWarningTest.java
@@ -0,0 +1,71 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6563143 8008436 8009138
+ * @summary javac should issue a warning for overriding equals without hashCode
+ * @summary javac should not issue a warning for overriding equals without hasCode
+ * @summary javac, equals-hashCode warning tuning
+ * if hashCode has been overriden by a superclass
+ * @compile/ref=EqualsHashCodeWarningTest.out -Xlint:overrides -XDrawDiagnostics EqualsHashCodeWarningTest.java
+ */
+
+import java.util.Comparator;
+
+public class EqualsHashCodeWarningTest {
+    @Override
+    public boolean equals(Object o) {
+        return o == this;
+    }
+
+    @Override
+    public int hashCode() {
+        return 0;
+    }
+
+    public Comparator m() {
+        return new Comparator() {
+            @Override
+            public boolean equals(Object o) {return true;}
+
+            @Override
+            public int compare(Object o1, Object o2) {
+                return 0;
+            }
+        };
+    }
+}
+
+class SubClass extends EqualsHashCodeWarningTest {
+    @Override
+    public boolean equals(Object o) {
+        return true;
+    }
+}
+
+ at SuppressWarnings("overrides")
+class DontWarnMe {
+    @Override
+    public boolean equals(Object o) {
+        return true;
+    }
+}
+
+class DoWarnMe {
+    @Override
+    public boolean equals(Object o) {
+        return o == this;
+    }
+}
+
+abstract class IamAbstractGetMeOutOfHere {
+    public boolean equals(Object o){return true;}
+}
+
+interface I {
+    public boolean equals(Object o);
+}
+
+enum E {
+    A, B
+}
+
+ at interface anno {}
diff --git a/test/tools/javac/6563143/EqualsHashCodeWarningTest.out b/test/tools/javac/6563143/EqualsHashCodeWarningTest.out
new file mode 100644
index 0000000..51f21b0
--- /dev/null
+++ b/test/tools/javac/6563143/EqualsHashCodeWarningTest.out
@@ -0,0 +1,2 @@
+EqualsHashCodeWarningTest.java:52:1: compiler.warn.override.equals.but.not.hashcode: DoWarnMe
+1 warning
diff --git a/test/tools/javac/6567415/T6567415.java b/test/tools/javac/6567415/T6567415.java
index 683197e..18a9255 100644
--- a/test/tools/javac/6567415/T6567415.java
+++ b/test/tools/javac/6567415/T6567415.java
@@ -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
@@ -137,7 +137,7 @@ public class T6567415 {
             }
         };
         t.start();
-        t.join(1000*10);
+        t.join(1000*60);
         System.out.println(t.getState());
         if (t.isAlive()) {
             throw new RuntimeException("Error: compilation is looping");
diff --git a/test/tools/javac/6758789/T6758789a.out b/test/tools/javac/6758789/T6758789a.out
index 4d82fbc..7a733c0 100644
--- a/test/tools/javac/6758789/T6758789a.out
+++ b/test/tools/javac/6758789/T6758789a.out
@@ -1,3 +1,3 @@
-T6758789a.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
-T6758789a.java:15:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
+T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
+T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, (compiler.misc.arg.length.mismatch)
 2 errors
diff --git a/test/tools/javac/6758789/T6758789b.out b/test/tools/javac/6758789/T6758789b.out
index 45a828d..5bdb51c 100644
--- a/test/tools/javac/6758789/T6758789b.out
+++ b/test/tools/javac/6758789/T6758789b.out
@@ -1,5 +1,5 @@
-T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
 T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
+T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object>
 - compiler.err.warnings.and.werror
 1 error
 2 warnings
diff --git a/test/tools/javac/6840059/T6840059.out b/test/tools/javac/6840059/T6840059.out
index c8f0186..af2afb2 100644
--- a/test/tools/javac/6840059/T6840059.out
+++ b/test/tools/javac/6840059/T6840059.out
@@ -1,3 +1,2 @@
-T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer)
-T6840059.java:15:25: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, (compiler.misc.arg.length.mismatch)
-2 errors
+T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
diff --git a/test/tools/javac/6857948/T6857948.out b/test/tools/javac/6857948/T6857948.out
index 5994663..467e086 100644
--- a/test/tools/javac/6857948/T6857948.out
+++ b/test/tools/javac/6857948/T6857948.out
@@ -1,3 +1,2 @@
 T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , (compiler.misc.location: kindname.class, Test, null)
-T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch)
-2 errors
+1 error
diff --git a/test/tools/javac/6889255/T6889255.java b/test/tools/javac/6889255/T6889255.java
index 5d77d8c..f0b9314 100644
--- a/test/tools/javac/6889255/T6889255.java
+++ b/test/tools/javac/6889255/T6889255.java
@@ -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
@@ -36,7 +36,7 @@ import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.code.TypeTags;
+import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.util.Context;
@@ -429,14 +429,14 @@ public class T6889255 {
         // -- no Code attribute for the LocalVariableTable attribute
         if ((v.owner.flags() & Flags.ABSTRACT) != 0)
             return "arg" + (i - 1);
-        // bridge methods use xN
+        // bridge methods use argN. No LVT for them anymore
         if ((v.owner.flags() & Flags.BRIDGE) != 0)
-            return "x" + (i - 1);
+            return "arg" + (i - 1);
 
         // The rest of this method assumes the local conventions in the test program
         Type t = v.type;
         String s;
-        if (t.tag == TypeTags.CLASS)
+        if (t.hasTag(TypeTag.CLASS))
             s = ((ClassType) t).tsym.name.toString();
         else
             s = t.toString();
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog
index d43be7b..c463cae 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD34.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, boolean
+TestCast6979683_BAD34.java:34:49: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Number, boolean)
 1 error
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog
index 270f5b7..17c497f 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD35.java:35:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, int
+TestCast6979683_BAD35.java:35:45: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Number, int)
 1 error
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog
index f4338d8..05f7cb4 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD36.java:36:58: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable<java.lang.Integer>, int
+TestCast6979683_BAD36.java:36:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Comparable<java.lang.Integer>, int)
 1 error
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog
index 89b7a57..a490164 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD37.java:37:61: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Comparable<java.lang.Short>, int
+TestCast6979683_BAD37.java:37:61: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Comparable<java.lang.Short>, int)
 1 error
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog
index 47d617a..90ebb73 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD38.java:38:62: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable<java.lang.Character>, float
+TestCast6979683_BAD38.java:38:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Comparable<java.lang.Character>, float)
 1 error
diff --git a/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog b/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog
index 9f41dfa..716d1e9 100644
--- a/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog
+++ b/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog
@@ -1,2 +1,2 @@
-TestCast6979683_BAD39.java:39:53: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Number, char
+TestCast6979683_BAD39.java:39:53: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Number, char)
 1 error
diff --git a/test/tools/javac/7079713/TestCircularClassfile.java b/test/tools/javac/7079713/TestCircularClassfile.java
new file mode 100644
index 0000000..bfa62b4
--- /dev/null
+++ b/test/tools/javac/7079713/TestCircularClassfile.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2011, 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 7079713
+ * @summary javac hangs when compiling a class that references a cyclically inherited class
+ * @run main TestCircularClassfile
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+
+public class TestCircularClassfile {
+
+    enum SourceKind {
+        A_EXTENDS_B("class B {} class A extends B { void m() {} }"),
+        B_EXTENDS_A("class A { void m() {} } class B extends A {}");
+
+        String sourceStr;
+
+        private SourceKind(String sourceStr) {
+            this.sourceStr = sourceStr;
+        }
+
+        SimpleJavaFileObject getSource() {
+            return new SimpleJavaFileObject(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return sourceStr;
+                }
+            };
+        }
+    }
+
+    enum TestKind {
+        REPLACE_A("A.class"),
+        REPLACE_B("B.class");
+
+        String targetClass;
+
+        private TestKind(String targetClass) {
+            this.targetClass = targetClass;
+        }
+    }
+
+    enum ClientKind {
+        METHOD_CALL1("A a = null; a.m();"),
+        METHOD_CALL2("B b = null; b.m();"),
+        CONSTR_CALL1("new A();"),
+        CONSTR_CALL2("new B();"),
+        ASSIGN1("A a = null; B b = a;"),
+        ASSIGN2("B b = null; A a = b;");
+
+        String mainMethod;
+
+        private ClientKind(String mainMethod) {
+            this.mainMethod = mainMethod;
+        }
+
+        SimpleJavaFileObject getSource() {
+            return new SimpleJavaFileObject(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return "class Test { public static void main(String[] args) { #M } }"
+                            .replace("#M", mainMethod);
+                }
+            };
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+        int count = 0;
+        for (SourceKind sk1 : SourceKind.values()) {
+            for (SourceKind sk2 : SourceKind.values()) {
+                for (TestKind tk : TestKind.values()) {
+                    for (ClientKind ck : ClientKind.values()) {
+                        new TestCircularClassfile("sub_"+count++, sk1, sk2, tk, ck).check(comp, fm);
+                    }
+                }
+            }
+        }
+    }
+
+    static String workDir = System.getProperty("user.dir");
+
+    String destPath;
+    SourceKind sk1;
+    SourceKind sk2;
+    TestKind tk;
+    ClientKind ck;
+
+    TestCircularClassfile(String destPath, SourceKind sk1, SourceKind sk2, TestKind tk, ClientKind ck) {
+        this.destPath = destPath;
+        this.sk1 = sk1;
+        this.sk2 = sk2;
+        this.tk = tk;
+        this.ck = ck;
+    }
+
+    void check(JavaCompiler comp, StandardJavaFileManager fm) throws Exception {
+        //step 1: compile first source code in the test subfolder
+        File destDir = new File(workDir, destPath); destDir.mkdir();
+        //output dir must be set explicitly as we are sharing the fm (see bug 7026941)
+        fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, null,
+                null, null, Arrays.asList(sk1.getSource()));
+        ct.generate();
+
+        //step 2: compile second source code in a temp folder
+        File tmpDir = new File(destDir, "tmp"); tmpDir.mkdir();
+        //output dir must be set explicitly as we are sharing the fm (see bug 7026941)
+        fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));
+        ct = (JavacTask)comp.getTask(null, fm, null,
+                null, null, Arrays.asList(sk2.getSource()));
+        ct.generate();
+
+        //step 3: move a classfile from the temp folder to the test subfolder
+        File fileToMove = new File(tmpDir, tk.targetClass);
+        File target = new File(destDir, tk.targetClass);
+        target.delete();
+        boolean success = fileToMove.renameTo(target);
+
+        if (!success) {
+            throw new AssertionError("error when moving file " + tk.targetClass);
+        }
+
+        //step 4: compile the client class against the classes in the test subfolder
+        //input/output dir must be set explicitly as we are sharing the fm (see bug 7026941)
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+        fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(destDir));
+        ct = (JavacTask)comp.getTask(null, fm, null,
+                null, null, Arrays.asList(ck.getSource()));
+
+        ct.generate();
+    }
+}
diff --git a/test/tools/javac/7129225/TestImportStar.java b/test/tools/javac/7129225/TestImportStar.java
index 0c2c913..eaca9ed 100644
--- a/test/tools/javac/7129225/TestImportStar.java
+++ b/test/tools/javac/7129225/TestImportStar.java
@@ -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
@@ -26,11 +26,11 @@
 /* @test
  * @bug 7129225
  * @summary import xxx.* isn't handled correctly by annotation processing
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java
  * @compile Anno.java AnnoProcessor.java
- * @compile/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
+ * @compile/fail/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
  */
 
  //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.*
diff --git a/test/tools/javac/7129225/TestImportStar.ref b/test/tools/javac/7129225/TestImportStar.ref
index 6248fad..5b3c75d 100644
--- a/test/tools/javac/7129225/TestImportStar.ref
+++ b/test/tools/javac/7129225/TestImportStar.ref
@@ -1,3 +1,4 @@
 - compiler.note.proc.messager: RUNNING - lastRound = false
 TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx
 - compiler.note.proc.messager: RUNNING - lastRound = true
+1 error
\ No newline at end of file
diff --git a/test/tools/javac/7132880/T7132880.java b/test/tools/javac/7132880/T7132880.java
new file mode 100644
index 0000000..b41f140
--- /dev/null
+++ b/test/tools/javac/7132880/T7132880.java
@@ -0,0 +1,60 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7132880
+ * @summary Resolve should support nested resolution contexts
+ * @compile/fail/ref=T7132880.out -XDrawDiagnostics T7132880.java
+ */
+class Outer {
+    void m1(String s) { }
+    void m2(int i1, int i2) { }
+
+    class Inner {
+        void test() {
+           //ok - no method named 'm' in Inner - hence, class to search is Outer
+           m1("");
+        }
+    }
+
+    class Inner1 {
+        void m1(Integer i) { }
+
+        void test() {
+           //error - Inner1 defines an incompatible method - hence, class to search is Inner1
+           m1("");
+        }
+    }
+
+    class Inner2 {
+        private void m1(Integer i) { }
+        private void m1(Double d) { }
+
+        void test() {
+           //error - Inner2 defines multiple incompatible methods - hence, class to search is Inner2
+           m1("");
+        }
+    }
+
+    class Inner3 {
+        private void m2(Object o, int i) { }
+        private void m2(int i, Object o) { }
+
+        void test() {
+           //error - Inner3 defines multiple ambiguous methods - hence, class to search is Inner3
+           m2(1, 1);
+        }
+    }
+
+    class Inner4 extends Inner2 {
+        void test() {
+           //ok - Inner2 defines multiple incompatible inaccessible methods - hence, class to search is Outer
+           m1("");
+        }
+    }
+
+    class Inner5 extends Inner3 {
+        void test() {
+           //ok - Inner3 defines multiple inaccessible ambiguous methods - hence, class to search is Outer
+           m2(1, 1);
+        }
+    }
+}
diff --git a/test/tools/javac/7132880/T7132880.out b/test/tools/javac/7132880/T7132880.out
new file mode 100644
index 0000000..e88309d
--- /dev/null
+++ b/test/tools/javac/7132880/T7132880.out
@@ -0,0 +1,4 @@
+T7132880.java:23:12: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Integer, java.lang.String, kindname.class, Outer.Inner1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+T7132880.java:33:12: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Integer), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.method, Outer.Inner2, m1(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Str [...]
+T7132880.java:43:12: compiler.err.ref.ambiguous: m2, kindname.method, m2(java.lang.Object,int), Outer.Inner3, kindname.method, m2(int,java.lang.Object), Outer.Inner3
+3 errors
diff --git a/test/tools/javac/7144981/IgnoreIgnorableCharactersInInput.java b/test/tools/javac/7144981/IgnoreIgnorableCharactersInInput.java
new file mode 100644
index 0000000..95bce2a
--- /dev/null
+++ b/test/tools/javac/7144981/IgnoreIgnorableCharactersInInput.java
@@ -0,0 +1,92 @@
+
+/*
+ * @test  /nodynamiccopyright/
+ * @bug 7144981
+ * @summary javac should ignore ignorable characters in input
+ * @run main IgnoreIgnorableCharactersInInput
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class IgnoreIgnorableCharactersInInput {
+
+    public static void main(String... args) throws Exception {
+        new IgnoreIgnorableCharactersInInput().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        File classesDir = new File(System.getProperty("user.dir"), "classes");
+        classesDir.mkdirs();
+        JavaSource[] sources = new JavaSource[]{
+            new JavaSource("TestOneIgnorableChar", "AA\\u0000BB"),
+            new JavaSource("TestMultipleIgnorableChar", "AA\\u0000\\u0000\\u0000BB")};
+        JavacTask ct = (JavacTask)comp.getTask(null, null, null,
+                Arrays.asList("-d", classesDir.getPath()),
+                null, Arrays.asList(sources));
+        try {
+            if (!ct.call()) {
+                throw new AssertionError("Error thrown when compiling test cases");
+            }
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when compiling test cases");
+        }
+        check(classesDir,
+                "TestOneIgnorableChar.class",
+                "TestOneIgnorableChar$AABB.class",
+                "TestMultipleIgnorableChar.class",
+                "TestMultipleIgnorableChar$AABB.class");
+        if (errors > 0)
+            throw new AssertionError("There are some errors in the test check the error output");
+    }
+
+    /**
+     *  Check that a directory contains the expected files.
+     */
+    void check(File dir, String... paths) {
+        Set<String> found = new TreeSet<String>(Arrays.asList(dir.list()));
+        Set<String> expect = new TreeSet<String>(Arrays.asList(paths));
+        if (found.equals(expect))
+            return;
+        for (String f: found) {
+            if (!expect.contains(f))
+                error("Unexpected file found: " + f);
+        }
+        for (String e: expect) {
+            if (!found.contains(e))
+                error("Expected file not found: " + e);
+        }
+    }
+
+    int errors;
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String internalSource =
+            "public class #O {public class #I {} }";
+        public JavaSource(String outerClassName, String innerClassName) {
+            super(URI.create(outerClassName + ".java"), JavaFileObject.Kind.SOURCE);
+            internalSource =
+                    internalSource.replace("#O", outerClassName).replace("#I", innerClassName);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return internalSource;
+        }
+    }
+}
diff --git a/test/tools/javac/7153958/CPoolRefClassContainingInlinedCts.java b/test/tools/javac/7153958/CPoolRefClassContainingInlinedCts.java
new file mode 100644
index 0000000..2e26cf6
--- /dev/null
+++ b/test/tools/javac/7153958/CPoolRefClassContainingInlinedCts.java
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7153958
+ * @summary add constant pool reference to class containing inlined constants
+ * @compile pkg/ClassToBeStaticallyImported.java CPoolRefClassContainingInlinedCts.java
+ * @run main CPoolRefClassContainingInlinedCts
+ */
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info;
+import com.sun.tools.classfile.ConstantPool.CPInfo;
+import com.sun.tools.classfile.ConstantPoolException;
+import java.io.File;
+import java.io.IOException;
+
+import static pkg.ClassToBeStaticallyImported.staticField;
+
+public class CPoolRefClassContainingInlinedCts {
+
+    public static void main(String args[]) throws Exception {
+        new CPoolRefClassContainingInlinedCts().run();
+    }
+
+    void run() throws Exception {
+        checkReferences();
+    }
+
+    int numberOfReferencedClassesToBeChecked = 0;
+
+    void checkClassName(String className) {
+        switch (className) {
+            case "SimpleAssignClass" : case "BinaryExpClass":
+            case "UnaryExpClass" : case "CastClass":
+            case "ParensClass" : case "CondClass":
+            case "IfClass" : case "pkg/ClassToBeStaticallyImported":
+                numberOfReferencedClassesToBeChecked++;
+        }
+    }
+
+    void checkReferences() throws IOException, ConstantPoolException {
+        File testClasses = new File(System.getProperty("test.classes"));
+        File file = new File(testClasses,
+                CPoolRefClassContainingInlinedCts.class.getName() + ".class");
+        ClassFile classFile = ClassFile.read(file);
+        int i = 1;
+        CPInfo cpInfo;
+        while (i < classFile.constant_pool.size()) {
+            cpInfo = classFile.constant_pool.get(i);
+            if (cpInfo instanceof CONSTANT_Class_info) {
+                checkClassName(((CONSTANT_Class_info)cpInfo).getName());
+            }
+            i += cpInfo.size();
+        }
+        if (numberOfReferencedClassesToBeChecked != 8) {
+            throw new AssertionError("Class reference missing in the constant pool");
+        }
+    }
+
+    private int assign = SimpleAssignClass.x;
+    private int binary = BinaryExpClass.x + 1;
+    private int unary = -UnaryExpClass.x;
+    private int cast = (int)CastClass.x;
+    private int parens = (ParensClass.x);
+    private int cond = (CondClass.x == 1) ? 1 : 2;
+    private static int ifConstant;
+    private static int importStatic;
+    static {
+        if (IfClass.x == 1) {
+            ifConstant = 1;
+        } else {
+            ifConstant = 2;
+        }
+    }
+    static {
+        if (staticField == 1) {
+            importStatic = 1;
+        } else {
+            importStatic = 2;
+        }
+    }
+}
+
+class SimpleAssignClass {
+    public static final int x = 1;
+}
+
+class BinaryExpClass {
+    public static final int x = 1;
+}
+
+class UnaryExpClass {
+    public static final int x = 1;
+}
+
+class CastClass {
+    public static final int x = 1;
+}
+
+class ParensClass {
+    public static final int x = 1;
+}
+
+class CondClass {
+    public static final int x = 1;
+}
+
+class IfClass {
+    public static final int x = 1;
+}
diff --git a/test/tools/javac/7153958/pkg/ClassToBeStaticallyImported.java b/test/tools/javac/7153958/pkg/ClassToBeStaticallyImported.java
new file mode 100644
index 0000000..801098d
--- /dev/null
+++ b/test/tools/javac/7153958/pkg/ClassToBeStaticallyImported.java
@@ -0,0 +1,29 @@
+/*
+ * 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 pkg;
+
+public class ClassToBeStaticallyImported {
+    public static final int staticField = 1;
+}
diff --git a/test/tools/javac/7166455/CheckACC_STRICTFlagOnclinitTest.java b/test/tools/javac/7166455/CheckACC_STRICTFlagOnclinitTest.java
new file mode 100644
index 0000000..0651132
--- /dev/null
+++ b/test/tools/javac/7166455/CheckACC_STRICTFlagOnclinitTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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 7166455
+ * @summary javac doesn't set ACC_STRICT bit on <clinit> for strictfp class
+ * @run main CheckACC_STRICTFlagOnclinitTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+import static com.sun.tools.classfile.AccessFlags.ACC_STRICT;
+
+public strictfp class CheckACC_STRICTFlagOnclinitTest {
+    private static final String AssertionErrorMessage =
+        "All methods should have the ACC_STRICT access flag " +
+        "please check output";
+    private static final String offendingMethodErrorMessage =
+        "Method %s of class %s doesn't have the ACC_STRICT access flag";
+
+    static {
+        class Foo {
+            class Bar {
+                void m11() {}
+            }
+            void m1() {}
+        }
+    }
+    void m2() {
+        class Any {
+            void m21() {}
+        }
+    }
+
+    private List<String> errors = new ArrayList<>();
+
+    public static void main(String[] args)
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        new CheckACC_STRICTFlagOnclinitTest().run();
+    }
+
+    private void run()
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        String testClasses = System.getProperty("test.classes");
+        check(testClasses,
+              "CheckACC_STRICTFlagOnclinitTest.class",
+              "CheckACC_STRICTFlagOnclinitTest$1Foo.class",
+              "CheckACC_STRICTFlagOnclinitTest$1Foo$Bar.class",
+              "CheckACC_STRICTFlagOnclinitTest$1Any.class");
+        if (errors.size() > 0) {
+            for (String error: errors) {
+                System.err.println(error);
+            }
+            throw new AssertionError(AssertionErrorMessage);
+        }
+    }
+
+    void check(String dir, String... fileNames)
+        throws
+            IOException,
+            ConstantPoolException,
+            Descriptor.InvalidDescriptor {
+        for (String fileName : fileNames) {
+            ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));
+
+            for (Method method : classFileToCheck.methods) {
+                if ((method.access_flags.flags & ACC_STRICT) == 0) {
+                    errors.add(String.format(offendingMethodErrorMessage,
+                            method.getName(classFileToCheck.constant_pool),
+                            classFileToCheck.getName()));
+                }
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/7167125/DiffResultAfterSameOperationInnerClasses.java b/test/tools/javac/7167125/DiffResultAfterSameOperationInnerClasses.java
new file mode 100644
index 0000000..abe101a
--- /dev/null
+++ b/test/tools/javac/7167125/DiffResultAfterSameOperationInnerClasses.java
@@ -0,0 +1,94 @@
+/*
+ * 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 7167125
+ * @summary Two variables after the same operation in a inner class return
+ * different results
+ * @run main DiffResultAfterSameOperationInnerClasses
+ */
+
+public class DiffResultAfterSameOperationInnerClasses {
+    public int i = 1;
+    private int j = 1;
+    public String s1 = "Hi, ";
+    private String s2 = "Hi, ";
+    public int arr1[] = new int[]{1};
+    public int arr2[] = new int[]{1};
+
+    public static void main(String[] args) {
+        DiffResultAfterSameOperationInnerClasses theTest =
+                new DiffResultAfterSameOperationInnerClasses();
+        InnerClass inner = theTest.new InnerClass();
+        if (!inner.test1()) {
+            throw new AssertionError("Different results after same calculation");
+        }
+
+        theTest.resetVars();
+        if (!inner.test2()) {
+            throw new AssertionError("Different results after same calculation");
+        }
+    }
+
+    void resetVars() {
+        i = 1;
+        j = 1;
+        s1 = "Hi, ";
+        s2 = "Hi, ";
+        arr1[0] = 1;
+        arr2[0] = 1;
+    }
+
+    class InnerClass {
+        public boolean test1() {
+            i += i += 1;
+            j += j += 1;
+
+            arr1[0] += arr1[0] += 1;
+            arr2[0] += arr2[0] += 1;
+
+            s1 += s1 += "dude";
+            s2 += s2 += "dude";
+
+            return (i == j && i == 3 &&
+                    arr1[0] == arr2[0] && arr2[0] == 3 &&
+                    s1.equals(s2) && s1.endsWith("Hi, Hi, dude"));
+        }
+
+        public boolean test2() {
+            (i) += (i) += 1;
+            (j) += (j) += 1;
+
+            (arr1[0])+= (arr1[0]) += 1;
+            (arr2[0])+= (arr2[0]) += 1;
+
+            (s1) += (s1) += "dude";
+            (s2) += (s2) += "dude";
+
+            return (i == j && i == 3 &&
+                    arr1[0] == arr2[0] && arr2[0] == 3 &&
+                    s1.equals(s2) && s1.endsWith("Hi, Hi, dude"));
+        }
+    }
+}
diff --git a/test/tools/javac/7199823/InnerClassCannotBeVerified.java b/test/tools/javac/7199823/InnerClassCannotBeVerified.java
new file mode 100644
index 0000000..c309274
--- /dev/null
+++ b/test/tools/javac/7199823/InnerClassCannotBeVerified.java
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7199823
+ * @summary javac generates inner class that can't be verified
+ * @run main InnerClassCannotBeVerified
+ */
+
+import java.util.Arrays;
+import javax.tools.JavaFileObject;
+import java.net.URI;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.JavaCompiler;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import java.io.File;
+import java.io.IOException;
+
+public class InnerClassCannotBeVerified {
+
+    private static final String errorMessage =
+            "Compile error while compiling the following source:\n";
+
+    public static void main(String... args) throws Exception {
+        new InnerClassCannotBeVerified().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource();
+        JavacTask ct = (JavacTask)comp.getTask(null, null, null,
+                null, null, Arrays.asList(source));
+        try {
+            if (!ct.call()) {
+                throw new AssertionError(errorMessage +
+                        source.getCharContent(true));
+            }
+        } catch (Throwable ex) {
+            throw new AssertionError(errorMessage +
+                    source.getCharContent(true));
+        }
+        check();
+    }
+
+    private void check() throws IOException, ConstantPoolException {
+        File file = new File("Test$1.class");
+        ClassFile classFile = ClassFile.read(file);
+        boolean inheritsFromObject =
+                classFile.getSuperclassName().equals("java/lang/Object");
+        boolean implementsNoInterface = classFile.interfaces.length == 0;
+        boolean noMethods = classFile.methods.length == 0;
+        if (!(inheritsFromObject &&
+              implementsNoInterface &&
+              noMethods)) {
+            throw new AssertionError("The inner classes reused as " +
+                    "access constructor tag for this code must be empty");
+        }
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String internalSource =
+                              "public class Test {\n" +
+                              "    private static class Foo {}\n" +
+                              "    public static void main(String[] args){ \n" +
+                              "        new Foo();\n" +
+                              "        if(false) {\n" +
+                              "            new Runnable() {\n" +
+                              "                @Override\n" +
+                              "                public void run() {\n" +
+                              "                    System.out.println();\n" +
+                              "                }\n" +
+                              "            }.run();\n" +
+                              "        }\n" +
+                              "   }\n" +
+                              "}";
+        public JavaSource() {
+            super(URI.create("Test.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return internalSource;
+        }
+    }
+}
diff --git a/test/tools/javac/8000518/DuplicateConstantPoolEntry.java b/test/tools/javac/8000518/DuplicateConstantPoolEntry.java
new file mode 100644
index 0000000..6830bf9
--- /dev/null
+++ b/test/tools/javac/8000518/DuplicateConstantPoolEntry.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+/*
+ * @test
+ * @bug 8000518
+ * @summary Javac generates duplicate name_and_type constant pool entry for
+ * class BinaryOpValueExp.java
+ * @run main DuplicateConstantPoolEntry
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+/*
+ * This bug was reproduced having two classes B and C referenced from a class A
+ * class C should be compiled and generated in advance. Later class A and B should
+ * be compiled like this: javac A.java B.java
+ */
+
+public class DuplicateConstantPoolEntry {
+
+    public static void main(String args[]) throws Exception {
+        new DuplicateConstantPoolEntry().run();
+    }
+
+    void run() throws Exception {
+        generateFilesNeeded();
+        checkReference();
+    }
+
+    void generateFilesNeeded() throws Exception {
+
+        StringJavaFileObject[] CSource = new StringJavaFileObject[] {
+            new StringJavaFileObject("C.java",
+                "class C {C(String s) {}}"),
+        };
+
+        List<StringJavaFileObject> AandBSource = Arrays.asList(
+                new StringJavaFileObject("A.java",
+                    "class A {void test() {new B(null);new C(null);}}"),
+                new StringJavaFileObject("B.java",
+                    "class B {B(String s) {}}")
+        );
+
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavacTask compileC = (JavacTask)tool.getTask(null, null, null, null, null,
+                Arrays.asList(CSource));
+        if (!compileC.call()) {
+            throw new AssertionError("Compilation error while compiling C.java sources");
+        }
+        JavacTask compileAB = (JavacTask)tool.getTask(null, null, null,
+                Arrays.asList("-cp", "."), null, AandBSource);
+        if (!compileAB.call()) {
+            throw new AssertionError("Compilation error while compiling A and B sources");
+        }
+    }
+
+    void checkReference() throws IOException, ConstantPoolException {
+        File file = new File("A.class");
+        ClassFile classFile = ClassFile.read(file);
+        for (int i = 1;
+                i < classFile.constant_pool.size() - 1;
+                i += classFile.constant_pool.get(i).size()) {
+            for (int j = i + classFile.constant_pool.get(i).size();
+                    j < classFile.constant_pool.size();
+                    j += classFile.constant_pool.get(j).size()) {
+                if (classFile.constant_pool.get(i).toString().
+                        equals(classFile.constant_pool.get(j).toString())) {
+                    throw new AssertionError(
+                            "Duplicate entries in the constant pool at positions " +
+                            i + " and " + j);
+                }
+            }
+        }
+    }
+
+    private static class StringJavaFileObject extends SimpleJavaFileObject {
+        StringJavaFileObject(String name, String text) {
+            super(URI.create(name), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean b) {
+            return text;
+        }
+        private String text;
+    }
+}
diff --git a/test/tools/javac/8002286/T8002286.java b/test/tools/javac/8002286/T8002286.java
new file mode 100644
index 0000000..f4a4579
--- /dev/null
+++ b/test/tools/javac/8002286/T8002286.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8002286
+ * @summary Resolve should support nested resolution contexts
+ * @compile/fail/ref=T8002286.out -XDrawDiagnostics T8002286.java
+ */
+class T8002286 {
+    @Anno(nonExistent())
+    static class Test { }
+
+    @interface Anno { }
+}
diff --git a/test/tools/javac/8002286/T8002286.out b/test/tools/javac/8002286/T8002286.out
new file mode 100644
index 0000000..dd53323
--- /dev/null
+++ b/test/tools/javac/8002286/T8002286.out
@@ -0,0 +1,3 @@
+T8002286.java:8:22: compiler.err.cant.resolve.location.args: kindname.method, value, , , (compiler.misc.location: kindname.annotation, T8002286.Anno, null)
+T8002286.java:8:11: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , , (compiler.misc.location: kindname.class, T8002286, null)
+2 errors
diff --git a/test/tools/javac/8005931/CheckACC_STRICTFlagOnPkgAccessClassTest.java b/test/tools/javac/8005931/CheckACC_STRICTFlagOnPkgAccessClassTest.java
new file mode 100644
index 0000000..e879a3c
--- /dev/null
+++ b/test/tools/javac/8005931/CheckACC_STRICTFlagOnPkgAccessClassTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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 8005931
+ * @summary javac doesn't set ACC_STRICT for classes with package access
+ * @run main CheckACC_STRICTFlagOnPkgAccessClassTest
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+import static com.sun.tools.classfile.AccessFlags.ACC_STRICT;
+
+public class CheckACC_STRICTFlagOnPkgAccessClassTest {
+
+    private static final String AssertionErrorMessage =
+        "All methods should have the ACC_STRICT access flag " +
+        "please check output";
+    private static final String CompilationErrorMessage =
+        "Error thrown when compiling the following source:\n";
+    private static final String offendingMethodErrorMessage =
+        "Method %s of class %s doesn't have the ACC_STRICT access flag";
+
+    JavaSource source = new JavaSource();
+
+    private List<String> errors = new ArrayList<>();
+
+    public static void main(String[] args)
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        new CheckACC_STRICTFlagOnPkgAccessClassTest().run(comp);
+    }
+
+    private void run(JavaCompiler comp)
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        compile(comp);
+        check();
+        if (errors.size() > 0) {
+            for (String error: errors) {
+                System.err.println(error);
+            }
+            throw new AssertionError(AssertionErrorMessage);
+        }
+    }
+
+    private void compile(JavaCompiler comp) {
+        JavacTask ct = (JavacTask)comp.getTask(null, null, null, null, null,
+                Arrays.asList(source));
+        try {
+            if (!ct.call()) {
+                throw new AssertionError(CompilationErrorMessage +
+                        source.getCharContent(true));
+            }
+        } catch (Throwable ex) {
+            throw new AssertionError(CompilationErrorMessage +
+                    source.getCharContent(true));
+        }
+    }
+
+    void check()
+        throws
+            IOException,
+            ConstantPoolException,
+            Descriptor.InvalidDescriptor {
+        ClassFile classFileToCheck = ClassFile.read(new File("Test.class"));
+
+        for (Method method : classFileToCheck.methods) {
+            if ((method.access_flags.flags & ACC_STRICT) == 0) {
+                errors.add(String.format(offendingMethodErrorMessage,
+                        method.getName(classFileToCheck.constant_pool),
+                        classFileToCheck.getName()));
+            }
+        }
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String source = "strictfp class Test {" +
+                "    Test(){}" +
+                "    void m(){}" +
+                "}";
+
+        public JavaSource() {
+            super(URI.create("Test.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
diff --git a/test/tools/javac/8009170/RedundantByteCodeInArrayTest.java b/test/tools/javac/8009170/RedundantByteCodeInArrayTest.java
new file mode 100644
index 0000000..a0c7267
--- /dev/null
+++ b/test/tools/javac/8009170/RedundantByteCodeInArrayTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 8009170
+ * @summary Regression: javac generates redundant bytecode in assignop involving
+ * arrays
+ * @run main RedundantByteCodeInArrayTest
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.Code_attribute.InvalidIndex;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+public class RedundantByteCodeInArrayTest {
+    public static void main(String[] args)
+            throws IOException, ConstantPoolException, InvalidDescriptor, InvalidIndex {
+        new RedundantByteCodeInArrayTest()
+                .checkClassFile(new File(System.getProperty("test.classes", "."),
+                    RedundantByteCodeInArrayTest.class.getName() + ".class"));
+    }
+
+    void arrMethod(int[] array, int p, int inc) {
+        array[p] += inc;
+    }
+
+    void checkClassFile(File file)
+            throws IOException, ConstantPoolException, InvalidDescriptor, InvalidIndex {
+        ClassFile classFile = ClassFile.read(file);
+        ConstantPool constantPool = classFile.constant_pool;
+
+        //lets get all the methods in the class file.
+        for (Method method : classFile.methods) {
+            if (method.getName(constantPool).equals("arrMethod")) {
+                Code_attribute code = (Code_attribute) method.attributes
+                        .get(Attribute.Code);
+                if (code.max_locals > 4)
+                    throw new AssertionError("Too many locals for method arrMethod");
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/8015701/AnonymousParameters.java b/test/tools/javac/8015701/AnonymousParameters.java
new file mode 100644
index 0000000..746b2b9
--- /dev/null
+++ b/test/tools/javac/8015701/AnonymousParameters.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8015701
+ * @summary javac should generate method parameters correctly.
+ * @compile -parameters AnonymousParameters.java
+ * @run main AnonymousParameters
+ */
+import java.lang.Class;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Parameter;
+import java.util.concurrent.Callable;
+
+public class AnonymousParameters {
+
+    String[] names = {
+        "this$0",
+        "val$message"
+    };
+
+    public static void main(String... args) throws Exception {
+        new AnonymousParameters().run();
+    }
+
+    void run() throws Exception {
+        Class<?> cls = new ParameterNames().makeInner("hello").getClass();
+        Constructor<?> ctor = cls.getDeclaredConstructors()[0];
+        Parameter[] params = ctor.getParameters();
+
+        if(params.length == 2) {
+            for(int i = 0; i < 2; i++) {
+                System.err.println("Testing parameter " + params[i].getName());
+                if(!params[i].getName().equals(names[i]))
+                    error("Expected parameter name " + names[i] +
+                          " got " + params[i].getName());
+            }
+        } else
+            error("Expected 2 parameters");
+
+        if(0 != errors)
+            throw new Exception("MethodParameters test failed with " +
+                                errors + " errors");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
+
+class ParameterNames {
+
+    public Callable<String> makeInner(final String message) {
+        return new Callable<String>()  {
+            public String call() throws Exception {
+                return message;
+            }
+        };
+    }
+
+    public static void main(String... args) throws Exception {
+        ParameterNames test = new ParameterNames();
+        System.out.println(test.makeInner("Hello").call());
+    }
+}
diff --git a/test/tools/javac/ClassFileModifiers/MemberModifiers.java b/test/tools/javac/ClassFileModifiers/MemberModifiers.java
index f66376d..dc70ff1 100644
--- a/test/tools/javac/ClassFileModifiers/MemberModifiers.java
+++ b/test/tools/javac/ClassFileModifiers/MemberModifiers.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, 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
@@ -26,7 +26,7 @@
  * @bug 4249112 4785453
  * @summary Verify that implicit member modifiers are set correctly.
  *
- * @compile/ref=MemberModifiers.out  -source 1.4 -target 1.4.2 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java
+ * @compile/ref=MemberModifiers.out  -source 1.4 -target 1.5 -Xlint:-options -XDdumpmodifiers=cfm MemberModifiers.java
  */
 
 // Currently, we check only that members of final classes are not final.
diff --git a/test/tools/javac/ClassPathTest/ClassPathTest.java b/test/tools/javac/ClassPathTest/ClassPathTest.java
new file mode 100644
index 0000000..de4f73f
--- /dev/null
+++ b/test/tools/javac/ClassPathTest/ClassPathTest.java
@@ -0,0 +1,178 @@
+/*
+ * 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 4241229 4785453
+ * @summary Test -classpath option and classpath defaults.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ClassPathTest
+ */
+
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+//original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
+public class ClassPathTest {
+
+    private static final String ClassPathTest1Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest1 {\n" +
+        "    ClassPathTestAux1 x;\n" +
+        "}";
+
+    private static final String ClassPathTest2Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest2 {\n" +
+        "    ClassPathTestAux2 x;\n" +
+        "}";
+
+    private static final String ClassPathTest3Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest3 {\n" +
+        "    ClassPathTestAux3 x;\n" +
+        "}";
+
+    private static final String fooPkgClassPathTestAux1Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux1 {}";
+
+    private static final String barPkgClassPathTestAux2Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux2 {}";
+
+    private static final String pkgClassPathTestAux3Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux3 {}";
+
+    ProcessBuilder pb = null;
+
+    public static void main(String[] args) throws Exception {
+        new ClassPathTest().test();
+    }
+
+    public void test() throws Exception {
+        createOutputDirAndSourceFiles();
+        checkCompileCommands();
+    }
+
+    void createOutputDirAndSourceFiles() throws Exception {
+        //dirs and files creation
+        ToolBox.createJavaFileFromSource(ClassPathTest1Src);
+        ToolBox.createJavaFileFromSource(ClassPathTest2Src);
+        ToolBox.createJavaFileFromSource(ClassPathTest3Src);
+        ToolBox.createJavaFileFromSource(Paths.get("foo"),
+                fooPkgClassPathTestAux1Src);
+        ToolBox.createJavaFileFromSource(Paths.get("bar"),
+                barPkgClassPathTestAux2Src);
+        ToolBox.createJavaFileFromSource(pkgClassPathTestAux3Src);
+    }
+
+    void checkCompileCommands() throws Exception {
+//        Without the -cp . parameter the command will fail seems like when called
+//        from the command line, the current dir is added to the classpath
+//        automatically but this is not happening when called using ProcessBuilder
+
+//        testJavac success ClassPathTest3.java
+        List<String> mainArgs = new ArrayList<>();
+        mainArgs.add(ToolBox.javacBinary.toString());
+        if (ToolBox.testToolVMOpts != null) {
+            mainArgs.addAll(ToolBox.testToolVMOpts);
+        }
+
+        List<String> commonArgs = new ArrayList<>();
+        commonArgs.addAll(mainArgs);
+        commonArgs.addAll(Arrays.asList("-cp", "."));
+
+        ToolBox.AnyToolArgs successParams = new ToolBox.AnyToolArgs()
+                .appendArgs(commonArgs)
+                .appendArgs("ClassPathTest3.java");
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure ClassPathTest1.java
+        ToolBox.AnyToolArgs failParams =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(commonArgs)
+                .appendArgs("ClassPathTest1.java");
+        ToolBox.executeCommand(failParams);
+
+//        This is done inside the executeCommand method
+//        CLASSPATH=bar; export CLASSPATH
+
+        Map<String, String> extVars = new TreeMap<>();
+        extVars.put("CLASSPATH", "bar");
+
+//        testJavac success ClassPathTest2.java
+        successParams = new ToolBox.AnyToolArgs()
+                .appendArgs(mainArgs)
+                .appendArgs("ClassPathTest2.java")
+                .set(extVars);
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure ClassPathTest1.java
+        failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(mainArgs)
+                .appendArgs("ClassPathTest1.java")
+                .set(extVars);
+        ToolBox.executeCommand(failParams);
+
+//        testJavac failure ClassPathTest3.java
+        failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(mainArgs)
+                .appendArgs("ClassPathTest3.java")
+                .set(extVars);
+        ToolBox.executeCommand(failParams);
+
+//        testJavac success -classpath foo ClassPathTest1.java
+
+        commonArgs.clear();
+        commonArgs.addAll(mainArgs);
+        commonArgs.addAll(Arrays.asList("-cp", "foo"));
+
+        successParams = new ToolBox.AnyToolArgs()
+                .appendArgs(commonArgs)
+                .appendArgs("ClassPathTest1.java")
+                .set(extVars);
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure -classpath foo ClassPathTest2.java
+        failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(commonArgs)
+                .appendArgs("ClassPathTest2.java")
+                .set(extVars);
+        ToolBox.executeCommand(failParams);
+
+//        testJavac failure -classpath foo ClassPathTest3.java
+        failParams = new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(commonArgs)
+                .appendArgs("ClassPathTest3.java")
+                .set(extVars);
+        ToolBox.executeCommand(failParams);
+    }
+
+}
diff --git a/test/tools/javac/ClassPathTest/ClassPathTest.sh b/test/tools/javac/ClassPathTest/ClassPathTest.sh
deleted file mode 100644
index e46aef0..0000000
--- a/test/tools/javac/ClassPathTest/ClassPathTest.sh
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, 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 4241229 4785453
-# @summary Test -classpath option and classpath defaults.
-# @author maddox
-#
-# @run shell/timeout=180 ClassPathTest.sh
-
-# TODO: Should test sourcepath and classpath separately.
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-cleanup() {
-	rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class
-	cp -rf $TESTSRC${FS}* .
-}
-
-fail() {
-	echo "FAIL: $1"
-	failed="yes"
-}
-
-# report expectedResult $?
-report() {
-	if   test "$1" = "success" -a "$2" = 0; then
-		echo "PASS: succeeded as expected"
-	elif test "$1" = "failure" -a "$2" != 0; then
-		echo "PASS: failed as expected"
-	elif test "$1" = "success" -a "$2" != 0; then
-		fail "test failed unexpectedly"
-	elif test "$1" = "failure" -a "$2" = 0; then
-		fail "test succeeded unexpectedly"
-	else
-		fail "internal error"
-	fi
-}
-
-# testJavac expectedResult javacArgs...
-testJavac() {
-	expectedResult="$1"; shift
-	cleanup
-	echo $javac ${TESTTOOLVMOPTS} "$@"
-	"$javac" ${TESTTOOLVMOPTS} "$@"
-	report $expectedResult $?
-}
-
-unset CLASSPATH
-
-# classpath should default to current directory
-
-testJavac success ClassPathTest3.java
-testJavac failure ClassPathTest1.java
-
-# if CLASSPATH is set, it should be honored
-
-CLASSPATH=bar; export CLASSPATH
-
-testJavac success ClassPathTest2.java
-testJavac failure ClassPathTest1.java
-testJavac failure ClassPathTest3.java
-
-# -classpath option should override default
-
-testJavac success -classpath foo ClassPathTest1.java
-testJavac failure -classpath foo ClassPathTest2.java
-testJavac failure -classpath foo ClassPathTest3.java
-
-if test -n "$failed"; then
-	echo "Some tests failed"
-	exit 1
-else
-	echo PASS: all tests gave expected results
-	exit 0
-fi
diff --git a/test/tools/javac/ClassPathTest/ClassPathTest1.java b/test/tools/javac/ClassPathTest/ClassPathTest1.java
deleted file mode 100644
index bb5f843..0000000
--- a/test/tools/javac/ClassPathTest/ClassPathTest1.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg.*;
-
-public class ClassPathTest1 {
-    ClassPathTestAux1 x;
-
-}
diff --git a/test/tools/javac/ClassPathTest/ClassPathTest2.java b/test/tools/javac/ClassPathTest/ClassPathTest2.java
deleted file mode 100644
index d596a09..0000000
--- a/test/tools/javac/ClassPathTest/ClassPathTest2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg.*;
-
-public class ClassPathTest2 {
-    ClassPathTestAux2 x;
-
-}
diff --git a/test/tools/javac/ClassPathTest/ClassPathTest3.java b/test/tools/javac/ClassPathTest/ClassPathTest3.java
deleted file mode 100644
index 94d9de5..0000000
--- a/test/tools/javac/ClassPathTest/ClassPathTest3.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg.*;
-
-public class ClassPathTest3 {
-    ClassPathTestAux3 x;
-
-}
diff --git a/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java b/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java
deleted file mode 100644
index a7e7799..0000000
--- a/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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 ClassPathTestAux2 {}
diff --git a/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java b/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java
deleted file mode 100644
index 15ea42f..0000000
--- a/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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 ClassPathTestAux1 {}
diff --git a/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java b/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java
deleted file mode 100644
index 5047280..0000000
--- a/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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 ClassPathTestAux3 {}
diff --git a/test/tools/javac/DefiniteAssignment/T7181578.java b/test/tools/javac/DefiniteAssignment/T7181578.java
new file mode 100644
index 0000000..d25d0d1
--- /dev/null
+++ b/test/tools/javac/DefiniteAssignment/T7181578.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ *
+ * 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 7181578
+ * @summary javac reports uninitialized variable with nested try...finally blocks
+  *
+ * @compile T7181578.java
+ */
+class T7181578 {
+    String test(boolean cond) {
+        final String s;
+        try {
+            if (cond) {
+                try {
+                    s = "";
+                    return s;
+                } finally { }
+            } else {
+                s = "";
+            }
+            return s; // bug occurs here: mapping is always initialized
+        } finally { }
+    }
+}
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234a_1.out b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out
index adfe7af..a51b6ca 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_1.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out
@@ -1,2 +1,2 @@
-T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
+T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234a_2.out b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out
index e535bdc..303e91a 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_2.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out
@@ -1,3 +1,3 @@
-T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
+T6722234a.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
 - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T6722234a),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, java.lang.Integer, kindname.method, <compiler.misc.type.var: T, 2>test(compiler.misc.type.var: T, 2))}
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out
index b019f8a..4545c9a 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out
@@ -1,2 +1,2 @@
-T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.type.captureof: 2, ? extends T6722234b>, List<T>)
+T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ? extends T6722234b, compiler.misc.type.captureof: 2, ? extends T6722234b,compiler.misc.type.captureof: 1, ? extends T6722234b)
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out
index e4e6693..bdf5fb5 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out
@@ -1,4 +1,4 @@
-T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.captured.type: 2>, List<T>)
+T6722234b.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1)
 - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))}
 - compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)}
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234c.out b/test/tools/javac/Diagnostics/6722234/T6722234c.out
index a518913..a8a6a3b 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234c.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out
@@ -1,2 +1,2 @@
-T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, java.lang.String, T6722234c.String)
+T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.lang.String, T6722234c.String))
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234d_1.out b/test/tools/javac/Diagnostics/6722234/T6722234d_1.out
index 101f78b..48bd8d3 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234d_1.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234d_1.out
@@ -1,3 +1,3 @@
-T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A
+T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.intersection.type: 1, T6722234d.A,java.lang.Object)
 - compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, java.lang.Object,T6722234d.I1,T6722234d.I2)}
 1 error
diff --git a/test/tools/javac/Diagnostics/6722234/T6722234d_2.out b/test/tools/javac/Diagnostics/6722234/T6722234d_2.out
index 236c80f..dd1d1de 100644
--- a/test/tools/javac/Diagnostics/6722234/T6722234d_2.out
+++ b/test/tools/javac/Diagnostics/6722234/T6722234d_2.out
@@ -1,3 +1,3 @@
-T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.intersection.type: 1, T6722234d.A
+T6722234d.java:18:20: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.intersection.type: 1, T6722234d.A,Object)
 - compiler.misc.where.description.intersection: compiler.misc.intersection.type: 1,{(compiler.misc.where.intersection: compiler.misc.intersection.type: 1, Object,I1,I2)}
 1 error
diff --git a/test/tools/javac/Diagnostics/6769027/T6769027.java b/test/tools/javac/Diagnostics/6769027/T6769027.java
index 922b00f..2d9bf18 100644
--- a/test/tools/javac/Diagnostics/6769027/T6769027.java
+++ b/test/tools/javac/Diagnostics/6769027/T6769027.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, 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
@@ -23,17 +23,26 @@
 
 /**
  * @test
- * @bug     6769027
+ * @bug     6769027 8006694
  * @summary Source line should be displayed immediately after the first diagnostic line
+ *  temporarily workaround combo tests are causing time out in several platforms
  * @author  Maurizio Cimadamore
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
  * @run main/othervm T6769027
  */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.net.URI;
 import java.util.regex.Matcher;
 import javax.tools.*;
 import com.sun.tools.javac.util.*;
 
-public class T6769027 {
+public class T6769027
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     enum OutputKind {
         RAW("rawDiagnostics","rawDiagnostics"),
@@ -314,7 +323,7 @@ public class T6769027 {
 
         @Override
         protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) {
-            return new java.io.PrintWriter(System.out);
+            return outWriter;
         }
 
         @Override
@@ -323,13 +332,42 @@ public class T6769027 {
         }
     }
 
-    int nerrors = 0;
-
-    void exec(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
+    OutputKind outputKind;
+    ErrorKind errorKind;
+    MultilineKind multiKind;
+    MultilinePolicy multiPolicy;
+    PositionKind posKind;
+    XDiagsSource xdiagsSource;
+    XDiagsCompact xdiagsCompact;
+    CaretKind caretKind;
+    SourceLineKind sourceLineKind;
+    IndentKind summaryIndent;
+    IndentKind detailsIndent;
+    IndentKind sourceIndent;
+    IndentKind subdiagsIndent;
+
+    T6769027(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
             MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
             XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
             IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
             IndentKind subdiagsIndent) {
+        this.outputKind = outputKind;
+        this.errorKind = errorKind;
+        this.multiKind = multiKind;
+        this.multiPolicy = multiPolicy;
+        this.posKind = posKind;
+        this.xdiagsSource = xdiagsSource;
+        this.xdiagsCompact = xdiagsCompact;
+        this.caretKind = caretKind;
+        this.sourceLineKind = sourceLineKind;
+        this.summaryIndent = summaryIndent;
+        this.detailsIndent = detailsIndent;
+        this.sourceIndent = sourceIndent;
+        this.subdiagsIndent = subdiagsIndent;
+    }
+
+    @Override
+    public void run() {
         Context ctx = new Context();
         Options options = Options.instance(ctx);
         outputKind.init(options);
@@ -362,23 +400,10 @@ public class T6769027 {
             d = new JCDiagnostic.MultilineDiagnostic(d, subdiags);
         }
         String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale());
-        checkOutput(diag,
-                outputKind,
-                errorKind,
-                multiKind,
-                multiPolicy,
-                posKind,
-                xdiagsSource,
-                xdiagsCompact,
-                caretKind,
-                sourceLineKind,
-                summaryIndent,
-                detailsIndent,
-                sourceIndent,
-                subdiagsIndent);
+        checkOutput(diag);
     }
 
-    void test() {
+    public static void main(String[] args) throws Exception {
         for (OutputKind outputKind : OutputKind.values()) {
             for (ErrorKind errKind : ErrorKind.values()) {
                 for (MultilineKind multiKind : MultilineKind.values()) {
@@ -392,7 +417,7 @@ public class T6769027 {
                                                 for (IndentKind detailsIndent : IndentKind.values()) {
                                                     for (IndentKind sourceIndent : IndentKind.values()) {
                                                         for (IndentKind subdiagsIndent : IndentKind.values()) {
-                                                            exec(outputKind,
+                                                            pool.execute(new T6769027(outputKind,
                                                                 errKind,
                                                                 multiKind,
                                                                 multiPolicy,
@@ -404,7 +429,7 @@ public class T6769027 {
                                                                 summaryIndent,
                                                                 detailsIndent,
                                                                 sourceIndent,
-                                                                subdiagsIndent);
+                                                                subdiagsIndent));
                                                         }
                                                     }
                                                 }
@@ -418,15 +443,11 @@ public class T6769027 {
                 }
             }
         }
-        if (nerrors != 0)
-            throw new AssertionError(nerrors + " errors found");
+
+        checkAfterExec(false);
     }
 
-    void printInfo(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
-            MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
-            XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
-            IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
-            IndentKind subdiagsIndent, String errorLine) {
+    void printInfo(String msg, String errorLine) {
         String sep = "*********************************************************";
         String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() +
                 " multiline=" + multiKind +" multiPolicy=" + multiPolicy.value +
@@ -434,18 +455,14 @@ public class T6769027 {
                 " caret=" + caretKind + " sourcePosition=" + sourceLineKind +
                 " summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent +
                 " sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent;
-        System.out.println(sep);
-        System.out.println(desc);
-        System.out.println(sep);
-        System.out.println(msg);
-        System.out.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
+        errWriter.println(sep);
+        errWriter.println(desc);
+        errWriter.println(sep);
+        errWriter.println(msg);
+        errWriter.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
     }
 
-    void checkOutput(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
-            MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
-            XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
-            IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
-            IndentKind subdiagsIndent) {
+    void checkOutput(String msg) {
         boolean shouldPrintSource = posKind == PositionKind.POS &&
                 xdiagsSource != XDiagsSource.NO_SOURCE &&
                 (xdiagsSource == XDiagsSource.SOURCE ||
@@ -453,7 +470,8 @@ public class T6769027 {
         String errorLine = posKind.getOutput(outputKind) +
                 errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
         if (xdiagsCompact != XDiagsCompact.COMPACT)
-            errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent);
+            errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy,
+                    summaryIndent, detailsIndent, subdiagsIndent);
         String[] lines = errorLine.split("\n");
         if (xdiagsCompact == XDiagsCompact.COMPACT) {
             errorLine = lines[0];
@@ -474,26 +492,9 @@ public class T6769027 {
         }
 
         if (!msg.equals(errorLine)) {
-            printInfo(msg,
-                    outputKind,
-                    errorKind,
-                    multiKind,
-                    multiPolicy,
-                    posKind,
-                    xdiagsSource,
-                    xdiagsCompact,
-                    caretKind,
-                    sourceLineKind,
-                    summaryIndent,
-                    detailsIndent,
-                    sourceIndent,
-                    subdiagsIndent,
-                    errorLine);
-            nerrors++;
+//            printInfo(msg, errorLine);
+            errCount.incrementAndGet();
         }
     }
 
-    public static void main(String... args) throws Exception {
-        new T6769027().test();
-    }
 }
diff --git a/test/tools/javac/Diagnostics/6799605/T6799605.out b/test/tools/javac/Diagnostics/6799605/T6799605.out
index 323a354..24bce3d 100644
--- a/test/tools/javac/Diagnostics/6799605/T6799605.out
+++ b/test/tools/javac/Diagnostics/6799605/T6799605.out
@@ -1,4 +1,4 @@
-T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (comp [...]
-T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type. [...]
-T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T679960 [...]
+T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.incompatible.eq.upper.bounds: T, compiler.misc.type.captureof: 1, ?, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method,  [...]
+T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ?, compiler.misc.typ [...]
+T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc. [...]
 3 errors
diff --git a/test/tools/javac/Diagnostics/6862608/T6862608a.out b/test/tools/javac/Diagnostics/6862608/T6862608a.out
index d32924f..215e53f 100644
--- a/test/tools/javac/Diagnostics/6862608/T6862608a.out
+++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>)
+T6862608a.java:19:33: compiler.err.cant.apply.symbol: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6862608a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
 - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))}
 1 error
diff --git a/test/tools/javac/Diagnostics/6862608/T6862608b.out b/test/tools/javac/Diagnostics/6862608/T6862608b.out
index d24e7cd..4539eb8 100644
--- a/test/tools/javac/Diagnostics/6862608/T6862608b.out
+++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out
@@ -1,3 +1,3 @@
-T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
+T6862608b.java:11:7: compiler.err.cant.apply.symbol: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1))
 - compiler.misc.where.description.typevar.1: compiler.misc.type.var: T, 1,compiler.misc.type.var: T, 2,compiler.misc.type.var: S, 1,compiler.misc.type.var: S, 2,{(compiler.misc.where.typevar: compiler.misc.type.var: T, 1, java.lang.String, kindname.class, T66862608b),(compiler.misc.where.typevar: compiler.misc.type.var: T, 2, compiler.misc.type.var: S, 1, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.ty [...]
 1 error
diff --git a/test/tools/javac/Diagnostics/7116676/T7116676.java b/test/tools/javac/Diagnostics/7116676/T7116676.java
new file mode 100644
index 0000000..40acc78
--- /dev/null
+++ b/test/tools/javac/Diagnostics/7116676/T7116676.java
@@ -0,0 +1,109 @@
+/*
+ * 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 7116676
+ * @summary RichDiagnosticFormatter throws NPE when formatMessage is called directly
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper.Trusted;
+import com.sun.tools.javac.api.DiagnosticFormatter;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.Log;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class T7116676 {
+
+    public static void main(String[] args) throws Exception {
+        T7116676 test = new T7116676();
+        test.testThroughFormatterFormat();
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+        private String text = "package test;\n" +
+                              "public class Test {\n" +
+                              "   private void t(java.util.List<? extends String> l) {\n" +
+                              "      t(java.util.Collections.singleton(l));\n" +
+                              "}  }";
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+    void assertEquals(String req, String found) {
+        if (!found.equals(req)) {
+            throw new AssertionError(String.format("Error. Found: \n\n%s ; Expected: \n\n%s", found, req));
+        }
+    }
+
+    public void testThroughFormatterFormat() throws IOException {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker("compiler.err.prob.found.req");
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(new JavaSource()));
+        ct.analyze();
+        DiagnosticFormatter<JCDiagnostic> formatter =
+                Log.instance(((JavacTaskImpl) ct).getContext()).getDiagnosticFormatter();
+        String msg = formatter.formatMessage(dc.diag, Locale.getDefault());
+        //no redundant package qualifiers
+        Assert.check(msg.indexOf("java.") == -1, msg);
+    }
+
+    @Trusted
+    private static final class DiagnosticChecker implements DiagnosticListener<JavaFileObject> {
+
+        String expectedKey;
+        JCDiagnostic diag;
+
+        DiagnosticChecker(String expectedKey) {
+            this.expectedKey = expectedKey;
+        }
+
+        @Override
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            JCDiagnostic diag = (JCDiagnostic)diagnostic;
+            if (diagnostic.getCode().equals(expectedKey)) {
+                this.diag = diag;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/Diagnostics/8010387/T8010387.java b/test/tools/javac/Diagnostics/8010387/T8010387.java
new file mode 100644
index 0000000..2077ef1
--- /dev/null
+++ b/test/tools/javac/Diagnostics/8010387/T8010387.java
@@ -0,0 +1,17 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     8010387
+ * @summary rich diagnostic sometimes contain wrong type variable numbering
+ * @compile/fail/ref=T8010387.out -XDrawDiagnostics -XDdiags=disambiguateTvars,where T8010387.java
+ */
+abstract class T8010387<X> {
+
+    interface F<X> { }
+
+    <P> void test() {
+        m(new F<P>() { });
+    }
+
+
+    abstract <T> T8010387<?> m(F<? extends X> fx);
+}
diff --git a/test/tools/javac/Diagnostics/8010387/T8010387.out b/test/tools/javac/Diagnostics/8010387/T8010387.out
new file mode 100644
index 0000000..e42c708
--- /dev/null
+++ b/test/tools/javac/Diagnostics/8010387/T8010387.out
@@ -0,0 +1,3 @@
+T8010387.java:12:9: compiler.err.cant.apply.symbol: kindname.method, m, T8010387.F<? extends X>, compiler.misc.anonymous.class: T8010387.F<P>, kindname.class, T8010387<X>, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: T8010387.F<P>, T8010387.F<? extends X>))
+- compiler.misc.where.description.typevar.1: X,P,T,{(compiler.misc.where.typevar: X, java.lang.Object, kindname.class, T8010387),(compiler.misc.where.typevar: P, java.lang.Object, kindname.method, <P>test()),(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>m(T8010387.F<? extends X>))}
+1 error
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003a.java b/test/tools/javac/Diagnostics/compressed/T8012003a.java
new file mode 100644
index 0000000..9772964
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003a.java
@@ -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');
+    }
+}
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003a.out b/test/tools/javac/Diagnostics/compressed/T8012003a.out
new file mode 100644
index 0000000..b128716
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003a.out
@@ -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
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003b.java b/test/tools/javac/Diagnostics/compressed/T8012003b.java
new file mode 100644
index 0000000..f5fbeb0
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003b.java
@@ -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);
+    }
+}
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003b.out b/test/tools/javac/Diagnostics/compressed/T8012003b.out
new file mode 100644
index 0000000..246900b
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003b.out
@@ -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
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003c.java b/test/tools/javac/Diagnostics/compressed/T8012003c.java
new file mode 100644
index 0000000..a64f977
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003c.java
@@ -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() { }
+}
diff --git a/test/tools/javac/Diagnostics/compressed/T8012003c.out b/test/tools/javac/Diagnostics/compressed/T8012003c.out
new file mode 100644
index 0000000..7af49cc
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8012003c.out
@@ -0,0 +1,3 @@
+T8012003c.java:18:15: compiler.err.report.access: m(), private, P
+- compiler.note.compressed.diags
+1 error
diff --git a/test/tools/javac/Diagnostics/compressed/T8020286.java b/test/tools/javac/Diagnostics/compressed/T8020286.java
new file mode 100644
index 0000000..eaf73eb
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8020286.java
@@ -0,0 +1,15 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     8020286
+ * @summary Wrong diagnostic after compaction
+ * @compile/fail/ref=T8020286.out -XDrawDiagnostics -Xdiags:compact T8020286.java
+ */
+
+class T8020286 {
+   void m(String s) { }
+   void m(Integer i, String s) { }
+   void test() {
+       m(1, 1);
+       m(1);
+   }
+}
diff --git a/test/tools/javac/Diagnostics/compressed/T8020286.out b/test/tools/javac/Diagnostics/compressed/T8020286.out
new file mode 100644
index 0000000..60801fd
--- /dev/null
+++ b/test/tools/javac/Diagnostics/compressed/T8020286.out
@@ -0,0 +1,4 @@
+T8020286.java:12:13: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.String)
+T8020286.java:13:10: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.String)
+- compiler.note.compressed.diags
+2 errors
diff --git a/test/tools/javac/ExtDirs/ExtDirTest.java b/test/tools/javac/ExtDirs/ExtDirTest.java
new file mode 100644
index 0000000..22af79a
--- /dev/null
+++ b/test/tools/javac/ExtDirs/ExtDirTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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 4204897 4256097 4785453 4863609
+ * @summary Test that '.jar' files in -extdirs are found.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ExtDirTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javac/ExtDirs/ExtDirs.sh
+public class ExtDirTest {
+
+    private static final String ExtDirTestClass1Src =
+        "package pkg1;\n" +
+        "\n" +
+        "public class ExtDirTestClass1 {}";
+
+    private static final String ExtDirTestClass2Src =
+        "package pkg2;\n" +
+        "\n" +
+        "public class ExtDirTestClass2 {}";
+
+    private static final String ExtDirTest_1Src =
+        "import pkg1.*;\n" +
+        "\n" +
+        "public class ExtDirTest_1 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "}";
+
+    private static final String ExtDirTest_2Src =
+        "import pkg1.*;\n" +
+        "import pkg2.*;\n" +
+        "\n" +
+        "public class ExtDirTest_2 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "  ExtDirTestClass2 y;\n" +
+        "}";
+
+    private static final String ExtDirTest_3Src =
+        "import pkg1.*;\n" +
+        "import pkg2.*;\n" +
+        "\n" +
+        "public class ExtDirTest_3 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "  ExtDirTestClass2 y;\n" +
+        "}";
+
+    private static final String jar1Manifest =
+        "Manifest-Version: 1.0\n" +
+        "\n" +
+        "Name: pkg1/ExtDirTestClass1.class\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: 9HEcO9LJmND3cvOlq/AbUsbD9S0=\n" +
+        "MD5-Digest: hffPBwfqcUcnEdNv4PXu1Q==\n" +
+        "\n" +
+        "Name: pkg1/ExtDirTestClass1.java\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: 2FQVe6w3n2Ma1ACYpe8a988EBU8=\n" +
+        "MD5-Digest: /Ivr4zVI9MSM26NmqWtZpQ==\n";
+
+    private static final String jar2Manifest =
+        "Manifest-Version: 1.0\n" +
+        "\n" +
+        "Name: pkg2/ExtDirTestClass2.class\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: elbPaqWf8hjj1+ZkkdW3PGTsilo=\n" +
+        "MD5-Digest: 57Nn0e2t1yEQfu/4kSw8yg==\n" +
+        "\n" +
+        "Name: pkg2/ExtDirTestClass2.java\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: ILJOhwHg5US+yuw1Sc1d+Avu628=\n" +
+        "MD5-Digest: j8wnz8wneEcuJ/gjXBBQNA==\n";
+
+    List<String> ouputDirParam = Arrays.asList("-d", ".");
+
+    public static void main(String args[]) throws Exception {
+        new ExtDirTest().run();
+    }
+
+    void run() throws Exception {
+        createJars();
+        compileWithExtDirs();
+    }
+
+    void createJars() throws Exception {
+
+//        for i in 1 2 3; do
+//            if test ! -d ext${i}; then mkdir ext${i}; fi
+//            cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
+//        done
+        sun.tools.jar.Main jarGenerator =
+                new sun.tools.jar.Main(System.out, System.err, "jar");
+
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .setOptions(ouputDirParam)
+                .setSources(ExtDirTestClass1Src);
+        ToolBox.javac(javacParams);
+
+        ToolBox.writeFile(Paths.get("pkg1", "MANIFEST.MF"), jar1Manifest);
+        jarGenerator.run(new String[] {"cfm", "pkg1.jar", "pkg1/MANIFEST.MF",
+            "pkg1/ExtDirTestClass1.class"});
+
+        javacParams.setSources(ExtDirTestClass2Src);
+        ToolBox.javac(javacParams);
+
+        ToolBox.writeFile(Paths.get("pkg2", "MANIFEST.MF"), jar2Manifest);
+        jarGenerator.run(new String[] {"cfm", "pkg2.jar", "pkg2/MANIFEST.MF",
+            "pkg2/ExtDirTestClass2.class"});
+
+        ToolBox.copyFile(Paths.get("ext1", "pkg1.jar"), Paths.get("pkg1.jar"));
+        ToolBox.copyFile(Paths.get("ext2", "pkg2.jar"), Paths.get("pkg2.jar"));
+        ToolBox.copyFile(Paths.get("ext3", "pkg1.jar"), Paths.get("pkg1.jar"));
+        ToolBox.copyFile(Paths.get("ext3", "pkg2.jar"), Paths.get("pkg2.jar"));
+
+        Files.delete(Paths.get("pkg1.jar"));
+        Files.delete(Paths.get("pkg2.jar"));
+
+        Files.delete(Paths.get("pkg1", "ExtDirTestClass1.class"));
+        Files.delete(Paths.get("pkg1", "MANIFEST.MF"));
+        Files.delete(Paths.get("pkg1"));
+        Files.delete(Paths.get("pkg2", "ExtDirTestClass2.class"));
+        Files.delete(Paths.get("pkg2", "MANIFEST.MF"));
+        Files.delete(Paths.get("pkg2"));
+    }
+
+    void compileWithExtDirs() throws Exception {
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-d", ".", "-extdirs", "ext1")
+                .setSources(ExtDirTest_1Src);
+        ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
+        params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2")
+                .setSources(ExtDirTest_2Src);
+        ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
+        params.setOptions("-d", ".", "-extdirs", "ext3")
+                .setSources(ExtDirTest_3Src);
+        ToolBox.javac(params);
+    }
+
+}
diff --git a/test/tools/javac/ExtDirs/ExtDirTest_1.java b/test/tools/javac/ExtDirs/ExtDirTest_1.java
deleted file mode 100644
index 5e1f20a..0000000
--- a/test/tools/javac/ExtDirs/ExtDirTest_1.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg1.*;
-
-public class ExtDirTest_1 {
-  ExtDirTestClass1 x;
-}
diff --git a/test/tools/javac/ExtDirs/ExtDirTest_2.java b/test/tools/javac/ExtDirs/ExtDirTest_2.java
deleted file mode 100644
index b76ad3f..0000000
--- a/test/tools/javac/ExtDirs/ExtDirTest_2.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_2 {
-  ExtDirTestClass1 x;
-  ExtDirTestClass2 y;
-}
diff --git a/test/tools/javac/ExtDirs/ExtDirTest_3.java b/test/tools/javac/ExtDirs/ExtDirTest_3.java
deleted file mode 100644
index 760d0ff..0000000
--- a/test/tools/javac/ExtDirs/ExtDirTest_3.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, 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 pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_3 {
-  ExtDirTestClass1 x;
-  ExtDirTestClass2 y;
-}
diff --git a/test/tools/javac/ExtDirs/ExtDirs.sh b/test/tools/javac/ExtDirs/ExtDirs.sh
deleted file mode 100644
index 00da24e..0000000
--- a/test/tools/javac/ExtDirs/ExtDirs.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, 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 4204897 4256097 4785453 4863609
-# @summary Test that '.jar' files in -extdirs are found.
-# @author maddox
-#
-# @run shell/timeout=180 ExtDirs.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";" # native PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-fail() {
-	echo 'FAIL: unexpected result encountered'
-        exit 1
-}
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-for i in 1 2 3; do
-    if test ! -d ext${i}; then mkdir ext${i}; fi
-    cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
-done
-
-echo "Test 1"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 2"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 3"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo PASS: all tests gave expected results
-exit 0
diff --git a/test/tools/javac/HiddenAbstractMethod/Test b/test/tools/javac/HiddenAbstractMethod/Test
deleted file mode 100644
index d511864..0000000
--- a/test/tools/javac/HiddenAbstractMethod/Test
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * @test
- * @bug 1240831
- * @summary Certain classes should have been reported as abstract, but
- *          the compiler failed to detect this.  This comes up when a
- *          subclass declares a method with the same name as an
- *          unimplemented, unaccessible method in a superclass.  Even though
- *          the method has the same name, it does not override.
- * @author turnidge
- *
- * @compile/fail -nowrite one/Parent.java two/Child.java
- */
diff --git a/test/tools/javac/HiddenAbstractMethod/Test.java b/test/tools/javac/HiddenAbstractMethod/Test.java
new file mode 100644
index 0000000..775eb1b
--- /dev/null
+++ b/test/tools/javac/HiddenAbstractMethod/Test.java
@@ -0,0 +1,12 @@
+/*
+ * @test
+ * @bug 1240831
+ * @summary Certain classes should have been reported as abstract, but
+ *          the compiler failed to detect this.  This comes up when a
+ *          subclass declares a method with the same name as an
+ *          unimplemented, unaccessible method in a superclass.  Even though
+ *          the method has the same name, it does not override.
+ * @author turnidge
+ *
+ * @compile/fail one/Parent.java two/Child.java
+ */
diff --git a/test/tools/javac/MethodParameters/AnnotationTest.java b/test/tools/javac/MethodParameters/AnnotationTest.java
new file mode 100644
index 0000000..ca8cd52
--- /dev/null
+++ b/test/tools/javac/MethodParameters/AnnotationTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters AnnotationTest.java
+ * @run main Tester AnnotationTest
+ */
+
+import java.lang.annotation.*;
+
+/** Test that annotations do not interfere with recording of parameter names */
+class AnnotationTest {
+
+    @Repeatable(Annos.class)
+    @interface Anno {
+        Class f() default int.class;
+    }
+
+    @interface Annos { Anno[] value(); String foo() default "hello"; }
+
+    interface I {
+        int m(@Anno @Anno int i, @Anno int ji);
+    }
+
+    public AnnotationTest(@Anno @Anno I i, @Anno int ji) { }
+    public @Anno String foo(@Anno @Anno I i, int ji) { return null; }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/AnonymousClass.java b/test/tools/javac/MethodParameters/AnonymousClass.java
new file mode 100644
index 0000000..ee87a20
--- /dev/null
+++ b/test/tools/javac/MethodParameters/AnonymousClass.java
@@ -0,0 +1,104 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters AnonymousClass.java
+ * @run main Tester AnonymousClass
+ */
+
+class AnonymousClass {
+
+    interface I<T> {
+        T m();
+        T m(T x, T yx);
+    }
+
+    private class Inner implements I<String> {
+        public Inner()  { }
+        public Inner(String arg, String barg)  { }
+        public String m() { return "0"; }
+        public String m(String s, String ts) { return "0"; }
+    }
+
+    public static class Sinner implements I<Long> {
+        public Sinner()  { }
+        public Sinner(Long arg, Long barg)  { }
+        public Long m() { return 0L; }
+        public Long m(Long s, Long ts) { return s + ts; }
+    }
+
+    /** Inner class in constructor context */
+    public AnonymousClass(final Long a, Long ba) {
+        new I<Long>() {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+        new Inner() {
+            public String m() { return null; }
+            public String m(String i, String ji) { return i + ji; }
+        }.m(a.toString(), ba.toString());
+        new Inner(a.toString(), ba.toString()) {
+            public String m() { return null; }
+            public String m(String i, String ji) { return i + ji; }
+        }.m(a.toString(), ba.toString());
+        new Sinner() {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+        new Sinner(a, ba) {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+    }
+
+    /** Inner class in method context */
+    public void foo(final Long a, Long ba) {
+        new I<Long>() {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+        new Inner() {
+            public String m() { return null; }
+            public String m(String i, String ji) { return i + ji; }
+        }.m(a.toString(), ba.toString());
+        new Inner(a.toString(), ba.toString()) {
+            public String m() { return null; }
+            public String m(String i, String ji) { return i + ji; }
+        }.m(a.toString(), ba.toString());
+        new Sinner() {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+        new Sinner(a, ba) {
+            public Long m() { return null; }
+            public Long m(Long i, Long ji) { return i + ji; }
+        }.m(a, ba);
+    }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/AttributeVisitor.java b/test/tools/javac/MethodParameters/AttributeVisitor.java
new file mode 100644
index 0000000..53c8136
--- /dev/null
+++ b/test/tools/javac/MethodParameters/AttributeVisitor.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.sun.tools.classfile.*;
+
+/**
+ * Trivial {@code Attribute.Visitor} implementation, to make it easy to
+ * write visitors for specific attributes.
+ */
+class AttributeVisitor<R, P> implements Attribute.Visitor<R, P> {
+    public R visitBootstrapMethods(BootstrapMethods_attribute attr, P p) { return null; }
+    public R visitDefault(DefaultAttribute attr, P p) { return null; }
+    public R visitAnnotationDefault(AnnotationDefault_attribute attr, P p) { return null; }
+    public R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p) { return null; }
+    public R visitCode(Code_attribute attr, P p) { return null; }
+    public R visitCompilationID(CompilationID_attribute attr, P p) { return null; }
+    public R visitConstantValue(ConstantValue_attribute attr, P p) { return null; }
+    public R visitDeprecated(Deprecated_attribute attr, P p) { return null; }
+    public R visitEnclosingMethod(EnclosingMethod_attribute attr, P p) { return null; }
+    public R visitExceptions(Exceptions_attribute attr, P p) { return null; }
+    public R visitInnerClasses(InnerClasses_attribute attr, P p) { return null; }
+    public R visitLineNumberTable(LineNumberTable_attribute attr, P p) { return null; }
+    public R visitLocalVariableTable(LocalVariableTable_attribute attr, P p) { return null; }
+    public R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p) { return null; }
+    public R visitMethodParameters(MethodParameters_attribute attr, P p) { return null; }
+    public R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p) { return null; }
+    public R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p) { return null; }
+    public R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p) { return null; }
+    public R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p) { return null; }
+    public R visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, P p) { return null; }
+    public R visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, P p) { return null; }
+    public R visitSignature(Signature_attribute attr, P p) { return null; }
+    public R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p) { return null; }
+    public R visitSourceFile(SourceFile_attribute attr, P p) { return null; }
+    public R visitSourceID(SourceID_attribute attr, P p) { return null; }
+    public R visitStackMap(StackMap_attribute attr, P p) { return null; }
+    public R visitStackMapTable(StackMapTable_attribute attr, P p) { return null; }
+    public R visitSynthetic(Synthetic_attribute attr, P p) { return null; }
+}
diff --git a/test/tools/javac/MethodParameters/ClassFileVisitor.java b/test/tools/javac/MethodParameters/ClassFileVisitor.java
new file mode 100644
index 0000000..777a552
--- /dev/null
+++ b/test/tools/javac/MethodParameters/ClassFileVisitor.java
@@ -0,0 +1,390 @@
+/*
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/**
+ * The {@code ClassFileVisitor} reads a class file using the
+ * {@code com.sun.tools.classfile} library. It iterates over the methods
+ * in a class, and checks MethodParameters attributes against JLS
+ * requirements, as well as assumptions about the javac implementations.
+ * <p>
+ * It enforces the following rules:
+ * <ul>
+ * <li>All non-synthetic methods with arguments must have the
+ * MethodParameters attribute. </li>
+ * <li>At most one MethodParameters attribute per method.</li>
+ * <li>An empty MethodParameters attribute is not allowed (i.e. no
+ * attribute for methods taking no parameters).</li>
+ * <li>The number of recorded parameter names much equal the number
+ * of parameters, including any implicit or synthetic parameters generated
+ * by the compiler.</li>
+ * <li>Although the spec allow recording parameters with no name, the javac
+ * implementation is assumed to record a name for all parameters. That is,
+ * the Methodparameters attribute must record a non-zero, valid constant
+ * pool index for each parameter.</li>
+ * <li>Check presence, expected names (e.g. this$N, $enum$name, ...) and flags
+ * (e.g. ACC_SYNTHETIC, ACC_MANDATED) for compiler generated parameters.</li>
+ * <li>Names of explicit parameters must reflect the names in the Java source.
+ * This is checked by assuming a design pattern where any name is permitted
+ * for the first explicit parameter. For subsequent parameters the following
+ * rule is checked: <i>param[n] == ++param[n-1].charAt(0) + param[n-1]</i>
+ * </ul>
+ */
+class ClassFileVisitor extends Tester.Visitor {
+
+    Tester tester;
+
+    public String cname;
+    public boolean isEnum;
+    public boolean isInterface;
+    public boolean isInner;
+    public boolean isPublic;
+    public boolean isStatic;
+    public boolean isAnon;
+    public ClassFile classFile;
+
+
+    public ClassFileVisitor(Tester tester) {
+        super(tester);
+    }
+
+    public void error(String msg) {
+        super.error("classfile: " + msg);
+    }
+
+    public void warn(String msg) {
+        super.warn("classfile: " + msg);
+    }
+
+    /**
+     * Read the class and determine some key characteristics, like if it's
+     * an enum, or inner class, etc.
+     */
+    void visitClass(final String cname, final File cfile, final StringBuilder sb)
+        throws Exception {
+        this.cname = cname;
+        classFile = ClassFile.read(cfile);
+        isEnum = classFile.access_flags.is(AccessFlags.ACC_ENUM);
+        isInterface = classFile.access_flags.is(AccessFlags.ACC_INTERFACE);
+        isPublic = classFile.access_flags.is(AccessFlags.ACC_PUBLIC);
+        isInner = false;
+        isStatic = true;
+        isAnon = false;
+
+        Attribute attr = classFile.getAttribute("InnerClasses");
+        if (attr != null) attr.accept(new InnerClassVisitor(), null);
+        isAnon = isInner & isAnon;
+
+        sb.append(isStatic ? "static " : "")
+            .append(isPublic ? "public " : "")
+            .append(isEnum ? "enum " : isInterface ? "interface " : "class ")
+            .append(cname).append(" -- ")
+            .append(isInner? "inner " : "" )
+            .append(isAnon ?  "anon" : "")
+            .append("\n");;
+
+        for (Method method : classFile.methods) {
+            new MethodVisitor().visitMethod(method, sb);
+        }
+    }
+
+    /**
+     * Used to visit InnerClasses_attribute of a class,
+     * to determne if this class is an local class, and anonymous
+     * inner class or a none-static member class. These types of
+     * classes all have an containing class instances field that
+     * requires an implicit or synthetic constructor argument.
+     */
+    class InnerClassVisitor extends AttributeVisitor<Void, Void> {
+        public Void visitInnerClasses(InnerClasses_attribute iattr, Void v) {
+            try{
+                for (InnerClasses_attribute.Info info : iattr.classes) {
+                    if (info.getInnerClassInfo(classFile.constant_pool) == null) continue;
+                    String in = info.getInnerClassInfo(classFile.constant_pool).getName();
+                    if (in == null || !cname.equals(in)) continue;
+                    isInner = true;
+                    isAnon = null == info.getInnerName(classFile.constant_pool);
+                    isStatic = info.inner_class_access_flags.is(AccessFlags.ACC_STATIC);
+                    break;
+                }
+            } catch(Exception e) {
+                throw new IllegalStateException(e);
+            }
+            return null;
+        }
+    }
+
+    /**
+     * Check the MethodParameters attribute of a method.
+     */
+    class MethodVisitor extends AttributeVisitor<Void, StringBuilder> {
+
+        public String mName;
+        public Descriptor mDesc;
+        public int mParams;
+        public int mAttrs;
+        public int mNumParams;
+        public boolean mSynthetic;
+        public boolean mIsConstructor;
+        public boolean mIsBridge;
+        public String prefix;
+
+        void visitMethod(Method method, StringBuilder sb) throws Exception {
+
+            mName = method.getName(classFile.constant_pool);
+            mDesc = method.descriptor;
+            mParams =  mDesc.getParameterCount(classFile.constant_pool);
+            mAttrs = method.attributes.attrs.length;
+            mNumParams = -1; // no MethodParameters attribute found
+            mSynthetic = method.access_flags.is(AccessFlags.ACC_SYNTHETIC);
+            mIsConstructor = mName.equals("<init>");
+            prefix = cname + "." + mName + "() - ";
+            mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE);
+
+            sb.append(cname).append(".").append(mName).append("(");
+
+            for (Attribute a : method.attributes) {
+                a.accept(this, sb);
+            }
+            if (mNumParams == -1) {
+                if (mSynthetic) {
+                    sb.append("<none>)!!");
+                } else {
+                    sb.append("<none>)");
+                }
+            }
+            sb.append("\n");
+
+            // IMPL: methods with arguments must have a MethodParameters
+            // attribute, except possibly some synthetic methods.
+            if (mNumParams == -1 && mParams > 0 && ! mSynthetic) {
+                error(prefix + "missing MethodParameters attribute");
+            }
+        }
+
+        public Void visitMethodParameters(MethodParameters_attribute mp,
+                                          StringBuilder sb) {
+
+            // SPEC: At most one MethodParameters attribute allowed
+            if (mNumParams != -1) {
+                error(prefix + "Multiple MethodParameters attributes");
+                return null;
+            }
+
+            mNumParams = mp.method_parameter_table_length;
+
+            // SPEC: An empty attribute is not allowed!
+            if (mNumParams == 0) {
+                error(prefix + "0 length MethodParameters attribute");
+                return null;
+            }
+
+            // SPEC: one name per parameter.
+            if (mNumParams != mParams) {
+                error(prefix + "found " + mNumParams +
+                      " parameters, expected " + mParams);
+                return null;
+            }
+
+            // IMPL: Whether MethodParameters attributes will be generated
+            // for some synthetics is unresolved. For now, assume no.
+            if (mSynthetic) {
+                warn(prefix + "synthetic has MethodParameter attribute");
+            }
+
+            String sep = "";
+            String userParam = null;
+            for (int x = 0; x <  mNumParams; x++) {
+
+                // IMPL: Assume all parameters are named, something.
+                int cpi = mp.method_parameter_table[x].name_index;
+                if (cpi == 0) {
+                    error(prefix + "name expected, param[" + x + "]");
+                    return null;
+                }
+
+                // SPEC: a non 0 index, must be valid!
+                String param = null;
+                try {
+                    param = classFile.constant_pool.getUTF8Value(cpi);
+                    sb.append(sep).append(param);
+                    sep = ", ";
+                } catch(ConstantPoolException e) {
+                    error(prefix + "invalid index " + cpi + " for param["
+                          + x + "]");
+                    return null;
+                }
+
+
+                // Check availability, flags and special names
+                int check = checkParam(mp, param, x, sb);
+                if (check < 0) {
+                    return null;
+                }
+
+                // TEST: check test assumptions about parameter name.
+                // Expected names are calculated starting with the
+                // 2nd explicit (user given) parameter.
+                // param[n] == ++param[n-1].charAt(0) + param[n-1]
+                String expect = null;
+                if (userParam != null) {
+                    char c = userParam.charAt(0);
+                    expect =  (++c) + userParam;
+                }
+                if (check > 0) {
+                    userParam = param;
+                }
+                if (expect != null && !param.equals(expect)) {
+                    error(prefix + "param[" + x + "]='"
+                          + param + "' expected '" + expect + "'");
+                    return null;
+                }
+            }
+            if (mSynthetic) {
+                sb.append(")!!");
+            } else {
+                sb.append(")");
+            }
+            return null;
+        }
+
+        /*
+         * Check a parameter for conformity to JLS and javac specific
+         * assumptions.
+         * Return -1, if an error is detected. Otherwise, return 0, if
+         * the parameter is compiler generated, or 1 for an (presumably)
+         * explicitly declared parameter.
+         */
+        int checkParam(MethodParameters_attribute mp, String param, int index,
+                       StringBuilder sb) {
+
+            boolean synthetic = (mp.method_parameter_table[index].flags
+                                 & AccessFlags.ACC_SYNTHETIC) != 0;
+            boolean mandated = (mp.method_parameter_table[index].flags
+                                & AccessFlags.ACC_MANDATED) != 0;
+
+            // Setup expectations for flags and special names
+            String expect = null;
+            boolean allowMandated = false;
+            boolean allowSynthetic = false;
+            if (mSynthetic || synthetic) {
+                // not an implementation gurantee, but okay for now
+                expect = "arg" + index; // default
+            }
+            if (mIsConstructor) {
+                if (isEnum) {
+                    if (index == 0) {
+                        expect = "\\$enum\\$name";
+                        allowSynthetic = true;
+                    } else if(index == 1) {
+                        expect = "\\$enum\\$ordinal";
+                        allowSynthetic = true;
+                    }
+                } else if (index == 0) {
+                    if (isAnon) {
+                        allowMandated = true;
+                        expect = "this\\$[0-n]*";
+                    } else if (isInner && !isStatic) {
+                        allowMandated = true;
+                        if (!isPublic) {
+                            // some but not all non-public inner classes
+                            // have synthetic argument. For now we give
+                            // the test a bit of slack and allow either.
+                            allowSynthetic = true;
+                        }
+                        expect = "this\\$[0-n]*";
+                    }
+                }
+            } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) {
+                expect = "name";
+                allowMandated = true;
+            } else if (mIsBridge) {
+                allowSynthetic = true;
+                /*  you can't expect an special name for bridges' parameters.
+                 *  The name of the original parameters are now copied.
+                 */
+                expect = null;
+            }
+            if (mandated) sb.append("!");
+            if (synthetic) sb.append("!!");
+
+            // IMPL: our rules a somewhat fuzzy, sometimes allowing both mandated
+            // and synthetic. However, a parameters cannot be both.
+            if (mandated && synthetic) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" ACC_SYNTHETIC and ACC_MANDATED");
+                return -1;
+            }
+            // ... but must be either, if both "allowed".
+            if (!(mandated || synthetic) && allowMandated && allowSynthetic) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" expected ACC_MANDATED or ACC_SYNTHETIC");
+                return -1;
+            }
+
+            // ... if only one is "allowed", we meant "required".
+            if (!mandated && allowMandated && !allowSynthetic) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" expected ACC_MANDATED");
+                return -1;
+            }
+            if (!synthetic && !allowMandated && allowSynthetic) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" expected ACC_SYNTHETIC");
+                return -1;
+            }
+
+            // ... and not "allowed", means prohibited.
+            if (mandated && !allowMandated) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" unexpected, is ACC_MANDATED");
+                return -1;
+            }
+            if (synthetic && !allowSynthetic) {
+                error(prefix + "param[" + index + "] == \"" + param
+                      + "\" unexpected, is ACC_SYNTHETIC");
+                return -1;
+            }
+
+            // Test special name expectations
+            if (expect != null) {
+                if (param.matches(expect)) {
+                    return 0;
+                }
+                error(prefix + "param[" + index + "]='" + param +
+                      "' expected '" + expect + "'");
+                return -1;
+            }
+
+            // No further checking for synthetic methods.
+            if (mSynthetic) {
+                return 0;
+            }
+
+            // Otherwise, do check test parameter naming convention.
+            return 1;
+        }
+    }
+}
diff --git a/test/tools/javac/MethodParameters/Constructors.java b/test/tools/javac/MethodParameters/Constructors.java
new file mode 100644
index 0000000..a4428d4
--- /dev/null
+++ b/test/tools/javac/MethodParameters/Constructors.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters Constructors.java
+ * @run main Tester Constructors
+ */
+
+public class Constructors {
+    public Constructors() {}
+    Constructors(final Object a, final String... ba) { }
+    protected Constructors(Object a, final Object ba, final String... cba) { }
+    private Constructors(int a, Object ba, final Object cba, final String... dcba) { }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/EnumTest.java b/test/tools/javac/MethodParameters/EnumTest.java
new file mode 100644
index 0000000..2f6cde3
--- /dev/null
+++ b/test/tools/javac/MethodParameters/EnumTest.java
@@ -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 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters EnumTest.java
+ * @run main Tester EnumTest
+ */
+
+/** Test that parameter names are recorded for enum methods */
+enum EnumTest {
+    E1(0), E2(1, "x"), E3(2, "x", "y"), E4;
+
+    EnumTest() { }
+    EnumTest(int a, String... ba) { }
+    boolean ok(int c, String... dc) { return true; }
+
+    int valueOf(EnumTest A, EnumTest BA) { return 0; }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/InstanceMethods.java b/test/tools/javac/MethodParameters/InstanceMethods.java
new file mode 100644
index 0000000..d3c87b5
--- /dev/null
+++ b/test/tools/javac/MethodParameters/InstanceMethods.java
@@ -0,0 +1,46 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters InstanceMethods.java
+ * @run main Tester InstanceMethods
+ */
+
+public class InstanceMethods {
+    public void empty() {}
+    final void def(Object a, final Object ba, final String... cba) { }
+    final public void pub(Object d, final Object ed, final String... fed) { }
+    protected boolean prot(Object g, final Object hg, final String... ihg) { return true; }
+    private boolean priv(Object j, final Object kj, final String... lkj) { return true; }
+    void def(int A, Object BA, final Object CBA, final String... DCBA) { }
+    public void pub(int B, Object CB, final Object DCB, final String... EDCB) { }
+    final protected boolean prot(int C, Object DC, final Object EDC, final String... FEDC) { return true; }
+    final private boolean priv(int D, Object ED, final Object FED, final String... GFED) { return true; }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/LambdaTest.java b/test/tools/javac/MethodParameters/LambdaTest.java
new file mode 100644
index 0000000..931b151
--- /dev/null
+++ b/test/tools/javac/MethodParameters/LambdaTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters LambdaTest.java
+ * @run main Tester LambdaTest
+ */
+
+/**
+ * Parameter names are not recorded for lambdas. This test verifies
+ * that there are no MethodParameters attribute for lambdas.
+ */
+class LambdaTest {
+
+    interface I {
+        int m(int x);
+    }
+
+    static int foo(I i) { return i.m(0); }
+
+    static {
+        foo((int x1) -> { return foo((int x2) -> { return x1 + x2; }); });
+    }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/LocalClassTest.java b/test/tools/javac/MethodParameters/LocalClassTest.java
new file mode 100644
index 0000000..101b276
--- /dev/null
+++ b/test/tools/javac/MethodParameters/LocalClassTest.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters LocalClassTest.java
+ * @run main Tester LocalClassTest
+ */
+
+class LocalClassTest {
+    void foo() {
+        class Local_default_constructor {
+            public void foo() {}
+            public void foo(int m, int nm) {}
+        }
+        class Local_has_constructor {
+            public Local_has_constructor() {}
+            public Local_has_constructor(int a, int ba) {}
+            public void foo() {}
+            public void foo(int m, int nm) {}
+        }
+        new LocalClassTest().foo();
+    }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/MemberClassTest.java b/test/tools/javac/MethodParameters/MemberClassTest.java
new file mode 100644
index 0000000..69482d7
--- /dev/null
+++ b/test/tools/javac/MethodParameters/MemberClassTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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 8006582 8008658
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters MemberClassTest.java
+ * @run main Tester MemberClassTest
+ */
+
+class MemberClassTest {
+
+    interface I {
+        Long m();
+        Long m(Long x, Long yx);
+    }
+
+    public class Member implements I {
+        public class Member_Member {
+            public Member_Member() {}
+            public Member_Member(String x, String yx) {}
+        }
+
+        public Member()  { }
+        public Member(Long a, Long ba)  { }
+        public Long m() { return 0L; }
+        public Long m(Long s, Long ts) { return 0L; }
+    }
+
+    static class Static_Member implements I {
+        public class Static_Member_Member {
+            public Static_Member_Member() {}
+            public Static_Member_Member(String x, String yx) {}
+        }
+
+        public static class Static_Member_Static_Member {
+            public Static_Member_Static_Member() {}
+            public Static_Member_Static_Member(String x, String yx) {}
+        }
+        public Static_Member()  { }
+        public Static_Member(Long arg, Long barg)  { }
+        public Long m() { return 0L; }
+        public Long m(Long s, Long ts) { return s + ts; }
+    }
+
+    public MemberClassTest() {
+    }
+    public MemberClassTest(final Long a, Long ba) {
+    }
+
+    public void foo() {
+
+        new I() {
+
+            class Anonymous_Member {
+                public Anonymous_Member() {}
+                public Anonymous_Member(String x, String yx) {}
+            }
+
+            public Long m() { return 0L; }
+            public Long m(Long s, Long ts) { return s + ts; }
+        }.m();
+    }
+}
diff --git a/test/tools/javac/MethodParameters/ReflectionVisitor.java b/test/tools/javac/MethodParameters/ReflectionVisitor.java
new file mode 100644
index 0000000..841e70c
--- /dev/null
+++ b/test/tools/javac/MethodParameters/ReflectionVisitor.java
@@ -0,0 +1,265 @@
+/*
+ * 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.io.*;
+import java.lang.reflect.*;
+
+/**
+ * Test MethodParameter attributs by reflection API
+ */
+public class ReflectionVisitor extends Tester.Visitor {
+
+    public ReflectionVisitor(Tester tester) {
+        super(tester);
+    }
+
+    public void error(String msg) {
+        super.error("reflection: " + msg);
+    }
+
+    public void warn(String msg) {
+        super.warn("reflection: " + msg);
+    }
+
+    boolean isEnum;
+    boolean isInterface;
+    boolean isAnon;
+    boolean isLocal;
+    boolean isMember;
+    boolean isStatic;
+    boolean isPublic;
+    Class clazz;
+    StringBuilder sb;
+
+    /**
+     * Read class using {@code ClassFile}, and generate a list of methods
+     * with parameter names as available in the MethodParameters attribute.
+     */
+    void visitClass(final String cl, final File cfile, final StringBuilder sb)
+        throws Exception {
+
+        this.sb = sb;
+        clazz = Class.forName(cl);
+        isEnum = clazz.isEnum();
+        isInterface = clazz.isInterface();
+        isAnon = clazz.isAnonymousClass();
+        isLocal = clazz.isLocalClass();
+        isMember = clazz.isMemberClass();
+        isStatic = ((clazz.getModifiers() & Modifier.STATIC) != 0);
+        isPublic = ((clazz.getModifiers() & Modifier.PUBLIC) != 0);
+
+        sb.append(isStatic ? "static " : "")
+            .append(isPublic ? "public " : "")
+            .append(isEnum ? "enum " : isInterface ? "interface " : "class ")
+            .append(cl).append(" -- ")
+            .append(isMember? "member " : "" )
+            .append(isLocal? "local " : "" )
+            .append(isAnon ?  "anon" : "")
+            .append("\n");
+
+        for (Constructor c : clazz.getDeclaredConstructors()) {
+            testConstructor(c);
+        }
+
+        for (Method m :clazz.getDeclaredMethods()) {
+
+            testMethod(m);
+        }
+    }
+
+    void testConstructor(Constructor c) {
+
+        String prefix = clazz.getName() + "." + c.getName() + "() - ";
+
+        // Parameters must match parameter types
+        Parameter params[] = c.getParameters();
+        int paramTypes =  c.getParameterTypes().length;
+        if (paramTypes != params.length) {
+            error(prefix + "number of parameter types (" + paramTypes
+                  + ") != number of parameters (" + params.length + ")");
+            return;
+        }
+
+        sb.append(clazz.getName()).append(".").append("<init>").append("(");
+        String sep = "";
+
+        // Some paramters are expected
+        if (params.length < 2 && isEnum) {
+            error(prefix + "enum constuctor, two arguments expected");
+        } else if (params.length < 1 && (isAnon || isLocal ||
+                                         (isMember && !isStatic ))) {
+            error(prefix + "class constuctor,expected implicit argument");
+        }
+
+        int i = -1;
+        String param = null;
+        for (Parameter p : c.getParameters()) {
+            i++;
+            String pname = p.getName();
+            sb.append(sep).append(pname);
+            if (p.isImplicit()) sb.append("!");
+            if (p.isSynthetic()) sb.append("!!");
+            sep = ", ";
+
+            // Set expectations
+            String expect = null;
+            boolean allowImplicit = false;
+            boolean allowSynthetic = false;
+            if (isEnum) {
+                if (i == 0) {
+                    expect = "\\$enum\\$name";
+                    allowSynthetic = true;
+                } else if(i == 1) {
+                    expect = "\\$enum\\$ordinal";
+                    allowSynthetic = true;
+                }
+            } else if (i == 0) {
+                if (isAnon) {
+                    allowImplicit = true;
+                } else if (isLocal) {
+                    allowImplicit = true;
+                    expect = "this\\$[0-n]*";
+                } else if ((isMember && !isStatic)) {
+                    allowImplicit = true;
+                    if (!isPublic) {
+                        // some but not all non-public inner classes
+                        // have synthetic argument. For now we give
+                        // the test a bit of slack and allow either.
+                        allowSynthetic = true;
+                    }
+                    expect = "this\\$[0-n]*";
+                }
+            }
+
+            // Check expected flags
+            if (p.isSynthetic() && p.isImplicit()) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' both isImplicit() and isSynthetic()");
+                break;
+            }
+            if (allowImplicit && allowSynthetic &&
+                !(p.isSynthetic() || p.isImplicit())) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' isImplicit() or isSynthetic() expected");
+                break;
+            }
+
+            if (allowImplicit && !allowSynthetic && !p.isImplicit()) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' isImplicit() expected");
+                break;
+            }
+            if (!allowImplicit && allowSynthetic && !p.isSynthetic()) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' isSynthetic() expected");
+                break;
+            }
+
+            if (!allowImplicit && p.isImplicit()) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' isImplicit() unexpected");
+                break;
+            }
+
+            if (!allowSynthetic && p.isSynthetic()) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' isSynthetic() unexpected");
+                break;
+            }
+
+            // Check expected names
+            if (expect != null) {
+                if (pname.matches(expect))  continue;
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' expected '" + expect + "'");
+                break;
+            }
+
+            // Test naming convention for explicit parameters.
+            boolean fidelity = !isAnon;
+            if (param != null && fidelity) {
+                char ch = param.charAt(0);
+                expect =  (++ch) + param;
+            }
+
+            if (pname != null && fidelity) {
+                param = pname;
+            }
+
+            if (expect != null && !expect.equals(pname)) {
+                error(prefix + "param[" + i + "]='" + pname +
+                      "' expected '" + expect + "'");
+                break;
+            }
+        }
+        if  (c.isSynthetic()) {
+            sb.append(")!!\n");
+        } else {
+            sb.append(")\n");
+        }
+    }
+
+    void testMethod(Method m) {
+
+        String prefix = clazz.getName() + "." + m.getName() + "() - ";
+
+        // Parameters must match parameter types
+        int paramTypes =  m.getParameterTypes().length;
+        int params = m.getParameters().length;
+        if (paramTypes != params) {
+            error(prefix + "number of parameter types (" + paramTypes
+                  + ") != number of parameters (" + params + ")");
+            return;
+        }
+
+        sb.append(clazz.getName()).append(".").append(m.getName()).append("(");
+        String sep = "";
+        String param = null;
+        int i = -1;
+        // For methods we expect all parameters to follow
+        // the test-case design pattern, except synthetic methods.
+        for (Parameter p : m.getParameters()) {
+            i++;
+            if (param == null) {
+                param = p.getName();
+                sb.append(sep).append(param);
+            } else  {
+                char c = param.charAt(0);
+                String expect =  m.isSynthetic() ? ("arg" + i) : ((++c) + param);
+                param = p.getName();
+                sb.append(sep).append(param);
+                if (!m.isBridge() && !expect.equals(param)) {
+                    error(prefix + "param[" + i + "]='"
+                          + param + "' expected '" + expect + "'");
+                    break;
+                }
+            }
+            sep = ", ";
+        }
+        if  (m.isSynthetic()) {
+            sb.append(")!!\n");
+        } else {
+            sb.append(")\n");
+        }
+    }
+}
diff --git a/test/tools/javac/MethodParameters/StaticMethods.java b/test/tools/javac/MethodParameters/StaticMethods.java
new file mode 100644
index 0000000..5e1ade4
--- /dev/null
+++ b/test/tools/javac/MethodParameters/StaticMethods.java
@@ -0,0 +1,46 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters StaticMethods.java
+ * @run main Tester StaticMethods
+ */
+
+public class StaticMethods {
+    static public void empty() {}
+    static final void def(Object a, final Object ba, final String... cba) { }
+    static final public void pub(Object d, final Object ed, final String... fed) { }
+    static protected boolean prot(Object g, final Object hg, final String... ihg) { return true; }
+    static private boolean priv(Object j, final Object kj, final String... lkj) { return true; }
+    static void def(int a, Object ba, final Object cba, final String... dcba) { }
+    static public void pub(int a, Object ba, final Object cba , final String... dcba) { }
+    static final protected boolean prot(int aa, Object baa, final Object cbaa, final String... dcbaa) { return true; }
+    static final private boolean priv(int abc, Object babc, final Object cbabc, final String... dcbabc) { return true; }
+}
+
+
+
diff --git a/test/tools/javac/MethodParameters/Tester.java b/test/tools/javac/MethodParameters/Tester.java
new file mode 100644
index 0000000..84b2ddd
--- /dev/null
+++ b/test/tools/javac/MethodParameters/Tester.java
@@ -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.
+ */
+
+import java.io.*;
+import java.lang.reflect.Constructor;
+
+/**
+ * Test driver for MethodParameters testing.
+ * <p>
+ * The intended use of this driver is to run it, giving the name of
+ * a single class compiled with -parameters as argument. The driver
+ * will test the specified class, and any nested classes it finds.
+ * <p>
+ * Each class is tested in two way. By refelction, and by directly
+ * checking MethodParameters attributes in the classfile. The checking
+ * is done using two visitor classes {@link ClassFileVisitor} and
+ * {@link ReflectionVisitor}.
+ * <p>
+ * The {@code ReflectionVisitor} test logically belongs with library tests.
+ * we wish to reuse the same test-cases, so both test are committed together,
+ * under langtools. The tests, may be duplicated in the jdk repository.
+ */
+public class Tester {
+
+    final static File classesdir = new File(System.getProperty("test.classes", "."));
+
+    /**
+     * The visitor classes that does the actual checking are referenced
+     * statically, to force compilations, without having to reference
+     * them in individual test cases.
+     * <p>
+     * This makes it easy to change the set of visitors, without
+     * complicating the design with dynamic discovery and compilation
+     * of visitor classes.
+     */
+    static final Class visitors[] = {
+        ClassFileVisitor.class,
+        ReflectionVisitor.class
+    };
+
+    /**
+     * Test-driver expect a single classname as argument.
+     */
+    public static void main(String... args) throws Exception {
+        if (args.length != 1) {
+            throw new Error("A single class name is expected as argument");
+        }
+        final String pattern = args[0] + ".*\\.class";
+        File files[] = classesdir.listFiles(new FileFilter() {
+                public boolean accept(File f) {
+                    return f.getName().matches(pattern);
+                }
+            });
+        if (files.length == 0) {
+            File file = new File(classesdir, args[0] + ".class");
+            throw new Error(file.getPath() + " not found");
+        }
+
+        new Tester(args[0], files).run();
+    }
+
+    public Tester(String name, File files[]) {
+        this.classname = name;
+        this.files = files;
+    }
+
+    void run() throws Exception {
+
+        // Test with each visitor
+        for (Class<Visitor> vclass : visitors) {
+            try {
+                String vname = vclass.getName();
+                Constructor c = vclass.getConstructor(Tester.class);
+
+                info("\nRun " + vname + " for " + classname + "\n");
+                StringBuilder sb = new StringBuilder();
+                for (File f : files) {
+                    String fname = f.getName();
+                    fname = fname.substring(0, fname.length() - 6);
+                    Visitor v = (Visitor) c.newInstance(this);
+                    try {
+                        v.visitClass(fname, f,  sb);
+                    } catch(Exception e) {
+                        error("Uncaught exception in visitClass()");
+                        e.printStackTrace();
+                    }
+                }
+                info(sb.toString());
+            } catch(ReflectiveOperationException e) {
+                warn("Class " + vclass.getName() + " ignored, not a Visitor");
+                continue;
+            }
+        }
+
+        if(0 != warnings)
+                System.err.println("Test generated " + warnings + " warnings");
+
+        if(0 != errors)
+            throw new Exception("Tester test failed with " +
+                                errors + " errors");
+    }
+
+    abstract static  class Visitor {
+        Tester tester;
+        File classesdir;
+
+        public Visitor(Tester tester) {
+            this.tester = tester;
+        }
+
+        abstract void visitClass(final String classname, final File  cfile,
+                final StringBuilder sb) throws Exception;
+
+        public void error(String msg) {
+            tester.error(msg);
+        }
+
+        public void warn(String msg) {
+            tester.warn(msg);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    void warn(String msg) {
+        System.err.println("Warning: " + msg);
+        warnings++;
+    }
+
+    void info(String msg) {
+        System.out.println(msg);
+    }
+
+    int errors;
+    int warnings;
+    String classname;
+    File files[];
+}
diff --git a/test/tools/javac/MethodParameters/UncommonParamNames.java b/test/tools/javac/MethodParameters/UncommonParamNames.java
new file mode 100644
index 0000000..62534d6
--- /dev/null
+++ b/test/tools/javac/MethodParameters/UncommonParamNames.java
@@ -0,0 +1,68 @@
+/*
+ * 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 8006582
+ * @summary javac should generate method parameters correctly.
+ * @build Tester
+ * @compile -parameters UncommonParamNames.java
+ * @run main Tester UncommonParamNames
+ */
+
+/** Test uncommon parameter names */
+class UncommonParamNames {
+    public UncommonParamNames(int _x) { }
+    public UncommonParamNames(short $1) { }
+    public UncommonParamNames(long \u0061) { }
+    public UncommonParamNames(char zero\u0000zero\u0000) { }
+    public UncommonParamNames(String zero\u0000zero\u0000seven\u0007) { }
+    public UncommonParamNames(Object zero\u0000zero\u0000eight\u0008) { }
+    public UncommonParamNames(Object aLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+                              Object baLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+                              Object cbaLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName) { }
+    public UncommonParamNames(int a, int ba, int cba, int dcba, int edcba, int fedcba, int gfedcba,
+                              int hgfedcba, int ihgfedcba, int jihgfedcba, int kjihgfedcba, int lkjihgfedcba,
+                              int mlkjihgfedcba, int nmlkjihgfedcba, int onmlkjihgfedcba, int ponmlkjihgfedcba,
+                              int qponmlkjihgfedcba, int rqponmlkjihgfedcba, int srqponmlkjihgfedcba,
+                              int tsrqponmlkjihgfedcba, int utsrqponmlkjihgfedcba, int vutsrqponmlkjihgfedcba,
+                              int wvutsrqponmlkjihgfedcba, int xwvutsrqponmlkjihgfedcba,
+                              int yxwvutsrqponmlkjihgfedcba, int zyxwvutsrqponmlkjihgfedcba) { }
+
+    public void foo(int _x) { }
+    public void foo(short $1) { }
+    public void foo(long \u0061) { }
+    public void foo(char zero\u0000zero\u0000) { }
+    public void foo(String zero\u0000zero\u0000seven\u0007) { }
+    public void foo(Object zero\u0000zero\u0000eight\u0008) { }
+    public void foo(Object aLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+                    Object baLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName,
+                    Object cbaLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongName) { }
+    public void foo(int a, int ba, int cba, int dcba, int edcba, int fedcba, int gfedcba,
+                    int hgfedcba, int ihgfedcba, int jihgfedcba, int kjihgfedcba, int lkjihgfedcba,
+                    int mlkjihgfedcba, int nmlkjihgfedcba, int onmlkjihgfedcba, int ponmlkjihgfedcba,
+                    int qponmlkjihgfedcba, int rqponmlkjihgfedcba, int srqponmlkjihgfedcba,
+                    int tsrqponmlkjihgfedcba, int utsrqponmlkjihgfedcba, int vutsrqponmlkjihgfedcba,
+                    int wvutsrqponmlkjihgfedcba, int xwvutsrqponmlkjihgfedcba,
+                    int yxwvutsrqponmlkjihgfedcba, int zyxwvutsrqponmlkjihgfedcba) { }
+}
diff --git a/test/tools/javac/MethodParametersTest.java b/test/tools/javac/MethodParametersTest.java
new file mode 100644
index 0000000..515eee3
--- /dev/null
+++ b/test/tools/javac/MethodParametersTest.java
@@ -0,0 +1,344 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8004727
+ * @summary javac should generate method parameters correctly.
+ */
+// key: opt.arg.parameters
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import java.io.*;
+import javax.lang.model.element.*;
+import java.util.*;
+
+public class MethodParametersTest {
+
+    static final String Foo_name = "Foo";
+    static final String Foo_contents =
+        "public class Foo {\n" +
+        "  Foo() {}\n" +
+        "  void foo0() {}\n" +
+        "  void foo2(int j, int k) {}\n" +
+        "}";
+    static final String Bar_name = "Bar";
+    static final String Bar_contents =
+        "public class Bar {\n" +
+        "  Bar(int i) {}" +
+        "  Foo foo() { return new Foo(); }\n" +
+        "}";
+    static final String Baz_name = "Baz";
+    static final String Baz_contents =
+        "public class Baz {\n" +
+        "  int baz;" +
+        "  Baz(int i) {}" +
+        "}";
+    static final String Qux_name = "Qux";
+    static final String Qux_contents =
+        "public class Qux extends Baz {\n" +
+        "  Qux(int i) { super(i); }" +
+        "}";
+    static final File classesdir = new File("methodparameters");
+
+    public static void main(String... args) throws Exception {
+        new MethodParametersTest().run();
+    }
+
+    void run() throws Exception {
+        classesdir.mkdir();
+        final File Foo_java =
+            writeFile(classesdir, Foo_name + ".java", Foo_contents);
+        final File Bar_java =
+            writeFile(classesdir, Bar_name + ".java", Bar_contents);
+        final File Baz_java =
+            writeFile(classesdir, Baz_name + ".java", Baz_contents);
+        System.err.println("Test compile with -parameter");
+        compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
+        // First test: make sure javac doesn't choke to death on
+        // MethodParameter attributes
+        System.err.println("Test compile with classfile containing MethodParameter attributes");
+        compile("-parameters", "-d", classesdir.getPath(),
+                "-cp", classesdir.getPath(), Bar_java.getPath());
+        System.err.println("Examine class foo");
+        checkFoo();
+        checkBar();
+        System.err.println("Test debug information conflict");
+        compile("-g", "-parameters", "-d", classesdir.getPath(),
+                "-cp", classesdir.getPath(), Baz_java.getPath());
+        System.err.println("Introducing debug information conflict");
+        Baz_java.delete();
+        modifyBaz(false);
+        System.err.println("Checking language model");
+        inspectBaz();
+        System.err.println("Permuting attributes");
+        modifyBaz(true);
+        System.err.println("Checking language model");
+        inspectBaz();
+
+        if(0 != errors)
+            throw new Exception("MethodParameters test failed with " +
+                                errors + " errors");
+    }
+
+    void inspectBaz() throws Exception {
+        final File Qux_java =
+            writeFile(classesdir, Qux_name + ".java", Qux_contents);
+        final String[] args = { "-XDsave-parameter-names", "-d",
+                                classesdir.getPath(),
+                                "-cp", classesdir.getPath(),
+                                Qux_java.getPath() };
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+
+        // We need to be able to crack open javac and look at its data
+        // structures.  We'll rig up a compiler instance, but keep its
+        // Context, thus allowing us to get at the ClassReader.
+        Context context = new Context();
+        Main comp =  new Main("javac", pw);
+        JavacFileManager.preRegister(context);
+
+        // Compile Qux, which uses Baz.
+        comp.compile(args, context);
+        pw.close();
+        final String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+
+        // Now get the class reader, construct a name for Baz, and load it.
+        com.sun.tools.javac.jvm.ClassReader cr =
+            com.sun.tools.javac.jvm.ClassReader.instance(context);
+        Name name = Names.instance(context).fromString(Baz_name);
+
+        // Now walk down the language model and check the name of the
+        // parameter.
+        final Element baz = cr.loadClass(name);
+        for (Element e : baz.getEnclosedElements()) {
+            if (e instanceof ExecutableElement) {
+                final ExecutableElement ee = (ExecutableElement) e;
+                final List<? extends VariableElement> params =
+                    ee.getParameters();
+                if (1 != params.size())
+                    throw new Exception("Classfile Baz badly formed: wrong number of methods");
+                final VariableElement param = params.get(0);
+                if (!param.getSimpleName().contentEquals("baz")) {
+                    errors++;
+                    System.err.println("javac did not correctly resolve the metadata conflict, parameter's name reads as " + param.getSimpleName());
+                } else
+                    System.err.println("javac did correctly resolve the metadata conflict");
+            }
+        }
+    }
+
+    void modifyBaz(boolean flip) throws Exception {
+        final File Baz_class = new File(classesdir, Baz_name + ".class");
+        final ClassFile baz = ClassFile.read(Baz_class);
+        final int ind = baz.constant_pool.getUTF8Index("baz");
+        MethodParameters_attribute mpattr = null;
+        int mpind = 0;
+        Code_attribute cattr = null;
+        int cind = 0;
+
+        // Find the indexes of the MethodParameters and the Code attributes
+        if (baz.methods.length != 1)
+            throw new Exception("Classfile Baz badly formed: wrong number of methods");
+        if (!baz.methods[0].getName(baz.constant_pool).equals("<init>"))
+            throw new Exception("Classfile Baz badly formed: method has name " +
+                                baz.methods[0].getName(baz.constant_pool));
+        for (int i = 0; i < baz.methods[0].attributes.attrs.length; i++) {
+            if (baz.methods[0].attributes.attrs[i] instanceof
+                MethodParameters_attribute) {
+                mpattr = (MethodParameters_attribute)
+                    baz.methods[0].attributes.attrs[i];
+                mpind = i;
+            } else if (baz.methods[0].attributes.attrs[i] instanceof
+                       Code_attribute) {
+                cattr = (Code_attribute) baz.methods[0].attributes.attrs[i];
+                cind = i;
+            }
+        }
+        if (null == mpattr)
+            throw new Exception("Classfile Baz badly formed: no method parameters info");
+        if (null == cattr)
+            throw new Exception("Classfile Baz badly formed: no local variable table");
+
+        int flags = mpattr.method_parameter_table[0].flags;
+
+        // Alter the MethodParameters attribute, changing the name of
+        // the parameter from i to baz.  This requires Black Magic...
+        //
+        // The (well-designed) classfile library (correctly) does not
+        // allow us to mess around with the attribute data structures,
+        // or arbitrarily generate new ones.
+        //
+        // Instead, we install a new subclass of Attribute that
+        // hijacks the Visitor pattern and outputs the sequence of
+        // bytes that we want.  This only works in this particular
+        // instance, because we know we'll only every see one kind of
+        // visitor.
+        //
+        // If anyone ever changes the makeup of the Baz class, or
+        // tries to install some kind of visitor that gets run prior
+        // to serialization, this will break.
+        baz.methods[0].attributes.attrs[mpind] =
+            new Attribute(mpattr.attribute_name_index,
+                          mpattr.attribute_length) {
+                public <R, D> R accept(Visitor<R, D> visitor, D data) {
+                    if (data instanceof ByteArrayOutputStream) {
+                        ByteArrayOutputStream out =
+                            (ByteArrayOutputStream) data;
+                        out.write(1);
+                        out.write((ind >> 8) & 0xff);
+                        out.write(ind & 0xff);
+                        out.write((flags >> 24) & 0xff);
+                        out.write((flags >> 16) & 0xff);
+                        out.write((flags >> 8) & 0xff);
+                        out.write(flags & 0xff);
+                    } else
+                        throw new RuntimeException("Output stream is of type " + data.getClass() + ", which is not handled by this test.  Update the test and it should work.");
+                    return null;
+                }
+            };
+
+        // Flip the code and method attributes.  This is for checking
+        // that order doesn't matter.
+        if (flip) {
+            baz.methods[0].attributes.attrs[mpind] = cattr;
+            baz.methods[0].attributes.attrs[cind] = mpattr;
+        }
+
+        new ClassWriter().write(baz, Baz_class);
+    }
+
+    // Run a bunch of structural tests on foo to make sure it looks right.
+    void checkFoo() throws Exception {
+        final File Foo_class = new File(classesdir, Foo_name + ".class");
+        final ClassFile foo = ClassFile.read(Foo_class);
+        for (int i = 0; i < foo.methods.length; i++) {
+            System.err.println("Examine method Foo." + foo.methods[i].getName(foo.constant_pool));
+            if (foo.methods[i].getName(foo.constant_pool).equals("foo2")) {
+                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
+                    if (foo.methods[i].attributes.attrs[j] instanceof
+                        MethodParameters_attribute) {
+                        MethodParameters_attribute mp =
+                            (MethodParameters_attribute)
+                            foo.methods[i].attributes.attrs[j];
+                        System.err.println("Foo.foo2 should have 2 parameters: j and k");
+                        if (2 != mp.method_parameter_table_length)
+                            error("expected 2 method parameter entries in foo2, got " +
+                                  mp.method_parameter_table_length);
+                        else if (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("j"))
+                            error("expected first parameter to foo2 to be \"j\", got \"" +
+                                  foo.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
+                                  "\" instead");
+                        else if  (!foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index).equals("k"))
+                            error("expected first parameter to foo2 to be \"k\", got \"" +
+                                  foo.constant_pool.getUTF8Value(mp.method_parameter_table[1].name_index) +
+                                  "\" instead");
+                    }
+            }
+            else if (foo.methods[i].getName(foo.constant_pool).equals("<init>")) {
+                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++) {
+                    if (foo.methods[i].attributes.attrs[j] instanceof
+                        MethodParameters_attribute)
+                        error("Zero-argument constructor shouldn't have MethodParameters");
+                }
+            }
+            else if (foo.methods[i].getName(foo.constant_pool).equals("foo0")) {
+                for (int j = 0; j < foo.methods[i].attributes.attrs.length; j++)
+                    if (foo.methods[i].attributes.attrs[j] instanceof
+                        MethodParameters_attribute)
+                        error("Zero-argument method shouldn't have MethodParameters");
+            }
+            else
+                error("Unknown method " + foo.methods[i].getName(foo.constant_pool) + " showed up in class Foo");
+        }
+    }
+
+    // Run a bunch of structural tests on Bar to make sure it looks right.
+    void checkBar() throws Exception {
+        final File Bar_class = new File(classesdir, Bar_name + ".class");
+        final ClassFile bar = ClassFile.read(Bar_class);
+        for (int i = 0; i < bar.methods.length; i++) {
+            System.err.println("Examine method Bar." + bar.methods[i].getName(bar.constant_pool));
+            if (bar.methods[i].getName(bar.constant_pool).equals("<init>")) {
+                for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++)
+                    if (bar.methods[i].attributes.attrs[j] instanceof
+                        MethodParameters_attribute) {
+                        MethodParameters_attribute mp =
+                            (MethodParameters_attribute)
+                            bar.methods[i].attributes.attrs[j];
+                        System.err.println("Bar constructor should have 1 parameter: i");
+                        if (1 != mp.method_parameter_table_length)
+                            error("expected 1 method parameter entries in constructor, got " +
+                                  mp.method_parameter_table_length);
+                        else if (!bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index).equals("i"))
+                            error("expected first parameter to foo2 to be \"i\", got \"" +
+                                  bar.constant_pool.getUTF8Value(mp.method_parameter_table[0].name_index) +
+                                  "\" instead");
+                    }
+            }
+            else if (bar.methods[i].getName(bar.constant_pool).equals("foo")) {
+                for (int j = 0; j < bar.methods[i].attributes.attrs.length; j++) {
+                    if (bar.methods[i].attributes.attrs[j] instanceof
+                        MethodParameters_attribute)
+                        error("Zero-argument constructor shouldn't have MethodParameters");
+                }
+            }
+        }
+    }
+
+    String compile(String... args) throws Exception {
+        System.err.println("compile: " + Arrays.asList(args));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            error("compilation failed, rc=" + rc);
+        return out;
+    }
+
+    File writeFile(File dir, String path, String body) throws IOException {
+        File f = new File(dir, path);
+        f.getParentFile().mkdirs();
+        FileWriter out = new FileWriter(f);
+        out.write(body);
+        out.close();
+        return f;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javac/MissingInclude.java b/test/tools/javac/MissingInclude.java
deleted file mode 100644
index ccbeb2c..0000000
--- a/test/tools/javac/MissingInclude.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, 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 4509051 4785453
- * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles doesn't exist.
- * @author gafter
- *
- * @run shell MissingInclude.sh
- */
-
-class MissingInclude {}
diff --git a/test/tools/javac/MissingInclude.sh b/test/tools/javac/MissingInclude.sh
deleted file mode 100644
index f175a50..0000000
--- a/test/tools/javac/MissingInclude.sh
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}MissingInclude.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
-result=$?
-cat ${TMP1}
-rm ${TMP1}
-
-if [ $result -eq 0 ]
-then
-  echo "Failed"
-  exit 1
-else
-  echo "Passed"
-  exit 0
-fi
diff --git a/test/tools/javac/MissingInclude/MissingIncludeTest.java b/test/tools/javac/MissingInclude/MissingIncludeTest.java
new file mode 100644
index 0000000..98f5bc0
--- /dev/null
+++ b/test/tools/javac/MissingInclude/MissingIncludeTest.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 4509051 4785453
+ * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles
+ * doesn't exist.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main MissingIncludeTest
+ */
+
+//original test: test/tools/javac/MissingInclude.sh
+public class MissingIncludeTest {
+
+    private static final String MissingIncludeSrc =
+        "class MissingInclude {}";
+
+    public static void main(String[] args) throws Exception {
+        ToolBox.createJavaFileFromSource(MissingIncludeSrc);
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setAllArgs("@/nonexistent_file", "MissingInclude.java");
+        ToolBox.javac(params);
+    }
+
+}
diff --git a/test/tools/javac/NonAmbiguousField/Test b/test/tools/javac/NonAmbiguousField/Test
deleted file mode 100644
index fb4cfd7..0000000
--- a/test/tools/javac/NonAmbiguousField/Test
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * @test
- * @bug 4053724
- * @summary Certain non-ambiguous field references were reported by the
- *          compiler as ambigous.
- * @author turnidge
- *
- * @compile -nowrite one/Parent.java two/Child.java
- * @compile -nowrite one/Parent2.java two/Child2.java
- */
diff --git a/test/tools/javac/NonAmbiguousField/Test.java b/test/tools/javac/NonAmbiguousField/Test.java
new file mode 100644
index 0000000..131bc87
--- /dev/null
+++ b/test/tools/javac/NonAmbiguousField/Test.java
@@ -0,0 +1,10 @@
+/*
+ * @test
+ * @bug 4053724
+ * @summary Certain non-ambiguous field references were reported by the
+ *          compiler as ambigous.
+ * @author turnidge
+ *
+ * @compile one/Parent.java two/Child.java
+ * @compile/fail one/Parent2.java two/Child2.java
+ */
diff --git a/test/tools/javac/NonAmbiguousField/two/Child2.java b/test/tools/javac/NonAmbiguousField/two/Child2.java
index 64fcc52..13ce68f 100644
--- a/test/tools/javac/NonAmbiguousField/two/Child2.java
+++ b/test/tools/javac/NonAmbiguousField/two/Child2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 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
@@ -28,9 +28,7 @@ interface I {
 }
 
 public class Child2 extends one.Parent2 implements I {
-    class inner {
-        void method() {
-            System.out.println(i);
-        }
+    void method() {
+        System.out.println(i);
     }
 }
diff --git a/test/tools/javac/OverrideChecks/6400189/T6400189a.out b/test/tools/javac/OverrideChecks/6400189/T6400189a.out
index 985ea64..2a12111 100644
--- a/test/tools/javac/OverrideChecks/6400189/T6400189a.out
+++ b/test/tools/javac/OverrideChecks/6400189/T6400189a.out
@@ -1,4 +1,4 @@
 T6400189a.java:14:35: compiler.warn.unchecked.call.mbr.of.raw.type: <T>getAnnotation(java.lang.Class<T>), java.lang.reflect.Constructor
-T6400189a.java:14:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.annotation.Annotation, java.lang.annotation.Documented
+T6400189a.java:14:35: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.annotation.Annotation, java.lang.annotation.Documented)
 1 error
 1 warning
diff --git a/test/tools/javac/OverrideChecks/6400189/T6400189b.out b/test/tools/javac/OverrideChecks/6400189/T6400189b.out
index 1797ef9..904cd3e 100644
--- a/test/tools/javac/OverrideChecks/6400189/T6400189b.out
+++ b/test/tools/javac/OverrideChecks/6400189/T6400189b.out
@@ -1,4 +1,4 @@
 T6400189b.java:24:24: compiler.warn.unchecked.call.mbr.of.raw.type: <T>m(T6400189b<T>), T6400189b.B
-T6400189b.java:24:24: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Object, java.lang.Integer
+T6400189b.java:24:24: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.Integer)
 1 error
 1 warning
diff --git a/test/tools/javac/Paths/TestCompileJARInClassPath.java b/test/tools/javac/Paths/TestCompileJARInClassPath.java
new file mode 100644
index 0000000..96347c2
--- /dev/null
+++ b/test/tools/javac/Paths/TestCompileJARInClassPath.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+/*
+ * @test
+ * @bug 6725230
+ * @summary Test to make sure that java Compilation with JSR199 does not ignore
+ * Class-Path in manifest
+ * @author vicente.romero
+ * @build TestCompileJARInClassPath
+ * @run main TestCompileJARInClassPath
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+public class TestCompileJARInClassPath {
+
+    public static void main(String args[]) throws Exception {
+        TestCompileJARInClassPath theTest = new TestCompileJARInClassPath();
+        theTest.run();
+    }
+
+    void run() throws Exception {
+        try {
+            clean();
+            generateFilesNeeded();
+            compileWithJSR199();
+        } finally {
+            clean();
+        }
+    }
+
+    void writeFile(String f, String contents) throws IOException {
+        PrintStream s = new PrintStream(new FileOutputStream(f));
+        s.println(contents);
+        s.close();
+    }
+
+    void rm(String filename) throws Exception {
+        File f = new File(filename);
+        f.delete();
+        if (f.exists())
+            throw new Exception(filename + ": couldn't remove");
+    }
+
+    void clean() throws Exception {
+        rm("C1.java");
+        rm("C1.class");
+        rm("C1.jar");
+
+        rm("C2.java");
+        rm("C2.class");
+        rm("C2.jar");
+        rm("MANIFEST.MF");
+
+        rm("C3.java");
+        rm("C3.class");
+    }
+
+    void generateFilesNeeded() throws Exception {
+        sun.tools.jar.Main jarGenerator = new sun.tools.jar.Main(System.out, System.err, "jar");
+
+        writeFile("C1.java",
+                  "public class C1 {public static void f() {}}");
+        com.sun.tools.javac.Main.compile(new String[]{"C1.java"});
+        jarGenerator.run(new String[] {"cf", "C1.jar", "C1.class"});
+
+        writeFile("C2.java",
+                  "public class C2 {public static void g() {}}");
+        writeFile("MANIFEST.MF",
+                  "Manifest-Version: 1.0\n" +
+                  "Class-Path: C1.jar\n" +
+                  "Main-Class: C2");
+        com.sun.tools.javac.Main.compile(new String[]{"C2.java"});
+        jarGenerator.run(new String[] {"cfm", "C2.jar", "MANIFEST.MF", "C2.class"});
+
+        writeFile("C3.java",
+                  "public class C3 {public static void h() {C2.g(); C1.f();}}");
+    }
+
+    void compileWithJSR199() throws IOException {
+        String cpath = "C2.jar";
+        File clientJarFile = new File(cpath);
+        File sourceFileToCompile = new File("C3.java");
+
+
+        javax.tools.JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
+        StandardJavaFileManager stdFileManager = javac.getStandardFileManager(diagnostics, null, null);
+
+        List<File> files = new ArrayList<>();
+        files.add(clientJarFile);
+
+        stdFileManager.setLocation(StandardLocation.CLASS_PATH, files);
+
+        Iterable<? extends JavaFileObject> sourceFiles = stdFileManager.getJavaFileObjects(sourceFileToCompile);
+
+        if (!javac.getTask(null, stdFileManager, diagnostics, null, null, sourceFiles).call()) {
+            throw new AssertionError("compilation failed");
+        }
+    }
+}
diff --git a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
deleted file mode 100644
index d06b82a..0000000
--- a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# Copyright (c) 1998, 2009, 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 4087314 4800342
-# @summary Verify allowed access to protected class from another package.
-# @author William Maddox (maddox)
-#
-# @run shell ProtectedInnerClass.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* ) 
-    PS=";" # native PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-rm -f ${TESTCLASSES}${FS}p1${FS}*.class ${TESTCLASSES}${FS}p2${FS}*.class
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
-"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
-result=$?
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
deleted file mode 100644
index dcdccc4..0000000
--- a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000, 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 4307565
- * @summary Verify that access to inaccessable protected inner class is rejected.
- * @author William Maddox (maddox)
- *
- * @run compile p1/ProtectedInnerClass1.java
- * @run compile/fail p2/ProtectedInnerClass3.java
- */
-class Dummy {}
diff --git a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java
new file mode 100644
index 0000000..cbe4c33
--- /dev/null
+++ b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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 4087314 4800342 4307565
+ * @summary Verify allowed access to protected class from another package
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ProtectedInnerClassesTest
+ */
+
+//original tests: test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
+//and test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+public class ProtectedInnerClassesTest {
+
+    private static final String protectedInnerClass1Src =
+        "package p1;\n" +
+        "\n" +
+        "public class ProtectedInnerClass1 {\n" +
+        "    protected class Foo {\n" +
+        "        public String getBar() { return \"bar\"; }\n" +
+        "    }\n" +
+        "}";
+
+    private static final String protectedInnerClass2Src =
+        "package p2;\n" +
+        "\n" +
+        "public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1\n" +
+        "{\n" +
+        "    class Bug extends Foo {\n" +
+        "        String getBug() { return getBar(); }\n" +
+        "    }\n" +
+        "\n" +
+        "    public static void main(String[] args) {\n" +
+        "        ProtectedInnerClass2 x = new ProtectedInnerClass2();\n" +
+        "        Bug y = x.new Bug();\n" +
+        "        System.out.println(y.getBug());\n" +
+        "    }\n" +
+        "}";
+
+    private static final String protectedInnerClass3Src =
+        "package p2;\n" +
+        "\n" +
+        "public class ProtectedInnerClass3 {\n" +
+        "\n" +
+        "  void test() {\n" +
+        "    p1.ProtectedInnerClass1.Foo x;\n" +
+        "  }\n" +
+        "\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        new ProtectedInnerClassesTest().run();
+    }
+
+    void run() throws Exception {
+        compileAndExecute();
+        compileOnly();
+    }
+
+    void compileAndExecute() throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-d", ".")
+                .setSources(protectedInnerClass1Src, protectedInnerClass2Src);
+
+        ToolBox.javac(javacParams);
+
+//"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
+        ToolBox.AnyToolArgs javaParams =
+                new ToolBox.AnyToolArgs()
+                .appendArgs(ToolBox.javaBinary)
+                .appendArgs(ToolBox.testVMOpts)
+                .appendArgs("-classpath", System.getProperty("user.dir"),
+                    "p2.ProtectedInnerClass2");
+        ToolBox.executeCommand(javaParams);
+    }
+
+//from test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+    void compileOnly() throws Exception {
+//@run compile p1/ProtectedInnerClass1.java
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .appendArgs("-d", ".")
+                .setSources(protectedInnerClass1Src);
+
+        ToolBox.javac(javacParams);
+
+//@run compile/fail p2/ProtectedInnerClass3.java
+        javacParams = new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs("-d", ".")
+                .setSources(protectedInnerClass3Src);
+        ToolBox.javac(javacParams);
+    }
+
+}
diff --git a/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java b/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java
deleted file mode 100644
index 82c2c21..0000000
--- a/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- * This file must be compiled prior to compiling p2.ProtectedInnerClass2.
- * It is that compilation that will either succeed or fail.
- */
-
-package p1;
-
-public class ProtectedInnerClass1 {
-    protected class Foo {
-        public String getBar() { return "bar"; }
-    }
-}
diff --git a/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java b/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java
deleted file mode 100644
index 8d86b86..0000000
--- a/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- *
- * This file should compile and run successfully.
- * Note that class p1.ProtectedInnerClass1 must be compiled first.
- */
-
-package p2;
-
-public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
-{
-    class Bug extends Foo {
-        String getBug() { return getBar(); }
-    }
-
-    public static void main(String[] args) {
-        ProtectedInnerClass2 x = new ProtectedInnerClass2();
-        Bug y = x.new Bug();
-        System.out.println(y.getBug());
-    }
-}
diff --git a/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java b/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java
deleted file mode 100644
index b16e78e..0000000
--- a/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2000, 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.
- */
-
-/*
- * Auxiliary file for ProtectedInnerClass_2.java (bugid 4307565)
- */
-
-package p2;
-
-public class ProtectedInnerClass3 {
-
-  void test() {
-    p1.ProtectedInnerClass1.Foo x;
-  }
-
-}
diff --git a/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out b/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out
index 6ed10a4..fb9c64b 100644
--- a/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out
+++ b/test/tools/javac/StringsInSwitch/BadlyTypedLabel1.out
@@ -1,2 +1,2 @@
-BadlyTypedLabel1.java:13:14: compiler.err.prob.found.req: (compiler.misc.incompatible.types), int, java.lang.String
+BadlyTypedLabel1.java:13:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.String)
 1 error
diff --git a/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out b/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out
index 13f5481..1c6a103 100644
--- a/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out
+++ b/test/tools/javac/StringsInSwitch/BadlyTypedLabel2.out
@@ -1,2 +1,2 @@
-BadlyTypedLabel2.java:15:14: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.math.RoundingMode, java.lang.String
+BadlyTypedLabel2.java:15:14: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.math.RoundingMode, java.lang.String)
 1 error
diff --git a/test/tools/javac/StringsInSwitch/StringSwitches.java b/test/tools/javac/StringsInSwitch/StringSwitches.java
index 56b4f93..2e6737e 100644
--- a/test/tools/javac/StringsInSwitch/StringSwitches.java
+++ b/test/tools/javac/StringsInSwitch/StringSwitches.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
diff --git a/test/tools/javac/T4965689/ClassLiteralWastesByteTest.java b/test/tools/javac/T4965689/ClassLiteralWastesByteTest.java
new file mode 100644
index 0000000..6e73192
--- /dev/null
+++ b/test/tools/javac/T4965689/ClassLiteralWastesByteTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 4965689
+ * @summary class literal code wastes a byte
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+
+public class ClassLiteralWastesByteTest {
+
+    private static final String assertionErrorMsg =
+            "Instead of ldc_w, ldc instruction should have been generated";
+
+    public static void main(String[] args) {
+        new ClassLiteralWastesByteTest().run();
+    }
+
+    void run() {
+        check("-c", Paths.get(System.getProperty("test.classes"),
+                "test.class").toString());
+    }
+
+    void check(String... params) {
+        StringWriter s;
+        String out;
+        try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+            com.sun.tools.javap.Main.run(params, pw);
+            out = s.toString();
+        }
+        if (out.contains("ldc_w")) {
+            throw new AssertionError(assertionErrorMsg);
+        }
+    }
+
+}
+
+class test {
+    void m() {
+        Class<?> aClass = test.class;
+    }
+}
diff --git a/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java b/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java
new file mode 100644
index 0000000..7b3027f
--- /dev/null
+++ b/test/tools/javac/T5053846/MethodRefDupInConstantPoolTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 5053846 8011432
+ * @summary javac: MethodRef entries are duplicated in the constant pool
+ * @summary javac, compiler regression iterable + captured type
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+import java.util.*;
+
+public class MethodRefDupInConstantPoolTest {
+
+    private static final String methodToLookFor =
+            "java/util/Vector.iterator:()Ljava/util/Iterator;";
+
+    public static void main(String[] args) {
+        new MethodRefDupInConstantPoolTest().run();
+    }
+
+    void run() {
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper1.class").toString());
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper2.class").toString());
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper3.class").toString());
+        check("-v", Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$TestHelper4.class").toString());
+    }
+
+    void check(String... params) {
+        StringWriter s;
+        String out;
+        try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+            com.sun.tools.javap.Main.run(params, pw);
+            out = s.toString();
+        }
+        String constantPool = getConstantPool(out);
+        if (constantPool.indexOf(methodToLookFor) !=
+                constantPool.lastIndexOf(methodToLookFor)) {
+            throw new AssertionError("There is more than one entry for the method seek "  +
+                    methodToLookFor);
+        }
+    }
+
+    String getConstantPool(String out) {
+        int start = out.indexOf("Constant pool:");
+        int end = out.indexOf("{");
+        return out.substring(start, end);
+    }
+
+    class TestHelper1 {
+        void m() {
+            Vector v = new Vector();
+            Iterator iter = v.iterator();
+            while (iter.hasNext()) {
+                Object o = iter.next();
+                Object o2 = o;
+            }
+            for (Object o: v) {
+                Object o2 = o;
+            }
+        }
+    }
+
+    class TestHelper2<X extends Number & Iterable<String>> {
+        void test(X x) {
+            for (String s : x) { }
+        }
+    }
+
+    interface Data extends Iterable<String> {}
+
+    class TestHelper3<X extends Number & Iterable<? extends Data>> {
+        void test(X x) {
+            for (Data s : x) { }
+        }
+    }
+
+    class TestHelper4 {
+         void test(Iterable<? extends Data> t) {
+             for(Object a: t.iterator().next());
+         }
+    }
+}
diff --git a/test/tools/javac/T5090006/AssertionFailureTest.java b/test/tools/javac/T5090006/AssertionFailureTest.java
new file mode 100644
index 0000000..c722676
--- /dev/null
+++ b/test/tools/javac/T5090006/AssertionFailureTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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 5090006
+ * @summary javac fails with assertion error
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main AssertionFailureTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/T5090006/compiler.sh
+public class AssertionFailureTest {
+
+    private static final String testSrc =
+        "import stub_tie_gen.wsdl_hello_lit.client.*;\n" +
+        "import junit.framework.*;\n" +
+        "import testutil.ClientServerTestUtil;\n" +
+        "\n" +
+        "public class Test {\n" +
+        "\n" +
+        "    void getStub() throws Exception {\n" +
+        "        Hello_PortType_Stub x = null;\n" +
+        "        new ClientServerTestUtil().setTransport(x, null, null, null);\n" +
+        "    }\n" +
+        "\n" +
+        "    public static void main(String[] args) {\n" +
+        "        System.out.println(\"FISK\");\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        String classpath = Paths.get(System.getProperty("test.src"), "broken.jar")
+                .toString();
+        classpath = new StringBuilder(classpath)
+                .append(File.pathSeparator).append(".").toString();
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-cp", classpath)
+                .setSources(testSrc);
+        ToolBox.javac(params);
+    }
+
+}
diff --git a/test/tools/javac/T5090006/T5090006.java b/test/tools/javac/T5090006/T5090006.java
deleted file mode 100644
index 168fc0e..0000000
--- a/test/tools/javac/T5090006/T5090006.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, 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 5090006
- * @summary javac fails with assertion error
- * @author Peter von der Ah\u00e9
- * @run shell compiler.sh T5090006.java
- * @run main T5090006
- */
-
-import stub_tie_gen.wsdl_hello_lit.client.*;
-import junit.framework.*;
-import testutil.ClientServerTestUtil;
-
-public class T5090006 {
-
-    void getStub() throws Exception {
-        Hello_PortType_Stub x = null;
-        new ClientServerTestUtil().setTransport(x, null, null, null);
-    }
-
-    public static void main(String[] args) {
-        System.out.println("FISK");
-    }
-}
diff --git a/test/tools/javac/T5090006/compiler.sh b/test/tools/javac/T5090006/compiler.sh
deleted file mode 100644
index 5c913b3..0000000
--- a/test/tools/javac/T5090006/compiler.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
-
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/T6181889/EmptyFinallyTest.java b/test/tools/javac/T6181889/EmptyFinallyTest.java
new file mode 100644
index 0000000..338bdf4
--- /dev/null
+++ b/test/tools/javac/T6181889/EmptyFinallyTest.java
@@ -0,0 +1,67 @@
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+
+/*
+ * 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 6181889
+ * @summary Empty try/finally results in bytecodes being generated
+ */
+
+public class EmptyFinallyTest {
+    private static final String assertionErrorMsg =
+            "No \"Exception table\" should be generated in this case";
+
+    public static void main(String[] args) {
+        new EmptyFinallyTest().run();
+    }
+
+    void run() {
+        check("-c", Paths.get(System.getProperty("test.classes"),
+                "EmptyFinally.class").toString());
+    }
+
+    void check(String... params) {
+        StringWriter s;
+        String out;
+        try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+            com.sun.tools.javap.Main.run(params, pw);
+            out = s.toString();
+        }
+        if (out.contains("Exception table")) {
+            throw new AssertionError(assertionErrorMsg);
+        }
+    }
+}
+
+class EmptyFinally {
+    void m() {
+        try {
+            System.out.println("EMPTY TRY!");
+        } finally {}
+    }
+}
diff --git a/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.java b/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.java
new file mode 100644
index 0000000..ec1caf3
--- /dev/null
+++ b/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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 6356530
+ * @summary -Xlint:serial does not flag abstract classes with concrete methods/members
+ * @compile/fail/ref=FinalVariableAssignedToInCatchBlockTest.out -XDrawDiagnostics FinalVariableAssignedToInCatchBlockTest.java
+ */
+
+import java.io.IOException;
+
+public class FinalVariableAssignedToInCatchBlockTest {
+    public void m1(int o)
+    {
+        final int i;
+        try {
+            if (o == 1) {
+                throw new IOException();
+            } else if (o == 2) {
+                throw new InterruptedException();
+            } else {
+                throw new Exception();
+            }
+        } catch (IOException e) {
+            i = 1;
+        } catch (InterruptedException ie) {
+            i = 2;
+        } catch (Exception e) {
+            i = 3;
+        } finally {
+            i = 4;
+        }
+    }
+
+    public void m2(int o)
+    {
+        final int i;
+        try {
+            if (o == 1) {
+                throw new IOException();
+            } else if (o == 2) {
+                throw new InterruptedException();
+            } else {
+                throw new Exception();
+            }
+        } catch (IOException e) {
+            i = 1;
+        } catch (InterruptedException ie) {
+            i = 2;
+        } catch (Exception e) {
+            i = 3;
+        }
+    }
+
+    public void m3(int o) throws Exception
+    {
+        final int i;
+        try {
+            if (o == 1) {
+                throw new IOException();
+            } else if (o == 2) {
+                throw new InterruptedException();
+            } else {
+                throw new Exception();
+            }
+        } catch (IOException e) {
+            i = 1;
+        } catch (InterruptedException ie) {
+            i = 2;
+        }
+        i = 3;
+    }
+}
diff --git a/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.out b/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.out
new file mode 100644
index 0000000..58ed58e
--- /dev/null
+++ b/test/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.out
@@ -0,0 +1,3 @@
+FinalVariableAssignedToInCatchBlockTest.java:52:13: compiler.err.var.might.already.be.assigned: i
+FinalVariableAssignedToInCatchBlockTest.java:92:9: compiler.err.var.might.already.be.assigned: i
+2 errors
diff --git a/test/tools/javac/T6326754.out b/test/tools/javac/T6326754.out
index faa786b..00963b8 100644
--- a/test/tools/javac/T6326754.out
+++ b/test/tools/javac/T6326754.out
@@ -1,7 +1,7 @@
 T6326754.java:44:12: compiler.err.name.clash.same.erasure: TestConstructor(T), TestConstructor(K)
 T6326754.java:52:17: compiler.err.name.clash.same.erasure: setT(K), setT(T)
-T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.incompatible.types), T, T
-T6326754.java:70:11: compiler.err.cant.apply.symbol.1: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, (compiler.misc.arg.length.mismatch)
+T6326754.java:64:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, T)
+T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, (compiler.misc.arg.length.mismatch)
 - compiler.note.unchecked.filename: T6326754.java
 - compiler.note.unchecked.recompile
 4 errors
diff --git a/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.java b/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.java
new file mode 100644
index 0000000..ffdf34d
--- /dev/null
+++ b/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.java
@@ -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
+ * @bug 6356530
+ * @summary -Xlint:serial does not flag abstract classes with concrete methods/members
+ * @compile/fail/ref=SerializableAbstractClassWithNonAbstractMethodsTest.out -XDrawDiagnostics -Werror -Xlint:serial SerializableAbstractClassWithNonAbstractMethodsTest.java
+ */
+
+abstract class SerializableAbstractClassWithNonAbstractMethodsTest implements java.io.Serializable {
+    void m1() {}
+    abstract void m2();
+
+    abstract class AWithUID implements java.io.Serializable {
+        private static final long serialVersionUID = 0;
+        void m(){}
+    }
+
+    interface IDefault extends java.io.Serializable {
+        default int m() { return 1; }
+    }
+
+    interface IDefaultAndUID extends java.io.Serializable {
+        static final long serialVersionUID = 0;
+        default int m() { return 1; }
+    }
+}
diff --git a/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.out b/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.out
new file mode 100644
index 0000000..b600771
--- /dev/null
+++ b/test/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.out
@@ -0,0 +1,5 @@
+SerializableAbstractClassWithNonAbstractMethodsTest.java:40:5: compiler.warn.missing.SVUID: SerializableAbstractClassWithNonAbstractMethodsTest.IDefault
+SerializableAbstractClassWithNonAbstractMethodsTest.java:31:10: compiler.warn.missing.SVUID: SerializableAbstractClassWithNonAbstractMethodsTest
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/T6558476.java b/test/tools/javac/T6558476.java
index 8f6dd43..ea034f0 100644
--- a/test/tools/javac/T6558476.java
+++ b/test/tools/javac/T6558476.java
@@ -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
@@ -23,6 +23,8 @@
 
 /*
  * @test
+ * @bug 6558476
+ * @summary com/sun/tools/javac/Main.compile don't release file handles on return
  * @run main/othervm -Xmx512m -Xms512m  T6558476
  */
 
@@ -70,8 +72,7 @@ public class T6558476 {
 
     public static void main(String[] args) throws IOException {
         File javaHomeDir = new File(System.getProperty("java.home"));
-        File tmpDir = new File(System.getProperty("java.io.tmpdir"));
-        File outputDir = new File(tmpDir, "outputDir" + new Random().nextInt(65536));
+        File outputDir = new File("outputDir" + new Random().nextInt(65536));
         outputDir.mkdir();
         outputDir.deleteOnExit();
 
diff --git a/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java b/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java
new file mode 100644
index 0000000..e2b503a
--- /dev/null
+++ b/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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 6695379
+ * @summary Copy method annotations and parameter annotations to synthetic
+ * bridge methods
+ * @run main AnnotationsAreNotCopiedToBridgeMethodsTest
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.io.BufferedInputStream;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import com.sun.tools.classfile.AccessFlags;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Attributes;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.util.Assert;
+
+public class AnnotationsAreNotCopiedToBridgeMethodsTest {
+
+    public static void main(String[] args) throws Exception {
+        new AnnotationsAreNotCopiedToBridgeMethodsTest().run();
+    }
+
+    void run() throws Exception {
+        checkClassFile(Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() + "$CovariantReturnType.class"));
+        checkClassFile(Paths.get(System.getProperty("test.classes"),
+                this.getClass().getSimpleName() +
+                "$CovariantReturnType$VisibilityChange.class"));
+    }
+
+    void checkClassFile(final Path cfilePath) throws Exception {
+        ClassFile classFile = ClassFile.read(
+                new BufferedInputStream(Files.newInputStream(cfilePath)));
+        for (Method method : classFile.methods) {
+            if (method.access_flags.is(AccessFlags.ACC_BRIDGE)) {
+                checkForAttr(method.attributes,
+                        "Annotations hasn't been copied to bridge method",
+                        Attribute.RuntimeVisibleAnnotations,
+                        Attribute.RuntimeVisibleParameterAnnotations);
+            }
+        }
+    }
+
+    void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) {
+        for (String attrName : attrNames) {
+            Assert.checkNonNull(attrs.get(attrName), errorMsg);
+        }
+    }
+
+    @Target(value = {ElementType.PARAMETER})
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface ParamAnnotation {}
+
+    @Target(value = {ElementType.METHOD})
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface MethodAnnotation {}
+
+    abstract class T<A,B> {
+        B m(A a){return null;}
+    }
+
+    class CovariantReturnType extends T<Integer, Integer> {
+        @MethodAnnotation
+        Integer m(@ParamAnnotation Integer i) {
+            return i;
+        }
+
+        public class VisibilityChange extends CovariantReturnType {}
+
+    }
+
+}
diff --git a/test/tools/javac/T6725036.java b/test/tools/javac/T6725036.java
index b27ad88..24ea347 100644
--- a/test/tools/javac/T6725036.java
+++ b/test/tools/javac/T6725036.java
@@ -24,6 +24,7 @@
 /*
  * @test
  * @bug 6725036
+ * @ignore 8016760: failure of regression test langtools/tools/javac/T6725036.java
  * @summary javac returns incorrect value for lastModifiedTime() when
  *          source is a zip file archive
  */
diff --git a/test/tools/javac/T6873845.java b/test/tools/javac/T6873845.java
index ff84028..b1cfea6 100644
--- a/test/tools/javac/T6873845.java
+++ b/test/tools/javac/T6873845.java
@@ -19,8 +19,8 @@ public class T6873845 {
         if (out.contains("sunapi"))
             throw new Exception("unexpected output for -X");
 
-        String warn1 = "T6873845.java:72:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
-        String warn2 = "T6873845.java:77:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
+        String warn1 = "T6873845.java:73:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
+        String warn2 = "T6873845.java:78:9: compiler.warn.sun.proprietary: sun.misc.Unsafe" + newline;
         String note1 = "- compiler.note.sunapi.filename: T6873845.java" + newline;
         String note2 = "- compiler.note.sunapi.recompile" + newline;
 
@@ -52,7 +52,8 @@ public class T6873845 {
         args.add(0, "-XDrawDiagnostics");
         String out = compile(args);
         if (!out.equals(expect))
-            throw new Exception("unexpected output from compiler");
+            throw new Exception("unexpected output from compiler; expected: " + expect +
+                    "\n  found: " + out);
     }
 
     String compile(List<String> args) throws Exception{
diff --git a/test/tools/javac/T6900149.java b/test/tools/javac/T6900149.java
index 64dbe2a..151b39e 100644
--- a/test/tools/javac/T6900149.java
+++ b/test/tools/javac/T6900149.java
@@ -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
@@ -39,7 +39,7 @@ public class T6900149 {
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
         StandardJavaFileManager fm =
                 compiler.getStandardFileManager(null, null, null);
-        File emptyFile = File.createTempFile("Empty", ".java");
+        File emptyFile = createTempFile("Empty.java");
         File[] files = new File[] { emptyFile, emptyFile };
         CompilationTask task = compiler.getTask(null, fm, diag,
                 null, null, fm.getJavaFileObjects(files));
@@ -47,4 +47,10 @@ public class T6900149 {
             throw new AssertionError("compilation failed");
         }
     }
+
+    private static File createTempFile(String path) throws IOException {
+        File f = new File(path);
+        try (FileWriter out = new FileWriter(f)) { }
+        return f;
+    }
 }
diff --git a/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java b/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java
new file mode 100644
index 0000000..a66f7ca
--- /dev/null
+++ b/test/tools/javac/T6970173/DebugPointerAtBadPositionTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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 6970173
+ * @summary Debug pointer at bad position
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main DebugPointerAtBadPositionTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.LineNumberTable_attribute;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.util.Assert;
+
+public class DebugPointerAtBadPositionTest {
+
+    static final String testSource =
+            "public class AssertionTest {\n" +
+            "    void lookForThisMethod() {\n" +
+            "        int i;\n" +
+            "        i = 33;\n" +
+            "        assert // line 5\n" +
+            "            i < 89:\n" +
+            "        i < 100; // line 7\n" +
+            "    }\n" +
+            "}";
+
+    static final int[][] expectedLNT = {
+        {4, 0},
+        {5, 3},
+        {8, 34}
+    };
+
+    static final String methodToLookFor = "lookForThisMethod";
+    static final String seekMethodNotFoundMsg =
+        "The seek method was not found";
+    static final String foundLNTLengthDifferentThanExpMsg =
+        "The LineNumberTable found has a length different to the expected one";
+
+    public static void main(String[] args) throws Exception {
+        new DebugPointerAtBadPositionTest().run();
+    }
+
+    void run() throws Exception {
+        compileTestClass();
+        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+                "AssertionTest.class").toUri()), methodToLookFor);
+    }
+
+    void compileTestClass() throws Exception {
+        ToolBox.JavaToolArgs javacSuccessArgs =
+                new ToolBox.JavaToolArgs().setSources(testSource);
+        ToolBox.javac(javacSuccessArgs);
+    }
+
+    void checkClassFile(final File cfile, String methodToFind) throws Exception {
+        ClassFile classFile = ClassFile.read(cfile);
+        boolean methodFound = false;
+        for (Method method : classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
+                methodFound = true;
+                Code_attribute code = (Code_attribute) method.attributes.get("Code");
+                LineNumberTable_attribute lnt =
+                        (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
+                Assert.check(lnt.line_number_table_length == expectedLNT.length,
+                        foundLNTLengthDifferentThanExpMsg);
+                int i = 0;
+                for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
+                    Assert.check(entry.line_number == expectedLNT[i][0] &&
+                            entry.start_pc == expectedLNT[i][1],
+                            "LNT entry at pos " + i + " differ from expected." +
+                            "Found " + entry.line_number + ":" + entry.start_pc +
+                            ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
+                    i++;
+                }
+            }
+        }
+        Assert.check(methodFound, seekMethodNotFoundMsg);
+    }
+
+    void error(String msg) {
+        throw new AssertionError(msg);
+    }
+
+}
diff --git a/test/tools/javac/T6985181.java b/test/tools/javac/T6985181.java
new file mode 100644
index 0000000..2211ff4
--- /dev/null
+++ b/test/tools/javac/T6985181.java
@@ -0,0 +1,88 @@
+/*
+ * 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 6985181
+ * @summary Annotations lost from classfile
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T6985181 {
+    public static void main(String... args) throws Exception{
+        new T6985181().run();
+    }
+
+    public void run() throws Exception {
+        String code = "@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_PARAMETER)\n" +
+                "@interface Simple { }\n" +
+                "interface Test<@Simple T> { }";
+
+        File srcFile = writeFile("Test.java", code);
+        File classesDir = new File("classes");
+        classesDir.mkdirs();
+        compile("-d", classesDir.getPath(), srcFile.getPath());
+        String out = javap(new File(classesDir, srcFile.getName().replace(".java", ".class")));
+        if (!out.contains("RuntimeInvisibleTypeAnnotations"))
+            throw new Exception("RuntimeInvisibleTypeAnnotations not found");
+    }
+
+    void compile(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("Compilation failed: rc=" + rc);
+    }
+
+    String javap(File classFile) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { "-v", classFile.getPath() };
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("javap failed: rc=" + rc);
+        return out;
+    }
+
+    File writeFile(String path, String body) throws IOException {
+        File f = new File(path);
+        FileWriter out = new FileWriter(f);
+        try {
+            out.write(body);
+        } finally {
+            out.close();
+        }
+        return f;
+    }
+}
diff --git a/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java b/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java
new file mode 100644
index 0000000..8557f99
--- /dev/null
+++ b/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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 7008643
+ * @summary inlined finally clauses confuse debuggers
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main InlinedFinallyConfuseDebuggersTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.LineNumberTable_attribute;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.util.Assert;
+
+public class InlinedFinallyConfuseDebuggersTest {
+
+    static final String testSource =
+    /* 01 */        "public class InlinedFinallyTest {\n" +
+    /* 02 */        "    void lookForThisMethod(int value) {\n" +
+    /* 03 */        "        try {\n" +
+    /* 04 */        "            if (value > 0) {\n" +
+    /* 05 */        "                System.out.println(\"if\");\n" +
+    /* 06 */        "                return;\n" +
+    /* 07 */        "            }\n" +
+    /* 08 */        "        } finally {\n" +
+    /* 09 */        "            System.out.println(\"finally\");\n" +
+    /* 10 */        "        }\n" +
+    /* 11 */        "    }\n" +
+    /* 12 */        "}";
+
+    static final int[][] expectedLNT = {
+    //  {line-number, start-pc},
+        {4,           0},       //if (value > 0) {
+        {5,           4},       //    System.out.println("if");
+        {9,           12},      //System.out.println("finally");
+        {6,           20},      //    return;
+        {9,           21},      //System.out.println("finally");
+        {10,          29},
+        {9,           32},      //System.out.println("finally");
+        {11,          43},
+    };
+
+    static final String methodToLookFor = "lookForThisMethod";
+
+    public static void main(String[] args) throws Exception {
+        new InlinedFinallyConfuseDebuggersTest().run();
+    }
+
+    void run() throws Exception {
+        compileTestClass();
+        checkClassFile(new File(Paths.get(System.getProperty("user.dir"),
+                "InlinedFinallyTest.class").toUri()), methodToLookFor);
+    }
+
+    void compileTestClass() throws Exception {
+        ToolBox.JavaToolArgs javacSuccessArgs =
+                new ToolBox.JavaToolArgs().setSources(testSource);
+        ToolBox.javac(javacSuccessArgs);
+    }
+
+    void checkClassFile(final File cfile, String methodToFind) throws Exception {
+        ClassFile classFile = ClassFile.read(cfile);
+        boolean methodFound = false;
+        for (Method method : classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals(methodToFind)) {
+                methodFound = true;
+                Code_attribute code = (Code_attribute) method.attributes.get("Code");
+                LineNumberTable_attribute lnt =
+                        (LineNumberTable_attribute) code.attributes.get("LineNumberTable");
+                Assert.check(lnt.line_number_table_length == expectedLNT.length,
+                        "The LineNumberTable found has a length different to the expected one");
+                int i = 0;
+                for (LineNumberTable_attribute.Entry entry: lnt.line_number_table) {
+                    Assert.check(entry.line_number == expectedLNT[i][0] &&
+                            entry.start_pc == expectedLNT[i][1],
+                            "LNT entry at pos " + i + " differ from expected." +
+                            "Found " + entry.line_number + ":" + entry.start_pc +
+                            ". Expected " + expectedLNT[i][0] + ":" + expectedLNT[i][1]);
+                    i++;
+                }
+            }
+        }
+        Assert.check(methodFound, "The seek method was not found");
+    }
+
+    void error(String msg) {
+        throw new AssertionError(msg);
+    }
+
+}
diff --git a/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java b/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java
new file mode 100644
index 0000000..e03b1a5
--- /dev/null
+++ b/test/tools/javac/T7053059/VerifyErrorWithDoubleAssignmentTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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 7053059
+ * @summary VerifyError with double Assignment using a Generic Member of a Superclass
+ * @run main VerifyErrorWithDoubleAssignmentTest
+ */
+
+public class VerifyErrorWithDoubleAssignmentTest {
+
+    static class A<D> {
+        D d;
+
+        D getD() {
+            return null;
+        }
+    }
+
+    static class B extends A<Integer> {
+        Integer y;
+        B() {
+            y = d = getD();
+        }
+    }
+
+    public static void main(String[] args) {
+        new B();
+    }
+}
diff --git a/test/tools/javac/T7093325.java b/test/tools/javac/T7093325.java
new file mode 100644
index 0000000..dcdc6e6
--- /dev/null
+++ b/test/tools/javac/T7093325.java
@@ -0,0 +1,269 @@
+/*
+ * 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
+ * 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 7093325 8006694
+ * @summary Redundant entry in bytecode exception table
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm T7093325
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.io.File;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Method;
+
+public class T7093325
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum StatementKind {
+        THROW("throw new RuntimeException();", false, false),
+        RETURN_NONEMPTY("System.out.println(); return;", true, false),
+        RETURN_EMPTY("return;", true, true),
+        APPLY("System.out.println();", true, false);
+
+        String stmt;
+        boolean canInline;
+        boolean empty;
+
+        private StatementKind(String stmt, boolean canInline, boolean empty) {
+            this.stmt = stmt;
+            this.canInline = canInline;
+            this.empty = empty;
+        }
+    }
+
+    enum CatchArity {
+        NONE(""),
+        ONE("catch (A a) { #S1 }"),
+        TWO("catch (B b) { #S2 }"),
+        THREE("catch (C c) { #S3 }"),
+        FOUR("catch (D d) { #S4 }");
+
+        String catchStr;
+
+        private CatchArity(String catchStr) {
+            this.catchStr = catchStr;
+        }
+
+        String catchers() {
+            if (this.ordinal() == 0) {
+                return catchStr;
+            } else {
+                return CatchArity.values()[this.ordinal() - 1].catchers() +
+                        catchStr;
+            }
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (CatchArity ca : CatchArity.values()) {
+            for (StatementKind stmt0 : StatementKind.values()) {
+                if (ca.ordinal() == 0) {
+                    pool.execute(new T7093325(ca, stmt0));
+                    continue;
+                }
+                for (StatementKind stmt1 : StatementKind.values()) {
+                    if (ca.ordinal() == 1) {
+                        pool.execute(new T7093325(ca, stmt0, stmt1));
+                        continue;
+                    }
+                    for (StatementKind stmt2 : StatementKind.values()) {
+                        if (ca.ordinal() == 2) {
+                            pool.execute(new T7093325(ca, stmt0, stmt1, stmt2));
+                            continue;
+                        }
+                        for (StatementKind stmt3 : StatementKind.values()) {
+                            if (ca.ordinal() == 3) {
+                                pool.execute(
+                                    new T7093325(ca, stmt0, stmt1, stmt2, stmt3));
+                                continue;
+                            }
+                            for (StatementKind stmt4 : StatementKind.values()) {
+                                if (ca.ordinal() == 4) {
+                                    pool.execute(
+                                        new T7093325(ca, stmt0, stmt1,
+                                                     stmt2, stmt3, stmt4));
+                                    continue;
+                                }
+                                for (StatementKind stmt5 : StatementKind.values()) {
+                                    pool.execute(
+                                        new T7093325(ca, stmt0, stmt1, stmt2,
+                                                     stmt3, stmt4, stmt5));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    /** instance decls **/
+
+    CatchArity ca;
+    StatementKind[] stmts;
+
+    public T7093325(CatchArity ca, StatementKind... stmts) {
+        this.ca = ca;
+        this.stmts = stmts;
+    }
+
+    @Override
+    public void run() {
+        int id = checkCount.incrementAndGet();
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource(id);
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), null,
+                null, null, Arrays.asList(source));
+        ct.call();
+        verifyBytecode(source, id);
+    }
+
+    void verifyBytecode(JavaSource source, int id) {
+        boolean lastInlined = false;
+        boolean hasCode = false;
+        int gapsCount = 0;
+        for (int i = 0; i < stmts.length ; i++) {
+            lastInlined = stmts[i].canInline;
+            hasCode = hasCode || !stmts[i].empty;
+            if (lastInlined && hasCode) {
+                hasCode = false;
+                gapsCount++;
+            }
+        }
+        if (!lastInlined) {
+            gapsCount++;
+        }
+
+        File compiledTest = new File(String.format("Test%s.class", id));
+        try {
+            ClassFile cf = ClassFile.read(compiledTest);
+            if (cf == null) {
+                throw new Error("Classfile not found: " +
+                                compiledTest.getName());
+            }
+
+            Method test_method = null;
+            for (Method m : cf.methods) {
+                if (m.getName(cf.constant_pool).equals("test")) {
+                    test_method = m;
+                    break;
+                }
+            }
+
+            if (test_method == null) {
+                throw new Error("Method test() not found in class Test");
+            }
+
+            Code_attribute code = null;
+            for (Attribute a : test_method.attributes) {
+                if (a.getName(cf.constant_pool).equals(Attribute.Code)) {
+                    code = (Code_attribute)a;
+                    break;
+                }
+            }
+
+            if (code == null) {
+                throw new Error("Code attribute not found in method test()");
+            }
+
+            int actualGapsCount = 0;
+            for (int i = 0; i < code.exception_table_langth ; i++) {
+                int catchType = code.exception_table[i].catch_type;
+                if (catchType == 0) { //any
+                    actualGapsCount++;
+                }
+            }
+
+            if (actualGapsCount != gapsCount) {
+                throw new Error("Bad exception table for test()\n" +
+                            "expected gaps: " + gapsCount + "\n" +
+                            "found gaps: " + actualGapsCount + "\n" +
+                            source);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + compiledTest +": " + e);
+        }
+
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        static final String source_template =
+                "class A extends RuntimeException {} \n" +
+                "class B extends RuntimeException {} \n" +
+                "class C extends RuntimeException {} \n" +
+                "class D extends RuntimeException {} \n" +
+                "class E extends RuntimeException {} \n" +
+                "class Test#ID {\n" +
+                "   void test() {\n" +
+                "   try { #S0 } #C finally { System.out.println(); }\n" +
+                "   }\n" +
+                "}";
+
+        String source;
+
+        public JavaSource(int id) {
+            super(URI.create(String.format("myfo:/Test%s.java", id)),
+                  JavaFileObject.Kind.SOURCE);
+            source = source_template.replace("#C", ca.catchers());
+            source = source.replace("#S0", stmts[0].stmt);
+            source = source.replace("#ID", String.valueOf(id));
+            for (int i = 1; i < ca.ordinal() + 1; i++) {
+                source = source.replace("#S" + i, stmts[i].stmt);
+            }
+        }
+
+        @Override
+        public String toString() {
+            return source;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+}
diff --git a/test/tools/javac/T7120266.java b/test/tools/javac/T7120266.java
new file mode 100644
index 0000000..f33db02
--- /dev/null
+++ b/test/tools/javac/T7120266.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 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 7120266
+ * @summary javac fails to compile hotspot code
+ * @compile T7120266.java
+ */
+
+class T7120266 {
+   void test(int i, int len) { that(i < len, "oopmap"); }
+   void that(boolean b, String s) { };
+}
diff --git a/test/tools/javac/T7159016.java b/test/tools/javac/T7159016.java
index 4c74f26..70df0f8 100644
--- a/test/tools/javac/T7159016.java
+++ b/test/tools/javac/T7159016.java
@@ -28,7 +28,7 @@
  * @library lib
  * @build JavacTestingAbstractProcessor
  * @run main T7159016
- * @author Jesse Glick
+ * @author Jessie Glick
  */
 
 import java.io.File;
diff --git a/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java b/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java
new file mode 100644
index 0000000..442923d
--- /dev/null
+++ b/test/tools/javac/T7165659/InnerClassAttrMustNotHaveStrictFPFlagTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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 7165659
+ * @summary javac incorrectly sets strictfp access flag on inner-classes
+ */
+
+import java.io.File;
+
+import com.sun.tools.classfile.AccessFlags;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.InnerClasses_attribute;
+import com.sun.tools.classfile.InnerClasses_attribute.Info;
+import com.sun.tools.javac.util.Assert;
+
+public class InnerClassAttrMustNotHaveStrictFPFlagTest {
+
+    public static void main(String[] args) throws Exception {
+        new InnerClassAttrMustNotHaveStrictFPFlagTest().run();
+    }
+
+    private void run() throws Exception {
+        File classPath = new File(System.getProperty("test.classes"), getClass().getSimpleName() + ".class");
+        analyzeClassFile(classPath);
+    }
+
+    void analyzeClassFile(File path) throws Exception {
+        ClassFile classFile = ClassFile.read(path);
+        InnerClasses_attribute innerClasses =
+                (InnerClasses_attribute) classFile.attributes.get(Attribute.InnerClasses);
+        for (Info classInfo : innerClasses.classes) {
+            Assert.check(!classInfo.inner_class_access_flags.is(AccessFlags.ACC_STRICT),
+                    "Inner classes attribute must not have the ACC_STRICT flag set");
+        }
+    }
+
+    strictfp void m() {
+        new Runnable() {
+            @Override
+            public void run() {}
+        };
+    }
+
+    static strictfp class Strict extends InnerClassAttrMustNotHaveStrictFPFlagTest {}
+
+}
diff --git a/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java b/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java
new file mode 100644
index 0000000..133bc34
--- /dev/null
+++ b/test/tools/javac/T7179353/GenericsAndTWRCompileErrorTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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 7179353
+ * @summary try-with-resources fails to compile with generic exception parameters
+ * @compile GenericsAndTWRCompileErrorTest.java
+ */
+
+public class GenericsAndTWRCompileErrorTest {
+
+    public static class Resource<E extends Exception> implements AutoCloseable {
+        public void close() throws E { }
+    }
+
+    public <E extends Exception> void test() throws E {
+        try (Resource<E> r = new Resource<E>()) {
+
+        }
+    }
+}
diff --git a/test/tools/javac/T8003967/DetectMutableStaticFields.java b/test/tools/javac/T8003967/DetectMutableStaticFields.java
new file mode 100644
index 0000000..c419cd3
--- /dev/null
+++ b/test/tools/javac/T8003967/DetectMutableStaticFields.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2006, 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.
+ */
+
+/*
+ * @test
+ * @bug 8003967
+ * @summary detect and remove all mutable implicit static enum fields in langtools
+ * @run main DetectMutableStaticFields
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Field;
+
+import static javax.tools.JavaFileObject.Kind.CLASS;
+import static com.sun.tools.classfile.AccessFlags.ACC_ENUM;
+import static com.sun.tools.classfile.AccessFlags.ACC_FINAL;
+import static com.sun.tools.classfile.AccessFlags.ACC_STATIC;
+
+public class DetectMutableStaticFields {
+
+    private static final String keyResource =
+            "com/sun/tools/javac/tree/JCTree.class";
+
+    private String[] packagesToSeekFor = new String[] {
+        "javax.tools",
+        "javax.lang.model",
+        "com.sun.javadoc",
+        "com.sun.source",
+        "com.sun.tools.classfile",
+        "com.sun.tools.doclets",
+        "com.sun.tools.javac",
+        "com.sun.tools.javadoc",
+        "com.sun.tools.javah",
+        "com.sun.tools.javap",
+    };
+
+    private static final Map<String, List<String>> classFieldsToIgnoreMap = new HashMap<>();
+
+    static {
+        classFieldsToIgnoreMap.
+                put("javax/tools/ToolProvider",
+                    Arrays.asList("instance"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javah/JavahTask",
+                    Arrays.asList("versionRB"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/classfile/Dependencies$DefaultFilter",
+                    Arrays.asList("instance"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javap/JavapTask",
+                    Arrays.asList("versionRB"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/doclets/formats/html/HtmlDoclet",
+                    Arrays.asList("docletToStart"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/util/JCDiagnostic",
+                    Arrays.asList("fragmentFormatter"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/util/JavacMessages",
+                    Arrays.asList("defaultBundle", "defaultMessages"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/file/ZipFileIndexCache",
+                    Arrays.asList("sharedInstance"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/main/JavaCompiler",
+                    Arrays.asList("versionRB"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/code/Type",
+                    Arrays.asList("moreInfo"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/util/SharedNameTable",
+                    Arrays.asList("freelist"));
+        classFieldsToIgnoreMap.
+                put("com/sun/tools/javac/util/Log",
+                    Arrays.asList("useRawMessages"));
+    }
+
+    private List<String> errors = new ArrayList<>();
+
+    public static void main(String[] args) {
+        try {
+            new DetectMutableStaticFields().run();
+        } catch (Exception ex) {
+            throw new AssertionError(
+                    "Exception during test execution with cause ",
+                    ex.getCause());
+        }
+    }
+
+    private void run()
+        throws
+            IOException,
+            ConstantPoolException,
+            InvalidDescriptor,
+            URISyntaxException {
+
+        URI resource = findResource(keyResource);
+        if (resource == null) {
+            throw new AssertionError("Resource " + keyResource +
+                "not found in the class path");
+        }
+        analyzeResource(resource);
+
+        if (errors.size() > 0) {
+            for (String error: errors) {
+                System.err.println(error);
+            }
+            throw new AssertionError("There are mutable fields, "
+                + "please check output");
+        }
+    }
+
+    URI findResource(String className) throws URISyntaxException {
+        URI uri = getClass().getClassLoader().getResource(className).toURI();
+        if (uri.getScheme().equals("jar")) {
+            String ssp = uri.getRawSchemeSpecificPart();
+            int sep = ssp.lastIndexOf("!");
+            uri = new URI(ssp.substring(0, sep));
+        } else if (uri.getScheme().equals("file")) {
+            uri = new URI(uri.getPath().substring(0,
+                    uri.getPath().length() - keyResource.length()));
+        }
+        return uri;
+    }
+
+    boolean shouldAnalyzePackage(String packageName) {
+        for (String aPackage: packagesToSeekFor) {
+            if (packageName.contains(aPackage)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    void analyzeResource(URI resource)
+        throws
+            IOException,
+            ConstantPoolException,
+            InvalidDescriptor {
+        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        JavaFileManager.Location location =
+                StandardLocation.locationFor(resource.getPath());
+        fm.setLocation(location, com.sun.tools.javac.util.List.of(
+                new File(resource.getPath())));
+
+        for (JavaFileObject file : fm.list(location, "", EnumSet.of(CLASS), true)) {
+            String className = fm.inferBinaryName(location, file);
+            int index = className.lastIndexOf('.');
+            String pckName = index == -1 ? "" : className.substring(0, index);
+            if (shouldAnalyzePackage(pckName)) {
+                analyzeClassFile(ClassFile.read(file.openInputStream()));
+            }
+        }
+    }
+
+    List<String> currentFieldsToIgnore;
+
+    boolean ignoreField(String field) {
+        if (currentFieldsToIgnore != null) {
+            for (String fieldToIgnore : currentFieldsToIgnore) {
+                if (field.equals(fieldToIgnore)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    void analyzeClassFile(ClassFile classFileToCheck)
+        throws
+            IOException,
+            ConstantPoolException,
+            Descriptor.InvalidDescriptor {
+        boolean enumClass =
+                (classFileToCheck.access_flags.flags & ACC_ENUM) != 0;
+        boolean nonFinalStaticEnumField;
+        boolean nonFinalStaticField;
+
+        currentFieldsToIgnore =
+                classFieldsToIgnoreMap.get(classFileToCheck.getName());
+
+        for (Field field : classFileToCheck.fields) {
+            if (ignoreField(field.getName(classFileToCheck.constant_pool))) {
+                continue;
+            }
+            nonFinalStaticEnumField =
+                    (field.access_flags.flags & (ACC_ENUM | ACC_FINAL)) == 0;
+            nonFinalStaticField =
+                    (field.access_flags.flags & ACC_STATIC) != 0 &&
+                    (field.access_flags.flags & ACC_FINAL) == 0;
+            if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) {
+                errors.add("There is a mutable field named " +
+                        field.getName(classFileToCheck.constant_pool) +
+                        ", at class " +
+                        classFileToCheck.getName());
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/T8004969.java b/test/tools/javac/T8004969.java
new file mode 100644
index 0000000..c6c7a22
--- /dev/null
+++ b/test/tools/javac/T8004969.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/*
+ at test
+ at bug 8004969
+ at summary Lambda deserialization
+
+*/
+
+import java.io.*;
+
+public class T8004969 implements Serializable {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static String mm(String s) { return "mref" + s; }
+
+    String aField = "aF";
+
+    public static void main(String[] args) throws Exception {
+        (new T8004969()).doit();
+    }
+
+    public void doit() throws Exception {
+        String aLocal = "aL";
+        int anInt = 99;
+
+        try {
+            // Write lambdas out
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutput out = new ObjectOutputStream(baos);
+
+            write(out, z -> "[" + z + "]" );
+            write(out, z -> { String x = z + z; return x + x; } );
+            write(out, T8004969::mm );
+            write(out, z -> (new LSI() { public String convert(String x) { return "*"+x; }} ).convert(z) );
+            write(out, z -> aField + z );
+            write(out, z -> aLocal + z );
+            write(out, z -> z + anInt );
+            out.flush();
+            out.close();
+
+            // Read them back
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(baos.toByteArray());
+            ObjectInputStream in = new ObjectInputStream(bais);
+            readAssert(in, "[X]");
+            readAssert(in, "XXXX");
+            readAssert(in, "mrefX");
+            readAssert(in, "*X");
+            readAssert(in, "aFX");
+            readAssert(in, "aLX");
+            readAssert(in, "X99");
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+        assertTrue(assertionCount == 7);
+    }
+
+    static void write(ObjectOutput out, LSI lamb) throws IOException {
+        out.writeObject(lamb);
+    }
+
+    static void readAssert(ObjectInputStream in, String expected)  throws IOException, ClassNotFoundException {
+        LSI ls = (LSI) in.readObject();
+        String result = ls.convert("X");
+        System.out.printf("Result: %s\n", result);
+        assertTrue(result.equals(expected));
+    }
+}
+
+interface LSI extends Serializable {
+    String convert(String x);
+}
diff --git a/test/tools/javac/T8010659/CompilerCrashWhenMixingBinariesAndSourcesTest.java b/test/tools/javac/T8010659/CompilerCrashWhenMixingBinariesAndSourcesTest.java
new file mode 100644
index 0000000..bfce546
--- /dev/null
+++ b/test/tools/javac/T8010659/CompilerCrashWhenMixingBinariesAndSourcesTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8010659
+ * @summary Javac Crashes while building OpenJFX
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CompilerCrashWhenMixingBinariesAndSourcesTest
+ */
+
+public class CompilerCrashWhenMixingBinariesAndSourcesTest {
+    private static final String ASource =
+            "class A {\n" +
+            "        void test() {new B(){};}\n" +
+            "}";
+    private static final String BSource =
+            "class B extends C {}";
+    private static final String CSource =
+            "class C extends D {\n" +
+            "        String m(int i) {return null;}\n" +
+            "}";
+    private static final String DSource =
+            "class D {\n" +
+            "        Object m(int i) {return null;}\n" +
+            "}";
+
+    public static void main (String[] args) throws Exception{
+        ToolBox.JavaToolArgs javacParams = new ToolBox.JavaToolArgs()
+                .setSources(ASource, BSource, CSource, DSource);
+        ToolBox.javac(javacParams);
+
+        ToolBox.rm("A.class");
+        ToolBox.rm("A$1.class");
+        ToolBox.rm("C.class");
+        ToolBox.rm("D.class");
+
+        javacParams = new ToolBox.JavaToolArgs()
+                .setOptions("-cp", ".")
+                .setSources(ASource, CSource, DSource);
+        ToolBox.javac(javacParams);
+    }
+}
diff --git a/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java b/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java
new file mode 100644
index 0000000..f58d186
--- /dev/null
+++ b/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java
@@ -0,0 +1,239 @@
+/*
+ * 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 8010737
+ * @summary javac, known parameter's names should be copied to automatically
+ * generated constructors for inner classes
+ * @run main ParameterNamesAreNotCopiedToAnonymousInitTest check_class_file check_init_symbol
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.api.BasicJavacTask;
+import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.VarSymbol;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.Names;
+
+public class ParameterNamesAreNotCopiedToAnonymousInitTest {
+
+    static final String noParamsErrorMsg =
+            "Test most be invoked with at least one parameter: check_class_file " +
+            "and/or check_init_symbol";
+    static final String wrongParamsErrorMsg =
+            "Accepted arguments are: check_class_file and check_init_symbol";
+    static final String paramNameNotCopiedAssertionMsg =
+            "The param name hasn't been copied to the init method";
+    static final String noAnnotationsForParameterMsg =
+            "No annotations for seek parameter";
+    static final String seekMethodNotFound =
+            "The seek init method was not found or conditions were not met";
+    static final String nonNullParamPositionsMsg =
+            "Parameter positions shold not be null";
+    static final String compilationFailed =
+            "Compilation failed";
+    static final String seekMethodNotFoundMsg =
+        "The seek method was not found";
+
+    static final String ParamAnnotationClassName =
+            ParameterNamesAreNotCopiedToAnonymousInitTest.class.getSimpleName() + "." +
+            ParamAnnotation.class.getSimpleName();
+
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            throw new Error(noParamsErrorMsg);
+        }
+        new ParameterNamesAreNotCopiedToAnonymousInitTest().run(args);
+    }
+
+    void run(String[] args) throws Exception {
+        for (String arg : args) {
+            if (arg.equals("check_class_file")) {
+                checkClassFile(new File(Paths.get(System.getProperty("test.classes"),
+                        this.getClass().getName() + "$initParams$1.class").toUri()), 1);
+                checkClassFile(new File(Paths.get(System.getProperty("test.classes"),
+                        this.getClass().getName() + "$Generics$1.class").toUri()), 2);
+            } else if (arg.equals("check_init_symbol")) {
+                checkInitSymbol("m1", Arrays.asList(0), Arrays.asList("i"));
+                checkInitSymbol("m2", Arrays.asList(0, 1), Arrays.asList("t1", "t2"));
+            } else {
+                error(wrongParamsErrorMsg);
+            }
+        }
+    }
+
+    void checkClassFile(final File cfile, int numberOfParams) throws Exception {
+        ClassFile classFile = ClassFile.read(cfile);
+        boolean methodFound = false;
+        for (Method method : classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals("<init>")) {
+                methodFound = true;
+            }
+        }
+        Assert.check(methodFound, seekMethodNotFoundMsg);
+    }
+
+    /*  This method expect a non-null ordered list of integers, listing the
+     *  position of the parameters to be checked on the init method. Position 0
+     *  corresponds to the first parameter.
+     *
+     *  As we are looking for a constructor of an anonymous class, the
+     *  classOwnerName parameter must be the name of the method where the
+     *  anonymous class is declared.
+     */
+    void checkInitSymbol(
+            final String classOwnerName,
+            final java.util.List<Integer> paramsToCheck,
+            final java.util.List<String> paramNames)
+            throws IOException {
+        Assert.checkNonNull(paramsToCheck, nonNullParamPositionsMsg);
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        Iterable<? extends JavaFileObject> fos =
+                fm.getJavaFileObjectsFromFiles(
+                Arrays.asList(new File(System.getProperty("test.src"),
+                this.getClass().getName() + ".java")));
+        JavacTask task = (JavacTask) c.getTask(null, fm, null,
+                Arrays.asList("-d", System.getProperty("user.dir")), null, fos);
+
+        BasicJavacTask impl = (BasicJavacTask)task;
+        Context context = impl.getContext();
+        final Names names = Names.instance(context);
+
+        task.addTaskListener(new TaskListener() {
+
+            @Override
+            public void started(TaskEvent e) {}
+
+            @Override
+            public void finished(TaskEvent e) {
+                class TheTreeScanner extends TreeScanner {
+                    boolean foundAndCorrect = false;
+
+                    @Override
+                    public void visitMethodDef(JCTree.JCMethodDecl tree) {
+                        ClassSymbol clazz = (ClassSymbol)tree.sym.owner;
+                        if (clazz.owner.name.toString().equals(classOwnerName) &&
+                            tree.sym.name == names.init) {
+
+                            int currentParamPos = 0;
+                            int paramArrayIndex = 0;
+
+                            List<VarSymbol> params = tree.sym.params;
+                            while (params.nonEmpty() && paramArrayIndex < paramsToCheck.size()) {
+                                VarSymbol param = params.head;
+                                if (currentParamPos == paramsToCheck.get(paramArrayIndex)) {
+                                    if (!param.name.toString()
+                                            .equals(paramNames.get(paramArrayIndex))) {
+                                        error(paramNameNotCopiedAssertionMsg);
+                                    }
+                                    paramArrayIndex++;
+                                }
+                                currentParamPos++;
+                                params = params.tail;
+                            }
+                            foundAndCorrect = paramArrayIndex >= paramsToCheck.size();
+                        }
+                        super.visitMethodDef(tree);
+                    }
+                }
+
+                if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+                    CompilationUnitTree compUnitTree = e.getCompilationUnit();
+                    boolean foundAndCorrect = false;
+                    for (Tree tree : compUnitTree.getTypeDecls()) {
+                        TheTreeScanner scanner = new TheTreeScanner();
+                        scanner.scan((JCTree) tree);
+                        foundAndCorrect = foundAndCorrect | scanner.foundAndCorrect;
+                    }
+                    if (!foundAndCorrect) {
+                        error(seekMethodNotFound);
+                    }
+                }
+            }
+        });
+
+        if (!task.call()) {
+            error(compilationFailed);
+        }
+    }
+
+    void error(String msg) {
+        throw new AssertionError(msg);
+    }
+
+    @Target(value = {ElementType.PARAMETER})
+    @interface ParamAnnotation {}
+
+    /*  If more cases are added in the future, it should be taken into account
+     *  that method checkInitSymbol locates the inner class looking for its
+     *  container method, which in the cases below are m1 and m2. So new cases
+     *  must have different names for container methods or method checkInitSymbol
+     *  should be changed.
+     */
+    public class initParams {
+        public initParams(@ParamAnnotation int i) {}
+
+        public void m1() {
+            new initParams(2) {};
+        }
+    }
+
+    class Generics<T1> {
+        T1 obj1;
+        Object obj2;
+        <T2> Generics(@ParamAnnotation T1 t1, @ParamAnnotation T2 t2) {
+            obj1 = t1;
+            obj2 = t2;
+        }
+
+        void m2() {
+            Generics<Integer> a = new <String>Generics<Integer>(
+                    new Integer(11), "foo") {};
+        }
+    }
+}
diff --git a/test/tools/javac/T8011181/EmptyUTF8ForInnerClassNameTest.java b/test/tools/javac/T8011181/EmptyUTF8ForInnerClassNameTest.java
new file mode 100644
index 0000000..27adb3c
--- /dev/null
+++ b/test/tools/javac/T8011181/EmptyUTF8ForInnerClassNameTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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 8011181
+ * @summary javac, empty UTF8 entry generated for inner class
+ */
+
+import java.io.BufferedInputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.classfile.ClassFile;
+
+import static com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8;
+import static com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info;
+import static com.sun.tools.classfile.ConstantPool.CPInfo;
+
+public class EmptyUTF8ForInnerClassNameTest {
+
+    public static void main(String[] args) throws Exception {
+        new EmptyUTF8ForInnerClassNameTest().run();
+    }
+
+    void run() throws Exception {
+        checkClassFile(Paths.get(System.getProperty("test.classes"),
+                this.getClass().getName() + "$1.class"));
+        checkClassFile(Paths.get(System.getProperty("test.classes"),
+                this.getClass().getName() + "$EnumPlusSwitch.class"));
+    }
+
+    void checkClassFile(final Path path) throws Exception {
+        ClassFile classFile = ClassFile.read(
+                new BufferedInputStream(Files.newInputStream(path)));
+        for (CPInfo cpInfo : classFile.constant_pool.entries()) {
+            if (cpInfo.getTag() == CONSTANT_Utf8) {
+                CONSTANT_Utf8_info utf8Info = (CONSTANT_Utf8_info)cpInfo;
+                Assert.check(utf8Info.value.length() > 0,
+                        "UTF8 with length 0 found at class " + classFile.getName());
+            }
+        }
+    }
+
+    static class EnumPlusSwitch {
+        enum E {E1}
+
+        public int m (E e) {
+            switch (e) {
+                case E1:
+                    return 0;
+            }
+            return -1;
+        }
+    }
+
+}
diff --git a/test/tools/javac/T8016099/UncheckedWarningRegressionTest.java b/test/tools/javac/T8016099/UncheckedWarningRegressionTest.java
new file mode 100644
index 0000000..2a66ad4
--- /dev/null
+++ b/test/tools/javac/T8016099/UncheckedWarningRegressionTest.java
@@ -0,0 +1,32 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     8016099
+ * @summary Some SuppressWarnings annotations ignored ( unchecked, rawtypes )
+ * @compile UncheckedWarningRegressionTest.java
+ * @compile/fail/ref=UncheckedWarningRegressionTest.out -XDrawDiagnostics -Werror -Xlint:unchecked UncheckedWarningRegressionTest.java
+ */
+
+public class UncheckedWarningRegressionTest {
+    <T> void suppressedWarningsFinalInitializer() {
+        @SuppressWarnings("unchecked")
+        T[] tt = (T[]) FINAL_EMPTY_ARRAY;
+    }
+
+    final Object[] FINAL_EMPTY_ARRAY = {};
+
+    <T> void finalInitializer() {
+        T[] tt = (T[]) FINAL_EMPTY_ARRAY;
+    }
+
+    <T> void suppressedWarningsNonFinalInitializer() {
+        @SuppressWarnings("unchecked")
+        T[] tt = (T[]) NON_FINAL_EMPTY_ARRAY;
+    }
+
+    Object[] NON_FINAL_EMPTY_ARRAY = {};
+
+    <T> void nonFinalInitializer() {
+        T[] tt = (T[]) NON_FINAL_EMPTY_ARRAY;
+    }
+
+}
diff --git a/test/tools/javac/T8016099/UncheckedWarningRegressionTest.out b/test/tools/javac/T8016099/UncheckedWarningRegressionTest.out
new file mode 100644
index 0000000..05bd6f7
--- /dev/null
+++ b/test/tools/javac/T8016099/UncheckedWarningRegressionTest.out
@@ -0,0 +1,5 @@
+UncheckedWarningRegressionTest.java:18:24: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Object[], T[]
+UncheckedWarningRegressionTest.java:29:24: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Object[], T[]
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/TryWithResources/T7164542.java b/test/tools/javac/TryWithResources/T7164542.java
new file mode 100644
index 0000000..9e3f2c1
--- /dev/null
+++ b/test/tools/javac/TryWithResources/T7164542.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ * 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 7164542
+ * @summary try-with-resources: problem with intersection types
+ * @compile T7164542.java
+ */
+
+public class T7164542 {
+    public static <S extends Readable & AutoCloseable,
+                       T extends Appendable & AutoCloseable>
+    void copy(S s, T t, int size) throws Exception {
+        /*
+         * compiler used to fail here with:
+         *     symbol:   method close()
+         *     location: interface Readable
+         *     Fatal Error: Unable to find method close
+         */
+        try (S src = s; T trg = t) {
+        }
+    }
+}
diff --git a/test/tools/javac/TryWithResources/TwrOnNonResource.out b/test/tools/javac/TryWithResources/TwrOnNonResource.out
index c8fe1c5..a68b248 100644
--- a/test/tools/javac/TryWithResources/TwrOnNonResource.out
+++ b/test/tools/javac/TryWithResources/TwrOnNonResource.out
@@ -1,4 +1,4 @@
-TwrOnNonResource.java:12:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:15:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:18:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:12:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: TwrOnNonResource, java.lang.AutoCloseable))
+TwrOnNonResource.java:15:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: TwrOnNonResource, java.lang.AutoCloseable))
+TwrOnNonResource.java:18:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: TwrOnNonResource, java.lang.AutoCloseable))
 3 errors
diff --git a/test/tools/javac/VersionOpt.java b/test/tools/javac/VersionOpt.java
index 285489c..560d47d 100644
--- a/test/tools/javac/VersionOpt.java
+++ b/test/tools/javac/VersionOpt.java
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 2005, 2008, 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
@@ -61,7 +61,7 @@ public class VersionOpt {
             javaHome = javaHome.getParentFile();
         File toolsJar = new File(new File(javaHome, "lib"), "tools.jar");
 
-        if (!javacHome.equals(toolsJar.toURI().toString())){
+        if (!javacHome.equalsIgnoreCase(toolsJar.toURI().toString())) {
             System.err.println("javac not found in tools.jar: " + javacHome);
             System.err.println("rest of test skipped");
             return;
diff --git a/test/tools/javac/annotations/6881115/T6881115.java b/test/tools/javac/annotations/6881115/T6881115.java
index 2f779c4..0c917f1 100644
--- a/test/tools/javac/annotations/6881115/T6881115.java
+++ b/test/tools/javac/annotations/6881115/T6881115.java
@@ -1,3 +1,6 @@
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
 /*
  * @test /nodynamiccopyright/
  * @bug     6881115 6976649
@@ -6,15 +9,18 @@
  * @compile/fail/ref=T6881115.out -XDrawDiagnostics T6881115.java
  */
 
+ at Target({ElementType.TYPE, ElementType.TYPE_PARAMETER, ElementType.ANNOTATION_TYPE})
 @interface A {
     B b() default @B(b2 = 1, b2 = 2);
     B[] b_arr() default {@B(), @B(b2 = 1, b2 = 2)};
 }
+
 @interface B {
     String b1();
     int b2();
 }
+
 @A(b = @B(b2 = 1, b2 = 2),
    b_arr = {@B(), @B(b2 = 1, b2 = 2)})
-class T6881115</*308 @A(b = @B(b2 = 1, b2 = 2),
-                  b_arr = {@B(), @B(b2 = 1, b2 = 2)})*/ X> {}
+class T6881115<@A(b = @B(b2 = 1, b2 = 2),
+                  b_arr = {@B(), @B(b2 = 1, b2 = 2)}) X> {}
diff --git a/test/tools/javac/annotations/6881115/T6881115.out b/test/tools/javac/annotations/6881115/T6881115.out
index 93b90cf..a924a31 100644
--- a/test/tools/javac/annotations/6881115/T6881115.out
+++ b/test/tools/javac/annotations/6881115/T6881115.out
@@ -1,11 +1,16 @@
-T6881115.java:10:30: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:10:19: compiler.err.annotation.missing.default.value: B, b1
-T6881115.java:11:26: compiler.err.annotation.missing.default.value.1: B, b1,b2
-T6881115.java:11:43: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:11:32: compiler.err.annotation.missing.default.value: B, b1
-T6881115.java:17:19: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:17:8: compiler.err.annotation.missing.default.value: B, b1
-T6881115.java:18:13: compiler.err.annotation.missing.default.value.1: B, b1,b2
-T6881115.java:18:30: compiler.err.duplicate.annotation.member.value: b2, B
-T6881115.java:18:19: compiler.err.annotation.missing.default.value: B, b1
-10 errors
+T6881115.java:14:30: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:14:19: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:15:26: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:15:43: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:15:32: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:23:19: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:23:8: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:24:13: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:24:30: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:24:19: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:25:34: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:25:23: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:26:28: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:26:45: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:26:34: compiler.err.annotation.missing.default.value: B, b1
+15 errors
diff --git a/test/tools/javac/annotations/clinit/AnnoWithClinit1.java b/test/tools/javac/annotations/clinit/AnnoWithClinit1.java
new file mode 100644
index 0000000..4c3498f
--- /dev/null
+++ b/test/tools/javac/annotations/clinit/AnnoWithClinit1.java
@@ -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 {}
+}
+
+
+ at AnnoWithClinit1
+class BarAnnoClinit1 {}
+
+ at interface AAnnoClinit1 {
+    Runnable r2 = new Runnable() { public void run() { }};
+    String str1();
+    String str2withdefault() default "bar";
+}
+
+ at AAnnoClinit1(str1="value")
+class TestAnnoClinit1 { }
diff --git a/test/tools/javac/annotations/clinit/AnnoWithClinitFail.java b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.java
new file mode 100644
index 0000000..52d0e8a
--- /dev/null
+++ b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.java
@@ -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 {}
+}
+
+ at AnnoWithClinitFail
+class TestAnnoWithClinitFail { }
diff --git a/test/tools/javac/annotations/clinit/AnnoWithClinitFail.out b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.out
new file mode 100644
index 0000000..c9526b4
--- /dev/null
+++ b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.out
@@ -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
diff --git a/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java
new file mode 100644
index 0000000..baf8b14
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.java
@@ -0,0 +1,18 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Base annotation specify itself as ContainerAnnotation
+ * @compile/fail/ref=BaseAnnoAsContainerAnno.out -XDrawDiagnostics BaseAnnoAsContainerAnno.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(Foo.class)
+ at interface Foo {
+    Foo[] value() default {};
+}
+
+ at Foo() @Foo()
+public class BaseAnnoAsContainerAnno {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out
new file mode 100644
index 0000000..0d6975a
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/BaseAnnoAsContainerAnno.out
@@ -0,0 +1,2 @@
+BaseAnnoAsContainerAnno.java:13:11: compiler.err.cyclic.annotation.element
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java b/test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java
new file mode 100644
index 0000000..848cd18
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean BasicRepeatingAnnotations BasicRepeatingAnnos BasicNonRepeatingAnno Foo Foos Bar
+ * @run compile BasicRepeatingAnnotations.java
+ * @run main BasicRepeatingAnnotations
+ */
+
+import java.lang.annotation.*;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(Foos.class)
+ at interface Foo {}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface Foos {
+    Foo[] value();
+}
+
+ at interface Bar {}
+
+ at Foo @Foo
+ at Foo
+ at Bar
+ at Foo
+ at Foo
+ at Foo
+ at Foo
+ at Foo @Foo
+ at Foo
+class BasicRepeatingAnnos {}
+
+ at Foo
+class BasicNonRepeatingAnno {}
+
+public class BasicRepeatingAnnotations {
+    public static void main(String[] args) throws Exception {
+        Annotation a = BasicRepeatingAnnos.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+
+        // verify that container not present on nonrepeating
+        a = BasicNonRepeatingAnno.class.getAnnotation(Foos.class);
+        if (a != null) {
+            throw new RuntimeException("Container annotation present");
+        }
+        a = BasicNonRepeatingAnno.class.getAnnotation(Foo.class);
+        if (a == null) {
+            throw new RuntimeException("Repeated annoation not directly present");
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java b/test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java
new file mode 100644
index 0000000..bdcfb1e
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Foos Foo Bars Bar Baz Bazs CheckTargets
+ * @run compile CheckTargets.java
+ */
+
+import java.lang.annotation.*;
+
+ at Repeatable(Foos.class)
+ at Target(ElementType.TYPE)
+ at interface Foo {}
+
+ at Target(ElementType.ANNOTATION_TYPE)
+ at interface Foos {
+    Foo[] value();
+}
+
+ at Repeatable(Bars.class)
+ at Target(ElementType.TYPE)
+ at interface Bar {}
+
+ at Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+ at interface Bars {
+    Bar[] value();
+}
+
+
+ at Repeatable(Bazs.class)
+ at Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
+ at interface Baz {}
+
+ at Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+ at interface Bazs {
+    Baz[] value();
+}
+
+
+public class CheckTargets {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java b/test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java
new file mode 100644
index 0000000..f441f5b
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/ClassReaderDefault.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ *
+ * @bug 7199925
+ *
+ * @clean ClassReaderDefault SeparateCompile
+ * @compile ClassReaderDefault.java
+ * @compile SeparateCompile.java
+ */
+import java.lang.annotation.Repeatable;
+
+public class ClassReaderDefault {
+}
+
+ at interface FooContainer {
+     Foo[] value();
+     int f() default 0;
+}
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java b/test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java
new file mode 100644
index 0000000..86cb6a0
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Bar BarContainer ContainerHasRepeatedContained
+ * @run compile ContainerHasRepeatedContained.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(BarContainer.class)
+ at interface Bar {}
+
+ at Bar
+ at Bar
+ at interface BarContainer {
+    Bar[] value();
+}
+
+public class ContainerHasRepeatedContained {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java
new file mode 100644
index 0000000..82d5270
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.java
@@ -0,0 +1,23 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Cyclic annotation not allowed
+ * @compile/fail/ref=CyclicAnnotation.out -XDrawDiagnostics CyclicAnnotation.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(Foo.class)
+ at interface Baz {
+    Foo[] value() default {};
+}
+
+ at Repeatable(Baz.class)
+ at interface Foo{
+    Baz[] value() default {};
+}
+
+ at Foo(value = {@Baz, at Baz})
+ at Baz(value = {@Foo, at Foo})
+public class CyclicAnnotation {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out
new file mode 100644
index 0000000..84079dd
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/CyclicAnnotation.out
@@ -0,0 +1,2 @@
+CyclicAnnotation.java:13:11: compiler.err.cyclic.annotation.element
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java b/test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java
new file mode 100644
index 0000000..4f8778d
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultCasePresent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Default case for methods other than value() in ContainerAnno
+ * @compile DefaultCasePresent.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer {
+    Foo[] value();
+    String other() default "other-method";
+}
+
+ at Foo @Foo
+public class DefaultCasePresent {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java b/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java
new file mode 100644
index 0000000..bffe1b5
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultTarget.java
@@ -0,0 +1,47 @@
+/*
+ * 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 8006547
+ * @compile DefaultTarget.java
+ */
+
+ at Target({
+    ElementType.CONSTRUCTOR,
+    ElementType.PARAMETER,
+    ElementType.TYPE,
+    ElementType.METHOD,
+    ElementType.LOCAL_VARIABLE,
+    ElementType.PACKAGE,
+    ElementType.ANNOTATION_TYPE,
+    ElementType.FIELD,
+})
+ at interface Container {
+  DefaultTarget[] value();
+}
+
+ at Repeatable(Container.class)
+public @interface DefaultTarget {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java
new file mode 100644
index 0000000..2338329
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8006547
+ * @compile/fail/ref=DefaultTargetTypeParameter.out -XDrawDiagnostics DefaultTargetTypeParameter.java
+ */
+
+ at Target({
+    ElementType.TYPE_PARAMETER,
+})
+ at interface Container {
+  DefaultTargetTypeParameter[] value();
+}
+
+ at Repeatable(Container.class)
+public @interface DefaultTargetTypeParameter {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out
new file mode 100644
index 0000000..fc1f934
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeParameter.out
@@ -0,0 +1,2 @@
+DefaultTargetTypeParameter.java:39:1: compiler.err.invalid.repeatable.annotation.incompatible.target: Container, DefaultTargetTypeParameter
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java
new file mode 100644
index 0000000..4c15843
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8006547
+ * @compile/fail/ref=DefaultTargetTypeUse.out -XDrawDiagnostics DefaultTargetTypeUse.java
+ */
+
+ at Target({
+    ElementType.TYPE_USE,
+})
+ at interface Container {
+  DefaultTargetTypeUse[] value();
+}
+
+ at Repeatable(Container.class)
+public @interface DefaultTargetTypeUse {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out
new file mode 100644
index 0000000..1aba28b
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DefaultTargetTypeUse.out
@@ -0,0 +1,2 @@
+DefaultTargetTypeUse.java:39:1: compiler.err.invalid.repeatable.annotation.incompatible.target: Container, DefaultTargetTypeUse
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java b/test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java
new file mode 100644
index 0000000..939ce4a
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean DelayRepeatedContainer Bar BarContainer
+ * @run compile DelayRepeatedContainer.java
+ */
+
+import java.lang.annotation.*;
+
+public class DelayRepeatedContainer {
+    @Bar("apa") @Bar("banan")
+    String meh() { return "meh"; }
+}
+
+ at Bar("katt")
+ at Bar("lol")
+ at Repeatable(BarContainer.class)
+ at interface Bar {
+    String value();
+}
+
+ at interface BarContainer {
+    Bar[] value();
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java
new file mode 100644
index 0000000..95fd96c
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.java
@@ -0,0 +1,21 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Base anno is Documented but Container anno is not
+ * @compile/fail/ref=DocumentedContainerAnno.out -XDrawDiagnostics DocumentedContainerAnno.java
+ */
+
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Documented;
+
+ at Documented
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer{
+    Foo[] value();
+}
+
+ at Foo @Foo
+public class DocumentedContainerAnno {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out
new file mode 100644
index 0000000..bb267c4
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DocumentedContainerAnno.out
@@ -0,0 +1,2 @@
+DocumentedContainerAnno.java:13:1: compiler.err.invalid.repeatable.annotation.not.documented: FooContainer, Foo
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.java b/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.java
new file mode 100644
index 0000000..a7a08ef
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.java
@@ -0,0 +1,37 @@
+/*
+ * 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 7196531
+ * @compile/fail/ref=DuplicateErrors.out  -XDrawDiagnostics DuplicateErrors.java
+ */
+
+
+ at interface Foo {}
+
+ at Foo
+ at Foo
+ at Foo
+public class DuplicateErrors {
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.out b/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.out
new file mode 100644
index 0000000..c38501e
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/DuplicateErrors.out
@@ -0,0 +1,3 @@
+DuplicateErrors.java:34:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
+DuplicateErrors.java:35:1: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
+2 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java
new file mode 100644
index 0000000..20f8ad2
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.java
@@ -0,0 +1,22 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author   sogoel
+ * @summary Base anno is Inherited but Container anno is not
+ * @compile/fail/ref=InheritedContainerAnno.out -XDrawDiagnostics InheritedContainerAnno.java
+ */
+
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Inherited;
+
+ at Inherited
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer{
+    Foo[] value();
+}
+
+ at Foo @Foo
+public class InheritedContainerAnno {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out
new file mode 100644
index 0000000..4373622
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/InheritedContainerAnno.out
@@ -0,0 +1,2 @@
+InheritedContainerAnno.java:13:1: compiler.err.invalid.repeatable.annotation.not.inherited: FooContainer, Foo
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java b/test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java
new file mode 100644
index 0000000..f85924a
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Foos Foo
+ * @run compile/fail InvalidTarget.java
+ */
+
+import java.lang.annotation.*;
+
+ at Repeatable(Foos.class)
+ at Target(ElementType.ANNOTATION_TYPE)
+ at interface Foo {}
+
+ at Target(ElementType.TYPE)
+ at interface Foos {
+    Foo[] value();
+}
+
+public class InvalidTargets {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java
new file mode 100644
index 0000000..aff6a15
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.java
@@ -0,0 +1,19 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362 8001114
+ * @author  sogoel
+ * @summary ContainerAnnotation does not have FooContainer.class specified
+ * @compile/fail/ref=MissingContainer.out -XDrawDiagnostics MissingContainer.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable()
+ at interface Foo {}
+
+ at interface FooContainer {
+    Foo[] value();
+}
+
+ at Foo @Foo
+public class MissingContainer {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out
new file mode 100644
index 0000000..5a0e89d
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainer.out
@@ -0,0 +1,4 @@
+MissingContainer.java:18:1: compiler.err.invalid.repeatable.annotation: Foo
+MissingContainer.java:18:6: compiler.err.invalid.repeatable.annotation: Foo
+MissingContainer.java:11:1: compiler.err.annotation.missing.default.value: java.lang.annotation.Repeatable, value
+3 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java
new file mode 100644
index 0000000..780c370
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.java
@@ -0,0 +1,20 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362 8001114
+ * @author  sogoel
+ * @summary Default case not specified for other methods in container annotation
+ * @compile/fail/ref=MissingDefaultCase1.out -XDrawDiagnostics MissingDefaultCase1.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer {
+    Foo[] value();
+    String other();  // missing default clause
+}
+
+ at Foo @Foo
+public class MissingDefaultCase1 {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out
new file mode 100644
index 0000000..474b6c1
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase1.out
@@ -0,0 +1,3 @@
+MissingDefaultCase1.java:19:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
+MissingDefaultCase1.java:11:1: compiler.err.invalid.repeatable.annotation.elem.nondefault: FooContainer, other()
+2 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java
new file mode 100644
index 0000000..73f2cfe
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.java
@@ -0,0 +1,20 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Missing default case for other method and return type is base annotation
+ * @compile/fail/ref=MissingDefaultCase2.out -XDrawDiagnostics MissingDefaultCase2.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer {
+    Foo[] value();
+    Foo other();  // missing default clause and return type is an annotation
+}
+
+ at Foo @Foo
+public class MissingDefaultCase2 {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out
new file mode 100644
index 0000000..de46710
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingDefaultCase2.out
@@ -0,0 +1,3 @@
+MissingDefaultCase2.java:19:1: compiler.err.duplicate.annotation.invalid.repeated: Foo
+MissingDefaultCase2.java:11:1: compiler.err.invalid.repeatable.annotation.elem.nondefault: FooContainer, other()
+2 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java
new file mode 100644
index 0000000..a539a94
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.java
@@ -0,0 +1,20 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author   sogoel
+ * @summary Missing value() method in ContainerAnnotation
+ * @compile/fail/ref=MissingValueMethod.out -XDrawDiagnostics MissingValueMethod.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at interface FooContainer{
+    Foo[] values();  // wrong method name
+}
+
+ at Foo @Foo
+public class MissingValueMethod {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out
new file mode 100644
index 0000000..bb1e888
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingValueMethod.out
@@ -0,0 +1,4 @@
+MissingValueMethod.java:18:1: compiler.err.invalid.repeatable.annotation.no.value: FooContainer
+MissingValueMethod.java:18:6: compiler.err.invalid.repeatable.annotation.no.value: FooContainer
+MissingValueMethod.java:11:1: compiler.err.invalid.repeatable.annotation.no.value: FooContainer
+3 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java b/test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java
new file mode 100644
index 0000000..8459f86
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MultiLevelRepeatableAnno.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug     7169362
+ * @author  sogoel
+ * @summary ContainerType can have its own container
+ * @compile MultiLevelRepeatableAnno.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+ at Repeatable(FooContainerContainer.class)
+ at interface FooContainer {
+    Foo[] value();
+}
+
+ at interface FooContainerContainer {
+  FooContainer[] value();
+}
+
+ at Foo @Foo
+public class MultiLevelRepeatableAnno  {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java b/test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java
new file mode 100644
index 0000000..5992dfc
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/MultipleAnnoMixedOrder.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Repeatable annotations in random order
+ * @compile MultipleAnnoMixedOrder.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {
+    int getNumbers();
+}
+
+ at interface FooContainer {
+  Foo[] value();
+}
+
+ at Repeatable(BazContainer.class)
+ at interface Baz {
+    String getStr();
+}
+
+ at interface BazContainer {
+  Baz[] value();
+}
+
+ at Foo(getNumbers=1)
+ at Baz(getStr="hello")
+ at Foo(getNumbers=2)
+ at Baz(getStr="world")
+public class MultipleAnnoMixedOrder  {}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java b/test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java
new file mode 100644
index 0000000..4694989
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean NestedContainers BasicRepeatingAnnos BasicRepeatingAnnos2 Foo Foos FoosFoos
+ * @run compile NestedContainers.java
+ * @run main NestedContainers
+ */
+
+import java.lang.annotation.*;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(Foos.class)
+ at interface Foo {}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(FoosFoos.class)
+ at interface Foos {
+    Foo[] value();
+}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface FoosFoos {
+    Foos[] value();
+}
+
+ at Foo
+ at Foo
+class BasicRepeatingAnnos {}
+
+ at Foos({})
+ at Foos({})
+class BasicRepeatingAnnos2 {}
+
+public class NestedContainers {
+    public static void main(String[] args) throws Exception {
+        Annotation a = BasicRepeatingAnnos.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+
+        // Check 2:nd level container
+        a = BasicRepeatingAnnos2.class.getAnnotation(FoosFoos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.java b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.java
new file mode 100644
index 0000000..a4c8e21
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.java
@@ -0,0 +1,12 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Foo is not a repeatable annotation but used as one.
+ * @compile/fail/ref=NoRepeatableAnno.out -XDrawDiagnostics NoRepeatableAnno.java
+ */
+
+ at interface Foo {}
+
+ at Foo @Foo
+public class NoRepeatableAnno {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out
new file mode 100644
index 0000000..0aa681f
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/NoRepeatableAnno.out
@@ -0,0 +1,2 @@
+NoRepeatableAnno.java:11:6: compiler.err.duplicate.annotation.missing.container: Foo, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java b/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java
new file mode 100644
index 0000000..eaa333e
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer.java
@@ -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.
+ */
+
+import java.lang.annotation.*;
+
+/**
+ * @test
+ * @bug 8006547
+ * @compile NoTargetOnContainer.java
+ */
+
+ at interface FooContainer {
+  Foo[] value();
+}
+
+ at Target({
+    ElementType.CONSTRUCTOR,
+    ElementType.PARAMETER,
+    ElementType.TYPE,
+    ElementType.METHOD,
+    ElementType.LOCAL_VARIABLE,
+    ElementType.PACKAGE,
+    ElementType.ANNOTATION_TYPE,
+    ElementType.FIELD,
+})
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+class NoTargetOnContainer {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java b/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java
new file mode 100644
index 0000000..539e299
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/NoTargetOnContainer2.java
@@ -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.
+ */
+
+import java.lang.annotation.*;
+
+/**
+ * @test
+ * @bug 8006547
+ * @compile NoTargetOnContainer2.java
+ */
+
+ at interface FooContainer {
+  Foo[] value();
+}
+
+ at Target({
+    ElementType.CONSTRUCTOR,
+    ElementType.PARAMETER,
+    ElementType.TYPE,
+    ElementType.METHOD,
+    ElementType.LOCAL_VARIABLE,
+    ElementType.PACKAGE,
+    ElementType.ANNOTATION_TYPE,
+    ElementType.FIELD,
+    ElementType.TYPE_USE,
+    ElementType.TYPE_PARAMETER})
+ at Repeatable(FooContainer.class)
+ at interface Foo {}
+
+class NoTargetOnContainer2 {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java b/test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java
new file mode 100644
index 0000000..2a6fc88
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean RepMemberAnno Bar BarContainer
+ * @run compile RepMemberAnno.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+public class RepMemberAnno {
+    @Bar("Apa") @Bar("Banan")
+    public void meh() {}
+}
+
+ at Repeatable(BarContainer.class)
+ at interface Bar {
+    String value();
+}
+
+ at interface BarContainer {
+    Bar[] value();
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java b/test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java
new file mode 100644
index 0000000..79fdf21
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean RepSelfMemberAnno BarContainer BarContainerContainer
+ * @run compile RepSelfMemberAnno.java
+ */
+
+import java.lang.annotation.*;
+
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(BarContainer.class)
+public @interface RepSelfMemberAnno {
+    @RepSelfMemberAnno @RepSelfMemberAnno
+    String meh() default "banan";
+}
+
+
+ at Repeatable(BarContainerContainer.class)
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface BarContainer {
+    RepSelfMemberAnno[] value();
+}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface BarContainerContainer {
+    BarContainer[] value();
+    String meh() default "apa";
+}
+
+ at BarContainer(value={})
+ at BarContainer(value={})
+ at interface Bar {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java b/test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java
new file mode 100644
index 0000000..62bc29f
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail RepeatingAndContainerPresent.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+ at Repeatable(Foos.class)
+ at interface Foo {}
+
+ at interface Foos {
+    Foo[] value();
+}
+
+
+ at Foo
+ at Foo
+ at Foos({})
+public class RepeatingAndContainerPresent {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java
new file mode 100644
index 0000000..7d2ba5e
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Container annotation is not checked for semantic correctness
+ * @bug 8001114
+ *
+ * @compile/fail/ref=RepeatingTargetNotAllowed.out -XDrawDiagnostics RepeatingTargetNotAllowed.java
+ */
+
+import java.lang.annotation.*;
+
+ at Repeatable(Foos.class)
+ at interface Foo {}
+
+ at Target(ElementType.ANNOTATION_TYPE)
+ at interface Foos {
+    Foo[] value();
+}
+
+public class RepeatingTargetNotAllowed {
+    @Foo @Foo int f = 0;
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out
new file mode 100644
index 0000000..7979c82
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingTargetNotAllowed.out
@@ -0,0 +1,2 @@
+RepeatingTargetNotAllowed.java:43:5: compiler.err.invalid.repeatable.annotation.incompatible.target: Foos, Foo
+1 error
diff --git a/test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java b/test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java
new file mode 100644
index 0000000..7a70c90
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean SelfRepeatingAnnotations Foos SelfRepeatingAnno
+ * @run compile SelfRepeatingAnnotations.java
+ * @run main SelfRepeatingAnnotations
+ */
+
+import java.lang.annotation.*;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface Foos {
+    SelfRepeatingAnno[] value();
+}
+
+ at SelfRepeatingAnno
+ at Retention(RetentionPolicy.RUNTIME)
+ at SelfRepeatingAnno
+ at Repeatable(Foos.class)
+ at interface SelfRepeatingAnno {}
+
+public class SelfRepeatingAnnotations {
+    public static void  main(String[] args) throws Exception {
+        Annotation a = SelfRepeatingAnno.class.getAnnotation(Foos.class);
+        if (a == null) {
+            throw new RuntimeException("Container annotation missing");
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/SeparateCompile.java b/test/tools/javac/annotations/repeatingAnnotations/SeparateCompile.java
new file mode 100644
index 0000000..66c5d0e
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/SeparateCompile.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * part of test for bug: 7199925
+ * see: ClassReaderDefault.java
+ */
+ at Foo  @Foo
+public class SeparateCompile {
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java b/test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java
new file mode 100644
index 0000000..56cc83c
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile SingleRepeatingAndContainer.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+ at Repeatable(Foos.class)
+ at interface Foo {}
+
+ at interface Foos {
+    Foo[] value();
+}
+
+ at Foo
+ at Foos({})
+public class SingleRepeatingAndContainer {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/UseWrongRepeatable.java b/test/tools/javac/annotations/repeatingAnnotations/UseWrongRepeatable.java
new file mode 100644
index 0000000..8d4b37f
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/UseWrongRepeatable.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @summary Smoke test for repeating annotations
+ * @compile/fail UseWrongRepeatable.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+ at interface Foos {
+    UseWrongRepeatable[] value();
+}
+
+ at Repeatable(Target.class)
+public @interface UseWrongRepeatable {}
+
+ at UseWrongRepeatable @UseWrongRepeatable
+ at interface Foo {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java
new file mode 100644
index 0000000..69f25b6
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.java
@@ -0,0 +1,21 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     7169362
+ * @author  sogoel
+ * @summary Wrong return type for value() in ContainerAnnotation
+ * @compile/fail/ref=WrongReturnTypeForValue.out -XDrawDiagnostics WrongReturnTypeForValue.java
+ */
+
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(FooContainer.class)
+ at interface Foo {
+    int getNumbers();
+}
+
+ at interface FooContainer{
+    Foo value();     // wrong return type
+}
+
+ at Foo @Foo
+public class WrongReturnTypeForValue {}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out
new file mode 100644
index 0000000..add7bba
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongReturnTypeForValue.out
@@ -0,0 +1,4 @@
+WrongReturnTypeForValue.java:20:1: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
+WrongReturnTypeForValue.java:20:6: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
+WrongReturnTypeForValue.java:11:1: compiler.err.invalid.repeatable.annotation.value.return: FooContainer, Foo, Foo[]
+3 errors
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java
new file mode 100644
index 0000000..03e9dbe
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/BasicSyntaxCombo.java
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug      8002157
+ * @author   sogoel
+ * @summary  Basic Syntax test for repeating annotations on all elements
+ * @build    Helper
+ * @compile  BasicSyntaxCombo.java
+ * @run main BasicSyntaxCombo
+ */
+
+
+import java.util.Arrays;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+import javax.tools.Diagnostic;
+
+/*
+ * Generate test src for element kinds with repeating annotations.
+ * The test uses Helper.java to get the template to create test src and
+ * compile the test src.
+ * The test passes if valid test src compile as expected and
+ * and invalid test src fail as expected.
+ */
+
+public class BasicSyntaxCombo extends Helper{
+    static int errors = 0;
+    static boolean exitMode = false;
+    static String TESTPKG = "testpkg";
+    static String srcContent = "";
+    static String pkgInfoContent = "";
+
+    static {
+        // If EXIT_ON_FAIL is set, the combo test will exit at the first error
+        String exitOnFail = System.getenv("EXIT_ON_FAIL");
+        if (exitOnFail == null || exitOnFail == ""  ) {
+            exitMode = false;
+        }
+        else {
+            if (exitOnFail.equalsIgnoreCase("YES") ||
+                    exitOnFail.equalsIgnoreCase("Y") ||
+                    exitOnFail.equalsIgnoreCase("TRUE") ||
+                    exitOnFail.equalsIgnoreCase("T")) {
+                exitMode = true;
+            }
+        }
+    }
+
+    enum TestElem {
+        ANNOTATION_TYPE(true),
+        PACKAGE(true),
+        CONSTRUCTOR(true),
+        FIELD(true),
+        LOCAL_VARIABLE(true),
+        METHOD(true),
+        TYPE(true),
+        PARAMETER(true),
+        INNER_CLASS(true),
+        STATIC_INI(false),
+        INSTANCE_INI(false);
+
+        TestElem(boolean compile) {
+            this.compile = compile;
+        }
+
+        boolean compile;
+        boolean shouldCompile() {
+            return compile;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        new BasicSyntaxCombo().runTest();
+    }
+
+    public void runTest() throws Exception {
+        boolean result = false;
+        Iterable<? extends JavaFileObject> files = null;
+        int testCtr = 0;
+        for (TestElem type : TestElem.values()) {
+            testCtr++;
+            String className = "BasicCombo_"+type;
+            files = getFileList(className, type);
+
+            boolean shouldCompile = type.shouldCompile();
+            result = getCompileResult(className, shouldCompile,files);
+
+            if (shouldCompile && !result) {
+                error(className + " did not compile as expected", srcContent);
+                if(!pkgInfoContent.isEmpty()) {
+                    System.out.println("package-info.java contents: " + pkgInfoContent);
+                }
+            }
+
+            if (!shouldCompile && !result) {
+                error(className + " compiled unexpectedly", srcContent);
+                if(!pkgInfoContent.isEmpty()) {
+                    System.out.println("package-info.java contents: " + pkgInfoContent);
+                }
+            }
+        }
+
+        System.out.println("Total number of tests run: " + testCtr);
+        System.out.println("Total number of errors: " + errors);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    private boolean getCompileResult(String className, boolean shouldCompile,
+            Iterable<? extends JavaFileObject> files) throws Exception {
+
+        DiagnosticCollector<JavaFileObject> diagnostics =
+                new DiagnosticCollector<JavaFileObject>();
+        boolean ok =  Helper.compileCode(diagnostics,files);
+        if (!shouldCompile && !ok) {
+            checkErrorKeys(className, diagnostics);
+        }
+        return (shouldCompile == ok);
+    }
+
+    private void checkErrorKeys (
+            String className, DiagnosticCollector<JavaFileObject> diagnostics) throws Exception {
+        String expectedErrKey = "compiler.err.illegal.start.of.type";
+        for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
+            if ((d.getKind() == Diagnostic.Kind.ERROR) &&
+                d.getCode().contains(expectedErrKey)) {
+                break; // Found the expected error
+            } else {
+                error("Incorrect error key, expected = "
+                      + expectedErrKey + ", Actual = " + d.getCode()
+                      + " for className = " + className, srcContent);
+            }
+        }
+    }
+
+    private Iterable<? extends JavaFileObject> getFileList(String className,
+            TestElem type ) {
+
+        String template = Helper.template;
+        String replaceStr = "/*"+type+"*/";
+        StringBuilder annoData = new StringBuilder();
+        annoData.append(Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal())
+                .append(Helper.ContentVars.CONTAINER.getVal())
+                .append(Helper.ContentVars.REPEATABLE.getVal())
+                .append(Helper.ContentVars.BASE.getVal());
+
+        JavaFileObject pkgInfoFile = null;
+
+        if (type.equals("PACKAGE")) {
+            srcContent = template.replace(replaceStr, "package testpkg;")
+                        .replace("#ClassName", className);
+
+            String pkgInfoName = TESTPKG+"."+"package-info";
+            pkgInfoContent = Helper.ContentVars.REPEATABLEANNO.getVal()
+                             + "package " + TESTPKG + ";"
+                             + annoData;
+            pkgInfoFile = getFile(pkgInfoName, pkgInfoContent);
+        } else {
+            template = template.replace(replaceStr, Helper.ContentVars.REPEATABLEANNO.getVal())
+                       .replace("#ClassName", className);
+            srcContent = annoData + template;
+        }
+
+        JavaFileObject srcFile = getFile(className, srcContent);
+
+        Iterable<? extends JavaFileObject> files = null;
+        if (pkgInfoFile != null) {
+            files = Arrays.asList(pkgInfoFile,srcFile);
+        }
+        else {
+            files = Arrays.asList(srcFile);
+        }
+        return files;
+    }
+
+    private void error(String msg, String... contents) throws Exception {
+        System.out.println("error: " + msg);
+        errors++;
+        if (contents.length == 1) {
+            System.out.println("Contents = " + contents[0]);
+        }
+        // Test exits as soon as it gets a failure
+        if (exitMode) throw new Exception();
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java
new file mode 100644
index 0000000..8a2bcca
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/DeprecatedAnnoCombo.java
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug      8002157
+ * @author   sogoel
+ * @summary  Combo test to check for usage of Deprecated
+ * @build    Helper
+ * @compile  DeprecatedAnnoCombo.java
+ * @run main DeprecatedAnnoCombo
+ */
+
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+/*
+ * Generate test src for use of @Deprecated on base anno
+ * or container anno or on both. In all cases, test src should compile and a
+ * warning should be generated. Repeating annotations used only on class for
+ * these generated test src.
+ */
+
+public class DeprecatedAnnoCombo extends Helper {
+    static int errors = 0;
+
+    enum TestCases {
+        DeprecatedonBoth,
+        DeprecatedonContainer,
+        DeprecatedonBase;
+    }
+
+    public static void main(String[] args) throws Exception {
+        new DeprecatedAnnoCombo().runTest();
+    }
+
+    public void runTest() throws Exception {
+        boolean ok = false;
+        int testCtr = 0;
+
+        for (TestCases clName : TestCases.values()) {
+            testCtr++;
+
+            // Create test source content
+            String contents = getContent(clName.toString());
+
+            // Compile the generated source file
+            DiagnosticCollector<JavaFileObject> diagnostics =
+                    new DiagnosticCollector<JavaFileObject>();
+            ok = compileCode(clName.toString(), contents, diagnostics);
+
+            String errorKey1 = "compiler.note.deprecated.filename";
+            String errorKey2 = "compiler.note.deprecated.recompile";
+            List<Diagnostic<? extends JavaFileObject>> diags = diagnostics.getDiagnostics();
+
+            //Check for deprecated warnings
+            if (ok) {
+                if (diags.size() == 0) {
+                    error("Did not get any warnings for @Deprecated usage");
+                } else {
+                    for (Diagnostic<?> d : diags) {
+                        if (d.getKind() == Diagnostic.Kind.NOTE) {
+                            if (d.getCode().contains(errorKey1)
+                                || d.getCode().contains(errorKey2)) {
+                                System.out.println("TestCase =" + clName + " passed as expected");
+                            } else {
+                                error("TestCase =" + clName + " did not give correct warnings" +
+                                    "Expected warning keys: " +
+                                    "errorKey1 = " + errorKey1 +
+                                    "errorKey2 = " + errorKey2 +
+                                    "actualErrorKey = " + d.getCode(), contents);
+                            }
+                        } else {
+                            error("Diagnostic Kind is incorrect, expected = " +
+                                 Diagnostic.Kind.NOTE + "actual = " + d.getKind(), contents);
+                        }
+                    }
+                }
+            } else {
+                error("TestCase =" + clName + " did not compile as expected", contents);
+            }
+        }
+
+        System.out.println("Total number of tests run: " + testCtr);
+        System.out.println("Total number of errors: " + errors);
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    private String getContent(String className) {
+        StringBuilder annoData = new StringBuilder();
+
+        switch(className) {
+        case "DeprecatedonBoth":
+            annoData.append(Helper.ContentVars.DEPRECATED.getVal())
+                    .append(Helper.ContentVars.CONTAINER.getVal())
+                    .append(Helper.ContentVars.DEPRECATED.getVal())
+                    .append(Helper.ContentVars.REPEATABLE.getVal())
+                    .append(Helper.ContentVars.BASE.getVal());
+            break;
+        case "DeprecatedonBase":
+            annoData.append(Helper.ContentVars.CONTAINER.getVal())
+                    .append(Helper.ContentVars.DEPRECATED.getVal())
+                    .append(Helper.ContentVars.REPEATABLE.getVal())
+                    .append(Helper.ContentVars.BASE.getVal());
+            break;
+        case "DeprecatedonContainer":
+            annoData.append(Helper.ContentVars.DEPRECATED.getVal())
+                    .append(Helper.ContentVars.CONTAINER.getVal())
+                    .append(Helper.ContentVars.REPEATABLE.getVal())
+                    .append(Helper.ContentVars.BASE.getVal());
+            break;
+        }
+
+        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
+                          + Helper.ContentVars.IMPORTDEPRECATED.getVal()
+                          + annoData
+                          + Helper.ContentVars.REPEATABLEANNO.getVal()
+                          + "\nclass "+ className + "{}";
+        return contents;
+    }
+
+    private void error(String msg, String... contents) {
+        System.out.println("error: " + msg);
+        errors++;
+        if (contents.length == 1) {
+            System.out.println("Contents = " + contents[0]);
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java
new file mode 100644
index 0000000..4bb3728
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/DocumentedAnnoCombo.java
@@ -0,0 +1,125 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug      8002157
+ * @author   sogoel
+ * @summary  Positive combo test for use of Documented on baseAnno/containerAnno
+ * @build    Helper
+ * @compile  DocumentedAnnoCombo.java
+ * @run main DocumentedAnnoCombo
+ */
+
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+/*
+ * Generate valid test src for the use of @Documented on container anno
+ * or on both base anno and container anno. Both test src should compile.
+ * Repeating annotations used only on class for these generated test src.
+ */
+public class DocumentedAnnoCombo extends Helper {
+    static int errors = 0;
+
+    enum TestCases {
+        DocumentedonBothAnno(true),
+        DocumentedonContainer(true);
+
+        TestCases(boolean compile) {
+            this.compile = compile;
+        }
+
+        boolean compile;
+        boolean shouldCompile() {
+            return compile;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        new DocumentedAnnoCombo().runTest();
+    }
+
+    public void runTest() throws Exception {
+        boolean ok = false;
+        int testCtr = 0;
+
+        // Create test source content
+        for (TestCases className : TestCases.values()) {
+            testCtr++;
+            String contents = getContent(className.toString());
+
+            // Compile the generated source file
+            DiagnosticCollector<JavaFileObject> diagnostics =
+                    new DiagnosticCollector<JavaFileObject>();
+            ok = compileCode(className.toString(), contents, diagnostics);
+            if (!ok) {
+                error("Class="+ className +" did not compile as expected", contents);
+            } else {
+                System.out.println("Test passed for className: " + className);
+            }
+        }
+
+        System.out.println("Total number of tests run: " + testCtr);
+        System.out.println("Total number of errors: " + errors);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    private String getContent(String className) {
+
+        StringBuilder annoData = new StringBuilder();
+        switch(className) {
+            case "DocumentedonBothAnno":
+                annoData.append(Helper.ContentVars.DOCUMENTED.getVal())
+                .append(Helper.ContentVars.CONTAINER.getVal())
+                .append(Helper.ContentVars.DOCUMENTED.getVal())
+                .append(Helper.ContentVars.REPEATABLE.getVal())
+                .append(Helper.ContentVars.BASE.getVal());
+            break;
+            case "DocumentedonContainer":
+                annoData.append(Helper.ContentVars.DOCUMENTED.getVal())
+                .append(Helper.ContentVars.CONTAINER.getVal())
+                .append(Helper.ContentVars.REPEATABLE.getVal())
+                .append(Helper.ContentVars.BASE.getVal());
+            break;
+        }
+
+        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
+                          + Helper.ContentVars.IMPORTDOCUMENTED.getVal()
+                          + annoData
+                          + Helper.ContentVars.REPEATABLEANNO.getVal()
+                          + "\nclass "+ className + "{}";
+        return contents;
+    }
+
+    private void error(String msg, String... contents) {
+        System.out.println("error: " + msg);
+        errors++;
+        if (contents.length == 1) {
+            System.out.println("Contents = " + contents[0]);
+        }
+    }
+}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java b/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java
new file mode 100644
index 0000000..0aee99c
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/Helper.java
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+
+public class Helper {
+
+    enum ContentVars {
+
+        IMPORTCONTAINERSTMTS("\nimport java.lang.annotation.Repeatable;\n"),
+        IMPORTDEPRECATED("import java.lang.Deprecated;\n"),
+        IMPORTDOCUMENTED("import java.lang.annotation.Documented;\n"),
+        IMPORTINHERITED("import java.lang.annotation.Inherited;\n"),
+        IMPORTRETENTION("import java.lang.annotation.Retention;\n"
+        + "\nimport java.lang.annotation.RetentionPolicy;\n"),
+        IMPORTSTMTS("import java.lang.annotation.*;\n"),
+        IMPORTEXPECTED("import expectedFiles.*;\n"),
+        REPEATABLE("\n at Repeatable(FooContainer.class)\n"),
+        CONTAINER("@interface FooContainer {\n" + "  Foo[] value();\n}\n"),
+        BASE("@interface Foo {}\n"),
+        BASEANNO("@Foo"),
+        LEGACYCONTAINER("@FooContainer(value = {@Foo, @Foo})\n"),
+        REPEATABLEANNO("\n at Foo() @Foo()"),
+        DEPRECATED("\n at Deprecated"),
+        DOCUMENTED("\n at Documented"),
+        INHERITED("\n at Inherited"),
+        TARGET("\n at Target(#VAL)\n"),
+        RETENTION("@Retention(RetentionPolicy.#VAL)\n"),
+        RETENTIONRUNTIME("@Retention(RetentionPolicy.RUNTIME)\n");
+        private String val;
+
+        private ContentVars(String val) {
+            this.val = val;
+        }
+
+        public String getVal() {
+            return val;
+        }
+    }
+
+    // Create and compile FileObject using values for className and contents
+    public static boolean compileCode(String className, String contents,
+            DiagnosticCollector<JavaFileObject> diagnostics) {
+        boolean ok = false;
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
+        }
+
+        JavaFileObject file = getFile(className, contents);
+        Iterable<? extends JavaFileObject> compilationUnit = Arrays.asList(file);
+
+        CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, compilationUnit);
+        ok = task.call();
+        return ok;
+    }
+    // Compile a list of FileObjects
+    // Used when packages are needed and classes need to be loaded at runtime
+    static File destDir = new File(System.getProperty("user.dir"));
+
+    public static boolean compileCode(DiagnosticCollector<JavaFileObject> diagnostics, Iterable<? extends JavaFileObject> files) {
+        boolean ok = false;
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
+        }
+
+        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+
+        // Assuming filesCount can maximum be 2 and if true, one file is package-info.java
+        if (isPkgInfoPresent(files)) {
+            JavacTask task = (JavacTask) compiler.getTask(null, fm, diagnostics, null, null, files);
+            try {
+                fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+                task.generate();
+            } catch (IOException ioe) {
+                throw new RuntimeException("Compilation failed for package level tests", ioe);
+            }
+            int err = 0;
+            for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
+                if(d.getKind() == Diagnostic.Kind.ERROR) {
+                  err++;
+                }
+            }
+            ok = (err == 0);
+        } else {
+            CompilationTask task = compiler.getTask(null, null, diagnostics, null, null, files);
+            ok = task.call();
+        }
+        return ok;
+    }
+
+    static private boolean isPkgInfoPresent(Iterable<? extends JavaFileObject> files) {
+        Iterator<? extends JavaFileObject> itr = files.iterator();
+        while (itr.hasNext()) {
+            String name = itr.next().getName();
+            if (name.contains("package-info")) {
+                return true;
+            }
+        }
+        return false;
+    }
+    /* String template where /*<TYPE>*/ /*gets replaced by repeating anno
+     * Used to generate test src for combo tests
+     *   - BasicSyntaxCombo.java
+     *   - TargetAnnoCombo.java
+     */
+
+    public static final String template =
+            "/*PACKAGE*/\n"
+            + "//pkg test;\n\n"
+            + "/*ANNODATA*/\n" // import statements, declaration of Foo/FooContainer
+            + "/*TYPE*/ //class\n"
+            + "class #ClassName {\n"
+            + "  /*FIELD*/ //instance var\n"
+            + "  public int x = 0;\n\n"
+            + "  /*FIELD*/ //Enum constants\n"
+            + "  TestEnum testEnum;\n\n"
+            + "  /*FIELD*/ // Static field\n"
+            + "  public static int num;\n\n"
+            + "  /*STATIC_INI*/\n"
+            + "  static { \n" + "num = 10; \n  }\n\n"
+            + "  /*CONSTRUCTOR*/\n"
+            + "  #ClassName() {}\n\n"
+            + "  /*INSTANCE_INI*/\n"
+            + "  { \n x = 10; \n }"
+            + "  /*INNER_CLASS*/\n"
+            + "  class innerClass {}\n"
+            + "  /*METHOD*/\n"
+            + "  void bar(/*PARAMETER*/ int baz) {\n"
+            + "    /*LOCAL_VARIABLE*/\n"
+            + "    int y = 0;\n"
+            + "  }\n"
+            + "}\n\n"
+            + "/*TYPE*/ //Enum\n"
+            + "enum TestEnum {}\n\n"
+            + "/*TYPE*/ //Interface\n"
+            + "interface TestInterface {}\n\n"
+            + "/*TYPE*/\n"
+            + "/*ANNOTATION_TYPE*/\n"
+            + "@interface TestAnnotationType{}\n"
+            + "class TestPkg {}\n"
+            + "class TestTypeAnno </*TYPE_PARAMETER*/ T extends Object> {\n"
+            + "  String /*TYPE_USE*/[] arr;\n"
+            + "}";
+
+    static JavaFileObject getFile(String name, String code) {
+        JavaFileObject o = null;
+        try {
+            o = new JavaStringFileObject(name, code);
+        } catch (URISyntaxException e) {
+            throw new RuntimeException(e);
+        }
+        return o;
+    }
+
+    static class JavaStringFileObject extends SimpleJavaFileObject {
+
+        final String theCode;
+
+        public JavaStringFileObject(String fileName, String theCode) throws URISyntaxException {
+            super(new URI("string:///" + fileName.replace('.', '/') + ".java"), Kind.SOURCE);
+            this.theCode = theCode;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return theCode;
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java
new file mode 100644
index 0000000..cb49350
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/InheritedAnnoCombo.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug      8002157
+ * @author   sogoel
+ * @summary  Positive combo test for use of Inherited on baseAnno/containerAnno
+ * @build    Helper
+ * @compile  InheritedAnnoCombo.java
+ * @run main InheritedAnnoCombo
+ */
+
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+/*
+ * Generate valid test src for the use of @Inherited on container anno
+ * or on both base anno and container anno. Both test src should compile.
+ * Repeating annotations used only on class for these generated test src.
+ */
+
+public class InheritedAnnoCombo extends Helper {
+    static int errors = 0;
+    enum TestCases {
+        InheritedonBothAnno(true),
+        InheritedonBase(true);
+
+        TestCases(boolean compile) {
+            this.compile = compile;
+        }
+
+        boolean compile;
+        boolean shouldCompile() {
+            return compile;
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        new InheritedAnnoCombo().runTest();
+    }
+
+    public void runTest() throws Exception {
+        int testCtr = 0;
+        boolean ok = false;
+
+        // Create test source content
+        for (TestCases className : TestCases.values()) {
+            testCtr++;
+            String contents = getContent(className.toString());
+
+            // Compile the generated code
+            DiagnosticCollector<JavaFileObject> diagnostics =
+                    new DiagnosticCollector<JavaFileObject>();
+            ok = compileCode(className.toString(), contents, diagnostics);
+
+            if (!ok) {
+                error("Class="+ className +" did not compile as expected", contents);
+            } else {
+                System.out.println("Test passed for className: " + className);
+            }
+        }
+
+        System.out.println("Total number of tests run: " + testCtr);
+        System.out.println("Total number of errors: " + errors);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    private String getContent(String className) {
+
+        StringBuilder annoData = new StringBuilder();
+        switch(className) {
+        case "InheritedonBothAnno":
+            annoData.append(Helper.ContentVars.INHERITED.getVal())
+            .append(Helper.ContentVars.CONTAINER.getVal())
+            .append(Helper.ContentVars.INHERITED.getVal())
+            .append(Helper.ContentVars.REPEATABLE.getVal())
+            .append(Helper.ContentVars.BASE.getVal());
+            break;
+        case "InheritedonBase":
+            annoData.append(Helper.ContentVars.INHERITED.getVal())
+            .append(Helper.ContentVars.CONTAINER.getVal())
+            .append(Helper.ContentVars.REPEATABLE.getVal())
+            .append(Helper.ContentVars.BASE.getVal());
+            break;
+        }
+
+        String contents = Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal()
+                          + Helper.ContentVars.IMPORTINHERITED.getVal()
+                          + annoData
+                          + Helper.ContentVars.REPEATABLEANNO.getVal()
+                          + "\nclass "+ className + "{}";
+        return contents;
+    }
+
+    private void error(String msg, String... contents) {
+        System.out.println("error: " + msg);
+        errors++;
+        if (contents.length == 1) {
+            System.out.println("Contents = " + contents[0]);
+        }
+    }
+}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java b/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java
new file mode 100644
index 0000000..419af33
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/ReflectionTest.java
@@ -0,0 +1,2932 @@
+/*
+ * 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      8001457
+ * @author   sogoel
+ * @summary  Reflection api tests
+ * @build    Helper
+ * @compile  expectedFiles/ExpectedBase.java expectedFiles/ExpectedContainer.java
+ * @run main ReflectionTest
+ */
+import java.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+import expectedFiles.ExpectedBase;
+import expectedFiles.ExpectedContainer;
+
+/*
+ * Objective:
+ * Test the following 6 methods from java.lang.reflect.AnnotatedElement:
+ * - getAnnotation(Class<T>)
+ * - getAnnotations()
+ * - getDeclaredAnnotations()
+ * - getDeclaredAnnotation(Class<T>)  // new method in JDK8
+ * - getAnnotationsByType(Class<T>)         // new method in JDK8
+ * - getDeclaredAnnotationsByType(Class<T>) // new method in JDK8
+ * for multiple test cases, for example, BasicNonRepeatable case, BasicRepeatable case
+ * for each of the src types - class, method, field, package
+ *
+ * This test uses following three enums:
+ * 1. TestCase - Defines the ExpectedBase/ExpectedContainer values for each testCase
+ *             - getTestFiles() - Creates list of JavaFileObjects for the primary
+ *                                src types (class, method, field, package)
+ *             - Each testCase is a new scenario with a combination of @Repeatable
+ *               relationship present/absent in conjunction with @Inherited.
+ *               For eg: BasicNonRepeatable_Legacy - It is a pre-JDK8 way of writing a single
+ *                       annotation on a given srcType( class, method, field, package)
+ *                       BasicRepeatable - It is a JDK8 way of writing repeating annotations
+ *                       on a given srcType with a @Repeatable relationship
+ *                       defined between Foo and FooContainer.
+ *
+ * 2. SrcType - Defines templates used in creation of test src
+ *            - Defines getExpectedBase() and getExpectedContainer() for primary src types
+ * 3. TestMethod - Defines getActualAnnoBase(), getActualAnnoContainer(), getExpectedAnnoBase(),
+ *                 and getExpectedAnnoContainer() for each of the 6 methods that are being tested
+ *                 in java.lang.reflect.AnnotatedElement
+ *
+ * Test execution flow:
+ * - Loop over each of the src types and each test cases
+ * - Creates test src for each flow, compile it, load the class object
+ * - Run all 6 methods on this class object
+ * - Get expected and actual annotations for each object and compare them.
+ * - Increment the error counter if the annotations don't match.
+ *
+ * The test fails if the number of errors is greater than 0.
+ */
+public class ReflectionTest {
+
+    static int errors = 0;
+    // Variables used in creating test src for a given testcase/testSrcType
+    static final String TESTPKG = "testpkg";
+    static final String TESTMETHOD = "testMethod";
+    static final String TESTFIELD = "testField";
+    static final String PKGINFONAME = TESTPKG + ".package-info";
+    static final String SUPERCLASS = "SuperClass";
+    static final String TESTINTERFACE = "TestInterface";
+    /*
+     *  Set it to true to get more debug information
+     */
+    static final boolean DEBUG = false;
+
+    public static void main(String args[]) throws Exception {
+        ReflectionTest test = new ReflectionTest();
+        test.runTest();
+    }
+
+    public void runTest() throws Exception {
+
+        ClassLoader parentClassLoader = getLoader();
+        String className = "";
+        Iterable<? extends JavaFileObject> files = null;
+
+        for (SrcType srcType : SrcType.getSrcTypes()) {
+            for (TestCase testCase : TestCase.values()) {
+                className = testCase + "_" + srcType;
+                debugPrint("*****************************************");
+                System.out.println("Running Test for ClassName: " + className);
+
+                // @Inherited only applicable for class, exclude cases for
+                // package, method, field
+                if (testCase.name().contains("Inherited")
+                        && (srcType != SrcType.CLASS)) {
+                    continue;
+                }
+
+                // Get list of JavaFileObjects to be compiled
+                files = testCase.getTestFiles(srcType, className);
+                if (srcType == SrcType.PACKAGE) {
+                    className = TESTPKG + "." + className;
+                }
+                DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
+
+                // Compile the list of JavaFileObjects
+                try {
+                    Helper.compileCode(diagnostics, files);
+                } catch (Exception ex) {
+                    printTestSrc(files);
+                    throw new RuntimeException(
+                            "Exception when compiling class " + className, ex);
+                }
+
+                // Get Class object for the compiled class
+                Class<?> c = loadClass(className, parentClassLoader, Helper.destDir);
+                if (c != null) {
+                    // For the loaded class object, compare expected and actual annotation values
+                    // for each of the methods under test from java.lang.reflect.AnnotatedElement
+                    checkAnnoValues(srcType, c);
+                } else {
+                    error("Could not load className = " + c);
+                }
+            }
+        }
+
+        if (getNumErrors() > 0) {
+            System.err.println("Test failed with " + getNumErrors() + " errors");
+            throw new RuntimeException();
+        }
+    }
+
+    /*
+     *  Each test case in this enum has the following:
+     *  - Define each test case with its @ExpectedBase and @ExpectedContainer annotations
+     *  - Override getTestFiles() that creates list of JavaFileObjects for each case
+     *    based on the src type.
+     */
+    enum TestCase {
+        BasicNonRepeatable_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + "getDeclAnnoVal = \"Foo\", "
+                + "getAnnosArgs = {\"Foo\"}, "
+                + "getDeclAnnosArgs = {\"Foo\"}) ",
+        "@ExpectedContainer") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+                anno = Helper.ContentVars.BASEANNO.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.BASE.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface Foo {}
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        // class, method, field
+                    /*
+                        Sample testSrc for class
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface Foo {}
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo
+                        class A {}
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate().replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        SingleAnnoInherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {\"Foo\", \"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {\"Foo\"}, "
+                + "getDeclAnnosArgs = {})",
+        "@ExpectedContainer") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                class SubClass extends SuperClass {}
+                 */
+
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+                anno = Helper.ContentVars.BASEANNO.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.INHERITED.getVal())
+                        .append(Helper.ContentVars.BASE.getVal());
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className).replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        InheritedAnnoOnInterface_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"},"
+                + "getDeclAnnoVal = \"NULL\"," + "getAnnosArgs = {},"
+                + "getDeclAnnosArgs = {})",
+        "@ExpectedContainer") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                /*
+                Sample test src:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Foo
+                interface TestInterface { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                class A implements TestInterface {}
+                 */
+                anno = Helper.ContentVars.BASEANNO.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.INHERITED.getVal())
+                        .append(Helper.ContentVars.BASE.getVal());
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for TestInterface
+                    replaceVal = commonStmts + "\n" + anno;
+                    String interfaceContents = SrcType.INTERFACE.getTemplate()
+                            .replace("#IN", TESTINTERFACE)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for class implementing TestInterface
+                    replaceVal = expectedVals;
+                    String classContents = SrcType.INTERFACEIMPL.getTemplate()
+                            .replace("#CN", className).replace("#IN", TESTINTERFACE)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = interfaceContents + classContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        AnnoOnSuperAndSubClass_Inherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + // override every annotation on superClass
+                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"Foo\", " // ignores inherited
+                + "getAnnosArgs = {\"Foo\"}, "
+                + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\", " + // ignores inherited
+                "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") { // ignores inherited
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                /*
+                Sample test src
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @Foo
+                class SubClass extends SuperClass {}
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.INHERITED.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.INHERITED.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS).replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className).replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        BasicContainer_Legacy(
+        "@ExpectedBase(value = Foo.class, "
+                + "getAnnotationVal = \"NULL\","
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", " + "getAnnosArgs = {}, "
+                + "getDeclAnnosArgs = {} )",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"FooContainer\", "
+                + "getAnnosArgs = {\"FooContainer\"}, "
+                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @FooContainer(value = {@Foo, @Foo})
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = "\n" + expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        /*
+                        Sample testSrc for class:
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @FooContainer(value = {@Foo, @Foo})
+                        class A {}
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate().replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        SingleAndContainerOnSuper_Legacy(
+        "@ExpectedBase(value = Foo.class, "
+                + "getAnnotationVal = \"Foo\","
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"Foo\", "
+                + "getAnnosArgs = {\"Foo\"}, "
+                + "getDeclAnnosArgs = {\"Foo\"} )",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"FooContainer\", "
+                + "getAnnosArgs = {\"FooContainer\"}, "
+                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+                        + Helper.ContentVars.BASEANNO.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo
+                        @FooContainer(value = {@Foo, @Foo})
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = "\n" + expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        /*
+                        Sample testSrc for class:
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo
+                        @FooContainer(value = {@Foo, @Foo})
+                        class A {}
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate().replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        BasicContainer_Inherited_Legacy(
+        "@ExpectedBase(value = Foo.class, "
+                + "getAnnotationVal = \"NULL\","
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {}, "
+                + "getDeclAnnosArgs = {} )",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {\"FooContainer\"}, "
+                + "getDeclAnnosArgs = {} )") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(false);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @FooContainer(value = {@Foo, @Foo})
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                class SubClass extends SuperClass {}
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        ContainerOnSuperSingleOnSub_Inherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+                + "getDeclAnnoVal = \"Foo\","
+                + "getAnnosArgs = {\"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(false);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @FooContainer(value = {@Foo, @Foo})
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @Foo
+                class SubClass extends SuperClass {}
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        ContainerAndSingleOnSuperSingleOnSub_Inherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+                + "getDeclAnnoVal = \"Foo\","
+                + "getAnnosArgs = {\"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(false);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @FooContainer(value = {@Foo, @Foo}) @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @Foo
+                class SubClass extends SuperClass {}
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+                            + Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className).replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        SingleOnSuperContainerOnSub_Inherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"Foo\"},"
+                + "getDeclAnnosArgs = {})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(false);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @FooContainer(value = {@Foo, @Foo})
+                class SubClass extends SuperClass {}
+                 */
+
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className).replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        SingleOnSuperContainerAndSingleOnSub_Inherited_Legacy(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"Foo\","
+                + "getAnnosArgs = {\"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(false);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @FooContainer(value = {@Foo, @Foo}) @Foo
+                class SubClass extends SuperClass {}
+                 */
+
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+                            + Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className).replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        BasicRepeatable(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\" }, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\","
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.REPEATABLE.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo() @Foo()
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        /*
+                        Sample testSrc for class:
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo @Foo
+                        class A { }
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate().replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        BasicContainerRepeatable(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"NULL\","
+                + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\","
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {\"FooContainer\"} )") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.REPEATABLE.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @FooContainer(value = {@Foo, @Foo})
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        /*
+                        Sample testSrc for class:
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @FooContainer(value = {@Foo, @Foo})
+                        class A { }
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate().replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        BasicContainerRepeatable_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+                + "getDeclAnnosArgs = {})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
+                + "getDeclAnnoVal = \"NULL\", "
+                + "getAnnosArgs = {\"FooContainer\"}, "
+                + "getDeclAnnosArgs = {})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @Repeatable(FooContainer.class)
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @FooContainer(value = {@Foo, @Foo})
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                class SubClass extends SuperClass { }
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+                anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        RepeatableAnnoInherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\", "
+                + // ignores inherited
+                "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+                + "getDeclAnnosArgs = {})", // ignores inherited
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = { \"ExpectedBase\", \"ExpectedContainer\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\", "
+                + // ignores inherited
+                "getAnnosArgs = {\"FooContainer\"}, "
+                + "getDeclAnnosArgs = {})") { // ignores inherited
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @Repeatable(FooContainer.class)
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo() @Foo()
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                class SubClass extends SuperClass { }
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+                anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        SingleAnnoWithContainer(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"Foo\","
+                + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\", \"Foo\",\"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getDeclAnnosArgs = {\"FooContainer\"},"
+                + "getAnnosArgs = {\"FooContainer\"})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String testSrc = "";
+                String pkgInfoContents = "";
+                String contents = "";
+
+                JavaFileObject pkgFileObj = null;
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = new StringBuilder();
+
+                anno = Helper.ContentVars.BASEANNO.getVal() + " "
+                        + Helper.ContentVars.LEGACYCONTAINER.getVal();
+                commonStmts.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+                        .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.REPEATABLE.getVal())
+                        .append(Helper.ContentVars.BASE.getVal())
+                        .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+                        .append(Helper.ContentVars.CONTAINER.getVal());
+                switch (srcType) {
+                    case PACKAGE:
+                        /*
+                        Sample package-info.java
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo @FooContainer(value = {@Foo, @Foo})
+                        package testpkg;
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        Sample testSrc:
+                        package testpkg;
+                        class A {}
+                         */
+                        testSrc = srcType.getTemplate().replace("#CN", className);
+                        contents = testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+
+                        replaceVal = expectedVals + "\n" + anno;
+                        pkgInfoContents = SrcType.PKGINFO.getTemplate()
+                                .replace("#REPLACE1", replaceVal)
+                                .replace("#REPLACE2", commonStmts);
+                        pkgFileObj = Helper.getFile(PKGINFONAME, pkgInfoContents);
+                        files = Arrays.asList(pkgFileObj, srcFileObj);
+                        break;
+                    default:
+                        /*
+                        Sample testSrc:
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @Repeatable(FooContainer.class)
+                        @interface Foo {}
+
+                        @Retention(RetentionPolicy.RUNTIME)
+                        @Inherited
+                        @interface FooContainer {
+                        Foo[] value();
+                        }
+
+                        @ExpectedBase
+                        @ExpectedContainer
+                        @Foo @FooContainer(value = {@Foo, @Foo})
+                        class A { }
+                         */
+                        replaceVal = expectedVals + anno;
+                        testSrc = srcType.getTemplate()
+                                .replace("#CN", className)
+                                .replace("#REPLACE", replaceVal);
+                        contents = commonStmts + testSrc;
+                        srcFileObj = Helper.getFile(className, contents);
+                        files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+        AnnoOnSuperAndSubClass_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
+                + // override every annotation on superClass
+                "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"Foo\", " // ignores inherited
+                + "getAnnosArgs = {\"Foo\"}, "
+                + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"NULL\", "
+                + "getAnnotationsVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\" }, "
+                + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+                + // ignores inherited annotations
+                "getDeclAnnoVal = \"NULL\", " + // ignores inherited
+                "getAnnosArgs = {}, " + "getDeclAnnosArgs = {})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @Repeatable(FooContainer.class)
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo()
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @Foo
+                class SubClass extends SuperClass { }
+                 */
+                // @Inherited only works for classes, no switch cases for
+                // method, field, package
+
+                if (srcType == SrcType.CLASS) {
+                    // Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    // Contents for SubClass that extends SuperClass
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+//         // Testcase not working as expected, JDK-8004912
+//         RepeatableOnSuperSingleOnSub_Inherited(
+//         "@ExpectedBase(value=Foo.class, "
+//                 + "getAnnotationVal = \"Foo\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + //override every annotation on superClass
+//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+//                 + // ignores inherited annotations
+//                 "getDeclAnnoVal = \"Foo\", " // ignores inherited
+//                 + "getAnnosArgs = {\"Foo\"}, "
+//                 + "getDeclAnnosArgs = { \"Foo\" })", // ignores inherited
+//         "@ExpectedContainer(value=FooContainer.class, "
+//                 + "getAnnotationVal = \"FooContainer\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"}, "
+//                 + // ignores inherited annotations
+//                 "getDeclAnnoVal = \"NULL\", "
+//                 + "getAnnosArgs = {\"FooContainer\"}, "
+//                 + "getDeclAnnosArgs = {}) // ignores inherited ") {
+
+//             @Override
+//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+//                     String className) {
+//                 String anno = "";
+//                 String replaceVal = "";
+//                 String contents = "";
+//                 JavaFileObject srcFileObj = null;
+//                 Iterable<? extends JavaFileObject> files = null;
+
+//                 String expectedVals = "\n" + getExpectedBase() + "\n"
+//                         + getExpectedContainer() + "\n";
+//                 StringBuilder commonStmts = getCommonStmts(true);
+
+//                 /*
+//                 Sample testSrc:
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @Repeatable(FooContainer.class)
+//                 @interface Foo {}
+
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @interface FooContainer {
+//                 Foo[] value();
+//                 }
+
+//                 @Foo() @Foo
+//                 class SuperClass { }
+
+//                 @ExpectedBase
+//                 @ExpectedContainer
+//                 @Foo
+//                 class SubClass extends SuperClass { }
+//                  */
+//                 //@Inherited only works for classes, no switch cases for method, field, package
+
+//                 if (srcType == SrcType.CLASS) {
+//                     //Contents for SuperClass
+//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+//                     replaceVal = commonStmts + "\n" + anno;
+//                     String superClassContents = srcType.getTemplate()
+//                             .replace("#CN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     //Contents for SubClass that extends SuperClass
+//                     anno = Helper.ContentVars.BASEANNO.getVal();
+//                     replaceVal = expectedVals + "\n" + anno;
+//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+//                             .replace("#CN", className)
+//                             .replace("#SN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+//                     contents = superClassContents + subClassContents;
+//                     srcFileObj = Helper.getFile(className, contents);
+//                     files = Arrays.asList(srcFileObj);
+//                 }
+//                 return files;
+//             }
+//         },
+//         //Testcase not working as expected, JDK-8004912
+//         SingleOnSuperRepeatableOnSub_Inherited(
+//         "@ExpectedBase(value=Foo.class, "
+//                 + "getAnnotationVal = \"Foo\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + //override every annotation on superClass
+//                 "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+//                 + // ignores inherited annotations
+//                 "getDeclAnnoVal = \"NULL\","// ignores inherited
+//                 + "getAnnosArgs = {\"Foo\", \"Foo\"}, "
+//                 + "getDeclAnnosArgs = { \"Foo\", \"Foo\"})",
+//         "@ExpectedContainer(value=FooContainer.class, "
+//                 + "getAnnotationVal = \"FooContainer\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"}, "
+//                 + // ignores inherited annotations
+//                 "getDeclAnnoVal = \"FooContainer\", "// ignores inherited
+//                 + "getAnnosArgs = {\"FooContainer\"}, "
+//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+//             @Override
+//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+//                     String className) {
+//                 String anno = "";
+//                 String replaceVal = "";
+//                 String contents = "";
+//                 JavaFileObject srcFileObj = null;
+//                 Iterable<? extends JavaFileObject> files = null;
+
+//                 String expectedVals = "\n" + getExpectedBase() + "\n"
+//                         + getExpectedContainer() + "\n";
+//                 StringBuilder commonStmts = getCommonStmts(true);
+
+//                 /*
+//                 Sample testSrc:
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @Repeatable(FooContainer.class)
+//                 @interface Foo {}
+
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @interface FooContainer {
+//                 Foo[] value();
+//                 }
+
+//                 @Foo()
+//                 class SuperClass { }
+
+//                 @ExpectedBase
+//                 @ExpectedContainer
+//                 @Foo @Foo
+//                 class SubClass extends SuperClass { }
+//                  */
+
+//                 //@Inherited only works for classes, no switch cases for method, field, package
+//                 if (srcType == SrcType.CLASS) {
+//                     //Contents for SuperClass
+//                     anno = Helper.ContentVars.BASEANNO.getVal();
+//                     replaceVal = commonStmts + "\n" + anno;
+//                     String superClassContents = srcType.getTemplate()
+//                             .replace("#CN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     //Contents for SubClass that extends SuperClass
+//                     anno = Helper.ContentVars.REPEATABLEANNO.getVal();
+//                     replaceVal = expectedVals + "\n" + anno;
+//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+//                             .replace("#CN", className)
+//                             .replace("#SN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     contents = superClassContents + subClassContents;
+//                     srcFileObj = Helper.getFile(className, contents);
+//                     files = Arrays.asList(srcFileObj);
+//                 }
+//                 return files;
+//             }
+//         },
+//         //Testcase not working as expected, JDK-8004912
+//         ContainerOnSuperSingleOnSub_Inherited(
+//         "@ExpectedBase(value=Foo.class, "
+//                 + "getAnnotationVal = \"Foo\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+//                 + "getDeclAnnoVal = \"Foo\","
+//                 + "getAnnosArgs = {\"Foo\"},"
+//                 + "getDeclAnnosArgs = {\"Foo\"})",
+//         "@ExpectedContainer(value=FooContainer.class, "
+//                 + "getAnnotationVal = \"FooContainer\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+//                 + "getDeclAnnoVal = \"NULL\","
+//                 + "getAnnosArgs = {\"FooContainer\"},"
+//                 + "getDeclAnnosArgs = {})") {
+
+//             @Override
+//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+//                     String className) {
+//                 String anno = "";
+//                 String replaceVal = "";
+//                 String contents = "";
+//                 JavaFileObject srcFileObj = null;
+//                 Iterable<? extends JavaFileObject> files = null;
+
+//                 String expectedVals = "\n" + getExpectedBase() + "\n"
+//                         + getExpectedContainer() + "\n";
+//                 StringBuilder commonStmts = getCommonStmts(true);
+
+//                 /*
+//                 Sample testSrc:
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @Repeatable(FooContainer.class)
+//                 @interface Foo {}
+
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @interface FooContainer {
+//                 Foo[] value();
+//                 }
+
+//                 @FooContainer(value = {@Foo, @Foo})
+//                 class SuperClass { }
+
+//                 @ExpectedBase
+//                 @ExpectedContainer
+//                 @Foo
+//                 class SubClass extends SuperClass { }
+//                  */
+
+//                 //@Inherited only works for classes, no switch cases for method, field, package
+//                 if (srcType == SrcType.CLASS) {
+//                     //Contents for SuperClass
+//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+//                     replaceVal = commonStmts + "\n" + anno;
+//                     String superClassContents = srcType.getTemplate()
+//                             .replace("#CN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     //Contents for SubClass that extends SuperClass
+//                     anno = Helper.ContentVars.BASEANNO.getVal();
+//                     replaceVal = expectedVals + "\n" + anno;
+//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+//                             .replace("#CN", className)
+//                             .replace("#SN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     contents = superClassContents + subClassContents;
+//                     srcFileObj = Helper.getFile(className, contents);
+//                     files = Arrays.asList(srcFileObj);
+//                 }
+//                 return files;
+//             }
+//         },
+//         // TestCase not working as expected, JDK-8004912
+//         SingleOnSuperContainerOnSub_Inherited(
+//         "@ExpectedBase(value=Foo.class, "
+//                 + "getAnnotationVal = \"Foo\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+//                 + "getDeclAnnoVal = \"NULL\","
+//                 + "getAnnosArgs = {\"Foo\", \"Foo\"},"
+//                 + "getDeclAnnosArgs = {\"Foo\", \"Foo\"})",
+//         "@ExpectedContainer(value=FooContainer.class, "
+//                 + "getAnnotationVal = \"FooContainer\", "
+//                 + "getAnnotationsVals = {"
+//                 +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                 + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"FooContainer\"},"
+//                 + "getDeclAnnoVal = \"FooContainer\","
+//                 + "getAnnosArgs = {\"FooContainer\"},"
+//                 + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+//             @Override
+//             public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+//                     String className) {
+//                 String anno = "";
+//                 String replaceVal = "";
+//                 String contents = "";
+//                 JavaFileObject srcFileObj = null;
+//                 Iterable<? extends JavaFileObject> files = null;
+
+//                 String expectedVals = "\n" + getExpectedBase() + "\n"
+//                         + getExpectedContainer() + "\n";
+//                 StringBuilder commonStmts = getCommonStmts(true);
+
+//                 /*
+//                 Sample testSrc:
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @Repeatable(FooContainer.class)
+//                 @interface Foo {}
+
+//                 @Retention(RetentionPolicy.RUNTIME)
+//                 @Inherited
+//                 @interface FooContainer {
+//                 Foo[] value();
+//                 }
+
+//                 @Foo
+//                 class SuperClass { }
+
+//                 @ExpectedBase
+//                 @ExpectedContainer
+//                 @FooContainer(value = {@Foo, @Foo})
+//                 class SubClass extends SuperClass { }
+//                  */
+
+//                 //@Inherited only works for classes, no switch cases for method, field, package
+//                 if (srcType == SrcType.CLASS) {
+//                     //Contents for SuperClass
+//                     anno = Helper.ContentVars.BASEANNO.getVal();
+//                     replaceVal = commonStmts + "\n" + anno;
+//                     String superClassContents = srcType.getTemplate()
+//                             .replace("#CN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     //Contents for SubClass that extends SuperClass
+//                     anno = Helper.ContentVars.LEGACYCONTAINER.getVal();
+//                     replaceVal = expectedVals + "\n" + anno;
+//                     String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+//                             .replace("#CN", className)
+//                             .replace("#SN", SUPERCLASS)
+//                             .replace("#REPLACE", replaceVal);
+
+//                     contents = superClassContents + subClassContents;
+//                     srcFileObj = Helper.getFile(className, contents);
+//                     files = Arrays.asList(srcFileObj);
+//                 }
+//                 return files;
+//             }
+//         },
+        SingleOnSuperContainerAndSingleOnSub_Inherited(
+        "@ExpectedBase(value=Foo.class, "
+                + "getAnnotationVal = \"Foo\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"Foo\","
+                + "getAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"},"
+                + "getDeclAnnosArgs = {\"Foo\", \"Foo\", \"Foo\"})",
+        "@ExpectedContainer(value=FooContainer.class, "
+                + "getAnnotationVal = \"FooContainer\", "
+                + "getAnnotationsVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+                + "getDeclAnnosVals = {"
+                +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"},"
+                + "getDeclAnnoVal = \"FooContainer\","
+                + "getAnnosArgs = {\"FooContainer\"},"
+                + "getDeclAnnosArgs = {\"FooContainer\"})") {
+
+            @Override
+            public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                    String className) {
+                String anno = "";
+                String replaceVal = "";
+                String contents = "";
+                JavaFileObject srcFileObj = null;
+                Iterable<? extends JavaFileObject> files = null;
+                String expectedVals = "\n" + getExpectedBase() + "\n"
+                        + getExpectedContainer() + "\n";
+                StringBuilder commonStmts = getCommonStmts(true);
+
+                /*
+                Sample testSrc:
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @interface Foo {}
+
+                @Retention(RetentionPolicy.RUNTIME)
+                @Inherited
+                @Repeatable(FooContainer.class)
+                @interface FooContainer {
+                Foo[] value();
+                }
+
+                @Foo
+                class SuperClass { }
+
+                @ExpectedBase
+                @ExpectedContainer
+                @FooContainer(value = {@Foo, @Foo}) @Foo
+                class SubClass extends SuperClass {}
+                 */
+
+                if (srcType == SrcType.CLASS) {
+                    //Contents for SuperClass
+                    anno = Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = commonStmts + "\n" + anno;
+                    String superClassContents = srcType.getTemplate()
+                            .replace("#CN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    //Contents for SubClass that extends SuperClass
+                    anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+                            + Helper.ContentVars.BASEANNO.getVal();
+                    replaceVal = expectedVals + "\n" + anno;
+                    String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+                            .replace("#CN", className)
+                            .replace("#SN", SUPERCLASS)
+                            .replace("#REPLACE", replaceVal);
+
+                    contents = superClassContents + subClassContents;
+                    srcFileObj = Helper.getFile(className, contents);
+                    files = Arrays.asList(srcFileObj);
+                }
+                return files;
+            }
+        },
+//          // TestCase not working as expected, JDK-8004912
+//          ContainerAndSingleOnSuperSingleOnSub_Inherited(
+//          "@ExpectedBase(value=Foo.class, "
+//                  + "getAnnotationVal = \"Foo\", "
+//                  + "getAnnotationsVals = {"
+//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+//                  + "getDeclAnnoVal = \"Foo\","
+//                  + "getAnnosArgs = {\"Foo\"},"
+//                  + "getDeclAnnosArgs = {\"Foo\"})",
+//          "@ExpectedContainer(value=FooContainer.class, "
+//                  + "getAnnotationVal = \"FooContainer\", "
+//                  + "getAnnotationsVals = {"
+//                  +       "\"ExpectedBase\", \"ExpectedContainer\", \"Foo\", \"FooContainer\"}, "
+//                  + "getDeclAnnosVals = {\"ExpectedBase\", \"ExpectedContainer\", \"Foo\"},"
+//                  + "getDeclAnnoVal = \"NULL\","
+//                  + "getAnnosArgs = {\"FooContainer\"},"
+//                  + "getDeclAnnosArgs = {})") {
+
+//              @Override
+//              public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+//                      String className) {
+//                  String anno = "";
+//                  String replaceVal = "";
+//                  String contents = "";
+//                  JavaFileObject srcFileObj = null;
+//                  Iterable<? extends JavaFileObject> files = null;
+
+//                  String expectedVals = "\n" + getExpectedBase() + "\n"
+//                          + getExpectedContainer() + "\n";
+//                  StringBuilder commonStmts = getCommonStmts(true);
+
+//                  /*
+//                  Sample testSrc:
+//                  @Retention(RetentionPolicy.RUNTIME)
+//                  @Inherited
+//                  @Repeatable(FooContainer.class)
+//                  @interface Foo {}
+
+//                  @Retention(RetentionPolicy.RUNTIME)
+//                  @Inherited
+//                  @interface FooContainer {
+//                  Foo[] value();
+//                  }
+
+//                  @FooContainer(value = {@Foo, @Foo})
+//                  @Foo
+//                  class SuperClass { }
+
+//                  @ExpectedBase
+//                  @ExpectedContainer
+//                  @Foo
+//                  class SubClass extends SuperClass { }
+//                   */
+
+//                  //@Inherited only works for classes, no switch cases for method, field, package
+//                  if (srcType == SrcType.CLASS) {
+//                      //Contents for SuperClass
+//                      anno = Helper.ContentVars.LEGACYCONTAINER.getVal()
+//                              + Helper.ContentVars.BASEANNO.getVal();
+//                      replaceVal = commonStmts + "\n" + anno;
+//                      String superClassContents = srcType.getTemplate()
+//                              .replace("#CN", SUPERCLASS)
+//                              .replace("#REPLACE", replaceVal);
+
+//                      //Contents for SubClass that extends SuperClass
+//                      anno = Helper.ContentVars.BASEANNO.getVal();
+//                      replaceVal = expectedVals + "\n" + anno;
+//                      String subClassContents = SrcType.CLASSEXTENDS.getTemplate()
+//                              .replace("#CN", className)
+//                              .replace("#SN", SUPERCLASS)
+//                              .replace("#REPLACE", replaceVal);
+
+//                      contents = superClassContents + subClassContents;
+//                      srcFileObj = Helper.getFile(className, contents);
+//                      files = Arrays.asList(srcFileObj);
+//                  }
+//                  return files;
+//              }
+//         }
+            ;
+         private String expectedBase, expectedContainer;
+
+         private TestCase(String expectedBase, String expectedContainer) {
+             this.expectedBase = expectedBase;
+             this.expectedContainer = expectedContainer;
+         }
+
+         public String getExpectedBase() {
+             return expectedBase;
+         }
+
+         public String getExpectedContainer() {
+             return expectedContainer;
+         }
+
+         // Each enum element should override this method
+         public Iterable<? extends JavaFileObject> getTestFiles(SrcType srcType,
+                 String className) {
+             return null;
+         }
+    }
+
+    /*
+     * Each srctype has its template defined used for test src generation
+     * Primary src types: class, method, field, package define
+     *                    getExpectedBase() and getExpectedContainer()
+     */
+    enum SrcType {
+
+        CLASS("\n#REPLACE\nclass #CN { } ") {
+
+            @Override
+            public ExpectedBase getExpectedBase(Class<?> c) {
+                return c.getAnnotation(ExpectedBase.class);
+            }
+
+            @Override
+            public ExpectedContainer getExpectedContainer(Class<?> c) {
+                return c.getAnnotation(ExpectedContainer.class);
+            }
+        },
+        METHOD("class #CN  {\n" + "   " + "#REPLACE\n" + "   void "
+        + TESTMETHOD + "() {} \n" + "}\n") {
+
+            @Override
+            public ExpectedBase getExpectedBase(Class<?> c) {
+                ExpectedBase ret = null;
+                try {
+                    ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+                            ExpectedBase.class);
+                } catch (NoSuchMethodException nme) {
+                    error("Could not get " + TESTMETHOD + " for className "
+                            + c.getName() + " Exception:\n" + nme);
+                }
+                return ret;
+            }
+
+            @Override
+            public ExpectedContainer getExpectedContainer(Class<?> c) {
+                ExpectedContainer ret = null;
+                try {
+                    ret = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+                            ExpectedContainer.class);
+                } catch (NoSuchMethodException nme) {
+                    error("Could not get " + TESTMETHOD + " for className "
+                            + c.getName() + " Exception:\n" + nme);
+                }
+                return ret;
+
+            }
+        },
+        FIELD("class #CN  {\n" + "   " + "#REPLACE\n" + "   int " + TESTFIELD
+        + " = 0; \n" + "}\n") {
+
+            @Override
+            public ExpectedBase getExpectedBase(Class<?> c) {
+                ExpectedBase ret = null;
+                try {
+                    ret = c.getDeclaredField(TESTFIELD).getAnnotation(
+                            ExpectedBase.class);
+                } catch (NoSuchFieldException nme) {
+                    error("Could not get " + TESTFIELD + " for className "
+                            + c.getName() + " Exception:\n" + nme);
+                }
+                return ret;
+            }
+
+            @Override
+            public ExpectedContainer getExpectedContainer(Class<?> c) {
+                ExpectedContainer ret = null;
+                try {
+                    ret = c.getDeclaredField(TESTFIELD).getAnnotation(
+                            ExpectedContainer.class);
+                } catch (NoSuchFieldException nme) {
+                    error("Could not get " + TESTFIELD + " for className "
+                            + c.getName() + " Exception:\n" + nme);
+                }
+                return ret;
+
+            }
+        },
+        PACKAGE("package " + TESTPKG + "; \n" + "class #CN {}") {
+
+            @Override
+            public ExpectedBase getExpectedBase(Class<?> c) {
+                return c.getPackage().getAnnotation(ExpectedBase.class);
+            }
+
+            @Override
+            public ExpectedContainer getExpectedContainer(Class<?> c) {
+                return c.getPackage().getAnnotation(ExpectedContainer.class);
+            }
+        },
+        PKGINFO("#REPLACE1\npackage " + TESTPKG + "; \n" + "#REPLACE2"),
+        INTERFACE("#REPLACE\ninterface #IN { } "),
+        INTERFACEIMPL("#REPLACE\nclass #CN implements #IN {}"),
+        CLASSEXTENDS("#REPLACE\nclass #CN extends #SN {}");
+        String template;
+
+        private SrcType(String template) {
+            this.template = template;
+        }
+
+        public String getTemplate() {
+            return template;
+        }
+
+        // Elements should override
+        public ExpectedBase getExpectedBase(Class<?> c) {
+            return null;
+        }
+
+        public ExpectedContainer getExpectedContainer(Class<?> c) {
+            return null;
+        }
+
+        /*
+         * Returns only primary src types ;
+         */
+        public static SrcType[] getSrcTypes() {
+            return new SrcType[]{CLASS, PACKAGE, METHOD, FIELD};
+        }
+    }
+
+    /*
+     * Each enum constant is one of the 6 methods from AnnotatedElement interface
+     * that needs to be tested.
+     * Each enum constant overrides these 4 methods:
+     * - getActualAnnoBase(SrcType srcType, Class<?> c)
+     * - getActualAnnoContainer(SrcType srcType, Class<?> c)
+     * - getExpectedAnnoBase(SrcType srcType, Class<?> c)
+     * - getExpectedAnnoContainer(SrcType srcType, Class<?> c)
+     */
+    enum TestMethod {
+
+        GET_ANNO("getAnnotation") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualAnno = new Annotation[1];
+                switch (srcType) {
+                    case CLASS:
+                        actualAnno[0] = c.getAnnotation(srcType.getExpectedBase(c).value());
+                        break;
+                    case PACKAGE:
+                        actualAnno[0] = c.getPackage().getAnnotation(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+                                    srcType.getExpectedBase(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
+                                    srcType.getExpectedBase(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnno;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualAnno = new Annotation[1];
+                switch (srcType) {
+                    case CLASS:
+                        actualAnno[0] = c.getAnnotation(srcType.getExpectedContainer(c).value());
+                        break;
+                    case PACKAGE:
+                        actualAnno[0] = c.getPackage().getAnnotation(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnno[0] = c.getDeclaredMethod(TESTMETHOD).getAnnotation(
+                                    srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnno[0] = c.getDeclaredField(TESTFIELD).getAnnotation(
+                                    srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnno;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                String[] expAnno = {srcType.getExpectedBase(c).getAnnotationVal()};
+                return expAnno;
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                String[] expAnno = {srcType.getExpectedContainer(c).getAnnotationVal()};
+                return expAnno;
+            }
+        },
+        GET_ANNOS("getAnnotations") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualAnnos = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualAnnos = c.getAnnotations();
+                        break;
+                    case PACKAGE:
+                        actualAnnos = c.getPackage().getAnnotations();
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnnos;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualAnnos = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualAnnos = c.getAnnotations();
+                        break;
+                    case PACKAGE:
+                        actualAnnos = c.getPackage().getAnnotations();
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnnos = c.getDeclaredMethod(TESTMETHOD).getAnnotations();
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnnos = c.getDeclaredField(TESTFIELD).getAnnotations();
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnnos;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedBase(c).getAnnotationsVals();
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedContainer(c).getAnnotationsVals();
+            }
+        },
+        GET_DECL_ANNOS("getDeclaredAnnotations") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualDeclAnnos = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnnos = c.getDeclaredAnnotations();
+                        break;
+                    case PACKAGE:
+                        actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotations();
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnnos = c.getDeclaredField(TESTFIELD)
+                                    .getDeclaredAnnotations();
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnnos;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualDeclAnnos = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnnos = c.getDeclaredAnnotations();
+                        break;
+                    case PACKAGE:
+                        actualDeclAnnos = c.getPackage().getDeclaredAnnotations();
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnnos = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotations();
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnnos = c.getDeclaredField(TESTFIELD)
+                                    .getDeclaredAnnotations();
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnnos;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedBase(c).getDeclAnnosVals();
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedContainer(c).getDeclAnnosVals();
+            }
+        },
+        GET_DECL_ANNO("getDeclaredAnnotation") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualDeclAnno = new Annotation[1];
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnno[0] = c.getDeclaredAnnotation(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case PACKAGE:
+                        actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotation(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
+                                    .getDeclaredAnnotation(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnno;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualDeclAnno = new Annotation[1];
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnno[0] = c.getDeclaredAnnotation(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case PACKAGE:
+                        actualDeclAnno[0] = c.getPackage().getDeclaredAnnotation(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnno[0] = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotation(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnno[0] = c.getDeclaredField(TESTFIELD)
+                                    .getDeclaredAnnotation(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnno;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                String[] expAnno = {srcType.getExpectedBase(c).getDeclAnnoVal()};
+                return expAnno;
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                String[] expAnno = {srcType.getExpectedContainer(c).getDeclAnnoVal()};
+                return expAnno;
+            }
+        }, // new
+        GET_ANNOS_ARG("getAnnotationsArg") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualAnnoArgs = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedBase(c).value());
+                        break;
+                    case PACKAGE:
+                        actualAnnoArgs = c.getPackage().getAnnotationsByType(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
+                                    .getAnnotationsByType(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnnoArgs = c.getDeclaredField(TESTFIELD)
+                                    .getAnnotationsByType(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnnoArgs;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualAnnoArgs = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualAnnoArgs = c.getAnnotationsByType(srcType.getExpectedContainer(c).value());
+                        break;
+                    case PACKAGE:
+                        actualAnnoArgs = c.getPackage().getAnnotationsByType(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualAnnoArgs = c.getDeclaredMethod(TESTMETHOD)
+                                    .getAnnotationsByType(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualAnnoArgs = c.getDeclaredField(TESTFIELD)
+                                    .getAnnotationsByType(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualAnnoArgs;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedBase(c).getAnnosArgs();
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedContainer(c).getAnnosArgs();
+            }
+        }, // new
+        GET_DECL_ANNOS_ARG("getDeclAnnosArg") {
+
+            @Override
+            public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+                Annotation[] actualDeclAnnosArgs = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case PACKAGE:
+                        actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
+                                srcType.getExpectedBase(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotationsByType(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
+                                    .getDeclaredAnnotationsByType(
+                                        srcType.getExpectedBase(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnnosArgs;
+            }
+
+            @Override
+            public Annotation[] getActualAnnoContainer(SrcType srcType,
+                    Class<?> c) {
+                Annotation[] actualDeclAnnosArgs = null;
+                switch (srcType) {
+                    case CLASS:
+                        actualDeclAnnosArgs = c.getDeclaredAnnotationsByType(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case PACKAGE:
+                        actualDeclAnnosArgs = c.getPackage().getDeclaredAnnotationsByType(
+                                srcType.getExpectedContainer(c).value());
+                        break;
+                    case METHOD:
+                        try {
+                            actualDeclAnnosArgs = c.getDeclaredMethod(TESTMETHOD)
+                                    .getDeclaredAnnotationsByType(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchMethodException nme) {
+                            error("Could not get " + TESTMETHOD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nme);
+                        }
+                        break;
+                    case FIELD:
+                        try {
+                            actualDeclAnnosArgs = c.getDeclaredField(TESTFIELD)
+                                   .getDeclaredAnnotationsByType(
+                                        srcType.getExpectedContainer(c).value());
+                        } catch (NoSuchFieldException nfe) {
+                            error("Could not get " + TESTFIELD
+                                    + " for className = " + c.getName()
+                                    + "Exception = " + nfe);
+                        }
+                        break;
+                }
+                return actualDeclAnnosArgs;
+            }
+
+            @Override
+            public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedBase(c).getDeclAnnosArgs();
+            }
+
+            @Override
+            public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+                return srcType.getExpectedContainer(c).getDeclAnnosArgs();
+            }
+        }; // new
+        String name;
+
+        private TestMethod(String name) {
+            this.name = name;
+        }
+
+        public Annotation[] getActualAnnoBase(SrcType srcType, Class<?> c) {
+            return null;
+        }
+
+        public Annotation[] getActualAnnoContainer(SrcType srcType, Class<?> c) {
+            return null;
+        }
+
+        public String[] getExpectedAnnoBase(SrcType srcType, Class<?> c) {
+            return null;
+        }
+
+        public String[] getExpectedAnnoContainer(SrcType srcType, Class<?> c) {
+            return null;
+        }
+    }
+
+    /*
+     * For a given srcType and class object, compare expectedBase and actualBase
+     * annotations as well as expectedContainer and actualContainer annotations.
+     *
+     * Return true if both comparisons are true else return false.
+     *
+     */
+    protected static void checkAnnoValues(SrcType srcType, Class<?> c) {
+
+        // Load @ExpectedBase and @ExpectedContainer
+        ExpectedBase eb = srcType.getExpectedBase(c);
+        ExpectedContainer ec = srcType.getExpectedContainer(c);
+        if (eb == null) {
+            error("Did not find ExpectedBase Annotation, Test will exit");
+            throw new RuntimeException();
+        }
+        if (ec == null) {
+            error("Did not find ExpectedContainer Annotation, Test will exit");
+            throw new RuntimeException();
+        }
+
+        for (TestMethod testMethod : TestMethod.values()) {
+            debugPrint("---------------------------------------------");
+            debugPrint("Test method = " + testMethod);
+            boolean isBasePass = true;
+            boolean isConPass = true;
+            // ExpectedBase = Annotation, no annotation is defined, skip comparison
+            if (!eb.value().getSimpleName().equalsIgnoreCase("Annotation")) {
+                isBasePass = compareAnnotations(
+                        testMethod.getActualAnnoBase(srcType, c),
+                        testMethod.getExpectedAnnoBase(srcType, c));
+            }
+
+            // ExpectedContainer = Annotation, no annotation is defined, skip comparison
+            if (!ec.value().getSimpleName().equalsIgnoreCase("Annotation")) {
+                isConPass = compareAnnotations(
+                        testMethod.getActualAnnoContainer(srcType, c),
+                        testMethod.getExpectedAnnoContainer(srcType, c));
+            }
+            if (isBasePass && isConPass) {
+                debugPrint("Testcase passed for " + testMethod +
+                        " for className = " + c.getName());
+            } else {
+                debugPrint("Testcase failed for " + testMethod +
+                        " for className = " + c.getName());
+            }
+        }
+    }
+
+    // Annotation comparison: Length should be same and all expected values
+    // should be present in actualAnno[].
+    private static boolean compareAnnotations(Annotation[] actualAnnos,
+            String[] expectedAnnos) {
+        // Length is different
+        if (actualAnnos.length != expectedAnnos.length) {
+            error("Length not same, Actual length = " + actualAnnos.length
+                    + " Expected length = " + expectedAnnos.length);
+            printArrContents(actualAnnos);
+            printArrContents(expectedAnnos);
+            return false;
+        } else {
+            int i = 0;
+            // Length is same and 0
+            if (actualAnnos.length == 0) {
+                // Expected/actual lengths already checked for
+                // equality; no more checks do to
+                return true;
+            }
+            // Expected annotation should be NULL
+            if (actualAnnos[0] == null) {
+                if (expectedAnnos[0].equals("NULL")) {
+                    debugPrint("Arr values are NULL as expected");
+                    return true;
+                } else {
+                    error("Array values are not NULL");
+                    printArrContents(actualAnnos);
+                    printArrContents(expectedAnnos);
+                    return false;
+                }
+            }
+            // Lengths are same, compare array contents
+            String[] actualArr = new String[actualAnnos.length];
+            for (Annotation a : actualAnnos) {
+                actualArr[i++] = a.annotationType().getSimpleName();
+            }
+
+            List<String> actualList = Arrays.asList(actualArr);
+            List<String> expectedList = Arrays.asList(expectedAnnos);
+
+            if (!actualList.containsAll(expectedList)) {
+                error("Array values are not same");
+                printArrContents(actualAnnos);
+                printArrContents(expectedAnnos);
+                return false;
+            } else {
+                debugPrint("Arr values are same as expected");
+            }
+        }
+        return true;
+    }
+
+    private static void printArrContents(Annotation[] actualAnnos) {
+        System.out.print("Actual Arr Values: ");
+        for (Annotation a : actualAnnos) {
+            if (a != null && a.annotationType() != null) {
+                System.out.print("[" + a.annotationType().getSimpleName() + "]");
+            } else {
+                System.out.println("[null]");
+            }
+        }
+        System.out.println();
+    }
+
+    private static void printArrContents(String[] expectedAnnos) {
+        System.out.print("Expected Arr Values: ");
+        for (String s : expectedAnnos) {
+            System.out.print("[" + s + "]");
+        }
+        System.out.println();
+    }
+
+    private ClassLoader getLoader() {
+        return getClass().getClassLoader();
+    }
+
+    private static Class<?> loadClass(String className, ClassLoader parentClassLoader, File... destDirs) {
+        try {
+            List<URL> list = new ArrayList<>();
+            for (File f : destDirs) {
+                list.add(new URL("file:" + f.toString().replace("\\", "/") + "/"));
+            }
+            return Class.forName(className, true, new URLClassLoader(
+                    list.toArray(new URL[list.size()]), parentClassLoader));
+        } catch (ClassNotFoundException | MalformedURLException e) {
+            throw new RuntimeException("Error loading class " + className, e);
+        }
+    }
+
+    private static void printTestSrc(Iterable<? extends JavaFileObject> files) {
+        for (JavaFileObject f : files) {
+            System.out.println("Test file " + f.getName() + ":");
+            try {
+                System.out.println("" + f.getCharContent(true));
+            } catch (IOException e) {
+                throw new RuntimeException(
+                        "Exception when printing test src contents for class " +
+                                f.getName(), e);
+            }
+        }
+
+    }
+
+    public static StringBuilder getCommonStmts(boolean isRepeatable) {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append(Helper.ContentVars.IMPORTEXPECTED.getVal())
+          .append(Helper.ContentVars.IMPORTSTMTS.getVal())
+          .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+          .append(Helper.ContentVars.INHERITED.getVal());
+        if(isRepeatable) {
+            sb.append(Helper.ContentVars.REPEATABLE.getVal());
+        }
+        sb.append(Helper.ContentVars.BASE.getVal())
+          .append(Helper.ContentVars.RETENTIONRUNTIME.getVal())
+          .append(Helper.ContentVars.INHERITED.getVal())
+          .append(Helper.ContentVars.CONTAINER.getVal());
+        return sb;
+    }
+
+    private static int getNumErrors() {
+        return errors;
+    }
+
+    private static void error(String msg) {
+        System.out.println("error: " + msg);
+        errors++;
+    }
+
+    private static void debugPrint(String string) {
+        if(DEBUG)
+            System.out.println(string);
+    }
+}
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java
new file mode 100644
index 0000000..3a5ebaf
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/RetentionAnnoCombo.java
@@ -0,0 +1,200 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug      8002157
+ * @author   sogoel
+ * @summary  Combo test for all possible combinations for Retention Values
+ * @build    Helper
+ * @compile  RetentionAnnoCombo.java
+ * @run main RetentionAnnoCombo
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+import javax.tools.Diagnostic;
+
+/*
+ * Generate all combinations for the use of @Retention on base anno or container
+ * anno or both. The test passes if valid test src compile as expected and
+ * and invalid test src fail as expected.
+ * Repeating annotations used only on class for these generated test src.
+ */
+
+public class RetentionAnnoCombo extends Helper {
+    static int errors = 0;
+    static boolean exitMode = false;
+    static {
+        String exitOnFail = System.getenv("EXIT_ON_FAIL");
+        if (exitOnFail == null || exitOnFail == ""  ) {
+            exitMode = false;
+        }
+        else {
+            if (exitOnFail.equalsIgnoreCase("YES") ||
+                    exitOnFail.equalsIgnoreCase("Y") ||
+                    exitOnFail.equalsIgnoreCase("TRUE") ||
+                    exitOnFail.equalsIgnoreCase("T")) {
+                exitMode = true;
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        new RetentionAnnoCombo().runTest();
+    }
+
+    public void runTest() throws Exception {
+
+        /* 4x4 matrix for Retention values SOURCE, DEFAULT, CLASS, RUNTIME
+         * i -> Retention value on ContainerAnno
+         * j -> Retention value on BaseAnno
+         * 1 -> retention value combo should compile
+         */
+        int[][] retention = { {1, 0, 0, 0},
+                              {1, 1, 1, 0},
+                              {1, 1, 1, 0},
+                              {1, 1, 1, 1} };
+
+        Map<Integer, String> retMap = setRetentionValMatrix();
+        String contents = "";
+        boolean result = false;
+        int testCtr = 0;
+        for (int i = 0; i < 4 ; i ++) {
+            for (int j = 0; j < 4; j++ ) {
+                testCtr++;
+                String className = "RetentionTest_"+i+"_"+j;
+                contents = getContent(className, retMap, i, j);
+                if (retention[i][j] == 1) {
+                    // Code generated should compile
+                    result = getCompileResult(contents,className, true);
+                    if (!result) {
+                        error("FAIL: " +  className + " did not compile as expected!", contents);
+                    }
+                } else {
+                    result = getCompileResult(contents,className, false);
+                    if (!result) {
+                        error("FAIL: " +  className + " compiled unexpectedly!", contents);
+                    }
+                }
+                if (result) {
+                    System.out.println("Test passed for className = " + className);
+                }
+            }
+        }
+
+        System.out.println("Total number of tests run: " + testCtr);
+        System.out.println("Total number of errors: " + errors);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    private boolean getCompileResult(String contents, String className,
+            boolean shouldCompile) throws Exception{
+
+        DiagnosticCollector<JavaFileObject> diagnostics =
+                new DiagnosticCollector<JavaFileObject>();
+        boolean ok = compileCode(className, contents, diagnostics);
+
+        String expectedErrKey = "compiler.err.invalid.repeatable" +
+                                        ".annotation.retention";
+        if (!shouldCompile && !ok) {
+            for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
+                if (!((d.getKind() == Diagnostic.Kind.ERROR) &&
+                    d.getCode().contains(expectedErrKey))) {
+                    error("FAIL: Incorrect error given, expected = "
+                            + expectedErrKey + ", Actual = " + d.getCode()
+                            + " for className = " + className, contents);
+                }
+            }
+        }
+
+        return (shouldCompile  == ok);
+    }
+
+    private Map<Integer,String> setRetentionValMatrix() {
+        HashMap<Integer,String> hm = new HashMap<>();
+        hm.put(0,"SOURCE");
+        hm.put(1,"DEFAULT");
+        hm.put(2,"CLASS");
+        hm.put(3,"RUNTIME");
+        return hm;
+    }
+
+    private String getContent(String className, Map<Integer, String> retMap,
+            int i, int j) {
+
+        String retContainerVal = retMap.get(i).toString();
+        String retBaseVal = retMap.get(j).toString();
+        String replacedRetBaseVal = "", replacedRetCAVal = "";
+        String retention = Helper.ContentVars.RETENTION.getVal();
+
+        // @Retention is available as default for both base and container anno
+        if (retContainerVal.equalsIgnoreCase("DEFAULT")
+                && retBaseVal.equalsIgnoreCase("DEFAULT")) {
+            replacedRetBaseVal = "";
+            replacedRetCAVal = "";
+        // @Retention is available as default for container anno
+        } else if (retContainerVal.equalsIgnoreCase("DEFAULT")) {
+            replacedRetBaseVal = retention.replace("#VAL", retBaseVal);
+            replacedRetCAVal = "";
+        // @Retention is available as default for base anno
+        } else if (retBaseVal.equalsIgnoreCase("DEFAULT")) {
+            replacedRetBaseVal = "";
+            replacedRetCAVal = retention.replace("#VAL", retContainerVal);
+        // @Retention is not available as default for both base and container anno
+        } else {
+            replacedRetBaseVal = retention.replace("#VAL", retBaseVal);
+            replacedRetCAVal = retention.replace("#VAL", retContainerVal);
+        }
+
+        StringBuilder annoData = new StringBuilder();
+        annoData.append(Helper.ContentVars.IMPORTCONTAINERSTMTS.getVal())
+                .append(Helper.ContentVars.IMPORTRETENTION.getVal())
+                .append(replacedRetCAVal)
+                .append(Helper.ContentVars.CONTAINER.getVal())
+                .append(Helper.ContentVars.REPEATABLE.getVal())
+                .append(replacedRetBaseVal)
+                .append(Helper.ContentVars.BASE.getVal());
+
+        String contents = annoData
+                          + Helper.ContentVars.REPEATABLEANNO.getVal()
+                          + "\nclass "+ className + "{}";
+        return contents;
+    }
+
+    private void error(String msg,String... contents) throws Exception {
+        System.out.println("error: " + msg);
+        errors++;
+        if (contents.length == 1) {
+            System.out.println("Contents = " + contents[0]);
+        }
+        // Test exits as soon as it gets a failure
+        if (exitMode) throw new Exception();
+    }
+}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java b/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java
new file mode 100644
index 0000000..058b489
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/TargetAnnoCombo.java
@@ -0,0 +1,508 @@
+/*
+ * 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      7151010 8006547 8007766
+ * @summary  Default test cases for running combinations for Target values
+ * @build    Helper
+ * @run main TargetAnnoCombo
+ */
+
+import java.util.Set;
+import java.util.List;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileObject;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.PACKAGE;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.TYPE_USE;
+import static java.lang.annotation.ElementType.TYPE_PARAMETER;
+
+public class TargetAnnoCombo {
+
+    static final String TESTPKG = "testpkg";
+
+    // Set it to true to get more debug information including base and container
+    // target sets for a given test case.
+    static final boolean DEBUG = false;
+
+    // Define constant target sets to be used for the combination of the target values.
+    final static Set<ElementType> noSet = null;
+    final static Set<ElementType> empty = EnumSet.noneOf(ElementType.class);
+
+    // [TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE,
+    // PACKAGE, TYPE_PARAMETER, TYPE_USE]
+    final static Set<ElementType> allTargets = EnumSet.allOf(ElementType.class);
+
+    // [TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE, ANNOTATION_TYPE,
+    // PACKAGE]
+    final static Set<ElementType> jdk7 = EnumSet.range(TYPE, PACKAGE);
+
+    // [TYPE_USE, TYPE_PARAMETER]
+    final static Set<ElementType> jdk8 = EnumSet.range(TYPE_PARAMETER, TYPE_USE);
+
+    // List of test cases to run. This list is created in generate().
+    // To run a specific test cases add case number in @run main line.
+    List<TestCase> testCases = new ArrayList<TestCase>();
+
+    int errors = 0;
+
+    // Identify test cases that fail.
+    enum IgnoreKind {
+        RUN,
+        IGNORE
+    };
+
+    private class TestCase {
+
+        private Set<ElementType> baseAnnotations;
+        private Set<ElementType> containerAnnotations;
+        private IgnoreKind ignore;
+
+        public TestCase(Set<ElementType> baseAnnotations, Set<ElementType> containerAnnotations) {
+            this(baseAnnotations, containerAnnotations, IgnoreKind.RUN);
+        }
+
+        public TestCase(Set<ElementType> baseAnnotations, Set<ElementType> containerAnnotations,
+                        IgnoreKind ignoreKind) {
+            this.baseAnnotations = baseAnnotations;
+            this.containerAnnotations = containerAnnotations;
+            this.ignore = ignoreKind;
+        }
+
+        public Set getBaseAnnotations() {
+            return baseAnnotations;
+        }
+
+        public Set getContainerAnnotations() {
+            return containerAnnotations;
+        }
+
+        public boolean isIgnored() {
+            return ignore == IgnoreKind.IGNORE;
+        }
+
+        // Determine if a testCase should compile or not.
+        private boolean isValidSubSet() {
+            /*
+             *  RULE 1: conAnnoTarget should be a subset of baseAnnoTarget
+             *  RULE 2: For empty @Target ({}) - annotation cannot be applied anywhere
+             *         - Empty sets for both is valid
+             *         - Empty baseTarget set is invalid with non-empty conTarget set
+             *         - Non-empty baseTarget set is valid with empty conTarget set
+             *  RULE 3: For no @Target specified - annotation can be applied to any JDK 7 targets
+             *         - No @Target for both is valid
+             *         - No @Target for baseTarget set with @Target conTarget set is valid
+             *         - @Target for baseTarget set with no @Target for conTarget is invalid
+             */
+
+
+            /* If baseAnno has no @Target, Foo can be either applied to @Target specified
+             * for container annotation else will be applicable for all default targets
+             * if no @Target is present for container annotation.
+             * In both cases, the set will be a valid set with no @Target for base annotation
+             */
+            if (baseAnnotations == null) {
+                if (containerAnnotations == null) {
+                    return true;
+                }
+                return !(containerAnnotations.contains(TYPE_USE) ||
+                         containerAnnotations.contains(TYPE_PARAMETER));
+            }
+
+            Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class);
+            tempBaseSet.addAll(baseAnnotations);
+            // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default.
+            if (baseAnnotations.contains(TYPE)) {
+                tempBaseSet.add(ANNOTATION_TYPE);
+            }
+
+            // If containerAnno has no @Target, only valid case if baseAnnoTarget has
+            // all targets defined else invalid set.
+            if (containerAnnotations == null) {
+                return tempBaseSet.containsAll(jdk7);
+            }
+
+            // At this point, neither conAnnoTarget or baseAnnoTarget are null.
+            if (containerAnnotations.isEmpty()) {
+                return true;
+            }
+
+            // At this point, conAnnoTarget is non-empty.
+            if (baseAnnotations.isEmpty()) {
+                return false;
+            }
+
+            // At this point, neither conAnnoTarget or baseAnnoTarget are empty.
+            return tempBaseSet.containsAll(containerAnnotations);
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        TargetAnnoCombo tac = new TargetAnnoCombo();
+        // Generates all test cases to be run.
+        tac.generate();
+        List<Integer> cases = new ArrayList<Integer>();
+        for (int i = 0; i < args.length; i++) {
+            cases.add(Integer.parseInt(args[i]));
+        }
+        if (cases.isEmpty()) {
+            tac.run();
+        } else {
+            for (int index : cases) {
+                tac.executeTestCase(tac.testCases.get(index), index);
+            }
+        }
+    }
+
+    private void generate() {
+        // Adding test cases to run.
+        testCases.addAll(Arrays.asList(
+                // No base target against no container target.
+                new TestCase(noSet, noSet),
+                // No base target against empty container target.
+                new TestCase(noSet, empty),
+                // No base target against TYPE_USE only container target.
+                new TestCase(noSet, less(jdk8, TYPE_PARAMETER)),
+                // No base target against TYPE_PARAMETER only container target.
+                new TestCase(noSet, less(jdk8, TYPE_USE)),
+                // No base target against TYPE_USE + TYPE_PARAMETER only container target.
+                new TestCase(noSet, jdk8),
+                // No base target against TYPE_USE + some selection of jdk7 targets.
+                new TestCase(noSet,
+                plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_USE)),
+                // No base target against TYPE_PARAMETER + some selection of jdk7 targets.
+                new TestCase(noSet,
+                plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_PARAMETER)),
+                // No base target against each jdk7 target alone as container target.
+                new TestCase(noSet, plus(empty, TYPE)),
+                new TestCase(noSet, plus(empty, PARAMETER)),
+                new TestCase(noSet, plus(empty, PACKAGE)),
+                new TestCase(noSet, plus(empty, METHOD)),
+                new TestCase(noSet, plus(empty, LOCAL_VARIABLE)),
+                new TestCase(noSet, plus(empty, FIELD)),
+                new TestCase(noSet, plus(empty, CONSTRUCTOR)),
+                new TestCase(noSet, plus(empty, ANNOTATION_TYPE)),
+                // Empty base target against no container target.
+                new TestCase(empty, noSet),
+                // Empty base target against empty container target.
+                new TestCase(empty, empty),
+                // Empty base target against any lone container target.
+                new TestCase(empty, plus(empty, TYPE)),
+                new TestCase(empty, plus(empty, PARAMETER)),
+                new TestCase(empty, plus(empty, PACKAGE)),
+                new TestCase(empty, plus(empty, METHOD)),
+                new TestCase(empty, plus(empty, LOCAL_VARIABLE)),
+                new TestCase(empty, plus(empty, FIELD)),
+                new TestCase(empty, plus(empty, CONSTRUCTOR)),
+                new TestCase(empty, plus(empty, ANNOTATION_TYPE)),
+                new TestCase(empty, less(jdk8, TYPE_USE)),
+                new TestCase(empty, less(jdk8, TYPE_PARAMETER)),
+                // No container target against all all-but one jdk7 targets.
+                new TestCase(less(jdk7, TYPE), noSet),
+                new TestCase(less(jdk7, PARAMETER), noSet),
+                new TestCase(less(jdk7, PACKAGE), noSet),
+                new TestCase(less(jdk7, METHOD), noSet),
+                new TestCase(less(jdk7, LOCAL_VARIABLE), noSet),
+                new TestCase(less(jdk7, FIELD), noSet),
+                new TestCase(less(jdk7, CONSTRUCTOR), noSet),
+                new TestCase(less(jdk7, ANNOTATION_TYPE), noSet),
+                // No container against all but TYPE and ANNOTATION_TYPE
+                new TestCase(less(jdk7, TYPE, ANNOTATION_TYPE), noSet),
+                // No container against jdk7 targets.
+                new TestCase(jdk7, noSet),
+                // No container against jdk7 targets plus one or both of TYPE_USE, TYPE_PARAMETER
+                new TestCase(plus(jdk7, TYPE_USE), noSet),
+                new TestCase(plus(jdk7, TYPE_PARAMETER), noSet),
+                new TestCase(allTargets, noSet),
+                // Empty container target against any lone target.
+                new TestCase(plus(empty, TYPE), empty),
+                new TestCase(plus(empty, PARAMETER), empty),
+                new TestCase(plus(empty, PACKAGE), empty),
+                new TestCase(plus(empty, METHOD), empty),
+                new TestCase(plus(empty, LOCAL_VARIABLE), empty),
+                new TestCase(plus(empty, FIELD), empty),
+                new TestCase(plus(empty, CONSTRUCTOR), empty),
+                new TestCase(plus(empty, ANNOTATION_TYPE), empty),
+                new TestCase(plus(empty, TYPE_USE), empty),
+                new TestCase(plus(empty, TYPE_PARAMETER), empty),
+                // All base targets against all container targets.
+                new TestCase(allTargets, allTargets),
+                // All base targets against all but one container targets.
+                new TestCase(allTargets, less(allTargets, TYPE)),
+                new TestCase(allTargets, less(allTargets, PARAMETER)),
+                new TestCase(allTargets, less(allTargets, PACKAGE)),
+                new TestCase(allTargets, less(allTargets, METHOD)),
+                new TestCase(allTargets, less(allTargets, LOCAL_VARIABLE)),
+                new TestCase(allTargets, less(allTargets, FIELD)),
+                new TestCase(allTargets, less(allTargets, CONSTRUCTOR)),
+                new TestCase(allTargets, less(allTargets, ANNOTATION_TYPE)),
+                new TestCase(allTargets, less(allTargets, TYPE_USE)),
+                new TestCase(allTargets, less(allTargets, TYPE_PARAMETER)),
+                // All container targets against all but one base targets.
+                new TestCase(less(allTargets, TYPE), allTargets),
+                new TestCase(less(allTargets, PARAMETER), allTargets),
+                new TestCase(less(allTargets, PACKAGE), allTargets),
+                new TestCase(less(allTargets, METHOD), allTargets),
+                new TestCase(less(allTargets, LOCAL_VARIABLE), allTargets),
+                new TestCase(less(allTargets, FIELD), allTargets),
+                new TestCase(less(allTargets, CONSTRUCTOR), allTargets),
+                new TestCase(less(allTargets, ANNOTATION_TYPE), allTargets),
+                new TestCase(less(allTargets, TYPE_USE), allTargets),
+                new TestCase(less(allTargets, TYPE_PARAMETER), allTargets)));
+        // Generates 100 test cases for any lone base target contained in Set
+        // allTargets against any lone container target.
+        for (ElementType b : allTargets) {
+            for (ElementType c : allTargets) {
+                testCases.add(new TestCase(plus(empty, b), plus(empty, c)));
+            }
+        }
+    }
+
+    void run() throws Exception {
+        int testCtr = 0;
+        for (TestCase tc : testCases) {
+            if (!tc.isIgnored()) {
+                executeTestCase(tc, testCases.indexOf(tc));
+                testCtr++;
+            }
+        }
+        System.out.println("Total tests run: " + testCtr);
+        if (errors > 0) {
+            throw new Exception(errors + " errors found");
+        }
+    }
+
+    private void executeTestCase(TestCase testCase, int index) {
+        debugPrint("Test case number = " + index);
+        debugPrint(" => baseAnnoTarget = " + testCase.getBaseAnnotations());
+        debugPrint(" => containerAnnoTarget = " + testCase.getContainerAnnotations());
+
+        String className = "TC" + index;
+        boolean shouldCompile = testCase.isValidSubSet();
+        Iterable<? extends JavaFileObject> files = getFileList(className, testCase, shouldCompile);
+        // Get result of compiling test src file(s).
+        boolean result = getCompileResult(className, shouldCompile, files);
+        // List test src code if test fails.
+        if (!result) {
+            System.out.println("FAIL: Test " + index);
+            try {
+                for (JavaFileObject f : files) {
+                    System.out.println("File: " + f.getName() + "\n" + f.getCharContent(true));
+                }
+            } catch (IOException ioe) {
+                System.out.println("Exception: " + ioe);
+            }
+        } else {
+            debugPrint("PASS: Test " + index);
+        }
+
+    }
+
+    // Create src code and corresponding JavaFileObjects.
+    private Iterable<? extends JavaFileObject> getFileList(String className,
+            TestCase testCase, boolean shouldCompile) {
+        Set<ElementType> baseAnnoTarget = testCase.getBaseAnnotations();
+        Set<ElementType> conAnnoTarget = testCase.getContainerAnnotations();
+        String srcContent = "";
+        String pkgInfoContent = "";
+        String template = Helper.template;
+        String baseTarget = "", conTarget = "";
+
+        String target = Helper.ContentVars.TARGET.getVal();
+        if (baseAnnoTarget != null) {
+            String tmp = target.replace("#VAL", convertToString(baseAnnoTarget).toString());
+            baseTarget = tmp.replace("[", "{").replace("]", "}");
+        }
+        if (conAnnoTarget != null) {
+            String tmp = target.replace("#VAL", convertToString(conAnnoTarget).toString());
+            conTarget = tmp.replace("[", "{").replace("]", "}");
+        }
+
+        String annoData = Helper.ContentVars.IMPORTSTMTS.getVal()
+                + conTarget
+                + Helper.ContentVars.CONTAINER.getVal()
+                + baseTarget
+                + Helper.ContentVars.REPEATABLE.getVal()
+                + Helper.ContentVars.BASE.getVal();
+
+        JavaFileObject pkgInfoFile = null;
+
+        // If shouldCompile = true and no @Target is specified for container annotation,
+        // then all 8 ElementType enum constants are applicable as targets for
+        // container annotation.
+        if (shouldCompile && conAnnoTarget == null) {
+            Set<ElementType> copySet = EnumSet.noneOf(ElementType.class);
+            copySet.addAll(jdk7);
+            conAnnoTarget = copySet;
+        }
+
+        if (shouldCompile) {
+            boolean isPkgCasePresent = conAnnoTarget.contains(PACKAGE);
+            String repeatableAnno = Helper.ContentVars.BASEANNO.getVal()
+                    + " " + Helper.ContentVars.BASEANNO.getVal();
+            for (ElementType s : conAnnoTarget) {
+                String replaceStr = "/*" + s.name() + "*/";
+                if (s.name().equalsIgnoreCase("PACKAGE")) {
+                    //Create packageInfo file.
+                    String pkgInfoName = TESTPKG + "." + "package-info";
+                    pkgInfoContent = repeatableAnno + "\npackage " + TESTPKG + ";" + annoData;
+                    pkgInfoFile = Helper.getFile(pkgInfoName, pkgInfoContent);
+                } else {
+                    template = template.replace(replaceStr, repeatableAnno);
+                    if (!isPkgCasePresent) {
+                        srcContent = template.replace(
+                                "/*ANNODATA*/", annoData).replace("#ClassName", className);
+                    } else {
+                        replaceStr = "/*PACKAGE*/";
+                        String tmp = template.replace(replaceStr, "package " + TESTPKG + ";");
+                        srcContent = tmp.replace("#ClassName", className);
+                    }
+                }
+            }
+        } else {
+            // For invalid cases, compilation should fail at declaration site.
+            template = "class #ClassName {}";
+            srcContent = annoData + template.replace("#ClassName", className);
+        }
+        JavaFileObject srcFile = Helper.getFile(className, srcContent);
+        Iterable<? extends JavaFileObject> files = null;
+        if (pkgInfoFile != null) {
+            files = Arrays.asList(pkgInfoFile, srcFile);
+        } else {
+            files = Arrays.asList(srcFile);
+        }
+        return files;
+    }
+
+    // Compile the test source file(s) and return test result.
+    private boolean getCompileResult(String className, boolean shouldCompile,
+            Iterable<? extends JavaFileObject> files) {
+
+        DiagnosticCollector<JavaFileObject> diagnostics =
+                new DiagnosticCollector<JavaFileObject>();
+        Helper.compileCode(diagnostics, files);
+        // Test case pass or fail.
+        boolean ok = false;
+        String errMesg = "";
+        int numDiags = diagnostics.getDiagnostics().size();
+        if (numDiags == 0) {
+            if (shouldCompile) {
+                debugPrint("Test passed, compiled as expected.");
+                ok = true;
+            } else {
+                errMesg = "Test failed, compiled unexpectedly.";
+                ok = false;
+            }
+        } else {
+            if (shouldCompile) {
+                // did not compile.
+                errMesg = "Test failed, did not compile.";
+                ok = false;
+            } else {
+                // Error in compilation as expected.
+                String expectedErrKey = "compiler.err.invalid.repeatable."
+                        + "annotation.incompatible.target";
+                for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
+                    if ((d.getKind() == Diagnostic.Kind.ERROR)
+                            && d.getCode().contains(expectedErrKey)) {
+                        // Error message as expected.
+                        debugPrint("Error message as expected.");
+                        ok = true;
+                        break;
+                    } else {
+                        // error message is incorrect.
+                        ok = false;
+                    }
+                }
+                if (!ok) {
+                    errMesg = "Incorrect error received when compiling "
+                            + className + ", expected: " + expectedErrKey;
+                }
+            }
+        }
+
+        if (!ok) {
+            error(errMesg);
+            for (Diagnostic<?> d : diagnostics.getDiagnostics()) {
+                System.out.println(" Diags: " + d);
+            }
+        }
+        return ok;
+    }
+
+    private Set<ElementType> less(Set<ElementType> base, ElementType... sub) {
+        Set<ElementType> res = EnumSet.noneOf(ElementType.class);
+        res.addAll(base);
+        for (ElementType t : sub) {
+            res.remove(t);
+        }
+        return res;
+    }
+
+    private Set<ElementType> plus(Set<ElementType> base, ElementType... add) {
+        Set<ElementType> res = EnumSet.noneOf(ElementType.class);
+        res.addAll(base);
+        for (ElementType t : add) {
+            res.add(t);
+        }
+        return res;
+    }
+
+    // Iterate target set and add "ElementType." in front of every target type.
+    private List<String> convertToString(Set<ElementType> annoTarget) {
+        if (annoTarget == null) {
+            return null;
+        }
+        List<String> annoTargets = new ArrayList<String>();
+        for (ElementType e : annoTarget) {
+            annoTargets.add("ElementType." + e.name());
+        }
+        return annoTargets;
+    }
+
+    private void debugPrint(String string) {
+        if (DEBUG) {
+            System.out.println(string);
+        }
+    }
+
+    private void error(String msg) {
+        System.out.println("ERROR: " + msg);
+        errors++;
+    }
+}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java
new file mode 100644
index 0000000..dbc72e8
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedBase.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 expectedFiles;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedBase {
+    Class<? extends Annotation> value() default Annotation.class;
+    String getAnnotationVal() default "";
+    String[] getAnnotationsVals() default {};
+    String[] getDeclAnnosVals() default {};
+    // JDK8 methods
+    String getDeclAnnoVal() default "";
+    String[] getAnnosArgs() default{};
+    String[] getDeclAnnosArgs() default {};
+}
+
diff --git a/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java
new file mode 100644
index 0000000..91f7055
--- /dev/null
+++ b/test/tools/javac/annotations/repeatingAnnotations/combo/expectedFiles/ExpectedContainer.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 expectedFiles;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedContainer {
+    Class<? extends Annotation> value() default Annotation.class;
+    String getAnnotationVal() default "";
+    String[] getAnnotationsVals() default {};
+    String[] getDeclAnnosVals() default {};
+    // JDK8 methods
+    String getDeclAnnoVal() default "";
+    String[] getAnnosArgs() default{};
+    String[] getDeclAnnosArgs() default {};
+}
+
diff --git a/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.java b/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.java
new file mode 100644
index 0000000..a0cbc78
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.java
@@ -0,0 +1,35 @@
+/*
+ * 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 6967002 8006775
+ * @summary JDK7 b99 javac compilation error (java.lang.AssertionError)
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T6967002.out -XDrawDiagnostics T6967002.java
+ */
+class Test {
+   private static void m(byte[] octets) {
+      return m(octets..., ?);
+   }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.out b/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.out
new file mode 100644
index 0000000..18b7530
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/6967002/T6967002.out
@@ -0,0 +1,8 @@
+T6967002.java:33:22: compiler.err.expected: ')'
+T6967002.java:33:25: compiler.err.illegal.start.of.expr
+T6967002.java:33:28: compiler.err.illegal.start.of.expr
+T6967002.java:33:29: compiler.err.illegal.start.of.expr
+T6967002.java:33:27: compiler.err.not.stmt
+T6967002.java:33:30: compiler.err.expected: ';'
+T6967002.java:35:2: compiler.err.premature.eof
+7 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java b/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java
new file mode 100644
index 0000000..5661e83
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/8013180/QualifiedName.java
@@ -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.
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/*
+ * @test
+ * @bug 8013180
+ * @summary Qualified type annotation name used to crash javac
+ * @compile QualifiedName.java
+ */
+
+public class QualifiedName {
+    @Target(ElementType.TYPE_USE) @interface TA { }
+    class E extends Exception { }
+
+    void m() throws @TA QualifiedName. at TA E { }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/InnerClass.java b/test/tools/javac/annotations/typeAnnotations/InnerClass.java
new file mode 100644
index 0000000..53cab9f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/InnerClass.java
@@ -0,0 +1,65 @@
+import java.lang.annotation.ElementType;
+
+/*
+ * 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 6843077 8006775
+ * @summary compiler crashes when visiting inner classes
+ * @author Mahmood Ali
+ * @compile InnerClass.java
+ */
+
+import java.lang.annotation.*;
+
+class InnerClass {
+
+    InnerClass() {}
+    InnerClass(Object o) {}
+
+    private void a() {
+        new Object() {
+            public <R> void method() { }
+        };
+    }
+
+    Object f1 = new InnerClass() {
+            <R> void method() { }
+        };
+
+    Object f2 = new InnerClass() {
+            <@A R> void method() { }
+        };
+
+    Object f3 = new InnerClass(null) {
+            <R> void method() { }
+        };
+
+    Object f4 = new InnerClass(null) {
+            <@A R> void method() { }
+        };
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface A { }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/MultipleTargets.java b/test/tools/javac/annotations/typeAnnotations/MultipleTargets.java
new file mode 100644
index 0000000..041366c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/MultipleTargets.java
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary check that type annotations may appear on void method if it is a
+ *          method annotation too.
+ * @author Mahmood Ali
+ * @compile MultipleTargets.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class TypeUseTarget<K extends @A Object> {
+  @A void voidMethod() { }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.METHOD})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/TargetTypes.java b/test/tools/javac/annotations/typeAnnotations/TargetTypes.java
new file mode 100644
index 0000000..8ffa7e5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/TargetTypes.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2009, 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.*;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.util.*;
+import java.io.*;
+
+/*
+ * @test
+ * @summary compiler accepts all values
+ * @author Mahmood Ali
+ * @author Yuri Gaevsky
+ * @compile TargetTypes.java
+ */
+
+ at Target({TYPE_USE, TYPE_PARAMETER, TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface A {}
+
+/** wildcard bound */
+class T0x1C {
+    void m0x1C(List<? extends @A String> lst) {}
+}
+
+/** wildcard bound generic/array */
+class T0x1D<T> {
+    void m0x1D(List<? extends @A List<int[]>> lst) {}
+}
+
+/** typecast */
+class T0x00 {
+    void m0x00(Long l1) {
+        Object l2 = (@A Long) l1;
+    }
+}
+
+/** typecast generic/array */
+class T0x01<T> {
+    void m0x01(List<T> list) {
+        List<T> l = (List<@A T>) list;
+    }
+}
+
+/** instanceof */
+class T0x02 {
+    boolean m0x02(String s) {
+        return (s instanceof @A String);
+    }
+}
+
+/** object creation (new) */
+class T0x04 {
+    void m0x04() {
+        new @A ArrayList<String>();
+    }
+}
+
+/** local variable */
+class T0x08 {
+    void m0x08() {
+      @A String s = null;
+    }
+}
+
+/** method parameter generic/array */
+class T0x0D {
+    void m0x0D(HashMap<@A Object, List<@A List<@A Class>>> s1) {}
+}
+
+/** method receiver */
+class T0x06 {
+    void m0x06(@A T0x06 this) {}
+}
+
+/** method return type generic/array */
+class T0x0B {
+    Class<@A Object> m0x0B() { return null; }
+}
+
+/** field generic/array */
+class T0x0F {
+    HashMap<@A Object, @A Object> c1;
+}
+
+/** method type parameter */
+class T0x20<T, U> {
+    <@A T, @A U> void m0x20() {}
+}
+
+/** class type parameter */
+class T0x22<@A T, @A U> {
+}
+
+/** class type parameter bound */
+class T0x10<T extends @A Object> {
+}
+
+/** method type parameter bound */
+class T0x12<T> {
+    <T extends @A Object> void m0x12() {}
+}
+
+/** class type parameter bound generic/array */
+class T0x11<T extends List<@A T>> {
+}
+
+
+/** method type parameter bound generic/array */
+class T0x13 {
+    static <T extends Comparable<@A T>> T m0x13() {
+        return null;
+    }
+}
+
+/** class extends/implements generic/array */
+class T0x15<T> extends ArrayList<@A T> {
+}
+
+/** type test (instanceof) generic/array */
+class T0x03<T> {
+    void m0x03(T typeObj, Object obj) {
+        boolean ok = obj instanceof String @A [];
+    }
+}
+
+/** object creation (new) generic/array */
+class T0x05<T> {
+    void m0x05() {
+        new ArrayList<@A T>();
+    }
+}
+
+/** local variable generic/array */
+class T0x09<T> {
+    void g() {
+        List<@A String> l = null;
+    }
+
+    void a() {
+        String @A [] as = null;
+    }
+}
+
+/** type argument in constructor call generic/array */
+class T0x19 {
+    <T> T0x19() {}
+
+    void g() {
+       new <List<@A String>> T0x19();
+    }
+}
+
+/** type argument in method call generic/array */
+class T0x1B<T> {
+    void m0x1B() {
+        Collections.<T @A []>emptyList();
+    }
+}
+
+/** type argument in constructor call */
+class T0x18<T> {
+    <T> T0x18() {}
+
+    void m() {
+        new <@A Integer> T0x18();
+    }
+}
+
+/** type argument in method call */
+class T0x1A<T,U> {
+    public static <T, U> T m() { return null; }
+    static void m0x1A() {
+        T0x1A.<@A Integer, @A Short>m();
+    }
+}
+
+/** class extends/implements */
+class T0x14 extends @A Object implements @A Serializable, @A Cloneable {
+}
+
+/** exception type in throws */
+class T0x16 {
+    void m0x16() throws @A Exception {}
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/TypeParameterTarget.java b/test/tools/javac/annotations/typeAnnotations/TypeParameterTarget.java
new file mode 100644
index 0000000..100331c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/TypeParameterTarget.java
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary check that type annotations may appear on all type parameter
+ * @author Mahmood Ali
+ * @compile TypeParameterTarget.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class TypeUseTarget<@A K extends Object> {
+  String[] field;
+
+  <@A K, @A V> String genericMethod(K k) { return null; }
+}
+
+interface MyInterface { }
+
+ at interface MyAnnotation { }
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/TypeProcOnly.java b/test/tools/javac/annotations/typeAnnotations/TypeProcOnly.java
new file mode 100644
index 0000000..e7e3831
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/TypeProcOnly.java
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+import java.io.*;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import javax.lang.model.util.ElementFilter;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+
+import static com.sun.tools.javac.comp.CompileStates.CompileState;
+
+/*
+ * @test
+ * @summary test that type processors are run when -proc:only is passed.
+ * This class implements the functionality of a type processor, as previously
+ * embodied by the AbstractTypeProcessor class.
+ *
+ * @author Mahmood Ali
+ * @author Werner Dietl
+ */
+ at SupportedAnnotationTypes("*")
+public class TypeProcOnly extends AbstractProcessor {
+    private static final String INDICATOR = "INDICATOR";
+
+    private final AttributionTaskListener listener = new AttributionTaskListener();
+    private final Set<Name> elements = new HashSet<Name>();
+
+    @Override
+    public final void init(ProcessingEnvironment env) {
+        super.init(env);
+        JavacTask.instance(env).addTaskListener(listener);
+        Context ctx = ((JavacProcessingEnvironment)processingEnv).getContext();
+        JavaCompiler compiler = JavaCompiler.instance(ctx);
+        compiler.shouldStopPolicyIfNoError = CompileState.max(
+                compiler.shouldStopPolicyIfNoError,
+                CompileState.FLOW);
+    }
+
+    @Override
+    public final boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) {
+            elements.add(elem.getQualifiedName());
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    private final class AttributionTaskListener implements TaskListener {
+        @Override
+        public void started(TaskEvent e) { }
+
+        @Override
+        public void finished(TaskEvent e) {
+            if (e.getKind() != TaskEvent.Kind.ANALYZE)
+                return;
+
+            if (!elements.remove(e.getTypeElement().getQualifiedName()))
+                return;
+
+            System.out.println(INDICATOR);
+        }
+    }
+
+
+    private static File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("class Test { }");
+        out.close();
+        return f;
+    }
+
+    public static void main(String[] args) throws Exception {
+        PrintStream prevOut = System.out;
+
+        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+        PrintStream out = new PrintStream(bytes);
+        System.setOut(out);
+
+        try {
+            File f = writeTestFile();
+            com.sun.tools.javac.Main.compile(new String[] {"-proc:only", "-processor", "TypeProcOnly", f.getAbsolutePath()});
+        } finally {
+            System.setOut(prevOut);
+        }
+
+        if (bytes.toString().trim().equals(INDICATOR)) {
+            System.out.println("PASSED");
+        } else {
+            throw new Exception("Processor did not run correctly. Output: " + bytes);
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/TypeUseTarget.java b/test/tools/javac/annotations/typeAnnotations/TypeUseTarget.java
new file mode 100644
index 0000000..4ec21c0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/TypeUseTarget.java
@@ -0,0 +1,62 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary check that type annotations may appear on all type declarations
+ * @author Mahmood Ali
+ * @compile TypeUseTarget.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+ at A
+class TypeUseTarget<K extends @A Object> {
+  @A String @A [] field;
+
+  @A String test(@A TypeUseTarget<K> this, @A String param, @A String @A ... vararg) {
+    @A Object o = new @A String @A [3];
+    TypeUseTarget<@A String> target;
+    return (@A String) null;
+  }
+
+  <K> @A String genericMethod(K k) { return null; }
+  @Decl <K> @A String genericMethod1(K k) { return null; }
+  @A @Decl <K> String genericMethod2(K k) { return null; }
+  @Decl @A <K> String genericMethod3(K k) { return null; }
+  <K> @Decl String genericMethod4(K k) { return null; }
+  <K> @A @Decl String genericMethod5(K k) { return null; }
+}
+
+ at A
+interface MyInterface { }
+
+ at A
+ at interface MyAnnotation { }
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
+
+ at interface Decl { }
diff --git a/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java b/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java
new file mode 100644
index 0000000..68f11f5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2010, 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 Checks the annotation types targeting array types
+ */
+
+import com.sun.tools.javac.api.JavacTool;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.annotation.*;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import com.sun.source.tree.*;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreeScanner;
+import javax.tools.StandardJavaFileManager;
+
+
+public class AnnotatedArrayOrder {
+    public static void main(String[] args) throws Exception {
+        PrintWriter out = new PrintWriter(System.out, true);
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File testSrc = new File(System.getProperty("test.src"));
+        Iterable<? extends JavaFileObject> f =
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "AnnotatedArrayOrder.java")));
+        JavacTask task = tool.getTask(out, fm, null, null, null, f);
+        Iterable<? extends CompilationUnitTree> trees = task.parse();
+        out.flush();
+
+        Scanner s = new Scanner();
+        for (CompilationUnitTree t: trees)
+            s.scan(t, null);
+
+    }
+
+    private static class Scanner extends TreeScanner<Void,Void> {
+        public Void visitCompilationUnit(CompilationUnitTree node, Void ignore) {
+            super.visitCompilationUnit(node, ignore);
+            if (!expectedLocations.isEmpty()) {
+                throw new AssertionError("Didn't found all annotations: " + expectedLocations);
+            }
+            return null;
+        }
+
+        private void testAnnotations(List<? extends AnnotationTree> annos, int found) {
+            String annotation = annos.get(0).toString();
+
+            if (!expectedLocations.containsKey(annotation))
+                throw new AssertionError("Found unexpected annotation: " + annotation + expectedLocations);
+
+            int expected = expectedLocations.get(annotation);
+            if (found != expected)
+                throw new AssertionError("The expected array length for this error doesn't match");
+
+            expectedLocations.remove(annotation);
+        }
+
+        public Void visitAnnotatedType(AnnotatedTypeTree node, Void ignore) {
+            testAnnotations(node.getAnnotations(), arrayLength(node));
+            return super.visitAnnotatedType(node, ignore);
+        }
+
+        private int arrayLength(Tree tree) {
+            switch (tree.getKind()) {
+            case ARRAY_TYPE:
+                return 1 + arrayLength(((ArrayTypeTree)tree).getType());
+            case ANNOTATED_TYPE:
+                return arrayLength(((AnnotatedTypeTree)tree).getUnderlyingType());
+            default:
+                return 0;
+            }
+        }
+    }
+
+    // expectedLocations values:
+    static Map<String, Integer> expectedLocations = new HashMap<String, Integer>();
+
+    // visited code
+    @A String @C [] @B [] field;
+    static {
+        // Shouldn't find @A(), as it is field annotation
+        expectedLocations.put("@B()", 1);
+        expectedLocations.put("@C()", 2);
+    }
+
+    List<@D String @F [] @E []> typearg;
+    static {
+        expectedLocations.put("@D()", 0);
+        expectedLocations.put("@E()", 1);
+        expectedLocations.put("@F()", 2);
+    }
+
+    void varargSimple(@G String @H ... vararg1) { }
+    static {
+        // Shouldn't find @G(), as it is a parameter annotation
+        expectedLocations.put("@H()", 1);
+    }
+
+    void varargLong(@I String @L [] @K [] @J ... vararg2) { }
+    static {
+        // Shouldn't find @I(), as it is a parameter annotation
+        expectedLocations.put("@J()", 1);
+        expectedLocations.put("@K()", 2);
+        expectedLocations.put("@L()", 3);
+    }
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface A {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface B {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface C {}
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface D {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface E {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface F {}
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface G {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface H {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface I {}
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface J {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface K {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface L {}
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/api/ArrayCreationTree.java b/test/tools/javac/annotations/typeAnnotations/api/ArrayCreationTree.java
new file mode 100644
index 0000000..952f37c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/api/ArrayCreationTree.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2010, 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 Checks that the interaction between annotated and unannotated
+  *         array levels in array creation trees
+ */
+
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.tree.JCTree.JCNewArray;
+import java.lang.annotation.*;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import com.sun.source.tree.*;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreeScanner;
+import javax.tools.StandardJavaFileManager;
+
+
+public class ArrayCreationTree {
+    public static void main(String[] args) throws Exception {
+        PrintWriter out = new PrintWriter(System.out, true);
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File testSrc = new File(System.getProperty("test.src"));
+        Iterable<? extends JavaFileObject> f =
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayCreationTree.java")));
+        JavacTask task = tool.getTask(out, fm, null, null, null, f);
+        Iterable<? extends CompilationUnitTree> trees = task.parse();
+        out.flush();
+
+        Scanner s = new Scanner();
+        for (CompilationUnitTree t: trees)
+            s.scan(t, null);
+
+    }
+
+    private static class Scanner extends TreeScanner<Void,Void> {
+        int foundAnnotations = 0;
+        public Void visitCompilationUnit(CompilationUnitTree node, Void ignore) {
+            super.visitCompilationUnit(node, ignore);
+            if (foundAnnotations != expectedAnnotations) {
+                throw new AssertionError("Expected " + expectedAnnotations +
+                        " annotations but found: " + foundAnnotations);
+            }
+            return null;
+        }
+
+        private void testAnnotations(List<? extends AnnotationTree> annos, int found) {
+            if (annos.isEmpty()) return;
+
+            String annotation = annos.get(0).toString();
+            foundAnnotations++;
+
+            int expected = -1;
+            if (annotation.equals("@A()"))
+                expected = 0;
+            else if (annotation.equals("@B()"))
+                expected = 1;
+            else if (annotation.equals("@C()"))
+                expected = 2;
+            else
+                throw new AssertionError("found an unexpected annotation: " + annotation);
+            if (found != expected) {
+                throw new AssertionError("Unexpected found length" +
+                    ", found " + found + " but expected " + expected);
+            }
+        }
+
+        public Void visitAnnotatedType(AnnotatedTypeTree node, Void ignore) {
+            testAnnotations(node.getAnnotations(), arrayLength(node));
+            return super.visitAnnotatedType(node, ignore);
+        }
+
+        public Void visitNewArray(NewArrayTree node, Void ignore) {
+            // the Tree API hasn't been updated to expose annotations yet
+            JCNewArray newArray = (JCNewArray)node;
+            int totalLength = node.getDimensions().size()
+                                + arrayLength(node.getType())
+                                + ((newArray.getInitializers() != null) ? 1 : 0);
+            testAnnotations(newArray.annotations, totalLength);
+            int count = 0;
+            for (List<? extends AnnotationTree> annos : newArray.dimAnnotations) {
+                testAnnotations(annos, totalLength - count);
+                count++;
+            }
+            return super.visitNewArray(node, ignore);
+        }
+
+        private int arrayLength(Tree tree) {
+            // TODO: the tree is null when called with node.getType(). Why?
+            if (tree==null) return -1;
+            switch (tree.getKind()) {
+            case ARRAY_TYPE:
+                return 1 + arrayLength(((ArrayTypeTree)tree).getType());
+            case ANNOTATED_TYPE:
+                return arrayLength(((AnnotatedTypeTree)tree).getUnderlyingType());
+            default:
+                return 0;
+            }
+        }
+    }
+
+    static int expectedAnnotations = 21;
+
+    Object a1 = new @A Object @C [2] @B [1];
+    Object b1 = new @A Object @C [2] @B [ ];
+    Object c1 = new @A Object @C [ ] @B [ ] { };
+
+    Object a2 = new @A Object @C [2]    [1];
+    Object b2 = new @A Object @C [2]    [ ];
+    Object c2 = new @A Object @C [ ]    [ ] { };
+
+    Object a3 = new @A Object    [2] @B [1];
+    Object b3 = new @A Object    [2] @B [ ];
+    Object c3 = new @A Object    [ ] @B [ ] { };
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface A {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface B {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface C {}
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/api/ArrayPositionConsistency.java b/test/tools/javac/annotations/typeAnnotations/api/ArrayPositionConsistency.java
new file mode 100644
index 0000000..1b73d91
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/api/ArrayPositionConsistency.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2010, 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 Checks that the interaction between annotated and unannotated
+  *         array levels
+ */
+
+import com.sun.tools.javac.api.JavacTool;
+import java.lang.annotation.*;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import com.sun.source.tree.*;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreeScanner;
+import javax.tools.StandardJavaFileManager;
+
+
+public class ArrayPositionConsistency {
+    public static void main(String[] args) throws Exception {
+        PrintWriter out = new PrintWriter(System.out, true);
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File testSrc = new File(System.getProperty("test.src"));
+        Iterable<? extends JavaFileObject> f =
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "ArrayPositionConsistency.java")));
+        JavacTask task = tool.getTask(out, fm, null, null, null, f);
+        Iterable<? extends CompilationUnitTree> trees = task.parse();
+        out.flush();
+
+        Scanner s = new Scanner();
+        for (CompilationUnitTree t: trees)
+            s.scan(t, null);
+
+    }
+
+    private static class Scanner extends TreeScanner<Void,Void> {
+        int foundAnnotations = 0;
+        public Void visitCompilationUnit(CompilationUnitTree node, Void ignore) {
+            super.visitCompilationUnit(node, ignore);
+            if (foundAnnotations != expectedAnnotations) {
+                throw new AssertionError("Expected " + expectedAnnotations +
+                        " annotations but found: " + foundAnnotations);
+            }
+            return null;
+        }
+
+        private void testAnnotations(List<? extends AnnotationTree> annos, int found) {
+            String annotation = annos.get(0).toString();
+            foundAnnotations++;
+
+            int expected = -1;
+            if (annotation.equals("@A()"))
+                expected = 0;
+            else if (annotation.equals("@B()"))
+                expected = 1;
+            else if (annotation.equals("@C()"))
+                expected = 2;
+            else
+                throw new AssertionError("found an unexpected annotation: " + annotation);
+            if (found != expected) {
+                throw new AssertionError("Unexpected found length" +
+                    ", found " + found + " but expected " + expected);
+            }
+        }
+
+        public Void visitAnnotatedType(AnnotatedTypeTree node, Void ignore) {
+            testAnnotations(node.getAnnotations(), arrayLength(node));
+            return super.visitAnnotatedType(node, ignore);
+        }
+
+        private int arrayLength(Tree tree) {
+            switch (tree.getKind()) {
+            case ARRAY_TYPE:
+                return 1 + arrayLength(((ArrayTypeTree)tree).getType());
+            case ANNOTATED_TYPE:
+                return arrayLength(((AnnotatedTypeTree)tree).getUnderlyingType());
+            default:
+                return 0;
+            }
+        }
+    }
+
+    static int expectedAnnotations = 23;
+
+    // visited code
+    @A String @C [] @B [] field1;
+    @A String @C []    [] field2;
+    @A String    [] @B [] field3;
+       String    [] @B [] field4;
+
+    @A List<String> @C [] @B [] genfield1;
+    @A List<String> @C []    [] genfield2;
+    @A List<String>    [] @B [] genfield3;
+       List<String>    [] @B [] genfield4;
+
+    List<@A String @C [] @B []> typearg1;
+    List<@A String @C []    []> typearg2;
+    List<@A String    [] @B []> typearg3;
+    List<   String    [] @B []> typearg4;
+
+    void vararg1(@A String @C [] @B ... arg) {}
+    void vararg2(@A String @C []    ... arg) {}
+    void vararg3(@A String    [] @B ... arg) {}
+    void vararg4(   String    [] @B ... arg) {}
+
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface A {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface B {}
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface C {}
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java b/test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java
new file mode 100644
index 0000000..810038c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/attribution/Scopes.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary test scopes of attribution
+ * @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(); }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java b/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java
new file mode 100644
index 0000000..952b73c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java
@@ -0,0 +1,246 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+public class ClassfileTestHelper {
+    int expected_tinvisibles = 0;
+    int expected_tvisibles = 0;
+    int expected_invisibles = 0;
+    int expected_visibles = 0;
+
+    //Makes debugging much easier. Set to 'false' for less output.
+    public Boolean verbose = true;
+    void println(String msg) { if(verbose) System.out.println(msg); }
+
+    File writeTestFile(String fname, String source) throws IOException {
+      File f = new File(fname);
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println(source);
+        out.close();
+        return f;
+    }
+
+    File compile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] {
+                "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
+        URL url = getClass().getResource(name);
+        InputStream in = url.openStream();
+        try {
+            return ClassFile.read(in);
+        } finally {
+            in.close();
+        }
+    }
+
+    ClassFile getClassFile(URL url) throws IOException, ConstantPoolException {
+        InputStream in = url.openStream();
+        try {
+            return ClassFile.read(in);
+        } finally {
+            in.close();
+        }
+    }
+
+    /************ Helper annotations counting methods ******************/
+    void test(ClassFile cf) {
+        test("CLASS",cf, null, null, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test("CLASS",cf, null, null, Attribute.RuntimeInvisibleTypeAnnotations, false);
+        //RuntimeAnnotations since one annotation can result in two attributes.
+        test("CLASS",cf, null, null, Attribute.RuntimeVisibleAnnotations, true);
+        test("CLASS",cf, null, null, 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(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.
+    void test(String ttype, ClassFile cf, Field f, Method m, String annName, boolean visible) {
+        String testtype = ttype;
+        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);
+                    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);
+                    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();
+                    index = cf.attributes.getIndex(cf.constant_pool, annName);
+                    if(index!= -1) attr = cf.attributes.get(index);
+            }
+        } catch(ConstantPoolException cpe) { cpe.printStackTrace(); }
+
+        if (index != -1) {
+            if(isTAattr) { //count RuntimeTypeAnnotations
+                RuntimeTypeAnnotations_attribute tAttr =
+                        (RuntimeTypeAnnotations_attribute)attr;
+                println(testtype + ": " + name + ", " + annName + ": " +
+                        tAttr.annotations.length );
+                allt += tAttr.annotations.length;
+                if (visible)
+                    tvisibles += tAttr.annotations.length;
+                else
+                    tinvisibles += tAttr.annotations.length;
+            } else {
+                RuntimeAnnotations_attribute tAttr =
+                        (RuntimeAnnotations_attribute)attr;
+                println(testtype + ": " + name + ", " + annName + ": " +
+                        tAttr.annotations.length );
+                all += tAttr.annotations.length;
+                if (visible)
+                    visibles += tAttr.annotations.length;
+                else
+                    invisibles += tAttr.annotations.length;
+            }
+        }
+    }
+
+    void countAnnotations() {
+        errors=0;
+        int expected_allt = expected_tvisibles + expected_tinvisibles;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_allt != allt) {
+            errors++;
+            System.err.println("Failure: expected " + expected_allt +
+                    " type annotations but found " + allt);
+        }
+        if (expected_all != all) {
+            errors++;
+            System.err.println("Failure: expected " + expected_all +
+                    " annotations but found " + all);
+        }
+        if (expected_tvisibles != tvisibles) {
+            errors++;
+            System.err.println("Failure: expected " + expected_tvisibles +
+                    " typevisible annotations but found " + tvisibles);
+        }
+
+        if (expected_tinvisibles != tinvisibles) {
+            errors++;
+            System.err.println("Failure: expected " + expected_tinvisibles +
+                    " typeinvisible annotations but found " + tinvisibles);
+        }
+        allt=0;
+        tvisibles=0;
+        tinvisibles=0;
+        all=0;
+        visibles=0;
+        invisibles=0;
+    }
+
+    int errors;
+    int allt;
+    int tvisibles;
+    int tinvisibles;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java
new file mode 100644
index 0000000..a33ea2d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest1.java
@@ -0,0 +1,381 @@
+/*
+ * 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 8005877 8004829 8005681 8006734 8006775
+ * @summary Combinations of Target ElementTypes on (repeated)type annotations.
+ */
+
+import com.sun.tools.classfile.*;
+import java.io.File;
+
+public class CombinationsTargetTest1 extends ClassfileTestHelper {
+
+    // Test count helps identify test case in event of failure.
+    int testcount = 0;
+
+    // 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"};
+
+    // local class tests will have an inner class.
+    Boolean hasInnerClass=false;
+    String innerClassname="";
+
+    public static void main(String[] args) throws Exception {
+        new CombinationsTargetTest1().run();
+    }
+
+    void run() throws Exception {
+        // Determines which repeat and order in source(ABMix).
+        Boolean As= false, BDs=true, ABMix=false;
+        int testrun=0;
+        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, 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, 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, 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);
+               }
+            }
+        }
+    }
+
+    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();
+        hasInnerClass=false;
+        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;
+
+        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);
+        } catch (Error err) {
+            System.err.println("Failed compile. Source:\n" + sourceString);
+            throw err;
+        }
+        //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 cf = ClassFile.read(classFile);
+
+        //Test class,fields and method counts.
+        test(cf);
+
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+        countAnnotations();
+        if (errors > 0) {
+            System.err.println( testDef );
+            System.err.println( "Source:\n" + sourceString );
+            throw new Exception( errors + " errors found" );
+        }
+        println("Pass");
+    }
+
+    //
+    // Source for test cases
+    //
+    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.HashMap; \n" +
+            "import java.util.Map; \n\n");
+
+            String sourceBase = new String("@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@Repeatable( AC.class )\n" +
+            "@interface A { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@interface AC { A[] value(); }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@Repeatable( BC.class )\n" +
+            "@interface B { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@interface BC { B[] value(); } \n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_PARAMETER,_OTHER_})\n" +
+            "@interface C { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
+            "@Repeatable(DC.class)\n" +
+            "@interface D { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
+            "@interface DC { D[] value(); }\n");
+
+        // Test case sources with sample generated source.
+        switch(src) {
+            case src1: // repeating type annotations at class level
+                    /*
+                     * @A @B class Test1 {
+                     * @A @B Test1(){}
+                     * @A @B Integer i1 = 0;
+                     * String @A @B [] @A @B [] sa = null;
+                     * // type usage in method body
+                     * String test(Test1 this, String param, String ... vararg) {
+                     *     Object o = new  String  [3];
+                     *     return (String) null;
+                     * }}
+                     */
+                source = new String(
+                    "// " + 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 src2: // (repeating) type annotations on method.
+                    /*
+                     * class Test12 {
+                     * Test12(){}
+                     * // type usage on method
+                     * @A @B String test(@A @B  Test12 this, @A @B  String param, @A @B  String @A @B  ... vararg) {
+                     *     Object o = new String [3];
+                     *     return (String) null;
+                     * }}
+                     */
+                source = new String(
+                    "// " + 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 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<String>() {
+                     *                  void m1(List<@A @B ? extends @A @B  Object> lst) {}
+                     *                  void m2() throws at A @B Exception { }
+                     *                });
+                     *     }
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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 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> {
+                     *     Map<List<String>, Integer> map =
+                     *         new HashMap<List< String>, Integer>();
+                     *     Map<List<String>,Integer> map2 = new HashMap<>();
+                     *     String test(Test2<T> this) { return null;}
+                     *     <T> String genericMethod(T t) { return null; }
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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 =
+                     *         new HashMap<List<String>, Integer>();
+                     *     Map<List<String>, Integer> map2 = new HashMap<>();
+                     *     String test(@A @B Test14<@D T> this) { return null;}
+                     *     <@C @D T> @A @B String genericMethod(@A @B @D T t) { return null; }
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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) {
+                     *         class maptest <@A @B @D E> {
+                     *             Map<List<@A @B @D E>, at A @B @D E> getMap() {
+                     *                 return new HashMap<List<E>,E>();
+                     *             }
+                     *         }
+                     *         return new maptest<E>().getMap();
+                     *    }
+                     *    Map<List<String>,String> shm = foo(new String("hello"));
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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;
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java
new file mode 100644
index 0000000..b660855
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest2.java
@@ -0,0 +1,365 @@
+/*
+ * 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 8005877 8004829 8005681 8006734 8006775 8006507
+ * @summary Combinations of Target ElementTypes on (repeated)type annotations.
+ */
+
+import com.sun.tools.classfile.*;
+import java.io.File;
+
+public class CombinationsTargetTest2 extends ClassfileTestHelper {
+
+    // Test count helps identify test case in event of failure.
+    int testcount = 0;
+
+    // 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"};
+
+    // local class tests will have an inner class.
+    Boolean hasInnerClass=false;
+    String innerClassname="";
+
+    public static void main(String[] args) throws Exception {
+        new CombinationsTargetTest2().run();
+    }
+
+    void run() throws Exception {
+        // Determines which repeat and order in source(ABMix).
+        Boolean As= false, BDs=true, ABMix=false;
+        int testrun=0;
+        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, 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 "FIELD":
+                       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;
+               }
+            }
+        }
+    }
+
+    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();
+        hasInnerClass=false;
+        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 + "\n    " + source.description;
+
+        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.
+        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);
+        } catch (Error err) {
+            System.err.println("Failed compile. Source:\n" + sourceString);
+            throw err;
+        }
+        //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());
+            println("classfile: " + classFile.getAbsolutePath());
+        }
+        ClassFile cf = ClassFile.read(classFile);
+
+        //Test class,fields and method counts.
+        test(cf);
+
+        for (Field f : cf.fields) {
+            if(source.local)
+                test(cf, f, true);
+            else
+                test(cf,f);
+        }
+        for (Method m: cf.methods) {
+            if(source.local)
+                test(cf, m, true);
+            else
+                test(cf, m);
+        }
+        countAnnotations();
+        if (errors > 0) {
+            System.err.println( testDef );
+            System.err.println( "Source:\n" + sourceString );
+            throw new Exception( errors + " errors found" );
+        }
+        println("Pass");
+    }
+
+    //
+    // Source for test cases
+    //
+    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.HashMap; \n" +
+            "import java.util.Map; \n\n");
+
+            String sourceBase = new String("@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@Repeatable( AC.class )\n" +
+            "@interface A { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@interface AC { A[] value(); }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@Repeatable( BC.class )\n" +
+            "@interface B { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,_OTHER_})\n" +
+            "@interface BC { B[] value(); } \n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
+            "@Repeatable(DC.class)\n" +
+            "@interface D { }\n\n" +
+
+            "@Retention("+retentn+")\n" +
+            "@Target({TYPE_USE,TYPE_PARAMETER,_OTHER_})\n" +
+            "@interface DC { D[] value(); }\n\n");
+
+        // Test case sources with sample generated source
+        switch(src) {
+            case src1: // (repeating) type annotations on field in method body
+                    /*
+                     * class Test1 {
+                     * Test1(){}
+                     * // type usage in method body
+                     * String test(Test1 this, String param, String ... vararg) {
+                     *     @A @B
+                     *     Object o = new @A @B  String @A @B  [3];
+                     *         return (@A @B  String) null;
+                     * }}
+                      */
+                source = new String(
+                    "// " + 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 =
+                     *         new HashMap<@A @B List<@A @B String>, @A @B Integer>();
+                     *     Map<List<String>, Integer> map2 = new @A @B HashMap<>();
+                     *     String test(Test2<T> this) { return null;}
+                     *     <T> String genericMethod(T t) { return null; }
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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) {
+                     *         class maptest <E> {
+                     *             Map<List<E>,E> getMap() {
+                     *                 Map<List<E>,E> Em = new HashMap<List<@A @B @D E>, at A @B @D E>();
+                     *                 return Em;
+                     *             }
+                     *         }
+                     *         return new maptest<E>().getMap();
+                     *    }
+                     *    Map<List<String>,String> shm = foo(new String("hello"));
+                     * }
+                     */
+                source = new String( source +
+                    "// " + 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;
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java
new file mode 100644
index 0000000..ee1ad3a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/CombinationsTargetTest3.java
@@ -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;
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java b/test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java
new file mode 100644
index 0000000..afcbd59
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/DeadCode.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test
+ * @bug 6917130 8006775
+ * @summary test that optimized away annotations are not emited to classfile
+ */
+
+public class DeadCode extends ClassfileTestHelper {
+    public static void main(String[] args) throws Exception {
+        new DeadCode().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 1;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("DeadCode$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        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 {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface A {}
+
+        void test() {
+            List<? extends @A Object> o = null;
+            o.toString();
+
+            @A String m;
+            if (false) {
+                @A String a;
+                @A String b = "m";
+                b.toString();
+                List<? extends @A Object> c = null;
+                c.toString();
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java b/test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java
new file mode 100644
index 0000000..24a8026
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/NewTypeArguments.java
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test ClassLiterals
+ * @summary test that new type arguments are emitted to classfile
+ */
+
+public class NewTypeArguments extends ClassfileTestHelper{
+    public static void main(String[] args) throws Exception {
+        new NewTypeArguments().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 3;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("NewTypeArguments$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        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 {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface A {}
+        <E> Test(E e) {}
+
+        void test() {
+            new <@A String> Test(null);
+            new <@A List<@A String>> Test(null);
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/NoTargetAnnotations.java b/test/tools/javac/annotations/typeAnnotations/classfile/NoTargetAnnotations.java
new file mode 100644
index 0000000..a5dc098
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/NoTargetAnnotations.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2008, 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.io.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test NoTargetAnnotations
+ * @summary test that annotations with no Target meta type is emitted
+ *          only once as declaration annotation
+ */
+public class NoTargetAnnotations {
+
+    public static void main(String[] args) throws Exception {
+        new NoTargetAnnotations().run();
+    }
+
+    public void run() throws Exception {
+        ClassFile cf = getClassFile("NoTargetAnnotations$Test.class");
+        for (Field f : cf.fields) {
+            test(cf, f);
+            testDeclaration(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+            testDeclaration(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
+        URL url = getClass().getResource(name);
+        InputStream in = url.openStream();
+        try {
+            return ClassFile.read(in);
+        } finally {
+            in.close();
+        }
+    }
+
+    /************ Helper annotations counting methods ******************/
+    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);
+    }
+
+    void testDeclaration(ClassFile cf, Method m) {
+        testDecl(cf, m, Attribute.RuntimeVisibleAnnotations, true);
+        testDecl(cf, m, Attribute.RuntimeInvisibleAnnotations, false);
+    }
+
+    void testDeclaration(ClassFile cf, Field m) {
+        testDecl(cf, m, Attribute.RuntimeVisibleAnnotations, true);
+        testDecl(cf, m, Attribute.RuntimeInvisibleAnnotations, false);
+    }
+
+    // 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;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void testDecl(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 RuntimeAnnotations_attribute;
+            RuntimeAnnotations_attribute tAttr = (RuntimeAnnotations_attribute)attr;
+            this.declAnnotations += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void testDecl(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 RuntimeAnnotations_attribute;
+            RuntimeAnnotations_attribute tAttr = (RuntimeAnnotations_attribute)attr;
+            this.declAnnotations += tAttr.annotations.length;
+        }
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-XDTA:writer", "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+        if (expected_decl != declAnnotations) {
+            errors++;
+            System.err.println("expected " + expected_decl
+                    + " declaration annotations but found " + declAnnotations);
+        }
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+
+    int declAnnotations;
+
+    /*********************** Test class *************************/
+    static int expected_invisibles = 0;
+    static int expected_visibles = 0;
+    static int expected_decl = 1;
+
+    static class Test {
+        @Retention(RetentionPolicy.RUNTIME)
+        @interface A {}
+
+        @A String method() {
+            return null;
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java b/test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java
new file mode 100644
index 0000000..046fc0a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/T8008762.java
@@ -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 { }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/T8008769.java b/test/tools/javac/annotations/typeAnnotations/classfile/T8008769.java
new file mode 100644
index 0000000..a727a67
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/T8008769.java
@@ -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(); }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/T8010015.java b/test/tools/javac/annotations/typeAnnotations/classfile/T8010015.java
new file mode 100644
index 0000000..72029a8
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/T8010015.java
@@ -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 { }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.java b/test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.java
new file mode 100644
index 0000000..504aaf9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/TestNewCastArray.java
@@ -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
+    }
+
+ at Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( AC.class ) @interface A { }
+ at Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( BC.class ) @interface B { }
+ at Retention(RUNTIME) @Target({FIELD}) @Repeatable( FC.class ) @interface F { }
+ at Retention(RUNTIME) @Target({TYPE_USE}) @interface AC { A[] value(); }
+ at Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { B[] value(); }
+ at Retention(RUNTIME) @Target({FIELD}) @interface FC { F[] value(); }
+
+}
+
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java b/test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java
new file mode 100644
index 0000000..017e75b
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/TypeCasts.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test
+ * @bug 6843077 8006775
+ * @summary test that typecasts annotation are emitted if only the cast
+ *          expression is optimized away
+ */
+
+public class TypeCasts extends ClassfileTestHelper{
+    public static void main(String[] args) throws Exception {
+        new TypeCasts().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 4;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("TypeCasts$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        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 {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface A {}
+
+        void emit() {
+            Object o = null;
+            String s = null;
+
+            String a0 = (@A String)o;
+            Object a1 = (@A Object)o;
+
+            String b0 = (@A String)s;
+            Object b1 = (@A Object)s;
+        }
+
+        void alldeadcode() {
+            Object o = null;
+
+            if (false) {
+                String a0 = (@A String)o;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java b/test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java
new file mode 100644
index 0000000..6ae292f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/classfile/Wildcards.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Wildcards
+ * @bug 6843077 8006775
+ * @summary test that annotations target wildcards get emitted to classfile
+ */
+public class Wildcards extends ClassfileTestHelper {
+    public static void main(String[] args) throws Exception {
+        new Wildcards().run();
+    }
+
+    public void run() throws Exception {
+        expected_tinvisibles = 3;
+        expected_tvisibles = 0;
+
+        ClassFile cf = getClassFile("Wildcards$Test.class");
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        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 {
+        @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+        @interface A {}
+
+        List<? extends @A Number> f;
+
+        List<? extends @A Object> test(List<? extends @A Number> p) {
+            List<? extends @A Object> l;  // not counted... gets optimized away
+            return null;
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java
new file mode 100644
index 0000000..db14aef
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006775
+ * @summary Import clauses cannot use annotations.
+ * @author Werner Dietl
+ * @compile/fail/ref=AnnotatedImport.out -XDrawDiagnostics AnnotatedImport.java
+ */
+
+import java. at A util.List;
+import @A java.util.Map;
+import java.util. at A HashMap;
+
+class AnnotatedImport { }
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.out b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.out
new file mode 100644
index 0000000..dbd0d42
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.out
@@ -0,0 +1,7 @@
+AnnotatedImport.java:9:13: compiler.err.expected: token.identifier
+AnnotatedImport.java:9:14: compiler.err.expected3: class, interface, enum
+AnnotatedImport.java:10:7: compiler.err.expected: token.identifier
+AnnotatedImport.java:10:10: compiler.err.expected: ';'
+AnnotatedImport.java:11:18: compiler.err.expected: token.identifier
+AnnotatedImport.java:11:19: compiler.err.expected3: class, interface, enum
+6 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java
new file mode 100644
index 0000000..6b8b64a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006775
+ * @summary Package declarations cannot use annotations.
+ * @author Werner Dietl
+ * @compile/fail/ref=AnnotatedPackage1.out -XDrawDiagnostics AnnotatedPackage1.java
+ */
+
+package name. at A p1.p2;
+
+class AnnotatedPackage1 { }
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out
new file mode 100644
index 0000000..66ae60f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out
@@ -0,0 +1,3 @@
+AnnotatedPackage1.java:9:14: compiler.err.expected: token.identifier
+AnnotatedPackage1.java:9:15: compiler.err.expected3: class, interface, enum
+2 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java
new file mode 100644
index 0000000..53eb5b1
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006775
+ * @summary Package declarations cannot use annotations.
+ * @author Werner Dietl
+ * @compile/fail/ref=AnnotatedPackage2.out -XDrawDiagnostics AnnotatedPackage2.java
+ */
+
+package @A p1.p2;
+
+class AnnotatedPackage2 { }
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.out b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.out
new file mode 100644
index 0000000..2ab8045
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.out
@@ -0,0 +1,3 @@
+AnnotatedPackage2.java:9:8: compiler.err.expected: token.identifier
+AnnotatedPackage2.java:9:10: compiler.err.expected3: class, interface, enum
+2 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java
new file mode 100644
index 0000000..9f80b2e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test that only Java 8 allows type annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -Xlint:-options -source 1.6 AnnotationVersion.java
+ * @compile/fail/ref=AnnotationVersion7.out -XDrawDiagnostics -Xlint:-options -source 1.7 AnnotationVersion.java
+ */
+class AnnotationVersion {
+  public void method(@A AnnotationVersion this) { }
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out
new file mode 100644
index 0000000..d836ff3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out
@@ -0,0 +1,2 @@
+AnnotationVersion.java:10:43: compiler.err.type.annotations.not.supported.in.source: 1.6
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out
new file mode 100644
index 0000000..cb2fca3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out
@@ -0,0 +1,2 @@
+AnnotationVersion.java:10:43: compiler.err.type.annotations.not.supported.in.source: 1.7
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/BadCast.java b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.java
new file mode 100644
index 0000000..a24c323
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006775
+ * @summary A cast cannot consist of only an annotation.
+ * @author Werner Dietl
+ * @compile/fail/ref=BadCast.out -XDrawDiagnostics BadCast.java
+ */
+class BadCast {
+  static void main() {
+    Object o = (@A) "";
+  }
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/BadCast.out b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.out
new file mode 100644
index 0000000..f1b8bf0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.out
@@ -0,0 +1,2 @@
+BadCast.java:10:19: compiler.err.illegal.start.of.type
+1 error
\ No newline at end of file
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java
new file mode 100644
index 0000000..70bc051
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java
@@ -0,0 +1,41 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006733 8006775
+ * @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
+ */
+
+import java.util.List;
+import java.lang.annotation.*;
+
+class CantAnnotateStaticClass {
+    @Target(ElementType.TYPE_USE)
+    @interface A {}
+
+    static class Outer {
+        class Inner {}
+    }
+
+    // 8 errors:
+    @A Outer.Inner f1;
+    @A Outer.Inner f1r() { return null; }
+    void f1p(@A Outer.Inner p) { }
+    void f1c(Object o) {
+        Object l = (@A Outer.Inner) o;
+    }
+
+    List<@A Outer.Inner> f2;
+    List<@A Outer.Inner> f2r() { return null; }
+    void f2p(List<@A Outer.Inner> p) { }
+    void f2c(Object o) {
+        Object l = (List<@A Outer.Inner>) o;
+    }
+
+    // OK:
+    @A Outer g1;
+    List<@A Outer> g2;
+    Outer. @A Inner g3;
+    List<Outer. @A Inner> g4;
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.out b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.out
new file mode 100644
index 0000000..2995a4d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.out
@@ -0,0 +1 @@
+dummy
\ No newline at end of file
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java
new file mode 100644
index 0000000..c414a5f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test incomplete array declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics IncompleteArray.java
+ */
+class IncompleteArray {
+  int @A [] @A var;
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out
new file mode 100644
index 0000000..a03a092
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out
@@ -0,0 +1,2 @@
+IncompleteArray.java:9:13: compiler.err.illegal.start.of.type
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.java b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.java
new file mode 100644
index 0000000..1bb05a4
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test incomplete vararg declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics IncompleteVararg.java
+ */
+class IncompleteArray {
+  // the last variable may be vararg
+  void method(int @A test) { }
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.out b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.out
new file mode 100644
index 0000000..7cec6c9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.out
@@ -0,0 +1,2 @@
+IncompleteVararg.java:10:19: compiler.err.illegal.start.of.type
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java
new file mode 100644
index 0000000..7098b93
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test indexing of an array
+ * @author Mahmood Ali
+ * @compile/fail/ref=IndexArray.out -XDrawDiagnostics IndexArray.java
+ */
+class IndexArray {
+  int[] var;
+  int a = var @A [1];
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out
new file mode 100644
index 0000000..762f38b
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out
@@ -0,0 +1,2 @@
+IndexArray.java:10:15: compiler.err.illegal.start.of.expr
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java b/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java
new file mode 100644
index 0000000..f70cefe
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.java
@@ -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
+ * @bug 8008077
+ * @summary Type annotations in a lazy constant need to be attributed
+ *   in the correct order.
+ * @author Werner Dietl
+ * @compile/ref=LazyConstantValue.out LazyConstantValue.java
+ */
+
+import java.lang.annotation.*;
+
+class ClassA {
+    Object o = ClassB.lcv;
+}
+
+class ClassB {
+    static final String[] lcv = new @TA String[0];
+}
+
+class ClassC {
+    static final Object o = (@TA Object) null;
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TA {}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.out b/test/tools/javac/annotations/typeAnnotations/failures/LazyConstantValue.out
new file mode 100644
index 0000000..e69de29
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/LintCast.java b/test/tools/javac/annotations/typeAnnotations/failures/LintCast.java
new file mode 100644
index 0000000..fdb3183
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/LintCast.java
@@ -0,0 +1,69 @@
+import java.lang.annotation.*;
+import java.util.List;
+
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test that compiler doesn't warn about annotated redundant casts
+ * @author Mahmood Ali
+ * @author Werner Dietl
+ * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics LintCast.java
+ */
+class LintCast {
+    void unparameterized() {
+        String s = "m";
+        String s1 = (String)s;
+        String s2 = (@A String)s;
+    }
+
+    void parameterized() {
+        List<String> l = null;
+        List<String> l1 = (List<String>)l;
+        List<String> l2 = (List<@A String>)l;
+    }
+
+    void array() {
+        int @A [] a = null;
+        int[] a1 = (int[])a;
+        int[] a2 = (int @A [])a;
+    }
+
+    void sameAnnotations() {
+        @A String annotated = null;
+        String unannotated = null;
+
+        // compiler ignore annotated casts even if redundant
+        @A String anno1 = (@A String)annotated;
+
+        // warn if redundant without an annotation
+        String anno2 = (String)annotated;
+        String unanno2 = (String)unannotated;
+    }
+
+    void more() {
+        Object @A [] a = null;
+        Object[] a1 = (Object[])a;
+        Object[] a2 = (Object @A [])a;
+
+        @A List<String> l3 = null;
+        List<String> l4 = (List<String>)l3;
+        List<String> l5 = (@A List<String>)l3;
+
+        List<@A String> l6 = null;
+        List<String> l7 = (List<String>)l6;
+        List<String> l8 = (List<@A String>)l6;
+
+        @A Object o = null;
+        Object o1 = (Object)o;
+        Object o2 = (@A Object)o;
+
+        Outer. @A Inner oi = null;
+        Outer.Inner oi1 = (Outer.Inner)oi;
+        Outer.Inner oi2 = (Outer. @A Inner)oi;
+    }
+
+    class Outer { class Inner {} }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out b/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out
new file mode 100644
index 0000000..cb65dba
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out
@@ -0,0 +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: 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: 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<@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
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/OldArray.java b/test/tools/javac/annotations/typeAnnotations/failures/OldArray.java
new file mode 100644
index 0000000..4ed4e87
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/OldArray.java
@@ -0,0 +1,35 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary test old array syntax
+ * @author Mahmood Ali
+ * @compile/fail -XDrawDiagnostics OldArray.java
+ */
+class OldArray {
+  String [@A]  s() { return null; }
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/Scopes.java b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.java
new file mode 100644
index 0000000..aab3c55
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check that A is accessible in the class type parameters
+ * @author Mahmood Ali
+ * @compile/fail/ref=Scopes.out -XDrawDiagnostics Scopes.java
+ */
+class Scopes<T extends @UniqueInner Object> {
+  // UniqueInner is not visible in the type parameters.
+  // One has to use Scopes.UniqueInner.
+  // Annotations with the default @Target are not allowed there,
+  // so we also get the second error about the invalid location.
+  // Adding the target here doesn't matter, as we don't resolve
+  // the annotation type.
+  // @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+  @interface UniqueInner { };
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/Scopes.out b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.out
new file mode 100644
index 0000000..cf7eece
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.out
@@ -0,0 +1,3 @@
+Scopes.java:8:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , 
+Scopes.java:8:24: compiler.err.annotation.type.not.applicable
+2 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java
new file mode 100644
index 0000000..f75583f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary static field access isn't a valid location
+ * @author Mahmood Ali
+ * @compile/fail/ref=StaticFields.out -XDrawDiagnostics StaticFields.java
+ */
+class C {
+  int f;
+  int a = @A C.f;
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out
new file mode 100644
index 0000000..3364c66
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out
@@ -0,0 +1,2 @@
+StaticFields.java:10:17: compiler.err.illegal.start.of.expr
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java b/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java
new file mode 100644
index 0000000..55fdfa3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary static methods don't have receivers
+ * @author Mahmood Ali
+ * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics StaticMethods.java
+ */
+class StaticMethods {
+  static void main(StaticMethods this) { }
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out b/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out
new file mode 100644
index 0000000..2e0923a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out
@@ -0,0 +1,2 @@
+StaticMethods.java:9:34: compiler.err.non-static.cant.be.ref: kindname.variable, this
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/T8008751.java b/test/tools/javac/annotations/typeAnnotations/failures/T8008751.java
new file mode 100644
index 0000000..9f54330
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/T8008751.java
@@ -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();
+           });
+   }
+}
+ at Retention(RUNTIME) @Target(TYPE_USE)  @interface A { String value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/T8009360.java b/test/tools/javac/annotations/typeAnnotations/failures/T8009360.java
new file mode 100644
index 0000000..3dbf477
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/T8009360.java
@@ -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
+           });
+   }
+}
+
+ at Target({TYPE_USE,FIELD}) @Repeatable( AC.class) @interface A { }
+ at Target({TYPE_USE,FIELD}) @interface AC { A[] value(); }
+ at Target({TYPE_USE}) @interface B { }
+ at Target({TYPE_USE, FIELD}) @interface C { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/T8011722.java b/test/tools/javac/annotations/typeAnnotations/failures/T8011722.java
new file mode 100644
index 0000000..7802db5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/T8011722.java
@@ -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. at C InnerException {    }
+}
+
+ at Target(ElementType.TYPE_USE) @interface C { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/TypeAndField.java b/test/tools/javac/annotations/typeAnnotations/failures/TypeAndField.java
new file mode 100644
index 0000000..4f600f4
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/TypeAndField.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8006703 8006775
+ * @summary Ensure that TYPE_USE and FIELD work together.
+ * @author Werner Dietl
+ * @compile TypeAndField.java
+ */
+import java.lang.annotation.*;
+
+class TypeAndField {
+    @TA Integer i;
+    @TA int j;
+}
+
+ at Retention(RetentionPolicy.CLASS)
+ at Target({ElementType.TYPE_USE, ElementType.FIELD})
+ at interface TA { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/TypeVariable.java b/test/tools/javac/annotations/typeAnnotations/failures/TypeVariable.java
new file mode 100644
index 0000000..2c83bfe
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/TypeVariable.java
@@ -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 8008077
+ * @summary Type annotations on a type variable, where the bound of
+ *   the type variable is also annotated, need to be processed correctly.
+ * @author Werner Dietl
+ * @compile TypeVariable.java
+ */
+
+import java.lang.annotation.*;
+
+class TypeVariable {
+    <TV extends  @TA Object> TV cast(TV p) {
+        return (@TA TV) p;
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TA {}
+
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/VoidGenericMethod.java b/test/tools/javac/annotations/typeAnnotations/failures/VoidGenericMethod.java
new file mode 100644
index 0000000..3650d11
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/VoidGenericMethod.java
@@ -0,0 +1,38 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary test type annotation on void generic methods
+ * @author Mahmood Ali
+ * @compile/fail VoidGenericMethod.java
+ */
+class VoidGenericMethod {
+  public @A <T> void method() { }
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.java
new file mode 100644
index 0000000..e60f72d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.java
@@ -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() { };
+}
+
+ at interface DA { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
new file mode 100644
index 0000000..91c76a5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DeclarationAnnotation.out
@@ -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
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..cc0b2d9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue {
+  void test() {
+    String @A(value = 2, value = 1) [] s;
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..566321c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:11:26: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..da0438e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnnotation {
+  void test() {
+    String @A @A [] s;
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..4584096
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:11:15: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.java
new file mode 100644
index 0000000..da44d21
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    String @A [] s;
+  }
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.out
new file mode 100644
index 0000000..868ab97
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:11:12: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java
new file mode 100644
index 0000000..4f099e0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    String @A [] s;
+  }
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out
new file mode 100644
index 0000000..74a7ef7
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:10:12: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..2230767
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue {
+  void method() {
+    class Inner<@A(value = 2, value = 1) K> {}
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..12248c8
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:11:31: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..3438dd2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnno {
+  void innermethod() {
+    class Inner<@A @A K> { }
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..902ec9e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:11:20: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java
new file mode 100644
index 0000000..46d65a8
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+class InvalidLocation {
+  void innermethod() {
+    class Inner<@A K> {}
+  }
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out
new file mode 100644
index 0000000..b74ad54
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:10:17: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java
new file mode 100644
index 0000000..5a5c8b6
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void innermethod() {
+    class Inner<@A K> { }
+  }
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out
new file mode 100644
index 0000000..637ff4a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:10:17: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..f3f3616
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue {
+  void test() {
+    String[] a = new String @A(value = 2, value = 1) [5] ;
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..cb7b69d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:11:43: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..be8f479
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnnotation {
+  void test() {
+    String[] a = new String @A @A [5] ;
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..4c41849
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:11:32: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.java
new file mode 100644
index 0000000..a43e2e7
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    String[] s = new String @A [5] ;
+  }
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.out
new file mode 100644
index 0000000..1d98d17
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:11:29: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java
new file mode 100644
index 0000000..15cf6e9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    String[] a = new String @A [5];
+  }
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out
new file mode 100644
index 0000000..6865348
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:10:29: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.java
new file mode 100644
index 0000000..7e45818
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.java
@@ -0,0 +1,99 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006775
+ * @summary Ensure unresolved upper bound annotation is handled correctly
+ * @author Werner Dietl
+ * @compile/fail/ref=BrokenAnnotation.out -XDrawDiagnostics BrokenAnnotation.java
+ */
+
+// No import, making the annotation @A invalid.
+// import java.lang.annotation.*;
+
+// Works: @Broke.A class...
+// Works: class Broke<@Broke.A T> {
+// Used to fail:
+class BrokenAnnotation<T extends @BrokenAnnotation.A Object> {
+    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+    @interface A { }
+}
+
+// If the Annotation is e.g. on the top-level class, we
+// get something like this:
+//
+// Broke.java:6: cannot find symbol
+// symbol  : class Target
+// location: class Broke
+//     @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+//      ^
+// 1 error
+//
+// When the annotation is in the upper bound, one used to get
+// the following stack trace:
+//
+// An exception has occurred in the compiler (1.7.0-jsr308-1.2.7). Please report this bug so we can fix it.  For instructions, see http://types.cs.washington.edu/checker-framework/current/README-jsr308.html#reporting-bugs .  Thank you.
+// java.lang.NullPointerException
+//      at com.sun.tools.javac.code.Type.isCompound(Type.java:346)
+//      at com.sun.tools.javac.code.Types.getBounds(Types.java:1940)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitTypeVar(RichDiagnosticFormatter.java:534)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitTypeVar(RichDiagnosticFormatter.java:1)
+//      at com.sun.tools.javac.code.Type$TypeVar.accept(Type.java:1049)
+//      at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3809)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter$1.visit(RichDiagnosticFormatter.java:450)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitClassType(RichDiagnosticFormatter.java:518)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter$1.visitClassType(RichDiagnosticFormatter.java:1)
+//      at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:596)
+//      at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3809)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessType(RichDiagnosticFormatter.java:442)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessArgument(RichDiagnosticFormatter.java:172)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessDiagnostic(RichDiagnosticFormatter.java:155)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessArgument(RichDiagnosticFormatter.java:178)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.preprocessDiagnostic(RichDiagnosticFormatter.java:155)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:111)
+//      at com.sun.tools.javac.util.RichDiagnosticFormatter.format(RichDiagnosticFormatter.java:1)
+//      at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:514)
+//      at com.sun.tools.javac.util.Log.report(Log.java:496)
+//      at com.sun.tools.javac.comp.Resolve.logResolveError(Resolve.java:2160)
+//      at com.sun.tools.javac.comp.Resolve.access(Resolve.java:1553)
+//      at com.sun.tools.javac.comp.Resolve.access(Resolve.java:1580)
+//      at com.sun.tools.javac.comp.Resolve.access(Resolve.java:1592)
+//      at com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1653)
+//      at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:2191)
+//      at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1873)
+//      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:467)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:503)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:496)
+//      at com.sun.tools.javac.comp.Attr.attribAnnotationTypes(Attr.java:605)
+//      at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:944)
+//      at com.sun.tools.javac.code.Symbol.complete(Symbol.java:432)
+//      at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:832)
+//      at com.sun.tools.javac.code.Symbol$ClassSymbol.flags(Symbol.java:775)
+//      at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:350)
+//      at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:346)
+//      at com.sun.tools.javac.comp.Resolve.findMemberType(Resolve.java:1346)
+//      at com.sun.tools.javac.comp.Resolve.findIdentInType(Resolve.java:1512)
+//      at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:2434)
+//      at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:2312)
+//      at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1805)
+//      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:467)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:503)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:496)
+//      at com.sun.tools.javac.comp.Attr.attribAnnotationTypes(Attr.java:605)
+//      at com.sun.tools.javac.comp.Attr.visitAnnotatedType(Attr.java:3016)
+//      at com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:2253)
+//      at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:467)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:503)
+//      at com.sun.tools.javac.comp.Attr.attribType(Attr.java:496)
+//      at com.sun.tools.javac.comp.Attr.attribTypeVariables(Attr.java:569)
+//      at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:955)
+//      at com.sun.tools.javac.code.Symbol.complete(Symbol.java:432)
+//      at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:832)
+//      at com.sun.tools.javac.comp.Enter.complete(Enter.java:500)
+//      at com.sun.tools.javac.comp.Enter.main(Enter.java:478)
+//      at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:950)
+//      at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:841)
+//      at com.sun.tools.javac.main.Main.compile(Main.java:441)
+//      at com.sun.tools.javac.main.Main.compile(Main.java:358)
+//      at com.sun.tools.javac.main.Main.compile(Main.java:347)
+//      at com.sun.tools.javac.main.Main.compile(Main.java:338)
+//      at com.sun.tools.javac.Main.compile(Main.java:76)
+//      at com.sun.tools.javac.Main.main(Main.java:61)
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.out
new file mode 100644
index 0000000..caeb4bb
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/BrokenAnnotation.out
@@ -0,0 +1,3 @@
+BrokenAnnotation.java:16:6: compiler.err.cant.resolve.location: kindname.class, Target, , , (compiler.misc.location: kindname.class, BrokenAnnotation<T>, null)
+BrokenAnnotation.java:15:34: compiler.err.annotation.type.not.applicable
+2 errors
\ No newline at end of file
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..ae1a043
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue<K extends @A(value = 2, value = 1) Object> {
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..5badf2c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:9:56: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..0e64a84
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnno<K extends @A @A Object> {
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..b657485
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:9:38: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.java
new file mode 100644
index 0000000..374a143
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation<K extends @A Object> {
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.out
new file mode 100644
index 0000000..d474f17
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:9:33: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java
new file mode 100644
index 0000000..58cb921
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java
@@ -0,0 +1,14 @@
+import java.lang.annotation.*;
+
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K extends @A Object> {
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out
new file mode 100644
index 0000000..89f3ef0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:10:40: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.java
new file mode 100644
index 0000000..886efb2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.java
@@ -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) {}
+}
+
+ at interface DA { }
+
+ at Target(ElementType.TYPE_USE)
+ at interface TA { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.out
new file mode 100644
index 0000000..5cd0173
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DeclarationAnnotation.out
@@ -0,0 +1,2 @@
+DeclarationAnnotation.java:14:14: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..aa0dd5c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values in receiver
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue {
+  void test(@A(value = 2, value = 1) DuplicateAnnotationValue this) { }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..73cff02
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:10:27: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..1ba2846
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations in receiver
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnnotation {
+  void test(@A @A DuplicateTypeAnnotation this) { }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..2105831
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:10:16: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.java
new file mode 100644
index 0000000..a0f0343
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test(@A InvalidLocation this) {
+  }
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.out
new file mode 100644
index 0000000..96a01ce
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:10:13: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java
new file mode 100644
index 0000000..4043ed6
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test(@A MissingAnnotationValue this) { }
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out
new file mode 100644
index 0000000..c833910
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:9:13: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java
new file mode 100644
index 0000000..1981d78
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/Nesting.java
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * 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 8006775
+ * @summary Ensure that nested classes/methods work
+ * @author Werner Dietl
+ * @compile Nesting.java
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
+
+class Nesting {
+    void top(@A Nesting this) {}
+
+    class B {
+        void inB(@A B this) {}
+    }
+
+    void meth(@A Nesting this) {
+        class C {
+            void inMethod(@A C this) {}
+        }
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.java
new file mode 100644
index 0000000..35ee843
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.java
@@ -0,0 +1,56 @@
+/*
+ * 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
+ * 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 8006775
+ * @summary the receiver parameter and static methods/classes
+ * @author Werner Dietl
+ * @compile/fail/ref=StaticThings.out -XDrawDiagnostics StaticThings.java
+ */
+class Test {
+  // bad
+  static void test1(Test this) {}
+
+  // bad
+  static Object test2(Test this) { return null; }
+
+  class Nested1 {
+    // good
+    void test3a(Nested1 this) {}
+    // good
+    void test3b(Test.Nested1 this) {}
+    // No static methods
+    // static void test3c(Nested1 this) {}
+  }
+  static class Nested2 {
+    // good
+    void test4a(Nested2 this) {}
+    // good
+    void test4b(Test.Nested2 this) {}
+    // bad
+    static void test4c(Nested2 this) {}
+    // bad
+    static void test4d(Test.Nested2 this) {}
+  }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out
new file mode 100644
index 0000000..e64bdba
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/StaticThings.out
@@ -0,0 +1,5 @@
+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
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java
new file mode 100644
index 0000000..14911c3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.java
@@ -0,0 +1,72 @@
+/*
+ * 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
+ * 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 8006775
+ * @summary the receiver parameter has the type of the surrounding class
+ * @author Werner Dietl
+ * @compile/fail/ref=WrongType.out -XDrawDiagnostics WrongType.java
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+ at Target(ElementType.TYPE_USE)
+ at interface A {}
+
+class WrongType {
+  Object f;
+
+  void good1(@A WrongType this) {}
+
+  void good2(@A WrongType this) {
+    this.f = null;
+    Object o = this.f;
+  }
+
+  void bad1(@A Object this) {}
+
+  void bad2(@A Object this) {
+    this.f = null;
+    Object o = this.f;
+  }
+
+  void wow(@A XYZ this) {
+    this.f = null;
+  }
+
+  class Inner {
+    void good1(@A Inner this) {}
+    void good2(@A WrongType.Inner this) {}
+
+    void outerOnly(@A WrongType this) {}
+    void wrongInner(@A Object this) {}
+    void badOuter(@A Outer.Inner this) {}
+    void badInner(@A WrongType.XY this) {}
+  }
+
+  class Generics<X> {
+    <Y> void m(Generics<Y> this) {}
+  }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out
new file mode 100644
index 0000000..b544267
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/receiver/WrongType.out
@@ -0,0 +1,9 @@
+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
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..5f399fa
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for Duplicate annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue {
+  void test() {
+    new @A String();
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..dd7e50b
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:11:9: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..014490f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnnotation {
+  void test() {
+    new @A @A String();
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..904f7c1
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:11:12: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.java
new file mode 100644
index 0000000..c362297
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    new @A String();
+  }
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.out
new file mode 100644
index 0000000..ad9861c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:11:9: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java
new file mode 100644
index 0000000..db3c563
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @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();
+  }
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out
new file mode 100644
index 0000000..3dac47d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/rest/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:14:9: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..a1f432e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue<@A(value = 2, value = 1) String> l;
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..c8e21de
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:10:42: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..c25afb5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A String> l;
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..9dc12fd
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.java
new file mode 100644
index 0000000..4b12e79
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A String> l;
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.out
new file mode 100644
index 0000000..30841b7
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java
new file mode 100644
index 0000000..a6e0030
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A String> l;
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out
new file mode 100644
index 0000000..749442f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..22ab06e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue<@A(value = 2, value = 1) K> {
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..b3485b2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:9:46: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..20883a0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnno<@A @A K> {
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..fe3d430
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:9:28: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.java
new file mode 100644
index 0000000..094a76c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation<@A K> {
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.out
new file mode 100644
index 0000000..87d42a2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:9:23: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java
new file mode 100644
index 0000000..39f8bee
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<@A K> {
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out
new file mode 100644
index 0000000..acac021
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:8:30: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.java
new file mode 100644
index 0000000..68d77b9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.java
@@ -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;
+}
+
+ at interface DA { }
+
+ at Target(ElementType.TYPE_USE)
+ at interface TA { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.out
new file mode 100644
index 0000000..c070ab3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DeclarationAnnotation.out
@@ -0,0 +1,2 @@
+DeclarationAnnotation.java:15:10: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java
new file mode 100644
index 0000000..7355719
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 6919944 8006775
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics DuplicateAnnotationValue.java
+ */
+import java.lang.annotation.*;
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue<@A(value = 2, value = 1) ?> l;
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out
new file mode 100644
index 0000000..c8e21de
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:10:42: compiler.err.duplicate.annotation.member.value: value, A
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java
new file mode 100644
index 0000000..17ac7a9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics DuplicateTypeAnnotation.java
+ */
+import java.lang.annotation.*;
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A ?> l;
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out
new file mode 100644
index 0000000..9dc12fd
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:10:24: compiler.err.duplicate.annotation.missing.container: A, java.lang.annotation.Repeatable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.java b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.java
new file mode 100644
index 0000000..eee6ed2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A ?> l;
+}
+
+ at java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.out b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.out
new file mode 100644
index 0000000..30841b7
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/InvalidLocation.out
@@ -0,0 +1,2 @@
+InvalidLocation.java:10:19: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java
new file mode 100644
index 0000000..c111c89
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A ?> l;
+}
+
+ at interface A { int field(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out
new file mode 100644
index 0000000..749442f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:9:26: compiler.err.annotation.missing.default.value: A, field
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.java b/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.java
new file mode 100644
index 0000000..bbba634
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.java
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=Constructor.out -XDrawDiagnostics Constructor.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class Constructor {
+  // Constructor result type use annotation
+  @A Constructor() { }
+
+  // Not type parameter annotation
+  @B Constructor(int x) { }
+
+  // TODO add err: no "this" receiver parameter for constructors
+  // Constructor(@A Constructor this, Object o) { }
+
+  // TODO: support Outer.this.
+}
+
+class Constructor2 {
+  class Inner {
+    // OK
+    @A Inner() { }
+  }
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface B { }
+
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.out b/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.out
new file mode 100644
index 0000000..0568924
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/Constructor.out
@@ -0,0 +1,2 @@
+Constructor.java:17:3: compiler.err.annotation.type.not.applicable
+1 error
\ No newline at end of file
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.java b/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.java
new file mode 100644
index 0000000..6363da0
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2009, 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 Class literals are not type uses and cannot be annotated
+ * @author Werner Dietl
+ * @compile/fail/ref=DotClass.out -XDrawDiagnostics DotClass.java
+ */
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.TYPE_PARAMETER;
+import static java.lang.annotation.ElementType.TYPE_USE;
+
+ at Target({TYPE_USE, TYPE_PARAMETER, TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+ at interface A {}
+
+ at interface B { int value(); }
+
+class T0x1E {
+    void m0x1E() {
+        Class<Object> c = @A Object.class;
+    }
+
+    Class<?> c = @A String.class;
+
+    Class<? extends @A String> as = @A String.class;
+}
+
+class ClassLiterals {
+    public static void main(String[] args) {
+        if (String.class != @A String.class) throw new Error();
+        if (@A int.class != int.class) throw new Error();
+        if (@A int.class != Integer.TYPE) throw new Error();
+        if (@A int @B(0) [].class != int[].class) throw new Error();
+
+        if (String[].class != @A String[].class) throw new Error();
+        if (String[].class != String @A [].class) throw new Error();
+        if (@A int[].class != int[].class) throw new Error();
+        if (@A int @B(0) [].class != int[].class) throw new Error();
+    }
+
+    Object classLit1 = @A String @C [] @B(0) [].class;
+    Object classLit2 = @A String @C []       [].class;
+    Object classLit3 = @A String    [] @B(0) [].class;
+    Object classLit4 =    String    [] @B(0) [].class;
+    Object classLit5 =    String @C []       [].class;
+    Object classLit6 =    String    []       [].class;
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.out b/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.out
new file mode 100644
index 0000000..c40f3d7
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/DotClass.out
@@ -0,0 +1,17 @@
+DotClass.java:47:42: compiler.err.no.annotations.on.dot.class
+DotClass.java:50:33: compiler.err.no.annotations.on.dot.class
+DotClass.java:52:52: compiler.err.no.annotations.on.dot.class
+DotClass.java:57:44: compiler.err.no.annotations.on.dot.class
+DotClass.java:58:26: compiler.err.no.annotations.on.dot.class
+DotClass.java:59:26: compiler.err.no.annotations.on.dot.class
+DotClass.java:60:35: compiler.err.no.annotations.on.dot.class
+DotClass.java:62:48: compiler.err.no.annotations.on.dot.class
+DotClass.java:63:49: compiler.err.no.annotations.on.dot.class
+DotClass.java:64:28: compiler.err.no.annotations.on.dot.class
+DotClass.java:65:35: compiler.err.no.annotations.on.dot.class
+DotClass.java:68:54: compiler.err.no.annotations.on.dot.class
+DotClass.java:69:54: compiler.err.no.annotations.on.dot.class
+DotClass.java:70:54: compiler.err.no.annotations.on.dot.class
+DotClass.java:71:54: compiler.err.no.annotations.on.dot.class
+DotClass.java:72:54: compiler.err.no.annotations.on.dot.class
+16 errors
\ No newline at end of file
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.java b/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.java
new file mode 100644
index 0000000..c414a5f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test incomplete array declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics IncompleteArray.java
+ */
+class IncompleteArray {
+  int @A [] @A var;
+}
+
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.out b/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.out
new file mode 100644
index 0000000..a03a092
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/IncompleteArray.out
@@ -0,0 +1,2 @@
+IncompleteArray.java:9:13: compiler.err.illegal.start.of.type
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java
new file mode 100644
index 0000000..49ba85f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test invalid location of TypeUse and TypeParameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics NotTypeParameter.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod<@A K> {
+  @A void test() { }
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
+
+class TypeVariable<@B T> {
+  @B T test1() { return null; }
+  void test2(@B T p) {}
+}
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out
new file mode 100644
index 0000000..40e4ebc
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeParameter.out
@@ -0,0 +1,4 @@
+NotTypeParameter.java:13:3: compiler.err.annotation.type.not.applicable
+NotTypeParameter.java:20:3: compiler.err.annotation.type.not.applicable
+NotTypeParameter.java:21:14: compiler.err.annotation.type.not.applicable
+3 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.java b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.java
new file mode 100644
index 0000000..6c8bfee
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics NotTypeUse.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+ at Target(ElementType.TYPE)
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.out b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.out
new file mode 100644
index 0000000..9728d35
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/NotTypeUse.out
@@ -0,0 +1,2 @@
+NotTypeUse.java:13:3: compiler.err.annotation.type.not.applicable
+1 error
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.java b/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.java
new file mode 100644
index 0000000..a82768c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.java
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6843077 8006775
+ * @summary test invalid location of TypeUse and TypeParameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics VoidMethod.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  // Invalid
+  @A void test1() { }
+  // The following is legal:
+  @B void test2() { }
+  // Invalid
+  @C void test3() { }
+  // The following is legal:
+  @D void test4() { }
+}
+
+ at Target(ElementType.TYPE_USE)
+ at interface A { }
+
+ at Target({ElementType.TYPE_USE, ElementType.METHOD})
+ at interface B { }
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface C { }
+
+ at Target({ElementType.TYPE_PARAMETER, ElementType.METHOD})
+ at interface D { }
diff --git a/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.out b/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.out
new file mode 100644
index 0000000..7cbba4a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/failures/target/VoidMethod.out
@@ -0,0 +1,3 @@
+VoidMethod.java:14:3: compiler.err.annotation.type.not.applicable
+VoidMethod.java:18:3: compiler.err.annotation.type.not.applicable
+2 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java b/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
new file mode 100644
index 0000000..e4136c2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/AnonymousClass.java
@@ -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() { };
+}
+
+ at interface DA { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TA { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TB { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java b/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java
new file mode 100644
index 0000000..8c7fb83
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java
@@ -0,0 +1,81 @@
+
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary random tests for new locations
+ * @author Matt Papi
+ * @compile BasicTest.java
+ */
+
+import java.lang.annotation.*;
+import java.util.*;
+import java.io.*;
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface C {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface D {}
+
+/**
+ * Tests basic JSR 308 parser functionality. We don't really care about what
+ * the parse tree looks like, just that these annotations can be parsed.
+ */
+class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
+
+    void test() {
+
+        // Handle annotated cast types
+        Object o = (@A Object) "foo";
+
+        // Handle annotated "new" expressions (except arrays; see ArrayTest)
+        String s = new @A String("bar");
+
+        boolean b = o instanceof @A Object;
+
+        @A Map<@B List<@C String>, @D String> map =
+            new @A HashMap<@B List<@C String>, @D String>();
+
+        Class<? extends @A String> c2 = null;
+    }
+
+    // Handle receiver annotations
+    // Handle annotations on a qualified identifier list
+    void test2(@C @D BasicTest<T> this) throws @A IllegalArgumentException, @B IOException {
+
+    }
+
+    // Handle annotations on a varargs element type
+    void test3(@B Object @A... objs) { }
+
+    void test4(@B Class<@C ?> @A ... clz) { }
+
+
+    // TODO: add more tests... nested classes, etc.
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/ClassExtends.java b/test/tools/javac/annotations/typeAnnotations/newlocations/ClassExtends.java
new file mode 100644
index 0000000..24df077
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/ClassExtends.java
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: class extends/implements
+ * @author Mahmood Ali
+ * @compile ClassExtends.java
+ */
+abstract class MyClass extends @A ParameterizedClass<@B String>
+  implements @B CharSequence, @A ParameterizedInterface<@B String> { }
+
+interface MyInterface extends @A ParameterizedInterface<@A String>,
+                              @B CharSequence { }
+
+class ParameterizedClass<K> {}
+interface ParameterizedInterface<K> {}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B {}
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/ClassParameters.java b/test/tools/javac/annotations/typeAnnotations/newlocations/ClassParameters.java
new file mode 100644
index 0000000..9b2fbbe
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/ClassParameters.java
@@ -0,0 +1,60 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: class type parameter bounds
+ * @author Mahmood Ali
+ * @compile ClassParameters.java
+ */
+class Unannotated<K> { }
+
+class ExtendsBound<K extends @A String> { }
+class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+class TwoBounds<K extends @A String, V extends @B String> { }
+
+class Complex1<K extends @A String&Runnable> { }
+class Complex2<K extends String & @B Runnable> { }
+class ComplexBoth<K extends @A String & @A Runnable> { }
+
+class Outer {
+  void inner() {
+    class Unannotated<K> { }
+
+    class ExtendsBound<K extends @A String> { }
+    class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+    class TwoBounds<K extends @A String, V extends @B String> { }
+
+    class Complex1<K extends @A String&Runnable> { }
+    class Complex2<K extends String & @B Runnable> { }
+    class ComplexBoth<K extends @A String & @A Runnable> { }
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/ConstructorTypeArgs.java b/test/tools/javac/annotations/typeAnnotations/newlocations/ConstructorTypeArgs.java
new file mode 100644
index 0000000..6db9804
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/ConstructorTypeArgs.java
@@ -0,0 +1,59 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: constructor type args
+ * @author Mahmood Ali
+ * @compile ConstructorTypeArgs.java
+ */
+
+class ConstructorTypeArgs {
+  void oneArg() {
+    new @A MyList<@A String>();
+    new MyList<@A MyList<@B(0) String>>();
+  }
+
+  void twoArg() {
+    new MyMap<String, String>();
+    new MyMap<@A String, @B(0) MyList<@A String>>();
+  }
+
+  void withArraysIn() {
+    new MyList<String[]>();
+    new MyList<@A String @B(0) [] @A []>();
+
+    new MyMap<@A String[], @B(0) MyList<@A String> @A []>();
+  }
+}
+
+class MyList<E> { }
+class MyMap<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/ExceptionParameters.java b/test/tools/javac/annotations/typeAnnotations/newlocations/ExceptionParameters.java
new file mode 100644
index 0000000..81b327c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/ExceptionParameters.java
@@ -0,0 +1,76 @@
+/*
+ * 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.*;
+
+import java.io.*;
+
+/*
+ * @test
+ * @bug 6843077 8006775
+ * @summary new type annotation location: exception parameters
+ * @author Werner Dietl
+ * @compile ExceptionParameters.java
+ */
+
+class ExceptionParameters {
+
+  void exception() {
+    try {
+      foobar();
+    } catch (@A Exception e) {
+      e.toString();
+    }
+  }
+
+  void finalException() {
+    try {
+      foobar();
+    } catch (final @B Exception e) {
+      e.toString();
+    }
+  }
+
+  void multiException1() {
+    try {
+      foobar();
+    } catch (@A NullPointerException | @B IndexOutOfBoundsException e) {
+      e.toString();
+    }
+  }
+
+  void multiException2() {
+    try {
+      foobar();
+    } catch (java.lang. at A NullPointerException | java.lang. at B IndexOutOfBoundsException e) {
+      e.toString();
+    }
+  }
+
+  void foobar() {}
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Expressions.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Expressions.java
new file mode 100644
index 0000000..bd4acc9
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Expressions.java
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: expressions
+ * @author Mahmood Ali
+ * @compile Expressions.java
+ */
+class Expressions {
+  void instanceOf() {
+    Object o = null;
+    boolean a = o instanceof @A String;
+    boolean b = o instanceof @B(0) String;
+  }
+
+  void instanceOfArray() {
+    Object o = null;
+    boolean a1 = o instanceof @A String [];
+    boolean a2 = o instanceof @B(0) String [];
+
+    boolean b1 = o instanceof String @A [];
+    boolean b2 = o instanceof String @B(0) [];
+  }
+
+  void objectCreation() {
+    new @A String();
+    new @B(0) String();
+  }
+
+  void objectCreationArray() {
+    Object a1 = new @A String [] [] { };
+    Object a2 = new @A String [1] [];
+    Object a3 = new @A String [1] [2];
+
+    Object b1 = new @A String @B(0) [] [] { };
+    Object b2 = new @A String @B(0) [1] [];
+    Object b3 = new @A String @B(0) [1] [2];
+
+    Object c1 = new @A String []  @B(0) [] { };
+    Object c2 = new @A String [1] @B(0) [];
+    Object c3 = new @A String [1] @B(0) [2];
+
+    Object d1 = new @A String @B(0) []  @B(0) [] { };
+    Object d2 = new @A String @B(0) [1] @B(0) [];
+    Object d3 = new @A String @B(0) [1] @B(0) [2];
+
+    Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
+
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Fields.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Fields.java
new file mode 100644
index 0000000..04fb39f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Fields.java
@@ -0,0 +1,77 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: field type array/generics
+ * @author Mahmood Ali
+ * @compile Fields.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated;
+  Parameterized<@A String, String> firstTypeArg;
+  Parameterized<String, @A String> secondTypeArg;
+  Parameterized<@A String, @B String> bothTypeArgs;
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized;
+
+  @A String [] array1;
+  @A String @B [] array1Deep;
+  @A String [] [] array2;
+  @A String @A [] @B [] array2Deep;
+  String @A [] [] array2First;
+  String [] @B [] array2Second;
+
+  // Old-style array syntax
+  String array2FirstOld @A [];
+  String array2SecondOld [] @B [];
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated = null;
+  public final Parameterized<@A String, String> firstTypeArg = null;
+  public final Parameterized<String, @A String> secondTypeArg = null;
+  public final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized = null;
+
+  public final @A String [] array1 = null;
+  public final @A String @B [] array1Deep = null;
+  public final @A String [] [] array2 = null;
+  public final @A String @A [] @B [] array2Deep = null;
+  public final String @A [] [] array2First = null;
+  public final String [] @B [] array2Second = null;
+}
+
+class Parameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java
new file mode 100644
index 0000000..a2d874b
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Lambda.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8008077
+ * @summary new type annotation location: lambda expressions
+ * @compile Lambda.java
+ * @author Werner Dietl
+ */
+
+import java.lang.annotation.*;
+
+public class Lambda {
+
+    interface LambdaInt {
+        <S, T> void generic(S p1, T p2);
+    }
+
+    static class LambdaImpl implements LambdaInt {
+        <S, T> LambdaImpl(S p1, T p2) {}
+        public <S, T> void generic(S p1, T p2) {}
+    }
+
+    LambdaInt getMethodRefTA(LambdaImpl r) {
+        return r::<@TA Object, @TB Object>generic;
+    }
+
+    LambdaInt getConstructorRefTA() {
+        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); };
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TA { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TB { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/LocalVariables.java b/test/tools/javac/annotations/typeAnnotations/newlocations/LocalVariables.java
new file mode 100644
index 0000000..9f057f5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/LocalVariables.java
@@ -0,0 +1,81 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: local variables array/generics
+ * @author Mahmood Ali
+ * @compile LocalVariables.java
+ */
+
+class DefaultScope {
+  void parameterized() {
+    Parameterized<String, String> unannotated;
+    Parameterized<@A String, String> firstTypeArg;
+    Parameterized<String, @A String> secondTypeArg;
+    Parameterized<@A String, @B String> bothTypeArgs;
+
+    Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized;
+  }
+
+  void arrays() {
+    @A String [] array1;
+    @A String @B [] array1Deep;
+    @A String [] [] array2;
+    @A String @A [] @B [] array2Deep;
+    String @A [] [] array2First;
+    String [] @B [] array2Second;
+  }
+}
+
+class ModifiedVars {
+  void parameterized() {
+    final Parameterized<String, String> unannotated = null;
+    final Parameterized<@A String, String> firstTypeArg = null;
+    final Parameterized<String, @A String> secondTypeArg = null;
+    final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+    final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized = null;
+  }
+
+  void arrays() {
+    final @A String [] array1 = null;
+    final @A String @B [] array1Deep = null;
+    final @A String [] [] array2 = null;
+    final @A String @A [] @B [] array2Deep = null;
+    final String @A [] [] array2First = null;
+    final String [] @B [] array2Second = null;
+  }
+}
+
+class Parameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/MethodReturnType.java b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodReturnType.java
new file mode 100644
index 0000000..1a3b490
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodReturnType.java
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: method return type array/generics
+ * @author Mahmood Ali
+ * @compile MethodReturnType.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated() { return null; }
+  Parameterized<@A String, String> firstTypeArg() { return null; }
+  Parameterized<String, @A String> secondTypeArg() { return null; }
+  Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public <T> @A String method() { return null; }
+
+  @A String [] array1() { return null; }
+  @A String @B [] array1Deep() { return null; }
+  @A String [] [] array2() { return null; }
+  @A String @A [] @B [] array2Deep() { return null; }
+  String @A [] [] array2First() { return null; }
+  String [] @B [] array2Second() { return null; }
+
+  // Old-style array syntax
+  String array2FirstOld() @A [] { return null; }
+  String array2SecondOld() [] @B [] { return null; }
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated() { return null; }
+  public final Parameterized<@A String, String> firstTypeArg() { return null; }
+  public final Parameterized<String, @A String> secondTypeArg() { return null; }
+  public final Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public final @A String [] array1() { return null; }
+  public final @A String @B [] array1Deep() { return null; }
+  public final @A String [] [] array2() { return null; }
+  public final @A String @A [] @B [] array2Deep() { return null; }
+  public final String @A [] [] array2First() { return null; }
+  public final String [] @B [] array2Second() { return null; }
+}
+
+class Parameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeArgs.java b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeArgs.java
new file mode 100644
index 0000000..1da6276
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeArgs.java
@@ -0,0 +1,67 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: method type args
+ * @author Mahmood Ali
+ * @compile MethodTypeArgs.java
+ */
+
+class MethodTypeArgs {
+  void oneArg() {
+    this.<@A String>newList();
+    this.<@A MyList<@B(0) String>>newList();
+
+    MethodTypeArgs.<@A String>newList();
+    MethodTypeArgs.<@A MyList<@B(0) String>>newList();
+  }
+
+  void twoArg() {
+    this.<String, String>newMap();
+    this.<@A String, @B(0) MyList<@A String>>newMap();
+
+    MethodTypeArgs.<String, String>newMap();
+    MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap();
+  }
+
+  void withArraysIn() {
+    this.<String[]>newList();
+    this.<@A String @B(0) [] @A []>newList();
+
+    this.<@A String[], @B(0) MyList<@A String> @A []>newMap();
+  }
+
+  static <E> void newList() { }
+  static <K, V> void newMap() { }
+}
+
+class MyList<E> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { int value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeParameters.java b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeParameters.java
new file mode 100644
index 0000000..4363af1
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/MethodTypeParameters.java
@@ -0,0 +1,53 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: method type parameter bounds
+ * @author Mahmood Ali
+ * @compile MethodTypeParameters.java
+ */
+
+class UnscopedUnmodified {
+  <K extends @A String> void methodExtends() {}
+  <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class PublicModifiedMethods {
+  public final <K extends @A String> void methodExtends() {}
+  public final <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  public final <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  public final <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class Parameterized<K> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java b/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
new file mode 100644
index 0000000..8a1545d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/MultiCatch.java
@@ -0,0 +1,78 @@
+/*
+ * 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
+ * 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 8006775
+ * @summary new type annotation location: multicatch
+ * @author Werner Dietl
+ * @compile MultiCatch.java
+ */
+
+class DefaultScope {
+  void exception01() {
+    try {
+        System.out.println("Hello 1!");
+    } catch (@B NullPointerException | @C IllegalArgumentException e) {
+      e.toString();
+    }
+  }
+  /* Disabled: there is no syntax to annotate all components
+   * of the multicatch.
+  void exception02() {
+    try {
+        System.out.println("Hello 2!");
+    } catch @A (@B NullPointerException | @C IllegalArgumentException e) {
+      e.toString();
+    }
+  }
+  */
+}
+
+class ModifiedVars {
+  void exception01() {
+    try {
+        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();
+    }
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface C { }
+
+ at interface Decl { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/NestedTypes.java b/test/tools/javac/annotations/typeAnnotations/newlocations/NestedTypes.java
new file mode 100644
index 0000000..7572b4f
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/NestedTypes.java
@@ -0,0 +1,212 @@
+/*
+ * 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
+ * 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.*;
+import java.util.Map;
+
+/*
+ * @test
+ * @bug 8006775
+ * @summary new type annotation location: nested types
+ * @author Werner Dietl
+ * @compile NestedTypes.java
+ */
+class Outer {
+    class Inner {
+        class Inner2 {
+            // m1a-c all have the same parameter type.
+            void m1a(@A Inner2 p1a) {}
+            void m1b(Inner. at A Inner2 p1b) {}
+            void m1c(Outer.Inner. at A Inner2 p1c) {}
+            // notice the difference to m1d
+            void m1d(@A Outer.Inner.Inner2 p1d) {}
+
+            // m2a-b both have the same parameter type.
+            void m2a(@A Inner.Inner2 p2a) {}
+            void m2b(Outer. at A Inner.Inner2 p2b) {}
+
+            // The location for @A is the same in m3a-c
+            void m3a(@A Outer p3a) {}
+            void m3b(@A Outer.Inner p3b) {}
+            void m3c(@A Outer.Inner.Inner2 p3c) {}
+
+            // Test combinations
+            void m4a(@A Outer p3a) {}
+            void m4b(@A Outer. @B Inner p3b) {}
+            void m4c(@A Outer. @B Inner. @C Inner2 p3c) {}
+        }
+    }
+
+    void m4a(@A Map p4a) {}
+    void m4b(Map. at B Entry p4c) {}
+    // Illegal:
+    // void m4b(@A Map.Entry p4b) {}
+    // void m4c(@A Map. at B Entry p4c) {}
+
+    void m4c(Map<String,String>. at B Entry<String,String> p4d) {}
+    // Illegal:
+    // void m4d(@A Map<String,String>. at B Entry<String,String> p4d) {}
+
+    void m4e(MyList<Map.Entry> p4e) {}
+    void m4f(MyList<Map. at B Entry> p4f) {}
+    // Illegal:
+    // void m4g(MyList<@A Map.Entry> p4e) {}
+    // void m4h(MyList<@A Map. at B Entry> p4f) {}
+
+    class GInner<X> {
+        class GInner2<Y, Z> {}
+    }
+
+    static class Static {}
+    static class GStatic<X, Y> {
+        static class GStatic2<Z> {}
+    }
+}
+
+class Test1 {
+    // Outer.GStatic<Object,Object>.GStatic2<Object> gs;
+    Outer.GStatic. at A GStatic2<Object> gsgood;
+    // TODO: add failing test
+    // Outer. at A GStatic.GStatic2<Object> gsbad;
+
+    MyList<@A Outer . @B Inner. @C Inner2> f;
+    @A Outer .GInner<Object>.GInner2<String, Integer> g;
+
+    // TODO: Make sure that something like this fails gracefully:
+    // MyList<java. at B lang.Object> pkg;
+
+    @A Outer f1;
+    @A Outer . @B Inner f2 = f1.new @B Inner();
+    // TODO: ensure type annos on new are stored.
+    @A Outer . @B GInner<@C Object> f3 = f1.new @B GInner<@C Object>();
+
+    MyList<@A Outer . @B GInner<@C MyList<@D Object>>. @E GInner2<@F Integer, @G Object>> f4;
+    // MyList<Outer.GInner<Object>.GInner2<Integer>> f4clean;
+
+    @A Outer . @B GInner<@C MyList<@D Object>>. @E GInner2<@F Integer, @G Object> f4top;
+
+    MyList<@A Outer . @B GInner<@C MyList<@D Object @E[] @F[]>>. @G GInner2<@H Integer, @I Object> @J[] @K[]> f4arr;
+
+    @A Outer . @B GInner<@C MyList<@D Object @E[] @F[]>>. @G GInner2<@H Integer, @I Object> @J[] @K[] f4arrtop;
+
+    MyList<Outer . @B Static> f5;
+    // Illegal:
+    // MyList<@A Outer . @B Static> f5;
+
+    Outer . @B Static f6;
+    // Illegal:
+    // @A Outer . @B Static f6;
+
+    Outer . @Bv("B") GStatic<@Cv("C") String, @Dv("D") Object> f7;
+    // Illegal:
+    // @Av("A") Outer . @Bv("B") GStatic<@Cv("C") String, @Dv("D") Object> f7;
+
+    Outer . @Cv("Data") Static f8;
+    // Illegal:
+    // @A Outer . @Cv("Data") Static f8;
+
+    MyList<Outer . @Cv("Data") Static> f9;
+    // Illegal:
+    // MyList<@A Outer . @Cv("Data") Static> f9;
+}
+
+class Test2 {
+    void m() {
+        @A Outer f1 = null;
+        @A Outer. at B Inner f2 = null;
+        Outer. at B Static f3 = null;
+        // Illegal:
+        // @A Outer. at B Static f3 = null;
+        @A Outer. at C Inner f4 = null;
+
+        Outer . @B Static f5 = null;
+        Outer . @Cv("Data") Static f6 = null;
+        MyList<Outer . @Cv("Data") Static> f7 = null;
+    }
+}
+
+class Test3 {
+    void monster(@A Outer p1,
+        @A Outer. at B Inner p2,
+        Outer. at B Static p3,
+        @A Outer. at Cv("Test") Inner p4,
+        Outer . @B Static p5,
+        Outer . @Cv("Data") Static p6,
+        MyList<Outer . @Cv("Data") Static> p7) {
+    }
+}
+
+class Test4 {
+    void m() {
+        @A Outer p1 = new @A Outer();
+        @A Outer. at B Inner p2 = p1.new @B Inner();
+        // Illegal:
+        // @A Outer. at B Static p3 = new @A Outer. at B Static();
+        // Object o3 = new @A Outer. at B Static();
+
+        @A Outer. at Cv("Test") Inner p4 = p1.new @Cv("Test") Inner();
+        Outer . @B Static p5 = new Outer . @B Static();
+        Outer . @Cv("Data") Static p6 = new Outer . @Cv("Data") Static();
+        MyList<Outer . @Cv("Data") Static> p7 = new MyList<Outer . @Cv("Data") Static>();
+    }
+}
+
+class MyList<K> { }
+
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface C { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface D { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface E { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface F { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface G { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface H { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface I { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface J { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface K { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Av { String value(); }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Bv { String value(); }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Cv { String value(); }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Dv { String value(); }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Ev { String value(); }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface Fv { String value(); }
+
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Parameters.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Parameters.java
new file mode 100644
index 0000000..4952986
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Parameters.java
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: parameter type array/generics
+ * @author Mahmood Ali
+ * @compile Parameters.java
+ */
+
+class Parameters {
+  void unannotated(Parameterized<String, String> a) {}
+  void firstTypeArg(Parameterized<@A String, String> a) {}
+  void secondTypeArg(Parameterized<String, @A String> a) {}
+  void bothTypeArgs(Parameterized<@A String, @B String> both) {}
+
+  void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {}
+
+  void array1(@A String [] a) {}
+  void array1Deep(@A String @B [] a) {}
+  void array2(@A String [] [] a) {}
+  void array2Deep(@A String @A [] @B [] a) {}
+  void array2First(String @A [] [] a) {}
+  void array2Second(String [] @B [] a) {}
+}
+
+class Parameterized<K, V> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java
new file mode 100644
index 0000000..95103ff
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java
@@ -0,0 +1,131 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: receivers
+ * @author Mahmood Ali, Werner Dietl
+ * @compile Receivers.java
+ */
+class DefaultUnmodified {
+  void plain(@A DefaultUnmodified this) { }
+  <T> void generic(@A DefaultUnmodified this) { }
+  void withException(@A DefaultUnmodified this) throws Exception { }
+  String nonVoid(@A DefaultUnmodified this) { return null; }
+  <T extends Runnable> void accept(@A DefaultUnmodified this, T r) throws Exception { }
+}
+
+class PublicModified {
+  public final void plain(@A PublicModified this) { }
+  public final <T> void generic(@A PublicModified this) { }
+  public final void withException(@A PublicModified this) throws Exception { }
+  public final String nonVoid(@A PublicModified this) { return null; }
+  public final <T extends Runnable> void accept(@A PublicModified this, T r) throws Exception { }
+}
+
+class WithValue {
+  void plain(@B("m") WithValue this) { }
+  <T> void generic(@B("m") WithValue this) { }
+  void withException(@B("m") WithValue this) throws Exception { }
+  String nonVoid(@B("m") WithValue this) { return null; }
+  <T extends Runnable> void accept(@B("m") WithValue this, T r) throws Exception { }
+}
+
+class WithFinal {
+  void plain(final @B("m") WithFinal this) { }
+  <T> void generic(final @B("m") WithFinal this) { }
+  void withException(final @B("m") WithFinal this) throws Exception { }
+  String nonVoid(final @B("m") WithFinal this) { return null; }
+  <T extends Runnable> void accept(final @B("m") WithFinal this, T r) throws Exception { }
+}
+
+class WithBody {
+  Object f;
+
+  void field(@A WithBody this) {
+    this.f = null;
+  }
+  void meth(@A WithBody this) {
+    this.toString();
+  }
+}
+
+class Generic1<X> {
+  void test1(Generic1<X> this) {}
+  void test2(@A Generic1<X> this) {}
+  void test3(Generic1<@A X> this) {}
+  void test4(@A Generic1<@A X> this) {}
+}
+
+class Generic2<@A X> {
+  void test1(Generic2<X> this) {}
+  void test2(@A Generic2<X> this) {}
+  void test3(Generic2<@A X> this) {}
+  void test4(@A Generic2<@A X> this) {}
+}
+
+class Generic3<X extends @A Object> {
+  void test1(Generic3<X> this) {}
+  void test2(@A Generic3<X> this) {}
+  void test3(Generic3<@A X> this) {}
+  void test4(@A Generic3<@A X> this) {}
+}
+
+class Generic4<X extends @A Object> {
+  <Y> void test1(Generic4<X> this) {}
+  <Y> void test2(@A Generic4<X> this) {}
+  <Y> void test3(Generic4<@A X> this) {}
+  <Y> void test4(@A Generic4<@A X> this) {}
+}
+
+class Outer {
+  class Inner {
+    void none(Outer.Inner this) {}
+    void outer(@A Outer.Inner this) {}
+    void inner(Outer. @B("i") Inner this) {}
+    void both(@A Outer. at B("i") Inner this) {}
+
+    void innerOnlyNone(Inner this) {}
+    void innerOnly(@A Inner this) {}
+  }
+}
+
+class GenericOuter<S, T> {
+  class GenericInner<U, V> {
+    void none(GenericOuter<S, T>.GenericInner<U, V> this) {}
+    void outer(@A GenericOuter<S, T>.GenericInner<U, V> this) {}
+    void inner(GenericOuter<S, T>. @B("i") GenericInner<U, V> this) {}
+    void both(@A GenericOuter<S, T>. at B("i") GenericInner<U, V> this) {}
+
+    void innerOnlyNone(GenericInner<U, V> this) {}
+    void innerOnly(@A GenericInner<U, V> this) {}
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { String value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.java b/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.java
new file mode 100644
index 0000000..3aecc7a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+
+/*
+ * @test
+ * @bug 8006775
+ * @summary repeating type annotations are possible
+ * @author Werner Dietl
+ * @compile/fail/ref=RepeatingTypeAnnotations.out -XDrawDiagnostics RepeatingTypeAnnotations.java
+ */
+
+class RepeatingTypeAnnotations {
+    // Fields
+    @RTA @RTA Object fr1 = null;
+    Object fr2 = new @RTA @RTA Object();
+    // error
+    Object fs = new @TA @TA Object();
+    // error
+    Object ft = new @TA @TA Object();
+    Object fe = new @TA @TA Object();
+
+    // Local variables
+    Object foo() {
+        Object o = new @RTA @RTA Object();
+        o = new @TA @RTA @RTA Object();
+        o = new @RTA @TA @RTA Object();
+        // error
+        o = new @RTA @TA @RTA @TA Object();
+        // error
+        return new @TA @TA Object();
+    }
+
+    // Instance creation
+    Object bar() {
+        Object o = new @RTA @RTA MyList<@RTA @RTA Object>();
+        o = new @TA @RTA MyList<@TA @RTA Object>();
+        o = new @TA @RTA @RTA MyList<@RTA @TA @RTA Object>();
+        // error
+        o = new @TA @TA MyList<@RTA @RTA Object>();
+        // error
+        o = new @RTA @RTA MyList<@TA @TA Object>();
+        // error
+        return new @TA @TA MyList<@RTA @RTA Object>();
+    }
+
+    // More tests
+    void oneArg() {
+        Object o = new @RTA @RTA Object();
+        // error
+        o = new @TA @TA Object();
+        o = new @RTA @TA @RTA Object();
+
+        o = new MyList<@RTA @RTA Object>();
+        // error
+        o = new MyList<@TA @TA Object>();
+        // error
+        o = new @TA @TA MyList<@TA @TA Object>();
+        // error
+        this.<@TA @TA String>newList();
+
+        this.<@RTA @RTA MyList<@RTA @RTA String>>newList();
+        // error
+        this.<@TA @TA MyList<@TA @TA String>>newList();
+
+        o = (@RTA @RTA MyList<@RTA @RTA Object>) o;
+        // error
+        o = (@TA @TA MyList<@TA @TA Object>) o;
+
+        this.<@RTA @RTA String, @RTA @RTA Object>newMap();
+        // error
+        this.<@TA @TA String, @TA @TA Object>newMap();
+
+        this.<@RTA @RTA String @RTA @RTA []>newList();
+        // error
+        this.<@TA @TA String @TA @TA []>newList();
+
+        this.<@RTA @RTA String @RTA @RTA [] @RTA @RTA [], MyList<@RTA @RTA String> @RTA @RTA []>newMap();
+        // error
+        this.<String @TA @TA [] @TA @TA [], MyList<@TA @TA String> @TA @TA []>newMap();
+    }
+
+    static <E> void newList() { }
+    static <K, V> void newMap() { }
+}
+
+class MyList<E> { }
+
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TA { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface TAs {
+    TA[] value();
+}
+
+ at Repeatable(RTAs.class)
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface RTA { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface RTAs {
+    RTA[] value();
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.out b/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.out
new file mode 100644
index 0000000..2e89277
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/RepeatingTypeAnnotations.out
@@ -0,0 +1,28 @@
+RepeatingTypeAnnotations.java:39:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:41:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:42:25: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:50:31: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:52:24: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:61:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:63:38: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:65:24: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:72:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:77:28: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:79:21: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:79:36: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:81:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:85:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:85:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:89:18: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:89:33: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:93:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:93:35: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:97:34: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:97:19: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:101:26: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:101:37: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:101:72: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+RepeatingTypeAnnotations.java:101:56: compiler.err.duplicate.annotation.missing.container: TA, java.lang.annotation.Repeatable
+- compiler.note.unchecked.filename: RepeatingTypeAnnotations.java
+- compiler.note.unchecked.recompile
+25 errors
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/ResourceVariables.java b/test/tools/javac/annotations/typeAnnotations/newlocations/ResourceVariables.java
new file mode 100644
index 0000000..7482e04
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/ResourceVariables.java
@@ -0,0 +1,46 @@
+/*
+ * 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.*;
+
+import java.io.*;
+
+/*
+ * @test
+ * @bug 6843077 8006775
+ * @summary new type annotation location: resource variables
+ * @author Werner Dietl
+ * @compile ResourceVariables.java
+ */
+
+class ResourceVariables {
+    void m() throws Exception {
+        try (@A InputStream is = new @B FileInputStream("xxx")) {
+        }
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Throws.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Throws.java
new file mode 100644
index 0000000..147325a
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Throws.java
@@ -0,0 +1,51 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: throw clauses
+ * @author Mahmood Ali
+ * @compile Throws.java
+ */
+class DefaultUnmodified {
+  void oneException() throws @A Exception {}
+  void twoExceptions() throws @A RuntimeException, @A Exception {}
+}
+
+class PublicModified {
+  public final void oneException(String a) throws @A Exception {}
+  public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {}
+}
+
+class WithValue {
+  void oneException() throws @B("m") Exception {}
+  void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {}
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { String value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/TopLevelBlocks.java b/test/tools/javac/annotations/typeAnnotations/newlocations/TopLevelBlocks.java
new file mode 100644
index 0000000..ee2a671
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/TopLevelBlocks.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+import java.lang.annotation.*;
+import java.util.Map;
+
+/*
+ * @test
+ * @bug 8006775
+ * @summary type annotation location: top level blocks
+ * @author Werner Dietl
+ * @compile TopLevelBlocks.java
+ */
+
+class TopLevelBlocks {
+    static Object f;
+
+    {
+        f = new @A Object();
+    }
+
+    static final Object sf;
+
+    static {
+        sf = new @A Object();
+    }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/TypeCasts.java b/test/tools/javac/annotations/typeAnnotations/newlocations/TypeCasts.java
new file mode 100644
index 0000000..c7508e2
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/TypeCasts.java
@@ -0,0 +1,48 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: type casts
+ * @author Mahmood Ali
+ * @compile TypeCasts.java
+ */
+class TypeCasts {
+  void methodA() {
+    String s = (@A String) null;
+    Object o = (@A Class<@A String>) null;
+  }
+
+  void methodB() {
+    String s = (@B("m") String) null;
+    Object o = (@B("m") Class<@B("m") String>) null;
+  }
+}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { String value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java b/test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java
new file mode 100644
index 0000000..1e93ba5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/TypeParameters.java
@@ -0,0 +1,60 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: class and method type parameters
+ * @author Mahmood Ali
+ * @compile TypeParameters.java
+ */
+
+class Unannotated<K> { }
+class OneAnnotated<@A K> { }
+class TwoAnnotated<@A K, @A V> { }
+class SecondAnnotated<K, @A V extends String> { }
+
+class TestMethods {
+  <K> void unannotated() { }
+  <@A K> void oneAnnotated() { }
+  <@A K, @B("m") V> void twoAnnotated() { }
+  <K, @A V extends @A String> void secondAnnotated() { }
+}
+
+class UnannotatedB<K> { }
+class OneAnnotatedB<@B("m") K> { }
+class TwoAnnotatedB<@B("m") K, @B("m") V> { }
+class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { }
+
+class OneAnnotatedC<@C K> { }
+class TwoAnnotatedC<@C K, @C V> { }
+class SecondAnnotatedC<K, @C V extends String> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { String value(); }
+ at Target(ElementType.TYPE_USE)
+ at interface C { }
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Varargs.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Varargs.java
new file mode 100644
index 0000000..e0c3082
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Varargs.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2008, 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 test acceptance of varargs annotations
+ * @author Mahmood Ali
+ * @compile Varargs.java
+ */
+
+import java.lang.annotation.*;
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A {}
+
+class Varargs {
+
+    // Handle annotations on a varargs element type
+    void varargPlain(Object @A... objs) {
+
+    }
+
+    void varargGeneric(Class<?> @A ... clz) {
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/newlocations/Wildcards.java b/test/tools/javac/annotations/typeAnnotations/newlocations/Wildcards.java
new file mode 100644
index 0000000..38de895
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Wildcards.java
@@ -0,0 +1,74 @@
+/*
+ * 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
+ * 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 6843077 8006775
+ * @summary new type annotation location: wildcard bound
+ * @author Mahmood Ali
+ * @compile Wildcards.java
+ */
+class BoundTest {
+  void wcExtends(MyList<? extends @A String> l) { }
+  void wcSuper(MyList<? super @A String> l) { }
+
+  MyList<? extends @A String> returnWcExtends() { return null; }
+  MyList<? super @A String> returnWcSuper() { return null; }
+  MyList<? extends @A MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class BoundWithValue {
+  void wcExtends(MyList<? extends @B("m") String> l) { }
+  void wcSuper(MyList<? super @B(value="m") String> l) { }
+
+  MyList<? extends @B("m") String> returnWcExtends() { return null; }
+  MyList<? super @B(value="m") String> returnWcSuper() { return null; }
+  MyList<? extends @B("m") MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class SelfTest {
+  void wcExtends(MyList<@A ?> l) { }
+  void wcSuper(MyList<@A ?> l) { }
+
+  MyList<@A ?> returnWcExtends() { return null; }
+  MyList<@A ?> returnWcSuper() { return null; }
+  MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; }
+}
+
+class SelfWithValue {
+  void wcExtends(MyList<@B("m") ?> l) { }
+  void wcSuper(MyList<@B(value="m") ?> l) { }
+
+  MyList<@B("m") ?> returnWcExtends() { return null; }
+  MyList<@B(value="m") ?> returnWcSuper() { return null; }
+  MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; }
+}
+
+class MyList<K> { }
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface A { }
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+ at interface B { String value(); }
diff --git a/test/tools/javac/annotations/typeAnnotations/packageanno/PackageProcessor.java b/test/tools/javac/annotations/typeAnnotations/packageanno/PackageProcessor.java
new file mode 100644
index 0000000..6d4c3b6
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/packageanno/PackageProcessor.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import javax.lang.model.util.ElementFilter;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+
+import static com.sun.tools.javac.comp.CompileStates.CompileState;
+
+/*
+ * @test
+ * @summary test that package annotations are available to type processors.
+ * This class implements the functionality of a type processor, as previously
+ * embodied by the AbstractTypeProcessor class.
+ *
+ * @author Mahmood Ali
+ * @author Werner Dietl
+ *
+ * @compile PackageProcessor.java
+ * @compile -cp . -processor PackageProcessor mypackage/Anno.java mypackage/MyClass.java mypackage/package-info.java
+ */
+
+ at SupportedAnnotationTypes("*")
+public class PackageProcessor extends AbstractProcessor {
+
+    private final AttributionTaskListener listener = new AttributionTaskListener();
+    private final Set<Name> elements = new HashSet<Name>();
+
+    @Override
+    public final void init(ProcessingEnvironment env) {
+        super.init(env);
+        JavacTask.instance(env).addTaskListener(listener);
+        Context ctx = ((JavacProcessingEnvironment)processingEnv).getContext();
+        JavaCompiler compiler = JavaCompiler.instance(ctx);
+        compiler.shouldStopPolicyIfNoError = CompileState.max(compiler.shouldStopPolicyIfNoError,
+                CompileState.FLOW);
+    }
+
+    @Override
+    public final boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) {
+            elements.add(elem.getQualifiedName());
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    private final class AttributionTaskListener implements TaskListener {
+        @Override
+        public void started(TaskEvent e) { }
+
+        @Override
+        public void finished(TaskEvent e) {
+            if (e.getKind() != TaskEvent.Kind.ANALYZE)
+                return;
+
+            if (!elements.remove(e.getTypeElement().getQualifiedName()))
+                return;
+
+            if (e.getTypeElement().getSimpleName().contentEquals("MyClass")) {
+                Element owner = e.getTypeElement().getEnclosingElement();
+                if (owner.getKind() != ElementKind.PACKAGE)
+                    throw new RuntimeException("class owner should be a package: " + owner);
+                if (owner.getAnnotationMirrors().size() != 1)
+                    throw new RuntimeException("the owner package should have one annotation: " + owner);
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/Anno.java b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/Anno.java
new file mode 100644
index 0000000..901cb6c
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/Anno.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2009, 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 mypackage;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Retention;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Anno {}
diff --git a/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/MyClass.java b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/MyClass.java
new file mode 100644
index 0000000..98f9e43
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/MyClass.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2009, 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 mypackage;
+
+public class MyClass {}
diff --git a/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/package-info.java b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/package-info.java
new file mode 100644
index 0000000..bcd7fb6
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/packageanno/mypackage/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2009, 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.
+ */
+
+ at mypackage.Anno
+package mypackage;
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassExtends.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassExtends.java
new file mode 100644
index 0000000..4d5f2db
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassExtends.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for class extends clauses
+ * @compile -g Driver.java ReferenceInfoUtil.java ClassExtends.java
+ * @run main Driver ClassExtends
+ */
+public class ClassExtends {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
+        @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
+    })
+    public String regularClass() {
+        return "class Test extends @TA Object implements Cloneable, @TB Runnable {"
+               + "  public void run() { } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
+                genericLocation  = { 3, 1 })
+    })
+    public String regularClassExtendsParametrized() {
+        return "class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1),
+        @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
+    })
+    public String abstractClass() {
+        return "abstract class Test extends @TA Date implements Cloneable, @TB Runnable {"
+               + "  public void run() { } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_EXTENDS, typeIndex = -1,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
+                genericLocation  = { 3, 1 })
+    })
+    public String abstractClassExtendsParametrized() {
+        return "abstract class Test extends HashMap<@TA String, String> implements Cloneable, Map<String, @TB String>{ } ";
+    }
+
+    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
+    public String regularInterface() {
+        return "interface Test extends Cloneable, @TB Runnable { }";
+    }
+
+    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
+            genericLocation  = { 3, 1 })
+    public String regularInterfaceExtendsParametrized() {
+        return "interface Test extends Cloneable, Map<String, @TB String>{ } ";
+    }
+
+    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1)
+    public String regularEnum() {
+        return "enum Test implements Cloneable, @TB Runnable { TEST; public void run() { } }";
+    }
+
+    @TADescription(annotation = "TB", type = CLASS_EXTENDS, typeIndex = 1,
+            genericLocation  = { 3, 0 })
+    public String regularEnumExtendsParametrized() {
+        return
+            "enum Test implements Cloneable, Comparator<@TB String> { TEST;  "
+            + "public int compare(String a, String b) { return 0; }}";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassTypeParam.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassTypeParam.java
new file mode 100644
index 0000000..2fca808
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ClassTypeParam.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for class type parameters
+ * @compile -g Driver.java ReferenceInfoUtil.java ClassTypeParam.java
+ * @run main Driver ClassTypeParam
+ */
+public class ClassTypeParam {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularClass() {
+        return "class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularClass2() {
+        return "class Test<@TA K extends @TB Date, @TC V extends @TE Cloneable> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
+    })
+    public String regularClassParameterized() {
+        return "class Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
+    })
+    public String regularClassParameterized2() {
+        return "class Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String abstractClass() {
+        return "abstract class Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
+    })
+    public String abstractClassParameterized() {
+        return "abstract class Test<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularInterface() {
+        return "interface Test<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
+    })
+    public String regularInterfaceParameterized() {
+        return "interface Test<K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TG", type = CLASS_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
+    })
+    public String regularInterfaceParameterized2() {
+        return "interface Test<K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> { }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String useInReturn1() {
+        return "class Test<T> { @TA T m() { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {3, 0})
+    public String useInReturn2() {
+        return "class Test<T> { Class<@TA T> m() { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            paramIndex = 0, genericLocation = {3, 0})
+    public String useInParam1() {
+        return "class Test<T> { void m(Class<@TA T> p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            paramIndex = 0, genericLocation = {3, 0})
+    public String useInParam2() {
+        return "class Test { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
new file mode 100644
index 0000000..38e4615
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+/*
+ * @test
+ * @summary Test population of reference info for constructor results
+ * @compile -g Driver.java ReferenceInfoUtil.java Constructors.java
+ * @run main Driver Constructors
+ */
+public class Constructors {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    })
+    public String regularClass() {
+        return "class Test { @TA Test() {}" +
+                           " @TB Test(@TC int b) {} }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    })
+    @TestClass("Test$Inner")
+    public String innerClass() {
+        return "class Test { class Inner {" +
+               " @TA Inner() {}" +
+               " @TB Inner(@TC int b) {}" +
+               " } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RECEIVER),
+        @TADescription(annotation = "TB", type = METHOD_RETURN),
+        @TADescription(annotation = "TC", type = METHOD_RECEIVER),
+        @TADescription(annotation = "TD", type = METHOD_RETURN),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    })
+    @TestClass("Test$Inner")
+    public String innerClass2() {
+        return "class Test { class Inner {" +
+               " @TB Inner(@TA Test Test.this) {}" +
+               " @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) {}" +
+               " } } }";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java
new file mode 100644
index 0000000..feaa4f3
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Driver.java
@@ -0,0 +1,289 @@
+/*
+ * 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.
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.TypeAnnotation;
+import com.sun.tools.classfile.TypeAnnotation.TargetType;
+
+public class Driver {
+
+    private static final PrintStream out = System.out;
+
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0 || args.length > 1)
+            throw new IllegalArgumentException("Usage: java Driver <test-name>");
+        String name = args[0];
+        Class<?> clazz = Class.forName(name);
+        new Driver().runDriver(clazz.newInstance());
+    }
+
+    protected void runDriver(Object object) throws Exception {
+        int passed = 0, failed = 0;
+        Class<?> clazz = object.getClass();
+        out.println("Tests for " + clazz.getName());
+
+        // Find methods
+        for (Method method : clazz.getMethods()) {
+            Map<String, TypeAnnotation.Position> expected = expectedOf(method);
+            if (expected == null)
+                continue;
+            if (method.getReturnType() != String.class)
+                throw new IllegalArgumentException("Test method needs to return a string: " + method);
+            String testClass = testClassOf(method);
+
+            try {
+                String compact = (String)method.invoke(object);
+                String fullFile = wrap(compact);
+                ClassFile cf = compileAndReturn(fullFile, testClass);
+                List<TypeAnnotation> actual = ReferenceInfoUtil.extendedAnnotationsOf(cf);
+                ReferenceInfoUtil.compare(expected, actual, cf);
+                out.println("PASSED:  " + method.getName());
+                ++passed;
+            } catch (Throwable e) {
+                out.println("FAILED:  " + method.getName());
+                out.println("    " + e.toString());
+                ++failed;
+            }
+        }
+
+        out.println();
+        int total = passed + failed;
+        out.println(total + " total tests: " + passed + " PASSED, " + failed + " FAILED");
+
+        out.flush();
+
+        if (failed != 0)
+            throw new RuntimeException(failed + " tests failed");
+    }
+
+    private Map<String, TypeAnnotation.Position> expectedOf(Method m) {
+        TADescription ta = m.getAnnotation(TADescription.class);
+        TADescriptions tas = m.getAnnotation(TADescriptions.class);
+
+        if (ta == null && tas == null)
+            return null;
+
+        Map<String, TypeAnnotation.Position> result =
+            new HashMap<String, TypeAnnotation.Position>();
+
+        if (ta != null)
+            result.putAll(expectedOf(ta));
+
+        if (tas != null) {
+            for (TADescription a : tas.value()) {
+                result.putAll(expectedOf(a));
+            }
+        }
+
+        return result;
+    }
+
+    private Map<String, TypeAnnotation.Position> expectedOf(TADescription d) {
+        String annoName = d.annotation();
+
+        TypeAnnotation.Position p = new TypeAnnotation.Position();
+        p.type = d.type();
+        if (d.offset() != NOT_SET)
+            p.offset = d.offset();
+        if (d.lvarOffset().length != 0)
+            p.lvarOffset = d.lvarOffset();
+        if (d.lvarLength().length != 0)
+            p.lvarLength = d.lvarLength();
+        if (d.lvarIndex().length != 0)
+            p.lvarIndex = d.lvarIndex();
+        if (d.boundIndex() != NOT_SET)
+            p.bound_index = d.boundIndex();
+        if (d.paramIndex() != NOT_SET)
+            p.parameter_index = d.paramIndex();
+        if (d.typeIndex() != NOT_SET)
+            p.type_index = d.typeIndex();
+        if (d.exceptionIndex() != NOT_SET)
+            p.exception_index = d.exceptionIndex();
+        if (d.genericLocation().length != 0) {
+            p.location = TypeAnnotation.Position.getTypePathFromBinary(wrapIntArray(d.genericLocation()));
+        }
+
+        return Collections.singletonMap(annoName, p);
+    }
+
+    private List<Integer> wrapIntArray(int[] ints) {
+        List<Integer> list = new ArrayList<Integer>(ints.length);
+        for (int i : ints)
+            list.add(i);
+        return list;
+    }
+
+    private String testClassOf(Method m) {
+        TestClass tc = m.getAnnotation(TestClass.class);
+        if (tc != null) {
+            return tc.value();
+        } else {
+            return "Test";
+        }
+    }
+
+    private ClassFile compileAndReturn(String fullFile, String testClass) throws Exception {
+        File source = writeTestFile(fullFile);
+        File clazzFile = compileTestFile(source, testClass);
+        return ClassFile.read(clazzFile);
+    }
+
+    protected File writeTestFile(String fullFile) throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println(fullFile);
+        out.close();
+        return f;
+    }
+
+    protected File compileTestFile(File f, String testClass) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path;
+        if (f.getParent() != null) {
+            path = f.getParent();
+        } else {
+            path = "";
+        }
+
+        return new File(path + testClass + ".class");
+    }
+
+    private String wrap(String compact) {
+        StringBuilder sb = new StringBuilder();
+
+        // Automatically import java.util
+        sb.append("\nimport java.util.*;");
+        sb.append("\nimport java.lang.annotation.*;");
+
+        sb.append("\n\n");
+        boolean isSnippet = !(compact.startsWith("class")
+                              || compact.contains(" class"))
+                            && !compact.contains("interface")
+                            && !compact.contains("enum");
+        if (isSnippet)
+            sb.append("class Test {\n");
+
+        sb.append(compact);
+        sb.append("\n");
+
+        if (isSnippet)
+            sb.append("}\n\n");
+
+        if (isSnippet) {
+            // Have a few common nested types for testing
+            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> {} }");
+        }
+
+        // create A ... F annotation declarations
+        sb.append("\n at interface A {}");
+        sb.append("\n at interface B {}");
+        sb.append("\n at interface C {}");
+        sb.append("\n at interface D {}");
+        sb.append("\n at interface E {}");
+        sb.append("\n at interface F {}");
+
+        // create TA ... TF proper type annotations
+        sb.append("\n");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TA {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TB {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TC {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TD {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TE {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TF {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TG {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TH {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TI {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TJ {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TK {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TL {}");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TM {}");
+
+        // create RTA, RTAs, RTB, RTBs for repeating type annotations
+        sb.append("\n");
+        sb.append("\n at Repeatable(RTAs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTA {}");
+        sb.append("\n at Repeatable(RTBs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTB {}");
+
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTAs { RTA[] value(); }");
+        sb.append("\n at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTBs { RTB[] value(); }");
+
+        sb.append("\n at Target(value={ElementType.TYPE,ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.CONSTRUCTOR,ElementType.LOCAL_VARIABLE})");
+        sb.append("\n at interface Decl {}");
+
+        return sb.toString();
+    }
+
+    public static final int NOT_SET = -888;
+
+}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+ at interface TADescription {
+    String annotation();
+
+    TargetType type();
+    int offset() default Driver.NOT_SET;
+    int[] lvarOffset() default { };
+    int[] lvarLength() default { };
+    int[] lvarIndex() default { };
+    int boundIndex() default Driver.NOT_SET;
+    int paramIndex() default Driver.NOT_SET;
+    int typeIndex() default Driver.NOT_SET;
+    int exceptionIndex() default Driver.NOT_SET;
+
+    int[] genericLocation() default {};
+}
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+ at interface TADescriptions {
+    TADescription[] value() default {};
+}
+
+/**
+ * The name of the class that should be analyzed.
+ * Should only need to be provided when analyzing inner classes.
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+ at interface TestClass {
+    String value() default "Test";
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
new file mode 100644
index 0000000..790a514
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ExceptionParameters.java
@@ -0,0 +1,89 @@
+/*
+ * 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
+ * @summary Test population of reference info for exception parameters
+ * @author Werner Dietl
+ * @compile -g Driver.java ReferenceInfoUtil.java ExceptionParameters.java
+ * @run main Driver ExceptionParameters
+ */
+public class ExceptionParameters {
+
+    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
+    public String exception() {
+        return "void exception() { try { new Object(); } catch(@TA Exception e) { } }";
+    }
+
+    @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0)
+    public String finalException() {
+        return "void finalException() { try { new Object(); } catch(final @TA 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 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) { }" +
+            "    }" +
+            "  }" +
+            "}";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Fields.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Fields.java
new file mode 100644
index 0000000..91bc649
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Fields.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for field
+ * @compile -g Driver.java ReferenceInfoUtil.java Fields.java
+ * @run main Driver Fields
+ */
+public class Fields {
+
+    // field types
+    @TADescription(annotation = "TA", type = FIELD)
+    public String fieldAsPrimitive() {
+        return "@TA int test;";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD)
+    public String fieldAsObject() {
+        return "@TA Object test;";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = { 3, 1, 3, 0 })
+    })
+    public String fieldAsParametrized() {
+        return "@TA Map<@TB String, @TC List<@TD String>> test;";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = { 0, 0 }),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = { 0, 0, 0, 0 })
+    })
+    public String fieldAsArray() {
+        return "@TC String @TA [] @TB [] test;";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = { 0, 0 }),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = { 0, 0, 0, 0 })
+    })
+    public String fieldAsArrayOld() {
+        return "@TC String test @TA [] @TB [];";
+    }
+
+    @TADescriptions({})
+    public String fieldWithDeclarationAnnotatin() {
+        return "@Decl String test;";
+    }
+
+    @TADescriptions({})
+    public String fieldWithNoTargetAnno() {
+        return "@A String test;";
+    }
+
+    // Smoke tests
+    @TADescription(annotation = "TA", type = FIELD)
+    public String interfacefieldAsObject() {
+        return "interface Test { @TA String test = null; }";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD)
+    public String abstractfieldAsObject() {
+        return "abstract class Test { @TA String test; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = { 3, 1, 3, 0 })
+    })
+    public String interfacefieldAsParametrized() {
+        return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test = null; }";
+    }
+
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = { 3, 1, 3, 0 })
+    })
+    public String staticFieldAsParametrized() {
+        return "static @TA Map<@TB String, @TC List<@TD String>> test;";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/FromSpecification.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/FromSpecification.java
new file mode 100644
index 0000000..c300639
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/FromSpecification.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ *
+ * 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
+ * @summary Test that the examples from the manual are stored as expected
+ * @compile -g Driver.java ReferenceInfoUtil.java FromSpecification.java
+ * @run main Driver FromSpecification
+ */
+public class FromSpecification {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 2, 0}, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 1, 3, 0}, paramIndex = 0)
+    })
+    public String testSpec1() {
+        return "void test(@TA Map<@TB ? extends @TC String, @TD List<@TE Object>> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 0, 0}, paramIndex = 0)
+    })
+    public String testSpec2() {
+        return "void test(@TI String @TF [] @TG [] @TH [] a) { }";
+    }
+
+    // Note first "1, 0" for top-level class Test.
+    @TADescriptions({
+        @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TL", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TM", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0}, paramIndex = 0)
+    })
+    public String testSpec3() {
+        return "class Test { class O1 { class O2 { class O3 { class NestedStatic {} } } }" +
+                "void test(@TM O1. at TL O2. at TK O3. at TJ NestedStatic a) { } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 3, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 3, 0, 0, 0, 0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 1, 3, 0}, paramIndex = 0)
+    })
+    public String testSpec4() {
+        return "void test(@TA Map<@TB Comparable<@TF Object @TC [] @TD [] @TE []>, @TG List<@TH String>> a) { }";
+    }
+
+    // Note first "1, 0" for top-level class Test.
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0, 1, 0, 3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0}, paramIndex = 0)
+    })
+    public String testSpec5() {
+        return "class Test { class O1 { class O2<A, B> { class O3 { class Nested<X, Y> {} } } }" +
+                "void test(@TH O1. at TE O2<@TF String, @TG String>. at TD O3. at TA Nested<@TB String, @TC String> a) { } }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java
new file mode 100644
index 0000000..3efd636
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Initializers.java
@@ -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; }";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java
new file mode 100644
index 0000000..b5580a8
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java
@@ -0,0 +1,288 @@
+/*
+ * 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 8008077
+ * @summary Test population of reference info for lambda expressions
+ * @compile -g Driver.java ReferenceInfoUtil.java Lambda.java
+ * @run main Driver Lambda
+ * @author Werner Dietl
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+public class Lambda {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String returnMethodRef1() {
+        return
+                "class Lambda {" +
+                "  public String getName() { return \"Lambda!\"; }" +
+                "}" +
+
+                "class Test {" +
+                "  java.util.function.Function<Lambda, String> lambda() {" +
+                "    return @TA @TB Lambda::getName;" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TD", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TE", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 })
+    })
+    public String returnMethodRef2() {
+        return
+                "class Lambda<S, T> {" +
+                "  public String getName() { return \"Lambda!\"; }" +
+                "}" +
+
+                "class Test {" +
+                "  java.util.function.Function<Lambda<Integer, Float>, String> lambda() {" +
+                "    return @TA Lambda<@TB @TC Integer, @TD @TE Float>::getName;" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "CTA", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "CTB", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "CTC", type = METHOD_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 })
+    })
+    public String returnMethodRef3() {
+        return
+                "class Lambda<S, T> {" +
+                "  public String getName() { return \"Lambda!\"; }" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTA {" +
+                "  String value();" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTB {" +
+                "  int age();" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTC {" +
+                "  String name();" +
+                "}" +
+
+                "class Test {" +
+                "  java.util.function.Function<Lambda<Integer, Float>, String> lambda() {" +
+                "    return @CTA(\"x\") Lambda<@CTB(age = 5) Integer, @CTC(name = \"y\") Float>::getName;" +
+                "  }" +
+                "}";
+    }
+
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String returnConstructorRef1() {
+        return
+                "class Lambda {" +
+                "  Lambda() { }" +
+                "}" +
+
+                "class Test {" +
+                "  Runnable lambda() {" +
+                "    return @TA @TB Lambda::new;" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TD", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TE", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 })
+    })
+    public String returnConstructorRef2() {
+        return
+                "class Lambda<S, T> {" +
+                "  Lambda() { }" +
+                "}" +
+
+                "class Test {" +
+                "  Runnable lambda() {" +
+                "    return @TA Lambda<@TB @TC Integer, @TD @TE Float>::new;" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "CTA", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "CTB", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "CTC", type = CONSTRUCTOR_REFERENCE,
+                offset = ReferenceInfoUtil.IGNORE_VALUE,
+                genericLocation = { 3, 1 })
+    })
+    public String returnConstructorRef3() {
+        return
+                "class Lambda<S, T> {" +
+                "  Lambda() { }" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTA {" +
+                "  String value();" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTB {" +
+                "  int age();" +
+                "}" +
+
+                "@Target(ElementType.TYPE_USE)" +
+                "@interface CTC {" +
+                "  String name();" +
+                "}" +
+
+                "class Test {" +
+                "  Runnable lambda() {" +
+                "    return @CTA(\"x\") Lambda<@CTB(age = 5) Integer, @CTC(name = \"y\") Float>::new;" +
+                "  }" +
+                "}";
+    }
+
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_REFERENCE_TYPE_ARGUMENT,
+                 offset = ReferenceInfoUtil.IGNORE_VALUE,
+                 typeIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_REFERENCE_TYPE_ARGUMENT,
+                 offset = ReferenceInfoUtil.IGNORE_VALUE,
+                 typeIndex = 1)
+    })
+    public String returnMethodRefTA1() {
+        return
+                "interface Lambda {" +
+                "  <S, T> void generic(S p1, T p2);" +
+                "}" +
+
+                "class LambdaImpl implements Lambda {" +
+                "  public <S, T> void generic(S p1, T p2) {}" +
+                "}" +
+
+                "class Test {" +
+                "  Lambda lambda(LambdaImpl r) {" +
+                "    return r::<@TA Object, @TB Object>generic;" +
+                "  }" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
+                 offset = ReferenceInfoUtil.IGNORE_VALUE,
+                 typeIndex = 0),
+        @TADescription(annotation = "TB", type = CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT,
+                 offset = ReferenceInfoUtil.IGNORE_VALUE,
+                 typeIndex = 1)
+    })
+    public String returnConstructorRefTA2() {
+        return
+                "interface Lambda {" +
+                "  <S, T> void generic(S p1, T p2);" +
+                "}" +
+
+                "class LambdaImpl implements Lambda {" +
+                "  <S, T> LambdaImpl(S p1, T p2) {}" +
+                "  public <S, T> void generic(S p1, T p2) {}" +
+                "}" +
+
+                "class Test {" +
+                "  Lambda lambda() {" +
+                "    return LambdaImpl::<@TA Object, @TB Object>new;" +
+                "  }" +
+                "}";
+    }
+
+    @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); };" +
+                "  }" +
+                "}";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodParameters.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodParameters.java
new file mode 100644
index 0000000..eb23838
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodParameters.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for method parameters
+ * @compile -g Driver.java ReferenceInfoUtil.java MethodParameters.java
+ * @run main Driver MethodParameters
+ */
+public class MethodParameters {
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    public String methodParamAsPrimitive() {
+        return "void test(@TA int a) { }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    public String methodParamAsObject() {
+        return "void test(Object b, @TA Object a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1 }, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
+    })
+    public String methodParamAsParametrized() {
+        return "void test(@TA Map<@TB String, @TC List<@TD String>> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 0, 2, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1 }, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0, 2, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0, 2, 0, 3, 0, 2, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0, 2, 0, 3, 1 }, paramIndex = 0),
+        @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0, 2, 0, 3, 1, 2, 0 }, paramIndex = 0)
+    })
+    public String methodParamAsWildcard() {
+        return "void test(@TA Map<@TB ? extends @TC String," +
+                "                 @TD List<@TE ? extends @TF Map<@TG ? super @TH String," +
+                "                                                @TI ? extends @TJ Object>>> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
+    })
+    public String methodParamAsArray() {
+        return "void test(Object b, @TC String @TA [] @TB [] a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1)
+    })
+    public String methodParamAsArray2() {
+        return "void test(Object b, @TA @TB String [] a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1)
+    })
+    public String methodParamAsArray3() {
+        return "void test(Object b, @TA @TB @TC String [] a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
+    })
+    public String methodParamAsVararg() {
+        return "void test(Object b, @TC String @TA [] @TB ... a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0 }, paramIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 0, 0, 0, 0 }, paramIndex = 1)
+    })
+    public String methodParamAsFQVararg() {
+        return "void test(Object b, java.lang. at TC String @TA [] @TB ... a) { }";
+    }
+
+    @TADescriptions({})
+    public String methodWithDeclarationAnnotatin() {
+        return "void test(@Decl String a) { }";
+    }
+
+    @TADescriptions({})
+    public String methodWithNoTargetAnno() {
+        return "void test(@A String a) { }";
+    }
+
+    // Smoke tests
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    public String interfacemethodParamAsObject() {
+        return "interface Test { void test(@TA Object a); }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 2)
+    public String abstractmethodParamAsObject() {
+        return "abstract class Test { abstract void test(Object b, Object c, @TA Object a); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 0 }, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1 }, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = { 3, 1, 3, 0 }, paramIndex = 0)
+    })
+    public String interfacemethodParamAsParametrized() {
+        return "interface Test { void test(@TA Map<@TB String, @TC List<@TD String>> a); }";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReceivers.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReceivers.java
new file mode 100644
index 0000000..dc19f8d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReceivers.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for method receivers
+ * @compile -g Driver.java ReferenceInfoUtil.java MethodReceivers.java
+ * @run main Driver MethodReceivers
+ */
+public class MethodReceivers {
+
+    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
+    public String regularMethod() {
+        return "class Test { void test(@TA Test this) { } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
+    public String abstractMethod() {
+        return "abstract class Test { abstract void test(@TA Test this); }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
+    public String interfaceMethod() {
+        return "interface Test { void test(@TA Test this); }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RECEIVER)
+    public String regularWithThrows() {
+        return "class Test { void test(@TA Test this) throws Exception { } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RECEIVER,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = METHOD_RECEIVER,
+                genericLocation = {1, 0})
+    })
+    @TestClass("TestOuter$TestInner")
+    public String nestedtypes1() {
+        return "class TestOuter { class TestInner { void test(@TA TestOuter. @TB TestInner this) { } } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RECEIVER,
+            genericLocation = {})
+    @TestClass("TestOuter$TestInner")
+    public String nestedtypes2() {
+        return "class TestOuter { class TestInner { void test(@TA TestOuter.TestInner this) { } } }";
+    }
+
+    @TADescription(annotation = "TB", type = METHOD_RECEIVER,
+            genericLocation = {1, 0})
+    @TestClass("TestOuter$TestInner")
+    public String nestedtypes3() {
+        return "class TestOuter { class TestInner { void test(TestOuter. @TB TestInner this) { } } }";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReturns.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReturns.java
new file mode 100644
index 0000000..b694681
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodReturns.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for method return
+ * @compile -g Driver.java ReferenceInfoUtil.java MethodReturns.java
+ * @run main Driver MethodReturns
+ */
+public class MethodReturns {
+
+    // Method returns
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String methodReturnAsPrimitive() {
+        return "@TA int test() { return 0; }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String methodReturnAsObject() {
+        return "@TA Object test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = { 3, 1, 3, 0 })
+    })
+    public String methodReturnAsParametrized() {
+        return "@TA Map<@TB String, @TC List<@TD String>> test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 0, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 0, 0, 0, 0 })
+    })
+    public String methodReturnAsArray() {
+        return "@TC String @TA [] @TB [] test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 0, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 0, 0, 0, 0 })
+    })
+    public String methodReturnAsArrayOld() {
+        return "@TC String test() @TA [] @TB [] { return null; }";
+    }
+
+    @TADescriptions({})
+    public String methodWithDeclarationAnnotation() {
+        return "@Decl String test() { return null; }";
+    }
+
+    @TADescriptions({})
+    public String methodWithNoTargetAnno() {
+        return "@A String test() { return null; }";
+    }
+
+    // Smoke tests
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String interfaceMethodReturnAsObject() {
+        return "interface Test { @TA Object test(); }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String abstractMethodReturnAsObject() {
+        return "abstract class Test { abstract @TA Object test(); }";
+    }
+
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 1 }),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = { 3, 1, 3, 0 })
+    })
+    public String interfaceMethodReturnAsParametrized() {
+        return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = { 3, 0 }),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0 }),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
+        @TADescription(annotation = "TE", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
+        @TADescription(annotation = "TF", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1, 2, 0 })
+    })
+    public String methodReturnAsNestedWildcard() {
+        return "Set<@TA ? extends @TB GOuter<String, String>. @TC GInner<@TD String, @TE ? super @TF Object>> entrySet() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 1, 0, 3, 0 }),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 1, 0, 3, 1 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 1, 0, 3, 1, 2, 0 })
+    })
+    public String methodReturnAsNestedWildcard2() {
+        return "class GOuter<X, Y> { class GInner<X, Y> {} } " +
+                "class Test<K> { Set<GOuter<String, String>.GInner<@TA K, @TB ? extends @TC Object>> entrySet() { return null; } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0 }),
+    })
+    public String methodReturnAsNestedWildcard3() {
+        return "Set<? extends @TB GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0 }),
+    })
+    public String methodReturnAsNestedWildcard4() {
+        return "Set<? extends GOuter<String, String>. @TC GInner<String, Object>> entrySet() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0 }),
+    })
+    public String methodReturnAsNestedWildcard5() {
+        return "Set<? extends @TB Outer. @TC Inner> entrySet() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0, 3, 0 }),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0, 3, 1 }),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = { 3, 0, 2, 0, 1, 0 }),
+    })
+    public String methodReturnAsNestedWildcard6() {
+        return "Set<? extends GOuter<String, String>. @TC GInner<@TA String, @TB Object>> entrySet() { return null; }";
+    }
+
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java
new file mode 100644
index 0000000..2b73c6e
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodThrows.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+/*
+ * @test
+ * @summary Test population of reference info for method exception clauses
+ * @compile -g Driver.java ReferenceInfoUtil.java MethodThrows.java
+ * @run main Driver MethodThrows
+ */
+public class MethodThrows {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
+        @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
+    })
+    public String regularMethod() {
+        return "class Test { void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception { } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
+        @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
+    })
+    public String abstractMethod() {
+        return "abstract class Test { abstract void test() throws @TA RuntimeException, IllegalArgumentException, @TB Exception; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = THROWS, typeIndex = 0),
+        @TADescription(annotation = "TB", type = THROWS, typeIndex = 2)
+    })
+    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. at TB Middle. at TC Inner1, @TD Outer. at TE Middle. at TF Inner2 { } }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodTypeParam.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodTypeParam.java
new file mode 100644
index 0000000..5798eaa
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MethodTypeParam.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for method type parameters
+ * @compile -g Driver.java ReferenceInfoUtil.java MethodTypeParam.java
+ * @run main Driver MethodTypeParam
+ */
+public class MethodTypeParam {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularClass() {
+        return "<@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test() { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularClass2() {
+        return "<@TA K extends @TB Date, @TC V extends @TE Cloneable> void test() { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0)
+    })
+    public String regularClassParameterized() {
+        return "<K extends @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> void test() { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String abstractClass() {
+        return "abstract class Test { abstract <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0)
+    })
+    public String abstractClassParameterized() {
+        return "abstract class Test { abstract <K extends @TG Object & @TA Map<String, @TB String>, V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0})
+    })
+    public String abstractClassParameterized2() {
+        return "abstract class Test { abstract <K extends @TA Map<String, @TB String>, V extends @TC List<@TD List<@TE Object>>> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String abstractClassParameterized3() {
+        return "abstract class Test { abstract <K extends @TA List<String>, V extends @TB List<Object>> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER, paramIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1)
+    })
+    public String regularInterface() {
+        return "interface Test { <@TA K extends @TB Date, @TC V extends @TD Object & @TE Cloneable> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
+    })
+    public String regularInterfaceParameterized() {
+        return "interface Test { <@TH K extends @TG Object & @TA Map<String, @TB String>, @TI V extends @TF Object & @TC List<@TD List<@TE Object>>> void test(); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1, genericLocation = {3, 1}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 1, boundIndex = 1, genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER, paramIndex = 1)
+    })
+    public String regularInterfaceParameterized2() {
+        return "interface Test { <@TF K extends @TA Map<String, @TB String>, @TG V extends @TC List<@TD List<@TE Object>>> void test(); }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN)
+    public String useInReturn1() {
+        return "class Test { <T> @TA T m() { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {3, 0})
+    public String useInReturn2() {
+        return "class Test { <T> Class<@TA T> m() { throw new RuntimeException(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_RETURN)
+    })
+    public String useInReturn3() {
+        return "class Test { <T extends @TA Object> @TB T m() { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            paramIndex = 0, genericLocation = {3, 0})
+    public String useInParam1() {
+        return "class Test { <T> void m(Class<@TA T> p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            paramIndex = 0, genericLocation = {3, 0})
+    public String useInParam2() {
+        return "class Test { void m(Class<@TA Object> p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND, paramIndex = 0, boundIndex = 2),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
+    })
+    public String useInParam3() {
+        return "interface IA {} " +
+               "interface IB<XB> {} " +
+               "interface IC<XC> {} " +
+               "class Test { <T extends @TA IB<IA> & @TB IC<IA>> void m(@TC T p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 1,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 2,
+                genericLocation = {}),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0)
+    })
+    public String useInParam4() {
+        return "class Test {" +
+               "  interface IA {} " +
+               "  interface IB<XB> {} " +
+               "  interface IC<XC> {} " +
+               "  <T extends @TA IB<IA> & @TB IC<IA>> void m(@TC T p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 0,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 0,
+                genericLocation = {1, 0}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 0,
+                genericLocation = {1, 0, 3, 0}),
+    })
+    public String useInParam5() {
+        return "class Test {" +
+               "  interface IA {} " +
+               "  class CB<XC> {} " +
+               "  <T extends @TA Test. @TB CB<@TC IA>> void m(T p) { throw new RuntimeException(); } }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER,
+                paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 0,
+                genericLocation = {}),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 0,
+                genericLocation = {1, 0, 3, 0}),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 1,
+                genericLocation = {}),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
+                paramIndex = 0, boundIndex = 1,
+                genericLocation = {3, 0})
+    })
+    public String useInParam6() {
+        return "class Test {" +
+               "  interface IA {} " +
+               "  interface IB<XB> {} " +
+               "  class CC<XC> {} " +
+               "  interface ID<XD> {} " +
+               "  <@TA T extends @TB Test.CC<@TC IA> & Test. @TD ID<@TE IA>> void m(T p) { throw new RuntimeException(); } }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
new file mode 100644
index 0000000..7c16a0d
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/MultiCatch.java
@@ -0,0 +1,67 @@
+/*
+ * 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 8006732 8006775
+ * @summary Test population of reference info for multicatch exception parameters
+ * @author Werner Dietl
+ * @compile -g Driver.java ReferenceInfoUtil.java MultiCatch.java
+ * @run main Driver MultiCatch
+ */
+public class MultiCatch {
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = EXCEPTION_PARAMETER, exceptionIndex = 0),
+        @TADescription(annotation = "TB", type = EXCEPTION_PARAMETER, exceptionIndex = 1)
+    })
+    public String multiCatch1() {
+        return "void multiCatch1() { " +
+            "try { new Object(); } catch (@TA NullPointerException | @TB IndexOutOfBoundsException e) { e.toString(); } }";
+    }
+
+    @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 multiCatch2() {
+        return "void multiCatch2() { " +
+            "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(); } }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java
new file mode 100644
index 0000000..3bd39e5
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java
@@ -0,0 +1,878 @@
+/*
+ * 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.
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+/*
+ * @test
+ * @summary Test population of reference info for nested types
+ * @compile -g Driver.java ReferenceInfoUtil.java NestedTypes.java
+ * @run main Driver NestedTypes
+ */
+public class NestedTypes {
+
+    // method parameters
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0}, paramIndex = 0)
+    })
+    public String testParam1() {
+        return "void test(@TA Outer. at TB Inner a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 1, 0}, paramIndex = 0)
+    })
+    public String testParam1b() {
+        return "void test(List<@TA Outer. at TB Inner> a) { }";
+    }
+
+    // TODO: the tests that use @TA Map.Entry should fail, as
+    // Map cannot be annotated.
+    // We need some tests for the fully qualified name syntax.
+    /*
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            genericLocation = {}, paramIndex = 0)
+    public String testParam1c() {
+        return "void test(java.util. at TA Map.Entry a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0}, paramIndex = 0)
+    })
+    public String testParam1d() {
+        return "void test(java.util. at TA Map. at TB Entry a) { }";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+            genericLocation = {3, 0}, paramIndex = 0)
+    public String testParam1e() {
+        return "void test(List<java.util. at TA Map.Entry> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 1, 0}, paramIndex = 0)
+    })
+    public String testParam1f() {
+        return "void test(List<java.util. at TA Map. @TB Entry> a) { }";
+    }
+    */
+
+    @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+           genericLocation = {3, 0}, paramIndex = 0)
+    public String testParam1g() {
+        return "void test(List<java.util.Map. @TB Entry> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {1, 0}, paramIndex = 0)
+    })
+    public String testParam2() {
+        return "void test(@TA GOuter<String,String>. at TB GInner<String,String> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 1, 0}, paramIndex = 0)
+    })
+    public String testParam2b() {
+        return "void test(List<@TA GOuter<String,String>. at TB GInner<String,String>> a) { }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER, paramIndex = 0),
+        @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {0, 0}, paramIndex = 0)
+    })
+    public String testParam3() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " void test(@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a) { }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}, paramIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}, paramIndex = 0),
+        @TADescription(annotation = "TJ", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0}, paramIndex = 0),
+        @TADescription(annotation = "TK", type = METHOD_FORMAL_PARAMETER,
+                genericLocation = {3, 0, 0, 0}, paramIndex = 0)
+    })
+    public String testParam4() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " void test(List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a) { }\n" +
+                "}";
+    }
+
+
+    // Local variables
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+                genericLocation = {},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+                genericLocation = {1, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
+    })
+    public String testLocal1a() {
+        return "void test() { @TA Outer. at TB Inner a = null; }";
+    }
+
+    @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+            genericLocation = {},
+            lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
+    public String testLocal1b() {
+        return "void test() { @TA Outer.Inner a = null; }";
+    }
+
+    @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+            genericLocation = {1, 0},
+            lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
+    public String testLocal1c() {
+        return "void test() { Outer. at TB Inner a = null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+                genericLocation = {},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+                genericLocation = {1, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
+    })
+    public String testLocal2() {
+        return "void test() { @TA GOuter<String,String>. at TB GInner<String,String> a = null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TD", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TE", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TF", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TG", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TH", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TI", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TJ", type = LOCAL_VARIABLE,
+                genericLocation = {},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TK", type = LOCAL_VARIABLE,
+                genericLocation = {0, 0},
+                lvarOffset = {5}, lvarLength = {1}, lvarIndex = {1})
+    })
+    public String testLocal3() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " void test() { @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a = null; }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TD", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TE", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TF", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TG", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TH", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TI", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TJ", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1}),
+        @TADescription(annotation = "TK", type = LOCAL_VARIABLE,
+                genericLocation = {3, 0, 0, 0},
+                lvarOffset = {2}, lvarLength = {1}, lvarIndex = {1})
+    })
+    public String testLocal4() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " void test() { List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a = null; }\n" +
+                "}";
+    }
+
+
+    // fields
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = {1, 0})
+    })
+    public String testField1a() {
+        return "@TA Outer. at TB Inner a;";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {})
+    public String testField1b() {
+        return "@TA Outer.Inner a;";
+    }
+
+    @TADescription(annotation = "TB", type = FIELD,
+            genericLocation = {1, 0})
+    public String testField1c() {
+        return "Outer. at TB Inner a;";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = {1, 0})
+    })
+    public String testField2() {
+        return "@TA GOuter<String,String>. at TB GInner<String,String> a;";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TE", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
+        @TADescription(annotation = "TG", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TH", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TI", type = FIELD,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
+        @TADescription(annotation = "TJ", type = FIELD),
+        @TADescription(annotation = "TK", type = FIELD,
+                genericLocation = {0, 0})
+    })
+    public String testField3() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] a;\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TD", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TE", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
+        @TADescription(annotation = "TG", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TH", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TI", type = FIELD,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
+        @TADescription(annotation = "TJ", type = FIELD,
+                genericLocation = {3, 0}),
+        @TADescription(annotation = "TK", type = FIELD,
+                genericLocation = {3, 0, 0, 0})
+    })
+    public String testField4() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> a;\n" +
+                "}";
+    }
+
+
+    // return types
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = {1, 0})
+    })
+    public String testReturn1() {
+        return "@TA Outer. at TB Inner test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = {1, 0})
+    })
+    public String testReturn2() {
+        return "@TA GOuter<String,String>. at TB GInner<String,String> test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TE", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
+        @TADescription(annotation = "TG", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TH", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TI", type = METHOD_RETURN,
+                genericLocation = {0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
+        @TADescription(annotation = "TJ", type = METHOD_RETURN),
+        @TADescription(annotation = "TK", type = METHOD_RETURN,
+                genericLocation = {0, 0})
+    })
+    public String testReturn3() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[] test() { return null; }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0}),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TE", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0}),
+        @TADescription(annotation = "TF", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
+        @TADescription(annotation = "TG", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0}),
+        @TADescription(annotation = "TH", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TI", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1}),
+        @TADescription(annotation = "TJ", type = METHOD_RETURN,
+                genericLocation = {3, 0}),
+        @TADescription(annotation = "TK", type = METHOD_RETURN,
+                genericLocation = {3, 0, 0, 0})
+    })
+    public String testReturn4() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]> test() { return null; }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_RETURN,
+                genericLocation = {3, 0}),
+        @TADescription(annotation = "TB", type = METHOD_RETURN,
+                genericLocation = {3, 0, 3, 0}),
+        @TADescription(annotation = "TC", type = METHOD_RETURN,
+                genericLocation = {3, 0, 3, 1}),
+        @TADescription(annotation = "TD", type = METHOD_RETURN,
+                genericLocation = {3, 0, 3, 1, 3, 0}),
+        @TADescription(annotation = "TE", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0}),
+        @TADescription(annotation = "TF", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0, 3, 0}),
+        @TADescription(annotation = "TG", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}),
+        @TADescription(annotation = "TH", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0}),
+        @TADescription(annotation = "TI", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0}),
+        @TADescription(annotation = "TJ", type = METHOD_RETURN,
+                genericLocation = {3, 0, 1, 0, 1, 0}),
+    })
+    public String testReturn5() {
+        return "class GOuter<A, B> {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " List<@TA GOuter<@TB String, @TC List<@TD Object>> . @TE GInner<@TF List<@TG Object @TH[] @TI[]>>. @TJ GInner2<String, String>> test() { return null; }\n" +
+                "}";
+    }
+
+
+    // type parameters
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {}, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0}, paramIndex = 0, boundIndex = 0)
+    })
+    public String testTypeparam1() {
+        return "<X extends @TA Outer. at TB Inner> X test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {}, paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0}, paramIndex = 0, boundIndex = 0)
+    })
+    public String testTypeparam2() {
+        return "<X extends @TA GOuter<String,String>. at TB GInner<String,String>> X test() { return null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 3, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 3, 0, 3, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 3, 0, 3, 0, 0, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 1, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 1, 0, 3, 0},
+                paramIndex = 0, boundIndex = 0),
+        @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {1, 0, 1, 0, 3, 1},
+                paramIndex = 0, boundIndex = 0),
+    })
+    public String testTypeparam3() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " <X extends @TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object>> X test() { return null; }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 3, 0, 3, 0, 0, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0, 0, 0, 1, 0, 1, 0, 3, 1},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TJ", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0},
+                paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TK", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 0, 0},
+                paramIndex = 0, boundIndex = 1)
+    })
+    public String testTypeparam4() {
+        return "class Outer {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " <X extends List<@TA Outer . @TB GInner<@TC List<@TD Object @TE[] @TF[]>>. @TG GInner2<@TH Integer, @TI Object> @TJ[] @TK[]>> X test() { return null; }\n" +
+                "}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TB", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TC", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 3, 1}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TD", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 3, 1, 3, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TE", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TF", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TG", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0, 0, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TH", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TI", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0, 3, 0, 3, 0, 0, 0}, paramIndex = 0, boundIndex = 1),
+        @TADescription(annotation = "TJ", type = METHOD_TYPE_PARAMETER_BOUND,
+                genericLocation = {3, 0, 1, 0, 1, 0}, paramIndex = 0, boundIndex = 1),
+    })
+    public String testTypeparam5() {
+        return "class GOuter<A, B> {\n" +
+                " class GInner<X> {\n" +
+                "  class GInner2<Y, Z> {}\n" +
+                "}}\n\n" +
+                "class Test {\n" +
+                " <X extends List<@TA GOuter<@TB String, @TC List<@TD Object>> . @TE GInner<@TF List<@TG Object @TH[] @TI[]>>. @TJ GInner2<String, String>>> X test() { return null; }\n" +
+                "}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0})
+    public String testUses1a() {
+        return "class Test { class Inner {}    List<@TA Inner> f; }";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0})
+    public String testUses1b() {
+        return "class Test { class Inner {}    List<@TA Test.Inner> f; }";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses2a() {
+        return "class Test { class Inner { class Inner2{}    List<@TA Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses2b() {
+        return "class Test { class Inner { class Inner2{}    List<@TA Inner.Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses2c() {
+        return "class Test { class Inner { class Inner2{}    List<Inner. at TA Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0})
+    @TestClass("Test$Inner")
+    public String testUses2d() {
+        return "class Test{ class Inner { class Inner2{}    List<@TA Test.Inner.Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses2e() {
+        return "class Test { class Inner { class Inner2{}    List<Test. at TA Inner.Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses2f() {
+        return "class Test { class Inner { class Inner2{}    List<Test.Inner. at TA Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses3a() {
+        return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
+                "    List<Test.Inner. at TA Inner2> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0})
+    @TestClass("Test$Inner")
+    public String testUses3b() {
+        return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
+                "    List<Test. at TA Inner.Inner2> f; }}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = FIELD,
+                genericLocation = {}),
+        @TADescription(annotation = "TB", type = FIELD,
+                genericLocation = {3, 0})
+    })
+    public String testUses4() {
+        return "class Test { static class TInner {}\n" +
+                "    @TA TInner f; \n" +
+                "    List<@TB TInner> g; }";
+    }
+
+    @TADescription(annotation = "TA", type = FIELD,
+            genericLocation = {3, 0, 1, 0, 3, 1})
+    @TestClass("Test$Inner")
+    public String testUses3c() {
+        return "class Test { class Inner<A, B> { class Inner2<C, D>{}\n" +
+                "    List<Test.Inner<String, @TA Object>.Inner2<Test, Test>> f; }}";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex=0)
+    public String testFullyQualified1() {
+        return "void testme(java.security. at TA ProtectionDomain protectionDomain) {}";
+    }
+
+    @TADescription(annotation = "TA", type = METHOD_FORMAL_PARAMETER, paramIndex=0,
+            genericLocation = {3, 0})
+    public String testFullyQualified2() {
+        return "void testme(List<java.security. at TA ProtectionDomain> protectionDomain) {}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = LOCAL_VARIABLE,
+                genericLocation = {},
+                lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = LOCAL_VARIABLE,
+                genericLocation = {1, 0},
+                lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = LOCAL_VARIABLE,
+                // Only classes count, not methods.
+                genericLocation = {1, 0, 1, 0},
+                lvarOffset = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarLength = ReferenceInfoUtil.IGNORE_VALUE,
+                lvarIndex = ReferenceInfoUtil.IGNORE_VALUE),
+    })
+    @TestClass("Outer$Inner")
+    public String testMethodNesting1() {
+        return "class Outer {\n" +
+                " class Inner {\n" +
+                "  void foo() {\n" +
+                "    class MInner {}\n" +
+                "    @TA Outer . @TB Inner l1 = null;\n" +
+                "    @TC MInner l2 = null;\n" +
+                "  }\n" +
+                "}}\n";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = NEW,
+                genericLocation = {},
+                offset = 0),
+        @TADescription(annotation = "TB", type = NEW,
+                genericLocation = {1, 0},
+                offset = 0),
+        @TADescription(annotation = "TC", type = NEW,
+                // Only classes count, not methods.
+                genericLocation = {1, 0, 1, 0},
+                offset = 12),
+    })
+    @TestClass("Outer$Inner")
+    public String testMethodNesting2() {
+        return "class Outer {\n" +
+                " class Inner {\n" +
+                "  void foo() {\n" +
+                "    class MInner {}\n" +
+                "    Object o1 = new @TA Outer . @TB Inner();" +
+                "    Object o2 = new @TC MInner();\n" +
+                "  }\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>. at 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" +
+                "  }" +
+                "}";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java
new file mode 100644
index 0000000..30913b1
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/NewObjects.java
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
+
+/*
+ * @test
+ * @summary Test population of reference info for new object creations
+ * @compile -g Driver.java ReferenceInfoUtil.java NewObjects.java
+ * @run main Driver NewObjects
+ */
+public class NewObjects {
+
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String returnObject() {
+        return "Object returnObject() { return new @TA 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 returnObjectGeneric() {
+        return "Object returnObjectGeneric() { return new @TA ArrayList<@TB String>(); }";
+    }
+
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String initObject() {
+        return "void initObject() { Object a =  new @TA 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,
+                genericLocation = { 3, 1 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String initObjectGeneric() {
+        return "void initObjectGeneric() { Object a = new @TA HashMap<@TB String, @TC String>(); }";
+    }
+
+    @TADescription(annotation = "TA", type = NEW, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String eqtestObject() {
+        return "void eqtestObject() { if (null == new @TA 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 eqtestObjectGeneric() {
+        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;";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java
new file mode 100644
index 0000000..0577c8b
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/ReferenceInfoUtil.java
@@ -0,0 +1,347 @@
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+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;
+import com.sun.tools.classfile.RuntimeTypeAnnotations_attribute;
+import com.sun.tools.classfile.ConstantPool.InvalidIndex;
+import com.sun.tools.classfile.ConstantPool.UnexpectedEntry;
+
+public class ReferenceInfoUtil {
+
+    public static final int IGNORE_VALUE = -321;
+
+    public static List<TypeAnnotation> extendedAnnotationsOf(ClassFile cf) {
+        List<TypeAnnotation> annos = new ArrayList<TypeAnnotation>();
+        findAnnotations(cf, annos);
+        return annos;
+    }
+
+    /////////////////// Extract type annotations //////////////////
+    private static void findAnnotations(ClassFile cf, List<TypeAnnotation> annos) {
+        findAnnotations(cf, Attribute.RuntimeVisibleTypeAnnotations, annos);
+        findAnnotations(cf, Attribute.RuntimeInvisibleTypeAnnotations, annos);
+
+        for (Field f : cf.fields) {
+            findAnnotations(cf, f, annos);
+        }
+        for (Method m: cf.methods) {
+            findAnnotations(cf, m, annos);
+        }
+    }
+
+    private static void findAnnotations(ClassFile cf, Method m, List<TypeAnnotation> annos) {
+        findAnnotations(cf, m, Attribute.RuntimeVisibleTypeAnnotations, annos);
+        findAnnotations(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, annos);
+    }
+
+    private static void findAnnotations(ClassFile cf, Field m, List<TypeAnnotation> annos) {
+        findAnnotations(cf, m, Attribute.RuntimeVisibleTypeAnnotations, annos);
+        findAnnotations(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, annos);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    private static void findAnnotations(ClassFile cf, String name, List<TypeAnnotation> annos) {
+        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;
+            annos.addAll(Arrays.asList(tAttr.annotations));
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    private static void findAnnotations(ClassFile cf, Method m, String name, List<TypeAnnotation> annos) {
+        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;
+            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
+    // encoded in the method's name
+    private static void findAnnotations(ClassFile cf, Field m, String name, List<TypeAnnotation> annos) {
+        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;
+            annos.addAll(Arrays.asList(tAttr.annotations));
+        }
+    }
+
+    /////////////////// TA Position Builder ///////////////////////
+    /* TODO: comment out this dead code. Was this unfinished code that was
+     * supposed to be used somewhere? The tests pass without this.
+    private static class TAPositionBuilder {
+        private TypeAnnotation.Position pos = new TypeAnnotation.Position();
+
+        private TAPositionBuilder() { }
+
+        public TypeAnnotation.Position build() { return pos; }
+
+        public static TAPositionBuilder ofType(TypeAnnotation.TargetType type) {
+            TAPositionBuilder builder = new TAPositionBuilder();
+            builder.pos.type = type;
+            return builder;
+        }
+
+        public TAPositionBuilder atOffset(int offset) {
+            switch (pos.type) {
+            // type cast
+            case TYPECAST:
+            // instanceof
+            case INSTANCEOF:
+            // new expression
+            case NEW:
+                pos.offset = offset;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atLocalPosition(int offset, int length, int index) {
+            switch (pos.type) {
+            // local variable
+            case LOCAL_VARIABLE:
+                pos.lvarOffset = new int[] { offset };
+                pos.lvarLength = new int[] { length };
+                pos.lvarIndex  = new int[] { index  };
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atParameterIndex(int index) {
+            switch (pos.type) {
+            // type parameters
+            case CLASS_TYPE_PARAMETER:
+            case METHOD_TYPE_PARAMETER:
+            // method parameter
+            case METHOD_FORMAL_PARAMETER:
+                pos.parameter_index = index;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atParamBound(int param, int bound) {
+            switch (pos.type) {
+            // type parameters bounds
+            case CLASS_TYPE_PARAMETER_BOUND:
+            case METHOD_TYPE_PARAMETER_BOUND:
+                pos.parameter_index = param;
+                pos.bound_index = bound;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atWildcardPosition(TypeAnnotation.Position pos) {
+            switch (pos.type) {
+            // wildcards
+            case WILDCARD_BOUND:
+                pos.wildcard_position = pos;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atTypeIndex(int index) {
+            switch (pos.type) {
+            // class extends or implements clauses
+            case CLASS_EXTENDS:
+            // throws
+            case THROWS:
+                pos.type_index = index;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atOffsetWithIndex(int offset, int index) {
+            switch (pos.type) {
+            // method type argument: wasn't specified
+            case NEW_TYPE_ARGUMENT:
+            case METHOD_TYPE_ARGUMENT:
+                pos.offset = offset;
+                pos.type_index = index;
+                break;
+            default:
+                throw new IllegalArgumentException("invalid field for given type: " + pos.type);
+            }
+            return this;
+        }
+
+        public TAPositionBuilder atGenericLocation(Integer ...loc) {
+            pos.location = Arrays.asList(loc);
+            pos.type = pos.type.getGenericComplement();
+            return this;
+        }
+    }*/
+
+    /////////////////////// Equality testing /////////////////////
+    private static boolean areEquals(int a, int b) {
+        return a == b || a == IGNORE_VALUE || b == IGNORE_VALUE;
+    }
+
+    private static boolean areEquals(int[] a, int[] a2) {
+        if (a==a2)
+            return true;
+        if (a==null || a2==null)
+            return false;
+
+        int length = a.length;
+        if (a2.length != length)
+            return false;
+
+        for (int i=0; i<length; i++)
+            if (a[i] != a2[i] && a[i] != IGNORE_VALUE && a2[i] != IGNORE_VALUE)
+                return false;
+
+        return true;
+    }
+
+    public static boolean areEquals(TypeAnnotation.Position p1, TypeAnnotation.Position p2) {
+        if (p1 == p2)
+            return true;
+        if (p1 == null || p2 == null)
+            return false;
+
+        return ((p1.type == p2.type)
+                && (p1.location.equals(p2.location))
+                && areEquals(p1.offset, p2.offset)
+                && areEquals(p1.lvarOffset, p2.lvarOffset)
+                && areEquals(p1.lvarLength, p2.lvarLength)
+                && areEquals(p1.lvarIndex, p2.lvarIndex)
+                && areEquals(p1.bound_index, p2.bound_index)
+                && areEquals(p1.parameter_index, p2.parameter_index)
+                && areEquals(p1.type_index, p2.type_index)
+                && areEquals(p1.exception_index, p2.exception_index));
+    }
+
+    private static TypeAnnotation findAnnotation(String name, List<TypeAnnotation> annotations, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
+        String properName = "L" + name + ";";
+        for (TypeAnnotation anno : annotations) {
+            String actualName = cf.constant_pool.getUTF8Value(anno.annotation.type_index);
+            if (properName.equals(actualName))
+                return anno;
+        }
+        return null;
+    }
+
+    public static boolean compare(Map<String, TypeAnnotation.Position> expectedAnnos,
+            List<TypeAnnotation> actualAnnos, ClassFile cf) throws InvalidIndex, UnexpectedEntry {
+        if (actualAnnos.size() != expectedAnnos.size()) {
+            throw new ComparisionException("Wrong number of annotations",
+                    expectedAnnos,
+                    actualAnnos);
+        }
+
+        for (Map.Entry<String, TypeAnnotation.Position> e : expectedAnnos.entrySet()) {
+            String aName = e.getKey();
+            TypeAnnotation.Position expected = e.getValue();
+            TypeAnnotation actual = findAnnotation(aName, actualAnnos, cf);
+            if (actual == null)
+                throw new ComparisionException("Expected annotation not found: " + aName);
+
+            // TODO: you currently get an exception if the test case does not use all necessary
+            // annotation attributes, e.g. forgetting the offset for a local variable.
+            // It would be nicer to give an understandable warning instead.
+            if (!areEquals(expected, actual.position)) {
+                throw new ComparisionException("Unexpected position for annotation : " + aName +
+                        "\n  Expected: " + expected.toString() +
+                        "\n  Found: " + actual.position.toString());
+            }
+        }
+        return true;
+    }
+}
+
+class ComparisionException extends RuntimeException {
+    private static final long serialVersionUID = -3930499712333815821L;
+
+    public final Map<String, TypeAnnotation.Position> expected;
+    public final List<TypeAnnotation> found;
+
+    public ComparisionException(String message) {
+        this(message, null, null);
+    }
+
+    public ComparisionException(String message, Map<String, TypeAnnotation.Position> expected, List<TypeAnnotation> found) {
+        super(message);
+        this.expected = expected;
+        this.found = found;
+    }
+
+    public String toString() {
+        String str = super.toString();
+        if (expected != null && found != null) {
+            str += "\n\tExpected: " + expected.size() + " annotations; but found: " + found.size() + " annotations\n" +
+                   "  Expected: " + expected +
+                   "\n  Found: " + found;
+        }
+        return str;
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/RepeatingTypeAnnotations.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/RepeatingTypeAnnotations.java
new file mode 100644
index 0000000..22982ae
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/RepeatingTypeAnnotations.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ *
+ * 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
+ * @summary Test population of reference info for repeating type annotations
+ * @compile -g Driver.java ReferenceInfoUtil.java RepeatingTypeAnnotations.java
+ * @run main Driver RepeatingTypeAnnotations
+ * @author Werner Dietl
+ */
+public class RepeatingTypeAnnotations {
+    // Field types
+    @TADescription(annotation = "RTAs", type = FIELD)
+    public String fieldAsPrimitive() {
+        return "@RTA @RTA int test;";
+    }
+
+    // Method returns
+    @TADescription(annotation = "RTAs", type = METHOD_RETURN)
+    public String methodReturn1() {
+        return "@RTA @RTA int test() { return 0; }";
+    }
+
+    @TADescription(annotation = "RTAs", type = METHOD_RETURN)
+    public String methodReturn2() {
+        return "@RTAs({@RTA, @RTA}) int test() { return 0; }";
+    }
+
+    // Method parameters
+    @TADescriptions({
+        @TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0),
+        @TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0,
+                genericLocation = { 3, 0 })
+    })
+    public String methodParam1() {
+        return "void m(@RTA @RTA List<@RTB @RTB String> p) {}";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "RTAs", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0),
+        @TADescription(annotation = "RTBs", type = METHOD_FORMAL_PARAMETER,
+                paramIndex = 0,
+                genericLocation = { 3, 0 })
+    })
+    public String methodParam2() {
+        return "void m(@RTAs({@RTA, @RTA}) List<@RTBs({@RTB, @RTB}) String> p) {}";
+    }
+
+    // TODO: test that all other locations work with repeated type annotations.
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/Test.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Test.java
new file mode 100644
index 0000000..b6cb1ca
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/Test.java
@@ -0,0 +1,33 @@
+
+import java.util.*;
+import java.lang.annotation.*;
+
+class Test<K> { GOuter<@TC Object, String> entrySet() { return null; } }
+
+ at interface A {}
+ at interface B {}
+ at interface C {}
+ at interface D {}
+ at interface E {}
+ at interface F {}
+
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TA {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TB {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TC {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TD {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TE {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TF {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TG {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TH {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TI {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TJ {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TK {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TL {}
+ at Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface TM {}
+
+ at Repeatable(RTAs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTA {}
+ at Repeatable(RTBs.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTB {}
+ at ContainerFor(RTA.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTAs { RTA[] value(); }
+ at ContainerFor(RTB.class) @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) @interface RTBs { RTB[] value(); }
+ at Target(value={ElementType.TYPE,ElementType.FIELD,ElementType.METHOD,ElementType.PARAMETER,ElementType.CONSTRUCTOR,ElementType.LOCAL_VARIABLE})
+ at interface Decl {}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeCasts.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeCasts.java
new file mode 100644
index 0000000..a50a964
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeCasts.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for type casts
+ * @compile -g Driver.java ReferenceInfoUtil.java TypeCasts.java
+ * @run main Driver TypeCasts
+ */
+public class TypeCasts {
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    public String returnObject() {
+        return "Object returnObject() { return (@TA String)null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TC", type = CAST,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String returnObjectArray() {
+        return "Object returnObjectArray() { return (@TC String @TA [] @TB [])null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String returnObjectGeneric() {
+        return "Object returnObjectGeneric() { return (@TA List<@TB String>)null; }";
+    }
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    public String returnPrim() {
+        return "Object returnPrim() { return (@TA int)0; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String returnPrimArray() {
+        return "Object returnPrimArray() { return (@TB int @TA [])null; }";
+    }
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    public String initObject() {
+        return "void initObject() { Object a =  (@TA String)null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String initObjectArray() {
+        return "void initObjectArray() { Object a = (@TB String @TA [])null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String initObjectGeneric() {
+        return "void initObjectGeneric() { Object a = (@TA List<@TB String>)null; }";
+    }
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    public String initPrim() {
+        return "void initPrim() { Object a =  (@TA int)0; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String initPrimArray() {
+        return "void initPrimArray() { Object a = (@TB int @TA [])null; }";
+    }
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    public String eqtestObject() {
+        return "void eqtestObject() { if (null == (@TA String)null); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String eqtestObjectArray() {
+        return "void eqtestObjectArray() { if (null == (@TB String @TA [])null); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 3, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String eqtestObjectGeneric() {
+        return "void eqtestObjectGeneric() { if (null == (@TA List<@TB String >)null); }";
+    }
+
+    @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+            typeIndex = 0)
+    // compiler optimizes away compile time constants casts
+    public String eqtestPrim() {
+        return "void eqtestPrim(int a) { if (0 == (@TA int)a); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE,
+                typeIndex = 0)
+    })
+    public String eqtestPrimArray() {
+        return "void eqtestPrimArray() { if (null == (@TB int @TA [])null); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1),
+        @TADescription(annotation = "TC", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
+                genericLocation = {3, 0})
+    })
+    public String intersection1() {
+        return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String>) null; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 0),
+        @TADescription(annotation = "TB", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1),
+        @TADescription(annotation = "TC", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 1,
+                genericLocation = {3, 0}),
+        @TADescription(annotation = "TD", type = CAST,
+                offset = ReferenceInfoUtil.IGNORE_VALUE, typeIndex = 2),
+    })
+    public String intersection2() {
+        return "void intersection() { Object o = (@TA String & @TB Comparable<@TC String> & @TD CharSequence) null; }";
+    }
+}
diff --git a/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeTests.java b/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeTests.java
new file mode 100644
index 0000000..3b31919
--- /dev/null
+++ b/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeTests.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2009, 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
+ * @summary Test population of reference info for class literals
+ * @compile -g Driver.java ReferenceInfoUtil.java TypeTests.java
+ * @run main Driver TypeTests
+ */
+public class TypeTests {
+
+    @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String returnObject() {
+        return "Object returnObject() { return null instanceof @TA String; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String returnObjectArray() {
+        return "Object returnObjectArray() { return null instanceof @TC String @TA [] @TB []; }";
+    }
+
+    // no type test for primitives
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String returnPrimArray() {
+        return "Object returnPrimArray() { return null instanceof @TC int @TA [] @TB []; }";
+    }
+
+    // no void
+    // no void array
+
+    @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String initObject() {
+        return "void initObject() { Object a =  null instanceof @TA String; }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String initObjectArray() {
+        return "void initObjectArray() { Object a = null instanceof @TC String @TA [] @TB []; }";
+    }
+
+    // no primitive instanceof
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String initPrimArray() {
+        return "void initPrimArray() { Object a = null instanceof @TC int @TA [] @TB []; }";
+    }
+
+    // no void
+    // no void array
+
+    @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    public String eqtestObject() {
+        return "void eqtestObject() { if (true == (null instanceof @TA String)); }";
+    }
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String eqtestObjectArray() {
+        return "void eqtestObjectArray() { if (true == (null instanceof @TC String @TA [] @TB [])); }";
+    }
+
+    // no primitives
+
+    @TADescriptions({
+        @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TB", type = INSTANCEOF,
+                genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
+        @TADescription(annotation = "TC", type = INSTANCEOF,
+                genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
+    })
+    public String eqtestPrimArray() {
+        return "void eqtestPrimArray() { if (true == (null instanceof @TC int @TA [] @TB [])); }";
+    }
+
+    // no void
+    // no void array
+
+}
diff --git a/test/tools/javac/api/6406133/T6406133.java b/test/tools/javac/api/6406133/T6406133.java
index 3227dda..26eb3e0 100644
--- a/test/tools/javac/api/6406133/T6406133.java
+++ b/test/tools/javac/api/6406133/T6406133.java
@@ -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.*;
diff --git a/test/tools/javac/api/6410643/T6410643.java b/test/tools/javac/api/6410643/T6410643.java
index ac5ca4c..80ac51d 100644
--- a/test/tools/javac/api/6410643/T6410643.java
+++ b/test/tools/javac/api/6410643/T6410643.java
@@ -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;
diff --git a/test/tools/javac/api/6411310/T6411310.java b/test/tools/javac/api/6411310/T6411310.java
index 892444c..885f347 100644
--- a/test/tools/javac/api/6411310/T6411310.java
+++ b/test/tools/javac/api/6411310/T6411310.java
@@ -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
  */
diff --git a/test/tools/javac/api/6411333/T6411333.java b/test/tools/javac/api/6411333/T6411333.java
index 6032b39..146f135 100644
--- a/test/tools/javac/api/6411333/T6411333.java
+++ b/test/tools/javac/api/6411333/T6411333.java
@@ -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
  */
diff --git a/test/tools/javac/api/6412656/T6412656.java b/test/tools/javac/api/6412656/T6412656.java
index e63ca2c..2dc64b7 100644
--- a/test/tools/javac/api/6412656/T6412656.java
+++ b/test/tools/javac/api/6412656/T6412656.java
@@ -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;
diff --git a/test/tools/javac/api/6415780/T6415780.java b/test/tools/javac/api/6415780/T6415780.java
index c5a4ed5..caf8c06 100644
--- a/test/tools/javac/api/6415780/T6415780.java
+++ b/test/tools/javac/api/6415780/T6415780.java
@@ -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 at ...
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
+ * @run main T6415780
  */
 
 import static javax.tools.StandardLocation.CLASS_PATH;
diff --git a/test/tools/javac/api/6418694/T6418694.java b/test/tools/javac/api/6418694/T6418694.java
index 7b7c1fe..f23cbf8 100644
--- a/test/tools/javac/api/6418694/T6418694.java
+++ b/test/tools/javac/api/6418694/T6418694.java
@@ -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
  */
diff --git a/test/tools/javac/api/6421111/T6421111.java b/test/tools/javac/api/6421111/T6421111.java
index fc2c581..96fbf2c 100644
--- a/test/tools/javac/api/6421111/T6421111.java
+++ b/test/tools/javac/api/6421111/T6421111.java
@@ -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
  */
diff --git a/test/tools/javac/api/6421756/T6421756.java b/test/tools/javac/api/6421756/T6421756.java
index f8b9306..9d20e03 100644
--- a/test/tools/javac/api/6421756/T6421756.java
+++ b/test/tools/javac/api/6421756/T6421756.java
@@ -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
  */
diff --git a/test/tools/javac/api/6422215/T6422215.java b/test/tools/javac/api/6422215/T6422215.java
index 20d8d75..c9a9c39 100644
--- a/test/tools/javac/api/6422215/T6422215.java
+++ b/test/tools/javac/api/6422215/T6422215.java
@@ -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;
diff --git a/test/tools/javac/api/6422327/T6422327.java b/test/tools/javac/api/6422327/T6422327.java
index ab3ddfd..e5f9f22 100644
--- a/test/tools/javac/api/6422327/T6422327.java
+++ b/test/tools/javac/api/6422327/T6422327.java
@@ -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;
diff --git a/test/tools/javac/api/6423003/T6423003.java b/test/tools/javac/api/6423003/T6423003.java
index 4af5f62..e7fe2f3 100644
--- a/test/tools/javac/api/6423003/T6423003.java
+++ b/test/tools/javac/api/6423003/T6423003.java
@@ -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
  */
diff --git a/test/tools/javac/api/6431257/T6431257.java b/test/tools/javac/api/6431257/T6431257.java
index f84afb7..9c0b2a4 100644
--- a/test/tools/javac/api/6431257/T6431257.java
+++ b/test/tools/javac/api/6431257/T6431257.java
@@ -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
  */
diff --git a/test/tools/javac/api/6437349/T6437349.java b/test/tools/javac/api/6437349/T6437349.java
index c21fe3b..af81251 100644
--- a/test/tools/javac/api/6437349/T6437349.java
+++ b/test/tools/javac/api/6437349/T6437349.java
@@ -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
  */
diff --git a/test/tools/javac/api/6437999/T6437999.java b/test/tools/javac/api/6437999/T6437999.java
index 65f72d0..2fbe321 100644
--- a/test/tools/javac/api/6437999/T6437999.java
+++ b/test/tools/javac/api/6437999/T6437999.java
@@ -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,16 +27,34 @@
  * @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
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
 import javax.tools.*;
+import static java.nio.file.StandardOpenOption.*;
 
 public class T6437999 extends ToolTester {
+    final File testFile = new File("Utf8.java");
+    T6437999() throws IOException {
+        createTestFile();
+    }
+    final void createTestFile() throws IOException {
+        List<String> scratch = new ArrayList<>();
+        scratch.add("// @author Peter von der Ah" + (char) 0xe9);
+        scratch.add("class Utf8{}");
+        Files.write(testFile.toPath(), scratch, Charset.forName("UTF-8"),
+                CREATE, TRUNCATE_EXISTING);
+    }
+
     static class MyDiagnosticListener implements DiagnosticListener<JavaFileObject> {
         boolean error = false;
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
@@ -54,7 +72,7 @@ public class T6437999 extends ToolTester {
         dl.error = false;
         fm = getFileManager(tool, dl, Charset.forName("ASCII"));
         fm.handleOption("-source", sourceLevel.iterator());
-        files = fm.getJavaFileObjects(new File(test_src, "Utf8.java"));
+        files = fm.getJavaFileObjects(testFile);
         tool.getTask(null, fm, null, null, null, files).call();
         if (!dl.error)
             throw new AssertionError("No error in ASCII mode");
@@ -62,12 +80,12 @@ public class T6437999 extends ToolTester {
         dl.error = false;
         fm = getFileManager(tool, dl, Charset.forName("UTF-8"));
         fm.handleOption("-source", sourceLevel.iterator());
-        files = fm.getJavaFileObjects(new File(test_src, "Utf8.java"));
+        files = fm.getJavaFileObjects(testFile);
         task = tool.getTask(null, fm, null, null, null, files);
         if (dl.error)
             throw new AssertionError("Error in UTF-8 mode");
     }
-    public static void main(String... args) {
+    public static void main(String... args) throws IOException {
         new T6437999().test(args);
     }
 }
diff --git a/test/tools/javac/api/6437999/Utf8.java b/test/tools/javac/api/6437999/Utf8.java
deleted file mode 100644
index a2504b0..0000000
--- a/test/tools/javac/api/6437999/Utf8.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2006, 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.
- */
-
-/**
- * @author Peter von der Ahé
- */
-class Utf8 {}
diff --git a/test/tools/javac/api/6440333/T6440333.java b/test/tools/javac/api/6440333/T6440333.java
index af38054..984ef40 100644
--- a/test/tools/javac/api/6440333/T6440333.java
+++ b/test/tools/javac/api/6440333/T6440333.java
@@ -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
  */
diff --git a/test/tools/javac/api/6440528/T6440528.java b/test/tools/javac/api/6440528/T6440528.java
index 188f5d2..0fc9194 100644
--- a/test/tools/javac/api/6440528/T6440528.java
+++ b/test/tools/javac/api/6440528/T6440528.java
@@ -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
  */
diff --git a/test/tools/javac/api/6468404/T6468404.java b/test/tools/javac/api/6468404/T6468404.java
index 8b7e045..dafbb36 100644
--- a/test/tools/javac/api/6468404/T6468404.java
+++ b/test/tools/javac/api/6468404/T6468404.java
@@ -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 at ...
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @build ToolTester
  * @compile T6468404.java
  * @run main T6468404
  */
diff --git a/test/tools/javac/api/6731573/T6731573.java b/test/tools/javac/api/6731573/T6731573.java
index 03d699a..b1bdc71 100644
--- a/test/tools/javac/api/6731573/T6731573.java
+++ b/test/tools/javac/api/6731573/T6731573.java
@@ -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.*;
diff --git a/test/tools/javac/api/6733837/T6733837.java b/test/tools/javac/api/6733837/T6733837.java
index db39c6b..4f1fcf4 100644
--- a/test/tools/javac/api/6733837/T6733837.java
+++ b/test/tools/javac/api/6733837/T6733837.java
@@ -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;
diff --git a/test/tools/javac/api/7086261/T7086261.java b/test/tools/javac/api/7086261/T7086261.java
index ab302bf..47fae1b 100644
--- a/test/tools/javac/api/7086261/T7086261.java
+++ b/test/tools/javac/api/7086261/T7086261.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 20011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
diff --git a/test/tools/javac/api/8007344/Test.java b/test/tools/javac/api/8007344/Test.java
new file mode 100644
index 0000000..23f63b7
--- /dev/null
+++ b/test/tools/javac/api/8007344/Test.java
@@ -0,0 +1,229 @@
+/*
+ * 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 8007344
+ * @summary javac may not make tree end positions and/or doc comments
+ *          available to processors and listeners
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor
+ * @run main Test
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.tree.*;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.Pretty;
+import com.sun.tools.javac.util.Position;
+
+/** Doc comment: Test */
+public class Test {
+    public static final int EXPECT_DOC_COMMENTS = 3;
+
+    /** Doc comment: main */
+    public static void main(String... args) throws Exception {
+        PrintWriter out = new PrintWriter(System.err);
+        try {
+            new Test(out).run();
+        } finally {
+            out.flush();
+        }
+    }
+
+    PrintWriter out;
+    int errors;
+
+    Test(PrintWriter out) {
+        this.out = out;
+    }
+
+    /** Doc comment: run */
+    void run() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File thisFile = new File(testSrc, getClass().getName() + ".java");
+        JavacTool javac = JavacTool.create();
+        StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
+        testAnnoProcessor(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
+        testTaskListener(javac, fm, fos, out, EXPECT_DOC_COMMENTS);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void testAnnoProcessor(JavacTool javac, StandardJavaFileManager fm,
+            Iterable<? extends JavaFileObject> files, PrintWriter out,
+            int expectedDocComments) {
+        out.println("Test annotation processor");
+        JavacTask task = javac.getTask(out, fm, null, null, null, files);
+        AnnoProc ap = new AnnoProc(DocTrees.instance(task));
+        task.setProcessors(Arrays.asList(ap));
+        task.call();
+        ap.checker.checkDocComments(expectedDocComments);
+    }
+
+    void testTaskListener(JavacTool javac, StandardJavaFileManager fm,
+            Iterable<? extends JavaFileObject> files, PrintWriter out,
+            int expectedDocComments) {
+        out.println("Test task listener");
+        JavacTask task = javac.getTask(out, fm, null, null, null, files);
+        TaskListnr tl = new TaskListnr(DocTrees.instance(task));
+        task.addTaskListener(tl);
+        task.call();
+        tl.checker.checkDocComments(expectedDocComments);
+    }
+
+    void error(String msg) {
+        out.println("Error: " + msg);
+        errors++;
+    }
+
+    class AnnoProc extends JavacTestingAbstractProcessor {
+        Checker checker;
+
+        AnnoProc(DocTrees trees) {
+            checker = new Checker(trees);
+        }
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            for (Element e : roundEnv.getRootElements()) {
+                checker.scan(checker.trees.getPath(e), null);
+            }
+            return true;
+        }
+    }
+
+    class TaskListnr implements TaskListener {
+        Checker checker;
+
+        TaskListnr(DocTrees trees) {
+            checker = new Checker(trees);
+        }
+
+        public void started(TaskEvent e) {
+            if (e.getKind() == TaskEvent.Kind.ANALYZE)
+                checker.scan(new TreePath(e.getCompilationUnit()), null);
+        }
+
+        public void finished(TaskEvent e) {
+        }
+    }
+
+    class Checker extends TreePathScanner<Void,Void> {
+        DocTrees trees;
+        SourcePositions srcPosns;
+
+        int docComments = 0;
+
+        Checker(DocTrees trees) {
+            this.trees = trees;
+            srcPosns = trees.getSourcePositions();
+        }
+
+        @Override
+        public Void scan(Tree tree, Void ignore) {
+            if (tree != null) {
+                switch (tree.getKind()) {
+                    // HACK: Workaround 8007350
+                    // Some tree nodes do not have endpos set
+                    case ASSIGNMENT:
+                    case BLOCK:
+                    case IDENTIFIER:
+                    case METHOD_INVOCATION:
+                        break;
+
+                    default:
+                        checkEndPos(getCurrentPath().getCompilationUnit(), tree);
+                }
+            }
+            return super.scan(tree, ignore);
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            checkComment();
+            return super.visitClass(tree, ignore);
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            checkComment();
+            return super.visitMethod(tree, ignore);
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            checkComment();
+            return super.visitVariable(tree, ignore);
+        }
+
+        void checkComment() {
+            DocCommentTree dc = trees.getDocCommentTree(getCurrentPath());
+            if (dc != null) {
+                out.println("comment: " + dc.toString().replaceAll("\\s+", " "));
+                docComments++;
+            }
+        }
+
+        void checkEndPos(CompilationUnitTree unit, Tree tree) {
+            long sp = srcPosns.getStartPosition(unit, tree);
+            long ep = srcPosns.getEndPosition(unit, tree);
+            if (sp >= 0 && ep == Position.NOPOS) {
+                error("endpos not set for " + tree.getKind()
+                        + " " + Pretty.toSimpleString(((JCTree) tree))
+                        +", start:" + sp);
+            }
+        }
+
+        void checkDocComments(int expected) {
+            if (docComments != expected) {
+                error("Unexpected number of doc comments received: "
+                        + docComments + ", expected: " + expected);
+            }
+        }
+
+    }
+}
diff --git a/test/tools/javac/api/EndPositions.java b/test/tools/javac/api/EndPositions.java
new file mode 100644
index 0000000..f791cc7
--- /dev/null
+++ b/test/tools/javac/api/EndPositions.java
@@ -0,0 +1,95 @@
+/*
+ * 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 7196760
+ * @summary javac doesn't report Diagnostic end positions properly when
+ * an annotation processor is present
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import static javax.tools.JavaFileObject.Kind.SOURCE;
+import javax.tools.ToolProvider;
+
+ at SupportedAnnotationTypes("*")
+public class EndPositions extends AbstractProcessor {
+    public static void main(String... args) throws IOException {
+        class MyFileObject extends SimpleJavaFileObject {
+            MyFileObject() {
+                super(URI.create("myfo:///Test.java"), SOURCE);
+            }
+            @Override
+            public String getCharContent(boolean ignoreEncodingErrors) {
+                //      0         1         2         3
+                //      012345678901234567890123456789012345
+                return "class Test { String s = 1234; }";
+            }
+        }
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        List<JavaFileObject> compilationUnits =
+                Collections.<JavaFileObject>singletonList(new MyFileObject());
+        DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
+        List<String> options = Arrays.asList("-processor", EndPositions.class.getCanonicalName());
+        JavacTask task = (JavacTask)javac.getTask(null, null, diagnostics, options, null, compilationUnits);
+        boolean valid = task.call();
+        if (valid)
+            throw new AssertionError("Expected one error, but found none.");
+
+        List<Diagnostic<? extends JavaFileObject>> errors = diagnostics.getDiagnostics();
+        if (errors.size() != 1)
+            throw new AssertionError("Expected one error only, but found " + errors.size() + "; errors: " + errors);
+
+        Diagnostic<?> error = errors.get(0);
+        if (error.getStartPosition() >= error.getEndPosition())
+            throw new AssertionError("Expected start to be less than end position: start [" +
+                    error.getStartPosition() + "], end [" + error.getEndPosition() +"]" +
+                    "; diagnostics code: " + error.getCode());
+
+        System.out.println("All is good!");
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        return true;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
diff --git a/test/tools/javac/api/T6306137.java b/test/tools/javac/api/T6306137.java
index b961d80..c17283c 100644
--- a/test/tools/javac/api/T6306137.java
+++ b/test/tools/javac/api/T6306137.java
@@ -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
@@ -25,15 +25,20 @@
  * @test
  * @bug     6306137
  * @summary JSR 199: encoding option doesn't affect standard file manager
- * @author  Peter von der Ahé
- * @ignore
- *    Need to make the contentCache in JavacFileManager be aware of changes to the encoding.
- *    Need to propogate -source (and -encoding?) down to the JavacFileManager
+ * @compile -encoding utf-8 T6306137.java
+ * @run main T6306137
+ * @author  Peter von der Ah\u00e9
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import javax.tools.*;
+import static java.nio.file.StandardOpenOption.*;
 
 public class T6306137 {
     boolean error;
@@ -41,8 +46,9 @@ public class T6306137 {
     final JavaCompiler compiler;
     Iterable<? extends JavaFileObject> files;
     DiagnosticListener<JavaFileObject> dl;
+    final File testFile = new File("Utf8.java");
 
-    T6306137() {
+    T6306137() throws IOException {
         dl = new DiagnosticListener<JavaFileObject>() {
                 public void report(Diagnostic<? extends JavaFileObject> message) {
                     if (message.getKind() == Diagnostic.Kind.ERROR)
@@ -57,11 +63,17 @@ public class T6306137 {
         };
         compiler = ToolProvider.getSystemJavaCompiler();
         fm = compiler.getStandardFileManager(dl, null, null);
-        String srcdir = System.getProperty("test.src");
         files =
-            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6306137.java")));
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(testFile));
+        createTestFile();
+    }
+    final void createTestFile() throws IOException {
+        List<String> scratch = new ArrayList<>();
+        scratch.add("// @author Peter von der Ah" + (char)0xe9);
+        scratch.add("class Utf8{}");
+        Files.write(testFile.toPath(), scratch, Charset.forName("UTF-8"),
+                CREATE, TRUNCATE_EXISTING);
     }
-
     void test(String encoding, boolean good) {
         error = false;
         Iterable<String> args = Arrays.asList("-source", "6", "-encoding", encoding, "-d", ".");
@@ -75,7 +87,7 @@ public class T6306137 {
         }
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws IOException {
         T6306137 self = new T6306137();
         self.test("utf-8", true);
         self.test("ascii", false);
diff --git a/test/tools/javac/api/T6395981.java b/test/tools/javac/api/T6395981.java
index 605ea1f..2ff7685 100644
--- a/test/tools/javac/api/T6395981.java
+++ b/test/tools/javac/api/T6395981.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,13 +23,13 @@
 
 /*
  * @test
- * @bug     6395981 6458819
+ * @bug     6395981 6458819 7025784
  * @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
  * @author  Peter von der Ah\u00e9
  * @run main/fail T6395981
  * @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
  * @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
- * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7
+ * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8
  */
 
 import java.util.EnumSet;
diff --git a/test/tools/javac/api/T6397104.java b/test/tools/javac/api/T6397104.java
index 841ffbb..a3d919c 100644
--- a/test/tools/javac/api/T6397104.java
+++ b/test/tools/javac/api/T6397104.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
diff --git a/test/tools/javac/api/T6838467.java b/test/tools/javac/api/T6838467.java
index 5087797..1dccda3 100644
--- a/test/tools/javac/api/T6838467.java
+++ b/test/tools/javac/api/T6838467.java
@@ -32,7 +32,6 @@ import java.util.*;
 import java.util.zip.*;
 import javax.tools.*;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Options;
 
diff --git a/test/tools/javac/api/TestGetElementReference.java b/test/tools/javac/api/TestGetElementReference.java
new file mode 100644
index 0000000..c1c67bc
--- /dev/null
+++ b/test/tools/javac/api/TestGetElementReference.java
@@ -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;
+        }
+    }
+
+}
diff --git a/test/tools/javac/api/TestGetElementReferenceData.java b/test/tools/javac/api/TestGetElementReferenceData.java
new file mode 100644
index 0000000..a72d95f
--- /dev/null
+++ b/test/tools/javac/api/TestGetElementReferenceData.java
@@ -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 {
+    }
+}
diff --git a/test/tools/javac/api/TestGetScope.java b/test/tools/javac/api/TestGetScope.java
new file mode 100644
index 0000000..40cf8c9
--- /dev/null
+++ b/test/tools/javac/api/TestGetScope.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011, 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 7090249
+ * @summary IllegalStateException from Trees.getScope when called from JSR 199
+ */
+
+import com.sun.source.tree.IdentifierTree;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+
+ at SupportedAnnotationTypes("*")
+public class TestGetScope extends AbstractProcessor {
+    public static void main(String... args) {
+        new TestGetScope().run();
+    }
+
+    public void run() {
+        File srcDir = new File(System.getProperty("test.src"));
+        File thisFile = new File(srcDir, getClass().getName() + ".java");
+
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+
+        List<String> opts = Arrays.asList("-proc:only", "-doe");
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+        JavacTask t = (JavacTask) c.getTask(null, fm, null, opts, null, files);
+        t.setProcessors(Collections.singleton(this));
+        boolean ok = t.call();
+        if (!ok)
+            throw new Error("compilation failed");
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        Trees trees = Trees.instance(processingEnv);
+        if (round++ == 0) {
+            for (Element e: roundEnv.getRootElements()) {
+                TreePath p = trees.getPath(e);
+                new Scanner().scan(p, trees);
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    int round;
+
+    static class Scanner extends TreePathScanner<Void,Trees> {
+        @Override
+        public Void visitIdentifier(IdentifierTree t, Trees trees) {
+            System.err.println("visitIdentifier: " + t);
+            trees.getScope(getCurrentPath());
+            return null;
+        }
+    }
+}
diff --git a/test/tools/javac/api/TestJavacTaskScanner.java b/test/tools/javac/api/TestJavacTaskScanner.java
index 40bde16..7103ba7 100644
--- a/test/tools/javac/api/TestJavacTaskScanner.java
+++ b/test/tools/javac/api/TestJavacTaskScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, 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
@@ -27,11 +27,13 @@
  * @summary Additional functionality test of task and JSR 269
  * @author  Peter von der Ah\u00e9
  * @library ./lib
+ * @build ToolTester
  * @run main TestJavacTaskScanner TestJavacTaskScanner.java
  */
 
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.parser.*;
+import com.sun.tools.javac.parser.Tokens.Token;
 import com.sun.tools.javac.util.*;
 import java.io.*;
 import java.net.*;
@@ -92,8 +94,8 @@ public class TestJavacTaskScanner extends ToolTester {
         System.out.println("#allMembers: " + numAllMembers);
 
         check(numTokens, "#Tokens", 1222);
-        check(numParseTypeElements, "#parseTypeElements", 136);
-        check(numAllMembers, "#allMembers", 67);
+        check(numParseTypeElements, "#parseTypeElements", 158);
+        check(numAllMembers, "#allMembers", 52);
     }
 
     void check(int value, String name, int expected) {
@@ -109,7 +111,8 @@ public class TestJavacTaskScanner extends ToolTester {
         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++;
         }
     }
@@ -121,7 +124,8 @@ public class TestJavacTaskScanner extends ToolTester {
 
     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++;
         }
     }
@@ -159,7 +163,7 @@ public class TestJavacTaskScanner extends ToolTester {
         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);
@@ -178,7 +182,6 @@ class MyScanner extends Scanner {
 
         @Override
         public Scanner newScanner(CharSequence input, boolean keepDocComments) {
-            assert !keepDocComments;
             if (input instanceof CharBuffer) {
                 return new MyScanner(this, (CharBuffer)input, test);
             } else {
@@ -189,7 +192,6 @@ class MyScanner extends Scanner {
 
         @Override
         public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
-            assert !keepDocComments;
             return new MyScanner(this, input, inputLength, test);
         }
 
@@ -206,7 +208,8 @@ class MyScanner extends Scanner {
 
     public void nextToken() {
         super.nextToken();
-        System.err.format("Saw token %s (%s)%n", token(), name());
+        Token tk = token();
+        System.err.format("Saw token %s %n", tk.kind);
         test.numTokens++;
     }
 
diff --git a/test/tools/javac/api/TestOperators.java b/test/tools/javac/api/TestOperators.java
index a963d05..d2069bf 100644
--- a/test/tools/javac/api/TestOperators.java
+++ b/test/tools/javac/api/TestOperators.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, 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,8 @@
  * @bug     6338064 6346249 6340951 6392177
  * @summary Tree API: can't determine kind of operator
  * @author  Peter von der Ah\u00e9
- * @compile TestOperators.java
+ * @library ../lib
+ * @build JavacTestingAbstractProcessor TestOperators
  * @compile -processor TestOperators -proc:only TestOperators.java
  */
 
@@ -46,7 +47,7 @@ import static com.sun.source.tree.Tree.Kind.*;
 }
 
 @SupportedAnnotationTypes("TestMe")
-public class TestOperators extends AbstractProcessor {
+public class TestOperators extends JavacTestingAbstractProcessor {
 
     @TestMe(POSTFIX_INCREMENT)
     public int test_POSTFIX_INCREMENT(int i) {
@@ -299,7 +300,7 @@ public class TestOperators extends AbstractProcessor {
         final Trees trees = Trees.instance(processingEnv);
         final Messager log = processingEnv.getMessager();
         final Elements elements = processingEnv.getElementUtils();
-        class Scan extends ElementScanner7<Void,Void> {
+        class Scan extends ElementScanner<Void,Void> {
             @Override
             public Void visitExecutable(ExecutableElement e, Void p) {
                 Object debug = e; // info for exception handler
@@ -343,5 +344,4 @@ public class TestOperators extends AbstractProcessor {
         }
         return true;
     }
-
 }
diff --git a/test/tools/javac/api/guide/Test.java b/test/tools/javac/api/guide/Test.java
index 9c1057f..a05295f 100644
--- a/test/tools/javac/api/guide/Test.java
+++ b/test/tools/javac/api/guide/Test.java
@@ -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
  */
diff --git a/test/tools/javac/api/lib/ToolTester.java b/test/tools/javac/api/lib/ToolTester.java
index 2f1a50e..ba66da8 100644
--- a/test/tools/javac/api/lib/ToolTester.java
+++ b/test/tools/javac/api/lib/ToolTester.java
@@ -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 @@ import static javax.tools.StandardLocation.CLASS_OUTPUT;
 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 @@ public class ToolTester {
         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;
+    }
 }
diff --git a/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java b/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java
new file mode 100644
index 0000000..e102b09
--- /dev/null
+++ b/test/tools/javac/api/taskListeners/TestSimpleAddRemove.java
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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     7093891
+ * @summary support multiple task listeners
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.JavacTool;
+
+public class TestSimpleAddRemove {
+    enum AddKind {
+        SET_IN_TASK,
+        ADD_IN_TASK,
+        ADD_IN_PROCESSOR,
+        ADD_IN_LISTENER;
+    }
+
+    enum RemoveKind {
+        REMOVE_IN_TASK,
+        REMOVE_IN_PROCESSOR,
+        REMOVE_IN_LISTENER,
+    }
+
+    enum CompileKind {
+        CALL {
+            void run(JavacTask t) {
+                if (!t.call()) throw new Error("compilation failed");
+            }
+        },
+        GENERATE {
+            void run(JavacTask t) throws IOException {
+                t.generate();
+            }
+        };
+        abstract void run(JavacTask t) throws IOException;
+    }
+
+    static class EventKindCounter extends EnumMap<TaskEvent.Kind, EventKindCounter.Count> {
+        static class Count {
+            int started;
+            int finished;
+
+            @Override
+            public String toString() {
+                return started + ":" + finished;
+            }
+        }
+
+        EventKindCounter() {
+            super(TaskEvent.Kind.class);
+        }
+
+        void inc(TaskEvent.Kind k, boolean started) {
+            Count c = get(k);
+            if (c == null)
+                put(k, c = new Count());
+
+            if (started)
+                c.started++;
+            else
+                c.finished++;
+        }
+    }
+
+    static class TestListener implements TaskListener {
+        EventKindCounter counter;
+
+        TestListener(EventKindCounter c) {
+            counter = c;
+        }
+
+        public void started(TaskEvent e) {
+            counter.inc(e.getKind(), true);
+        }
+
+        public void finished(TaskEvent e) {
+            counter.inc(e.getKind(), false);
+        }
+    }
+
+    static void addInListener(final JavacTask task, final TaskEvent.Kind kind, final TaskListener listener) {
+        task.addTaskListener(new TaskListener() {
+            public void started(TaskEvent e) {
+                if (e.getKind() == kind) {
+                    task.addTaskListener(listener);
+                    task.removeTaskListener(this);
+                }
+            }
+
+            public void finished(TaskEvent e) { }
+        });
+    }
+
+    static void removeInListener(final JavacTask task, final TaskEvent.Kind kind, final TaskListener listener) {
+        task.addTaskListener(new TaskListener() {
+            public void started(TaskEvent e) {
+                if (e.getKind() == kind) {
+                    task.removeTaskListener(listener);
+                    task.removeTaskListener(this);
+                }
+            }
+
+            public void finished(TaskEvent e) { }
+        });
+    }
+
+    @SupportedAnnotationTypes("*")
+    class TestProcessor extends AbstractProcessor {
+        AddKind ak;
+        RemoveKind rk;
+        TaskListener listener;
+
+        TestProcessor(AddKind ak, RemoveKind rk, TaskListener listener) {
+            this.ak = ak;
+            this.rk = rk;
+            this.listener = listener;
+        }
+
+        int round = 0;
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+//            System.err.println("TestProcessor.process " + roundEnv);
+            JavacTask task = JavacTask.instance(processingEnv);
+            if (++round == 1) {
+                switch (ak) {
+                    case ADD_IN_PROCESSOR:
+                        task.addTaskListener(listener);
+                        break;
+                    case ADD_IN_LISTENER:
+                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
+                        break;
+                }
+            } else if (roundEnv.processingOver()) {
+                switch (rk) {
+                    case REMOVE_IN_PROCESSOR:
+                        task.removeTaskListener(listener);
+                        break;
+                    case REMOVE_IN_LISTENER:
+                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
+                        break;
+                }
+            }
+            return true;
+        }
+    }
+
+    static class TestSource extends SimpleJavaFileObject {
+        public TestSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return "class Test { }";
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        new TestSimpleAddRemove().run();
+    }
+
+    JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+
+    void run() throws Exception {
+        for (CompileKind ck: CompileKind.values()) {
+            for (AddKind ak: AddKind.values()) {
+                for (RemoveKind rk: RemoveKind.values()) {
+                    test(ck, ak, rk);
+                }
+            }
+        }
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
+        System.err.println("Test: " + ck + " " + ak + " " + rk);
+
+        File tmpDir = new File(ck + "-" + ak + "-" + rk);
+        tmpDir.mkdirs();
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));
+
+        List<String> options = new ArrayList<String>();
+        Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavacTask task = tool.getTask(pw, fm, null, options, null, files);
+
+        EventKindCounter ec = new EventKindCounter();
+        TaskListener listener = new TestListener(ec);
+        boolean needProcessor = false;
+
+        switch (ak) {
+            case SET_IN_TASK:
+                task.setTaskListener(listener);
+                break;
+            case ADD_IN_TASK:
+                task.addTaskListener(listener);
+                break;
+            case ADD_IN_PROCESSOR:
+            case ADD_IN_LISTENER:
+                needProcessor = true;
+        }
+
+        switch (rk) {
+            case REMOVE_IN_TASK:
+                task.removeTaskListener(listener);
+                break;
+            case REMOVE_IN_PROCESSOR:
+            case REMOVE_IN_LISTENER:
+                needProcessor = true;
+        }
+
+        if (needProcessor)
+            task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));
+
+        ck.run(task);
+        System.err.println(ec);
+
+        check(ck, ak, rk, ec);
+
+        System.err.println();
+    }
+
+    void check(CompileKind ck, AddKind ak, RemoveKind rk, EventKindCounter ec) {
+        // All results should be independent of ck, so we can ignore that
+
+        // Quick way to compare expected values of ec, by comparing ec.toString()
+        String expect = ec.toString();
+        String found;
+
+        switch (ak) {
+            // Add/set in task should record all events until the listener is removed
+            case SET_IN_TASK:
+            case ADD_IN_TASK:
+                switch (rk) {
+                    case REMOVE_IN_TASK:
+                        // Remove will succeed, meaning no events will be recorded
+                        found = "{}";
+                        break;
+                    case REMOVE_IN_PROCESSOR:
+                        found = "{PARSE=1:1, ENTER=2:2, ANNOTATION_PROCESSING=1:0, ANNOTATION_PROCESSING_ROUND=2:1}";
+                        break;
+                    case REMOVE_IN_LISTENER:
+                        found = "{PARSE=1:1, ENTER=3:3, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=1:1, ANNOTATION_PROCESSING_ROUND=2:2}";
+                        break;
+                    default:
+                        throw new IllegalStateException();
+                }
+                break;
+
+            // "Add in processor" should skip initial PARSE/ENTER events
+            case ADD_IN_PROCESSOR:
+                switch (rk) {
+                    // Remove will fail (too early), so events to end will be recorded
+                    case REMOVE_IN_TASK:
+                        found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:1, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}";
+                        break;
+                    case REMOVE_IN_PROCESSOR:
+                        found = "{ENTER=1:1, ANNOTATION_PROCESSING_ROUND=1:1}";
+                        break;
+                    case REMOVE_IN_LISTENER:
+                        found = "{ENTER=2:2, ANALYZE=1:1, GENERATE=1:0, ANNOTATION_PROCESSING=0:1, ANNOTATION_PROCESSING_ROUND=1:2}";
+                        break;
+                    default:
+                        throw new IllegalStateException();
+                }
+                break;
+
+            // "Add in listener" will occur during "ANALYSE.started" event
+            case ADD_IN_LISTENER:
+                switch (rk) {
+                    // Remove will fail (too early, so events to end will be recorded
+                    case REMOVE_IN_TASK:
+                    case REMOVE_IN_PROCESSOR:
+                        found = "{ANALYZE=0:1, GENERATE=1:1}";
+                        break;
+                    // Remove will succeed during "GENERATE.finished" event
+                    case REMOVE_IN_LISTENER:
+                        found = "{ANALYZE=0:1, GENERATE=1:0}";
+                        break;
+                    default:
+                        throw new IllegalStateException();
+                }
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+
+        if (!found.equals(expect)) {
+            System.err.println("Expected: " + expect);
+            System.err.println("   Found: " + found);
+            error("unexpected value found");
+        }
+    }
+
+    int errors;
+
+    void error(String message) {
+        System.err.println("Error: " + message);
+        errors++;
+    }
+}
diff --git a/test/tools/javac/apt.sh b/test/tools/javac/apt.sh
deleted file mode 100644
index f6a4785..0000000
--- a/test/tools/javac/apt.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 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.
-#
-
-# 
-# Usage:
-#  @run apt.sh <apt-args>
-#
-# This script is to run apt for a regression test
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  Windows* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-CLASSPATH="${TESTCLASSES}${PS}${TESTJAVA}${FS}lib${FS}tools.jar" "${TESTJAVA}${FS}bin${FS}apt" ${TESTTOOLVMOPTS} $*
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
-
-
diff --git a/test/tools/javac/cast/6270087/T6270087neg.out b/test/tools/javac/cast/6270087/T6270087neg.out
index 3509a66..91bb841 100644
--- a/test/tools/javac/cast/6270087/T6270087neg.out
+++ b/test/tools/javac/cast/6270087/T6270087neg.out
@@ -1,2 +1,2 @@
-T6270087neg.java:36:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6270087neg.Foo<V>, T6270087neg.Foo<U>
+T6270087neg.java:36:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6270087neg.Foo<V>, T6270087neg.Foo<U>)
 1 error
diff --git a/test/tools/javac/cast/6557182/T6557182.out b/test/tools/javac/cast/6557182/T6557182.out
index 05c8b55..0434504 100644
--- a/test/tools/javac/cast/6557182/T6557182.out
+++ b/test/tools/javac/cast/6557182/T6557182.out
@@ -1,4 +1,4 @@
-T6557182.java:12:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T, java.lang.Comparable<java.lang.Integer>
+T6557182.java:12:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T, java.lang.Comparable<java.lang.Integer>)
 T6557182.java:16:56: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable<java.lang.Integer>
 1 error
 1 warning
diff --git a/test/tools/javac/cast/6665356/T6665356.out b/test/tools/javac/cast/6665356/T6665356.out
index 2c4ca37..094a0c2 100644
--- a/test/tools/javac/cast/6665356/T6665356.out
+++ b/test/tools/javac/cast/6665356/T6665356.out
@@ -1,8 +1,8 @@
-T6665356.java:31:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<java.lang.Long>
-T6665356.java:35:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.Number>
-T6665356.java:39:65: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>
-T6665356.java:43:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? extends java.lang.String>.Inner<java.lang.Long>
-T6665356.java:47:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? extends java.lang.String>
-T6665356.java:51:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.String>.Inner<java.lang.Long>
-T6665356.java:55:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.String>
+T6665356.java:31:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<java.lang.Long>)
+T6665356.java:35:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.Number>)
+T6665356.java:39:65: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>)
+T6665356.java:43:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? extends java.lang.String>.Inner<java.lang.Long>)
+T6665356.java:47:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? extends java.lang.String>)
+T6665356.java:51:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<? super java.lang.String>.Inner<java.lang.Long>)
+T6665356.java:55:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6665356.Outer<java.lang.Integer>.Inner<java.lang.Long>, T6665356.Outer<java.lang.Integer>.Inner<? super java.lang.String>)
 7 errors
diff --git a/test/tools/javac/cast/6795580/T6795580.out b/test/tools/javac/cast/6795580/T6795580.out
index a96517c..b0398f0 100644
--- a/test/tools/javac/cast/6795580/T6795580.out
+++ b/test/tools/javac/cast/6795580/T6795580.out
@@ -1,8 +1,8 @@
-T6795580.java:31:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<java.lang.Long>[]
-T6795580.java:35:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.Number>[]
-T6795580.java:39:67: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>[]
-T6795580.java:43:59: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? extends java.lang.String>.Inner<java.lang.Long>[]
-T6795580.java:47:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? extends java.lang.String>[]
-T6795580.java:51:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.String>.Inner<java.lang.Long>[]
-T6795580.java:55:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.String>[]
+T6795580.java:31:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<java.lang.Long>[])
+T6795580.java:35:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.Number>[])
+T6795580.java:39:67: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.Number>.Inner<? super java.lang.Number>[])
+T6795580.java:43:59: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? extends java.lang.String>.Inner<java.lang.Long>[])
+T6795580.java:47:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? extends java.lang.String>[])
+T6795580.java:51:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<? super java.lang.String>.Inner<java.lang.Long>[])
+T6795580.java:55:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6795580.Outer<java.lang.Integer>.Inner<java.lang.Long>[], T6795580.Outer<java.lang.Integer>.Inner<? super java.lang.String>[])
 7 errors
diff --git a/test/tools/javac/cast/6932571/T6932571neg.out b/test/tools/javac/cast/6932571/T6932571neg.out
index 360e774..9a9422a 100644
--- a/test/tools/javac/cast/6932571/T6932571neg.out
+++ b/test/tools/javac/cast/6932571/T6932571neg.out
@@ -1,2 +1,2 @@
-T6932571neg.java:39:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6932571neg.S, G
+T6932571neg.java:39:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T6932571neg.S, G)
 1 error
diff --git a/test/tools/javac/cast/7005095/T7005095neg.out b/test/tools/javac/cast/7005095/T7005095neg.out
index 88b831b..2bc942f 100644
--- a/test/tools/javac/cast/7005095/T7005095neg.out
+++ b/test/tools/javac/cast/7005095/T7005095neg.out
@@ -1,2 +1,2 @@
-T7005095neg.java:13:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T7005095pos.FooImpl, T7005095pos.Foo<T>
+T7005095neg.java:13:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: T7005095pos.FooImpl, T7005095pos.Foo<T>)
 1 error
diff --git a/test/tools/javac/cast/7005671/T7005671.out b/test/tools/javac/cast/7005671/T7005671.out
index a654622..fae6c77 100644
--- a/test/tools/javac/cast/7005671/T7005671.out
+++ b/test/tools/javac/cast/7005671/T7005671.out
@@ -1,17 +1,17 @@
-T7005671.java:12:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), byte[], X[]
-T7005671.java:13:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), short[], X[]
-T7005671.java:14:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), int[], X[]
-T7005671.java:15:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), long[], X[]
-T7005671.java:16:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), float[], X[]
-T7005671.java:17:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), double[], X[]
-T7005671.java:18:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), char[], X[]
-T7005671.java:19:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), boolean[], X[]
-T7005671.java:23:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], byte[]
-T7005671.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], short[]
-T7005671.java:25:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], int[]
-T7005671.java:26:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], long[]
-T7005671.java:27:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], float[]
-T7005671.java:28:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], double[]
-T7005671.java:29:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], char[]
-T7005671.java:30:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), X[], boolean[]
+T7005671.java:12:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: byte[], X[])
+T7005671.java:13:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: short[], X[])
+T7005671.java:14:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int[], X[])
+T7005671.java:15:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: long[], X[])
+T7005671.java:16:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: float[], X[])
+T7005671.java:17:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: double[], X[])
+T7005671.java:18:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: char[], X[])
+T7005671.java:19:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: boolean[], X[])
+T7005671.java:23:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], byte[])
+T7005671.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], short[])
+T7005671.java:25:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], int[])
+T7005671.java:26:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], long[])
+T7005671.java:27:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], float[])
+T7005671.java:28:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], double[])
+T7005671.java:29:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], char[])
+T7005671.java:30:32: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X[], boolean[])
 16 errors
diff --git a/test/tools/javac/cast/7123100/T7123100a.out b/test/tools/javac/cast/7123100/T7123100a.out
index a816314..b71aa5f 100644
--- a/test/tools/javac/cast/7123100/T7123100a.out
+++ b/test/tools/javac/cast/7123100/T7123100a.out
@@ -1,4 +1,4 @@
-T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z
+T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), E, Z
 - compiler.err.warnings.and.werror
 1 error
 1 warning
diff --git a/test/tools/javac/cast/7126754/T7126754.java b/test/tools/javac/cast/7126754/T7126754.java
new file mode 100644
index 0000000..79e49ec
--- /dev/null
+++ b/test/tools/javac/cast/7126754/T7126754.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @author mcimadamore
+ * @bug     7005671
+ * @summary Generics compilation failure casting List<? extends Set...> to List<Set...>
+ * @compile/fail/ref=T7126754.out -Xlint:unchecked -Werror -XDrawDiagnostics T7126754.java
+ */
+
+import java.util.List;
+
+class T7126754 {
+    List<? extends List<? extends String>> c = null;
+    List<List<? extends String>> d = (List<List<? extends String>>)c;
+}
diff --git a/test/tools/javac/cast/7126754/T7126754.out b/test/tools/javac/cast/7126754/T7126754.out
new file mode 100644
index 0000000..73baf16
--- /dev/null
+++ b/test/tools/javac/cast/7126754/T7126754.out
@@ -0,0 +1,4 @@
+T7126754.java:13:68: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.util.List<compiler.misc.type.captureof: 1, ? extends java.util.List<? extends java.lang.String>>, java.util.List<java.util.List<? extends java.lang.String>>
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/cast/intersection/IntersectionTypeCastTest.java b/test/tools/javac/cast/intersection/IntersectionTypeCastTest.java
new file mode 100644
index 0000000..7aea2d4
--- /dev/null
+++ b/test/tools/javac/cast/intersection/IntersectionTypeCastTest.java
@@ -0,0 +1,359 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8002099 8006694
+ * @summary Add support for intersection types in cast expression
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm/timeout=360 IntersectionTypeCastTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.util.List;
+import com.sun.tools.javac.util.ListBuffer;
+
+public class IntersectionTypeCastTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    interface Type {
+        boolean subtypeOf(Type that);
+        String asString();
+        boolean isClass();
+        boolean isInterface();
+    }
+
+    enum InterfaceKind implements Type {
+        A("interface A { }\n", "A", null),
+        B("interface B { }\n", "B", null),
+        C("interface C extends A { }\n", "C", A);
+
+        String declStr;
+        String typeStr;
+        InterfaceKind superInterface;
+
+        InterfaceKind(String declStr, String typeStr,
+                InterfaceKind superInterface) {
+            this.declStr = declStr;
+            this.typeStr = typeStr;
+            this.superInterface = superInterface;
+        }
+
+        @Override
+        public boolean subtypeOf(Type that) {
+            return this == that || superInterface == that ||
+                   that == ClassKind.OBJECT;
+        }
+
+        @Override
+        public String asString() {
+            return typeStr;
+        }
+
+        @Override
+        public boolean isClass() {
+            return false;
+        }
+
+        @Override
+        public boolean isInterface() {
+            return true;
+        }
+    }
+
+    enum ClassKind implements Type {
+        OBJECT(null, "Object"),
+        CA("#M class CA implements A { }\n", "CA",
+           InterfaceKind.A),
+        CB("#M class CB implements B { }\n", "CB",
+           InterfaceKind.B),
+        CAB("#M class CAB implements A, B { }\n", "CAB",
+            InterfaceKind.A, InterfaceKind.B),
+        CC("#M class CC implements C { }\n", "CC",
+           InterfaceKind.C, InterfaceKind.A),
+        CCA("#M class CCA implements C, A { }\n", "CCA",
+            InterfaceKind.C, InterfaceKind.A),
+        CCB("#M class CCB implements C, B { }\n", "CCB",
+            InterfaceKind.C, InterfaceKind.A, InterfaceKind.B),
+        CCAB("#M class CCAB implements C, A, B { }\n", "CCAB",
+             InterfaceKind.C, InterfaceKind.A, InterfaceKind.B);
+
+        String declTemplate;
+        String typeStr;
+        List<InterfaceKind> superInterfaces;
+
+        ClassKind(String declTemplate, String typeStr,
+                InterfaceKind... superInterfaces) {
+            this.declTemplate = declTemplate;
+            this.typeStr = typeStr;
+            this.superInterfaces = List.from(superInterfaces);
+        }
+
+        String getDecl(ModifierKind mod) {
+            return declTemplate != null ?
+                    declTemplate.replaceAll("#M", mod.modStr) :
+                    "";
+        }
+
+        @Override
+        public boolean subtypeOf(Type that) {
+            return this == that || superInterfaces.contains(that) ||
+                    that == OBJECT;
+        }
+
+        @Override
+        public String asString() {
+            return typeStr;
+        }
+
+        @Override
+        public boolean isClass() {
+            return true;
+        }
+
+        @Override
+        public boolean isInterface() {
+            return false;
+        }
+    }
+
+    enum ModifierKind {
+        NONE(""),
+        FINAL("final");
+
+        String modStr;
+
+        ModifierKind(String modStr) {
+            this.modStr = modStr;
+        }
+    }
+
+    enum CastKind {
+        CLASS("(#C)", 0),
+        INTERFACE("(#I0)", 1),
+        INTERSECTION2("(#C & #I0)", 1),
+        INTERSECTION3("(#C & #I0 & #I1)", 2);
+        //INTERSECTION4("(#C & #I0 & #I1 & #I2)", 3);
+
+        String castTemplate;
+        int interfaceBounds;
+
+        CastKind(String castTemplate, int interfaceBounds) {
+            this.castTemplate = castTemplate;
+            this.interfaceBounds = interfaceBounds;
+        }
+    }
+
+    static class CastInfo {
+        CastKind kind;
+        Type[] types;
+
+        CastInfo(CastKind kind, Type... types) {
+            this.kind = kind;
+            this.types = types;
+        }
+
+        String getCast() {
+            String temp = kind.castTemplate.replaceAll("#C",
+                    types[0].asString());
+            for (int i = 0; i < kind.interfaceBounds ; i++) {
+                temp = temp.replace(String.format("#I%d", i),
+                                    types[i + 1].asString());
+            }
+            return temp;
+        }
+
+        boolean hasDuplicateTypes() {
+            for (int i = 0 ; i < types.length ; i++) {
+                for (int j = 0 ; j < types.length ; j++) {
+                    if (i != j && types[i] == types[j]) {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+        boolean compatibleWith(ModifierKind mod, CastInfo that) {
+            for (Type t1 : types) {
+                for (Type t2 : that.types) {
+                    boolean compat =
+                            t1.subtypeOf(t2) ||
+                            t2.subtypeOf(t1) ||
+                            (t1.isInterface() && t2.isInterface()) || //side-cast (1)
+                            (mod == ModifierKind.NONE &&
+                            (t1.isInterface() != t2.isInterface())); //side-cast (2)
+                    if (!compat) return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ModifierKind mod : ModifierKind.values()) {
+            for (CastInfo cast1 : allCastInfo()) {
+                for (CastInfo cast2 : allCastInfo()) {
+                    pool.execute(
+                        new IntersectionTypeCastTest(mod, cast1, cast2));
+                }
+            }
+        }
+        checkAfterExec();
+    }
+
+    static List<CastInfo> allCastInfo() {
+        ListBuffer<CastInfo> buf = ListBuffer.lb();
+        for (CastKind kind : CastKind.values()) {
+            for (ClassKind clazz : ClassKind.values()) {
+                if (kind == CastKind.INTERFACE && clazz != ClassKind.OBJECT) {
+                    continue;
+                } else if (kind.interfaceBounds == 0) {
+                    buf.append(new CastInfo(kind, clazz));
+                    continue;
+                } else {
+                    for (InterfaceKind intf1 : InterfaceKind.values()) {
+                        if (kind.interfaceBounds == 1) {
+                            buf.append(new CastInfo(kind, clazz, intf1));
+                            continue;
+                        } else {
+                            for (InterfaceKind intf2 : InterfaceKind.values()) {
+                                if (kind.interfaceBounds == 2) {
+                                    buf.append(
+                                            new CastInfo(kind, clazz, intf1, intf2));
+                                    continue;
+                                } else {
+                                    for (InterfaceKind intf3 : InterfaceKind.values()) {
+                                        buf.append(
+                                                new CastInfo(kind, clazz, intf1,
+                                                             intf2, intf3));
+                                        continue;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return buf.toList();
+    }
+
+    ModifierKind mod;
+    CastInfo cast1, cast2;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    IntersectionTypeCastTest(ModifierKind mod, CastInfo cast1, CastInfo cast2) {
+        this.mod = mod;
+        this.cast1 = cast1;
+        this.cast2 = cast2;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    @Override
+    public void run() {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when compiling the following code:\n" +
+                    source.getCharContent(true));
+        }
+        check();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "class Test {\n" +
+                              "   void test() {\n" +
+                              "      Object o = #C1#C2null;\n" +
+                              "   } }";
+
+        String source = "";
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            for (ClassKind ck : ClassKind.values()) {
+                source += ck.getDecl(mod);
+            }
+            for (InterfaceKind ik : InterfaceKind.values()) {
+                source += ik.declStr;
+            }
+            source += bodyTemplate.replaceAll("#C1", cast1.getCast()).
+                    replaceAll("#C2", cast2.getCast());
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        boolean errorExpected = cast1.hasDuplicateTypes() ||
+                cast2.hasDuplicateTypes();
+
+        errorExpected |= !cast2.compatibleWith(mod, cast1);
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/cast/intersection/IntersectionTypeParserTest.java b/test/tools/javac/cast/intersection/IntersectionTypeParserTest.java
new file mode 100644
index 0000000..c699bab
--- /dev/null
+++ b/test/tools/javac/cast/intersection/IntersectionTypeParserTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ *
+ * 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 8002099
+ * @summary Add support for intersection types in cast expression
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class IntersectionTypeParserTest {
+
+    static int checkCount = 0;
+
+    enum TypeKind {
+        SIMPLE("A"),
+        GENERIC("A<X>"),
+        WILDCARD("A<? super X, ? extends Y>");
+
+        String typeStr;
+
+        TypeKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+    }
+
+    enum ArrayKind {
+        NONE(""),
+        SINGLE("[]"),
+        DOUBLE("[][]");
+
+        String arrStr;
+
+        ArrayKind(String arrStr) {
+            this.arrStr = arrStr;
+        }
+    }
+
+    static class Type {
+        TypeKind tk;
+        ArrayKind ak;
+
+        Type(TypeKind tk, ArrayKind ak) {
+            this.tk = tk;
+            this.ak = ak;
+        }
+
+        String asString() {
+            return tk.typeStr + ak.arrStr;
+        }
+    }
+
+    enum CastKind {
+        ONE("(#T0)", 1),
+        TWO("(#T0 & T1)", 2),
+        THREE("(#T0 & #T1 & #T2)", 3);
+
+        String castTemplate;
+        int nBounds;
+
+        CastKind(String castTemplate, int nBounds) {
+            this.castTemplate = castTemplate;
+            this.nBounds = nBounds;
+        }
+
+        String asString(Type... types) {
+            String res = castTemplate;
+            for (int i = 0; i < nBounds ; i++) {
+                res = res.replaceAll(String.format("#T%d", i), types[i].asString());
+            }
+            return res;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (CastKind ck : CastKind.values()) {
+            for (TypeKind t1 : TypeKind.values()) {
+                for (ArrayKind ak1 : ArrayKind.values()) {
+                    Type typ1 = new Type(t1, ak1);
+                    if (ck.nBounds == 1) {
+                        new IntersectionTypeParserTest(ck, typ1).run(comp, fm);
+                        continue;
+                    }
+                    for (TypeKind t2 : TypeKind.values()) {
+                        for (ArrayKind ak2 : ArrayKind.values()) {
+                            Type typ2 = new Type(t2, ak2);
+                            if (ck.nBounds == 2) {
+                                new IntersectionTypeParserTest(ck, typ1, typ2).run(comp, fm);
+                                continue;
+                            }
+                            for (TypeKind t3 : TypeKind.values()) {
+                                for (ArrayKind ak3 : ArrayKind.values()) {
+                                    Type typ3 = new Type(t3, ak3);
+                                    new IntersectionTypeParserTest(ck, typ1, typ2, typ3).run(comp, fm);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    CastKind ck;
+    Type[] types;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    IntersectionTypeParserTest(CastKind ck, Type... types) {
+        this.ck = ck;
+        this.types = types;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "class Test {\n" +
+                              "   void test() {\n" +
+                              "      Object o = #Cnull;\n" +
+                              "   } }";
+
+        String source = "";
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source += bodyTemplate.replaceAll("#C", ck.asString(types));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        checkCount++;
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        ct.parse();
+        if (diagChecker.errorFound) {
+            throw new Error("Unexpected parser error for source:\n" +
+                source.getCharContent(true));
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/cast/intersection/model/Check.java b/test/tools/javac/cast/intersection/model/Check.java
new file mode 100644
index 0000000..d47a6fd
--- /dev/null
+++ b/test/tools/javac/cast/intersection/model/Check.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * Annotation used by ModelChecker to mark the class whose model is to be checked
+ */
+ at interface Check {}
diff --git a/test/tools/javac/cast/intersection/model/IntersectionTypeInfo.java b/test/tools/javac/cast/intersection/model/IntersectionTypeInfo.java
new file mode 100644
index 0000000..bed6fc0
--- /dev/null
+++ b/test/tools/javac/cast/intersection/model/IntersectionTypeInfo.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/**
+ * Used by ModelChecker to validate the modeling information of a union type.
+ */
+ at interface IntersectionTypeInfo {
+    String[] value();
+}
diff --git a/test/tools/javac/cast/intersection/model/Member.java b/test/tools/javac/cast/intersection/model/Member.java
new file mode 100644
index 0000000..ee14474
--- /dev/null
+++ b/test/tools/javac/cast/intersection/model/Member.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.lang.model.element.ElementKind;
+
+/**
+ * Annotation used by ModelChecker to mark a member that is to be checked
+ */
+ at interface Member {
+   ElementKind value();
+}
diff --git a/test/tools/javac/cast/intersection/model/Model01.java b/test/tools/javac/cast/intersection/model/Model01.java
new file mode 100644
index 0000000..2174017
--- /dev/null
+++ b/test/tools/javac/cast/intersection/model/Model01.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ *
+ * 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 8002099
+ * @summary Add support for intersection types in cast expression
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor ModelChecker
+ * @compile -processor ModelChecker Model01.java
+ */
+
+import javax.lang.model.element.ElementKind;
+
+ at Check
+class Test {
+
+    interface A {
+        @Member(ElementKind.METHOD)
+        public void m1();
+    }
+
+    interface B {
+        @Member(ElementKind.METHOD)
+        public void m2();
+    }
+
+    void test(){
+        @IntersectionTypeInfo({"java.lang.Object", "Test.A", "Test.B"})
+        Object o = (A & B)null;
+    }
+}
diff --git a/test/tools/javac/cast/intersection/model/ModelChecker.java b/test/tools/javac/cast/intersection/model/ModelChecker.java
new file mode 100644
index 0000000..1486d21
--- /dev/null
+++ b/test/tools/javac/cast/intersection/model/ModelChecker.java
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ *
+ * 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 com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.TypeCastTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
+
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.IntersectionType;
+import javax.lang.model.type.UnknownTypeException;
+import javax.lang.model.util.SimpleTypeVisitor6;
+import javax.lang.model.util.SimpleTypeVisitor7;
+
+ at SupportedAnnotationTypes("Check")
+public class ModelChecker extends JavacTestingAbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver())
+            return true;
+
+        Trees trees = Trees.instance(processingEnv);
+
+        TypeElement testAnno = elements.getTypeElement("Check");
+        for (Element elem: roundEnv.getElementsAnnotatedWith(testAnno)) {
+            TreePath p = trees.getPath(elem);
+            new IntersectionCastTester(trees).scan(p, null);
+        }
+        return true;
+    }
+
+    class IntersectionCastTester extends TreePathScanner<Void, Void> {
+        Trees trees;
+
+        public IntersectionCastTester(Trees trees) {
+            super();
+            this.trees = trees;
+        }
+
+        @Override
+        public Void visitVariable(VariableTree node, Void p) {
+
+            TreePath varPath = new TreePath(getCurrentPath(), node);
+            Element v = trees.getElement(varPath);
+
+            IntersectionTypeInfo it = v.getAnnotation(IntersectionTypeInfo.class);
+            assertTrue(it != null, "IntersectionType annotation must be present");
+
+            ExpressionTree varInit = node.getInitializer();
+            assertTrue(varInit != null && varInit.getKind() == Tree.Kind.TYPE_CAST,
+                    "variable must have be initialized to an expression containing an intersection type cast");
+
+            TypeMirror t = ((JCExpression)((TypeCastTree)varInit).getType()).type;
+
+            validateIntersectionTypeInfo(t, it);
+
+            for (Element e2 : types.asElement(t).getEnclosedElements()) {
+                assertTrue(false, "an intersection type has no declared members");
+            }
+
+            for (Element e2 : elements.getAllMembers((TypeElement)types.asElement(t))) {
+                Member m = e2.getAnnotation(Member.class);
+                if (m != null) {
+                    assertTrue(e2.getKind() == m.value(), "Expected " + m.value() + " - found " + e2.getKind());
+                }
+            }
+
+            assertTrue(assertionCount == 10, "Expected 10 assertions - found " + assertionCount);
+            return super.visitVariable(node, p);
+        }
+    }
+
+    private void validateIntersectionTypeInfo(TypeMirror expectedIntersectionType, IntersectionTypeInfo it) {
+
+        assertTrue(expectedIntersectionType.getKind() == TypeKind.INTERSECTION, "INTERSECTION kind expected");
+
+        try {
+            new SimpleTypeVisitor6<Void, Void>(){}.visit(expectedIntersectionType);
+            throw new RuntimeException("Expected UnknownTypeException not thrown.");
+        } catch (UnknownTypeException ute) {
+            ; // Expected
+        }
+
+        try {
+            new SimpleTypeVisitor7<Void, Void>(){}.visit(expectedIntersectionType);
+            throw new RuntimeException("Expected UnknownTypeException not thrown.");
+        } catch (UnknownTypeException ute) {
+            ; // Expected
+        }
+
+        IntersectionType intersectionType = new SimpleTypeVisitor<IntersectionType, Void>(){
+            @Override
+            protected IntersectionType defaultAction(TypeMirror e, Void p) {return null;}
+
+            @Override
+            public IntersectionType visitIntersection(IntersectionType t, Void p) {return t;}
+        }.visit(expectedIntersectionType);
+        assertTrue(intersectionType != null, "Must get a non-null intersection type.");
+
+        assertTrue(it.value().length == intersectionType.getBounds().size(), "Cardinalities do not match");
+
+        String[] typeNames = it.value();
+        for(int i = 0; i < typeNames.length; i++) {
+            TypeMirror typeFromAnnotation = nameToType(typeNames[i]);
+            assertTrue(types.isSameType(typeFromAnnotation, intersectionType.getBounds().get(i)),
+                       "Types were not equal.");
+        }
+    }
+
+    private TypeMirror nameToType(String name) {
+        return elements.getTypeElement(name).asType();
+    }
+
+    private static void assertTrue(boolean cond, String msg) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError(msg);
+    }
+
+    static int assertionCount = 0;
+}
diff --git a/test/tools/javac/classfiles/ClassVersionChecker.java b/test/tools/javac/classfiles/ClassVersionChecker.java
new file mode 100644
index 0000000..f08d850
--- /dev/null
+++ b/test/tools/javac/classfiles/ClassVersionChecker.java
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ *
+ * 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 7157626 8001112
+ * @summary Test major version for all legal combinations for -source and -target
+ * @author sgoel
+ *
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.util.*;
+import java.util.regex.*;
+
+public class ClassVersionChecker {
+
+    int errors;
+    String[] jdk = {"","1.2","1.3","1.4","1.5","1.6","1.7","1.8"};
+    File javaFile = null;
+
+    public static void main(String[] args) throws Throwable {
+        new ClassVersionChecker().run();
+    }
+
+    void run() throws Exception {
+        writeTestFile();
+        /* Rules applicable for -source and -target combinations
+         * 1. If both empty, version num is for 1.7
+         * 2. If source is not empty and target is empty, version is based on source
+         * 3. If both non-empty, version is based on target
+         */
+
+        /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...)
+         * ver[0][0] => no -source or -target was given
+         * -1 => invalid combinations
+         */
+        int[][] ver =
+                {{52, -1, -1, -1, -1, -1, -1, -1},
+                 {48, 46, 47, 48, 49, 50, 51, 52},
+                 {48, 46, 47, 48, 49, 50, 51, 52},
+                 {48, -1, -1, 48, 49, 50, 51, 52},
+                 {52, -1, -1, -1, 49, 50, 51, 52},
+                 {52, -1, -1, -1, -1, 50, 51, 52},
+                 {52, -1, -1, -1, -1, -1, 51, 52},
+                 {52, -1, -1, -1, -1, -1, -1, 52}};
+
+        // Loop to run all possible combinations of source/target values
+        for (int i = 0; i< ver.length; i++) {
+            for (int j = 0 ; j< ver[i].length; j++) {
+                if(ver[i][j] != -1) {
+                    logMsg("Index values for i = " + i + " j = " + j);
+                    logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]);
+                    test(i,j, ver[i][j]);
+                }
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test (int i, int j, int expected) {
+        File classFile = compileTestFile(i, j, javaFile);
+        short majorVer = getMajorVersion(classFile);
+        checkVersion(majorVer, expected);
+    }
+
+    void writeTestFile() throws IOException {
+        javaFile = new File("Test.java");
+        try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(javaFile)));) {
+            out.println("class Test { ");
+            out.println("  public void foo() { }");
+            out.println("}");
+        } catch (IOException ioe) {
+            error("IOException while creating Test.java" + ioe);
+        }
+    }
+
+    File compileTestFile(int i , int j, File f) {
+        int rc = -1;
+        // Src and target are empty
+        if (i == 0 && j == 0 ) {
+            rc = compile("-g", f.getPath());
+        } else if( j == 0 ) {  // target is empty
+            rc = compile("-source", jdk[i], "-g", f.getPath());
+        } else {
+            rc = compile("-source", jdk[i], "-target", jdk[j], "-g", f.getPath());
+        }
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    int compile(String... args) {
+        return com.sun.tools.javac.Main.compile(args);
+    }
+
+    void logMsg (String str) {
+        System.out.println(str);
+    }
+
+    short getMajorVersion(File f) {
+        List<String> args = new ArrayList<String>();
+        short majorVer = 0;
+        try(DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)));) {
+            in.readInt();
+            in.readShort();
+            majorVer = in.readShort();
+            System.out.println("major version:" +  majorVer);
+        } catch (IOException e) {
+            error("IOException while reading Test.class" + e);
+        }
+        return majorVer;
+    }
+
+    void checkVersion(short majorVer, int expected) {
+        if (majorVer != expected ) {
+            error("versions did not match, Expected: " + expected + "Got: " + majorVer);
+        }
+    }
+
+    void error(String msg) {
+       System.out.println("error: " + msg);
+       errors++;
+    }
+}
diff --git a/test/tools/javac/classreader/T7031108.java b/test/tools/javac/classreader/T7031108.java
index 51a58ff..14b308a 100644
--- a/test/tools/javac/classreader/T7031108.java
+++ b/test/tools/javac/classreader/T7031108.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 7031108
  * @summary NPE in javac.jvm.ClassReader.findMethod in PackageElement.enclosedElements from AP in incr build
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor T7031108
  * @run main T7031108
  */
diff --git a/test/tools/javac/conditional/Conditional.java b/test/tools/javac/conditional/Conditional.java
index 8d66dba..c637103 100644
--- a/test/tools/javac/conditional/Conditional.java
+++ b/test/tools/javac/conditional/Conditional.java
@@ -27,7 +27,8 @@
  * @summary Conditional operator applies assignment conversion
  * @author Tim Hanson, BEA
  *
- * @compile/fail Conditional.java
+ * @compile Conditional.java
+ * @compile/fail -source 7 Conditional.java
  */
 
 import java.util.*;
diff --git a/test/tools/javac/conditional/T8016702.java b/test/tools/javac/conditional/T8016702.java
new file mode 100644
index 0000000..df99fd6
--- /dev/null
+++ b/test/tools/javac/conditional/T8016702.java
@@ -0,0 +1,66 @@
+/*
+ * 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 8016702
+ * @summary use of ternary operator in lambda expression gives incorrect results
+ */
+import java.util.Arrays;
+import java.util.List;
+
+public class T8016702 {
+
+    static int assertionCount;
+
+    static void assertTrue(boolean b, String msg) {
+        assertionCount++;
+        if (!b) {
+            throw new AssertionError(msg);
+        }
+    }
+
+    interface IntFunction<Y> {
+        Y m(int x);
+    }
+
+    void test(List<Integer> li) {
+        map(i -> (i % 2 == 0) ? "" : "i="+i, li);
+    }
+
+
+    @SuppressWarnings("unchecked")
+    <R> void map(IntFunction<R> mapper, List<Integer> li) {
+        for (int i : li) {
+            String res = (String)mapper.m(i);
+            assertTrue((i % 2 == 0) ? res.isEmpty() : res.contains("" + i),
+                    "i = " + i + " res = " + res);
+        }
+    }
+
+    public static void main(String[] args) {
+        T8016702 tester = new T8016702();
+        tester.test(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
+        assertTrue(assertionCount == 10, "wrong assertion count: " + assertionCount);
+    }
+}
diff --git a/test/tools/javac/constDebug/ConstDebug.java b/test/tools/javac/constDebug/ConstDebug.java
deleted file mode 100644
index 940ca87..0000000
--- a/test/tools/javac/constDebug/ConstDebug.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4645152 4785453
- * @summary javac compiler incorrectly inserts <clinit> when -g is specified
- * @author gafter
- *
- * @run shell ConstDebug.sh ConstDebug
- */
-
-public class ConstDebug {
-    public static final long l = 12;
-}
diff --git a/test/tools/javac/constDebug/ConstDebug.sh b/test/tools/javac/constDebug/ConstDebug.sh
deleted file mode 100644
index 0a96a47..0000000
--- a/test/tools/javac/constDebug/ConstDebug.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";" # Platform PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}$1.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
-result=$?
-if [ $result -ne 0 ]; then exit $result; fi
-if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then
-  echo "Failed"
-  exit 1;
-else
-  echo "Passed"
-  exit 0;
-fi
diff --git a/test/tools/javac/constDebug/ConstDebugTest.java b/test/tools/javac/constDebug/ConstDebugTest.java
new file mode 100644
index 0000000..20a4bf5
--- /dev/null
+++ b/test/tools/javac/constDebug/ConstDebugTest.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 4645152 4785453
+ * @summary javac compiler incorrectly inserts <clinit> when -g is specified
+ * @run compile -g ConstDebugTest.java
+ * @run main ConstDebugTest
+ */
+import java.nio.file.Paths;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Method;
+
+public class ConstDebugTest {
+
+    public static final long l = 12;
+
+    public static void main(String args[]) throws Exception {
+        ClassFile classFile = ClassFile.read(Paths.get(System.getProperty("test.classes"),
+                ConstDebugTest.class.getSimpleName() + ".class"));
+        for (Method method: classFile.methods) {
+            if (method.getName(classFile.constant_pool).equals("<clinit>")) {
+                throw new AssertionError(
+                    "javac should not create a <clinit> method for ConstDebugTest class");
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java b/test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java
new file mode 100644
index 0000000..906b40a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/CheckACC_STRICTFlagOnDefaultMethodTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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 8012723
+ * @summary strictfp interface misses strictfp modifer on default method
+ * @run main CheckACC_STRICTFlagOnDefaultMethodTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+import java.io.IOException;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+import static com.sun.tools.classfile.AccessFlags.ACC_STRICT;
+
+public class CheckACC_STRICTFlagOnDefaultMethodTest {
+    private static final String AssertionErrorMessage =
+        "All methods should have the ACC_STRICT access flag " +
+        "please check output";
+    private static final String offendingMethodErrorMessage =
+        "Method %s of class %s doesn't have the ACC_STRICT access flag";
+
+    private List<String> errors = new ArrayList<>();
+
+    public static void main(String[] args)
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        new CheckACC_STRICTFlagOnDefaultMethodTest().run();
+    }
+
+    private void run()
+            throws IOException, ConstantPoolException, InvalidDescriptor {
+        String testClasses = System.getProperty("test.classes");
+        check(testClasses,
+                "CheckACC_STRICTFlagOnDefaultMethodTest$StrictfpInterface.class");
+        if (errors.size() > 0) {
+            for (String error: errors) {
+                System.err.println(error);
+            }
+            throw new AssertionError(AssertionErrorMessage);
+        }
+    }
+
+    void check(String dir, String... fileNames)
+        throws
+            IOException,
+            ConstantPoolException,
+            Descriptor.InvalidDescriptor {
+        for (String fileName : fileNames) {
+            ClassFile classFileToCheck = ClassFile.read(new File(dir, fileName));
+
+            for (Method method : classFileToCheck.methods) {
+                if ((method.access_flags.flags & ACC_STRICT) == 0) {
+                    errors.add(String.format(offendingMethodErrorMessage,
+                            method.getName(classFileToCheck.constant_pool),
+                            classFileToCheck.getName()));
+                }
+            }
+        }
+    }
+
+    strictfp interface StrictfpInterface {
+        default void default_interface_method() {}
+        static void static_interface_method() {}
+    }
+
+}
diff --git a/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java b/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java
new file mode 100644
index 0000000..0e533ac
--- /dev/null
+++ b/test/tools/javac/defaultMethods/ClassReaderTest/ClassReaderTest.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2011, 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 check that default methods don't cause ClassReader to complete classes recursively
+ * @author  Maurizio Cimadamore
+ * @compile pkg/Foo.java
+ * @compile ClassReaderTest.java
+ */
+
+abstract class ClassReaderTest implements pkg.Foo {}
diff --git a/test/tools/javac/defaultMethods/ClassReaderTest/pkg/Foo.java b/test/tools/javac/defaultMethods/ClassReaderTest/pkg/Foo.java
new file mode 100644
index 0000000..d960f8f
--- /dev/null
+++ b/test/tools/javac/defaultMethods/ClassReaderTest/pkg/Foo.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 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 interface Foo  {
+    default void m1() { Impl.m1(this); }
+    default void m2() { Impl.m2(this); }
+}
+
+class Impl {
+    static void m1(Foo f) { }
+    static void m2(Foo f) { }
+}
diff --git a/test/tools/javac/defaultMethods/DefaultMethodFlags.java b/test/tools/javac/defaultMethods/DefaultMethodFlags.java
new file mode 100644
index 0000000..2aea0e4
--- /dev/null
+++ b/test/tools/javac/defaultMethods/DefaultMethodFlags.java
@@ -0,0 +1,111 @@
+/*
+ * 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 8011383
+ * @summary Symbol.getModifiers omits ACC_ABSTRACT from interface with default methods
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import javax.lang.model.element.*;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.util.Assert;
+
+public class DefaultMethodFlags {
+
+    public static void main(String[] args) throws IOException {
+        new DefaultMethodFlags().run(args);
+    }
+
+    void run(String[] args) throws IOException {
+        checkDefaultMethodFlags();
+    }
+
+    void checkDefaultMethodFlags() throws IOException {
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        Iterable<? extends JavaFileObject> fos =
+                fm.getJavaFileObjectsFromFiles(
+                Arrays.asList(new File(
+                System.getProperty("test.src"),
+                this.getClass().getSimpleName() + ".java")));
+        JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, fos);
+
+        task.addTaskListener(new TaskListener() {
+
+            @Override
+            public void started(TaskEvent e) {}
+
+            @Override
+            public void finished(TaskEvent e) {
+                if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+                    TypeElement te = e.getTypeElement();
+                    if (te.getSimpleName().toString().equals("I")) {
+                        checkDefaultInterface(te);
+                    }
+                }
+            }
+        });
+
+        task.analyze();
+    }
+
+    void checkDefaultInterface(TypeElement te) {
+        System.err.println("Checking " + te.getSimpleName());
+        Assert.check(te.getModifiers().contains(Modifier.ABSTRACT));
+        for (Element e : te.getEnclosedElements()) {
+            if (e.getSimpleName().toString().matches("(\\w)_(default|static|abstract)")) {
+                boolean abstractExpected = false;
+                String methodKind = e.getSimpleName().toString().substring(2);
+                switch (methodKind) {
+                    case "default":
+                    case "static":
+                        break;
+                    case "abstract":
+                        abstractExpected = true;
+                        break;
+                    default:
+                        Assert.error("Cannot get here!" + methodKind);
+                }
+                Assert.check(e.getModifiers().contains(Modifier.ABSTRACT) == abstractExpected);
+            }
+        }
+    }
+}
+
+interface I {
+    default void m_default() { }
+    static void m_static() { }
+    void m_abstract();
+}
diff --git a/test/tools/javac/defaultMethods/Neg01.java b/test/tools/javac/defaultMethods/Neg01.java
new file mode 100644
index 0000000..bbf1aba
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg01.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary negative test for ambiguous defaults
+ * @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java
+ */
+
+class Neg01 {
+    interface IA { default int m() { return Neg01.m1(this); } }
+    interface IB { default int m() { return Neg01.m2(this); } }
+
+    static class A implements IA {}
+    static class B implements IB {}
+
+    static class AB implements IA, IB {}
+
+    static int m1(IA a) { return 0; }
+    static int m2(IB b) { return 0; }
+}
diff --git a/test/tools/javac/defaultMethods/Neg01.out b/test/tools/javac/defaultMethods/Neg01.out
new file mode 100644
index 0000000..ca44ab6
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg01.out
@@ -0,0 +1,2 @@
+Neg01.java:14:12: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg01.AB, m, , Neg01.IA, Neg01.IB
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg02.java b/test/tools/javac/defaultMethods/Neg02.java
new file mode 100644
index 0000000..deb35a1
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg02.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that ill-formed MI hierarchies do not compile
+ * @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java
+ */
+
+class Neg02 {
+     interface A {
+         default void m() { Neg02.impl(this); }
+     }
+
+     interface B {
+         default void m() { Neg02.impl(this); }
+     }
+
+     static class X implements A, B { } //error
+
+     void test(X x) {
+         x.m();
+         ((A)x).m();
+         ((B)x).m();
+     }
+
+     static void impl(A a) { }
+     static void impl(B b) { }
+}
diff --git a/test/tools/javac/defaultMethods/Neg02.out b/test/tools/javac/defaultMethods/Neg02.out
new file mode 100644
index 0000000..3fb05ab
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg02.out
@@ -0,0 +1,2 @@
+Neg02.java:16:13: compiler.err.types.incompatible.unrelated.defaults: kindname.class, Neg02.X, m, , Neg02.A, Neg02.B
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg03.java b/test/tools/javac/defaultMethods/Neg03.java
new file mode 100644
index 0000000..ba6262c
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg03.java
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that re-abstraction works properly
+ * @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java
+ */
+
+class Neg03 {
+    interface A {
+        default void m() { Neg03.one(this); }
+    }
+
+    interface B {
+        default void m() { Neg03.two(this); }
+    }
+
+    interface C extends A, B {
+        default void m() { Neg03.one(this); }
+    }
+
+    static class X implements C, A { } //ok - ignore extraneous remix of A
+
+    interface D extends A, B {
+      void m();  // ok - m() is not reabstracted!
+    }
+
+    static class Y implements D, A { } // invalid - abstract D.m()
+
+    interface E extends A {
+        void m();  // reabstraction of m()
+    }
+
+    static class W implements D, E { } // invalid - abstracts D.m()/E.m()
+
+    static class Z implements D, A, B { } // invalid - abstract D.m()
+
+    static void one(Object a) {  }
+    static void two(Object a) {  }
+}
diff --git a/test/tools/javac/defaultMethods/Neg03.out b/test/tools/javac/defaultMethods/Neg03.out
new file mode 100644
index 0000000..338eb6c
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg03.out
@@ -0,0 +1,4 @@
+Neg03.java:26:12: compiler.err.does.not.override.abstract: Neg03.Y, m(), Neg03.D
+Neg03.java:32:12: compiler.err.does.not.override.abstract: Neg03.W, m(), Neg03.D
+Neg03.java:34:12: compiler.err.does.not.override.abstract: Neg03.Z, m(), Neg03.D
+3 errors
diff --git a/test/tools/javac/defaultMethods/Neg04.java b/test/tools/javac/defaultMethods/Neg04.java
new file mode 100644
index 0000000..a057f35
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg04.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default method must have most specific return type
+ * @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java
+ */
+
+class Neg04 {
+    interface IA1 { Integer m(); }
+    interface IA2 extends IA1 { default Number m() { return Neg04.m(this); } } //error
+
+    abstract class C implements IA1, IA2 {}
+
+    static int m(IA2 a) { return 0; }
+}
diff --git a/test/tools/javac/defaultMethods/Neg04.out b/test/tools/javac/defaultMethods/Neg04.out
new file mode 100644
index 0000000..a6fc1ad
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg04.out
@@ -0,0 +1,2 @@
+Neg04.java:9:48: compiler.err.override.incompatible.ret: (compiler.misc.clashes.with: m(), Neg04.IA2, m(), Neg04.IA1), java.lang.Number, java.lang.Integer
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg05.java b/test/tools/javac/defaultMethods/Neg05.java
new file mode 100644
index 0000000..3550c49
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg05.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that abstract methods are compatible with inherited defaults
+ * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
+ */
+
+class Neg05 {
+    interface IA1 { default Number m() { return Neg05.m1(this); } }
+    interface IA2 extends IA1 { default Integer m() { return Neg05.m2(this); } }
+    interface IA3 extends IA2 { Number m(); } //error
+
+    static class C implements IA3{}
+
+    static int m1(IA1 a) { return 0; }
+    static int m2(IA2 b) { return 0; }
+}
diff --git a/test/tools/javac/defaultMethods/Neg05.out b/test/tools/javac/defaultMethods/Neg05.out
new file mode 100644
index 0000000..17a0c45
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg05.out
@@ -0,0 +1,3 @@
+Neg05.java:10:40: compiler.err.override.incompatible.ret: (compiler.misc.clashes.with: m(), Neg05.IA3, m(), Neg05.IA2), java.lang.Number, java.lang.Integer
+Neg05.java:12:12: compiler.err.does.not.override.abstract: Neg05.C, m(), Neg05.IA3
+2 errors
diff --git a/test/tools/javac/defaultMethods/Neg06.java b/test/tools/javac/defaultMethods/Neg06.java
new file mode 100644
index 0000000..602ece8
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg06.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary flow analysis is not run on inlined default bodies
+ * @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java
+ */
+
+class Neg06 {
+
+    interface A {
+        default String m() { C.m(); }
+    }
+
+    static class C {
+        static String m() { return ""; }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg06.out b/test/tools/javac/defaultMethods/Neg06.out
new file mode 100644
index 0000000..53c39d0
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg06.out
@@ -0,0 +1,2 @@
+Neg06.java:10:37: compiler.err.missing.ret.stmt
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg07.java b/test/tools/javac/defaultMethods/Neg07.java
new file mode 100644
index 0000000..c11f315
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg07.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default overrides are properly type-checked
+ * @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java
+ */
+
+class Neg07 {
+    interface I {
+        default int m() { return 1; }
+    }
+
+    static class C1 {
+        public void m() { } //incompatible return
+    }
+
+    static class C2 extends C1 implements I { }
+
+    static class C3 implements I {
+        public void m() { } //incompatible return
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg07.out b/test/tools/javac/defaultMethods/Neg07.out
new file mode 100644
index 0000000..97d2ac8
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg07.out
@@ -0,0 +1,3 @@
+Neg07.java:16:12: compiler.err.override.incompatible.ret: (compiler.misc.cant.implement: m(), Neg07.C1, m(), Neg07.I), void, int
+Neg07.java:19:21: compiler.err.override.incompatible.ret: (compiler.misc.cant.implement: m(), Neg07.C3, m(), Neg07.I), void, int
+2 errors
diff --git a/test/tools/javac/defaultMethods/Neg08.java b/test/tools/javac/defaultMethods/Neg08.java
new file mode 100644
index 0000000..5e3ef07
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg08.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default overrides are properly type-checked
+ * @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java
+ */
+class Neg08 {
+    interface I {
+        default void m() { }
+    }
+
+    static class C1 {
+        void m() { } //weaker modifier
+    }
+
+    static class C2 extends C1 implements I { }
+
+    static class C3 implements I {
+        void m() { } //weaker modifier
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg08.out b/test/tools/javac/defaultMethods/Neg08.out
new file mode 100644
index 0000000..38f1c9b
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg08.out
@@ -0,0 +1,3 @@
+Neg08.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: m(), Neg08.C1, m(), Neg08.I), public
+Neg08.java:18:14: compiler.err.override.weaker.access: (compiler.misc.cant.implement: m(), Neg08.C3, m(), Neg08.I), public
+2 errors
diff --git a/test/tools/javac/defaultMethods/Neg09.java b/test/tools/javac/defaultMethods/Neg09.java
new file mode 100644
index 0000000..cabda07
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg09.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default overrides are properly type-checked
+ * @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java
+ */
+import java.util.List;
+
+class Neg09 {
+    interface I {
+        default List<String> m() { return null; }
+    }
+
+    static class C1 {
+        public List m() { return null; } //unchecked (return) override
+    }
+
+    static class C2 extends C1 implements I { }
+
+    static class C3 implements I {
+        public List m() { return null; } //unchecked (return) override
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg09.out b/test/tools/javac/defaultMethods/Neg09.out
new file mode 100644
index 0000000..2f13e2f
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg09.out
@@ -0,0 +1,5 @@
+Neg09.java:17:12: compiler.warn.override.unchecked.ret: (compiler.misc.unchecked.implement: m(), Neg09.C1, m(), Neg09.I), java.util.List, java.util.List<java.lang.String>
+Neg09.java:20:21: compiler.warn.override.unchecked.ret: (compiler.misc.unchecked.implement: m(), Neg09.C3, m(), Neg09.I), java.util.List, java.util.List<java.lang.String>
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/defaultMethods/Neg10.java b/test/tools/javac/defaultMethods/Neg10.java
new file mode 100644
index 0000000..3ecb1af
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg10.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default overrides are properly type-checked
+ * @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java
+ */
+class Neg10 {
+    interface I<X extends Exception> {
+        default void m() throws X { }
+    }
+
+    static class C1 {
+        public void m() throws Exception { } //unchecked (throws) override
+    }
+
+    static class C2<Z extends Exception> extends C1 implements I<Z> { }
+
+    static class C3<Z extends Exception> implements I<Z> {
+        public void m() throws Exception { } //unchecked (throws) override
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg10.out b/test/tools/javac/defaultMethods/Neg10.out
new file mode 100644
index 0000000..82be6eb
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg10.out
@@ -0,0 +1,5 @@
+Neg10.java:15:12: compiler.warn.override.unchecked.thrown: (compiler.misc.cant.implement: m(), Neg10.C1, m(), Neg10.I), java.lang.Exception
+Neg10.java:18:21: compiler.warn.override.unchecked.thrown: (compiler.misc.cant.implement: m(), Neg10.C3, m(), Neg10.I), java.lang.Exception
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/defaultMethods/Neg11.java b/test/tools/javac/defaultMethods/Neg11.java
new file mode 100644
index 0000000..acf88f6
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg11.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default overrides are properly type-checked
+ * @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java
+ */
+class Neg11 {
+    interface I {
+        default void m() { }
+    }
+
+    static class C1 {
+        public void m() throws Exception { } //bad throws
+    }
+
+    static class C2 extends C1 implements I { }
+
+    static class C3 implements I {
+        public void m() throws Exception { } //bad throws
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg11.out b/test/tools/javac/defaultMethods/Neg11.out
new file mode 100644
index 0000000..f85ac2d
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg11.out
@@ -0,0 +1,3 @@
+Neg11.java:15:12: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: m(), Neg11.C1, m(), Neg11.I), java.lang.Exception
+Neg11.java:18:21: compiler.err.override.meth.doesnt.throw: (compiler.misc.cant.implement: m(), Neg11.C3, m(), Neg11.I), java.lang.Exception
+2 errors
diff --git a/test/tools/javac/defaultMethods/Neg12.java b/test/tools/javac/defaultMethods/Neg12.java
new file mode 100644
index 0000000..e61245b
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg12.java
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that abstract methods are discarded in overload resolution diags
+ * @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java
+ */
+class Neg12 {
+
+    interface I1 {
+        default void m(String s) {};
+    }
+
+    interface I2 {
+        void m(String s);
+    }
+
+    static class B {
+        void m(Integer i) { }
+    }
+
+    static class C extends B implements I1 { }
+    static class D extends B implements I2 { }
+
+    void test(C c, D d) {
+        c.m();
+        d.m();
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg12.out b/test/tools/javac/defaultMethods/Neg12.out
new file mode 100644
index 0000000..8083d03
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg12.out
@@ -0,0 +1,4 @@
+Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
+Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
+Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
+3 errors
diff --git a/test/tools/javac/defaultMethods/Neg13.java b/test/tools/javac/defaultMethods/Neg13.java
new file mode 100644
index 0000000..e512cc3
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg13.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that default method overriding object members are flagged as error
+ * @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java
+ */
+interface Neg13 {
+    default protected Object clone() { return null; } //protected not allowed here
+    default boolean equals(Object obj) { return false; }
+    default protected void finalize() { } //protected not allowed here
+    default Class<?> getClass() { return null; }
+    default int hashCode() { return 0; }
+    default void notify() { }
+    default void notifyAll() { }
+    default String toString() { return null; }
+    default void wait() { }
+    default void wait(long timeout) { }
+    default void wait(long timeout, int nanos) { }
+}
diff --git a/test/tools/javac/defaultMethods/Neg13.out b/test/tools/javac/defaultMethods/Neg13.out
new file mode 100644
index 0000000..ce8bf03
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg13.out
@@ -0,0 +1,12 @@
+Neg13.java:7:30: compiler.err.mod.not.allowed.here: protected
+Neg13.java:9:28: compiler.err.mod.not.allowed.here: protected
+Neg13.java:8:21: compiler.err.default.overrides.object.member: equals, kindname.interface, Neg13
+Neg13.java:10:22: compiler.err.override.meth: (compiler.misc.cant.override: getClass(), Neg13, getClass(), java.lang.Object), final
+Neg13.java:11:17: compiler.err.default.overrides.object.member: hashCode, kindname.interface, Neg13
+Neg13.java:12:18: compiler.err.override.meth: (compiler.misc.cant.override: notify(), Neg13, notify(), java.lang.Object), final
+Neg13.java:13:18: compiler.err.override.meth: (compiler.misc.cant.override: notifyAll(), Neg13, notifyAll(), java.lang.Object), final
+Neg13.java:14:20: compiler.err.default.overrides.object.member: toString, kindname.interface, Neg13
+Neg13.java:15:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(), Neg13, wait(), java.lang.Object), final
+Neg13.java:16:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(long), Neg13, wait(long), java.lang.Object), final
+Neg13.java:17:18: compiler.err.override.meth: (compiler.misc.cant.override: wait(long,int), Neg13, wait(long,int), java.lang.Object), final
+11 errors
diff --git a/test/tools/javac/defaultMethods/Neg14.java b/test/tools/javac/defaultMethods/Neg14.java
new file mode 100644
index 0000000..9c3c6a6
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg14.java
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that a class cannot have two sibling interfaces with a default and abstract method
+ * @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java
+ */
+class Neg14 {
+    interface IA { int m(); }
+    interface IB { default int m() { return 1; } }
+
+    abstract class AB implements IA, IB {}
+}
diff --git a/test/tools/javac/defaultMethods/Neg14.out b/test/tools/javac/defaultMethods/Neg14.out
new file mode 100644
index 0000000..0d595aa
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg14.out
@@ -0,0 +1,2 @@
+Neg14.java:10:14: compiler.err.types.incompatible.abstract.default: kindname.class, Neg14.AB, m, , Neg14.IB, Neg14.IA
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg15.java b/test/tools/javac/defaultMethods/Neg15.java
new file mode 100644
index 0000000..7c42167
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg15.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that level skipping in default super calls is correctly rejected
+ * @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java
+ */
+class Neg15 {
+    interface I { default void m() {  } }
+    interface J extends I { default void m() {  } }
+    interface K extends I {}
+
+    static class C implements J, K {
+        void foo() { K.super.m(); }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg15.out b/test/tools/javac/defaultMethods/Neg15.out
new file mode 100644
index 0000000..c649eb5
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg15.out
@@ -0,0 +1,2 @@
+Neg15.java:12:31: compiler.err.illegal.default.super.call: Neg15.K, (compiler.misc.overridden.default: m(), Neg15.J)
+1 error
diff --git a/test/tools/javac/defaultMethods/Neg16.java b/test/tools/javac/defaultMethods/Neg16.java
new file mode 100644
index 0000000..1022fda
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg16.java
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that level skipping in default super calls is correctly rejected
+ * @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java
+ */
+class Neg16 {
+    interface I { default void m() {  } }
+    interface J extends I { default void m() {  } }
+
+    static class C implements I, J {
+        void foo() { I.super.m(); }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Neg16.out b/test/tools/javac/defaultMethods/Neg16.out
new file mode 100644
index 0000000..13490e3
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Neg16.out
@@ -0,0 +1,2 @@
+Neg16.java:11:23: compiler.err.illegal.default.super.call: Neg16.I, (compiler.misc.redundant.supertype: Neg16.I, Neg16.J)
+1 error
diff --git a/test/tools/javac/defaultMethods/Pos01.java b/test/tools/javac/defaultMethods/Pos01.java
new file mode 100644
index 0000000..13fa6b4
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos01.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 basic test for default methods
+ * @author  Maurizio Cimadamore
+ */
+
+import java.util.*;
+
+public class Pos01 {
+
+    interface Mapper<T> {
+        T map(T in);
+    }
+
+    interface ExtendedList<T> extends List<T> {
+        default List<T> testMap(Mapper<T> r) {
+            return Pos01.<T>listMapper(this, r);
+        }
+    }
+
+    static class MyList<E> extends ArrayList<E> implements ExtendedList<E> {}
+
+    public static void main(String[] args) {
+       MyList<Integer> l = new MyList<Integer>();
+       l.add(1); l.add(2); l.add(3);
+       l.testMap((Integer x) -> x * x );
+    }
+
+    static <T> List<T> listMapper(List<T> l, Mapper<T> mapper) {
+        MyList<T> new_list = new MyList<T>();
+        for (T el : l) {
+            new_list.add(mapper.map(el));
+        }
+        return new_list;
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Pos02.java b/test/tools/javac/defaultMethods/Pos02.java
new file mode 100644
index 0000000..597e7f5
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos02.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ * 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 test for explicit resolution of ambiguous default methods
+ * @author  Maurizio Cimadamore
+ * @compile Pos02.java
+ */
+
+class Pos02 {
+    interface IA { default int m() { return Pos02.m1(this); } }
+    interface IB { default int m() { return Pos02.m2(this); } }
+
+    static class A implements IA {}
+    static class B implements IB {}
+
+    static class AB implements IA, IB {
+        public int m() { return 0; }
+        void test() {
+            AB.this.m();
+            IA.super.m();
+        }
+    }
+
+    static int m1(IA a) { return 0; }
+    static int m2(IB b) { return 0; }
+}
diff --git a/test/tools/javac/defaultMethods/Pos04.java b/test/tools/javac/defaultMethods/Pos04.java
new file mode 100644
index 0000000..3cc0cd4
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos04.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ *
+ * 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 test for overriding with default method
+ * @author  Maurizio Cimadamore
+ * @compile Pos04.java
+ */
+
+class Pos04 {
+    interface A { default int m() { return Pos04.m(this); } }
+    static abstract class B { public int m() { return 0; } }
+
+    static class C extends B implements A {
+        void test() {
+            C.this.m();
+            A.super.m();
+        }
+    }
+
+    static int m(A a) { return 0; }
+}
diff --git a/test/tools/javac/defaultMethods/Pos05.java b/test/tools/javac/defaultMethods/Pos05.java
new file mode 100644
index 0000000..92a7eac
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos05.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 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 check that indirectly inherited default methods are discovered during resolution
+ * @author  Maurizio Cimadamore
+ * @compile Pos05.java
+ */
+
+class Pos05  {
+     interface A {
+         default void m() { Pos05.impl(this); }
+     }
+
+     interface B extends A { }
+
+     static class E implements B { }
+
+     void test(E e) {
+         e.m();
+     }
+
+     static void impl(A a) { }
+}
diff --git a/test/tools/javac/defaultMethods/Pos06.java b/test/tools/javac/defaultMethods/Pos06.java
new file mode 100644
index 0000000..3263e92
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos06.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 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 check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities)
+ * @author  Maurizio Cimadamore
+ * @compile Pos06.java
+ */
+
+class Pos06 {
+     interface A {
+         default void m() { Pos06.impl(this); }
+     }
+
+     interface B extends A {
+         default void m() { Pos06.impl(this); }
+     }
+
+     static class X implements A, B { }
+
+     void test(X x) {
+         x.m();
+         ((A)x).m();
+         ((B)x).m();
+     }
+
+     static void impl(Object a) { }
+}
diff --git a/test/tools/javac/defaultMethods/Pos07.java b/test/tools/javac/defaultMethods/Pos07.java
new file mode 100644
index 0000000..6e1c230
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos07.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, 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 check that compilation order does not matter
+ * @author  Maurizio Cimadamore
+ * @compile Pos07.java
+ */
+
+class Pos07 {
+    interface A {
+         default void foo() { Pos07.impl(this); }
+         default void bar() { Pos07.impl(this); }
+    }
+
+    static class C implements B, A {}
+
+    interface B extends A {
+        default void foo() { Pos07.impl(this); }
+    }
+
+    static void impl(A a) {}
+}
diff --git a/test/tools/javac/defaultMethods/Pos08.java b/test/tools/javac/defaultMethods/Pos08.java
new file mode 100644
index 0000000..b12486a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos08.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 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 check that common overrider solves default method conflicts
+ * @author  Maurizio Cimadamore
+ * @compile Pos08.java
+ */
+
+class Pos08 {
+    interface A {
+        default void m() { Pos08.a(this); }
+    }
+
+    interface B {
+        default void m() { Pos08.b(this); }
+    }
+
+    interface C extends A, B {
+        default void m() { Pos08.b(this); }
+    }
+
+    static void a(A o) { }
+    static void b(B o) { }
+}
diff --git a/test/tools/javac/defaultMethods/Pos10.java b/test/tools/javac/defaultMethods/Pos10.java
new file mode 100644
index 0000000..7f0039a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos10.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 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 check that type-variables in generic extension decl can be accessed from default impl
+ * @author  Maurizio Cimadamore
+ * @compile Pos10.java
+ */
+
+class Pos10 {
+    interface Function<X,Y> {
+        Y apply(X x);
+    }
+
+    interface A<T> {
+        default <R> void m(Function<T,R> f) { Impl.<T,R>m(this, f); }
+    }
+
+    static class Impl {
+        static <T,R> void m(A<T> a, Function<T,R> f) {  }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Pos11.java b/test/tools/javac/defaultMethods/Pos11.java
new file mode 100644
index 0000000..91b83cc
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos11.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2010, 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 complex test with conflict resolution via overriding
+ * @author  Brian Goetz
+ * @compile Pos11.java
+ */
+
+class Pos11 {
+    interface A {
+        default void get() { Pos11.one(this); }
+    }
+
+    interface B {
+        default void get() { Pos11.two(this); }
+    }
+
+    interface C extends A {
+        default void get() { Pos11.two(this); }
+    }
+
+    interface D extends A, B {
+        default void get() { Pos11.two(this); }
+    }
+
+    static class X implements C { }
+
+    static class Y implements C, A { }
+
+    static class Z implements D, A, B { }
+
+    static void one(Object a) {  }
+    static void two(Object a) {  }
+}
diff --git a/test/tools/javac/defaultMethods/Pos12.java b/test/tools/javac/defaultMethods/Pos12.java
new file mode 100644
index 0000000..4db7f3c
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos12.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 check that 'this' can be used from within an extension method
+ * @compile Pos12.java
+ */
+
+interface Pos12 {
+
+    default Object m() {
+        Object o = this;
+        f(this);
+        return this;
+    }
+
+    void f(Object o);
+}
diff --git a/test/tools/javac/defaultMethods/Pos13.java b/test/tools/javac/defaultMethods/Pos13.java
new file mode 100644
index 0000000..b9acba3
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos13.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ * 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 qualified 'this' inside default method causes StackOverflowException
+ * @compile Pos13.java
+ */
+
+public class Pos13 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Outer {
+        abstract void doSomething();
+
+        default void m() {
+            new SubOuter() {
+                public void doSomething() {
+                    Outer.this.doSomething();
+                }
+            }.doSomething();
+        }
+    }
+
+    interface SubOuter extends Outer { }
+
+    static class E implements Outer {
+        public void doSomething() { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        new E().m();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Pos14.java b/test/tools/javac/defaultMethods/Pos14.java
new file mode 100644
index 0000000..d8ac04a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos14.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 check that overload resolution selects most specific signature
+ * @compile Pos14.java
+ */
+
+class Pos14 {
+    interface A { default Object m() { return null; } }
+    static abstract class B { abstract public String m(); }
+
+    static abstract class C extends B implements A {
+        void test() {
+            m().length();
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Pos15.java b/test/tools/javac/defaultMethods/Pos15.java
new file mode 100644
index 0000000..a2dad21
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos15.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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 check that overload resolution selects most specific signature
+ * @compile Pos15.java
+ */
+
+class Pos15 {
+    interface A { default String m() { return null; } }
+    static abstract class B { abstract public Object m(); }
+
+    static abstract class C extends B implements A {
+        void test() {
+            m().length();
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/Pos16.java b/test/tools/javac/defaultMethods/Pos16.java
new file mode 100644
index 0000000..eca63b9
--- /dev/null
+++ b/test/tools/javac/defaultMethods/Pos16.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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 'class wins' should not short-circuit overload resolution
+ * @compile Pos16.java
+ */
+
+class Pos16 {
+    interface I {
+        default String m(Integer i) { return ""; }
+    }
+
+    class C implements I {
+        Integer m(Object o) { return 1; }
+    }
+
+    void test(C c) {
+        c.m(1).length();
+    }
+}
diff --git a/test/tools/javac/defaultMethods/TestDefaultBody.java b/test/tools/javac/defaultMethods/TestDefaultBody.java
new file mode 100644
index 0000000..be3f6bf
--- /dev/null
+++ b/test/tools/javac/defaultMethods/TestDefaultBody.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, 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  check that code attributed for default methods is correctly generated
+ */
+
+import com.sun.tools.classfile.AccessFlags;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.Method;
+
+import com.sun.tools.classfile.Opcode;
+import java.io.*;
+
+public class TestDefaultBody {
+
+    interface TestInterface {
+        int no_default(int i);
+        default int yes_default(int i) { return impl(this, i); }
+    }
+
+    static int impl(TestInterface ti, int i) { return 0; }
+
+    static final String TARGET_CLASS_NAME = "TestDefaultBody";
+    static final String TARGET_NAME = "impl";
+    static final String TARGET_TYPE = "(LTestDefaultBody$TestInterface;I)I";
+    static final String SUBTEST_NAME = TestInterface.class.getName() + ".class";
+    static final String TEST_METHOD_NAME = "yes_default";
+
+    public static void main(String... args) throws Exception {
+        new TestDefaultBody().run();
+    }
+
+    public void run() throws Exception {
+        String workDir = System.getProperty("test.classes");
+        File compiledTest = new File(workDir, SUBTEST_NAME);
+        verifyDefaultBody(compiledTest);
+    }
+
+    void verifyDefaultBody(File f) {
+        System.err.println("verify: " + f);
+        try {
+            ClassFile cf = ClassFile.read(f);
+            Method testMethod = null;
+            Code_attribute codeAttr = null;
+            for (Method m : cf.methods) {
+                codeAttr = (Code_attribute)m.attributes.get(Attribute.Code);
+                String mname = m.getName(cf.constant_pool);
+                if (mname.equals(TEST_METHOD_NAME)) {
+                    testMethod = m;
+                    break;
+                } else {
+                    codeAttr = null;
+                }
+            }
+            if (testMethod == null) {
+                throw new Error("Test method not found");
+            }
+            if (testMethod.access_flags.is(AccessFlags.ACC_ABSTRACT)) {
+                throw new Error("Test method is abstract");
+            }
+            if (codeAttr == null) {
+                throw new Error("Code attribute in test method not found");
+            }
+
+            boolean found = false;
+            for (Instruction instr : codeAttr.getInstructions()) {
+                if (instr.getOpcode() == Opcode.INVOKESTATIC) {
+                    found = true;
+                    int pc_index = instr.getShort(1);
+                    CONSTANT_Methodref_info mref = (CONSTANT_Methodref_info)cf.constant_pool.get(pc_index);
+                    String className = mref.getClassName();
+                    String targetName = mref.getNameAndTypeInfo().getName();
+                    String targetType = mref.getNameAndTypeInfo().getType();
+
+                    if (!className.equals(TARGET_CLASS_NAME)) {
+                        throw new Error("unexpected class in default method body " + className);
+                    }
+                    if (!targetName.equals(TARGET_NAME)) {
+                        throw new Error("unexpected method name in default method body " + targetName);
+                    }
+                    if (!targetType.equals(TARGET_TYPE)) {
+                        throw new Error("unexpected method type in default method body " + targetType);
+                    }
+                    break;
+                }
+            }
+
+            if (!found) {
+                throw new Error("no invokestatic found in default method body");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + f +": " + e);
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java b/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java
new file mode 100644
index 0000000..328629c
--- /dev/null
+++ b/test/tools/javac/defaultMethods/TestNoBridgeOnDefaults.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011, 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  check that javac does not generate bridge methods for defaults
+ */
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Method;
+
+import java.io.*;
+
+public class TestNoBridgeOnDefaults {
+
+    interface A<X> {
+        default <Y> A<X> m(X x, Y y) { return Impl.<X,Y>m1(this, x, y); }
+    }
+
+    static abstract class B<X> implements A<X> { }
+
+    interface C<X> extends A<X> {
+        default <Y> C<X> m(X x, Y y) { return Impl.<X,Y>m2(this, x, y); }
+    }
+
+    static abstract class D<X> extends B<X> implements C<X> { }
+
+    static class Impl {
+       static <X, Y> A<X> m1(A<X> rec, X x, Y y) { return null; }
+       static <X, Y> C<X> m2(C<X> rec, X x, Y y) { return null; }
+    }
+
+    static final String[] SUBTEST_NAMES = { B.class.getName() + ".class", D.class.getName() + ".class" };
+    static final String TEST_METHOD_NAME = "m";
+
+    public static void main(String... args) throws Exception {
+        new TestNoBridgeOnDefaults().run();
+    }
+
+    public void run() throws Exception {
+        String workDir = System.getProperty("test.classes");
+        for (int i = 0 ; i < SUBTEST_NAMES.length ; i ++) {
+            File compiledTest = new File(workDir, SUBTEST_NAMES[i]);
+            checkNoBridgeOnDefaults(compiledTest);
+        }
+    }
+
+    void checkNoBridgeOnDefaults(File f) {
+        System.err.println("check: " + f);
+        try {
+            ClassFile cf = ClassFile.read(f);
+            for (Method m : cf.methods) {
+                String mname = m.getName(cf.constant_pool);
+                if (mname.equals(TEST_METHOD_NAME)) {
+                    throw new Error("unexpected bridge method found " + m);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + f +": " + e);
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/crossCompile/Clinit.java b/test/tools/javac/defaultMethods/crossCompile/Clinit.java
new file mode 100644
index 0000000..60dc4f4
--- /dev/null
+++ b/test/tools/javac/defaultMethods/crossCompile/Clinit.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+interface Clinit {
+    String s = Inner.m();
+
+    static class Inner {
+        static String m() { return ""; }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java b/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java
new file mode 100644
index 0000000..de51d4a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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 check that clinit in interface doesn't cause spurious default method diagnostics
+ * @compile -source 1.4 -target 1.4 Clinit.java
+ * @compile CrossCompile.java
+ */
+class CrossCompile {
+   void test() {
+        String s = Clinit.s;
+   }
+}
diff --git a/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java b/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java
new file mode 100644
index 0000000..566780d
--- /dev/null
+++ b/test/tools/javac/defaultMethods/defaultMethodExecution/DefaultMethodRegressionTests.java
@@ -0,0 +1,138 @@
+/*
+ * 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.  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
+ * @ignore 8007517: DefaultMethodRegressionTests.java fail in TL
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng DefaultMethodRegressionTests
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+/**
+ * This set of classes/interfaces (K/I/C) is specially designed to expose a
+ * bug in the JVM where it did not find some overloaded methods in some
+ * specific situations. (fixed by hotspot changeset ffb9316fd9ed)
+ */
+interface K {
+    int bbb(Long l);
+}
+
+interface I extends K {
+    default void aaa() {}
+    default void aab() {}
+    default void aac() {}
+
+    default int bbb(Integer i) { return 22; }
+    default int bbb(Float f) { return 33; }
+    default int bbb(Long l) { return 44; }
+    default int bbb(Double d) { return 55; }
+    default int bbb(String s) { return 66; }
+
+    default void caa() {}
+    default void cab() {}
+    default void cac() {}
+}
+
+class C implements I {}
+
+public class DefaultMethodRegressionTests {
+
+    @Test(groups = "vm")
+    public void testLostOverloadedMethod() {
+        C c = new C();
+        assertEquals(c.bbb(new Integer(1)), 22);
+        assertEquals(c.bbb(new Float(1.1)), 33);
+        assertEquals(c.bbb(new Long(1L)), 44);
+        assertEquals(c.bbb(new Double(0.01)), 55);
+        assertEquals(c.bbb(new String("")), 66);
+    }
+
+    // Test to ensure that the inference verifier accepts older classfiles
+    // with classes that implement interfaces with defaults.
+    @Test(groups = "vm")
+    public void testInferenceVerifier() {
+        // interface I { int m() default { return 99; } }
+        byte I_bytes[] = {
+            (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x33,
+            0x00, 0x08, 0x07, 0x00, 0x06, 0x07, 0x00, 0x07,
+            0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x01, 0x00,
+            0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x04, 0x43,
+            0x6f, 0x64, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01,
+            0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+            0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+            0x63, 0x74, 0x06, 0x00, 0x00, 0x01, 0x00, 0x02,
+            0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01,
+            0x00, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x05,
+            0x00, 0x00, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x01,
+            0x00, 0x00, 0x00, 0x03, 0x10, 0x63, (byte)0xac, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00
+        };
+        // public class C implements I {}  /* -target 1.5 */
+        byte C_bytes[] = {
+            (byte)0xca, (byte)0xfe, (byte)0xba, (byte)0xbe, 0x00, 0x00, 0x00, 0x31,
+            0x00, 0x0c, 0x0a, 0x00, 0x03, 0x00, 0x08, 0x07,
+            0x00, 0x09, 0x07, 0x00, 0x0a, 0x07, 0x00, 0x0b,
+            0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74,
+            0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01,
+            0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0c, 0x00,
+            0x05, 0x00, 0x06, 0x01, 0x00, 0x01, 0x43, 0x01,
+            0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c,
+            0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65,
+            0x63, 0x74, 0x01, 0x00, 0x01, 0x49, 0x00, 0x21,
+            0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04,
+            0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x05,
+            0x00, 0x06, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00,
+            0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
+            0x00, 0x05, 0x2a, (byte)0xb7, 0x00, 0x01, (byte)0xb1, 0x00,
+            0x00, 0x00, 0x00, 0x00, 0x00
+        };
+
+        ClassLoader cl = new ClassLoader() {
+            protected Class<?> findClass(String name) {
+                if (name.equals("I")) {
+                    return defineClass("I", I_bytes, 0, I_bytes.length);
+                } else if (name.equals("C")) {
+                    return defineClass("C", C_bytes, 0, C_bytes.length);
+                } else {
+                    return null;
+                }
+            }
+        };
+        try {
+            Class.forName("C", true, cl);
+        } catch (Exception e) {
+            // unmodified verifier will throw VerifyError
+            fail("No exception should be thrown");
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/separate/Separate.java b/test/tools/javac/defaultMethods/separate/Separate.java
new file mode 100644
index 0000000..7dcf4e3
--- /dev/null
+++ b/test/tools/javac/defaultMethods/separate/Separate.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 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 smoke test for separate compilation of default methods
+ * @author  Maurizio Cimadamore
+ * @compile  pkg1/A.java
+ * @compile  Separate.java
+ */
+
+import pkg1.A;
+
+class Separate {
+    interface B extends A.I {
+        default void m() { A.m(this); }
+    }
+
+    interface C extends A.I, B { }
+}
diff --git a/test/tools/javac/defaultMethods/separate/pkg1/A.java b/test/tools/javac/defaultMethods/separate/pkg1/A.java
new file mode 100644
index 0000000..2430179
--- /dev/null
+++ b/test/tools/javac/defaultMethods/separate/pkg1/A.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 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 pkg1;
+
+public class A {
+    public interface I {
+        default void m() { A.m(this); }
+    }
+
+    public static void m(Object o) {}
+}
diff --git a/test/tools/javac/defaultMethods/static/Static01.java b/test/tools/javac/defaultMethods/static/Static01.java
new file mode 100644
index 0000000..d1e1b3a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/Static01.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          smoke test for static interface methods
+ * @compile -XDallowStaticInterfaceMethods Static01.java
+ */
+public class Static01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface I {
+        public static void test() {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        I.test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/Static02.java b/test/tools/javac/defaultMethods/static/Static02.java
new file mode 100644
index 0000000..e539e58
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/Static02.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          smoke test for static interface methods
+ * @compile/fail/ref=Static02.out -XDrawDiagnostics -XDallowStaticInterfaceMethods Static02.java
+ */
+class Static02 {
+
+    interface I {
+        public static void test() { }
+    }
+
+    public static void main(String[] args) {
+        I.test(); //ok
+        I i = new I() {};
+        i.test(); //no!
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/Static02.out b/test/tools/javac/defaultMethods/static/Static02.out
new file mode 100644
index 0000000..10a5722
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/Static02.out
@@ -0,0 +1,2 @@
+Static02.java:40:15: compiler.err.illegal.static.intf.meth.call: Static02.I
+1 error
diff --git a/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java
new file mode 100644
index 0000000..6a14608
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/hiding/InterfaceMethodHidingTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          Smoke test for static interface method hiding
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class InterfaceMethodHidingTest {
+
+    static int checkCount = 0;
+
+    enum SignatureKind {
+        VOID_INTEGER("void m(Integer s)", "return;"),
+        STRING_INTEGER("String m(Integer s)", "return null;"),
+        VOID_STRING("void m(String s)", "return;"),
+        STRING_STRING("String m(String s)", "return null;");
+
+        String sigStr;
+        String retStr;
+
+        SignatureKind(String sigStr, String retStr) {
+            this.sigStr = sigStr;
+            this.retStr = retStr;
+        }
+
+        boolean overrideEquivalentWith(SignatureKind s2) {
+            switch (this) {
+                case VOID_INTEGER:
+                case STRING_INTEGER:
+                    return s2 == VOID_INTEGER || s2 == STRING_INTEGER;
+                case VOID_STRING:
+                case STRING_STRING:
+                    return s2 == VOID_STRING || s2 == STRING_STRING;
+                default:
+                    throw new AssertionError("bad signature kind");
+            }
+        }
+    }
+
+    enum MethodKind {
+        VIRTUAL("", "#M #S;"),
+        STATIC("static", "#M #S { #BE; #R }"),
+        DEFAULT("default", "#M #S { #BE; #R }");
+
+        String modStr;
+        String methTemplate;
+
+        MethodKind(String modStr, String methTemplate) {
+            this.modStr = modStr;
+            this.methTemplate = methTemplate;
+        }
+
+        boolean inherithed() {
+            return this != STATIC;
+        }
+
+        static boolean overrides(MethodKind mk1, SignatureKind sk1, MethodKind mk2, SignatureKind sk2) {
+            return sk1 == sk2 &&
+                    mk2.inherithed() &&
+                    mk1 != STATIC;
+        }
+
+        String getBody(BodyExpr be, SignatureKind sk) {
+            return methTemplate.replaceAll("#BE", be.bodyExprStr)
+                    .replaceAll("#R", sk.retStr)
+                    .replaceAll("#M", modStr)
+                    .replaceAll("#S", sk.sigStr);
+        }
+    }
+
+    enum BodyExpr {
+        NONE(""),
+        THIS("Object o = this");
+
+        String bodyExprStr;
+
+        BodyExpr(String bodyExprStr) {
+            this.bodyExprStr = bodyExprStr;
+        }
+
+        boolean allowed(MethodKind mk) {
+            return this == NONE ||
+                    mk != MethodKind.STATIC;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (MethodKind mk1 : MethodKind.values()) {
+            for (SignatureKind sk1 : SignatureKind.values()) {
+                for (BodyExpr be1 : BodyExpr.values()) {
+                    for (MethodKind mk2 : MethodKind.values()) {
+                        for (SignatureKind sk2 : SignatureKind.values()) {
+                            for (BodyExpr be2 : BodyExpr.values()) {
+                                for (MethodKind mk3 : MethodKind.values()) {
+                                    for (SignatureKind sk3 : SignatureKind.values()) {
+                                        for (BodyExpr be3 : BodyExpr.values()) {
+                                            new InterfaceMethodHidingTest(mk1, mk2, mk3, sk1, sk2, sk3, be1, be2, be3).run(comp, fm);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    MethodKind mk1, mk2, mk3;
+    SignatureKind sk1, sk2, sk3;
+    BodyExpr be1, be2, be3;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    InterfaceMethodHidingTest(MethodKind mk1, MethodKind mk2, MethodKind mk3,
+            SignatureKind sk1, SignatureKind sk2, SignatureKind sk3, BodyExpr be1, BodyExpr be2, BodyExpr be3) {
+        this.mk1 = mk1;
+        this.mk2 = mk2;
+        this.mk3 = mk3;
+        this.sk1 = sk1;
+        this.sk2 = sk2;
+        this.sk3 = sk3;
+        this.be1 = be1;
+        this.be2 = be2;
+        this.be3 = be3;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface Sup {\n" +
+                          "   default void sup() { }\n" +
+                          "}\n" +
+                          "interface A extends Sup {\n" +
+                          "   #M1\n" +
+                          "}\n" +
+                          "interface B extends A, Sup {\n" +
+                          "   #M2\n" +
+                          "}\n" +
+                          "interface C extends B, Sup {\n" +
+                          "   #M3\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#M1", mk1.getBody(be1, sk1))
+                    .replaceAll("#M2", mk2.getBody(be2, sk2))
+                    .replaceAll("#M3", mk3.getBody(be3, sk3));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                Arrays.asList("-XDallowStaticInterfaceMethods"), null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected =
+                !be1.allowed(mk1) || !be2.allowed(mk2) || !be3.allowed(mk3);
+
+        if (mk1.inherithed()) {
+            errorExpected |=
+                    sk2.overrideEquivalentWith(sk1) && !MethodKind.overrides(mk2, sk2, mk1, sk1) ||
+                    sk3.overrideEquivalentWith(sk1) && !MethodKind.overrides(mk3, sk3, mk1, sk1);
+        }
+
+        if (mk2.inherithed()) {
+            errorExpected |=
+                    sk3.overrideEquivalentWith(sk2) && !MethodKind.overrides(mk3, sk3, mk2, sk2);
+        }
+
+        checkCount++;
+        if (diagChecker.errorFound != errorExpected) {
+            throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
+                    "\nfound error: " + diagChecker.errorFound);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/import/StaticImport1.java b/test/tools/javac/defaultMethods/static/import/StaticImport1.java
new file mode 100644
index 0000000..e976a32
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/StaticImport1.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          Smoke test for static imports of static interface methods
+ * @compile -XDallowStaticInterfaceMethods StaticImport1.java
+ */
+
+import static pkg.A.*;
+
+class StaticImport1 {
+    void test() {
+        m();
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/import/StaticImport2.java b/test/tools/javac/defaultMethods/static/import/StaticImport2.java
new file mode 100644
index 0000000..53ab19a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/StaticImport2.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          Smoke test for static imports of static interface methods
+ * @compile/fail/ref=StaticImport2.out -XDrawDiagnostics -XDallowStaticInterfaceMethods StaticImport2.java
+ */
+
+import static pkg.B.*;
+
+class StaticImport2 {
+    void test() {
+        m();
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/import/StaticImport2.out b/test/tools/javac/defaultMethods/static/import/StaticImport2.out
new file mode 100644
index 0000000..d21b3a9
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/StaticImport2.out
@@ -0,0 +1,2 @@
+StaticImport2.java:36:9: compiler.err.cant.resolve.location.args: kindname.method, m, , , (compiler.misc.location: kindname.class, StaticImport2, null)
+1 error
diff --git a/test/tools/javac/defaultMethods/static/import/StaticImport3.java b/test/tools/javac/defaultMethods/static/import/StaticImport3.java
new file mode 100644
index 0000000..2eb6b0a
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/StaticImport3.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 8005166
+ * @summary Add support for static interface methods
+ *          Smoke test for static imports of static interface methods
+ * @compile/fail/ref=StaticImport3.out -XDrawDiagnostics -XDallowStaticInterfaceMethods StaticImport3.java
+ */
+
+import static pkg.C.*;
+
+class StaticImport3 {
+    void test() {
+        m();
+    }
+}
diff --git a/test/tools/javac/defaultMethods/static/import/StaticImport3.out b/test/tools/javac/defaultMethods/static/import/StaticImport3.out
new file mode 100644
index 0000000..51bfb5d
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/StaticImport3.out
@@ -0,0 +1,2 @@
+StaticImport3.java:36:9: compiler.err.cant.resolve.location.args: kindname.method, m, , , (compiler.misc.location: kindname.class, StaticImport3, null)
+1 error
diff --git a/test/tools/javac/defaultMethods/static/import/pkg/A.java b/test/tools/javac/defaultMethods/static/import/pkg/A.java
new file mode 100644
index 0000000..d3f92fd
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/pkg/A.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * 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 interface A {
+    static void m() { }
+}
diff --git a/test/tools/javac/defaultMethods/static/import/pkg/B.java b/test/tools/javac/defaultMethods/static/import/pkg/B.java
new file mode 100644
index 0000000..5b28506
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/pkg/B.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * 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 interface B extends A { }
diff --git a/test/tools/javac/defaultMethods/static/import/pkg/C.java b/test/tools/javac/defaultMethods/static/import/pkg/C.java
new file mode 100644
index 0000000..46d5159
--- /dev/null
+++ b/test/tools/javac/defaultMethods/static/import/pkg/C.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * 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 C implements A { }
diff --git a/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java b/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java
new file mode 100644
index 0000000..9c3a513
--- /dev/null
+++ b/test/tools/javac/defaultMethods/super/TestDefaultSuperCall.java
@@ -0,0 +1,417 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8006694
+ * @summary Automatic test for checking correctness of default super/this resolution
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm TestDefaultSuperCall
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.util.JavacTask;
+
+public class TestDefaultSuperCall
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum InterfaceKind {
+        DEFAULT("interface A extends B { default void m() { } }"),
+        ABSTRACT("interface A extends B { void m(); }"),
+        NONE("interface A extends B { }");
+
+        String interfaceStr;
+
+        InterfaceKind(String interfaceStr) {
+            this.interfaceStr = interfaceStr;
+        }
+
+        boolean methodDefined() {
+            return this == DEFAULT;
+        }
+    }
+
+    enum PruneKind {
+        NO_PRUNE("interface C { }"),
+        PRUNE("interface C extends A { }");
+
+        boolean methodDefined(InterfaceKind ik) {
+            return this == PRUNE &&
+                    ik.methodDefined();
+        }
+
+        String interfaceStr;
+
+        PruneKind(String interfaceStr) {
+            this.interfaceStr = interfaceStr;
+        }
+    }
+
+    enum QualifierKind {
+        DIRECT_1("C"),
+        DIRECT_2("A"),
+        INDIRECT("B"),
+        UNRELATED("E"),
+        ENCLOSING_1(null),
+        ENCLOSING_2(null);
+
+        String qualifierStr;
+
+        QualifierKind(String qualifierStr) {
+            this.qualifierStr = qualifierStr;
+        }
+
+        String getQualifier(Shape sh) {
+            switch (this) {
+                case ENCLOSING_1: return sh.enclosingAt(0);
+                case ENCLOSING_2: return sh.enclosingAt(1);
+                default:
+                    return qualifierStr;
+            }
+        }
+
+        boolean isEnclosing() {
+            return this == ENCLOSING_1 ||
+                    this == ENCLOSING_2;
+        }
+
+        boolean allowSuperCall(InterfaceKind ik, PruneKind pk) {
+            switch (this) {
+                case DIRECT_1:
+                    return pk.methodDefined(ik);
+                case DIRECT_2:
+                    return ik.methodDefined() && pk == PruneKind.NO_PRUNE;
+                default:
+                    return false;
+            }
+        }
+    }
+
+    enum ExprKind {
+        THIS("this"),
+        SUPER("super");
+
+        String exprStr;
+
+        ExprKind(String exprStr) {
+            this.exprStr = exprStr;
+        }
+    }
+
+    enum ElementKind {
+        INTERFACE("interface #N { #B }", true),
+        INTERFACE_EXTENDS("interface #N extends A, C { #B }", true),
+        CLASS("class #N { #B }", false),
+        CLASS_EXTENDS("abstract class #N implements A, C { #B }", false),
+        STATIC_CLASS("static class #N { #B }", true),
+        STATIC_CLASS_EXTENDS("abstract static class #N implements A, C { #B }", true),
+        ANON_CLASS("new Object() { #B };", false),
+        METHOD("void test() { #B }", false),
+        STATIC_METHOD("static void test() { #B }", true),
+        DEFAULT_METHOD("default void test() { #B }", false);
+
+        String templateDecl;
+        boolean isStatic;
+
+        ElementKind(String templateDecl, boolean isStatic) {
+            this.templateDecl = templateDecl;
+            this.isStatic = isStatic;
+        }
+
+        boolean isClassDecl() {
+            switch(this) {
+                case METHOD:
+                case STATIC_METHOD:
+                case DEFAULT_METHOD:
+                    return false;
+                default:
+                    return true;
+            }
+        }
+
+        boolean isAllowedEnclosing(ElementKind ek, boolean isTop) {
+            switch (this) {
+                case CLASS:
+                case CLASS_EXTENDS:
+                    //class is implicitly static inside interface, so skip this combo
+                    return ek.isClassDecl() &&
+                            ek != INTERFACE && ek != INTERFACE_EXTENDS;
+                case ANON_CLASS:
+                    return !ek.isClassDecl();
+                case METHOD:
+                    return ek == CLASS || ek == CLASS_EXTENDS ||
+                            ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS ||
+                            ek == ANON_CLASS;
+                case INTERFACE:
+                case INTERFACE_EXTENDS:
+                case STATIC_CLASS:
+                case STATIC_CLASS_EXTENDS:
+                case STATIC_METHOD:
+                    return (isTop && (ek == CLASS || ek == CLASS_EXTENDS)) ||
+                            ek == STATIC_CLASS || ek == STATIC_CLASS_EXTENDS;
+                case DEFAULT_METHOD:
+                    return ek == INTERFACE || ek == INTERFACE_EXTENDS;
+                default:
+                    throw new AssertionError("Bad enclosing element kind" + this);
+            }
+        }
+
+        boolean isAllowedTop() {
+            switch (this) {
+                case CLASS:
+                case CLASS_EXTENDS:
+                case INTERFACE:
+                case INTERFACE_EXTENDS:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        boolean hasSuper() {
+            return this == INTERFACE_EXTENDS ||
+                    this == STATIC_CLASS_EXTENDS ||
+                    this == CLASS_EXTENDS;
+        }
+    }
+
+    static class Shape {
+
+        String shapeStr;
+        List<ElementKind> enclosingElements;
+        List<String> enclosingNames;
+        List<String> elementsWithMethod;
+
+        Shape(ElementKind... elements) {
+            enclosingElements = new ArrayList<>();
+            enclosingNames = new ArrayList<>();
+            elementsWithMethod = new ArrayList<>();
+            int count = 0;
+            String prevName = null;
+            for (ElementKind ek : elements) {
+                String name = "name"+count++;
+                if (ek.isStatic) {
+                    enclosingElements = new ArrayList<>();
+                    enclosingNames = new ArrayList<>();
+                }
+                if (ek.isClassDecl()) {
+                    enclosingElements.add(ek);
+                    enclosingNames.add(name);
+                } else {
+                    elementsWithMethod.add(prevName);
+                }
+                String element = ek.templateDecl.replaceAll("#N", name);
+                shapeStr = shapeStr ==
+                        null ? element : shapeStr.replaceAll("#B", element);
+                prevName = name;
+            }
+        }
+
+        String getShape(QualifierKind qk, ExprKind ek) {
+            String methName = ek == ExprKind.THIS ? "test" : "m";
+            String call = qk.getQualifier(this) + "." +
+                    ek.exprStr + "." + methName + "();";
+            return shapeStr.replaceAll("#B", call);
+        }
+
+        String enclosingAt(int index) {
+            return index < enclosingNames.size() ?
+                    enclosingNames.get(index) : "BAD";
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (InterfaceKind ik : InterfaceKind.values()) {
+            for (PruneKind pk : PruneKind.values()) {
+                for (ElementKind ek1 : ElementKind.values()) {
+                    if (!ek1.isAllowedTop()) continue;
+                    for (ElementKind ek2 : ElementKind.values()) {
+                        if (!ek2.isAllowedEnclosing(ek1, true)) continue;
+                        for (ElementKind ek3 : ElementKind.values()) {
+                            if (!ek3.isAllowedEnclosing(ek2, false)) continue;
+                            for (ElementKind ek4 : ElementKind.values()) {
+                                if (!ek4.isAllowedEnclosing(ek3, false)) continue;
+                                for (ElementKind ek5 : ElementKind.values()) {
+                                    if (!ek5.isAllowedEnclosing(ek4, false) ||
+                                            ek5.isClassDecl()) continue;
+                                    for (QualifierKind qk : QualifierKind.values()) {
+                                        for (ExprKind ek : ExprKind.values()) {
+                                            pool.execute(
+                                                    new TestDefaultSuperCall(ik, pk,
+                                                    new Shape(ek1, ek2, ek3,
+                                                    ek4, ek5), qk, ek));
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    InterfaceKind ik;
+    PruneKind pk;
+    Shape sh;
+    QualifierKind qk;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    TestDefaultSuperCall(InterfaceKind ik, PruneKind pk, Shape sh,
+            QualifierKind qk, ExprKind ek) {
+        this.ik = ik;
+        this.pk = pk;
+        this.sh = sh;
+        this.qk = qk;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface E {}\n" +
+                          "interface B { }\n" +
+                          "#I\n" +
+                          "#P\n" +
+                          "#C";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#I", ik.interfaceStr)
+                    .replaceAll("#P", pk.interfaceStr)
+                    .replaceAll("#C", sh.getShape(qk, ek));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            processException(ex);
+            return;
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected = false;
+
+        boolean badEnclosing = false;
+        boolean badThis = false;
+        boolean badSuper = false;
+
+        if (qk == QualifierKind.ENCLOSING_1 &&
+                sh.enclosingNames.size() < 1) {
+            errorExpected |= true;
+            badEnclosing = true;
+        }
+
+        if (qk == QualifierKind.ENCLOSING_2 &&
+                sh.enclosingNames.size() < 2) {
+            errorExpected |= true;
+            badEnclosing = true;
+        }
+
+        if (ek == ExprKind.THIS) {
+            boolean found = false;
+            for (int i = 0; i < sh.enclosingElements.size(); i++) {
+                if (sh.enclosingElements.get(i) == ElementKind.ANON_CLASS) continue;
+                if (sh.enclosingNames.get(i).equals(qk.getQualifier(sh))) {
+                    found = sh.elementsWithMethod.contains(sh.enclosingNames.get(i));
+                    break;
+                }
+            }
+            errorExpected |= !found;
+            if (!found) {
+                badThis = true;
+            }
+        }
+
+        if (ek == ExprKind.SUPER) {
+
+            int lastIdx = sh.enclosingElements.size() - 1;
+            boolean found = lastIdx == -1 ? false :
+                    sh.enclosingElements.get(lastIdx).hasSuper() &&
+                    qk.allowSuperCall(ik, pk);
+
+            errorExpected |= !found;
+            if (!found) {
+                badSuper = true;
+            }
+        }
+
+        checkCount.incrementAndGet();
+        if (diagChecker.errorFound != errorExpected) {
+            throw new AssertionError("Problem when compiling source:\n" +
+                    source.getCharContent(true) +
+                    "\nenclosingElems: " + sh.enclosingElements +
+                    "\nenclosingNames: " + sh.enclosingNames +
+                    "\nelementsWithMethod: " + sh.elementsWithMethod +
+                    "\nbad encl: " + badEnclosing +
+                    "\nbad this: " + badThis +
+                    "\nbad super: " + badSuper +
+                    "\nqual kind: " + qk +
+                    "\nfound error: " + diagChecker.errorFound);
+        }
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java b/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java
new file mode 100644
index 0000000..e720f37
--- /dev/null
+++ b/test/tools/javac/defaultMethods/syntax/TestDefaultMethodsSyntax.java
@@ -0,0 +1,287 @@
+/*
+ * 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.
+ *
+ * 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 7192245 8005851 8005166
+ * @summary Automatic test for checking set of allowed modifiers on interface methods
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class TestDefaultMethodsSyntax {
+
+    static int checkCount = 0;
+
+    enum VersionKind {
+        PRE_LAMBDA("7"),
+        LAMBDA("8");
+
+        String versionString;
+
+        VersionKind(String versionString) {
+            this.versionString = versionString;
+        }
+
+        List<String> getOptions() {
+            return Arrays.asList("-XDallowStaticInterfaceMethods", "-source", versionString);
+        }
+    }
+
+    enum ModifierKind {
+        NONE(""),
+        PUBLIC("public"),
+        PROTECTED("protected"),
+        PRIVATE("private"),
+        ABSTRACT("abstract"),
+        STATIC("static"),
+        NATIVE("native"),
+        SYNCHRONIZED("synchronized"),
+        FINAL("final"),
+        STRICTFP("strictfp"),
+        DEFAULT("default");
+
+        String modStr;
+
+        private ModifierKind(String modStr) {
+            this.modStr = modStr;
+        }
+
+        static boolean intersect(ModifierKind mk, ModifierKind... mks) {
+            for (ModifierKind mk2 : mks) {
+                if (mk == mk2) return true;
+            }
+            return false;
+        }
+
+        static boolean compatible(MethodKind mk, ModifierKind mod1, ModifierKind mod2, EnclosingKind ek) {
+            if (intersect(ABSTRACT, mod1, mod2) || intersect(NATIVE, mod1, mod2)) {
+                return mk == MethodKind.NO_BODY;
+            } else if (intersect(DEFAULT, mod1, mod2) || intersect(STATIC, mod1, mod2)) {
+                return mk == MethodKind.BODY;
+            } else {
+                return ek == EnclosingKind.INTERFACE ?
+                        mk == MethodKind.NO_BODY : mk == MethodKind.BODY;
+            }
+        }
+
+        boolean compatible(EnclosingKind ek) {
+            switch (this) {
+                case PRIVATE:
+                case PROTECTED:
+                    return ek != EnclosingKind.INTERFACE;
+                default:
+                    return true;
+            }
+        }
+
+        static boolean compatible(ModifierKind m1, ModifierKind m2, EnclosingKind ek) {
+            Result res1 = allowedModifierPairs[m1.ordinal()][m2.ordinal()];
+            Result res2 = allowedModifierPairs[m2.ordinal()][m1.ordinal()];
+            if (res1 != res2) {
+                throw new AssertionError(String.format("Ill-formed table: [%s,%s] != [%s,%s]", m1, m2, m2, m1));
+            } else {
+                return res1.compatible(ek, m1, m2);
+            }
+        }
+
+        interface Result {
+            boolean compatible(EnclosingKind ek, ModifierKind m1, ModifierKind m2);
+        }
+
+        static final Result T = new Result() {
+            @Override
+            public boolean compatible(EnclosingKind ek, ModifierKind m1, ModifierKind m2) {
+                return true;
+            }
+        };
+
+        static final Result F = new Result() {
+            @Override
+            public boolean compatible(EnclosingKind ek, ModifierKind m1, ModifierKind m2) {
+                return false;
+            }
+        };
+
+        static final Result C = new Result() {
+            @Override
+            public boolean compatible(EnclosingKind ek, ModifierKind m1, ModifierKind m2) {
+                return ek != EnclosingKind.INTERFACE;
+            }
+        };
+
+        static final Result I = new Result() {
+            @Override
+            public boolean compatible(EnclosingKind ek, ModifierKind m1, ModifierKind m2) {
+                return ek == EnclosingKind.INTERFACE;
+            }
+        };
+
+        static Result[][] allowedModifierPairs = {
+            /*                     NONE  PUBLIC  PROTECTED  PRIVATE  ABSTRACT  STATIC  NATIVE  SYNCHRONIZED  FINAL  STRICTFP  DEFAULT */
+            /* NONE */           { T   , T    , C        , C       , T       , T     , C     , C           , C    , C       , I   },
+            /* PUBLIC */         { T   , F    , F        , F       , T       , T     , C     , C           , C    , C       , I   },
+            /* PROTECTED */      { C   , F    , F        , F       , C       , C     , C     , C           , C    , C       , F   },
+            /* PRIVATE */        { C   , F    , F        , F       , F       , C     , C     , C           , C    , C       , F   },
+            /* ABSTRACT */       { T   , T    , C        , F       , F       , F     , F     , F           , F    , F       , F   },
+            /* STATIC */         { T   , T    , C        , C       , F       , F     , C     , C           , C    , T       , F   },
+            /* NATIVE */         { C   , C    , C        , C       , F       , C     , F     , C           , C    , F       , F   },
+            /* SYNCHRONIZED */   { C   , C    , C        , C       , F       , C     , C     , F           , C    , C       , F   },
+            /* FINAL */          { C   , C    , C        , C       , F       , C     , C     , C           , F    , C       , F   },
+            /* STRICTFP */       { C   , C    , C        , C       , F       , T     , F     , C           , C    , F       , I   },
+            /* DEFAULT */        { I   , I    , F        , F       , F       , F     , F     , F           , F    , I       , F   }};
+    }
+
+    enum MethodKind {
+        NO_BODY("void m();"),
+        BODY("void m() { }");
+
+        String methStr;
+
+        private MethodKind(String methStr) {
+            this.methStr = methStr;
+        }
+    }
+
+    enum EnclosingKind {
+        ABSTRACT_CLASS("abstract class Test "),
+        INTERFACE("interface Test ");
+
+        String enclStr;
+
+        EnclosingKind(String enclStr) {
+            this.enclStr = enclStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (VersionKind vk : VersionKind.values()) {
+            for (EnclosingKind ek : EnclosingKind.values()) {
+                for (MethodKind mk : MethodKind.values()) {
+                    for (ModifierKind modk1 : ModifierKind.values()) {
+                        for (ModifierKind modk2 : ModifierKind.values()) {
+                            new TestDefaultMethodsSyntax(vk, ek, mk, modk1, modk2).run(comp, fm);
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    VersionKind vk;
+    EnclosingKind ek;
+    MethodKind mk;
+    ModifierKind modk1, modk2;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    TestDefaultMethodsSyntax(VersionKind vk, EnclosingKind ek, MethodKind mk, ModifierKind modk1, ModifierKind modk2) {
+        this.vk = vk;
+        this.ek = ek;
+        this.mk = mk;
+        this.modk1 = modk1;
+        this.modk2 = modk2;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "#EK {\n" +
+                          "   #MOD1 #MOD2 #METH\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#EK", ek.enclStr)
+                    .replaceAll("#MOD1", modk1.modStr)
+                    .replaceAll("#MOD2", modk2.modStr)
+                    .replaceAll("#METH", mk.methStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                vk.getOptions(), null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected = !ModifierKind.compatible(modk1, modk2, ek);
+
+        errorExpected |= !ModifierKind.compatible(mk, modk1, modk2, ek);
+
+        errorExpected |= !modk1.compatible(ek) || !modk2.compatible(ek);
+
+        errorExpected |= ModifierKind.intersect(ModifierKind.DEFAULT, modk1, modk2) &&
+                vk == VersionKind.PRE_LAMBDA;
+
+        errorExpected |= ModifierKind.intersect(ModifierKind.STATIC, modk1, modk2) &&
+                ek == EnclosingKind.INTERFACE && vk == VersionKind.PRE_LAMBDA;
+
+        checkCount++;
+        if (diagChecker.errorFound != errorExpected) {
+            throw new AssertionError("Problem when compiling source:\n" + source.getCharContent(true) +
+                    "\nfound error: " + diagChecker.errorFound);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/depDocComment/DeprecatedDocComment3.java b/test/tools/javac/depDocComment/DeprecatedDocComment3.java
new file mode 100644
index 0000000..d7f4dbc
--- /dev/null
+++ b/test/tools/javac/depDocComment/DeprecatedDocComment3.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 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 7096014
+ * @summary Javac tokens should retain state
+ * @compile -Xlint -Werror DeprecatedDocComment3.java
+ */
+
+class DeprecatedDocComment3 {
+    static class Foo { }
+
+    ; /** @deprecated */ ;
+
+    static class A {}
+
+    static class B {
+       A a; //not deprecated!
+    }
+}
diff --git a/test/tools/javac/depDocComment/DeprecatedDocComment4.java b/test/tools/javac/depDocComment/DeprecatedDocComment4.java
new file mode 100644
index 0000000..9e7d936
--- /dev/null
+++ b/test/tools/javac/depDocComment/DeprecatedDocComment4.java
@@ -0,0 +1,20 @@
+/**
+ * @test  /nodynamiccopyright/
+ * @bug 7104201
+ * @summary Refactor DocCommentScanner
+ * @compile/fail/ref=DeprecatedDocComment4.out -XDrawDiagnostics -Werror -Xlint:dep-ann DeprecatedDocComment4.java
+ */
+
+class DeprecatedDocComment4 {
+    /** @deprecated **/
+    /* block */
+    void test1() {};
+
+    /** @deprecated **/
+    /** double javadoc */
+    void test2() {};
+
+    /** @deprecated **/
+    //line comment
+    void test3() {};
+}
diff --git a/test/tools/javac/depDocComment/DeprecatedDocComment4.out b/test/tools/javac/depDocComment/DeprecatedDocComment4.out
new file mode 100644
index 0000000..88622ac
--- /dev/null
+++ b/test/tools/javac/depDocComment/DeprecatedDocComment4.out
@@ -0,0 +1,6 @@
+DeprecatedDocComment4.java:11:10: compiler.warn.missing.deprecated.annotation
+DeprecatedDocComment4.java:15:10: compiler.warn.missing.deprecated.annotation
+DeprecatedDocComment4.java:19:10: compiler.warn.missing.deprecated.annotation
+- compiler.err.warnings.and.werror
+1 error
+3 warnings
diff --git a/test/tools/javac/diags/ArgTypeCompilerFactory.java b/test/tools/javac/diags/ArgTypeCompilerFactory.java
index 7945465..6c5ef03 100644
--- a/test/tools/javac/diags/ArgTypeCompilerFactory.java
+++ b/test/tools/javac/diags/ArgTypeCompilerFactory.java
@@ -35,7 +35,7 @@ import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.file.*;
 import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.main.JavaCompiler;
-import com.sun.tools.javac.parser.Token;
+import com.sun.tools.javac.parser.Tokens.TokenKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
 import javax.lang.model.SourceVersion;
@@ -105,13 +105,11 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
 
             Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
 
-            JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos);
-            Context c = t.getContext();
+            Context c = new Context();
             ArgTypeMessages.preRegister(c);
             ArgTypeJavaCompiler.preRegister(c);
-            Boolean ok = t.call();
-
-            return ok;
+            JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos, c);
+            return t.call();
         }
     }
 
@@ -146,9 +144,9 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
-            int result = main.compile(args.toArray(new String[args.size()]), c);
+            Main.Result result = main.compile(args.toArray(new String[args.size()]), c);
 
-            return (result == 0);
+            return result.isOK();
         }
     }
 
@@ -172,10 +170,10 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
-            com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
-            int rc = m.compile(args.toArray(new String[args.size()]), c);
+            Main m = new Main("javac", out);
+            Main.Result result = m.compile(args.toArray(new String[args.size()]), c);
 
-            return (rc == 0);
+            return result.isOK();
         }
 
     }
@@ -319,7 +317,7 @@ class ArgTypeCompilerFactory implements Example.Compiler.Factory {
             return "modifier";
         if (o instanceof KindName)
             return "symbol kind";
-        if (o instanceof Token)
+        if (o instanceof TokenKind)
             return "token";
         if (o instanceof Symbol)
             return "symbol";
diff --git a/test/tools/javac/diags/CheckExamples.java b/test/tools/javac/diags/CheckExamples.java
index 9bf63ee..60ddd3b 100644
--- a/test/tools/javac/diags/CheckExamples.java
+++ b/test/tools/javac/diags/CheckExamples.java
@@ -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
@@ -25,14 +25,17 @@
  * @test
  * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
- * @build Example CheckExamples
+ * @build Example CheckExamples DocCommentProcessor
  * @run main/othervm CheckExamples
  */
+
 /*
  *      See CR 7127924 for info on why othervm is used.
  */
 
 import java.io.*;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.util.*;
 
 /**
@@ -52,7 +55,27 @@ public class CheckExamples {
      * Standard entry point.
      */
     public static void main(String... args) throws Exception {
-        new CheckExamples().run();
+        boolean jtreg = (System.getProperty("test.src") != null);
+        Path tmpDir;
+        boolean deleteOnExit;
+        if (jtreg) {
+            // use standard jtreg scratch directory: the current directory
+            tmpDir = Paths.get(System.getProperty("user.dir"));
+            deleteOnExit = false;
+        } else {
+            tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir")),
+                    CheckExamples.class.getName());
+            deleteOnExit = true;
+        }
+        Example.setTempDir(tmpDir.toFile());
+
+        try {
+            new CheckExamples().run();
+        } finally {
+            if (deleteOnExit) {
+                clean(tmpDir);
+            }
+        }
     }
 
     /**
@@ -189,6 +212,25 @@ public class CheckExamples {
 
     int errors;
 
+    /**
+     * Clean the contents of a directory.
+     */
+    static void clean(Path dir) throws IOException {
+        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+            @Override
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+                Files.delete(file);
+                return super.visitFile(file, attrs);
+            }
+
+            @Override
+            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+                if (exc == null) Files.delete(dir);
+                return super.postVisitDirectory(dir, exc);
+            }
+        });
+    }
+
     static class Counts {
         static String[] prefixes = {
             "compiler.err.",
diff --git a/test/tools/javac/diags/CheckResourceKeys.java b/test/tools/javac/diags/CheckResourceKeys.java
index 80af58b..bb9e10b 100644
--- a/test/tools/javac/diags/CheckResourceKeys.java
+++ b/test/tools/javac/diags/CheckResourceKeys.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -185,6 +185,8 @@ public class CheckResourceKeys {
         "compiler.err.cant.resolve.args.params",
         "compiler.err.cant.resolve.location.args",
         "compiler.err.cant.resolve.location.args.params",
+        "compiler.misc.cant.resolve.location.args",
+        "compiler.misc.cant.resolve.location.args.params",
         // JavaCompiler, reports #errors and #warnings
         "compiler.misc.count.error",
         "compiler.misc.count.error.plural",
@@ -198,6 +200,7 @@ public class CheckResourceKeys {
 
 
     Set<String> needToInvestigate = new TreeSet<String>(Arrays.asList(
+        "compiler.misc.fatal.err.cant.close.loader",        // Supressed by JSR308
         "compiler.err.cant.read.file",                      // UNUSED
         "compiler.err.illegal.self.ref",                    // UNUSED
         "compiler.err.io.exception",                        // UNUSED
@@ -259,6 +262,7 @@ public class CheckResourceKeys {
             "application.home", // in Paths.java
             "env.class.path",
             "line.separator",
+            "os.name",
             "user.dir",
             // file names
             "ct.sym",
@@ -307,9 +311,8 @@ public class CheckResourceKeys {
                     pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
                 String name = fo.getName();
                 // ignore resource files, and files which are not really part of javac
-                if (name.contains("resources")
-                        || name.contains("Launcher.class")
-                        || name.contains("CreateSymbols.class"))
+                if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*")
+                        || name.matches(".*CreateSymbols\\.class.*"))
                     continue;
                 scan(fo, results);
             }
diff --git a/test/tools/javac/diags/DocCommentProcessor.java b/test/tools/javac/diags/DocCommentProcessor.java
new file mode 100644
index 0000000..bb41985
--- /dev/null
+++ b/test/tools/javac/diags/DocCommentProcessor.java
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ *
+ * 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.util.*;
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.ErroneousTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.tree.DocPretty;
+import java.io.PrintWriter;
+import javax.tools.Diagnostic;
+
+/**
+ * Standard annotation processor for use by examples to
+ * scan DocCommentTree nodes looking for ErroneousTree,
+ * on which to call {@code getMessage}.
+ */
+ at SupportedAnnotationTypes("*")
+public class DocCommentProcessor extends AbstractProcessor {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        trees = DocTrees.instance(pEnv);
+        messager = pEnv.getMessager();
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) {
+        for (Element e : rEnv.getRootElements()) {
+            new DocCommentScanner().scan(e);
+        }
+        return true;
+    }
+
+    class DocCommentScanner extends TreePathScanner<Void,Void> {
+        public void scan(Element e) {
+            scan(trees.getPath(e), null);
+        }
+
+        @Override
+        public Void visitClass(ClassTree tree, Void ignore) {
+            check();
+            return super.visitClass(tree, ignore);
+        }
+
+        @Override
+        public Void visitMethod(MethodTree tree, Void ignore) {
+            check();
+            return super.visitMethod(tree, ignore);
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void ignore) {
+            check();
+            return super.visitVariable(tree, ignore);
+        }
+
+        private void check() {
+            DocCommentTree dc = trees.getDocCommentTree(getCurrentPath());
+            if (dc == null)
+                return;
+
+            DocTreeScanner<Void, Void> s = new DocTreeScanner<Void, Void>() {
+                @Override
+                public Void visitErroneous(ErroneousTree tree, Void ignore) {
+                    messager.printMessage(Diagnostic.Kind.NOTE, tree.getDiagnostic().getMessage(null));
+                    return null;
+                }
+            };
+
+            s.scan(dc, null);
+        }
+
+    }
+
+    private DocTrees trees;
+    private Messager messager;
+}
diff --git a/test/tools/javac/diags/Example.java b/test/tools/javac/diags/Example.java
index 924bc16..b53b1aa 100644
--- a/test/tools/javac/diags/Example.java
+++ b/test/tools/javac/diags/Example.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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,6 +41,7 @@ import javax.tools.ToolProvider;
 
 import com.sun.tools.javac.api.ClientCodeWrapper;
 import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.JCDiagnostic;
@@ -208,6 +209,13 @@ class Example implements Comparable<Example> {
             opts.add("-classpath"); // avoid using -processorpath for now
             opts.add(classesDir.getPath());
             createAnnotationServicesFile(classesDir, procFiles);
+        } else if (options != null) {
+            int i = options.indexOf("-processor");
+            // check for built-in anno-processor(s)
+            if (i != -1 && options.get(i + 1).equals("DocCommentProcessor")) {
+                opts.add("-classpath");
+                opts.add(System.getProperty("test.classes"));
+            }
         }
 
         if (srcPathDir != null) {
@@ -288,7 +296,10 @@ class Example implements Comparable<Example> {
     private Set<String> actualKeys;
     private Set<String> declaredKeys;
 
-    static File tempDir = new File(System.getProperty("java.io.tmpdir"));
+    static File tempDir = (System.getProperty("test.src") != null) ?
+            new File(System.getProperty("user.dir")):
+            new File(System.getProperty("java.io.tmpdir"));
+
     static void setTempDir(File tempDir) {
         Example.tempDir = tempDir;
     }
@@ -515,14 +526,14 @@ class Example implements Comparable<Example> {
             Context c = new Context();
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
             MessageTracker.preRegister(c, keys);
-            com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", pw);
-            int rc = m.compile(args.toArray(new String[args.size()]), c);
+            Main m = new Main("javac", pw);
+            Main.Result rc = m.compile(args.toArray(new String[args.size()]), c);
 
             if (keys != null) {
                 pw.close();
             }
 
-            return (rc == 0);
+            return rc.isOK();
         }
 
         static class MessageTracker extends JavacMessages {
diff --git a/test/tools/javac/diags/MessageFile.java b/test/tools/javac/diags/MessageFile.java
index 72b7928..da4dc5c 100644
--- a/test/tools/javac/diags/MessageFile.java
+++ b/test/tools/javac/diags/MessageFile.java
@@ -65,7 +65,7 @@ class MessageFile {
         }
 
         void insertAfter(Line l) {
-            assert prev == null && next == null;
+            assert l.prev == null && l.next == null;
             l.prev = this;
             l.next = next;
             if (next == null)
@@ -82,7 +82,7 @@ class MessageFile {
         }
 
         void insertBefore(Line l) {
-            assert prev == null && next == null;
+            assert l.prev == null && l.next == null;
             l.prev = prev;
             l.next = this;
             if (prev == null)
diff --git a/test/tools/javac/diags/MessageInfo.java b/test/tools/javac/diags/MessageInfo.java
index 80809af..aaeaeed 100644
--- a/test/tools/javac/diags/MessageInfo.java
+++ b/test/tools/javac/diags/MessageInfo.java
@@ -409,5 +409,3 @@ public class MessageInfo {
     }
 
 }
-
-
diff --git a/test/tools/javac/diags/RunExamples.java b/test/tools/javac/diags/RunExamples.java
index 08e161c..788b46b 100644
--- a/test/tools/javac/diags/RunExamples.java
+++ b/test/tools/javac/diags/RunExamples.java
@@ -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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
- * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples
+ * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples DocCommentProcessor
  * @run main/othervm RunExamples
  */
 /*
@@ -33,7 +33,8 @@
  */
 
 import java.io.*;
-import java.text.SimpleDateFormat;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -56,16 +57,18 @@ import java.util.regex.Pattern;
 public class RunExamples {
     public static void main(String... args) throws Exception {
         jtreg = (System.getProperty("test.src") != null);
-        File tmpDir;
+        Path tmpDir;
+        boolean deleteOnExit;
         if (jtreg) {
             // use standard jtreg scratch directory: the current directory
-            tmpDir = new File(System.getProperty("user.dir"));
+            tmpDir = Paths.get(System.getProperty("user.dir"));
+            deleteOnExit = false;
         } else {
-            tmpDir = new File(System.getProperty("java.io.tmpdir"),
-                    RunExamples.class.getName()
-                    + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date()));
+            tmpDir = Files.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir")),
+                    RunExamples.class.getName());
+            deleteOnExit = true;
         }
-        Example.setTempDir(tmpDir);
+        Example.setTempDir(tmpDir.toFile());
 
         RunExamples r = new RunExamples();
 
@@ -73,15 +76,8 @@ public class RunExamples {
             if (r.run(args))
                 return;
         } finally {
-            /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
-             * jtreg scratch directory, which is the current directory.
-             * In case someone is faking jtreg mode, make sure to only
-             * clean tmpDir when it is reasonable to do so.
-             */
-            if (tmpDir.isDirectory() &&
-                    tmpDir.getName().startsWith(RunExamples.class.getName())) {
-                if (clean(tmpDir))
-                    tmpDir.delete();
+            if (deleteOnExit) {
+                clean(tmpDir);
             }
         }
 
@@ -203,14 +199,20 @@ public class RunExamples {
     /**
      * Clean the contents of a directory.
      */
-    static boolean clean(File dir) {
-        boolean ok = true;
-        for (File f: dir.listFiles()) {
-            if (f.isDirectory())
-                ok &= clean(f);
-            ok &= f.delete();
-        }
-        return ok;
+    static void clean(Path dir) throws IOException {
+        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+            @Override
+            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+                Files.delete(file);
+                return super.visitFile(file, attrs);
+            }
+
+            @Override
+            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
+                if (exc == null) Files.delete(dir);
+                return super.postVisitDirectory(dir, exc);
+            }
+        });
     }
 
     static abstract class Runner {
diff --git a/test/tools/javac/diags/examples.not-yet.txt b/test/tools/javac/diags/examples.not-yet.txt
index 199e26e..2e442f3 100644
--- a/test/tools/javac/diags/examples.not-yet.txt
+++ b/test/tools/javac/diags/examples.not-yet.txt
@@ -1,13 +1,14 @@
 compiler.err.already.annotated                          # internal compiler error?
 compiler.err.already.defined.this.unit                  # seems to be masked by compiler.err.duplicate.class
 compiler.err.annotation.value.not.allowable.type        # cannot happen: precluded by complete type-specific tests
-compiler.err.assignment.from.super-bound                # DEAD
-compiler.err.assignment.to.extends-bound                # DEAD
-compiler.err.cant.apply.symbol
+compiler.err.bad.functional.intf.anno                   # seems to be masked by compiler.err.annotation.type.not.applicable
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
+compiler.err.dc.unterminated.string                     # cannot happen
 compiler.err.illegal.char.for.encoding
-compiler.err.internal.error.cant.instantiate            # Attr: should not happen
+compiler.err.invalid.repeatable.annotation              # should not happen
+compiler.err.invalid.repeatable.annotation.invalid.value # "can't" happen
+compiler.err.invalid.repeatable.annotation.multiple.values # can't happen
 compiler.err.io.exception                               # (javah.JavahTask?)
 compiler.err.limit.code                                 # Code
 compiler.err.limit.code.too.large.for.try.stmt          # Gen
@@ -24,14 +25,12 @@ compiler.err.no.annotation.member
 compiler.err.no.encl.instance.of.type.in.scope          # cannot occur; always followed by assert false;
 compiler.err.no.match.entry                             # UNUSED?
 compiler.err.not.annotation.type                        # cannot occur given preceding checkType
-compiler.err.prob.found.req.1                           # Check: DEAD, in unused method
 compiler.err.proc.bad.config.file                       # JavacProcessingEnvironment
 compiler.err.proc.cant.access                           # completion failure
 compiler.err.proc.cant.access.1                         # completion failure, no stack trace
 compiler.err.proc.cant.create.loader                    # security exception from service loader
 compiler.err.proc.no.service                            # JavacProcessingEnvironment: no service loader available
 compiler.err.proc.processor.bad.option.name             # cannot happen? masked by javac.err.invalid.A.key
-compiler.err.proc.processor.constructor.error
 compiler.err.proc.service.problem                       # JavacProcessingEnvironment: catch Throwable from service loader
 compiler.err.signature.doesnt.match.intf                # UNUSED
 compiler.err.signature.doesnt.match.supertype           # UNUSED
@@ -39,12 +38,8 @@ compiler.err.source.cant.overwrite.input.file
 compiler.err.stack.sim.error
 compiler.err.type.var.more.than.once                    # UNUSED
 compiler.err.type.var.more.than.once.in.result          # UNUSED
-compiler.err.undetermined.type
 compiler.err.unexpected.type
 compiler.err.unsupported.cross.fp.lit                   # Scanner: host system dependent
-compiler.err.wrong.target.for.polymorphic.signature.definition     # Transitional 292
-compiler.misc.assignment.from.super-bound
-compiler.misc.assignment.to.extends-bound
 compiler.misc.bad.class.file.header                     # bad class file
 compiler.misc.bad.class.signature                       # bad class file
 compiler.misc.bad.const.pool.tag                        # bad class file
@@ -53,6 +48,7 @@ compiler.misc.bad.enclosing.class                       # bad class file
 compiler.misc.bad.enclosing.method                      # bad class file
 compiler.misc.bad.runtime.invisible.param.annotations   # bad class file
 compiler.misc.bad.signature                             # bad class file
+compiler.misc.bad.type.annotation.value
 compiler.misc.base.membership                           # UNUSED
 compiler.misc.ccf.found.later.version
 compiler.misc.ccf.unrecognized.attribute
@@ -61,9 +57,10 @@ compiler.misc.class.file.wrong.class
 compiler.misc.fatal.err.cant.locate.ctor                # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.field               # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.meth                # Resolve, from Lower
-compiler.misc.fatal.err.cant.close.loader               # JavacProcessingEnvironment
+compiler.misc.fatal.err.cant.close	                # JavaCompiler
 compiler.misc.file.does.not.contain.package
 compiler.misc.illegal.start.of.class.file
+compiler.misc.inferred.do.not.conform.to.lower.bounds   # cannot happen?
 compiler.misc.kindname.annotation
 compiler.misc.kindname.enum
 compiler.misc.kindname.package
@@ -71,7 +68,9 @@ compiler.misc.kindname.static
 compiler.misc.kindname.type.variable
 compiler.misc.kindname.type.variable.bound
 compiler.misc.kindname.value
+compiler.misc.incompatible.eq.lower.bounds              # cannot happen?
 compiler.misc.no.unique.minimal.instance.exists
+compiler.misc.no.unique.maximal.instance.exists         # cannot happen?
 compiler.misc.resume.abort                              # prompt for a response
 compiler.misc.source.unavailable                        # DiagnosticSource
 compiler.misc.token.bad-symbol
@@ -86,10 +85,8 @@ compiler.misc.type.captureof
 compiler.misc.type.captureof.1
 compiler.misc.type.none
 compiler.misc.type.req.exact
-compiler.misc.type.variable.has.undetermined.type
 compiler.misc.unable.to.access.file                     # ClassFile
 compiler.misc.undecl.type.var                           # ClassReader
-compiler.misc.undetermined.type
 compiler.misc.unicode.str.not.supported                 # ClassReader
 compiler.misc.verbose.retro                             # UNUSED
 compiler.misc.verbose.retro.with                        # UNUSED
@@ -113,3 +110,5 @@ compiler.warn.unchecked.cast.to.type                    # DEAD, replaced by comp
 compiler.warn.unexpected.archive.file                   # Paths: zip file with unknown extn
 compiler.warn.unknown.enum.constant                     # in bad class file
 compiler.warn.unknown.enum.constant.reason              # in bad class file
+compiler.warn.override.equals.but.not.hashcode          # when a class overrides equals but not hashCode method from Object
+
diff --git a/test/tools/javac/diags/examples/ApplicableMethodFound.java b/test/tools/javac/diags/examples/ApplicableMethodFound.java
new file mode 100644
index 0000000..6755449
--- /dev/null
+++ b/test/tools/javac/diags/examples/ApplicableMethodFound.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011, 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.misc.applicable.method.found
+// key: compiler.note.verbose.resolve.multi
+// options: -XDverboseResolution=applicable,success
+
+class ApplicableMethodFound {
+
+    void m() {}
+
+    { m(); }
+}
diff --git a/test/tools/javac/diags/examples/ApplicableMethodFound1.java b/test/tools/javac/diags/examples/ApplicableMethodFound1.java
new file mode 100644
index 0000000..0780b32
--- /dev/null
+++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.misc.applicable.method.found.1
+// key: compiler.note.verbose.resolve.multi
+// key: compiler.misc.partial.inst.sig
+// options: -XDverboseResolution=applicable,success
+
+class ApplicableMethodFound1 {
+
+    <X> void m(X x) {}
+
+    { m(1); }
+}
diff --git a/test/tools/javac/diags/examples/ArrayAndReceiver.java b/test/tools/javac/diags/examples/ArrayAndReceiver.java
new file mode 100644
index 0000000..fc15597
--- /dev/null
+++ b/test/tools/javac/diags/examples/ArrayAndReceiver.java
@@ -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[]) { }
+}
diff --git a/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassUsingAuxiliary.java b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassUsingAuxiliary.java
new file mode 100644
index 0000000..d558fea
--- /dev/null
+++ b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassUsingAuxiliary.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.warn.auxiliary.class.accessed.from.outside.of.its.source.file
+// options: -Xlint:auxiliaryclass
+
+class ClassUsingAuxiliary {
+    AuxiliaryClass ahem;
+}
diff --git a/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassWithAuxiliary.java b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassWithAuxiliary.java
new file mode 100644
index 0000000..2cc6aea
--- /dev/null
+++ b/test/tools/javac/diags/examples/AuxiliaryClassWarning/ClassWithAuxiliary.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+class ClassWithAuxiliaryClass {
+}
+
+// Auxiliary class that cannot be found through implicit compilation.
+class AuxiliaryClass {
+}
diff --git a/test/tools/javac/diags/examples/BadArgTypesInLambda.java b/test/tools/javac/diags/examples/BadArgTypesInLambda.java
new file mode 100644
index 0000000..493c4c3
--- /dev/null
+++ b/test/tools/javac/diags/examples/BadArgTypesInLambda.java
@@ -0,0 +1,41 @@
+/*
+ * 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.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 {
+        void m(Integer i);
+    }
+
+    void g(SAM s) { }
+
+    void test() {
+        g(x->{ String s = x; });
+    }
+}
diff --git a/test/tools/javac/diags/examples/BadEntity.java b/test/tools/javac/diags/examples/BadEntity.java
new file mode 100644
index 0000000..bfff5c8
--- /dev/null
+++ b/test/tools/javac/diags/examples/BadEntity.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.bad.entity
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** & */
+class BadEntity { }
+
diff --git a/test/tools/javac/diags/examples/BadFunctionalIntfAnno.java b/test/tools/javac/diags/examples/BadFunctionalIntfAnno.java
new file mode 100644
index 0000000..8709050
--- /dev/null
+++ b/test/tools/javac/diags/examples/BadFunctionalIntfAnno.java
@@ -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.bad.functional.intf.anno.1
+// key: compiler.misc.not.a.functional.intf
+
+ at FunctionalInterface
+class BadFunctionalIntfAnno { }
diff --git a/test/tools/javac/diags/examples/BadGreaterThan.java b/test/tools/javac/diags/examples/BadGreaterThan.java
new file mode 100644
index 0000000..f9be624
--- /dev/null
+++ b/test/tools/javac/diags/examples/BadGreaterThan.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.bad.gt
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** > */
+class BadGreaterThan { }
+
diff --git a/test/tools/javac/diags/examples/BadInlineTag.java b/test/tools/javac/diags/examples/BadInlineTag.java
new file mode 100644
index 0000000..902cf66
--- /dev/null
+++ b/test/tools/javac/diags/examples/BadInlineTag.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.bad.inline.tag
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @inheritDoc */
+class BadInlineTag { }
+
diff --git a/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java b/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java
new file mode 100644
index 0000000..ce4f323
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ * 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.cant.access.inner.cls.constr
+// key: compiler.misc.invalid.mref
+
+class CantAccessInnerClsConstructor {
+
+    interface SAM {
+        Outer m();
+    }
+
+    class Outer { }
+
+    static void test() {
+        SAM s = Outer::new;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantAnnotateNestedType.java b/test/tools/javac/diags/examples/CantAnnotateNestedType.java
new file mode 100644
index 0000000..30d4572
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantAnnotateNestedType.java
@@ -0,0 +1,41 @@
+/*
+ * 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.cant.annotate.nested.type
+
+import java.lang.annotation.*;
+
+class CantAnnotateStaticClass {
+    @Target(ElementType.TYPE_USE)
+    @interface A {}
+
+    interface Outer {
+        interface Inner {}
+    }
+
+    // Error:
+    @A Outer.Inner f;
+
+    // OK:
+    @A Outer g;
+}
diff --git a/test/tools/javac/diags/examples/CantAnnotateStaticClass.java b/test/tools/javac/diags/examples/CantAnnotateStaticClass.java
new file mode 100644
index 0000000..d3505bb
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantAnnotateStaticClass.java
@@ -0,0 +1,41 @@
+/*
+ * 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.cant.annotate.static.class
+
+import java.lang.annotation.*;
+
+class CantAnnotateStaticClass {
+    @Target(ElementType.TYPE_USE)
+    @interface A {}
+
+    static class Outer {
+        class Inner {}
+    }
+
+    // Error:
+    @A Outer.Inner f;
+
+    // OK:
+    @A Outer g;
+}
diff --git a/test/tools/javac/diags/examples/CantApplyDiamond1.java b/test/tools/javac/diags/examples/CantApplyDiamond1.java
new file mode 100644
index 0000000..18ca0a6
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantApplyDiamond1.java
@@ -0,0 +1,36 @@
+/*
+ * 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.cant.apply.diamond.1
+// key: compiler.misc.incompatible.eq.upper.bounds
+// key: compiler.misc.diamond
+
+class CantApplyDiamond1<X> {
+
+    CantApplyDiamond1(CantApplyDiamond1<? super X> lz) { }
+
+    void test(CantApplyDiamond1<Integer> li) {
+       CantApplyDiamond1<String> ls = new CantApplyDiamond1<>(li);
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantApplySymbolFragment.java b/test/tools/javac/diags/examples/CantApplySymbolFragment.java
new file mode 100644
index 0000000..0ed248c
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantApplySymbolFragment.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ * 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.misc.no.conforming.assignment.exists
+// key: compiler.misc.cant.apply.symbol
+// key: compiler.misc.invalid.mref
+
+class CantApplySymbolFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    static void f(String s) { }
+
+    void test() {
+        SAM s = CantApplySymbolFragment::f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantApplySymbolsFragment.java b/test/tools/javac/diags/examples/CantApplySymbolsFragment.java
new file mode 100644
index 0000000..d49b7f8
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantApplySymbolsFragment.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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.misc.no.conforming.assignment.exists
+// key: compiler.misc.arg.length.mismatch
+// key: compiler.misc.inapplicable.method
+// key: compiler.misc.cant.apply.symbols
+// key: compiler.misc.invalid.mref
+
+class CantApplySymbolsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    static void f() { }
+
+    static void f(String s) { }
+
+    void test() {
+        SAM s = CantApplySymbolsFragment::f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java b/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java
new file mode 100644
index 0000000..421d1f0
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ * 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.cant.ref.non.effectively.final.var
+// key: compiler.misc.inner.cls
+// key: compiler.misc.lambda
+
+class CantRefNonEffectivelyFinalVar {
+    void test() {
+        int i = 0;
+        new Object() { int j = i; };
+        i = 2;
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    void test2() {
+        int i = 0;
+        SAM s = ()-> { int j = i; };
+        i++;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java b/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java
new file mode 100644
index 0000000..d8e1160
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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.misc.cant.resolve.location.args
+// key: compiler.misc.location
+// key: compiler.err.invalid.mref
+
+class CantResolveLocationArgsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void test() {
+        SAM s = CantResolveLocationArgsFragment::f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java b/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java
new file mode 100644
index 0000000..b522e7f
--- /dev/null
+++ b/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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.misc.cant.resolve.location.args.params
+// key: compiler.misc.location
+// key: compiler.err.invalid.mref
+
+class CantResolveLocationArgsParamsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void test() {
+        SAM s = CantResolveLocationArgsParamsFragment::<String>f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CantReturnValueForVoid.java b/test/tools/javac/diags/examples/CantReturnValueForVoid.java
deleted file mode 100644
index fbd42dd..0000000
--- a/test/tools/javac/diags/examples/CantReturnValueForVoid.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 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.cant.ret.val.from.meth.decl.void
-
-class CantReturnValueForVoid {
-    void m() {
-        return 3;
-    }
-}
diff --git a/test/tools/javac/diags/examples/CatchWithoutTry.java b/test/tools/javac/diags/examples/CatchWithoutTry.java
index 2fa7070..6d355a3 100644
--- a/test/tools/javac/diags/examples/CatchWithoutTry.java
+++ b/test/tools/javac/diags/examples/CatchWithoutTry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -22,8 +22,6 @@
  */
 
 // key: compiler.err.catch.without.try
-// key: compiler.err.expected
-// key: compiler.err.not.stmt
 
 class CatchWithoutTry {
     void m() {
diff --git a/test/tools/javac/diags/examples/CompressedDiags.java b/test/tools/javac/diags/examples/CompressedDiags.java
new file mode 100644
index 0000000..a71f735
--- /dev/null
+++ b/test/tools/javac/diags/examples/CompressedDiags.java
@@ -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);
+    }
+}
diff --git a/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java b/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java
new file mode 100644
index 0000000..7ba0991
--- /dev/null
+++ b/test/tools/javac/diags/examples/ConditionalTargetCantBeVoid.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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.incompatible.ret.type.in.lambda
+// key: compiler.misc.conditional.target.cant.be.void
+
+class ConditionalTargetCantBeVoid {
+
+    interface SAM {
+        void m();
+    }
+
+    void test(boolean cond, Object o1, Object o2) {
+        SAM s = ()-> cond ? o1 : o2;
+    }
+}
diff --git a/test/tools/javac/diags/examples/CyclicInference.java b/test/tools/javac/diags/examples/CyclicInference.java
new file mode 100644
index 0000000..0a6bc7a
--- /dev/null
+++ b/test/tools/javac/diags/examples/CyclicInference.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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.cyclic.inference
+
+class CyclicInference {
+    interface SAM<X> {
+        void m(X x);
+    }
+
+    <Z> void g(SAM<Z> sz) { }
+
+    void test() {
+        g(x-> {});
+    }
+}
diff --git a/test/tools/javac/diags/examples/DefaultMethodNotSupported.java b/test/tools/javac/diags/examples/DefaultMethodNotSupported.java
new file mode 100644
index 0000000..6e47999
--- /dev/null
+++ b/test/tools/javac/diags/examples/DefaultMethodNotSupported.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.default.methods.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+interface DefaultMethodNotSupported {
+    default void m() { }
+}
diff --git a/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java b/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java
new file mode 100644
index 0000000..395a3c2
--- /dev/null
+++ b/test/tools/javac/diags/examples/DefaultOverridesObjectMember.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * 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.default.overrides.object.member
+
+interface DefaultOverridesObjectMember {
+    default String toString() { return ""; }
+}
diff --git a/test/tools/javac/diags/examples/DeferredMethodInst.java b/test/tools/javac/diags/examples/DeferredMethodInst.java
new file mode 100644
index 0000000..ff56e5e
--- /dev/null
+++ b/test/tools/javac/diags/examples/DeferredMethodInst.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 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.misc.applicable.method.found.1
+// key: compiler.note.verbose.resolve.multi
+// key: compiler.note.deferred.method.inst
+// key: compiler.misc.partial.inst.sig
+// options: -XDverboseResolution=applicable,success,deferred-inference
+
+class DeferredMethodInst {
+
+    <X> X m() { return null; }
+
+    { Integer i = m(); }
+}
diff --git a/test/tools/javac/diags/examples/DuplicateAnnotation.java b/test/tools/javac/diags/examples/DuplicateAnnotation.java
index 48a4325..1301f4e 100644
--- a/test/tools/javac/diags/examples/DuplicateAnnotation.java
+++ b/test/tools/javac/diags/examples/DuplicateAnnotation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -22,6 +22,8 @@
  */
 
 // key: compiler.err.duplicate.annotation
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 7
 
 @interface Anno { }
 
diff --git a/test/tools/javac/diags/examples/DuplicateAnnotationJava8.java b/test/tools/javac/diags/examples/DuplicateAnnotationJava8.java
new file mode 100644
index 0000000..8fcb549
--- /dev/null
+++ b/test/tools/javac/diags/examples/DuplicateAnnotationJava8.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ * 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.duplicate.annotation.missing.container
+
+ at interface Anno { }
+
+ at Anno
+ at Anno
+class DuplicateAnnotationJava8 { }
diff --git a/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java b/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java
index 255a09c..cd10b13 100644
--- a/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java
+++ b/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.explicit.param.do.not.conform.to.bounds
 
 class ExplicitParamsDoNotConformToBounds {
diff --git a/test/tools/javac/diags/examples/ForeachBadInitialization.java b/test/tools/javac/diags/examples/ForeachBadInitialization.java
new file mode 100644
index 0000000..5a90de1
--- /dev/null
+++ b/test/tools/javac/diags/examples/ForeachBadInitialization.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.bad.initializer
+import java.util.List;
+class ForeachBadInitialization {
+    void m() {
+        List<String> s = null;
+        for (a : s) {}
+    }
+}
diff --git a/test/tools/javac/diags/examples/GreaterThanExpected.java b/test/tools/javac/diags/examples/GreaterThanExpected.java
new file mode 100644
index 0000000..60b2022
--- /dev/null
+++ b/test/tools/javac/diags/examples/GreaterThanExpected.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.dc.gt.expected
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+class GreaterThanExpected {
+    /** @param <T */
+    <T> void m(T t) { }
+}
+
diff --git a/test/tools/javac/diags/examples/IllegalChar.java b/test/tools/javac/diags/examples/IllegalChar.java
index 003a7b0..28bf827 100644
--- a/test/tools/javac/diags/examples/IllegalChar.java
+++ b/test/tools/javac/diags/examples/IllegalChar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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,5 +24,5 @@
 // key: compiler.err.illegal.char
 
 class IllegalChar {
-    int i = #;
+    int i = `;
 }
diff --git a/test/tools/javac/diags/examples/IllegalDot.java b/test/tools/javac/diags/examples/IllegalDot.java
new file mode 100644
index 0000000..be0aa4b
--- /dev/null
+++ b/test/tools/javac/diags/examples/IllegalDot.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.illegal.dot
+// key: compiler.err.expected
+// key: compiler.err.illegal.start.of.type
+
+class X {
+    void m(Object.. args) { }
+}
diff --git a/test/tools/javac/diags/examples/IllegalStartOfStmt.java b/test/tools/javac/diags/examples/IllegalStartOfStmt.java
new file mode 100644
index 0000000..5f29f48
--- /dev/null
+++ b/test/tools/javac/diags/examples/IllegalStartOfStmt.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.illegal.start.of.stmt
+// key: compiler.err.expected3
+
+class IllegalStartOfStmt {
+    void m() {
+        if (true) }
+    }
+}
diff --git a/test/tools/javac/diags/examples/IllegalStaticIntfMethCall.java b/test/tools/javac/diags/examples/IllegalStaticIntfMethCall.java
new file mode 100644
index 0000000..29fa0bb
--- /dev/null
+++ b/test/tools/javac/diags/examples/IllegalStaticIntfMethCall.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.illegal.static.intf.meth.call
+// options: -XDallowStaticInterfaceMethods
+
+class IllegalStaticIntfMethCall {
+    interface A {
+        static void m() { }
+    }
+    void test(A a) {
+        a.m();
+    }
+}
diff --git a/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java b/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java
index 3bdfc83..8a8c95c 100644
--- a/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java
+++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.inaccessible.varargs.type
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 
 import p1.B;
 
diff --git a/test/tools/javac/diags/examples/IncompatibleAbstracts.java b/test/tools/javac/diags/examples/IncompatibleAbstracts.java
new file mode 100644
index 0000000..351ce64
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleAbstracts.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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.not.a.functional.intf.1
+// key: compiler.misc.incompatible.abstracts
+
+class IncompatibleAbstracts {
+
+    interface SAM {
+        void m(String s);
+        void m(Integer i);
+    }
+
+    SAM s = x-> { };
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java b/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java
new file mode 100644
index 0000000..be53ae2
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ *
+ * 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.incompatible.arg.types.in.lambda
+
+class IncompatibleArgTypesInLambda {
+    interface SAM {
+        void m(Integer x);
+    }
+
+    SAM s = (String x)-> {};
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java b/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java
new file mode 100644
index 0000000..999eb90
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleArgTypesInMethodRef.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cant.apply.symbol
+// key: compiler.misc.infer.no.conforming.assignment.exists
+// key: compiler.misc.incompatible.arg.types.in.mref
+
+class IncompatibleArgTypesInMethodRef {
+    interface SAM<X> {
+        void m(X x);
+    }
+
+    void g(String s, Integer i) { }
+
+    <Z> void m(SAM<Z> s) { }
+
+    void test() {
+        m(this::g);
+    }
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java b/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java
new file mode 100644
index 0000000..4873516
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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.types.incompatible.diff.ret
+// key: compiler.err.prob.found.req
+// key: compiler.misc.incompatible.descs.in.functional.intf
+// key: compiler.misc.descriptor
+// key: compiler.misc.descriptor.throws
+
+class IncompatibleDescsInFunctionalIntf {
+    interface A {
+        Integer m(String i) throws Exception;
+    }
+
+    interface B {
+        String m(String i);
+    }
+
+    interface SAM extends A,B { }
+
+    SAM s = x-> { };
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleEqUpperBounds.java b/test/tools/javac/diags/examples/IncompatibleEqUpperBounds.java
new file mode 100644
index 0000000..83651fe
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleEqUpperBounds.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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.cant.apply.symbol
+//key: compiler.misc.incompatible.eq.upper.bounds
+
+import java.util.List;
+
+class IncompatibleEqUpperBounds {
+    <S, T extends List<S>> void m(List<? super S> s1, T s2) { }
+
+    void test(List<Integer> li, List<String> ls) {
+        m(li, ls);
+    }
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java b/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java
new file mode 100644
index 0000000..0270a08
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.misc.incompatible.ret.type.in.lambda
+
+class IncompatibleRetTypeInLambda {
+    interface SAM {
+        Integer m();
+    }
+
+    SAM s = ()-> "";
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java b/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java
new file mode 100644
index 0000000..aeca948
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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.misc.incompatible.ret.type.in.mref
+
+class IncompatibleRetTypeInMref {
+    interface SAM {
+        Integer m();
+    }
+
+    static String f() { }
+
+    SAM s = IncompatibleRetTypeInMref::f;
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java b/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java
new file mode 100644
index 0000000..952314a
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.incompatible.thrown.types.in.mref
+
+class IncompatibleThrownTypesInMref {
+    interface SAM {
+        void m();
+    }
+
+    static void f() throws Exception { }
+
+    SAM s = IncompatibleThrownTypesInMref::f;
+}
diff --git a/test/tools/javac/diags/examples/IncompatibleTypes1.java b/test/tools/javac/diags/examples/IncompatibleTypes1.java
index 1305d7f..a5c9073 100644
--- a/test/tools/javac/diags/examples/IncompatibleTypes1.java
+++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -21,14 +21,13 @@
  * questions.
  */
 
-// key: compiler.misc.incompatible.types.1
 // key: compiler.misc.infer.no.conforming.instance.exists
 // key: compiler.err.prob.found.req
 
 class IncompatibleTypes1<V> {
-    <T extends Integer & Runnable> IncompatibleTypes1<T> m() {
+    <T> IncompatibleTypes1<Integer> m() {
         return null;
     }
 
-    IncompatibleTypes1<? super String> o = m();
+    IncompatibleTypes1<? extends String> o = m();
 }
diff --git a/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java b/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java
new file mode 100644
index 0000000..25e8e3d
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.incompatible.type.in.conditional
+// key: compiler.misc.inconvertible.types
+
+class IncompatibleTypesInConditional {
+
+    interface A { }
+    interface B { }
+
+    B b = true ? (A)null : (B)null;
+}
diff --git a/test/tools/javac/diags/examples/InconvertibleTypes.java b/test/tools/javac/diags/examples/InconvertibleTypes.java
index 7df79d4..5c76b85 100644
--- a/test/tools/javac/diags/examples/InconvertibleTypes.java
+++ b/test/tools/javac/diags/examples/InconvertibleTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
diff --git a/test/tools/javac/diags/examples/IncorrectConstructorReceiverName.java b/test/tools/javac/diags/examples/IncorrectConstructorReceiverName.java
new file mode 100644
index 0000000..21fd4d5
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncorrectConstructorReceiverName.java
@@ -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) { }
+    }
+}
diff --git a/test/tools/javac/diags/examples/IncorrectConstructorReceiverType.java b/test/tools/javac/diags/examples/IncorrectConstructorReceiverType.java
new file mode 100644
index 0000000..0bc2e79
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncorrectConstructorReceiverType.java
@@ -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) { }
+    }
+}
diff --git a/test/tools/javac/diags/examples/IncorrectReceiverName.java b/test/tools/javac/diags/examples/IncorrectReceiverName.java
new file mode 100644
index 0000000..32471ba
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncorrectReceiverName.java
@@ -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) { }
+    }
+}
diff --git a/test/tools/javac/diags/examples/IncorrectReceiverType.java b/test/tools/javac/diags/examples/IncorrectReceiverType.java
new file mode 100644
index 0000000..548067b
--- /dev/null
+++ b/test/tools/javac/diags/examples/IncorrectReceiverType.java
@@ -0,0 +1,28 @@
+/*
+ * 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.type
+
+class IncorrectReceiverType {
+    void m(Object this) {}
+}
diff --git a/test/tools/javac/diags/examples/InferArgsLengthMismatch.java b/test/tools/javac/diags/examples/InferArgsLengthMismatch.java
index 28411b4..f01bd14 100644
--- a/test/tools/javac/diags/examples/InferArgsLengthMismatch.java
+++ b/test/tools/javac/diags/examples/InferArgsLengthMismatch.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.infer.arg.length.mismatch
 
 class InferArgsLengthMismatch {
diff --git a/test/tools/javac/diags/examples/InferNoConformingAssignment.java b/test/tools/javac/diags/examples/InferNoConformingAssignment.java
new file mode 100644
index 0000000..adfb1f8
--- /dev/null
+++ b/test/tools/javac/diags/examples/InferNoConformingAssignment.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.cant.apply.symbol
+// key: compiler.misc.inconvertible.types
+// key: compiler.misc.infer.no.conforming.assignment.exists
+
+import java.util.*;
+
+class InferNoConformingAssignment {
+    <X extends Number> List<X> m(String s) { return null; }
+    { this.m(1); }
+}
+
diff --git a/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java b/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java
new file mode 100644
index 0000000..eca02fa
--- /dev/null
+++ b/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.cant.apply.symbol
+// key: compiler.misc.infer.varargs.argument.mismatch
+// key: compiler.misc.inconvertible.types
+
+class InferVarargsArgumentMismatch {
+    <X> void m(X x1, String... xs) {}
+    { this.m("", 1); }
+}
diff --git a/test/tools/javac/diags/examples/InferredDoNotConformToBounds.java b/test/tools/javac/diags/examples/InferredDoNotConformToBounds.java
deleted file mode 100644
index 95cb23c..0000000
--- a/test/tools/javac/diags/examples/InferredDoNotConformToBounds.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2010, 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.misc.inferred.do.not.conform.to.bounds
-// key: compiler.err.cant.apply.diamond.1
-// key: compiler.misc.diamond
-
-class InferredDoNotConformToBounds {
-   static class SuperFoo<X> {}
-   static class Foo<X extends Number> extends SuperFoo<X> {
-       Foo(X x) {}
-   }
-
-   SuperFoo<String> sf1 = new Foo<>("");
-}
diff --git a/test/tools/javac/diags/examples/InferredDoNotConformToEq.java b/test/tools/javac/diags/examples/InferredDoNotConformToEq.java
new file mode 100644
index 0000000..c5beec0
--- /dev/null
+++ b/test/tools/javac/diags/examples/InferredDoNotConformToEq.java
@@ -0,0 +1,33 @@
+/*
+ * 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.cant.apply.symbol
+// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
+// options: -source 7 -Xlint:-options
+
+import java.util.*;
+
+class InferredDoNotConformToEq {
+    <X> void m(List<X> lx1, List<X> lx2) {}
+    { this.m(Arrays.asList(""), Arrays.asList(1)); }
+}
diff --git a/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java b/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java
new file mode 100644
index 0000000..ca45b46
--- /dev/null
+++ b/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java
@@ -0,0 +1,33 @@
+/*
+ * 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.cant.apply.symbol
+// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
+// options: -source 7 -Xlint:-options
+
+import java.util.*;
+
+class InferredDoNotConformToUpper {
+    <X> void m(X x, List<? super X> lx) {}
+    { this.m("", Arrays.asList(1)); }
+}
diff --git a/test/tools/javac/diags/examples/IntersectionTypesInCastNotSupported.java b/test/tools/javac/diags/examples/IntersectionTypesInCastNotSupported.java
new file mode 100644
index 0000000..8126a35
--- /dev/null
+++ b/test/tools/javac/diags/examples/IntersectionTypesInCastNotSupported.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.intersection.types.in.cast.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+interface IntersectionTypesInCastNotSupported {
+    Object o = (A & B)null;
+}
diff --git a/test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java b/test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java
new file mode 100644
index 0000000..4d2cf29
--- /dev/null
+++ b/test/tools/javac/diags/examples/InvalidDuplicateAnnotation.java
@@ -0,0 +1,39 @@
+/*
+ * 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.duplicate.annotation.invalid.repeated
+// key: compiler.err.invalid.repeatable.annotation.elem.nondefault
+
+// We need an almost valid containing annotation. The easiest way to get
+// one close enough to valid is by forgetting a default.
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); String foo(); }
+
+ at Anno
+ at Anno
+class InvalidDuplicateAnnotation { }
diff --git a/test/tools/javac/diags/examples/InvalidGenericLambdaTarget.java b/test/tools/javac/diags/examples/InvalidGenericLambdaTarget.java
new file mode 100644
index 0000000..225b5f3
--- /dev/null
+++ b/test/tools/javac/diags/examples/InvalidGenericLambdaTarget.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.invalid.generic.lambda.target
+
+class InvalidGenericLambdaTarget {
+
+    interface SAM {
+        <Z> void m();
+    }
+
+    SAM s = x-> { };
+}
diff --git a/test/tools/javac/diags/examples/InvalidInferredTypes.java b/test/tools/javac/diags/examples/InvalidInferredTypes.java
deleted file mode 100644
index 22dfb6b..0000000
--- a/test/tools/javac/diags/examples/InvalidInferredTypes.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010, 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.invalid.inferred.types
-// key: compiler.misc.inferred.do.not.conform.to.bounds
-
-import java.util.*;
-
-class InvalidInferredTypes {
-
-    <T extends List<? super T>> T makeList() {
-        return null;
-    }
-
-    public void test() {
-        List<? super String> l = makeList();
-    }
-}
diff --git a/test/tools/javac/diags/examples/KindnameConstructor.java b/test/tools/javac/diags/examples/KindnameConstructor.java
index 21396b5..4b0f739 100644
--- a/test/tools/javac/diags/examples/KindnameConstructor.java
+++ b/test/tools/javac/diags/examples/KindnameConstructor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,12 +23,12 @@
 
 // key: compiler.misc.kindname.constructor
 // key: compiler.misc.kindname.class
-// key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol.1
-// key: compiler.misc.arg.length.mismatch
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.no.conforming.assignment.exists
-// key: compiler.misc.count.error.plural
+// key: compiler.misc.inconvertible.types
+// key: compiler.misc.count.error
 // key: compiler.err.error
+// options: -Xdiags:verbose
 // run: backdoor
 
 class KindnameConstructor {
diff --git a/test/tools/javac/diags/examples/LambdaNotSupported.java b/test/tools/javac/diags/examples/LambdaNotSupported.java
new file mode 100644
index 0000000..ea57fe4
--- /dev/null
+++ b/test/tools/javac/diags/examples/LambdaNotSupported.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, 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.lambda.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class LambdaNotSupported {
+    S s = ()->{};
+}
diff --git a/test/tools/javac/diags/examples/LambdaStat.java b/test/tools/javac/diags/examples/LambdaStat.java
new file mode 100644
index 0000000..2eb894a
--- /dev/null
+++ b/test/tools/javac/diags/examples/LambdaStat.java
@@ -0,0 +1,29 @@
+/*
+ * 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.note.lambda.stat
+// options: -XDdumpLambdaToMethodStats
+
+class LambdaStat {
+    Runnable r = ()->{};
+}
diff --git a/test/tools/javac/diags/examples/LocalVarNeedsFinal.java b/test/tools/javac/diags/examples/LocalVarNeedsFinal.java
index fea47ef..fc7c553 100644
--- a/test/tools/javac/diags/examples/LocalVarNeedsFinal.java
+++ b/test/tools/javac/diags/examples/LocalVarNeedsFinal.java
@@ -22,6 +22,7 @@
  */
 
 // key: compiler.err.local.var.accessed.from.icls.needs.final
+// options: -Xlint:-options -source 7
 
 class LocalVarNeedsFinal {
     Runnable m() {
diff --git a/test/tools/javac/diags/examples/MalformedHTML.java b/test/tools/javac/diags/examples/MalformedHTML.java
new file mode 100644
index 0000000..522c188
--- /dev/null
+++ b/test/tools/javac/diags/examples/MalformedHTML.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.dc.malformed.html
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** <b */
+class MalformedHTML { }
diff --git a/test/tools/javac/diags/examples/MethodReferencesNotSupported.java b/test/tools/javac/diags/examples/MethodReferencesNotSupported.java
new file mode 100644
index 0000000..3cd8e67
--- /dev/null
+++ b/test/tools/javac/diags/examples/MethodReferencesNotSupported.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, 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.method.references.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class MethodReferencesNotSupported {
+    S s = A::foo;
+}
diff --git a/test/tools/javac/diags/examples/MissingReturnValue.java b/test/tools/javac/diags/examples/MissingReturnValue.java
index 3341c3b..55e96a4 100644
--- a/test/tools/javac/diags/examples/MissingReturnValue.java
+++ b/test/tools/javac/diags/examples/MissingReturnValue.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,7 +21,8 @@
  * questions.
  */
 
-// key: compiler.err.missing.ret.val
+// key: compiler.err.prob.found.req
+// key: compiler.misc.missing.ret.val
 
 class MissingReturnValue {
     int m() {
diff --git a/test/tools/javac/diags/examples/MissingReturnValueFragment.java b/test/tools/javac/diags/examples/MissingReturnValueFragment.java
new file mode 100644
index 0000000..8edeb62
--- /dev/null
+++ b/test/tools/javac/diags/examples/MissingReturnValueFragment.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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.incompatible.ret.type.in.lambda
+// key: compiler.misc.missing.ret.val
+
+class MissingReturnValueFragment {
+    interface SAM {
+        String m();
+    }
+
+    void test() {
+        SAM s = ()->{};
+    }
+}
diff --git a/test/tools/javac/diags/examples/MissingSemicolon.java b/test/tools/javac/diags/examples/MissingSemicolon.java
new file mode 100644
index 0000000..7d9cd71
--- /dev/null
+++ b/test/tools/javac/diags/examples/MissingSemicolon.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.missing.semicolon
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** &lt */
+class MissingSemicolon { }
+
diff --git a/test/tools/javac/diags/examples/MrefStat.java b/test/tools/javac/diags/examples/MrefStat.java
new file mode 100644
index 0000000..d87e665
--- /dev/null
+++ b/test/tools/javac/diags/examples/MrefStat.java
@@ -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.note.mref.stat
+// options: -XDdumpLambdaToMethodStats
+
+class MrefStat {
+    Runnable r = MrefStat::m;
+
+    static void m() { }
+}
diff --git a/test/tools/javac/diags/examples/MrefStat.java.rej b/test/tools/javac/diags/examples/MrefStat.java.rej
new file mode 100644
index 0000000..f5286e5
--- /dev/null
+++ b/test/tools/javac/diags/examples/MrefStat.java.rej
@@ -0,0 +1,34 @@
+--- MrefStat.java
++++ MrefStat.java
+@@ -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.note.mref.stat
++// options: -XDdumpLambdaToMethodStats
++
++class MrefStat {
++    Runnable r = MrefStat::m;
++    
++    static void m() { }
++}
diff --git a/test/tools/javac/diags/examples/MrefStat1.java b/test/tools/javac/diags/examples/MrefStat1.java
new file mode 100644
index 0000000..6318e3c
--- /dev/null
+++ b/test/tools/javac/diags/examples/MrefStat1.java
@@ -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.
+ */
+
+// key: compiler.note.mref.stat.1
+// options: -XDdumpLambdaToMethodStats
+
+class MrefStat1 {
+
+    void m() { }
+
+    static class Sub extends MrefStat1 {
+        Runnable r = super::m;
+    }
+}
diff --git a/test/tools/javac/diags/examples/MrefStat1.java.rej b/test/tools/javac/diags/examples/MrefStat1.java.rej
new file mode 100644
index 0000000..b247270
--- /dev/null
+++ b/test/tools/javac/diags/examples/MrefStat1.java.rej
@@ -0,0 +1,37 @@
+--- MrefStat1.java
++++ MrefStat1.java
+@@ -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.
++ */
++
++// key: compiler.note.mref.stat.1
++// options: -XDdumpLambdaToMethodStats
++
++class MrefStat1 {    
++    
++    void m() { }
++    
++    static class Sub extends MrefStat1 {
++        Runnable r = super::m;
++    }
++}
diff --git a/test/tools/javac/diags/examples/NoAbstracts.java b/test/tools/javac/diags/examples/NoAbstracts.java
new file mode 100644
index 0000000..011115e
--- /dev/null
+++ b/test/tools/javac/diags/examples/NoAbstracts.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ *
+ * 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.not.a.functional.intf.1
+// key: compiler.misc.no.abstracts
+
+class NoAbstracts {
+
+    interface SAM { }
+
+    SAM s = x-> { };
+}
diff --git a/test/tools/javac/diags/examples/NoAnnotationsOnDotClass.java b/test/tools/javac/diags/examples/NoAnnotationsOnDotClass.java
new file mode 100644
index 0000000..0ce6553
--- /dev/null
+++ b/test/tools/javac/diags/examples/NoAnnotationsOnDotClass.java
@@ -0,0 +1,31 @@
+/*
+ * 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.no.annotations.on.dot.class
+
+class NoAnnotationsOnDotClass {
+    @Target(ElementType.TYPE_USE)
+    @interface A {}
+
+    Object o = @A Object.class;
+}
diff --git a/test/tools/javac/diags/examples/NoArgs.java b/test/tools/javac/diags/examples/NoArgs.java
index 59c2795..6d27582 100644
--- a/test/tools/javac/diags/examples/NoArgs.java
+++ b/test/tools/javac/diags/examples/NoArgs.java
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.arg.length.mismatch
 // run: simple
 
diff --git a/test/tools/javac/diags/examples/NoContent.java b/test/tools/javac/diags/examples/NoContent.java
new file mode 100644
index 0000000..2408a59
--- /dev/null
+++ b/test/tools/javac/diags/examples/NoContent.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ *
+ * 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.dc.no.content
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see */
+class NoContent {
+}
+
diff --git a/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java b/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java
new file mode 100644
index 0000000..ef21673
--- /dev/null
+++ b/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.no.suitable.functional.intf.inst
+
+class NoSuitableFunctionalIntfInst {
+
+    interface SAM<X extends Number> {
+        void m(X x);
+    }
+
+    SAM<?> ss = (String s)-> { };
+}
diff --git a/test/tools/javac/diags/examples/NoTagName.java b/test/tools/javac/diags/examples/NoTagName.java
new file mode 100644
index 0000000..89fdc0d
--- /dev/null
+++ b/test/tools/javac/diags/examples/NoTagName.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.no.tag.name
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @ */
+class NoTagName { }
+
diff --git a/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java b/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java
new file mode 100644
index 0000000..0336937
--- /dev/null
+++ b/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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.misc.non-static.cant.be.ref
+// key: compiler.err.invalid.mref
+
+class NonStaticCantBeRefFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void f(Integer i) { }
+
+    static void test() {
+        SAM s = NonStaticCantBeRefFragment::f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotAFunctionalIntf.java b/test/tools/javac/diags/examples/NotAFunctionalIntf.java
new file mode 100644
index 0000000..e151aa4
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotAFunctionalIntf.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.not.a.functional.intf
+
+class NotAFunctionalIntf {
+
+    abstract class SAM {
+        abstract <Z> void m();
+    }
+
+    SAM s = x-> { };
+}
diff --git a/test/tools/javac/diags/examples/NotAStatement.java b/test/tools/javac/diags/examples/NotAStatement.java
new file mode 100644
index 0000000..39af85a
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotAStatement.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 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.not.stmt
+
+class NotAStatement {
+    void m() {
+        x + 1;
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotAllowedClass.java b/test/tools/javac/diags/examples/NotAllowedClass.java
new file mode 100644
index 0000000..3801dfd
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotAllowedClass.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.class.not.allowed
+
+class NotAllowedClass {
+    void t1() {
+        if (true)
+            class X {}
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotAllowedVariable.java b/test/tools/javac/diags/examples/NotAllowedVariable.java
new file mode 100644
index 0000000..a2a1f7a
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotAllowedVariable.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.variable.not.allowed
+
+class NotAllowedVariable {
+    void t1() {
+        if (true)
+            int x = 0;
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotAnInterfaceComponent.java b/test/tools/javac/diags/examples/NotAnInterfaceComponent.java
new file mode 100644
index 0000000..3ca0a11
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotAnInterfaceComponent.java
@@ -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.prob.found.req
+// key: compiler.misc.bad.intersection.target.for.functional.expr
+// key: compiler.misc.not.an.intf.component
+
+class NotAnInterfaceComponent {
+    Object o = (Object & Runnable) ()-> { };
+}
diff --git a/test/tools/javac/diags/examples/NotApplicableMethodFound.java b/test/tools/javac/diags/examples/NotApplicableMethodFound.java
new file mode 100644
index 0000000..c1e41ac
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotApplicableMethodFound.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.misc.not.applicable.method.found
+// key: compiler.note.verbose.resolve.multi.1
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.no.conforming.assignment.exists
+// key: compiler.misc.inconvertible.types
+// options: -XDverboseResolution=inapplicable,failure
+
+class NotApplicableMethodFound {
+
+    void m(int i) {}
+
+    { m(""); }
+}
diff --git a/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java b/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java
new file mode 100644
index 0000000..cbcdf66
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ *
+ * 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.not.def.access.class.intf.cant.access
+// key: compiler.misc.invalid.mref
+
+class NotDefAccessClassIntfCantAccessFragment {
+
+    private class Private {
+        void m() { }
+    }
+
+    Private getPrivate() { return new Private(); }
+}
+
+class NotDefAccessClassIntfCantAccessFragmentTest {
+
+    interface SAM {
+        void m();
+    }
+
+    static void test() {
+        SAM s = new NotDefAccessClassIntfCantAccessFragment().getPrivate()::m;
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/NotDefPublicCantAccessFragment.java b/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/NotDefPublicCantAccessFragment.java
new file mode 100644
index 0000000..c0fc560
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/NotDefPublicCantAccessFragment.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.mref
+// key: compiler.misc.not.def.public.cant.access
+
+class NotDefPublicCantAccessFragment {
+    interface SAM {
+        void m();
+    }
+
+    void test (p.C c) {
+        SAM s = c::m;
+    }
+}
diff --git a/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/p/C.java b/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/p/C.java
new file mode 100644
index 0000000..43bbced
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotDefPublicCantAccessFragment/p/C.java
@@ -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 C {
+    void m() { }
+}
diff --git a/test/tools/javac/diags/examples/NotInProfile.java b/test/tools/javac/diags/examples/NotInProfile.java
new file mode 100644
index 0000000..7165651
--- /dev/null
+++ b/test/tools/javac/diags/examples/NotInProfile.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2010, 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.not.in.profile
+// options: -profile compact1
+
+class NotInProfile {
+    Class<?> c = java.awt.Frame.class;
+}
diff --git a/test/tools/javac/diags/examples/OverriddenDefault.java b/test/tools/javac/diags/examples/OverriddenDefault.java
new file mode 100644
index 0000000..6fe9bcc
--- /dev/null
+++ b/test/tools/javac/diags/examples/OverriddenDefault.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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.illegal.default.super.call
+// key: compiler.misc.overridden.default
+
+class OverriddenDefault {
+    interface I { default void m() {  } }
+    interface J extends I { default void m() {  } }
+    interface K extends I {}
+
+    static class C implements J, K {
+        void foo() { K.super.m(); }
+    }
+}
diff --git a/test/tools/javac/diags/examples/PartialInstSig.java b/test/tools/javac/diags/examples/PartialInstSig.java
new file mode 100644
index 0000000..c095bdd
--- /dev/null
+++ b/test/tools/javac/diags/examples/PartialInstSig.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011, 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.misc.applicable.method.found.1
+// key: compiler.note.verbose.resolve.multi
+// key: compiler.misc.partial.inst.sig
+// options: -XDverboseResolution=applicable,success
+
+class PartialInstSig {
+
+    <X> X m() { return null; }
+
+    { m(); }
+}
diff --git a/test/tools/javac/diags/examples/PossibleLossPrecision.java b/test/tools/javac/diags/examples/PossibleLossPrecision.java
index bbb1d49..1626a3c 100644
--- a/test/tools/javac/diags/examples/PossibleLossPrecision.java
+++ b/test/tools/javac/diags/examples/PossibleLossPrecision.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
diff --git a/test/tools/javac/diags/examples/PotentialLambdaFound.java b/test/tools/javac/diags/examples/PotentialLambdaFound.java
new file mode 100644
index 0000000..050f26c
--- /dev/null
+++ b/test/tools/javac/diags/examples/PotentialLambdaFound.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.note.potential.lambda.found
+// options: -XDidentifyLambdaCandidate=true
+
+class PotentialLambdaFound {
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s = new SAM() { public void m() { } };
+}
diff --git a/test/tools/javac/diags/examples/ProbFoundReqFragment.java b/test/tools/javac/diags/examples/ProbFoundReqFragment.java
new file mode 100644
index 0000000..4eaa88c
--- /dev/null
+++ b/test/tools/javac/diags/examples/ProbFoundReqFragment.java
@@ -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;
+    }
+}
diff --git a/test/tools/javac/diags/examples/ReceiverParameterNotApplicableConstructor.java b/test/tools/javac/diags/examples/ReceiverParameterNotApplicableConstructor.java
new file mode 100644
index 0000000..7678b37
--- /dev/null
+++ b/test/tools/javac/diags/examples/ReceiverParameterNotApplicableConstructor.java
@@ -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) { }
+}
diff --git a/test/tools/javac/diags/examples/RedundantSupertype.java b/test/tools/javac/diags/examples/RedundantSupertype.java
new file mode 100644
index 0000000..3129025
--- /dev/null
+++ b/test/tools/javac/diags/examples/RedundantSupertype.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.illegal.default.super.call
+// key: compiler.misc.redundant.supertype
+
+class RedundantSupertype {
+    interface I { default void m() {  } }
+    interface J extends I { default void m() {  } }
+
+    static class C implements I, J {
+        void foo() { I.super.m(); }
+    }
+}
diff --git a/test/tools/javac/diags/examples/RefAmbiguousFragment.java b/test/tools/javac/diags/examples/RefAmbiguousFragment.java
new file mode 100644
index 0000000..7909002
--- /dev/null
+++ b/test/tools/javac/diags/examples/RefAmbiguousFragment.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ * 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.ref.ambiguous
+// key: compiler.misc.invalid.mref
+
+class RefAmbiguousFragment {
+
+    interface SAM {
+        void m(Integer i1, Integer i2);
+    }
+
+    void f(Number n, Integer i) { }
+    void f(Integer i, Number n) { }
+
+    void test() {
+        SAM s = RefAmbiguousFragment::f;
+    }
+}
diff --git a/test/tools/javac/diags/examples/RefBadParens.java b/test/tools/javac/diags/examples/RefBadParens.java
new file mode 100644
index 0000000..813f1ed
--- /dev/null
+++ b/test/tools/javac/diags/examples/RefBadParens.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.ref.bad.parens
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see #m((int)) */
+class RefBadParens { }
+
diff --git a/test/tools/javac/diags/examples/RefIdentifierExpected.java b/test/tools/javac/diags/examples/RefIdentifierExpected.java
new file mode 100644
index 0000000..7028076
--- /dev/null
+++ b/test/tools/javac/diags/examples/RefIdentifierExpected.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * 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.dc.identifier.expected
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+class IdentifierExpected2 {
+    /** @param 123 */
+    void m() { }
+}
+
diff --git a/test/tools/javac/diags/examples/RefSyntaxError.java b/test/tools/javac/diags/examples/RefSyntaxError.java
new file mode 100644
index 0000000..dc84314
--- /dev/null
+++ b/test/tools/javac/diags/examples/RefSyntaxError.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.ref.syntax.error
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see #m(int [) */
+class RefSyntaxError { }
+
diff --git a/test/tools/javac/diags/examples/RefUnexpectedInput.java b/test/tools/javac/diags/examples/RefUnexpectedInput.java
new file mode 100644
index 0000000..aa09b3b
--- /dev/null
+++ b/test/tools/javac/diags/examples/RefUnexpectedInput.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.ref.unexpected.input
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see String#isEmpty% */
+class UnexpectedInput { }
+
diff --git a/test/tools/javac/diags/examples/RepeatableDocumentedMismatch.java b/test/tools/javac/diags/examples/RepeatableDocumentedMismatch.java
new file mode 100644
index 0000000..0329acf
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableDocumentedMismatch.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.repeatable.annotation.not.documented
+
+import java.lang.annotation.*;
+
+ at Documented
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); }
+
+ at Anno
+ at Anno
+class RepeatableDocumentedMismatch { }
diff --git a/test/tools/javac/diags/examples/RepeatableInheritedMismatch.java b/test/tools/javac/diags/examples/RepeatableInheritedMismatch.java
new file mode 100644
index 0000000..57ad170
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableInheritedMismatch.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.repeatable.annotation.not.inherited
+
+import java.lang.annotation.*;
+
+ at Inherited
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); }
+
+ at Anno
+ at Anno
+class RepeatableInheritedMismatch { }
diff --git a/test/tools/javac/diags/examples/RepeatableNoValue.java b/test/tools/javac/diags/examples/RepeatableNoValue.java
new file mode 100644
index 0000000..01f8871
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableNoValue.java
@@ -0,0 +1,35 @@
+/*
+ * 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.invalid.repeatable.annotation.no.value
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos {}
+
+ at Anno
+ at Anno
+class RepeatableNoValue { }
diff --git a/test/tools/javac/diags/examples/RepeatableNonDefault.java b/test/tools/javac/diags/examples/RepeatableNonDefault.java
new file mode 100644
index 0000000..bbf2ce5
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableNonDefault.java
@@ -0,0 +1,33 @@
+/*
+ * 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.invalid.repeatable.annotation.elem.nondefault
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); String foo(); }
+
+class RepeatableNonDefault { }
diff --git a/test/tools/javac/diags/examples/RepeatableRetentionMismatch.java b/test/tools/javac/diags/examples/RepeatableRetentionMismatch.java
new file mode 100644
index 0000000..47a19e2
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableRetentionMismatch.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.repeatable.annotation.retention
+
+import java.lang.annotation.*;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); }
+
+ at Anno
+ at Anno
+class RepeatableRetentionMismatch { }
diff --git a/test/tools/javac/diags/examples/RepeatableTargetMismatch.java b/test/tools/javac/diags/examples/RepeatableTargetMismatch.java
new file mode 100644
index 0000000..d16cad2
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableTargetMismatch.java
@@ -0,0 +1,34 @@
+/*
+ * 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.invalid.repeatable.annotation.incompatible.target
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at Target(ElementType.METHOD)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); }
+
+class RepeatableTargetMismatch { }
diff --git a/test/tools/javac/diags/examples/RepeatableWrongValueType.java b/test/tools/javac/diags/examples/RepeatableWrongValueType.java
new file mode 100644
index 0000000..583e015
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatableWrongValueType.java
@@ -0,0 +1,35 @@
+/*
+ * 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.invalid.repeatable.annotation.value.return
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { String value(); }
+
+ at Anno
+ at Anno
+class RepeatableWrongValueType { }
diff --git a/test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java b/test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java
new file mode 100644
index 0000000..dec4b59
--- /dev/null
+++ b/test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.repeatable.annotation.repeated.and.container.present
+
+import java.lang.annotation.*;
+
+ at Repeatable(Annos.class)
+ at interface Anno { }
+
+ at interface Annos { Anno[] value(); }
+
+ at Anno
+ at Anno
+ at Annos(@Anno)
+class RepeatingAnnotationAndContainer { }
diff --git a/test/tools/javac/diags/examples/ResourceNotApplicableToType.java b/test/tools/javac/diags/examples/ResourceNotApplicableToType.java
index f34477e..eb4e01e 100644
--- a/test/tools/javac/diags/examples/ResourceNotApplicableToType.java
+++ b/test/tools/javac/diags/examples/ResourceNotApplicableToType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,6 +23,7 @@
 
 // key: compiler.misc.try.not.applicable.to.type
 // key: compiler.err.prob.found.req
+// key: compiler.misc.inconvertible.types
 
 class ResourceNotApplicableToType {
     void m() {
diff --git a/test/tools/javac/diags/examples/StaticBoundMref.java b/test/tools/javac/diags/examples/StaticBoundMref.java
new file mode 100644
index 0000000..e53ce7d
--- /dev/null
+++ b/test/tools/javac/diags/examples/StaticBoundMref.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.invalid.mref
+// key: compiler.misc.static.bound.mref
+
+class StaticBoundMref {
+
+    Runnable r = new StaticBoundMref()::m;
+
+    static void m() { }
+}
diff --git a/test/tools/javac/diags/examples/StaticIntfMethodNotSupported.java b/test/tools/javac/diags/examples/StaticIntfMethodNotSupported.java
new file mode 100644
index 0000000..4cd3061
--- /dev/null
+++ b/test/tools/javac/diags/examples/StaticIntfMethodNotSupported.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ *
+ * 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.static.intf.methods.not.supported.in.source
+// options: -source 7 -Xlint:-options -XDallowStaticInterfaceMethods
+
+interface StaticIntfMethodNotSupported {
+    static void m() { }
+}
diff --git a/test/tools/javac/diags/examples/StaticMethodInUnboundLookup.java b/test/tools/javac/diags/examples/StaticMethodInUnboundLookup.java
new file mode 100644
index 0000000..227bc6f
--- /dev/null
+++ b/test/tools/javac/diags/examples/StaticMethodInUnboundLookup.java
@@ -0,0 +1,36 @@
+/*
+ * 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.invalid.mref
+// key: compiler.misc.static.method.in.unbound.lookup
+
+class StaticBoundMref {
+
+    interface SAM {
+        void m(StaticBoundMref m);
+    }
+
+    SAM s = StaticBoundMref::m;
+
+    static void m() { }
+}
diff --git a/test/tools/javac/diags/examples/StaticMrefWithTargs.java b/test/tools/javac/diags/examples/StaticMrefWithTargs.java
new file mode 100644
index 0000000..a033291
--- /dev/null
+++ b/test/tools/javac/diags/examples/StaticMrefWithTargs.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.invalid.mref
+// key: compiler.misc.static.mref.with.targs
+
+class StaticMrefWithTargs<X> {
+
+    Runnable r = StaticMrefWithTargs<String>::m;
+
+    static void m() { }
+}
diff --git a/test/tools/javac/diags/examples/ThisAsIdentifier.java b/test/tools/javac/diags/examples/ThisAsIdentifier.java
new file mode 100644
index 0000000..cb3be61
--- /dev/null
+++ b/test/tools/javac/diags/examples/ThisAsIdentifier.java
@@ -0,0 +1,28 @@
+/*
+ * 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.this.as.identifier
+
+class ThisAsIdentifier {
+    Object this;
+}
diff --git a/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java b/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java
new file mode 100644
index 0000000..16e6b8b
--- /dev/null
+++ b/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.type.annotations.not.supported.in.source
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 6
+
+ at interface Anno { }
+
+class TypeAnnotationsNotSupported {
+    void m() {
+        int i = (@Anno int) 3.14;
+    }
+}
diff --git a/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java b/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java
new file mode 100644
index 0000000..d94a88e
--- /dev/null
+++ b/test/tools/javac/diags/examples/TypesIncompatibleAbstractDefault.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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.types.incompatible.abstract.default
+
+class TypesIncompatibleAbstractDefault {
+    interface A {
+        default void m() { }
+    }
+
+    interface B {
+        void m();
+    }
+
+    interface AB extends A, B { }
+}
diff --git a/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java b/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java
new file mode 100644
index 0000000..28c75bc
--- /dev/null
+++ b/test/tools/javac/diags/examples/TypesIncompatibleUnrelatedDefaults.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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.types.incompatible.unrelated.defaults
+
+class TypesIncompatibleUnrelatedDefaults {
+    interface A {
+        default void m() { }
+    }
+
+    interface B {
+        default void m() { }
+    }
+
+    interface AB extends A, B { }
+}
diff --git a/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java b/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java
new file mode 100644
index 0000000..91c939c
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java
@@ -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.warn.underscore.as.identifier
+
+class UnderscoreAsIdentifier {
+    String _ = null;
+}
diff --git a/test/tools/javac/diags/examples/UndeterminedType1.java b/test/tools/javac/diags/examples/UndeterminedType1.java
deleted file mode 100644
index 0339d10..0000000
--- a/test/tools/javac/diags/examples/UndeterminedType1.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, 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.undetermined.type.1
-// key: compiler.misc.no.unique.maximal.instance.exists
-
-class UndeterminedType1<V> {
-    <T extends Integer & Runnable> UndeterminedType1<T> m() {
-        return null;
-    }
-
-
-    UndeterminedType1<? extends String> c2 = m();
-}
diff --git a/test/tools/javac/diags/examples/UnexpectedContent.java b/test/tools/javac/diags/examples/UnexpectedContent.java
new file mode 100644
index 0000000..26ed303
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnexpectedContent.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.unexpected.content
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** {@docRoot a} */
+class UnterminatedSignature { }
+
diff --git a/test/tools/javac/diags/examples/UnexpectedLambda.java b/test/tools/javac/diags/examples/UnexpectedLambda.java
new file mode 100644
index 0000000..e1c2783
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnexpectedLambda.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * 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.unexpected.lambda
+
+class UnexpectedLambda {
+    { (()-> { })++; }
+}
diff --git a/test/tools/javac/diags/examples/UnexpectedMref.java b/test/tools/javac/diags/examples/UnexpectedMref.java
new file mode 100644
index 0000000..9cc21d9
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnexpectedMref.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * 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.unexpected.mref
+
+class UnexpectedLambda {
+    { (Foo::bar)++; }
+}
diff --git a/test/tools/javac/diags/examples/UnexpectedReturnValue.java b/test/tools/javac/diags/examples/UnexpectedReturnValue.java
new file mode 100644
index 0000000..6327d32
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnexpectedReturnValue.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.unexpected.ret.val
+
+class UnexpectedReturnValue {
+    void m() {
+        return 3;
+    }
+}
diff --git a/test/tools/javac/diags/examples/UnsupportedEncoding.java b/test/tools/javac/diags/examples/UnsupportedEncoding.java
index af32e9f..49b0862 100644
--- a/test/tools/javac/diags/examples/UnsupportedEncoding.java
+++ b/test/tools/javac/diags/examples/UnsupportedEncoding.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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,5 +23,6 @@
 
 // key: compiler.err.unsupported.encoding
 // options: -encoding UNSUPPORTED -doe
+// run: simple
 
 class UnsupportedEncoding { }
diff --git a/test/tools/javac/diags/examples/UnterminatedInlineTag.java b/test/tools/javac/diags/examples/UnterminatedInlineTag.java
new file mode 100644
index 0000000..fcaf8f2
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnterminatedInlineTag.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.unterminated.inline.tag
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** {@code */
+class UnterminatedInlineTag { }
+
diff --git a/test/tools/javac/diags/examples/UnterminatedSignature.java b/test/tools/javac/diags/examples/UnterminatedSignature.java
new file mode 100644
index 0000000..7e505d4
--- /dev/null
+++ b/test/tools/javac/diags/examples/UnterminatedSignature.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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.dc.unterminated.signature
+// key: compiler.note.note
+// key: compiler.note.proc.messager
+// run: backdoor
+// options: -processor DocCommentProcessor -proc:only
+
+/** @see String#equals( */
+class UnterminatedSignature { }
+
diff --git a/test/tools/javac/diags/examples/VarargsAndReceiver.java b/test/tools/javac/diags/examples/VarargsAndReceiver.java
new file mode 100644
index 0000000..ae06042
--- /dev/null
+++ b/test/tools/javac/diags/examples/VarargsAndReceiver.java
@@ -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) { }
+}
diff --git a/test/tools/javac/diags/examples/VarargsArgumentMismatch.java b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java
index 62ac552..f9435d1 100644
--- a/test/tools/javac/diags/examples/VarargsArgumentMismatch.java
+++ b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -21,8 +21,9 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.varargs.argument.mismatch
+// key: compiler.misc.inconvertible.types
 
 class VarargsArgumentMismatch {
     void m(String s, Integer... is) {}
diff --git a/test/tools/javac/diags/examples/VerboseResolveMulti.java b/test/tools/javac/diags/examples/VerboseResolveMulti.java
new file mode 100644
index 0000000..59a8d3c
--- /dev/null
+++ b/test/tools/javac/diags/examples/VerboseResolveMulti.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011, 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.misc.applicable.method.found
+// key: compiler.note.verbose.resolve.multi
+// options: -XDverboseResolution=applicable,success
+
+class VerboseResolveMulti {
+
+    void m() {}
+
+    { m(); }
+}
diff --git a/test/tools/javac/diags/examples/VerboseResolveMulti1.java b/test/tools/javac/diags/examples/VerboseResolveMulti1.java
new file mode 100644
index 0000000..99c90e2
--- /dev/null
+++ b/test/tools/javac/diags/examples/VerboseResolveMulti1.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.misc.not.applicable.method.found
+// key: compiler.note.verbose.resolve.multi.1
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.no.conforming.assignment.exists
+// key: compiler.misc.inconvertible.types
+// options: -XDverboseResolution=inapplicable,failure
+
+class VerboseResolveMulti1 {
+
+    void m(int i) {}
+
+    { m(""); }
+}
diff --git a/test/tools/javac/diags/examples/WhereCaptured.java b/test/tools/javac/diags/examples/WhereCaptured.java
index 78ded49..8f64ac9 100644
--- a/test/tools/javac/diags/examples/WhereCaptured.java
+++ b/test/tools/javac/diags/examples/WhereCaptured.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,8 +25,8 @@
 // key: compiler.misc.where.description.captured.1
 // key: compiler.misc.where.description.typevar
 // key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol.1
-// key: compiler.misc.infer.no.conforming.assignment.exists
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
 // key: compiler.misc.captured.type
 // options: -XDdiags=where,simpleNames
 // run: simple
diff --git a/test/tools/javac/diags/examples/WhereCaptured1.java b/test/tools/javac/diags/examples/WhereCaptured1.java
index 28ef10a..b069356 100644
--- a/test/tools/javac/diags/examples/WhereCaptured1.java
+++ b/test/tools/javac/diags/examples/WhereCaptured1.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,8 +25,8 @@
 // key: compiler.misc.where.description.captured.1
 // key: compiler.misc.where.description.typevar
 // key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol.1
-// key: compiler.misc.infer.no.conforming.assignment.exists
+// key: compiler.err.cant.apply.symbol
+// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
 // key: compiler.misc.captured.type
 // key: compiler.misc.type.null
 // options: -XDdiags=where,simpleNames
diff --git a/test/tools/javac/diags/examples/WhereFreshTvar.java b/test/tools/javac/diags/examples/WhereFreshTvar.java
new file mode 100644
index 0000000..92a8157
--- /dev/null
+++ b/test/tools/javac/diags/examples/WhereFreshTvar.java
@@ -0,0 +1,37 @@
+/*
+ * 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.misc.where.fresh.typevar
+// key: compiler.misc.where.description.typevar
+// key: compiler.err.prob.found.req
+// key: compiler.misc.inconvertible.types
+// options: -XDdiags=where,simpleNames
+// run: simple
+
+import java.util.*;
+
+class WhereFreshTvar {
+    <T extends List<T>> T m() {}
+
+    { Object o = (List<String>)m(); }
+}
diff --git a/test/tools/javac/diags/examples/WhereIntersection.java b/test/tools/javac/diags/examples/WhereIntersection.java
index fe58f64..b8b94f8 100644
--- a/test/tools/javac/diags/examples/WhereIntersection.java
+++ b/test/tools/javac/diags/examples/WhereIntersection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -24,8 +24,8 @@
 // key: compiler.misc.where.intersection
 // key: compiler.misc.where.description.intersection
 // key: compiler.misc.intersection.type
-// key: compiler.misc.incompatible.types
 // key: compiler.err.prob.found.req
+// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
 // options: -XDdiags=where
 // run: simple
 
diff --git a/test/tools/javac/diags/examples/WhereTypeVar.java b/test/tools/javac/diags/examples/WhereTypeVar.java
index f7c41d6..f809165 100644
--- a/test/tools/javac/diags/examples/WhereTypeVar.java
+++ b/test/tools/javac/diags/examples/WhereTypeVar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -24,8 +24,9 @@
 // key: compiler.misc.where.typevar
 // key: compiler.misc.where.description.typevar.1
 // key: compiler.misc.type.var
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.no.conforming.assignment.exists
+// key: compiler.misc.inconvertible.types
 // options: -XDdiags=where,disambiguateTvars
 // run: simple
 
diff --git a/test/tools/javac/doclint/DocLintTest.java b/test/tools/javac/doclint/DocLintTest.java
new file mode 100644
index 0000000..7da6e14
--- /dev/null
+++ b/test/tools/javac/doclint/DocLintTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.
+ *
+ * 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 8004833
+ * @summary Integrate doclint support into javac
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import static javax.tools.Diagnostic.Kind.*;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.main.Main;
+import java.util.EnumSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class DocLintTest {
+    public static void main(String... args) throws Exception {
+        new DocLintTest().run();
+    }
+
+    JavaCompiler javac;
+    StandardJavaFileManager fm;
+    JavaFileObject file;
+
+    final String code =
+        /* 01 */    "/** Class comment. */\n" +
+        /* 02 */    "public class Test {\n" +
+        /* 03 */    "    /** Method comment. */\n" +
+        /* 04 */    "    public void method() { }\n" +
+        /* 05 */    "\n" +
+        /* 06 */    "    /** Syntax < error. */\n" +
+        /* 07 */    "    private void syntaxError() { }\n" +
+        /* 08 */    "\n" +
+        /* 09 */    "    /** @see DoesNotExist */\n" +
+        /* 10 */    "    protected void referenceError() { }\n" +
+        /* 08 */    "\n" +
+        /* 09 */    "    /** @return */\n" +
+        /* 10 */    "    public int emptyReturn() { return 0; }\n" +
+        /* 11 */    "}\n";
+
+    final String rawDiags = "-XDrawDiagnostics";
+    private enum Message {
+        // doclint messages
+        DL_ERR6(ERROR, "Test.java:6:16: compiler.err.proc.messager: malformed HTML"),
+        DL_ERR9(ERROR, "Test.java:9:14: compiler.err.proc.messager: reference not found"),
+        DL_WRN12(WARNING, "Test.java:12:9: compiler.warn.proc.messager: no description for @return"),
+
+        OPT_BADARG(ERROR, "invalid flag: -Xdoclint:badarg");
+
+        final Diagnostic.Kind kind;
+        final String text;
+
+        static Message get(String text) {
+            for (Message m: values()) {
+                if (m.text.equals(text))
+                    return m;
+            }
+            return null;
+        }
+
+        Message(Diagnostic.Kind kind, String text) {
+            this.kind = kind;
+            this.text = text;
+        }
+
+        @Override
+        public String toString() {
+            return "[" + kind + ",\"" + text + "\"]";
+        }
+    }
+    void run() throws Exception {
+        javac = ToolProvider.getSystemJavaCompiler();
+        fm = javac.getStandardFileManager(null, null, null);
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+        file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
+            @Override
+            public CharSequence getCharContent(boolean ignoreEncoding) {
+                return code;
+            }
+        };
+
+        test(Collections.<String>emptyList(),
+                Main.Result.OK,
+                EnumSet.noneOf(Message.class));
+
+        test(Arrays.asList("-Xdoclint:none"),
+                Main.Result.OK,
+                EnumSet.noneOf(Message.class));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
+                Main.Result.OK,
+                EnumSet.of(Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR9));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
+                Main.Result.CMDERR,
+                EnumSet.of(Message.OPT_BADARG));
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
+        System.err.println("test: " + opts);
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        List<JavaFileObject> files = Arrays.asList(file);
+        try {
+            JavacTask t = (JavacTask) javac.getTask(pw, fm, null, opts, null, files);
+            boolean ok = t.call();
+            pw.close();
+            String out = sw.toString().replaceAll("[\r\n]+", "\n");
+            if (!out.isEmpty())
+                System.err.println(out);
+            if (ok && expectResult != Main.Result.OK) {
+                error("Compilation succeeded unexpectedly");
+            } else if (!ok && expectResult != Main.Result.ERROR) {
+                error("Compilation failed unexpectedly");
+            } else
+                check(out, expectMessages);
+        } catch (IllegalArgumentException e) {
+            System.err.println(e);
+            String expectOut = expectMessages.iterator().next().text;
+            if (expectResult != Main.Result.CMDERR)
+                error("unexpected exception caught");
+            else if (!e.getMessage().equals(expectOut)) {
+                error("unexpected exception message: "
+                        + e.getMessage()
+                        + " expected: " + expectOut);
+            }
+        }
+
+//        if (errors > 0)
+//            throw new Error("stop");
+    }
+
+    private void check(String out, Set<Message> expect) {
+        Pattern stats = Pattern.compile("^([1-9]+) (error|warning)(s?)");
+        Set<Message> found = EnumSet.noneOf(Message.class);
+        int e = 0, w = 0;
+        if (!out.isEmpty()) {
+            for (String line: out.split("[\r\n]+")) {
+                Matcher s = stats.matcher(line);
+                if (s.matches()) {
+                    int i = Integer.valueOf(s.group(1));
+                    if (s.group(2).equals("error"))
+                        e++;
+                    else
+                        w++;
+                    continue;
+                }
+
+                Message m = Message.get(line);
+                if (m == null)
+                    error("Unexpected line: " + line);
+                else
+                    found.add(m);
+            }
+        }
+        for (Message m: expect) {
+            if (!found.contains(m))
+                error("expected message not found: " + m.text);
+        }
+        for (Message m: found) {
+            if (!expect.contains(m))
+                error("unexpected message found: " + m.text);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javac/doclint/ImplicitHeadersTest.java b/test/tools/javac/doclint/ImplicitHeadersTest.java
new file mode 100644
index 0000000..e80b88c
--- /dev/null
+++ b/test/tools/javac/doclint/ImplicitHeadersTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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 8006346
+ * @summary doclint should make allowance for headers generated by standard doclet
+ * @compile -Xdoclint:all/public ImplicitHeadersTest.java
+ */
+
+/**
+ * <h3> Header </h3>
+ */
+public class ImplicitHeadersTest { }
+
diff --git a/test/tools/javac/doctree/AttrTest.java b/test/tools/javac/doctree/AttrTest.java
new file mode 100644
index 0000000..2e13a16
--- /dev/null
+++ b/test/tools/javac/doctree/AttrTest.java
@@ -0,0 +1,281 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester AttrTest.java
+ */
+
+class AttrTest {
+    /**
+     * <a name=unquoted>foo</a>
+     */
+    void unquoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: UNQUOTED
+          value: 1
+            Text[TEXT, pos:9, unquoted]
+        ]
+    ]
+    Text[TEXT, pos:18, foo]
+    EndElement[END_ELEMENT, pos:21, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name="double_quoted">foo</a>
+     */
+    void double_quoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: DOUBLE
+          value: 1
+            Text[TEXT, pos:10, double_quoted]
+        ]
+    ]
+    Text[TEXT, pos:25, foo]
+    EndElement[END_ELEMENT, pos:28, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name='single_quoted'>foo</a>
+     */
+    void single_quoted_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: SINGLE
+          value: 1
+            Text[TEXT, pos:10, single_quoted]
+        ]
+    ]
+    Text[TEXT, pos:25, foo]
+    EndElement[END_ELEMENT, pos:28, a]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <hr size="3">
+     */
+    void numeric_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:5
+          name: size
+          vkind: DOUBLE
+          value: 1
+            Text[TEXT, pos:11, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a href="{@docRoot}/index.html">
+     */
+    void docRoot_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: href
+          vkind: DOUBLE
+          value: 2
+            DocRoot[DOC_ROOT, pos:10]
+            Text[TEXT, pos:20, /index.html]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <a name="abc"def">
+     */
+    void entity_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:a
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:4
+          name: name
+          vkind: DOUBLE
+          value: 3
+            Text[TEXT, pos:10, abc]
+            Entity[ENTITY, pos:13, quot]
+            Text[TEXT, pos:19, def]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * <hr noshade>
+     */
+    void no_value_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    StartElement[START_ELEMENT, pos:1
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:5
+          name: noshade
+          vkind: EMPTY
+          value: null
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size='3'/>
+     */
+    void self_closing_attr_1() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:9
+          name: size
+          vkind: SINGLE
+          value: 1
+            Text[TEXT, pos:15, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size=3 />
+     */
+    void self_closing_attr_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: 1
+        Attribute[ATTRIBUTE, pos:9
+          name: size
+          vkind: UNQUOTED
+          value: 1
+            Text[TEXT, pos:14, 3]
+        ]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size="3
+     */
+    void unterminated_attr_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr_size="3]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr size="3
+     * @author jjg
+     */
+    void unterminated_attr_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr_size="3]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:18
+      name: 1
+        Text[TEXT, pos:26, jjg]
+    ]
+]
+*/
+}
diff --git a/test/tools/javac/doctree/AuthorTest.java b/test/tools/javac/doctree/AuthorTest.java
new file mode 100644
index 0000000..daec9cf
--- /dev/null
+++ b/test/tools/javac/doctree/AuthorTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester AuthorTest.java
+ */
+
+class AuthorTest {
+    /** abc @author jjg & others */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, abc_ at author_jjg_]
+    Entity[ENTITY, pos:16, amp]
+    Text[TEXT, pos:21, _others]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/BadTest.java b/test/tools/javac/doctree/BadTest.java
new file mode 100644
index 0000000..86aa6aa
--- /dev/null
+++ b/test/tools/javac/doctree/BadTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester Bad.java
+ */
+
+class BadTest {
+
+    /**
+     * abc {@value java.awt.Color#RED junk}
+     */
+    int trailing_junk() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.unexpected.content
+      body: {@value_java.awt.Color#RED_j
+    ]
+    Text[TEXT, pos:33, unk}]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/CodeTest.java b/test/tools/javac/doctree/CodeTest.java
new file mode 100644
index 0000000..29781fc
--- /dev/null
+++ b/test/tools/javac/doctree/CodeTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester CodeTest.java
+ */
+
+class CodeTest {
+    /** {@code if (a < b) { }} */
+    void minimal() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Literal[CODE, pos:0, if_(a_<_b)_{_}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [{@code if (a < b) { }}] */
+    void in_brackets() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, []
+    Literal[CODE, pos:1, if_(a_<_b)_{_}]
+    Text[TEXT, pos:23, ]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [ {@code if (a < b) { }} ] */
+    void in_brackets_with_whitespace() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, [_]
+    Literal[CODE, pos:2, if_(a_<_b)_{_}]
+    Text[TEXT, pos:24, _]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code {@code nested} }
+     */
+    void nested() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[CODE, pos:1, {@code_nested}_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code if (a < b) {
+     *        }
+     * }
+     */
+    void embedded_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[CODE, pos:1, if_(a_<_b)_{|________}|_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** {@code if (a < b) { } */
+    void unterminated_1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:0
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@code_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@code if (a < b) { }
+     * @author jjg */
+    void unterminated_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@code_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:24
+      name: 1
+        Text[TEXT, pos:32, jjg]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/DeprecatedTest.java b/test/tools/javac/doctree/DeprecatedTest.java
new file mode 100644
index 0000000..cb26eea
--- /dev/null
+++ b/test/tools/javac/doctree/DeprecatedTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester DeprecatedTest.java
+ */
+
+class DeprecatedTest {
+    /**
+     * @deprecated
+     */
+    void deprecated() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Deprecated[DEPRECATED, pos:1
+      body: empty
+    ]
+]
+*/
+
+    /**
+     * @deprecated text
+     */
+    void deprecated_text() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Deprecated[DEPRECATED, pos:1
+      body: 1
+        Text[TEXT, pos:13, text]
+    ]
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/DocCommentTester.java b/test/tools/javac/doctree/DocCommentTester.java
new file mode 100644
index 0000000..8a6775a
--- /dev/null
+++ b/test/tools/javac/doctree/DocCommentTester.java
@@ -0,0 +1,779 @@
+/*
+ * 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.
+ *
+ * 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.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.doctree.*;
+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.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 com.sun.tools.javac.tree.DCTree;
+import com.sun.tools.javac.tree.DCTree.DCDocComment;
+import com.sun.tools.javac.tree.DCTree.DCErroneous;
+import com.sun.tools.javac.tree.DocPretty;
+
+public class DocCommentTester {
+
+    public static void main(String... args) throws Exception {
+        new DocCommentTester().run(args);
+    }
+
+    public void run(String... args) throws Exception {
+        String testSrc = System.getProperty("test.src");
+
+        List<File> files = new ArrayList<File>();
+        for (String arg: args)
+            files.add(new File(testSrc, arg));
+
+        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);
+        final DocTrees trees = DocTrees.instance(t);
+
+        final Checker[] checkers = {
+            new ASTChecker(this, trees),
+            new PosChecker(this, trees),
+            new PrettyChecker(this, trees)
+        };
+
+        DeclScanner d = new DeclScanner() {
+            @Override
+            public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+                for (Checker c: checkers)
+                    c.visitCompilationUnit(tree);
+                return super.visitCompilationUnit(tree, ignore);
+            }
+
+            @Override
+            void visitDecl(Tree tree, Name name) {
+                TreePath path = getCurrentPath();
+                String dc = trees.getDocComment(path);
+                if (dc != null) {
+                    for (Checker c : checkers) {
+                        try {
+                            System.err.println(path.getLeaf().getKind()
+                                    + " " + name
+                                    + " " + c.getClass().getSimpleName());
+
+                            c.check(path, name);
+
+                            System.err.println();
+                        } catch (Exception e) {
+                            error("Exception " + e);
+                            e.printStackTrace(System.err);
+                        }
+                    }
+                }
+            }
+        };
+
+        Iterable<? extends CompilationUnitTree> units = t.parse();
+        for (CompilationUnitTree unit: units) {
+            d.scan(unit, null);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static abstract class DeclScanner extends TreePathScanner<Void, Void> {
+        abstract void visitDecl(Tree tree, Name name);
+
+        @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;
+        }
+    }
+
+    /**
+     * Base class for checkers to check the doc comment on a declaration
+     * (when present.)
+     */
+    abstract class Checker {
+        final DocTrees trees;
+
+        Checker(DocTrees trees) {
+            this.trees = trees;
+        }
+
+        void visitCompilationUnit(CompilationUnitTree tree) { }
+
+        abstract void check(TreePath tree, Name name) throws Exception;
+
+        void error(String msg) {
+            DocCommentTester.this.error(msg);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    /**
+     * Verify the structure of the DocTree AST by comparing it against golden text.
+     */
+    static class ASTChecker extends Checker {
+        static final String NEWLINE = System.getProperty("line.separator");
+        Printer printer = new Printer();
+        String source;
+
+        ASTChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void visitCompilationUnit(CompilationUnitTree tree) {
+            try {
+                source = tree.getSourceFile().getCharContent(true).toString();
+            } catch (IOException e) {
+                source = "";
+            }
+        }
+
+        void check(TreePath path, Name name) {
+            StringWriter out = new StringWriter();
+            DocCommentTree dc = trees.getDocCommentTree(path);
+            printer.print(dc, out);
+            out.flush();
+            String found = out.toString().replace(NEWLINE, "\n");
+
+            // Look for the first block comment after the first occurrence of name
+            int start = source.indexOf("\n/*\n", findName(source, name));
+            int end = source.indexOf("\n*/\n", start);
+            String expect = source.substring(start + 4, end + 1);
+            if (!found.equals(expect)) {
+                System.err.println("Expect:\n" + expect);
+                System.err.println("Found:\n" + found);
+                error("AST mismatch for " + name);
+            }
+        }
+
+        /**
+         * This main program is to set up the golden comments used by this
+         * checker.
+         * Usage:
+         *     java DocCommentTester$ASTChecker -o dir file...
+         * The given files are written to the output directory with their
+         * golden comments updated. The intent is that the files should
+         * then be compared with the originals, e.g. with meld, and if the
+         * changes are approved, the new files can be used to replace the old.
+         */
+        public static void main(String... args) throws Exception {
+            List<File> files = new ArrayList<File>();
+            File o = null;
+            for (int i = 0; i < args.length; i++) {
+                String arg = args[i];
+                if (arg.equals("-o"))
+                    o = new File(args[++i]);
+                else if (arg.startsWith("-"))
+                    throw new IllegalArgumentException(arg);
+                else {
+                    files.add(new File(arg));
+                }
+            }
+
+            if (o == null)
+                throw new IllegalArgumentException("no output dir specified");
+            final File outDir = o;
+
+            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);
+            final DocTrees trees = DocTrees.instance(t);
+
+            DeclScanner d = new DeclScanner() {
+                Printer p = new Printer();
+                String source;
+
+                @Override
+                public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+                    System.err.println("processing " + tree.getSourceFile().getName());
+                    try {
+                        source = tree.getSourceFile().getCharContent(true).toString();
+                    } catch (IOException e) {
+                        source = "";
+                    }
+
+                    // remove existing gold by removing all block comments after the first '{'.
+                    int start = source.indexOf("{");
+                    while ((start = source.indexOf("\n/*\n", start)) != -1) {
+                        int end = source.indexOf("\n*/\n");
+                        source = source.substring(0, start + 1) + source.substring(end + 4);
+                    }
+
+                    // process decls in compilation unit
+                    super.visitCompilationUnit(tree, ignore);
+
+                    // write the modified source
+                    File f = new File(tree.getSourceFile().getName());
+                    File outFile = new File(outDir, f.getName());
+                    try {
+                        FileWriter out = new FileWriter(outFile);
+                        try {
+                            out.write(source);
+                        } finally {
+                            out.close();
+                        }
+                    } catch (IOException e) {
+                        System.err.println("Can't write " + tree.getSourceFile().getName()
+                                + " to " + outFile + ": " + e);
+                    }
+                    return null;
+                }
+
+                @Override
+                void visitDecl(Tree tree, Name name) {
+                    DocTree dc = trees.getDocCommentTree(getCurrentPath());
+                    if (dc != null) {
+                        StringWriter out = new StringWriter();
+                        p.print(dc, out);
+                        String found = out.toString();
+
+                        // Look for the empty line after the first occurrence of name
+                        int pos = source.indexOf("\n\n", findName(source, name));
+
+                        // Insert the golden comment
+                        source = source.substring(0, pos)
+                                + "\n/*\n"
+                                + found
+                                + "*/"
+                                + source.substring(pos);
+                    }
+                }
+
+            };
+
+            Iterable<? extends CompilationUnitTree> units = t.parse();
+            for (CompilationUnitTree unit: units) {
+                d.scan(unit, null);
+            }
+        }
+
+        static int findName(String source, Name name) {
+            Pattern p = Pattern.compile("\\s" + name + "[(;]");
+            Matcher m = p.matcher(source);
+            if (!m.find())
+                throw new Error("cannot find " + name);
+            return m.start();
+        }
+
+        static class Printer implements DocTreeVisitor<Void, Void> {
+            PrintWriter out;
+
+            void print(DocTree tree, Writer out) {
+                this.out = (out instanceof PrintWriter)
+                        ? (PrintWriter) out : new PrintWriter(out);
+                tree.accept(this, null);
+                this.out.flush();
+            }
+
+            public Void visitAttribute(AttributeTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName().toString());
+                print("vkind", node.getValueKind().toString());
+                print("value", node.getValue());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitAuthor(AuthorTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitComment(CommentTree node, Void p) {
+                header(node, compress(node.getBody()));
+                return null;
+            }
+
+            public Void visitDeprecated(DeprecatedTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitDocComment(DocCommentTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("firstSentence", node.getFirstSentence());
+                print("body", node.getBody());
+                print("block tags", node.getBlockTags());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitDocRoot(DocRootTree node, Void p) {
+                header(node, "");
+                return null;
+            }
+
+            public Void visitEndElement(EndElementTree node, Void p) {
+                header(node, node.getName().toString());
+                return null;
+            }
+
+            public Void visitEntity(EntityTree node, Void p) {
+                header(node, node.getName().toString());
+                return null;
+            }
+
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("code", ((DCErroneous) node).diag.getCode());
+                print("body", compress(node.getBody()));
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitIdentifier(IdentifierTree node, Void p) {
+                header(node, compress(node.getName().toString()));
+                return null;
+            }
+
+            public Void visitInheritDoc(InheritDocTree node, Void p) {
+                header(node, "");
+                return null;
+            }
+
+            public Void visitLink(LinkTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                print("body", node.getLabel());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitLiteral(LiteralTree node, Void p) {
+                header(node, compress(node.getBody().getBody()));
+                return null;
+            }
+
+            public Void visitParam(ParamTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitReference(ReferenceTree node, Void p) {
+                header(node, compress(node.getSignature()));
+                return null;
+            }
+
+            public Void visitReturn(ReturnTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSee(SeeTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerial(SerialTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerialData(SerialDataTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSerialField(SerialFieldTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("name", node.getName());
+                print("type", node.getType());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitSince(SinceTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitStartElement(StartElementTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("name:" + node.getName());
+                print("attributes", node.getAttributes());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitText(TextTree node, Void p) {
+                header(node, compress(node.getBody()));
+                return null;
+            }
+
+            public Void visitThrows(ThrowsTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("exceptionName", node.getExceptionName());
+                print("description", node.getDescription());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("tag:" + node.getTagName());
+                print("content", node.getContent());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
+                header(node);
+                indent(+1);
+                indent();
+                out.println("tag:" + node.getTagName());
+                print("content", node.getContent());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitValue(ValueTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("reference", node.getReference());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitVersion(VersionTree node, Void p) {
+                header(node);
+                indent(+1);
+                print("body", node.getBody());
+                indent(-1);
+                indent();
+                out.println("]");
+                return null;
+            }
+
+            public Void visitOther(DocTree node, Void p) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            void header(DocTree node) {
+                indent();
+                out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos);
+            }
+
+            void header(DocTree node, String rest) {
+                indent();
+                out.println(simpleClassName(node) + "[" + node.getKind() + ", pos:" + ((DCTree) node).pos
+                        + (rest.isEmpty() ? "" : ", " + rest)
+                        + "]");
+            }
+
+            String simpleClassName(DocTree node) {
+                return node.getClass().getSimpleName().replaceAll("DC(.*)", "$1");
+            }
+
+            void print(String name, DocTree item) {
+                indent();
+                if (item == null)
+                    out.println(name + ": null");
+                else {
+                    out.println(name + ":");
+                    indent(+1);
+                    item.accept(this, null);
+                    indent(-1);
+                }
+            }
+
+            void print(String name, String s) {
+                indent();
+                out.println(name + ": " + s);
+            }
+
+            void print(String name, List<? extends DocTree> list) {
+                indent();
+                if (list == null)
+                    out.println(name + ": null");
+                else if (list.isEmpty())
+                    out.println(name + ": empty");
+                else {
+                    out.println(name + ": " + list.size());
+                    indent(+1);
+                    for (DocTree tree: list) {
+                        tree.accept(this, null);
+                    }
+                    indent(-1);
+                }
+            }
+
+            int indent = 0;
+
+            void indent() {
+                for (int i = 0; i < indent; i++) {
+                    out.print("  ");
+                }
+            }
+
+            void indent(int n) {
+                indent += n;
+            }
+
+            String compress(String s) {
+                s = s.replace("\n", "|").replace(" ", "_");
+                return (s.length() < 32)
+                        ? s
+                        : s.substring(0, 16) + "..." + s.substring(16);
+            }
+
+            String quote(String s) {
+                if (s.contains("\""))
+                    return "'" + s + "'";
+                else if (s.contains("'") || s.contains(" "))
+                    return '"' + s + '"';
+                else
+                    return s;
+            }
+
+
+        }
+    }
+
+    /**
+     * Verify the reported tree positions by comparing the characters found
+     * at and after the reported position with the beginning of the pretty-
+     * printed text.
+     */
+    static class PosChecker extends Checker {
+        PosChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void check(TreePath path, Name name) throws Exception {
+            JavaFileObject fo = path.getCompilationUnit().getSourceFile();
+            final CharSequence cs = fo.getCharContent(true);
+
+            final DCDocComment dc = (DCDocComment) trees.getDocCommentTree(path);
+            DCTree t = (DCTree) trees.getDocCommentTree(path);
+
+            DocTreeScanner scanner = new DocTreeScanner<Void,Void>() {
+                @Override
+                public Void scan(DocTree node, Void ignore) {
+                    if (node != null) {
+                        try {
+                            String expect = getExpectText(node);
+                            long pos = ((DCTree) node).getSourcePosition(dc);
+                            String found = getFoundText(cs, (int) pos, expect.length());
+                            if (!found.equals(expect)) {
+                                System.err.println("expect: " + expect);
+                                System.err.println("found:  " + found);
+                                error("mismatch");
+                            }
+
+                        } catch (StringIndexOutOfBoundsException e) {
+                            error(node.getClass() + ": " + e.toString());
+                                e.printStackTrace();
+                        }
+                    }
+                    return super.scan(node, ignore);
+                }
+            };
+
+            scanner.scan(t, null);
+        }
+
+        String getExpectText(DocTree t) {
+            StringWriter sw = new StringWriter();
+            DocPretty p = new DocPretty(sw);
+            try { p.print(t); } catch (IOException never) { }
+            String s = sw.toString();
+            if (s.length() <= 1)
+                return s;
+            int ws = s.replaceAll("\\s+", " ").indexOf(" ");
+            if (ws != -1) s = s.substring(0, ws);
+            return (s.length() < 5) ? s : s.substring(0, 5);
+        }
+
+        String getFoundText(CharSequence cs, int pos, int len) {
+            return (pos == -1) ? "" : cs.subSequence(pos, Math.min(pos + len, cs.length())).toString();
+        }
+    }
+
+    /**
+     * Verify the pretty printed text against a normalized form of the
+     * original doc comment.
+     */
+    static class PrettyChecker extends Checker {
+
+        PrettyChecker(DocCommentTester test, DocTrees t) {
+            test.super(t);
+        }
+
+        @Override
+        void check(TreePath path, Name name) throws Exception {
+            String raw = trees.getDocComment(path);
+            String normRaw = normalize(raw);
+
+            StringWriter out = new StringWriter();
+            DocPretty dp = new DocPretty(out);
+            dp.print(trees.getDocCommentTree(path));
+            String pretty = out.toString();
+
+            if (!pretty.equals(normRaw)) {
+                error("mismatch");
+                System.err.println("*** expected:");
+                System.err.println(normRaw.replace(" ", "_"));
+                System.err.println("*** found:");
+                System.err.println(pretty.replace(" ", "_"));
+    //            throw new Error();
+            }
+        }
+
+        /**
+         * Normalize white space in places where the tree does not preserve it.
+         */
+        String normalize(String s) {
+            return s.trim()
+                    .replaceFirst("\\.\\s++([^@])", ". $1")
+                    .replaceFirst("\\.\\s*\\n *@", ".\n@")
+                    .replaceFirst("\\s+<(/?p|pre|h[1-6])>", " <$1>")
+                    .replaceAll("\\{@docRoot\\s+\\}", "{@docRoot}")
+                    .replaceAll("\\{@inheritDoc\\s+\\}", "{@inheritDoc}")
+                    .replaceAll("(\\{@value\\s+[^}]+)\\s+(\\})", "$1$2")
+                    .replaceAll("\n[ \t]+@", "\n@");
+        }
+
+    }
+
+}
+
diff --git a/test/tools/javac/doctree/DocRootTest.java b/test/tools/javac/doctree/DocRootTest.java
new file mode 100644
index 0000000..2c3f9a7
--- /dev/null
+++ b/test/tools/javac/doctree/DocRootTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester DocRootTest.java
+ */
+
+class DocRootTest {
+    /** abc {@docRoot} */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot } */
+    void standard_ws1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot  } */
+    void standard_ws2() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    DocRoot[DOC_ROOT, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@docRoot junk} */
+    void error() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    Erroneous[ERRONEOUS, pos:4
+      code: compiler.err.dc.unexpected.content
+      body: {@docRoot_junk}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/DocTreePathScannerTest.java b/test/tools/javac/doctree/DocTreePathScannerTest.java
new file mode 100644
index 0000000..5261a0a
--- /dev/null
+++ b/test/tools/javac/doctree/DocTreePathScannerTest.java
@@ -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);
+        }
+    }
+
+}
diff --git a/test/tools/javac/doctree/ElementTest.java b/test/tools/javac/doctree/ElementTest.java
new file mode 100644
index 0000000..2228a76
--- /dev/null
+++ b/test/tools/javac/doctree/ElementTest.java
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ElementTest.java
+ */
+
+class ElementTest {
+    /**
+     * <p>para</p>
+     */
+    void simple() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: 3
+    StartElement[START_ELEMENT, pos:1
+      name:p
+      attributes: empty
+    ]
+    Text[TEXT, pos:4, para]
+    EndElement[END_ELEMENT, pos:8, p]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr/>
+     */
+    void self_closing() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    StartElement[START_ELEMENT, pos:5
+      name:hr
+      attributes: empty
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc < def
+     */
+    void bad_lt() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc > def
+     */
+    void bad_gt() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:6, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <p 123> def
+     */
+    void bad_chars_start();
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 5
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, p_123]
+    Erroneous[ERRONEOUS, pos:11
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc </p 123> def
+     */
+    void bad_chars_end();
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 5
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p_123]
+    Erroneous[ERRONEOUS, pos:12
+      code: compiler.err.dc.bad.gt
+      body: >
+    ]
+    Text[TEXT, pos:13, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr
+     */
+    void unterminated_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc <hr
+     * @author jjg
+     */
+    void unterminated_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, hr]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:10
+      name: 1
+        Text[TEXT, pos:18, jjg]
+    ]
+]
+*/
+
+
+    /**
+     * abc </p
+     */
+    void unterminated_end_eoi() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc </p
+     * @author jjg
+     */
+    void unterminated_end_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.malformed.html
+      body: <
+    ]
+    Text[TEXT, pos:6, /p]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:10
+      name: 1
+        Text[TEXT, pos:18, jjg]
+    ]
+]
+*/
+
+    /**
+     * abc
+     * <!-- comment -->
+     * def
+     */
+    void comment() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc|_]
+    Comment[COMMENT, pos:6, <!--_comment_-->]
+    Text[TEXT, pos:22, |_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/EntityTest.java b/test/tools/javac/doctree/EntityTest.java
new file mode 100644
index 0000000..1a19f54
--- /dev/null
+++ b/test/tools/javac/doctree/EntityTest.java
@@ -0,0 +1,165 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester EntityTest.java
+ */
+
+class EntityTest {
+    /**
+     *  abc < def
+     */
+    public void name() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, lt]
+    Text[TEXT, pos:10, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc   def
+     */
+    public void decimal_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #160]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#xa0; def
+     */
+    public void lower_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #xa0]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#XA0; def
+     */
+    public void upper_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Entity[ENTITY, pos:6, #XA0]
+    Text[TEXT, pos:12, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc & def
+     */
+    public void bad_amp() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.bad.entity
+      body: &
+    ]
+    Text[TEXT, pos:7, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &1 def
+     */
+    public void bad_entity_name() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.bad.entity
+      body: &
+    ]
+    Text[TEXT, pos:7, 1_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#012.3; def
+     */
+    public void bad_entity_decimal_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.missing.semicolon
+      body: &#012
+    ]
+    Text[TEXT, pos:11, .3;_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     *  abc &#x012azc; def
+     */
+    public void bad_entity_hex_value() { }
+/*
+DocComment[DOC_COMMENT, pos:2
+  firstSentence: 3
+    Text[TEXT, pos:2, abc_]
+    Erroneous[ERRONEOUS, pos:6
+      code: compiler.err.dc.missing.semicolon
+      body: &#x012a
+    ]
+    Text[TEXT, pos:13, zc;_def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/ExceptionTest.java b/test/tools/javac/doctree/ExceptionTest.java
new file mode 100644
index 0000000..6e02abe
--- /dev/null
+++ b/test/tools/javac/doctree/ExceptionTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ExceptionTest.java
+ */
+
+class ExceptionTest {
+    /**
+     * @exception Exception
+     */
+    void exception() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[EXCEPTION, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:12, Exception]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @exception Exception text
+     */
+    void exception_text() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[EXCEPTION, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:12, Exception]
+      description: 1
+        Text[TEXT, pos:22, text]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/FirstSentenceTest.java b/test/tools/javac/doctree/FirstSentenceTest.java
new file mode 100644
index 0000000..b91528d
--- /dev/null
+++ b/test/tools/javac/doctree/FirstSentenceTest.java
@@ -0,0 +1,198 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester FirstSentenceTest.java
+ */
+
+class FirstSentenceTest {
+    /** */
+    void empty() { }
+/*
+DocComment[DOC_COMMENT, pos:-1
+  firstSentence: empty
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc def ghi */
+    void no_terminator() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Text[TEXT, pos:0, abc_def_ghi]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi.
+     */
+    void no_body() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi. jkl mno pqr.
+     */
+    void dot_space() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: 1
+    Text[TEXT, pos:14, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi.
+     * jkl mno pqr
+     */
+    void dot_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi.]
+  body: 1
+    Text[TEXT, pos:15, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * <p>jkl mno pqr
+     */
+    void dot_p() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: 2
+    StartElement[START_ELEMENT, pos:14
+      name:p
+      attributes: empty
+    ]
+    Text[TEXT, pos:17, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * </p>jkl mno pqr
+     */
+    void dot_end_p() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: 2
+    EndElement[END_ELEMENT, pos:14, p]
+    Text[TEXT, pos:18, jkl_mno_pqr]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc < ghi. jkl mno pqr.
+     */
+    void entity() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Entity[ENTITY, pos:5, lt]
+    Text[TEXT, pos:9, _ghi.]
+  body: 1
+    Text[TEXT, pos:15, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@code code} ghi. jkl mno pqr.
+     */
+    void inline_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Literal[CODE, pos:5, code]
+    Text[TEXT, pos:17, _ghi.]
+  body: 1
+    Text[TEXT, pos:23, jkl_mno_pqr.]
+  block tags: empty
+]
+*/
+
+    /**
+     * abc def ghi
+     * @author jjg
+     */
+    void block_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc_def_ghi]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:14
+      name: 1
+        Text[TEXT, pos:22, jjg]
+    ]
+]
+*/
+
+    /**
+     * @author jjg
+     */
+    void just_tag() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:1
+      name: 1
+        Text[TEXT, pos:9, jjg]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/InheritDocTest.java b/test/tools/javac/doctree/InheritDocTest.java
new file mode 100644
index 0000000..542c738
--- /dev/null
+++ b/test/tools/javac/doctree/InheritDocTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester InheritDocTest.java
+ */
+
+class InheritDocTest {
+    /** abc {@inheritDoc} */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc } */
+    void standard_ws1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc  } */
+    void standard_ws2() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    InheritDoc[INHERIT_DOC, pos:4]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** abc {@inheritDoc junk} */
+    void error() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 2
+    Text[TEXT, pos:0, abc_]
+    Erroneous[ERRONEOUS, pos:4
+      code: compiler.err.dc.unexpected.content
+      body: {@inheritDoc_junk}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/LinkPlainTest.java b/test/tools/javac/doctree/LinkPlainTest.java
new file mode 100644
index 0000000..87d95c1
--- /dev/null
+++ b/test/tools/javac/doctree/LinkPlainTest.java
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LinkPlainTest.java
+ */
+
+class LinkPlainTest {
+    /**
+     * abc {@linkplain String} def
+      */
+    void simple_name() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, String]
+      body: empty
+    ]
+    Text[TEXT, pos:24, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain String desc} def
+     */
+    void simple_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, String]
+      body: 1
+        Text[TEXT, pos:24, desc]
+    ]
+    Text[TEXT, pos:29, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String desc} def
+     */
+    void pkg_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String]
+      body: 1
+        Text[TEXT, pos:34, desc]
+    ]
+    Text[TEXT, pos:39, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#isEmpty desc} def
+     */
+    void method_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#isEmpty]
+      body: 1
+        Text[TEXT, pos:42, desc]
+    ]
+    Text[TEXT, pos:47, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#isEmpty() desc} def
+     */
+    void method_0_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#isEmpty()]
+      body: 1
+        Text[TEXT, pos:44, desc]
+    ]
+    Text[TEXT, pos:49, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#substring(int) desc} def
+     */
+    void method_1_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String#substring(int)]
+      body: 1
+        Text[TEXT, pos:49, desc]
+    ]
+    Text[TEXT, pos:54, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.lang.String#substring(int, int) desc} def
+     */
+    void method_2_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.lang.String...#substring(int,_int)]
+      body: 1
+        Text[TEXT, pos:54, desc]
+    ]
+    Text[TEXT, pos:59, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@linkplain java.util.List<T> desc} def
+     */
+    void pkg_name_typarams_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK_PLAIN, pos:5
+      reference:
+        Reference[REFERENCE, pos:17, java.util.List<T>]
+      body: 1
+        Text[TEXT, pos:35, desc]
+    ]
+    Text[TEXT, pos:40, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/LinkTest.java b/test/tools/javac/doctree/LinkTest.java
new file mode 100644
index 0000000..5881e62
--- /dev/null
+++ b/test/tools/javac/doctree/LinkTest.java
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LinkTest.java
+ */
+
+class LinkTest {
+    /**
+     * abc {@link String} def
+      */
+    void simple_name() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, String]
+      body: empty
+    ]
+    Text[TEXT, pos:19, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link String desc} def
+     */
+    void simple_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, String]
+      body: 1
+        Text[TEXT, pos:19, desc]
+    ]
+    Text[TEXT, pos:24, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String desc} def
+     */
+    void pkg_name_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String]
+      body: 1
+        Text[TEXT, pos:29, desc]
+    ]
+    Text[TEXT, pos:34, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#isEmpty desc} def
+     */
+    void method_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#isEmpty]
+      body: 1
+        Text[TEXT, pos:37, desc]
+    ]
+    Text[TEXT, pos:42, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#isEmpty() desc} def
+     */
+    void method_0_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#isEmpty()]
+      body: 1
+        Text[TEXT, pos:39, desc]
+    ]
+    Text[TEXT, pos:44, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#substring(int) desc} def
+     */
+    void method_1_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String#substring(int)]
+      body: 1
+        Text[TEXT, pos:44, desc]
+    ]
+    Text[TEXT, pos:49, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.lang.String#substring(int, int) desc} def
+     */
+    void method_2_args_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.lang.String...#substring(int,_int)]
+      body: 1
+        Text[TEXT, pos:49, desc]
+    ]
+    Text[TEXT, pos:54, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@link java.util.List<T> desc} def
+     */
+    void pkg_name_typarams_desc() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Link[LINK, pos:5
+      reference:
+        Reference[REFERENCE, pos:12, java.util.List<T>]
+      body: 1
+        Text[TEXT, pos:30, desc]
+    ]
+    Text[TEXT, pos:35, _def]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/LiteralTest.java b/test/tools/javac/doctree/LiteralTest.java
new file mode 100644
index 0000000..1228c43
--- /dev/null
+++ b/test/tools/javac/doctree/LiteralTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester LiteralTest.java
+ */
+
+class LiteralTest {
+    /** {@literal if (a < b) { }} */
+    void minimal() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Literal[LITERAL, pos:0, if_(a_<_b)_{_}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [{@literal if (a < b) { }}] */
+    void in_brackets() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, []
+    Literal[LITERAL, pos:1, if_(a_<_b)_{_}]
+    Text[TEXT, pos:26, ]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /** [ {@literal if (a < b) { }} ] */
+    void in_brackets_with_whitespace() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 3
+    Text[TEXT, pos:0, [_]
+    Literal[LITERAL, pos:2, if_(a_<_b)_{_}]
+    Text[TEXT, pos:27, _]]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal {@literal nested} }
+     */
+    void nested() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[LITERAL, pos:1, {@literal_nested}_]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal if (a < b) {
+     *        }
+     * }
+     */
+    void embedded_newline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Literal[LITERAL, pos:1, if_(a_<_b)_{|________}|_]
+  body: empty
+  block tags: empty
+]
+*/
+
+
+    /** {@literal if (a < b) { } */
+    void unterminated_1() { }
+/*
+DocComment[DOC_COMMENT, pos:0
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:0
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@literal_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@literal if (a < b) { }
+     * @author jjg */
+    void unterminated_2() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@literal_if_(a_<_b)_{_}
+    ]
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:27
+      name: 1
+        Text[TEXT, pos:35, jjg]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/ParamTest.java b/test/tools/javac/doctree/ParamTest.java
new file mode 100644
index 0000000..483e800
--- /dev/null
+++ b/test/tools/javac/doctree/ParamTest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ParamTest.java
+ */
+
+class ParamTest {
+    /**
+     * @param x
+     */
+    void no_description(int x) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Param[PARAM, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:8, x]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @param x description
+     */
+    void with_description(int x) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Param[PARAM, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:8, x]
+      description: 1
+        Text[TEXT, pos:10, description]
+    ]
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/ReferenceTest.java b/test/tools/javac/doctree/ReferenceTest.java
new file mode 100644
index 0000000..944a132
--- /dev/null
+++ b/test/tools/javac/doctree/ReferenceTest.java
@@ -0,0 +1,216 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @summary check references in at-see and {at-link} tags
+ * @build ReferenceTest
+ * @compile -processor ReferenceTest -proc:only ReferenceTest.java
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.LinkTree;
+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;
+
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+/**
+ * {@link java.lang        Package}
+ * {@link java.lang.ERROR  Bad}
+ *
+ * {@link java.lang.String Class}
+ * {@link           String Class}
+ * {@link java.lang.String#CASE_INSENSITIVE_ORDER Field}
+ * {@link java.lang.String#String Constructor}
+ * {@link java.lang.String#String(byte[]) Constructor}
+ * {@link java.lang.String#String(byte[] bytes) Constructor}
+ * {@link java.lang.String#String(byte[], String) Constructor}
+ * {@link java.lang.String#String(byte[] bytes, String charSetName) Constructor}
+ * {@link java.lang.String#isEmpty Method}
+ * {@link java.lang.String#isEmpty() Method}
+ * {@link java.lang.String#ERROR Bad}
+ * {@link java.lang.String#equals(Object) Method}
+ *
+ * {@link AbstractProcessor Class}
+ *
+ * {@link List#add(Object) Method}
+ *
+ * {@link #trees Field}
+ * {@link #getSupportedSourceVersion Method}
+ * {@link #init(ProcessingEnvironment Method}
+ *
+ * @see java.lang        Package
+ * @see java.lang.ERROR  Bad
+ *
+ * @see java.lang.String Class
+ * @see           String Class
+ * @see java.lang.String#CASE_INSENSITIVE_ORDER Field
+ * @see java.lang.String#String Constructor
+ * @see java.lang.String#String(byte[]) Constructor
+ * @see java.lang.String#String(byte[] bytes) Constructor
+ * @see java.lang.String#String(byte[],String) Constructor
+ * @see java.lang.String#String(byte[] bytes, String charsetName) Constructor
+ * @see java.lang.String#isEmpty Method
+ * @see java.lang.String#isEmpty() Method
+ * @see java.lang.String#ERROR Bad
+ * @see java.lang.String#equals(Object) Method
+ *
+ * @see AbstractProcessor Class
+ *
+ * @see List#add(Object) Method
+ *
+ * @see #trees Field
+ * @see #getSupportedSourceVersion Method
+ * @see #init(ProcessingEnvironment) Method
+ *
+ * @see java.io.BufferedInputStream#BufferedInputStream(InputStream) Constructor
+ */
+ at SupportedAnnotationTypes("*")
+public class ReferenceTest extends AbstractProcessor {
+    DocTrees trees;
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        trees = DocTrees.instance(pEnv);
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        for (Element e: roundEnv.getRootElements()) {
+            new DocCommentScanner(trees.getPath(e)).scan();
+        }
+        return true;
+    }
+
+    class DocCommentScanner extends DocTreePathScanner<Void, Void> {
+        TreePath path;
+        DocCommentTree dc;
+
+        DocCommentScanner(TreePath path) {
+            this.path = path;
+        }
+
+        void scan() {
+            dc = trees.getDocCommentTree(path);
+            scan(new DocTreePath(path, dc), null);
+        }
+
+        @Override
+        public Void visitLink(LinkTree tree, Void ignore) {
+            checkReference(tree.getReference(), tree.getLabel());
+            return null;
+        }
+
+        @Override
+        public Void visitSee(SeeTree tree, Void ignore) {
+            List<? extends DocTree> refLabel = tree.getReference();
+            if (refLabel.size() > 1 && (refLabel.get(0) instanceof ReferenceTree)) {
+                ReferenceTree ref = (ReferenceTree) refLabel.get(0);
+                List<? extends DocTree> label = refLabel.subList(1, refLabel.size());
+                checkReference(ref, label);
+            }
+            return null;
+        }
+
+        void checkReference(ReferenceTree tree, List<? extends DocTree> label) {
+            String sig = tree.getSignature();
+
+            Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree));
+            if (found == null) {
+                System.err.println(sig + " NOT FOUND");
+            } else {
+                System.err.println(sig + " found " + found.getKind() + " " + found);
+            }
+
+            String expect = "UNKNOWN";
+            if (label.size() > 0 && label.get(0) instanceof TextTree)
+                expect = ((TextTree) label.get(0)).getBody();
+
+            if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) {
+                error(tree, "Unexpected value found: " + found +", expected: " + expect);
+            }
+        }
+
+        void error(DocTree tree, String msg) {
+            trees.printMessage(Kind.ERROR, msg, tree, dc, path.getCompilationUnit());
+        }
+    }
+}
+
+/**
+ * @see ReferenceTestExtras    Class
+ * @see #ReferenceTestExtras   Field
+ * @see #ReferenceTestExtras() Constructor
+ *
+ * @see #X    Field
+ * @see #X()  Method
+ *
+ * @see #m    Method
+ *
+ * @see #varargs(int...)        Method
+ * @see #varargs(int... args)   Method
+ * @see #varargs(int[])         Method
+ * @see #varargs(int[] args)    Method
+ */
+class ReferenceTestExtras {
+    int ReferenceTestExtras;            // field
+    ReferenceTestExtras() { }           // constructor
+    void ReferenceTestExtras() { }      // method
+
+    int X;
+    void X() { }
+    static class X { }
+
+    void m() { }
+    void m(int i) { }
+    void m(int i, int j) { }
+
+    void varargs(int... args) { }
+}
+
+
diff --git a/test/tools/javac/doctree/ReturnTest.java b/test/tools/javac/doctree/ReturnTest.java
new file mode 100644
index 0000000..e79a91f
--- /dev/null
+++ b/test/tools/javac/doctree/ReturnTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ReturnTest.java
+ */
+
+class ReturnTest {
+    /**
+     * @return something
+     */
+    int an_int() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Return[RETURN, pos:1
+      description: 1
+        Text[TEXT, pos:9, something]
+    ]
+]
+*/
+
+}
+
+
diff --git a/test/tools/javac/doctree/SeeTest.java b/test/tools/javac/doctree/SeeTest.java
new file mode 100644
index 0000000..bb27348
--- /dev/null
+++ b/test/tools/javac/doctree/SeeTest.java
@@ -0,0 +1,174 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SeeTest.java
+ */
+
+class SeeTest {
+    /**
+     * abc.
+     * @see "String"
+     */
+    void quoted_text() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:7
+      code: compiler.err.dc.unexpected.content
+      body: @see_"String"
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see <a href="url">url</a>
+     */
+    void url() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 3
+        StartElement[START_ELEMENT, pos:12
+          name:a
+          attributes: 1
+            Attribute[ATTRIBUTE, pos:15
+              name: href
+              vkind: DOUBLE
+              value: 1
+                Text[TEXT, pos:21, url]
+            ]
+        ]
+        Text[TEXT, pos:26, url]
+        EndElement[END_ELEMENT, pos:29, a]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see String text
+     */
+    void string() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, String]
+        Text[TEXT, pos:19, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String text
+     */
+    void j_l_string() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String]
+        Text[TEXT, pos:29, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String#length text
+     */
+    void j_l_string_length() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String#length]
+        Text[TEXT, pos:36, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see java.lang.String#matches(String regex) text
+     */
+    void j_l_string_matches() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    See[SEE, pos:7
+      reference: 2
+        Reference[REFERENCE, pos:12, java.lang.String...#matches(String_regex)]
+        Text[TEXT, pos:51, text]
+    ]
+]
+*/
+
+    /**
+     * abc.
+     * @see 123 text
+     */
+    void bad_numeric() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:7
+      code: compiler.err.dc.unexpected.content
+      body: @see_123_text
+    ]
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/SerialDataTest.java b/test/tools/javac/doctree/SerialDataTest.java
new file mode 100644
index 0000000..f68be74
--- /dev/null
+++ b/test/tools/javac/doctree/SerialDataTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialDataTest.java
+ */
+
+class SerialDataTest {
+    /**
+     * @serialData description
+     */
+    void writeObject(ObjectOutputStream stream) { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialData[SERIAL_DATA, pos:1
+      description: 1
+        Text[TEXT, pos:13, description]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/SerialFieldTest.java b/test/tools/javac/doctree/SerialFieldTest.java
new file mode 100644
index 0000000..aeffcbc
--- /dev/null
+++ b/test/tools/javac/doctree/SerialFieldTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialFieldTest.java
+ */
+
+class SerialFieldTest {
+
+    /**
+     * @serialField field String
+     */
+    String f1;
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialField[SERIAL_FIELD, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:14, field]
+      type:
+        Reference[REFERENCE, pos:20, String]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @serialField field String f2 is a String
+     */
+    String f2;
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    SerialField[SERIAL_FIELD, pos:1
+      name:
+        Identifier[IDENTIFIER, pos:14, field]
+      type:
+        Reference[REFERENCE, pos:20, String]
+      description: 1
+        Text[TEXT, pos:27, f2_is_a_String]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/SerialTest.java b/test/tools/javac/doctree/SerialTest.java
new file mode 100644
index 0000000..14f025c
--- /dev/null
+++ b/test/tools/javac/doctree/SerialTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SerialTest.java
+ */
+
+class SerialTest {
+    /**
+     * @serial include
+     */
+    void include() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, include]
+    ]
+]
+*/
+
+    /**
+     * @serial exclude
+     */
+    void exclude() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, exclude]
+    ]
+]
+*/
+
+    /**
+     * @serial description
+     */
+    void description() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: 1
+        Text[TEXT, pos:9, description]
+    ]
+]
+*/
+
+    /**
+     * @serial
+     */
+    void empty() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Serial[SERIAL, pos:1
+      description: empty
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java b/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java
new file mode 100644
index 0000000..8b0bf81
--- /dev/null
+++ b/test/tools/javac/doctree/SimpleDocTreeVisitorTest.java
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+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.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.SimpleDocTreeVisitor;
+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.EnumSet;
+import java.util.List;
+import java.util.Set;
+import javax.lang.model.element.Name;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+public class SimpleDocTreeVisitorTest {
+    public static void main(String... args) throws Exception {
+        SimpleDocTreeVisitorTest t = new SimpleDocTreeVisitorTest();
+        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();
+
+        Set<DocTree.Kind> found = EnumSet.noneOf(DocTree.Kind.class);
+        DeclScanner ds = new DeclScanner(trees, found);
+        for (CompilationUnitTree unit: units) {
+            ds.scan(unit, null);
+        }
+
+        for (DocTree.Kind k: DocTree.Kind.values()) {
+            if (!found.contains(k) && k != DocTree.Kind.OTHER)
+                error("not found: " + k);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    static class DeclScanner extends TreePathScanner<Void, Void> {
+        DocTrees trees;
+        DocTreeScanner<Void,Void> cs;
+
+        DeclScanner(DocTrees trees, final Set<DocTree.Kind> found) {
+            this.trees = trees;
+            cs = new CommentScanner(found);
+        }
+
+        @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(dc, null);
+        }
+    }
+
+    static class CommentScanner extends DocTreeScanner<Void, Void> {
+        DocTreeVisitor<Void, Void> visitor;
+
+        CommentScanner(Set<DocTree.Kind> found) {
+            visitor = new Visitor(found);
+        }
+
+        @Override
+        public Void scan(DocTree tree, Void ignore) {
+            if (tree != null)
+                tree.accept(visitor, ignore);
+            return super.scan(tree, ignore);
+        }
+    }
+
+    static class Visitor extends SimpleDocTreeVisitor<Void, Void> {
+        Set<DocTree.Kind> found;
+
+        Visitor(Set<DocTree.Kind> found) {
+            this.found = found;
+        }
+
+        @Override
+        public Void defaultAction(DocTree tree, Void ignore) {
+            found.add(tree.getKind());
+            return null;
+        }
+    }
+}
diff --git a/test/tools/javac/doctree/SinceTest.java b/test/tools/javac/doctree/SinceTest.java
new file mode 100644
index 0000000..d2f3ae2
--- /dev/null
+++ b/test/tools/javac/doctree/SinceTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester SinceTest.java
+ */
+
+class SinceTest {
+    /**
+     * abc.
+     * @since then & now.
+     */
+    void standard() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Text[TEXT, pos:1, abc.]
+  body: empty
+  block tags: 1
+    Since[SINCE, pos:7
+      body: 3
+        Text[TEXT, pos:14, then_]
+        Entity[ENTITY, pos:19, amp]
+        Text[TEXT, pos:24, _now.]
+    ]
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/TagTest.java b/test/tools/javac/doctree/TagTest.java
new file mode 100644
index 0000000..5657acc
--- /dev/null
+++ b/test/tools/javac/doctree/TagTest.java
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester TagTest.java
+ */
+
+class TagTest {
+    /**
+     * @author jjg
+     */
+    void simple_standard_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Author[AUTHOR, pos:1
+      name: 1
+        Text[TEXT, pos:9, jjg]
+    ]
+]
+*/
+
+    /**
+     * @ abc
+     */
+    void no_name_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.no.tag.name
+      body: @_abc
+    ]
+]
+*/
+
+    /**
+     * @abc def ghi
+     */
+    void unknown_name_block() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    UnknownBlockTag[UNKNOWN_BLOCK_TAG, pos:1
+      tag:abc
+      content: 1
+        Text[TEXT, pos:6, def_ghi]
+    ]
+]
+*/
+
+    /**
+     * {@link String}
+     */
+    void simple_standard_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Link[LINK, pos:1
+      reference:
+        Reference[REFERENCE, pos:8, String]
+      body: empty
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@ abc}
+     */
+    void no_name_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.no.tag.name
+      body: {@
+    ]
+    Text[TEXT, pos:3, _abc}]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@abc def ghi}
+     */
+    void unknown_name_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    UnknownInlineTag[UNKNOWN_INLINE_TAG, pos:1
+      tag:abc
+      content: 1
+        Text[TEXT, pos:7, def_ghi]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * {@abc def ghi
+     */
+    void unterminated_standard_inline() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 1
+    Erroneous[ERRONEOUS, pos:1
+      code: compiler.err.dc.unterminated.inline.tag
+      body: {@abc_def_ghi
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
diff --git a/test/tools/javac/doctree/ThrowableTest.java b/test/tools/javac/doctree/ThrowableTest.java
new file mode 100644
index 0000000..31e49e7
--- /dev/null
+++ b/test/tools/javac/doctree/ThrowableTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ThrowableTest.java
+ */
+
+class ThrowableTest {
+    /**
+     * @throws Exception
+     */
+    void exception() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[THROWS, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:9, Exception]
+      description: empty
+    ]
+]
+*/
+
+    /**
+     * @throws Exception text
+     */
+    void exception_text() throws Exception { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Throws[THROWS, pos:1
+      exceptionName:
+        Reference[REFERENCE, pos:9, Exception]
+      description: 1
+        Text[TEXT, pos:19, text]
+    ]
+]
+*/
+
+}
+
diff --git a/test/tools/javac/doctree/ValueTest.java b/test/tools/javac/doctree/ValueTest.java
new file mode 100644
index 0000000..1e14417
--- /dev/null
+++ b/test/tools/javac/doctree/ValueTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester ValueTest.java
+ */
+
+class ValueTest {
+    /**
+     * abc {@value}
+     */
+    int no_ref() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference: null
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED}
+     */
+    int typical() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference:
+        Reference[REFERENCE, pos:13, java.awt.Color#RED]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED }
+     */
+    int trailing_ws() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 2
+    Text[TEXT, pos:1, abc_]
+    Value[VALUE, pos:5
+      reference:
+        Reference[REFERENCE, pos:13, java.awt.Color#RED]
+    ]
+  body: empty
+  block tags: empty
+]
+*/
+
+    /**
+     * abc {@value java.awt.Color#RED junk}
+     */
+    int trailing_junk() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: 3
+    Text[TEXT, pos:1, abc_]
+    Erroneous[ERRONEOUS, pos:5
+      code: compiler.err.dc.unexpected.content
+      body: {@value_java.awt.Color#RED_j
+    ]
+    Text[TEXT, pos:33, unk}]
+  body: empty
+  block tags: empty
+]
+*/
+
+}
+
+
diff --git a/test/tools/javac/doctree/VersionTest.java b/test/tools/javac/doctree/VersionTest.java
new file mode 100644
index 0000000..cbd6b8f
--- /dev/null
+++ b/test/tools/javac/doctree/VersionTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ * 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 7021614
+ * @summary extend com.sun.source API to support parsing javadoc comments
+ * @build DocCommentTester
+ * @run main DocCommentTester VersionTest.java
+ */
+
+class VersionTest {
+    /**
+     * @version 1.2
+     */
+    void version() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+  firstSentence: empty
+  body: empty
+  block tags: 1
+    Version[VERSION, pos:1
+      body: 1
+        Text[TEXT, pos:10, 1.2]
+    ]
+]
+*/
+
+}
+
+
diff --git a/test/tools/javac/doctree/positions/TestPosition.java b/test/tools/javac/doctree/positions/TestPosition.java
new file mode 100644
index 0000000..8d03c8d
--- /dev/null
+++ b/test/tools/javac/doctree/positions/TestPosition.java
@@ -0,0 +1,105 @@
+/*
+ * 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 8008174
+ * @summary proper source positions for doc comments
+ * @build TestPosition
+ * @compile/ref=TestPosition.out -processor TestPosition -proc:only TestPositionSource.java
+ */
+
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.util.DocSourcePositions;
+import com.sun.source.util.DocTreeScanner;
+import com.sun.source.util.DocTrees;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import java.io.IOException;
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+ at SupportedAnnotationTypes("*")
+public class TestPosition extends AbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        TypeElement source = processingEnv.getElementUtils().getTypeElement("TestPositionSource");
+
+        if (source == null) throw new IllegalStateException();
+
+        if (!roundEnv.getRootElements().contains(source)) return false;
+
+        final DocTrees trees = DocTrees.instance(processingEnv);
+        final TreePath testElement = trees.getPath(source);
+
+        if (testElement == null) throw new IllegalStateException();
+
+        String code;
+
+        try {
+            code = testElement.getCompilationUnit().getSourceFile().getCharContent(false).toString();
+        } catch ( IOException ex) {
+            throw new IllegalStateException(ex);
+        }
+
+        new TreePathScanner<Void, Void>() {
+            @Override public Void visitMethod(MethodTree node, Void p) {
+                final DocCommentTree docCommentTree = trees.getDocCommentTree(getCurrentPath());
+
+                if (docCommentTree != null) {
+                    System.out.println(node.getName() + ":");
+                    new DocTreeScanner<Void, Void>() {
+                        @Override public Void scan(DocTree node, Void p) {
+                            if (node != null) {
+                                DocSourcePositions sp = (DocSourcePositions) trees.getSourcePositions(); //XXX: the cast???
+                                int start = (int) sp.getStartPosition(testElement.getCompilationUnit(), docCommentTree, node);
+                                int end   = (int) sp.getEndPosition(testElement.getCompilationUnit(), docCommentTree, node);
+                                String snippet = code.substring(start, end).replace(" \n", "!trailing-whitespace!\n");
+
+                                if (snippet.endsWith(" ")) {
+                                    snippet = snippet.substring(0, snippet.length() - 1) + "!trailing-whitespace!";
+                                }
+                                System.out.println(node.getKind().name() + ":" + snippet);
+                            }
+                            return super.scan(node, p);
+                        }
+                    }.scan(docCommentTree, null);
+                }
+
+                return super.visitMethod(node, p);
+            }
+        }.scan(testElement, null);
+
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
diff --git a/test/tools/javac/doctree/positions/TestPosition.out b/test/tools/javac/doctree/positions/TestPosition.out
new file mode 100644
index 0000000..36a3868
--- /dev/null
+++ b/test/tools/javac/doctree/positions/TestPosition.out
@@ -0,0 +1,99 @@
+valid:
+DOC_COMMENT:First sentence.
+     *
+     * <p>Description with {@link java.io.InputStream link}
+     *
+     * @param first description
+     * @param second description
+     * @return whatever
+     * @throws IllegalStateException why?
+     * @since 1.15
+     * @see java.util.List
+TEXT:First sentence.
+START_ELEMENT:<p>
+TEXT:Description with!trailing-whitespace!
+LINK:{@link java.io.InputStream link}
+REFERENCE:java.io.InputStream
+TEXT:link
+PARAM:@param first description
+IDENTIFIER:first
+TEXT:description
+PARAM:@param second description
+IDENTIFIER:second
+TEXT:description
+RETURN:@return whatever
+TEXT:whatever
+THROWS:@throws IllegalStateException why?
+REFERENCE:IllegalStateException
+TEXT:why?
+SINCE:@since 1.15
+TEXT:1.15
+SEE:@see java.util.List
+REFERENCE:java.util.List
+erroneous:
+DOC_COMMENT:First sentence.
+     *
+     * <p>Description with {@link}, {@link java.util.List}, {@link
+     *
+     * @param
+     * @param second
+     * @return
+     * @throws
+     * @throws IllegalStateException
+     * @since
+     * @see
+TEXT:First sentence.
+START_ELEMENT:<p>
+TEXT:Description with!trailing-whitespace!
+LINK:{@link}
+TEXT:,!trailing-whitespace!
+LINK:{@link java.util.List}
+REFERENCE:java.util.List
+TEXT:,!trailing-whitespace!
+ERRONEOUS:{@link
+ERRONEOUS:@param
+PARAM:@param second
+IDENTIFIER:second
+RETURN:@return
+ERRONEOUS:@throws
+THROWS:@throws IllegalStateException
+REFERENCE:IllegalStateException
+SINCE:@since
+ERRONEOUS:@see
+withWhiteSpaces:
+DOC_COMMENT:First sentence.
+     *
+     * <p>Description with {@link    }, {@link java.util.List#add(   int   )},
+     * {@link java.util.List#add(   int   ) some   text   with   whitespaces}, {@link
+     *
+     * @param     first
+     * @param     second   some   text   with trailing whitespace
+     * @return      some   return
+     * @throws      java.lang.IllegalStateException
+     * @throws   java.lang.IllegalStateException some     text
+TEXT:First sentence.
+START_ELEMENT:<p>
+TEXT:Description with!trailing-whitespace!
+LINK:{@link    }
+TEXT:,!trailing-whitespace!
+LINK:{@link java.util.List#add(   int   )}
+REFERENCE:java.util.List#add(   int   )
+TEXT:,
+     *!trailing-whitespace!
+LINK:{@link java.util.List#add(   int   ) some   text   with   whitespaces}
+REFERENCE:java.util.List#add(   int   )
+TEXT:some   text   with   whitespaces
+TEXT:,!trailing-whitespace!
+ERRONEOUS:{@link
+PARAM:@param     first
+IDENTIFIER:first
+PARAM:@param     second   some   text   with trailing whitespace
+IDENTIFIER:second
+TEXT:some   text   with trailing whitespace
+RETURN:@return      some   return
+TEXT:some   return
+THROWS:@throws      java.lang.IllegalStateException
+REFERENCE:java.lang.IllegalStateException
+THROWS:@throws   java.lang.IllegalStateException some     text
+REFERENCE:java.lang.IllegalStateException
+TEXT:some     text
\ No newline at end of file
diff --git a/test/tools/javac/doctree/positions/TestPositionSource.java b/test/tools/javac/doctree/positions/TestPositionSource.java
new file mode 100644
index 0000000..801af3d
--- /dev/null
+++ b/test/tools/javac/doctree/positions/TestPositionSource.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+public class TestPositionSource {
+
+    /**First sentence.
+     *
+     * <p>Description with {@link java.io.InputStream link}
+     *
+     * @param first description
+     * @param second description
+     * @return whatever
+     * @throws IllegalStateException why?
+     * @since 1.15
+     * @see java.util.List
+     */
+    public boolean valid(int first, int second) throws IllegalStateException {
+        return true;
+    }
+
+    /**First sentence.
+     *
+     * <p>Description with {@link}, {@link java.util.List}, {@link
+     *
+     * @param
+     * @param second
+     * @return
+     * @throws
+     * @throws IllegalStateException
+     * @since
+     * @see
+     */
+    public boolean erroneous(int first, int second) throws IllegalStateException {
+        return true;
+    }
+
+    /**First sentence.
+     *
+     * <p>Description with {@link    }, {@link java.util.List#add(   int   )},
+     * {@link java.util.List#add(   int   ) some   text   with   whitespaces}, {@link
+     *
+     * @param     first
+     * @param     second   some   text   with trailing whitespace
+     * @return      some   return
+     * @throws      java.lang.IllegalStateException
+     * @throws   java.lang.IllegalStateException some     text
+     */
+    public boolean withWhiteSpaces(int first, int second) throws IllegalStateException {
+        return true;
+    }
+
+}
diff --git a/test/tools/javac/enum/6350057/T6350057.java b/test/tools/javac/enum/6350057/T6350057.java
index f4c47a1..a2253fb 100644
--- a/test/tools/javac/enum/6350057/T6350057.java
+++ b/test/tools/javac/enum/6350057/T6350057.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,10 +23,11 @@
 
 /*
  * @test
- * @bug 6350057
+ * @bug 6350057 7025809
  * @summary Test that parameters on implicit enum methods have the right kind
  * @author  Joseph D. Darcy
- * @compile T6350057.java
+ * @library /tools/javac/lib
+ * @build   JavacTestingAbstractProcessor T6350057
  * @compile -processor T6350057 -proc:only TestEnum.java
  */
 
@@ -38,9 +39,8 @@ import javax.lang.model.element.*;
 import javax.lang.model.util.*;
 import static javax.tools.Diagnostic.Kind.*;
 
- at SupportedAnnotationTypes("*")
-public class T6350057 extends AbstractProcessor {
-    static class LocalVarAllergy extends ElementKindVisitor6<Boolean, Void> {
+public class T6350057 extends JavacTestingAbstractProcessor {
+    static class LocalVarAllergy extends ElementKindVisitor<Boolean, Void> {
         @Override
         public Boolean visitTypeAsEnum(TypeElement e, Void v) {
             System.out.println("visitTypeAsEnum: " + e.getSimpleName().toString());
diff --git a/test/tools/javac/enum/6424358/T6424358.java b/test/tools/javac/enum/6424358/T6424358.java
index 0ab0d8d..baa6e07 100644
--- a/test/tools/javac/enum/6424358/T6424358.java
+++ b/test/tools/javac/enum/6424358/T6424358.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,10 +23,11 @@
 
 /*
  * @test
- * @bug     6424358
+ * @bug     6424358 7025809
  * @summary Synthesized static enum method values() is final
  * @author  Peter von der Ah\u00e9
- * @compile T6424358.java
+ * @library /tools/javac/lib
+ * @build   JavacTestingAbstractProcessor T6424358
  * @compile -processor T6424358 -proc:only T6424358.java
  */
 
@@ -39,8 +40,7 @@ import static javax.tools.Diagnostic.Kind.*;
 
 @interface TestMe {}
 
- at SupportedAnnotationTypes("*")
-public class T6424358 extends AbstractProcessor {
+public class T6424358 extends JavacTestingAbstractProcessor {
     @TestMe enum Test { FOO; }
 
     public boolean process(Set<? extends TypeElement> annotations,
@@ -48,7 +48,7 @@ public class T6424358 extends AbstractProcessor {
         final Messager log = processingEnv.getMessager();
         final Elements elements = processingEnv.getElementUtils();
         final TypeElement testMe = elements.getTypeElement("TestMe");
-        class Scan extends ElementScanner7<Void,Void> {
+        class Scan extends ElementScanner<Void,Void> {
             @Override
             public Void visitExecutable(ExecutableElement e, Void p) {
                 System.err.println("Looking at " + e);
@@ -65,9 +65,4 @@ public class T6424358 extends AbstractProcessor {
             scan.scan(e);
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
diff --git a/test/tools/javac/enum/7160084/T7160084a.java b/test/tools/javac/enum/7160084/T7160084a.java
new file mode 100644
index 0000000..74cd4df
--- /dev/null
+++ b/test/tools/javac/enum/7160084/T7160084a.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ *
+ * 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     7160084
+ * @summary javac fails to compile an apparently valid class/interface combination
+ */
+public class T7160084a {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond) {
+            throw new AssertionError();
+        }
+    }
+
+    interface Intf {
+       enum MyEnumA {
+          AA(""),
+          UNUSED("");
+
+          private MyEnumA(String s) { }
+       }
+    }
+
+    enum MyEnumA implements Intf {
+        AA("");
+
+        private MyEnumA(String s) { }
+    }
+
+    public static void main(String... args) {
+        assertTrue(MyEnumA.values().length == 1);
+        assertTrue(Intf.MyEnumA.values().length == 2);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/enum/7160084/T7160084b.java b/test/tools/javac/enum/7160084/T7160084b.java
new file mode 100644
index 0000000..706f4b8
--- /dev/null
+++ b/test/tools/javac/enum/7160084/T7160084b.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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     7160084
+ * @summary javac fails to compile an apparently valid class/interface combination
+ */
+public class T7160084b {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond) {
+            throw new AssertionError();
+        }
+    }
+
+    interface Extras {
+        static class Enums {
+            static class Component {
+                Component() { throw new RuntimeException("oops!"); }
+            }
+        }
+    }
+
+    interface Test {
+        public class Enums {
+            interface Widget {
+                enum Component { X, Y };
+            }
+
+            enum Component implements Widget, Extras {
+                Z;
+            };
+
+            public static void test() {
+               assertTrue(Component.values().length == 1);
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        Test.Enums.test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/failover/CheckAttributedTree.java b/test/tools/javac/failover/CheckAttributedTree.java
index e249689..8f7fc37 100644
--- a/test/tools/javac/failover/CheckAttributedTree.java
+++ b/test/tools/javac/failover/CheckAttributedTree.java
@@ -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
@@ -21,7 +21,19 @@
  * questions.
  */
 
-import com.sun.source.util.TaskEvent;
+/*
+ * @test
+ * @bug 6970584 8006694
+ * @summary assorted position errors in compiler syntax trees
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm CheckAttributedTree -q -r -et ERRONEOUS .
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
@@ -34,6 +46,20 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.lang.model.element.Element;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
@@ -49,41 +75,25 @@ import javax.swing.event.CaretListener;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultHighlighter;
 import javax.swing.text.Highlighter;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
 
 import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.TaskEvent;
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.TaskListener;
-import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.tree.EndPosTable;
 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.JCImport;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Pair;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import javax.lang.model.element.Element;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /**
  * Utility and test program to check validity of tree positions for tree nodes.
@@ -97,13 +107,7 @@ import javax.lang.model.element.Element;
  * covering any new language features that may be tested in this test suite.
  */
 
-/*
- * @test
- * @bug 6970584
- * @summary assorted position errors in compiler syntax trees
- * @run main CheckAttributedTree -q -r -et ERRONEOUS .
- */
-public class CheckAttributedTree {
+public class CheckAttributedTree extends JavacTestingAbstractThreadedTest {
     /**
      * Main entry point.
      * If test.src is set, program runs in jtreg mode, and will throw an Error
@@ -112,9 +116,10 @@ public class CheckAttributedTree {
      * args is the value of ${test.src}. In jtreg mode, the -r option can be
      * given to change the default base directory to the root test directory.
      */
-    public static void main(String... args) {
+    public static void main(String... args) throws Exception {
         String testSrc = System.getProperty("test.src");
         File baseDir = (testSrc == null) ? null : new File(testSrc);
+        throwAssertionOnError = false;
         boolean ok = new CheckAttributedTree().run(baseDir, args);
         if (!ok) {
             if (testSrc != null)  // jtreg mode
@@ -132,7 +137,7 @@ public class CheckAttributedTree {
      * @param args command line args
      * @return true if successful or in gui mode
      */
-    boolean run(File baseDir, String... args) {
+    boolean run(File baseDir, String... args) throws Exception {
         if (args.length == 0) {
             usage(System.out);
             return true;
@@ -147,8 +152,10 @@ public class CheckAttributedTree {
                 gui = true;
             else if (arg.equals("-q"))
                 quiet = true;
-            else if (arg.equals("-v"))
+            else if (arg.equals("-v")) {
                 verbose = true;
+                printAll = true;
+            }
             else if (arg.equals("-t") && i + 1 < args.length)
                 tags.add(args[++i]);
             else if (arg.equals("-ef") && i + 1 < args.length)
@@ -181,12 +188,11 @@ public class CheckAttributedTree {
                 error("File not found: " + file);
         }
 
-        if (fileCount != 1)
-            System.err.println(fileCount + " files read");
-        if (errors > 0)
-            System.err.println(errors + " errors");
+        if (fileCount.get() != 1)
+            errWriter.println(fileCount + " files read");
+        checkAfterExec(false);
 
-        return (gui || errors == 0);
+        return (gui || errCount.get() == 0);
     }
 
     /**
@@ -217,7 +223,7 @@ public class CheckAttributedTree {
      * for java files.
      * @param file the file or directory to test
      */
-    void test(File file) {
+    void test(final File file) {
         if (excludeFiles.contains(file)) {
             if (!quiet)
                 error("File " + file + " excluded");
@@ -232,20 +238,24 @@ public class CheckAttributedTree {
         }
 
         if (file.isFile() && file.getName().endsWith(".java")) {
-            try {
-                if (verbose)
-                    System.err.println(file);
-                fileCount++;
-                NPETester p = new NPETester();
-                p.test(read(file));
-            } catch (AttributionException e) {
-                if (!quiet) {
-                    error("Error attributing " + file + "\n" + e.getMessage());
+            pool.execute(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        if (verbose)
+                            errWriter.println(file);
+                        fileCount.incrementAndGet();
+                        NPETester p = new NPETester();
+                        p.test(read(file));
+                    } catch (AttributionException e) {
+                        if (!quiet) {
+                            error("Error attributing " + file + "\n" + e.getMessage());
+                        }
+                    } catch (IOException e) {
+                        error("Error reading " + file + ": " + e);
+                    }
                 }
-            } catch (IOException e) {
-                error("Error reading " + file + ": " + e);
-            }
-            return;
+            });
         }
 
         if (!quiet)
@@ -256,8 +266,6 @@ public class CheckAttributedTree {
     StringWriter sw = new StringWriter();
     PrintWriter pw = new PrintWriter(sw);
     Reporter r = new Reporter(pw);
-    JavacTool tool = JavacTool.create();
-    StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
 
     /**
      * Read a file.
@@ -267,11 +275,10 @@ public class CheckAttributedTree {
      * @throws TreePosTest.ParseException if any errors occur while parsing the file
      */
     List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException {
-        JavacTool tool = JavacTool.create();
         r.errors = 0;
-        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
+        Iterable<? extends JavaFileObject> files = fm.get().getJavaFileObjects(file);
         String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" };
-        JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
+        JavacTask task = (JavacTask)comp.getTask(pw, fm.get(), r, Arrays.asList(opts), null, files);
         final List<Element> analyzedElems = new ArrayList<>();
         task.setTaskListener(new TaskListener() {
             public void started(TaskEvent e) {
@@ -289,7 +296,7 @@ public class CheckAttributedTree {
             for (CompilationUnitTree t : trees) {
                JCCompilationUnit cu = (JCCompilationUnit)t;
                for (JCTree def : cu.defs) {
-                   if (def.getTag() == JCTree.CLASSDEF &&
+                   if (def.hasTag(CLASSDEF) &&
                            analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
                        //System.out.println("Adding pair...");
                        res.add(new Pair<>(cu, def));
@@ -310,13 +317,9 @@ public class CheckAttributedTree {
      */
     void error(String msg) {
         System.err.println(msg);
-        errors++;
+        errCount.incrementAndGet();
     }
 
-    /** Number of files that have been analyzed. */
-    int fileCount;
-    /** Number of errors reported. */
-    int errors;
     /** Flag: don't report irrelevant files. */
     boolean quiet;
     /** Flag: show errors in GUI viewer. */
@@ -359,11 +362,18 @@ public class CheckAttributedTree {
             }
 
             Info self = new Info(tree, endPosTable);
-            check(!mandatoryType(tree) ||
-                    (tree.type != null &&
-                    checkFields(tree)),
-                    "'null' found in tree ",
-                    self);
+            if (mandatoryType(tree)) {
+                check(tree.type != null,
+                        "'null' field 'type' found in tree ", self);
+                if (tree.type==null)
+                    new Throwable().printStackTrace();
+            }
+
+            Field errField = checkFields(tree);
+            if (errField!=null) {
+                check(false,
+                        "'null' field '" + errField.getName() + "' found in tree ", self);
+            }
 
             Info prevEncl = encl;
             encl = self;
@@ -373,12 +383,12 @@ public class CheckAttributedTree {
 
         private boolean mandatoryType(JCTree that) {
             return that instanceof JCTree.JCExpression ||
-                    that.getTag() == JCTree.VARDEF ||
-                    that.getTag() == JCTree.METHODDEF ||
-                    that.getTag() == JCTree.CLASSDEF;
+                    that.hasTag(VARDEF) ||
+                    that.hasTag(METHODDEF) ||
+                    that.hasTag(CLASSDEF);
         }
 
-        private final List<String> excludedFields = Arrays.asList("varargsElement");
+        private final List<String> excludedFields = Arrays.asList("varargsElement", "targetType");
 
         void check(boolean ok, String label, Info self) {
             if (!ok) {
@@ -387,11 +397,12 @@ public class CheckAttributedTree {
                         viewer = new Viewer();
                     viewer.addEntry(sourcefile, label, encl, self);
                 }
-                error(label + self.toString() + " encl: " + encl.toString() + " in file: " + sourcefile + "  " + self.tree);
+                error(label + self.toString() + " encl: " + encl.toString() +
+                        " in file: " + sourcefile + "  " + self.tree);
             }
         }
 
-        boolean checkFields(JCTree t) {
+        Field checkFields(JCTree t) {
             List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
                     excludedFields,
                     Symbol.class,
@@ -399,7 +410,7 @@ public class CheckAttributedTree {
             for (Field f : fieldsToCheck) {
                 try {
                     if (f.get(t) == null) {
-                        return false;
+                        return f;
                     }
                 }
                 catch (IllegalAccessException e) {
@@ -407,7 +418,7 @@ public class CheckAttributedTree {
                     //swallow it
                 }
             }
-            return true;
+            return null;
         }
 
         @Override
@@ -419,7 +430,7 @@ public class CheckAttributedTree {
         }
 
         JavaFileObject sourcefile;
-        Map<JCTree, Integer> endPosTable;
+        EndPosTable endPosTable;
         Info encl;
     }
 
@@ -429,13 +440,13 @@ public class CheckAttributedTree {
     private class Info {
         Info() {
             tree = null;
-            tag = JCTree.ERRONEOUS;
+            tag = ERRONEOUS;
             start = 0;
             pos = 0;
             end = Integer.MAX_VALUE;
         }
 
-        Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
+        Info(JCTree tree, EndPosTable endPosTable) {
             this.tree = tree;
             tag = tree.getTag();
             start = TreeInfo.getStartPos(tree);
@@ -449,7 +460,7 @@ public class CheckAttributedTree {
         }
 
         final JCTree tree;
-        final int tag;
+        final JCTree.Tag tag;
         final int start;
         final int pos;
         final int end;
@@ -457,27 +468,10 @@ public class CheckAttributedTree {
 
     /**
      * Names for tree tags.
-     * javac does not provide an API to convert tag values to strings, so this class uses
-     * reflection to determine names of public static final int values in JCTree.
      */
     private static class TreeUtil {
-        String nameFromTag(int tag) {
-            if (names == null) {
-                names = new HashMap<Integer, String>();
-                Class c = JCTree.class;
-                for (Field f : c.getDeclaredFields()) {
-                    if (f.getType().equals(int.class)) {
-                        int mods = f.getModifiers();
-                        if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
-                            try {
-                                names.put(f.getInt(null), f.getName());
-                            } catch (IllegalAccessException e) {
-                            }
-                        }
-                    }
-                }
-            }
-            String name = names.get(tag);
+        String nameFromTag(JCTree.Tag tag) {
+            String name = tag.name();
             return (name == null) ? "??" : name;
         }
 
@@ -496,8 +490,6 @@ public class CheckAttributedTree {
             }
             return buf;
         }
-
-        private Map<Integer, String> names;
     }
 
     /**
@@ -524,7 +516,7 @@ public class CheckAttributedTree {
         }
 
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-            out.println(diagnostic);
+            //out.println(diagnostic);
             switch (diagnostic.getKind()) {
                 case ERROR:
                     errors++;
@@ -775,4 +767,8 @@ public class CheckAttributedTree {
             final Info self;
         }
     }
+
+    /** Number of files that have been analyzed. */
+    static AtomicInteger fileCount = new AtomicInteger();
+
 }
diff --git a/test/tools/javac/fatalErrors/NoJavaLang.java b/test/tools/javac/fatalErrors/NoJavaLang.java
deleted file mode 100644
index a027e41..0000000
--- a/test/tools/javac/fatalErrors/NoJavaLang.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1999, 2002, 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 4263768 4785453
- * @summary Verify that the compiler does not crash when java.lang is not
- * found.
- * @author iag
- *
- * @run shell NoJavaLang.sh
- */
-
-public class NoJavaLang {
-    private String s;
-
-    public String s() {
-        return s;
-    }
-}
diff --git a/test/tools/javac/fatalErrors/NoJavaLang.out b/test/tools/javac/fatalErrors/NoJavaLang.out
deleted file mode 100644
index 7cb0c5b..0000000
--- a/test/tools/javac/fatalErrors/NoJavaLang.out
+++ /dev/null
@@ -1 +0,0 @@
-Fatal Error: Unable to find package java.lang in classpath or bootclasspath
diff --git a/test/tools/javac/fatalErrors/NoJavaLang.sh b/test/tools/javac/fatalErrors/NoJavaLang.sh
deleted file mode 100644
index 77cc37c..0000000
--- a/test/tools/javac/fatalErrors/NoJavaLang.sh
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTSRC=${TESTSRC}" ; echo
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTJAVA=${TESTJAVA}" ; echo
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTCLASSES=${TESTCLASSES}" ; echo
-printf '%s' "CLASSPATH=${CLASSPATH}" ; echo
-echo
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}NoJavaLang.java" .
-
-echo "- verifing that fatal error is not produced in the regular case" 
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed - base compilation successful"
-else
-  echo "Failed - unable to compile test"
-  exit $result
-fi
-
-echo
-
-echo "- verifing the fatal error is produced"
-rm "${TMP1}"
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
-
-# return code should be EXIT_SYSERR
-result=$?
-if [ $result -ne 3 ]
-then
-  echo "Failed - unexpected return code"
-  exit $result
-else
-  echo "Passed - expected return code"
-fi
-
-# expected message
-cat "${TMP1}"
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
-result=$?
-rm "${TMP1}"
-
-if [ $result -eq 0 ]
-then
-  echo "Passed - expected message"
-else
-  echo "Failed - unexpected message"
-  exit $result
-
-fi
-
-exit
diff --git a/test/tools/javac/fatalErrors/NoJavaLangTest.java b/test/tools/javac/fatalErrors/NoJavaLangTest.java
new file mode 100644
index 0000000..6a1c7b8
--- /dev/null
+++ b/test/tools/javac/fatalErrors/NoJavaLangTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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 4263768 4785453
+ * @summary Verify that the compiler does not crash when java.lang is not
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NoJavaLangTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javac/fatalErrors/NoJavaLang.sh
+public class NoJavaLangTest {
+
+    private static final String noJavaLangSrc =
+        "public class NoJavaLang {\n" +
+        "    private String s;\n" +
+        "\n" +
+        "    public String s() {\n" +
+        "        return s;\n" +
+        "    }\n" +
+        "}";
+
+    private static final String compilerErrorMessage =
+        "Fatal Error: Unable to find package java.lang in classpath or bootclasspath";
+
+    public static void main(String[] args) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
+        ToolBox.JavaToolArgs javacSuccessArgs =
+                new ToolBox.JavaToolArgs().setSources(noJavaLangSrc);
+        ToolBox.javac(javacSuccessArgs);
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
+        List<String> output = new ArrayList<>();
+        ToolBox.JavaToolArgs javacFailArgs =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setOptions("-bootclasspath", ".")
+                .setSources(noJavaLangSrc)
+                .setErrOutput(output);
+
+        int cr = ToolBox.javac(javacFailArgs);
+        if (cr != 3) {
+            throw new AssertionError("Compiler exit result should be 3");
+        }
+
+//        diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
+        if (!(output.size() == 1 && output.get(0).equals(compilerErrorMessage))) {
+            throw new AssertionError("javac generated error output is not correct");
+        }
+    }
+
+}
diff --git a/test/tools/javac/file/T7018098.java b/test/tools/javac/file/T7018098.java
index bc8009c..bacc116 100644
--- a/test/tools/javac/file/T7018098.java
+++ b/test/tools/javac/file/T7018098.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 7018098
  * @summary CacheFSInfo persists too long
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor T7018098
  * @run main T7018098
  */
diff --git a/test/tools/javac/file/zip/8003512/LoadClassFromJava6CreatedJarTest.java b/test/tools/javac/file/zip/8003512/LoadClassFromJava6CreatedJarTest.java
new file mode 100644
index 0000000..a315ad8
--- /dev/null
+++ b/test/tools/javac/file/zip/8003512/LoadClassFromJava6CreatedJarTest.java
@@ -0,0 +1,183 @@
+
+/*
+ * Copyright (c) 2002, 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.
+ */
+
+/*
+ * @test
+ * @bug 8003512
+ * @summary javac doesn't work with jar files with >64k entries
+ * @compile -target 6 -source 6 -XDignore.symbol.file LoadClassFromJava6CreatedJarTest.java ../Utils.java
+ * @run main/timeout=360 LoadClassFromJava6CreatedJarTest
+ */
+
+/*
+ * The test creates a jar file with more than 64K entries. The jar file is
+ * created executing the LoadClassFromJava6CreatedJarTest$MakeJar
+ * class with a JVM version 6. The test must include Java 6 features only.
+ *
+ * The aim is to verify classes included in jar files with more than 64K entries
+ * created with Java 6 can be loaded by more recent versions of Java.
+ *
+ * A path to JDK or JRE version 6 is needed. This can be provided
+ * by passing this option to jtreg:
+ * -javaoption:-Djava6.home="/path/to/jdk_or_jre6"
+ */
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.List;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class LoadClassFromJava6CreatedJarTest {
+
+    static final String javaHome6 = System.getProperty("java6.home");
+    static final String testClasses = System.getProperty("test.classes");
+
+    public static void main(String... args)
+            throws IOException, InterruptedException {
+        if (javaHome6 != null) {
+            new LoadClassFromJava6CreatedJarTest().run();
+        } else {
+            System.out.println(
+                "The test LoadClassFromJava6CreatedJarTest cannot be executed. " +
+                "In order to run it you should pass an option with " +
+                "this form -javaoption:-Djava6.home=\"/path/to/jdk_or_jre6\" " +
+                "to jtreg.");
+        }
+    }
+
+    void run() throws IOException, InterruptedException {
+        File classA = new File("A.java");
+        Utils.createJavaFile(classA, null);
+        if (!Utils.compile("-target", "6", "-source", "6",
+            classA.getAbsolutePath())) {
+            throw new AssertionError("Test failed while compiling class A");
+        }
+
+        executeCommand(Arrays.asList(javaHome6 + "/bin/java", "-classpath",
+            testClasses, "LoadClassFromJava6CreatedJarTest$MakeJar"));
+
+        File classB = new File("B.java");
+        Utils.createJavaFile(classB, classA);
+        if (!Utils.compile("-cp", "a.jar", classB.getAbsolutePath())) {
+            throw new AssertionError("Test failed while compiling class Main");
+        }
+    }
+
+    void executeCommand(List<String> command)
+            throws IOException, InterruptedException {
+        ProcessBuilder pb = new ProcessBuilder(command).
+            redirectErrorStream(true);
+        Process p = pb.start();
+        BufferedReader r =
+            new BufferedReader(new InputStreamReader(p.getInputStream()));
+        String line;
+        while ((line = r.readLine()) != null) {
+            System.err.println(line);
+        }
+        int rc = p.waitFor();
+        if (rc != 0) {
+            throw new AssertionError("Unexpected exit code: " + rc);
+        }
+    }
+
+    static class MakeJar {
+        public static void main(String[] args) throws Throwable {
+            File classFile = new File("A.class");
+            ZipOutputStream zos = null;
+            FileInputStream fis = null;
+            final int MAX = Short.MAX_VALUE * 2 + 10;
+            ZipEntry ze = null;
+            try {
+                zos = new ZipOutputStream(new FileOutputStream("a.jar"));
+                zos.setLevel(ZipOutputStream.STORED);
+                zos.setMethod(ZipOutputStream.STORED);
+                for (int i = 0; i < MAX ; i++) {
+                    ze = new ZipEntry("X" + i + ".txt");
+                    ze.setSize(0);
+                    ze.setCompressedSize(0);
+                    ze.setCrc(0);
+                    zos.putNextEntry(ze);
+                }
+
+                // add a class file
+                ze = new ZipEntry("A.class");
+                ze.setCompressedSize(classFile.length());
+                ze.setSize(classFile.length());
+                ze.setCrc(computeCRC(classFile));
+                zos.putNextEntry(ze);
+                fis = new FileInputStream(classFile);
+                for (int c; (c = fis.read()) >= 0;) {
+                    zos.write(c);
+                }
+            } finally {
+                zos.close();
+                fis.close();
+            }
+        }
+
+        private static final int BUFFER_LEN = Short.MAX_VALUE * 2;
+
+        static long getCount(long minlength) {
+            return (minlength / BUFFER_LEN) + 1;
+        }
+
+        static long computeCRC(long minlength) {
+            CRC32 crc = new CRC32();
+            byte[] buffer = new byte[BUFFER_LEN];
+            long count = getCount(minlength);
+            for (long i = 0; i < count; i++) {
+                crc.update(buffer);
+            }
+            return crc.getValue();
+        }
+
+        static long computeCRC(File inFile) throws IOException {
+            byte[] buffer = new byte[8192];
+            CRC32 crc = new CRC32();
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try {
+                fis = new FileInputStream(inFile);
+                bis = new BufferedInputStream(fis);
+                int n = bis.read(buffer);
+                while (n > 0) {
+                    crc.update(buffer, 0, n);
+                    n = bis.read(buffer);
+                }
+            } finally {
+                bis.close();
+                fis.close();
+            }
+            return crc.getValue();
+        }
+    }
+}
diff --git a/test/tools/javac/file/zip/Utils.java b/test/tools/javac/file/zip/Utils.java
index 2f5f31b..35e7c6d 100644
--- a/test/tools/javac/file/zip/Utils.java
+++ b/test/tools/javac/file/zip/Utils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,6 +21,12 @@
  * questions.
  */
 
+/*
+ * This utils class is been used by test T8003512 which is compiled with Java 6
+ * only features. So if this class is modified, it should be so using Java 6
+ * features only.
+ */
+
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.Closeable;
diff --git a/test/tools/javac/foreach/7139681/T7139681neg.java b/test/tools/javac/foreach/7139681/T7139681neg.java
new file mode 100644
index 0000000..e5b34a5
--- /dev/null
+++ b/test/tools/javac/foreach/7139681/T7139681neg.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7139681
+ * @summary Enhanced for loop: local variable scope inconsistent with JLS
+ *
+ * @compile/fail/ref=T7139681neg.out -XDrawDiagnostics T7139681neg.java
+ */
+class T7139681neg {
+    void testArray() {
+        for (int a : a) { }
+    }
+
+    void testIterable() {
+        for (Integer b : b) { }
+    }
+}
diff --git a/test/tools/javac/foreach/7139681/T7139681neg.out b/test/tools/javac/foreach/7139681/T7139681neg.out
new file mode 100644
index 0000000..f900f9d
--- /dev/null
+++ b/test/tools/javac/foreach/7139681/T7139681neg.out
@@ -0,0 +1,3 @@
+T7139681neg.java:10:22: compiler.err.cant.resolve.location: kindname.variable, a, , , (compiler.misc.location: kindname.class, T7139681neg, null)
+T7139681neg.java:14:26: compiler.err.cant.resolve.location: kindname.variable, b, , , (compiler.misc.location: kindname.class, T7139681neg, null)
+2 errors
diff --git a/test/tools/javac/foreach/7139681/T7139681pos.java b/test/tools/javac/foreach/7139681/T7139681pos.java
new file mode 100644
index 0000000..bca79e9
--- /dev/null
+++ b/test/tools/javac/foreach/7139681/T7139681pos.java
@@ -0,0 +1,46 @@
+/*
+ * 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 7139681
+ * @summary Enhanced for loop: local variable scope inconsistent with JLS
+ *
+ * @compile T7139681pos.java
+ */
+class T7139681pos {
+    int[] a;
+    Iterable<Integer> b;
+
+    void testArray() {
+        for (int a : a) {
+            int a2 = a;
+        }
+    }
+
+    void testIterable() {
+        for (Integer b : b) {
+            Integer b2 = b;
+        }
+    }
+}
diff --git a/test/tools/javac/generics/6207386/T6207386.out b/test/tools/javac/generics/6207386/T6207386.out
index 768c5c2..cb14ad3 100644
--- a/test/tools/javac/generics/6207386/T6207386.out
+++ b/test/tools/javac/generics/6207386/T6207386.out
@@ -1,2 +1,2 @@
-T6207386.java:13:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), X, T6207386.F<? super X>
+T6207386.java:13:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: X, T6207386.F<? super X>)
 1 error
diff --git a/test/tools/javac/generics/6723444/T6723444.java b/test/tools/javac/generics/6723444/T6723444.java
index 6d7c339..faf563d 100644
--- a/test/tools/javac/generics/6723444/T6723444.java
+++ b/test/tools/javac/generics/6723444/T6723444.java
@@ -4,7 +4,8 @@
  *
  * @summary javac fails to substitute type variables into a constructor's throws clause
  * @author Mark Mahieu
- * @compile/fail/ref=T6723444.out -XDrawDiagnostics T6723444.java
+ * @compile/fail/ref=T6723444_1.out -Xlint:-options -source 7 -XDrawDiagnostics T6723444.java
+ * @compile/fail/ref=T6723444_2.out -XDrawDiagnostics T6723444.java
  *
  */
 public class T6723444 {
diff --git a/test/tools/javac/generics/6723444/T6723444.out b/test/tools/javac/generics/6723444/T6723444.out
deleted file mode 100644
index add9485..0000000
--- a/test/tools/javac/generics/6723444/T6723444.out
+++ /dev/null
@@ -1,13 +0,0 @@
-T6723444.java:42:9: compiler.err.unreported.exception.need.to.catch.or.throw: X2
-T6723444.java:43:9: compiler.err.unreported.exception.need.to.catch.or.throw: X2
-T6723444.java:45:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:46:17: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:48:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:49:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:50:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:51:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:52:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:53:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:54:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-T6723444.java:55:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
-12 errors
diff --git a/test/tools/javac/generics/6723444/T6723444_1.out b/test/tools/javac/generics/6723444/T6723444_1.out
new file mode 100644
index 0000000..0b14993
--- /dev/null
+++ b/test/tools/javac/generics/6723444/T6723444_1.out
@@ -0,0 +1,13 @@
+T6723444.java:43:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:44:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:46:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:47:17: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:49:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:50:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:51:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:52:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:53:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:54:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:55:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:56:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+12 errors
diff --git a/test/tools/javac/generics/6723444/T6723444_2.out b/test/tools/javac/generics/6723444/T6723444_2.out
new file mode 100644
index 0000000..7fbc519
--- /dev/null
+++ b/test/tools/javac/generics/6723444/T6723444_2.out
@@ -0,0 +1,11 @@
+T6723444.java:46:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:47:17: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:49:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:50:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:51:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:52:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:53:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:54:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:55:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+T6723444.java:56:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable
+10 errors
diff --git a/test/tools/javac/generics/7015430/T7015430.java b/test/tools/javac/generics/7015430/T7015430.java
index f875e53..c0f89d6 100644
--- a/test/tools/javac/generics/7015430/T7015430.java
+++ b/test/tools/javac/generics/7015430/T7015430.java
@@ -4,7 +4,8 @@
  *
  * @summary  Incorrect thrown type determined for unchecked invocations
  * @author Daniel Smith
- * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
+ * @compile/fail/ref=T7015430_1.out -source 7 -Xlint:-options,unchecked -XDrawDiagnostics T7015430.java
+ * @compile/fail/ref=T7015430_2.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
  *
  */
 
diff --git a/test/tools/javac/generics/7015430/T7015430.out b/test/tools/javac/generics/7015430/T7015430.out
deleted file mode 100644
index 269d484..0000000
--- a/test/tools/javac/generics/7015430/T7015430.out
+++ /dev/null
@@ -1,19 +0,0 @@
-T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
-T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
-T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
-T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
-T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
-T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
-T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T7015430.java:95:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T7015430.java:113:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T7015430.java:129:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-5 errors
-12 warnings
diff --git a/test/tools/javac/generics/7015430/T7015430_1.out b/test/tools/javac/generics/7015430/T7015430_1.out
new file mode 100644
index 0000000..3bee4e5
--- /dev/null
+++ b/test/tools/javac/generics/7015430/T7015430_1.out
@@ -0,0 +1,19 @@
+T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:42:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:69:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:96:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:114:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:130:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+5 errors
+12 warnings
diff --git a/test/tools/javac/generics/7015430/T7015430_2.out b/test/tools/javac/generics/7015430/T7015430_2.out
new file mode 100644
index 0000000..da5be70
--- /dev/null
+++ b/test/tools/javac/generics/7015430/T7015430_2.out
@@ -0,0 +1,15 @@
+T7015430.java:42:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:42:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:51:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:51:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:69:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:69:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:78:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:78:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:105:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:105:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:114:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:114:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:130:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+1 error
+12 warnings
diff --git a/test/tools/javac/generics/7022054/T7022054pos1.java b/test/tools/javac/generics/7022054/T7022054pos1.java
index 2b87e72..25003a8 100644
--- a/test/tools/javac/generics/7022054/T7022054pos1.java
+++ b/test/tools/javac/generics/7022054/T7022054pos1.java
@@ -26,7 +26,8 @@
  * @bug 7022054
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
- * @compile T7022054pos1.java
+ * @compile -source 7 T7022054pos1.java
+ * @compile/fail/ref=T7022054pos1.out -XDrawDiagnostics T7022054pos1.java
  *
  */
 
diff --git a/test/tools/javac/generics/7022054/T7022054pos1.out b/test/tools/javac/generics/7022054/T7022054pos1.out
new file mode 100644
index 0000000..b7f4106
--- /dev/null
+++ b/test/tools/javac/generics/7022054/T7022054pos1.out
@@ -0,0 +1,2 @@
+T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: <X>m(java.lang.String), T7022054pos1.B, m(java.lang.String), T7022054pos1.A, <X>m(java.lang.String), T7022054pos1.B
+1 error
diff --git a/test/tools/javac/generics/7022054/T7022054pos2.java b/test/tools/javac/generics/7022054/T7022054pos2.java
index e577630..613b454 100644
--- a/test/tools/javac/generics/7022054/T7022054pos2.java
+++ b/test/tools/javac/generics/7022054/T7022054pos2.java
@@ -26,8 +26,8 @@
  * @bug 7022054
  *
  * @summary  Invalid compiler error on covariant overriding methods with the same erasure
- * @compile T7022054pos2.java
- *
+ * @compile -source 7 T7022054pos2.java
+ * @compile/fail/ref=T7022054pos2.out -XDrawDiagnostics T7022054pos2.java
  */
 
 class T7022054pos2 {
diff --git a/test/tools/javac/generics/7022054/T7022054pos2.out b/test/tools/javac/generics/7022054/T7022054pos2.out
new file mode 100644
index 0000000..406bef8
--- /dev/null
+++ b/test/tools/javac/generics/7022054/T7022054pos2.out
@@ -0,0 +1,2 @@
+T7022054pos2.java:38:32: compiler.err.name.clash.same.erasure.no.hide: <X>m(java.lang.String), T7022054pos2.B, m(java.lang.String), T7022054pos2.A
+1 error
diff --git a/test/tools/javac/generics/7034511/T7034511a.java b/test/tools/javac/generics/7034511/T7034511a.java
index 5a8709c..26418d6 100644
--- a/test/tools/javac/generics/7034511/T7034511a.java
+++ b/test/tools/javac/generics/7034511/T7034511a.java
@@ -1,7 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @ignore backing out 7034511, see 7040883
- * @bug     7034511 7040883
+ * @bug     7034511 7040883 7041019
  * @summary Loophole in typesafety
  * @compile/fail/ref=T7034511a.out -XDrawDiagnostics T7034511a.java
  */
diff --git a/test/tools/javac/generics/7034511/T7034511a.out b/test/tools/javac/generics/7034511/T7034511a.out
index 8636950..4ce8eaf 100644
--- a/test/tools/javac/generics/7034511/T7034511a.out
+++ b/test/tools/javac/generics/7034511/T7034511a.out
@@ -1,2 +1,2 @@
-T7034511a.java:18:14: compiler.err.cant.apply.symbol.1: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A<T>, (compiler.misc.no.conforming.assignment.exists: java.lang.String[], compiler.misc.type.captureof: 1, ?[])
+T7034511a.java:18:14: compiler.err.cant.apply.symbol: kindname.method, foo, compiler.misc.type.captureof: 1, ?[], java.lang.String[], kindname.interface, T7034511a.A<T>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String[], compiler.misc.type.captureof: 1, ?[]))
 1 error
diff --git a/test/tools/javac/generics/7034511/T7034511b.java b/test/tools/javac/generics/7034511/T7034511b.java
index de29aea..93d1678 100644
--- a/test/tools/javac/generics/7034511/T7034511b.java
+++ b/test/tools/javac/generics/7034511/T7034511b.java
@@ -1,7 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @ignore backing out 7034511, see 7040883
- * @bug     7034511 7040883
+ * @bug     7034511 7040883 7041019
  * @summary Loophole in typesafety
  * @compile/fail/ref=T7034511b.out -XDrawDiagnostics T7034511b.java
  */
diff --git a/test/tools/javac/generics/7034511/T7034511b.out b/test/tools/javac/generics/7034511/T7034511b.out
index 5d3da3f..1cff6c3 100644
--- a/test/tools/javac/generics/7034511/T7034511b.out
+++ b/test/tools/javac/generics/7034511/T7034511b.out
@@ -1,2 +1,2 @@
-T7034511b.java:14:11: compiler.err.cant.apply.symbol.1: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList<E>, (compiler.misc.no.conforming.assignment.exists: java.lang.Object[], compiler.misc.type.captureof: 1, ?[])
+T7034511b.java:14:11: compiler.err.cant.apply.symbol: kindname.method, toArray, compiler.misc.type.captureof: 1, ?[], java.lang.Object[], kindname.class, T7034511b.MyList<E>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object[], compiler.misc.type.captureof: 1, ?[]))
 1 error
diff --git a/test/tools/javac/generics/7034511/T7041019.java b/test/tools/javac/generics/7034511/T7041019.java
new file mode 100644
index 0000000..78b7bed
--- /dev/null
+++ b/test/tools/javac/generics/7034511/T7041019.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 7034511 7040883 7041019
+ * @summary Bogus type-variable substitution with array types with dependencies on accessibility check
+ *
+ * @compile T7041019.java
+ */
+import java.util.List;
+
+class T7041019 {
+   <E> List<E>[] m(List<E> l) { return null; }
+
+   void test(List<? extends String> ls) {
+      int i = m(ls).length;
+   }
+}
diff --git a/test/tools/javac/generics/7151802/T7151802.java b/test/tools/javac/generics/7151802/T7151802.java
new file mode 100644
index 0000000..efc1aec
--- /dev/null
+++ b/test/tools/javac/generics/7151802/T7151802.java
@@ -0,0 +1,43 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7151802
+ * @summary compiler update caused sqe test failed
+ * @compile/fail/ref=T7151802.out -Werror -Xlint:unchecked -XDrawDiagnostics T7151802.java
+ */
+class T7151802 {
+    static class Foo<X> { }
+
+    static class SubFoo<X> extends Foo<X> { }
+
+    //generic - bound - arg - non-slilent
+    <Z extends Foo<String>> void get1(Z fz) { }
+    void test1(Foo foo) { get1(foo); }
+
+    //generic - bound - arg - silent
+    <Z extends Foo<?>> void get2(Z fz) { }
+    void test2(Foo foo) { get2(foo); }
+
+    //generic - nobound - arg - non-slilent
+    <Z> void get3(Foo<Z> fz) { }
+    void test(Foo foo) { get3(foo); }
+
+    //generic - nobound - arg - slilent
+    <Z> void get4(Foo<?> fz) { }
+    void test4(Foo foo) { get4(foo); }
+
+    //generic - bound - ret - non-slilent
+    <Z extends Foo<String>> Z get5() { return null; }
+    void test5() { SubFoo sf = get5(); }
+
+    //generic - bound - ret - slilent
+    static <Z extends Foo<?>> Z get6() { return null; }
+    void test6() { SubFoo sf = get6(); }
+
+    //nogeneric - nobound - arg - non-slilent
+    void get7(Foo<String> fz) { }
+    void test7(Foo foo) { get7(foo); }
+
+    //nogeneric - nobound - arg - slilent
+    static void get8(Foo<?> fz) { }
+    void test8(Foo foo) { get8(foo); }
+}
diff --git a/test/tools/javac/generics/7151802/T7151802.out b/test/tools/javac/generics/7151802/T7151802.out
new file mode 100644
index 0000000..dd708d6
--- /dev/null
+++ b/test/tools/javac/generics/7151802/T7151802.out
@@ -0,0 +1,9 @@
+T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802
+T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802
+T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.Object>
+T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802
+T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo<java.lang.String>, T7151802.Foo, kindname.class, T7151802
+T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
+- compiler.err.warnings.and.werror
+1 error
+6 warnings
diff --git a/test/tools/javac/generics/8004094/B.java b/test/tools/javac/generics/8004094/B.java
new file mode 100644
index 0000000..735a7fd
--- /dev/null
+++ b/test/tools/javac/generics/8004094/B.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+abstract class A {
+
+    private static String s = null;
+
+    static void test() {
+        new Object() {
+            void m() {
+                Object o = s;
+            }
+        };
+    }
+}
+
+public abstract class B<T> extends A {
+
+    private static Integer i = null;
+
+    static void test() {
+        new Object() {
+            void m() {
+                Object o = i;
+            }
+        };
+    }
+}
diff --git a/test/tools/javac/generics/8004094/T8004094.java b/test/tools/javac/generics/8004094/T8004094.java
new file mode 100644
index 0000000..76c54d2
--- /dev/null
+++ b/test/tools/javac/generics/8004094/T8004094.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ *
+ * 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 8004094
+ * @summary Javac compiler error - synthetic method accessor generated with duplicate name
+ *
+ * @compile B.java T8004094.java
+ */
+
+public class T8004094 extends B<Object> { }
diff --git a/test/tools/javac/generics/8016640/T8016640.java b/test/tools/javac/generics/8016640/T8016640.java
new file mode 100644
index 0000000..43c7680
--- /dev/null
+++ b/test/tools/javac/generics/8016640/T8016640.java
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     8016640 8022508
+ * @summary compiler hangs if the generics arity of a base class is wrong
+ * @compile/fail/ref=T8016640.out -XDrawDiagnostics T8016640.java
+ */
+class T8016640 {
+    static class Foo<X,Y> { }
+    static class BadFoo<T> extends Foo<T> { }
+    static class SubBadFoo<T> extends BadFoo<T> { }
+}
diff --git a/test/tools/javac/generics/8016640/T8016640.out b/test/tools/javac/generics/8016640/T8016640.out
new file mode 100644
index 0000000..7731422
--- /dev/null
+++ b/test/tools/javac/generics/8016640/T8016640.out
@@ -0,0 +1,2 @@
+T8016640.java:9:39: compiler.err.wrong.number.type.args: 2
+1 error
diff --git a/test/tools/javac/generics/OverrideBridge.java b/test/tools/javac/generics/OverrideBridge.java
index 43c1f5e..9c9af07 100644
--- a/test/tools/javac/generics/OverrideBridge.java
+++ b/test/tools/javac/generics/OverrideBridge.java
@@ -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;
diff --git a/test/tools/javac/generics/bridges/Bridge.java b/test/tools/javac/generics/bridges/Bridge.java
new file mode 100644
index 0000000..76e323e
--- /dev/null
+++ b/test/tools/javac/generics/bridges/Bridge.java
@@ -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.
+ */
+import java.lang.annotation.Repeatable;
+
+ at Repeatable(Bridges.class)
+ at interface Bridge {
+    String value();
+}
diff --git a/test/tools/javac/generics/bridges/BridgeHarness.java b/test/tools/javac/generics/bridges/BridgeHarness.java
new file mode 100644
index 0000000..b4199cf
--- /dev/null
+++ b/test/tools/javac/generics/bridges/BridgeHarness.java
@@ -0,0 +1,219 @@
+/*
+ * 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 8013789
+ * @summary Compiler should emit bridges in interfaces
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor BridgeHarness
+ * @run main BridgeHarness
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.AccessFlags;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPool;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.util.List;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import static javax.tools.StandardLocation.*;
+
+public class BridgeHarness {
+
+    /** number of errors found (must be zero for the test to pass) */
+    static int nerrors = 0;
+
+    /** the (shared) Java compiler used for compiling the tests */
+    static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+    /** the (shared) file manager used by the compiler */
+    static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    public static void main(String[] args) throws Exception {
+        //set sourcepath
+        fm.setLocation(SOURCE_PATH,
+                Arrays.asList(new File(System.getProperty("test.src"), "tests")));
+        //set output (-d)
+        fm.setLocation(javax.tools.StandardLocation.CLASS_OUTPUT,
+                Arrays.asList(new File(System.getProperty("user.dir"))));
+        for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+            //for each source, compile and check against annotations
+            new BridgeHarness(jfo).compileAndCheck();
+        }
+        //if there were errors, fail
+        if (nerrors > 0) {
+            throw new AssertionError("Errors were found");
+        }
+    }
+
+    /* utility methods */
+
+    /**
+     * Remove an element from a list
+     */
+    static <Z> List<Z> drop(List<Z> lz, Z z) {
+        if (lz.head == z) {
+            return drop(lz.tail, z);
+        } else if (lz.isEmpty()) {
+            return lz;
+        } else {
+            return drop(lz.tail, z).prepend(lz.head);
+        }
+    }
+
+    /**
+     * return a string representation of a bytecode method
+     */
+    static String descriptor(Method m, ConstantPool cp) throws ConstantPoolException {
+        return m.getName(cp) + m.descriptor.getValue(cp);
+    }
+
+    /* test harness */
+
+    /** Test file to be compiled */
+    JavaFileObject jfo;
+
+    /** Mapping between class name and list of bridges in class with that name */
+    Map<String, List<Bridge>> bridgesMap = new HashMap<String, List<Bridge>>();
+
+    protected BridgeHarness(JavaFileObject jfo) {
+        this.jfo = jfo;
+    }
+
+    /**
+     * Compile a test using a custom annotation processor and check the generated
+     * bytecode against discovered annotations.
+     */
+    protected void compileAndCheck() throws Exception {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, null, null, null, Arrays.asList(jfo));
+        ct.setProcessors(Collections.singleton(new BridgeFinder()));
+
+        for (JavaFileObject jfo : ct.generate()) {
+            checkBridges(jfo);
+        }
+    }
+
+    /**
+     * Check that every bridge in the generated classfile has a matching bridge
+     * annotation in the bridge map
+     */
+    protected void checkBridges(JavaFileObject jfo) {
+        try (InputStream is = jfo.openInputStream()) {
+            ClassFile cf = ClassFile.read(is);
+            System.err.println("checking: " + cf.getName());
+
+            List<Bridge> bridgeList = bridgesMap.get(cf.getName());
+            if (bridgeList == null) {
+                //no bridges - nothing to check;
+                bridgeList = List.nil();
+            }
+
+            for (Method m : cf.methods) {
+                if (m.access_flags.is(AccessFlags.ACC_SYNTHETIC | AccessFlags.ACC_BRIDGE)) {
+                    //this is a bridge - see if there's a match in the bridge list
+                    Bridge match = null;
+                    for (Bridge b : bridgeList) {
+                        if (b.value().equals(descriptor(m, cf.constant_pool))) {
+                            match = b;
+                            break;
+                        }
+                    }
+                    if (match == null) {
+                        error("No annotation for bridge method: " + descriptor(m, cf.constant_pool));
+                    } else {
+                        bridgeList = drop(bridgeList, match);
+                    }
+                }
+            }
+            if (bridgeList.nonEmpty()) {
+                error("Redundant bridge annotation found: " + bridgeList.head.value());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + jfo.toUri() +": " + e);
+        }
+    }
+
+    /**
+     * Log an error
+     */
+    protected void error(String msg) {
+        nerrors++;
+        System.err.printf("Error occurred while checking file: %s\nreason: %s\n", jfo.getName(), msg);
+    }
+
+    /**
+     * This annotation processor is used to populate the bridge map with the
+     * contents of the annotations that are found on the tests being compiled
+     */
+    @SupportedAnnotationTypes({"Bridges","Bridge"})
+    class BridgeFinder extends JavacTestingAbstractProcessor {
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver())
+                return true;
+
+            TypeElement bridgeAnno = elements.getTypeElement("Bridge");
+            TypeElement bridgesAnno = elements.getTypeElement("Bridges");
+
+            //see if there are repeated annos
+            for (Element elem: roundEnv.getElementsAnnotatedWith(bridgesAnno)) {
+                List<Bridge> bridgeList = List.nil();
+                Bridges bridges = elem.getAnnotation(Bridges.class);
+                for (Bridge bridge : bridges.value()) {
+                    bridgeList = bridgeList.prepend(bridge);
+                }
+                bridgesMap.put(((ClassSymbol)elem).flatname.toString(), bridgeList);
+            }
+
+            //see if there are non-repeated annos
+            for (Element elem: roundEnv.getElementsAnnotatedWith(bridgeAnno)) {
+                Bridge bridge = elem.getAnnotation(Bridge.class);
+                bridgesMap.put(((ClassSymbol)elem).flatname.toString(),
+                        List.of(bridge));
+            }
+
+            return true;
+        }
+    }
+}
diff --git a/test/tools/javac/generics/bridges/Bridges.java b/test/tools/javac/generics/bridges/Bridges.java
new file mode 100644
index 0000000..1980cf1
--- /dev/null
+++ b/test/tools/javac/generics/bridges/Bridges.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+ at interface Bridges {
+    Bridge[] value();
+}
diff --git a/test/tools/javac/generics/bridges/tests/TestBridgeWithDefault.java b/test/tools/javac/generics/bridges/tests/TestBridgeWithDefault.java
new file mode 100644
index 0000000..51a7ada
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestBridgeWithDefault.java
@@ -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.
+ */
+class TestBridgeWithDefault {
+    interface A { Object m(int x); }
+
+    @Bridge("m(I)Ljava/lang/Object;")
+    interface B extends A {
+        String m(int x);
+        default Integer m(long x) { return null; }
+    }
+}
diff --git a/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical01.java b/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical01.java
new file mode 100644
index 0000000..370cddc
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical01.java
@@ -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.
+ */
+class TestClassAndInterfaceBridgeIdentical01 {
+
+    interface A { Object m(); }
+    interface B { Number m(); }
+
+    @Bridge("m()Ljava/lang/Object;")
+    @Bridge("m()Ljava/lang/Number;")
+    interface C extends A, B {
+        Integer m();
+    }
+
+    @Bridge("m()Ljava/lang/Object;")
+    @Bridge("m()Ljava/lang/Number;")
+    static abstract class D implements A, B {
+        public abstract Integer m();
+    }
+
+    @Bridge("m()Ljava/lang/Object;")
+    @Bridge("m()Ljava/lang/Number;")
+    static class E implements A, B {
+        public Integer m() { return 1; }
+    }
+}
diff --git a/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical02.java b/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical02.java
new file mode 100644
index 0000000..c774d60
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestClassAndInterfaceBridgeIdentical02.java
@@ -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.
+ */
+class TestClassAndInterfaceBridgeIdentical02 {
+
+    interface A<X extends Object> { void m(X x); }
+    interface B<X extends Number> { void m(X x); }
+
+    @Bridge("m(Ljava/lang/Object;)V")
+    @Bridge("m(Ljava/lang/Number;)V")
+    interface C extends A<Integer>, B<Integer> {
+        void m(Integer i);
+    }
+
+    @Bridge("m(Ljava/lang/Object;)V")
+    @Bridge("m(Ljava/lang/Number;)V")
+    static abstract class D implements A<Integer>, B<Integer> {
+        public abstract void m(Integer i);
+    }
+
+    @Bridge("m(Ljava/lang/Object;)V")
+    @Bridge("m(Ljava/lang/Number;)V")
+    static class E implements A<Integer>, B<Integer> {
+        public void m(Integer i) { }
+    }
+}
diff --git a/test/tools/javac/generics/bridges/tests/TestNoBridgeInSiblingsSuper.java b/test/tools/javac/generics/bridges/tests/TestNoBridgeInSiblingsSuper.java
new file mode 100644
index 0000000..bfe1dcb
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestNoBridgeInSiblingsSuper.java
@@ -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.
+ */
+class TestNoBridgeInSiblingSuper {
+    interface A { Object m(); }
+    interface B { String m(); }
+    //no bridge here!
+    interface C extends A, B { }
+
+    @Bridge("m()Ljava/lang/Object;")
+    interface D extends C {
+        String m();
+    }
+}
+
diff --git a/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges01.java b/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges01.java
new file mode 100644
index 0000000..d575ef9
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges01.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+class TestNoDuplicateBridges01 {
+    interface A1 { Object m(); }
+    interface A2 { Object m(); }
+
+    @Bridge("m()Ljava/lang/Object;")
+    interface B extends A1, A2 { B m(); }
+}
diff --git a/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges02.java b/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges02.java
new file mode 100644
index 0000000..adab090
--- /dev/null
+++ b/test/tools/javac/generics/bridges/tests/TestNoDuplicateBridges02.java
@@ -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.
+ */
+class TestNoDuplicateBridges02 {
+    interface A<T> {
+        A<T> get();
+    }
+
+    @Bridge("get()LTestNoDuplicateBridges02$A;")
+    interface B<T> extends A<T> {
+        B<T> get();
+    }
+
+    @Bridge("get()LTestNoDuplicateBridges02$A;")
+    @Bridge("get()LTestNoDuplicateBridges02$B;")
+    interface C<T> extends A<T>, B<T> {
+        C<T> get();
+    }
+}
diff --git a/test/tools/javac/generics/diamond/6939780/T6939780.java b/test/tools/javac/generics/diamond/6939780/T6939780.java
new file mode 100644
index 0000000..d3f41e4
--- /dev/null
+++ b/test/tools/javac/generics/diamond/6939780/T6939780.java
@@ -0,0 +1,50 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939780 7020044 8009459 8021338
+ *
+ * @summary  add a warning to detect diamond sites
+ * @author mcimadamore
+ * @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfindDiamond
+ * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfindDiamond
+ *
+ */
+
+class T6939780 {
+
+    static class Foo<X extends Number> {
+        Foo() {}
+        Foo(X x) {}
+    }
+
+    void testAssign() {
+        Foo<Number> f1 = new Foo<Number>(1);
+        Foo<?> f2 = new Foo<Number>();
+        Foo<?> f3 = new Foo<Integer>();
+        Foo<Number> f4 = new Foo<Number>(1) {};
+        Foo<?> f5 = new Foo<Number>() {};
+        Foo<?> f6 = new Foo<Integer>() {};
+    }
+
+    void testMethod() {
+        gn(new Foo<Number>(1));
+        gw(new Foo<Number>());
+        gw(new Foo<Integer>());
+        gn(new Foo<Number>(1) {});
+        gw(new Foo<Number>() {});
+        gw(new Foo<Integer>() {});
+    }
+
+    void gw(Foo<?> fw) { }
+    void gn(Foo<Number> fn) { }
+
+    static class Foo2<X> {
+        X copy(X t) {
+            return t;
+        }
+    }
+
+    void testReciever() {
+        Number s = new Foo2<Number>().copy(0);
+    }
+
+}
diff --git a/test/tools/javac/generics/diamond/6939780/T6939780_7.out b/test/tools/javac/generics/diamond/6939780/T6939780_7.out
new file mode 100644
index 0000000..f44ff80
--- /dev/null
+++ b/test/tools/javac/generics/diamond/6939780/T6939780_7.out
@@ -0,0 +1,4 @@
+T6939780.java:21:28: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:30:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+3 warnings
diff --git a/test/tools/javac/generics/diamond/6939780/T6939780_8.out b/test/tools/javac/generics/diamond/6939780/T6939780_8.out
new file mode 100644
index 0000000..dfbda80
--- /dev/null
+++ b/test/tools/javac/generics/diamond/6939780/T6939780_8.out
@@ -0,0 +1,7 @@
+T6939780.java:20:33: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:21:28: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:29:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:30:19: compiler.warn.diamond.redundant.args: T6939780.Foo<java.lang.Number>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+6 warnings
diff --git a/test/tools/javac/generics/diamond/7002837/T7002837.java b/test/tools/javac/generics/diamond/7002837/T7002837.java
index 4a93005..acdb72b 100644
--- a/test/tools/javac/generics/diamond/7002837/T7002837.java
+++ b/test/tools/javac/generics/diamond/7002837/T7002837.java
@@ -4,7 +4,7 @@
  *
  * @summary  Diamond: javac generates diamond inference errors when in 'finder' mode
  * @author mcimadamore
- * @compile -Werror -XDfindDiamond T7002837.java
+ * @compile/fail/ref=T7002837.out -Werror -XDrawDiagnostics -XDfindDiamond T7002837.java
  *
  */
 
diff --git a/test/tools/javac/generics/diamond/7002837/T7002837.out b/test/tools/javac/generics/diamond/7002837/T7002837.out
new file mode 100644
index 0000000..fbd134d
--- /dev/null
+++ b/test/tools/javac/generics/diamond/7002837/T7002837.out
@@ -0,0 +1,4 @@
+T7002837.java:13:19: compiler.warn.diamond.redundant.args.1: T7002837<java.lang.Integer>, T7002837<java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java b/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java
index 3aab739..b50c4ef 100644
--- a/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java
+++ b/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -23,23 +23,27 @@
 
 /*
  * @test
- * @bug 7046778
+ * @bug 7046778 8006694
  * @summary Project Coin: problem with diamond and member inner classes
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm DiamondAndInnerClassTest
  */
 
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import com.sun.source.util.JavacTask;
 import java.net.URI;
 import java.util.Arrays;
 import javax.tools.Diagnostic;
-import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-public class DiamondAndInnerClassTest {
 
-    static int checkCount = 0;
+public class DiamondAndInnerClassTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     enum TypeArgumentKind {
         NONE(""),
@@ -151,11 +155,6 @@ public class DiamondAndInnerClassTest {
     }
 
     public static void main(String... args) throws Exception {
-
-        //create default shared JavaCompiler - reused across multiple compilations
-        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
-
         for (InnerClassDeclArity innerClassDeclArity : InnerClassDeclArity.values()) {
             for (TypeQualifierArity declType : TypeQualifierArity.values()) {
                 if (!declType.matches(innerClassDeclArity)) continue;
@@ -168,53 +167,79 @@ public class DiamondAndInnerClassTest {
                             //no diamond on decl site
                             if (taDecl1 == TypeArgumentKind.DIAMOND) continue;
                             for (TypeArgumentKind taSite1 : TypeArgumentKind.values()) {
-                                boolean isSiteRaw = taSite1 == TypeArgumentKind.NONE;
+                                boolean isSiteRaw =
+                                        taSite1 == TypeArgumentKind.NONE;
                                 //diamond only allowed on the last type qualifier
                                 if (taSite1 == TypeArgumentKind.DIAMOND &&
-                                        innerClassDeclArity != InnerClassDeclArity.ONE) continue;
+                                        innerClassDeclArity !=
+                                        InnerClassDeclArity.ONE)
+                                    continue;
                                 for (ArgumentKind arg1 : ArgumentKind.values()) {
                                     if (innerClassDeclArity == innerClassDeclArity.ONE) {
-                                        new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
-                                                argList, new TypeArgumentKind[] {taDecl1},
-                                                new TypeArgumentKind[] {taSite1}, new ArgumentKind[] {arg1}).run(comp, fm);
+                                        pool.execute(
+                                                new DiamondAndInnerClassTest(
+                                                innerClassDeclArity, declType,
+                                                newClassType, argList,
+                                                new TypeArgumentKind[] {taDecl1},
+                                                new TypeArgumentKind[] {taSite1},
+                                                new ArgumentKind[] {arg1}));
                                         continue;
                                     }
                                     for (TypeArgumentKind taDecl2 : TypeArgumentKind.values()) {
                                         //no rare types
-                                        if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE)) continue;
+                                        if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE))
+                                            continue;
                                         //no diamond on decl site
-                                        if (taDecl2 == TypeArgumentKind.DIAMOND) continue;
+                                        if (taDecl2 == TypeArgumentKind.DIAMOND)
+                                            continue;
                                         for (TypeArgumentKind taSite2 : TypeArgumentKind.values()) {
                                             //no rare types
-                                            if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE)) continue;
+                                            if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE))
+                                                continue;
                                             //diamond only allowed on the last type qualifier
                                             if (taSite2 == TypeArgumentKind.DIAMOND &&
-                                                    innerClassDeclArity != InnerClassDeclArity.TWO) continue;
+                                                    innerClassDeclArity != InnerClassDeclArity.TWO)
+                                                continue;
                                             for (ArgumentKind arg2 : ArgumentKind.values()) {
                                                 if (innerClassDeclArity == innerClassDeclArity.TWO) {
-                                                    new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
-                                                            argList, new TypeArgumentKind[] {taDecl1, taDecl2},
+                                                    pool.execute(
+                                                            new DiamondAndInnerClassTest(
+                                                            innerClassDeclArity,
+                                                            declType,
+                                                            newClassType,
+                                                            argList,
+                                                            new TypeArgumentKind[] {taDecl1, taDecl2},
                                                             new TypeArgumentKind[] {taSite1, taSite2},
-                                                            new ArgumentKind[] {arg1, arg2}).run(comp, fm);
+                                                            new ArgumentKind[] {arg1, arg2}));
                                                     continue;
                                                 }
                                                 for (TypeArgumentKind taDecl3 : TypeArgumentKind.values()) {
                                                     //no rare types
-                                                    if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE)) continue;
+                                                    if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE))
+                                                        continue;
                                                     //no diamond on decl site
-                                                    if (taDecl3 == TypeArgumentKind.DIAMOND) continue;
+                                                    if (taDecl3 == TypeArgumentKind.DIAMOND)
+                                                        continue;
                                                     for (TypeArgumentKind taSite3 : TypeArgumentKind.values()) {
                                                         //no rare types
-                                                        if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE)) continue;
+                                                        if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE))
+                                                            continue;
                                                         //diamond only allowed on the last type qualifier
                                                         if (taSite3 == TypeArgumentKind.DIAMOND &&
-                                                                innerClassDeclArity != InnerClassDeclArity.THREE) continue;
+                                                            innerClassDeclArity != InnerClassDeclArity.THREE)
+                                                            continue;
                                                         for (ArgumentKind arg3 : ArgumentKind.values()) {
-                                                            if (innerClassDeclArity == innerClassDeclArity.THREE) {
-                                                                new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
-                                                                        argList, new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3},
+                                                            if (innerClassDeclArity ==
+                                                                    innerClassDeclArity.THREE) {
+                                                                pool.execute(
+                                                                        new DiamondAndInnerClassTest(
+                                                                        innerClassDeclArity,
+                                                                        declType,
+                                                                        newClassType,
+                                                                        argList,
+                                                                        new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3},
                                                                         new TypeArgumentKind[] {taSite1, taSite2, taSite3},
-                                                                        new ArgumentKind[] {arg1, arg2, arg3}).run(comp, fm);
+                                                                        new ArgumentKind[] {arg1, arg2, arg3}));
                                                                 continue;
                                                             }
                                                         }
@@ -230,7 +255,8 @@ public class DiamondAndInnerClassTest {
                 }
             }
         }
-        System.out.println("Total check executed: " + checkCount);
+
+        checkAfterExec();
     }
 
     InnerClassDeclArity innerClassDeclArity;
@@ -244,9 +270,9 @@ public class DiamondAndInnerClassTest {
     DiagnosticChecker diagChecker;
 
     DiamondAndInnerClassTest(InnerClassDeclArity innerClassDeclArity,
-            TypeQualifierArity declType, TypeQualifierArity siteType, ArgumentListArity argList,
-            TypeArgumentKind[] declTypeArgumentKinds, TypeArgumentKind[] siteTypeArgumentKinds,
-            ArgumentKind[] argumentKinds) {
+            TypeQualifierArity declType, TypeQualifierArity siteType,
+            ArgumentListArity argList, TypeArgumentKind[] declTypeArgumentKinds,
+            TypeArgumentKind[] siteTypeArgumentKinds, ArgumentKind[] argumentKinds) {
         this.innerClassDeclArity = innerClassDeclArity;
         this.declType = declType;
         this.siteType = siteType;
@@ -267,9 +293,9 @@ public class DiamondAndInnerClassTest {
         public JavaSource() {
             super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
             source = innerClassDeclArity.classDeclStr.replace("#B", bodyTemplate)
-                             .replace("#D", declType.getType(declTypeArgumentKinds))
-                             .replace("#S", siteType.getType(siteTypeArgumentKinds))
-                             .replace("#AL", argList.getArgs(argumentKinds));
+                    .replace("#D", declType.getType(declTypeArgumentKinds))
+                    .replace("#S", siteType.getType(siteTypeArgumentKinds))
+                    .replace("#AL", argList.getArgs(argumentKinds));
         }
 
         @Override
@@ -278,36 +304,39 @@ public class DiamondAndInnerClassTest {
         }
     }
 
-    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+    @Override
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
                 null, null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
-            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+            throw new AssertionError("Error thrown when compiling the following code:\n" +
+                    source.getCharContent(true));
         }
         check();
     }
 
     void check() {
-        checkCount++;
+        checkCount.incrementAndGet();
 
         boolean errorExpected = false;
 
-        TypeArgumentKind[] expectedArgKinds = new TypeArgumentKind[innerClassDeclArity.n];
+        TypeArgumentKind[] expectedArgKinds =
+                new TypeArgumentKind[innerClassDeclArity.n];
 
         for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
             if (!declTypeArgumentKinds[i].compatible(siteTypeArgumentKinds[i])) {
                 errorExpected = true;
                 break;
             }
-            expectedArgKinds[i] = siteTypeArgumentKinds[i] == TypeArgumentKind.DIAMOND ?
+            expectedArgKinds[i] = siteTypeArgumentKinds[i] ==
+                    TypeArgumentKind.DIAMOND ?
                 declTypeArgumentKinds[i] : siteTypeArgumentKinds[i];
         }
 
         if (!errorExpected) {
             for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
-                //System.out.println("check " + expectedArgKinds[i] + " against " + argumentKinds[i]);
                 if (!expectedArgKinds[i].compatible(argumentKinds[i])) {
                     errorExpected = true;
                     break;
@@ -323,7 +352,8 @@ public class DiamondAndInnerClassTest {
         }
     }
 
-    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         boolean errorFound;
 
@@ -333,4 +363,5 @@ public class DiamondAndInnerClassTest {
             }
         }
     }
+
 }
diff --git a/test/tools/javac/generics/diamond/7188968/T7188968.java b/test/tools/javac/generics/diamond/7188968/T7188968.java
new file mode 100644
index 0000000..f50bb1a
--- /dev/null
+++ b/test/tools/javac/generics/diamond/7188968/T7188968.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7188968
+ *
+ * @summary  Diamond: javac generates diamond inference errors when in 'finder' mode
+ * @author mcimadamore
+ * @compile/fail/ref=T7188968.out -Xlint:unchecked -XDrawDiagnostics T7188968.java
+ *
+ */
+import java.util.List;
+
+class T7188968 {
+
+    static class Foo<X> {
+        Foo(List<X> ls, Object o) { }
+        static <Z> Foo<Z> makeFoo(List<Z> lz, Object o) { return null; }
+    }
+
+    void test(List l) {
+        new Foo(l, unknown);
+        new Foo(l, unknown) { };
+        new Foo<>(l, unknown);
+        Foo.makeFoo(l, unknown);
+    }
+}
diff --git a/test/tools/javac/generics/diamond/7188968/T7188968.out b/test/tools/javac/generics/diamond/7188968/T7188968.out
new file mode 100644
index 0000000..83b7b8b
--- /dev/null
+++ b/test/tools/javac/generics/diamond/7188968/T7188968.out
@@ -0,0 +1,7 @@
+T7188968.java:20:20: compiler.err.cant.resolve.location: kindname.variable, unknown, , , (compiler.misc.location: kindname.class, T7188968, null)
+T7188968.java:21:20: compiler.err.cant.resolve.location: kindname.variable, unknown, , , (compiler.misc.location: kindname.class, T7188968, null)
+T7188968.java:21:29: compiler.warn.unchecked.call.mbr.of.raw.type: T7188968.Foo(java.util.List<X>,java.lang.Object), T7188968.Foo
+T7188968.java:22:22: compiler.err.cant.resolve.location: kindname.variable, unknown, , , (compiler.misc.location: kindname.class, T7188968, null)
+T7188968.java:23:24: compiler.err.cant.resolve.location: kindname.variable, unknown, , , (compiler.misc.location: kindname.class, T7188968, null)
+4 errors
+1 warning
diff --git a/test/tools/javac/generics/diamond/T6939780.java b/test/tools/javac/generics/diamond/T6939780.java
deleted file mode 100644
index 857320d..0000000
--- a/test/tools/javac/generics/diamond/T6939780.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6939780 7020044
- *
- * @summary  add a warning to detect diamond sites
- * @author mcimadamore
- * @compile/ref=T6939780.out T6939780.java -XDrawDiagnostics -XDfindDiamond
- *
- */
-
-class T6939780 {
-
-    void test() {
-        class Foo<X extends Number> {
-            Foo() {}
-            Foo(X x) {}
-        }
-        Foo<Number> f1 = new Foo<Number>(1);
-        Foo<?> f2 = new Foo<Number>();
-        Foo<?> f3 = new Foo<Integer>();
-        Foo<Number> f4 = new Foo<Number>(1) {};
-        Foo<?> f5 = new Foo<Number>() {};
-        Foo<?> f6 = new Foo<Integer>() {};
-    }
-}
diff --git a/test/tools/javac/generics/diamond/T6939780.out b/test/tools/javac/generics/diamond/T6939780.out
deleted file mode 100644
index 5fe51e6..0000000
--- a/test/tools/javac/generics/diamond/T6939780.out
+++ /dev/null
@@ -1,3 +0,0 @@
-T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
-T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
-2 warnings
diff --git a/test/tools/javac/generics/diamond/neg/Neg05.out b/test/tools/javac/generics/diamond/neg/Neg05.out
index fc8fa05..7ab2ece 100644
--- a/test/tools/javac/generics/diamond/neg/Neg05.out
+++ b/test/tools/javac/generics/diamond/neg/Neg05.out
@@ -1,25 +1,25 @@
 Neg05.java:19:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:19:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
 Neg05.java:20:58: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:20:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
 Neg05.java:21:43: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:21:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
 Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
 Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
 Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
 Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
 Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
 Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:31:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
 Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
 Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:33:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
 Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
 Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
 Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
 Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:38:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
 Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:39:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
 24 errors
diff --git a/test/tools/javac/generics/diamond/neg/Neg06.out b/test/tools/javac/generics/diamond/neg/Neg06.out
index adb2a0d..bf439f7 100644
--- a/test/tools/javac/generics/diamond/neg/Neg06.out
+++ b/test/tools/javac/generics/diamond/neg/Neg06.out
@@ -1,2 +1,2 @@
-Neg06.java:16:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+Neg06.java:16:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
 1 error
diff --git a/test/tools/javac/generics/diamond/neg/Neg07.out b/test/tools/javac/generics/diamond/neg/Neg07.out
index 5ce7f0f..59c3789 100644
--- a/test/tools/javac/generics/diamond/neg/Neg07.out
+++ b/test/tools/javac/generics/diamond/neg/Neg07.out
@@ -1,2 +1,2 @@
-Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
+Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
 1 error
diff --git a/test/tools/javac/generics/diamond/neg/Neg10.java b/test/tools/javac/generics/diamond/neg/Neg10.java
index d8f9a18..5bae2b0 100644
--- a/test/tools/javac/generics/diamond/neg/Neg10.java
+++ b/test/tools/javac/generics/diamond/neg/Neg10.java
@@ -4,7 +4,8 @@
  *
  * @summary  Check that 'complex' diamond can infer type that is too specific
  * @author mcimadamore
- * @compile/fail/ref=Neg10.out Neg10.java -XDrawDiagnostics
+ * @compile/fail/ref=Neg10.out -source 7 -Xlint:-options Neg10.java -XDrawDiagnostics
+ * @compile Neg10.java -XDrawDiagnostics
  *
  */
 
diff --git a/test/tools/javac/generics/diamond/neg/Neg10.out b/test/tools/javac/generics/diamond/neg/Neg10.out
index 8205ae5..d5b323e 100644
--- a/test/tools/javac/generics/diamond/neg/Neg10.out
+++ b/test/tools/javac/generics/diamond/neg/Neg10.out
@@ -1,2 +1,2 @@
-Neg10.java:16:22: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg10.Foo<java.lang.Integer>, Neg10.Foo<java.lang.Number>
+Neg10.java:17:22: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: Neg10.Foo<java.lang.Integer>, Neg10.Foo<java.lang.Number>)
 1 error
diff --git a/test/tools/javac/generics/inference/6278587/T6278587Neg.java b/test/tools/javac/generics/inference/6278587/T6278587Neg.java
index c3d6f47..54ff0ad 100644
--- a/test/tools/javac/generics/inference/6278587/T6278587Neg.java
+++ b/test/tools/javac/generics/inference/6278587/T6278587Neg.java
@@ -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
@@ -23,10 +23,11 @@
 
 /*
  * @test
- * @bug     6278587
+ * @bug     6278587 8007464
  * @summary Inference broken for subtypes of subtypes of F-bounded types
  * @author  Peter von der Ah\u00e9
- * @compile/fail T6278587Neg.java
+ * @compile/fail -source 7 T6278587Neg.java
+ * @compile T6278587Neg.java
  */
 
 public abstract class T6278587Neg {
diff --git a/test/tools/javac/generics/inference/6315770/T6315770.out b/test/tools/javac/generics/inference/6315770/T6315770.out
index befd56e..933cf73 100644
--- a/test/tools/javac/generics/inference/6315770/T6315770.out
+++ b/test/tools/javac/generics/inference/6315770/T6315770.out
@@ -1,3 +1,3 @@
-T6315770.java:16:42: compiler.err.undetermined.type.1: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
-T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String>
+T6315770.java:16:42: compiler.err.prob.found.req: (compiler.misc.incompatible.upper.bounds: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
+T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Integer,java.lang.Runnable)
 2 errors
diff --git a/test/tools/javac/generics/inference/6611449/T6611449.out b/test/tools/javac/generics/inference/6611449/T6611449.out
index 388f3b7..b68f810 100644
--- a/test/tools/javac/generics/inference/6611449/T6611449.out
+++ b/test/tools/javac/generics/inference/6611449/T6611449.out
@@ -1,5 +1,5 @@
-T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))}
-T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch))}
-T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
-T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
+T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch: T))}
+T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch: T)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))}
+T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
+T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
 4 errors
diff --git a/test/tools/javac/generics/inference/6638712/T6638712a.out b/test/tools/javac/generics/inference/6638712/T6638712a.out
index 20446fd..ba745eb 100644
--- a/test/tools/javac/generics/inference/6638712/T6638712a.out
+++ b/test/tools/javac/generics/inference/6638712/T6638712a.out
@@ -1,2 +1,2 @@
-T6638712a.java:16:41: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>)
+T6638712a.java:16:33: compiler.err.cant.apply.symbol: kindname.method, compound, java.lang.Iterable<? extends java.util.Comparator<? super T>>, java.util.List<java.util.Comparator<?>>, kindname.class, T6638712a, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<java.util.Comparator<?>>, java.lang.Iterable<? extends java.util.Comparator<? super T>>))
 1 error
diff --git a/test/tools/javac/generics/inference/6638712/T6638712b.out b/test/tools/javac/generics/inference/6638712/T6638712b.out
index 0033150..9f72699 100644
--- a/test/tools/javac/generics/inference/6638712/T6638712b.out
+++ b/test/tools/javac/generics/inference/6638712/T6638712b.out
@@ -1,2 +1,2 @@
-T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
+T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: T, java.lang.Integer, java.lang.String,java.lang.Object)
 1 error
diff --git a/test/tools/javac/generics/inference/6638712/T6638712c.out b/test/tools/javac/generics/inference/6638712/T6638712c.out
index 0cd7096..9d67519 100644
--- a/test/tools/javac/generics/inference/6638712/T6638712c.out
+++ b/test/tools/javac/generics/inference/6638712/T6638712c.out
@@ -1,2 +1,2 @@
-T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.no.conforming.assignment.exists: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>)
+T6638712c.java:16:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>))
 1 error
diff --git a/test/tools/javac/generics/inference/6638712/T6638712d.out b/test/tools/javac/generics/inference/6638712/T6638712d.out
index 71a1f97..b1137d0 100644
--- a/test/tools/javac/generics/inference/6638712/T6638712d.out
+++ b/test/tools/javac/generics/inference/6638712/T6638712d.out
@@ -1,2 +1,2 @@
-T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.no.conforming.assignment.exists: int, java.lang.String)
+T6638712d.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.incompatible.eq.lower.bounds: U, java.lang.String, java.lang.Integer)
 1 error
diff --git a/test/tools/javac/generics/inference/6638712/T6638712e.out b/test/tools/javac/generics/inference/6638712/T6638712e.out
index 3216ed2..18adee2 100644
--- a/test/tools/javac/generics/inference/6638712/T6638712e.out
+++ b/test/tools/javac/generics/inference/6638712/T6638712e.out
@@ -1,2 +1,2 @@
-T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>
+T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.Object, java.lang.Boolean,java.lang.Object)
 1 error
diff --git a/test/tools/javac/generics/inference/6650759/T6650759m.out b/test/tools/javac/generics/inference/6650759/T6650759m.out
index 474d8db..ee2582c 100644
--- a/test/tools/javac/generics/inference/6650759/T6650759m.out
+++ b/test/tools/javac/generics/inference/6650759/T6650759m.out
@@ -1,2 +1,2 @@
-T6650759m.java:43:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.util.List<? super java.lang.Integer>, java.util.List<? super java.lang.String>
+T6650759m.java:43:36: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Integer,java.lang.Object)
 1 error
diff --git a/test/tools/javac/generics/inference/6718364/T6718364.out b/test/tools/javac/generics/inference/6718364/T6718364.out
index d637c1f..a7a70c6 100644
--- a/test/tools/javac/generics/inference/6718364/T6718364.out
+++ b/test/tools/javac/generics/inference/6718364/T6718364.out
@@ -1,3 +1,3 @@
-T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer>
 T6718364.java:13:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X<T>,T, T6718364.X<T6718364.X<java.lang.Integer>>,T6718364.X, kindname.class, T6718364
+T6718364.java:13:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X<java.lang.Integer>
 2 warnings
diff --git a/test/tools/javac/generics/inference/6838943/T6838943.out b/test/tools/javac/generics/inference/6838943/T6838943.out
index 47aff38..d2cd718 100644
--- a/test/tools/javac/generics/inference/6838943/T6838943.out
+++ b/test/tools/javac/generics/inference/6838943/T6838943.out
@@ -1,2 +1,2 @@
-T6838943.java:13:14: compiler.err.cant.apply.symbol.1: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, T6838943.A<T6838943.B>, T6838943.A<Z>)
+T6838943.java:13:14: compiler.err.cant.apply.symbol: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: T6838943.A<T6838943.B>, T6838943.A<Z>))
 1 error
diff --git a/test/tools/javac/generics/inference/7086586/T7086586.out b/test/tools/javac/generics/inference/7086586/T7086586.out
index e9a6a75..25e696c 100644
--- a/test/tools/javac/generics/inference/7086586/T7086586.out
+++ b/test/tools/javac/generics/inference/7086586/T7086586.out
@@ -1,5 +1,5 @@
-T7086586.java:14:21: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super java.lang.Object>)
-T7086586.java:15:21: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super java.lang.Object>)
-T7086586.java:16:24: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super java.lang.Object>)
-T7086586.java:17:10: compiler.err.invalid.inferred.types: T, (compiler.misc.no.conforming.assignment.exists: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super java.lang.Object>)
+T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
+T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>, java.util.List<compiler.misc.type.captureof: 1, ?>, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List<compiler.misc.type.captureof: 1, ?>, java.util.List<? super T>))
 4 errors
diff --git a/test/tools/javac/generics/inference/7086586/T7086586b.java b/test/tools/javac/generics/inference/7086586/T7086586b.java
new file mode 100644
index 0000000..75dca61
--- /dev/null
+++ b/test/tools/javac/generics/inference/7086586/T7086586b.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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 7086586
+ *
+ * @summary Inference producing null type argument
+ */
+import java.util.List;
+
+public class T7086586b {
+
+    int assertionCount = 0;
+
+    void assertTrue(boolean cond) {
+        if (!cond) {
+            throw new AssertionError();
+        }
+        assertionCount++;
+    }
+
+    <T> void m(List<? super T> dummy) { assertTrue(false); }
+    <T> void m(Object dummy) { assertTrue(true); }
+
+    void test(List<?> l) {
+        m(l);
+        assertTrue(assertionCount == 1);
+    }
+
+    public static void main(String[] args) {
+        new T7086586b().test(null);
+    }
+}
diff --git a/test/tools/javac/generics/inference/7086601/T7086601a.out b/test/tools/javac/generics/inference/7086601/T7086601a.out
index 8b2cdb2..7733826 100644
--- a/test/tools/javac/generics/inference/7086601/T7086601a.out
+++ b/test/tools/javac/generics/inference/7086601/T7086601a.out
@@ -1,5 +1,5 @@
-T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
-T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incomp [...]
-T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
-T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Intege [...]
+T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length. [...]
+T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable [...]
+T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch))}
+T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object)),(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), [...]
 4 errors
diff --git a/test/tools/javac/generics/inference/7086601/T7086601b.java b/test/tools/javac/generics/inference/7086601/T7086601b.java
index 0eceb7f..64a3c81 100644
--- a/test/tools/javac/generics/inference/7086601/T7086601b.java
+++ b/test/tools/javac/generics/inference/7086601/T7086601b.java
@@ -146,7 +146,7 @@ public class T7086601b {
         try {
             ct.analyze();
         } catch (Throwable ex) {
-            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+            throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true));
         }
         check();
     }
diff --git a/test/tools/javac/generics/inference/7154127/T7154127.java b/test/tools/javac/generics/inference/7154127/T7154127.java
new file mode 100644
index 0000000..ea92c86
--- /dev/null
+++ b/test/tools/javac/generics/inference/7154127/T7154127.java
@@ -0,0 +1,22 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7154127 8007464
+ * @summary Inference cleanup: remove bound check analysis from visitors in Types.java
+ * @compile/fail/ref=T7154127.out -Xlint:-options -source 7 -XDrawDiagnostics T7154127.java
+ * @compile T7154127.java
+ */
+class T7154127 {
+
+    static class B<V> {}
+
+    static class D extends B<E> {}
+    static class E extends B<D> {}
+
+    static class Triple<U,V,W> { }
+
+    static <T, Y extends B<U>, U extends B<Y>> Triple<T, Y, U> m() { return null; }
+
+    void test() {
+       Triple<B, ? extends D, ? extends E> t = m();
+    }
+}
diff --git a/test/tools/javac/generics/inference/7154127/T7154127.out b/test/tools/javac/generics/inference/7154127/T7154127.out
new file mode 100644
index 0000000..e3d7798
--- /dev/null
+++ b/test/tools/javac/generics/inference/7154127/T7154127.out
@@ -0,0 +1,2 @@
+T7154127.java:20:49: compiler.err.prob.found.req: (compiler.misc.incompatible.upper.bounds: Y, T7154127.B<U>,T7154127.D)
+1 error
diff --git a/test/tools/javac/generics/inference/7177306/T7177306a.java b/test/tools/javac/generics/inference/7177306/T7177306a.java
new file mode 100644
index 0000000..1e903e4
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306a.java
@@ -0,0 +1,19 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7177306
+ * @summary Regression: unchecked method call does not erase return type
+ * @compile/fail/ref=T7177306a.out -Werror -Xlint:unchecked -XDrawDiagnostics T7177306a.java
+ */
+
+import java.util.List;
+
+class T7177306a<A> {
+
+    public static void test(List l) {
+        T7177306a<Object> to = m(l);
+    }
+
+    public static <E> T7177306a<String> m(List<E> le) {
+        return null;
+    }
+}
diff --git a/test/tools/javac/generics/inference/7177306/T7177306a.out b/test/tools/javac/generics/inference/7177306/T7177306a.out
new file mode 100644
index 0000000..4a21e56
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306a.out
@@ -0,0 +1,6 @@
+T7177306a.java:13:33: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, java.util.List<E>, java.util.List, kindname.class, T7177306a
+T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<java.lang.Object>
+T7177306a.java:13:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7177306a, T7177306a<java.lang.Object>
+- compiler.err.warnings.and.werror
+1 error
+3 warnings
diff --git a/test/tools/javac/generics/inference/7177306/T7177306b.java b/test/tools/javac/generics/inference/7177306/T7177306b.java
new file mode 100644
index 0000000..97953fe
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306b.java
@@ -0,0 +1,18 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7177306
+ * @summary Regression: unchecked method call does not erase return type
+ * @compile/fail/ref=T7177306b.out -Werror -Xlint:unchecked -XDrawDiagnostics T7177306b.java
+ */
+
+import java.util.List;
+
+class T7177306b {
+
+    <T, S extends List<T>> List<T> m(List<? super T> arg1, S arg2, Class<Object> arg3) { return arg2; }
+
+    void test(List<Integer> li, List<String> ls, Class c) {
+        m(li, ls, c);
+        // should fail, because of bounds T <: Integer, S :> List<String>
+    }
+}
diff --git a/test/tools/javac/generics/inference/7177306/T7177306b.out b/test/tools/javac/generics/inference/7177306/T7177306b.out
new file mode 100644
index 0000000..d0d5a0c
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306b.out
@@ -0,0 +1,2 @@
+T7177306b.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List<? super T>,S,java.lang.Class<java.lang.Object>, java.util.List<java.lang.Integer>,java.util.List<java.lang.String>,java.lang.Class, kindname.class, T7177306b, (compiler.misc.incompatible.eq.upper.bounds: T, java.lang.String, java.lang.Integer,java.lang.Object)
+1 error
diff --git a/test/tools/javac/generics/inference/7177306/T7177306c.java b/test/tools/javac/generics/inference/7177306/T7177306c.java
new file mode 100644
index 0000000..3348244
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306c.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 7177306
+ * @summary Regression: unchecked method call does not erase return type
+ */
+public class T7177306c {
+
+    static <T> T m(T t) { return (T)"Null"; }
+
+    public static void main(String[] args) {
+        if (m("NonNullConst") != "Null") {
+            throw new AssertionError("should not get there!");
+        }
+    }
+}
diff --git a/test/tools/javac/generics/inference/7177306/T7177306d.java b/test/tools/javac/generics/inference/7177306/T7177306d.java
new file mode 100644
index 0000000..0f28e8a
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306d.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ *
+ * 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 7177306
+ * @summary Regression: unchecked method call does not erase return type
+ */
+import java.util.List;
+
+public class T7177306d {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        if (!cond) {
+            throw new AssertionError();
+        }
+        assertionCount++;
+    }
+
+    static <T, S extends List<T>> void m(List<? super T> arg1, S arg2, Class<Object> arg3) { assertTrue(false); }
+    static void m(Object o1, Object o2, Object o3) { assertTrue(true); }
+
+    static void test(List<Integer> li, List<String> ls, Class c) {
+        m(li, ls, c);
+    }
+
+    public static void main(String[] args) {
+        test(null, null, null);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/generics/inference/7177306/T7177306e.java b/test/tools/javac/generics/inference/7177306/T7177306e.java
new file mode 100644
index 0000000..4786e7b
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306e.java
@@ -0,0 +1,18 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7177306 8007464
+ * @summary Regression: unchecked method call does not erase return type
+ * @compile/fail/ref=T7177306e.out -source 7 -Xlint:-options -XDrawDiagnostics T7177306e.java
+ * @compile/fail T7177306e.java
+ */
+
+import java.util.List;
+
+class T7177306e {
+
+    <Z, U extends List<Z>> void m(List<U> lu) { }
+
+    void test(List<List<?>> llw) {
+       m(llw);
+    }
+}
diff --git a/test/tools/javac/generics/inference/7177306/T7177306e.out b/test/tools/javac/generics/inference/7177306/T7177306e.out
new file mode 100644
index 0000000..323b786
--- /dev/null
+++ b/test/tools/javac/generics/inference/7177306/T7177306e.out
@@ -0,0 +1,2 @@
+T7177306e.java:16:9: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.util.List<?>, java.util.List<compiler.misc.type.captureof: 1, ?>)
+1 error
diff --git a/test/tools/javac/generics/inference/8006692/T8006692.java b/test/tools/javac/generics/inference/8006692/T8006692.java
new file mode 100644
index 0000000..83597e3
--- /dev/null
+++ b/test/tools/javac/generics/inference/8006692/T8006692.java
@@ -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 8006692
+ * @summary jdk/test/java/util/Collections/BigBinarySearch.java fails to compile
+ * @compile T8006692.java
+ */
+
+import java.util.*;
+
+class Test {
+    static void test(List<Integer> l, int i) {
+        equal(i, Collections.binarySearch(l, l.get(i)));
+    }
+    static void equal(Object x, Object y) {}
+}
diff --git a/test/tools/javac/generics/inference/8015505/T8015505.java b/test/tools/javac/generics/inference/8015505/T8015505.java
new file mode 100644
index 0000000..3b21402
--- /dev/null
+++ b/test/tools/javac/generics/inference/8015505/T8015505.java
@@ -0,0 +1,18 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8015505
+ * @summary Spurious inference error when return type of generic method requires unchecked conversion to target
+ * @compile/fail/ref=T8015505.out -Xlint:-options -source 7 -XDrawDiagnostics T8015505.java
+ * @compile T8015505.java
+ */
+
+import java.util.List;
+
+class T8015505 {
+
+    <Z> List m() { return null; }
+
+    void test() {
+        List<?> l = m();
+    }
+}
diff --git a/test/tools/javac/generics/inference/8015505/T8015505.out b/test/tools/javac/generics/inference/8015505/T8015505.out
new file mode 100644
index 0000000..4742a17
--- /dev/null
+++ b/test/tools/javac/generics/inference/8015505/T8015505.out
@@ -0,0 +1,2 @@
+T8015505.java:16:22: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.instance.exists: Z, java.util.List, java.util.List<?>)
+1 error
diff --git a/test/tools/javac/generics/inference/8019824/T8019824.java b/test/tools/javac/generics/inference/8019824/T8019824.java
new file mode 100644
index 0000000..30f0eff
--- /dev/null
+++ b/test/tools/javac/generics/inference/8019824/T8019824.java
@@ -0,0 +1,15 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8019824
+ * @summary very long error messages on inference error
+ * @compile/fail/ref=T8019824.out -XDrawDiagnostics T8019824.java
+ */
+class T8019824 {
+    void test(Class<? extends Foo<?, ?>> cls) {
+        Foo<?, ?> foo = make(cls);
+    }
+
+    <A, B, C extends Foo<A, B>> Foo<A, B> make(Class<C> cls) { return null; }
+
+    interface Foo<A, B> {}
+}
diff --git a/test/tools/javac/generics/inference/8019824/T8019824.out b/test/tools/javac/generics/inference/8019824/T8019824.out
new file mode 100644
index 0000000..481268c
--- /dev/null
+++ b/test/tools/javac/generics/inference/8019824/T8019824.out
@@ -0,0 +1,2 @@
+T8019824.java:9:25: compiler.err.cant.apply.symbol: kindname.method, make, java.lang.Class<C>, java.lang.Class<compiler.misc.type.captureof: 1, ? extends T8019824.Foo<?,?>>, kindname.class, T8019824, (compiler.misc.incompatible.eq.upper.bounds: C, compiler.misc.type.captureof: 1, ? extends T8019824.Foo<?,?>, T8019824.Foo<compiler.misc.type.captureof: 2, ?,B>)
+1 error
diff --git a/test/tools/javac/generics/inference/8020149/T8020149.java b/test/tools/javac/generics/inference/8020149/T8020149.java
new file mode 100644
index 0000000..863fdaf
--- /dev/null
+++ b/test/tools/javac/generics/inference/8020149/T8020149.java
@@ -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
+ * @bug 8020149
+ * @summary Graph inference: wrong logic for picking best variable to solve
+ * @compile T8020149.java
+ */
+class T8020149 {
+    static class TestData<X,Y> { }
+
+    interface Foo<X, Y extends Foo<X, Y>> { }
+
+    interface IntFoo extends Foo<Integer, IntFoo> { }
+
+    interface Function<X, Y> {
+        Y apply(X x);
+    }
+
+    void test(TestData<Integer, IntFoo> data) {
+       m1(data, s->s);
+       m2(data, s->s);
+    }
+
+    <E, E_OUT extends Foo<E, E_OUT>, W, W_IN extends Foo<W, W_IN>> void m1(TestData<W, W_IN> data, Function<W_IN, E_OUT> m) {  }
+    <W, W_IN extends Foo<W, W_IN>, E, E_OUT extends Foo<E, E_OUT>> void m2(TestData<W, W_IN> data, Function<W_IN, E_OUT> m) {  }
+}
diff --git a/test/tools/javac/generics/odersky/BadTest4.java b/test/tools/javac/generics/odersky/BadTest4.java
index 20bdd10..d0ed639 100644
--- a/test/tools/javac/generics/odersky/BadTest4.java
+++ b/test/tools/javac/generics/odersky/BadTest4.java
@@ -23,11 +23,12 @@
 
 /*
  * @test
- * @ bug
+ * @bug 8007464
  * @summary Negative regression test from odersky
  * @author odersky
  *
- * @compile/fail  BadTest4.java
+ * @compile/fail -source 7 BadTest4.java
+ * @compile BadTest4.java
  */
 
 class BadTest4 {
diff --git a/test/tools/javac/generics/rare/6665356/T6665356.out b/test/tools/javac/generics/rare/6665356/T6665356.out
index 62a62e6..4994352 100644
--- a/test/tools/javac/generics/rare/6665356/T6665356.out
+++ b/test/tools/javac/generics/rare/6665356/T6665356.out
@@ -1,5 +1,5 @@
 T6665356.java:17:37: compiler.err.improperly.formed.type.param.missing
 T6665356.java:18:40: compiler.err.improperly.formed.type.inner.raw.param
-T6665356.java:26:23: compiler.err.improperly.formed.type.param.missing
+T6665356.java:26:22: compiler.err.improperly.formed.type.param.missing
 T6665356.java:27:25: compiler.err.improperly.formed.type.inner.raw.param
 4 errors
diff --git a/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java
index ae1a1cd..404ae36 100644
--- a/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java
+++ b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -23,23 +23,39 @@
 
 /*
  * @test
- * @bug 7062745
- * @summary  Regression: difference in overload resolution when two methods are maximally specific
+ * @bug 7062745 8006694
+ * @summary  Regression: difference in overload resolution when two methods
+ *  are maximally specific
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm GenericOverrideTest
  */
 
-import com.sun.source.util.JavacTask;
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.net.URI;
 import java.util.Arrays;
 import javax.tools.Diagnostic;
-import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
 
-public class GenericOverrideTest {
+public class GenericOverrideTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
-    static int checkCount = 0;
+    enum SourceLevel {
+        SOURCE_7("-source", "7"),
+        SOURCE_DEFAULT();
+
+        String[] opts;
+
+        SourceLevel(String... opts) {
+            this.opts = opts;
+        }
+    }
 
     enum SignatureKind {
         NON_GENERIC(""),
@@ -107,12 +123,13 @@ public class GenericOverrideTest {
             }
         }
 
-        boolean assignableTo(TypeArgumentKind that, SignatureKind sig) {
+        boolean assignableTo(TypeArgumentKind that, SignatureKind sig, SourceLevel level) {
             switch (this) {
                 case NONE:
                     //this case needs to workaround to javac's impl of 15.12.2.8 being too strict
-                    //ideally should be just 'return true' (see 7067746)
-                    return sig == SignatureKind.NON_GENERIC || that == NONE;
+                    //ideally should be just 'return true' (see 7067746/8015505)
+                    return level == SourceLevel.SOURCE_DEFAULT ||
+                            sig == SignatureKind.NON_GENERIC || that == NONE;
                 case UNBOUND:
                     return that == this || that == NONE;
                 case INTEGER:
@@ -126,11 +143,6 @@ public class GenericOverrideTest {
     }
 
     public static void main(String... args) throws Exception {
-
-        //create default shared JavaCompiler - reused across multiple compilations
-        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
-
         for (SignatureKind sig1 : SignatureKind.values()) {
             for (ReturnTypeKind rt1 : ReturnTypeKind.values()) {
                 for (TypeArgumentKind ta1 : TypeArgumentKind.values()) {
@@ -141,8 +153,14 @@ public class GenericOverrideTest {
                                 if (!ta2.compatibleWith(sig2)) continue;
                                 for (ReturnTypeKind rt3 : ReturnTypeKind.values()) {
                                     for (TypeArgumentKind ta3 : TypeArgumentKind.values()) {
-                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue;
-                                        new GenericOverrideTest(sig1, rt1, ta1, sig2, rt2, ta2, rt3, ta3).run(comp, fm);
+                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC))
+                                            continue;
+                                        for (SourceLevel level : SourceLevel.values()) {
+                                            pool.execute(
+                                                    new GenericOverrideTest(sig1,
+                                                    rt1, ta1, sig2, rt2,
+                                                    ta2, rt3, ta3, level));
+                                        }
                                     }
                                 }
                             }
@@ -151,17 +169,20 @@ public class GenericOverrideTest {
                 }
             }
         }
-        System.out.println("Total check executed: " + checkCount);
+
+        checkAfterExec();
     }
 
     SignatureKind sig1, sig2;
     ReturnTypeKind rt1, rt2, rt3;
     TypeArgumentKind ta1, ta2, ta3;
+    SourceLevel level;
     JavaSource source;
     DiagnosticChecker diagChecker;
 
     GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1,
-            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, ReturnTypeKind rt3, TypeArgumentKind ta3) {
+            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2,
+            ReturnTypeKind rt3, TypeArgumentKind ta3, SourceLevel level) {
         this.sig1 = sig1;
         this.sig2 = sig2;
         this.rt1 = rt1;
@@ -170,6 +191,7 @@ public class GenericOverrideTest {
         this.ta1 = ta1;
         this.ta2 = ta2;
         this.ta3 = ta3;
+        this.level = level;
         this.source = new JavaSource();
         this.diagChecker = new DiagnosticChecker();
     }
@@ -204,19 +226,22 @@ public class GenericOverrideTest {
         }
     }
 
-    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
-                null, null, Arrays.asList(source));
+    @Override
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                level.opts != null ? Arrays.asList(level.opts) : null,
+                null, Arrays.asList(source));
         try {
             ct.analyze();
         } catch (Throwable ex) {
-            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+            throw new AssertionError("Error thrown when compiling the following code:\n" +
+                    source.getCharContent(true));
         }
         check();
     }
 
     void check() {
-        checkCount++;
+        checkCount.incrementAndGet();
 
         boolean errorExpected = false;
         int mostSpecific = 0;
@@ -234,14 +259,17 @@ public class GenericOverrideTest {
         //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw)
         if (!errorExpected) {
             if (ta1 != ta2) {
-                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) || ta2.moreSpecificThan(ta1, true);
+                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) ||
+                        ta2.moreSpecificThan(ta1, true);
                 if (!ta1.moreSpecificThan(ta2, useStrictCheck) &&
                         !ta2.moreSpecificThan(ta1, useStrictCheck)) {
                     errorExpected = true;
                 } else {
                     int mostSpecific2 = ta1.moreSpecificThan(ta2, useStrictCheck) ? 1 : 2;
                     if (mostSpecific != 0 && mostSpecific2 != mostSpecific) {
-                        errorExpected = mostSpecific == 1 ? ta1 != TypeArgumentKind.NONE : ta2 != TypeArgumentKind.NONE;
+                        errorExpected = mostSpecific == 1 ?
+                                ta1 != TypeArgumentKind.NONE :
+                                ta2 != TypeArgumentKind.NONE;
                     } else {
                         mostSpecific = mostSpecific2;
                     }
@@ -260,7 +288,7 @@ public class GenericOverrideTest {
             SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2;
 
             if (!msrt.moreSpecificThan(rt3) ||
-                    !msta.assignableTo(ta3, mssig)) {
+                    !msta.assignableTo(ta3, mssig, level)) {
                 errorExpected = true;
             }
         }
@@ -273,7 +301,8 @@ public class GenericOverrideTest {
         }
     }
 
-    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         boolean errorFound;
 
@@ -283,4 +312,5 @@ public class GenericOverrideTest {
             }
         }
     }
+
 }
diff --git a/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out
index 620ccfe..72334e6 100644
--- a/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out
+++ b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out
@@ -1,2 +1,2 @@
-T7062745neg.java:16:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Object, java.lang.Number
+T7062745neg.java:16:36: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.Number)
 1 error
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test1.java b/test/tools/javac/generics/rawOverride/7157798/Test1.java
new file mode 100644
index 0000000..b889ff5
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test1.java
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ *
+ * 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      7062745 7157798
+ * @summary  Test inheritance of same-name methods from mulitple interfaces
+             when the methods have compatible return types
+ * @compile  Test1.java
+ */
+
+import java.util.*;
+
+interface A { List<Number> getList(); }
+interface B { List getList(); }
+
+interface AB extends A, B {} //return type: List<Number>
+
+interface C<T> { List<T> getList(); }
+
+interface BC<T> extends B, C<T> {} //return type: List<T>
+
+interface D { Number m(); }
+interface E { Double m(); }
+
+interface DE extends D, E {} //return type: Double
+
+interface F { ArrayList getList(); }
+interface G { Collection getList(); }
+
+interface AG extends A, G{}; //return type: List<Number>
+
+interface CF<T> extends C<T>, F {} //return type: ArrayList
+
+interface CG<T> extends C<T>, G {} //return type: List<T>
+
+interface H<T> { Iterable<T> getList(); }
+
+interface CH<T> extends C<T>, H<T> {} //return type: List<T>
+
+interface CFGH<T> extends C<T>, F, G, H<T> {} //return type: ArrayList
+
+
+class Test1 {
+
+    //raw and typed return types:
+    void test(AB ab) {
+        Number n = ab.getList().get(1);
+    }
+
+    void test(BC<String> bc) {
+        String s = bc.getList().get(1);
+    }
+
+    void testRaw(BC bc) {
+        List list = bc.getList();
+    }
+
+    void testWildCard(BC<?> bc) {
+        List<?> list = bc.getList();
+    }
+
+    <T> void testGeneric(BC<T> bc) {
+        T t = bc.getList().get(1);
+    }
+
+    //covariant return:
+    void test(DE de) {
+        Double d = de.m();
+    }
+
+    //mixed:
+    void test(AG ag) {
+        Number n = ag.getList().get(0);
+    }
+
+    void test(CF<Integer> cf) {
+        ArrayList list = cf.getList();
+    }
+
+    void test(CG<String> cg) {
+        String s = cg.getList().get(0);
+    }
+
+    void test(CH<String> ch) {
+        String s = ch.getList().get(0);
+    }
+
+    void test(CFGH<Double> cfgh) {
+        ArrayList list = cfgh.getList();
+    }
+
+    void testWildCard(CFGH<?> cfgh) {
+        ArrayList list = cfgh.getList();
+    }
+}
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test2.java b/test/tools/javac/generics/rawOverride/7157798/Test2.java
new file mode 100644
index 0000000..577d860
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test2.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ * 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      7062745 7157798
+ * @summary  Test inheritance of same-name methods from multiple interfaces
+             when the methods have compatible parameter types and return types
+ * @compile  Test2.java
+ */
+
+import java.util.*;
+
+interface A { void m(Map map); }
+interface B { void m(Map<Number, String> map); }
+
+interface AB extends A, B {} //paramter type: Map<Number, String>
+
+interface C<K, V> { List<V> getList(Map<K, V> map); }
+interface D { ArrayList getList(Map map); }
+
+interface CD<K, V> extends C<K, V>, D {} //paramter type: Map<K, V>
+
+interface E<T> { T get(List<?> list); }
+interface F<T> { T get(List list); }
+
+interface EF<T1, T2 extends T1> extends E<T1>, F<T2> {} //parameter type: List<?>
+
+class Test2 {
+
+    //compatible parameter types:
+    void test(AB ab) {
+        ab.m(new HashMap<Number, String>());
+    }
+
+    //compatible parameter types and return types:
+    void testRaw(CD cd) { //return type: ArrayList
+        ArrayList al = cd.getList(new HashMap());
+    }
+
+    <K, V> void testGeneric(CD<K, V> cd) { //return type: List<V>
+        V v = cd.getList(new HashMap<K, V>()).get(0);
+    }
+
+    void test(CD<Number, String> cd) { //return type: List<String>
+        String s = cd.getList(new HashMap<Number, String>()).get(0);
+    }
+
+    void test(EF<Number, Integer> ef) { //return type: Number
+        Number n = ef.get(new ArrayList<Integer>());
+    }
+
+    <T, U extends T> void testGeneric(EF<T, U> ef) { //return type: T
+        T t = ef.get(new ArrayList<U>());
+    }
+}
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test3.java b/test/tools/javac/generics/rawOverride/7157798/Test3.java
new file mode 100644
index 0000000..927ec12
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.java
@@ -0,0 +1,37 @@
+/**
+ * @test     /nodynamiccopyright/
+ * @bug      7062745 7157798
+ * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when return type not compatible
+ * @compile/fail/ref=Test3.out -Werror -Xlint:unchecked -XDrawDiagnostics Test3.java
+ */
+
+import java.util.List;
+import java.io.Serializable;
+
+interface A { int m(); }
+interface B { Integer m(); }
+
+interface AB extends A, B {} //error
+
+interface C { List<Integer> m(); }
+interface D { List<Number> m(); }
+
+interface CD extends C, D {} //error
+
+interface E<T> { T m(); }
+interface F<T> { T m(); }
+interface G { Serializable m(); }
+
+interface BE extends B, E<Number> {} //ok, covariant return
+
+interface BE2<T> extends B, E<T> {} //error
+
+interface EF<T> extends E<T>, F<T> {} //ok
+
+interface EF2<U, V extends U> extends E<U>, F<V> {} //ok, covariant return
+
+interface EF3<U, V> extends E<U>, F<V> {} //error
+
+interface EG<T extends Number> extends E<T>, G {} //ok
+
+interface EFG<U extends Serializable, V extends Serializable> extends E<U>, F<V>, G {} //error
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test3.out b/test/tools/javac/generics/rawOverride/7157798/Test3.out
new file mode 100644
index 0000000..80960df
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.out
@@ -0,0 +1,6 @@
+Test3.java:14:1: compiler.err.types.incompatible.diff.ret: B, A, m()
+Test3.java:19:1: compiler.err.types.incompatible.diff.ret: D, C, m()
+Test3.java:27:1: compiler.err.types.incompatible.diff.ret: E<T>, B, m()
+Test3.java:33:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
+Test3.java:37:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
+5 errors
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test4.java b/test/tools/javac/generics/rawOverride/7157798/Test4.java
new file mode 100644
index 0000000..8ff39c9
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.java
@@ -0,0 +1,29 @@
+/**
+ * @test     /nodynamiccopyright/
+ * @bug      7062745 7157798
+ * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when parameter types not compatible
+ * @compile/fail/ref=Test4.out -Werror -Xlint:unchecked -XDrawDiagnostics Test4.java
+ */
+
+import java.util.Set;
+import java.util.HashSet;
+
+interface A { void m(Set<Integer> s); }
+interface B { void m(Set<String> s); }
+interface C { void m(Set<?> s); }
+
+interface AB extends A, B {} //error
+
+interface AC extends A, C {} //error
+
+interface D<T> { void m(Set<T> s); }
+
+interface AD extends A, D<Integer> {} //OK
+
+interface AD2 extends A, D<Number> {} //error
+
+interface CD<T> extends C, D<T> {} //error
+
+interface E { <T> void m(Set<T> s); }
+
+interface DE<T> extends D<T>, E {} //error
diff --git a/test/tools/javac/generics/rawOverride/7157798/Test4.out b/test/tools/javac/generics/rawOverride/7157798/Test4.out
new file mode 100644
index 0000000..c4018ab
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.out
@@ -0,0 +1,6 @@
+Test4.java:15:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<java.lang.String>), B, m(java.util.Set<java.lang.Integer>), A
+Test4.java:17:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<?>), C, m(java.util.Set<java.lang.Integer>), A
+Test4.java:23:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<java.lang.Integer>), A
+Test4.java:25:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<?>), C
+Test4.java:29:1: compiler.err.name.clash.same.erasure.no.override: <T>m(java.util.Set<T>), E, m(java.util.Set<T>), D
+5 errors
diff --git a/test/tools/javac/generics/rawOverride/T8008627.java b/test/tools/javac/generics/rawOverride/T8008627.java
new file mode 100644
index 0000000..425cd63
--- /dev/null
+++ b/test/tools/javac/generics/rawOverride/T8008627.java
@@ -0,0 +1,47 @@
+/*
+ * 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 8008627
+ * @summary Compiler mishandles three-way return-type-substitutability
+ * @compile T8008627.java
+ */
+
+class T8008627 {
+
+    interface I {
+        Object m(Iterable l);
+    }
+
+    interface J<S> {
+        S m(Iterable<String> l);
+    }
+
+    interface K<T> {
+        T m(Iterable<String> l);
+    }
+
+    @FunctionalInterface
+    interface Functional<S,T> extends I, J<S>, K<T> {}
+}
diff --git a/test/tools/javac/generics/wildcards/6886247/T6886247_2.out b/test/tools/javac/generics/wildcards/6886247/T6886247_2.out
index f999786..e3534f1 100644
--- a/test/tools/javac/generics/wildcards/6886247/T6886247_2.out
+++ b/test/tools/javac/generics/wildcards/6886247/T6886247_2.out
@@ -1,2 +1,2 @@
-T6886247_2.java:35:28: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.type.captureof: 1, ?, E
+T6886247_2.java:35:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, E)
 1 error
diff --git a/test/tools/javac/incompleteStatements/T8000484.java b/test/tools/javac/incompleteStatements/T8000484.java
new file mode 100644
index 0000000..3c24200
--- /dev/null
+++ b/test/tools/javac/incompleteStatements/T8000484.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8000484
+ * @summary Bad error recovery when 'catch' without 'try' is found
+ * @compile/fail/ref=T8000484.out -XDrawDiagnostics T8000484.java
+ */
+
+public class T8000484 {
+    void m() {
+        catch (Exception e){}
+        else{}
+        finally{}
+        catch (Exception e) {catch (Exception e){}}
+        else{else{}}
+        finally{finally{}}
+    }
+}
diff --git a/test/tools/javac/incompleteStatements/T8000484.out b/test/tools/javac/incompleteStatements/T8000484.out
new file mode 100644
index 0000000..b202536
--- /dev/null
+++ b/test/tools/javac/incompleteStatements/T8000484.out
@@ -0,0 +1,10 @@
+T8000484.java:10:9: compiler.err.catch.without.try
+T8000484.java:11:9: compiler.err.else.without.if
+T8000484.java:12:9: compiler.err.finally.without.try
+T8000484.java:13:30: compiler.err.catch.without.try
+T8000484.java:13:9: compiler.err.catch.without.try
+T8000484.java:14:14: compiler.err.else.without.if
+T8000484.java:14:9: compiler.err.else.without.if
+T8000484.java:15:17: compiler.err.finally.without.try
+T8000484.java:15:9: compiler.err.finally.without.try
+9 errors
diff --git a/test/tools/javac/innerClassFile/Driver.sh b/test/tools/javac/innerClassFile/Driver.sh
deleted file mode 100644
index dbe7366..0000000
--- a/test/tools/javac/innerClassFile/Driver.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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 4491755 4785453
-# @summary Prob w/static inner class with same name as a regular class
-# @author gafter
-#
-# @run shell Driver.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-set -x
-mkdir src
-cp -r ${TESTSRC}${FS}* src
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
-rm y/R3.class
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/y/Main.java
diff --git a/test/tools/javac/innerClassFile/InnerClassFileTest.java b/test/tools/javac/innerClassFile/InnerClassFileTest.java
new file mode 100644
index 0000000..6c1e5ed
--- /dev/null
+++ b/test/tools/javac/innerClassFile/InnerClassFileTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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 4491755 4785453
+ * @summary Prob w/static inner class with same name as a regular class
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main InnerClassFileTest
+ */
+
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/innerClassFile/Driver.sh
+public class InnerClassFileTest {
+
+    private static final String BSrc =
+        "package x;\n" +
+        "\n" +
+        "import x.*;\n" +
+        "\n" +
+        "public class B {\n" +
+        "    public static class C {}\n" +
+        "}";
+
+    private static final String CSrc =
+        "package x;\n" +
+        "\n" +
+        "import x.*;\n" +
+        "\n" +
+        "public class C {}";
+
+    private static final String MainSrc =
+        "package y;\n" +
+        "\n" +
+        "class Main {\n" +
+        "        private R1 a;\n" +
+        "        private R2 b;\n" +
+        "        private R3 c;\n" +
+        "}";
+
+    private static final String R1Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R1 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "    R2 c = new R2();\n" +
+        "}";
+
+    private static final String R2Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R2 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "}";
+
+    private static final String R3Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R3 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "    R1 c = new R1();\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        new InnerClassFileTest().run();
+    }
+
+    void run() throws Exception {
+        createFiles();
+        compileFiles();
+    }
+
+    void createFiles() throws Exception {
+//        mkdir src
+//        cp -r ${TESTSRC}${FS}* src
+        ToolBox.createJavaFileFromSource(Paths.get("src"), BSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), CSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), MainSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R1Src);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R2Src);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R3Src);
+    }
+
+    void compileFiles() throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+//              -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
+        ToolBox.JavaToolArgs args =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-d", ".", "-cp" , ".", "-sourcepath", "src",
+                "src/x/B.java", "src/x/C.java", "src/y/Main.java");
+        ToolBox.javac(args);
+
+//        rm y/R3.class
+        ToolBox.rm(Paths.get("y", "R3.class"));
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+//                -sourcepath src src/y/Main.java
+        args.setAllArgs("-d", ".", "-cp", ".", "-sourcepath", "src", "src/y/Main.java");
+        ToolBox.javac(args);
+    }
+
+}
diff --git a/test/tools/javac/innerClassFile/x/B.java b/test/tools/javac/innerClassFile/x/B.java
deleted file mode 100644
index 8027a3a..0000000
--- a/test/tools/javac/innerClassFile/x/B.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, 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 x;
-
-import x.*;
-
-public class B {
-    public static class C {}
-}
diff --git a/test/tools/javac/innerClassFile/x/C.java b/test/tools/javac/innerClassFile/x/C.java
deleted file mode 100644
index 094fbd4..0000000
--- a/test/tools/javac/innerClassFile/x/C.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2002, 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 x;
-
-import x.*;
-
-public class C {}
diff --git a/test/tools/javac/innerClassFile/y/Main.java b/test/tools/javac/innerClassFile/y/Main.java
deleted file mode 100644
index f1d744a..0000000
--- a/test/tools/javac/innerClassFile/y/Main.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, 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 y;
-
-class Main {
-        private R1 a;
-        private R2 b;
-        private R3 c;
-}
diff --git a/test/tools/javac/innerClassFile/y/R1.java b/test/tools/javac/innerClassFile/y/R1.java
deleted file mode 100644
index 8302120..0000000
--- a/test/tools/javac/innerClassFile/y/R1.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, 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 y;
-
-public final class R1 {
-    x.B.C a = null;
-    x.C b = null;
-    R2 c = new R2();
-}
diff --git a/test/tools/javac/innerClassFile/y/R2.java b/test/tools/javac/innerClassFile/y/R2.java
deleted file mode 100644
index 84b18f5..0000000
--- a/test/tools/javac/innerClassFile/y/R2.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2002, 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 y;
-
-public final class R2 {
-    x.B.C a = null;
-    x.C b = null;
-}
diff --git a/test/tools/javac/innerClassFile/y/R3.java b/test/tools/javac/innerClassFile/y/R3.java
deleted file mode 100644
index 1460757..0000000
--- a/test/tools/javac/innerClassFile/y/R3.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2002, 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 y;
-
-public final class R3 {
-    x.B.C a = null;
-    x.C b = null;
-    R1 c = new R1();
-}
diff --git a/test/tools/javac/javazip/A.java b/test/tools/javac/javazip/A.java
deleted file mode 100644
index 43dd39e..0000000
--- a/test/tools/javac/javazip/A.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// A class that references another
-class A {
-    B b;
-}
diff --git a/test/tools/javac/javazip/JavaZipTest.java b/test/tools/javac/javazip/JavaZipTest.java
new file mode 100644
index 0000000..e800881
--- /dev/null
+++ b/test/tools/javac/javazip/JavaZipTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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 4098712 6304984 6388453
+ * @summary check that source files inside zip files on the class path are ignored
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavaZipTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/javazip/Test.sh
+public class JavaZipTest {
+
+    private static final String ASrc =
+        "class A {\n" +
+        "    B b;\n" +
+        "}";
+
+    private static final String BGoodSrc =
+        "public class B {}";
+
+    private static final String BBadSrc =
+        "class B";
+
+    private static final String[][] jarArgs = {
+        {"cf", "good.jar", "-C", "good", "B.java"},
+        {"cf", "good.zip", "-C", "good", "B.java"},
+        {"cf", "bad.jar", "-C", "bad", "B.java"},
+        {"cf", "bad.zip", "-C", "bad", "B.java"},
+    };
+
+    private static final String[][] successfulCompilationArgs = {
+        {"-d", "output", "A.java", "good/B.java"},
+        {"-d", "output", "-cp", "good", "A.java"},
+        {"-d", "output", "-sourcepath", "good", "A.java"},
+        {"-d", "output", "-cp", "good.zip", "A.java"},
+        {"-d", "output", "-cp", "good.jar", "A.java"},
+    };
+
+    private static final String[][] unSuccessfulCompilationArgs = {
+        {"-d", "output", "A.java", "bad/B.java"},
+        {"-d", "output", "-cp", "bad", "A.java"},
+        {"-d", "output", "-sourcepath", "bad", "A.java"},
+        {"-d", "output", "-sourcepath", "bad.zip", "A.java"},
+        {"-d", "output", "-sourcepath", "bad.jar", "A.java"},
+    };
+
+    public static void main(String[] args) throws Exception {
+        new JavaZipTest().test();
+    }
+
+    public void test() throws Exception {
+        createOutputDirAndSourceFiles();
+        createZipsAndJars();
+        check(ToolBox.Expect.SUCCESS, successfulCompilationArgs);
+        check(ToolBox.Expect.FAIL, unSuccessfulCompilationArgs);
+    }
+
+    void createOutputDirAndSourceFiles() throws Exception {
+        //create output dir
+        new File("output").mkdir();
+
+        //source file creation
+        ToolBox.createJavaFileFromSource(Paths.get("good"), BGoodSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("bad"), BBadSrc);
+        ToolBox.createJavaFileFromSource(ASrc);
+    }
+
+    void createZipsAndJars() throws Exception {
+        //jar and zip creation
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar"  -C "${TESTSRC}${FS}bad" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip"  -C "${TESTSRC}${FS}bad" B.java
+        for (String[] args: jarArgs) {
+            ToolBox.jar(args);
+        }
+    }
+
+    void check(ToolBox.Expect whatToExpect, String[][] theArgs) throws Exception {
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good"   "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good"  "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip"   "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar"   "${TESTSRC}${FS}A.java"
+
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad"    "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad"   "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip"   "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar"   "${TESTSRC}${FS}A.java"
+        ToolBox.JavaToolArgs args =
+                new ToolBox.JavaToolArgs(whatToExpect);
+
+        for (String[] allArgs: theArgs) {
+            args.setAllArgs(allArgs);
+            ToolBox.javac(args);
+        }
+    }
+
+}
diff --git a/test/tools/javac/javazip/Test.sh b/test/tools/javac/javazip/Test.sh
deleted file mode 100644
index 4fbf874..0000000
--- a/test/tools/javac/javazip/Test.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2011, 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 4098712 6304984 6388453
-# @summary check that source files inside zip files on the class path are ignored
-# @run shell Test.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-SCR=`pwd`
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    SCR=`pwd`
-    ;;
-  CYGWIN* )
-    FS="/"
-    SCR=`pwd | cygpath -d -f -`
-    ;;
-  Windows* )
-    FS="\\"
-    SCR=`pwd`
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-check() {
-    expected=$1
-    shift
-
-    # clean old classes
-    rm -f ${TC}${FS}*.class 
-
-    echo "$@"
-    if "$@" 2>&1 ; then
-      actual=ok
-    else
-      actual=err
-    fi
-    if [ "$actual" != "$expected" ]; then
-      case "$actual" in
-        ok  ) echo "error: unexpected result: command succeeded" ;;
-        err ) echo "error: unexpected result: command failed"
-      esac
-      exit 1
-    else 
-      case "$actual" in
-        ok  ) echo "command succeeded as expected" ;;
-        err ) echo "command failed as expected."
-      esac
-    fi
-
-    echo 
-}
-
-echo "# create zip/jar files with source code"
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar"  -C "${TESTSRC}${FS}bad" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip"  -C "${TESTSRC}${FS}bad" B.java
-
-echo "# control tests, with no paths"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
-
-echo "# test that source files are found in directories on path"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good"   "${TESTSRC}${FS}A.java"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good"  "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad"    "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad"   "${TESTSRC}${FS}A.java"
-
-echo "# test that source files are found in zip/jar files on path"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip"   "${TESTSRC}${FS}A.java"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar"   "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip"   "${TESTSRC}${FS}A.java"  
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar"   "${TESTSRC}${FS}A.java" 
diff --git a/test/tools/javac/javazip/bad/B.java b/test/tools/javac/javazip/bad/B.java
deleted file mode 100644
index 4ba60bf..0000000
--- a/test/tools/javac/javazip/bad/B.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// this class is invalid
-class B
diff --git a/test/tools/javac/javazip/good/B.java b/test/tools/javac/javazip/good/B.java
deleted file mode 100644
index 7b999c6..0000000
--- a/test/tools/javac/javazip/good/B.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// this is a valid class
-public class B {
-}
diff --git a/test/tools/javac/jvm/T7024096.java b/test/tools/javac/jvm/T7024096.java
new file mode 100644
index 0000000..04af2d5
--- /dev/null
+++ b/test/tools/javac/jvm/T7024096.java
@@ -0,0 +1,31 @@
+/*
+ * @test  /nodynamiccopyright/
+ * @bug 7024096
+ * @summary Stack trace has invalid line numbers
+ * @author Bruce Chapman
+ * @compile T7024096.java
+ * @run main T7024096
+ */
+
+public class T7024096 {
+    private static final int START = 14; // starting line number for the test
+    public static void main(String[] args) {
+        T7024096 m = new T7024096();
+        m.nest(START);
+        m.nest(START + 1, m.nest(START + 1), m.nest(START + 1),
+            m.nest(START + 2),
+            m.nest(START + 3, m.nest(START + 3)));
+    }
+
+    public T7024096 nest(int expectedline, T7024096... args) {
+        Exception e = new Exception("expected line#: " + expectedline);
+        int myline = e.getStackTrace()[1].getLineNumber();
+        if( myline != expectedline) {
+            throw new RuntimeException("Incorrect line number " +
+                    "expected: " + expectedline +
+                    ", got: " + myline, e);
+        }
+        System.out.format("Got expected line number %d correct %n", myline);
+        return null;
+    }
+}
diff --git a/test/tools/javac/lambda/8019480/T8019480.java b/test/tools/javac/lambda/8019480/T8019480.java
new file mode 100644
index 0000000..6d270b1
--- /dev/null
+++ b/test/tools/javac/lambda/8019480/T8019480.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8019480
+ * @summary Javac crashes when method is called on a type-variable receiver from lambda expression
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=T8019480.out -XDrawDiagnostics T8019480.java
+ */
+import java.util.*;
+
+class T8019480<U> {
+    interface Predicate<T> {
+       void m(T t);
+    }
+
+    interface Stream<T> {
+       void forEach(Predicate<T> pt);
+    }
+
+    void test(U current, Stream<U> stream) {
+        List<U> list3 = new ArrayList<>();
+        stream.forEach(i -> list3.add(current.clone()));
+    }
+}
diff --git a/test/tools/javac/lambda/8019480/T8019480.out b/test/tools/javac/lambda/8019480/T8019480.out
new file mode 100644
index 0000000..afc509c
--- /dev/null
+++ b/test/tools/javac/lambda/8019480/T8019480.out
@@ -0,0 +1,3 @@
+T8019480.java:21:46: compiler.err.report.access: clone(), protected, java.lang.Object
+T8019480.java:21:34: compiler.err.cant.apply.symbols: kindname.method, add, java.lang.Object,{(compiler.misc.inapplicable.method: kindname.method, java.util.Collection, add(U), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, U))),(compiler.misc.inapplicable.method: kindname.method, java.util.List, add(U), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Object, U))),(compiler.misc.inapplica [...]
+2 errors
diff --git a/test/tools/javac/lambda/8020147/T8020147.java b/test/tools/javac/lambda/8020147/T8020147.java
new file mode 100644
index 0000000..ec2ae91
--- /dev/null
+++ b/test/tools/javac/lambda/8020147/T8020147.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8020147
+ * @summary Spurious errors when compiling nested stuck lambdas
+ * @compile/fail/ref=T8020147.out -Werror -Xlint:cast -XDrawDiagnostics T8020147.java
+ */
+class T8020147 {
+    interface Function<X, Y> {
+        Y apply(X x);
+    }
+
+    <T> void g(Function<String, T> f) { }
+    <U> String m(U u, Function<U, U> fuu) { return null; }
+
+    void test() {
+        g(x->m("", i->(String)i));
+        g(x->m("", i->(String)x));
+    }
+}
diff --git a/test/tools/javac/lambda/8020147/T8020147.out b/test/tools/javac/lambda/8020147/T8020147.out
new file mode 100644
index 0000000..88a4aef
--- /dev/null
+++ b/test/tools/javac/lambda/8020147/T8020147.out
@@ -0,0 +1,5 @@
+T8020147.java:16:23: compiler.warn.redundant.cast: java.lang.String
+T8020147.java:17:23: compiler.warn.redundant.cast: java.lang.String
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/lambda/BadAccess.java b/test/tools/javac/lambda/BadAccess.java
new file mode 100644
index 0000000..39eed69
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess.java
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-static variables are not accessible from static lambdas
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess.out -XDrawDiagnostics BadAccess.java
+ */
+
+public class BadAccess {
+
+    int i;
+    static int I;
+
+    interface SAM {
+        int m();
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        final int L = 0;
+        SAM s = ()-> i + I + l + L;
+    }
+}
diff --git a/test/tools/javac/lambda/BadAccess.out b/test/tools/javac/lambda/BadAccess.out
new file mode 100644
index 0000000..26484a7
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess.out
@@ -0,0 +1,2 @@
+BadAccess.java:22:22: compiler.err.non-static.cant.be.ref: kindname.variable, i
+1 error
diff --git a/test/tools/javac/lambda/BadAccess02.java b/test/tools/javac/lambda/BadAccess02.java
new file mode 100644
index 0000000..d8a9e6e
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess02.java
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda can access only effectively-final locals
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadAccess02.out -XDrawDiagnostics BadAccess02.java
+ */
+
+public class BadAccess02 {
+
+    interface SAM {
+        int m(int h);
+    }
+
+    static void test1() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + j + l + L; };
+    }
+
+    void test2() {
+        int l = 0; //effectively final
+        int j = 0; //non-effectively final
+        j = 2;
+        final int L = 0;
+        SAM s = (int h) -> { int k = 0; return h + k + j + l + L; };
+    }
+}
diff --git a/test/tools/javac/lambda/BadAccess02.out b/test/tools/javac/lambda/BadAccess02.out
new file mode 100644
index 0000000..a28d065
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess02.out
@@ -0,0 +1,3 @@
+BadAccess02.java:21:52: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+BadAccess02.java:29:56: compiler.err.cant.ref.non.effectively.final.var: j, (compiler.misc.lambda)
+2 errors
diff --git a/test/tools/javac/lambda/BadAccess03.java b/test/tools/javac/lambda/BadAccess03.java
new file mode 100644
index 0000000..22af177
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess03.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check lambda cannot assign non-effectively final locals
+ * @compile/fail/ref=BadAccess03.out -XDrawDiagnostics BadAccess03.java
+ */
+
+class BadAccess03 {
+    void test() {
+        int k = 0;
+        int n = 2; //effectively final variable
+        Runnable r = ()-> { k = n; }; //error
+    }
+}
diff --git a/test/tools/javac/lambda/BadAccess03.out b/test/tools/javac/lambda/BadAccess03.out
new file mode 100644
index 0000000..5520b30
--- /dev/null
+++ b/test/tools/javac/lambda/BadAccess03.out
@@ -0,0 +1,2 @@
+BadAccess03.java:13:29: compiler.err.cant.ref.non.effectively.final.var: k, (compiler.misc.lambda)
+1 error
diff --git a/test/tools/javac/lambda/BadBreakContinue.java b/test/tools/javac/lambda/BadBreakContinue.java
new file mode 100644
index 0000000..861c879
--- /dev/null
+++ b/test/tools/javac/lambda/BadBreakContinue.java
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that break/continue is disallowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadBreakContinue.out -XDrawDiagnostics BadBreakContinue.java
+ */
+
+class BadBreakContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { break; };
+    SAM s2 = ()-> { continue; };
+    SAM s3 = ()-> {
+        SAM s3_1 = ()-> { break; };
+        SAM s3_2 = ()-> { continue; };
+    };
+
+    void testLabelled() {
+        loop: while (true) {
+            SAM s1 = ()-> { break loop; };
+            SAM s2 = ()-> { continue loop; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break loop; };
+                SAM s3_2 = ()-> { continue loop; };
+            };
+        }
+    }
+
+    void testNonLabelled() {
+        while (true) {
+            SAM s1 = ()-> { break; };
+            SAM s2 = ()-> { continue; };
+            SAM s3 = ()-> {
+                SAM s3_1 = ()-> { break; };
+                SAM s3_2 = ()-> { continue; };
+            };
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/BadBreakContinue.out b/test/tools/javac/lambda/BadBreakContinue.out
new file mode 100644
index 0000000..76acc71
--- /dev/null
+++ b/test/tools/javac/lambda/BadBreakContinue.out
@@ -0,0 +1,13 @@
+BadBreakContinue.java:16:21: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:17:21: compiler.err.cont.outside.loop
+BadBreakContinue.java:19:27: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:20:27: compiler.err.cont.outside.loop
+BadBreakContinue.java:25:29: compiler.err.undef.label: loop
+BadBreakContinue.java:26:29: compiler.err.undef.label: loop
+BadBreakContinue.java:28:35: compiler.err.undef.label: loop
+BadBreakContinue.java:29:35: compiler.err.undef.label: loop
+BadBreakContinue.java:36:29: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:37:29: compiler.err.cont.outside.loop
+BadBreakContinue.java:39:35: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:40:35: compiler.err.cont.outside.loop
+12 errors
diff --git a/test/tools/javac/lambda/BadConv03.java b/test/tools/javac/lambda/BadConv03.java
new file mode 100644
index 0000000..c2f440d
--- /dev/null
+++ b/test/tools/javac/lambda/BadConv03.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  NPE while checking if subinterface is a SAM type
+ * @compile/fail/ref=BadConv03.out -XDrawDiagnostics BadConv03.java
+ */
+
+class BadConv03 {
+
+    interface A {
+        void a();
+    }
+
+    interface B extends A { //not a SAM (2 non-override equivalent abstracts!)
+        void a(int i);
+    }
+
+    B b = ()-> { };
+}
diff --git a/test/tools/javac/lambda/BadConv03.out b/test/tools/javac/lambda/BadConv03.out
new file mode 100644
index 0000000..2101480
--- /dev/null
+++ b/test/tools/javac/lambda/BadConv03.out
@@ -0,0 +1,2 @@
+BadConv03.java:19:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: BadConv03.B, (compiler.misc.incompatible.abstracts: kindname.interface, BadConv03.B))
+1 error
diff --git a/test/tools/javac/lambda/BadConv04.java b/test/tools/javac/lambda/BadConv04.java
new file mode 100644
index 0000000..910d3ec
--- /dev/null
+++ b/test/tools/javac/lambda/BadConv04.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that ill-formed SAM type generates right diagnostic when SAM converted
+ * @compile/fail/ref=BadConv04.out -XDrawDiagnostics BadConv04.java
+ */
+
+class BadConv04 {
+
+    interface I1 {
+        int m();
+    }
+
+    interface I2 {
+        long m();
+    }
+
+    interface SAM extends I1, I2 {}
+
+    SAM s = ()-> { };
+}
diff --git a/test/tools/javac/lambda/BadConv04.out b/test/tools/javac/lambda/BadConv04.out
new file mode 100644
index 0000000..4eae22a
--- /dev/null
+++ b/test/tools/javac/lambda/BadConv04.out
@@ -0,0 +1,3 @@
+BadConv04.java:19:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m()
+BadConv04.java:21:13: compiler.err.prob.found.req: (compiler.misc.incompatible.descs.in.functional.intf: kindname.interface, BadConv04.SAM,{(compiler.misc.descriptor: m, , long, ),(compiler.misc.descriptor: m, , int, )})
+2 errors
diff --git a/test/tools/javac/lambda/BadExpressionLambda.java b/test/tools/javac/lambda/BadExpressionLambda.java
new file mode 100644
index 0000000..567ab8a
--- /dev/null
+++ b/test/tools/javac/lambda/BadExpressionLambda.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that a conditonal can't be void
+ * @compile/fail/ref=BadExpressionLambda.out -XDrawDiagnostics BadExpressionLambda.java
+ */
+
+class BadExpressionLambda {
+
+    interface SAM {
+        void invoke();
+    }
+
+    public static void m() {}
+
+    void test() {
+        SAM sam1 = () -> m(); //ok
+        SAM sam2 = () -> true ? m() : m(); //not ok
+    }
+}
diff --git a/test/tools/javac/lambda/BadExpressionLambda.out b/test/tools/javac/lambda/BadExpressionLambda.out
new file mode 100644
index 0000000..f466df0
--- /dev/null
+++ b/test/tools/javac/lambda/BadExpressionLambda.out
@@ -0,0 +1,2 @@
+BadExpressionLambda.java:19:31: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
+1 error
diff --git a/test/tools/javac/lambda/BadLambdaExpr.java b/test/tools/javac/lambda/BadLambdaExpr.java
new file mode 100644
index 0000000..80b3422
--- /dev/null
+++ b/test/tools/javac/lambda/BadLambdaExpr.java
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  compile crashes on partial lambda expressions
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+
+public class BadLambdaExpr {
+
+    static int checkCount = 0;
+
+    enum ParameterListKind {
+        ZERO_ARY("()"),
+        UNARY("(#P)"),
+        TWO_ARY("(#P, #P)"),
+        THREE_ARY("(#P, #P, #P)");
+
+        String parametersTemplateStr;
+
+        ParameterListKind(String parametersTemplateStr) {
+            this.parametersTemplateStr = parametersTemplateStr;
+        }
+
+        String getParameterString(ParameterKind pk) {
+            return parametersTemplateStr.replaceAll("#P", pk.parameterStr);
+        }
+    }
+
+    enum ParameterKind {
+        IMPLICIT("a"),
+        EXPLIICT("A a");
+
+        String parameterStr;
+
+        ParameterKind(String parameterStr) {
+            this.parameterStr = parameterStr;
+        }
+    }
+
+    enum ArrowKind {
+        NONE(""),
+        SEMI("-"),
+        FULL("->");
+
+        String arrowStr;
+
+        ArrowKind(String arrowStr) {
+            this.arrowStr = arrowStr;
+        }
+    }
+
+    enum ExprKind {
+        NONE("#P#A"),
+        METHOD_CALL("m(#P#A)"),
+        CONSTR_CALL("new Foo(#P#A)");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(ParameterListKind plk, ParameterKind pk,
+                ArrowKind ak) {
+            return expressionTemplate.replaceAll("#P", plk.getParameterString(pk))
+                    .replaceAll("#A", ak.arrowStr);
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (ParameterListKind plk : ParameterListKind.values()) {
+            for (ParameterKind pk : ParameterKind.values()) {
+                for (ArrowKind ak : ArrowKind.values()) {
+                    for (ExprKind ek : ExprKind.values()) {
+                        new BadLambdaExpr(plk, pk, ak, ek).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    ParameterListKind plk;
+    ParameterKind pk;
+    ArrowKind ak;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    BadLambdaExpr(ParameterListKind plk, ParameterKind pk, ArrowKind ak, ExprKind ek) {
+        this.plk = plk;
+        this.pk = pk;
+        this.ak = ak;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.expressionString(plk, pk, ak));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected =
+                ak != ArrowKind.NONE ||
+                plk != ParameterListKind.UNARY ||
+                pk != ParameterKind.IMPLICIT;
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("bad diag for source:\n" +
+                source.getCharContent(true));
+        }
+        checkCount++;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        @Override
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/BadLambdaPos.java b/test/tools/javac/lambda/BadLambdaPos.java
new file mode 100644
index 0000000..52c517f
--- /dev/null
+++ b/test/tools/javac/lambda/BadLambdaPos.java
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda is only allowed in argument/cast/assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadLambdaPos.out -XDrawDiagnostics BadLambdaPos.java
+ */
+
+interface SAM {
+    void m(Integer x);
+}
+
+class Test {
+    void test(Object x) {}
+
+    void test1() {
+        test((int x)-> { } + (int x)-> { } );
+        test((int x)-> { } instanceof Object );
+    }
+
+    void test2() {
+        int i2 = (int x)-> { } + (int x)-> { };
+        boolean b = (int x)-> { } instanceof Object;
+    }
+
+    void test3() {
+        test((Object)(int x)-> { });
+        Object o = (Object)(int x)-> { };
+    }
+}
diff --git a/test/tools/javac/lambda/BadLambdaPos.out b/test/tools/javac/lambda/BadLambdaPos.out
new file mode 100644
index 0000000..d192495
--- /dev/null
+++ b/test/tools/javac/lambda/BadLambdaPos.out
@@ -0,0 +1,9 @@
+BadLambdaPos.java:18:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:18:30: compiler.err.unexpected.lambda
+BadLambdaPos.java:19:14: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:18: compiler.err.unexpected.lambda
+BadLambdaPos.java:23:34: compiler.err.unexpected.lambda
+BadLambdaPos.java:24:21: compiler.err.unexpected.lambda
+BadLambdaPos.java:28:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+BadLambdaPos.java:29:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+8 errors
diff --git a/test/tools/javac/lambda/BadMethodCall.java b/test/tools/javac/lambda/BadMethodCall.java
new file mode 100644
index 0000000..f129f15
--- /dev/null
+++ b/test/tools/javac/lambda/BadMethodCall.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that diagnostics on nested erroneous deferred types are flushed
+ * @compile/fail/ref=BadMethodCall.out -XDrawDiagnostics BadMethodCall.java
+ */
+import java.util.*;
+
+class BadMethodCall {
+    <I> List<I> id(List<I> z) { return null; };
+
+    List<String> cons(String s, List<String> ls) { return null; }
+
+    void test(List<Object> lo) { Object t = cons(id(""),lo); }
+}
diff --git a/test/tools/javac/lambda/BadMethodCall.out b/test/tools/javac/lambda/BadMethodCall.out
new file mode 100644
index 0000000..deb85f5
--- /dev/null
+++ b/test/tools/javac/lambda/BadMethodCall.out
@@ -0,0 +1,2 @@
+BadMethodCall.java:15:50: compiler.err.cant.apply.symbol: kindname.method, id, java.util.List<I>, java.lang.String, kindname.class, BadMethodCall, (compiler.misc.infer.no.conforming.assignment.exists: I, (compiler.misc.inconvertible.types: java.lang.String, java.util.List<I>))
+1 error
diff --git a/test/tools/javac/lambda/BadMethodCall2.java b/test/tools/javac/lambda/BadMethodCall2.java
new file mode 100644
index 0000000..fec5bd7
--- /dev/null
+++ b/test/tools/javac/lambda/BadMethodCall2.java
@@ -0,0 +1,13 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8004099
+ * @summary Bad compiler diagnostic generated when poly expression is passed to non-existent method
+ * @compile/fail/ref=BadMethodCall2.out -XDrawDiagnostics BadMethodCall2.java
+ */
+class BadMethodCall2 {
+     void test(Object rec) {
+         rec.nonExistent(System.out::println);
+         rec.nonExistent(()->{});
+         rec.nonExistent(true ? "1" : "2");
+     }
+}
diff --git a/test/tools/javac/lambda/BadMethodCall2.out b/test/tools/javac/lambda/BadMethodCall2.out
new file mode 100644
index 0000000..5186858
--- /dev/null
+++ b/test/tools/javac/lambda/BadMethodCall2.out
@@ -0,0 +1,4 @@
+BadMethodCall2.java:9:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , @309, (compiler.misc.location.1: kindname.variable, rec, java.lang.Object)
+BadMethodCall2.java:10:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , @356, (compiler.misc.location.1: kindname.variable, rec, java.lang.Object)
+BadMethodCall2.java:11:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistent, , @390, (compiler.misc.location.1: kindname.variable, rec, java.lang.Object)
+3 errors
diff --git a/test/tools/javac/lambda/BadNestedLambda.java b/test/tools/javac/lambda/BadNestedLambda.java
new file mode 100644
index 0000000..616c086
--- /dev/null
+++ b/test/tools/javac/lambda/BadNestedLambda.java
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8017618
+ * @summary NullPointerException in RichDiagnosticFormatter for bad input program
+ * @compile/fail/ref=BadNestedLambda.out -XDrawDiagnostics BadNestedLambda.java
+ */
+class BadNestedLambda {
+    void test() {
+        Runnable add = (int x) -> (int y) -> x + y;
+    }
+}
diff --git a/test/tools/javac/lambda/BadNestedLambda.out b/test/tools/javac/lambda/BadNestedLambda.out
new file mode 100644
index 0000000..268ad85
--- /dev/null
+++ b/test/tools/javac/lambda/BadNestedLambda.out
@@ -0,0 +1,3 @@
+BadNestedLambda.java:9:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.not.a.functional.intf: void))
+BadNestedLambda.java:9:24: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+2 errors
diff --git a/test/tools/javac/lambda/BadRecovery.java b/test/tools/javac/lambda/BadRecovery.java
new file mode 100644
index 0000000..271a7ff
--- /dev/null
+++ b/test/tools/javac/lambda/BadRecovery.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that recovery of speculative types is not attempted if receiver is erroneous
+ * @compile/fail/ref=BadRecovery.out -XDrawDiagnostics BadRecovery.java
+ */
+class BadRecovery {
+
+    interface SAM1 {
+        void m(Object o);
+    }
+
+    void m(SAM1 m) { };
+
+    void test() {
+        m((receiver, t) -> { receiver.someMemberOfReceiver(()->{ Object x = f; }); });
+    }
+}
diff --git a/test/tools/javac/lambda/BadRecovery.out b/test/tools/javac/lambda/BadRecovery.out
new file mode 100644
index 0000000..6035eec
--- /dev/null
+++ b/test/tools/javac/lambda/BadRecovery.out
@@ -0,0 +1,2 @@
+BadRecovery.java:17:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null)
+1 error
diff --git a/test/tools/javac/lambda/BadReturn.java b/test/tools/javac/lambda/BadReturn.java
new file mode 100644
index 0000000..01667ec
--- /dev/null
+++ b/test/tools/javac/lambda/BadReturn.java
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that incompatible return types in lambdas are flagged with error
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadReturn.out -XDrawDiagnostics BadReturn.java
+ */
+
+class BadReturn {
+
+    interface SAM {
+        Comparable<?> m();
+    }
+
+    static void testNeg1() {
+        SAM s = ()-> {
+            if (true) {
+                return "";
+            } else {
+                return System.out.println("");
+            }};
+    }
+
+    static void testNeg2() {
+        SAM s = ()-> { return System.out.println(""); };
+    }
+
+    static void testPos() {
+        SAM s = ()-> {
+            if (false) {
+                return 10;
+            }
+            else {
+                return true;
+            }};
+    }
+}
diff --git a/test/tools/javac/lambda/BadReturn.out b/test/tools/javac/lambda/BadReturn.out
new file mode 100644
index 0000000..2f32c6c
--- /dev/null
+++ b/test/tools/javac/lambda/BadReturn.out
@@ -0,0 +1,3 @@
+BadReturn.java:21:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+BadReturn.java:26:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+2 errors
diff --git a/test/tools/javac/lambda/BadStatementInLambda.java b/test/tools/javac/lambda/BadStatementInLambda.java
new file mode 100644
index 0000000..ae17d26
--- /dev/null
+++ b/test/tools/javac/lambda/BadStatementInLambda.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda.out -XDrawDiagnostics BadStatementInLambda.java
+ */
+
+class BadStatementInLambda {
+
+    interface SAM{
+        Object m();
+    }
+
+    SAM t1 = ()-> { null; };
+    SAM t2 = ()-> { 1; };
+    SAM t3 = ()-> { 1 + 5; };
+}
diff --git a/test/tools/javac/lambda/BadStatementInLambda.out b/test/tools/javac/lambda/BadStatementInLambda.out
new file mode 100644
index 0000000..5978768
--- /dev/null
+++ b/test/tools/javac/lambda/BadStatementInLambda.out
@@ -0,0 +1,4 @@
+BadStatementInLambda.java:16:21: compiler.err.not.stmt
+BadStatementInLambda.java:17:21: compiler.err.not.stmt
+BadStatementInLambda.java:18:23: compiler.err.not.stmt
+3 errors
diff --git a/test/tools/javac/lambda/BadStatementInLambda02.java b/test/tools/javac/lambda/BadStatementInLambda02.java
new file mode 100644
index 0000000..0b55404
--- /dev/null
+++ b/test/tools/javac/lambda/BadStatementInLambda02.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that the compiler emits meaningful diagnostics when the lambda body contains bad statements
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadStatementInLambda02.out -XDrawDiagnostics BadStatementInLambda02.java
+ */
+
+class BadStatementInLambda02 {
+
+    interface SAM {
+        void m();
+    }
+
+    { call(()-> { System.out.println(new NonExistentClass() + ""); }); }
+
+    void call(SAM s) { }
+}
diff --git a/test/tools/javac/lambda/BadStatementInLambda02.out b/test/tools/javac/lambda/BadStatementInLambda02.out
new file mode 100644
index 0000000..99a4c06
--- /dev/null
+++ b/test/tools/javac/lambda/BadStatementInLambda02.out
@@ -0,0 +1,2 @@
+BadStatementInLambda02.java:16:42: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, BadStatementInLambda02, null)
+1 error
diff --git a/test/tools/javac/lambda/BadTargetType.java b/test/tools/javac/lambda/BadTargetType.java
new file mode 100644
index 0000000..f7eabd8
--- /dev/null
+++ b/test/tools/javac/lambda/BadTargetType.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that only SAM are allowed as target types for lambda expressions
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=BadTargetType.out -XDrawDiagnostics BadTargetType.java
+ */
+
+class BadTargetType {
+
+    static void m1(Object o) {}
+    void m2(Object o) {}
+
+    static Object l1 = (int pos)-> { };
+    Object l2 = (int pos)-> { };
+
+    {
+        m1((int pos)-> { });
+        m2((int pos)-> { });
+    }
+}
diff --git a/test/tools/javac/lambda/BadTargetType.out b/test/tools/javac/lambda/BadTargetType.out
new file mode 100644
index 0000000..122b4c8
--- /dev/null
+++ b/test/tools/javac/lambda/BadTargetType.out
@@ -0,0 +1,5 @@
+BadTargetType.java:16:24: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+BadTargetType.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+BadTargetType.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Object, @460, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: java.lang.Object))
+BadTargetType.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, java.lang.Object, @489, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: java.lang.Object))
+4 errors
diff --git a/test/tools/javac/lambda/Conditional01.java b/test/tools/javac/lambda/Conditional01.java
new file mode 100644
index 0000000..61b0f26
--- /dev/null
+++ b/test/tools/javac/lambda/Conditional01.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  conditional and varargs
+ * @compile -XDcomplexinference Conditional01.java
+ */
+
+import java.util.*;
+
+class Conditional01 {
+    void varargs(Object ... args) {  }
+
+    void test(boolean flag, List<String> ls) {
+       varargs(flag ? "" : ls);
+       varargs(null, flag ? "" : ls);
+       varargs(flag ? "" : ls());
+       varargs(null, flag ? "" : ls());
+    }
+
+    List<String> ls() { return null; }
+}
diff --git a/test/tools/javac/lambda/Conditional02.java b/test/tools/javac/lambda/Conditional02.java
new file mode 100644
index 0000000..5a5e72c
--- /dev/null
+++ b/test/tools/javac/lambda/Conditional02.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  inference and conditionals
+ * @compile -XDcomplexinference Conditional02.java
+ */
+
+class Conditional02 {
+
+    <Z> void m1(Z z) { }
+    <Z> void m2(Z... z) { }
+
+    void test(boolean flag) {
+        m1(flag ? "" : "");
+        m2(flag ? "" : "");
+        m2("", flag ? "" : "");
+    }
+}
diff --git a/test/tools/javac/lambda/Conditional03.java b/test/tools/javac/lambda/Conditional03.java
new file mode 100644
index 0000000..2b8d627
--- /dev/null
+++ b/test/tools/javac/lambda/Conditional03.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  conditionals and boxing
+ * @compile -XDcomplexinference Conditional03.java
+ */
+
+class Conditional03 {
+
+   void m1(Object o) { }
+   void m2(int i) { }
+
+   void test(boolean cond) {
+       m1((cond ? 1 : 1));
+       m1((cond ? box(1) : box(1)));
+   }
+
+   Integer box(int i) { return i; }
+}
diff --git a/test/tools/javac/lambda/Conformance01.java b/test/tools/javac/lambda/Conformance01.java
new file mode 100644
index 0000000..54c593d
--- /dev/null
+++ b/test/tools/javac/lambda/Conformance01.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  lambda compiler regression with uninferred type-variables in generic constructor call
+ * @compile Conformance01.java
+ */
+
+class Conformance01 {
+    <T1, T2> Conformance01(T1 t) { }
+
+    Conformance01 c01 = new Conformance01(null);
+}
diff --git a/test/tools/javac/lambda/Defender01.java b/test/tools/javac/lambda/Defender01.java
new file mode 100644
index 0000000..b8c3f2c
--- /dev/null
+++ b/test/tools/javac/lambda/Defender01.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  routine that checks for SAM types should skip defender methods in extended interfaces
+ * @author  Maurizio Cimadamore
+ * @compile Defender01.java
+ */
+
+class Defender01 {
+
+    interface A{
+        Object m();
+        default void n() { E.n(this); }
+    }
+
+    static class E{
+        static void n(A a){};
+    }
+
+    A t = ()-> null;
+}
diff --git a/test/tools/javac/lambda/DisjunctiveTypeTest.java b/test/tools/javac/lambda/DisjunctiveTypeTest.java
new file mode 100644
index 0000000..137e980
--- /dev/null
+++ b/test/tools/javac/lambda/DisjunctiveTypeTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that subtyping between disjunctive and non disjunctive type works
+ * @author  Maurizio Cimadamore
+ * @compile DisjunctiveTypeTest.java
+ */
+
+class DisjunctiveTypeTest {
+
+    static class A extends IllegalArgumentException {
+       A(String a) { super(a); }
+    }
+
+    class B extends IllegalArgumentException {
+       B(String b) { super(b); }
+    }
+
+    void m() throws A,B {}
+
+    void test() {
+        try {
+            m();
+        } catch (A|B e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/DoubleStaticImport.java b/test/tools/javac/lambda/DoubleStaticImport.java
new file mode 100644
index 0000000..6116900
--- /dev/null
+++ b/test/tools/javac/lambda/DoubleStaticImport.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 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 8009820
+ * @summary AssertionError when compiling java code with two identical static imports
+ * @compile DoubleStaticImport.java
+ */
+
+import static java.lang.Thread.holdsLock;
+import static java.lang.Thread.holdsLock; //dup
+
+class DoubleStaticImport {
+    public void test() {
+        holdsLock(null);
+    }
+}
diff --git a/test/tools/javac/lambda/EffectivelyFinal01.java b/test/tools/javac/lambda/EffectivelyFinal01.java
new file mode 100644
index 0000000..c12062c
--- /dev/null
+++ b/test/tools/javac/lambda/EffectivelyFinal01.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  effectively final check fails on method parameter
+ * @compile/fail/ref=EffectivelyFinal01.out -XDrawDiagnostics EffectivelyFinal01.java
+ */
+class EffectivelyFinal01 {
+
+    interface SAM {
+        Integer m(Integer i);
+    }
+
+    void test(Integer nefPar) {
+        SAM s = (Integer h) ->  { Integer k = 0; return k + h + nefPar; };
+        nefPar++;  //non-effectively final
+    }
+}
diff --git a/test/tools/javac/lambda/EffectivelyFinal01.out b/test/tools/javac/lambda/EffectivelyFinal01.out
new file mode 100644
index 0000000..dadc311
--- /dev/null
+++ b/test/tools/javac/lambda/EffectivelyFinal01.out
@@ -0,0 +1,2 @@
+EffectivelyFinal01.java:15:65: compiler.err.cant.ref.non.effectively.final.var: nefPar, (compiler.misc.lambda)
+1 error
diff --git a/test/tools/javac/lambda/EffectivelyFinalTest.java b/test/tools/javac/lambda/EffectivelyFinalTest.java
new file mode 100644
index 0000000..9d1dff9
--- /dev/null
+++ b/test/tools/javac/lambda/EffectivelyFinalTest.java
@@ -0,0 +1,55 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate effectively final check with DA/DU analysis
+ * @compile/fail/ref=EffectivelyFinalTest01.out -XDrawDiagnostics EffectivelyFinalTest.java
+ * @compile/fail/ref=EffectivelyFinalTest02.out -source 7 -Xlint:-options -XDrawDiagnostics EffectivelyFinalTest.java
+ */
+class EffectivelyFinalTest {
+
+    void m1(int x) {
+        int y = 1;
+        new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF
+    }
+
+    void m2(int x) {
+        int y;
+        y = 1;
+        new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF
+    }
+
+    void m3(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        new Object() { { System.out.println(x+y); } }; //error - y not DA
+    }
+
+    void m4(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        else y = 2;
+        new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF
+    }
+
+    void m5(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        y = 2;
+        new Object() { { System.out.println(x+y); } }; //error - y not EF
+    }
+
+    void m6(int x) {
+        new Object() { { System.out.println(x+1); } }; //error - x not EF
+        x++; // Illegal: x is not effectively final.
+    }
+
+    void m7(int x) {
+        new Object() { { System.out.println(x=1); } }; //error - x not EF
+    }
+
+    void m8() {
+        int y;
+        new Object() { { System.out.println(y=1); } }; //error - y not EF
+    }
+}
diff --git a/test/tools/javac/lambda/EffectivelyFinalTest01.out b/test/tools/javac/lambda/EffectivelyFinalTest01.out
new file mode 100644
index 0000000..2796163
--- /dev/null
+++ b/test/tools/javac/lambda/EffectivelyFinalTest01.out
@@ -0,0 +1,6 @@
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:39:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:43:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:48:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:53:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+5 errors
diff --git a/test/tools/javac/lambda/EffectivelyFinalTest02.out b/test/tools/javac/lambda/EffectivelyFinalTest02.out
new file mode 100644
index 0000000..c151039
--- /dev/null
+++ b/test/tools/javac/lambda/EffectivelyFinalTest02.out
@@ -0,0 +1,14 @@
+EffectivelyFinalTest.java:25:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:13:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:13:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:19:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:19:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:25:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:32:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:39:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:39:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:43:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:48:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: y
+13 errors
diff --git a/test/tools/javac/lambda/ErroneousArg.java b/test/tools/javac/lambda/ErroneousArg.java
new file mode 100644
index 0000000..9e3a259
--- /dev/null
+++ b/test/tools/javac/lambda/ErroneousArg.java
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache mismatches between Resolve.access and Attr.checkId leads to compiler crashes
+ * @compile/fail/ref=ErroneousArg.out -XDrawDiagnostics ErroneousArg.java
+ */
+class ErroneousArg {
+
+    private static class Foo {
+        static int j() { return 1; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(String s) { return 1; }
+    static int g(Double s) { return 1; }
+
+    int h() { return 1; }
+}
+
+class TestErroneousArg extends ErroneousArg {
+    static void test() {
+        m(unknown()); //method not found
+        m(f(1)); //inapplicable method
+        m(g(1)); //inapplicable methods
+        m(g(null)); //ambiguous
+        m(h()); //static error
+        m(foo.j()); //inaccessible method
+    }
+}
diff --git a/test/tools/javac/lambda/ErroneousArg.out b/test/tools/javac/lambda/ErroneousArg.out
new file mode 100644
index 0000000..bd59686
--- /dev/null
+++ b/test/tools/javac/lambda/ErroneousArg.out
@@ -0,0 +1,7 @@
+ErroneousArg.java:29:11: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, TestErroneousArg, null)
+ErroneousArg.java:30:11: compiler.err.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, ErroneousArg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))
+ErroneousArg.java:31:11: compiler.err.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.method, ErroneousArg, g(java.lang.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.Double)))}
+ErroneousArg.java:32:11: compiler.err.ref.ambiguous: g, kindname.method, g(java.lang.String), ErroneousArg, kindname.method, g(java.lang.Double), ErroneousArg
+ErroneousArg.java:33:11: compiler.err.non-static.cant.be.ref: kindname.method, h()
+ErroneousArg.java:34:14: compiler.err.not.def.access.class.intf.cant.access: j(), ErroneousArg.Foo
+6 errors
diff --git a/test/tools/javac/lambda/ErroneousLambdaExpr.java b/test/tools/javac/lambda/ErroneousLambdaExpr.java
new file mode 100644
index 0000000..be21473
--- /dev/null
+++ b/test/tools/javac/lambda/ErroneousLambdaExpr.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  stale state after speculative attribution round leads to missing classfiles
+ */
+public class ErroneousLambdaExpr<T> {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1<X> {
+        X m(X t, String s);
+    }
+
+    interface SAM2 {
+        void m(String s, int i);
+    }
+
+    interface SAM3<X> {
+        X m(X t, String s, int i);
+    }
+
+    void call(SAM1<T> s1) { assertTrue(true); }
+
+    void call(SAM2 s2) { assertTrue(false); }
+
+    void call(SAM3<T> s3) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        ErroneousLambdaExpr<StringBuilder> test =
+                new ErroneousLambdaExpr<>();
+
+        test.call((builder, string) -> { builder.append(string); return builder; });
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/ExceptionsInLambda.java b/test/tools/javac/lambda/ExceptionsInLambda.java
new file mode 100644
index 0000000..bb63dae
--- /dev/null
+++ b/test/tools/javac/lambda/ExceptionsInLambda.java
@@ -0,0 +1,61 @@
+/*
+ * 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 8015809
+ * @summary Producing individual errors for uncaught undeclared exceptions inside lambda expressions, instead of one error for whole lambda
+ * @compile/fail/ref=ExceptionsInLambda.out -XDrawDiagnostics ExceptionsInLambda.java
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.InputStream;
+import java.io.Reader;
+
+public class ExceptionsInLambda {
+
+    public static void main(Runnable p, File f) {
+        main(() -> {
+            StringBuilder sb = new StringBuilder();
+
+            Reader in = new FileReader(f);
+            int r;
+
+            while ((r = in.read()) != (-1)) {
+                sb.append((char) r);
+            }
+        }, f);
+
+        doOpen(() -> new FileInputStream(f));
+    }
+
+    public static InputStream doOpen(Open open) {
+        return open.open();
+    }
+
+    public interface Open {
+        public InputStream open();
+    }
+}
diff --git a/test/tools/javac/lambda/ExceptionsInLambda.out b/test/tools/javac/lambda/ExceptionsInLambda.out
new file mode 100644
index 0000000..5cfa249
--- /dev/null
+++ b/test/tools/javac/lambda/ExceptionsInLambda.out
@@ -0,0 +1,4 @@
+ExceptionsInLambda.java:43:25: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.FileNotFoundException
+ExceptionsInLambda.java:46:32: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.IOException
+ExceptionsInLambda.java:51:22: compiler.err.unreported.exception.need.to.catch.or.throw: java.io.FileNotFoundException
+3 errors
diff --git a/test/tools/javac/lambda/FunctionalInterfaceAnno.java b/test/tools/javac/lambda/FunctionalInterfaceAnno.java
new file mode 100644
index 0000000..49248a0
--- /dev/null
+++ b/test/tools/javac/lambda/FunctionalInterfaceAnno.java
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary smoke test for functional interface annotation
+ * @compile/fail/ref=FunctionalInterfaceAnno.out -XDrawDiagnostics FunctionalInterfaceAnno.java
+ */
+class FunctionalInterfaceAnno {
+    @FunctionalInterface
+    static class A { } //not an interface
+
+    @FunctionalInterface
+    static abstract class B { } //not an interface
+
+    @FunctionalInterface
+    enum C { } //not an interface
+
+    @FunctionalInterface
+    @interface D { } //not an interface
+
+    @FunctionalInterface
+    interface E { } //no abstracts
+
+    @FunctionalInterface
+    interface F { default void m() { } } //no abstracts
+
+    @FunctionalInterface
+    interface G { String toString(); } //no abstracts
+
+    @FunctionalInterface
+    interface H { void m(); void n(); } //incompatible abstracts
+
+    @FunctionalInterface
+    interface I { void m(); } //ok
+}
diff --git a/test/tools/javac/lambda/FunctionalInterfaceAnno.out b/test/tools/javac/lambda/FunctionalInterfaceAnno.out
new file mode 100644
index 0000000..d6b8c39
--- /dev/null
+++ b/test/tools/javac/lambda/FunctionalInterfaceAnno.out
@@ -0,0 +1,9 @@
+FunctionalInterfaceAnno.java:7:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf: FunctionalInterfaceAnno.A)
+FunctionalInterfaceAnno.java:10:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf: FunctionalInterfaceAnno.B)
+FunctionalInterfaceAnno.java:13:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf: FunctionalInterfaceAnno.C)
+FunctionalInterfaceAnno.java:16:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf: FunctionalInterfaceAnno.D)
+FunctionalInterfaceAnno.java:19:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf.1: FunctionalInterfaceAnno.E, (compiler.misc.no.abstracts: kindname.interface, FunctionalInterfaceAnno.E))
+FunctionalInterfaceAnno.java:22:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf.1: FunctionalInterfaceAnno.F, (compiler.misc.no.abstracts: kindname.interface, FunctionalInterfaceAnno.F))
+FunctionalInterfaceAnno.java:25:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf.1: FunctionalInterfaceAnno.G, (compiler.misc.no.abstracts: kindname.interface, FunctionalInterfaceAnno.G))
+FunctionalInterfaceAnno.java:28:5: compiler.err.bad.functional.intf.anno.1: (compiler.misc.not.a.functional.intf.1: FunctionalInterfaceAnno.H, (compiler.misc.incompatible.abstracts: kindname.interface, FunctionalInterfaceAnno.H))
+8 errors
diff --git a/test/tools/javac/lambda/FunctionalInterfaceAnno02.java b/test/tools/javac/lambda/FunctionalInterfaceAnno02.java
new file mode 100644
index 0000000..088ce67
--- /dev/null
+++ b/test/tools/javac/lambda/FunctionalInterfaceAnno02.java
@@ -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 8007535
+ * @summary Compiler crashes on FunctionalInterface used on interface with two inherited methods with same signatures
+ * @compile FunctionalInterfaceAnno02.java
+ */
+class FunctionalInterfaceAnno02 {
+    interface Foo<T, N extends Number> {
+        void m(T arg);
+        void m(N arg);
+    }
+
+    @FunctionalInterface
+    interface Baz extends Foo<Integer, Integer> { }
+}
diff --git a/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java b/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java
new file mode 100644
index 0000000..06db215
--- /dev/null
+++ b/test/tools/javac/lambda/FunctionalInterfaceConversionTest.java
@@ -0,0 +1,309 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003280 8004102 8006694
+ * @summary Add lambda tests
+ *  perform several automated checks in lambda conversion, esp. around accessibility
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @author  Maurizio Cimadamore
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm FunctionalInterfaceConversionTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
+
+public class FunctionalInterfaceConversionTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum PackageKind {
+        NO_PKG(""),
+        PKG_A("a");
+
+        String pkg;
+
+        PackageKind(String pkg) {
+            this.pkg = pkg;
+        }
+
+        String getPkgDecl() {
+            return this == NO_PKG ?
+                "" :
+                "package " + pkg + ";";
+        }
+
+        String getImportStat() {
+            return this == NO_PKG ?
+                "" :
+                "import " + pkg + ".*;";
+        }
+    }
+
+    enum SamKind {
+        CLASS("public class Sam {  }"),
+        ABSTACT_CLASS("public abstract class Sam {  }"),
+        ANNOTATION("public @interface Sam {  }"),
+        ENUM("public enum Sam { }"),
+        INTERFACE("public interface Sam { \n #METH; \n }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(String methStr) {
+            return sam_str.replaceAll("#METH", methStr);
+        }
+    }
+
+    enum ModifierKind {
+        PUBLIC("public"),
+        PACKAGE("");
+
+        String modifier_str;
+
+        ModifierKind(String modifier_str) {
+            this.modifier_str = modifier_str;
+        }
+
+        boolean stricterThan(ModifierKind that) {
+            return this.ordinal() > that.ordinal();
+        }
+    }
+
+    enum TypeKind {
+        EXCEPTION("Exception"),
+        PKG_CLASS("PackageClass");
+
+        String typeStr;
+
+        private TypeKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+    }
+
+    enum ExprKind {
+        LAMBDA("x -> null"),
+        MREF("this::m");
+
+        String exprStr;
+
+        private ExprKind(String exprStr) {
+            this.exprStr = exprStr;
+        }
+    }
+
+    enum MethodKind {
+        NONE(""),
+        NON_GENERIC("public abstract #R m(#ARG s) throws #T;"),
+        GENERIC("public abstract <X> #R m(#ARG s) throws #T;");
+
+        String methodTemplate;
+
+        private MethodKind(String methodTemplate) {
+            this.methodTemplate = methodTemplate;
+        }
+
+        String getMethod(TypeKind retType, TypeKind argType, TypeKind thrownType) {
+            return methodTemplate.replaceAll("#R", retType.typeStr).
+                    replaceAll("#ARG", argType.typeStr).
+                    replaceAll("#T", thrownType.typeStr);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        for (PackageKind samPkg : PackageKind.values()) {
+            for (ModifierKind modKind : ModifierKind.values()) {
+                for (SamKind samKind : SamKind.values()) {
+                    for (MethodKind samMeth : MethodKind.values()) {
+                        for (MethodKind clientMeth : MethodKind.values()) {
+                            for (TypeKind retType : TypeKind.values()) {
+                                for (TypeKind argType : TypeKind.values()) {
+                                    for (TypeKind thrownType : TypeKind.values()) {
+                                        for (ExprKind exprKind : ExprKind.values()) {
+                                            pool.execute(
+                                                new FunctionalInterfaceConversionTest(
+                                                    samPkg, modKind, samKind,
+                                                    samMeth, clientMeth, retType,
+                                                    argType, thrownType, exprKind));
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec(false);
+    }
+
+    PackageKind samPkg;
+    ModifierKind modKind;
+    SamKind samKind;
+    MethodKind samMeth;
+    MethodKind clientMeth;
+    TypeKind retType;
+    TypeKind argType;
+    TypeKind thrownType;
+    ExprKind exprKind;
+    DiagnosticChecker dc;
+
+    SourceFile samSourceFile = new SourceFile("Sam.java", "#P \n #C") {
+        @Override
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#C", samKind.getSam(
+                    samMeth.getMethod(retType, argType, thrownType)));
+        }
+    };
+
+    SourceFile pkgClassSourceFile =
+            new SourceFile("PackageClass.java",
+                           "#P\n #M class PackageClass extends Exception { }") {
+        @Override
+        public String toString() {
+            return template.replaceAll("#P", samPkg.getPkgDecl()).
+                    replaceAll("#M", modKind.modifier_str);
+        }
+    };
+
+    SourceFile clientSourceFile =
+            new SourceFile("Client.java",
+                           "#I\n abstract class Client { \n" +
+                           "  Sam s = #E;\n" +
+                           "  #M \n }") {
+        @Override
+        public String toString() {
+            return template.replaceAll("#I", samPkg.getImportStat())
+                    .replaceAll("#E", exprKind.exprStr)
+                    .replaceAll("#M", clientMeth.getMethod(retType, argType, thrownType));
+        }
+    };
+
+    FunctionalInterfaceConversionTest(PackageKind samPkg, ModifierKind modKind,
+            SamKind samKind, MethodKind samMeth, MethodKind clientMeth,
+            TypeKind retType, TypeKind argType, TypeKind thrownType,
+            ExprKind exprKind) {
+        this.samPkg = samPkg;
+        this.modKind = modKind;
+        this.samKind = samKind;
+        this.samMeth = samMeth;
+        this.clientMeth = clientMeth;
+        this.retType = retType;
+        this.argType = argType;
+        this.thrownType = thrownType;
+        this.exprKind = exprKind;
+        this.dc = new DiagnosticChecker();
+    }
+
+    @Override
+    public void run() {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), dc, null, null,
+                Arrays.asList(samSourceFile, pkgClassSourceFile, clientSourceFile));
+        try {
+            ct.analyze();
+        } catch (IOException ex) {
+            throw new AssertionError("Test failing with cause", ex.getCause());
+        }
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" +
+                pkgClassSourceFile + "\n\n" + clientSourceFile);
+        }
+    }
+
+    boolean checkSamConversion() {
+        if (samKind != SamKind.INTERFACE) {
+            //sam type must be an interface
+            return false;
+        } else if (samMeth == MethodKind.NONE) {
+            //interface must have at least a method
+            return false;
+        } else if (exprKind == ExprKind.LAMBDA &&
+                samMeth != MethodKind.NON_GENERIC) {
+            //target method for lambda must be non-generic
+            return false;
+        } else if (exprKind == ExprKind.MREF &&
+                clientMeth == MethodKind.NONE) {
+            return false;
+        } else if (samPkg != PackageKind.NO_PKG &&
+                modKind != ModifierKind.PUBLIC &&
+                (retType == TypeKind.PKG_CLASS ||
+                argType == TypeKind.PKG_CLASS ||
+                thrownType == TypeKind.PKG_CLASS)) {
+            //target must not contain inaccessible types
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        @Override
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        @Override
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/GenericMethodRefImplClass.java b/test/tools/javac/lambda/GenericMethodRefImplClass.java
new file mode 100644
index 0000000..07f369d
--- /dev/null
+++ b/test/tools/javac/lambda/GenericMethodRefImplClass.java
@@ -0,0 +1,81 @@
+/*
+ * 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 8009582
+ * @summary Method reference generic constructor gives: IllegalArgumentException: Invalid lambda deserialization
+ * @author  Robert Field
+ * @run main GenericMethodRefImplClass
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class GenericMethodRefImplClass {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            // Write lambdas out
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutput out = new ObjectOutputStream(baos);
+
+            write(out, HashMap::new );
+            out.flush();
+            out.close();
+
+            // Read them back
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(baos.toByteArray());
+            ObjectInputStream in = new ObjectInputStream(bais);
+            readIt(in);
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+        assertTrue(assertionCount == 1);
+    }
+
+    static void write(ObjectOutput out, GenericMethodRefImplClassLSI lamb) throws IOException {
+        out.writeObject(lamb);
+    }
+
+    static void readIt(ObjectInputStream in)  throws IOException, ClassNotFoundException {
+        GenericMethodRefImplClassLSI ls = (GenericMethodRefImplClassLSI) in.readObject();
+        Map result = ls.convert();
+        assertTrue(result.getClass().getName().equals("java.util.HashMap"));
+    }
+}
+
+interface GenericMethodRefImplClassLSI extends Serializable {
+    Map convert();
+}
diff --git a/test/tools/javac/lambda/IdentifierTest.java b/test/tools/javac/lambda/IdentifierTest.java
new file mode 100644
index 0000000..17e480d
--- /dev/null
+++ b/test/tools/javac/lambda/IdentifierTest.java
@@ -0,0 +1,182 @@
+/*
+ * @test   /nodynamiccopyright/
+ * @bug    8007401 8007427
+ * @author sogoel
+ * @summary Test generation of warnings when '_' is used an identifier
+ * @compile/fail/ref=IdentifierTest.out -Werror -XDrawDiagnostics IdentifierTest.java
+ */
+
+import java.util.List;
+
+/*
+ * This test checks for the generation of warnings when '_' is used as an
+ * identifier in following cases:
+ * package name, class name, class member names including constructor
+ * cass members access using class object or this
+ * loops: for, enhanced-for, while, do-while
+ * arrays,
+ * switch,
+ * annotations, element=value pair
+ * try-catch,
+ * enum
+ * break + identifier
+ * continue + identifier
+ * type-bounds
+ * Above cases for identifier occurrences have been identified from JLS v3.
+ *
+ */
+
+// Test class
+public class IdentifierTest {
+    class _UnderscorePrefix {}
+    class Underscore_Infix {}
+    class UnderscorePostfix_ {}
+    class __ {}
+
+    static final int _prefix = 10;
+    List<String> postfix_;
+
+    // Test: class with name as '_'
+    class _ {
+        String in_fix;
+        //Test: Constructor, "_", local variable, value
+        public _() {
+            String _ = "_";
+            in_fix = _;
+        }
+
+        public void testClassMembersAccess(String[] _args) {
+            // Instance creation
+            _ _ = new _();
+            //Method invocation
+            _.testTryCatch();
+            //Field access
+            _.in_fix = "__";
+        }
+
+        // Test: try-catch
+        public void testTryCatch() {
+            try {
+                int _ = 30/0;
+            } catch (ArithmeticException _) {
+                System.out.println("Got Arithmentic exception " + _);
+            }
+        }
+    }
+
+    // Test: class member access using class object '_', use of this.
+    class TestMisc {
+        int _;
+        void _ () {
+            this._ = 5;
+        }
+
+        public void testClassMemberAccess(String[] args) {
+            // Instance creation
+            TestMisc _ = new TestMisc();
+            //Field access
+            _._ = 10;
+           //Method access
+            _._();
+        }
+    }
+
+    //Test: Type Bounds
+    class TestTypeBounds {
+        //Type bounds
+        <_ extends Object> void test(_ t) {}
+    }
+
+    // Test: enum and switch case
+    static class TestEnum {
+        // Enum
+        enum _ {
+            _MONDAY, _TUESDAY, _WEDNESDAY, _THURSDAY, _FRIDAY,
+            _SATURDAY, _SUNDAY;
+        }
+
+        void foo() {
+            // switch-case
+            for(_ _day : _.values()) {
+                switch(_day) {
+                case _SATURDAY:
+                case _SUNDAY:
+                    System.out.println("Weekend is here!");
+                    break;
+                default:
+                    System.out.println("Weekday is here!");
+                    break;
+                }
+            }
+        }
+    }
+
+    // Test: Annotation
+    static class TestAnno {
+        // Annotation with name as _
+        @interface _ {
+            String _name();
+            int _id();
+        }
+        // Element-Value pair
+        @_(_name ="m",_id=1)
+        public void m(int arg) {}
+
+        //Annotation with _ as one of the elements
+        @interface MyAnno {
+            int _();
+        }
+        // Element Value pair
+        @MyAnno(_='1')
+        public void m2() {}
+    }
+
+    // Test: for loop, while loop, do-while loop, increment/decrement op, condition, print
+    public void testLoop() {
+        // for loop
+        for(int _ = 0; _ < 5; ++_) {
+            System.out.println("_=" + _ + " ");
+        }
+
+        // while loop
+        int _ = 0;
+        while(_ <= 5) {
+            _++;
+        }
+
+        //do-while loop
+        do {
+            --_;
+        } while(_ > 0);
+    }
+
+    // Test: Array and enhanced for loop
+    public void testArraysEnhancedForLoop() {
+        // Arrays
+        String _[] = {"A","B","C","D"};
+
+        for(String _s : _ ) {
+            System.out.println("_s="+_s);
+        }
+    }
+
+    // Test: Labels in break, continue
+    public void testLabels() {
+        // break/continue with labels
+        int j = 0;
+    _:
+        for (int i = 0; i <= 5; i++) {
+            while( j > 4 ) {
+                j++;
+                continue _;
+            }
+            break _;
+        }
+    }
+}
+
+//interface
+interface _ {
+    void mI();
+}
+
diff --git a/test/tools/javac/lambda/IdentifierTest.out b/test/tools/javac/lambda/IdentifierTest.out
new file mode 100644
index 0000000..d78edb1
--- /dev/null
+++ b/test/tools/javac/lambda/IdentifierTest.out
@@ -0,0 +1,47 @@
+IdentifierTest.java:40:11: compiler.warn.underscore.as.identifier
+IdentifierTest.java:43:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:44:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:45:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:50:23: compiler.warn.underscore.as.identifier
+IdentifierTest.java:52:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:54:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:60:21: compiler.warn.underscore.as.identifier
+IdentifierTest.java:61:42: compiler.warn.underscore.as.identifier
+IdentifierTest.java:62:67: compiler.warn.underscore.as.identifier
+IdentifierTest.java:69:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:70:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:71:18: compiler.warn.underscore.as.identifier
+IdentifierTest.java:76:22: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:78:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:80:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:87:38: compiler.warn.underscore.as.identifier
+IdentifierTest.java:93:14: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:100:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:117:20: compiler.warn.underscore.as.identifier
+IdentifierTest.java:122:10: compiler.warn.underscore.as.identifier
+IdentifierTest.java:127:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:130:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:24: compiler.warn.underscore.as.identifier
+IdentifierTest.java:137:33: compiler.warn.underscore.as.identifier
+IdentifierTest.java:138:39: compiler.warn.underscore.as.identifier
+IdentifierTest.java:142:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:143:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:144:13: compiler.warn.underscore.as.identifier
+IdentifierTest.java:149:15: compiler.warn.underscore.as.identifier
+IdentifierTest.java:150:17: compiler.warn.underscore.as.identifier
+IdentifierTest.java:156:16: compiler.warn.underscore.as.identifier
+IdentifierTest.java:158:25: compiler.warn.underscore.as.identifier
+IdentifierTest.java:167:5: compiler.warn.underscore.as.identifier
+IdentifierTest.java:171:26: compiler.warn.underscore.as.identifier
+IdentifierTest.java:173:19: compiler.warn.underscore.as.identifier
+IdentifierTest.java:179:11: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+44 warnings
diff --git a/test/tools/javac/lambda/InnerConstructor.java b/test/tools/javac/lambda/InnerConstructor.java
new file mode 100644
index 0000000..3675020
--- /dev/null
+++ b/test/tools/javac/lambda/InnerConstructor.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  Regression test JDK-8003306 inner class constructor in lambda
+ * @author  Robert Field
+ */
+
+public class InnerConstructor {
+
+    public static void main(String... args) {
+        InnerConstructor ic = new InnerConstructor();
+        String res = ic.seq1().m().toString();
+        if (!res.equals("Cbl.toString")) {
+            throw new AssertionError(String.format("Unexpected result: %s", res));
+        }
+    }
+
+    Ib1 seq1() {
+        return () -> new Cbl();
+    }
+
+    class Cbl {
+        Cbl() {  }
+        public String toString() {
+            return "Cbl.toString";
+        }
+    }
+
+    interface Ib1 {
+        Object m();
+    }
+}
diff --git a/test/tools/javac/lambda/Intersection01.java b/test/tools/javac/lambda/Intersection01.java
new file mode 100644
index 0000000..6a034f2
--- /dev/null
+++ b/test/tools/javac/lambda/Intersection01.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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 8002099
+ * @summary Add support for intersection types in cast expression
+ * @compile Intersection01.java
+ */
+class Intersection01 {
+
+    interface SAM {
+        void m();
+    }
+
+    Object o1 = (java.io.Serializable & SAM)()->{};
+    Object o2 = (SAM & java.io.Serializable)()->{};
+    Object o3 = (java.io.Serializable & SAM)Intersection01::m;
+    Object o4 = (SAM & java.io.Serializable)Intersection01::m;
+
+    static void m() { }
+}
diff --git a/test/tools/javac/lambda/Intersection02.java b/test/tools/javac/lambda/Intersection02.java
new file mode 100644
index 0000000..2afcec1
--- /dev/null
+++ b/test/tools/javac/lambda/Intersection02.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ * 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 8010101
+ * @summary Intersection type cast issues redundant unchecked warning
+ * @compile/fail/ref=Intersection02.out -Werror -Xlint:unchecked -XDrawDiagnostics Intersection02.java
+ */
+import java.io.Serializable;
+import java.util.List;
+
+class Intersection02 {
+
+    interface P<X> { }
+
+    void test(List<String> ls) {
+        Object o1 = (List<String> & Serializable)ls;
+        Object o2 = (List<String> & Serializable & P<String>)ls;
+    }
+}
diff --git a/test/tools/javac/lambda/Intersection02.out b/test/tools/javac/lambda/Intersection02.out
new file mode 100644
index 0000000..f3844e2
--- /dev/null
+++ b/test/tools/javac/lambda/Intersection02.out
@@ -0,0 +1,4 @@
+Intersection02.java:39:62: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.util.List<java.lang.String>, java.lang.Object&java.util.List<java.lang.String>&java.io.Serializable&Intersection02.P<java.lang.String>
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/lambda/Intersection03.java b/test/tools/javac/lambda/Intersection03.java
new file mode 100644
index 0000000..a6de788
--- /dev/null
+++ b/test/tools/javac/lambda/Intersection03.java
@@ -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 8011392
+ * @summary Missing checkcast when casting to intersection type
+ */
+import java.util.*;
+
+public class Intersection03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond) throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        try {
+            Runnable r = (List<?> & Runnable)new ArrayList<String>();
+            assertTrue(false);
+        } catch (ClassCastException cce) {
+            assertTrue(true);
+        }
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture01.java b/test/tools/javac/lambda/LambdaCapture01.java
new file mode 100644
index 0000000..4ee36d6
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture01.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture01
+ */
+
+public class LambdaCapture01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    //Simple local capture
+    void test1() {
+        final int N = 1;
+        int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final int N = 1;
+        new Tester() {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final int N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final int M = 2;
+                int res = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final int N = 4;
+        int res1 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture01.<Integer,Integer>exec((Integer x) -> x + LambdaCapture01.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture01 t = new LambdaCapture01();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture02.java b/test/tools/javac/lambda/LambdaCapture02.java
new file mode 100644
index 0000000..3faf6a0
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture02.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture02
+ */
+
+public class LambdaCapture02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public Integer n = 5;
+
+    //Simple local capture
+    void test1() {
+        final Integer N = 1;
+        int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N, 3);
+        assertTrue(4 == res);
+    }
+
+    //Local capture with multiple scopes (anon class)
+    void test2() {
+        final Integer N = 1;
+        new Tester() {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }.test();
+    }
+
+    //Local capture with multiple scopes (local class)
+    void test3() {
+        final Integer N = 1;
+        class MyTester implements Tester {
+            public void test() {
+                final Integer M = 2;
+                int res = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + N + M, 3);
+                assertTrue(6 == res);
+            }
+        }
+        new MyTester().test();
+    }
+
+    //access to field from enclosing scope
+    void test4() {
+        final Integer N = 4;
+        int res1 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + n + N, 3);
+        assertTrue(12 == res1);
+        int res2 = LambdaCapture02.<Integer,Integer>exec((Integer x) -> x + LambdaCapture02.this.n + N, 3);
+        assertTrue(12 == res2);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture02 t = new LambdaCapture02();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 5);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture03.java b/test/tools/javac/lambda/LambdaCapture03.java
new file mode 100644
index 0000000..5399754
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture03.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture03
+ */
+
+public class LambdaCapture03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                           assertTrue(res == 66);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        int res = LambdaCapture03.exec((Integer x) -> x + n1 + n2 + N1 + N2 + N3, 30);
+                        assertTrue(res == 66);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture03 t = new LambdaCapture03();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture04.java b/test/tools/javac/lambda/LambdaCapture04.java
new file mode 100644
index 0000000..8f4c193
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture04.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test for capture of non-mutable locals/outer fields in multiple scopes
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture04
+ */
+
+public class LambdaCapture04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Tester {
+        void test();
+    }
+
+    interface TU<U> {
+        public void foo(U u);
+    }
+
+    public static <U> void exec(TU<U> lambda, U x) {
+        lambda.foo(x);
+    }
+
+    Integer n1 = 10;
+
+    void test1() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test2() {
+        final Integer N1 = 1;
+        class A {
+            Integer n2 = 20;
+            void test() {
+                  final Integer N2 = 2;
+                  class B {
+                       void test() {
+                           final Integer N3 = 3;
+                           exec((final Integer x) -> {
+                               class LocTester implements Tester {
+                                   public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                               };
+                               new LocTester().test();
+                           },30);
+                       }
+                  }
+                  new B().test();
+            }
+        }
+        new A().test();
+    }
+
+    void test3() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> new Tester() { public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); } }.test(),30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    void test4() {
+        final Integer N1 = 1;
+        new Tester() {
+            Integer n2 = 20;
+            public void test() {
+                final Integer N2 = 2;
+                new Tester() {
+                    public void test() {
+                        final Integer N3 = 3;
+                        exec((final Integer x) -> {
+                            class LocTester implements Tester {
+                                public void test() { assertTrue(x + n1 + n2 + N1 + N2 + N3 == 66); }
+                            };
+                            new LocTester().test();
+                        },30);
+                    }
+                }.test();
+            }
+        }.test();
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture04 t = new LambdaCapture04();
+        t.test1();
+        t.test2();
+        t.test3();
+        t.test4();
+        assertTrue(assertionCount == 4);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture05.java b/test/tools/javac/lambda/LambdaCapture05.java
new file mode 100644
index 0000000..3752dd7
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture05.java
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  test for capture in nested lambda expressions
+ * @author  Maurizio Cimadamore
+ * @run main LambdaCapture05
+ */
+
+public class LambdaCapture05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    int i = 40;
+
+    void test1(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(106 == (a0 + a1 + a2 + a3 + x2 + x3 + i)); return null; }, 3);
+                return null;
+            },2);
+            return null;
+        },1);
+    }
+
+    static void test2(final int a0) {
+        exec((final Integer a1) -> {
+            final Integer x2 = 10; exec((final Integer a2) -> {
+                final Integer x3 = 20;
+                exec((final Integer a3) -> { assertTrue(66 == (a0 + a1 + a2 + a3 + x2 + x3)); return null; }, 3);
+                return null;
+            }, 2);
+            return null;
+        }, 1);
+    }
+
+    public static void main(String[] args) {
+        LambdaCapture05 t = new LambdaCapture05();
+        t.test1(30);
+        test2(30);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaCapture06.java b/test/tools/javac/lambda/LambdaCapture06.java
new file mode 100644
index 0000000..99a72d2
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture06.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  Compiler crash when local inner class nested inside lambda captures local variables from enclosing scope
+ */
+public class LambdaCapture06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m(int n);
+    }
+
+    public static void main(String[] args) {
+        int n = 5;
+        SAM s = k -> {
+            new Object() {
+                void test() { int j = n; assertTrue(j == 5); }
+            }.test();
+        };
+        s.m(42);
+        assertTrue(assertionCount == 1);
+    }
+}
+
+
diff --git a/test/tools/javac/lambda/LambdaCapture07.java b/test/tools/javac/lambda/LambdaCapture07.java
new file mode 100644
index 0000000..088623f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaCapture07.java
@@ -0,0 +1,60 @@
+/*
+ * 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 8004962
+ * @summary Code generation crash with lambda and local classes
+ */
+public class LambdaCapture07 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    void test(int i) {
+        class Local { Local() { assertTrue(i == 42); } }
+        class LocalSub extends Local { }
+        SAM s_sup = ()->new Local();
+        s_sup.m();
+        SAM s_sub = ()->new LocalSub();
+        s_sub.m();
+        SAM s_sup_nested = ()->{ SAM s = ()->new Local(); s.m(); };
+        s_sup_nested.m();
+        SAM s_sub_nested = ()->{ SAM s = ()->new LocalSub(); s.m(); };
+        s_sub_nested.m();
+    }
+
+    public static void main(String[] args) {
+        new LambdaCapture07().test(42);
+        assertTrue(assertionCount == 4);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv01.java b/test/tools/javac/lambda/LambdaConv01.java
new file mode 100644
index 0000000..582c99f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv01.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for lambda conversion
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv01
+ */
+
+public class LambdaConv01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface IntToInt {
+      public int foo(int x);
+    }
+
+    interface IntToVoid {
+      public void foo(int x);
+    }
+
+    interface VoidToInt {
+      public int foo();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3).intValue());
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3).intValue());
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3).intValue());
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Assignment conversion:
+        VoidToInt f1 = ()-> 3;
+        assertTrue(3 == f1.foo());
+        //Covariant returns:
+        TU<Number, Integer> f2 = (Integer x) -> x;
+        assertTrue(3 == f2.foo(3).intValue());
+        //Method resolution with boxing:
+        int res = LambdaConv01.<Integer,Integer>exec((Integer x) -> x, 3);
+        assertTrue(3 == res);
+        //Runtime exception transparency:
+        try {
+            LambdaConv01.<Integer,Object>exec((Object x) -> x.hashCode(), null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv01().test2();
+        assertTrue(assertionCount == 16);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv03.java b/test/tools/javac/lambda/LambdaConv03.java
new file mode 100644
index 0000000..1c0480b
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv03.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  SAM types and method type inference
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv03
+ */
+
+public class LambdaConv03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+      public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    static {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void test1() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public void test2() {
+        //Covariant returns:
+        int i1 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i1);
+        //Method resolution with boxing:
+        int i2 = exec((Integer x) -> { return x; }, 3);
+        assertTrue(3 == i2);
+        //Runtime exception transparency:
+        try {
+            exec((Object x) -> { return x.hashCode(); }, null);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaConv03().test2();
+        assertTrue(assertionCount == 12);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv05.java b/test/tools/javac/lambda/LambdaConv05.java
new file mode 100644
index 0000000..7cce28a
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv05.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  function type and method type inference
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv05
+ */
+
+import java.util.*;
+
+public class LambdaConv05 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    int count = 0;
+
+    void sort(List<String> data) {
+      Collections.sort(data,
+                       (String a, String b) -> { LambdaConv05.this.count++; return a.length()-b.length(); });
+    }
+
+    public static void main(String[] args) {
+        ArrayList<String> arr = new ArrayList<>();
+        arr.add("Three");
+        arr.add("Four");
+        arr.add("One");
+        LambdaConv05 sorter = new LambdaConv05();
+        sorter.sort(arr);
+        assertTrue(arr.get(0).equals("One"));
+        assertTrue(arr.get(1).equals("Four"));
+        assertTrue(arr.get(2).equals("Three"));
+        assertTrue(sorter.count == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv06.java b/test/tools/javac/lambda/LambdaConv06.java
new file mode 100644
index 0000000..404ca52
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv06.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  ensure that definite assignment analysis doesn't mess up with lambda attribution
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv06.java
+ */
+
+class LambdaConv06 {
+
+    private int t() {
+        return a((final Object indexed) -> {
+            return b(new R() {
+                public String build(final Object index) {
+                    return "";
+                }
+            });
+        });
+    }
+
+    private int a(R r) {return 0;}
+    private String b(R r) {return null;}
+
+    public static interface R {
+        public String build(Object o);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv08.java b/test/tools/javac/lambda/LambdaConv08.java
new file mode 100644
index 0000000..8363866
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv08.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles covarinat return types correctly
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv08
+ */
+
+public class LambdaConv08 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public interface ObjectF { Object invoke(); }
+    public interface StringF extends ObjectF { String invoke(); }
+
+    public static void call(StringF stringFunc) {
+        assertTrue(true);
+    }
+
+    public static void call(ObjectF objectFunc) {  }
+
+    public static void main(String[] args)   {
+        call(()-> "Hello");
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv09.java b/test/tools/javac/lambda/LambdaConv09.java
new file mode 100644
index 0000000..7ae1993
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv09.java
@@ -0,0 +1,50 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that SAM conversion handles Object members correctly
+ * @author  Alex Buckley
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv09.out -XDrawDiagnostics LambdaConv09.java
+ */
+
+class LambdaConv09 {
+
+    // Not a SAM type; not enough abstract methods
+    interface Foo1 {}
+
+    // SAM type; Foo has no abstract methods
+    interface Foo2 { boolean equals(Object object); }
+
+
+    // Not a SAM type; Foo still has no abstract methods
+    interface Foo3 extends Foo2 { public abstract String toString(); }
+
+    // SAM type; Bar has one abstract non-Object method
+    interface Foo4<T> extends Foo2 { int compare(T o1, T o2); }
+
+    // Not a SAM type; still no valid abstract methods
+    interface Foo5 {
+        boolean equals(Object object);
+        String toString();
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo6<T> {
+        boolean equals(Object obj);
+        int compare(T o1, T o2);
+    }
+
+    // SAM type; Foo6 has one abstract non-Object method
+    interface Foo7<T> extends Foo2, Foo6<T> { }
+
+    void test() {
+        Foo1 f1 = ()-> { };
+        Foo2 f2 = ()-> { };
+        Foo3 f3 = x -> true;
+        Foo4 f4 = (x, y) -> 1;
+        Foo5 f5 = x -> true;
+        Foo6 f6 = (x, y) -> 1;
+        Foo7 f7 = (x, y) -> 1;
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv09.out b/test/tools/javac/lambda/LambdaConv09.out
new file mode 100644
index 0000000..5265879
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv09.out
@@ -0,0 +1,5 @@
+LambdaConv09.java:42:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: LambdaConv09.Foo1, (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo1))
+LambdaConv09.java:43:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: LambdaConv09.Foo2, (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo2))
+LambdaConv09.java:44:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: LambdaConv09.Foo3, (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo3))
+LambdaConv09.java:46:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: LambdaConv09.Foo5, (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo5))
+4 errors
diff --git a/test/tools/javac/lambda/LambdaConv10.java b/test/tools/javac/lambda/LambdaConv10.java
new file mode 100644
index 0000000..cc11f96
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv10.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda conversion does not allow boxing of lambda parameters
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaConv10.out -XDrawDiagnostics LambdaConv10.java
+ */
+
+class LambdaConv10 {
+
+    interface Method1<R, A1> { public R call( A1 a1 ); }
+
+    public static void main( final String... notUsed ) {
+        Method1<Integer,Integer> m1 = (int i) -> 2 * i;
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv10.out b/test/tools/javac/lambda/LambdaConv10.out
new file mode 100644
index 0000000..0f58e5e
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv10.out
@@ -0,0 +1,2 @@
+LambdaConv10.java:15:39: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
diff --git a/test/tools/javac/lambda/LambdaConv11.java b/test/tools/javac/lambda/LambdaConv11.java
new file mode 100644
index 0000000..f696014
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv11.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  issues with lambda conversion involving generic class hierarchies
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv11.java
+ */
+
+import java.util.Comparator;
+
+class LambdaConv11<T> {
+
+    interface SAM<X> extends Comparator<X> {
+        public int compare(X left, X right);
+    }
+
+    SAM<T> y = (l, r) -> 0;
+}
diff --git a/test/tools/javac/lambda/LambdaConv12.java b/test/tools/javac/lambda/LambdaConv12.java
new file mode 100644
index 0000000..59ef7ca
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv12.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  instance creation expression should allow lambda expressions as constrcutor arguments
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv12.java
+ */
+
+class LambdaConv12 {
+
+    LambdaConv12(SAM s) {}
+
+    interface SAM {
+        public abstract void m();
+    }
+
+    void test() {
+        new LambdaConv12(()-> { });
+        new LambdaConv12(()-> { }) {};
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv13.java b/test/tools/javac/lambda/LambdaConv13.java
new file mode 100644
index 0000000..326609a
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv13.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  interface methods in diamond shaped inheritance trees shouldn't be counted twice
+ * @author  Maurizio Cimadamore
+ * @compile LambdaConv13.java
+ */
+
+class LambdaConv13 {
+
+    interface I {
+        void m();
+    }
+
+    interface A extends I {}
+    interface B extends I {}
+    interface C extends A, B {}
+    interface D extends A, I {}
+    interface E extends B, I {}
+
+    C c = ()-> { };
+    D d = ()-> { };
+    D e = ()-> { };
+}
diff --git a/test/tools/javac/lambda/LambdaConv16.java b/test/tools/javac/lambda/LambdaConv16.java
new file mode 100644
index 0000000..04c3059
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv16.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  SAM conversion and raw types in argument/return types
+ * @author  Maurizio Cimadamore
+ * @run main LambdaConv16
+ */
+
+import java.util.*;
+
+public class LambdaConv16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        Iterable m(List<String> ls);
+    }
+
+    interface B {
+        Iterable<String> m(List l);
+    }
+
+    interface AB extends A, B {} //SAM type ([List], Iterable<String>, {})
+
+    static void test(AB ab, List l) { ab.m(l); }
+
+    public static void main(String[] args) {
+        AB ab = (List list) -> { assertTrue(true); return new ArrayList<String>(); };
+        ab.m(null);
+        test((List list) -> { assertTrue(true); return new ArrayList<String>(); }, null);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv17.java b/test/tools/javac/lambda/LambdaConv17.java
new file mode 100644
index 0000000..7cf9371
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv17.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  lambda compiler crashes if lambda has try-with-resources
+ * @compile LambdaConv17.java
+ */
+
+class LambdaConv17 {
+    interface SAM {
+       void m() throws Exception;
+    }
+
+    SAM s = ()-> { try (AutoCloseable ac = null){ } };
+}
diff --git a/test/tools/javac/lambda/LambdaConv18.java b/test/tools/javac/lambda/LambdaConv18.java
new file mode 100644
index 0000000..279d99f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv18.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  simple test for lambda candidate check
+ * @compile/fail/ref=LambdaConv18.out -XDrawDiagnostics -XDidentifyLambdaCandidate=true LambdaConv18.java
+ */
+
+class LambdaConv18 {
+
+    interface SAM {
+        void m();
+    }
+
+    interface NonSAM {
+        void m1();
+        void m2();
+    }
+
+    SAM s1 = new SAM() { public void m() {} };
+    NonSAM s2 = new NonSAM() { public void m1() {}
+                              public void m2() {} };
+    NonExistent s3 = new NonExistent() { public void m() {} };
+}
diff --git a/test/tools/javac/lambda/LambdaConv18.out b/test/tools/javac/lambda/LambdaConv18.out
new file mode 100644
index 0000000..fa84e6b
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv18.out
@@ -0,0 +1,4 @@
+LambdaConv18.java:23:5: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+LambdaConv18.java:20:24: compiler.note.potential.lambda.found
+LambdaConv18.java:23:26: compiler.err.cant.resolve.location: kindname.class, NonExistent, , , (compiler.misc.location: kindname.class, LambdaConv18, null)
+2 errors
diff --git a/test/tools/javac/lambda/LambdaConv19.java b/test/tools/javac/lambda/LambdaConv19.java
new file mode 100644
index 0000000..4ba76e6
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv19.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that redundant cast warnings are not generated for SAM conversions
+ * @compile -Xlint:cast -Werror LambdaConv19.java
+ */
+
+class LambdaConv19 {
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s = (SAM)()-> { };
+}
diff --git a/test/tools/javac/lambda/LambdaConv20.java b/test/tools/javac/lambda/LambdaConv20.java
new file mode 100644
index 0000000..4a9e9c3
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv20.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts are added when erased type of lambda body
+ *          ends up being too general
+ * @run main LambdaConv20
+ */
+
+import java.util.*;
+
+public class LambdaConv20 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m(List<X> l);
+    }
+
+    public static void main(String[] args) {
+        SAM<Integer> si1 = l -> l.get(0);
+        assertTrue(si1.m(Arrays.asList(1)) == 1);
+        SAM<Integer> si2 = l -> { return l.get(0); };
+        assertTrue(si2.m(Arrays.asList(1)) == 1);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv21.java b/test/tools/javac/lambda/LambdaConv21.java
new file mode 100644
index 0000000..d4ac403
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv21.java
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @compile/fail/ref=LambdaConv21.out -XDrawDiagnostics LambdaConv21.java
+ */
+
+class LambdaConv21 {
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void {
+        Void m();
+    }
+
+    static void m_void() { }
+
+    static Void m_java_lang_Void() { return null; }
+
+    static void testExpressionLambda() {
+        SAM_void s1 = ()->m_void(); //ok
+        SAM_java_lang_Void s2 = ()->m_void(); //no - incompatible target
+        SAM_void s3 = ()->m_java_lang_Void(); //ok - expression statement lambda is compatible with void
+        SAM_java_lang_Void s4 = ()->m_java_lang_Void(); //ok
+    }
+
+    static void testStatementLambda() {
+        SAM_void s1 = ()-> { m_void(); }; //ok
+        SAM_java_lang_Void s2 = ()-> { m_void(); }; //no - missing return value
+        SAM_void s3 = ()-> { return m_java_lang_Void(); }; //no - unexpected return value
+        SAM_java_lang_Void s4 = ()-> { return m_java_lang_Void(); }; //ok
+        SAM_void s5 = ()-> { m_java_lang_Void(); }; //ok
+        SAM_java_lang_Void s6 = ()-> { m_java_lang_Void(); }; //no - missing return value
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv21.out b/test/tools/javac/lambda/LambdaConv21.out
new file mode 100644
index 0000000..9976d9c
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv21.out
@@ -0,0 +1,5 @@
+LambdaConv21.java:25:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void))
+LambdaConv21.java:32:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+LambdaConv21.java:33:53: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))
+LambdaConv21.java:36:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+4 errors
diff --git a/test/tools/javac/lambda/LambdaConv22.java b/test/tools/javac/lambda/LambdaConv22.java
new file mode 100644
index 0000000..0ef1a9f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv22.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  inner class translator fails with spurious method clash errors
+ * @compile LambdaConv22.java
+ */
+
+class LambdaConv22<U> {
+
+    interface Factory<T> { T make(); }
+
+    U make() { return null; }
+
+    void test(U u) {
+        Factory<U> fu1 = () -> u;
+        Factory<U> fu2 = this::make;
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv23.java b/test/tools/javac/lambda/LambdaConv23.java
new file mode 100644
index 0000000..a4197cc
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv23.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check super varargs reference is handled correctly
+ * @run main LambdaConv23
+ */
+public class LambdaConv23 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { void m(Integer a, Integer b); }
+
+    static class Super {
+        void m(Object... vi) { assertTrue(true); }
+    }
+
+
+    static class Sub extends Super {
+
+        void m(Object... vi) { assertTrue(false); }
+
+        public void test() {
+            SAM q = super::m;
+            q.m(1, 2);
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv24.java b/test/tools/javac/lambda/LambdaConv24.java
new file mode 100644
index 0000000..4ddb049
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv24.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda inside 'this' call is handled properly
+ * @run main LambdaConv24
+ */
+public class LambdaConv24 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    LambdaConv24(SAM<String> p) {
+        assertTrue(p.m("42"));
+    }
+
+    LambdaConv24(int i) {
+        this(s->true);
+    }
+
+    LambdaConv24(int i1, int i2) {
+        this(LambdaConv24::m);
+    }
+
+    static boolean m(String s) { return true; }
+
+    public static void main(String[] args) {
+        new LambdaConv24(1);
+        new LambdaConv24(1,2);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv25.java b/test/tools/javac/lambda/LambdaConv25.java
new file mode 100644
index 0000000..bde154c
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv25.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary check that merged inherited descriptors preservers type-parameters
+ * @compile/fail/ref=LambdaConv25.out -XDrawDiagnostics LambdaConv25.java
+ */
+class LambdaConv25 {
+
+    interface A {
+        <X> void m();
+    }
+
+    interface B {
+        <X> void m();
+    }
+
+    interface C extends A, B { }
+
+    void test() {
+        C c = ()->{}; //should fail
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv25.out b/test/tools/javac/lambda/LambdaConv25.out
new file mode 100644
index 0000000..8f544da
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv25.out
@@ -0,0 +1,2 @@
+LambdaConv25.java:19:15: compiler.err.prob.found.req: (compiler.misc.invalid.generic.lambda.target: <X>()void, kindname.interface, LambdaConv25.C)
+1 error
diff --git a/test/tools/javac/lambda/LambdaConv26.java b/test/tools/javac/lambda/LambdaConv26.java
new file mode 100644
index 0000000..12833fb
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv26.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8006749
+ * @summary compiler does not allow Object protected methods to be used in lambda
+ * @compile LambdaConv26.java
+ */
+public class LambdaConv26 {
+    interface I {
+        Object clone();
+    }
+
+    Object m() { return null; }
+
+    void test() {
+        I i1 = ()->null;
+        I i2 = this::m;
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaConv27.java b/test/tools/javac/lambda/LambdaConv27.java
new file mode 100644
index 0000000..5bf3d57
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaConv27.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8008227
+ * @summary Mixing lambdas with anonymous classes leads to NPE thrown by compiler
+ * @run main LambdaConv27
+ */
+public class LambdaConv27 {
+
+     public static void main(String[] args) {
+         SAM s = ()-> { SAM s2 = ()->{ new Object() { }; }; s2.m(); };
+         s.m();
+     }
+
+     interface SAM {
+         void m();
+     }
+}
diff --git a/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java
new file mode 100644
index 0000000..944d554
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java
@@ -0,0 +1,60 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Integrate efectively final check with DA/DU analysis
+ * @compile/fail/ref=LambdaEffectivelyFinalTest.out -XDrawDiagnostics LambdaEffectivelyFinalTest.java
+ */
+class LambdaEffectivelyFinalTest {
+
+    interface SAM {
+        int m();
+    }
+
+    void foo(LambdaEffectivelyFinalTest.SAM s) { }
+
+    void m1(int x) {
+        int y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m2(int x) {
+        int y;
+        y = 1;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m3(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        foo(() -> x+y); // Illegal: y is effectively final, but not definitely assigned.
+    }
+
+    void m4(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        else y = 2;
+        foo(() -> x+y); // Legal: x and y are both effectively final.
+    }
+
+    void m5(int x, boolean cond) {
+        int y;
+        if (cond) y = 1;
+        y = 2;
+        foo(() -> x+y); // Illegal: y is not effectively final.t EF
+    }
+
+    void m6(int x) {
+        foo(() -> x+1);
+        x++; // Illegal: x is not effectively final.
+    }
+
+    void m7(int x) {
+        foo(() -> x=1); // Illegal: x in the assignment does not denote a variable (see 6.5.6.1)
+    }
+
+    void m8() {
+        int y;
+        foo(() -> y=1); // Illegal: y in the assignment does not denote a variable (see 6.5.6.1)
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out
new file mode 100644
index 0000000..8291f3b
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out
@@ -0,0 +1,6 @@
+LambdaEffectivelyFinalTest.java:30:21: compiler.err.var.might.not.have.been.initialized: y
+LambdaEffectivelyFinalTest.java:44:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:48:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:53:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:58:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+5 errors
diff --git a/test/tools/javac/lambda/LambdaExpr01.java b/test/tools/javac/lambda/LambdaExpr01.java
new file mode 100644
index 0000000..d0960c9
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr01.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> 3;
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> 3;
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x)-> x+1;
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x)-> x+1;
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> x.intValue() + 1;
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr01().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr02.java b/test/tools/javac/lambda/LambdaExpr02.java
new file mode 100644
index 0000000..d2fb358
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr02.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for simple lambda expressions in multiple scopes
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaExpr01
+ */
+
+public class LambdaExpr02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S_int {
+        int m();
+    }
+
+    interface S_Integer {
+        Integer m();
+    }
+
+    interface S_int_int {
+        int m(int i);
+    }
+
+    interface S_Integer_int {
+        int m(Integer i);
+    }
+
+    interface S_int_Integer {
+        Integer m(int i);
+    }
+
+    interface S_Integer_Integer {
+        Integer m(Integer i);
+    }
+
+    static {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    static void test1() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    void test2() {
+        S_int s_i = ()-> { return 3; };
+        assertTrue(3 == s_i.m());
+        S_Integer s_I = ()-> { return 3; };
+        assertTrue(3 == s_I.m());
+        S_int_int s_i_i = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_i.m(3));
+        S_int_Integer s_i_I = (int x) -> { return x + 1; };
+        assertTrue(4 == s_i_I.m(3));
+        S_Integer_int s_I_i = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_i.m(3));
+        S_Integer_Integer s_I_I = (Integer x) -> { return x.intValue() + 1; };
+        assertTrue(4 == s_I_I.m(3));
+    }
+
+    public static void main(String[] args) {
+        test1();
+        new LambdaExpr02().test2();
+        assertTrue(assertionCount == 24);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr04.java b/test/tools/javac/lambda/LambdaExpr04.java
new file mode 100644
index 0000000..eadf826
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr04.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda initializers compile w/o problems
+ * @author Jan Lahoda
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr04.java
+ */
+
+class LambdaExpr04 {
+
+    interface SAM {
+        void m(int i);
+    }
+    static SAM lambda_01 = (int pos) -> { };
+
+    static final SAM lambda_02 = (int pos) -> { };
+
+    SAM lambda_03 = (int pos) -> { };
+
+    final SAM lambda_04 = (int pos) -> { };
+}
diff --git a/test/tools/javac/lambda/LambdaExpr05.java b/test/tools/javac/lambda/LambdaExpr05.java
new file mode 100644
index 0000000..db0348f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr05.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that binary expression in lambda expression is parsed correctly
+ * @author  Maurizio Cimadamore
+ * @compile LambdaExpr05.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { int foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
diff --git a/test/tools/javac/lambda/LambdaExpr06.java b/test/tools/javac/lambda/LambdaExpr06.java
new file mode 100644
index 0000000..71d47ca
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr06.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  parser test for nested parenthesized lambda expression
+ * @run main LambdaExpr06
+ */
+
+public class LambdaExpr06 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int dup(int i);
+    }
+
+    public static void main(String[] args) {
+        A a = ()-> ((B)i -> i * 2).dup(3);
+        assertTrue(a.m() == 6);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr07.java b/test/tools/javac/lambda/LambdaExpr07.java
new file mode 100644
index 0000000..2ea0f75
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr07.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check access to effectively final local variable from doubly nested lambda
+ * @run main LambdaExpr07
+ */
+
+public class LambdaExpr07 {
+
+    interface Block<A, R> {
+        R apply(A x);
+    }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String S = "A";
+
+    void test() {
+        Block<String, Block<String, String>> o = s1 -> s2 -> S + s1 + s2;
+        assertTrue(o.apply("B").apply("C").equals("ABC"));
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr07().test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr08.java b/test/tools/javac/lambda/LambdaExpr08.java
new file mode 100644
index 0000000..bb48c3e
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr08.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that reference to local final variable w/o initializer is accepted
+ * @compile LambdaExpr08.java
+ */
+
+class LambdaExpr08 {
+
+    interface SAM {
+       String m();
+    }
+
+    void test() {
+        final String s;
+        s = "";
+        SAM sam = () -> s;
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr09.java b/test/tools/javac/lambda/LambdaExpr09.java
new file mode 100644
index 0000000..e42e298
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr09.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers is correctly accepted
+ * @compile LambdaExpr09.java
+ */
+
+class LambdaExpr09 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Block<?>[] arr1 =  { t -> { }, t -> { } };
+        Block<?>[][] arr2 =  { { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test2() {
+        Block<?>[] arr1 =  new Block<?>[]{ t -> { }, t -> { } };
+        Block<?>[][] arr2 =  new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } };
+    }
+
+    void test3() {
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+        apply(new Block<?>[][]{ { t -> { }, t -> { } }, { t -> { }, t -> { } } });
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr10.java b/test/tools/javac/lambda/LambdaExpr10.java
new file mode 100644
index 0000000..299582a
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr10.java
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda in array initializers (with wrong type) are correctly rejected
+ * @compile/fail/ref=LambdaExpr10.out -XDrawDiagnostics LambdaExpr10.java
+ */
+
+class LambdaExpr10 {
+
+    interface Block<T> {
+       void m(T t);
+    }
+
+    void apply(Object[] obj_arr) { }
+
+    void test1() {
+        Object[] arr1 =  { t -> { } };
+        Object[][] arr2 =  { { t -> { } } };
+    }
+
+    void test2() {
+        Object[] arr1 =  new Object[]{ t -> { } };
+        Object[][] arr2 =  new Object[][]{ { t -> { } } };
+    }
+
+    void test3() {
+        apply(new Object[]{ t -> { } });
+        apply(new Object[][]{ { t -> { } } });
+    }
+
+    void test4() {
+        Block<?>[] arr1 =  { t -> t };
+        Block<?>[] arr2 =  new Block<?>[]{ t -> t };
+        apply(new Block<?>[]{ t -> { }, t -> { } });
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr10.out b/test/tools/javac/lambda/LambdaExpr10.out
new file mode 100644
index 0000000..9270b14
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr10.out
@@ -0,0 +1,9 @@
+LambdaExpr10.java:18:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:19:32: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:23:40: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:24:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:28:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:29:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+LambdaExpr10.java:33:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+8 errors
diff --git a/test/tools/javac/lambda/LambdaExpr11.java b/test/tools/javac/lambda/LambdaExpr11.java
new file mode 100644
index 0000000..81e69b3
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr11.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr11
+ */
+public class LambdaExpr11 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Inner {
+        Inner() { assertTrue(true); }
+    }
+
+    void test() {
+        Runnable r1 = ()-> { new Inner(); };
+        r1.run();
+        Runnable r2 = ()-> { new Inner() {}; };
+        r2.run();
+        Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+        r3.run();
+        Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+        r4.run();
+        new Inner2().test();
+    }
+
+    class Inner2 {
+        void test() {
+            Runnable r1 = ()-> { new Inner(); };
+            r1.run();
+            Runnable r2 = ()-> { new Inner() {}; };
+            r2.run();
+            Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+            r3.run();
+            Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+            r4.run();
+            new Inner3().test();
+        }
+
+        class Inner3 {
+            void test() {
+                Runnable r1 = ()-> { new Inner(); };
+                r1.run();
+                Runnable r2 = ()-> { new Inner() {}; };
+                r2.run();
+                Runnable r3 = ()-> { class SubInner extends Inner {}; new SubInner(); };
+                r3.run();
+                Runnable r4 = ()-> { class SubInner extends Inner {}; new SubInner() {}; };
+                r4.run();
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr11().test();
+        assertTrue(assertionCount == 12);
+    }
+}
+
diff --git a/test/tools/javac/lambda/LambdaExpr12.java b/test/tools/javac/lambda/LambdaExpr12.java
new file mode 100644
index 0000000..5fe2713
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr12.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that creating an inner class from a lambda does add a captured this
+ * @run main LambdaExpr12
+ */
+
+public class LambdaExpr12 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Getter<X> {
+        X get();
+    }
+
+
+    interface Mapper<X,Y> {
+        Y map(X x);
+    }
+
+    void test() {
+        Mapper<String, Getter<Character>> mapper =
+                (final String s) -> new Getter<Character>() {
+                     @Override
+                     public Character get() {
+                         return s.charAt(0);
+                     }
+                };
+        assertTrue(mapper.map("First").get() == 'F');
+    }
+
+    public static void main(String[] args) {
+        new LambdaExpr12().test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr13.java b/test/tools/javac/lambda/LambdaExpr13.java
new file mode 100644
index 0000000..7a5181e
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr13.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that recursive lambda (through field ref) is accepted in all contexts
+ * @compile LambdaExpr13.java
+ */
+
+class LambdaExpr13 {
+
+    Runnable ir = () -> { ir.run(); };;
+    static Runnable sr = () -> { sr.run(); };
+
+    { ir = () -> { ir.run(); }; }
+    static { sr = () -> { sr.run(); }; }
+
+    static void m1() {
+        sr = () -> { sr.run(); };
+    }
+
+    void m2() {
+        ir = () -> { ir.run(); };
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr14.java b/test/tools/javac/lambda/LambdaExpr14.java
new file mode 100644
index 0000000..e729093
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr14.java
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that recursion from doubly nested lambda is handled correctly
+ */
+
+public class LambdaExpr14 {
+
+    interface SAM {
+       SAM invoke();
+    }
+
+    static SAM local;
+
+    public static void main(String[] args) {
+        local = () -> () -> local.invoke();
+        local.invoke().invoke(); // Not a recursive lambda - exec should terminate
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr15.java b/test/tools/javac/lambda/LambdaExpr15.java
new file mode 100644
index 0000000..af00ee5
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr15.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that nested inner class in statement lambdas don't get corrupted return statements
+ * @run main LambdaExpr15
+ */
+public class LambdaExpr15 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Block<T> {
+       void apply(T t);
+    }
+
+    public static void main(String[] args) {
+        //anon class
+        Block<Object> ba1 = t -> {
+            new Object() {
+                String get() { return ""; }
+            };
+            assertTrue((Integer)t == 1);
+        };
+        ba1.apply(1);
+
+        //local class
+        Block<Object> ba2 = t -> {
+            class A {
+                String get() { return ""; }
+            };
+            new A();
+            assertTrue((Integer)t == 2);
+        };
+        ba2.apply(2);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr16.java b/test/tools/javac/lambda/LambdaExpr16.java
new file mode 100644
index 0000000..7d2200c
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr16.java
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that super inside lambda is handled correctly
+ * @run main LambdaExpr16
+ */
+public class LambdaExpr16 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A { void m(); }
+
+    static class Sup {
+       void m() {
+          assertTrue(true);
+       }
+    }
+
+    static class Sub extends Sup {
+        void testLambda1() {
+            A a = ()->{ super.m(); };
+            a.m();
+        }
+        void testLambda2() {
+            A a = () -> { A a1 = () -> { super.m(); }; a1.m(); };
+            a.m();
+        }
+        void testRef1() {
+            A a = () -> { A a1 = super::m; a1.m(); };
+            a.m();
+        }
+        void testRef2() {
+            A a = () -> { A a1 = () -> { A a2 = super::m; a2.m(); }; a1.m(); };
+            a.m();
+        }
+    }
+
+   public static void main(String[] args) {
+      Sub s = new Sub();
+      s.testLambda1();
+      s.testLambda2();
+      s.testRef1();
+      s.testRef2();
+      assertTrue(assertionCount == 4);
+   }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr17.java b/test/tools/javac/lambda/LambdaExpr17.java
new file mode 100644
index 0000000..3be3a64
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr17.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that super in argument position inside lambda is handled correctly
+ * @run main LambdaExpr17
+ */
+public class LambdaExpr17 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static class Sup {
+        protected String m() {
+            assertTrue(true);
+            return "Hello!";
+        }
+    }
+
+    static class Sub extends Sup {
+        void test() {
+            SAM s = () -> { System.out.println(super.m()); };
+            s.m();
+        }
+    }
+
+    public static void main(String[] args) {
+        new Sub().test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr18.java b/test/tools/javac/lambda/LambdaExpr18.java
new file mode 100644
index 0000000..fee12b6
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr18.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that synthetic casts from outer environment are not inserted twice
+ * @run main LambdaExpr18
+ */
+public class LambdaExpr18 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<R> {
+        R eval();
+    }
+
+    static void test(){
+        SAM<Integer> sam1 = () -> {
+            assertTrue(true);
+            SAM<String> sam2 = () -> {
+                assertTrue(true);
+                return "";
+            };
+            sam2.eval();
+            return 1;
+        };
+        sam1.eval();
+    }
+
+    public static void main(String[] args) {
+        test();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr19.java b/test/tools/javac/lambda/LambdaExpr19.java
new file mode 100644
index 0000000..1a1ba3d
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr19.java
@@ -0,0 +1,53 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that inner scopes are left after a lambda check exception has been thrown
+ * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
+ */
+class LambdaExpr19 {
+
+    interface SAM {
+        String m();
+    }
+
+    void m(SAM s) { }
+
+    void testTry() {
+        m(() -> {
+                try { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testTryWithResources() {
+        m(() -> {
+                try (AutoCloseable c = null) { return 1; }
+                catch (Exception e) { }
+            });
+    }
+
+    void testSwitch() {
+        m(() -> {
+                switch (1) {
+                    default: return 1;
+                }
+            });
+    }
+
+    void testFor() {
+        m(() -> {
+                for (;;) {
+                    return 1;
+                }
+            });
+    }
+
+    void testForeach() {
+        m(() -> {
+                for (Object o : new Object[] { null , null }) {
+                    return 1;
+                }
+            });
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr19.out b/test/tools/javac/lambda/LambdaExpr19.out
new file mode 100644
index 0000000..7b5a94f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr19.out
@@ -0,0 +1,6 @@
+LambdaExpr19.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @363, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:24:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @512, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:31:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @676, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @824, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:47:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @965, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+5 errors
diff --git a/test/tools/javac/lambda/LambdaExpr20.java b/test/tools/javac/lambda/LambdaExpr20.java
new file mode 100644
index 0000000..21a464b
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr20.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that default super call from lambda expression is compiled successfully
+ * @compile LambdaExpr20.java
+ */
+
+class LambdaExpr20 {
+
+    interface K {
+        default void m() { }
+    }
+
+    static class Test implements K {
+        @Override
+        public void m() {
+            Runnable r = () -> { K.super.m(); };
+            r.run();
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExpr21.java b/test/tools/javac/lambda/LambdaExpr21.java
new file mode 100644
index 0000000..1d44e22
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExpr21.java
@@ -0,0 +1,67 @@
+/*
+ * 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 8006684
+ * @summary Compiler produces java.lang.VerifyError: Bad type on operand stack
+ * @run main LambdaExpr21
+ */
+public class LambdaExpr21 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void foo();
+    }
+
+    static class Checker {
+        Checker(boolean cond) {
+            assertTrue(cond);
+        }
+    }
+
+    static {
+        SAM s = ()-> { new Checker(true) { }; };
+        s.foo();
+    }
+
+    static void test(){
+        SAM s = ()-> { new Checker(true) { }; };
+        s.foo();
+    }
+
+    static SAM s = ()-> { new Checker(true) { }; };
+
+    public static void main(String[] args) {
+        test();
+        s.foo();
+        assertTrue(assertionCount == 3);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaExprNotVoid.java b/test/tools/javac/lambda/LambdaExprNotVoid.java
new file mode 100644
index 0000000..0d04119
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExprNotVoid.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression body (when not a block) cannot be void
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=LambdaExprNotVoid.out -XDlambdaInferenceDiags=false -XDrawDiagnostics LambdaExprNotVoid.java
+ */
+
+class LambdaExpr05 {
+
+    interface SAM { void foo(int i); }
+
+    SAM s1 = i -> i * 2;
+    SAM s2 = i -> 2 * i;
+}
diff --git a/test/tools/javac/lambda/LambdaExprNotVoid.out b/test/tools/javac/lambda/LambdaExprNotVoid.out
new file mode 100644
index 0000000..97b66c8
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaExprNotVoid.out
@@ -0,0 +1,3 @@
+LambdaExprNotVoid.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:15:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+2 errors
diff --git a/test/tools/javac/lambda/LambdaInnerTypeVarArgs.java b/test/tools/javac/lambda/LambdaInnerTypeVarArgs.java
new file mode 100644
index 0000000..1e5d7cd
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaInnerTypeVarArgs.java
@@ -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 8005653
+ * @summary A lambda containing an inner class referencing an external type var in class parameter type
+ * @author  Robert Field
+ * @run main LambdaInnerTypeVarArgs
+ */
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaInnerTypeVarArgs {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface I {
+        C doit();
+    }
+
+    abstract class C {
+        abstract Object it();
+    }
+
+    class TV {
+        C go() {
+            List<String> ls = new ArrayList<>();
+            ls.add("Oh");
+            ls.add("my");
+            return foo(ls).doit();
+        }
+
+        <RRRRR> I foo(List<RRRRR> r) {
+            return () -> new C() {
+                List<RRRRR> xxxxx = r;
+                @Override
+                    Object it() { return xxxxx; };
+            };
+        }
+    }
+
+    void test1() {
+        assertTrue(((List<String>)(new TV().go().it())).get(0).equals("Oh"));
+    }
+
+    public static void main(String[] args) {
+        LambdaInnerTypeVarArgs t = new LambdaInnerTypeVarArgs();
+        t.test1();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaInnerTypeVarArgsSerialize.java b/test/tools/javac/lambda/LambdaInnerTypeVarArgsSerialize.java
new file mode 100644
index 0000000..f75841f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaInnerTypeVarArgsSerialize.java
@@ -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 8005653
+ * @summary A serialized lambda containing an inner class referencing an external type var in class parameter type
+ * @author  Robert Field
+ * @run main LambdaInnerTypeVarArgsSerialize
+ */
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaInnerTypeVarArgsSerialize {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface I extends Serializable {
+        C doit();
+    }
+
+    abstract class C {
+        abstract Object it();
+    }
+
+    class TV {
+        C go() {
+            List<String> ls = new ArrayList<>();
+            ls.add("Oh");
+            ls.add("my");
+            return foo(ls).doit();
+        }
+
+        <RRRRR> I foo(List<RRRRR> r) {
+            return () -> new C() {
+                List<RRRRR> xxxxx = r;
+                @Override
+                    Object it() { return xxxxx; };
+            };
+        }
+    }
+
+    void test1() {
+        assertTrue(((List<String>)(new TV().go().it())).get(0).equals("Oh"));
+    }
+
+    public static void main(String[] args) {
+        LambdaInnerTypeVarArgsSerialize t = new LambdaInnerTypeVarArgsSerialize();
+        t.test1();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaInnerTypeVarReflect.java b/test/tools/javac/lambda/LambdaInnerTypeVarReflect.java
new file mode 100644
index 0000000..0a573a9
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaInnerTypeVarReflect.java
@@ -0,0 +1,86 @@
+/*
+ * 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 8005653
+ * @summary A lambda containing an inner class referencing an external type var
+ * @author  Robert Field
+ * @run main LambdaInnerTypeVarReflect
+ */
+
+import java.io.StringWriter;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+public class LambdaInnerTypeVarReflect {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface I {
+        C doit();
+    }
+
+    abstract class C {
+        abstract Object it();
+    }
+
+    class TV {
+        C go() {
+            return foo("Frump").doit();
+        }
+
+        <RRRRR> I foo(RRRRR r) {
+            return () -> new C() {
+                public RRRRR xxxxx = r;
+                @Override
+                    Object it() { return xxxxx; };
+            };
+        }
+    }
+
+    void test1() throws IOException {
+        char[] buffer = new char[1024];
+        String innerName = new TV().go().getClass().getName();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int exitCode = com.sun.tools.javap.Main.run(new String[] {innerName}, pw);
+        assertTrue(exitCode == 0);
+
+        String javapOut = sw.toString();
+        assertTrue(javapOut.contains(innerName));
+        assertTrue(!javapOut.contains("RRRRR"));
+    }
+
+    public static void main(String[] args) throws IOException {
+        LambdaInnerTypeVarReflect t = new LambdaInnerTypeVarReflect();
+        t.test1();
+        assertTrue(assertionCount == 3);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaInnerTypeVarSerialize.java b/test/tools/javac/lambda/LambdaInnerTypeVarSerialize.java
new file mode 100644
index 0000000..bbb2d22
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaInnerTypeVarSerialize.java
@@ -0,0 +1,75 @@
+/*
+ * 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 8005653
+ * @summary A serialized lambda containing an inner class referencing an external type var
+ * @author  Robert Field
+ * @run main LambdaInnerTypeVarSerialize
+ */
+
+import java.io.Serializable;
+
+public class LambdaInnerTypeVarSerialize {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface I extends Serializable {
+        C doit();
+    }
+
+    abstract class C {
+        abstract Object it();
+    }
+
+    class TV {
+        C go() {
+            return foo("Frump").doit();
+        }
+
+        <RRRRR> I foo(RRRRR r) {
+            return () -> new C() {
+                RRRRR xxxxx = r;
+                @Override
+                    Object it() { return xxxxx; };
+            };
+        }
+    }
+
+    void test1() {
+        assertTrue(new TV().go().it().equals("Frump"));
+    }
+
+    public static void main(String[] args) {
+        LambdaInnerTypeVarSerialize t = new LambdaInnerTypeVarSerialize();
+        t.test1();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaInterfaceStaticField.java b/test/tools/javac/lambda/LambdaInterfaceStaticField.java
new file mode 100644
index 0000000..5a8bf2e
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaInterfaceStaticField.java
@@ -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;
+}
diff --git a/test/tools/javac/lambda/LambdaLambdaSerialized.java b/test/tools/javac/lambda/LambdaLambdaSerialized.java
new file mode 100644
index 0000000..f788e8a
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaLambdaSerialized.java
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+/*
+ at test
+ at bug 8010010
+ at summary NPE generating serializedLambdaName for nested lambda
+*/
+
+import java.io.*;
+import java.util.Map;
+import java.util.HashMap;
+
+public class LambdaLambdaSerialized {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            // Write lambdas out
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutput out = new ObjectOutputStream(baos);
+            LSI<LSI<Map>> ssi = () -> (() -> new HashMap());
+            write(out, ssi );
+            out.flush();
+            out.close();
+
+            // Read them back
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(baos.toByteArray());
+            ObjectInputStream in = new ObjectInputStream(bais);
+            readAssert(in, "[X]");
+            in.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+    }
+
+    static void write(ObjectOutput out, LSI<LSI<Map>> lamb) throws IOException {
+        out.writeObject(lamb);
+    }
+
+    static void readAssert(ObjectInputStream in, String expected)  throws IOException, ClassNotFoundException {
+        LSI<LSI<Map>> ls = (LSI<LSI<Map>>) in.readObject();
+        Map result = ls.get().get();
+        System.out.printf("Result: %s\n", result);
+    }
+}
+
+interface LSI<T> extends Serializable {
+    T get();
+}
diff --git a/test/tools/javac/lambda/LambdaParserTest.java b/test/tools/javac/lambda/LambdaParserTest.java
new file mode 100644
index 0000000..ae62027
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaParserTest.java
@@ -0,0 +1,317 @@
+/*
+ * 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
+ * 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 7115050 8003280 8005852 8006694
+ * @summary Add lambda tests
+ *  Add parser support for lambda expressions
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm LambdaParserTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import com.sun.source.util.JavacTask;
+
+public class LambdaParserTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum LambdaKind {
+        NILARY_EXPR("()->x"),
+        NILARY_STMT("()->{ return x; }"),
+        ONEARY_SHORT_EXPR("#PN->x"),
+        ONEARY_SHORT_STMT("#PN->{ return x; }"),
+        ONEARY_EXPR("(#M1 #T1 #PN)->x"),
+        ONEARY_STMT("(#M1 #T1 #PN)->{ return x; }"),
+        TWOARY_EXPR("(#M1 #T1 #PN, #M2 #T2 y)->x"),
+        TWOARY_STMT("(#M1 #T1 #PN, #M2 #T2 y)->{ return x; }");
+
+        String lambdaTemplate;
+
+        LambdaKind(String lambdaTemplate) {
+            this.lambdaTemplate = lambdaTemplate;
+        }
+
+        String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+                ModifierKind mk1, ModifierKind mk2, LambdaParameterName pn) {
+            return lambdaTemplate.replaceAll("#M1", mk1.modifier)
+                    .replaceAll("#M2", mk2.modifier)
+                    .replaceAll("#T1", pk1.parameterType)
+                    .replaceAll("#T2", pk2.parameterType)
+                    .replaceAll("#PN", pn.nameStr);
+        }
+
+        int arity() {
+            switch (this) {
+                case NILARY_EXPR:
+                case NILARY_STMT: return 0;
+                case ONEARY_SHORT_EXPR:
+                case ONEARY_SHORT_STMT:
+                case ONEARY_EXPR:
+                case ONEARY_STMT: return 1;
+                case TWOARY_EXPR:
+                case TWOARY_STMT: return 2;
+                default: throw new AssertionError("Invalid lambda kind " + this);
+            }
+        }
+
+        boolean isShort() {
+            return this == ONEARY_SHORT_EXPR ||
+                    this == ONEARY_SHORT_STMT;
+        }
+    }
+
+    enum LambdaParameterName {
+        IDENT("x"),
+        UNDERSCORE("_");
+
+        String nameStr;
+
+        LambdaParameterName(String nameStr) {
+            this.nameStr = nameStr;
+        }
+    }
+
+    enum LambdaParameterKind {
+        IMPLICIT(""),
+        EXPLIICT_SIMPLE("A"),
+        EXPLIICT_SIMPLE_ARR1("A[]"),
+        EXPLIICT_SIMPLE_ARR2("A[][]"),
+        EXPLICIT_VARARGS("A..."),
+        EXPLICIT_GENERIC1("A<X>"),
+        EXPLICIT_GENERIC2("A<? extends X, ? super Y>"),
+        EXPLICIT_GENERIC2_VARARGS("A<? extends X, ? super Y>..."),
+        EXPLICIT_GENERIC2_ARR1("A<? extends X, ? super Y>[]"),
+        EXPLICIT_GENERIC2_ARR2("A<? extends X, ? super Y>[][]");
+
+        String parameterType;
+
+        LambdaParameterKind(String parameterType) {
+            this.parameterType = parameterType;
+        }
+
+        boolean explicit() {
+            return this != IMPLICIT;
+        }
+
+        boolean isVarargs() {
+            return this == EXPLICIT_VARARGS ||
+                    this == EXPLICIT_GENERIC2_VARARGS;
+        }
+    }
+
+    enum ModifierKind {
+        NONE(""),
+        FINAL("final"),
+        PUBLIC("public");
+
+        String modifier;
+
+        ModifierKind(String modifier) {
+            this.modifier = modifier;
+        }
+
+        boolean compatibleWith(LambdaParameterKind pk) {
+            switch (this) {
+                case PUBLIC: return false;
+                case FINAL: return pk != LambdaParameterKind.IMPLICIT;
+                case NONE: return true;
+                default: throw new AssertionError("Invalid modifier kind " + this);
+            }
+        }
+    }
+
+    enum ExprKind {
+        NONE("#L#S"),
+        SINGLE_PAREN1("(#L#S)"),
+        SINGLE_PAREN2("(#L)#S"),
+        DOUBLE_PAREN1("((#L#S))"),
+        DOUBLE_PAREN2("((#L)#S)"),
+        DOUBLE_PAREN3("((#L))#S");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+                ModifierKind mk1, ModifierKind mk2, LambdaKind lk, LambdaParameterName pn, SubExprKind sk) {
+            return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2, pn))
+                    .replaceAll("#S", sk.subExpression);
+        }
+    }
+
+    enum SubExprKind {
+        NONE(""),
+        SELECT_FIELD(".f"),
+        SELECT_METHOD(".f()"),
+        SELECT_NEW(".new Foo()"),
+        POSTINC("++"),
+        POSTDEC("--");
+
+        String subExpression;
+
+        SubExprKind(String subExpression) {
+            this.subExpression = subExpression;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (LambdaKind lk : LambdaKind.values()) {
+            for (LambdaParameterName pn : LambdaParameterName.values()) {
+                for (LambdaParameterKind pk1 : LambdaParameterKind.values()) {
+                    if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT)
+                        continue;
+                    for (LambdaParameterKind pk2 : LambdaParameterKind.values()) {
+                        if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT)
+                            continue;
+                        for (ModifierKind mk1 : ModifierKind.values()) {
+                            if (mk1 != ModifierKind.NONE && lk.isShort())
+                                continue;
+                            if (lk.arity() < 1 && mk1 != ModifierKind.NONE)
+                                continue;
+                            for (ModifierKind mk2 : ModifierKind.values()) {
+                                if (lk.arity() < 2 && mk2 != ModifierKind.NONE)
+                                    continue;
+                                for (SubExprKind sk : SubExprKind.values()) {
+                                    for (ExprKind ek : ExprKind.values()) {
+                                        pool.execute(
+                                            new LambdaParserTest(pk1, pk2, mk1,
+                                                                 mk2, lk, sk, ek, pn));
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    LambdaParameterKind pk1;
+    LambdaParameterKind pk2;
+    ModifierKind mk1;
+    ModifierKind mk2;
+    LambdaKind lk;
+    LambdaParameterName pn;
+    SubExprKind sk;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2,
+            ModifierKind mk1, ModifierKind mk2, LambdaKind lk,
+            SubExprKind sk, ExprKind ek, LambdaParameterName pn) {
+        this.pk1 = pk1;
+        this.pk2 = pk2;
+        this.mk1 = mk1;
+        this.mk2 = mk2;
+        this.lk = lk;
+        this.pn = pn;
+        this.sk = sk;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E",
+                    ek.expressionString(pk1, pk2, mk1, mk2, lk, pn, sk));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            processException(ex);
+            return;
+        }
+        check();
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) ||
+                (lk.arity() > 1 && !mk2.compatibleWith(pk2));
+
+        if (lk.arity() == 2 &&
+                (pk1.explicit() != pk2.explicit() ||
+                pk1.isVarargs())) {
+            errorExpected = true;
+        }
+
+        errorExpected |= pn == LambdaParameterName.UNDERSCORE &&
+                lk.arity() > 0;
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/LambdaScope01.java b/test/tools/javac/lambda/LambdaScope01.java
new file mode 100644
index 0000000..ab8afe3
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope01.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope01
+ */
+
+public class LambdaScope01 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface TU<T, U> {
+        public T foo(U u);
+    }
+
+    public static <T, U> T exec(TU<T, U> lambda, U x) {
+        return lambda.foo(x);
+    }
+
+    public int n = 5;
+
+    public int hashCode() {
+        throw new RuntimeException();
+    }
+
+    public void test1() {
+        try {
+            int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x * hashCode(), 3);
+        }
+        catch (RuntimeException e) {
+            assertTrue(true); //should throw
+        }
+    }
+
+    public void test2() {
+        final int n = 10;
+        int res = LambdaScope01.<Integer,Integer>exec((Integer x) -> x + n, 3);
+        assertTrue(13 == res);
+    }
+
+    public static void main(String[] args) {
+        LambdaScope01 t = new LambdaScope01();
+        t.test1();
+        t.test2();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaScope02.java b/test/tools/javac/lambda/LambdaScope02.java
new file mode 100644
index 0000000..0ab28a3
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope02.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that Object members are accessible as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope02
+ */
+
+public class LambdaScope02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    @Override
+    public String toString() {
+        return "Callable1";
+    }
+
+    interface Callable {
+        void call();
+    }
+
+    static void call(Callable c) { c.call(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope02.this.toString().equals("Callable1")); });
+        call(()-> { assertTrue(toString().equals("Callable1")); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope02().test();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaScope03.java b/test/tools/javac/lambda/LambdaScope03.java
new file mode 100644
index 0000000..16b9db0
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope03.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that unqualified Object members are accessed as expected
+ * @author  Maurizio Cimadamore
+ * @run main LambdaScope03
+ */
+
+public class LambdaScope03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void call(SAM s) { s.m(); }
+
+    void test() {
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.getClass().equals(this.getClass())); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.hashCode() == this.hashCode()); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.toString().equals(this.toString())); });
+        call(()-> { assertTrue(LambdaScope03.this.equals(this)); });
+        call(()-> { assertTrue(equals(LambdaScope03.this)); });
+    }
+
+    public static void main(String[] args) {
+        new LambdaScope03().test();
+        assertTrue(assertionCount == 8);
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaScope04.java b/test/tools/javac/lambda/LambdaScope04.java
new file mode 100644
index 0000000..a2ebc6f
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope04.java
@@ -0,0 +1,163 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda cannot shadow variables from enclosing scope
+ * @compile/fail/ref=LambdaScope04.out -XDrawDiagnostics LambdaScope04.java
+ */
+
+class LambdaScope04 {
+
+    interface SAM {
+        void m(Object o);
+    }
+
+    static SAM field1 = field1->{}; //ok
+    static SAM field2 = param->{ Object field2 = null; }; //ok
+
+    SAM field3 = field3->{}; //ok
+    SAM field4 = param->{ Object field4 = null; }; //ok
+
+    {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+    }
+
+    static {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testLocalInstance() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testLocalStatic() {
+        Object local = null;
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testParamInstance(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    static void testParamStatic(Object local) {
+        SAM s1 = local->{}; //error
+        SAM s2 = param->{ Object local = null; }; //error
+        SAM s3 = field1->{ Object field_2 = null; }; //ok
+    }
+
+    void testForInstance() {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForStatic(Iterable<Object> elems) {
+        for (int local = 0; local != 0 ; local++) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testForEachInstance(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testForEachStatic(Iterable<Object> elems) {
+        for (Object local : elems) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testCatchInstance() {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testCatchStatic(Iterable<Object> elems) {
+        try { } catch (Throwable local) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testTWRInstance(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    static void testTWRStatic(AutoCloseable res) {
+        try (AutoCloseable local = res) {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        } finally { }
+    }
+
+    void testBlockLocalInstance() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    static void testBlockLocalStatic() {
+        Object local = null;
+        {
+            SAM s1 = local->{}; //error
+            SAM s2 = param->{ Object local = null; }; //error
+            SAM s3 = field1->{ Object field_2 = null; }; //ok
+        }
+    }
+
+    void testSwitchLocalInstance(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+
+    static void testSwitchLocalStatic(int i) {
+        switch (i) {
+            case 0: Object local = null;
+            default: {
+                SAM s1 = local->{}; //error
+                SAM s2 = param->{ Object local = null; }; //error
+                SAM s3 = field1->{ Object field_2 = null; }; //ok
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaScope04.out b/test/tools/javac/lambda/LambdaScope04.out
new file mode 100644
index 0000000..8cb2e2a
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope04.out
@@ -0,0 +1,37 @@
+LambdaScope04.java:23:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:24:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.instance.init, kindname.class, LambdaScope04
+LambdaScope04.java:29:18: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:30:34: compiler.err.already.defined.in.clinit: kindname.variable, local, kindname.static.init, kindname.class, LambdaScope04
+LambdaScope04.java:36:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:37:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalInstance()
+LambdaScope04.java:43:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:44:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testLocalStatic()
+LambdaScope04.java:49:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:50:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamInstance(java.lang.Object)
+LambdaScope04.java:55:18: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:56:34: compiler.err.already.defined: kindname.variable, local, kindname.method, testParamStatic(java.lang.Object)
+LambdaScope04.java:62:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:63:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForInstance()
+LambdaScope04.java:70:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:71:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:78:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:79:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachInstance(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:86:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:87:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testForEachStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:94:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:95:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchInstance()
+LambdaScope04.java:102:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:103:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testCatchStatic(java.lang.Iterable<java.lang.Object>)
+LambdaScope04.java:110:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:111:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRInstance(java.lang.AutoCloseable)
+LambdaScope04.java:118:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:119:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testTWRStatic(java.lang.AutoCloseable)
+LambdaScope04.java:127:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:128:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalInstance()
+LambdaScope04.java:136:22: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:137:38: compiler.err.already.defined: kindname.variable, local, kindname.method, testBlockLocalStatic()
+LambdaScope04.java:146:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:147:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalInstance(int)
+LambdaScope04.java:157:26: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+LambdaScope04.java:158:42: compiler.err.already.defined: kindname.variable, local, kindname.method, testSwitchLocalStatic(int)
+36 errors
diff --git a/test/tools/javac/lambda/LambdaScope05.java b/test/tools/javac/lambda/LambdaScope05.java
new file mode 100644
index 0000000..0fbb4a2
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope05.java
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8015648
+ * @summary Duplicate variable in lambda causes javac crash
+ * @compile/fail/ref=LambdaScope05.out -XDrawDiagnostics LambdaScope05.java
+ */
+
+class LambdaScope05 {
+    interface VoidFun1 {
+        void m(int i);
+    }
+
+    static Runnable r1 = () -> { VoidFun1 p = p -> { }; };
+    Runnable r2 = () -> { VoidFun1 p = p -> { }; };
+
+    static {
+        Runnable r = () -> { VoidFun1 p = p -> { }; };
+    }
+
+    {
+        Runnable r = () -> { VoidFun1 p = p -> { }; };
+    }
+
+    static void m_static() {
+        Runnable r = () -> { VoidFun1 p = p -> { }; };
+    }
+
+    void m() {
+        Runnable r = () -> { VoidFun1 p = p -> { }; };
+    }
+}
diff --git a/test/tools/javac/lambda/LambdaScope05.out b/test/tools/javac/lambda/LambdaScope05.out
new file mode 100644
index 0000000..722e29d
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaScope05.out
@@ -0,0 +1,7 @@
+LambdaScope05.java:13:47: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05
+LambdaScope05.java:14:40: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05
+LambdaScope05.java:17:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.static.init, kindname.class, LambdaScope05
+LambdaScope05.java:21:43: compiler.err.already.defined.in.clinit: kindname.variable, p, kindname.instance.init, kindname.class, LambdaScope05
+LambdaScope05.java:25:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m_static()
+LambdaScope05.java:29:43: compiler.err.already.defined: kindname.variable, p, kindname.method, m()
+6 errors
diff --git a/test/tools/javac/lambda/LambdaWithInterfaceSuper.java b/test/tools/javac/lambda/LambdaWithInterfaceSuper.java
new file mode 100644
index 0000000..c8f7727
--- /dev/null
+++ b/test/tools/javac/lambda/LambdaWithInterfaceSuper.java
@@ -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();
+       }
+    }
+}
diff --git a/test/tools/javac/lambda/LocalBreakAndContinue.java b/test/tools/javac/lambda/LocalBreakAndContinue.java
new file mode 100644
index 0000000..16505b4
--- /dev/null
+++ b/test/tools/javac/lambda/LocalBreakAndContinue.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that local break/continue is allowed in lambda expressions
+ * @author  Maurizio Cimadamore
+ * @compile LocalBreakAndContinue.java
+ */
+
+class LocalBreakAndContinue {
+
+    static interface SAM {
+       void m();
+    }
+
+    SAM s1 = ()-> { while (true) break; };
+    SAM s2 = ()-> { while (true) continue; };
+}
diff --git a/test/tools/javac/lambda/MethodReference01.java b/test/tools/javac/lambda/MethodReference01.java
new file mode 100644
index 0000000..dcde9ce
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference01.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  use method reference to sort list elements by field
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference01
+ */
+
+import java.util.*;
+
+public class MethodReference01 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    static class Foo {
+        private Integer a;
+        private String b;
+
+        Foo(Integer a, String b) {
+            this.a = a;
+            this.b = b;
+        }
+
+        static Integer getA(Foo f) { return f.a; }
+        static String getB(Foo f) { return f.b; }
+    }
+
+    public static <T, U extends Comparable<? super U>>
+           void sortBy(List<T> s, final Getter<U, T> getter) {
+        Collections.sort(s, new Comparator<T>() {
+            public int compare(T t1, T t2) {
+                return getter.get(t1).compareTo(getter.get(t2));
+            }
+        });
+    };
+
+    public static void main(String[] args) {
+        List<Foo> c = new ArrayList<Foo>();
+        c.add(new Foo(2, "Hello3!"));
+        c.add(new Foo(3, "Hello1!"));
+        c.add(new Foo(1, "Hello2!"));
+        checkSortByA(c);
+        checkSortByB(c);
+    }
+
+    static void checkSortByA(List<Foo> l) {
+        sortBy(l, Foo::getA);
+        int oldA = -1;
+        for (Foo foo : l) {
+            if (foo.a.compareTo(oldA) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+
+    static void checkSortByB(List<Foo> l) {
+        sortBy(l, Foo::getB);
+        String oldB = "";
+        for (Foo foo : l) {
+            if (foo.b.compareTo(oldB) < 1) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference02.java b/test/tools/javac/lambda/MethodReference02.java
new file mode 100644
index 0000000..86090ee
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference02.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that seemingly ambiguous method references are resolved properly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference02.java
+ */
+
+class MethodReference02 {
+    static interface SAM {
+       void m(Integer i);
+    }
+
+    void m(Integer i) {}
+    void m(Double d) {}
+
+    SAM s = this::m; //use target type to disambiguate
+}
diff --git a/test/tools/javac/lambda/MethodReference03.java b/test/tools/javac/lambda/MethodReference03.java
new file mode 100644
index 0000000..d61312a
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference03.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that most specific method is selected as expected
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference03
+ */
+
+public class MethodReference03 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(Integer i);
+    }
+
+    static void m(Number i) {}
+    static void m(Integer d) { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference03::m;
+        s.m(1);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference04.java b/test/tools/javac/lambda/MethodReference04.java
new file mode 100644
index 0000000..8ff9018
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference04.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that target type of a method ref is a SAM type
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference04.out -XDrawDiagnostics MethodReference04.java
+ */
+
+class MethodReference04 {
+    void m(Integer i) {}
+
+    Object o = this::m; //fail - not a valid target type
+}
diff --git a/test/tools/javac/lambda/MethodReference04.out b/test/tools/javac/lambda/MethodReference04.out
new file mode 100644
index 0000000..46c933a
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference04.out
@@ -0,0 +1,2 @@
+MethodReference04.java:13:16: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+1 error
diff --git a/test/tools/javac/lambda/MethodReference05.java b/test/tools/javac/lambda/MethodReference05.java
new file mode 100644
index 0000000..434c265
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference05.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-static method refernces from static context are handled correctly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference05
+ */
+
+public class MethodReference05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m(MethodReference05 receiver, Integer i);
+    }
+
+    void m(Integer i) { assertTrue(this != null); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference05::m;
+        s.m(new MethodReference05(), 1);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference06.java b/test/tools/javac/lambda/MethodReference06.java
new file mode 100644
index 0000000..66b7f7e
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference06.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  method references and super
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference06
+ */
+
+public class MethodReference06 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM { //works if SAM is an abstract class
+        abstract void meth(int i);
+    }
+
+    static class A {
+        void m(int i) { assertTrue(true); }
+    }
+
+    static class B extends A {
+        void m(int i) {
+            SAM mh = super::m;
+            mh.meth(i);
+        }
+    }
+
+    public static void main(String[] args) {
+        new B().m(10);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference07.java b/test/tools/javac/lambda/MethodReference07.java
new file mode 100644
index 0000000..2a36393
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference07.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference07.java
+ */
+
+class MethodReference07 {
+    interface SAM {
+       String m(Foo<String> f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo<String>::getX;
+       }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference08.java b/test/tools/javac/lambda/MethodReference08.java
new file mode 100644
index 0000000..9792c4a
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference08.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that syntax for selecting generic receiver works
+ * @author  Maurizio Cimadamore
+ *
+ * @compile MethodReference08.java
+ * @compile/fail/ref=MethodReference08.out -Werror -Xlint:rawtypes -XDrawDiagnostics MethodReference08.java
+ */
+
+class MethodReference08 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       static void test() {
+          SAM s = Foo::getX;
+       }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference08.out b/test/tools/javac/lambda/MethodReference08.out
new file mode 100644
index 0000000..30b7436
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference08.out
@@ -0,0 +1,5 @@
+MethodReference08.java:14:17: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+MethodReference08.java:21:19: compiler.warn.raw.class.use: MethodReference08.Foo, MethodReference08.Foo<X>
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
diff --git a/test/tools/javac/lambda/MethodReference09.java b/test/tools/javac/lambda/MethodReference09.java
new file mode 100644
index 0000000..a1d4853
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference09.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non static members cannot be referenced from a method reference qualifier
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference09.out -XDrawDiagnostics MethodReference09.java
+ */
+
+class MethodReference09 {
+    interface SAM {
+       String m(Foo f);
+    }
+
+    static class Foo<X> {
+       String getX() { return null; }
+
+       Foo<X> getThis() { return this; }
+
+       static void test() {
+          SAM s1 = Foo.getThis()::getX;
+          SAM s2 = this::getX;
+       }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference09.out b/test/tools/javac/lambda/MethodReference09.out
new file mode 100644
index 0000000..84984bb
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference09.out
@@ -0,0 +1,4 @@
+MethodReference09.java:21:23: compiler.err.non-static.cant.be.ref: kindname.method, getThis()
+MethodReference09.java:21:20: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, getX, compiler.misc.no.args, MethodReference09.Foo, kindname.class, MethodReference09.Foo<X>, (compiler.misc.arg.length.mismatch)))
+MethodReference09.java:22:20: compiler.err.non-static.cant.be.ref: kindname.variable, this
+3 errors
diff --git a/test/tools/javac/lambda/MethodReference10.java b/test/tools/javac/lambda/MethodReference10.java
new file mode 100644
index 0000000..a943832
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference10.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that non static selectors in method refs are handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile MethodReference10.java
+ */
+
+import java.util.*;
+
+class MethodReference10 {
+
+    interface Getter<U, T> {
+        public U get(T t);
+    }
+
+    public static <T, U extends Comparable<? super U>>
+        void sortBy(Collection<T> s, Getter<U, T> getter) {};
+
+    static class Foo {
+        private String a;
+        String getA(Foo f) { return f.a; }
+    }
+
+    public static void main(String[] args) {
+        Collection<Foo> c = new ArrayList<Foo>();
+        sortBy(c, new Foo()::getA);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference11.java b/test/tools/javac/lambda/MethodReference11.java
new file mode 100644
index 0000000..1eb43bc
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference11.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that static vs. non-static selection logic in method references works
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference11
+ */
+
+import java.util.*;
+
+public class MethodReference11 {
+    public static void main(String[] args) {
+        String[] strings = new String[] { "D", "C", "B", "A" };
+        Arrays.sort( strings, String.CASE_INSENSITIVE_ORDER::compare );
+        String last = "1";
+        for (String s : strings) {
+            if (String.CASE_INSENSITIVE_ORDER.compare(last, s) > 0) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference12.java b/test/tools/javac/lambda/MethodReference12.java
new file mode 100644
index 0000000..0d16adf
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference12.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that Object methods are dispatched accordingly
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference12
+ */
+
+public class MethodReference12 {
+
+    interface SAM { void foo(int i); }
+
+    static void print(int i) {
+        System.out.println(i);
+    }
+
+    public static void main(String[] args) {
+        try {
+            test(MethodReference12::print);
+            test(i -> { System.out.println(i); } );
+        }
+        catch (Throwable t) {
+            t.printStackTrace();
+            throw new AssertionError("An error occurred");
+        }
+    }
+
+    static void test(SAM s) throws Throwable {
+        s.hashCode();
+        s.equals(null);
+        s.toString();
+        try {
+            s.notify(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.notifyAll(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException e) {  }
+        try {
+            s.wait(1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(1,1); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+        try {
+            s.wait(); //will throw IllegalMonitorStateException
+        }
+        catch (final IllegalMonitorStateException | InterruptedException e) {  }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference13.java b/test/tools/javac/lambda/MethodReference13.java
new file mode 100644
index 0000000..ac454f8
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference13.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that equals() on Proxied objects is handled accordingly
+ * @author  Maurizio Cimadamore
+ * @compile -XDuseProxy MethodReference13.java
+ * @run main MethodReference13
+ */
+
+public class MethodReference13 {
+
+    static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference13::m;
+        assertTrue(s.equals(s));
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference14.java b/test/tools/javac/lambda/MethodReference14.java
new file mode 100644
index 0000000..8f9cce1
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference14.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check casting a method reference to a SAM type does not result in a CCE
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference14
+ */
+
+public class MethodReference14 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { assertTrue(true); }
+
+    public static void main(String[] args) {
+        SAM s = (SAM)MethodReference14::m;
+        s.m();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference15.java b/test/tools/javac/lambda/MethodReference15.java
new file mode 100644
index 0000000..66fcf19
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference15.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that assignments involving method references do not trigger transitional 292 warnings
+ * @author  Maurizio Cimadamore
+ * @compile -Werror MethodReference15.java
+ */
+
+public class MethodReference15 {
+
+    interface SAM {
+        void m();
+    }
+
+    static void m() { }
+
+    static void test() {
+        SAM s = MethodReference15::m;
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference16.java b/test/tools/javac/lambda/MethodReference16.java
new file mode 100644
index 0000000..e8fd014
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference16.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  semantics of statically qualified method reference should not depend on the context
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference16
+ */
+
+public class MethodReference16 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(MethodReference16 receiver);
+    }
+
+    void m() { assertTrue(true); }
+
+    void test() {
+        SAM s = (SAM)MethodReference16::m;
+        s.m(this);
+    }
+
+    public static void main(String[] args) {
+        MethodReference16 rec = new MethodReference16();
+        SAM s = (SAM)MethodReference16::m;
+        s.m(rec);
+        rec.test();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference17.java b/test/tools/javac/lambda/MethodReference17.java
new file mode 100644
index 0000000..590b2ec
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference17.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference17
+ */
+
+public class MethodReference17 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference17() {
+        assertTrue(true);
+    }
+
+    interface SAM {
+        MethodReference17 m();
+    }
+
+    static void test(SAM s) {
+        s.m();
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference17::new;
+        s.m();
+        test(MethodReference17::new);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference18.java b/test/tools/javac/lambda/MethodReference18.java
new file mode 100644
index 0000000..d9d9248
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference18.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference18
+ */
+
+public class MethodReference18 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference18(Object o) {
+        assertTrue(true);
+    }
+
+    MethodReference18(Number n) {
+        assertTrue(false);
+    }
+
+    interface SAM {
+        MethodReference18 m(Object o);
+    }
+
+    static void test(SAM s, Object arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference18::new;
+        s.m("");
+        test(MethodReference18::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference19.java b/test/tools/javac/lambda/MethodReference19.java
new file mode 100644
index 0000000..c155616
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference19.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @run main MethodReference19
+ */
+
+public class MethodReference19<X> {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    MethodReference19(X x) {
+        assertTrue(true);
+    }
+
+    interface SAM<Z> {
+        MethodReference19<Z> m(Z z);
+    }
+
+    static <Y> void test(SAM<Y> s, Y arg) {
+        s.m(arg);
+    }
+
+    public static void main(String[] args) {
+        SAM<String> s = MethodReference19<String>::new;
+        s.m("");
+        test(MethodReference19<String>::new, "");
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference20.java b/test/tools/javac/lambda/MethodReference20.java
new file mode 100644
index 0000000..e37ac79
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference20.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  basic test for constructor references and generic classes
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference20.out -XDrawDiagnostics MethodReference20.java
+ */
+
+class MethodReference20<X> {
+
+    MethodReference20(X x) { }
+
+    interface SAM<Z> {
+        MethodReference20<Z> m(Z z);
+    }
+
+    static void test(SAM<Integer> s) {   }
+
+    public static void main(String[] args) {
+        SAM<Integer> s = MethodReference20<String>::new;
+        test(MethodReference20<String>::new);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference20.out b/test/tools/javac/lambda/MethodReference20.out
new file mode 100644
index 0000000..8af6bdb
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference20.out
@@ -0,0 +1,3 @@
+MethodReference20.java:21:26: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.String))))
+MethodReference20.java:22:9: compiler.err.cant.apply.symbol: kindname.method, test, MethodReference20.SAM<java.lang.Integer>, @549, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, MethodReference20, java.lang.String, java.lang.Integer, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconverti [...]
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference21.java b/test/tools/javac/lambda/MethodReference21.java
new file mode 100644
index 0000000..4daec95
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference21.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference21.out -XDrawDiagnostics MethodReference21.java
+ */
+
+class MethodReference21 {
+
+    interface SAM {
+        void m();
+    }
+
+    void call(SAM s) {}
+
+    SAM s = NonExistentType::m;
+
+    {
+        call(NonExistentType::m);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference21.out b/test/tools/javac/lambda/MethodReference21.out
new file mode 100644
index 0000000..6133c2a
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference21.out
@@ -0,0 +1,3 @@
+MethodReference21.java:18:13: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+MethodReference21.java:21:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference21, null)
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference22.java b/test/tools/javac/lambda/MethodReference22.java
new file mode 100644
index 0000000..9517ee0
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference22.java
@@ -0,0 +1,67 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound method references checked correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference22.out -XDrawDiagnostics MethodReference22.java
+ */
+
+class MethodReference22 {
+
+    void m1(String x) { }
+    void m1(MethodReference22 rec, String x) { }
+
+    static void m2(String x) { }
+    static void m2(MethodReference22 rec, String x) { }
+
+    static void m3(String x) { }
+    void m3(MethodReference22 rec, String x) { }
+
+    void m4(String x) { }
+    static void m4(MethodReference22 rec, String x) { }
+
+    interface SAM1 {
+        void m(String x);
+    }
+
+    interface SAM2 {
+        void m(MethodReference22 rec, String x);
+    }
+
+    static void call1(SAM1 s) {   }
+
+    static void call2(SAM2 s) {   }
+
+    static void call3(SAM1 s) {   }
+    static void call3(SAM2 s) {   }
+
+    static void test1() {
+        SAM1 s1 = MethodReference22::m1; //fail
+        call1(MethodReference22::m1); //fail
+        SAM1 s2 = MethodReference22::m2; //ok
+        call1(MethodReference22::m2); //ok
+        SAM1 s3 = MethodReference22::m3; //ok
+        call1(MethodReference22::m3); //ok
+        SAM1 s4 = MethodReference22::m4; //fail
+        call1(MethodReference22::m4); //fail
+    }
+
+    static void test2() {
+        SAM2 s1 = MethodReference22::m1; //ambiguous
+        call2(MethodReference22::m1); //ambiguous
+        SAM2 s2 = MethodReference22::m2; //ambiguous
+        call2(MethodReference22::m2); //ambiguous
+        SAM2 s3 = MethodReference22::m3; //ambiguous
+        call2(MethodReference22::m3); //ambiguous
+        SAM2 s4 = MethodReference22::m4; //ambiguous
+        call2(MethodReference22::m4); //ambiguous
+    }
+
+    static void test3() {
+        call3(MethodReference22::m1); //fail
+        call3(MethodReference22::m2); //ok
+        call3(MethodReference22::m3); //ok
+        call3(MethodReference22::m4); //fail
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference22.out b/test/tools/javac/lambda/MethodReference22.out
new file mode 100644
index 0000000..d25b71e
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference22.out
@@ -0,0 +1,15 @@
+MethodReference22.java:40:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:41:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:46:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+MethodReference22.java:47:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+MethodReference22.java:51:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22))
+MethodReference22.java:52:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1401, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22)))
+MethodReference22.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22))
+MethodReference22.java:54:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1504, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22)))
+MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22))
+MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1607, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22)))
+MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))
+MethodReference22.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1710, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
+MethodReference22.java:62:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))
+MethodReference22.java:65:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))
+14 errors
diff --git a/test/tools/javac/lambda/MethodReference23.java b/test/tools/javac/lambda/MethodReference23.java
new file mode 100644
index 0000000..b761038
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference23.java
@@ -0,0 +1,74 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that pair of bound/non-bound constructor references is flagged as ambiguous
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=MethodReference23.out -XDrawDiagnostics MethodReference23.java
+ */
+
+class MethodReference23 {
+
+    class Inner1 {
+        Inner1(MethodReference23 outer) {};
+        Inner1() {};
+    }
+
+    static class Inner2 {
+        Inner2(MethodReference23 outer) {};
+        Inner2() {};
+    }
+
+    interface SAM11 {
+        Inner1 m(MethodReference23 rec);
+    }
+
+    interface SAM12 {
+        Inner1 m();
+    }
+
+    interface SAM21 {
+        Inner2 m(MethodReference23 rec);
+    }
+
+    interface SAM22 {
+        Inner2 m();
+    }
+
+    static void call11(SAM11 s) {   }
+
+    static void call12(SAM12 s) {   }
+
+    static void call21(SAM21 s) {   }
+
+    static void call22(SAM22 s) {   }
+
+    static void call3(SAM11 s) {   }
+    static void call3(SAM12 s) {   }
+    static void call3(SAM21 s) {   }
+    static void call3(SAM22 s) {   }
+
+    static void test11() {
+        SAM11 s = MethodReference23.Inner1::new; //ok
+        call11(MethodReference23.Inner1::new); //ok
+    }
+
+    static void test12() {
+        SAM12 s = MethodReference23.Inner1::new; //fail
+        call12(MethodReference23.Inner1::new); //fail
+    }
+
+    static void test21() {
+        SAM21 s = MethodReference23.Inner2::new; //ok
+        call21(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test22() {
+        SAM22 s = MethodReference23.Inner2::new; //ok
+        call22(MethodReference23.Inner2::new); //ok
+    }
+
+    static void test3() {
+        call3(MethodReference23.Inner2::new); //ambiguous
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference23.out b/test/tools/javac/lambda/MethodReference23.out
new file mode 100644
index 0000000..3849d86
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference23.out
@@ -0,0 +1,6 @@
+MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))
+MethodReference23.java:53:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)))
+MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
+MethodReference23.java:58:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)))
+MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
+5 errors
diff --git a/test/tools/javac/lambda/MethodReference24.java b/test/tools/javac/lambda/MethodReference24.java
new file mode 100644
index 0000000..f7fa8f1
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference24.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference24
+ */
+
+public class MethodReference24 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    static void m(int i) { assertTrue(true); }
+    static void m(Integer i) { assertTrue(false); }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(SAM s) { s.m(42); }
+
+    public static void main(String[] args) {
+        SAM s = MethodReference24::m; //resolves to m(int)
+        s.m(42);
+        call(MethodReference24::m); //resolves to m(int)
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference25.java b/test/tools/javac/lambda/MethodReference25.java
new file mode 100644
index 0000000..8f02359
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference25.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references is not preferred over boxing one
+ * @compile/fail/ref=MethodReference25.out -XDrawDiagnostics MethodReference25.java
+ */
+
+class MethodReference25 {
+
+    static void m(Integer i) { }
+
+    interface SAM1 {
+        void m(int x);
+    }
+
+    interface SAM2 {
+        void m(Integer x);
+    }
+
+    static void call(int i, SAM1 s) { s.m(i);  }
+    static void call(int i, SAM2 s) { s.m(i);  }
+
+    public static void main(String[] args) {
+        call(1, MethodReference25::m); //ambiguous
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference25.out b/test/tools/javac/lambda/MethodReference25.out
new file mode 100644
index 0000000..3b4e267
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference25.out
@@ -0,0 +1,2 @@
+MethodReference25.java:48:9: compiler.err.ref.ambiguous: call, kindname.method, call(int,MethodReference25.SAM1), MethodReference25, kindname.method, call(int,MethodReference25.SAM2), MethodReference25
+1 error
diff --git a/test/tools/javac/lambda/MethodReference26.java b/test/tools/javac/lambda/MethodReference26.java
new file mode 100644
index 0000000..29a4b5e
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference26.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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 check strict method conversion allows loose method reference conversion
+ * @compile MethodReference26.java
+ */
+
+class MethodReference26 {
+
+    static void m(Integer i) { }
+
+    interface SAM {
+        void m(int x);
+    }
+
+    static void call(int i, SAM s) {   }
+    static void call(Integer i, SAM s) {   }
+
+    static void test() {
+        call(1, MethodReference26::m); //ok
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference27.java b/test/tools/javac/lambda/MethodReference27.java
new file mode 100644
index 0000000..ae1a4ec
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference27.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-boxing method references conversion has the precedence
+ * @run main MethodReference27
+ */
+
+public class MethodReference27 {
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static int assertionCount = 0;
+
+    interface SAM {
+        void m(int i1, int i2);
+    }
+
+    static void m1(int i1, int i2) { assertTrue(true); }
+    static void m1(Integer i1, int i2) { assertTrue(false); }
+    static void m1(int i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer i1, Integer i2) { assertTrue(false); }
+    static void m1(Integer... is) { assertTrue(false); }
+
+    static void m2(int... is) { assertTrue(true); }
+    static void m2(double... ds) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        SAM s1 = MethodReference27::m1;
+        s1.m(42,42);
+        SAM s2 = MethodReference27::m2;
+        s2.m(42,42);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference28.java b/test/tools/javac/lambda/MethodReference28.java
new file mode 100644
index 0000000..61da154
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference28.java
@@ -0,0 +1,56 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that non-compatible method references are rejected
+ * @compile/fail/ref=MethodReference28.out -XDrawDiagnostics MethodReference28.java
+ */
+
+class MethodReference28 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(MethodReference28 rec, int i);
+    }
+
+    static void static_m1(Integer i) { } //ok - boxing
+    static void static_m2(Integer i1, Integer i2) { } //wrong arity
+    static void static_m3(String s) { } //type mismatch
+    static void static_m4(String... ss) { } //type mismatch - varargs
+
+    void m1(Integer i) { } //ok - boxing
+    void m2(Integer i1, Integer i2) { } //wrong arity
+    void m3(String s) { } //type mismatch
+    void m4(String... ss) { } //type mismatch - varargs
+
+    static void testStatic() {
+        SAM1 s1 = MethodReference28::static_m1;
+        SAM1 s2 = MethodReference28::static_m2;
+        SAM1 s3 = MethodReference28::static_m3;
+        SAM1 s4 = MethodReference28::static_m4;
+    }
+
+    void testBadMember() {
+        SAM1 s1 = MethodReference28::m1;
+        SAM1 s2 = MethodReference28::m2;
+        SAM1 s3 = MethodReference28::m3;
+        SAM1 s4 = MethodReference28::m4;
+    }
+
+    void testMember() {
+        SAM1 s1 = this::m1;
+        SAM1 s2 = this::m2;
+        SAM1 s3 = this::m3;
+        SAM1 s4 = this::m4;
+    }
+
+    static void testUnbound() {
+        SAM2 s1 = MethodReference28::m1;
+        SAM2 s2 = MethodReference28::m2;
+        SAM2 s3 = MethodReference28::m3;
+        SAM2 s4 = MethodReference28::m4;
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference28.out b/test/tools/javac/lambda/MethodReference28.out
new file mode 100644
index 0000000..123cb51
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference28.out
@@ -0,0 +1,14 @@
+MethodReference28.java:31:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:32:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:33:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, static_m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:37:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer))
+MethodReference28.java:38:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:39:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:40:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:45:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:46:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:47:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference28.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m2, java.lang.Integer,java.lang.Integer, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: MethodReference28, java.lang.Integer))))
+MethodReference28.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m3, java.lang.String, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:54:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m4, java.lang.String[], MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: MethodReference28, java.lang.String))))
+13 errors
diff --git a/test/tools/javac/lambda/MethodReference29.java b/test/tools/javac/lambda/MethodReference29.java
new file mode 100644
index 0000000..51b0e7b
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference29.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  reference to super leads to compiler crash when 292 translation scheme is enabled
+ */
+
+public class MethodReference29 {
+
+    interface SAM {
+        void m(Integer i);
+    }
+
+    static class A {
+        void m(int i) { }
+    }
+
+    static class B extends A {
+        void test() {
+            SAM s = super::m;
+            s.m(42);
+        }
+
+        void m(int i) { throw new AssertionError(); }
+    }
+
+    public static void main(String[] args) {
+        new B().test();
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference30.java b/test/tools/javac/lambda/MethodReference30.java
new file mode 100644
index 0000000..81945c6
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference30.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that non-static qualifier of static method reference is eagerly evaluated
+ */
+
+public class MethodReference30 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+       void m();
+    }
+
+    MethodReference30() {
+        assertTrue(true);
+    }
+
+   void m() { }
+
+   public static void main(String[] args) {
+      SAM s = new MethodReference30()::m;
+      assertTrue(assertionCount == 1);
+   }
+}
diff --git a/test/tools/javac/lambda/MethodReference31.java b/test/tools/javac/lambda/MethodReference31.java
new file mode 100644
index 0000000..aa3085b
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference31.java
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that boxing of return-type works as expected
+ */
+
+public class MethodReference31 {
+
+    static class Success extends RuntimeException { }
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM<X> {
+        X m();
+    }
+
+    interface SAM_byte {
+        byte m();
+    }
+
+    interface SAM_short {
+        short m();
+    }
+
+    interface SAM_int {
+        int m();
+    }
+
+    interface SAM_long {
+        long m();
+    }
+
+    interface SAM_float {
+        float m();
+    }
+
+    interface SAM_double {
+        double m();
+    }
+
+    static <Z> Z test() {
+        assertTrue(true);
+        throw new Success();
+    }
+
+    static byte test_byte() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static short test_short() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static int test_int() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static long test_long() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static float test_float() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static double test_double() {
+        assertTrue(true);
+        return 0;
+    }
+
+    static void testByte() {
+        SAM<Byte> s1 = MethodReference31::test_byte;
+        s1.m();
+        SAM_byte s2 = MethodReference31::test_byte;
+        s2.m();
+        SAM<Byte> s3 = MethodReference31::<Byte>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_byte s4 = MethodReference31::<Byte>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testShort() {
+        SAM<Short> s1 = MethodReference31::test_short;
+        s1.m();
+        SAM_short s2 = MethodReference31::test_short;
+        s2.m();
+        SAM<Short> s3 = MethodReference31::<Short>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_short s4 = MethodReference31::<Short>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testInteger() {
+        SAM<Integer> s1 = MethodReference31::test_int;
+        s1.m();
+        SAM_int s2 = MethodReference31::test_int;
+        s2.m();
+        SAM<Integer> s3 = MethodReference31::<Integer>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_int s4 = MethodReference31::<Integer>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testLong() {
+        SAM<Long> s1 = MethodReference31::test_long;
+        s1.m();
+        SAM_long s2 = MethodReference31::test_long;
+        s2.m();
+        SAM<Long> s3 = MethodReference31::<Long>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_long s4 = MethodReference31::<Long>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testFloat() {
+        SAM<Float> s1 = MethodReference31::test_float;
+        s1.m();
+        SAM_float s2 = MethodReference31::test_float;
+        s2.m();
+        SAM<Float> s3 = MethodReference31::<Float>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_float s4 = MethodReference31::<Float>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    static void testDouble() {
+        SAM<Double> s1 = MethodReference31::test_double;
+        s1.m();
+        SAM_double s2 = MethodReference31::test_double;
+        s2.m();
+        SAM<Double> s3 = MethodReference31::<Double>test;
+        try {
+            s3.m();
+        }
+        catch (RuntimeException ex) { }
+        SAM_double s4 = MethodReference31::<Double>test;
+        try {
+            s4.m();
+        }
+        catch (RuntimeException ex) { }
+    }
+
+    public static void main(String[] args) {
+        testByte();
+        testShort();
+        testInteger();
+        testLong();
+        testFloat();
+        testDouble();
+        assertTrue(assertionCount == 24);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference32.java b/test/tools/javac/lambda/MethodReference32.java
new file mode 100644
index 0000000..754dd36
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference32.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that varargs warnings are generated during SAM conversion
+ * @compile/fail/ref=MethodReference32.out -Xlint:unchecked -Werror -XDrawDiagnostics MethodReference32.java
+ */
+
+import java.util.*;
+
+class MethodReference32 {
+
+    interface SAM {
+        MethodReference32 m(List<Integer> l1, List<Integer> l2);
+    }
+
+    MethodReference32 meth(List<Integer>... lli) { return null; }
+    MethodReference32(List<Integer>... lli) { }
+
+    SAM s1 = this::meth;
+    SAM s2 = MethodReference32::new;
+}
diff --git a/test/tools/javac/lambda/MethodReference32.out b/test/tools/javac/lambda/MethodReference32.out
new file mode 100644
index 0000000..1ea868c
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference32.out
@@ -0,0 +1,7 @@
+MethodReference32.java:17:45: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:18:40: compiler.warn.unchecked.varargs.non.reifiable.type: java.util.List<java.lang.Integer>
+MethodReference32.java:20:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+MethodReference32.java:21:14: compiler.warn.unchecked.generic.array.creation: java.util.List<java.lang.Integer>[]
+- compiler.err.warnings.and.werror
+1 error
+4 warnings
diff --git a/test/tools/javac/lambda/MethodReference33.java b/test/tools/javac/lambda/MethodReference33.java
new file mode 100644
index 0000000..5edde66
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference33.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test bridged constructor references
+ */
+
+public class MethodReference33 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    class Foo {
+        Foo(Integer i) { assertTrue(true); }
+        Foo() { assertTrue(true); }
+    }
+
+    interface BridgeSAMBound<X> {
+        X m(int i);
+    }
+
+    interface NonBridgeSAMBound<X> {
+        X m();
+    }
+
+    void test() {
+        BridgeSAMBound<Foo> b1 = Foo::new;
+        b1.m(1);
+        NonBridgeSAMBound<Foo> b2 = Foo::new;
+        b2.m();
+    }
+
+    public static void main(String[] args) {
+        MethodReference33 test = new MethodReference33();
+        test.test();
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference34.java b/test/tools/javac/lambda/MethodReference34.java
new file mode 100644
index 0000000..7591d36
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference34.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that code generation handles void-compatibility correctly
+ * @run main MethodReference34
+ */
+
+public class MethodReference34 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM_void<X> {
+        void m();
+    }
+
+    interface SAM_java_lang_Void<X> {
+        void m();
+    }
+
+    static void m_void() { assertTrue(true); }
+
+    static Void m_java_lang_Void() { assertTrue(true); return null; }
+
+    public static void main(String[] args) {
+        SAM_void s1 = MethodReference34::m_void;
+        s1.m();
+        SAM_java_lang_Void s2 = MethodReference34::m_void;
+        s2.m();
+        SAM_void s3 = MethodReference34::m_java_lang_Void;
+        s3.m();
+        SAM_java_lang_Void s4 = MethodReference34::m_java_lang_Void;
+        s4.m();
+        assertTrue(assertionCount == 4);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference35.java b/test/tools/javac/lambda/MethodReference35.java
new file mode 100644
index 0000000..bb326c9
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference35.java
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda/method references are valid method reference qualifiers
+ * @run main MethodReference35
+ */
+
+public class MethodReference35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        MethodReference35 invoke();
+    }
+
+    MethodReference35() {
+        assertTrue(true);
+    }
+
+    static MethodReference35 m() {
+        assertTrue(true);
+        return null;
+    }
+
+    public static void main(String[] args) {
+        SAM sam1 = ((SAM)() -> { assertTrue(true); return null; })::invoke;
+        sam1.invoke();
+        SAM sam2 = ((SAM)MethodReference35::new)::invoke;
+        sam1.invoke();
+        SAM sam3 = ((SAM)MethodReference35::m)::invoke;
+        sam1.invoke();
+        assertTrue(assertionCount == 3);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference36.java b/test/tools/javac/lambda/MethodReference36.java
new file mode 100644
index 0000000..8382857
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference36.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that method reference handles varargs conversion properly
+ * @run main MethodReference36
+ */
+
+public class MethodReference36 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SamC { void m(char[] a); }
+    interface SamZ { void m(boolean[] a); }
+    interface SamB { void m(byte[] a); }
+    interface SamS { void m(short[] a); }
+    interface SamI { void m(int[] a); }
+    interface SamL { void m(long[] a); }
+    interface SamF { void m(float[] a); }
+    interface SamD { void m(double[] a); }
+    interface SamO { void m(Object[] a); }
+
+
+    static void m(Object... vi) {
+        assertTrue(true);
+    }
+
+    public void test() {
+
+        SamC sc = MethodReference36::m;
+        sc.m(new char[] { 'a', 'b' } );
+
+        SamZ sz = MethodReference36::m;
+        sz.m(new boolean[] { true, false } );
+
+        SamB sb = MethodReference36::m;
+        sb.m(new byte[] { 0, 1 } );
+
+        SamS ss = MethodReference36::m;
+        ss.m(new short[] { 0, 1 } );
+
+        SamI si = MethodReference36::m;
+        si.m(new int[] { 0, 1 } );
+
+        SamL sl = MethodReference36::m;
+        sl.m(new long[] { 0, 1 } );
+
+        SamF sf = MethodReference36::m;
+        sf.m(new float[] { 0, 1 } );
+
+        SamD sd = MethodReference36::m;
+        sd.m(new double[] { 0, 1 } );
+
+        SamO so = MethodReference36::m;
+        so.m(new Object[] { null, null } );
+    }
+
+    public static void main(String[] args) {
+       new MethodReference36().test();
+       assertTrue(assertionCount == 9);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference37.java b/test/tools/javac/lambda/MethodReference37.java
new file mode 100644
index 0000000..c991a95
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference37.java
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  spurious exceptions when checking references to inner constructors where
+ *          the enclosing class is not defined in any outer context
+ * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java
+ */
+
+class MethodReference37 {
+
+    interface SAM1<R> {
+        R invoke();
+    }
+
+    interface SAM2<R, A> {
+        R invoke(A a);
+    }
+
+    static class Outer {
+        class Inner { }
+
+        static void test1() {
+            SAM2<Inner, Outer> sam = Inner::new;
+        }
+
+        void test2() {
+            SAM1<Inner> sam0 = Inner::new;
+            SAM2<Inner, Outer> sam1 = Inner::new;
+        }
+    }
+
+    static void test1() {
+        SAM2<Outer.Inner, Outer> sam = Outer.Inner::new;
+    }
+
+    void test2() {
+        SAM2<Outer.Inner, Outer> sam1 = Outer.Inner::new;
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference37.out b/test/tools/javac/lambda/MethodReference37.out
new file mode 100644
index 0000000..09dc966
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference37.out
@@ -0,0 +1,5 @@
+MethodReference37.java:24:38: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:29:39: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:34:40: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference37.java:38:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, compiler.misc.no.args, MethodReference37.Outer, kindname.class, MethodReference37.Outer.Inner, (compiler.misc.arg.length.mismatch)))
+4 errors
diff --git a/test/tools/javac/lambda/MethodReference38.java b/test/tools/javac/lambda/MethodReference38.java
new file mode 100644
index 0000000..e1e926e
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference38.java
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  The qualifier type of a constructor reference must be a concrete class
+ * @compile/fail/ref=MethodReference38.out -XDrawDiagnostics MethodReference38.java
+ */
+
+class MethodReference38 {
+
+    interface SAM<R> {
+        R invoke();
+    }
+
+    @interface A { }
+
+    interface I { }
+
+    static abstract class AC { }
+
+    enum E { }
+
+    void test() {
+        SAM s1 = A::new;
+        SAM s2 = I::new;
+        SAM s3 = AC::new;
+        SAM s4 = E::new;
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference38.out b/test/tools/javac/lambda/MethodReference38.out
new file mode 100644
index 0000000..53c0f26
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference38.out
@@ -0,0 +1,5 @@
+MethodReference38.java:24:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.A
+MethodReference38.java:25:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.I
+MethodReference38.java:26:18: compiler.err.abstract.cant.be.instantiated: MethodReference38.AC
+MethodReference38.java:27:18: compiler.err.enum.cant.be.instantiated
+4 errors
diff --git a/test/tools/javac/lambda/MethodReference39.java b/test/tools/javac/lambda/MethodReference39.java
new file mode 100644
index 0000000..f3b6f5d
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference39.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that bad enclosing class parameter type is discarded accordingly
+ * @compile/fail/ref=MethodReference39.out -XDrawDiagnostics MethodReference39.java
+ */
+class MethodReference39 {
+
+    static class Sup {}
+
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup m(Sup x, String str); }
+
+        class Inner extends Sup {
+            Inner(String val) { }
+        }
+
+        void test() {
+            SAM var = Sub.Inner::new;;
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference39.out b/test/tools/javac/lambda/MethodReference39.out
new file mode 100644
index 0000000..0cfcd40
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference39.out
@@ -0,0 +1,2 @@
+MethodReference39.java:22:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference39.Sup,java.lang.String, kindname.class, MethodReference39.Sub.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
diff --git a/test/tools/javac/lambda/MethodReference40.java b/test/tools/javac/lambda/MethodReference40.java
new file mode 100644
index 0000000..a725044
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference40.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that unbound constructor reference are not accepted
+ * @compile/fail/ref=MethodReference40.out -XDrawDiagnostics MethodReference40.java
+ */
+class MethodReference40 {
+
+    static class Sup {
+        class Inner {
+            Inner(String val) { }
+        }
+    }
+
+    static class Sub extends Sup {
+
+        interface SAM { Sup.Inner m(Sub x, String str); }
+
+        void test() {
+            SAM var = Sub.Inner::new;
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference40.out b/test/tools/javac/lambda/MethodReference40.out
new file mode 100644
index 0000000..9afa437
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference40.out
@@ -0,0 +1,2 @@
+MethodReference40.java:21:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Inner, java.lang.String, MethodReference40.Sub,java.lang.String, kindname.class, MethodReference40.Sup.Inner, (compiler.misc.arg.length.mismatch)))
+1 error
diff --git a/test/tools/javac/lambda/MethodReference41.java b/test/tools/javac/lambda/MethodReference41.java
new file mode 100644
index 0000000..a259332
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference41.java
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference41
+ */
+public class MethodReference41 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference42.java b/test/tools/javac/lambda/MethodReference42.java
new file mode 100644
index 0000000..1c8aaef
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference42.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference42
+ */
+public class MethodReference42 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(true); }
+    static void m(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference43.java b/test/tools/javac/lambda/MethodReference43.java
new file mode 100644
index 0000000..f7b8203
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference43.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that diamond inference is applied when using raw constructor reference qualifier
+ * @run main MethodReference43
+ */
+public class MethodReference43 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       Foo<?> m(String s);
+    }
+
+    interface SAM2 {
+       Foo<?> m(Integer s);
+    }
+
+    interface SAM3 {
+       Foo<?> m(Object o);
+    }
+
+    interface SAM4 {
+       Foo<Number> m(Integer o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+
+    static void m(SAM1 s) { assertTrue(false); }
+    static void m(SAM2 s) { assertTrue(false); }
+    static void m(SAM3 s) { assertTrue(false); }
+    static void m(SAM4 s) { assertTrue(true); }
+
+    public static void main(String[] args) {
+        m(Foo::new);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference44.java b/test/tools/javac/lambda/MethodReference44.java
new file mode 100644
index 0000000..8c92593
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference44.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference44
+ */
+public class MethodReference44 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        SuperFoo<String> m();
+    }
+
+    interface SAM2 {
+        SuperFoo<Integer> m();
+    }
+
+    interface SAM3 {
+        SuperFoo<Object> m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference44::m);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference45.java b/test/tools/javac/lambda/MethodReference45.java
new file mode 100644
index 0000000..3c132df
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference45.java
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference45.out -XDrawDiagnostics MethodReference45.java
+ */
+public class MethodReference45 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class SuperFoo<X> { }
+
+    static class Foo<X extends Number> extends SuperFoo<X> { }
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    static <X extends Number> Foo<X> m() { return null; }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    void test() {
+        g1(MethodReference45::m);
+        g2(MethodReference45::m);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference45.out b/test/tools/javac/lambda/MethodReference45.out
new file mode 100644
index 0000000..7a6b558
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference45.out
@@ -0,0 +1,2 @@
+MethodReference45.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference45.SAM1), MethodReference45, kindname.method, g2(MethodReference45.SAM2), MethodReference45
+1 error
diff --git a/test/tools/javac/lambda/MethodReference46.java b/test/tools/javac/lambda/MethodReference46.java
new file mode 100644
index 0000000..8f0c327
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference46.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @run main MethodReference46
+ */
+public class MethodReference46 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(String s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    interface SAM3 {
+       void m(Object o);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g(SAM1 s) { assertTrue(false); }
+    static void g(SAM2 s) { assertTrue(true); }
+    static void g(SAM3 s) { assertTrue(false); }
+
+    public static void main(String[] args) {
+        g(MethodReference46::m);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference47.java b/test/tools/javac/lambda/MethodReference47.java
new file mode 100644
index 0000000..5bc949d
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference47.java
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that generic method reference is inferred when type parameters are omitted
+ * @compile/fail/ref=MethodReference47.out -XDrawDiagnostics MethodReference47.java
+ */
+public class MethodReference47 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM1 {
+       void m(Integer s);
+    }
+
+    interface SAM2 {
+       void m(Integer s);
+    }
+
+    static class Foo<X extends Number> {
+        Foo(X x) { }
+    }
+
+    static <X extends Number> void m(X fx) { }
+
+    static void g1(SAM1 s) { }
+    static void g2(SAM1 s) { }
+    static void g2(SAM2 s) { }
+
+    public static void main(String[] args) {
+        g1(MethodReference46::m);
+        g2(MethodReference46::m);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference47.out b/test/tools/javac/lambda/MethodReference47.out
new file mode 100644
index 0000000..39d3c31
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference47.out
@@ -0,0 +1,2 @@
+MethodReference47.java:38:9: compiler.err.ref.ambiguous: g2, kindname.method, g2(MethodReference47.SAM1), MethodReference47, kindname.method, g2(MethodReference47.SAM2), MethodReference47
+1 error
diff --git a/test/tools/javac/lambda/MethodReference48.java b/test/tools/javac/lambda/MethodReference48.java
new file mode 100644
index 0000000..8c3a704
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference48.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that raw qualifier in unbound method reference is inferred from descriptor
+ * @run main MethodReference48
+ */
+public class MethodReference48 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static class Foo<X> {
+        X m() { return null; };
+    }
+
+    interface SAM1 {
+        Foo<Object> m(Foo<String> fs);
+    }
+
+    interface SAM2 {
+        Integer m(Foo<Integer> fi);
+    }
+
+    interface SAM3 {
+        Object m(Foo<Integer> fi);
+    }
+
+    static void g(SAM1 s) { assertTrue(false); } //return type not compatible
+    static void g(SAM2 s) { assertTrue(true); } //ok
+    static void g(SAM3 s) { assertTrue(false); } //ok but less specific
+
+    public static void main(String[] args) {
+        g(Foo::m);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference49.java b/test/tools/javac/lambda/MethodReference49.java
new file mode 100644
index 0000000..1515392
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference49.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that an array type can be used as a qualifier of an unbound method reference
+ * @run main MethodReference49
+ */
+public class MethodReference49 {
+
+    interface SAM {
+       Object m(int[] i);
+    }
+
+    public static void main(String[] args) {
+        SAM s = int[]::clone;
+        int[] iarr = { 1, 2, 3 };
+        int[] iarr2 = (int[])s.m(iarr);
+        if (iarr == iarr2) {
+            throw new AssertionError();
+        }
+        for (int i = 0 ; i < iarr.length ; i ++) {
+            if (iarr[i] != iarr2[i]) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference50.java b/test/tools/javac/lambda/MethodReference50.java
new file mode 100644
index 0000000..7da0950
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference50.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that erroneous method references are flagged with errors as expected
+ * @compile/fail/ref=MethodReference50.out -XDrawDiagnostics MethodReference50.java
+ */
+
+class MethodReference50 {
+
+    interface SAM1 {
+        void m();
+    }
+
+    interface SAM2 {
+        void m();
+    }
+
+    void call(SAM1 s) {}
+    void call(SAM2 s) {}
+
+    {
+        call(NonExistentType::m);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference50.out b/test/tools/javac/lambda/MethodReference50.out
new file mode 100644
index 0000000..3303de7
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference50.out
@@ -0,0 +1,2 @@
+MethodReference50.java:23:14: compiler.err.cant.resolve.location: kindname.variable, NonExistentType, , , (compiler.misc.location: kindname.class, MethodReference50, null)
+1 error
diff --git a/test/tools/javac/lambda/MethodReference51.java b/test/tools/javac/lambda/MethodReference51.java
new file mode 100644
index 0000000..1ce3d74
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference51.java
@@ -0,0 +1,46 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  certain cases of erroneous member reference lookup are not handled by Attr.visitReference
+ * @compile/fail/ref=MethodReference51.out -XDrawDiagnostics MethodReference51.java
+ */
+class MethodReference51 {
+
+    private static class Foo {
+        static int j(int i) { return i; }
+    }
+
+    static Foo foo = new Foo();
+
+    static void m(String s) { }
+    static void m(Integer i) { }
+
+    static int f(String s) { return 1; }
+
+    static int g(Integer i, Number n) { return 1; }
+    static int g(Number n, Integer i) { return 1; }
+
+    int h(int i) { return i; }
+}
+
+class TestMethodReference51 {
+
+    interface IntSam {
+        int m(int i);
+    }
+
+    interface IntegerIntegerSam {
+        int m(Integer i1, Integer i2);
+    }
+
+
+    static void test() {
+        IntSam s1 = MethodReference51::unknown; //method not found
+        IntSam s2 = MethodReference51::f; //inapplicable method
+        IntSam s3 = MethodReference51::g; //inapplicable methods
+        IntegerIntegerSam s4 = MethodReference51::g; //ambiguous
+        IntSam s5 = MethodReference51::h; //static error
+        IntSam s6 = MethodReference51.foo::j; //inaccessible method
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference51.out b/test/tools/javac/lambda/MethodReference51.out
new file mode 100644
index 0000000..4986561
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference51.out
@@ -0,0 +1,7 @@
+MethodReference51.java:39:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , int, (compiler.misc.location: kindname.class, MethodReference51, null))
+MethodReference51.java:40:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, f, java.lang.String, int, kindname.class, MethodReference51, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
+MethodReference51.java:41:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch))}))
+MethodReference51.java:42:32: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: g, kindname.method, g(java.lang.Integer,java.lang.Number), MethodReference51, kindname.method, g(java.lang.Number,java.lang.Integer), MethodReference51))
+MethodReference51.java:43:21: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int))
+MethodReference51.java:44:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo))
+6 errors
diff --git a/test/tools/javac/lambda/MethodReference52.java b/test/tools/javac/lambda/MethodReference52.java
new file mode 100644
index 0000000..49170d5
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference52.java
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  special cases of method references (getClass()/Array.clone()) not handled properly
+ * @compile/fail/ref=MethodReference52.out -XDrawDiagnostics MethodReference52.java
+ */
+import java.util.*;
+
+class MethodReference52 {
+
+    interface Clone1 {
+        int[] m();
+    }
+
+    interface Clone2 {
+        Object m();
+    }
+
+    interface WrongClone {
+        long[] m();
+    }
+
+    interface GetClass {
+        Class<? extends List> m();
+    }
+
+    interface WrongGetClass {
+        Class<List<String>> m();
+    }
+
+    void test(int[] iarr, List<String> ls) {
+        Clone1 c1 = iarr::clone; //ok
+        Clone2 c2 = iarr::clone; //ok - type more generic
+        WrongClone c3 = iarr::clone; //bad return type
+        GetClass c4 = ls::getClass; //ok
+        WrongGetClass c5 = ls::getClass; //bad return type
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference52.out b/test/tools/javac/lambda/MethodReference52.out
new file mode 100644
index 0000000..1802ab5
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference52.out
@@ -0,0 +1,3 @@
+MethodReference52.java:35:25: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], long[]))
+MethodReference52.java:37:28: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Class<? extends java.util.List>, java.lang.Class<java.util.List<java.lang.String>>))
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference53.java b/test/tools/javac/lambda/MethodReference53.java
new file mode 100644
index 0000000..df597d4
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference53.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  the case in which no member reference is found is now treated as a normal error (not dependent on target-type)
+ * @compile/fail/ref=MethodReference53.out -XDrawDiagnostics MethodReference53.java
+ */
+class MethodReference53 {
+
+    interface SAM1 {
+        void m(int i);
+    }
+
+    interface SAM2 {
+        void m(long i);
+    }
+
+    void m(SAM1 s1) { }
+    void m(SAM2 s1) { }
+
+    void test() {
+        m(this::unknown); //should not generate outer resolution diagnostic
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference53.out b/test/tools/javac/lambda/MethodReference53.out
new file mode 100644
index 0000000..f6f063f
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference53.out
@@ -0,0 +1,2 @@
+MethodReference53.java:22:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, MethodReference53, null))
+1 error
diff --git a/test/tools/javac/lambda/MethodReference54.java b/test/tools/javac/lambda/MethodReference54.java
new file mode 100644
index 0000000..f442735
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference54.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  method call with bad qualifier generates NPE if argument is a method reference
+ * @compile/fail/ref=MethodReference54.out -XDrawDiagnostics MethodReference54.java
+ */
+class MethodReference54 {
+
+    interface SAM {
+        void m();
+    }
+
+    void test() {
+        nonExistent.m(MethodReference54::get);
+    }
+
+    static String get() { return ""; }
+}
diff --git a/test/tools/javac/lambda/MethodReference54.out b/test/tools/javac/lambda/MethodReference54.out
new file mode 100644
index 0000000..02dba67
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference54.out
@@ -0,0 +1,2 @@
+MethodReference54.java:15:9: compiler.err.cant.resolve.location: kindname.variable, nonExistent, , , (compiler.misc.location: kindname.class, MethodReference54, null)
+1 error
diff --git a/test/tools/javac/lambda/MethodReference55.java b/test/tools/javac/lambda/MethodReference55.java
new file mode 100644
index 0000000..e21bf3e
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference55.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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 8004101
+ * @summary Add checks for method reference well-formedness
+ * @compile/fail/ref=MethodReference55.out -XDrawDiagnostics MethodReference55.java
+ */
+class MethodReference55<X> {
+
+    interface V {
+        void m(Object o);
+    }
+
+    V v = new MethodReference55<String>()::m;
+
+    void test() {
+        g(new MethodReference55<String>()::m);
+    }
+
+    void g(V v) { }
+
+    static void m(Object o) { };
+}
diff --git a/test/tools/javac/lambda/MethodReference55.out b/test/tools/javac/lambda/MethodReference55.out
new file mode 100644
index 0000000..8488a28
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference55.out
@@ -0,0 +1,3 @@
+MethodReference55.java:36:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.bound.mref)
+MethodReference55.java:39:11: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.bound.mref)
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference56.java b/test/tools/javac/lambda/MethodReference56.java
new file mode 100644
index 0000000..9e79fab
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference56.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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 8004101
+ * @summary Add checks for method reference well-formedness
+ * @compile/fail/ref=MethodReference56.out -XDrawDiagnostics MethodReference56.java
+ */
+class MethodReference56<X> {
+
+    interface V {
+        void m(Object o);
+    }
+
+    V v = MethodReference56<String>::m;
+
+    void test() {
+        g(MethodReference56<String>::m);
+    }
+
+    void g(V v) { }
+
+    static void m(Object o) { };
+}
diff --git a/test/tools/javac/lambda/MethodReference56.out b/test/tools/javac/lambda/MethodReference56.out
new file mode 100644
index 0000000..34ccd15
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference56.out
@@ -0,0 +1,3 @@
+MethodReference56.java:36:28: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.mref.with.targs)
+MethodReference56.java:39:28: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.mref.with.targs)
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference57.java b/test/tools/javac/lambda/MethodReference57.java
new file mode 100644
index 0000000..b24749f
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference57.java
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ *
+ * 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 8004102
+ * @summary Add support for generic functional descriptors
+ * @compile MethodReference57.java
+ */
+class MethodReference57 {
+
+    interface F {
+        <X> void m();
+    }
+
+    void test() {
+        F f = this::g; //ok
+    }
+
+    void g() { }
+}
diff --git a/test/tools/javac/lambda/MethodReference58.java b/test/tools/javac/lambda/MethodReference58.java
new file mode 100644
index 0000000..02652da
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference58.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ *
+ * 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 8004102
+ * @summary Add support for generic functional descriptors
+ * @compile/fail/ref=MethodReference58.out -XDrawDiagnostics MethodReference58.java
+ */
+class MethodReference58 {
+
+    interface F_Object {
+        <X> void m(X x);
+    }
+
+    interface F_Integer {
+        <X extends Integer> void m(X x);
+    }
+
+    void test() {
+        F_Object f1 = this::g; //incompatible bounds
+        F_Integer f2 = this::g; //ok
+    }
+
+    <Z extends Number> void g(Z z) { }
+}
diff --git a/test/tools/javac/lambda/MethodReference58.out b/test/tools/javac/lambda/MethodReference58.out
new file mode 100644
index 0000000..102facb
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference58.out
@@ -0,0 +1,2 @@
+MethodReference58.java:41:23: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, g, Z, X, kindname.class, MethodReference58, (compiler.misc.inferred.do.not.conform.to.upper.bounds: X, java.lang.Number)))
+1 error
diff --git a/test/tools/javac/lambda/MethodReference59.java b/test/tools/javac/lambda/MethodReference59.java
new file mode 100644
index 0000000..76b6669
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference59.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ *
+ * 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 8004102
+ * @summary Add support for array constructor references
+ */
+public class MethodReference59 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface ArrayFactory<X> {
+        X make(int size);
+    }
+
+    public static void main(String[] args) {
+        ArrayFactory<int[]> factory1 = int[]::new;
+        int[] i1 = factory1.make(5);
+        assertTrue(i1.length == 5);
+        ArrayFactory<int[][]> factory2 = int[][]::new;
+        int[][] i2 = factory2.make(5);
+        assertTrue(i2.length == 5);
+        assertTrue(assertionCount == 2);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference60.java b/test/tools/javac/lambda/MethodReference60.java
new file mode 100644
index 0000000..f8317af
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference60.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ * 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 8004102
+ * @summary Add support for array constructor references
+ * @compile/fail/ref=MethodReference60.out -XDrawDiagnostics MethodReference60.java
+ */
+public class MethodReference60 {
+
+    interface ArrayFactory<X> {
+        X make(int size);
+    }
+
+    interface BadArrayFactory1<X> {
+        X make();
+    }
+
+    interface BadArrayFactory2<X> {
+        X make(int i1, int i2);
+    }
+
+    interface BadArrayFactory3<X> {
+        X make(String s);
+    }
+
+    public static void main(String[] args) {
+        BadArrayFactory1<int[]> factory1 = int[]::new; //param mismatch
+        BadArrayFactory2<int[]> factory2 = int[]::new; //param mismatch
+        BadArrayFactory3<int[]> factory3 = int[]::new; //param mismatch
+        ArrayFactory<Integer> factory4 = int[]::new; //return type mismatch
+        ArrayFactory<Integer[]> factory5 = int[]::new; //return type mismatch
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference60.out b/test/tools/javac/lambda/MethodReference60.out
new file mode 100644
index 0000000..5aa973c
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference60.out
@@ -0,0 +1,6 @@
+MethodReference60.java:49:44: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Array, int, compiler.misc.no.args, kindname.class, Array, (compiler.misc.arg.length.mismatch)))
+MethodReference60.java:50:44: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Array, int, int,int, kindname.class, Array, (compiler.misc.arg.length.mismatch)))
+MethodReference60.java:51:44: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, Array, int, java.lang.String, kindname.class, Array, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int))))
+MethodReference60.java:52:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], java.lang.Integer))
+MethodReference60.java:53:44: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], java.lang.Integer[]))
+5 errors
diff --git a/test/tools/javac/lambda/MethodReference61.java b/test/tools/javac/lambda/MethodReference61.java
new file mode 100644
index 0000000..2bf7bdf
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference61.java
@@ -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 8006763
+ * @summary super in method reference used in anonymous class
+ */
+public class MethodReference61 {
+    interface SAM {
+        void m();
+    }
+
+    static class MyTester {
+        public void ifoo() { }
+    }
+
+    public static void main(String args[]) {
+        MyTester t = new MyTester() {
+            SAM s = super::ifoo;
+        };
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference62.java b/test/tools/javac/lambda/MethodReference62.java
new file mode 100644
index 0000000..e34b594
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference62.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007285
+ * @summary AbstractMethodError instead of compile-time error when method reference with super and abstract
+ * @compile/fail/ref=MethodReference62.out -XDrawDiagnostics MethodReference62.java
+ */
+class MethodReference62 {
+    interface SAM {
+        int m();
+    }
+
+    static abstract class Sup {
+        abstract int foo() ;
+    }
+
+    static abstract class Sub extends Sup {
+        abstract int foo() ;
+        void test() {
+            SAM s = super::foo;
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference62.out b/test/tools/javac/lambda/MethodReference62.out
new file mode 100644
index 0000000..79d51f3
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference62.out
@@ -0,0 +1,2 @@
+MethodReference62.java:19:21: compiler.err.abstract.cant.be.accessed.directly: kindname.method, foo(), MethodReference62.Sup
+1 error
diff --git a/test/tools/javac/lambda/MethodReference63.java b/test/tools/javac/lambda/MethodReference63.java
new file mode 100644
index 0000000..f89a83d
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference63.java
@@ -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 8005183
+ * @summary Missing accessor for constructor reference pointing to private inner class ctor
+ */
+public class MethodReference63 {
+
+    interface SAM {
+        void m();
+    }
+
+    static class Foo {
+        private Foo() { }
+    }
+
+    public static void main(String[] args) {
+        SAM s = Foo::new;
+        s.m();
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference64.java b/test/tools/javac/lambda/MethodReference64.java
new file mode 100644
index 0000000..27160f0
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference64.java
@@ -0,0 +1,46 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8008540 8008539 8008538
+ * @summary Constructor reference to non-reifiable array should be rejected
+ * @compile/fail/ref=MethodReference64.out -XDrawDiagnostics MethodReference64.java
+ */
+class MethodReference64 {
+    interface ClassFactory {
+        Object m();
+    }
+
+    interface ArrayFactory {
+        Object m(int i);
+    }
+
+    @interface Anno { }
+
+    enum E { }
+
+    interface I { }
+
+    static class Foo<X> { }
+
+    void m(ClassFactory cf) { }
+    void m(ArrayFactory cf) { }
+
+    void testAssign() {
+        ClassFactory c1 = Anno::new; //error
+        ClassFactory c2 = E::new; //error
+        ClassFactory c3 = I::new; //error
+        ClassFactory c4 = Foo<?>::new; //error
+        ClassFactory c5 = 1::new; //error
+        ArrayFactory a1 = Foo<?>[]::new; //ok
+        ArrayFactory a2 = Foo<? extends String>[]::new; //error
+    }
+
+    void testMethod() {
+        m(Anno::new); //error
+        m(E::new); //error
+        m(I::new); //error
+        m(Foo<?>::new); //error
+        m(1::new); //error
+        m(Foo<?>[]::new); //ok - resolves to m(ArrayFactory)
+        m(Foo<? extends String>[]::new); //error
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference64.out b/test/tools/javac/lambda/MethodReference64.out
new file mode 100644
index 0000000..03d6a94
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference64.out
@@ -0,0 +1,13 @@
+MethodReference64.java:28:27: compiler.err.abstract.cant.be.instantiated: MethodReference64.Anno
+MethodReference64.java:29:27: compiler.err.enum.cant.be.instantiated
+MethodReference64.java:30:27: compiler.err.abstract.cant.be.instantiated: MethodReference64.I
+MethodReference64.java:31:30: compiler.err.type.found.req: ?, (compiler.misc.type.req.exact)
+MethodReference64.java:32:27: compiler.err.unexpected.type: kindname.class, kindname.value
+MethodReference64.java:34:48: compiler.err.generic.array.creation
+MethodReference64.java:38:11: compiler.err.abstract.cant.be.instantiated: MethodReference64.Anno
+MethodReference64.java:39:11: compiler.err.enum.cant.be.instantiated
+MethodReference64.java:40:11: compiler.err.abstract.cant.be.instantiated: MethodReference64.I
+MethodReference64.java:41:14: compiler.err.type.found.req: ?, (compiler.misc.type.req.exact)
+MethodReference64.java:42:11: compiler.err.unexpected.type: kindname.class, kindname.value
+MethodReference64.java:44:32: compiler.err.generic.array.creation
+12 errors
diff --git a/test/tools/javac/lambda/MethodReference65.java b/test/tools/javac/lambda/MethodReference65.java
new file mode 100644
index 0000000..6d23b1f
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference65.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8009154
+ * @summary Missing cast in method reference bridge leads to NoSuchMethodError
+ */
+public class MethodReference65 {
+
+    interface SAM<X> {
+        void m(X ss, String s);
+    }
+
+    void m(String... s) { }
+
+    public static void main(String[] args) {
+        SAM<MethodReference65> st = MethodReference65::m;
+        st.m(new MethodReference65(), "");
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference66.java b/test/tools/javac/lambda/MethodReference66.java
new file mode 100644
index 0000000..6c6751c
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference66.java
@@ -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 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
+ */
+public class MethodReference66 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface SAM {
+        void m(int i);
+    }
+
+    interface I {
+        static void f(int i) { assertTrue(i == 42); }
+    }
+    public static void main(String[] args) {
+        SAM s = I::f;
+        s.m(42);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference67.java b/test/tools/javac/lambda/MethodReference67.java
new file mode 100644
index 0000000..7f98699
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference67.java
@@ -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;
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference67.out b/test/tools/javac/lambda/MethodReference67.out
new file mode 100644
index 0000000..7d06e04
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference67.out
@@ -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
diff --git a/test/tools/javac/lambda/MethodReference68.java b/test/tools/javac/lambda/MethodReference68.java
new file mode 100644
index 0000000..fa5f861
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference68.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile/fail/ref=MethodReference68.out -XDrawDiagnostics MethodReference68.java
+ */
+class MethodReference68 {
+    interface F<X> {
+       String m(X x);
+    }
+
+    static class Foo {
+        String getName() { return ""; }
+    }
+
+    @SuppressWarnings("unchecked")
+    <Z> void g(F<Z> fz, Z... zs) { }
+
+    void test() {
+         g(Foo::getName);
+         g(Foo::getName, 1); //incompatible constraints, Z <: Foo, Z :> Integer
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference68.out b/test/tools/javac/lambda/MethodReference68.out
new file mode 100644
index 0000000..2db24d1
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference68.out
@@ -0,0 +1,2 @@
+MethodReference68.java:21:10: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference68.F<Z>,Z[], @493,int, kindname.class, MethodReference68, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, MethodReference68.Foo,java.lang.Object)
+1 error
diff --git a/test/tools/javac/lambda/MethodReference69.java b/test/tools/javac/lambda/MethodReference69.java
new file mode 100644
index 0000000..70dc42d
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference69.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile/fail/ref=MethodReference69.out -XDrawDiagnostics MethodReference69.java
+ */
+class MethodReference69 {
+    interface F<X> {
+        String m(Integer x1, X x2);
+    }
+
+    static class Foo {
+        String getNameAt(Integer i) { return ""; }
+    }
+
+    <Z> void g(F<Z> fz) { }
+
+    void test() {
+         g(Foo::getName);
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference69.out b/test/tools/javac/lambda/MethodReference69.out
new file mode 100644
index 0000000..de40b53
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference69.out
@@ -0,0 +1,2 @@
+MethodReference69.java:19:12: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, getName, , , (compiler.misc.location: kindname.class, MethodReference69.Foo, null))
+1 error
diff --git a/test/tools/javac/lambda/MethodReference70.java b/test/tools/javac/lambda/MethodReference70.java
new file mode 100644
index 0000000..0cc26f5
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference70.java
@@ -0,0 +1,28 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile/fail/ref=MethodReference70.out -XDrawDiagnostics MethodReference70.java
+ */
+class MethodReference70 {
+    interface F<X> {
+        void m(X x);
+    }
+
+    interface G<X> {
+        Integer m(X x);
+    }
+
+    void m1(Integer i) { }
+
+    void m2(Integer i) { }
+    void m2(String i) { }
+
+    <Z> void g(F<Z> fz) { }
+    <Z> void g(G<Z> gz) { }
+
+    void test() {
+         g(this::m1); //ok
+         g(this::m2); //ambiguous (stuck!)
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference70.out b/test/tools/javac/lambda/MethodReference70.out
new file mode 100644
index 0000000..875b9d2
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference70.out
@@ -0,0 +1,3 @@
+MethodReference70.java:26:10: compiler.err.ref.ambiguous: g, kindname.method, <Z>g(MethodReference70.F<Z>), MethodReference70, kindname.method, <Z>g(MethodReference70.G<Z>), MethodReference70
+MethodReference70.java:26:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z)
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference71.java b/test/tools/javac/lambda/MethodReference71.java
new file mode 100644
index 0000000..5b59c7d
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference71.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile/fail/ref=MethodReference71.out -XDrawDiagnostics MethodReference71.java
+ */
+class MethodReference71 {
+    interface F<X> {
+        void m(X x);
+    }
+
+    interface G<X> {
+        Integer m(X x);
+    }
+
+    void m1(Integer i) { }
+    void m2(Integer... i) { }
+
+    <Z> void g(F<Z> f) { }
+    <Z> void g(G<Z> g) { }
+
+    void test() {
+         g(this::m1); //ok
+         g(this::m2); //ambiguous (stuck!)
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference71.out b/test/tools/javac/lambda/MethodReference71.out
new file mode 100644
index 0000000..f1a8942
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference71.out
@@ -0,0 +1,3 @@
+MethodReference71.java:24:10: compiler.err.ref.ambiguous: g, kindname.method, <Z>g(MethodReference71.F<Z>), MethodReference71, kindname.method, <Z>g(MethodReference71.G<Z>), MethodReference71
+MethodReference71.java:24:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z)
+2 errors
diff --git a/test/tools/javac/lambda/MethodReference72.java b/test/tools/javac/lambda/MethodReference72.java
new file mode 100644
index 0000000..b3dfa1b
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference72.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile/fail/ref=MethodReference72.out -XDrawDiagnostics MethodReference72.java
+ */
+class MethodReference72 {
+    interface F<X> {
+        @SuppressWarnings("unchecked")
+        void m(X... x);
+    }
+
+    void m1(Integer i) { }
+
+    <Z> void g(F<Z> f) { }
+
+    void test() {
+        g(this::m1); //?
+    }
+}
diff --git a/test/tools/javac/lambda/MethodReference72.out b/test/tools/javac/lambda/MethodReference72.out
new file mode 100644
index 0000000..cf4c08c
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReference72.out
@@ -0,0 +1,2 @@
+MethodReference72.java:18:9: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference72.F<Z>, @420, kindname.class, MethodReference72, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, m1, java.lang.Integer, Z[], kindname.class, MethodReference72, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: Z[], java.lang.Integer)))))
+1 error
diff --git a/test/tools/javac/lambda/MethodReferenceParserTest.java b/test/tools/javac/lambda/MethodReferenceParserTest.java
new file mode 100644
index 0000000..513f1e3
--- /dev/null
+++ b/test/tools/javac/lambda/MethodReferenceParserTest.java
@@ -0,0 +1,265 @@
+/*
+ * 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
+ * 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 7115052 8003280 8006694
+ * @summary Add lambda tests
+ *  Add parser support for method references
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm MethodReferenceParserTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import com.sun.source.util.JavacTask;
+
+public class MethodReferenceParserTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum ReferenceKind {
+        METHOD_REF("#Q::#Gm"),
+        CONSTRUCTOR_REF("#Q::#Gnew"),
+        FALSE_REF("min < max"),
+        ERR_SUPER("#Q::#Gsuper"),
+        ERR_METH0("#Q::#Gm()"),
+        ERR_METH1("#Q::#Gm(X)"),
+        ERR_CONSTR0("#Q::#Gnew()"),
+        ERR_CONSTR1("#Q::#Gnew(X)");
+
+        String referenceTemplate;
+
+        ReferenceKind(String referenceTemplate) {
+            this.referenceTemplate = referenceTemplate;
+        }
+
+        String getReferenceString(QualifierKind qk, GenericKind gk) {
+            return referenceTemplate
+                    .replaceAll("#Q", qk.qualifier)
+                    .replaceAll("#G", gk.typeParameters);
+        }
+
+        boolean erroneous() {
+            switch (this) {
+                case ERR_SUPER:
+                case ERR_METH0:
+                case ERR_METH1:
+                case ERR_CONSTR0:
+                case ERR_CONSTR1:
+                    return true;
+                default: return false;
+            }
+        }
+    }
+
+    enum ContextKind {
+        ASSIGN("SAM s = #E;"),
+        METHOD("m(#E, i);");
+
+        String contextTemplate;
+
+        ContextKind(String contextTemplate) {
+            this.contextTemplate = contextTemplate;
+        }
+
+        String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk,
+                GenericKind gk, SubExprKind sk) {
+            return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
+        }
+    }
+
+    enum GenericKind {
+        NONE(""),
+        ONE("<X>"),
+        TWO("<X,Y>");
+
+        String typeParameters;
+
+        GenericKind(String typeParameters) {
+            this.typeParameters = typeParameters;
+        }
+    }
+
+    enum QualifierKind {
+        THIS("this"),
+        SUPER("super"),
+        NEW("new Foo()"),
+        METHOD("m()"),
+        FIELD("a.f"),
+        UBOUND_SIMPLE("A"),
+        UNBOUND_ARRAY1("int[]"),
+        UNBOUND_ARRAY2("A<G>[][]"),
+        UNBOUND_GENERIC1("A<X>"),
+        UNBOUND_GENERIC2("A<X, Y>"),
+        UNBOUND_GENERIC3("A<? extends X, ? super Y>"),
+        UNBOUND_GENERIC4("A<int[], short[][]>"),
+        NESTED_GENERIC1("A<A<X,Y>, A<X,Y>>"),
+        NESTED_GENERIC2("A<A<A<X,Y>,A<X,Y>>, A<A<X,Y>,A<X,Y>>>");
+
+        String qualifier;
+
+        QualifierKind(String qualifier) {
+            this.qualifier = qualifier;
+        }
+    }
+
+    enum ExprKind {
+        NONE("#R::S"),
+        SINGLE_PAREN1("(#R#S)"),
+        SINGLE_PAREN2("(#R)#S"),
+        DOUBLE_PAREN1("((#R#S))"),
+        DOUBLE_PAREN2("((#R)#S)"),
+        DOUBLE_PAREN3("((#R))#S");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) {
+            return expressionTemplate
+                    .replaceAll("#R", rk.getReferenceString(qk, gk))
+                    .replaceAll("#S", sk.subExpression);
+        }
+    }
+
+    enum SubExprKind {
+        NONE(""),
+        SELECT_FIELD(".f"),
+        SELECT_METHOD(".f()"),
+        SELECT_NEW(".new Foo()"),
+        POSTINC("++"),
+        POSTDEC("--");
+
+        String subExpression;
+
+        SubExprKind(String subExpression) {
+            this.subExpression = subExpression;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ReferenceKind rk : ReferenceKind.values()) {
+            for (QualifierKind qk : QualifierKind.values()) {
+                for (GenericKind gk : GenericKind.values()) {
+                    for (SubExprKind sk : SubExprKind.values()) {
+                        for (ExprKind ek : ExprKind.values()) {
+                            for (ContextKind ck : ContextKind.values()) {
+                                pool.execute(new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    ReferenceKind rk;
+    QualifierKind qk;
+    GenericKind gk;
+    SubExprKind sk;
+    ExprKind ek;
+    ContextKind ck;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek, ContextKind ck) {
+        this.rk = rk;
+        this.qk = qk;
+        this.gk = gk;
+        this.sk = sk;
+        this.ek = ek;
+        this.ck = ck;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   void test() {\n" +
+                          "      #C\n" +
+                          "   }" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#C", ck.contextString(ek, rk, qk, gk, sk));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    @Override
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            processException(ex);
+            return;
+        }
+        check();
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        if (diagChecker.errorFound != rk.erroneous()) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + rk.erroneous());
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/MostSpecific01.java b/test/tools/javac/lambda/MostSpecific01.java
new file mode 100644
index 0000000..f915c53
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific01.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific01.out -XDrawDiagnostics MostSpecific01.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, String s) { }
+    void m(LongMapper lm, Integer s) { }
+
+    void test() {
+        m(()->1, null);
+    }
+}
diff --git a/test/tools/javac/lambda/MostSpecific01.out b/test/tools/javac/lambda/MostSpecific01.out
new file mode 100644
index 0000000..da2f5c0
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific01.out
@@ -0,0 +1,2 @@
+MostSpecific01.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,java.lang.String), Test, kindname.method, m(Test.LongMapper,java.lang.Integer), Test
+1 error
diff --git a/test/tools/javac/lambda/MostSpecific02.java b/test/tools/javac/lambda/MostSpecific02.java
new file mode 100644
index 0000000..af5349a
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific02.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific02.out -XDrawDiagnostics MostSpecific02.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper im, LongMapper s) { }
+    void m(LongMapper lm, IntMapper s) { }
+
+    void test() {
+        m(()->1, ()->1);
+    }
+}
diff --git a/test/tools/javac/lambda/MostSpecific02.out b/test/tools/javac/lambda/MostSpecific02.out
new file mode 100644
index 0000000..814fefb
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific02.out
@@ -0,0 +1,2 @@
+MostSpecific02.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper,Test.LongMapper), Test, kindname.method, m(Test.LongMapper,Test.IntMapper), Test
+1 error
diff --git a/test/tools/javac/lambda/MostSpecific03.java b/test/tools/javac/lambda/MostSpecific03.java
new file mode 100644
index 0000000..8fb8e78
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific03.java
@@ -0,0 +1,63 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check correctness of structural most specific test routine
+ * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java
+ */
+
+class Test {
+
+    interface IntMapper {
+        int map();
+    }
+
+    interface LongMapper {
+        long map();
+    }
+
+    void m(IntMapper... im) { }
+    void m(LongMapper... lm) { }
+
+    void m2(IntMapper im1, IntMapper... im) { }
+    void m2(LongMapper... lm) { }
+
+    void test1() {
+        m(); //ambiguous
+        m(()->1); //ok
+        m(()->1, ()->1); //ok
+        m(()->1, ()->1, ()->1); //ok
+    }
+
+    void test2() {
+        m(null, null); //ambiguous
+        m(()->1, null); //ambiguous
+        m(null, ()->1); //ambiguous
+        m(()->1L, null); //ok
+        m(null, ()->1L); //ok
+    }
+
+    void test3() {
+        m2(); //ok
+        m2(()->1); //ambiguous
+        m2(()->1, ()->1); //ok
+        m2(()->1, ()->1, ()->1); //ok
+    }
+
+    void test4() {
+        m2(null, null, null); //ambiguous
+        m2(()->1, null, null); //ambiguous
+        m2(null, ()->1, null); //ambiguous
+        m2(null, null, ()->1); //ambiguous
+        m2(()->1, ()->1, null); //ambiguous
+        m2(null, ()->1, ()->1); //ambiguous
+        m2(()->1, null, ()->1); //ambiguous
+
+        m2(()->1L, null, null); //ok
+        m2(null, ()->1L, null); //ok
+        m2(null, null, ()->1L); //ok
+        m2(()->1L, ()->1L, null); //ok
+        m2(null, ()->1L, ()->1L); //ok
+        m2(()->1L, null, ()->1L); //ok
+    }
+}
diff --git a/test/tools/javac/lambda/MostSpecific03.out b/test/tools/javac/lambda/MostSpecific03.out
new file mode 100644
index 0000000..6bb4fed
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific03.out
@@ -0,0 +1,13 @@
+MostSpecific03.java:26:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:33:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:34:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:35:9: compiler.err.ref.ambiguous: m, kindname.method, m(Test.IntMapper...), Test, kindname.method, m(Test.LongMapper...), Test
+MostSpecific03.java:42:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:48:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:49:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:50:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:51:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:52:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:53:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+MostSpecific03.java:54:9: compiler.err.ref.ambiguous: m2, kindname.method, m2(Test.IntMapper,Test.IntMapper...), Test, kindname.method, m2(Test.LongMapper...), Test
+12 errors
diff --git a/test/tools/javac/lambda/MostSpecific04.java b/test/tools/javac/lambda/MostSpecific04.java
new file mode 100644
index 0000000..c5fbc3d
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific04.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific04 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface DoubleMapper<T> {
+        double map(T t);
+    }
+
+    interface LongMapper<T> {
+        long map(T t);
+    }
+
+    static class MyList<E> {
+        void map(DoubleMapper<? super E> m) { assertTrue(false); }
+        void map(LongMapper<? super E> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyList<String> ls = new MyList<String>();
+        ls.map(e->e.length());
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MostSpecific05.java b/test/tools/javac/lambda/MostSpecific05.java
new file mode 100644
index 0000000..177a43e
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific05.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  Structural most specific doesn't handle cases with wildcards in functional interfaces
+ */
+public class MostSpecific05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface ObjectConverter<T extends Object> {
+        T map(Object o);
+    }
+
+    interface NumberConverter<T extends Number> {
+        T map(Object o);
+    }
+
+    static class MyMapper<A extends Object, B extends Number> {
+        void map(ObjectConverter<? extends A> m) { assertTrue(false); }
+        void map(NumberConverter<? extends B> m) { assertTrue(true); }
+    }
+
+    public static void main(String[] args) {
+        MyMapper<Number, Double> mm = new MyMapper<Number, Double>();
+        mm.map(e->1.0);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/MostSpecific06.java b/test/tools/javac/lambda/MostSpecific06.java
new file mode 100644
index 0000000..d8f48e9
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific06.java
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  most specific resolution crashes on stuck lambdas
+ * @compile/fail/ref=MostSpecific06.out -XDrawDiagnostics MostSpecific06.java
+ */
+import java.util.*;
+
+class MostSpecific06 {
+
+    interface Predicate<X> {
+        boolean accept(X x);
+    }
+
+    interface ExtPredicate<X> extends Predicate<X> { }
+
+
+
+    void test(boolean cond, ArrayList<String> als) {
+        m(u -> true, als, als);
+        m((u -> true), als, als);
+        m(cond ? u -> true : u -> false, als, als);
+    }
+
+    <U> U m(Predicate<U> p, List<U> lu, ArrayList<U> au) { return null; }
+
+
+    <U> U m(ExtPredicate<U> ep, ArrayList<U> au, List<U> lu) { return null; }
+}
diff --git a/test/tools/javac/lambda/MostSpecific06.out b/test/tools/javac/lambda/MostSpecific06.out
new file mode 100644
index 0000000..83e47c5
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific06.out
@@ -0,0 +1,4 @@
+MostSpecific06.java:21:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:22:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+MostSpecific06.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U>m(MostSpecific06.Predicate<U>,java.util.List<U>,java.util.ArrayList<U>), MostSpecific06, kindname.method, <U>m(MostSpecific06.ExtPredicate<U>,java.util.ArrayList<U>,java.util.List<U>), MostSpecific06
+3 errors
diff --git a/test/tools/javac/lambda/MostSpecific07.java b/test/tools/javac/lambda/MostSpecific07.java
new file mode 100644
index 0000000..a128cd4
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific07.java
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  speculative cache contents are overwritten by deferred type-checking of nested stuck expressions
+ * @compile/fail/ref=MostSpecific07.out -XDrawDiagnostics MostSpecific07.java
+ */
+import java.util.*;
+
+class MostSpecific07 {
+
+    interface Predicate<X, Y> {
+        Y accept(X x);
+    }
+
+    interface VoidMapper {
+        void accept();
+    }
+
+    interface ExtPredicate<X, Y> extends Predicate<X, Y> { }
+
+    void test(boolean cond, ArrayList<String> als, VoidMapper vm) {
+        m(u -> ()->{}, als, als, vm);
+        m((u -> ()->{}), als, als, vm);
+        m(cond ? u -> ()->{} : u -> ()->{}, als, als, vm);
+    }
+
+    <U, V> U m(Predicate<U, V> p, List<U> lu, ArrayList<U> au, V v) { return null; }
+
+    <U, V> U m(ExtPredicate<U, V> ep, ArrayList<U> au, List<U> lu, V v) { return null; }
+}
diff --git a/test/tools/javac/lambda/MostSpecific07.out b/test/tools/javac/lambda/MostSpecific07.out
new file mode 100644
index 0000000..76fc516
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific07.out
@@ -0,0 +1,4 @@
+MostSpecific07.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:24:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+MostSpecific07.java:25:9: compiler.err.ref.ambiguous: m, kindname.method, <U,V>m(MostSpecific07.Predicate<U,V>,java.util.List<U>,java.util.ArrayList<U>,V), MostSpecific07, kindname.method, <U,V>m(MostSpecific07.ExtPredicate<U,V>,java.util.ArrayList<U>,java.util.List<U>,V), MostSpecific07
+3 errors
diff --git a/test/tools/javac/lambda/MostSpecific08.java b/test/tools/javac/lambda/MostSpecific08.java
new file mode 100644
index 0000000..453f04c
--- /dev/null
+++ b/test/tools/javac/lambda/MostSpecific08.java
@@ -0,0 +1,62 @@
+/*
+ * 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 8008813
+ * @summary Structural most specific fails when method reference is passed to overloaded method
+ * @compile MostSpecific08.java
+ */
+class MostSpecific08 {
+
+    static class C {
+        int getInt() { return -1; }
+        Integer getInteger() { return -1; }
+    }
+
+    interface IntResult { }
+    interface ReferenceResult<X> { }
+
+    interface PrimitiveFunction {
+        int f(C c);
+    }
+
+    interface ReferenceFunction<X> {
+        X f(C c);
+    }
+
+    interface Tester {
+        IntResult apply(PrimitiveFunction p);
+        <Z> ReferenceResult<Z> apply(ReferenceFunction<Z> p);
+    }
+
+    void testMref(Tester t) {
+        IntResult pr = t.apply(C::getInt);
+        ReferenceResult<Integer> rr = t.apply(C::getInteger);
+    }
+
+    void testLambda(Tester t) {
+        IntResult pr = t.apply(c->c.getInt());
+        ReferenceResult<Integer> rr = t.apply(c->c.getInteger());
+    }
+}
diff --git a/test/tools/javac/lambda/NakedThis.java b/test/tools/javac/lambda/NakedThis.java
new file mode 100644
index 0000000..0cb6cab
--- /dev/null
+++ b/test/tools/javac/lambda/NakedThis.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  basic test for capture of non-mutable locals
+ * @author  Brian Goetz
+ * @author  Maurizio Cimadamore
+ * @compile NakedThis.java
+ */
+
+class NakedThis {
+
+    interface SAM {
+        NakedThis m(int x);
+    }
+
+    SAM s1 = (int x) -> this;
+    SAM s2 = (int x) -> NakedThis.this;
+}
diff --git a/test/tools/javac/lambda/NestedCapture01.java b/test/tools/javac/lambda/NestedCapture01.java
new file mode 100644
index 0000000..4b7e903
--- /dev/null
+++ b/test/tools/javac/lambda/NestedCapture01.java
@@ -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 8012238
+ * @summary Nested method capture and inference
+ * @compile NestedCapture01.java
+ */
+class NestedCapture01 {
+
+    void test(String s) {
+       g(m(s.getClass()));
+    }
+
+    <F extends String> F m(Class<F> cf) {
+       return null;
+    }
+
+    <P extends String> P g(P vo) {
+       return null;
+    }
+}
diff --git a/test/tools/javac/lambda/NestedCapture02.java b/test/tools/javac/lambda/NestedCapture02.java
new file mode 100644
index 0000000..89f2589
--- /dev/null
+++ b/test/tools/javac/lambda/NestedCapture02.java
@@ -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 8012238
+ * @summary Nested method capture and inference
+ * @compile NestedCapture02.java
+ */
+class NestedCapture02<S,T> {
+
+     <S,T> NestedCapture02<S,T> create(NestedCapture02<? super S,?> first,
+             NestedCapture02<? super S, T> second) {
+         return null;
+     }
+
+     <U> NestedCapture02<S, ? extends U> cast(Class<U> target) { return null; }
+
+     <U> NestedCapture02<S, ? extends U> test(Class<U> target,
+             NestedCapture02<? super S, ?> first, NestedCapture02<? super S, T> second) {
+        return create(first, second.cast(target));
+     }
+}
diff --git a/test/tools/javac/lambda/NestedCapture03.java b/test/tools/javac/lambda/NestedCapture03.java
new file mode 100644
index 0000000..11a0f2e
--- /dev/null
+++ b/test/tools/javac/lambda/NestedCapture03.java
@@ -0,0 +1,36 @@
+/*
+ * 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 8012238
+ * @summary Nested method capture and inference
+ * @compile NestedCapture03.java
+ */
+class NestedCapture03 {
+    <T extends String> T factory(Class<T> c) { return null; }
+
+    void test(Class<?> c) {
+        factory(c.asSubclass(String.class)).matches(null);
+    }
+}
diff --git a/test/tools/javac/lambda/NoWarnOnImplicitParams.java b/test/tools/javac/lambda/NoWarnOnImplicitParams.java
new file mode 100644
index 0000000..39a1da5
--- /dev/null
+++ b/test/tools/javac/lambda/NoWarnOnImplicitParams.java
@@ -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 {}
+}
diff --git a/test/tools/javac/lambda/NoWarnOnImplicitParams.out b/test/tools/javac/lambda/NoWarnOnImplicitParams.out
new file mode 100644
index 0000000..684de0f
--- /dev/null
+++ b/test/tools/javac/lambda/NoWarnOnImplicitParams.out
@@ -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
diff --git a/test/tools/javac/lambda/SerializedLambdaInInit.java b/test/tools/javac/lambda/SerializedLambdaInInit.java
new file mode 100644
index 0000000..cafa39c
--- /dev/null
+++ b/test/tools/javac/lambda/SerializedLambdaInInit.java
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+/*
+ at test
+ at bug 8009742
+ at summary Bad method name: Serialized lambda in a constructor or class init
+*/
+
+import java.io.*;
+import java.lang.reflect.Method;
+
+public class SerializedLambdaInInit {
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static LSI cvisi = z -> "[" + z + "]";
+    static LSI cisi;
+
+    static {
+        cisi = z -> z + z;
+    }
+
+    LSI ivsi = z -> "blah";
+    LSI iisi;
+
+    SerializedLambdaInInit() {
+        iisi = z -> "*" + z;
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            // Write lambdas out
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutput out = new ObjectOutputStream(baos);
+            SerializedLambdaInInit slii = new SerializedLambdaInInit();
+
+            write(out, cvisi );
+            write(out, cisi );
+            write(out, slii.ivsi );
+            write(out, slii.iisi );
+            out.flush();
+            out.close();
+
+            // Read them back
+            ByteArrayInputStream bais =
+                new ByteArrayInputStream(baos.toByteArray());
+            ObjectInputStream in = new ObjectInputStream(bais);
+            readAssert(in, "[X]");
+            readAssert(in, "XX");
+            readAssert(in, "blah");
+            readAssert(in, "*X");
+            in.close();
+
+            // Reflectively test for valid method names
+            for (Method meth : slii.getClass().getDeclaredMethods()) {
+                checkIdentifier(meth.getName());
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        }
+        assertTrue(assertionCount == 4);
+    }
+
+    static void write(ObjectOutput out, LSI lamb) throws IOException {
+        out.writeObject(lamb);
+    }
+
+    static void readAssert(ObjectInputStream in, String expected)  throws IOException, ClassNotFoundException {
+        LSI ls = (LSI) in.readObject();
+        String result = ls.convert("X");
+        System.out.printf("Result: %s\n", result);
+        assertTrue(result.equals(expected));
+    }
+
+    public static void checkIdentifier(String str) throws Exception {
+        // null and zero length identifers will throw their own exceptions
+        char[] chars = str.toCharArray();
+        if (!Character.isJavaIdentifierStart(chars[0])) {
+            throw new IllegalArgumentException(str + ": bad identifier start character: '" + chars[0] + "'");
+        }
+        for (char ch : chars) {
+            if (!Character.isJavaIdentifierPart(ch)) {
+                throw new IllegalArgumentException(str + ": bad identifier character: '" + ch + "'");
+            }
+        }
+    }
+}
+
+interface LSI extends Serializable {
+    String convert(String x);
+}
diff --git a/test/tools/javac/lambda/SourceLevelTest.java b/test/tools/javac/lambda/SourceLevelTest.java
new file mode 100644
index 0000000..11ef228
--- /dev/null
+++ b/test/tools/javac/lambda/SourceLevelTest.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that lambda features are not enabled with source < 8
+ * @compile/fail/ref=SourceLevelTest.out -XDrawDiagnostics -source 7 SourceLevelTest.java
+ */
+
+class SourceLevelTest {
+    interface I {
+        default void m() { SourceLevelTest.impl(this); }
+    }
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s1 = () -> { };
+    SAM s2 = this::m;
+
+    static void impl(I i) {}
+    void m() {}
+}
diff --git a/test/tools/javac/lambda/SourceLevelTest.out b/test/tools/javac/lambda/SourceLevelTest.out
new file mode 100644
index 0000000..a9ed3bb
--- /dev/null
+++ b/test/tools/javac/lambda/SourceLevelTest.out
@@ -0,0 +1,6 @@
+- compiler.warn.source.no.bootclasspath: 1.7
+SourceLevelTest.java:11:9: compiler.err.default.methods.not.supported.in.source: 1.7
+SourceLevelTest.java:18:17: compiler.err.lambda.not.supported.in.source: 1.7
+SourceLevelTest.java:19:20: compiler.err.method.references.not.supported.in.source: 1.7
+3 errors
+1 warning
diff --git a/test/tools/javac/lambda/StaticMethodNegTest.java b/test/tools/javac/lambda/StaticMethodNegTest.java
new file mode 100644
index 0000000..2acfc84
--- /dev/null
+++ b/test/tools/javac/lambda/StaticMethodNegTest.java
@@ -0,0 +1,26 @@
+/**
+ * @test    /nodynamiccopyright/
+ * @bug     8008337
+ * @author  sogoel
+ * @summary static method is called via super
+ * @compile/fail/ref=StaticMethodNegTest.out -XDrawDiagnostics StaticMethodNegTest.java
+ */
+
+interface A {
+  static String m() {
+    return "A";
+  }
+}
+
+interface B {
+  static String m() {
+    return "B";
+  }
+}
+
+interface AB extends A, B {
+ static String m() {
+   return A.super.m();
+ }
+}
+
diff --git a/test/tools/javac/lambda/StaticMethodNegTest.out b/test/tools/javac/lambda/StaticMethodNegTest.out
new file mode 100644
index 0000000..6e2258e
--- /dev/null
+++ b/test/tools/javac/lambda/StaticMethodNegTest.out
@@ -0,0 +1,2 @@
+StaticMethodNegTest.java:23:12: compiler.err.not.encl.class: A
+1 error
diff --git a/test/tools/javac/lambda/TargetType01.java b/test/tools/javac/lambda/TargetType01.java
new file mode 100644
index 0000000..0e8f16c
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType01.java
@@ -0,0 +1,47 @@
+/*
+ * 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
+ * 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 8003280 8009131
+ * @summary Add lambda tests
+ *  check nested case of overload resolution and lambda parameter inference
+ * @compile TargetType01.java
+ */
+
+class TargetType01 {
+
+    interface Func<A,B> {
+        B call(A a);
+    }
+
+    interface F_I_I extends Func<Integer,Integer> {}
+    interface F_S_S extends Func<String,String> {}
+
+    static Integer M(F_I_I f){ return null; }
+    static String M(F_S_S f){ return null; }
+
+    static {
+        M(x1 -> { return M( x2 -> { return x1 + x2; });}); //ambiguous
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType02.java b/test/tools/javac/lambda/TargetType02.java
new file mode 100644
index 0000000..f5141ed
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType02.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType02
+ */
+
+public class TargetType02 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface S1<X extends Number> {
+        X m(Integer x);
+    }
+
+    interface S2<X extends String> {
+        abstract X m(Integer x);
+    }
+
+    static <Z extends Number> void call(S1<Z> s) { s.m(1); assertTrue(true); }
+    static <Z extends String> void call(S2<Z> s) { s.m(2); assertTrue(false); }
+
+    void test() {
+        call(i -> { toString(); return i; });
+    }
+
+    public static void main(String[] args) {
+        new TargetType02().test();
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType03.java b/test/tools/javac/lambda/TargetType03.java
new file mode 100644
index 0000000..b413c09
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType03.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check overload resolution and target type inference w.r.t. generic methods
+ * @author  Maurizio Cimadamore
+ * @run main TargetType03
+ */
+import java.util.*;
+
+public class TargetType03 {
+
+    interface Mapper<X,Y> {
+        Y myMap(X a);
+    }
+
+    static class MapperList<A> extends ArrayList<A> {
+        public <B> List<B> myMap(Mapper<A, B> mapper) {
+            ArrayList<B> mappedList = new ArrayList<>();
+            for (A elem : this) {
+                mappedList.add(mapper.myMap(elem));
+            }
+            return mappedList;
+        };
+    }
+
+    public static void main(String[] args) {
+        MapperList<Integer> numbers = new MapperList<>();
+        numbers.add(1);
+        numbers.add(2);
+        numbers.add(3);
+        numbers.add(4);
+        numbers.add(5);
+        List<Integer> sqNumbers = numbers.myMap(a -> a * a);
+        //check invariants
+        if (numbers.size() != sqNumbers.size()) {
+            throw new AssertionError();
+        }
+        for (int i = 0; i < numbers.size() ; i ++) {
+            if (sqNumbers.get(i) != Math.pow(numbers.get(i), 2)) {
+                throw new AssertionError();
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType04.java b/test/tools/javac/lambda/TargetType04.java
new file mode 100644
index 0000000..103b8ff
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType04.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target typing in assignment context
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType04.out -XDrawDiagnostics TargetType04.java
+ */
+class TargetType04 {
+
+    interface S<X extends Number, Y extends Number> {
+       Y m(X x);
+    }
+
+    S<Integer, Integer> s1 = i -> { return i; }; //ok
+    S<Double, Integer> s2 = i -> { return i; }; //no
+    S<Integer, Double> s3 = i -> { return i; }; //no
+}
diff --git a/test/tools/javac/lambda/TargetType04.out b/test/tools/javac/lambda/TargetType04.out
new file mode 100644
index 0000000..e31efd4
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType04.out
@@ -0,0 +1,3 @@
+TargetType04.java:16:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Double, java.lang.Integer))
+TargetType04.java:17:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Double))
+2 errors
diff --git a/test/tools/javac/lambda/TargetType05.java b/test/tools/javac/lambda/TargetType05.java
new file mode 100644
index 0000000..936b133
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType05.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  test recursion through SAM type
+ * @author  Maurizio Cimadamore
+ * @run main TargetType05
+ */
+public class TargetType05 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface Func<A,R> {
+        R call(A a);
+    }
+
+    static Func<Integer, Integer> f;
+
+    public static void main(String[] args) {
+        f = i -> { return i == 1 ? 1 : f.call(i-1) * i; };
+        assertTrue(f.call(5) == 120);
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType06.java b/test/tools/javac/lambda/TargetType06.java
new file mode 100644
index 0000000..39aaf68
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType06.java
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check complex case of target typing
+ * @author  Maurizio Cimadamore
+ * @compile TargetType06.java
+ */
+
+import java.util.List;
+
+class TargetType06 {
+
+    class Foo {
+        Foo getFoo() { return null; }
+    }
+
+    interface Function<A,R> {
+        R invoke(A a);
+    }
+
+    static <B> List<B> map(Function<B, B> function) { return null; }
+
+    void test() {
+        List<Foo> l = map(foo -> foo.getFoo());
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType07.java b/test/tools/javac/lambda/TargetType07.java
new file mode 100644
index 0000000..bb897e6
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType07.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that explicit generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType07.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1<X> { X m(); }
+    public interface SAM2<X> { X m(); }
+
+    public static <X> void call(SAM1<X> s) { }
+    public static <X> void call(SAM2<X> s) { }
+
+    public static void main(String[] args) {
+        call((SAM1<Integer>)()-> 1 );
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType08.java b/test/tools/javac/lambda/TargetType08.java
new file mode 100644
index 0000000..21711ef
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType08.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that explicit non-generic target type parses w/o problems
+ * @author  Peter Levart
+ * @author  Maurizio Cimadamore
+ * @compile TargetType08.java
+ */
+
+class TargetType07 {
+
+    public interface SAM1 { String m(); }
+    public interface SAM2 { Comparable<?> m(); }
+
+    public static void call(SAM1 s) { }
+    public static void call(SAM2 s) { }
+
+    public static void main(String[] args) {
+        call((SAM1)()-> "Hello!" );
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType10.java b/test/tools/javac/lambda/TargetType10.java
new file mode 100644
index 0000000..39afaee
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType10.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType10.out -XDrawDiagnostics TargetType10.java
+ */
+
+class TargetType10 {
+    interface Function<A,R> {
+        R apply(A a);
+    }
+
+    static class Test {
+        <A,B,C> Function<A,C> compose(Function<B,C> g, Function<A,? extends B> f) { return null; }
+        { compose(x ->  "a" + x, x -> x + "b"); }
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType10.out b/test/tools/javac/lambda/TargetType10.out
new file mode 100644
index 0000000..eaf9bb3
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType10.out
@@ -0,0 +1,2 @@
+TargetType10.java:17:18: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: B,A)
+1 error
diff --git a/test/tools/javac/lambda/TargetType11.java b/test/tools/javac/lambda/TargetType11.java
new file mode 100644
index 0000000..99359aa
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType11.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that wildcards in the target method of a lambda conversion is handled correctly
+ * @author  Maurizio Cimadamore
+ * @compile TargetType11.java
+ */
+
+class TargetType11 {
+    interface Predicate<X> {
+        boolean apply(X c);
+    }
+
+    static class Test {
+        public <T> Predicate<T> and(Predicate<? super T>... first) { return null; }
+        public Predicate<Character> forPredicate(Predicate<? super Character> predicate) { return null; }
+
+        Predicate<Character> c2 = forPredicate(c -> c.compareTo('e') < 0);
+        Predicate<Integer> k = and(i -> i > 0, i -> i % 2 == 0);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType12.java b/test/tools/javac/lambda/TargetType12.java
new file mode 100644
index 0000000..a04ec71
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType12.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  Flow should not analyze lambda body that contains errors due to partially specified parameter types
+ * @author  Maurizio Cimadamore
+ * @compile TargetType12.java
+ */
+
+import java.util.*;
+
+class TargetType12 {
+
+    interface Extractor<X,Y> {
+       Y get(X x);
+    }
+
+    static <T, U extends Comparable<? super U>> void sortBy2(T[] array, Extractor<T, U> extractor) {
+        Comparator<T> comparator = (left,right) -> extractor.get(left).compareTo(extractor.get(right));
+        Arrays.sort(array, comparator);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType13.java b/test/tools/javac/lambda/TargetType13.java
new file mode 100644
index 0000000..d391315
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType13.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  failure to infer exception thrown types from lambda body causes checked exception to be skipped
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType13.out -XDlambdaInferenceDiags=false -XDrawDiagnostics TargetType13.java
+ */
+
+class TargetType13 {
+
+    interface SAM<E extends Throwable> {
+       void m(Integer x) throws E;
+    }
+
+    static <E extends Throwable> void call(SAM<E> s) throws E { }
+
+    void test() {
+        call(i -> { if (i == 2) throw new Exception(); return; });
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType13.out b/test/tools/javac/lambda/TargetType13.out
new file mode 100644
index 0000000..cd75acd
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType13.out
@@ -0,0 +1,2 @@
+TargetType13.java:19:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+1 error
diff --git a/test/tools/javac/lambda/TargetType14.java b/test/tools/javac/lambda/TargetType14.java
new file mode 100644
index 0000000..c976a3b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType14.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that return type is inferred from target type when cyclic inference found
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=TargetType14.out -XDrawDiagnostics TargetType14.java
+ */
+
+class TargetType14 {
+
+    interface SAM<X> {
+        X m(int i, int j);
+    }
+
+    static void test() {
+        SAM<Integer> s1 = (i, j) -> i + j;
+        m((i, j) -> i + j);
+        SAM<Integer> s2 = m2((i, j) -> i + j); //ok
+        SAM<Integer> s3 = m2((i, j) -> "" + i + j); //no
+    }
+
+    static void m(SAM<Integer> s) { }
+    static <X> SAM<X> m2(SAM<X> s) { return null; }
+}
diff --git a/test/tools/javac/lambda/TargetType14.out b/test/tools/javac/lambda/TargetType14.out
new file mode 100644
index 0000000..fc03187
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType14.out
@@ -0,0 +1,2 @@
+TargetType14.java:20:29: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.lower.bounds: X, java.lang.Integer, java.lang.String)
+1 error
diff --git a/test/tools/javac/lambda/TargetType15.java b/test/tools/javac/lambda/TargetType15.java
new file mode 100644
index 0000000..fe49639
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType15.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  bad target-type inference lead to compiler crash
+ * @author  Maurizio Cimadamore
+ * @compile TargetType15.java
+ */
+
+class TargetType15 {
+
+    interface SAM<T> {
+        T foo(T a, T b);
+    }
+
+    void m1(SAM<? extends String> f_1) {}
+    void m2(SAM<? super String> f_2) {}
+    void m3(SAM<?> f_3) {}
+
+    SAM<? extends String> f_1 = (a, b) -> a;
+    SAM<? super String> f_2 = (a, b) -> a;
+    SAM<?> f_3 = (a, b) -> a;
+
+    {
+        m1((a, b) -> a);
+        m2((a, b) -> a);
+        m3((a, b) -> a);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType16.java b/test/tools/javac/lambda/TargetType16.java
new file mode 100644
index 0000000..1de0d12
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType16.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Check void-compatibility in strict vs. loose conversion contexts
+ * @compile/fail/ref=TargetType16.out -XDrawDiagnostics TargetType16.java
+ */
+
+class TargetType16 {
+
+    interface SAM1 {
+        void m1();
+    }
+
+    interface SAM2<X> {
+        X m2();
+    }
+
+    static void m(SAM1 s1) { }
+    static <T> void m(SAM2<T> s2) { }
+
+    public static void main(String[] args) {
+        m(() -> { throw new AssertionError(); }); //ambiguous
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType16.out b/test/tools/javac/lambda/TargetType16.out
new file mode 100644
index 0000000..f803ca3
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType16.out
@@ -0,0 +1,2 @@
+TargetType16.java:23:9: compiler.err.ref.ambiguous: m, kindname.method, m(TargetType16.SAM1), TargetType16, kindname.method, <T>m(TargetType16.SAM2<T>), TargetType16
+1 error
diff --git a/test/tools/javac/lambda/TargetType17.java b/test/tools/javac/lambda/TargetType17.java
new file mode 100644
index 0000000..cc1d9cf
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType17.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that javac recovers succesfully from bad cast conversion to primitive type
+ * @compile/fail/ref=TargetType17.out -XDrawDiagnostics TargetType17.java
+ */
+
+class TargetType17 {
+    interface SAM<X> {
+        boolean m(X x);
+    }
+
+    byte b = (byte) ()-> true;
+    short s = (short) ()-> 1;
+    int i = (int) ()-> 1;
+    long l = (long) ()-> 1L;
+    float f = (float) ()-> 1.0F;
+    double d = (double) ()-> 1.0;
+    char c = (char) ()-> 'c';
+    boolean z = (boolean) ()-> true;
+}
diff --git a/test/tools/javac/lambda/TargetType17.out b/test/tools/javac/lambda/TargetType17.out
new file mode 100644
index 0000000..2bdf33c
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType17.out
@@ -0,0 +1,9 @@
+TargetType17.java:14:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: byte)
+TargetType17.java:15:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: short)
+TargetType17.java:16:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: int)
+TargetType17.java:17:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: long)
+TargetType17.java:18:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: float)
+TargetType17.java:19:25: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: double)
+TargetType17.java:20:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: char)
+TargetType17.java:21:27: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: boolean)
+8 errors
diff --git a/test/tools/javac/lambda/TargetType18.java b/test/tools/javac/lambda/TargetType18.java
new file mode 100644
index 0000000..cadffed
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType18.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that javac doesn't crash if implicit lambda parameter is involved in cast
+ * @compile TargetType18.java
+ */
+
+class TargetType18 {
+
+    interface Folder<T> {
+        public T fold(T a, T b);
+    }
+
+
+    public static <T> Folder<T> max() {
+        return (a, b) -> (((Comparable)a).compareTo(b)<0)? b: a;
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType19.java b/test/tools/javac/lambda/TargetType19.java
new file mode 100644
index 0000000..736168d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType19.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  complex case of generic method call with lambda argument where target
+ *          is a wildcard SAM
+ * @compile TargetType19.java
+ */
+import java.util.List;
+
+class TargetType19 {
+
+    interface SAM<X> {
+        void f(List<? extends X> i);
+    }
+
+    <Z> void call(SAM<? extends Z> s, Z z) {  }
+
+   { call((List<? extends String> p) -> { }, 1); }
+}
diff --git a/test/tools/javac/lambda/TargetType19.out b/test/tools/javac/lambda/TargetType19.out
new file mode 100644
index 0000000..60a8b1d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType19.out
@@ -0,0 +1,2 @@
+TargetType19.java:40:10: compiler.err.invalid.inferred.types: (compiler.misc.no.conforming.assignment.exists: TargetType19.SAM<java.lang.String>, TargetType19.SAM<? extends java.lang.Integer>)
+1 error
diff --git a/test/tools/javac/lambda/TargetType20.java b/test/tools/javac/lambda/TargetType20.java
new file mode 100644
index 0000000..0678b01
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType20.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of lambda return type that depends on generic method
+ *          inference variable
+ * @compile -XDrawDiagnostics TargetType20.java
+ */
+import java.util.*;
+
+class TargetType20 {
+
+    interface SAM2<X> {
+      List<X> f();
+    }
+
+    class Test {
+       <Z> void call(SAM2<Z> x, SAM2<Z> y) { }
+       { call(() -> Collections.emptyList(), () -> new ArrayList<String>()); }
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType21.java b/test/tools/javac/lambda/TargetType21.java
new file mode 100644
index 0000000..ac70cac
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType21.java
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with cyclic type-inference are removed from the
+ *          set of applicable methods
+ * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
+ */
+
+class TargetType21 {
+    interface SAM1 {
+        String m1(Integer n) throws Exception;
+    }
+
+    interface SAM2 {
+        void m2(Integer n);
+    }
+
+    interface SAM3<R,A> {
+        R m3(A n);
+    }
+
+    void call(SAM1 sam) { }
+    void call(SAM2 sam) { }
+    <R,A> void call(SAM3<R,A> sam) { }
+
+    void test() {
+        call(x -> { throw new Exception(); }); //ambiguous
+        call(x -> { System.out.println(""); }); //ambiguous
+        call(x -> { return (Object) null; }); //cyclic inference
+        call(x -> { return null; }); //ambiguous
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType21.out b/test/tools/javac/lambda/TargetType21.out
new file mode 100644
index 0000000..904e30f
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType21.out
@@ -0,0 +1,5 @@
+TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21
+TargetType21.java:29:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21
+TargetType21.java:30:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: A)
+TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21
+4 errors
diff --git a/test/tools/javac/lambda/TargetType22.java b/test/tools/javac/lambda/TargetType22.java
new file mode 100644
index 0000000..5407f84
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType22.java
@@ -0,0 +1,44 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that candidates with incompatible SAM descriptor args length
+            are removed from the set of applicable methods
+ * @compile/fail/ref=TargetType22.out -Xlint:unchecked -XDrawDiagnostics TargetType22.java
+ */
+
+class TargetType22 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1<A> {
+        void m(A a);
+    }
+
+    interface Sam2<A> {
+        void m(A a1, A a2);
+    }
+
+    interface Sam3<A> {
+        void m(A a1, A a2, A a3);
+    }
+
+    interface SamX<A> {
+        void m(A... as);
+    }
+
+    void call(Sam0 s) { }
+    void call(Sam1<String> s) { }
+    void call(Sam2<String> s) { }
+    void call(Sam3<String> s) { }
+    void call(SamX<String> s) { }
+
+    void test() {
+        call(() -> { });
+        call(a1 -> { }); //ambiguous - both call(Sam1) and call(SamX) match
+        call((a1, a2) -> { });
+        call((a1, a2, a3) -> { });
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType22.out b/test/tools/javac/lambda/TargetType22.out
new file mode 100644
index 0000000..d94b2cc
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType22.out
@@ -0,0 +1,4 @@
+TargetType22.java:29:21: compiler.warn.unchecked.varargs.non.reifiable.type: A
+TargetType22.java:40:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType22.Sam1<java.lang.String>), TargetType22, kindname.method, call(TargetType22.SamX<java.lang.String>), TargetType22
+1 error
+1 warning
diff --git a/test/tools/javac/lambda/TargetType23.java b/test/tools/javac/lambda/TargetType23.java
new file mode 100644
index 0000000..0786af3
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType23.java
@@ -0,0 +1,37 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of ambiguous method call with lambda whose body cannot
+            complete normally
+ * @compile/fail/ref=TargetType23.out -XDrawDiagnostics TargetType23.java
+ */
+
+class TargetType23 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1 {
+        int m();
+    }
+
+    interface Sam2 {
+        String m();
+    }
+
+    interface Sam3<A> {
+        A m();
+    }
+
+
+    void call(Sam0 s) { }
+    void call(Sam1 s) { }
+    void call(Sam2 s) { }
+    <Z> void call(Sam3<Z> s) { }
+
+    void test() {
+        call(()-> { throw new RuntimeException(); }); //ambiguous - both call(Sam0), call(Sam2), call(Sam3) match
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType23.out b/test/tools/javac/lambda/TargetType23.out
new file mode 100644
index 0000000..2b40d26
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType23.out
@@ -0,0 +1,2 @@
+TargetType23.java:35:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType23.Sam2), TargetType23, kindname.method, <Z>call(TargetType23.Sam3<Z>), TargetType23
+1 error
diff --git a/test/tools/javac/lambda/TargetType24.java b/test/tools/javac/lambda/TargetType24.java
new file mode 100644
index 0000000..b470a91
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType24.java
@@ -0,0 +1,39 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check case of nested method calls with lambda expression
+ * @compile/fail/ref=TargetType24.out -XDrawDiagnostics TargetType24.java
+ */
+
+class TargetType24 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    interface FSub<A, B> extends F<A,B> { }
+
+    static class Array<A> {
+        boolean forAll(final F<A, Boolean> f) {
+            return false;
+        }
+
+        String forAll(final FSub<A, String> f) {
+            return "";
+        }
+
+        String forAll2(final FSub<A, String> f) {
+            return "";
+        }
+    }
+
+    void test(Array<String> as, final Array<Character> ac) {
+        final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok
+        final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok
+        final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail
+        final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail
+        final boolean b3 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail
+        final String s3 = as.forAll((FSub<String, String>)s -> ac.forAll((FSub<Character, String>)c -> false)); //fail
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType24.out b/test/tools/javac/lambda/TargetType24.out
new file mode 100644
index 0000000..7554a6d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType24.out
@@ -0,0 +1,5 @@
+TargetType24.java:34:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean)
+TargetType24.java:35:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @945, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)))
+TargetType24.java:36:101: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean))
+TargetType24.java:37:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))
+4 errors
diff --git a/test/tools/javac/lambda/TargetType25.java b/test/tools/javac/lambda/TargetType25.java
new file mode 100644
index 0000000..4ea78f8
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType25.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that lambda expression can appear in
+ * @compile TargetType25.java
+ */
+
+class TargetType25 {
+
+    interface F<A, B> {
+        B f(A a);
+    }
+
+    <Z> void m1(F<String, Z> f) {  }
+    <Z> void m2(F<String, F<String, Z>> f) {  }
+    <Z> void m3(F<String, F<String, F<String, Z>>> f) {  }
+
+    void testExprLambdaInMethodContext() {
+        m1(s1 -> 1);
+        m2(s1 -> s2 -> 1);
+        m3(s1 -> s2 -> s3 -> 1);
+    }
+
+    void testExprLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> 1;
+        F<String, F<String, Integer>> fn2 = s1 -> s2 -> 1;
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> s2 -> s3 -> 1;
+    }
+
+    void testStatementLambdaInMethodContext() {
+        m1(s1 -> { return 1; });
+        m2(s1 -> { return s2 -> { return 1; }; });
+        m3(s1 -> { return s2 -> { return s3 -> { return 1; }; }; });
+    }
+
+    void testStatementLambdaInAssignmentContext() {
+        F<String, Integer> fn1 = s1 -> { return 1; };
+        F<String, F<String, Integer>> fn2 = s1 -> { return s2 -> { return 1; }; };
+        F<String, F<String, F<String, Integer>>> fn3 = s1 -> { return s2 -> { return s3 -> { return 1; }; }; };
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType26.java b/test/tools/javac/lambda/TargetType26.java
new file mode 100644
index 0000000..92fe58d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType26.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  case of cyclic type inference (lambda passed where inference var expected)
+ * @compile/fail/ref=TargetType26.out -XDrawDiagnostics TargetType26.java
+ */
+
+class TargetType26 {
+    interface SAM {
+       void m();
+    }
+
+    <Z> void call(Z z) { }
+
+    { call(() -> { }); }
+}
diff --git a/test/tools/javac/lambda/TargetType26.out b/test/tools/javac/lambda/TargetType26.out
new file mode 100644
index 0000000..15cfc61
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType26.out
@@ -0,0 +1,2 @@
+TargetType26.java:16:11: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: Z)
+1 error
diff --git a/test/tools/javac/lambda/TargetType27.java b/test/tools/javac/lambda/TargetType27.java
new file mode 100644
index 0000000..407c1ae
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType27.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  complex case of cyclic type inference (lambda returned where inference var expected)
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics TargetType27.java
+ * @compile/fail/ref=TargetType27.out -XDrawDiagnostics -XDcomplexinference TargetType27.java
+ */
+
+class TargetType27 {
+    interface F<X, Y>  {
+        Y f(X a);
+    }
+
+    <A, R> F<A, R> m(F<A, R>  f) { return null; }
+
+    void test() {
+        m((String s1) ->  (String s2) ->  new Integer(1));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType27.out b/test/tools/javac/lambda/TargetType27.out
new file mode 100644
index 0000000..bf38859
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType27.out
@@ -0,0 +1,2 @@
+TargetType27.java:18:10: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: R)
+1 error
diff --git a/test/tools/javac/lambda/TargetType28.java b/test/tools/javac/lambda/TargetType28.java
new file mode 100644
index 0000000..4e4679b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType28.java
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  target type inference in a case where lambda expression returns diamond
+ * @compile/fail/ref=TargetType28.out -XDrawDiagnostics TargetType28.java
+ */
+
+class TargetType28 {
+    static class SuperFoo<X> {}
+
+    static class Foo<X extends Number> extends SuperFoo<X> {}
+
+    interface A<X, Y> {
+       SuperFoo<Y> m(X x);
+    }
+
+    <Z, R> SuperFoo<R> apply(A<Z, R> ax, Z x) { return null; }
+
+    SuperFoo<String> ls = apply(x-> new Foo<>(), 1);
+    SuperFoo<Integer> li = apply(x-> new Foo<>(), 1);
+    SuperFoo<?> lw = apply(x-> new Foo<>(), 1);
+}
diff --git a/test/tools/javac/lambda/TargetType28.out b/test/tools/javac/lambda/TargetType28.out
new file mode 100644
index 0000000..57a38f3
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType28.out
@@ -0,0 +1,2 @@
+TargetType28.java:20:32: compiler.err.prob.found.req: (compiler.misc.incompatible.eq.upper.bounds: X, R,java.lang.String, java.lang.Object,java.lang.Number)
+1 error
diff --git a/test/tools/javac/lambda/TargetType29.java b/test/tools/javac/lambda/TargetType29.java
new file mode 100644
index 0000000..fba06bc
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType29.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check type-substitution in SAM type wildcards inference
+ * @compile TargetType29.java
+ */
+
+import java.util.*;
+
+class TargetType29 {
+    interface Reducer<E, V> {
+        public V reduce(E element, V value);
+    }
+
+    private static <E> int reduce(Iterable<? extends E> iterable, Reducer<? super E, Integer> reducer) { return 0;  }
+
+    void test(List<Integer> li) {
+        reduce(li, (e, v) -> e + v);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType30.java b/test/tools/javac/lambda/TargetType30.java
new file mode 100644
index 0000000..678d743
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType30.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that target type is propagated through parenthesized expressions
+ * @compile TargetType30.java
+ */
+
+class TargetType30 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (x-> { System.out.println("Hello!"); });
+        SAM s2 = ((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((x-> { System.out.println("Hello!"); }));
+        m(((x-> { System.out.println("Hello!"); })));
+        m((((x-> { System.out.println("Hello!"); }))));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType31.java b/test/tools/javac/lambda/TargetType31.java
new file mode 100644
index 0000000..4940142
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType31.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  check that target type of a cast is propagated through parenthesized expressions
+ * @compile TargetType31.java
+ */
+
+class TargetType31 {
+
+    interface SAM {
+        void m(int x);
+    }
+
+    void m(SAM s) { }
+
+    void testAssignmentContext() {
+        SAM s1 = (SAM)(x-> { System.out.println("Hello!"); });
+        SAM s2 = (SAM)((x-> { System.out.println("Hello!"); }));
+        SAM s3 = (SAM)(((x-> { System.out.println("Hello!"); })));
+    }
+
+    void testMethodContext() {
+        m((SAM)(x-> { System.out.println("Hello!"); }));
+        m((SAM)((x-> { System.out.println("Hello!"); })));
+        m((SAM)(((x-> { System.out.println("Hello!"); }))));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType32.java b/test/tools/javac/lambda/TargetType32.java
new file mode 100644
index 0000000..d9b20b7
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType32.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  target-typing and conditional operator
+ */
+
+public class TargetType32 {
+
+    interface A<X> {
+        X m();
+    }
+
+    interface B<X> extends A<X> {}
+
+    void m(A<Integer> a) { }
+    void m(B<String> b) { }
+
+    <Z extends Integer> void m2(A<Z> a) { }
+    <Z extends String> void m2(B<Z> b) { }
+
+    void m3(A<TargetType32> a) { }
+    void m3(B<String> b) { }
+
+    <Z> void m4(A<Z> a) { }
+    <Z extends String> void m4(B<Z> b) { }
+
+    int intRes() { return 42; }
+
+    void testLambda(boolean flag) {
+        A<Integer> c = flag ? (() -> 23) : (() -> 42);
+        m(flag ? (() -> 23) : (() -> 42));
+        m2(flag ? (() -> 23) : (() -> 23));
+    }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+
+    void testConstrRef(boolean flag) {
+        A<TargetType32> c = flag ? TargetType32::new : TargetType32::new;
+        m3(flag ? TargetType32::new : TargetType32::new);
+        m4(flag ? TargetType32::new : TargetType32::new);
+    }
+
+    public static void main(String[] args) {
+        TargetType32 test = new TargetType32();
+        test.testLambda(true);
+        test.testMethodRef(true);
+        test.testConstrRef(true);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType33.java b/test/tools/javac/lambda/TargetType33.java
new file mode 100644
index 0000000..567aec4
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType33.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  crash when incompatible method reference is found in conditional expression
+ * @compile/fail/ref=TargetType33.out -XDrawDiagnostics TargetType33.java
+ */
+
+class TargetType33 {
+
+    interface A<X> {
+        X m();
+    }
+
+    void m(A<Integer> a) { }
+    <Z> void m2(A<Z> a) { }
+
+    int intRes(Object o) { return 42; }
+
+    void testMethodRef(boolean flag) {
+        A<Integer> c = flag ? this::intRes : this::intRes;
+        m(flag ? this::intRes : this::intRes);
+        m2(flag ? this::intRes : this::intRes);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType33.out b/test/tools/javac/lambda/TargetType33.out
new file mode 100644
index 0000000..9a090de
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType33.out
@@ -0,0 +1,5 @@
+TargetType33.java:21:31: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:21:46: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
+TargetType33.java:22:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType33.A<java.lang.Integer>, @509, kindname.class, TargetType33, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+TargetType33.java:23:9: compiler.err.cant.apply.symbol: kindname.method, m2, TargetType33.A<Z>, @557, kindname.class, TargetType33, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+4 errors
diff --git a/test/tools/javac/lambda/TargetType34.java b/test/tools/javac/lambda/TargetType34.java
new file mode 100644
index 0000000..f361f93
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType34.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  spurious resolution diagnostics when diamond constructor contains poly expression
+ * @compile -XDcomplexinference TargetType34.java
+ */
+
+class TargetType34<X> {
+
+    TargetType34(X x) {}
+
+    Object next;
+
+    void test() {
+        new TargetType34<>(next==null ? null : null);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType35.java b/test/tools/javac/lambda/TargetType35.java
new file mode 100644
index 0000000..facb7bd
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType35.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  missing erasure on intersection supertype of generated lambda class
+ */
+public class TargetType35 {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    interface A {}
+
+    interface B {}
+
+    static class C implements A, B {}
+
+    static class D implements A, B {}
+
+    interface SAM<Y, X> {
+        Y invoke(X arg);
+    }
+
+    static class Sup {
+       <Z> Z m(Z z) { return z; }
+    }
+
+    static class Sub extends Sup {
+        <Z> Z m(Z z) { return z; }
+
+        void test(C c, D d) {
+            choose(c, d, x->x);
+            choose(c, d, this::m);
+            choose(c, d, super::m);
+        }
+
+        <T> void choose(T t1, T t2, SAM<T, T> t3) {
+            assertTrue(true);
+        }
+    }
+
+    public static void main(String[] args)
+    {
+        new Sub().test(null, null);
+        assertTrue(assertionCount == 3);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType36.java b/test/tools/javac/lambda/TargetType36.java
new file mode 100644
index 0000000..38f9c2a
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType36.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8003280 8013404
+ * @summary Add lambda tests
+ *  check that target type of cast is not propagated to conditional subexpressions
+ * @compile/fail/ref=TargetType36.out -XDrawDiagnostics TargetType36.java
+ */
+class TargetType36 { //awaits spec wording on cast vs. poly
+
+    interface SAM {
+       int m(int i, int j);
+    }
+
+    void test() {
+        SAM s1 = (SAM)((a,b)->a+b);
+        SAM s2 = (SAM)(true? (SAM)((a,b)->a+b) : (SAM)((a,b)->a+b));
+        SAM s3 = (SAM)(true? (a,b)->a+b : (a,b)->a+b);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType36.out b/test/tools/javac/lambda/TargetType36.out
new file mode 100644
index 0000000..92542dd
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType36.out
@@ -0,0 +1,3 @@
+TargetType36.java:40:30: compiler.err.unexpected.lambda
+TargetType36.java:40:43: compiler.err.unexpected.lambda
+2 errors
diff --git a/test/tools/javac/lambda/TargetType37.java b/test/tools/javac/lambda/TargetType37.java
new file mode 100644
index 0000000..235da33
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType37.java
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context is propagated to conditional subexpressions
+ * @compile TargetType37.java
+ */
+class TargetType37 {
+
+    interface I { }
+
+    void test(Object o, boolean cond) {
+        I i = (I)(cond ? o : o);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType38.java b/test/tools/javac/lambda/TargetType38.java
new file mode 100644
index 0000000..e6ec4d1
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType38.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that cast conversion context does not affect compatibility of lambda
+ * @compile/fail/ref=TargetType38.out -XDrawDiagnostics TargetType38.java
+ */
+class TargetType38 {
+
+    interface I { }
+
+    interface SAM {
+        I m();
+    }
+
+    static Object m() { return null; }
+
+    void test() {
+        Object o1 = (SAM)()->new Object();
+        Object o2 = (SAM)TargetType38::m;
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType38.out b/test/tools/javac/lambda/TargetType38.out
new file mode 100644
index 0000000..df741eb
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType38.out
@@ -0,0 +1,3 @@
+TargetType38.java:19:30: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+TargetType38.java:20:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+2 errors
diff --git a/test/tools/javac/lambda/TargetType39.java b/test/tools/javac/lambda/TargetType39.java
new file mode 100644
index 0000000..bcca027
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType39.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that type-checking fails because of recursive analysis of stuck expressions
+  * @compile/fail/ref=TargetType39.out -XDrawDiagnostics TargetType39.java
+ */
+class TargetType39 {
+
+    interface I { }
+
+    interface SAM<A, R> {
+        R m(A a);
+    }
+
+    <U, V> void call(SAM<U, V> s) { }
+
+    void test(boolean cond, SAM<String, Void> ssv) {
+        call(cond ? x-> null : ssv);
+        call((String s)-> cond ? x-> null : ssv);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType39.out b/test/tools/javac/lambda/TargetType39.out
new file mode 100644
index 0000000..36a61bc
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType39.out
@@ -0,0 +1,3 @@
+TargetType39.java:19:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: U)
+TargetType39.java:20:13: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: V)
+2 errors
diff --git a/test/tools/javac/lambda/TargetType40.java b/test/tools/javac/lambda/TargetType40.java
new file mode 100644
index 0000000..831c059
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType40.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler silently crashes when void method is passed as argument in overloaded call site
+ * @compile/fail/ref=TargetType40.out -XDrawDiagnostics TargetType40.java
+ */
+
+class TargetType40 {
+    void m(String s) { }
+    void m(Integer i) { }
+
+    void void_method() {}
+
+    void test() {
+       m(void_method());
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType40.out b/test/tools/javac/lambda/TargetType40.out
new file mode 100644
index 0000000..c01b3d1
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType40.out
@@ -0,0 +1,2 @@
+TargetType40.java:16:21: compiler.err.void.not.allowed.here
+1 error
diff --git a/test/tools/javac/lambda/TargetType41.java b/test/tools/javac/lambda/TargetType41.java
new file mode 100644
index 0000000..d48f369
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType41.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  out-of-order method checking should check as many arguments as possible
+ * @compile/fail/ref=TargetType41.out -XDrawDiagnostics TargetType41.java
+ */
+
+class TargetType41 {
+    <X> void m(String s, java.util.List<String> lx) { }
+
+    void test() {
+        m(1, new java.util.ArrayList<>());
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType41.out b/test/tools/javac/lambda/TargetType41.out
new file mode 100644
index 0000000..87d99ad
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType41.out
@@ -0,0 +1,2 @@
+TargetType41.java:13:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.String,java.util.List<java.lang.String>, int,java.util.ArrayList<java.lang.Object>, kindname.class, TargetType41, (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.lang.String))
+1 error
diff --git a/test/tools/javac/lambda/TargetType42.java b/test/tools/javac/lambda/TargetType42.java
new file mode 100644
index 0000000..a476134
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType42.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  effects of speculative attribution are undone on a per-argument basis rather than on a per-resolution basis
+ * @compile TargetType42.java
+ */
+class TargetType42 {
+
+    interface SAM<X, Y> {
+      Y f(X x);
+    }
+
+    <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { }
+
+    void test(Object obj) {
+        m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType43.java b/test/tools/javac/lambda/TargetType43.java
new file mode 100644
index 0000000..9b9876b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType43.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  recovery attribution step for unchecked arguments
+ * @compile/fail/ref=TargetType43.out -XDrawDiagnostics TargetType43.java
+ */
+class TargetType43 {
+
+    void m(Object o) { }
+
+    void test(Object obj) {
+        Object o = x-> { new NonExistentClass(x); return 5; };
+        m(x-> { new NonExistentClass(x); return 5; });
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType43.out b/test/tools/javac/lambda/TargetType43.out
new file mode 100644
index 0000000..666e67c
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType43.out
@@ -0,0 +1,4 @@
+TargetType43.java:13:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+TargetType43.java:13:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+TargetType43.java:14:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
+3 errors
diff --git a/test/tools/javac/lambda/TargetType44.java b/test/tools/javac/lambda/TargetType44.java
new file mode 100644
index 0000000..d36f0c3
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType44.java
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler throw AssertionError while backtracing from speculative attribution round
+ * @compile/fail/ref=TargetType44.out -XDrawDiagnostics TargetType44.java
+ */
+class TargetType44 {
+
+    interface Unary {
+        void m(int i1);
+    }
+
+    interface Binary {
+        void m(int i1, int i2);
+    }
+
+    void m(Unary u) { }
+    void m(Binary u) { }
+
+    void test() {
+        m(()-> { new Object() { }; }); //fail
+        m(x -> { new Object() { }; }); //ok
+        m((x, y) -> { new Object() { }; }); //ok
+        m((x, y, z) -> { new Object() { }; }); //fail
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType44.out b/test/tools/javac/lambda/TargetType44.out
new file mode 100644
index 0000000..43e01a0
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType44.out
@@ -0,0 +1,3 @@
+TargetType44.java:22:9: compiler.err.cant.apply.symbols: kindname.method, m, @458,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+TargetType44.java:25:9: compiler.err.cant.apply.symbols: kindname.method, m, @597,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+2 errors
diff --git a/test/tools/javac/lambda/TargetType45.java b/test/tools/javac/lambda/TargetType45.java
new file mode 100644
index 0000000..3d1e6f8
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType45.java
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler crashes during flow analysis as it fails to report diagnostics during attribution
+ * @compile TargetType45.java
+ */
+class TargetType45 {
+
+    interface Predicate<X> {
+        boolean apply(X x);
+    }
+
+    interface Mapper<X, Y> {
+        Y apply(X x);
+    }
+
+    class Foo<X> {
+        Foo<X> filter(Predicate<? super X> p) { return null; }
+    }
+
+    static <U, V> Predicate<U> compose(Predicate<? super V> pi, Mapper<? super U, ? extends V> m) { return null; }
+
+    static Predicate<Integer> isOdd = i -> i % 2 != 0;
+
+    void top10Counties(Foo<String> foos) {
+        foos.filter(compose(isOdd, (String e) -> e.length()));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType46.java b/test/tools/javac/lambda/TargetType46.java
new file mode 100644
index 0000000..da37123
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType46.java
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  compiler doesn't report accessibility problem due to inaccessible target
+ * @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
+ */
+import java.util.*;
+
+class TargetType46Outer {
+
+    private interface PI {
+       void m();
+    }
+
+    void m(PI p) { }
+    void m(List<PI> p) { }
+}
+
+class TargetType46 {
+    void test(TargetType46Outer outer) {
+        outer.m(()->{}); //access error
+        outer.m(this::g); //access error
+        outer.m(new ArrayList<>()); //ok
+        outer.m(Collections.emptyList()); //ok
+    }
+
+    void g() { }
+}
diff --git a/test/tools/javac/lambda/TargetType46.out b/test/tools/javac/lambda/TargetType46.out
new file mode 100644
index 0000000..ac3a125
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType46.out
@@ -0,0 +1,3 @@
+TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+2 errors
diff --git a/test/tools/javac/lambda/TargetType47.java b/test/tools/javac/lambda/TargetType47.java
new file mode 100644
index 0000000..920e44b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType47.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType47.java
+ */
+
+class TargetType47 {
+    interface A {
+        void a();
+        void b();
+        default void c() { };
+    }
+
+    interface B extends A {
+        default void b() { };
+    }
+
+    B b = ()-> {};
+}
diff --git a/test/tools/javac/lambda/TargetType48.java b/test/tools/javac/lambda/TargetType48.java
new file mode 100644
index 0000000..675737e
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType48.java
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  spurious functional interface conversion errors with default methods in target type
+ * @compile TargetType48.java
+ */
+
+class TargetType48 {
+    interface I1 {
+        void a();
+        void b();
+        void c();
+    }
+
+    interface I2 extends I1 {
+        default void a() { }
+    }
+
+    interface I3 extends I2 {
+        default void b() { }
+    }
+
+    I3 i3 = ()->{ };
+}
diff --git a/test/tools/javac/lambda/TargetType49.java b/test/tools/javac/lambda/TargetType49.java
new file mode 100644
index 0000000..64aa781
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType49.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  javac accepts ill-formed lambda/method reference targets
+ * @compile/fail/ref=TargetType49.out -XDrawDiagnostics TargetType49.java
+ */
+class TargetType49 {
+
+    interface F {
+        default Object clone() { return null; }
+        void m();
+    }
+
+    F f1 = ()->{};
+    F f2 = this::g;
+
+    void g() { }
+}
diff --git a/test/tools/javac/lambda/TargetType49.out b/test/tools/javac/lambda/TargetType49.out
new file mode 100644
index 0000000..df13b27
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType49.out
@@ -0,0 +1,3 @@
+TargetType49.java:15:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+TargetType49.java:16:12: compiler.err.override.weaker.access: (compiler.misc.cant.implement: clone(), java.lang.Object, clone(), TargetType49.F), public
+2 errors
diff --git a/test/tools/javac/lambda/TargetType50.java b/test/tools/javac/lambda/TargetType50.java
new file mode 100644
index 0000000..d2942b9
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType50.java
@@ -0,0 +1,51 @@
+/*
+ * 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 8003280
+ * @summary Add lambda tests
+ *  bad stuck check for method reference leads to javac crash
+ * @compile TargetType50.java
+ */
+import java.util.*;
+
+class TargetType50 {
+
+    interface Factory<F> {
+        F make();
+    }
+
+    static class Sink<T> {
+        static <Z> Sink<Z> make() { return null; }
+    }
+
+    <Y, S extends Sink<Y>> List<Y> m(Factory<S> factory) { return null; }
+
+    void test() {
+        List<?> l1 = m(Sink::new);
+        List<?> l2 = m(Sink::make);
+        List<String> l3 = m(Sink::new);
+        List<String> l4 = m(Sink::make);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType51.java b/test/tools/javac/lambda/TargetType51.java
new file mode 100644
index 0000000..7e7a129
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType51.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 8005244
+ * @summary Implement overload resolution as per latest spec EDR
+ *          smoke test for combinator-like stuck analysis
+ * @author  Maurizio Cimadamore
+ * @compile TargetType51.java
+ */
+
+import java.util.Comparator;
+
+class TargetType51 {
+
+    interface SimpleMapper<T, U> {
+       T map(U t);
+    }
+
+    interface SimpleList<X> {
+        SimpleList<X> sort(Comparator<? super X> c);
+    }
+
+    static class Person {
+        String getName() { return ""; }
+    }
+
+    <T, U extends Comparable<? super U>> Comparator<T> comparing(SimpleMapper<U, T> mapper) {  return null; }
+
+    static class F<U extends Comparable<? super U>, T> {
+        F(SimpleMapper<U, T> f) { }
+    }
+
+    void testAssignmentContext(SimpleList<Person> list, boolean cond) {
+        SimpleList<Person> p1 = list.sort(comparing(Person::getName));
+        SimpleList<Person> p2 = list.sort(comparing(x->x.getName()));
+        SimpleList<Person> p3 = list.sort(cond ? comparing(Person::getName) : comparing(x->x.getName()));
+        SimpleList<Person> p4 = list.sort((cond ? comparing(Person::getName) : comparing(x->x.getName())));
+    }
+
+    void testMethodContext(SimpleList<Person> list, boolean cond) {
+        testMethodContext(list.sort(comparing(Person::getName)), true);
+        testMethodContext(list.sort(comparing(x->x.getName())), true);
+        testMethodContext(list.sort(cond ? comparing(Person::getName) : comparing(x->x.getName())), true);
+        testMethodContext(list.sort((cond ? comparing(Person::getName) : comparing(x->x.getName()))), true);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType52.java b/test/tools/javac/lambda/TargetType52.java
new file mode 100644
index 0000000..f06c3e9
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType52.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8005244
+ * @summary Implement overload resolution as per latest spec EDR
+ *          uncatched sam conversion failure exception lead to javac crash
+ * @compile/fail/ref=TargetType52.out -XDrawDiagnostics TargetType52.java
+ */
+class TargetType52 {
+
+    interface FI<T extends CharSequence, V extends java.util.AbstractList<T>> {
+        T m(V p);
+    }
+
+    void m(FI<? extends CharSequence, ? extends java.util.ArrayList<? extends CharSequence>> fip) { }
+
+    void test() {
+        m(p -> p.get(0));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType52.out b/test/tools/javac/lambda/TargetType52.out
new file mode 100644
index 0000000..ccfb466
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType52.out
@@ -0,0 +1,2 @@
+TargetType52.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType52.FI<? extends java.lang.CharSequence,? extends java.util.ArrayList<? extends java.lang.CharSequence>>, @525, kindname.class, TargetType52, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.no.suitable.functional.intf.inst: TargetType52.FI<java.lang.CharSequence,java.util.ArrayList<? extends java.lang.CharSequence>>))
+1 error
diff --git a/test/tools/javac/lambda/TargetType53.java b/test/tools/javac/lambda/TargetType53.java
new file mode 100644
index 0000000..30f1a37
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType53.java
@@ -0,0 +1,46 @@
+/*
+ * 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 8007464
+ * @summary Add graph inference support
+ *          smoke test for graph inference
+ * @compile TargetType53.java
+ */
+import java.util.*;
+import java.util.stream.*;
+import java.util.function.*;
+
+class TargetType53 {
+
+    <P> List<List<P>> perm(List<P> l) { return null; }
+
+    void g(List<List<UnaryOperator<IntStream>>> l) { }
+
+    void test() {
+        List<List<UnaryOperator<IntStream>>> l =
+            perm(Arrays.asList(s -> s.sorted()));
+        g(perm(Arrays.asList(s -> s.sorted())));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType54.java b/test/tools/javac/lambda/TargetType54.java
new file mode 100644
index 0000000..5c62016
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType54.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8007464
+ * @summary Add graph inference support
+ *          smoke test for graph inference
+ * @compile TargetType54.java
+ */
+import java.util.stream.*;
+import java.util.*;
+import static java.util.stream.Collectors.*;
+
+class TargetType54 {
+    void test(Stream<Integer> si) {
+        List<Integer> l1 = si.collect(toList());
+        List<Integer> l2 = si.collect(toCollection(ArrayList::new));
+        m(si.collect(toList()));
+        m(si.collect(toCollection(ArrayList::new)));
+    }
+
+    void m(List<Integer> l) { }
+}
diff --git a/test/tools/javac/lambda/TargetType55.java b/test/tools/javac/lambda/TargetType55.java
new file mode 100644
index 0000000..3484a74
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType55.java
@@ -0,0 +1,42 @@
+/*
+ * 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 8007464
+ * @summary Add graph inference
+ *          support smoke test for graph inference
+ * @compile TargetType55.java
+ */
+import java.util.function.*;
+
+class TargetType55  {
+
+    <R> void m(Function<Integer, R> collector) { }
+
+    <T, D> Function<T, Integer> g(D d, BinaryOperator<D> reducer) { return null; }
+
+    public void test() {
+        m(g((Integer)null, (x,y)->1));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType56.java b/test/tools/javac/lambda/TargetType56.java
new file mode 100644
index 0000000..c292b2d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType56.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8007464
+ * @summary Add graph inference support
+ *          smoke test for graph inference
+ * @compile TargetType56.java
+ */
+class TargetType56 {
+    <Z> Z m(Z z) { return null; }
+
+    void test() {
+        double d1 = m(1);
+        double d2 = m((Integer)null);
+        double d3 = m(m(1));
+        double d4 = m(m((Integer)null));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType57.java b/test/tools/javac/lambda/TargetType57.java
new file mode 100644
index 0000000..23f7a13
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType57.java
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007464
+ * @summary Add graph inference support
+ *          more smoke tests for graph inference
+ * @compile/fail/ref=TargetType57.out -XDrawDiagnostics TargetType57.java
+ */
+import java.util.*;
+import java.util.function.*;
+
+class TargetType57 {
+
+    void test(List<Integer> list) {
+        m(list, s -> s.intValue(), s -> s.nonExistentMethod());
+    }
+
+    <U, R, S_IN, S_OUT> R m(List<S_IN> list,
+                        Function<S_IN, S_OUT> f1,
+                        Function<S_OUT, R> f2) { return null; }
+}
diff --git a/test/tools/javac/lambda/TargetType57.out b/test/tools/javac/lambda/TargetType57.out
new file mode 100644
index 0000000..8475e6b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType57.out
@@ -0,0 +1,2 @@
+TargetType57.java:14:42: compiler.err.cant.resolve.location.args: kindname.method, nonExistentMethod, , , (compiler.misc.location.1: kindname.variable, s, java.lang.Integer)
+1 error
diff --git a/test/tools/javac/lambda/TargetType58.java b/test/tools/javac/lambda/TargetType58.java
new file mode 100644
index 0000000..cb3ca90
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType58.java
@@ -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 8007464
+ * @summary Add graph inference support
+ *          more smoke tests for graph inference
+ * @compile TargetType58.java
+ */
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.*;
+
+class TargetType58 {
+
+    void test(List<Integer> li) {
+        g(li, s -> s.substream(200), Collections.emptyList());
+    }
+
+    <T, U, S_OUT extends Stream<U>,
+            I extends Iterable<U>> Collection<U> g(Collection<T> coll, Function<Stream<T>, S_OUT> f, I i) {
+        return null;
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType59.java b/test/tools/javac/lambda/TargetType59.java
new file mode 100644
index 0000000..f366179
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType59.java
@@ -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
+ * @bug 8007464
+ * @summary Add graph inference support
+ *          more smoke tests for graph inference
+ * @compile TargetType59.java
+ */
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.*;
+
+class TargetType59 {
+
+    <T, R> Collector<T, R> m(Supplier<? extends R> supplier, BiConsumer<R, T> accumulator) {
+        return null;
+    }
+
+    <T, C extends Collection<T>> Collector<T,C> test1(Supplier<C> collectionFactory) {
+        return m(collectionFactory, Collection::add);
+    }
+
+    Collector<String, StringBuilder> test2(Supplier<StringBuilder> sb) {
+        return m(sb, StringBuilder::append);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType60.java b/test/tools/javac/lambda/TargetType60.java
new file mode 100644
index 0000000..0506f39
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType60.java
@@ -0,0 +1,65 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8007462
+ * @summary Fix provisional applicability for method references
+ * @compile/fail/ref=TargetType60.out -XDrawDiagnostics TargetType60.java
+ */
+class TargetType60 {
+
+    interface Sam0 {
+        void m();
+    }
+
+    interface Sam1<X> {
+        void m(X x);
+    }
+
+    interface Sam2<X,Y> {
+        void m(X x, Y y);
+    }
+
+    void m0() { }
+    void m1(String s) { }
+    void m2(String s1, String s2) { }
+
+    void m01() { }
+    void m01(String s) { }
+
+    void m012() { }
+    void m012(String s) { }
+    void m012(String s1, String s2) { }
+
+    void n0() { }
+    void n1(String s) { }
+    void n2(TargetType60 rec, String s2) { }
+
+    void n01() { }
+    void n01(String s) { }
+
+    void n012() { }
+    void n012(String s) { }
+    void n012(TargetType60 rec, String s2) { }
+
+    static String g(Sam0 s) { return null; }
+    static <U> U g(Sam1<U> s) { return null; }
+    static <U> U g(Sam2<U,String> s) { return null; }
+
+    static <U> U u(Sam1<U> s) { return null; }
+    static <U> U u(Sam2<U,String> s) { return null; }
+
+    void testBound() {
+        String s1 = g(this::m0); //ok - resolves to g(Sam0)
+        String s2 = g(this::m1); //ok - resolves to g(Sam1)
+        String s3 = g(this::m2); //ok - resolves to g(Sam2)
+        String s4 = g(this::m01);//ambiguous (g(Sam0), g(Sam1) apply)
+        String s5 = g(this::m012);//ambiguous (g(Sam0), g(Sam1), g(Sam2) apply)
+    }
+
+    static void testUnbound() {
+        TargetType60 s1 = u(TargetType60::n0); //ok - resolves to u(Sam1)
+        TargetType60 s2 = u(TargetType60::n1); //ambiguous (u(Sam1), u(Sam2) apply)
+        TargetType60 s3 = u(TargetType60::n2); //none is applicable
+        TargetType60 s4 = u(TargetType60::n01);//ambiguous (u(Sam1), u(Sam2) apply)
+        TargetType60 s5 = u(TargetType60::n012);//ambiguous (u(Sam1), u(Sam2) apply)
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType60.out b/test/tools/javac/lambda/TargetType60.out
new file mode 100644
index 0000000..e0bf52f
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType60.out
@@ -0,0 +1,8 @@
+TargetType60.java:54:21: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType60.Sam0), TargetType60, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60
+TargetType60.java:55:21: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:60:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:60:29: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, n1(java.lang.String))
+TargetType60.java:61:29: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, n2(TargetType60,java.lang.String))
+TargetType60.java:62:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+TargetType60.java:63:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60
+7 errors
diff --git a/test/tools/javac/lambda/TargetType61.java b/test/tools/javac/lambda/TargetType61.java
new file mode 100644
index 0000000..1eae34e
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType61.java
@@ -0,0 +1,47 @@
+/*
+ * 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 8007464
+ * @summary Add graph inference support
+ *          check that new wildcards inference strategy doesn't run into 7190296
+ * @compile TargetType61.java
+ */
+class TargetType61 {
+
+    interface Stream<T> {
+        void forEach(Sink<? super T> sink);
+    }
+
+    interface Sink<T> {
+        void put(T t);
+    }
+
+    public boolean add(CharSequence s) { return false; }
+
+    public void addAll(Stream<? extends CharSequence> stream) {
+        stream.forEach(this::add);
+        stream.forEach(e -> { add(e); });
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType62.java b/test/tools/javac/lambda/TargetType62.java
new file mode 100644
index 0000000..9bf79bb
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType62.java
@@ -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 8007464
+ * @summary Add graph inference support
+ *          check that new wildcards inference strategy doesn't run into 7190296
+ * @compile TargetType62.java
+ */
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.*;
+
+class TargetType61 {
+
+    Collector test(Function<Integer, Integer> classifier) {
+        return g(classifier, TreeMap::new, m(HashSet::new));
+    }
+
+    <R> Collector<Integer, R> m(Supplier<R> s) { return null; }
+
+    <T, K, D, M extends Map<K, D>>
+            Collector<T, M> g(Function<T, K> classifier, Supplier<M> mapFactory, Collector<T, D> downstream) { return null; }
+}
diff --git a/test/tools/javac/lambda/TargetType63.java b/test/tools/javac/lambda/TargetType63.java
new file mode 100644
index 0000000..93d292a
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType63.java
@@ -0,0 +1,40 @@
+/*
+ * @test /nodynamiccopyright/
+ * @summary smoke test for inference of throws type variables
+ * @compile/fail/ref=TargetType63.out -XDrawDiagnostics TargetType63.java
+ */
+class TargetType63 {
+
+    interface F<T extends Throwable> {
+        void m() throws T;
+    }
+
+    void g1() { }
+    void g2() throws ClassNotFoundException { }
+    void g3() throws Exception { }
+
+    <Z extends Throwable> void m1(F<Z> fz) throws Z { }
+    <Z extends ClassNotFoundException> void m2(F<Z> fz) throws Z { }
+
+    void test1() {
+        m1(()->{ }); //ok (Z = RuntimeException)
+        m1(this::g1); //ok (Z = RuntimeException)
+    }
+
+    void test2() {
+        m2(()->{ }); //fail (Z = ClassNotFoundException)
+        m2(this::g1); //fail (Z = ClassNotFoundException)
+    }
+
+    void test3() {
+        m1(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException)
+        m1(this::g2); //fail (Z = ClassNotFoundException)
+        m2(()->{ throw new ClassNotFoundException(); }); //fail (Z = ClassNotFoundException)
+        m2(this::g2); //fail (Z = ClassNotFoundException)
+    }
+
+    void test4() {
+        m1(()->{ throw new Exception(); }); //fail (Z = Exception)
+        m1(this::g3); //fail (Z = Exception)
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType63.out b/test/tools/javac/lambda/TargetType63.out
new file mode 100644
index 0000000..cfacfe2
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType63.out
@@ -0,0 +1,9 @@
+TargetType63.java:25:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:26:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:30:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:31:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:32:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:33:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.ClassNotFoundException
+TargetType63.java:37:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+TargetType63.java:38:11: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+8 errors
diff --git a/test/tools/javac/lambda/TargetType64.java b/test/tools/javac/lambda/TargetType64.java
new file mode 100644
index 0000000..60209e0
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType64.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8008293
+ * @summary Declared bounds not considered when functional interface containing unbound wildcards is instantiated
+ * @compile TargetType64.java
+ */
+class TargetType64 {
+    interface SAM<X extends Number> {
+        void m(X x);
+    }
+
+    void g(Object o) { }
+
+    void test() {
+        SAM<?> s1 = (x)->{};
+        SAM<?> s2 = this::g;
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType65.java b/test/tools/javac/lambda/TargetType65.java
new file mode 100644
index 0000000..6224848
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType65.java
@@ -0,0 +1,58 @@
+/*
+ * 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 8008723
+ * @summary Graph Inference: bad graph calculation leads to assertion error
+ * @compile TargetType65.java
+ */
+class TargetType65 {
+    interface Predicate<X> {
+        boolean accepts(X x);
+    }
+
+    static class Optional<T> {
+        public boolean isPresent() { return false; }
+        public static<E> Optional<E> empty() { return null; }
+    }
+
+    interface Supplier<X> {
+        X make();
+    }
+
+    static class Sink<O, T> { }
+
+    static class SubSink<R> extends Sink<R, Optional<R>> {  }
+
+    static class Tester<T, O> {
+        public static <F> Tester<F, Optional<F>> makeRef() {
+            return new Tester<>(Optional.empty(), Optional::isPresent, SubSink::new);
+        }
+
+        private Tester(O emptyValue,
+                       Predicate<O> presentPredicate,
+                       Supplier<Sink<T, O>> sinkSupplier) {
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType66.java b/test/tools/javac/lambda/TargetType66.java
new file mode 100644
index 0000000..d9e85a0
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType66.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8009131
+ * @summary Overload: javac should discard methods that lead to errors in lambdas with implicit parameter types
+ * @compile/fail/ref=TargetType66.out -XDrawDiagnostics TargetType66.java
+ */
+class TargetType66 {
+    interface SAM1 {
+        void m(String s);
+    }
+
+    interface SAM2 {
+        void m(Integer s);
+    }
+
+    void g(SAM1 s1) { }
+    void g(SAM2 s2) { }
+
+    void test() {
+        g(x->{ String s = x; }); //g(SAM1)
+        g(x->{ Integer i = x; }); //g(SAM2)
+        g(x->{ Object o = x; }); //ambiguous
+        g(x->{ Character c = x; }); //error: inapplicable methods
+        g(x->{ Character c = ""; }); //error: incompatible types
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType66.out b/test/tools/javac/lambda/TargetType66.out
new file mode 100644
index 0000000..b5c828d
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType66.out
@@ -0,0 +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.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.n [...]
+TargetType66.java:24:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Character)
+3 errors
diff --git a/test/tools/javac/lambda/TargetType67.java b/test/tools/javac/lambda/TargetType67.java
new file mode 100644
index 0000000..b949b32
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType67.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8010303
+ * @summary Graph inference: missing incorporation step causes spurious inference error
+ * @compile TargetType67.java
+ */
+class TargetType67 {
+
+    interface Func<A, B> {
+        B f(A a);
+    }
+
+    class List<X> {
+
+        <M> List<M> map(Func<X, M> f) {
+            return null;
+        }
+
+        <A> List<A> apply(final List<Func<X, A>> lf) {
+            return null;
+        }
+
+        <B, C> List<C> bind(final List<B> lb, final Func<X, Func<B, C>> f) {
+            return lb.apply(map(f));
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType68.java b/test/tools/javac/lambda/TargetType68.java
new file mode 100644
index 0000000..92ce99b
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType68.java
@@ -0,0 +1,63 @@
+/*
+ * 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 8010303
+ * @summary Graph inference: missing incorporation step causes spurious inference error
+ * @compile TargetType68.java
+ */
+import java.util.*;
+
+class TargetType68 {
+
+    //derived from FX 2.2 API
+    static class XYChart<X,Y> {
+        static final class Series<X,Y> {
+            Series(java.lang.String name, ObservableList<XYChart.Data<X,Y>> data) { }
+        }
+
+        static final class Data<X,Y> { }
+
+        ObservableList<XYChart.Series<X,Y>> getData() { return null; }
+    }
+
+    //derived from FX 2.2 API
+    interface ObservableList<X> extends List<X> {
+        boolean setAll(Collection<? extends X> col);
+    }
+
+    //derived from FX 2.2 API
+    static class FXCollections {
+        static <E> ObservableList<E> observableList(List<E> l) { return null; }
+    }
+
+    private void testMethod() {
+            XYChart<Number, Number> numberChart = null;
+            List<XYChart.Data<Number, Number>> data_1 = new ArrayList<>();
+            List<XYChart.Data<Number, Number>> data_2 = new ArrayList<>();
+            numberChart.getData().setAll(
+                    Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)),
+                    new XYChart.Series<>("Data", FXCollections.observableList(data_2))));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType69.java b/test/tools/javac/lambda/TargetType69.java
new file mode 100644
index 0000000..065c1e9
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType69.java
@@ -0,0 +1,51 @@
+/*
+ * 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 8010303
+ * @summary Graph inference: missing incorporation step causes spurious inference error
+ * @compile TargetType69.java
+ */
+import java.util.*;
+
+class TargetType69 {
+
+    interface Function<X,Y> {
+        Y m(X x);
+    }
+
+    abstract class TabulationAssertion<T, U> { }
+
+    class GroupedMapAssertion<K, M1 extends Map<K, ?>> extends TabulationAssertion<Integer, M1> {
+        GroupedMapAssertion(Function<Integer, K> classifier) { }
+    }
+
+
+    <T, M2 extends Map> void exerciseMapTabulation(Function<T, ? extends M2> collector,
+                                                             TabulationAssertion<T, M2> assertion)  { }
+
+    void test(Function<Integer, Integer> classifier, Function<Integer, Map<Integer, List<Integer>>> coll) {
+        exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType70.java b/test/tools/javac/lambda/TargetType70.java
new file mode 100644
index 0000000..3686813
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType70.java
@@ -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 8011028
+ * @summary lang/INFR/infr001/infr00101md/infr00101md.java fails to compile after switch to JDK8-b82
+ * @compile TargetType70.java
+ */
+class TargetType70  {
+
+    static class Sup {}
+    static class Sub extends Sup {}
+
+    interface I<T extends GenSup<U>, U> {
+        T m(U o);
+    }
+
+    static class GenSup<T> {
+        GenSup(T f) { }
+    }
+
+    static class GenSub<T> extends GenSup<T> {
+        GenSub(T f) { super(f); }
+    }
+
+    <T extends Sup> void m(I<? extends GenSup<T>, T> o1, T o2) { }
+
+    void test(Sub sub) {
+        m(GenSub::new, sub);
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType71.java b/test/tools/javac/lambda/TargetType71.java
new file mode 100644
index 0000000..9f17a1e
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType71.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8011377
+ * @summary Javac crashes when multiple lambdas are defined in an array
+ * @compile TargetType71.java
+ */
+class TargetType71 {
+    void test() {
+        Runnable[] rs = { () -> { String x = null; }, () -> { String x = null; } };
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType72.java b/test/tools/javac/lambda/TargetType72.java
new file mode 100644
index 0000000..c74efab
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType72.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8011376
+ * @summary Spurious checked exception errors in nested method call
+ * @compile TargetType72.java
+ */
+import java.io.IOException;
+import java.util.concurrent.Callable;
+
+class TargetType72 {
+
+    Callable<Number> c = id(id(()->{ if (true) throw new java.io.IOException(); return 0; }));
+
+    <Z> Z id(Z z) { return null; }
+
+}
diff --git a/test/tools/javac/lambda/TargetType73.java b/test/tools/javac/lambda/TargetType73.java
new file mode 100644
index 0000000..36e5684
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType73.java
@@ -0,0 +1,47 @@
+/*
+ * 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 8014494
+ * @summary javac crashes when varargs element of a method reference is inferred from the context
+ * @compile TargetType73.java
+ */
+import java.util.List;
+
+class TargetType73 {
+
+    interface Function<X,Y> {
+        Y m(X x);
+    }
+
+    static void test() {
+        m(TargetType73::g);
+    }
+
+    public static <T> List<T> g(T... a) {
+        return null;
+    }
+
+    public static <C> void m(Function<String, C> zipper) {  }
+}
diff --git a/test/tools/javac/lambda/TargetType74.java b/test/tools/javac/lambda/TargetType74.java
new file mode 100644
index 0000000..ffd8dbf
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType74.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8015432
+ * @summary javac crashes with stack overflow when method called recursively from nested generic call
+ * @compile TargetType74.java
+ */
+class TargetType74 {
+
+    static class LazySeq<E> { }
+
+    <C> LazySeq<C> cons(LazySeq<C> tailFun) { return null; }
+
+    <T extends Comparable<T>> LazySeq<T> mergeSorted(LazySeq<T> a) {
+        return cons(mergeSorted(a));
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType75.java b/test/tools/javac/lambda/TargetType75.java
new file mode 100644
index 0000000..a65b9b9
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType75.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8016060 8016059
+ * @summary Lambda isn't compiled with return statement
+ * @compile TargetType75.java
+ */
+class TargetType75 {
+    interface P<X> {
+        void m(X x);
+    }
+
+    <Z> void m(P<Z> r, Z z) { }
+
+    void test() {
+        m(x->{ return; }, "");
+        m(x->System.out.println(""), "");
+    }
+}
diff --git a/test/tools/javac/lambda/TargetType76.java b/test/tools/javac/lambda/TargetType76.java
new file mode 100644
index 0000000..c8a8086
--- /dev/null
+++ b/test/tools/javac/lambda/TargetType76.java
@@ -0,0 +1,65 @@
+/*
+ * 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 8016175
+ * @summary Add bottom-up type-checking support for unambiguous method references
+ * @compile TargetType76.java
+ */
+class TargetType76 {
+
+    interface Function<X, Y> {
+        Y m(X x);
+    }
+
+    interface OfRef<T> { }
+
+    interface Supplier<X> {
+        X make();
+    }
+
+    interface Stream<X> { }
+
+    interface Node<E> {
+        Spliterator<E> spliterator();
+    }
+
+    interface Spliterator<X> {
+        Spliterator<X> spliterator();
+    }
+
+    class RefTestData<T, I> implements OfRef<T> {
+        RefTestData(I state,
+                    Function<I, Stream<T>> streamFn,
+                    Function<I, Spliterator<T>> splitrFn) { }
+    }
+
+    <O> OfRef<O> ofCollection(Node<O> collection) {
+        return new RefTestData<>(collection,
+                                 x->stream(x::spliterator),
+                                 Node::spliterator);
+    }
+
+    <S> Stream<S> stream(Supplier<? extends Spliterator<S>> supplier) { return null; }
+}
diff --git a/test/tools/javac/lambda/TestInvokeDynamic.java b/test/tools/javac/lambda/TestInvokeDynamic.java
new file mode 100644
index 0000000..3a3a03f
--- /dev/null
+++ b/test/tools/javac/lambda/TestInvokeDynamic.java
@@ -0,0 +1,494 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7194586 8003280 8006694 8010404
+ * @summary Add lambda tests
+ *  Add back-end support for invokedynamic
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm TestInvokeDynamic
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Locale;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.TreeScanner;
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.BootstrapMethods_attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.LineNumberTable_attribute;
+import com.sun.tools.classfile.Method;
+
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Types;
+import com.sun.tools.javac.jvm.Pool;
+import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
+import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Names;
+
+import static com.sun.tools.javac.jvm.ClassFile.*;
+
+public class TestInvokeDynamic
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum StaticArgumentKind {
+        STRING("Hello!", "String", "Ljava/lang/String;") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_String_info) &&
+                        ((CONSTANT_String_info)cpInfo).getString()
+                        .equals(value);
+            }
+        },
+        CLASS(null, "Class<?>", "Ljava/lang/Class;") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_Class_info) &&
+                        ((CONSTANT_Class_info)cpInfo).getName()
+                        .equals("java/lang/String");
+            }
+        },
+        INTEGER(1, "int", "I") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_Integer_info) &&
+                        ((CONSTANT_Integer_info)cpInfo).value ==
+                        ((Integer)value).intValue();
+            }
+        },
+        LONG(1L, "long", "J") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_Long_info) &&
+                        ((CONSTANT_Long_info)cpInfo).value ==
+                        ((Long)value).longValue();
+            }
+        },
+        FLOAT(1.0f, "float", "F") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_Float_info) &&
+                        ((CONSTANT_Float_info)cpInfo).value ==
+                        ((Float)value).floatValue();
+            }
+        },
+        DOUBLE(1.0, "double","D") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_Double_info) &&
+                        ((CONSTANT_Double_info)cpInfo).value ==
+                        ((Double)value).doubleValue();
+            }
+        },
+        METHOD_HANDLE(null, "MethodHandle", "Ljava/lang/invoke/MethodHandle;") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                if (!(cpInfo instanceof CONSTANT_MethodHandle_info))
+                    return false;
+                CONSTANT_MethodHandle_info handleInfo =
+                        (CONSTANT_MethodHandle_info)cpInfo;
+                return handleInfo.getCPRefInfo().getClassName().equals("Array") &&
+                        handleInfo.reference_kind == RefKind.REF_invokeVirtual &&
+                        handleInfo.getCPRefInfo()
+                        .getNameAndTypeInfo().getName().equals("clone") &&
+                        handleInfo.getCPRefInfo()
+                        .getNameAndTypeInfo().getType().equals("()Ljava/lang/Object;");
+            }
+        },
+        METHOD_TYPE(null, "MethodType", "Ljava/lang/invoke/MethodType;") {
+            @Override
+            boolean check(CPInfo cpInfo) throws Exception {
+                return (cpInfo instanceof CONSTANT_MethodType_info) &&
+                        ((CONSTANT_MethodType_info)cpInfo).getType()
+                        .equals("()Ljava/lang/Object;");
+            }
+        };
+
+        Object value;
+        String sourceTypeStr;
+        String bytecodeTypeStr;
+
+        StaticArgumentKind(Object value, String sourceTypeStr,
+                String bytecodeTypeStr) {
+            this.value = value;
+            this.sourceTypeStr = sourceTypeStr;
+            this.bytecodeTypeStr = bytecodeTypeStr;
+        }
+
+        abstract boolean check(CPInfo cpInfo) throws Exception;
+
+        Object getValue(Symtab syms, Names names, Types types) {
+            switch (this) {
+                case STRING:
+                case INTEGER:
+                case LONG:
+                case FLOAT:
+                case DOUBLE:
+                    return value;
+                case CLASS:
+                    return syms.stringType.tsym;
+                case METHOD_HANDLE:
+                    return new Pool.MethodHandle(REF_invokeVirtual,
+                            syms.arrayCloneMethod, types);
+                case METHOD_TYPE:
+                    return syms.arrayCloneMethod.type;
+                default:
+                    throw new AssertionError();
+            }
+        }
+    }
+
+    enum StaticArgumentsArity {
+        ZERO(0),
+        ONE(1),
+        TWO(2),
+        THREE(3);
+
+        int arity;
+
+        StaticArgumentsArity(int arity) {
+            this.arity = arity;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (StaticArgumentsArity arity : StaticArgumentsArity.values()) {
+            if (arity.arity == 0) {
+                pool.execute(new TestInvokeDynamic(arity));
+            } else {
+                for (StaticArgumentKind sak1 : StaticArgumentKind.values()) {
+                    if (arity.arity == 1) {
+                        pool.execute(new TestInvokeDynamic(arity, sak1));
+                    } else {
+                        for (StaticArgumentKind sak2 : StaticArgumentKind.values()) {
+                            if (arity.arity == 2) {
+                                pool.execute(new TestInvokeDynamic(arity, sak1, sak2));
+                            } else {
+                                for (StaticArgumentKind sak3 : StaticArgumentKind.values()) {
+                                    pool.execute(
+                                        new TestInvokeDynamic(arity, sak1, sak2, sak3));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    StaticArgumentsArity arity;
+    StaticArgumentKind[] saks;
+    DiagChecker dc;
+
+    TestInvokeDynamic(StaticArgumentsArity arity, StaticArgumentKind... saks) {
+        this.arity = arity;
+        this.saks = saks;
+        dc = new DiagChecker();
+    }
+
+    public void run() {
+        int id = checkCount.incrementAndGet();
+        JavaSource source = new JavaSource(id);
+        JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc,
+                Arrays.asList("-g"), null, Arrays.asList(source));
+        Context context = ct.getContext();
+        Symtab syms = Symtab.instance(context);
+        Names names = Names.instance(context);
+        Types types = Types.instance(context);
+        ct.addTaskListener(new Indifier(syms, names, types));
+        try {
+            ct.generate();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            throw new AssertionError(
+                    String.format("Error thrown when compiling following code\n%s",
+                    source.source));
+        }
+        if (dc.diagFound) {
+            throw new AssertionError(
+                    String.format("Diags found when compiling following code\n%s\n\n%s",
+                    source.source, dc.printDiags()));
+        }
+        verifyBytecode(id);
+    }
+
+    void verifyBytecode(int id) {
+        File compiledTest = new File(String.format("Test%d.class", id));
+        try {
+            ClassFile cf = ClassFile.read(compiledTest);
+            Method testMethod = null;
+            for (Method m : cf.methods) {
+                if (m.getName(cf.constant_pool).equals("test")) {
+                    testMethod = m;
+                    break;
+                }
+            }
+            if (testMethod == null) {
+                throw new Error("Test method not found");
+            }
+            Code_attribute ea =
+                    (Code_attribute)testMethod.attributes.get(Attribute.Code);
+            if (testMethod == null) {
+                throw new Error("Code attribute for test() method not found");
+            }
+
+            int bsmIdx = -1;
+
+            for (Instruction i : ea.getInstructions()) {
+                if (i.getMnemonic().equals("invokedynamic")) {
+                    CONSTANT_InvokeDynamic_info indyInfo =
+                         (CONSTANT_InvokeDynamic_info)cf
+                            .constant_pool.get(i.getShort(1));
+                    bsmIdx = indyInfo.bootstrap_method_attr_index;
+                    if (!indyInfo.getNameAndTypeInfo().getType().equals("()V")) {
+                        throw new
+                            AssertionError("type mismatch for CONSTANT_InvokeDynamic_info");
+                    }
+                }
+            }
+            if (bsmIdx == -1) {
+                throw new Error("Missing invokedynamic in generated code");
+            }
+
+            BootstrapMethods_attribute bsm_attr =
+                    (BootstrapMethods_attribute)cf
+                    .getAttribute(Attribute.BootstrapMethods);
+            if (bsm_attr.bootstrap_method_specifiers.length != 1) {
+                throw new Error("Bad number of method specifiers " +
+                        "in BootstrapMethods attribute");
+            }
+            BootstrapMethods_attribute.BootstrapMethodSpecifier bsm_spec =
+                    bsm_attr.bootstrap_method_specifiers[0];
+
+            if (bsm_spec.bootstrap_arguments.length != arity.arity) {
+                throw new Error("Bad number of static invokedynamic args " +
+                        "in BootstrapMethod attribute");
+            }
+
+            int count = 0;
+            for (StaticArgumentKind sak : saks) {
+                if (!sak.check(cf.constant_pool
+                        .get(bsm_spec.bootstrap_arguments[count]))) {
+                    throw new Error("Bad static argument value " + sak);
+                }
+                count++;
+            }
+
+            CONSTANT_MethodHandle_info bsm_handle =
+                    (CONSTANT_MethodHandle_info)cf.constant_pool
+                    .get(bsm_spec.bootstrap_method_ref);
+
+            if (bsm_handle.reference_kind != RefKind.REF_invokeStatic) {
+                throw new Error("Bad kind on boostrap method handle");
+            }
+
+            CONSTANT_Methodref_info bsm_ref =
+                    (CONSTANT_Methodref_info)cf.constant_pool
+                    .get(bsm_handle.reference_index);
+
+            if (!bsm_ref.getClassInfo().getName().equals("Bootstrap")) {
+                throw new Error("Bad owner of boostrap method");
+            }
+
+            if (!bsm_ref.getNameAndTypeInfo().getName().equals("bsm")) {
+                throw new Error("Bad boostrap method name");
+            }
+
+            if (!bsm_ref.getNameAndTypeInfo()
+                    .getType().equals(asBSMSignatureString())) {
+                throw new Error("Bad boostrap method type" +
+                        bsm_ref.getNameAndTypeInfo().getType() + " " +
+                        asBSMSignatureString());
+            }
+
+            LineNumberTable_attribute lnt =
+                    (LineNumberTable_attribute)ea.attributes.get(Attribute.LineNumberTable);
+
+            if (lnt == null) {
+                throw new Error("No LineNumberTable attribute");
+            }
+            if (lnt.line_number_table_length != 2) {
+                throw new Error("Wrong number of entries in LineNumberTable");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + compiledTest +": " + e);
+        }
+    }
+
+    String asBSMSignatureString() {
+        StringBuilder buf = new StringBuilder();
+        buf.append("(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;");
+        for (StaticArgumentKind sak : saks) {
+            buf.append(sak.bytecodeTypeStr);
+        }
+        buf.append(")Ljava/lang/invoke/CallSite;");
+        return buf.toString();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        static final String source_template = "import java.lang.invoke.*;\n" +
+                "class Bootstrap {\n" +
+                "   public static CallSite bsm(MethodHandles.Lookup lookup, " +
+                "String name, MethodType methodType #SARGS) {\n" +
+                "       return null;\n" +
+                "   }\n" +
+                "}\n" +
+                "class Test#ID {\n" +
+                "   void m() { }\n" +
+                "   void test() {\n" +
+                "      Object o = this; // marker statement \n" +
+                "      m();\n" +
+                "   }\n" +
+                "}";
+
+        String source;
+
+        JavaSource(int id) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = source_template.replace("#SARGS", asSignatureString())
+                    .replace("#ID", String.valueOf(id));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+
+        String asSignatureString() {
+            int count = 0;
+            StringBuilder buf = new StringBuilder();
+            for (StaticArgumentKind sak : saks) {
+                buf.append(",");
+                buf.append(sak.sourceTypeStr);
+                buf.append(' ');
+                buf.append(String.format("x%d", count++));
+            }
+            return buf.toString();
+        }
+    }
+
+    class Indifier extends TreeScanner<Void, Void> implements TaskListener {
+
+        MethodSymbol bsm;
+        Symtab syms;
+        Names names;
+        Types types;
+
+        Indifier(Symtab syms, Names names, Types types) {
+            this.syms = syms;
+            this.names = names;
+            this.types = types;
+        }
+
+        @Override
+        public void started(TaskEvent e) {
+            //do nothing
+        }
+
+        @Override
+        public void finished(TaskEvent e) {
+            if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+                scan(e.getCompilationUnit(), null);
+            }
+        }
+
+        @Override
+        public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
+            super.visitMethodInvocation(node, p);
+            JCMethodInvocation apply = (JCMethodInvocation)node;
+            JCIdent ident = (JCIdent)apply.meth;
+            Symbol oldSym = ident.sym;
+            if (!oldSym.isConstructor()) {
+                Object[] staticArgs = new Object[arity.arity];
+                for (int i = 0; i < arity.arity ; i++) {
+                    staticArgs[i] = saks[i].getValue(syms, names, types);
+                }
+                ident.sym = new Symbol.DynamicMethodSymbol(oldSym.name,
+                        oldSym.owner, REF_invokeStatic, bsm, oldSym.type, staticArgs);
+            }
+            return null;
+        }
+
+        @Override
+        public Void visitMethod(MethodTree node, Void p) {
+            super.visitMethod(node, p);
+            if (node.getName().toString().equals("bsm")) {
+                bsm = ((JCMethodDecl)node).sym;
+            }
+            return null;
+        }
+    }
+
+    static class DiagChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean diagFound;
+        ArrayList<String> diags = new ArrayList<>();
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            diags.add(diagnostic.getMessage(Locale.getDefault()));
+            diagFound = true;
+        }
+
+        String printDiags() {
+            StringBuilder buf = new StringBuilder();
+            for (String s : diags) {
+                buf.append(s);
+                buf.append("\n");
+            }
+            return buf.toString();
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/TestLambdaToMethodStats.java b/test/tools/javac/lambda/TestLambdaToMethodStats.java
new file mode 100644
index 0000000..7a1d06a
--- /dev/null
+++ b/test/tools/javac/lambda/TestLambdaToMethodStats.java
@@ -0,0 +1,192 @@
+/*
+ * 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 8013576
+ * @summary Add stat support to LambdaToMethod
+ * @library ../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm TestLambdaToMethodStats
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+public class TestLambdaToMethodStats
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum ExprKind {
+        LAMBDA("()->null"),
+        MREF1("this::g"),
+        MREF2("this::h");
+
+        String exprStr;
+
+        ExprKind(String exprStr) {
+            this.exprStr = exprStr;
+        }
+    }
+
+    enum TargetKind {
+        IMPLICIT(""),
+        SERIALIZABLE("(A & java.io.Serializable)");
+
+        String targetStr;
+
+        TargetKind(String targetStr) {
+            this.targetStr = targetStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ExprKind ek : ExprKind.values()) {
+            for (TargetKind tk : TargetKind.values()) {
+                pool.execute(new TestLambdaToMethodStats(ek, tk));
+            }
+        }
+
+        checkAfterExec(true);
+    }
+
+    ExprKind ek;
+    TargetKind tk;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+
+    TestLambdaToMethodStats(ExprKind ek, TargetKind tk) {
+        this.ek = ek;
+        this.tk = tk;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface A {\n" +
+                          "   Object o();\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                          "   A a = #C#E;\n" +
+                          "   Object g() { return null; }\n" +
+                          "   Object h(Object... o) { return null; }\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.exprStr)
+                    .replaceAll("#C", tk.targetStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                Arrays.asList("-XDdumpLambdaToMethodStats"),
+                null, Arrays.asList(source));
+        try {
+            ct.generate();
+        } catch (Throwable ex) {
+            throw new
+                AssertionError("Error thron when analyzing the following source:\n" +
+                    source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        boolean error = diagChecker.lambda !=
+                (ek == ExprKind.LAMBDA);
+
+        error |= diagChecker.bridge !=
+                (ek == ExprKind.MREF2);
+
+        error |= diagChecker.altMetafactory !=
+                (tk == TargetKind.SERIALIZABLE);
+
+        if (error) {
+            throw new AssertionError("Bad stat diagnostic found for source\n" +
+                    "lambda = " + diagChecker.lambda + "\n" +
+                    "bridge = " + diagChecker.bridge + "\n" +
+                    "altMF = " + diagChecker.altMetafactory + "\n" +
+                    source.source);
+        }
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean altMetafactory;
+        boolean bridge;
+        boolean lambda;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            try {
+                if (diagnostic.getKind() == Diagnostic.Kind.NOTE) {
+                    switch (diagnostic.getCode()) {
+                        case "compiler.note.lambda.stat":
+                            lambda = true;
+                            break;
+                        case "compiler.note.mref.stat":
+                            lambda = false;
+                            bridge = false;
+                            break;
+                        case "compiler.note.mref.stat.1":
+                            lambda = false;
+                            bridge = true;
+                            break;
+                        default:
+                            throw new AssertionError("unexpected note: " + diagnostic.getCode());
+                    }
+                    ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
+                        (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
+                    altMetafactory = (Boolean)dsu.d.getArgs()[0];
+                }
+            } catch (RuntimeException t) {
+                t.printStackTrace();
+                throw t;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/TestSelfRef.java b/test/tools/javac/lambda/TestSelfRef.java
new file mode 100644
index 0000000..967673e
--- /dev/null
+++ b/test/tools/javac/lambda/TestSelfRef.java
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  Check that self/forward references from lambda expressions behave
+ *          consistently w.r.t. local inner classes
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class TestSelfRef {
+
+    static int checkCount = 0;
+
+    enum RefKind {
+        SELF_LAMBDA("SAM s = x->{ System.out.println(s); };", true, false),
+        FORWARD_LAMBDA("SAM s = x->{ System.out.println(f); };\nObject f = null;", false, true),
+        SELF_ANON("Object s = new Object() { void test() { System.out.println(s); } };", true, false),
+        FORWARD_ANON("Object s = new Object() { void test() { System.out.println(f); } }; Object f = null;", false, true);
+
+        String refStr;
+        boolean selfRef;
+        boolean forwardRef;
+
+        private RefKind(String refStr, boolean selfRef, boolean forwardRef) {
+            this.refStr = refStr;
+            this.selfRef = selfRef;
+            this.forwardRef = forwardRef;
+        }
+    }
+
+    enum EnclosingKind {
+        TOPLEVEL("class C { #S }"),
+        MEMBER_INNER("class Outer { class C { #S } }"),
+        NESTED_INNER("class Outer { static class C { #S } }");
+
+        String enclStr;
+
+        private EnclosingKind(String enclStr) {
+            this.enclStr = enclStr;
+        }
+    }
+
+    enum InnerKind {
+        NONE("#R"),
+        LOCAL_NONE("class Local { #R }"),
+        LOCAL_MTH("class Local { void test() { #R } }"),
+        ANON_NONE("new Object() { #R };"),
+        ANON_MTH("new Object() { void test() { #R } };");
+
+        String innerStr;
+
+        private InnerKind(String innerStr) {
+            this.innerStr = innerStr;
+        }
+
+        boolean inMethodContext(SiteKind sk) {
+            switch (this) {
+                case LOCAL_MTH:
+                case ANON_MTH: return true;
+                case NONE: return sk != SiteKind.NONE;
+                default:
+                    return false;
+            }
+        }
+    }
+
+    enum SiteKind {
+        NONE("#I"),
+        STATIC_INIT("static { #I }"),
+        INSTANCE_INIT("{ #I }"),
+        CONSTRUCTOR("C() { #I }"),
+        METHOD("void test() { #I }");
+
+        String siteStr;
+
+        private SiteKind(String siteStr) {
+            this.siteStr = siteStr;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (EnclosingKind ek : EnclosingKind.values()) {
+            for (SiteKind sk : SiteKind.values()) {
+                if (sk == SiteKind.STATIC_INIT && ek == EnclosingKind.MEMBER_INNER)
+                    continue;
+                for (InnerKind ik : InnerKind.values()) {
+                    if (ik != InnerKind.NONE && sk == SiteKind.NONE)
+                        break;
+                    for (RefKind rk : RefKind.values()) {
+                        new TestSelfRef(ek, sk, ik, rk).run(comp, fm);
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    EnclosingKind ek;
+    SiteKind sk;
+    InnerKind ik;
+    RefKind rk;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    TestSelfRef(EnclosingKind ek, SiteKind sk, InnerKind ik, RefKind rk) {
+        this.ek = ek;
+        this.sk = sk;
+        this.ik = ik;
+        this.rk = rk;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "interface SAM { void test(Object o); }\n#B";
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = bodyTemplate.replace("#B",
+                    ek.enclStr.replace("#S", sk.siteStr.replace("#I", ik.innerStr.replace("#R", rk.refStr))));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        //illegal forward ref
+        boolean errorExpected = ik.inMethodContext(sk) &&
+                (rk.selfRef || rk.forwardRef);
+        if (diagChecker.errorFound != errorExpected) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/VoidCompatibility.java b/test/tools/javac/lambda/VoidCompatibility.java
new file mode 100644
index 0000000..41fcf48
--- /dev/null
+++ b/test/tools/javac/lambda/VoidCompatibility.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that that void compatibility affects overloading as expected
+ * @compile VoidCompatibility.java
+ */
+class VoidCompatibility {
+
+    interface Runnable { void run(); } //1
+    interface Thunk<T> { T get(); } //2
+
+    void schedule(Runnable r) { }
+    void schedule(Thunk<?> t) { }
+
+    void test() {
+        schedule(() -> System.setProperty("done", "true")); //non-void most specific
+        schedule(() -> { System.setProperty("done", "true"); }); //1
+        schedule(() -> { return System.setProperty("done", "true"); }); //2
+        schedule(() -> System.out.println("done")); //1
+        schedule(() -> { System.out.println("done"); }); //1
+        schedule(Thread::yield); //1
+        schedule(Thread::getAllStackTraces); //non-void most specific
+        schedule(Thread::interrupted); //1 (most specific)
+    }
+}
diff --git a/test/tools/javac/lambda/WarnUnderscoreAsIdent.java b/test/tools/javac/lambda/WarnUnderscoreAsIdent.java
new file mode 100644
index 0000000..2090e4b
--- /dev/null
+++ b/test/tools/javac/lambda/WarnUnderscoreAsIdent.java
@@ -0,0 +1,55 @@
+/*
+ * 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 Check usages of underscore as identifier generate warnings
+ * @compile/fail/ref=WarnUnderscoreAsIdent.out -XDrawDiagnostics -Werror WarnUnderscoreAsIdent.java
+ */
+package _._;
+
+import _._;
+
+class _ {
+    String _ = null;
+    void _(String _) { }
+    void testLocal() {
+        String _ = null;
+    }
+    void testFor() {
+        for (int _ = 0; _ < 10; _++);
+    }
+    void testTry() {
+        try { } catch (Throwable _) { }
+    }
+    void testLabel() {
+        _:
+        for (;;) {
+            break _;
+        }
+        _:
+        for (;;) {
+            continue _;
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/WarnUnderscoreAsIdent.out b/test/tools/javac/lambda/WarnUnderscoreAsIdent.out
new file mode 100644
index 0000000..0d1185f
--- /dev/null
+++ b/test/tools/javac/lambda/WarnUnderscoreAsIdent.out
@@ -0,0 +1,20 @@
+WarnUnderscoreAsIdent.java:29:9: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:29:11: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:31:8: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:31:10: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:33:7: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:34:12: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:35:10: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:35:19: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:37:16: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:40:18: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:40:25: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:40:33: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:43:34: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:46:9: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:48:19: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:50:9: compiler.warn.underscore.as.identifier
+WarnUnderscoreAsIdent.java:52:22: compiler.warn.underscore.as.identifier
+- compiler.err.warnings.and.werror
+1 error
+17 warnings
diff --git a/test/tools/javac/lambda/abort/Abort.java b/test/tools/javac/lambda/abort/Abort.java
new file mode 100644
index 0000000..5f20a93
--- /dev/null
+++ b/test/tools/javac/lambda/abort/Abort.java
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that all diagnostics are dumped to output when compiler exits abruptly
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class Abort {
+
+    public static void main(String... args) throws Exception {
+
+        String SCRATCH_DIR = System.getProperty("user.dir");
+        JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
+        java.io.File testDir = new java.io.File(SCRATCH_DIR);
+
+        sourceA.dumpTo(testDir);
+        sourceB.dumpTo(testDir);
+
+        DiagnosticChecker diagChecker = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)javacTool.getTask(null, null, diagChecker,
+                Arrays.asList("-XDrawDiagnostics", "-cp", testDir.getAbsolutePath()),
+                null, Arrays.asList(sourceA.asJFO(testDir)));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            //ignore abort exception thrown by javac
+        }
+
+        if (!diagChecker.errorFound) {
+            throw new AssertionError("Missing diagnostic");
+        }
+    }
+
+    static class JavaSource {
+        String contents;
+        String filename;
+
+        public JavaSource(String filename, String contents) {
+            this.filename =  filename;
+            this.contents = contents;
+        }
+
+        void dumpTo(java.io.File loc) throws Exception {
+            java.io.File file = new java.io.File(loc, filename);
+            java.io.BufferedWriter bw = new java.io.BufferedWriter(new java.io.FileWriter(file));
+            bw.append(contents);
+            bw.close();
+        }
+
+        SimpleJavaFileObject asJFO(java.io.File dir) {
+            return new SimpleJavaFileObject(new java.io.File(dir, filename).toURI(), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return contents;
+                }
+            };
+        }
+    }
+
+    static JavaSource sourceA = new JavaSource("Abort.java", "public class Abort {\n" +
+                                "    public static void main(String[] args) {\n" +
+                                "        System.out.println(C.m());\n" +
+                                "    }\n" +
+                                "}");
+
+    static JavaSource sourceB = new JavaSource("C.java", "package com.example;\n" +
+                                "public class C {\n" +
+                                "    public static String m() { return null; }\n" +
+                                "}");
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                    diagnostic.getCode().contains("compiler.err.cant.access")) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/abort/CompletionFailure.java b/test/tools/javac/lambda/abort/CompletionFailure.java
new file mode 100644
index 0000000..879fba4
--- /dev/null
+++ b/test/tools/javac/lambda/abort/CompletionFailure.java
@@ -0,0 +1,137 @@
+/*
+ * 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 8009227
+ * @summary Certain diagnostics should not be deferred
+ */
+
+import com.sun.source.util.JavacTask;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class CompletionFailure {
+
+    public static void main(String... args) throws Exception {
+
+        String SCRATCH_DIR = System.getProperty("user.dir");
+        JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
+        File scratchDir = new File(SCRATCH_DIR);
+
+        sourceA.dumpTo(scratchDir);
+        sourceB.dumpTo(scratchDir);
+
+        JavacTask ct = (JavacTask)javacTool.getTask(null, null, null,
+                null, null, Arrays.asList(sourceA.asJFO(scratchDir), sourceB.asJFO(scratchDir)));
+
+        ct.generate();
+
+        remove(scratchDir, "A.java");
+        remove(scratchDir, "B.java");
+        remove(scratchDir, "A.class");
+
+        sourceC.dumpTo(scratchDir);
+        sourceD.dumpTo(scratchDir);
+
+        DiagnosticChecker diagChecker = new DiagnosticChecker();
+        ct = (JavacTask)javacTool.getTask(null, null, diagChecker,
+                Arrays.asList("-XDrawDiagnostics", "-cp", scratchDir.getAbsolutePath()),
+                null, Arrays.asList(sourceC.asJFO(scratchDir), sourceD.asJFO(scratchDir)));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            //ignore abort exception thrown by javac
+        }
+
+        if (!diagChecker.errorFound) {
+            throw new AssertionError("Missing diagnostic");
+        }
+    }
+
+    static void remove(File dir, String fileName) {
+        File fileToRemove = new File(dir, fileName);
+        fileToRemove.delete();
+    }
+
+    static class JavaSource {
+        String contents;
+        String filename;
+
+        public JavaSource(String filename, String contents) {
+            this.filename =  filename;
+            this.contents = contents;
+        }
+
+        void dumpTo(java.io.File loc) throws Exception {
+            File file = new File(loc, filename);
+            BufferedWriter bw = new java.io.BufferedWriter(new FileWriter(file));
+            bw.append(contents);
+            bw.close();
+        }
+
+        SimpleJavaFileObject asJFO(java.io.File dir) {
+            return new SimpleJavaFileObject(new File(dir, filename).toURI(), JavaFileObject.Kind.SOURCE) {
+                @Override
+                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+                    return contents;
+                }
+            };
+        }
+    }
+
+    static JavaSource sourceA = new JavaSource("A.java", "public interface A { }\n");
+
+    static JavaSource sourceB = new JavaSource("B.java", "public class B implements A {\n" +
+                                               "   public static Object n() { return null; }\n" +
+                                               "}\n");
+
+    static JavaSource sourceC = new JavaSource("C.java", "public class C {\n" +
+                                               "   void test(B b) {\n" +
+                                               "      D.m(B.n());\n" +
+                                               "}  }\n");
+
+    static JavaSource sourceD = new JavaSource("D.java", "public class D {\n" +
+                                               "   static void m(Object o) { }\n" +
+                                               "}\n");
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                    diagnostic.getCode().contains("compiler.err.cant.access")) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/badMemberRefBytecode/Main.java b/test/tools/javac/lambda/badMemberRefBytecode/Main.java
new file mode 100644
index 0000000..4c834cf
--- /dev/null
+++ b/test/tools/javac/lambda/badMemberRefBytecode/Main.java
@@ -0,0 +1,9 @@
+import java.util.Collections;
+
+public class Main {
+
+    public static void main(String[] args) {
+        Collections.<String>sort(null, String::compareTo);
+    }
+
+}
diff --git a/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java b/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java
new file mode 100644
index 0000000..b314998
--- /dev/null
+++ b/test/tools/javac/lambda/badMemberRefBytecode/TestBadMemberRefBytecode.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 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 8003280
+ * @summary Add lambda tests
+ *  check that classfiles with member ref CP entries are read correctly
+ * @author  Jan Lahoda
+ * @compile Main.java
+ * @compile Use.java
+ */
diff --git a/test/tools/javac/lambda/badMemberRefBytecode/Use.java b/test/tools/javac/lambda/badMemberRefBytecode/Use.java
new file mode 100644
index 0000000..bb5a77a
--- /dev/null
+++ b/test/tools/javac/lambda/badMemberRefBytecode/Use.java
@@ -0,0 +1,3 @@
+public class Use {
+    private Main m;
+}
diff --git a/test/tools/javac/lambda/bridge/TestMetafactoryBridges.java b/test/tools/javac/lambda/bridge/TestMetafactoryBridges.java
new file mode 100644
index 0000000..3a4a695
--- /dev/null
+++ b/test/tools/javac/lambda/bridge/TestMetafactoryBridges.java
@@ -0,0 +1,359 @@
+/*
+ * 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 8013789
+ * @summary Compiler should emit bridges in interfaces
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.Diagnostic;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class TestMetafactoryBridges {
+
+    static int checkCount = 0;
+
+    enum ClasspathKind {
+        NONE(),
+        B7(7, ClassKind.B),
+        A7(7, ClassKind.A),
+        B8(8, ClassKind.B),
+        A8(8, ClassKind.A);
+
+        int version;
+        ClassKind ck;
+
+        ClasspathKind() {
+            this(-1, null);
+        }
+
+        ClasspathKind(int version, ClassKind ck) {
+            this.version = version;
+            this.ck = ck;
+        }
+    }
+
+    enum PreferPolicy {
+        SOURCE("-Xprefer:source"),
+        NEWER("-Xprefer:newer");
+
+        String preferOpt;
+
+        PreferPolicy(String preferOpt) {
+            this.preferOpt = preferOpt;
+        }
+    }
+
+    enum SourcepathKind {
+        NONE,
+        A(ClassKind.A),
+        B(ClassKind.B),
+        C(ClassKind.C),
+        AB(ClassKind.A, ClassKind.B),
+        BC(ClassKind.B, ClassKind.C),
+        AC(ClassKind.A, ClassKind.C),
+        ABC(ClassKind.A, ClassKind.B, ClassKind.C);
+
+        List<ClassKind> sources;
+
+        SourcepathKind(ClassKind... sources) {
+            this.sources = Arrays.asList(sources);
+        }
+    }
+
+    enum SourceSet {
+        ALL() {
+            @Override
+            List<List<ClassKind>> permutations() {
+                return Arrays.asList(
+                    Arrays.asList(ClassKind.A, ClassKind.B, ClassKind.C),
+                    Arrays.asList(ClassKind.A, ClassKind.B, ClassKind.C),
+                    Arrays.asList(ClassKind.B, ClassKind.A, ClassKind.C),
+                    Arrays.asList(ClassKind.B, ClassKind.C, ClassKind.A),
+                    Arrays.asList(ClassKind.C, ClassKind.A, ClassKind.B),
+                    Arrays.asList(ClassKind.C, ClassKind.B, ClassKind.A)
+                );
+            }
+        },
+        AC() {
+            @Override
+            List<List<ClassKind>> permutations() {
+                return Arrays.asList(
+                    Arrays.asList(ClassKind.A, ClassKind.C),
+                    Arrays.asList(ClassKind.C, ClassKind.A)
+                );
+            }
+        },
+        C() {
+            @Override
+            List<List<ClassKind>> permutations() {
+                return Arrays.asList(Arrays.asList(ClassKind.C));
+            }
+        };
+
+        abstract List<List<ClassKind>> permutations();
+    }
+
+    enum ClassKind {
+        A("A", "interface A { Object m(); }"),
+        B("B", "interface B extends A { Integer m(); }", A),
+        C("C", "class C { B b = ()->42; }", A, B);
+
+        String name;
+        String source;
+        ClassKind[] deps;
+
+        ClassKind(String name, String source, ClassKind... deps) {
+            this.name = name;
+            this.source = source;
+            this.deps = deps;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        String SCRATCH_DIR = System.getProperty("user.dir");
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+        int n = 0;
+        for (SourceSet ss : SourceSet.values()) {
+            for (List<ClassKind> sources : ss.permutations()) {
+                for (SourcepathKind spKind : SourcepathKind.values()) {
+                    for (ClasspathKind cpKind : ClasspathKind.values()) {
+                        for (PreferPolicy pp : PreferPolicy.values()) {
+                            Set<ClassKind> deps = EnumSet.noneOf(ClassKind.class);
+                            if (cpKind.ck != null) {
+                                deps.add(cpKind.ck);
+                            }
+                            deps.addAll(sources);
+                            if (deps.size() < 3) continue;
+                            File testDir = new File(SCRATCH_DIR, "test" + n);
+                            testDir.mkdir();
+                            try (PrintWriter debugWriter = new PrintWriter(new File(testDir, "debug.txt"))) {
+                                new TestMetafactoryBridges(testDir, sources, spKind, cpKind, pp, debugWriter).run(comp);
+                                n++;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    File testDir;
+    List<ClassKind> sources;
+    SourcepathKind spKind;
+    ClasspathKind cpKind;
+    PreferPolicy pp;
+    PrintWriter debugWriter;
+    DiagnosticChecker diagChecker;
+
+    TestMetafactoryBridges(File testDir, List<ClassKind>sources, SourcepathKind spKind,
+            ClasspathKind cpKind, PreferPolicy pp, PrintWriter debugWriter) {
+        this.testDir = testDir;
+        this.sources = sources;
+        this.spKind = spKind;
+        this.cpKind = cpKind;
+        this.pp = pp;
+        this.debugWriter = debugWriter;
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        final String source;
+
+        public JavaSource(ClassKind ck) {
+            super(URI.create(String.format("myfo:/%s.java", ck.name)), JavaFileObject.Kind.SOURCE);
+            this.source = ck.source;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool) throws Exception {
+        File classesDir = new File(testDir, "classes");
+        File outDir = new File(testDir, "out");
+        File srcDir = new File(testDir, "src");
+        classesDir.mkdir();
+        outDir.mkdir();
+        srcDir.mkdir();
+
+        debugWriter.append(testDir.getName() + "\n");
+        debugWriter.append("sources = " + sources + "\n");
+        debugWriter.append("spKind = " + spKind  + "\n");
+        debugWriter.append("cpKind = " + cpKind + "\n");
+        debugWriter.append("preferPolicy = " + pp.preferOpt + "\n");
+
+        //step 1 - prepare sources (older!!)
+        debugWriter.append("Preparing sources\n");
+        for (ClassKind ck : spKind.sources) {
+            //skip sources explicitly provided on command line
+            if (!sources.contains(ck)) {
+                debugWriter.append("Copy " + ck.name + ".java to" + srcDir.getAbsolutePath() + "\n");
+                File dest = new File(srcDir, ck.name + ".java");
+                PrintWriter pw = new PrintWriter(dest);
+                pw.append(ck.source);
+                pw.close();
+            }
+        }
+
+        //step 2 - prepare classes
+        debugWriter.append("Preparing classes\n");
+        if (cpKind != ClasspathKind.NONE) {
+            List<JavaSource> sources = new ArrayList<>();
+            ClassKind toRemove = null;
+            sources.add(new JavaSource(cpKind.ck));
+            if (cpKind.ck.deps.length != 0) {
+                //at most only one dependency
+                toRemove = cpKind.ck.deps[0];
+                sources.add(new JavaSource(toRemove));
+            }
+            JavacTask ct = (JavacTask)tool.getTask(debugWriter, null, null,
+                    Arrays.asList("-d", classesDir.getAbsolutePath(), "-source", String.valueOf(cpKind.version)), null, sources);
+            try {
+                ct.generate();
+                if (toRemove != null) {
+                    debugWriter.append("Remove " + toRemove.name + ".class from" + classesDir.getAbsolutePath() + "\n");
+                    File fileToRemove = new File(classesDir, toRemove.name + ".class");
+                    fileToRemove.delete();
+                }
+            } catch (Throwable ex) {
+                throw new AssertionError("Error thrown when generating side-classes");
+            }
+        }
+
+        //step 3 - compile
+        debugWriter.append("Compiling test\n");
+        List<JavaSource> sourcefiles = new ArrayList<>();
+        for (ClassKind ck : sources) {
+            sourcefiles.add(new JavaSource(ck));
+        }
+        JavacTask ct = (JavacTask)tool.getTask(debugWriter, null, diagChecker,
+                    Arrays.asList("-XDdumpLambdaToMethodStats", "-d", outDir.getAbsolutePath(),
+                                  "-sourcepath", srcDir.getAbsolutePath(),
+                                  "-classpath", classesDir.getAbsolutePath(),
+                                  pp.preferOpt), null, sourcefiles);
+        try {
+            ct.generate();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when compiling test case");
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+        if (diagChecker.errorFound) {
+            throw new AssertionError("Unexpected compilation failure");
+        }
+
+        boolean altMetafactory =
+                cpKind == ClasspathKind.B7 &&
+                !sources.contains(ClassKind.B) &&
+                (pp == PreferPolicy.NEWER || !spKind.sources.contains(ClassKind.B));
+
+        if (altMetafactory != diagChecker.altMetafactory) {
+            throw new AssertionError("Bad metafactory detected - expected altMetafactory: " + altMetafactory +
+                    "\ntest: " + testDir);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean altMetafactory = false;
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            } else if (statProcessor.matches(diagnostic)) {
+                statProcessor.process(diagnostic);
+            }
+        }
+
+        abstract class DiagnosticProcessor {
+
+            List<String> codes;
+            Diagnostic.Kind kind;
+
+            public DiagnosticProcessor(Kind kind, String... codes) {
+                this.codes = Arrays.asList(codes);
+                this.kind = kind;
+            }
+
+            abstract void process(Diagnostic<? extends JavaFileObject> diagnostic);
+
+            boolean matches(Diagnostic<? extends JavaFileObject> diagnostic) {
+                return (codes.isEmpty() || codes.contains(diagnostic.getCode())) &&
+                        diagnostic.getKind() == kind;
+            }
+
+            JCDiagnostic asJCDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic) {
+                if (diagnostic instanceof JCDiagnostic) {
+                    return (JCDiagnostic)diagnostic;
+                } else if (diagnostic instanceof DiagnosticSourceUnwrapper) {
+                    return ((DiagnosticSourceUnwrapper)diagnostic).d;
+                } else {
+                    throw new AssertionError("Cannot convert diagnostic to JCDiagnostic: " + diagnostic.getClass().getName());
+                }
+            }
+        }
+
+        DiagnosticProcessor statProcessor = new DiagnosticProcessor(Kind.NOTE,
+                "compiler.note.lambda.stat",
+                "compiler.note.mref.stat",
+                "compiler.note.mref.stat.1") {
+            @Override
+            void process(Diagnostic<? extends JavaFileObject> diagnostic) {
+                JCDiagnostic diag = asJCDiagnostic(diagnostic);
+                if ((Boolean)diag.getArgs()[0]) {
+                    altMetafactory = true;
+                }
+            }
+        };
+    }
+}
diff --git a/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java b/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java
new file mode 100644
index 0000000..300f61c
--- /dev/null
+++ b/test/tools/javac/lambda/bytecode/TestLambdaBytecode.java
@@ -0,0 +1,365 @@
+/*
+ * 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 8009649
+ * @summary Lambda back-end should generate invokespecial for method handles referring to private instance methods
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm TestLambdaBytecode
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.BootstrapMethods_attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.Method;
+
+import com.sun.tools.javac.api.JavacTaskImpl;
+
+
+import java.io.File;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Locale;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import static com.sun.tools.javac.jvm.ClassFile.*;
+
+public class TestLambdaBytecode
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum ClassKind {
+        CLASS("class"),
+        INTERFACE("interface");
+
+        String classStr;
+
+        ClassKind(String classStr) {
+            this.classStr = classStr;
+        }
+    }
+
+    enum AccessKind {
+        PUBLIC("public"),
+        PRIVATE("private");
+
+        String accessStr;
+
+        AccessKind(String accessStr) {
+            this.accessStr = accessStr;
+        }
+    }
+
+    enum StaticKind {
+        STATIC("static"),
+        INSTANCE("");
+
+        String staticStr;
+
+        StaticKind(String staticStr) {
+            this.staticStr = staticStr;
+        }
+    }
+
+    enum DefaultKind {
+        DEFAULT("default"),
+        NO_DEFAULT("");
+
+        String defaultStr;
+
+        DefaultKind(String defaultStr) {
+            this.defaultStr = defaultStr;
+        }
+    }
+
+    enum ExprKind {
+        LAMBDA("Runnable r = ()->{ target(); };");
+
+        String exprString;
+
+        ExprKind(String exprString) {
+            this.exprString = exprString;
+        }
+    }
+
+    static class MethodKind {
+        ClassKind ck;
+        AccessKind ak;
+        StaticKind sk;
+        DefaultKind dk;
+
+        MethodKind(ClassKind ck, AccessKind ak, StaticKind sk, DefaultKind dk) {
+            this.ck = ck;
+            this.ak = ak;
+            this.sk = sk;
+            this.dk = dk;
+        }
+
+        boolean inInterface() {
+            return ck == ClassKind.INTERFACE;
+        }
+
+        boolean isPrivate() {
+            return ak == AccessKind.PRIVATE;
+        }
+
+        boolean isStatic() {
+            return sk == StaticKind.STATIC;
+        }
+
+        boolean isDefault() {
+            return dk == DefaultKind.DEFAULT;
+        }
+
+        boolean isOK() {
+            if (isDefault() && (!inInterface() || isStatic())) {
+                return false;
+            } else if (inInterface() &&
+                    ((!isStatic() && !isDefault()) || isPrivate())) {
+                return false;
+            } else {
+                return true;
+            }
+        }
+
+        String mods() {
+            StringBuilder buf = new StringBuilder();
+            buf.append(ak.accessStr);
+            buf.append(' ');
+            buf.append(sk.staticStr);
+            buf.append(' ');
+            buf.append(dk.defaultStr);
+            return buf.toString();
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ClassKind ck : ClassKind.values()) {
+            for (AccessKind ak1 : AccessKind.values()) {
+                for (StaticKind sk1 : StaticKind.values()) {
+                    for (DefaultKind dk1 : DefaultKind.values()) {
+                        for (AccessKind ak2 : AccessKind.values()) {
+                            for (StaticKind sk2 : StaticKind.values()) {
+                                for (DefaultKind dk2 : DefaultKind.values()) {
+                                    for (ExprKind ek : ExprKind.values()) {
+                                        pool.execute(new TestLambdaBytecode(ck, ak1, ak2, sk1, sk2, dk1, dk2, ek));
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    MethodKind mk1, mk2;
+    ExprKind ek;
+    DiagChecker dc;
+
+    TestLambdaBytecode(ClassKind ck, AccessKind ak1, AccessKind ak2, StaticKind sk1,
+            StaticKind sk2, DefaultKind dk1, DefaultKind dk2, ExprKind ek) {
+        mk1 = new MethodKind(ck, ak1, sk1, dk1);
+        mk2 = new MethodKind(ck, ak2, sk2, dk2);
+        this.ek = ek;
+        dc = new DiagChecker();
+    }
+
+    public void run() {
+        int id = checkCount.incrementAndGet();
+        JavaSource source = new JavaSource(id);
+        JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc,
+                null, null, Arrays.asList(source));
+        try {
+            ct.generate();
+        } catch (Throwable t) {
+            t.printStackTrace();
+            throw new AssertionError(
+                    String.format("Error thrown when compiling following code\n%s",
+                    source.source));
+        }
+        if (dc.diagFound) {
+            boolean errorExpected = !mk1.isOK() || !mk2.isOK();
+            errorExpected |= mk1.isStatic() && !mk2.isStatic();
+
+            if (!errorExpected) {
+                throw new AssertionError(
+                        String.format("Diags found when compiling following code\n%s\n\n%s",
+                        source.source, dc.printDiags()));
+            }
+            return;
+        }
+        verifyBytecode(id, source);
+    }
+
+    void verifyBytecode(int id, JavaSource source) {
+        File compiledTest = new File(String.format("Test%d.class", id));
+        try {
+            ClassFile cf = ClassFile.read(compiledTest);
+            Method testMethod = null;
+            for (Method m : cf.methods) {
+                if (m.getName(cf.constant_pool).equals("test")) {
+                    testMethod = m;
+                    break;
+                }
+            }
+            if (testMethod == null) {
+                throw new Error("Test method not found");
+            }
+            Code_attribute ea =
+                    (Code_attribute)testMethod.attributes.get(Attribute.Code);
+            if (testMethod == null) {
+                throw new Error("Code attribute for test() method not found");
+            }
+
+            int bsmIdx = -1;
+
+            for (Instruction i : ea.getInstructions()) {
+                if (i.getMnemonic().equals("invokedynamic")) {
+                    CONSTANT_InvokeDynamic_info indyInfo =
+                         (CONSTANT_InvokeDynamic_info)cf
+                            .constant_pool.get(i.getShort(1));
+                    bsmIdx = indyInfo.bootstrap_method_attr_index;
+                    if (!indyInfo.getNameAndTypeInfo().getType().equals(makeIndyType(id))) {
+                        throw new
+                            AssertionError("type mismatch for CONSTANT_InvokeDynamic_info " + source.source + "\n" + indyInfo.getNameAndTypeInfo().getType() + "\n" + makeIndyType(id));
+                    }
+                }
+            }
+            if (bsmIdx == -1) {
+                throw new Error("Missing invokedynamic in generated code");
+            }
+
+            BootstrapMethods_attribute bsm_attr =
+                    (BootstrapMethods_attribute)cf
+                    .getAttribute(Attribute.BootstrapMethods);
+            if (bsm_attr.bootstrap_method_specifiers.length != 1) {
+                throw new Error("Bad number of method specifiers " +
+                        "in BootstrapMethods attribute");
+            }
+            BootstrapMethods_attribute.BootstrapMethodSpecifier bsm_spec =
+                    bsm_attr.bootstrap_method_specifiers[0];
+
+            if (bsm_spec.bootstrap_arguments.length != MF_ARITY) {
+                throw new Error("Bad number of static invokedynamic args " +
+                        "in BootstrapMethod attribute");
+            }
+
+            CONSTANT_MethodHandle_info mh =
+                    (CONSTANT_MethodHandle_info)cf.constant_pool.get(bsm_spec.bootstrap_arguments[1]);
+
+            boolean kindOK;
+            switch (mh.reference_kind) {
+                case REF_invokeStatic: kindOK = mk2.isStatic(); break;
+                case REF_invokeSpecial: kindOK = !mk2.isStatic(); break;
+                case REF_invokeInterface: kindOK = mk2.inInterface(); break;
+                default:
+                    kindOK = false;
+            }
+
+            if (!kindOK) {
+                throw new Error("Bad invoke kind in implementation method handle");
+            }
+
+            if (!mh.getCPRefInfo().getNameAndTypeInfo().getType().toString().equals(MH_SIG)) {
+                throw new Error("Type mismatch in implementation method handle");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + compiledTest +": " + e);
+        }
+    }
+    String makeIndyType(int id) {
+        StringBuilder buf = new StringBuilder();
+        buf.append("(");
+        if (!mk2.isStatic()) {
+            buf.append(String.format("LTest%d;", id));
+        }
+        buf.append(")Ljava/lang/Runnable;");
+        return buf.toString();
+    }
+
+    static final int MF_ARITY = 3;
+    static final String MH_SIG = "()V";
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        static final String source_template =
+                "#CK Test#ID {\n" +
+                "   #MOD1 void test() { #EK }\n" +
+                "   #MOD2 void target() { }\n" +
+                "}\n";
+
+        String source;
+
+        JavaSource(int id) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = source_template.replace("#CK", mk1.ck.classStr)
+                    .replace("#MOD1", mk1.mods())
+                    .replace("#MOD2", mk2.mods())
+                    .replace("#EK", ek.exprString)
+                    .replace("#ID", String.valueOf(id));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    static class DiagChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean diagFound;
+        ArrayList<String> diags = new ArrayList<>();
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            diags.add(diagnostic.getMessage(Locale.getDefault()));
+            diagFound = true;
+        }
+
+        String printDiags() {
+            StringBuilder buf = new StringBuilder();
+            for (String s : diags) {
+                buf.append(s);
+                buf.append("\n");
+            }
+            return buf.toString();
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/Helper.java b/test/tools/javac/lambda/funcInterfaces/Helper.java
new file mode 100644
index 0000000..ebc0f51
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/Helper.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+/*SAM types:
+         1. An interface that has a single abstract method
+         2. Having more than one distinct methods, but only one is "real", the others are overriden public methods in Object - example: Comparator<T>
+         3. Having more than one methods due to inheritance, but they have the same signature
+         4. Having more than one methods due to inheritance, but one of them has a subsignature of all other methods
+                a) parameter types compatible
+                b) return type substitutable
+                c) thrown type not conflicting with the thrown clause of any other method
+                d) mixed up
+         5. Type-dependent SAM types
+  non-SAM types:
+         6. An interface that has a single abstract method, which is also public method in Object
+         7. Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+*/
+
+import java.util.List;
+import java.util.Collection;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+
+interface A {int getOldest(List<Number> list);}
+interface B {int getOldest(List list);}
+interface C {int getOldest(List<?> list);}
+interface D {int getOldest(List<Integer> list);}
+interface E {int getOldest(Collection<?> collection);}
+//Not SAM type, case #7
+interface DE extends D, E {}
+
+interface Foo {int getAge(Number n);}
+interface Bar {int getAge(Integer i);}
+//Not SAM type, case #7
+interface FooBar extends Foo, Bar {}
+
+//Not SAM type, case #6
+interface Planet {boolean equals(Object o);}
+
+// SAM type interfaces:
+// type #2:
+//only one abstract non-Ojbect method getAge()
+interface Mars<T> extends Planet {int getAge(T t);}
+//only one abstract non-Ojbect method increment()
+interface Jupiter {
+    boolean equals(Object o);
+    String toString();
+    int increment(int i);
+}
+
+// type #3:
+interface X {int getTotal(List<String> arg);}
+interface Y {int getTotal(List<String> strs);}
+//SAM type ([List<String>], int, {})
+interface XY extends X, Y {}
+//SAM type ([List<String>], int, {})
+interface XYZ extends X, Y, XY {}
+
+// type #4 a):
+//SAM type ([List], int, {})
+interface AB extends A, B {}
+
+// type #4 b):
+interface F {Number getValue(String str);}
+interface G {Integer getValue(String str);}
+interface H {Serializable getValue(String str);}
+interface I {Object getValue(String str);}
+//SAM type ([String], Integer, {})
+interface FGHI extends F, G, H, I {}
+
+interface J {List<Number> getAll(String str);}
+interface K {List<?> getAll(String str);}
+interface L {List getAll(String str);}
+interface M {Collection getAll(String str);}
+//SAM type ([String], List<Number>/List, {}) - the return type is flexible to some degree
+interface JK extends J, K {}
+//SAM type ([String], List<Number>/List, {})
+interface JL extends J, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKL extends J, K, L {}
+//SAM type ([String], List<Number>/List, {})
+interface JKLM extends J, K, L, M {}
+
+// type #4 c):
+interface N {String getText(File f) throws IOException;}
+interface O {String getText(File f) throws FileNotFoundException;}
+interface P {String getText(File f) throws NullPointerException;}
+//SAM type ([File], String, {FileNotFoundException})
+interface NO extends N, O {}
+//SAM type ([File], String, {})
+interface NOP extends N, O, P {}
+
+interface Boo {int getAge(String s) throws IOException;}
+interface Doo {int getAge(String s) throws SQLException;}
+//SAM type ([String], int, {})
+interface BooDoo extends Boo, Doo {}
+
+// type #4 d):
+interface Q {Iterable m(Iterable<String> arg);}
+interface R {Iterable<String> m(Iterable arg);}
+//SAM type ([Iterable], Iterable<String>/Iterable, {})
+interface QR extends Q, R {}
+
+interface U {Collection foo(List<String> arg) throws IOException, SQLTransientException;}
+interface V {List<?> foo(List<String> arg) throws EOFException, SQLException, TimeoutException;}
+interface W {List<String> foo(List arg) throws Exception;}
+//SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+interface UV extends U, V {}
+// SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+interface UVW extends U, V, W {}
+
+// type #5:
+// Not a SAM because sam-ness depends on instantiation of type-variables
+interface Qoo<T> {void m(T arg);}
+interface Roo<S extends Number> {void m(S arg);}
+interface QooRoo<T1, T2 extends Number, T3> extends Qoo<T1>, Roo<T2> {}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java
new file mode 100644
index 0000000..022c94c
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1.java
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *   This test is for lambda expressions
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest1 {
+    public static void main(String[] args) {
+
+        LambdaTest1 test = new LambdaTest1();
+
+        test.method2((int n) -> { });
+        test.method2((int n) -> { });
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { System.out.println(n); }); // ";" is optional here
+        test.method2(n -> { System.out.println(n); }); //warning, explict type required for n?
+
+        test.method3(()-> { System.out.println("implementing VoidVoid.vvMethod()"); });
+        test.method3(() -> {});
+
+        test.method4(()-> 42);
+        test.method4(()-> { return 42; });//";" is mandatory here
+
+        test.method5((int n)-> n+1);
+        test.method5((int n) -> 42);
+        test.method5((int n) -> { return 42; });
+        test.method5(
+            (int n) -> { //"{" optional here
+                if(n > 0)
+                    return n++;
+                else
+                    return n--;
+            }
+        );
+
+        Runnable r = ()-> { System.out.println("Runnable.run() method implemented"); };
+        r.run();
+        ((Runnable)()-> { System.out.println("Runnable.run() method implemented"); }).run();
+    }
+
+    void method2(VoidInt a) {
+        System.out.println("method2()");
+        final int N = 1;
+        int n = 2; //effectively final variable
+        System.out.println("method2() \"this\":" + this);
+        ((Runnable)
+            ()->{
+                System.out.println("inside lambda \"this\":" + this);
+                System.out.println("inside lambda accessing final variable N:" + N);
+                System.out.println("inside lambda accessing effectively final variable n:" + n);
+            }
+        ).run();
+        //n++; //compile error if n is modified
+        a.viMethod(2);
+    }
+
+    void method3(VoidVoid a) {
+        System.out.println("method3()");
+        a.vvMethod();
+    }
+
+    void method4(IntVoid a) {
+        System.out.println("method4()");
+        System.out.println(a.ivMethod());
+    }
+
+    void method5(IntInt a) {
+        System.out.println("method5()");
+        System.out.println(a.iiMethod(5));
+    }
+
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java
new file mode 100644
index 0000000..90226c0
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify invalid lambda expressions
+ * @compile/fail/ref=LambdaTest1_neg1.out -XDrawDiagnostics LambdaTest1_neg1.java
+ */
+
+import java.util.Comparator;
+
+public class LambdaTest1_neg1 {
+    void method() {
+        Comparator<Number> c = (Number n1, Number n2) -> { 42; } //compile error, not a statement
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out
new file mode 100644
index 0000000..2ea34b7
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg1.out
@@ -0,0 +1,3 @@
+LambdaTest1_neg1.java:13:60: compiler.err.not.stmt
+LambdaTest1_neg1.java:13:65: compiler.err.expected: ';'
+2 errors
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java
new file mode 100644
index 0000000..62e452d
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of accessing "this" from within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg2.out -XDrawDiagnostics LambdaTest1_neg2.java
+ */
+
+public class LambdaTest1_neg2 {
+    static void method() {
+        ((Runnable)
+            ()-> {
+                Object o = this; //use "this" inside lambda expression which is inside a static method, not allowed
+            }
+        ).run();
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out
new file mode 100644
index 0000000..55ebd7f
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg2.out
@@ -0,0 +1,2 @@
+LambdaTest1_neg2.java:13:28: compiler.err.non-static.cant.be.ref: kindname.variable, this
+1 error
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java
new file mode 100644
index 0000000..338a310
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is to verify mis-use of capturing local variable within lambda expression
+ * @compile/fail/ref=LambdaTest1_neg3.out -XDrawDiagnostics LambdaTest1_neg3.java
+ */
+
+public class LambdaTest1_neg3 {
+    void method() {
+        int n = 2; //effectively final variable
+        ((Runnable)
+            ()-> {
+                int n2 = n; //inside lambda accessing effectively final variable;
+            }
+        ).run();
+        n++; //compile error if n is modified
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out
new file mode 100644
index 0000000..b93fb04
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest1_neg3.out
@@ -0,0 +1,2 @@
+LambdaTest1_neg3.java:14:26: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+1 error
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java
new file mode 100644
index 0000000..050ae2a
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM1.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types 2 and 3, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM1.java Helper.java
+ * @run main LambdaTest2_SAM1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.*;
+
+public class LambdaTest2_SAM1 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<File> files = new ArrayList<File>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        files.add(new File("a.txt"));
+        files.add(new File("c.txt"));
+        files.add(new File("b.txt"));
+
+        //type #2: Comparator<T>
+        Collections.sort(files, (File f1, File f2) -> f1.getName().compareTo(f2.getName()));
+        for(File f : files)
+            System.out.println(f.getName());
+        System.out.println();
+        Collections.sort(files, (File f1, File f2) -> (int)(f1.length() - f2.length()));
+        for(File f : files)
+            System.out.println(f.getName() + " " + f.length());
+        System.out.println();
+
+        LambdaTest2_SAM1 test = new LambdaTest2_SAM1();
+
+        //type #2:
+        test.methodMars((File f) -> {
+            System.out.println("implementing Mars<File>.getAge(File f)...");
+            return (int)f.length();
+        });
+        test.methodJupiter((int n) -> n+1);
+
+        //type #3:
+        test.methodXY((List<String> strList) -> strList.size() );
+        test.methodXYZ((List<String> strList) -> 20 );
+    }
+
+    //type #2:
+    void methodMars(Mars<File> m) {
+        System.out.println("methodMars(): SAM type interface Mars object instantiated: " + m);
+        System.out.println(m.getAge(new File("a.txt")));
+    }
+
+    //type #2:
+    void methodJupiter(Jupiter j) {
+        System.out.println("methodJupiter(): SAM type interface Jupiter object instantiated: " + j);
+        System.out.println(j.increment(33));
+    }
+
+    //type #3:
+    void methodXY(XY xy) {
+        System.out.println("methodXY(): SAM type interface XY object instantiated: " + xy);
+        System.out.println(xy.getTotal(strs));
+    }
+
+    //type #3:
+    void methodXYZ(XYZ xyz) {
+        System.out.println("methodXYZ(): SAM type interface XYZ object instantiated: " + xyz);
+        System.out.println(xyz.getTotal(strs));
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java
new file mode 100644
index 0000000..464cd4a
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM2.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #4, see Helper.java for SAM types
+ * @compile LambdaTest2_SAM2.java Helper.java
+ * @run main LambdaTest2_SAM2
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.concurrent.TimeoutException;
+import java.io.*;
+import java.sql.SQLException;
+import java.sql.SQLTransientException;
+
+public class LambdaTest2_SAM2 {
+    private static List<String> strs = new ArrayList<String>();
+
+    public static void main(String[] args) {
+        strs.add("copy");
+        strs.add("paste");
+        strs.add("delete");
+        strs.add("rename");
+
+        LambdaTest2_SAM2 test = new LambdaTest2_SAM2();
+
+        //type #4 a):
+        test.methodAB((List list) -> 100);
+
+        //type #4 b):
+        test.methodFGHI((String s) -> new Integer(22));
+        //type #4 b):
+        test.methodJK((String s) -> new ArrayList<Number>());
+        test.methodJK((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJL((String s) -> new ArrayList<Number>());
+        test.methodJL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKL((String s) -> new ArrayList<Number>());
+        test.methodJKL((String s) -> new ArrayList());
+        //type #4 b):
+        test.methodJKLM((String s) -> new ArrayList<Number>());
+        test.methodJKLM((String s) -> new ArrayList());
+
+        // tyep #4 c):
+        test.methodNO((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(FileNotFoundException fne){throw fne;}
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // tyep #4 c):
+        test.methodNOP((File f) -> {
+                String temp = null;
+                StringBuffer sb = new StringBuffer();
+                try
+                {
+                    BufferedReader br = new BufferedReader(new FileReader(f));
+                    while((temp=br.readLine()) != null)
+                        sb.append(temp).append("\n");
+                }
+                catch(IOException e){e.printStackTrace();}
+                return sb.toString();
+        });
+        // type #4 c):
+        test.methodBooDoo((String s) -> s.length());
+
+        //type #4 d):
+        test.methodQR((Iterable i) -> new ArrayList<String>());
+        test.methodQR((Iterable i) -> new ArrayList());
+        //type #4 d):
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUV((List<String> list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+        //type #4 d):
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList<String>();
+        });
+        test.methodUVW((List list) -> {
+                test.exceptionMethod1();
+                test.exceptionMethod2();
+                return new ArrayList();
+        });
+    }
+
+    private void exceptionMethod1() throws EOFException{
+    }
+
+    private void exceptionMethod2() throws SQLTransientException{
+    }
+
+    //type #4 a): SAM type ([List], int, {})
+    void methodAB (AB ab) {
+        System.out.println("methodAB(): SAM type interface AB object instantiated: " + ab);
+        System.out.println(ab.getOldest(strs));
+    }
+
+    //type #4 b): SAM type ([String], Integer, {})
+    void methodFGHI(FGHI f) {
+        System.out.println("methodFGHI(): SAM type interface FGHI object instantiated: " + f);
+        System.out.println(f.getValue("str"));
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJK(JK jk) {
+        System.out.println("methodJK(): SAM type interface JK object instantiated: " + jk);
+        for(Number n : jk.getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJL(JL jl) {
+        System.out.println("methodJL(): SAM type interface JL object instantiated: " + jl);
+        for(Number n : ((J)jl).getAll("in")) //cast should be redundant - see 7062745
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKL(JKL jkl) { //commented - see 7062745
+        System.out.println("methodJKL(): SAM type interface JKL object instantiated: " + jkl);
+        for(Number n : ((J)jkl).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 b): SAM type ([String], List<Number>, {})
+    void methodJKLM(JKLM jklm) { //commented - see 7062745
+        System.out.println("methodJKLM(): SAM type interface JKLM object instantiated: " + jklm);
+        for(Number n : ((J)jklm).getAll("in"))
+            System.out.println(n);
+    }
+
+    //type #4 c): SAM type ([File], String, {FileNotFoundException})
+    void methodNO(NO no) {
+        System.out.println("methodNO(): SAM type interface \"NO\" object instantiated: " + no);
+        try {
+            System.out.println("text=" + no.getText(new File("a.txt")));
+            System.out.println("got here, no exception thrown");
+        }
+        catch(FileNotFoundException e){e.printStackTrace();}
+    }
+
+    //type #4 c): SAM type ([File]), String, {})
+    void methodNOP(NOP nop) {
+        System.out.println("methodNOP(): SAM type interface \"NOP\" object instantiated: " + nop);
+        System.out.println("text=" + nop.getText(new File("a.txt")));
+    }
+
+    //type #4 c): SAM type ([String], int, {})
+    void methodBooDoo(BooDoo bd) {
+        System.out.println("methodBooDoo(): SAM type interface BooDoo object instantiated: " + bd);
+        System.out.println("result=" + bd.getAge("lambda"));
+    }
+
+    //type #4 d): SAM type ([Iterable], Iterable<String>, {})
+    void methodQR(QR qr) {
+        System.out.println("methodQR(): SAM type interface QR object instantiated: " + qr);
+        System.out.println("Iterable returned: " + qr.m(new SQLException()));
+    }
+
+    //type #4 d): SAM type ([List<String>], List<String>/List, {EOFException, SQLTransientException})
+    void methodUV(UV uv) {
+        System.out.println("methodUV(): SAM type interface UV object instantiated: " + uv);
+        try{
+            System.out.println("result returned: " + uv.foo(strs));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+
+    //type #4 d): SAM type ([List], List<String>/List, {EOFException, SQLTransientException})
+    void methodUVW(UVW uvw) {
+        System.out.println("methodUVW(): SAM type interface UVW object instantiated: " + uvw);
+        try{
+            System.out.println("passing List<String>: " + uvw.foo(strs));
+            System.out.println("passing List: " + uvw.foo(new ArrayList()));
+        }catch(EOFException e){
+            System.out.println(e.getMessage());
+        }catch(SQLTransientException ex){
+            System.out.println(ex.getMessage());
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java
new file mode 100644
index 0000000..f9b2a35
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_SAM3.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile LambdaTest2_SAM3.java Helper.java
+ * @run main LambdaTest2_SAM3
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+public class LambdaTest2_SAM3 {
+    private static List<String> strs = new ArrayList<String>();
+    private static List<Integer> integers = new ArrayList<Integer>();
+
+    public static void main(String[] args) {
+        LambdaTest2_SAM3 test = new LambdaTest2_SAM3();
+
+        //type #7, Not SAM-convertible, through inner class only:
+        test.methodFooBar(new FooBar() {
+                public int getAge(Number n) {
+                    System.out.println("getAge(Number n) called");
+                    return 100;
+                }
+                public int getAge(Integer i) {
+                    System.out.println("getAge(Integer i) called");
+                    return 200;
+                }
+            }
+        );
+
+        //type #7:
+        test.methodDE(new DE(){
+                public int getOldest(List<Integer > list) {
+                    System.out.println("getOldest(List<Integer> list) called");
+                    return 100;
+                }
+                public int getOldest(Collection<?> collection) {
+                    System.out.println("getOldest(Collection<?> collection) called");
+                    return 200;
+                }
+            }
+        );
+
+    }
+
+    //type #7: Not SAM type
+    void methodFooBar(FooBar fb) {
+        System.out.println("methodFooBar(): interface FooBar object instantiated: " + fb);
+        System.out.println("result=" + fb.getAge(new Byte("10")));
+        System.out.println("result=" + fb.getAge(new Integer(10)));
+    }
+
+    //type #7: Not SAM type
+    void methodDE (DE de) {
+        System.out.println("methodDE(): interface DE object instantiated: " + de);
+        System.out.println(de.getOldest(integers));
+        System.out.println(de.getOldest(strs));
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java
new file mode 100644
index 0000000..2375733
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying SAM types #5 and instantiating non-SAM types #7 through inner class,
+             see Helper.java for SAM types
+ * @compile/fail/ref=LambdaTest2_neg1.out -XDrawDiagnostics LambdaTest2_neg1.java Helper.java
+ */
+
+public class LambdaTest2_neg1 {
+
+    public static void main(String[] args) {
+        LambdaTest2_neg1 test = new LambdaTest2_neg1();
+        //not convertible - QooRoo is not a SAM
+        test.methodQooRoo((Integer i) -> { });
+    }
+
+    void methodQooRoo(QooRoo<Integer, Integer, Void> qooroo) { }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out
new file mode 100644
index 0000000..0a96b7d
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/LambdaTest2_neg1.out
@@ -0,0 +1,2 @@
+LambdaTest2_neg1.java:15:13: compiler.err.cant.apply.symbol: kindname.method, methodQooRoo, QooRoo<java.lang.Integer,java.lang.Integer,java.lang.Void>, @531, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: QooRoo, (compiler.misc.incompatible.abstracts: kindname.interface, QooRoo)))
+1 error
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM1.java b/test/tools/javac/lambda/funcInterfaces/NonSAM1.java
new file mode 100644
index 0000000..41fd742
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM1.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type 6: An interface that has a single abstract method, which is also public method in Object
+ * @compile/fail/ref=NonSAM1.out -XDrawDiagnostics NonSAM1.java Helper.java
+ */
+
+public class NonSAM1 {
+    void method() {
+        Planet n = (Object o) -> true;
+        System.out.println("never reach here " + n);
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM1.out b/test/tools/javac/lambda/funcInterfaces/NonSAM1.out
new file mode 100644
index 0000000..abfaf96
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM1.out
@@ -0,0 +1,2 @@
+NonSAM1.java:11:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: Planet, (compiler.misc.no.abstracts: kindname.interface, Planet))
+1 error
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM2.java b/test/tools/javac/lambda/funcInterfaces/NonSAM2.java
new file mode 100644
index 0000000..2dd6b31
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM2.java
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
+ * @compile/fail/ref=NonSAM2.out -XDrawDiagnostics NonSAM2.java Helper.java
+ */
+
+import java.util.List;
+
+interface Foo1 { int getAge(String s);}
+interface Bar1 { Integer getAge(String s);}
+interface Foo1Bar1 extends Foo1, Bar1 {} //types Bar1 and Foo1 are incompatible; both define getAge(String), but with unrelated return types
+
+interface AC extends A, C {} //name clash: getOldest(List<?>) in C and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+interface ABC extends A, B, C {} //ok - raw override
+interface AD extends A, D {} //name clash: getOldest(List<Integer>) in D and getOldest(List<Number>) in A have the same erasure, yet neither overrides the other
+
+interface Foo2<T> { void m(T arg);}
+interface Bar2<S> { void m(S arg);}
+interface Foo2Bar2<T1, T2> extends Foo2<T1>, Bar2<T2> {} //name clash: m(S) in Bar and m(T) in Foo have the same erasure, yet neither overrides the other
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM2.out b/test/tools/javac/lambda/funcInterfaces/NonSAM2.out
new file mode 100644
index 0000000..b44b64c
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM2.out
@@ -0,0 +1,5 @@
+NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String)
+NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<java.lang.Integer>), D, getOldest(java.util.List<java.lang.Number>), A
+NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2
+4 errors
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM3.java b/test/tools/javac/lambda/funcInterfaces/NonSAM3.java
new file mode 100644
index 0000000..bafbfb2
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM3.java
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This test is for identifying a non-SAM type: Having overloaded methods due to inheritance
+ * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java
+ */
+
+import java.util.Collection;
+import java.util.List;
+
+public class NonSAM3 {
+    void method() {
+        //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods"
+        FooBar fb = (Number n) -> 100;
+        FooBar fb2 = (Integer i) -> 100;
+        DE de = (List<Integer> list) -> 100;
+        DE de2 = (List<?> list) -> 100;
+        DE de3 = (List list) -> 100;
+        DE de4 = (Collection<Integer> collection) -> 100;
+        DE de5 = (Collection<?> collection) -> 100;
+        DE de6 = (Collection collection) -> 100;
+    }
+}
diff --git a/test/tools/javac/lambda/funcInterfaces/NonSAM3.out b/test/tools/javac/lambda/funcInterfaces/NonSAM3.out
new file mode 100644
index 0000000..9f52ba5
--- /dev/null
+++ b/test/tools/javac/lambda/funcInterfaces/NonSAM3.out
@@ -0,0 +1,9 @@
+NonSAM3.java:15:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: FooBar, (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:16:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: FooBar, (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:17:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:21:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:22:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: DE, (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+8 errors
diff --git a/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.java b/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.java
new file mode 100644
index 0000000..614ef3b
--- /dev/null
+++ b/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  check that classfiles with member ref CP entries are read correctly
+ * @compile/fail/ref=InaccessibleMref01.out -XDrawDiagnostics InaccessibleMref01.java
+ */
+class InaccessibleMref01 {
+    interface SAM {
+        void m();
+    }
+
+    void test(p1.C c) {
+        SAM s = c::m;
+    }
+}
diff --git a/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.out b/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.out
new file mode 100644
index 0000000..bc0f3b8
--- /dev/null
+++ b/test/tools/javac/lambda/inaccessibleMref01/InaccessibleMref01.out
@@ -0,0 +1,2 @@
+InaccessibleMref01.java:37:17: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.not.def.public.cant.access: m(), p1.C))
+1 error
diff --git a/test/tools/javac/lambda/inaccessibleMref01/p1/C.java b/test/tools/javac/lambda/inaccessibleMref01/p1/C.java
new file mode 100644
index 0000000..be4f563
--- /dev/null
+++ b/test/tools/javac/lambda/inaccessibleMref01/p1/C.java
@@ -0,0 +1,27 @@
+/*
+ * 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 p1;
+
+public class C {
+    void m() { }
+}
diff --git a/test/tools/javac/lambda/inaccessibleMref02/InaccessibleMref02.java b/test/tools/javac/lambda/inaccessibleMref02/InaccessibleMref02.java
new file mode 100644
index 0000000..4da9a1f
--- /dev/null
+++ b/test/tools/javac/lambda/inaccessibleMref02/InaccessibleMref02.java
@@ -0,0 +1,40 @@
+/*
+ * 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 8003280
+ * @summary Add lambda tests
+ *  check that classfiles with member ref CP entries are read correctly
+ */
+public class InaccessibleMref02 {
+    interface SAM {
+        void m();
+    }
+
+    public static void main(String[] args) {
+        p1.C c = new p1.C();
+        SAM s = c::m;
+        s.m();
+    }
+}
diff --git a/test/tools/javac/lambda/inaccessibleMref02/p1/C.java b/test/tools/javac/lambda/inaccessibleMref02/p1/C.java
new file mode 100644
index 0000000..b97ad24
--- /dev/null
+++ b/test/tools/javac/lambda/inaccessibleMref02/p1/C.java
@@ -0,0 +1,29 @@
+/*
+ * 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 p1;
+
+class Sup {
+    public void m() { }
+}
+
+public class C extends Sup { }
diff --git a/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
new file mode 100644
index 0000000..660721e
--- /dev/null
+++ b/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
@@ -0,0 +1,337 @@
+/*
+ * 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.
+ *
+ * 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 8002099
+ * @summary Add support for intersection types in cast expression
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.util.ListBuffer;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class IntersectionTargetTypeTest {
+
+    static int checkCount = 0;
+
+    enum BoundKind {
+        INTF,
+        CLASS;
+    }
+
+    enum MethodKind {
+        NONE(false),
+        ABSTRACT_M(true),
+        DEFAULT_M(false),
+        ABSTRACT_G(true),
+        DEFAULT_G(false);
+
+        boolean isAbstract;
+
+        MethodKind(boolean isAbstract) {
+            this.isAbstract = isAbstract;
+        }
+    }
+
+    enum TypeKind {
+        A("interface A { }\n", "A", BoundKind.INTF, MethodKind.NONE),
+        B("interface B { default void m() { } }\n", "B", BoundKind.INTF, MethodKind.DEFAULT_M),
+        C("interface C { void m(); }\n", "C", BoundKind.INTF, MethodKind.ABSTRACT_M),
+        D("interface D extends B { }\n", "D", BoundKind.INTF, MethodKind.DEFAULT_M),
+        E("interface E extends C { }\n", "E", BoundKind.INTF, MethodKind.ABSTRACT_M),
+        F("interface F extends C { void g(); }\n", "F", BoundKind.INTF, MethodKind.ABSTRACT_G, MethodKind.ABSTRACT_M),
+        G("interface G extends B { void g(); }\n", "G", BoundKind.INTF, MethodKind.ABSTRACT_G, MethodKind.DEFAULT_M),
+        H("interface H extends A { void g(); }\n", "H", BoundKind.INTF, MethodKind.ABSTRACT_G),
+        OBJECT("", "Object", BoundKind.CLASS),
+        STRING("", "String", BoundKind.CLASS);
+
+        String declStr;
+        String typeStr;
+        BoundKind boundKind;
+        MethodKind[] methodKinds;
+
+        private TypeKind(String declStr, String typeStr, BoundKind boundKind, MethodKind... methodKinds) {
+            this.declStr = declStr;
+            this.typeStr = typeStr;
+            this.boundKind = boundKind;
+            this.methodKinds = methodKinds;
+        }
+
+        boolean compatibleSupertype(TypeKind tk) {
+            if (tk == this) return true;
+            switch (tk) {
+                case B:
+                    return this != C && this != E && this != F;
+                case C:
+                    return this != B && this != C && this != D && this != G;
+                case D: return compatibleSupertype(B);
+                case E:
+                case F: return compatibleSupertype(C);
+                case G: return compatibleSupertype(B);
+                case H: return compatibleSupertype(A);
+                default:
+                    return true;
+            }
+        }
+    }
+
+    enum CastKind {
+        ONE_ARY("(#B0)", 1),
+        TWO_ARY("(#B0 & #B1)", 2),
+        THREE_ARY("(#B0 & #B1 & #B2)", 3);
+
+        String castTemplate;
+        int nbounds;
+
+        CastKind(String castTemplate, int nbounds) {
+            this.castTemplate = castTemplate;
+            this.nbounds = nbounds;
+        }
+    }
+
+    enum ExpressionKind {
+        LAMBDA("()->{}", true),
+        MREF("this::m", true),
+        //COND_LAMBDA("(true ? ()->{} : ()->{})", true), re-enable if spec allows this
+        //COND_MREF("(true ? this::m : this::m)", true),
+        STANDALONE("null", false);
+
+        String exprString;
+        boolean isFunctional;
+
+        private ExpressionKind(String exprString, boolean isFunctional) {
+            this.exprString = exprString;
+            this.isFunctional = isFunctional;
+        }
+    }
+
+    static class CastInfo {
+        CastKind kind;
+        TypeKind[] types;
+
+        CastInfo(CastKind kind, TypeKind... types) {
+            this.kind = kind;
+            this.types = types;
+        }
+
+        String getCast() {
+            String temp = kind.castTemplate;
+            for (int i = 0; i < kind.nbounds ; i++) {
+                temp = temp.replace(String.format("#B%d", i), types[i].typeStr);
+            }
+            return temp;
+        }
+
+        boolean wellFormed() {
+            //check for duplicate types
+            for (int i = 0 ; i < types.length ; i++) {
+                for (int j = 0 ; j < types.length ; j++) {
+                    if (i != j && types[i] == types[j]) {
+                        return false;
+                    }
+                }
+            }
+            //check that classes only appear as first bound
+            boolean classOk = true;
+            for (int i = 0 ; i < types.length ; i++) {
+                if (types[i].boundKind == BoundKind.CLASS &&
+                        !classOk) {
+                    return false;
+                }
+                classOk = false;
+            }
+            //check that supertypes are mutually compatible
+            for (int i = 0 ; i < types.length ; i++) {
+                for (int j = 0 ; j < types.length ; j++) {
+                    if (!types[i].compatibleSupertype(types[j]) && i != j) {
+                        return false;
+                    }
+                }
+            }
+            return true;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (CastInfo cInfo : allCastInfo()) {
+            for (ExpressionKind ek : ExpressionKind.values()) {
+                new IntersectionTargetTypeTest(cInfo, ek).run(comp, fm);
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    static List<CastInfo> allCastInfo() {
+        ListBuffer<CastInfo> buf = ListBuffer.lb();
+        for (CastKind kind : CastKind.values()) {
+            for (TypeKind b1 : TypeKind.values()) {
+                if (kind.nbounds == 1) {
+                    buf.append(new CastInfo(kind, b1));
+                    continue;
+                } else {
+                    for (TypeKind b2 : TypeKind.values()) {
+                        if (kind.nbounds == 2) {
+                            buf.append(new CastInfo(kind, b1, b2));
+                            continue;
+                        } else {
+                            for (TypeKind b3 : TypeKind.values()) {
+                                buf.append(new CastInfo(kind, b1, b2, b3));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return buf.toList();
+    }
+
+    CastInfo cInfo;
+    ExpressionKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    IntersectionTargetTypeTest(CastInfo cInfo, ExpressionKind ek) {
+        this.cInfo = cInfo;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "class Test {\n" +
+                              "   void m() { }\n" +
+                              "   void test() {\n" +
+                              "      Object o = #C#E;\n" +
+                              "   } }";
+
+        String source = "";
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            for (TypeKind tk : TypeKind.values()) {
+                source += tk.declStr;
+            }
+            source += bodyTemplate.replaceAll("#C", cInfo.getCast()).replaceAll("#E", ek.exprString);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        boolean errorExpected = !cInfo.wellFormed();
+
+        if (ek.isFunctional) {
+            List<MethodKind> mks = new ArrayList<>();
+            for (TypeKind tk : cInfo.types) {
+                if (tk.boundKind == BoundKind.CLASS) {
+                    errorExpected = true;
+                    break;
+                } else {
+                    mks = mergeMethods(mks, Arrays.asList(tk.methodKinds));
+                }
+            }
+            int abstractCount = 0;
+            for (MethodKind mk : mks) {
+                if (mk.isAbstract) {
+                    abstractCount++;
+                }
+            }
+            errorExpected |= abstractCount != 1;
+        }
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    List<MethodKind> mergeMethods(List<MethodKind> l1, List<MethodKind> l2) {
+        List<MethodKind> mergedMethods = new ArrayList<>(l1);
+        for (MethodKind mk2 : l2) {
+            boolean add = !mergedMethods.contains(mk2);
+            switch (mk2) {
+                case ABSTRACT_G:
+                    add = add && !mergedMethods.contains(MethodKind.DEFAULT_G);
+                    break;
+                case ABSTRACT_M:
+                    add = add && !mergedMethods.contains(MethodKind.DEFAULT_M);
+                    break;
+                case DEFAULT_G:
+                    mergedMethods.remove(MethodKind.ABSTRACT_G);
+                case DEFAULT_M:
+                    mergedMethods.remove(MethodKind.ABSTRACT_M);
+                case NONE:
+                    add = false;
+                    break;
+            }
+            if (add) {
+                mergedMethods.add(mk2);
+            }
+        }
+        return mergedMethods;
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/InInterface.java b/test/tools/javac/lambda/lambdaExecution/InInterface.java
new file mode 100644
index 0000000..ca7dc27
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/InInterface.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+/**
+ * @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
+ */
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+interface LTII {
+
+    interface ILsp1 {
+        String m();
+    }
+
+    interface ILsp2 {
+        String m(String x);
+    }
+
+    default ILsp1 t1() {
+        return () -> { return "yo"; };
+    }
+
+    default ILsp2 t2() {
+        return (x) -> { return "snur" + x; };
+    }
+
+}
+
+ at Test
+public class InInterface implements LTII {
+
+    public void testLambdaInDefaultMethod() {
+        assertEquals(t1().m(), "yo");
+        assertEquals(t2().m("p"), "snurp");
+    }
+
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java b/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java
new file mode 100644
index 0000000..21b747d
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/InnerConstructor.java
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng InnerConstructor
+ */
+
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.Test;
+
+ at Test
+public class InnerConstructor  {
+
+    public void testLambdaWithInnerConstructor() {
+        assertEquals(seq1().m().toString(), "Cbl:nada");
+        assertEquals(seq2().m("rats").toString(), "Cbl:rats");
+    }
+
+    Ib1 seq1() {
+        return () -> { return new Cbl(); };
+    }
+
+    Ib2 seq2() {
+        return (x) -> { return new Cbl(x); };
+    }
+
+    class Cbl {
+        String val;
+
+        Cbl() {
+            this.val = "nada";
+        }
+
+        Cbl(String z) {
+            this.val = z;
+        }
+
+        public String toString() {
+            return "Cbl:" + val;
+        }
+    }
+
+    interface Ib1 {
+        Object m();
+    }
+
+    interface Ib2 {
+        Object m(String x);
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java b/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java
new file mode 100644
index 0000000..083d2ce
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest1.java
@@ -0,0 +1,234 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng LambdaTranslationTest1
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+ at Test
+public class LambdaTranslationTest1 extends LT1Sub {
+
+    String cntxt = "blah";
+
+    private static final ThreadLocal<Object> result = new ThreadLocal<>();
+
+    private static void setResult(Object s) { result.set(s); }
+    private static void appendResult(Object s) { result.set(result.get().toString() + s); }
+
+    private static void assertResult(String expected) {
+        assertEquals(result.get().toString(), expected);
+    }
+
+    static Integer count(String s) {
+        return s.length();
+    }
+
+    static int icount(String s) {
+        return s.length();
+    }
+
+    static void eye(Integer i) {
+        setResult(String.format("I:%d", i));
+    }
+
+    static void ieye(int i) {
+        setResult(String.format("i:%d", i));
+    }
+
+    static void deye(double d) {
+        setResult(String.format("d:%f", d));
+    }
+
+    public void testLambdas() {
+        TBlock<Object> b = t -> {setResult("Sink0::" + t);};
+        b.apply("Howdy");
+        assertResult("Sink0::Howdy");
+
+        TBlock<String> b1 = t -> {setResult("Sink1::" + t);};
+        b1.apply("Rowdy");
+        assertResult("Sink1::Rowdy");
+
+        for (int i = 5; i < 10; ++i) {
+            TBlock<Integer> b2 = t -> {setResult("Sink2::" + t);};
+            b2.apply(i);
+            assertResult("Sink2::" + i);
+        }
+
+        TBlock<Integer> b3 = t -> {setResult("Sink3::" + t);};
+        for (int i = 900; i > 0; i -= 100) {
+            b3.apply(i);
+            assertResult("Sink3::" + i);
+        }
+
+        cntxt = "blah";
+        TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
+        b4.apply("Yor");
+        assertResult("b4: blah .. Yor");
+
+        String flaw = "flaw";
+        TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
+        b5.apply("BB");
+        assertResult("b5: flaw .. BB");
+
+        cntxt = "flew";
+        TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
+        b6.apply("flee");
+        assertResult("b6: flee .. flew .. flaw");
+
+        TBlock<String> b7 = t -> {setResult(String.format("b7: %s %s", t, this.protectedSuperclassMethod()));};
+        b7.apply("this:");
+        assertResult("b7: this: instance:flew");
+
+        TBlock<String> b8 = t -> {setResult(String.format("b8: %s %s", t, super.protectedSuperclassMethod()));};
+        b8.apply("super:");
+        assertResult("b8: super: I'm the sub");
+
+        TBlock<String> b7b = t -> {setResult(String.format("b9: %s %s", t, protectedSuperclassMethod()));};
+        b7b.apply("implicit this:");
+        assertResult("b9: implicit this: instance:flew");
+
+        TBlock<Object> b10 = t -> {setResult(String.format("b10: new LT1Thing: %s", (new LT1Thing(t)).str));};
+        b10.apply("thing");
+        assertResult("b10: new LT1Thing: thing");
+
+        TBlock<Object> b11 = t -> {setResult(String.format("b11: %s", (new LT1Thing(t) {
+            String get() {
+                return "*" + str.toString() + "*";
+            }
+        }).get()));};
+        b11.apply(999);
+        assertResult("b11: *999*");
+    }
+
+    public void testMethodRefs() {
+        LT1IA ia = LambdaTranslationTest1::eye;
+        ia.doit(1234);
+        assertResult("I:1234");
+
+        LT1IIA iia = LambdaTranslationTest1::ieye;
+        iia.doit(1234);
+        assertResult("i:1234");
+
+        LT1IA da = LambdaTranslationTest1::deye;
+        da.doit(1234);
+        assertResult("d:1234.000000");
+
+        LT1SA a = LambdaTranslationTest1::count;
+        assertEquals((Integer) 5, a.doit("howdy"));
+
+        a = LambdaTranslationTest1::icount;
+        assertEquals((Integer) 6, a.doit("shower"));
+    }
+
+    public void testInner() throws Exception {
+        (new In()).doInner();
+    }
+
+    protected String protectedSuperclassMethod() {
+        return "instance:" + cntxt;
+    }
+
+    private class In {
+
+        private int that = 1234;
+
+        void doInner() {
+            TBlock<String> i4 = t -> {setResult(String.format("i4: %d .. %s", that, t));};
+            i4.apply("=1234");
+            assertResult("i4: 1234 .. =1234");
+
+            TBlock<String> i5 = t -> {setResult(""); appendResult(t); appendResult(t);};
+            i5.apply("fruit");
+            assertResult("fruitfruit");
+
+            cntxt = "human";
+            TBlock<String> b4 = t -> {setResult(String.format("b4: %s .. %s", cntxt, t));};
+            b4.apply("bin");
+            assertResult("b4: human .. bin");
+
+            final String flaw = "flaw";
+
+/**
+ Callable<String> c5 = () ->  "["+flaw+"]" ;
+ System.out.printf("c5: %s\n", c5.call() );
+ **/
+
+            TBlock<String> b5 = t -> {setResult(String.format("b5: %s .. %s", flaw, t));};
+            b5.apply("BB");
+            assertResult("b5: flaw .. BB");
+
+            cntxt = "borg";
+            TBlock<String> b6 = t -> {setResult(String.format("b6: %s .. %s .. %s", t, cntxt, flaw));};
+            b6.apply("flee");
+            assertResult("b6: flee .. borg .. flaw");
+
+            TBlock<String> b7b = t -> {setResult(String.format("b7b: %s %s", t, protectedSuperclassMethod()));};
+            b7b.apply("implicit outer this");
+            assertResult("b7b: implicit outer this instance:borg");
+
+            /**
+             TBlock<Object> b9 = t -> { System.out.printf("New: %s\n", (new LT1Thing(t)).str); };
+             b9.apply("thing");
+
+             TBlock<Object> ba = t -> { System.out.printf("Def: %s\n", (new LT1Thing(t) { String get() { return "*" + str.toString() +"*";}}).get() ); };
+             ba.apply(999);
+
+             */
+        }
+    }
+}
+
+class LT1Sub {
+    protected String protectedSuperclassMethod() {
+        return "I'm the sub";
+    }
+}
+
+class LT1Thing {
+    final Object str;
+
+    LT1Thing(Object s) {
+        str = s;
+    }
+}
+
+interface LT1SA {
+    Integer doit(String s);
+}
+
+interface LT1IA {
+    void doit(int i);
+}
+
+interface LT1IIA {
+    void doit(Integer i);
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java b/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java
new file mode 100644
index 0000000..574bca3
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/LambdaTranslationTest2.java
@@ -0,0 +1,355 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng LambdaTranslationTest2
+ */
+
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambdaTranslationTest2 -- end-to-end smoke tests for lambda evaluation
+ */
+
+ at Test
+public class LambdaTranslationTest2 {
+
+    final String dummy = "dummy";
+
+    public void testLambdas() {
+        TPredicate<String> isEmpty = s -> s.isEmpty();
+        assertTrue(isEmpty.test(""));
+        assertTrue(!isEmpty.test("foo"));
+
+        TPredicate<Object> oIsEmpty = s -> ((String) s).isEmpty();
+        assertTrue(oIsEmpty.test(""));
+        assertTrue(!oIsEmpty.test("foo"));
+
+        TPredicate<Object> alwaysTrue = o -> true;
+        assertTrue(alwaysTrue.test(""));
+        assertTrue(alwaysTrue.test(null));
+
+        TPredicate<Object> alwaysFalse = o -> false;
+        assertTrue(!alwaysFalse.test(""));
+        assertTrue(!alwaysFalse.test(null));
+
+        // tests local capture
+        String foo = "foo";
+        TPredicate<String> equalsFoo = s -> s.equals(foo);
+        assertTrue(!equalsFoo.test(""));
+        assertTrue(equalsFoo.test("foo"));
+
+        // tests instance capture
+        TPredicate<String> equalsDummy = s -> s.equals(dummy);
+        assertTrue(!equalsDummy.test(""));
+        assertTrue(equalsDummy.test("dummy"));
+
+        TMapper<Object, Object> ident = s -> s;
+
+        assertEquals("blarf", ident.map("blarf"));
+        assertEquals("wooga", ident.map("wooga"));
+        assertTrue("wooga" == ident.map("wooga"));
+
+        // constant capture
+        TMapper<Object, Object> prefixer = s -> "p" + s;
+        assertEquals("pblarf", prefixer.map("blarf"));
+        assertEquals("pwooga", prefixer.map("wooga"));
+
+        // instance capture
+        TMapper<Object, Object> prefixer2 = s -> dummy + s;
+        assertEquals("dummyblarf", prefixer2.map("blarf"));
+        assertEquals("dummywooga", prefixer2.map("wooga"));
+    }
+
+    interface Factory<T> {
+        T make();
+    }
+
+    interface StringFactory extends Factory<String> { }
+
+    interface StringFactory2 extends Factory<String> {
+        String make();
+    }
+
+    public void testBridges() {
+        Factory<String> of = () -> "y";
+        Factory<?> ef = () -> "z";
+
+        assertEquals("y", of.make());
+        assertEquals("y", ((Factory<?>) of).make());
+        assertEquals("y", ((Factory) of).make());
+
+        assertEquals("z", ef.make());
+        assertEquals("z", ((Factory) ef).make());
+    }
+
+    public void testBridgesImplicitSpecialization() {
+        StringFactory sf = () -> "x";
+
+        assertEquals("x", sf.make());
+        assertEquals("x", ((Factory<String>) sf).make());
+        assertEquals("x", ((Factory<?>) sf).make());
+        assertEquals("x", ((Factory) sf).make());
+    }
+
+    public void testBridgesExplicitSpecialization() {
+        StringFactory2 sf = () -> "x";
+
+        assertEquals("x", sf.make());
+        assertEquals("x", ((Factory<String>) sf).make());
+        assertEquals("x", ((Factory<?>) sf).make());
+        assertEquals("x", ((Factory) sf).make());
+    }
+
+    public void testSuperCapture() {
+        class A {
+            String make() { return "x"; }
+        }
+
+        class B extends A {
+            void testSuperCapture() {
+                StringFactory sf = () -> super.make();
+                assertEquals("x", sf.make());
+            }
+        }
+
+        new B().testSuperCapture();
+    }
+
+    interface WidenD {
+        public String m(float a0, double a1);
+    }
+
+    interface WidenS {
+        public String m(byte a0, short a1);
+    }
+
+    interface WidenI {
+        public String m(byte a0, short a1, char a2, int a3);
+    }
+
+    interface WidenL {
+        public String m(byte a0, short a1, char a2, int a3, long a4);
+    }
+
+    interface Box {
+        public String m(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7);
+    }
+
+    static String pb(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7) {
+        return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
+    }
+
+    static String pwI1(int a0, int a1, int a2, int a3) {
+        return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
+    }
+
+    static String pwI2(Integer a0, Integer a1, Integer a2, Integer a3) {
+        return String.format("b%d s%d c%d i%d", a0, a1, a2, a3);
+    }
+
+    static String pwL1(long a0, long a1, long a2, long a3, long a4) {
+        return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
+    }
+
+    static String pwL2(Long a0, Long a1, Long a2, Long a3, Long a4) {
+        return String.format("b%d s%d c%d i%d j%d", a0, a1, a2, a3, a4);
+    }
+
+    static String pwS1(short a0, short a1) {
+        return String.format("b%d s%d", a0, a1);
+    }
+
+    static String pwS2(Short a0, Short a1) {
+        return String.format("b%d s%d", a0, a1);
+    }
+
+    static String pwD1(double a0, double a1) {
+        return String.format("f%f d%f", a0, a1);
+    }
+
+    static String pwD2(Double a0, Double a1) {
+        return String.format("f%f d%f", a0, a1);
+    }
+
+    public void testPrimitiveWidening() {
+        WidenS ws1 = LambdaTranslationTest2::pwS1;
+        assertEquals("b1 s2", ws1.m((byte) 1, (short) 2));
+
+        WidenD wd1 = LambdaTranslationTest2::pwD1;
+        assertEquals("f1.000000 d2.000000", wd1.m(1.0f, 2.0));
+
+        WidenI wi1 = LambdaTranslationTest2::pwI1;
+        assertEquals("b1 s2 c3 i4", wi1.m((byte) 1, (short) 2, (char) 3, 4));
+
+        WidenL wl1 = LambdaTranslationTest2::pwL1;
+        assertEquals("b1 s2 c3 i4 j5", wl1.m((byte) 1, (short) 2, (char) 3, 4, 5L));
+
+        // @@@ TODO: clarify spec on widen+box conversion
+    }
+
+    interface Unbox {
+        public String m(Byte a0, Short a1, Character a2, Integer a3, Long a4, Boolean a5, Float a6, Double a7);
+    }
+
+    static String pu(byte a0, short a1, char a2, int a3, long a4, boolean a5, float a6, double a7) {
+        return String.format("b%d s%d c%c i%d j%d z%b f%f d%f", a0, a1, a2, a3, a4, a5, a6, a7);
+    }
+
+    public void testUnboxing() {
+        Unbox u = LambdaTranslationTest2::pu;
+        assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
+    }
+
+    public void testBoxing() {
+        Box b = LambdaTranslationTest2::pb;
+        assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0));
+    }
+
+    static boolean cc(Object o) {
+        return ((String) o).equals("foo");
+    }
+
+    public void testArgCastingAdaptation() {
+        TPredicate<String> p = LambdaTranslationTest2::cc;
+        assertTrue(p.test("foo"));
+        assertTrue(!p.test("bar"));
+    }
+
+    interface SonOfPredicate<T> extends TPredicate<T> { }
+
+    public void testExtendsSAM() {
+        SonOfPredicate<String> p = s -> s.isEmpty();
+        assertTrue(p.test(""));
+        assertTrue(!p.test("foo"));
+    }
+
+    public void testConstructorRef() {
+        Factory<List<String>> lf = ArrayList<String>::new;
+        List<String> list = lf.make();
+        assertTrue(list instanceof ArrayList);
+        assertTrue(list != lf.make());
+        list.add("a");
+        assertEquals("[a]", list.toString());
+    }
+
+    private static String privateMethod() {
+        return "private";
+    }
+
+    public void testPrivateMethodRef() {
+        Factory<String> sf = LambdaTranslationTest2::privateMethod;
+        assertEquals("private", sf.make());
+    }
+
+    private interface PrivateIntf {
+        String make();
+    }
+
+    public void testPrivateIntf() {
+        PrivateIntf p = () -> "foo";
+        assertEquals("foo", p.make());
+    }
+
+    interface Op<T> {
+        public T op(T a, T b);
+    }
+
+    public void testBoxToObject() {
+        Op<Integer> maxer = Math::max;
+        for (int i=-100000; i < 100000; i += 100)
+            for (int j=-100000; j < 100000; j += 99) {
+                assertEquals((int) maxer.op(i,j), Math.max(i,j));
+            }
+    }
+
+    protected static String protectedMethod() {
+        return "protected";
+    }
+
+    public void testProtectedMethodRef() {
+        Factory<String> sf = LambdaTranslationTest2::protectedMethod;
+        assertEquals("protected", sf.make());
+    }
+
+    class Inner1 {
+        String m1() {
+            return "Inner1.m1()";
+        }
+
+        class Inner2 {
+            public String m1() {
+                return "Inner1.Inner2.m1()";
+            }
+
+            protected String m2() {
+                return "Inner1.Inner2.m2()";
+            }
+
+            String m3() {
+                return "Inner1.Inner2.m3()";
+            }
+
+            class Inner3<T> {
+                T t = null;
+                Inner3(T t) {
+                    this.t = t;
+                }
+                T m1() {
+                    return t;
+                }
+            }
+        }
+    }
+
+    public void testInnerClassMethodRef() {
+        Factory<String> fs = new Inner1()::m1;
+        assertEquals("Inner1.m1()", fs.make());
+
+        fs = new Inner1().new Inner2()::m1;
+        assertEquals("Inner1.Inner2.m1()", fs.make());
+
+        fs = new Inner1().new Inner2()::m2;
+        assertEquals("Inner1.Inner2.m2()", fs.make());
+
+        fs = new Inner1().new Inner2()::m3;
+        assertEquals("Inner1.Inner2.m3()", fs.make());
+
+        fs = new Inner1().new Inner2().new Inner3<String>("Inner1.Inner2.Inner3")::m1;
+        assertEquals("Inner1.Inner2.Inner3", fs.make());
+
+        Factory<Integer> fsi = new Inner1().new Inner2().new Inner3<Integer>(100)::m1;
+        assertEquals(100, (int)fsi.make());
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/TBlock.java b/test/tools/javac/lambda/lambdaExecution/TBlock.java
new file mode 100644
index 0000000..329eaf2
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/TBlock.java
@@ -0,0 +1,36 @@
+/**
+ * Performs operations upon an input object which may modify that object and/or
+ * external state (other objects).
+ *
+ * <p>All block implementations are expected to:
+ * <ul>
+ * <li>When used for aggregate operations upon many elements blocks
+ * should not assume that the {@code apply} operation will be called upon
+ * elements in any specific order.</li>
+ * </ul>
+ *
+ * @param <T> The type of input objects to {@code apply}.
+ */
+public interface TBlock<T> {
+
+    /**
+     * Performs operations upon the provided object which may modify that object
+     * and/or external state.
+     *
+     * @param t an input object
+     */
+    void apply(T t);
+
+    /**
+     * Returns a Block which performs in sequence the {@code apply} methods of
+     * multiple Blocks. This Block's {@code apply} method is performed followed
+     * by the {@code apply} method of the specified Block operation.
+     *
+     * @param other an additional Block which will be chained after this Block
+     * @return a Block which performs in sequence the {@code apply} method of
+     * this Block and the {@code apply} method of the specified Block operation
+     */
+    public default TBlock<T> chain(TBlock<? super T> other) {
+        return (T t) -> { apply(t); other.apply(t); };
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/TMapper.java b/test/tools/javac/lambda/lambdaExecution/TMapper.java
new file mode 100644
index 0000000..6a7096b
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/TMapper.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2010, 2011, 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.
+ */
+
+/**
+ * Given an input object maps to an appropriate output object. A mapper may
+ * variously provide a mapping between types, object instances or keys and
+ * values or any other form of transformation upon the input.
+ *
+ * <p/>All mapper implementations are expected to:
+ * <ul>
+ *  <li>Provide stable results such that for any {@code t} the result of two
+ * {@code map} operations are always equivalent. ie.<pre>
+ * Foo one = mapper.map(a);
+ * Foo two = mapper.map(a);
+ *
+ * assert one.equals(two) && two.equals(one);
+ * </pre></li>
+ * <li>Equivalent input objects should map to equivalent output objects. ie.<pre>
+ * assert a.equals(b);  // a and b are equivalent
+ *
+ * Foo x = mapper.map(a);
+ * Foo y = mapper.map(b);
+ *
+ * assert x.equals(y); // their mapped results should be as equivalent.
+ * </pre></li>
+ * <li>The mapper should not modify the input object in any way that would
+ * change the mapping.</li>
+ * <li>When used for aggregate operations upon many elements mappers
+ * should not assume that the {@code map} operation will be called upon elements
+ * in any specific order.</li>
+ * </ul>
+ *
+ * @param <R> the type of output objects from {@code map} operation. May be the
+ * @param <T> the type of input objects provided to the {@code map} operation.
+ * same type as {@code <T>}.
+ */
+public interface TMapper<R, T> {
+
+    /**
+     * Map the provided input object to an appropriate output object.
+     *
+     * @param t the input object to be mapped.
+     * @return the mapped output object.
+     */
+    R map(T t);
+}
diff --git a/test/tools/javac/lambda/lambdaExecution/TPredicate.java b/test/tools/javac/lambda/lambdaExecution/TPredicate.java
new file mode 100644
index 0000000..2e98df2
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExecution/TPredicate.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2010, 2011, 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.
+ */
+
+/**
+ * Determines if the input object matches some criteria.
+ *
+ * <p>All predicate implementations are expected to:
+ * <ul>
+ *  <li>Provide stable results such that for any {@code t} the result of two
+ * {@code eval} operations are always equivalent. ie.<pre>
+ * boolean one = predicate.test(a);
+ * boolean two = predicate.test(a);
+ *
+ * assert one == two;
+ * </pre></li>
+ * <li>Equivalent input objects should map to equivalent output objects. ie.<pre>
+ * assert a.equals(b);  // a and b are equivalent
+ *
+ * boolean x = predicate.test(a);
+ * boolean y = predicate.test(ab;
+ *
+ * assert x == y; // their test results should be the same.
+ * </pre></li>
+ * <li>The predicate should not modify the input object in any way that would
+ * change the evaluation.</li>
+ * <li>When used for aggregate operations upon many elements predicates
+ * should not assume that the {@code test} operation will be called upon
+ * elements in any specific order.</li>
+ * </ul>
+ *
+ * @param <T> the type of input objects provided to {@code test}.
+ */
+public interface TPredicate<T> {
+
+    /**
+     * Return {@code true} if the input object matches some criteria.
+     *
+     * @param t the input object.
+     * @return {@code true} if the input object matched some criteria.
+     */
+     boolean test(T t);
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java b/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java
new file mode 100644
index 0000000..ac8db55
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test that lambda conversion is only for SAM interface, not abstract class
+ * @compile/fail/ref=AbstractClass_neg.out -XDrawDiagnostics AbstractClass_neg.java
+ */
+
+public class AbstractClass_neg {
+
+    abstract class SAM {
+        abstract int m();
+    }
+
+    void test() {
+        SAM s = ()-> 6;
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out b/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out
new file mode 100644
index 0000000..cfe6838
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/AbstractClass_neg.out
@@ -0,0 +1,2 @@
+AbstractClass_neg.java:16:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: AbstractClass_neg.SAM)
+1 error
diff --git a/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java b/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java
new file mode 100644
index 0000000..af4e5c9
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test accessing non-static variable from lambda expressions in static context
+ * @compile/fail/ref=AccessNonStatic_neg.out -XDrawDiagnostics AccessNonStatic_neg.java
+ */
+
+public class AccessNonStatic_neg {
+
+    private int n = 0;
+
+    static {
+        ((Runnable) ()-> {
+            System.out.println(this);
+            System.out.println(n);
+        }).run();
+    }
+
+    public static void test() {
+        ((Runnable) ()-> {
+            Object o = this;
+            n++;
+        }).run();
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out b/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out
new file mode 100644
index 0000000..78b649a
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/AccessNonStatic_neg.out
@@ -0,0 +1,5 @@
+AccessNonStatic_neg.java:15:32: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:16:32: compiler.err.non-static.cant.be.ref: kindname.variable, n
+AccessNonStatic_neg.java:22:24: compiler.err.non-static.cant.be.ref: kindname.variable, this
+AccessNonStatic_neg.java:23:13: compiler.err.non-static.cant.be.ref: kindname.variable, n
+4 errors
diff --git a/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java b/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java
new file mode 100644
index 0000000..d5f2b52
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.java
@@ -0,0 +1,25 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Negative test of capture of "effectively final" local variable in lambda expressions
+ * @compile/fail/ref=EffectivelyFinal_neg.out -XDrawDiagnostics EffectivelyFinal_neg.java
+ */
+
+public class EffectivelyFinal_neg {
+
+    void test() {
+        String s = "a";
+        String s2 = "a";
+        int n = 1;
+        ((Runnable)
+            ()-> {
+                s2 = "b"; //re-assign illegal here
+                System.out.println(n);
+                System.out.println(s);
+                s = "b"; // not effectively final
+            }
+        ).run();
+        n = 2; // not effectively final
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out b/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out
new file mode 100644
index 0000000..00abf40
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/EffectivelyFinal_neg.out
@@ -0,0 +1,5 @@
+EffectivelyFinal_neg.java:17:17: compiler.err.cant.ref.non.effectively.final.var: s2, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:18:36: compiler.err.cant.ref.non.effectively.final.var: n, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:19:36: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+EffectivelyFinal_neg.java:20:17: compiler.err.cant.ref.non.effectively.final.var: s, (compiler.misc.lambda)
+4 errors
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java b/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java
new file mode 100644
index 0000000..095350f
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression1.out -XDrawDiagnostics InvalidExpression1.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression1 {
+
+    void test() {
+        Comparator<Number> c = (Number n1, Number n2)-> { 42; }; //not a statement
+        Comparator<Number> c = (Number n1, Number n2)-> { return 42 }; //";" expected
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out b/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out
new file mode 100644
index 0000000..276f0f9
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression1.out
@@ -0,0 +1,3 @@
+InvalidExpression1.java:14:59: compiler.err.not.stmt
+InvalidExpression1.java:15:68: compiler.err.expected: ';'
+2 errors
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java b/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java
new file mode 100644
index 0000000..37cfa3b
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.java
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression3.out -XDrawDiagnostics InvalidExpression3.java
+ */
+
+import java.util.Comparator;
+
+public class InvalidExpression3 {
+
+    void test() {
+        Comparator<Integer> c2 = (Integer i1, Integer i2) -> { return "0"; }; //return type need to match
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out b/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out
new file mode 100644
index 0000000..8c4f9e8
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression3.out
@@ -0,0 +1,2 @@
+InvalidExpression3.java:14:71: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int))
+1 error
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java b/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java
new file mode 100644
index 0000000..7a6e59b
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.java
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression4.out -XDrawDiagnostics InvalidExpression4.java
+ */
+
+public class InvalidExpression4 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (Integer i) -> { }; //parameters not match, boxing not allowed here
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out b/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out
new file mode 100644
index 0000000..0383172
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression4.out
@@ -0,0 +1,2 @@
+InvalidExpression4.java:16:17: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
+1 error
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java b/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java
new file mode 100644
index 0000000..145734c
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.java
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression5.out -XDrawDiagnostics InvalidExpression5.java
+ */
+
+public class InvalidExpression5 {
+
+    void test() {
+        Object o = (int n) -> { }; // Invalid target type
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out b/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out
new file mode 100644
index 0000000..f9c70cd
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression5.out
@@ -0,0 +1,2 @@
+InvalidExpression5.java:12:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf: java.lang.Object)
+1 error
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java b/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java
new file mode 100644
index 0000000..8a64185
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.java
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Test invalid lambda expressions
+ * @compile/fail/ref=InvalidExpression6.out -XDrawDiagnostics InvalidExpression6.java
+ */
+
+public class InvalidExpression6 {
+
+    interface SAM {
+        void m(int i);
+    }
+
+    void test() {
+        SAM s = (int n) -> { break; }; //break not allowed
+        s = (int n) -> { continue; }; //continue not allowed
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out b/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out
new file mode 100644
index 0000000..aea9cfb
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/InvalidExpression6.out
@@ -0,0 +1,3 @@
+InvalidExpression6.java:16:30: compiler.err.break.outside.switch.loop
+InvalidExpression6.java:17:26: compiler.err.cont.outside.loop
+2 errors
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java
new file mode 100644
index 0000000..699ad5d
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for existing SAM interfaces like Runnable and Comparator<T>
+ * @compile LambdaTest1.java
+ * @run main LambdaTest1
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Date;
+
+public class LambdaTest1 {
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Runnable r) {
+        r.run();
+    }
+
+    void test2(Object o) {
+        if(o instanceof Runnable)
+            ((Runnable)o).run();
+    }
+
+    Runnable test3() {
+        return ()-> { assertionStr += "Runnable6"; };
+    }
+
+    public static void main(String[] args) {
+
+        //lambda expressions for SAM interface Runnable:
+        //assign:
+        Runnable r = ()-> { assertionStr += "Runnable1 "; };
+        r.run();
+
+        //cast:
+        ((Runnable)()-> { assertionStr += "Runnable2 "; }).run();
+
+        Object o = (Runnable)()-> {};
+
+        o = (Runnable)()-> {
+                switch (assertionStr) {
+                    case "Runnable1 Runnable2 ":
+                        assertionStr += "Runnable3 ";
+                        break;
+                    default:
+                        throw new AssertionError();
+                }
+                return;
+            };
+
+        //method parameter:
+        test1(()-> { assertionStr += "Runnable4 "; return; });
+
+        LambdaTest1 test = new LambdaTest1();
+        test.test2((Runnable)()-> { assertionStr += "Runnable5 "; });
+
+        //return type:
+        r = test.test3();
+        r.run();
+
+        assertTrue(assertionStr.equals("Runnable1 Runnable2 Runnable4 Runnable5 Runnable6"));
+
+        //lambda expressions for SAM interface Comparator<T>:
+        List<Integer> list = new ArrayList<Integer>();
+        list.add(4);
+        list.add(10);
+        list.add(-5);
+        list.add(100);
+        list.add(9);
+        Collections.sort(list, (Integer i1, Integer i2)-> i2 - i1);
+        String result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("100 10 9 4 -5 "));
+
+        Collections.sort(list,
+            (i1, i2) -> {
+                String s1 = i1.toString();
+                String s2 = i2.toString();
+                return s1.length() - s2.length();
+             });
+        result = "";
+        for(int i : list)
+            result += i + " ";
+        assertTrue(result.equals("9 4 10 -5 100 "));
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java
new file mode 100644
index 0000000..4c0c7af
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest2.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions for different method signatures (parameter and return type)
+ * @compile LambdaTest2.java
+ * @run main LambdaTest2
+ */
+
+public class LambdaTest2 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest2 test = new LambdaTest2();
+
+        test.method2((int n) -> { ; });
+        test.method2(n -> { }); // "int" is optional here
+        test.method2((int n) -> { }); // ";" is optional here
+        test.method2((int n) -> { return; }); // ";" is mandatory here
+        test.method2((int n) -> { count += n; });
+        assertTrue(count == 10);
+
+        VoidInt vi = (int i) -> {
+                            switch (i) {
+                                case 0:
+                                    System.out.println("normal");
+                                    break;
+                                default:
+                                    System.out.println("invalid");
+                            }
+                       };
+
+        test.method3(()-> { count++; });
+        test.method3(() -> {});
+        assertTrue(count == 11);
+
+        VoidVoid vv = ()-> { while(true)
+                            if(false)
+                                break;
+                            else
+                                continue;
+                       };
+
+        IntVoid iv1 = () -> 42;
+        IntVoid iv2 = () -> { return 43; };//";" is mandatory here
+        assertTrue(iv1.ivMethod() == 42);
+        assertTrue(iv2.ivMethod() == 43);
+
+        IntInt ii1 = (int n) -> n+1;
+        IntInt ii2 = n -> 42;
+        IntInt ii3 = n -> { return 43; };
+        IntInt ii4 =
+            (int n) -> {
+                if(n > 0)
+                    return n+1;
+                else
+                    return n-1;
+            };
+        assertTrue(ii1.iiMethod(1) == 2);
+        assertTrue(ii2.iiMethod(1) == 42);
+        assertTrue(ii3.iiMethod(1) == 43);
+        assertTrue(ii4.iiMethod(-1) == -2);
+    }
+
+    void method2(VoidInt a) {
+        a.viMethod(10);
+    }
+
+    void method3(VoidVoid a) {
+        a.vvMethod();
+    }
+
+    //SAM type interfaces
+    interface VoidInt {
+        void viMethod(int n);
+    }
+
+    interface VoidVoid {
+        void vvMethod();
+    }
+
+    interface IntVoid {
+        int ivMethod();
+    }
+
+    interface IntInt {
+        int iiMethod(int n);
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java
new file mode 100644
index 0000000..9275ae8
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest3.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test capture of "effectively final" local variable in lambda expressions
+ * @compile LambdaTest3.java
+ * @run main LambdaTest3
+ */
+
+public class LambdaTest3 {
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        final int N = 100;
+        int n = 2; //effectively final variable
+
+        Runnable r = ((Runnable)
+            () -> {
+                count += N;
+                count += n;
+            }
+        );
+        assertTrue(count == 0);
+        r.run();
+        assertTrue(count == 102);
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java
new file mode 100644
index 0000000..14af25e
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest4.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test accessing "this" in lambda expressions
+ * @compile LambdaTest4.java
+ * @run main LambdaTest4
+ */
+
+public class LambdaTest4 {
+
+    private String thisStr;
+    private static int count = 0;
+
+    {
+        ((Runnable)
+            ()-> {
+                this.init();
+                assertTrue(this.toString().equals(thisStr));
+                count++;
+            }
+        ).run();
+    }
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private void init() {
+        thisStr = this.toString();
+    }
+
+    private void m() {
+        String s1 = this.toString();
+        ((Runnable)
+            ()-> {
+                assertTrue(this.toString().equals(thisStr));
+                assertTrue(this.toString().equals(s1));
+            }
+        ).run();
+    }
+
+    public static void main(String[] args) {
+        LambdaTest4 test = new LambdaTest4();
+        assertTrue(count == 1);
+        test.m();
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java
new file mode 100644
index 0000000..0db7b51
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest5.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test lambda expressions inside lambda expressions
+ * @compile LambdaTest5.java
+ * @run main LambdaTest5
+ */
+
+public class LambdaTest5 {
+
+    interface A {
+        int m();
+    }
+
+    interface B {
+        int make (int i);
+    }
+
+    private static int count = 0;
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static A a;
+    static A a2;
+    static A a3;
+    static A a4;
+
+    public static void main(String[] args) {
+        B b = (int i) -> ((A)()-> 5).m();
+        assertTrue(b.make(0) == 5);
+
+        a = () -> ((A)()-> { return 6; }).m(); //self reference
+        assertTrue(a.m() == 6);
+
+        a2 = ()-> {
+                  A an = ()-> { return 7; }; //self reference
+                  return an.m();
+                };
+        assertTrue(a2.m() == 7);
+
+        a3 = () -> a3.m(); //self reference
+        try {
+            a3.m();
+        } catch(StackOverflowError e) {
+            count++;
+        }
+        assertTrue(count==1);
+
+        a4 = ()-> ((B)(int i)-> ((A)()-> 9).m() ).make(0);
+        assertTrue(a4.m() == 9);
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java b/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java
new file mode 100644
index 0000000..ff1c209
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest6.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods for certain SAM conversions
+ * @compile LambdaTest6.java
+ * @run main LambdaTest6
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class LambdaTest6<T> {
+
+    interface H {Object m();}
+
+    interface K<U> {void m(U element);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    private void test1()
+    {
+        L la = s -> { };
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+    }
+
+    private void test2()
+    {
+        KM km = s -> { };
+        //km.m("hi");
+        Class<? extends KM> c2 = km.getClass();
+        Method[] methods = c2.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+    }
+
+    private void test3()
+    {
+        N na = ()-> "hi";
+        assertTrue( na.m().equals("hi") );
+        assertTrue( ((H)na).m().equals("hi") );
+        Class<? extends N> c3 = na.getClass();
+        Method[] methods = c3.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        for(Method m : methods) {
+            assertTrue(m.getName().equals("m"));
+            Class returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.size() == 1); //there's a bridge
+    }
+
+
+    public static void main(String[] args) {
+        LambdaTest6 test = new LambdaTest6();
+        test.test1();
+        test.test2();
+        test.test3();
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/SamConversion.java b/test/tools/javac/lambda/lambdaExpression/SamConversion.java
new file mode 100644
index 0000000..5dfb4da
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/SamConversion.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in context of assignment, method call, return statement and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws Exception;
+    }
+
+    private static String assertionStr = "";
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static void test1(Foo foo) {
+        assertTrue(foo.m(1) == 2);
+    }
+
+    private static void test2(Bar bar) {
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return n -> n + 1;
+        case 1:
+            return (Integer n) -> 2 * n;
+        case 2:
+            return (Integer n) -> {return new Integer(n-1);};
+        case 3:
+            return n -> {throw new Exception();};
+        default:
+            return null;
+        }
+    }
+
+    public static void main(String[] args) {
+
+        //assign:
+        Foo foo = (int n) -> n + 1; //explicit type and boxing
+        assertTrue(foo.m(1) == 2);
+
+        foo = n -> n + 1; //type inferrred and boxing
+        assertTrue(foo.m(1) == 2);
+
+        Bar bar = (Integer n) -> n + 1; //explicit type and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = (Integer n) -> new Integer(n+1); //explicit type and unboxing twice
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n.intValue() + 1; //type inferred
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = n -> n + 1; // type inferred and unboxing
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //cast:
+        assertTrue(((Foo)n -> {return n+1;}).m(1) == 2); //statement (instead of expression) in lambda body
+        try {
+            assertTrue(((Bar)n -> {return n+1;}).m(1) == 2); //statement in lambda body
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        //method parameter:
+        test1((int n) -> new Integer(n+1)); //explicit type
+        test2((Integer n) -> n.intValue() + 1); //explicit type
+
+        //return statement:
+        bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(3) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(10) == 9);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            bar.m(10);
+            assertTrue(false);
+        } catch (Exception e) {}
+    }
+}
diff --git a/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java
new file mode 100644
index 0000000..baf359b
--- /dev/null
+++ b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of lambda expressions in combinations of different contexts,
+ *           lambda body types(statement/expression), explict/implicit target type etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(Integer i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+
+        String getParameterType() {
+            switch(this) {
+            case A:
+                return "int";
+            case B:
+            case C:
+                return "Integer";
+            default:
+                return null;
+            }
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #LBody;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "    void method2() {\n" +
+                    "        method1(#LBody);\n" +
+                    "    }"),
+        CONSTRUCTOR("X x = new X(#LBody);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #LBody;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (#FType)#LBody};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#LBody).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#LBody).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #LBody : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, LambdaKind lk, LambdaBody lb, ReturnValue rv) {
+            return context.replace("#FType", f.interfaceType).replace("#LBody", lb.getLambdaBody(f, lk, rv));
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}"),
+        EXCEPTION_STMT("{throw new Exception();}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ReturnValue {
+        INT("i + 1"),
+        INTEGER("new Integer(i+1)"),
+        INT2("i.intValue() + 1"),
+        STRING("i + \"\""),
+        DOUBLE("i * 1.0");
+
+        String rValue;
+
+        ReturnValue(String rValue) {
+            this.rValue = rValue;
+        }
+    }
+
+    enum LambdaBody {
+        IMPLICIT("i -> #RET"),//type inferred
+        EXPLICIT("(#Type i) -> #RET");//explicit type
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(FInterface fi, LambdaKind lk, ReturnValue rv) {
+            return bodyStr.replace("#Type", fi.getParameterType()).replace("#RET", lk.stmt.replace("#VAL", rv.rValue));
+        }
+    }
+
+    boolean checkSamConversion() {
+        if(lambdaKind != LambdaKind.EXCEPTION_STMT && (returnValue == ReturnValue.DOUBLE || returnValue == ReturnValue.STRING)) //return type mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR) {//context other than construcotr argument
+            if(fInterface != FInterface.C && lambdaKind == LambdaKind.EXCEPTION_STMT)
+                return false;
+            if(fInterface == FInterface.A && returnValue == ReturnValue.INT2)
+                return false;
+        }
+        else { //constructor argument context
+            //match X(A a) or X(B b) or X(C c)
+            if (lambdaKind == LambdaKind.EXCEPTION_STMT) {
+                return false; //ambiguous target type
+            }
+            else if(lambdaBody == LambdaBody.IMPLICIT) {
+                return false;
+            }
+            else { //explicit parameter type
+                if(fInterface.getParameterType().equals("Integer")) //ambiguous target type
+                //e.g. X x = new X((Integer i) -> i + 1);
+                    return false;
+                if(returnValue == ReturnValue.INT2)
+                //e.g. X x = new X(int i -> i.intValue() + 1);
+                    return false;
+            }
+        }
+        return true;
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(6);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(7);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(8);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n" +
+                            "}";
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, lambdaKind, lambdaBody, returnValue));
+        }
+    };
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + lambdaKind + ", " + lambdaBody + ", " + returnValue);
+        System.out.println(samSourceFile + "\n");
+        String clientFileStr = clientSourceFile.toString();
+        System.out.println(clientFileStr.substring(0, clientFileStr.indexOf("\n\n")));
+
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    LambdaBody lambdaBody;
+    LambdaKind lambdaKind;
+    ReturnValue returnValue;
+    static int count = 0;
+
+    SamConversionComboTest(FInterface f, Context c, LambdaBody lb, LambdaKind lk, ReturnValue rv) {
+        fInterface = f;
+        context = c;
+        lambdaKind = lk;
+        lambdaBody = lb;
+        returnValue = rv;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (LambdaKind lk: LambdaKind.values()) {
+                    for (LambdaBody lb : LambdaBody.values()) {
+                        for(ReturnValue rv : ReturnValue.values()) {
+                            new SamConversionComboTest(fi, ct, lb, lk, rv).test();
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/BridgeMethod.java b/test/tools/javac/lambda/methodReference/BridgeMethod.java
new file mode 100644
index 0000000..bf70432
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/BridgeMethod.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test bridge methods in certain SAM conversion
+ * @compile BridgeMethod.java
+ * @run main BridgeMethod
+ */
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+public class BridgeMethod {
+
+    interface H {Object m();}
+
+    interface K<T> {void m(T t);}
+
+    interface L extends K<String> {} //generic substitution
+
+    interface M {void m(String s);}
+
+    interface KM extends K<String>, M{} //generic substitution
+
+    interface N extends H {String m();} //covariant return
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar(String s) {
+        System.out.println("BridgeMethod.bar(String) " + s);
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    private static Set<String> setOfStringObject() {
+        Set<String> s = new HashSet<>();
+        s.add("java.lang.String");
+        s.add("java.lang.Object");
+        return s;
+    }
+
+    public static void main(String[] args) {
+        L la = BridgeMethod::bar; //static reference
+        la.m("hi");
+        Class<? extends L> c1 = la.getClass();
+        Method[] methods = c1.getDeclaredMethods();
+        Set<String> types = setOfStringObject();
+        System.out.println("methods in SAM conversion of L:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty() || (types.size() == 1 && types.contains("java.lang.String")));
+
+        KM km = BridgeMethod::bar;
+        //km.m("hi"); //will be uncommented when CR7028808 fixed
+        Class<? extends KM> c2 = km.getClass();
+        methods = c2.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of KM:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?>[] parameterTypes = m.getParameterTypes();
+            assertTrue(parameterTypes.length == 1);
+            assertTrue(types.remove(parameterTypes[0].getName()));
+        }
+        assertTrue(types.isEmpty());
+
+        N n = new BridgeMethod()::moo; //instance reference
+        assertTrue( n.m().equals("moo") );
+        assertTrue( ((H)n).m().equals("moo") );
+        Class<? extends N> c3 = n.getClass();
+        methods = c3.getDeclaredMethods();
+        types = setOfStringObject();
+        System.out.println("methods in SAM conversion of N:");
+        for(Method m : methods) {
+            System.out.println(m.toGenericString());
+            assertTrue(m.getName().equals("m"));
+            Class<?> returnType = m.getReturnType();
+            assertTrue(types.remove(returnType.getName()));
+        }
+        assertTrue(types.size() == 1); //there's a bridge
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef1.java b/test/tools/javac/lambda/methodReference/MethodRef1.java
new file mode 100644
index 0000000..bfccad8
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef1.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test static method reference
+ * @compile MethodRef1.java
+ * @run main MethodRef1
+ */
+
+public class MethodRef1 {
+
+    static interface A {void m();}
+
+    static interface B {void m(int i);}
+
+    static interface C {String m(String s);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void foo(int x) {
+        System.out.println("MethodRef1.foo(int) " + x);
+    }
+
+    static void bar() {
+        System.out.println("MethodRef1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef1.bar(int) " + x);
+    }
+
+    static String bar(String s) {
+        return "MethodRef1.bar(String) " + s;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef1::bar; //static reference to bar()
+        a.m();
+
+        B b = MethodRef1::foo; //static reference to foo(int), (int) omitted because method foo is not overloaded
+        b.m(1);
+
+        b = MethodRef1::foo; //static reference to foo(int)
+        b.m(1);
+
+        b = MethodRef1::bar; //static reference to bar(int)
+        b.m(2);
+
+        C c = MethodRef1::bar; //static reference to bar(String)
+        assertTrue( c.m("hi").equals("MethodRef1.bar(String) hi") );
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef2.java b/test/tools/javac/lambda/methodReference/MethodRef2.java
new file mode 100644
index 0000000..60f41ba
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef2.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test instance method reference
+ * @compile MethodRef2.java
+ * @run main MethodRef2
+ */
+
+public class MethodRef2 {
+
+    static interface A {String m();}
+
+    static interface B {String m(int i);}
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef2 mr = new MethodRef2();
+
+        A a = mr::moo; //instance reference to moo()
+        assertTrue( a.m().equals("moo") );
+
+        a = new MethodRef2()::wahoo; //instance reference to wahoo()
+        assertTrue( a.m().equals("wahoo") );
+
+        B b = mr::wahoo; //instance reference to wahoo(int)
+        assertTrue( b.m(4).equals("wahoo 4") );
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef3.java b/test/tools/javac/lambda/methodReference/MethodRef3.java
new file mode 100644
index 0000000..ec2780d
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef3.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test unbound method reference
+ * @compile MethodRef3.java
+ * @run main MethodRef3
+ */
+
+public class MethodRef3 {
+
+    static interface A { String m(MethodRef3 mr); }
+
+    static interface B { String m(MethodRef3 mr, String s); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    String moo() {
+        return "moo";
+    }
+
+    String wahoo(String s) {
+        return "wahoo " + s;
+    }
+
+    public static void main(String[] args) {
+
+        MethodRef3 mr = new MethodRef3();
+        A a = MethodRef3::moo; //unbound reference to moo()
+        assertTrue( a.m(mr).equals("moo") );
+        B b = MethodRef3::wahoo; //unbound reference to wahoo()
+        assertTrue( b.m(mr, "hi").equals("wahoo hi") );
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef4.java b/test/tools/javac/lambda/methodReference/MethodRef4.java
new file mode 100644
index 0000000..a05b3fb
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef4.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test constructor reference
+ * @compile MethodRef4.java
+ * @run main MethodRef4
+ */
+
+public class MethodRef4 {
+
+    static interface A {Fee<String> m();}
+
+    static interface B {Fee<String> m(String s);}
+
+    static interface C {Object m();}
+
+    static class Fee<T> {
+
+        private T t;
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(T t) {
+            this.t = t;
+            System.out.println("Fee<T> instantiated: " + t);
+        }
+
+        public void make() {
+            System.out.println(this + ": make()");
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        A a = Fee<String>::new; //constructor reference to Fee<T>()
+        a.m().make();
+
+        B b = Fee<String>::new; //constructor reference to Fee<T>(String)
+        b.m("hi").make();
+
+        C c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = MethodRef4::new; //constructor reference to MethodRef4()
+        assertTrue( c.m() instanceof MethodRef4 );
+        c = Fee<String>::new; //constructor reference to Fee<T>()
+        assertTrue( c.m() instanceof Fee );
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef5.java b/test/tools/javac/lambda/methodReference/MethodRef5.java
new file mode 100644
index 0000000..4738108
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef5.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test method reference with SAM interface Comparator<T>
+ * @compile MethodRef5.java
+ * @run main MethodRef5
+ */
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+
+public class MethodRef5 {
+
+    static class Person {
+
+        private String firstName;
+        private String lastName;
+        private int age;
+
+        public Person() { }
+
+        public Person(String fn, String ln, int a) {
+            firstName = fn;
+            lastName = ln;
+            age = a;
+        }
+
+        public String getLastName() {
+            return lastName;
+        }
+
+        public int getAge() {
+            return age;
+        }
+
+        //the following 2 methods are signature-compatible with Comparator<Person>.compare():
+        public static int compareByAge(Person a, Person b) {
+            return a.age - b.age;
+        }
+
+        public int compareByLastName(Person a, Person b) {
+            return a.lastName.compareToIgnoreCase(b.lastName);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        List<Person> persons = new ArrayList<Person>();
+        persons.add(new Person("John", "Smith", 49));
+        persons.add(new Person("Abraham", "Lincoln", 30));
+        persons.add(new Person("George", "Washington", 29));
+        persons.add(new Person("Peter", "Derby", 50));
+        Collections.sort(persons, Person::compareByAge);//static method reference to compareByAge(Person, Person)
+        String age = "";
+        for (Person p : persons) {
+            age += p.getAge() + " ";
+        }
+        assertTrue( (age.equals("29 30 49 50 ")) );
+        Collections.sort(persons, new Person()::compareByLastName);//instance method reference to compareByLastName(Person, Person)
+        String lastName = "";
+        for (Person p : persons) {
+            lastName += p.getLastName() + " ";
+        }
+        assertTrue( lastName.equals("Derby Lincoln Smith Washington ") );
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef6.java b/test/tools/javac/lambda/methodReference/MethodRef6.java
new file mode 100644
index 0000000..0cd740f
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef6.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test that the most specific reference is selected when method parameters are elided
+ * @compile MethodRef6.java
+ * @run main MethodRef6
+ */
+
+public class MethodRef6 {
+
+    static interface A { String make(Integer i); }
+
+    static interface B { String make(Number i); }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static String m(Object o) {
+        return "Object " + o;
+    }
+
+    static String m(Number n) {
+        return "Number " + n;
+    }
+
+    static String m(Integer i) {
+        return "Integer " + i;
+    }
+
+    static String m(int i) {
+        return "int " + i;
+    }
+
+    public static void main(String[] args) {
+        A a = MethodRef6::m;
+        assertTrue(a.make(1).equals("Integer 1"));//method parameter type inferred from SAM descriptor, boxing applied
+        B b = MethodRef6::m;
+        assertTrue(b.make(1).equals("Number 1"));//method parameter type inferred from SAM descriptor, boxing and widen applied
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef7.java b/test/tools/javac/lambda/methodReference/MethodRef7.java
new file mode 100644
index 0000000..edcb6d4
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef7.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   Test that parameter types are inferred from SAM descriptor when method parameters are elided,
+             with different types of method references
+ * @compile MethodRef7.java
+ * @run main MethodRef7
+ */
+
+public class MethodRef7 {
+
+    static interface A {void m();}
+
+    static interface A2 {void m(int n);}
+
+    static interface B {String m();}
+
+    static interface B2 {String m(int n);}
+
+    static interface C {String m(MethodRef7 mr);}
+
+    static interface C2 {String m(MethodRef7 mr, int n);}
+
+    static interface D {Fee<String> m();}
+
+    static interface D2 {Fee<String> m(String s);}
+
+    static class Fee<T> {
+
+        public Fee() {
+            System.out.println("Fee<T> instantiated");
+        }
+
+        public Fee(String s) {
+            System.out.println("Fee<T> instantiated: " + s);
+        }
+    }
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    static void bar() {
+        System.out.println("MethodRef_neg1.bar()");
+    }
+
+    static void bar(int x) {
+        System.out.println("MethodRef_neg1.bar(int) " + x);
+    }
+
+    String wahoo() {
+        return "wahoo";
+    }
+
+    String wahoo(int x) {
+        return "wahoo " + x;
+    }
+
+    public static void main(String[] args) {
+
+        A a = MethodRef7::bar; //static reference to bar()
+        a.m();
+        A2 a2 = MethodRef7::bar; //static reference to bar(int x)
+        a2.m(10);
+
+        MethodRef7 mr = new MethodRef7();
+        B b = mr::wahoo; //instance reference to wahoo()
+        assertTrue(b.m().equals("wahoo"));
+        B2 b2 = mr::wahoo; //instance reference to wahoo(int x)
+        assertTrue(b2.m(1).equals("wahoo 1"));
+
+        C c = MethodRef7::wahoo; //unbound reference to wahoo()
+        assertTrue(c.m(mr).equals("wahoo"));
+        C2 c2 = MethodRef7::wahoo; //unbound reference to wahoo(int x)
+        assertTrue(c2.m(mr, 2).equals("wahoo 2"));
+
+        D d = Fee<String>::new; //constructor reference to Fee()
+        D2 d2 = Fee<String>::new; //constructor reference to Fee(String s)
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef_neg.java b/test/tools/javac/lambda/methodReference/MethodRef_neg.java
new file mode 100644
index 0000000..0a89097
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef_neg.java
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   This is negative test for wrong parameter/return type in method references
+ * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java
+ */
+
+public class MethodRef_neg {
+
+    static interface A {void m(Integer i);}
+
+    static interface B {void m(String s);}
+
+    static interface C {Integer m();}
+
+    static interface D {String m();}
+
+
+    static void bar(int x) { }
+
+    int foo() {
+        return 5;
+    }
+
+    static void make() { }
+
+    void method() {
+        A a = MethodRef_neg::bar; //boxing on parameter type is ok
+        B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int
+        C c = this::foo; //boxing on return type is ok
+        D d = this::foo; //wrong return type, required: String, actual: int
+        a = MethodRef_neg::make; //missing parameter
+        c = MethodRef_neg::make; //missing return type
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/MethodRef_neg.out b/test/tools/javac/lambda/methodReference/MethodRef_neg.out
new file mode 100644
index 0000000..58b77bc
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/MethodRef_neg.out
@@ -0,0 +1,5 @@
+MethodRef_neg.java:30:15: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, bar, int, java.lang.String, kindname.class, MethodRef_neg, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int))))
+MethodRef_neg.java:32:15: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int, java.lang.String))
+MethodRef_neg.java:33:13: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, make, compiler.misc.no.args, java.lang.Integer, kindname.class, MethodRef_neg, (compiler.misc.arg.length.mismatch)))
+MethodRef_neg.java:34:13: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: void, java.lang.Integer))
+4 errors
diff --git a/test/tools/javac/lambda/methodReference/SamConversion.java b/test/tools/javac/lambda/methodReference/SamConversion.java
new file mode 100644
index 0000000..134973a
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/SamConversion.java
@@ -0,0 +1,320 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in contexts of assignment, method/constructor argument,
+ *           return statement, array initializer, lambda expression body, conditional expression and cast.
+ * @compile SamConversion.java
+ * @run main SamConversion
+ */
+
+public class SamConversion {
+
+    static int assertionCount = 0;
+
+    static interface Foo {
+        Integer m(int i);
+    }
+
+    static interface Bar {
+        int m(Integer i) throws MyException;
+    }
+
+    private static void assertTrue(boolean b) {
+        assertionCount++;
+        if(!b)
+            throw new AssertionError();
+    }
+
+    private static int test1(Foo foo) {
+        return foo.m(1);
+    }
+
+    private static void test2(Bar bar, int result) {
+        try {
+            assertTrue(bar.m(1) == result);
+        } catch (Exception e){
+            assertTrue(false);
+        }
+    }
+
+    private static Bar test3(int i) {
+        switch (i) {
+        case 0:
+            return A::method1;
+        case 1:
+            return new A()::method2;
+        case 2:
+            return A::method3;
+        case 3:
+            return new A()::method4;
+        case 4:
+            return new A()::method5;
+        case 5:
+            return A::method6;
+        default:
+            return null;
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in assignment context
+     */
+    private static void testAssignment() {
+        Foo foo = A::method1; //static reference, parameter type matching and return type matching
+        assertTrue(foo.m(1) == 2);
+
+        foo = new A()::method2; //instance reference, parameter type unboxing and return type boxing
+        assertTrue(foo.m(1) == 3);
+
+        foo = A::method3; //static reference, parameter type matching and return type boxing
+        assertTrue(foo.m(1) == 4);
+
+        foo = new A()::method4; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 5);
+
+        foo = new A()::method5; //instance reference, parameter type unboxing and return type matching
+        assertTrue(foo.m(1) == 6);
+
+        Bar bar = A::method1;
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method2;
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = A::method3;
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method4;
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+
+        bar = new A()::method5;
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in method/constructor argument context
+     */
+    private static void testMethodArgument() {
+        assertTrue(test1(A::method1) == 2);
+        assertTrue(test1(new A()::method2) == 3);
+        assertTrue(test1(A::method3) == 4);
+        assertTrue(test1(new A()::method4) == 5);
+        assertTrue(test1(new A()::method5) == 6);
+        test2(A::method1, 2);
+        test2(new A()::method2, 3);
+        test2(A::method3, 4);
+        test2(new A()::method4, 5);
+        test2(new A()::method5, 6);
+    }
+
+    /**
+     * Test SAM conversion of method reference in return statement context
+     */
+    private static void testReturnStatement() {
+        Bar bar = test3(0);
+        try {
+            assertTrue(bar.m(1) == 2);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(1);
+        try {
+            assertTrue(bar.m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(2);
+        try {
+            assertTrue(bar.m(1) == 4);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(3);
+        try {
+            assertTrue(bar.m(1) == 5);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(4);
+        try {
+            assertTrue(bar.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+        bar = test3(5);
+        try {
+            bar.m(1);
+            assertTrue(false);
+        } catch (MyException e) {
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in cast context
+     */
+    private static void testCast() {
+        assertTrue(((Foo)A::method1).m(1) == 2);
+        try {
+            assertTrue(((Bar)new A()::method2).m(1) == 3);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in array initializer context
+     */
+    private static void testArrayInitializer() {
+        Object[] oarray = {"a", 1, (Foo)A::method3}; //last element need a cast
+        Object[] oarray2 = {"a", 1, (Bar)new A()::method4}; //last element need a cast
+        Foo[] farray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5};
+        Bar[] barray = {A::method1, new A()::method2, A::method3, new A()::method4, new A()::method5, A::method6};
+    }
+
+    /**
+     * Test SAM conversion of method reference in conditional expression context
+     */
+    private static void testConditionalExpression(boolean b) {
+        Foo f = b ? A::method3 : new A()::method5;
+        if(b)
+            assertTrue(f.m(1) == 4);
+        else
+            assertTrue(f.m(1) == 6);
+
+        Bar bar = b ? A::method1 : A::method6;
+        if(b) {
+            try {
+                assertTrue(bar.m(1) == 2);
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+        else {
+            try {
+                bar.m(1);
+                assertTrue(false);
+            } catch (MyException e) {
+            } catch (Exception e) {
+                assertTrue(false);
+            }
+        }
+    }
+
+    /**
+     * Test SAM conversion of method reference in lambda expression body
+     */
+    private static void testLambdaExpressionBody() {
+        Foo f = n -> ((Foo)A::method3).m(n);
+        assertTrue(f.m(1) == 4);
+
+        Bar b = n -> { return ((Foo)new A()::method5).m(n); };
+        try {
+            assertTrue(b.m(1) == 6);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+    public static void main(String[] args) {
+        testAssignment();
+        testMethodArgument();
+        testReturnStatement();
+        testCast();
+        testArrayInitializer();
+        testConditionalExpression(true);
+        testConditionalExpression(false);
+        testLambdaExpressionBody();
+
+        assertTrue(assertionCount == 32);
+    }
+
+    static class MyException extends Exception {}
+
+    static class A {
+
+        int value = 0;
+
+        A() {
+        }
+
+        A(Foo f) {
+            value = f.m(9);
+        }
+
+        A(Bar b) {
+            try {
+                value = b.m(9);
+            } catch (MyException e){}
+        }
+
+        static Integer method1(int n) {
+            return n + 1;
+        }
+
+        int method2(Integer n) {
+            return value == 0 ? n + 2 : n + value;
+        }
+
+        static int method3(int n) {
+            return n + 3;
+        }
+
+        Integer method4(Integer n) {
+            return value == 0 ? n + 4 : n + value;
+        }
+
+        Integer method5(Integer n) {
+            return value == 0 ? new Integer(n + 5) : new Integer(n + value);
+        }
+
+        static int method6(Integer n) throws MyException{
+            throw new MyException();
+        }
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/SamConversionComboTest.java b/test/tools/javac/lambda/methodReference/SamConversionComboTest.java
new file mode 100644
index 0000000..22d8e25
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/SamConversionComboTest.java
@@ -0,0 +1,262 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *   Test SAM conversion of method references in combinations of different contexts,
+ *           lambda body types(statement/expression), boxing/unboxing etc, to verify
+ *           SAM conversion being conducted successfully as expected.
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import javax.tools.StandardJavaFileManager;
+
+public class SamConversionComboTest {
+
+    enum FInterface {
+        A("A", "interface A { Integer m(int i); }"),
+        B("B", "interface B { int m(Integer i); }"),
+        C("C", "interface C { int m(int i) throws Exception; }");
+
+        String interfaceType;
+        String interfaceDef;
+
+        FInterface(String interfaceType, String interfaceDef) {
+            this.interfaceType = interfaceType;
+            this.interfaceDef = interfaceDef;
+        }
+    }
+
+    enum Context {
+        ASSIGNMENT("#FType f = #MR;"),
+        METHOD_CALL("void method1(#FType f) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#MR);\n" +
+                    "}"),
+        CONSTRUCTOR("X x = new X(#MR);"),
+        RETURN_OF_METHOD("#FType method1() {\n" +
+                         "    return #MR;\n" +
+                         "}"),
+        ARRAY_INITIALIZER("#FType[] oarray = {#MR};"),
+        LAMBDA_BODY("#FType f = n -> ((#FType)#MR).m(n);"),
+        CAST("void test() throws Exception { int n = ((#FType)#MR).m(1); }"),
+        CONDITIONAL_EXPRESSION("#FType f = 2 > 1 ? #MR : null;");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(FInterface f, MethodReference mr) {
+            return context.replace("#FType", f.interfaceType).replace("#MR", mr.mrValue);
+        }
+    }
+
+    enum MethodReference {
+        METHOD1("X::method1"),
+        METHOD2("new X()::method2"),
+        METHOD3("X::method3"),
+        METHOD4("new X()::method4"),
+        METHOD5("new X()::method5"),
+        METHOD6("X::method6"),
+        METHOD7("X::method7"),
+        METHOD8("X::method8");
+
+        String mrValue;
+
+        MethodReference(String mr) {
+            mrValue = mr;
+        }
+    }
+
+    enum MethodDef {
+        METHOD1("    static Integer method1(int n) {\n" +
+                "        return n + 1;\n" +
+                "    }\n", 0),
+        METHOD2("    int method2(Integer n) {\n" +
+                "        return value == 0 ? n + 2 : n + value;\n" +
+                "    }\n", 1),
+        METHOD3("    static int method3(int n) {\n" +
+                "        return n + 3;\n" +
+                "    }\n", 2),
+        METHOD4("    Integer method4(Integer n) {\n" +
+                "        return value == 0 ? n + 4 : n + value;\n" +
+                "    }\n", 3),
+        METHOD5("    Integer method5(Integer n) {\n" +
+                "        return value == 0 ? new Integer(n + 5) : new Integer(n + value);\n" +
+                "    }\n", 4),
+        METHOD6("    static int method6(Integer n) throws Exception{\n" +
+                "        throw new Exception();\n" +
+                "    }\n", 5),
+        METHOD7("    static int method7(String s){\n" +
+                "        return s.length();\n" +
+                "    }\n", 6),
+        METHOD8("    static String method8(Integer n){\n" +
+                "        return n + \"\";\n" +
+                "    }\n", 7);
+
+        String methodStr;
+        int index;
+
+        MethodDef(String ms, int i) {
+            methodStr = ms;
+            index = i;
+        }
+
+        MethodReference getMethodReference() {
+            return MethodReference.values()[index];
+        }
+    }
+
+    SourceFile samSourceFile = new SourceFile("FInterface.java", "#C") {
+        public String toString() {
+            String interfaces = "";
+            for(FInterface fi : FInterface.values())
+                interfaces += fi.interfaceDef + "\n";
+            return template.replace("#C", interfaces);
+        }
+    };
+
+    String clientTemplate = "class Client {\n" +
+                            "    #Context\n" +
+                            "}\n\n" +
+
+                            "class X {\n" +
+                            "    int value = 0;\n\n" +
+
+                            "    X() {\n" +
+                            "    }\n\n" +
+
+                            "    X(A a) {\n" +
+                            "        value = a.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(B b) {\n" +
+                            "        value = b.m(9);\n" +
+                            "    }\n\n" +
+
+                            "    X(C c) {\n" +
+                            "        try {\n" +
+                            "            value = c.m(9);\n" +
+                            "        } catch (Exception e){}\n" +
+                            "    }\n\n" +
+
+                            "#MethodDef" +
+                            "}";
+
+    SourceFile clientSourceFile = new SourceFile("Client.java", clientTemplate) {
+        public String toString() {
+            return template.replace("#Context", context.getContext(fInterface, methodReference)).replace("#MethodDef", methodDef.methodStr);
+        }
+    };
+
+    boolean checkSamConversion() {
+        if(methodDef == MethodDef.METHOD7 || methodDef == MethodDef.METHOD8)//method signature mismatch
+            return false;
+        if(context != Context.CONSTRUCTOR && fInterface != FInterface.C && methodDef == MethodDef.METHOD6)
+        //method that throws exceptions not thrown by the interface method is a mismatch
+            return false;
+        if(context == Context.CONSTRUCTOR)
+               return false;
+        return true;
+    }
+
+    void test() throws Exception {
+        System.out.println("\n====================================");
+        System.out.println(fInterface + ", " +  context + ", " + methodReference);
+        System.out.println(samSourceFile + "\n" + clientSourceFile);
+
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        ct.analyze();
+        if (dc.errorFound == checkSamConversion()) {
+            throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile);
+        }
+        count++;
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    FInterface fInterface;
+    Context context;
+    MethodDef methodDef;
+    MethodReference methodReference;
+    static int count = 0;
+
+    static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    SamConversionComboTest(FInterface f, Context c, MethodDef md) {
+        fInterface = f;
+        context = c;
+        methodDef = md;
+        methodReference = md.getMethodReference();
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (FInterface fi : FInterface.values()) {
+                for (MethodDef md: MethodDef.values()) {
+                    new SamConversionComboTest(fi, ct, md).test();
+                }
+            }
+        }
+        System.out.println("total tests: " + count);
+    }
+}
diff --git a/test/tools/javac/lambda/methodReference/TreeMakerParamsIsGoofy.java b/test/tools/javac/lambda/methodReference/TreeMakerParamsIsGoofy.java
new file mode 100644
index 0000000..92f692b
--- /dev/null
+++ b/test/tools/javac/lambda/methodReference/TreeMakerParamsIsGoofy.java
@@ -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) {
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java
new file mode 100644
index 0000000..00eed06
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestFDCCE.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestFDCCE
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/**
+ * Method references and raw types.
+ * @author Robert Field
+ */
+
+ at Test
+ at SuppressWarnings({"rawtypes", "unchecked"})
+public class MethodReferenceTestFDCCE {
+
+    static void assertCCE(Throwable t) {
+        assertEquals(t.getClass().getName(), "java.lang.ClassCastException");
+    }
+
+    interface Pred<T> { boolean accept(T x); }
+
+    interface Ps { boolean accept(short x); }
+
+    interface Oo { Object too(int x); }
+
+    interface Reto<T> { T m(); }
+
+    class A {}
+    class B extends A {}
+
+    static boolean isMinor(int x) {
+        return x < 18;
+    }
+
+    static boolean tst(A x) {
+        return true;
+    }
+
+    static Object otst(Object x) {
+        return x;
+    }
+
+    static boolean stst(Short x) {
+        return x < 18;
+    }
+
+    static short ritst() {
+        return 123;
+    }
+
+    public void testMethodReferenceFDPrim1() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        assertTrue(p2.accept((Byte)(byte)15));
+    }
+
+    public void testMethodReferenceFDPrim2() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        assertTrue(p2.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimICCE() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        try {
+            p2.accept(15); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDPrimOCCE() {
+        Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
+        Pred p2 = p;
+        try {
+            p2.accept(new Object()); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDRef() {
+        Pred<B> p = MethodReferenceTestFDCCE::tst;
+        Pred p2 = p;
+        assertTrue(p2.accept(new B()));
+    }
+
+    public void testMethodReferenceFDRefCCE() {
+        Pred<B> p = MethodReferenceTestFDCCE::tst;
+        Pred p2 = p;
+        try {
+            p2.accept(new A()); // should throw CCE
+            fail("Exception should have been thrown");
+        } catch (Throwable t) {
+            assertCCE(t);
+        }
+    }
+
+    public void testMethodReferenceFDPrimPrim() {
+        Ps p = MethodReferenceTestFDCCE::isMinor;
+        assertTrue(p.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimBoxed() {
+        Ps p = MethodReferenceTestFDCCE::stst;
+        assertTrue(p.accept((byte)15));
+    }
+
+    public void testMethodReferenceFDPrimRef() {
+        Oo p = MethodReferenceTestFDCCE::otst;
+        assertEquals(p.too(15).getClass().getName(), "java.lang.Integer");
+    }
+
+    public void testMethodReferenceFDRet1() {
+        Reto<Short> p = MethodReferenceTestFDCCE::ritst;
+        assertEquals(p.m(), (Short)(short)123);
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java
new file mode 100644
index 0000000..cdc9ef8
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerDefault.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerDefault
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface IDSs { String m(String a); }
+
+interface InDefA {
+    default String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    default String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+}
+
+interface InDefB extends InDefA {
+
+    default String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    default String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+}
+
+ at Test
+public class MethodReferenceTestInnerDefault implements InDefB {
+
+    public void testMethodReferenceInnerDefault() {
+        (new In()).testMethodReferenceInnerDefault();
+    }
+
+    class In {
+
+        public void testMethodReferenceInnerDefault() {
+            IDSs q;
+
+            q = MethodReferenceTestInnerDefault.this::xsA__;
+            assertEquals(q.m("*"), "A__xsA:*");
+
+            q = MethodReferenceTestInnerDefault.this::xsAB_;
+            assertEquals(q.m("*"), "AB_xsB:*");
+
+            q = MethodReferenceTestInnerDefault.this::xs_B_;
+            assertEquals(q.m("*"), "_B_xsB:*");
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java
new file mode 100644
index 0000000..165b470
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerInstance.java
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerInstance
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestInnerInstance {
+
+    public void testMethodReferenceInnerInstance() {
+        cia().cib().testMethodReferenceInstance();
+    }
+
+    public void testMethodReferenceInnerExternal() {
+        cia().cib().testMethodReferenceExternal();
+    }
+
+    interface SI {
+        String m(Integer a);
+    }
+
+    class CIA {
+
+        String xI(Integer i) {
+            return "xI:" + i;
+        }
+
+        public class CIB {
+
+            public void testMethodReferenceInstance() {
+                SI q;
+
+                q = CIA.this::xI;
+                assertEquals(q.m(55), "xI:55");
+            }
+
+            public void testMethodReferenceExternal() {
+                SI q;
+
+                q = (new E())::xI;
+                assertEquals(q.m(77), "ExI:77");
+            }
+        }
+
+        CIB cib() {
+            return new CIB();
+        }
+
+        class E {
+
+            String xI(Integer i) {
+                return "ExI:" + i;
+            }
+        }
+
+    }
+
+    CIA cia() {
+        return new CIA();
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java
new file mode 100644
index 0000000..791bafb
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInnerVarArgsThis.java
@@ -0,0 +1,250 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInnerVarArgsThis
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestInnerVarArgsThis {
+
+    interface NsII {
+
+        String m(Integer a, Integer b);
+    }
+
+    interface Nsiii {
+
+        String m(int a, int b, int c);
+    }
+
+    interface Nsi {
+
+        String m(int a);
+    }
+
+    interface NsaO {
+
+        String m(Object[] a);
+    }
+
+    interface Nsai {
+
+        String m(int[] a);
+    }
+
+    interface Nsvi {
+
+        String m(int... va);
+    }
+
+    class CIA {
+
+        String xvI(Integer... vi) {
+            StringBuilder sb = new StringBuilder("xvI:");
+            for (Integer i : vi) {
+                sb.append(i);
+                sb.append("-");
+            }
+            return sb.toString();
+        }
+
+        String xIvI(Integer f, Integer... vi) {
+            StringBuilder sb = new StringBuilder("xIvI:");
+            sb.append(f);
+            for (Integer i : vi) {
+                sb.append(i);
+                sb.append("-");
+            }
+            return sb.toString();
+        }
+
+        String xvi(int... vi) {
+            int sum = 0;
+            for (int i : vi) {
+                sum += i;
+            }
+            return "xvi:" + sum;
+        }
+
+        String xIvi(Integer f, int... vi) {
+            int sum = 0;
+            for (int i : vi) {
+                sum += i;
+            }
+            return "xIvi:(" + f + ")" + sum;
+        }
+
+        String xvO(Object... vi) {
+            StringBuilder sb = new StringBuilder("xvO:");
+            for (Object i : vi) {
+                if (i.getClass().isArray()) {
+                    sb.append("[");
+                    int len = Array.getLength(i);
+                    for (int x = 0; x < len; ++x) {
+                        sb.append(Array.get(i, x));
+                        sb.append(",");
+                    }
+                    sb.append("]");
+
+                } else {
+                    sb.append(i);
+                }
+                sb.append("*");
+            }
+            return sb.toString();
+        }
+
+        public class CIB {
+
+            // These should be processed as var args
+            public void testVarArgsNsSuperclass() {
+                NsII q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(55, 66), "xvO:55*66*");
+            }
+
+            public void testVarArgsNsArray() {
+                Nsai q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(new int[]{55, 66}), "xvO:[55,66,]*");
+            }
+
+            public void testVarArgsNsII() {
+                NsII q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(33, 7), "xvI:33-7-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(50, 40), "xIvI:5040-");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(100, 23), "xvi:123");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(9, 21), "xIvi:(9)21");
+            }
+
+            public void testVarArgsNsiii() {
+                Nsiii q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(900, 80, 7), "xvi:987");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(333, 27, 72), "xIvi:(333)99");
+            }
+
+            public void testVarArgsNsi() {
+                Nsi q;
+
+                q = CIA.this::xvI;
+                assertEquals(q.m(3), "xvI:3-");
+
+                q = CIA.this::xIvI;
+                assertEquals(q.m(888), "xIvI:888");
+
+                q = CIA.this::xvi;
+                assertEquals(q.m(900), "xvi:900");
+
+                q = CIA.this::xIvi;
+                assertEquals(q.m(333), "xIvi:(333)0");
+            }
+
+            // These should NOT be processed as var args
+            public void testVarArgsNsaO() {
+                NsaO q;
+
+                q = CIA.this::xvO;
+                assertEquals(q.m(new String[]{"yo", "there", "dude"}), "xvO:yo*there*dude*");
+            }
+        }
+
+        CIB cib() {
+            return new CIB();
+        }
+
+        class E {
+
+            String xI(Integer i) {
+                return "ExI:" + i;
+            }
+        }
+    }
+
+    CIA cia() {
+        return new CIA();
+    }
+
+    // These should be processed as var args
+    public void testVarArgsNsSuperclass() {
+        cia().cib().testVarArgsNsSuperclass();
+    }
+
+    public void testVarArgsNsArray() {
+        cia().cib().testVarArgsNsArray();
+    }
+
+    public void testVarArgsNsII() {
+        cia().cib().testVarArgsNsII();
+    }
+
+    public void testVarArgsNsiii() {
+        cia().cib().testVarArgsNsiii();
+    }
+
+    public void testVarArgsNsi() {
+        cia().cib().testVarArgsNsi();
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNsaO() {
+        cia().cib().testVarArgsNsaO();
+    }
+
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java
new file mode 100644
index 0000000..7aba6d9
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestInstance.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestInstance
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestInstance_E {
+    String xI(Integer i) {
+        return "ExI:" + i;
+    }
+}
+
+ at Test
+public class MethodReferenceTestInstance {
+
+    interface SI { String m(Integer a); }
+
+    String xI(Integer i) {
+        return "xI:" + i;
+    }
+
+    public void testMethodReferenceInstance() {
+        SI q;
+
+        q = this::xI;
+        assertEquals(q.m(55), "xI:55");
+    }
+
+    public void testMethodReferenceExternal() {
+        SI q;
+
+        q = (new MethodReferenceTestInstance_E())::xI;
+        assertEquals(q.m(77), "ExI:77");
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java
new file mode 100644
index 0000000..2f885fd
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestKinds.java
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestKinds
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup {
+
+    interface S0 { String get(); }
+    interface S1 { String get(MethodReferenceTestKinds x); }
+    interface S2 { String get(MethodReferenceTestKinds x, MethodReferenceTestKinds y); }
+
+    interface SXN0 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x); }
+    interface SXN1 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x, String str); }
+
+    interface SN0 { MethodReferenceTestKindsBase make(); }
+    interface SN1 { MethodReferenceTestKindsBase make(String x); }
+
+    class In extends MethodReferenceTestKindsBase {
+        In(String val) {
+            this.val = val;
+        }
+
+        In() {
+            this("blank");
+        }
+    }
+
+    String instanceMethod0() { return "IM:0-" + this; }
+    String instanceMethod1(MethodReferenceTestKinds x) { return "IM:1-" + this + x; }
+
+    static String staticMethod0() { return "SM:0"; }
+    static String staticMethod1(MethodReferenceTestKinds x) { return "SM:1-" + x; }
+
+    MethodReferenceTestKinds(String val) {
+        super(val);
+    }
+
+    MethodReferenceTestKinds() {
+        super("blank");
+    }
+
+    MethodReferenceTestKinds inst(String val) {
+        return new MethodReferenceTestKinds(val);
+    }
+
+    public void testMRBound() {
+        S0 var = this::instanceMethod0;
+        assertEquals(var.get(), "IM:0-MethodReferenceTestKinds(blank)");
+    }
+
+    public void testMRBoundArg() {
+        S1 var = this::instanceMethod1;
+        assertEquals(var.get(inst("arg")), "IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRUnbound() {
+        S1 var = MethodReferenceTestKinds::instanceMethod0;
+        assertEquals(var.get(inst("rcvr")), "IM:0-MethodReferenceTestKinds(rcvr)");
+    }
+
+    public void testMRUnboundArg() {
+        S2 var = MethodReferenceTestKinds::instanceMethod1;
+        assertEquals(var.get(inst("rcvr"), inst("arg")), "IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRSuper() {
+        S0 var = super::instanceMethod0;
+        assertEquals(var.get(), "SIM:0-MethodReferenceTestKinds(blank)");
+    }
+
+    public void testMRSuperArg() {
+        S1 var = super::instanceMethod1;
+        assertEquals(var.get(inst("arg")), "SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRStatic() {
+        S0 var = MethodReferenceTestKinds::staticMethod0;
+        assertEquals(var.get(), "SM:0");
+    }
+
+    public void testMRStaticArg() {
+        S1 var = MethodReferenceTestKinds::staticMethod1;
+        assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
+    }
+
+    public void testMRTopLevel() {
+        SN0 var = MethodReferenceTestKindsBase::new;
+        assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)");
+    }
+
+    public void testMRTopLevelArg() {
+        SN1 var = MethodReferenceTestKindsBase::new;
+        assertEquals(var.make("name").toString(), "MethodReferenceTestKindsBase(name)");
+    }
+
+    public void testMRImplicitInner() {
+        SN0 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make().toString(), "In(blank)");
+    }
+
+    public void testMRImplicitInnerArg() {
+        SN1 var = MethodReferenceTestKinds.In::new;
+        assertEquals(var.make("name").toString(), "In(name)");
+    }
+
+}
+
+
+class MethodReferenceTestKindsBase {
+    String val = "unset";
+
+    public String toString() {
+        return getClass().getSimpleName() + "(" + val + ")";
+    }
+
+    MethodReferenceTestKindsBase(String val) {
+        this.val = val;
+    }
+
+    MethodReferenceTestKindsBase() {
+        this("blank");
+    }
+
+}
+
+class MethodReferenceTestKindsSup extends MethodReferenceTestKindsBase {
+    String instanceMethod0() { return "SIM:0-" + this; }
+    String instanceMethod1(MethodReferenceTestKinds x) { return "SIM:1-" + this + x; }
+
+    MethodReferenceTestKindsSup(String val) {
+        super(val);
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java
new file mode 100644
index 0000000..c2f377f
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNew.java
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestNew
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestNew {
+
+    interface M0<T> {
+
+        T m();
+    }
+
+    static class N0 {
+
+        N0() {
+        }
+    }
+
+    interface M1<T> {
+
+        T m(Integer a);
+    }
+
+    static class N1 {
+
+        int i;
+
+        N1(int i) {
+            this.i = i;
+        }
+    }
+
+    interface M2<T> {
+
+        T m(Integer n, String o);
+    }
+
+    static class N2 {
+
+        Number n;
+        Object o;
+
+        N2(Number n, Object o) {
+            this.n = n;
+            this.o = o;
+        }
+
+        public String toString() {
+            return "N2(" + n + "," + o + ")";
+        }
+    }
+
+    interface MV {
+
+        NV m(Integer ai, int i);
+    }
+
+    static class NV {
+
+        int i;
+
+        NV(int... v) {
+            i = 0;
+            for (int x : v) {
+                i += x;
+            }
+        }
+
+        public String toString() {
+            return "NV(" + i + ")";
+        }
+    }
+
+    public void testConstructorReference0() {
+        M0<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m().getClass().getSimpleName(), "N0");
+    }
+
+    public void testConstructorReference1() {
+        M1<N1> q;
+
+        q = N1::new;
+        assertEquals(q.m(14).getClass().getSimpleName(), "N1");
+    }
+
+    public void testConstructorReference2() {
+        M2<N2> q;
+
+        q = N2::new;
+        assertEquals(q.m(7, "hi").toString(), "N2(7,hi)");
+    }
+
+    public void testConstructorReferenceVarArgs() {
+        MV q;
+
+        q = NV::new;
+        assertEquals(q.m(5, 45).toString(), "NV(50)");
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java
new file mode 100644
index 0000000..9664957
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInner.java
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestNewInner
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestNewInner {
+
+    String note = "NO NOTE";
+
+    interface M0<T> {
+
+        T m();
+    }
+
+    interface MP<T> {
+
+        T m(MethodReferenceTestNewInner m);
+    }
+
+    class N0 {
+
+        N0() {
+        }
+    }
+
+    interface M1<T> {
+
+        T m(Integer a);
+    }
+
+    class N1 {
+
+        int i;
+
+        N1(int i) {
+            this.i = i;
+        }
+    }
+
+    interface M2<T> {
+
+        T m(Integer n, String o);
+    }
+
+    class N2 {
+
+        Number n;
+        Object o;
+
+        N2(Number n, Object o) {
+            this.n = n;
+            this.o = o;
+        }
+
+        public String toString() {
+            return note + ":N2(" + n + "," + o + ")";
+        }
+    }
+
+    interface MV {
+
+        NV m(Integer ai, int i);
+    }
+
+    class NV {
+
+        int i;
+
+        NV(int... v) {
+            i = 0;
+            for (int x : v) {
+                i += x;
+            }
+        }
+
+        public String toString() {
+            return note + ":NV(" + i + ")";
+        }
+    }
+
+/* unbound constructor case not supported anymore (dropped by EG)
+    public static void testConstructorReferenceP() {
+        MP<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m(new MethodReferenceTestNewInner()).getClass().getSimpleName(), "N0");
+    }
+*/
+    public void testConstructorReference0() {
+        M0<N0> q;
+
+        q = N0::new;
+        assertEquals(q.m().getClass().getSimpleName(), "N0");
+    }
+
+    public void testConstructorReference1() {
+        M1<N1> q;
+
+        q = N1::new;
+        assertEquals(q.m(14).getClass().getSimpleName(), "N1");
+    }
+
+    public void testConstructorReference2() {
+        M2<N2> q;
+
+        note = "T2";
+        q = N2::new;
+        assertEquals(q.m(7, "hi").toString(), "T2:N2(7,hi)");
+    }
+
+    /***
+    public void testConstructorReferenceVarArgs() {
+        MV q;
+
+        note = "TVA";
+        q = NV::new;
+        assertEquals(q.m(5, 45).toString(), "TNV:NV(50)");
+    }
+    ***/
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java
new file mode 100644
index 0000000..4f91057
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestNewInnerImplicitArgs.java
@@ -0,0 +1,82 @@
+/*
+ * 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 8011591
+ * @summary BootstrapMethodError when capturing constructor ref to local classes
+ * @run testng MethodReferenceTestNewInnerImplicitArgs
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Test the case that a constructor has implicit parameters added to
+ * access local variables and that this constructor is used in a
+ * method reference.
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestNewInnerImplicitArgs {
+
+
+    static class S {
+        String b;
+        S(String s, String s2) { b = s + s2; }
+    }
+
+    interface I {
+        S m();
+    }
+
+    interface I2 {
+        S m(int i, int j);
+    }
+
+    public static void testConstructorReferenceImplicitParameters() {
+        String title = "Hey";
+        String a2 = "!!!";
+        class MS extends S {
+            MS() {
+                super(title, a2);
+            }
+        }
+
+        I result = MS::new;
+        assertEquals(result.m().b, "Hey!!!");
+
+        class MS2 extends S {
+            MS2(int x, int y) {
+                super(title+x, a2+y);
+            }
+        }
+
+        I2 result2 = MS2::new;
+        assertEquals(result2.m(8, 4).b, "Hey8!!!4");
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java
new file mode 100644
index 0000000..2579f9a
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase1.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase1
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestSueCase1 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    String instanceMethod(String s) { return "2"; }
+    Sam2<MethodReferenceTestSueCase1> var = MethodReferenceTestSueCase1::instanceMethod;
+
+    String m() {  return var.get(new MethodReferenceTestSueCase1(), ""); }
+
+    public void testSueCase1() {
+        assertEquals(m(), "2");
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java
new file mode 100644
index 0000000..fefa3d2
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase2.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase2
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestSueCase2 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    String instanceMethod(String s) { return "2"; }
+    static Sam2<MethodReferenceTestSueCase2> var = MethodReferenceTestSueCase2::instanceMethod;
+
+    String m() {  return var.get(new MethodReferenceTestSueCase2(), ""); }
+
+    public void testSueCase2() {
+        assertEquals(m(), "2");
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java
new file mode 100644
index 0000000..7f3de0e
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSueCase4.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSueCase4
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestSueCase4 {
+
+    public interface Sam2<T> { public String get(T target, String s); }
+
+    Sam2<Target> var = new Object().equals(new Object()) ? Target::instanceMethod : Target::instanceMethod;
+
+    String m() {
+        return var.get(new Target(), "");
+    }
+
+    static class Target {
+        String instanceMethod(String s) { return "2"; }
+    }
+
+    public void testSueCase4() {
+        assertEquals(m(), "2");
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java
new file mode 100644
index 0000000..9449b26
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuper.java
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSuper
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface SPRI { String m(String a); }
+
+class SPRA {
+    String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    String xsA_M(String s) {
+        return "A_MxsA:" + s;
+    }
+
+    String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+    String xsABM(String s) {
+        return "ABMxsA:" + s;
+    }
+
+}
+
+class SPRB extends SPRA {
+
+    String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    String xsABM(String s) {
+        return "ABMxsB:" + s;
+    }
+
+    String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+
+    String xs_BM(String s) {
+        return "_BMxsB:" + s;
+    }
+
+}
+
+ at Test
+public class MethodReferenceTestSuper extends SPRB {
+
+    String xsA_M(String s) {
+        return "A_MxsM:" + s;
+    }
+
+
+    String xsABM(String s) {
+        return "ABMxsM:" + s;
+    }
+
+    String xs_BM(String s) {
+        return "_BMxsM:" + s;
+    }
+
+    public void testMethodReferenceSuper() {
+        SPRI q;
+
+        q = super::xsA__;
+        assertEquals(q.m("*"), "A__xsA:*");
+
+        q = super::xsA_M;
+        assertEquals(q.m("*"), "A_MxsA:*");
+
+        q = super::xsAB_;
+        assertEquals(q.m("*"), "AB_xsB:*");
+
+        q = super::xsABM;
+        assertEquals(q.m("*"), "ABMxsB:*");
+
+        q = super::xs_B_;
+        assertEquals(q.m("*"), "_B_xsB:*");
+
+        q = super::xs_BM;
+        assertEquals(q.m("*"), "_BMxsB:*");
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java
new file mode 100644
index 0000000..753bace
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestSuperDefault.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestSuperDefault
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface DSPRI { String m(String a); }
+
+interface DSPRA {
+    default String xsA__(String s) {
+        return "A__xsA:" + s;
+    }
+
+    default String xsAB_(String s) {
+        return "AB_xsA:" + s;
+    }
+
+}
+
+interface DSPRB extends DSPRA {
+
+    default String xsAB_(String s) {
+        return "AB_xsB:" + s;
+    }
+
+    default String xs_B_(String s) {
+        return "_B_xsB:" + s;
+    }
+
+}
+
+ at Test
+public class MethodReferenceTestSuperDefault implements DSPRB {
+
+    public void testMethodReferenceSuper() {
+        DSPRI q;
+
+        q = DSPRB.super::xsA__;
+        assertEquals(q.m("*"), "A__xsA:*");
+
+        q = DSPRB.super::xsAB_;
+        assertEquals(q.m("*"), "AB_xsB:*");
+
+        q = DSPRB.super::xs_B_;
+        assertEquals(q.m("*"), "_B_xsB:*");
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java
new file mode 100644
index 0000000..6fd6de4
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestTypeConversion.java
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestTypeConversion
+ */
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestTypeConversion_E<T> {
+    T xI(T t) { return t; }
+}
+
+ at Test
+public class MethodReferenceTestTypeConversion {
+
+    interface ISi { int m(Short a); }
+
+    interface ICc { char m(Character a); }
+
+    public void testUnboxObjectToNumberWiden() {
+        ISi q = (new MethodReferenceTestTypeConversion_E<Short>())::xI;
+        assertEquals(q.m((short)77), (short)77);
+    }
+
+    public void testUnboxObjectToChar() {
+        ICc q = (new MethodReferenceTestTypeConversion_E<Character>())::xI;
+        assertEquals(q.m('@'), '@');
+    }
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java
new file mode 100644
index 0000000..bd811df
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgs.java
@@ -0,0 +1,204 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgs
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+ at Test
+public class MethodReferenceTestVarArgs {
+
+    interface SII {
+
+        String m(Integer a, Integer b);
+    }
+
+    interface Siii {
+
+        String m(int a, int b, int c);
+    }
+
+    interface Si {
+
+        String m(int a);
+    }
+
+    interface SaO {
+
+        String m(Object[] a);
+    }
+
+    interface Sai {
+
+        String m(int[] a);
+    }
+
+    interface Svi {
+
+        String m(int... va);
+    }
+
+    // These should be processed as var args
+
+    static String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    static String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    static String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    static String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    static String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+    public void testVarArgsSuperclass() {
+        SII q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsArray() {
+        Sai q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsII() {
+        SII q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsiii() {
+        Siii q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsi() {
+        Si q;
+
+        q = MethodReferenceTestVarArgs::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = MethodReferenceTestVarArgs::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = MethodReferenceTestVarArgs::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = MethodReferenceTestVarArgs::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsaO() {
+        SaO q;
+
+        q = MethodReferenceTestVarArgs::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java
new file mode 100644
index 0000000..c515285
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsExt.java
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsExt
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface NXII { String m(Integer a, Integer b); }
+
+interface NXiii { String m(int a, int b, int c); }
+
+interface NXi { String m(int a); }
+
+interface NXaO { String m(Object[] a); }
+
+interface NXai { String m(int[] a); }
+
+interface NXvi { String m(int... va); }
+
+ at Test
+public class MethodReferenceTestVarArgsExt {
+
+    // These should be processed as var args
+
+    public void testVarArgsNXSuperclass() {
+        NXII q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsNXArray() {
+        NXai q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsNXII() {
+        NXII q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsNXiii() {
+        NXiii q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsNXi() {
+        NXi q;
+
+        q = (new Ext())::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = (new Ext())::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = (new Ext())::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = (new Ext())::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNXaO() {
+        NXaO q;
+
+        q = (new Ext())::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
+
+class Ext {
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java
new file mode 100644
index 0000000..88c4cd2
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuper.java
@@ -0,0 +1,207 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsSuper
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+class MethodReferenceTestVarArgsSuper_Sub {
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+}
+
+ at Test
+public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsSuper_Sub {
+
+    interface SPRII { String m(Integer a, Integer b); }
+
+    interface SPRiii { String m(int a, int b, int c); }
+
+    interface SPRi { String m(int a); }
+
+    interface SPRaO { String m(Object[] a); }
+
+    interface SPRai { String m(int[] a); }
+
+    interface SPRvi { String m(int... va); }
+
+    String xvI(Integer... vi) {
+        return "ERROR";
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        return "ERROR";
+    }
+
+    String xvi(int... vi) {
+        return "ERROR";
+    }
+
+    String xIvi(Integer f, int... vi) {
+        return "ERROR";
+   }
+
+    String xvO(Object... vi) {
+        return "ERROR";
+    }
+
+    // These should be processed as var args
+
+    public void testVarArgsSPRSuperclass() {
+        SPRII q;
+
+        q = super::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsSPRArray() {
+        SPRai q;
+
+        q = super::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsSPRII() {
+        SPRII q;
+
+        q = super::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = super::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = super::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = super::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsSPRiii() {
+        SPRiii q;
+
+        q = super::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = super::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = super::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = super::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsSPRi() {
+        SPRi q;
+
+        q = super::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = super::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = super::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = super::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsSPRaO() {
+        SPRaO q;
+
+        q = super::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java
new file mode 100644
index 0000000..6e00605
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsSuperDefault.java
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsSuperDefault
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface MethodReferenceTestVarArgsSuperDefault_I {
+
+    default String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    default String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    default String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    default String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    default String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+}
+
+ at Test
+public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTestVarArgsSuperDefault_I {
+
+    interface DSPRII { String m(Integer a, Integer b); }
+
+    interface DSPRiii { String m(int a, int b, int c); }
+
+    interface DSPRi { String m(int a); }
+
+    interface DSPRaO { String m(Object[] a); }
+
+    interface DSPRai { String m(int[] a); }
+
+    interface DSPRvi { String m(int... va); }
+
+    // These should be processed as var args
+
+    public void testVarArgsSPRSuperclass() {
+        DSPRII q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsSPRArray() {
+        DSPRai q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsSPRII() {
+        DSPRII q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsSPRiii() {
+        DSPRiii q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsSPRi() {
+        DSPRi q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsSPRaO() {
+        DSPRaO q;
+
+        q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
diff --git a/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java
new file mode 100644
index 0000000..9c5e0d6
--- /dev/null
+++ b/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceTestVarArgsThis.java
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8003639
+ * @summary convert lambda testng tests to jtreg and add them
+ * @run testng MethodReferenceTestVarArgsThis
+ */
+
+import org.testng.annotations.Test;
+import java.lang.reflect.Array;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * @author Robert Field
+ */
+
+interface NsII { String m(Integer a, Integer b); }
+
+interface Nsiii { String m(int a, int b, int c); }
+
+interface Nsi { String m(int a); }
+
+interface NsaO { String m(Object[] a); }
+
+interface Nsai { String m(int[] a); }
+
+interface Nsvi { String m(int... va); }
+
+ at Test
+public class MethodReferenceTestVarArgsThis {
+
+    // These should be processed as var args
+
+    String xvI(Integer... vi) {
+        StringBuilder sb = new StringBuilder("xvI:");
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xIvI(Integer f, Integer... vi) {
+        StringBuilder sb = new StringBuilder("xIvI:");
+        sb.append(f);
+        for (Integer i : vi) {
+            sb.append(i);
+            sb.append("-");
+        }
+        return sb.toString();
+    }
+
+    String xvi(int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xvi:" + sum;
+    }
+
+    String xIvi(Integer f, int... vi) {
+        int sum = 0;
+        for (int i : vi) {
+            sum += i;
+        }
+        return "xIvi:(" + f + ")" + sum;
+    }
+
+    String xvO(Object... vi) {
+        StringBuilder sb = new StringBuilder("xvO:");
+        for (Object i : vi) {
+            if (i.getClass().isArray()) {
+                sb.append("[");
+                int len = Array.getLength(i);
+                for (int x = 0; x < len; ++x)  {
+                    sb.append(Array.get(i, x));
+                    sb.append(",");
+                }
+                sb.append("]");
+
+            } else {
+                sb.append(i);
+            }
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+    public void testVarArgsNsSuperclass() {
+        NsII q;
+
+        q = this::xvO;
+        assertEquals(q.m(55,66), "xvO:55*66*");
+    }
+
+    public void testVarArgsNsArray() {
+        Nsai q;
+
+        q = this::xvO;
+        assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
+    }
+
+    public void testVarArgsNsII() {
+        NsII q;
+
+        q = this::xvI;
+        assertEquals(q.m(33,7), "xvI:33-7-");
+
+        q = this::xIvI;
+        assertEquals(q.m(50,40), "xIvI:5040-");
+
+        q = this::xvi;
+        assertEquals(q.m(100,23), "xvi:123");
+
+        q = this::xIvi;
+        assertEquals(q.m(9,21), "xIvi:(9)21");
+    }
+
+    public void testVarArgsNsiii() {
+        Nsiii q;
+
+        q = this::xvI;
+        assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
+
+        q = this::xIvI;
+        assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
+
+        q = this::xvi;
+        assertEquals(q.m(900,80,7), "xvi:987");
+
+        q = this::xIvi;
+        assertEquals(q.m(333,27, 72), "xIvi:(333)99");
+    }
+
+    public void testVarArgsNsi() {
+        Nsi q;
+
+        q = this::xvI;
+        assertEquals(q.m(3), "xvI:3-");
+
+        q = this::xIvI;
+        assertEquals(q.m(888), "xIvI:888");
+
+        q = this::xvi;
+        assertEquals(q.m(900), "xvi:900");
+
+        q = this::xIvi;
+        assertEquals(q.m(333), "xIvi:(333)0");
+    }
+
+    // These should NOT be processed as var args
+
+    public void testVarArgsNsaO() {
+        NsaO q;
+
+        q = this::xvO;
+        assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
+    }
+
+
+}
diff --git a/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java
new file mode 100644
index 0000000..dbd7d13
--- /dev/null
+++ b/test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java
@@ -0,0 +1,312 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8003280 8006694
+ * @summary Add lambda tests
+ *  Automatic test for checking correctness of structural most specific test routine
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm/timeout=600 StructuralMostSpecificTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+public class StructuralMostSpecificTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+
+    enum RetTypeKind {
+        SHORT("short"),
+        INT("int"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        VOID("void"),
+        J_L_VOID("Void");
+
+        String retTypeStr;
+
+        RetTypeKind(String retTypeStr) {
+            this.retTypeStr = retTypeStr;
+        }
+
+        boolean moreSpecificThan(RetTypeKind rk) {
+            return moreSpecificThan[this.ordinal()][rk.ordinal()];
+        }
+
+        static boolean[][] moreSpecificThan = {
+                //              SHORT |  INT  | OBJECT | INTEGER | VOID  | J_L_VOID
+                /* SHORT */   { true  , true  , true   , false   , false , false },
+                /* INT */     { false , true  , true   , true    , false , false },
+                /* OBJECT */  { false , false , true   , false   , false , false },
+                /* INTEGER */ { false , false , true   , true    , false , false },
+                /* VOID */    { false , false , false  , false   , true  , true  },
+                /* J_L_VOID */{ false , false , true   , false   , false , true  } };
+    }
+
+    enum ArgTypeKind {
+        SHORT("short"),
+        INT("int"),
+        BOOLEAN("boolean"),
+        OBJECT("Object"),
+        INTEGER("Integer"),
+        DOUBLE("Double");
+
+        String argTypeStr;
+
+        ArgTypeKind(String typeStr) {
+            this.argTypeStr = typeStr;
+        }
+    }
+
+    enum ExceptionKind {
+        NONE(""),
+        EXCEPTION("throws Exception"),
+        SQL_EXCEPTION("throws java.sql.SQLException"),
+        IO_EXCEPTION("throws java.io.IOException");
+
+        String exceptionStr;
+
+        ExceptionKind(String exceptionStr) {
+            this.exceptionStr = exceptionStr;
+        }
+    }
+
+    enum LambdaReturnKind {
+        VOID("return;"),
+        SHORT("return (short)0;"),
+        INT("return 0;"),
+        INTEGER("return (Integer)null;"),
+        NULL("return null;");
+
+        String retStr;
+
+        LambdaReturnKind(String retStr) {
+            this.retStr = retStr;
+        }
+
+        boolean compatibleWith(RetTypeKind rk) {
+            return compatibleWith[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] compatibleWith = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , true  , false   , false   , false },
+                /* INT */     { false , true  , true    , true    , false },
+                /* OBJECT */  { false , true  , true    , true    , true  },
+                /* INTEGER */ { false , false , true    , true    , true  },
+                /* VOID */    { true  , false , false   , false   , false },
+                /* J_L_VOID */{ false , false , false   , false   , true  } };
+
+        boolean needsConversion(RetTypeKind rk) {
+            return needsConversion[rk.ordinal()][ordinal()];
+        }
+
+        static boolean[][] needsConversion = {
+                //              VOID  | SHORT | INT     | INTEGER | NULL
+                /* SHORT */   { false , false , false   , false   , false },
+                /* INT */     { false , false , false   , true    , false },
+                /* OBJECT */  { false , true  , true    , false   , false },
+                /* INTEGER */ { false , false , true    , false   , false },
+                /* VOID */    { false , false , false   , false   , false },
+                /* J_L_VOID */{ true  , false , false   , false   , false } };
+    }
+
+    public static void main(String... args) throws Exception {
+        for (LambdaReturnKind lrk : LambdaReturnKind.values()) {
+            for (RetTypeKind rk1 : RetTypeKind.values()) {
+                for (RetTypeKind rk2 : RetTypeKind.values()) {
+                    for (ExceptionKind ek1 : ExceptionKind.values()) {
+                        for (ExceptionKind ek2 : ExceptionKind.values()) {
+                            for (ArgTypeKind ak11 : ArgTypeKind.values()) {
+                                for (ArgTypeKind ak12 : ArgTypeKind.values()) {
+                                    pool.execute(
+                                        new StructuralMostSpecificTest(lrk, rk1,
+                                            rk2, ek1, ek2, ak11, ak12));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec();
+    }
+
+    LambdaReturnKind lrk;
+    RetTypeKind rt1, rt2;
+    ArgTypeKind ak1, ak2;
+    ExceptionKind ek1, ek2;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    StructuralMostSpecificTest(LambdaReturnKind lrk, RetTypeKind rt1, RetTypeKind rt2,
+            ExceptionKind ek1, ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
+        this.lrk = lrk;
+        this.rt1 = rt1;
+        this.rt2 = rt2;
+        this.ek1 = ek1;
+        this.ek2 = ek2;
+        this.ak1 = ak1;
+        this.ak2 = ak2;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "interface SAM1 {\n" +
+                          "   #R1 m(#A1 a1) #E1;\n" +
+                          "}\n" +
+                          "interface SAM2 {\n" +
+                          "   #R2 m(#A2 a1) #E2;\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                          "   void m(SAM1 s) { }\n" +
+                          "   void m(SAM2 s) { }\n" +
+                          "   { m(x->{ #LR }); }\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#LR", lrk.retStr)
+                    .replaceAll("#R1", rt1.retTypeStr)
+                    .replaceAll("#R2", rt2.retTypeStr)
+                    .replaceAll("#A1", ak1.argTypeStr)
+                    .replaceAll("#A2", ak2.argTypeStr)
+                    .replaceAll("#E1", ek1.exceptionStr)
+                    .replaceAll("#E2", ek2.exceptionStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
+                Arrays.asList("-XDverboseResolution=all,-predef,-internal,-object-init"),
+                null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new
+                AssertionError("Error thron when analyzing the following source:\n" +
+                    source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount.incrementAndGet();
+
+        if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2))
+            return;
+
+        if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2))
+            return;
+
+        boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2);
+        boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1);
+
+        boolean ambiguous = (m1MoreSpecific == m2MoreSpecific);
+
+        if (ambiguous != diagChecker.ambiguityFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nAmbiguity found: " + diagChecker.ambiguityFound +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific +
+                "\nexpected ambiguity: " + ambiguous);
+        }
+
+        if (!ambiguous) {
+            String sigToCheck = m1MoreSpecific ? "m(SAM1)" : "m(SAM2)";
+            if (!sigToCheck.equals(diagChecker.mostSpecificSig)) {
+                throw new Error("invalid most specific method selected:\n" +
+                source.getCharContent(true) +
+                "\nMost specific found: " + diagChecker.mostSpecificSig +
+                "\nm1 more specific: " + m1MoreSpecific +
+                "\nm2 more specific: " + m2MoreSpecific);
+            }
+        }
+    }
+
+    boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1,
+            ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
+        if (!rk1.moreSpecificThan(rk2))
+            return false;
+
+        if (ak1 != ak2)
+            return false;
+
+        return true;
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean ambiguityFound;
+        String mostSpecificSig;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            try {
+                if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                        diagnostic.getCode().equals("compiler.err.ref.ambiguous")) {
+                    ambiguityFound = true;
+                } else if (diagnostic.getKind() == Diagnostic.Kind.NOTE &&
+                        diagnostic.getCode()
+                        .equals("compiler.note.verbose.resolve.multi")) {
+                    ClientCodeWrapper.DiagnosticSourceUnwrapper dsu =
+                        (ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic;
+                    JCDiagnostic.MultilineDiagnostic mdiag =
+                        (JCDiagnostic.MultilineDiagnostic)dsu.d;
+                    int mostSpecificIndex = (Integer)mdiag.getArgs()[2];
+                    mostSpecificSig =
+                        ((JCDiagnostic)mdiag.getSubdiagnostics()
+                            .get(mostSpecificIndex)).getArgs()[1].toString();
+                }
+            } catch (RuntimeException t) {
+                t.printStackTrace();
+                throw t;
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/lambda/separate/Foo.java b/test/tools/javac/lambda/separate/Foo.java
new file mode 100644
index 0000000..506f532
--- /dev/null
+++ b/test/tools/javac/lambda/separate/Foo.java
@@ -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.
+ */
+interface Foo<X extends Number> {
+    void m(X x);
+}
+
+class FooLib {
+    void m1(Foo<?> uf) { }
+    void m2(Foo<? extends Object> uf) { }
+}
diff --git a/test/tools/javac/lambda/separate/Test.java b/test/tools/javac/lambda/separate/Test.java
new file mode 100644
index 0000000..7aa6b2c
--- /dev/null
+++ b/test/tools/javac/lambda/separate/Test.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @compile Foo.java
+ * @compile Test.java
+ */
+class Test {
+    void test(FooLib fl) {
+        fl.m1(x->{});
+        fl.m2(x->{});
+    }
+}
diff --git a/test/tools/javac/lambda/speculative/A.java b/test/tools/javac/lambda/speculative/A.java
new file mode 100644
index 0000000..da3436e
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/A.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+public class A {
+    public A(NonExistentClass nec) {}
+}
diff --git a/test/tools/javac/lambda/speculative/DiamondFinder.java b/test/tools/javac/lambda/speculative/DiamondFinder.java
new file mode 100644
index 0000000..35f56af
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/DiamondFinder.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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 8003280
+ * @summary Add lambda tests
+ *  spurious crashes when running in 'diamond finder' mode
+ * @compile -XDfindDiamond DiamondFinder.java
+ */
+import java.util.*;
+
+class DiamondFinder {
+    Collection<String> f = new HashSet<String>(Arrays.asList("a"));
+}
diff --git a/test/tools/javac/lambda/speculative/Main.java b/test/tools/javac/lambda/speculative/Main.java
new file mode 100644
index 0000000..cf37949
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/Main.java
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  On-demand symbol completion during speculative attribution round fails to report error messages
+ * @compile/fail/ref=Main.out -XDrawDiagnostics Main.java
+ */
+class Main {
+    void test() {
+        m(new A(new Object()));
+        m(new A(null));
+    }
+
+    void m(Object o) {}
+}
diff --git a/test/tools/javac/lambda/speculative/Main.out b/test/tools/javac/lambda/speculative/Main.out
new file mode 100644
index 0000000..91348ae
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/Main.out
@@ -0,0 +1,2 @@
+A.java:25:14: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, A, null)
+1 error
diff --git a/test/tools/javac/lambda/speculative/MissingError.java b/test/tools/javac/lambda/speculative/MissingError.java
new file mode 100644
index 0000000..9027462
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/MissingError.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8008276
+ * @summary assertion error in com.sun.tools.javac.comp.TransTypes.visitApply
+ * @compile/fail/ref=MissingError.out -XDrawDiagnostics MissingError.java
+ */
+class MissingError {
+    void test() {
+       mtest(new Bad(){ Integer i = ""; });
+    }
+
+    void mtest(Bad t){ }
+}
+
+class Bad {
+    String s = 1;
+}
diff --git a/test/tools/javac/lambda/speculative/MissingError.out b/test/tools/javac/lambda/speculative/MissingError.out
new file mode 100644
index 0000000..9e93bc8
--- /dev/null
+++ b/test/tools/javac/lambda/speculative/MissingError.out
@@ -0,0 +1,3 @@
+MissingError.java:16:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.String)
+MissingError.java:9:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
+2 errors
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest11.java b/test/tools/javac/lambda/typeInference/InferenceTest11.java
new file mode 100644
index 0000000..402b1c1
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest11.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *   This test is for self referential and recursive lambda expression that have type inference
+ * @compile InferenceTest11.java
+ * @run main InferenceTest11
+ */
+
+public class InferenceTest11 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    static Func<Integer, Integer> f1;
+    static Func<Integer, ? extends Number> f2;
+
+    public static void main(String[] args) {
+
+        f1 = n -> {
+            if(n <= 0)
+                return 0;
+            if(n == 1)
+                return 1;
+            return f1.m(n-1) + f1.m(n-2);
+        };
+        assertTrue(f1.m(-1) == 0);
+        assertTrue(f1.m(0) == 0);
+        assertTrue(f1.m(10) == 55);
+
+        f2 = n -> {
+            if(n <= 1)
+            return 1.0;
+            return 2 * (Double)f2.m(n-1) + 1;
+        };
+        assertTrue(f2.m(4).doubleValue() == 15.0);
+    }
+
+    interface Func<T, V> {
+        V m(T t);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest2.java b/test/tools/javac/lambda/typeInference/InferenceTest2.java
new file mode 100644
index 0000000..6fe90b9
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest2.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2011, 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.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.io.Serializable;
+import java.io.File;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics without wildcard
+ * @compile InferenceTest2.java
+ * @run main InferenceTest2
+ */
+
+public class InferenceTest2 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2 test = new InferenceTest2();
+
+        //test SAM1<T>
+        SAM1<String> sam1 = para -> { String result = "";
+                                      for(String s : para)
+                                          if(s.compareTo(result) > 0)
+                                              result = s;
+                                      return result; };
+        List<String> list = Arrays.asList("a", "b", "c");
+        assertTrue(sam1.m1(list).equals("c"));
+
+        test.method1(para -> para.get(0));
+
+        //test SAM2<T>
+        SAM2<String> sam2 = para -> {para = para.substring(0);};
+        SAM2<Double> sam2_2 = para -> {};
+        SAM2<File> sam2_3 = para -> { if(para.isDirectory())
+                                          System.out.println("directory");
+                                    };
+
+        //test SAM3<T>
+        SAM3<String> sam3 = para -> para[0].substring(0, para[0].length()-1);
+        assertTrue(sam3.m3("hello+").equals("hello"));
+
+        SAM3<Integer> sam3_2 = para -> para[0] - para[1];
+        assertTrue(sam3_2.m3(1, -1) == 2);
+
+        SAM3<Double> sam3_3 = para -> para[0] + para[1] + para[2] + para[3];
+        assertTrue(sam3_3.m3(1.0, 2.0, 3.0, 4.0) == 10.0);
+
+        test.method3(para -> para[0] + 1);
+
+        //test SAM6<T>
+        SAM6<String> sam6 = (para1, para2) -> para1.concat(para2);
+        assertTrue(sam6.m6("hello", "world").equals("helloworld"));
+
+        test.method6((para1, para2) -> para1 >= para2? para1 : para2);
+    }
+
+    void method1(SAM1<Integer> sam1) {
+        List<Integer> list = Arrays.asList(3,2,1);
+        assertTrue(sam1.m1(list) == 3);
+    }
+
+    void method3(SAM3<Double> sam3) {
+        assertTrue(sam3.m3(2.5) == 3.5);
+    }
+
+    void method6(SAM6<Long> sam6) {
+        assertTrue(sam6.m6(5L, -5L) == 5);
+    }
+
+    interface SAM1<T> {
+        T m1(List<T> x);
+    }
+
+    interface SAM2<T extends Serializable> {
+        void m2(T x);
+    }
+
+    interface SAM3<T> {
+        T m3(T... x);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest2b.java b/test/tools/javac/lambda/typeInference/InferenceTest2b.java
new file mode 100644
index 0000000..2dbe880
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest2b.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, 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.util.*;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Parameter types inferred from target type in generics with wildcard
+ * @compile InferenceTest2b.java
+ * @run main InferenceTest2b
+ */
+
+public class InferenceTest2b {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+
+        InferenceTest2b test = new InferenceTest2b();
+
+        test.m1((a, b) -> {return a;});
+        test.m2((a, b) -> {return a;});
+        test.m3((a, b) -> a);
+    }
+
+    interface SAM6<T> {
+        T m6(T a, T b);
+    }
+
+    void m1(SAM6<? super List<?>> s) {
+        System.out.println("m1()");
+        Stack<String> a = new Stack<String>();
+        ArrayList<String> b = new ArrayList<String>();
+        assertTrue(s.m6(a, b) == a);
+
+        Vector<?> c = null;
+        assertTrue(s.m6(c, b) == c);
+    }
+
+    void m2(SAM6<? super Integer> s) {
+        System.out.println("m2()");
+        assertTrue(s.m6(1, 2).equals(Integer.valueOf(1)));
+    }
+
+    void m3(SAM6<? super Calendar> s) {
+        System.out.println("m3()");
+        Calendar gc = Calendar.getInstance();
+        GregorianCalendar gc2 = new GregorianCalendar();
+        assertTrue(s.m6(gc, gc2) == gc);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest3.java b/test/tools/javac/lambda/typeInference/InferenceTest3.java
new file mode 100644
index 0000000..b5ea9b6
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest3.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  Interface inheritance, sub-interface resolves the type of the super interface.
+ * @compile InferenceTest3.java
+ * @run main InferenceTest3
+ */
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+public class InferenceTest3 {
+
+    private static void assertTrue(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest3 test = new InferenceTest3();
+        test.m1(a -> a.getTime());
+        test.m2(a -> a.toString());
+
+        C<String, Integer> c = a -> a.length();
+        assertTrue(c.m("lambda") == 6);
+
+        E<Double, String> e = a -> Double.toHexString(a);
+        assertTrue(e.m(Double.MAX_VALUE).equals("0x1.fffffffffffffp1023"));
+        assertTrue(e.m(Double.MIN_VALUE).equals("0x0.0000000000001p-1022"));
+        assertTrue(e.m(1.0).equals("0x1.0p0"));
+    }
+
+    private void m1(C<Date, Long> c) {
+        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+        cal.set(1970, 0, 1, 0, 0, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        Date date = cal.getTime();
+        assertTrue(c.m(date) == 0L);
+    }
+
+    private void m2(E<Integer, String> e) {
+        assertTrue(e.m(2).equals("2"));
+    }
+
+    interface A<T extends Serializable, U> {
+        U m(T t);
+    }
+
+    interface C<X extends Serializable, Y extends Number> extends A<X,Y> {}
+
+    interface E<X extends Serializable, Y extends String> extends A<X,Y> {}
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest4.java b/test/tools/javac/lambda/typeInference/InferenceTest4.java
new file mode 100644
index 0000000..477f578
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest4.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  This test is for generic methods whose type is the same as the type
+            of the generic SAM interface that is taken as the parameter of the
+            generic method; the type can be inferred from the value of the other
+            type arguments
+ * @compile InferenceTest4.java
+ * @run main InferenceTest4
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class InferenceTest4 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest4 test = new InferenceTest4();
+        test.method1(n -> n.size(), "abc", "java.lang.String");
+        test.method1(n -> n.size(), 'c', "java.lang.Character");
+        test.method1(n -> n.size(), 0, "java.lang.Integer");
+        test.method1(n -> n.size(), 0.1, "java.lang.Double");
+        test.method1(n -> n.size(), 0.1f, "java.lang.Float");
+        test.method1(n -> n.size(), 0L, "java.lang.Long");
+        test.method1(n -> n.size(), (short)0, "java.lang.Short");
+        test.method1(n -> n.size(), (byte)0, "java.lang.Byte");
+        test.method1(n -> n.size(), true, "java.lang.Boolean");
+        test.method1(n -> n.size(), new int[]{1, 2, 3}, "[I");
+        test.method1(n -> n.size(), new double[]{1.0}, "[D");
+        test.method1(n -> n.size(), new String[]{}, "[Ljava.lang.String;");
+    }
+
+    <T> void method1(SAM1<T> s, T t, String className) {
+        List<T> list = new ArrayList<T>();
+        System.out.println(className + "-" + t.getClass().getName());
+        assertTrue(t.getClass().getName().equals(className));
+        list.add(t);
+        assertTrue(s.m1(list) == 1);
+    }
+
+    interface SAM1<T> {
+        int m1(List<T> x);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest5.java b/test/tools/javac/lambda/typeInference/InferenceTest5.java
new file mode 100644
index 0000000..2910680
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest5.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, 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 8003280
+ * @summary Add lambda tests
+ *  This test is for overloaded methods, verify that the specific method is
+             selected when type inference occurs
+ * @compile InferenceTest5.java
+ * @run main InferenceTest5
+ */
+
+import java.util.List;
+import java.io.File;
+
+public class InferenceTest5 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest5 test = new InferenceTest5();
+        int n = test.method1((a, b) -> {} );
+        assertTrue(n == 1);
+
+        n = test.method1(() -> null);
+        assertTrue(n == 2);
+
+        n = test.method1(a -> null);
+        assertTrue(n == 3);
+
+        n = test.method1(a -> {});
+        assertTrue(n == 4);
+
+        n = test.method1(() -> {});
+        assertTrue(n == 5);
+
+        n = test.method1((a, b) -> 0);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null);
+        assertTrue(n == 6);
+
+        n = test.method1((a, b) -> null, (a, b) -> null);
+        assertTrue(n == 7);
+    }
+
+    int method1(SAM1<String> s) {
+        return 1;
+    }
+
+    int method1(SAM2 s) {
+        return 2;
+    }
+
+    int method1(SAM3 s) {
+        return 3;
+    }
+
+    int method1(SAM4 s) {
+        return 4;
+    }
+
+    int method1(SAM5 s) {
+        return 5;
+    }
+
+    int method1(SAM6<?, ? super Integer> s) {
+        return 6;
+    }
+
+    int method1(SAM6<?, ?>... s) {
+        return 7;
+    }
+
+    static interface SAM1<T> {
+        void foo(List<T> a, List<T> b);
+    }
+
+    static interface SAM2 {
+        List<String> foo();
+    }
+
+    static interface SAM3 {
+        String foo(int a);
+    }
+
+    static interface SAM4 {
+        void foo(List<File> a);
+    }
+
+    static interface SAM5 {
+        void foo();
+    }
+
+    static interface SAM6<T, V> {
+        V get(T t, T t2);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest789.java b/test/tools/javac/lambda/typeInference/InferenceTest789.java
new file mode 100644
index 0000000..6bc0016
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest789.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, 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.io.Serializable;
+import java.util.Calendar;
+
+/**
+ * @test
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  This test is for when lambda return type is inferred from target type
+ * @compile InferenceTest789.java
+ * @run main InferenceTest789
+ */
+
+public class InferenceTest789 {
+
+    private static void assertTrue(boolean b) {
+        if(!b)
+            throw new AssertionError();
+    }
+
+    public static void main(String[] args) {
+        InferenceTest789 test = new InferenceTest789();
+        test.method1(() -> 1);
+        SAM1<? extends Number> sam1 = () -> 1.0;
+        SAM1<? extends Serializable> sam1_2 = () -> "a";
+        SAM1<? extends Comparable<?>> sam1_3 = () -> Calendar.getInstance();
+        SAM1<?> sam1_4 = () -> 1.5f;
+
+        SAM2<Number> sam2 = a -> 1;
+        SAM2<? extends Serializable> sam2_2 = a -> 1;
+    }
+
+    void method1(SAM1<?> s) {
+        System.out.println("s.m1()=" + s.m1() + " s.m1().getClass()=" + s.m1().getClass());
+          assertTrue(s.m1().equals(new Integer(1)));
+    }
+
+    interface SAM1<T> {
+        T m1();
+    }
+
+    interface SAM2<T extends Serializable> {
+        T m2(T t);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java b/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java
new file mode 100644
index 0000000..3d77c95
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.java
@@ -0,0 +1,58 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *   Overloaded methods take raw SAM types that have type inference according to SAM descriptor
+             should have ambiguous resolution of method
+ * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java
+ */
+
+public class InferenceTest_neg1_2 {
+
+    public static void main(String[] args) {
+        InferenceTest_neg1_2 test = new InferenceTest_neg1_2();
+        test.method(n -> null); //method 1-5 all match
+        test.method(n -> "a"); //method 2, 4 match
+        test.method(n -> 0); //method 1, 3, 5 match
+    }
+
+    void method(SAM1 s) { //method 1
+        Integer i = s.foo("a");
+    }
+
+    void method(SAM2 s) { //method 2
+        String str = s.foo(0);
+    }
+
+    void method(SAM3<Integer> s) { //method 3
+        Integer i = s.get(0);
+    }
+
+    void method(SAM4<Double, String> s) { //method 4
+        String str = s.get(0.0);
+    }
+
+    void method(SAM5<Integer> s) { //method 5
+        Integer i = s.get(0.0);
+    }
+
+    interface SAM1 {
+        Integer foo(String a);
+    }
+
+    interface SAM2 {
+        String foo(Integer a);
+    }
+
+    interface SAM3<T> {
+        T get(T t);
+    }
+
+    interface SAM4<T, V> {
+        V get(T t);
+    }
+
+    interface SAM5<T> {
+        T get(Double i);
+    }
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out b/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out
new file mode 100644
index 0000000..cf0d1d5
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest_neg1_2.out
@@ -0,0 +1,4 @@
+InferenceTest_neg1_2.java:14:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:15:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM2), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM4<java.lang.Double,java.lang.String>), InferenceTest_neg1_2
+InferenceTest_neg1_2.java:16:13: compiler.err.ref.ambiguous: method, kindname.method, method(InferenceTest_neg1_2.SAM3<java.lang.Integer>), InferenceTest_neg1_2, kindname.method, method(InferenceTest_neg1_2.SAM5<java.lang.Integer>), InferenceTest_neg1_2
+3 errors
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java b/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java
new file mode 100644
index 0000000..d5f757e
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest_neg5.java
@@ -0,0 +1,26 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8003280
+ * @summary Add lambda tests
+ *  Missing cast to SAM type that causes type inference to not work.
+ * @compile/fail/ref=InferenceTest_neg5.out -XDrawDiagnostics InferenceTest_neg5.java
+ */
+
+import java.util.*;
+
+public class InferenceTest_neg5 {
+    public static void main(String[] args) {
+        InferenceTest_neg5 test = new InferenceTest_neg5();
+        test.method1(n -> {});
+        test.method1((SAM1<String>)n -> {});
+        test.method1((SAM1<Integer>)n -> {n++;});
+        test.method1((SAM1<Comparator<String>>)n -> {List<String> list = Arrays.asList("string1", "string2"); Collections.sort(list,n);});
+        test.method1((SAM1<Thread>)n -> {n.start();});
+    }
+
+    interface SAM1<X> {
+        void m1(X arg);
+    }
+
+    <X> void method1(SAM1<X> s) {}
+}
diff --git a/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out b/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out
new file mode 100644
index 0000000..7f64725
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/InferenceTest_neg5.out
@@ -0,0 +1,2 @@
+InferenceTest_neg5.java:14:21: compiler.err.prob.found.req: (compiler.misc.cyclic.inference: X)
+1 error
diff --git a/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java b/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java
new file mode 100644
index 0000000..9399eb7
--- /dev/null
+++ b/test/tools/javac/lambda/typeInference/combo/TypeInferenceComboTest.java
@@ -0,0 +1,397 @@
+/*
+ * 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
+ * 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 8003280 8006694
+ * @summary Add lambda tests
+ *  perform automated checks in type inference in lambda expressions
+ *  in different contexts
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @compile  TypeInferenceComboTest.java
+ * @run main/othervm/timeout=360 TypeInferenceComboTest
+ */
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import com.sun.source.util.JavacTask;
+
+public class TypeInferenceComboTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
+    enum Context {
+        ASSIGNMENT("SAM#Type s = #LBody;"),
+        METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" +
+                    "void method2() {\n" +
+                    "    method1(#LBody);\n" +
+                    "}"),
+        RETURN_OF_METHOD("SAM#Type method1() {\n" +
+                "    return #LBody;\n" +
+                "}"),
+        LAMBDA_RETURN_EXPRESSION("SAM2 s2 = () -> {return (SAM#Type)#LBody;};\n"),
+        ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (SAM#Type)#LBody};");
+
+        String context;
+
+        Context(String context) {
+            this.context = context;
+        }
+
+        String getContext(SamKind sk, TypeKind samTargetT, Keyword kw,
+                TypeKind parameterT, TypeKind returnT, LambdaKind lk,
+                ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) {
+            String result = context;
+            if (sk == SamKind.GENERIC) {
+                if(this == Context.METHOD_CALL) {
+                    result = result.replaceAll("#GenericDeclKind",
+                            gdk.getGenericDeclKind(samTargetT));
+                    if(gdk == GenericDeclKind.NON_GENERIC)
+                        result = result.replaceAll("#Type", "<" +
+                                samTargetT.typeStr + ">");
+                    else //#GenericDeclKind is <T> or <T extends xxx>
+                        result = result.replaceAll("#Type", "<T>");
+                }
+                else {
+                    if(kw == Keyword.VOID)
+                        result = result.replaceAll("#Type", "<" +
+                                samTargetT.typeStr + ">");
+                    else
+                        result = result.replaceAll("#Type", "<? " + kw.keyStr +
+                                " " + samTargetT.typeStr + ">");
+                }
+            }
+            else
+                result = result.replaceAll("#Type", "").
+                        replaceAll("#GenericDeclKind", "");
+
+            return result.replaceAll("#LBody",
+                    lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk));
+        }
+    }
+
+    enum SamKind {
+        GENERIC("interface SAM<T> { #R m(#ARG); }"),
+        NON_GENERIC("interface SAM { #R m(#ARG); }");
+
+        String sam_str;
+
+        SamKind(String sam_str) {
+            this.sam_str = sam_str;
+        }
+
+        String getSam(TypeKind parameterT, TypeKind returnT) {
+            return sam_str.replaceAll("#ARG",
+                    parameterT == TypeKind.VOID ?
+                        "" : parameterT.typeStr + " arg")
+                    .replaceAll("#R", returnT.typeStr);
+        }
+    }
+
+    enum TypeKind {
+        VOID("void", ""),
+        STRING("String", "\"hello\""),
+        INTEGER("Integer", "1"),
+        INT("int", "0"),
+        COMPARATOR("java.util.Comparator<String>",
+                "(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"),
+        SAM("SAM2", "null"),
+        GENERIC("T", null);
+
+        String typeStr;
+        String valStr;
+
+        TypeKind(String typeStr, String valStr) {
+            this.typeStr = typeStr;
+            this.valStr = valStr;
+        }
+    }
+
+    enum LambdaKind {
+        EXPRESSION("#VAL"),
+        STATEMENT("{return #VAL;}");
+
+        String stmt;
+
+        LambdaKind(String stmt) {
+            this.stmt = stmt;
+        }
+    }
+
+    enum ParameterKind {
+        EXPLICIT("#TYPE"),
+        IMPLICIT("");
+
+        String paramTemplate;
+
+        ParameterKind(String paramTemplate) {
+             this.paramTemplate = paramTemplate;
+        }
+    }
+
+    enum Keyword {
+        SUPER("super"),
+        EXTENDS("extends"),
+        VOID("");
+
+        String keyStr;
+
+        Keyword(String keyStr) {
+            this.keyStr = keyStr;
+        }
+    }
+
+    enum LambdaBody {
+        //no parameters, return type is one of the TypeKind
+        RETURN_VOID("() -> #RET"),
+        //has parameters, return type is one of the TypeKind
+        RETURN_ARG("(#PK arg) -> #RET");
+
+        String bodyStr;
+
+        LambdaBody(String bodyStr) {
+            this.bodyStr = bodyStr;
+        }
+
+        String getLambdaBody(TypeKind samTargetT, TypeKind parameterT,
+                TypeKind returnT, LambdaKind lk, ParameterKind pk) {
+            String result = bodyStr.replaceAll("#PK", pk.paramTemplate);
+
+            if(result.contains("#TYPE")) {
+                if (parameterT == TypeKind.GENERIC && this != RETURN_VOID)
+                    result = result.replaceAll("#TYPE",
+                            samTargetT == null? "": samTargetT.typeStr);
+                else
+                    result = result.replaceAll("#TYPE", parameterT.typeStr);
+            }
+            if (this == RETURN_ARG && parameterT == returnT)
+                return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg"));
+            else {
+                if(returnT != TypeKind.GENERIC)
+                    return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL",
+                            (returnT==TypeKind.VOID &&
+                            lk==LambdaKind.EXPRESSION) ? "{}" : returnT.valStr));
+                else
+                    return result.replaceAll("#RET",
+                            lk.stmt.replaceAll("#VAL", samTargetT.valStr));
+            }
+        }
+    }
+
+    enum GenericDeclKind {
+        NON_GENERIC(""),
+        GENERIC_NOBOUND("<T>"),
+        GENERIC_BOUND("<T extends #ExtendedType>");
+        String typeStr;
+
+        GenericDeclKind(String typeStr) {
+            this.typeStr = typeStr;
+        }
+
+        String getGenericDeclKind(TypeKind et) {
+            return typeStr.replaceAll("#ExtendedType", et==null? "":et.typeStr);
+        }
+    }
+
+    boolean checkTypeInference() {
+        if (parameterType == TypeKind.VOID) {
+            if (lambdaBodyType != LambdaBody.RETURN_VOID)
+                return false;
+        }
+        else if (lambdaBodyType != LambdaBody.RETURN_ARG)
+            return false;
+        if (  genericDeclKind == GenericDeclKind.GENERIC_NOBOUND ||
+                genericDeclKind == GenericDeclKind.GENERIC_BOUND ) {
+            if ( parameterType == TypeKind.GENERIC &&
+                    parameterKind == ParameterKind.IMPLICIT) //cyclic inference
+                return false;
+        }
+        return true;
+    }
+
+    String templateStr = "#C\n" +
+                         "interface SAM2 {\n" +
+                         "    SAM m();\n" +
+                         "}\n";
+    SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) {
+        public String toString() {
+            return template.replaceAll("#C",
+                    samKind.getSam(parameterType, returnType));
+        }
+    };
+
+    SourceFile clientSourceFile = new SourceFile("Client.java",
+                                                 "class Client { \n" +
+                                                 "    #Context\n" +
+                                                 "}") {
+        public String toString() {
+            return template.replaceAll("#Context",
+                    context.getContext(samKind, samTargetType, keyword,
+                    parameterType, returnType, lambdaKind, parameterKind,
+                    genericDeclKind, lambdaBodyType));
+        }
+    };
+
+    public void run() {
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), dc,
+                null, null, Arrays.asList(samSourceFile, clientSourceFile));
+        try {
+            ct.analyze();
+        } catch (Throwable t) {
+            processException(t);
+        }
+        if (dc.errorFound == checkTypeInference()) {
+            throw new AssertionError(samSourceFile + "\n\n" +
+                    clientSourceFile + "\n" + parameterType + " " + returnType);
+        }
+    }
+
+    abstract class SourceFile extends SimpleJavaFileObject {
+
+        protected String template;
+
+        public SourceFile(String filename, String template) {
+            super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE);
+            this.template = template;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public abstract String toString();
+    }
+
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+
+    SamKind samKind;
+    TypeKind samTargetType;
+    TypeKind parameterType;
+    TypeKind returnType;
+    Context context;
+    LambdaBody lambdaBodyType;
+    LambdaKind lambdaKind;
+    ParameterKind parameterKind;
+    Keyword keyword;
+    GenericDeclKind genericDeclKind;
+
+    TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT,
+            TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk,
+            ParameterKind pk, Keyword kw, GenericDeclKind gdk) {
+        samKind = sk;
+        samTargetType = samTargetT;
+        parameterType = parameterT;
+        returnType = returnT;
+        context = c;
+        lambdaKind = lk;
+        parameterKind = pk;
+        keyword = kw;
+        lambdaBodyType = lb;
+        genericDeclKind = gdk;
+    }
+
+    public static void main(String[] args) throws Exception {
+        for(Context ct : Context.values()) {
+            for (TypeKind returnT : TypeKind.values()) {
+                for (TypeKind parameterT : TypeKind.values()) {
+                    for(LambdaBody lb : LambdaBody.values()) {
+                        for (ParameterKind parameterK : ParameterKind.values()) {
+                            for(LambdaKind lambdaK : LambdaKind.values()) {
+                                for (SamKind sk : SamKind.values()) {
+                                    if (sk == SamKind.NON_GENERIC) {
+                                        generateNonGenericSAM(ct, returnT,
+                                                parameterT, lb, parameterK,
+                                                lambdaK, sk);
+                                    }
+                                    else if (sk == SamKind.GENERIC) {
+                                        generateGenericSAM(ct, returnT,
+                                                parameterT, lb, parameterK,
+                                                lambdaK, sk);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        checkAfterExec(false);
+    }
+
+    static void generateNonGenericSAM(Context ct, TypeKind returnT,
+            TypeKind parameterT, LambdaBody lb, ParameterKind parameterK,
+            LambdaKind lambdaK, SamKind sk) {
+        if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC ) {
+            pool.execute(new TypeInferenceComboTest(sk, null, parameterT,
+                    returnT, lb, ct, lambdaK, parameterK, null, null));
+        }
+    }
+
+    static void generateGenericSAM(Context ct, TypeKind returnT,
+            TypeKind parameterT, LambdaBody lb, ParameterKind parameterK,
+            LambdaKind lambdaK, SamKind sk) {
+        for (Keyword kw : Keyword.values()) {
+            for (TypeKind samTargetT : TypeKind.values()) {
+                if(samTargetT != TypeKind.VOID &&
+                   samTargetT != TypeKind.INT &&
+                   samTargetT != TypeKind.GENERIC &&
+                   (parameterT == TypeKind.GENERIC ||
+                   returnT == TypeKind.GENERIC)) {
+                    if(ct != Context.METHOD_CALL) {
+                        pool.execute(
+                            new TypeInferenceComboTest(sk, samTargetT, parameterT,
+                                returnT, lb, ct, lambdaK, parameterK, kw, null));
+                    } else {//Context.METHOD_CALL
+                        for (GenericDeclKind gdk :
+                                GenericDeclKind.values())
+                            pool.execute(
+                                    new TypeInferenceComboTest(sk, samTargetT,
+                                    parameterT, returnT, lb, ct, lambdaK,
+                                    parameterK, kw, gdk));
+                    }
+                }
+            }
+         }
+    }
+
+}
diff --git a/test/tools/javac/lambdaShapes/TEST.properties b/test/tools/javac/lambdaShapes/TEST.properties
new file mode 100644
index 0000000..51a8537
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/TEST.properties
@@ -0,0 +1,2 @@
+TestNG.dirs = tools/javac/lambdaShapes
+
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java
new file mode 100644
index 0000000..3819221
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ *
+ * 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 org.openjdk.tests.javac;
+
+import org.openjdk.tests.shapegen.*;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.util.Pair;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.DataProvider;
+import static org.testng.Assert.*;
+
+public class FDTest {
+
+    public enum TestKind {
+        POSITIVE,
+        NEGATIVE;
+
+        Collection<Hierarchy> getHierarchy(HierarchyGenerator hg) {
+            return this == POSITIVE ?
+                    hg.getOK() : hg.getErr();
+        }
+    }
+
+    public static JavaCompiler comp;
+    public static StandardJavaFileManager fm;
+
+    @BeforeSuite
+    static void init() {
+        // create default shared JavaCompiler - reused across multiple
+        // compilations
+
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+    }
+
+    public static void main(String[] args) throws Exception {
+        init();
+
+        for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
+            runTest(fdtest.fst, fdtest.snd, comp, fm);
+        }
+    }
+
+    @Test(dataProvider = "fdCases")
+    public void testOneCase(TestKind tk, Hierarchy hs)
+            throws Exception {
+        FDTest.runTest(tk, hs, comp, fm);
+    }
+
+    @DataProvider(name = "fdCases")
+    public Object[][] caseGenerator() {
+        List<Pair<TestKind, Hierarchy>> cases = generateCases();
+        Object[][] fdCases = new Object[cases.size()][];
+        for (int i = 0; i < cases.size(); ++i) {
+            fdCases[i] = new Object[2];
+            fdCases[i][0] = cases.get(i).fst;
+            fdCases[i][1] = cases.get(i).snd;
+        }
+        return fdCases;
+    }
+
+    public static List<Pair<TestKind, Hierarchy>> generateCases() {
+        ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
+        HierarchyGenerator hg = new HierarchyGenerator();
+        for (TestKind tk : TestKind.values()) {
+            for (Hierarchy hs : tk.getHierarchy(hg)) {
+                list.add(new Pair<>(tk, hs));
+            }
+        }
+        return list;
+    }
+
+    public static void runTest(TestKind tk, Hierarchy hs,
+            JavaCompiler comp, StandardJavaFileManager fm) throws Exception {
+        new FDTest(tk, hs).run(comp, fm);
+    }
+
+    TestKind tk;
+    Hierarchy hs;
+    DefenderTestSource source;
+    DiagnosticChecker diagChecker;
+
+    public FDTest() {}
+
+    FDTest(TestKind tk, Hierarchy hs) {
+        this.tk = tk;
+        this.hs = hs;
+        this.source = new DefenderTestSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            fail("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        boolean errorExpected = tk == TestKind.NEGATIVE;
+        if (errorExpected != diagChecker.errorFound) {
+            fail("problem in source: \n" +
+                 "\nerror found = " + diagChecker.errorFound +
+                 "\nerror expected = " + errorExpected +
+                 "\n" + dumpHierarchy() +
+                 "\n" + source.getCharContent(true));
+        }
+    }
+
+    String dumpHierarchy() {
+        StringBuilder buf = new StringBuilder();
+        buf.append("root = " + hs.root + "\n");
+        for (ClassCase cc : hs.all) {
+            buf.append("  class name = " + cc.getName() + "\n");
+            buf.append("    class OK = " + cc.get_OK() + "\n");
+            buf.append("    prov = " + cc.get_mprov() + "\n");
+
+        }
+        return buf.toString();
+    }
+
+    class DefenderTestSource extends SimpleJavaFileObject {
+
+        String source;
+
+        public DefenderTestSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            StringBuilder buf = new StringBuilder();
+            List<ClassCase> defaultRef = new ArrayList<>();
+            for (ClassCase cc : hs.all) {
+                Hierarchy.genClassDef(buf, cc, null, defaultRef);
+            }
+            source = buf.toString();
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java
new file mode 100644
index 0000000..5dd0055
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/AttributeInjector.java
@@ -0,0 +1,73 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.io.*;
+
+public class AttributeInjector implements ClassFilePreprocessor {
+
+    private String attributeName;
+    private byte[] attributeData;
+
+    public AttributeInjector(String attributeName, byte[] attributeData) {
+        this.attributeName = attributeName;
+        this.attributeData = attributeData;
+    }
+
+    public byte[] preprocess(String name, byte[] cf) {
+        ClassFile classfile = new ClassFile(cf);
+
+        short cpIndex = (short)classfile.constant_pool.size();
+
+        ClassFile.CpUtf8 entry = new ClassFile.CpUtf8();
+        entry.bytes = new byte[attributeName.length()];
+        for (int i = 0; i < attributeName.length(); ++i) {
+            entry.bytes[i] = (byte)attributeName.charAt(i);
+        }
+
+        classfile.constant_pool.add(entry);
+
+        ClassFile.Attribute attr = new ClassFile.Attribute();
+        attr.attribute_name_index = cpIndex;
+        attr.info = attributeData;
+
+        classfile.attributes.add(attr);
+        return classfile.toByteArray();
+    }
+
+/*
+    public static void main(String argv[]) throws Exception {
+        File input = new File(argv[0]);
+        byte[] buffer = new byte[(int)input.length()];
+        new FileInputStream(input).read(buffer);
+
+        ClassFilePreprocessor cfp =
+            new AttributeInjector("RequiresBridges", new byte[0]);
+        byte[] cf = cfp.preprocess(argv[0], buffer);
+        new FileOutputStream(argv[0] + ".mod").write(cf);
+    }
+*/
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java
new file mode 100644
index 0000000..9d460cb
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFile.java
@@ -0,0 +1,454 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.io.*;
+import java.util.*;
+
+class CfInputStream extends ByteArrayInputStream {
+    private int ct;
+    public CfInputStream(byte[] input) {
+        super(input);
+    }
+
+    byte u1() { return (byte)read(); }
+    short u2() {
+        int b0 = read() << 8;
+        int b1 = read();
+        return (short)(b0 | b1);
+    }
+    int u4() {
+        int b0 = read() << 24;
+        int b1 = read() << 16;
+        int b2 = read() << 8;
+        int b3 = read();
+        return b0 | b1 | b2 | b3;
+    }
+    byte[] array(int count) {
+        byte[] ret = new byte[count];
+        read(ret, 0, count);
+        return ret;
+    }
+};
+
+class CfOutputStream extends ByteArrayOutputStream {
+    void u1(byte b) { write((int)b); }
+    void u2(short s) {
+        write((s >> 8) & 0xff);
+        write(s & 0xff);
+    }
+    void u4(int i) {
+        write((i >> 24) & 0xff);
+        write((i >> 16) & 0xff);
+        write((i >> 8) & 0xff);
+        write(i & 0xff);
+    }
+    void array(byte[] a) {
+        write(a, 0, a.length);
+    }
+
+    public byte[] toByteArray() { return super.toByteArray(); }
+};
+
+// A quick and dirty class file parser and representation
+public class ClassFile {
+
+    int magic;
+    short minor_version;
+    short major_version;
+    ArrayList<CpEntry> constant_pool;
+    short access_flags;
+    short this_class;
+    short super_class;
+    ArrayList<Interface> interfaces;
+    ArrayList<Field> fields;
+    ArrayList<Method> methods;
+    ArrayList<Attribute> attributes;
+
+    ClassFile(byte[] cf) {
+        CfInputStream in = new CfInputStream(cf);
+
+        magic = in.u4();
+        minor_version = in.u2();
+        major_version = in.u2();
+
+        short cpCount = in.u2();
+        constant_pool = new ArrayList<>();
+        constant_pool.add(new CpNull());
+        for (int i = 1; i < cpCount; ++i) {
+            constant_pool.add(CpEntry.newCpEntry(in));
+        }
+
+        access_flags = in.u2();
+        this_class = in.u2();
+        super_class = in.u2();
+
+        short ifaceCount = in.u2();
+        interfaces = new ArrayList<>();
+        for (int i = 0; i < ifaceCount; ++i) {
+            interfaces.add(new Interface(in));
+        }
+
+        short fieldCount = in.u2();
+        fields = new ArrayList<>();
+        for (int i = 0; i < fieldCount; ++i) {
+            fields.add(new Field(in));
+        }
+
+        short methodCount = in.u2();
+        methods = new ArrayList<>();
+        for (int i = 0; i < methodCount; ++i) {
+            methods.add(new Method(in));
+        }
+
+        short attributeCount = in.u2();
+        attributes = new ArrayList<>();
+        for (int i = 0; i < attributeCount; ++i) {
+            attributes.add(new Attribute(in));
+        }
+    }
+
+    byte[] toByteArray() {
+        CfOutputStream out = new CfOutputStream();
+
+        out.u4(magic);
+        out.u2(minor_version);
+        out.u2(major_version);
+
+        out.u2((short)(constant_pool.size()));
+        for (CpEntry cp : constant_pool) {
+            cp.write(out);
+        }
+
+        out.u2(access_flags);
+        out.u2(this_class);
+        out.u2(super_class);
+
+        out.u2((short)interfaces.size());
+        for (Interface iface : interfaces) {
+            iface.write(out);
+        }
+
+        out.u2((short)fields.size());
+        for (Field field : fields) {
+            field.write(out);
+        }
+
+        out.u2((short)methods.size());
+        for (Method method : methods) {
+            method.write(out);
+        }
+
+        out.u2((short)attributes.size());
+        for (Attribute attribute : attributes) {
+            attribute.write(out);
+        }
+
+        return out.toByteArray();
+    }
+
+    static abstract class CpEntry {
+        byte tag;
+
+        CpEntry(byte t) { tag = t; }
+        void write(CfOutputStream out) {
+            out.u1(tag);
+        }
+
+        static CpEntry newCpEntry(CfInputStream in) {
+            byte tag = in.u1();
+            switch (tag) {
+                case CpUtf8.TAG: return new CpUtf8(in);
+                case CpInteger.TAG: return new CpInteger(in);
+                case CpFloat.TAG: return new CpFloat(in);
+                case CpLong.TAG: return new CpLong(in);
+                case CpDouble.TAG: return new CpDouble(in);
+                case CpClass.TAG: return new CpClass(in);
+                case CpString.TAG: return new CpString(in);
+                case CpFieldRef.TAG: return new CpFieldRef(in);
+                case CpMethodRef.TAG: return new CpMethodRef(in);
+                case CpInterfaceMethodRef.TAG:
+                    return new CpInterfaceMethodRef(in);
+                case CpNameAndType.TAG: return new CpNameAndType(in);
+                case CpMethodHandle.TAG: return new CpMethodHandle(in);
+                case CpMethodType.TAG: return new CpMethodType(in);
+                case CpInvokeDynamic.TAG: return new CpInvokeDynamic(in);
+                default: throw new RuntimeException("Bad cp entry tag: " + tag);
+            }
+        }
+    }
+
+    static class CpNull extends CpEntry {
+        CpNull() { super((byte)0); }
+        CpNull(CfInputStream in) { super((byte)0); }
+        void write(CfOutputStream out) {}
+    }
+
+    static class CpUtf8 extends CpEntry {
+        static final byte TAG = 1;
+        byte[] bytes;
+
+        CpUtf8() { super(TAG); }
+        CpUtf8(CfInputStream in) {
+            this();
+            short length = in.u2();
+            bytes = in.array(length);
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2((short)bytes.length);
+            out.array(bytes);
+        }
+    }
+
+    static class CpU4Constant extends CpEntry {
+        byte[] bytes;
+
+        CpU4Constant(byte tag) { super(tag); }
+        CpU4Constant(byte tag, CfInputStream in) {
+            this(tag);
+            bytes = in.array(4);
+        }
+        void write(CfOutputStream out) { super.write(out); out.array(bytes); }
+    }
+    static class CpInteger extends CpU4Constant {
+        static final byte TAG = 3;
+        CpInteger() { super(TAG); }
+        CpInteger(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpFloat extends CpU4Constant {
+        static final byte TAG = 4;
+        CpFloat() { super(TAG); }
+        CpFloat(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpU8Constant extends CpEntry {
+        byte[] bytes;
+
+        CpU8Constant(byte tag) { super(tag); }
+        CpU8Constant(byte tag, CfInputStream in) {
+            this(tag);
+            bytes = in.array(8);
+        }
+        void write(CfOutputStream out) { super.write(out); out.array(bytes); }
+    }
+    static class CpLong extends CpU8Constant {
+        static final byte TAG = 5;
+        CpLong() { super(TAG); }
+        CpLong(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpDouble extends CpU8Constant {
+        static final byte TAG = 6;
+        CpDouble() { super(TAG); }
+        CpDouble(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpClass extends CpEntry {
+        static final byte TAG = 7;
+        short name_index;
+
+        CpClass() { super(TAG); }
+        CpClass(CfInputStream in) { super(TAG); name_index = in.u2(); }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(name_index);
+        }
+    }
+
+    static class CpString extends CpEntry {
+        static final byte TAG = 8;
+        short string_index;
+
+        CpString() { super(TAG); }
+        CpString(CfInputStream in) { super(TAG); string_index = in.u2(); }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(string_index);
+        }
+    }
+
+    static class CpRef extends CpEntry {
+        short class_index;
+        short name_and_type_index;
+
+        CpRef(byte tag) { super(tag); }
+        CpRef(byte tag, CfInputStream in) {
+            this(tag);
+            class_index = in.u2();
+            name_and_type_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(class_index);
+            out.u2(name_and_type_index);
+        }
+    }
+    static class CpFieldRef extends CpRef {
+        static final byte TAG = 9;
+        CpFieldRef() { super(TAG); }
+        CpFieldRef(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpMethodRef extends CpRef {
+        static final byte TAG = 10;
+        CpMethodRef() { super(TAG); }
+        CpMethodRef(CfInputStream in) { super(TAG, in); }
+    }
+    static class CpInterfaceMethodRef extends CpRef {
+        static final byte TAG = 11;
+        CpInterfaceMethodRef() { super(TAG); }
+        CpInterfaceMethodRef(CfInputStream in) { super(TAG, in); }
+    }
+
+    static class CpNameAndType extends CpEntry {
+        static final byte TAG = 12;
+        short name_index;
+        short descriptor_index;
+
+        CpNameAndType() { super(TAG); }
+        CpNameAndType(CfInputStream in) {
+            this();
+            name_index = in.u2();
+            descriptor_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(name_index);
+            out.u2(descriptor_index);
+        }
+    }
+
+    static class CpMethodHandle extends CpEntry {
+        static final byte TAG = 15;
+        byte reference_kind;
+        short reference_index;
+
+        CpMethodHandle() { super(TAG); }
+        CpMethodHandle(CfInputStream in) {
+            this();
+            reference_kind = in.u1();
+            reference_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u1(reference_kind);
+            out.u2(reference_index);
+        }
+    }
+
+    static class CpMethodType extends CpEntry {
+        static final byte TAG = 16;
+        short descriptor_index;
+
+        CpMethodType() { super(TAG); }
+        CpMethodType(CfInputStream in) {
+            this();
+            descriptor_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(descriptor_index);
+        }
+    }
+
+    static class CpInvokeDynamic extends CpEntry {
+        static final byte TAG = 18;
+        short bootstrap_index;
+        short name_and_type_index;
+
+        CpInvokeDynamic() { super(TAG); }
+        CpInvokeDynamic(CfInputStream in) {
+            this();
+            bootstrap_index = in.u2();
+            name_and_type_index = in.u2();
+        }
+        void write(CfOutputStream out) {
+            super.write(out);
+            out.u2(bootstrap_index);
+            out.u2(name_and_type_index);
+        }
+    }
+
+    static class Interface {
+        short index;
+
+        Interface() {}
+        Interface(CfInputStream in) { index = in.u2(); }
+        void write(CfOutputStream out) { out.u2(index); }
+    }
+
+    static class FieldOrMethod {
+        short access_flags;
+        short name_index;
+        short descriptor_index;
+        ArrayList<Attribute> attributes;
+
+        FieldOrMethod() { attributes = new ArrayList<>(); }
+        FieldOrMethod(CfInputStream in) {
+            access_flags = in.u2();
+            name_index = in.u2();
+            descriptor_index = in.u2();
+
+            short attrCount = in.u2();
+            attributes = new ArrayList<>();
+            for (int i = 0; i < attrCount; ++i) {
+                attributes.add(new Attribute(in));
+            }
+        }
+        void write(CfOutputStream out) {
+            out.u2(access_flags);
+            out.u2(name_index);
+            out.u2(descriptor_index);
+            out.u2((short)attributes.size());
+            for (Attribute attribute : attributes) { attribute.write(out); }
+        }
+    }
+
+    static class Field extends FieldOrMethod {
+        Field() {}
+        Field(CfInputStream in) { super(in); }
+    }
+    static class Method extends FieldOrMethod {
+        Method() {}
+        Method(CfInputStream in) { super(in); }
+    }
+
+    static class Attribute {
+        short attribute_name_index;
+        byte[] info;
+
+        Attribute() { info = new byte[0]; }
+        Attribute(CfInputStream in) {
+            attribute_name_index = in.u2();
+            int length = in.u4();
+            info = in.array(length);
+        }
+        void write(CfOutputStream out) {
+            out.u2(attribute_name_index);
+            out.u4(info.length);
+            out.array(info);
+        }
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java
new file mode 100644
index 0000000..30e8422
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassFilePreprocessor.java
@@ -0,0 +1,30 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+public interface ClassFilePreprocessor {
+    public byte[] preprocess(String name, byte[] classfile);
+};
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java
new file mode 100644
index 0000000..202441b
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/ClassToInterfaceConverter.java
@@ -0,0 +1,94 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.io.*;
+import java.util.*;
+
+public class ClassToInterfaceConverter implements ClassFilePreprocessor {
+
+    private String whichClass;
+
+    public ClassToInterfaceConverter(String className) {
+        this.whichClass = className;
+    }
+
+    private boolean utf8Matches(ClassFile.CpEntry entry, String v) {
+        if (!(entry instanceof ClassFile.CpUtf8)) {
+            return false;
+        }
+        ClassFile.CpUtf8 utf8 = (ClassFile.CpUtf8)entry;
+        if (v.length() != utf8.bytes.length) {
+            return false;
+        }
+        for (int i = 0; i < v.length(); ++i) {
+            if (v.charAt(i) != utf8.bytes[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void convertToInterface(ClassFile cf) {
+        cf.access_flags = 0x0601; // ACC_INTERFACE | ACC_ABSTRACT | ACC_PUBLIC
+        ArrayList<ClassFile.Method> new_methods = new ArrayList<>();
+        // Find <init> method and delete it
+        for (int i = 0; i < cf.methods.size(); ++i) {
+            ClassFile.Method method = cf.methods.get(i);
+            ClassFile.CpEntry name = cf.constant_pool.get(method.name_index);
+            if (!utf8Matches(name, "<init>")) {
+                new_methods.add(method);
+            }
+        }
+        cf.methods = new_methods;
+    }
+
+    public byte[] preprocess(String classname, byte[] bytes) {
+        ClassFile cf = new ClassFile(bytes);
+
+        ClassFile.CpEntry entry = cf.constant_pool.get(cf.this_class);
+        ClassFile.CpEntry name = cf.constant_pool.get(
+            ((ClassFile.CpClass)entry).name_index);
+        if (utf8Matches(name, whichClass)) {
+            convertToInterface(cf);
+            return cf.toByteArray();
+        } else {
+            return bytes; // unmodified
+        }
+    }
+
+/*
+    public static void main(String argv[]) throws Exception {
+        File input = new File(argv[0]);
+        byte[] buffer = new byte[(int)input.length()];
+        new FileInputStream(input).read(buffer);
+
+        ClassFilePreprocessor cfp = new ClassToInterfaceConverter("Hello");
+        byte[] cf = cfp.preprocess(argv[0], buffer);
+        new FileOutputStream(argv[0] + ".mod").write(cf);
+    }
+*/
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java
new file mode 100644
index 0000000..4aace3d
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/Compiler.java
@@ -0,0 +1,232 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.ConcurrentHashMap;
+import java.io.*;
+import java.net.URI;
+import javax.tools.*;
+
+import com.sun.source.util.JavacTask;
+
+import static org.openjdk.tests.separate.SourceModel.Type;
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.Extends;
+import static org.openjdk.tests.separate.SourceModel.SourceProcessor;
+
+public class Compiler {
+
+    public enum Flags {
+        VERBOSE, // Prints out files as they are compiled
+        USECACHE // Keeps results around for reuse.  Only use this is
+                 // you're sure that each compilation name maps to the
+                 // same source code
+    };
+
+    private static final AtomicInteger counter = new AtomicInteger();
+    private static final String targetDir = "gen-separate";
+    private static final File root = new File(targetDir);
+    private static ConcurrentHashMap<String,File> cache =
+            new ConcurrentHashMap<>();
+
+    Set<Flags> flags;
+
+    private JavaCompiler systemJavaCompiler;
+    private StandardJavaFileManager fm;
+    private List<File> tempDirs;
+    private List<ClassFilePreprocessor> postprocessors;
+
+    private static class SourceFile extends SimpleJavaFileObject {
+        private final String content;
+
+        public SourceFile(String name, String content) {
+            super(URI.create("myfo:/" + name + ".java"), Kind.SOURCE);
+            this.content = content;
+        }
+
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public String toString() { return this.content; }
+    }
+
+    public Compiler(Flags ... flags) {
+        setFlags(flags);
+        this.tempDirs = new ArrayList<>();
+        this.postprocessors = new ArrayList<>();
+        this.systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
+        this.fm = systemJavaCompiler.getStandardFileManager(null, null, null);
+    }
+
+    public void setFlags(Flags ... flags) {
+        this.flags = new HashSet<Flags>(Arrays.asList(flags));
+    }
+
+    public void addPostprocessor(ClassFilePreprocessor cfp) {
+        this.postprocessors.add(cfp);
+    }
+
+    /**
+     * Compile hierarchies starting with each of the 'types' and return
+     * a ClassLoader that can be used to load the compiled classes.
+     */
+    public ClassLoader compile(Type ... types) {
+        ClassFilePreprocessor[] cfps = this.postprocessors.toArray(
+            new ClassFilePreprocessor[0]);
+
+        DirectedClassLoader dcl = new DirectedClassLoader(cfps);
+
+        for (Type t : types) {
+            for (Map.Entry<String,File> each : compileHierarchy(t).entrySet()) {
+                dcl.setLocationFor(each.getKey(), each.getValue());
+            }
+        }
+        return dcl;
+    }
+
+    /**
+     * Compiles and loads a hierarchy, starting at 'type'
+     */
+    public java.lang.Class<?> compileAndLoad(Type type)
+            throws ClassNotFoundException {
+
+        ClassLoader loader = compile(type);
+        return java.lang.Class.forName(type.getName(), false, loader);
+    }
+
+    /**
+     * Compiles a hierarchy, starting at 'type' and return a mapping of the
+     * name to the location where the classfile for that type resides.
+     */
+    private Map<String,File> compileHierarchy(Type type) {
+        HashMap<String,File> outputDirs = new HashMap<>();
+
+        File outDir = compileOne(type);
+        outputDirs.put(type.getName(), outDir);
+
+        Class superClass = type.getSuperclass();
+        if (superClass != null) {
+            for( Map.Entry<String,File> each : compileHierarchy(superClass).entrySet()) {
+                outputDirs.put(each.getKey(), each.getValue());
+            }
+        }
+        for (Extends ext : type.getSupertypes()) {
+            Type iface = ext.getType();
+            for( Map.Entry<String,File> each : compileHierarchy(iface).entrySet()) {
+                outputDirs.put(each.getKey(), each.getValue());
+            }
+        }
+
+        return outputDirs;
+    }
+
+    private File compileOne(Type type) {
+        if (this.flags.contains(Flags.USECACHE)) {
+            File dir = cache.get(type.getName());
+            if (dir != null) {
+                return dir;
+            }
+        }
+        List<JavaFileObject> files = new ArrayList<>();
+        SourceProcessor accum =
+            (name, src) -> { files.add(new SourceFile(name, src)); };
+
+        for (Type dep : type.typeDependencies()) {
+            dep.generateAsDependency(accum, type.methodDependencies());
+        }
+
+        type.generate(accum);
+
+        JavacTask ct = (JavacTask)this.systemJavaCompiler.getTask(
+            null, this.fm, null, null, null, files);
+        File destDir = null;
+        do {
+            int value = counter.incrementAndGet();
+            destDir = new File(root, Integer.toString(value));
+        } while (destDir.exists());
+
+        if (this.flags.contains(Flags.VERBOSE)) {
+            System.out.println("Compilation unit for " + type.getName() +
+                " : compiled into " + destDir);
+            for (JavaFileObject jfo : files) {
+                System.out.println(jfo.toString());
+            }
+        }
+
+        try {
+            destDir.mkdirs();
+            this.fm.setLocation(
+                StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+        } catch (IOException e) {
+            throw new RuntimeException(
+                "IOException encountered during compilation");
+        }
+        Boolean result = ct.call();
+        if (result == Boolean.FALSE) {
+            throw new RuntimeException(
+                "Compilation failure in " + type.getName() + " unit");
+        }
+        if (this.flags.contains(Flags.USECACHE)) {
+            File existing = cache.putIfAbsent(type.getName(), destDir);
+            if (existing != null) {
+                deleteDir(destDir);
+                return existing;
+            }
+        } else {
+        this.tempDirs.add(destDir);
+        }
+        return destDir;
+    }
+
+    private static void deleteDir(File dir) {
+        for (File f : dir.listFiles()) {
+            f.delete();
+        };
+        dir.delete();
+    }
+
+    public void cleanup() {
+        if (!this.flags.contains(Flags.USECACHE)) {
+            for (File d : tempDirs) {
+                deleteDir(d);
+            };
+            tempDirs = new ArrayList<>();
+        }
+    }
+
+    // Removes all of the elements in the cache and deletes the associated
+    // output directories.  This may not actually empty the cache if there
+    // are concurrent users of it.
+    public static void purgeCache() {
+        for (Map.Entry<String,File> entry : cache.entrySet()) {
+            cache.remove(entry.getKey());
+            deleteDir(entry.getValue());
+        }
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java
new file mode 100644
index 0000000..ba09714
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/DirectedClassLoader.java
@@ -0,0 +1,101 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.util.HashMap;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+class DirectedClassLoader extends ClassLoader {
+
+    private HashMap<String,File> loadLocations;
+    private File defaultLocation;
+    private ClassFilePreprocessor[] preprocessors;
+
+    public DirectedClassLoader(
+            HashMap<String,File> locations, File fallback,
+            ClassFilePreprocessor ... preprocessors) {
+        loadLocations = new HashMap<>(locations);
+        defaultLocation = fallback;
+        this.preprocessors = preprocessors;
+    }
+
+    public DirectedClassLoader(
+            File fallback, ClassFilePreprocessor ... preprocessors) {
+        loadLocations = new HashMap<>();
+        defaultLocation = fallback;
+        this.preprocessors = preprocessors;
+    }
+
+    public DirectedClassLoader(ClassFilePreprocessor ... preprocessors) {
+        this((File)null, preprocessors);
+    }
+
+    public void setDefaultLocation(File dir) { this.defaultLocation = dir; }
+    public void setLocationFor(String name, File dir) {
+        loadLocations.put(name, dir);
+    }
+
+    @Override
+    protected Class<?> findClass(String name) {
+        String path = name.replace(".", File.separator) + ".class";
+
+        File location = loadLocations.get(name);
+        if (location == null || !(new File(location, path)).exists()) {
+            File def = new File(defaultLocation, path);
+            if (def.exists()) {
+                return defineFrom(name, new File(location, path));
+            }
+        } else {
+            return defineFrom(name, new File(location, path));
+        }
+        return null;
+    }
+
+    private Class<?> defineFrom(String name, File file) {
+        FileInputStream fis = null;
+        try {
+            try {
+                fis = new FileInputStream(file);
+                byte[] bytes = new byte[fis.available()];
+                int read = fis.read(bytes);
+                if (read != bytes.length) {
+                    return null;
+                }
+                if (preprocessors != null) {
+                    for (ClassFilePreprocessor cfp : preprocessors) {
+                        bytes = cfp.preprocess(name, bytes);
+                    }
+                 }
+                return defineClass(name, bytes, 0, bytes.length);
+            } finally {
+                fis.close();
+            }
+        } catch (IOException e) {}
+        return null;
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java
new file mode 100644
index 0000000..22fbff7
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/SourceModel.java
@@ -0,0 +1,582 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import java.util.*;
+import java.io.StringWriter;
+import java.io.PrintWriter;
+
+public class SourceModel {
+
+    public static final String stdMethodName = "m";
+
+    public static interface SourceProcessor {
+        // Called with a generated source file
+        void process(String name, String content);
+    }
+
+    public static abstract class Element {
+
+        protected abstract void generate(PrintWriter pw);
+
+        public String toString() {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            return sw.toString();
+        }
+    };
+
+    public static class AccessFlag extends Element {
+        private String flag;
+
+        public AccessFlag(String name) { flag = name; }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(flag);
+        }
+
+        public String toString() { return flag; }
+
+        public static final AccessFlag PUBLIC = new AccessFlag("public");
+        public static final AccessFlag PRIVATE = new AccessFlag("private");
+        public static final AccessFlag PROTECTED = new AccessFlag("protected");
+        public static final AccessFlag STATIC = new AccessFlag("static");
+        public static final AccessFlag FINAL = new AccessFlag("final");
+        public static final AccessFlag SYNCHRONIZED = new AccessFlag("synchronized");
+        public static final AccessFlag VOLATILE = new AccessFlag("volatile");
+        public static final AccessFlag NATIVE = new AccessFlag("native");
+        public static final AccessFlag ABSTRACT = new AccessFlag("abstract");
+        public static final AccessFlag STRICTFP = new AccessFlag("strictfp");
+        public static final AccessFlag DEFAULT = new AccessFlag("default");
+    }
+
+    public static class TypeParameter extends Element {
+        private String parameter;
+
+        public TypeParameter(String str) {
+            this.parameter = str;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(parameter);
+        }
+    }
+
+    public static class TypeArgument extends Element {
+        private String argument;
+
+        public TypeArgument(String str) {
+            this.argument = str;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.print(argument);
+        }
+    }
+
+    public static class MethodParameter extends Element {
+        private String type;
+        private String name;
+
+        public MethodParameter(String type, String name) {
+            this.type = type;
+            this.name = name;
+        }
+
+        protected void generate(PrintWriter pw) {
+            pw.printf("%s %s", this.type, this.name);
+        }
+
+        public String toString() { return type + " " + name; }
+    }
+
+    public static abstract class Type extends Element {
+        private String name;
+        private List<AccessFlag> accessFlags;
+        private List<TypeParameter> parameters;
+        private List<Extends> supertypes;
+        private List<Method> methods;
+
+        // methods from superclasses that are required for compilation
+        // (and thus will be present in stubs)
+        private Set<Method> methodDependencies;
+        private List<Type> typeDependencies;
+
+        protected Type(String name,
+                List<AccessFlag> flags, List<TypeParameter> params,
+                List<Extends> ifaces, List<Method> methods) {
+            this.name = name;
+            this.accessFlags = flags == null ? new ArrayList<>() : flags;
+            this.parameters = params == null ? new ArrayList<>() : params;
+            this.supertypes = ifaces == null ? new ArrayList<>() : ifaces;
+            this.methods = methods == null ? new ArrayList<>() : methods;
+            this.methodDependencies = new HashSet<>();
+            this.typeDependencies = new ArrayList<>();
+        }
+
+        public String getName() { return this.name; }
+        public List<AccessFlag> getAccessFlags() { return this.accessFlags; }
+        public List<TypeParameter> getParameters() { return this.parameters; }
+        public List<Extends> getSupertypes() { return this.supertypes; }
+        public List<Method> getMethods() { return this.methods; }
+        public Set<Method> methodDependencies() {
+            return this.methodDependencies;
+        }
+
+        public Class getSuperclass() { return null; }
+        protected abstract void setSuperClass(Extends supertype);
+
+        public void addSuperType(Extends sup) {
+            assert sup.getType() instanceof Interface : "Must be an interface";
+            this.supertypes.add(sup);
+        }
+        public void addSuperType(Interface iface) {
+            this.supertypes.add(new Extends(iface));
+        }
+
+        public void addMethod(Method m) {
+            this.methods.add(m);
+        }
+
+        public void addAccessFlag(AccessFlag f) {
+            this.accessFlags.add(f);
+        }
+
+        // Convenience method for creation.  Parameters are interpreted
+        // according to their type.  Class (or Extends with a Class type) is
+        // considered a superclass (only one allowed).  TypeParameters are
+        // generic parameter names.  Interface (or Extends with an Interface
+        // type) is an implemented supertype.  Methods are methods (duh!).
+        protected void addComponent(Element p) {
+            if (p instanceof Class) {
+                setSuperClass(new Extends((Class)p));
+            } else if (p instanceof Extends) {
+                Extends ext = (Extends)p;
+                if (ext.supertype instanceof Class) {
+                    setSuperClass(ext);
+                } else if (ext.supertype instanceof Interface) {
+                    addSuperType(ext);
+                } else {
+                    assert false : "What is this thing?";
+                }
+            } else if (p instanceof Interface) {
+                addSuperType((Interface)p);
+            } else if (p instanceof TypeParameter) {
+                this.parameters.add((TypeParameter)p);
+            } else if (p instanceof Method) {
+                addMethod((Method)p);
+            } else if (p instanceof AccessFlag) {
+                addAccessFlag((AccessFlag)p);
+            } else {
+                assert false : "What is this thing?";
+            }
+        }
+
+        // Find and return the first method that has name 'name'
+        public Method findMethod(String name) {
+            for (Method m : methods) {
+                if (m.name.equals(name)) {
+                    return m;
+                }
+            }
+            return null;
+        }
+
+        public void addCompilationDependency(Type t) {
+            typeDependencies.add(t);
+        }
+
+        public void addCompilationDependency(Method m) {
+            methodDependencies.add(m);
+        }
+
+        // Convenience method for creating an Extends object using this
+        // class and specified type arguments.
+        public Extends with(String ... args) {
+            return new Extends(this, args);
+        }
+
+        public abstract void generate(SourceProcessor sp);
+        public abstract void generateAsDependency(
+            SourceProcessor sp, Set<Method> neededMethods);
+
+        protected void generateName(PrintWriter pw) {
+            pw.print(this.name);
+            toJoinedString(this.parameters, ",", "<", ">", "");
+            pw.print(toJoinedString(this.parameters, ",", "<", ">", ""));
+            pw.print(" ");
+        }
+
+        protected void generateBody(PrintWriter pw, String superSpec) {
+            pw.print(toJoinedString(this.supertypes, ",", superSpec + " ", " ", ""));
+            pw.println("{ ");
+            pw.print(toJoinedString(this.methods, "\n    ", "\n    ", "\n", ""));
+            pw.println("}");
+        }
+
+        protected void generateAccessFlags(PrintWriter pw) {
+            pw.print(toJoinedString(this.accessFlags, " ", "", " "));
+        }
+
+        protected void generateBodyAsDependency(
+            PrintWriter pw, Set<Method> neededMethods) {
+            pw.println(" {");
+            for (Method m : this.methods) {
+                if (neededMethods.contains(m)) {
+                    pw.print("    ");
+                    m.generate(pw);
+                    pw.println();
+                }
+            }
+            pw.println("}");
+        }
+
+        public Collection<Type> typeDependencies() {
+            HashMap<String,Type> dependencies = new HashMap<>();
+            Type superclass = getSuperclass();
+            if (superclass != null) {
+                dependencies.put(superclass.getName(), superclass);
+            }
+            for (Extends e : getSupertypes())
+                dependencies.put(e.getType().getName(), e.getType());
+            // Do these last so that they override
+            for (Type t : this.typeDependencies)
+                dependencies.put(t.getName(), t);
+            return dependencies.values();
+        }
+    }
+
+    public static class Class extends Type {
+        private Extends superClass;
+
+        public Class(String name, List<AccessFlag> flags,
+                List<TypeParameter> params, Extends sprClass,
+                List<Extends> interfaces, List<Method> methods) {
+            super(name, flags, params, interfaces, methods);
+            this.superClass = sprClass;
+            addAccessFlag(AccessFlag.PUBLIC); // should remove this
+        }
+
+        public Class(String name, Element ... components) {
+            super(name, null, null, null, null);
+            this.superClass = null;
+
+            for (Element p : components) {
+                addComponent(p);
+            }
+            addAccessFlag(AccessFlag.PUBLIC); // should remove this
+        }
+
+        public boolean isAbstract() {
+            for (AccessFlag flag : getAccessFlags()) {
+                if (flag == AccessFlag.ABSTRACT) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public void setSuperClass(Extends ext) {
+            assert this.superClass == null : "Multiple superclasses defined";
+            assert ext.getType() instanceof Class : "Must be a class";
+            this.superClass = ext;
+        }
+
+        public void setSuperClass(Class c) {
+            setSuperClass(new Extends(c));
+        }
+
+        @Override
+        public Class getSuperclass() {
+            return superClass == null ? null : (Class)superClass.supertype;
+        }
+
+        public void generate(SourceProcessor processor) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            processor.process(getName(), sw.toString());
+        }
+
+        public void generate(PrintWriter pw) {
+            generateAccessFlags(pw);
+            pw.print("class ");
+            generateName(pw);
+            if (superClass != null) {
+                pw.print("extends ");
+                superClass.generate(pw);
+                pw.print(" ");
+            }
+            generateBody(pw, "implements");
+        }
+
+        public void generateAsDependency(
+                SourceProcessor processor, Set<Method> neededMethods) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generateAccessFlags(pw);
+            pw.print("class ");
+            generateName(pw);
+            pw.print(" ");
+            generateBodyAsDependency(pw, neededMethods);
+
+            processor.process(getName(), sw.toString());
+        }
+    }
+
+    public static class Interface extends Type {
+
+        public Interface(String name,
+                  List<AccessFlag> flags, List<TypeParameter> params,
+                  List<Extends> interfaces, List<Method> methods) {
+            super(name, flags, params, interfaces, methods);
+        }
+
+        public Interface(String name, Element ... components) {
+            super(name, null, null, null, null);
+            for (Element c : components) {
+                addComponent(c);
+            }
+        }
+
+        protected void setSuperClass(Extends ext) {
+            assert false : "Interfaces cannot have Class supertypes";
+        }
+
+        public void generate(SourceProcessor processor) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            generate(pw);
+            processor.process(getName(), sw.toString());
+        }
+
+        public void generate(PrintWriter pw) {
+            generateAccessFlags(pw);
+            pw.print("interface ");
+            generateName(pw);
+            pw.print(" ");
+            generateBody(pw, "extends");
+        }
+
+        public void generateAsDependency(
+                SourceProcessor processor, Set<Method> neededMethods) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+
+            generateAccessFlags(pw);
+            pw.print("interface ");
+            generateName(pw);
+            pw.print(" ");
+            generateBodyAsDependency(pw, neededMethods);
+
+            processor.process(getName(), sw.toString());
+        }
+    }
+
+    /**
+     * Represents a type extension that might contain type arguments
+     */
+    public static class Extends extends Element {
+        private final Type supertype;
+        private final List<TypeArgument> arguments;
+
+        public Type getType() { return supertype; }
+        public List<TypeArgument> getArguments() {
+            return arguments;
+        }
+
+        public Extends(Type supertype, String ... args) {
+            assert supertype != null : "Null supertype";
+            this.supertype = supertype;
+            this.arguments = new ArrayList<>();
+            for (String arg : args) {
+                this.arguments.add(new TypeArgument(arg));
+            }
+        }
+
+        public void generate(PrintWriter pw) {
+            pw.print(supertype.getName());
+            pw.print(toJoinedString(getArguments(), ",", "<", ">", ""));
+        }
+    }
+
+    public static abstract class Method extends Element {
+        private String name;
+        private String returnType;
+        private List<AccessFlag> accessFlags;
+        private List<MethodParameter> parameters;
+        private boolean emitSuppressWarnings;
+
+        protected Method(String ret, String name, Element ... params) {
+            this.name = name;
+            this.returnType = ret;
+            this.accessFlags = new ArrayList<>();
+            this.parameters = new ArrayList<>();
+            this.emitSuppressWarnings = false;
+
+            for (Element e : params) {
+                if (e instanceof MethodParameter) {
+                    this.parameters.add((MethodParameter) e);
+                } else if (e instanceof AccessFlag) {
+                    this.accessFlags.add((AccessFlag) e);
+                }
+            }
+            assert accessFlags.size() + parameters.size() == params.length :
+                   "Non method parameters or access flags in constructor";
+        }
+
+        public String getName() { return this.name; }
+        public String getReturnType() { return this.returnType; }
+        public List<MethodParameter> getParameters() {
+            return this.parameters;
+        }
+        public List<AccessFlag> getAccessFlags() {
+            return this.accessFlags;
+        }
+        public Element[] getElements() {
+            ArrayList<Element> elements = new ArrayList<>();
+            elements.addAll(getParameters());
+            elements.addAll(getAccessFlags());
+            return elements.toArray(new Element[0]);
+        }
+
+        public void suppressWarnings() { this.emitSuppressWarnings = true; }
+
+        public void generateWarningSuppression(PrintWriter pw) {
+            if (this.emitSuppressWarnings) {
+                pw.printf("@SuppressWarnings(\"unchecked\")\n    ");
+            }
+        }
+
+        protected void generateDecl(PrintWriter pw) {
+            generateWarningSuppression(pw);
+            pw.print(toJoinedString(this.accessFlags, " ", "", " "));
+            pw.printf("%s %s(", returnType, name);
+            pw.print(toJoinedString(parameters, ","));
+            pw.print(")");
+        }
+    }
+
+    public static class AbstractMethod extends Method {
+        public AbstractMethod(
+                String ret, String name, Element ... params) {
+            super(ret, name, params);
+            this.getAccessFlags().add(AccessFlag.ABSTRACT);
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.print(";");
+        }
+
+        public static AbstractMethod std() {
+            return new AbstractMethod(
+                "int", SourceModel.stdMethodName, AccessFlag.PUBLIC);
+        }
+    }
+
+    public static class ConcreteMethod extends Method {
+        protected String body;
+
+        public ConcreteMethod(String ret, String name,
+                String body, Element ... params) {
+            super(ret, name, params);
+            this.body = body;
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.printf(" { %s }", this.body);
+        }
+
+        public static ConcreteMethod std(String value) {
+            return new ConcreteMethod(
+                "int", SourceModel.stdMethodName, "return " + value + ";",
+                AccessFlag.PUBLIC);
+        }
+    }
+
+    // When the default method flag gets moved into the traditional
+    // access flags location, we can remove this class completely and
+    // use a ConcreteMethod with an AccessFlag("default") in the constructor
+    public static class DefaultMethod extends Method {
+        protected String body;
+
+        public DefaultMethod(String ret, String name, String body,
+                Element ... params) {
+            super(ret, name, params);
+            this.body = body;
+            this.getAccessFlags().add(AccessFlag.DEFAULT);
+        }
+
+        public void generate(PrintWriter pw) {
+            generateDecl(pw);
+            pw.printf(" { %s }", this.body);
+        }
+
+        public static DefaultMethod std(String value) {
+            return new DefaultMethod(
+                "int", SourceModel.stdMethodName, "return " + value + ";");
+        }
+    }
+
+    private static <T> String toJoinedString(List<T> list, String... p) {
+        StringBuilder sb = new StringBuilder();
+        String sep = "";
+        String init = "";
+        String end = "";
+        String empty = null;
+        switch (p.length) {
+            case 4:
+                empty = p[3];
+            /*fall-through*/
+            case 3:
+                end = p[2];
+            /*fall-through*/
+            case 2:
+                init = p[1];
+            /*fall-through*/
+            case 1:
+                sep = p[0];
+                break;
+        }
+        if (empty != null && list.isEmpty()) {
+            return empty;
+        } else {
+            sb.append(init);
+            for (T x : list) {
+                if (sb.length() != init.length()) {
+                    sb.append(sep);
+                }
+                sb.append(x.toString());
+            }
+            sb.append(end);
+            return sb.toString();
+        }
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java
new file mode 100644
index 0000000..18ea7cd
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/separate/TestHarness.java
@@ -0,0 +1,354 @@
+/*
+ * 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 org.openjdk.tests.separate;
+
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.testng.Assert.*;
+
+public class TestHarness {
+
+    /**
+     * Creates a per-thread persistent compiler object to allow as much
+     * sharing as possible, but still allows for parallel execution of tests.
+     */
+    protected ThreadLocal<Compiler> compilerLocal = new ThreadLocal<Compiler>(){
+         protected synchronized Compiler initialValue() {
+             return new Compiler();
+         }
+    };
+
+    protected ThreadLocal<Boolean> verboseLocal = new ThreadLocal<Boolean>() {
+         protected synchronized Boolean initialValue() {
+             return Boolean.FALSE;
+         }
+    };
+
+    protected boolean verbose;
+    protected boolean canUseCompilerCache;
+    public static final String stdMethodName = SourceModel.stdMethodName;
+
+    private TestHarness() {
+    }
+
+    protected TestHarness(boolean verbose, boolean canUseCompilerCache) {
+        this.verbose = verbose;
+        this.canUseCompilerCache = canUseCompilerCache;
+    }
+
+    public void setTestVerbose() {
+        verboseLocal.set(Boolean.TRUE);
+    }
+
+    @AfterMethod
+    public void reset() {
+        if (!this.verbose) {
+            verboseLocal.set(Boolean.FALSE);
+        }
+    }
+
+    public Compiler.Flags[] compilerFlags() {
+        HashSet<Compiler.Flags> flags = new HashSet<>();
+        if (verboseLocal.get() == Boolean.TRUE) {
+            flags.add(Compiler.Flags.VERBOSE);
+        }
+        if (this.canUseCompilerCache) {
+            flags.add(Compiler.Flags.USECACHE);
+        }
+        return flags.toArray(new Compiler.Flags[0]);
+    }
+
+    @AfterMethod
+    public void printError(ITestResult result) {
+        if (result.getStatus() == ITestResult.FAILURE) {
+            String clsName = result.getTestClass().getName();
+            clsName = clsName.substring(clsName.lastIndexOf(".") + 1);
+            System.out.println("Test " + clsName + "." +
+                               result.getName() + " FAILED");
+        }
+    }
+
+    private static final ConcreteMethod stdCM = ConcreteMethod.std("-1");
+    private static final AbstractMethod stdAM =
+            new AbstractMethod("int", stdMethodName);
+
+    /**
+     * Returns a class which has a static method with the same name as
+     * 'method', whose body creates an new instance of 'specimen' and invokes
+     * 'method' upon it via an invokevirtual instruction with 'args' as
+     * function call parameters.
+     *
+     * 'returns' is a dummy return value that need only match 'methods'
+     * return type (it is only used in the dummy class when compiling IV).
+     */
+    private Class invokeVirtualHarness(
+            Class specimen, ConcreteMethod method,
+            String returns, String ... args) {
+        Method cm = new ConcreteMethod(
+            method.getReturnType(), method.getName(),
+            "return " + returns + ";",  method.getElements());
+        Class stub = new Class(specimen.getName(), cm);
+
+        String params = toJoinedString(args, ", ");
+
+        ConcreteMethod sm = new ConcreteMethod(
+            method.getReturnType(), method.getName(),
+            String.format("return (new %s()).%s(%s);",
+                          specimen.getName(), method.getName(), params),
+            new AccessFlag("public"), new AccessFlag("static"));
+
+        Class iv = new Class("IV_" + specimen.getName(), sm);
+
+        iv.addCompilationDependency(stub);
+        iv.addCompilationDependency(cm);
+
+        return iv;
+    }
+
+    /**
+     * Returns a class which has a static method with the same name as
+     * 'method', whose body creates an new instance of 'specimen', casts it
+     * to 'iface' (including the type parameters)  and invokes
+     * 'method' upon it via an invokeinterface instruction with 'args' as
+     * function call parameters.
+     */
+    private Class invokeInterfaceHarness(Class specimen, Extends iface,
+            AbstractMethod method, String ... args) {
+        Interface istub = new Interface(
+            iface.getType().getName(), iface.getType().getAccessFlags(),
+            iface.getType().getParameters(),
+            null, Arrays.asList((Method)method));
+        Class cstub = new Class(specimen.getName());
+
+        String params = toJoinedString(args, ", ");
+
+        ConcreteMethod sm = new ConcreteMethod(
+            "int", SourceModel.stdMethodName,
+            String.format("return ((%s)(new %s())).%s(%s);", iface.toString(),
+                specimen.getName(), method.getName(), params),
+            new AccessFlag("public"), new AccessFlag("static"));
+        sm.suppressWarnings();
+
+        Class ii = new Class("II_" + specimen.getName() + "_" +
+            iface.getType().getName(), sm);
+        ii.addCompilationDependency(istub);
+        ii.addCompilationDependency(cstub);
+        ii.addCompilationDependency(method);
+        return ii;
+    }
+
+
+    /**
+     * Uses 'loader' to load class 'clzz', and calls the static method
+     * 'method'.  If the return value does not equal 'value' (or if an
+     * exception is thrown), then a test failure is indicated.
+     *
+     * If 'value' is null, then no equality check is performed -- the assertion
+     * fails only if an exception is thrown.
+     */
+    protected void assertStaticCallEquals(
+            ClassLoader loader, Class clzz, String method, Object value) {
+        java.lang.Class<?> cls = null;
+        try {
+            cls = java.lang.Class.forName(clzz.getName(), true, loader);
+        } catch (ClassNotFoundException e) {}
+        assertNotNull(cls);
+
+        java.lang.reflect.Method m = null;
+        try {
+            m = cls.getMethod(method);
+        } catch (NoSuchMethodException e) {}
+        assertNotNull(m);
+
+        try {
+            Object res = m.invoke(null);
+            assertNotNull(res);
+            if (value != null) {
+                assertEquals(res, value);
+            }
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            fail("Unexpected exception thrown: " + e.getCause());
+        }
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokevirtual,
+     * compiles and loads both the new class and 'target', and then invokes
+     * the method.  If the returned value does not match 'value' then a
+     * test failure is indicated.
+     */
+    public void assertInvokeVirtualEquals(
+            Object value, Class target, ConcreteMethod method,
+            String returns, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class iv = invokeVirtualHarness(target, method, returns, args);
+        ClassLoader loader = compiler.compile(iv, target);
+
+        assertStaticCallEquals(loader, iv, method.getName(), value);
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertInvokeVirtualEquals(int value, Class target) {
+        assertInvokeVirtualEquals(
+            new Integer(value), target, stdCM, "-1");
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokeinterface
+     * through 'iface', compiles and loads both it and 'target', and
+     * then invokes the method.  If the returned value does not match
+     * 'value' then a test failure is indicated.
+     */
+    public void assertInvokeInterfaceEquals(Object value, Class target,
+            Extends iface, AbstractMethod method, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class ii = invokeInterfaceHarness(target, iface, method, args);
+        ClassLoader loader = compiler.compile(ii, target);
+
+        assertStaticCallEquals(loader, ii, method.getName(), value);
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertInvokeInterfaceEquals(
+            int value, Class target, Interface iface) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        assertInvokeInterfaceEquals(
+            new Integer(value), target, new Extends(iface), stdAM);
+
+        compiler.cleanup();
+    }
+
+    /**
+     * Creates a class which calls target::method(args) via invokevirtual,
+     * compiles and loads both the new class and 'target', and then invokes
+     * the method.  If an exception of type 'exceptionType' is not thrown,
+     * then a test failure is indicated.
+     */
+    public void assertThrows(java.lang.Class<?> exceptionType, Class target,
+            ConcreteMethod method, String returns, String ... args) {
+
+        Compiler compiler = compilerLocal.get();
+        compiler.setFlags(compilerFlags());
+
+        Class iv = invokeVirtualHarness(target, method, returns, args);
+        ClassLoader loader = compiler.compile(iv, target);
+
+        java.lang.Class<?> cls = null;
+        try {
+            cls = java.lang.Class.forName(iv.getName(), true, loader);
+        } catch (ClassNotFoundException e) {}
+        assertNotNull(cls);
+
+        java.lang.reflect.Method m = null;
+        try {
+            m = cls.getMethod(method.getName());
+        } catch (NoSuchMethodException e) {}
+        assertNotNull(m);
+
+        try {
+            m.invoke(null);
+            fail("Exception should have been thrown");
+        } catch (InvocationTargetException | IllegalAccessException e) {
+            if (verboseLocal.get() == Boolean.TRUE) {
+                System.out.println(e.getCause());
+            }
+            assertEquals(e.getCause().getClass(), exceptionType);
+        }
+        compiler.cleanup();
+    }
+
+    /**
+     * Convenience method for above, which assumes stdMethodName,
+     * a return type of 'int', and no arguments.
+     */
+    public void assertThrows(java.lang.Class<?> exceptionType, Class target) {
+        assertThrows(exceptionType, target, stdCM, "-1");
+    }
+
+    private static <T> String toJoinedString(T[] a, String... p) {
+        return toJoinedString(Arrays.asList(a), p);
+    }
+
+    private static <T> String toJoinedString(List<T> list, String... p) {
+        StringBuilder sb = new StringBuilder();
+        String sep = "";
+        String init = "";
+        String end = "";
+        String empty = null;
+        switch (p.length) {
+            case 4:
+                empty = p[3];
+            /*fall-through*/
+            case 3:
+                end = p[2];
+            /*fall-through*/
+            case 2:
+                init = p[1];
+            /*fall-through*/
+            case 1:
+                sep = p[0];
+                break;
+        }
+        if (empty != null && list.isEmpty()) {
+            return empty;
+        } else {
+            sb.append(init);
+            for (T x : list) {
+                if (sb.length() != init.length()) {
+                    sb.append(sep);
+                }
+                sb.append(x.toString());
+            }
+            sb.append(end);
+            return sb.toString();
+        }
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java
new file mode 100644
index 0000000..d3578ee
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/ClassCase.java
@@ -0,0 +1,312 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class ClassCase {
+
+    public enum Kind {
+        IVAC        (true,  "v"),
+        IPRESENT    (true,  "p"),
+        IDEFAULT    (true,  "d"),
+        CNONE       (false, "n"),
+        CABSTRACT   (false, "a"),
+        CCONCRETE   (false, "c");
+
+        private final String prefix;
+        public final boolean isInterface;
+
+        Kind(boolean isInterface, String prefix) {
+            this.isInterface = isInterface;
+            this.prefix = prefix;
+        }
+
+        public String getPrefix() { return prefix; }
+    }
+
+    public final Kind kind;
+    private final ClassCase superclass;
+    private final List<ClassCase> supertypes;
+
+    private String name;
+    private boolean _OK;
+    private boolean _HasClassMethod;
+    private Set<ClassCase> _mprov;
+    private boolean _IsConcrete;
+    private boolean _HasDefault;
+    private ClassCase _mres;
+    private ClassCase _mdefend;
+
+    private Set<RuleGroup> executed = new HashSet<RuleGroup>();
+
+    public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
+        this.kind = kind;
+        this.superclass = superclass;
+
+        // Set supertypes from superclass (if any) and interfaces
+        List<ClassCase> lc;
+        if (superclass == null) {
+            lc = interfaces;
+        } else {
+            lc = new ArrayList<>();
+            lc.add(superclass);
+            lc.addAll(interfaces);
+        }
+        this.supertypes = lc;
+    }
+
+    public final boolean isInterface() { return kind.isInterface; }
+    public final boolean isClass() { return !kind.isInterface; }
+
+    public Set<ClassCase> get_mprov() {
+        exec(RuleGroup.PROVENENCE);
+        return _mprov;
+    }
+
+    public void set_mprov(ClassCase cc) {
+        Set<ClassCase> s = new HashSet<>();
+        s.add(cc);
+        _mprov = s;
+    }
+
+    public void set_mprov(Set<ClassCase> s) {
+        _mprov = s;
+    }
+
+    public ClassCase get_mres() {
+        exec(RuleGroup.RESOLUTION);
+        return _mres;
+    }
+
+    public void set_mres(ClassCase cc) {
+        _mres = cc;
+    }
+
+    public ClassCase get_mdefend() {
+        exec(RuleGroup.DEFENDER);
+        return _mdefend;
+    }
+
+    public void set_mdefend(ClassCase cc) {
+        _mdefend = cc;
+    }
+
+    public boolean get_HasClassMethod() {
+        exec(RuleGroup.PROVENENCE);
+        return _HasClassMethod;
+    }
+
+    public void set_HasClassMethod(boolean bool) {
+        _HasClassMethod = bool;
+    }
+
+    public boolean get_HasDefault() {
+        exec(RuleGroup.MARKER);
+        return _HasDefault;
+    }
+
+    public void set_HasDefault(boolean bool) {
+        _HasDefault = bool;
+    }
+
+    public boolean get_IsConcrete() {
+        exec(RuleGroup.MARKER);
+        return _IsConcrete;
+    }
+
+    public void set_IsConcrete(boolean bool) {
+        _IsConcrete = bool;
+    }
+
+    public boolean get_OK() {
+        exec(RuleGroup.CHECKING);
+        return _OK;
+    }
+
+    public void set_OK(boolean bool) {
+        _OK = bool;
+    }
+
+    public boolean isMethodDefined() {
+        for (ClassCase cc : supertypes) {
+            if (cc.isMethodDefined()) {
+                return true;
+            }
+        }
+        switch (kind) {
+            case CCONCRETE:
+            case CABSTRACT:
+            case IPRESENT:
+            case IDEFAULT:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    public boolean isAbstract() {
+        return isMethodDefined() && (get_mres()==null);
+    }
+
+    public boolean hasSuperclass() {
+        return superclass != null;
+    }
+
+    public ClassCase getSuperclass() {
+        return superclass;
+    }
+
+    public List<ClassCase> getSupertypes() {
+        return supertypes;
+    }
+
+    public List<ClassCase> getInterfaces() {
+        if (superclass != null) {
+            if (supertypes.get(0) != superclass) {
+                throw new AssertionError("superclass missing from supertypes");
+            }
+            return supertypes.subList(1, supertypes.size());
+        } else {
+            return supertypes;
+        }
+    }
+
+    public boolean isSubtypeOf(ClassCase cc) {
+        // S-Refl
+        if (cc.equals(this)) {
+            return true;
+        }
+
+        // S-Def
+        for (ClassCase sp : getSupertypes()) {
+            if (cc.equals(sp)) {
+                return true;
+            }
+        }
+
+        // _S-Trans
+        for (ClassCase sp : getSupertypes()) {
+            if (sp.isSubtypeOf(cc)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public void init(Map<String, Integer> namingContext) {
+        if (name != null) {
+            return; // Already inited
+        }
+
+        for (ClassCase sup : supertypes) {
+            sup.init(namingContext);
+        }
+
+        // Build name
+        StringBuilder sb = new StringBuilder();
+        if (!supertypes.isEmpty()) {
+            sb.append(isInterface() ? "I" : "C");
+            for (ClassCase cc : supertypes) {
+                sb.append(cc.getName());
+            }
+            sb.append(kind.isInterface ? "i" : "c");
+        }
+        sb.append(kind.prefix);
+        String pname = sb.toString();
+        Integer icnt = namingContext.get(pname);
+        int cnt = icnt == null ? 0 : icnt;
+        ++cnt;
+        namingContext.put(pname, cnt);
+        if (cnt > 1) {
+            sb.append(cnt);
+        }
+        this.name = sb.toString();
+    }
+
+    public boolean isa(Kind... kinds) {
+        for (Kind k : kinds) {
+            if (kind == k) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void exec(RuleGroup rg ) {
+        if (!executed.contains(rg)) {
+            rg.exec(this);
+            executed.add(rg);
+        }
+    }
+
+    public void collectClasses(Set<ClassCase> seen) {
+        seen.add(this);
+        for (ClassCase cc : supertypes) {
+            cc.collectClasses(seen);
+        }
+    }
+
+    public String getID() {
+        if (name == null) {
+            throw new Error("Access to uninitialized ClassCase");
+        } else {
+            return name;
+        }
+    }
+
+    public final String getName() {
+        if (name == null) {
+            return "ClassCase uninited@" + hashCode();
+        } else {
+            return name;
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
+    }
+
+    @Override
+    public int hashCode() {
+        return getID().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return getName();
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java
new file mode 100644
index 0000000..b594eec
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Hierarchy.java
@@ -0,0 +1,209 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class Hierarchy {
+
+    public final ClassCase root;
+    public final Set<ClassCase> all;
+
+    public Hierarchy(ClassCase root) {
+        this.root = root;
+        root.init(new HashMap<String,Integer>());
+        Set<ClassCase> allClasses = new HashSet<>();
+        root.collectClasses(allClasses);
+        this.all = allClasses;
+    }
+
+    public boolean anyDefaults() {
+        for (ClassCase cc : all) {
+            if (cc.kind == IDEFAULT) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean get_OK() {
+        return root.get_OK();
+    }
+
+    public String testName() {
+        return root + "Test";
+    }
+
+    private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
+            if (!interfaces.isEmpty()) {
+                buf.append(" ");
+                buf.append(prefix);
+                buf.append(" ");
+                buf.append(interfaces.get(0));
+                for (int i = 1; i < interfaces.size(); ++i) {
+                    buf.append(", " + interfaces.get(i));
+                }
+            }
+    }
+
+    public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
+        if (cc.isInterface()) {
+            buf.append("interface ");
+            buf.append(cc.getName() + " ");
+            genInterfaceList(buf, "extends", cc.getInterfaces());
+            buf.append(" {\n");
+
+            switch (cc.kind) {
+                case IDEFAULT:
+                    buf.append("    default String m() { return \"\"; }\n");
+                    defaultRef.add(cc);
+                    break;
+                case IPRESENT:
+                    buf.append("    String m();\n");
+                    break;
+                case IVAC:
+                    break;
+                default:
+                    throw new AssertionError("Unexpected kind");
+            }
+            buf.append("}\n\n");
+        } else {
+            buf.append((cc.isAbstract()? "abstract " : ""));
+            buf.append(" class " + cc.getName());
+            if (cc.getSuperclass() != null) {
+                buf.append(" extends " + cc.getSuperclass());
+            }
+
+            genInterfaceList(buf, "implements", cc.getInterfaces());
+            buf.append(" {\n");
+
+            switch (cc.kind) {
+                case CCONCRETE:
+                    buf.append("   public String m() { return \"\"; }\n");
+                    break;
+                case CABSTRACT:
+                    buf.append("   public abstract String m();\n");
+                    break;
+                case CNONE:
+                    break;
+                default:
+                    throw new AssertionError("Unexpected kind");
+            }
+            buf.append("}\n\n");
+        }
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
+    }
+
+    @Override
+    public int hashCode() {
+        return root.getID().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return root.getName();
+    }
+
+    private static String classNames[] = {
+        "C", "D", "E", "F", "G", "H", "S", "T", "U", "V"
+    };
+
+    private static String interfaceNames[] = {
+        "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R"
+    };
+
+    private static int CLASS_INDEX = 0;
+    private static int INTERFACE_INDEX = 1;
+    private static int NUM_INDICIES = 2;
+
+    public List<String> getDescription() {
+        Map<ClassCase,String> nameMap = new HashMap<>();
+        assignNames(root, new int[NUM_INDICIES], nameMap);
+
+        ArrayList<String> res = new ArrayList<>();
+        if (root.getSupertypes().size() == 0) {
+           res.add(nameMap.get(root) + root.kind.getPrefix() + "()");
+        } else {
+            genCaseDescription(root, res, new HashSet<ClassCase>(), nameMap);
+        }
+        return res;
+    }
+
+    private static void assignNames(
+            ClassCase cc, int indices[], Map<ClassCase,String> names) {
+        String name = names.get(cc);
+        if (name == null) {
+            if (cc.isInterface()) {
+                names.put(cc, interfaceNames[indices[INTERFACE_INDEX]++]);
+            } else {
+                names.put(cc, classNames[indices[CLASS_INDEX]++]);
+            }
+            for (int i = 0; i < cc.getSupertypes().size(); ++i) {
+                assignNames(cc.getSupertypes().get(i), indices, names);
+            }
+        }
+    }
+
+    private static void genCaseDescription(
+            ClassCase cc, List<String> res, Set<ClassCase> alreadyDone,
+            Map<ClassCase,String> nameMap) {
+        if (!alreadyDone.contains(cc)) {
+            if (cc.getSupertypes().size() > 0) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(nameMap.get(cc));
+                sb.append(cc.kind.getPrefix());
+                sb.append("(");
+                for (int i = 0; i < cc.getSupertypes().size(); ++i) {
+                    ClassCase supertype = cc.getSupertypes().get(i);
+                    if (i != 0) {
+                        sb.append(",");
+                    }
+                    genCaseDescription(supertype, res, alreadyDone, nameMap);
+                    sb.append(nameMap.get(supertype));
+                    sb.append(supertype.kind.getPrefix());
+                }
+                sb.append(")");
+                res.add(sb.toString());
+            }
+        }
+        alreadyDone.add(cc);
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java
new file mode 100644
index 0000000..828b313
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/HierarchyGenerator.java
@@ -0,0 +1,192 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import org.openjdk.tests.shapegen.ClassCase.Kind;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+import static java.lang.Math.pow;
+
+/**
+ *
+ * @author Robert Field
+ */
+public final class HierarchyGenerator {
+
+    private int okcnt = 0;
+    private int errcnt = 0;
+    private Set<Hierarchy> uniqueOK = new HashSet<>();
+    private Set<Hierarchy> uniqueErr = new HashSet<>();
+
+    /**
+     * @param args the command line arguments
+     */
+    public HierarchyGenerator() {
+        organize("exhaustive interface", iExhaustive(2));
+        organize("exhaustive class", cExhaustive());
+        organize("shapes interface", iShapes());
+        organize("shapes class/interface", ciShapes());
+
+        System.out.printf("\nExpect OK:    %d -- unique %d",   okcnt,  uniqueOK.size());
+        System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size());
+    }
+
+    public Collection<Hierarchy> getOK() {
+        return uniqueOK;
+    }
+
+    public Collection<Hierarchy> getErr() {
+        return uniqueErr;
+    }
+
+    private void organize(String tname, List<Hierarchy> totest) {
+        System.out.printf("\nGenerating %s....\n", tname);
+        int nodefault = 0;
+        List<Hierarchy> ok = new ArrayList<>();
+        List<Hierarchy> err = new ArrayList<>();
+        for (Hierarchy cc : totest) {
+            if (cc.anyDefaults()) {
+                //System.out.printf("  %s\n", cc);
+                if (cc.get_OK()) {
+                    ok.add(cc);
+                } else {
+                    err.add(cc);
+                }
+            } else {
+                ++nodefault;
+            }
+        }
+
+        errcnt += err.size();
+        okcnt += ok.size();
+        uniqueErr.addAll(err);
+        uniqueOK.addAll(ok);
+
+        System.out.printf("  %5d No default\n  %5d Error\n  %5d OK\n  %5d Total\n",
+                nodefault, err.size(), ok.size(), totest.size());
+    }
+
+    public List<Hierarchy> iExhaustive(int idepth) {
+        List<ClassCase> current = new ArrayList<>();
+        for (int i = 0; i < idepth; ++i) {
+            current = ilayer(current);
+        }
+        return wrapInClassAndHierarchy(current);
+    }
+
+    private List<ClassCase> ilayer(List<ClassCase> srcLayer) {
+        List<ClassCase> lay = new ArrayList<>();
+        for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) {
+            List<ClassCase> itfs = new ArrayList<>();
+            for (int b = srcLayer.size() - 1; b >= 0; --b) {
+                if ((i & (1<<b)) != 0) {
+                    itfs.add(srcLayer.get(b));
+                }
+            }
+            lay.add(new ClassCase(IVAC, null, itfs));
+            lay.add(new ClassCase(IPRESENT, null, itfs));
+            lay.add(new ClassCase(IDEFAULT, null, itfs));
+            lay.add(new ClassCase(IDEFAULT, null, itfs));
+        }
+        return lay;
+    }
+
+    public List<Hierarchy> cExhaustive() {
+        final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null};
+        final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE};
+        List<Hierarchy> totest = new ArrayList<>();
+        for (int i1 = 0; i1 < iKinds.length; ++i1) {
+            for (int i2 = 0; i2 < iKinds.length; ++i2) {
+                for (int i3 = 0; i3 < iKinds.length; ++i3) {
+                    for (int c1 = 0; c1 < cKinds.length; ++c1) {
+                        for (int c2 = 0; c2 < cKinds.length; ++c2) {
+                            for (int c3 = 0; c3 < cKinds.length; ++c3) {
+                                totest.add( new Hierarchy(
+                                        new ClassCase(cKinds[c1],
+                                            new ClassCase(cKinds[c2],
+                                                new ClassCase(cKinds[c3],
+                                                    null,
+                                                    iList(iKinds[i1])
+                                                ),
+                                                iList(iKinds[i2])
+                                            ),
+                                            iList(iKinds[i3])
+                                        )));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return totest;
+    }
+
+    public static final List<ClassCase> EMPTY_LIST = new ArrayList<>();
+
+    private List<ClassCase> iList(Kind kind) {
+        if (kind == null) {
+            return EMPTY_LIST;
+        } else {
+            List<ClassCase> itfs = new ArrayList<>();
+            itfs.add(new ClassCase(kind, null, EMPTY_LIST));
+            return itfs;
+        }
+    }
+
+    public List<Hierarchy> ciShapes() {
+        return wrapInHierarchy(TTShape.allCases(true));
+    }
+
+    public List<Hierarchy> iShapes() {
+        return wrapInClassAndHierarchy(TTShape.allCases(false));
+    }
+
+    public List<Hierarchy> wrapInClassAndHierarchy(List<ClassCase> ihs) {
+        List<Hierarchy> totest = new ArrayList<>();
+        for (ClassCase cc : ihs) {
+            List<ClassCase> interfaces = new ArrayList<>();
+            interfaces.add(cc);
+            totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces)));
+        }
+        return totest;
+    }
+
+    public List<Hierarchy> wrapInHierarchy(List<ClassCase> ihs) {
+        List<Hierarchy> totest = new ArrayList<>();
+        for (ClassCase cc : ihs) {
+            totest.add(new Hierarchy(cc));
+        }
+        return totest;
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java
new file mode 100644
index 0000000..a02eea9
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/Rule.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+/**
+ *
+ * @author Robert Field
+ */
+public abstract class Rule {
+
+    public final String name;
+
+    public Rule(String name) {
+        this.name = name;
+    }
+
+    abstract boolean guard(ClassCase cc);
+
+    abstract void eval(ClassCase cc);
+
+    @Override
+    public String toString() {
+        return name;
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java
new file mode 100644
index 0000000..0ff573b
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/RuleGroup.java
@@ -0,0 +1,206 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class RuleGroup {
+
+    final String name;
+    private final Rule[] rules;
+
+    public RuleGroup(String name, Rule[] rules) {
+        this.name = name;
+        this.rules = rules;
+    }
+
+    public boolean exec(ClassCase cc) {
+        boolean found = false;
+        for (Rule rule : rules) {
+            if (rule.guard(cc)) {
+                if (found) {
+                    throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc);
+                } else {
+                    rule.eval(cc);
+                    found = true;
+                }
+            }
+        }
+        return found;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] {
+      new Rule("P-CDeclare") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(CCONCRETE, CABSTRACT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc);
+              cc.set_HasClassMethod(true);
+          }
+      },
+
+      new Rule("P-IDeclare") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IDEFAULT, IPRESENT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc);
+          }
+      },
+
+      new Rule("P-IntfInh") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
+          }
+
+          void eval(ClassCase cc) {
+              Set<ClassCase> _S = new HashSet<>();
+              for (ClassCase t : cc.getSupertypes()) {
+                  _S.addAll(t.get_mprov());
+              }
+              Set<ClassCase> tops = new HashSet<>();
+              for (ClassCase _W : _S) {
+                  for (ClassCase _V : _S) {
+                      if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) {
+                          tops.add(_W);
+                      }
+                  }
+              }
+              cc.set_mprov(tops);
+          }
+      },
+
+      new Rule("P-ClassInh") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mprov(cc.getSuperclass());
+              cc.set_HasClassMethod(true);
+          }
+      },
+
+    });
+
+    public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] {
+      new Rule("M-Default") {
+          boolean guard(ClassCase cc) {
+              return cc.isa(IDEFAULT);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_HasDefault(true);
+          }
+      },
+
+      new Rule("M-Conc") {
+          boolean guard(ClassCase cc) {
+            return cc.isa(CCONCRETE);
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_IsConcrete(true);
+          }
+      },
+
+    });
+
+    public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] {
+      new Rule("R-Resolve") {
+          boolean guard(ClassCase cc) {
+              if (!(cc.isClass() && cc.get_mprov().size() == 1)) {
+                  return false;
+              }
+              ClassCase _V = cc.get_mprov().iterator().next();
+              return _V.get_IsConcrete() || _V.get_HasDefault();
+          }
+
+          void eval(ClassCase cc) {
+              ClassCase _V = cc.get_mprov().iterator().next();
+              cc.set_mres(_V);
+          }
+      },
+
+    });
+
+    public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] {
+      new Rule("D-Defend") {
+          boolean guard(ClassCase cc) {
+              ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null;
+              boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper);
+              return cc.isa(CNONE) && !eq;
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_mdefend(cc.get_mres());
+          }
+      },
+
+    });
+
+    public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] {
+      new Rule("C-Check") {
+          boolean guard(ClassCase cc) {
+              for (ClassCase t : cc.getSupertypes()) {
+                  if (! t.get_OK()) {
+                      return false;
+                  }
+              }
+              int defenderCount = 0;
+              int provCount = 0;
+              for (ClassCase prov : cc.get_mprov()) {
+                  if (prov.get_HasDefault()) {
+                      defenderCount++;
+                  }
+                  provCount++;
+              }
+              return provCount <= 1 || defenderCount == 0;
+          }
+
+          void eval(ClassCase cc) {
+              cc.set_OK(true);
+          }
+      },
+
+    });
+
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java
new file mode 100644
index 0000000..db0e835
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTNode.java
@@ -0,0 +1,126 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import org.openjdk.tests.shapegen.ClassCase.Kind;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.openjdk.tests.shapegen.ClassCase.Kind.*;
+
+/**
+ * Type Template Node
+ *
+ * @author Robert Field
+ */
+public class TTNode {
+
+    final List<TTNode> supertypes;
+    final boolean canBeClass;
+
+    private int currentKindIndex;
+    private Kind[] kinds;
+
+    public TTNode(List<TTNode> subtypes, boolean canBeClass) {
+        this.supertypes = subtypes;
+        this.canBeClass = canBeClass;
+    }
+
+    public void start(boolean includeClasses) {
+        kinds =
+             supertypes.isEmpty()?
+                (new Kind[]{IDEFAULT, IPRESENT})
+             :  ((includeClasses && canBeClass)?
+                  new Kind[]{CNONE, IVAC, IDEFAULT, IPRESENT}
+                : new Kind[]{IVAC, IDEFAULT, IPRESENT});
+        currentKindIndex = 0;
+
+        for (TTNode sub : supertypes) {
+            sub.start(includeClasses);
+        }
+    }
+
+    public boolean next() {
+        ++currentKindIndex;
+        if (currentKindIndex >= kinds.length) {
+            currentKindIndex = 0;
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    public void collectAllSubtypes(Set<TTNode> subs) {
+        subs.add(this);
+        for (TTNode n : supertypes) {
+            n.collectAllSubtypes(subs);
+        }
+    }
+
+    private Kind getKind() {
+        return kinds[currentKindIndex];
+    }
+
+    boolean isInterface() {
+        return getKind().isInterface;
+    }
+
+    boolean isClass() {
+        return !isInterface();
+    }
+
+    boolean hasDefault() {
+        return getKind() == IDEFAULT;
+    }
+
+    public boolean isValid() {
+        for (TTNode n : supertypes) {
+            if (!n.isValid() || (isInterface() && n.isClass())) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public ClassCase genCase() {
+        ClassCase subclass;
+        List<TTNode> ttintfs;
+        if (isClass() && !supertypes.isEmpty() && supertypes.get(0).isClass()) {
+            subclass = supertypes.get(0).genCase();
+            ttintfs = supertypes.subList(1, supertypes.size());
+        } else {
+            subclass = null;
+            ttintfs = supertypes;
+        }
+        List<ClassCase> intfs = new ArrayList<>();
+        for (TTNode node : ttintfs) {
+            intfs.add(node.genCase());
+        }
+        return new ClassCase(getKind(), subclass, intfs);
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java
new file mode 100644
index 0000000..f54eb37
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTParser.java
@@ -0,0 +1,100 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.StringReader;
+
+import static java.lang.Character.isLetter;
+import static java.lang.Character.isUpperCase;
+import static java.lang.Character.isWhitespace;
+
+/**
+ * Parse a type template definition string
+ *
+ *   input     :: classDef
+ *   classDef  :: letter [ ( classDef* ) ]
+ *
+ * @author Robert Field
+ */
+public class TTParser extends StringReader {
+
+    private Map<Character, TTNode> letterMap = new HashMap<>();
+    private char ch;
+
+    private final String def;
+
+    public TTParser(String s) {
+        super(s);
+        this.def = s;
+    }
+
+    private void advance() throws IOException {
+        do {
+            ch = (char)read();
+        } while (isWhitespace(ch));
+    }
+
+    public TTNode parse() {
+        try {
+            advance();
+            return classDef();
+        } catch (IOException t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private TTNode classDef() throws IOException {
+        if (!isLetter(ch)) {
+            if (ch == (char)-1) {
+                throw new IOException("Unexpected end of type template in " + def);
+            } else {
+                throw new IOException("Unexpected character in type template: " + (Character)ch + " in " + def);
+            }
+        }
+        char nodeCh = ch;
+        TTNode node = letterMap.get(nodeCh);
+        boolean canBeClass = isUpperCase(nodeCh);
+        advance();
+        if (node == null) {
+            List<TTNode> subtypes = new ArrayList<>();
+            if (ch == '(') {
+                advance();
+                while (ch != ')') {
+                    subtypes.add(classDef());
+                }
+                advance();
+            }
+            node = new TTNode(subtypes, canBeClass);
+            letterMap.put(nodeCh, node);
+        }
+        return node;
+    }
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java
new file mode 100644
index 0000000..07a23da
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/shapegen/TTShape.java
@@ -0,0 +1,104 @@
+/*
+ * 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 org.openjdk.tests.shapegen;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * @author Robert Field
+ */
+public class TTShape {
+
+    private final TTNode root;
+    private final TTNode[] nodes;
+
+    TTShape(TTNode root) {
+        this.root = root;
+        Set<TTNode> subs = new HashSet<>();
+        root.collectAllSubtypes(subs);
+        nodes = subs.toArray(new TTNode[subs.size()]);
+    }
+
+    private List<ClassCase> toCases(boolean includeClasses) {
+        List<ClassCase> ccs = new ArrayList<>();
+        root.start(includeClasses);
+        int i;
+        outer:
+        while (true) {
+            if (root.isValid()) {
+                ClassCase cc = root.genCase();
+                //System.out.println(cc);
+                ccs.add(cc);
+            }
+
+            i = 0;
+            do {
+                if (i >= nodes.length) {
+                    break outer;
+                }
+            } while(!nodes[i++].next());
+        }
+        return ccs;
+    }
+
+   public static List<ClassCase> allCases(boolean includeClasses) {
+        List<ClassCase> ccs = new ArrayList<>();
+        for (TTShape shape : SHAPES) {
+            ccs.addAll(shape.toCases(includeClasses));
+        }
+        return ccs;
+    }
+
+    public static TTShape parse(String s) {
+        return new TTShape(new TTParser(s).parse());
+    }
+
+    public static final TTShape[] SHAPES = new TTShape[] {
+        parse("a"),
+        parse("a(b)"),
+        parse("A(bb)"),
+        parse("A(B(d)c(d))"),
+        parse("A(b(c))"),
+        parse("A(B(cd)d)"),
+        parse("A(B(c)c)"),
+        parse("A(B(Ce)d(e))"),
+        parse("A(B(C)d(e))"),
+        parse("A(Bc(d))"),
+        parse("A(B(d)dc)"),
+        parse("A(B(dc)dc)"),
+        parse("A(B(c(d))d)"),
+        parse("A(B(C(d))d)"),
+        parse("A(B(C(e)d(e))e)"),
+        parse("A(B(c(d))c)"),
+        parse("A(B(dc(d))c)"),
+        parse("A(B(C(d))d)"),
+    };
+
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java
new file mode 100644
index 0000000..77500f2
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/DefaultMethodsTest.java
@@ -0,0 +1,820 @@
+/*
+ * 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 org.openjdk.tests.vm;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.io.File;
+import java.io.IOException;
+
+import org.testng.annotations.Test;
+import org.openjdk.tests.separate.*;
+import org.openjdk.tests.separate.Compiler;
+
+import static org.testng.Assert.*;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.openjdk.tests.separate.SourceModel.Class;
+
+ at Test(groups = "vm")
+public class DefaultMethodsTest extends TestHarness {
+    public DefaultMethodsTest() {
+        super(false, false);
+    }
+
+    /**
+     * class C { public int m() { return 22; } }
+     *
+     * TEST: C c = new C(); c.m() == 22
+     */
+    public void testHarnessInvokeVirtual() {
+        Class C = new Class("C", ConcreteMethod.std("22"));
+        assertInvokeVirtualEquals(22, C);
+    }
+
+    /**
+     * interface I { int m(); }
+     * class C implements I { public int m() { return 33; } }
+     *
+     * TEST: I i = new C(); i.m() == 33;
+     */
+    public void testHarnessInvokeInterface() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Class C = new Class("C", I, ConcreteMethod.std("33"));
+        assertInvokeInterfaceEquals(33, C, I);
+    }
+
+    /**
+     * class C {}
+     *
+     * TEST: C c = new C(); c.m() throws NoSuchMethod
+     */
+    public void testHarnessThrows() {
+        Class C = new Class("C");
+        assertThrows(NoSuchMethodError.class, C);
+    }
+
+    /**
+     * interface I { int m() default { return 44; } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: I i = new C(); i.m() == 44;
+     */
+    public void testBasicDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Class C = new Class("C", I);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 44; } }
+     * interface J extends I {}
+     * interface K extends J {}
+     * class C implements K {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: I i = new C(); i.m() == 44;
+     */
+    public void testFarDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", J);
+        Class C = new Class("C", K);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, K);
+    }
+
+    /**
+     * interface I { int m(); }
+     * interface J extends I { default int m() { return 44; } }
+     * interface K extends J {}
+     * class C implements K {}
+     *
+     * TEST: C c = new C(); c.m() == 44;
+     * TEST: K k = new C(); k.m() == 44;
+     */
+    public void testOverrideAbstract() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Interface J = new Interface("J", I, DefaultMethod.std("44"));
+        Interface K = new Interface("K", J);
+        Class C = new Class("C", K);
+
+        assertInvokeVirtualEquals(44, C);
+        assertInvokeInterfaceEquals(44, C, K);
+    }
+
+    /**
+     * interface I { int m() default { return 44; } }
+     * class C implements I { public int m() { return 55; } }
+     *
+     * TEST: C c = new C(); c.m() == 55;
+     * TEST: I i = new C(); i.m() == 55;
+     */
+    public void testExisting() {
+        Interface I = new Interface("I", DefaultMethod.std("44"));
+        Class C = new Class("C", I, ConcreteMethod.std("55"));
+
+        assertInvokeVirtualEquals(55, C);
+        assertInvokeInterfaceEquals(55, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testInherited() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class C { public int m() { return 11; } }
+     * class D extends C implements I {}
+     *
+     * TEST: D d = new D(); d.m() == 11;
+     * TEST: I i = new D(); i.m() == 11;
+     */
+    public void testExistingInherited() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class C = new Class("C", ConcreteMethod.std("11"));
+        Class D = new Class("D", C, I);
+
+        assertInvokeVirtualEquals(11, D);
+        assertInvokeInterfaceEquals(11, D, I);
+    }
+
+    /**
+     * interface I { default int m() { return 44; } }
+     * class C implements I { public int m() { return 11; } }
+     * class D extends C { public int m() { return 22; } }
+     *
+     * TEST: D d = new D(); d.m() == 22;
+     * TEST: I i = new D(); i.m() == 22;
+     */
+    void testExistingInheritedOverride() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class C = new Class("C", I, ConcreteMethod.std("11"));
+        Class D = new Class("D", C, ConcreteMethod.std("22"));
+
+        assertInvokeVirtualEquals(22, D);
+        assertInvokeInterfaceEquals(22, D, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J { defaultint m() { return 88; } }
+     * class C implements I { public int m() { return 11; } }
+     * class D extends C { public int m() { return 22; } }
+     * class E extends D implements J {}
+     *
+     * TEST: E e = new E(); e.m() == 22;
+     * TEST: J j = new E(); j.m() == 22;
+     */
+    public void testExistingInheritedPlusDefault() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, ConcreteMethod.std("11"));
+        Class D = new Class("D", C, ConcreteMethod.std("22"));
+        Class E = new Class("E", D, J);
+
+        assertInvokeVirtualEquals(22, E);
+        assertInvokeInterfaceEquals(22, E, J);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B { public int m() { return 77; } }
+     *
+     * TEST: C c = new C(); c.m() == 77;
+     * TEST: I i = new C(); i.m() == 77;
+     */
+    public void testInheritedWithConcrete() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B, ConcreteMethod.std("77"));
+
+        assertInvokeVirtualEquals(77, C);
+        assertInvokeInterfaceEquals(77, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class B implements I {}
+     * class C extends B implements I { public int m() { return 66; } }
+     *
+     * TEST: C c = new C(); c.m() == 66;
+     * TEST: I i = new C(); i.m() == 66;
+     */
+    public void testInheritedWithConcreteAndImpl() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Class B = new Class("B", I);
+        Class C = new Class("C", B, I, ConcreteMethod.std("66"));
+
+        assertInvokeVirtualEquals(66, C);
+        assertInvokeInterfaceEquals(66, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J { default int m() { return 88; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testConflict() {
+        // debugTest();
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { int m(); }
+     * interface J { default int m() { return 88; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testAmbiguousReabstract() {
+        Interface I = new Interface("I", AbstractMethod.std());
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Class C = new Class("C", I, J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { }
+     * interface K extends I { }
+     * class C implements J, K {}
+     *
+     * TEST: C c = new C(); c.m() == 99
+     * TEST: J j = new C(); j.m() == 99
+     * TEST: K k = new C(); k.m() == 99
+     * TEST: I i = new C(); i.m() == 99
+     */
+    public void testDiamond() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", I);
+        Class C = new Class("C", J, K);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, K);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { }
+     * interface K extends I { }
+     * interface L extends I { }
+     * interface M extends I { }
+     * class C implements I, J, K, L, M {}
+     *
+     * TEST: C c = new C(); c.m() == 99
+     * TEST: J j = new C(); j.m() == 99
+     * TEST: K k = new C(); k.m() == 99
+     * TEST: I i = new C(); i.m() == 99
+     * TEST: L l = new C(); l.m() == 99
+     * TEST: M m = new C(); m.m() == 99
+     */
+    public void testExpandedDiamond() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I);
+        Interface K = new Interface("K", I);
+        Interface L = new Interface("L", I);
+        Interface M = new Interface("M", L);
+        Class C = new Class("C", I, J, K, L, M);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, K);
+        assertInvokeInterfaceEquals(99, C, I);
+        assertInvokeInterfaceEquals(99, C, L);
+        assertInvokeInterfaceEquals(99, C, M);
+    }
+
+    /**
+     * interface I { int m() default { return 99; } }
+     * interface J extends I { int m(); }
+     * class C implements J {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     */
+    public void testReabstract() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I, AbstractMethod.std());
+        Class C = new Class("C", J);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 88; } }
+     * interface J extends I { default int m() { return 99; } }
+     * class C implements J {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: J j = new C(); j.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testShadow() {
+        Interface I = new Interface("I", DefaultMethod.std("88"));
+        Interface J = new Interface("J", I, DefaultMethod.std("99"));
+        Class C = new Class("C", J);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I { default int m() { return 88; } }
+     * interface J extends I { default int m() { return 99; } }
+     * class C implements I, J {}
+     *
+     * TEST: C c = new C(); c.m() == 99;
+     * TEST: J j = new C(); j.m() == 99;
+     * TEST: I i = new C(); i.m() == 99;
+     */
+    public void testDisqualified() {
+        Interface I = new Interface("I", DefaultMethod.std("88"));
+        Interface J = new Interface("J", I, DefaultMethod.std("99"));
+        Class C = new Class("C", I, J);
+
+        assertInvokeVirtualEquals(99, C);
+        assertInvokeInterfaceEquals(99, C, J);
+        assertInvokeInterfaceEquals(99, C, I);
+    }
+
+    /**
+     * interface I<T> { default int m(T t) { return 99; } }
+     * Class C implements I<String> { public int m() { return 88; } }
+     *
+     * TEST: C c = new C(); c.m() == 88;
+     * TEST: I i = new C(); i.m() == 88;
+     */
+    @Test(enabled=false)
+    public void testSelfFill() {
+        // This test ensures that a concrete method overrides a default method
+        // that matches at the language-level, but has a different method
+        // signature due to erasure.
+
+        // debugTest();
+
+        DefaultMethod dm = new DefaultMethod(
+            "int", "m", "return 99;", new MethodParameter("T", "t"));
+        ConcreteMethod cm = new ConcreteMethod(
+            "int", "m", "return 88;", AccessFlag.PUBLIC,
+            new MethodParameter("String", "s"));
+
+        Interface I = new Interface("I", new TypeParameter("T"), dm);
+        Class C = new Class("C", I.with("String"), cm);
+
+        AbstractMethod pm = new AbstractMethod(
+            "int", "m", new MethodParameter("T", "t"));
+
+        assertInvokeVirtualEquals(new Integer(88), C, cm, "-1", "\"string\"");
+        assertInvokeInterfaceEquals(
+            new Integer(88), C, I.with("String"), pm, "\"string\"");
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * class C implements I {}
+     *
+     * TEST: C.class.getMethod("m").invoke(new C()) == 99
+     */
+    public void testReflectCall() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        //workaround accessibility issue when loading C with DirectedClassLoader
+        I.addAccessFlag(AccessFlag.PUBLIC);
+        Class C = new Class("C", I);
+
+        Compiler.Flags[] flags = this.verbose ?
+            new Compiler.Flags[] { Compiler.Flags.VERBOSE } :
+            new Compiler.Flags[] {};
+        Compiler compiler = new Compiler(flags);
+        java.lang.Class<?> cls = null;
+        try {
+            cls = compiler.compileAndLoad(C);
+        } catch (ClassNotFoundException e) {
+            fail("Could not load class");
+        }
+
+        java.lang.reflect.Method method = null;
+        try {
+            method = cls.getMethod(stdMethodName);
+        } catch (NoSuchMethodException e) {
+            fail("Could not find method in class");
+        }
+        assertNotNull(method);
+
+        Object c = null;
+        try {
+            c = cls.newInstance();
+        } catch (InstantiationException | IllegalAccessException e) {
+            fail("Could not create instance of class");
+        }
+        assertNotNull(c);
+
+        Integer res = null;
+        try {
+            res = (Integer)method.invoke(c);
+        } catch (IllegalAccessException |
+                 java.lang.reflect.InvocationTargetException e) {
+            fail("Could not invoke default instance method");
+        }
+        assertNotNull(res);
+
+        assertEquals(res.intValue(), 99);
+
+        compiler.cleanup();
+    }
+
+    /**
+     * interface I<T,V,W> { default int m(T t, V v, W w) { return 99; } }
+     * interface J<T,V> extends I<String,T,V> { int m(T t, V v, String w); } }
+     * interface K<T> extends J<String,T> { int m(T t, String v, String w); } }
+     * class C implements K<String> {
+     *     public int m(String t, String v, String w) { return 88; }
+     * }
+     *
+     * TEST: I<String,String,String> i = new C(); i.m("A","B","C") == 88;
+     * TEST: J<String,String> j = new C(); j.m("A","B","C") == 88;
+     * TEST: K<String> k = new C(); k.m("A","B","C") == 88;
+     */
+    @Test(enabled=false)
+    public void testBridges() {
+        DefaultMethod dm = new DefaultMethod("int", stdMethodName, "return 99;",
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("W", "w"));
+
+        AbstractMethod pm0 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("W", "w"));
+
+        AbstractMethod pm1 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("V", "v"),
+            new MethodParameter("String", "w"));
+
+        AbstractMethod pm2 = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("T", "t"), new MethodParameter("String", "v"),
+            new MethodParameter("String", "w"));
+
+        ConcreteMethod cm = new ConcreteMethod("int",stdMethodName,"return 88;",
+            AccessFlag.PUBLIC,
+            new MethodParameter("String", "t"),
+            new MethodParameter("String", "v"),
+            new MethodParameter("String", "w"));
+
+        Interface I = new Interface("I", new TypeParameter("T"),
+            new TypeParameter("V"), new TypeParameter("W"), dm);
+        Interface J = new Interface("J",
+            new TypeParameter("T"), new TypeParameter("V"),
+            I.with("String", "T", "V"), pm1);
+        Interface K = new Interface("K", new TypeParameter("T"),
+            J.with("String", "T"), pm2);
+        Class C = new Class("C", K.with("String"), cm);
+
+        String[] args = new String[] { "\"A\"", "\"B\"", "\"C\"" };
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            I.with("String", "String", "String"), pm0, args);
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            J.with("String", "String"), pm1, args);
+        assertInvokeInterfaceEquals(new Integer(88), C,
+            K.with("String"), pm2, args);
+    }
+
+    /**
+     * interface J { default int m() { return 88; } }
+     * interface I extends J { default int m() { return J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() == 88;
+     * TEST: I i = new C(); i.m() == 88;
+     */
+    public void testSuperBasic() {
+        // debugTest();
+
+        Interface J = new Interface("J", DefaultMethod.std("88"));
+        Interface I = new Interface("I", J, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        I.addCompilationDependency(J.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertInvokeVirtualEquals(88, C);
+        assertInvokeInterfaceEquals(88, C, I);
+    }
+
+    /**
+     * interface K { int m() default { return 99; } }
+     * interface L { int m() default { return 101; } }
+     * interface J extends K, L {}
+     * interface I extends J, K { int m() default { J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for K k = new C(); k.m() throws AME
+     */
+    public void testSuperConflict() {
+        // debugTest();
+
+        Interface K = new Interface("K", DefaultMethod.std("99"));
+        Interface L = new Interface("L", DefaultMethod.std("101"));
+        Interface J = new Interface("J", K, L);
+        Interface I = new Interface("I", J, K, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        Interface Jstub = new Interface("J", DefaultMethod.std("-1"));
+        I.addCompilationDependency(Jstub);
+        I.addCompilationDependency(Jstub.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface I { default int m() { return 99; } }
+     * interface J extends I { default int m() { return 55; } }
+     * class C implements I, J { public int m() { return I.super.m(); } }
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for J j = new C(); j.m() throws AME
+     */
+    public void testSuperDisqual() {
+        Interface I = new Interface("I", DefaultMethod.std("99"));
+        Interface J = new Interface("J", I, DefaultMethod.std("55"));
+        Class C = new Class("C", I, J,
+            new ConcreteMethod("int", stdMethodName, "return I.super.m();",
+                AccessFlag.PUBLIC));
+        C.addCompilationDependency(I.findMethod(stdMethodName));
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface J { int m(); }
+     * interface I extends J { default int m() { return J.super.m(); } }
+     * class C implements I {}
+     *
+     * TEST: C c = new C(); c.m() throws AME
+     * TODO: add case for I i = new C(); i.m() throws AME
+     */
+    public void testSuperNull() {
+        Interface J = new Interface("J", AbstractMethod.std());
+        Interface I = new Interface("I", J, new DefaultMethod(
+            "int", stdMethodName, "return J.super.m();"));
+        Interface Jstub = new Interface("J", DefaultMethod.std("99"));
+        I.addCompilationDependency(Jstub);
+        I.addCompilationDependency(Jstub.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        assertThrows(AbstractMethodError.class, C);
+    }
+
+    /**
+     * interface J<T> { default int m(T t) { return 88; } }
+     * interface I extends J<String> {
+     *     int m(String s) default { return J.super.m(); }
+     * }
+     * class C implements I {}
+     *
+     * TEST: I i = new C(); i.m("") == 88;
+     */
+    public void testSuperGeneric() {
+        Interface J = new Interface("J", new TypeParameter("T"),
+            new DefaultMethod("int", stdMethodName, "return 88;",
+                new MethodParameter("T", "t")));
+        Interface I = new Interface("I", J.with("String"),
+            new DefaultMethod("int", stdMethodName, "return J.super.m(s);",
+                new MethodParameter("String", "s")));
+        I.addCompilationDependency(J.findMethod(stdMethodName));
+        Class C = new Class("C", I);
+
+        AbstractMethod pm = new AbstractMethod("int", stdMethodName,
+            new MethodParameter("String", "s"));
+
+        assertInvokeInterfaceEquals(
+            new Integer(88), C, new Extends(I), pm, "\"\"");
+    }
+
+    /**
+     * interface I<T> { int m(T t) default { return 44; } }
+     * interface J extends I<String> { int m(String s) default { return 55; } }
+     * class C implements I<String>, J {
+     *     public int m(String s) { return I.super.m(s); }
+     * }
+     *
+     * TEST: C c = new C(); c.m("string") throws AME
+     */
+    public void testSuperGenericDisqual() {
+        MethodParameter t = new MethodParameter("T", "t");
+        MethodParameter s = new MethodParameter("String", "s");
+
+        Interface I = new Interface("I", new TypeParameter("T"),
+            new DefaultMethod("int", stdMethodName, "return 44;", t));
+        Interface J = new Interface("J", I.with("String"),
+            new DefaultMethod("int", stdMethodName, "return 55;", s));
+        Class C = new Class("C", I.with("String"), J,
+            new ConcreteMethod("int", stdMethodName,
+                "return I.super.m(s);", AccessFlag.PUBLIC, s));
+        C.addCompilationDependency(I.findMethod(stdMethodName));
+
+        assertThrows(AbstractMethodError.class, C,
+            new ConcreteMethod(
+                "int", stdMethodName, "return -1;", AccessFlag.PUBLIC, s),
+            "-1", "\"string\"");
+    }
+
+    /**
+     * interface I { default Integer m() { return new Integer(88); } }
+     * class C { Number m() { return new Integer(99); } }
+     * class D extends C implements I {}
+     * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
+     * TEST: S s = new S(); s.foo() == new Integer(99)
+     */
+    @Test(enabled=false)
+    public void testCovarBridge() {
+        Interface I = new Interface("I", new DefaultMethod(
+            "Integer", "m", "return new Integer(88);"));
+        Class C = new Class("C", new ConcreteMethod(
+            "Number", "m", "return new Integer(99);", AccessFlag.PUBLIC));
+        Class D = new Class("D", I, C);
+
+        ConcreteMethod DstubMethod = new ConcreteMethod(
+            "Integer", "m", "return null;", AccessFlag.PUBLIC);
+        Class Dstub = new Class("D", DstubMethod);
+
+        ConcreteMethod toCall = new ConcreteMethod(
+            "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC);
+        Class S = new Class("S", D, toCall);
+        S.addCompilationDependency(Dstub);
+        S.addCompilationDependency(DstubMethod);
+
+        assertInvokeVirtualEquals(new Integer(99), S, toCall, "null");
+    }
+
+    /**
+     * interface I { default Integer m() { return new Integer(88); } }
+     * class C { int m() { return 99; } }
+     * class D extends C implements I {}
+     * class S { Object foo() { return (new D()).m(); } // link sig: ()LInteger;
+     * TEST: S s = new S(); s.foo() == new Integer(88)
+     */
+    public void testNoCovarNoBridge() {
+        Interface I = new Interface("I", new DefaultMethod(
+            "Integer", "m", "return new Integer(88);"));
+        Class C = new Class("C", new ConcreteMethod(
+            "int", "m", "return 99;", AccessFlag.PUBLIC));
+        Class D = new Class("D", I, C);
+
+        ConcreteMethod DstubMethod = new ConcreteMethod(
+            "Integer", "m", "return null;", AccessFlag.PUBLIC);
+        Class Dstub = new Class("D", DstubMethod);
+
+        ConcreteMethod toCall = new ConcreteMethod(
+            "Object", "foo", "return (new D()).m();", AccessFlag.PUBLIC);
+        Class S = new Class("S", D, toCall);
+        S.addCompilationDependency(Dstub);
+        S.addCompilationDependency(DstubMethod);
+
+        assertInvokeVirtualEquals(new Integer(88), S, toCall, "null");
+    }
+
+    /**
+     * interface J { int m(); }
+     * interface I extends J { default int m() { return 99; } }
+     * class B implements J {}
+     * class C extends B implements I {}
+     * TEST: C c = new C(); c.m() == 99
+     *
+     * The point of this test is that B does not get default method analysis,
+     * and C does not generate any new miranda methods in the vtable.
+     * It verifies that default method analysis occurs when mirandas have been
+     * inherited and the supertypes don't have any overpass methods.
+     */
+    public void testNoNewMiranda() {
+        Interface J = new Interface("J", AbstractMethod.std());
+        Interface I = new Interface("I", J, DefaultMethod.std("99"));
+        Class B = new Class("B", J);
+        Class C = new Class("C", B, I);
+        assertInvokeVirtualEquals(99, C);
+    }
+
+    /**
+     * interface I<T,V,W> { int m(T t, V v, W w); }
+     * interface J<T,V> implements I<T,V,String> { int m(T t, V v, String w); }
+     * interface K<T> implements J<T,String> {
+     *     int m(T t, String v, String w); { return 99; } }
+     * class C implements K<String> {
+     *     public int m(Object t, Object v, String w) { return 77; }
+     * }
+     * TEST C = new C(); ((I)c).m(Object,Object,Object) == 99
+     * TEST C = new C(); ((J)c).m(Object,Object,String) == 77
+     * TEST C = new C(); ((K)c).m(Object,String,String) == 99
+     *
+     * Test that a erased-signature-matching method does not implement
+     * non-language-level matching methods
+     */
+    @Test(enabled=false)
+    public void testNonConcreteFill() {
+        AbstractMethod ipm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("V", "s"),
+            new MethodParameter("W", "w"));
+        Interface I = new Interface("I",
+            new TypeParameter("T"),
+            new TypeParameter("V"),
+            new TypeParameter("W"), ipm);
+
+        AbstractMethod jpm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("V", "s"),
+            new MethodParameter("String", "w"));
+        Interface J = new Interface("J",
+            new TypeParameter("T"),
+            new TypeParameter("V"),
+            I.with("T", "V", "String"), jpm);
+
+        AbstractMethod kpm = new AbstractMethod("int", "m",
+            new MethodParameter("T", "t"),
+            new MethodParameter("String", "s"),
+            new MethodParameter("String", "w"));
+        Interface K = new Interface("K",
+            new TypeParameter("T"),
+            J.with("T", "String"),
+            new DefaultMethod("int", "m", "return 99;",
+                new MethodParameter("T", "t"),
+                new MethodParameter("String", "v"),
+                new MethodParameter("String", "w")));
+
+        Class C = new Class("C",
+            K.with("String"),
+            new ConcreteMethod("int", "m", "return 77;",
+                AccessFlag.PUBLIC,
+                new MethodParameter("Object", "t"),
+                new MethodParameter("Object", "v"),
+                new MethodParameter("String", "w")));
+
+        String a = "\"\"";
+        assertInvokeInterfaceEquals(99, C,
+            K.with("String"), kpm, a, a, a);
+        assertInvokeInterfaceEquals(77, C,
+            J.with("String", "String"), jpm, a, a, a);
+        assertInvokeInterfaceEquals(99, C,
+            I.with("String", "String", "String"), ipm, a, a, a);
+    }
+
+    public void testStrictfpDefault() {
+        try {
+            java.lang.Class.forName("org.openjdk.tests.vm.StrictfpDefault");
+        } catch (Exception e) {
+            fail("Could not load class", e);
+        }
+    }
+}
+
+interface StrictfpDefault {
+    default strictfp void m() {}
+}
diff --git a/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java b/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java
new file mode 100644
index 0000000..9626b45
--- /dev/null
+++ b/test/tools/javac/lambdaShapes/org/openjdk/tests/vm/FDSeparateCompilationTest.java
@@ -0,0 +1,200 @@
+/*
+ * 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.  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.
+ */
+
+// this test has been disabled because of timeout issues.
+// see JDK-8006746
+
+package org.openjdk.tests.vm;
+
+import java.util.*;
+
+import org.testng.ITestResult;
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+
+import org.openjdk.tests.separate.*;
+import org.openjdk.tests.separate.Compiler;
+
+import org.openjdk.tests.shapegen.Hierarchy;
+import org.openjdk.tests.shapegen.HierarchyGenerator;
+import org.openjdk.tests.shapegen.ClassCase;
+
+import static org.testng.Assert.*;
+import static org.openjdk.tests.separate.SourceModel.*;
+import static org.openjdk.tests.separate.SourceModel.Class;
+import static org.openjdk.tests.separate.SourceModel.Method;
+import static org.openjdk.tests.separate.SourceModel.Type;
+
+public class FDSeparateCompilationTest extends TestHarness {
+
+    private static String EMPTY = "\"\"";
+
+    public FDSeparateCompilationTest() {
+        super(false, true);
+    }
+
+    @DataProvider(name = "allShapes", parallel = true)
+    public Object[][] hierarchyGenerator() {
+        ArrayList<Object[]> allCases = new ArrayList<>();
+
+        HierarchyGenerator hg = new HierarchyGenerator();
+        for (Object x : hg.getOK()) {
+            allCases.add(new Object[]{x});
+        }
+        for (Object x : hg.getErr()) {
+            allCases.add(new Object[]{x});
+        }
+        return allCases.toArray(new Object[0][]);
+    }
+
+    // The expected value obtained when invoking the method from the specified
+    // class.  If returns null, then an AbstractMethodError is expected.
+    private static String getExpectedResult(ClassCase cc) {
+        Set<ClassCase> provs = cc.get_mprov();
+        if (cc.get_mres() != null) {
+            return cc.get_mres().getName();
+        } else if (provs != null && provs.size() == 1) {
+            ClassCase cand = provs.iterator().next();
+            switch (cand.kind) {
+                case CCONCRETE:
+                case IDEFAULT:
+                    return cand.getName();
+                case CNONE:
+                case IVAC:
+                    return getExpectedResult(cand);
+            }
+        }
+        return null;
+    }
+
+    private static final ConcreteMethod canonicalMethod = new ConcreteMethod(
+            "String", "m", "returns " + EMPTY + ";", AccessFlag.PUBLIC);
+
+    @Test(enabled = false, groups = "vm", dataProvider = "allShapes")
+    public void separateCompilationTest(Hierarchy hs) {
+        ClassCase cc = hs.root;
+        Type type = sourceTypeFrom(hs.root);
+
+        Class specimen = null;
+        if (type instanceof Class) {
+            Class ctype = (Class)type;
+            if (ctype.isAbstract()) {
+                specimen = new Class("Test" + ctype.getName(), ctype);
+            } else {
+                specimen = ctype;
+            }
+        } else {
+            specimen = new Class("Test" + type.getName(), (Interface)type);
+        }
+
+        String value = getExpectedResult(cc);
+        if (value != null) {
+            assertInvokeVirtualEquals(value, specimen, canonicalMethod, EMPTY);
+        } else {
+            assertThrows(AbstractMethodError.class, specimen,
+                canonicalMethod, EMPTY);
+        }
+    }
+
+    @AfterMethod
+    public void printCaseError(ITestResult result) {
+        if (result.getStatus() == ITestResult.FAILURE) {
+            Hierarchy hs = (Hierarchy)result.getParameters()[0];
+            System.out.println("Separate compilation case " + hs);
+            printCaseDetails(hs);
+        }
+    }
+
+    @AfterSuite
+    public void cleanupCompilerCache() {
+        Compiler.purgeCache();
+    }
+
+    private void printCaseDetails(Hierarchy hs) {
+        String exp = getExpectedResult(hs.root);
+        for (String s : hs.getDescription()) {
+             System.out.println("    " + s);
+        }
+        if (exp != null) {
+            System.out.println("    Expected \"" + exp + "\"");
+        } else {
+            System.out.println("    Expected AbstractMethodError");
+        }
+    }
+
+    private Type sourceTypeFrom(ClassCase cc) {
+        Type type = null;
+
+        if (cc.isInterface()) {
+            Interface iface = new Interface(cc.getName());
+            for (ClassCase scc : cc.getInterfaces()) {
+                Interface supertype = (Interface)sourceTypeFrom(scc);
+                iface.addSuperType(supertype);
+            }
+            type = iface;
+        } else {
+            Class cls = new Class(cc.getName());
+            if (cc.hasSuperclass()) {
+                Class superc = (Class)sourceTypeFrom(cc.getSuperclass());
+                cls.setSuperClass(superc);
+            }
+            for (ClassCase scc : cc.getInterfaces()) {
+                Interface supertype = (Interface)sourceTypeFrom(scc);
+                cls.addSuperType(supertype);
+            }
+            if (cc.isAbstract()) {
+                cls.getAccessFlags().add(AccessFlag.ABSTRACT);
+            }
+            type = cls;
+        }
+        Method method = methodFrom(cc);
+        if (method != null) {
+            type.addMethod(method);
+        }
+        return type;
+    }
+
+    private Method methodFrom(ClassCase cc) {
+        switch (cc.kind) {
+            case IVAC:
+            case CNONE: return null;
+            case IPRESENT:
+            case CABSTRACT:
+                return new AbstractMethod("String", "m", AccessFlag.PUBLIC);
+            case IDEFAULT:
+                return new DefaultMethod(
+                    "String", "m", "return \"" + cc.getName() + "\";");
+            case CCONCRETE:
+                return new ConcreteMethod(
+                    "String", "m", "return \"" + cc.getName() + "\";",
+                    AccessFlag.PUBLIC);
+            default:
+                fail("Unknown method type in class");
+                return null;
+        }
+    }
+}
diff --git a/test/tools/javac/lib/CompileFail.java b/test/tools/javac/lib/CompileFail.java
index cc03a65..328c271 100644
--- a/test/tools/javac/lib/CompileFail.java
+++ b/test/tools/javac/lib/CompileFail.java
@@ -23,6 +23,7 @@
 
 import java.io.*;
 import java.util.*;
+import com.sun.tools.javac.main.Main;
 
 /*
  * Utility class to emulate jtreg @compile/fail, but also checking the specific
@@ -41,7 +42,7 @@ public class CompileFail {
         ));
 
         File testSrc = new File(System.getProperty("test.src"));
-        for (int i = 1; i < args.length; i++) {
+        for (int i = 1; i < args.length; i++) { // skip first arg
             String arg = args[i];
             if (arg.endsWith(".java"))
                 javacArgs.add(new File(testSrc, arg).getPath());
@@ -58,32 +59,7 @@ public class CompileFail {
     }
 
     static int getReturnCode(String name) {
-        switch (name) {
-            case "OK":
-                return EXIT_OK;
-
-            case "ERROR":
-                return EXIT_ERROR;
-
-            case "CMDERR":
-                return EXIT_CMDERR;
-
-            case "SYSERR":
-                return EXIT_SYSERR;
-
-            case "ABNORMAL":
-                return EXIT_ABNORMAL;
-
-            default:
-                throw new IllegalArgumentException(name);
-        }
+        return Main.Result.valueOf(name).exitCode;
     }
 
-    // The following is cut-n-paste from com.sun.tools.javac.main.Main
-    static final int
-        EXIT_OK = 0,        // Compilation completed with no errors.
-        EXIT_ERROR = 1,     // Completed but reported errors.
-        EXIT_CMDERR = 2,    // Bad command-line arguments
-        EXIT_SYSERR = 3,    // System error or resource exhaustion.
-        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
 }
diff --git a/test/tools/javac/lib/DPrinter.java b/test/tools/javac/lib/DPrinter.java
new file mode 100644
index 0000000..8df4881
--- /dev/null
+++ b/test/tools/javac/lib/DPrinter.java
@@ -0,0 +1,1333 @@
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.tools.FileObject;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.code.Annotations;
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Kinds;
+import com.sun.tools.javac.code.Printer;
+import com.sun.tools.javac.code.Scope;
+import com.sun.tools.javac.code.Scope.CompoundScope;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.TypeTag;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.Pretty;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+
+
+/**
+ * Debug printer for javac internals, for when toString() just isn't enough.
+ *
+ * <p>
+ * The printer provides an API to generate structured views of javac objects,
+ * such as AST nodes, symbol, types and annotations. Various aspects of the
+ * output can be configured, such as whether to show nulls, empty lists, or
+ * a compressed representation of the source code. Visitors are used to walk
+ * object hierarchies, and can be replaced with custom visitors if the default
+ * visitors are not flexible enough.
+ *
+ * <p>
+ * In general, nodes are printed with an initial line identifying the node
+ * followed by indented lines for the child nodes. Currently, graphs are
+ * represented by printing a spanning subtree.
+ *
+ * <p>
+ * The printer can be accessed via a simple command-line utility,
+ * which makes it easy to see the internal representation of source code,
+ * such as simple test programs, during the compilation pipeline.
+ *
+ *  <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 DPrinter {
+    protected final PrintWriter out;
+    protected final Trees trees;
+    protected Printer printer;
+    protected boolean showEmptyItems = true;
+    protected boolean showNulls = true;
+    protected boolean showPositions = false;
+    protected boolean showSrc;
+    protected boolean showTreeSymbols;
+    protected boolean showTreeTypes;
+    protected int maxSrcLength = 32;
+    protected Locale locale = Locale.getDefault();
+    protected static final String NULL = "#null";
+
+    // <editor-fold defaultstate="collapsed" desc="Configuration">
+
+    public static DPrinter instance(Context context) {
+        DPrinter dp = context.get(DPrinter.class);
+        if (dp == null) {
+            dp = new DPrinter(context);
+        }
+        return dp;
+
+    }
+
+    protected DPrinter(Context context) {
+        context.put(DPrinter.class, this);
+        out = context.get(Log.outKey);
+        trees = JavacTrees.instance(context);
+    }
+
+    public DPrinter(PrintWriter out, Trees trees) {
+        this.out = out;
+        this.trees = trees;
+    }
+
+    public DPrinter emptyItems(boolean showEmptyItems) {
+        this.showEmptyItems = showEmptyItems;
+        return this;
+    }
+
+    public DPrinter nulls(boolean showNulls) {
+        this.showNulls = showNulls;
+        return this;
+    }
+
+    public DPrinter positions(boolean showPositions) {
+        this.showPositions = showPositions;
+        return this;
+    }
+
+    public DPrinter source(boolean showSrc) {
+        this.showSrc = showSrc;
+        return this;
+    }
+
+    public DPrinter source(int maxSrcLength) {
+        this.showSrc = true;
+        this.maxSrcLength = maxSrcLength;
+        return this;
+    }
+
+    public DPrinter treeSymbols(boolean showTreeSymbols) {
+        this.showTreeSymbols = showTreeSymbols;
+        return this;
+    }
+
+    public DPrinter treeTypes(boolean showTreeTypes) {
+        this.showTreeTypes = showTreeTypes;
+        return this;
+    }
+
+    public DPrinter typeSymbolPrinter(Printer p) {
+        printer = p;
+        return this;
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Printing">
+
+    protected enum Details {
+        /** A one-line non-recursive summary */
+        SUMMARY,
+        /** Multi-line, possibly recursive. */
+        FULL
+    };
+
+    public void printAnnotations(String label, Annotations annotations) {
+        printAnnotations(label, annotations, Details.FULL);
+    }
+
+    protected void printAnnotations(String label, Annotations annotations, Details details) {
+        if (annotations == null) {
+            printNull(label);
+        } else {
+            // no SUMMARY format currently available to use
+
+            // use reflection to get at private fields
+            Object DECL_NOT_STARTED = getField(null, Annotations.class, "DECL_NOT_STARTED");
+            Object DECL_IN_PROGRESS = getField(null, Annotations.class, "DECL_IN_PROGRESS");
+            Object attributes = getField(annotations, Annotations.class, "attributes");
+            Object type_attributes = getField(annotations, Annotations.class, "type_attributes");
+
+            if (!showEmptyItems) {
+                if (attributes instanceof List && ((List) attributes).isEmpty()
+                        && attributes != DECL_NOT_STARTED
+                        && attributes != DECL_IN_PROGRESS
+                        && type_attributes instanceof List && ((List) type_attributes).isEmpty())
+                    return;
+            }
+
+            printString(label, hashString(annotations));
+
+            indent(+1);
+            if (attributes == DECL_NOT_STARTED)
+                printString("attributes", "DECL_NOT_STARTED");
+            else if (attributes == DECL_IN_PROGRESS)
+                printString("attributes", "DECL_IN_PROGRESS");
+            else if (attributes instanceof List)
+                printList("attributes", (List) attributes);
+            else
+                printObject("attributes", attributes, Details.SUMMARY);
+
+            if (attributes instanceof List)
+                printList("type_attributes", (List) type_attributes);
+            else
+                printObject("type_attributes", type_attributes, Details.SUMMARY);
+            indent(-1);
+        }
+    }
+
+    public void printAttribute(String label, Attribute attr) {
+        if (attr == null) {
+            printNull(label);
+        } else {
+            printString(label, attr.getClass().getSimpleName());
+
+            indent(+1);
+            attr.accept(attrVisitor);
+            indent(-1);
+        }
+    }
+
+    public void printFileObject(String label, FileObject fo) {
+        if (fo == null) {
+            printNull(label);
+        } else {
+            printString(label, fo.getName());
+        }
+    }
+
+    protected <T> void printImplClass(T item, Class<? extends T> stdImplClass) {
+        if (item.getClass() != stdImplClass)
+            printString("impl", item.getClass().getName());
+    }
+
+    public void printInt(String label, int i) {
+        printString(label, String.valueOf(i));
+    }
+
+    public void printList(String label, List<?> list) {
+        if (list == null) {
+             printNull(label);
+        } else if (!list.isEmpty() || showEmptyItems) {
+            printString(label, "[" + list.size() + "]");
+
+            indent(+1);
+            int i = 0;
+            for (Object item: list) {
+                printObject(String.valueOf(i++), item, Details.FULL);
+            }
+            indent(-1);
+        }
+    }
+
+    public void printName(String label, Name name) {
+        if (name == null) {
+            printNull(label);
+        } else {
+            printString(label, name.toString());
+        }
+    }
+
+    public void printNull(String label) {
+        if (showNulls)
+            printString(label, NULL);
+    }
+
+    protected void printObject(String label, Object item, Details details) {
+        if (item == null) {
+            printNull(label);
+        } else if (item instanceof Attribute) {
+            printAttribute(label, (Attribute) item);
+        } else if (item instanceof Symbol) {
+            printSymbol(label, (Symbol) item, details);
+        } else if (item instanceof Type) {
+            printType(label, (Type) item, details);
+        } else if (item instanceof JCTree) {
+            printTree(label, (JCTree) item);
+        } else if (item instanceof List) {
+            printList(label, (List) item);
+        } else if (item instanceof Name) {
+            printName(label, (Name) item);
+        } else {
+            printString(label, String.valueOf(item));
+        }
+    }
+
+    public void printScope(String label, Scope scope) {
+        printScope(label, scope, Details.FULL);
+    }
+
+    public void printScope(String label, Scope scope, Details details) {
+        if (scope == null) {
+            printNull(label);
+        } else {
+            switch (details) {
+                case SUMMARY: {
+                    indent();
+                    out.print(label);
+                    out.print(": [");
+                    String sep = "";
+                    for (Symbol sym: scope.getElements()) {
+                        out.print(sep);
+                        out.print(sym.name);
+                        sep = ",";
+                    }
+                    out.println("]");
+                    break;
+                }
+
+                case FULL: {
+                    indent();
+                    out.println(label);
+
+                    indent(+1);
+                    printImplClass(scope, Scope.class);
+                    printSymbol("owner", scope.owner, Details.SUMMARY);
+                    printScope("next", scope.next, Details.SUMMARY);
+                    printObject("shared", getField(scope, Scope.class, "shared"), Details.SUMMARY);
+                    if (scope instanceof CompoundScope) {
+                        printObject("subScopes",
+                                getField(scope, CompoundScope.class, "subScopes"),
+                                Details.FULL);
+                    } else {
+                        for (Symbol sym : scope.getElements()) {
+                            printSymbol(sym.name.toString(), sym, Details.SUMMARY);
+                        }
+                    }
+                    indent(-1);
+                    break;
+                }
+            }
+        }
+    }
+
+    public void printSource(String label, JCTree tree) {
+        printString(label, Pretty.toSimpleString(tree, maxSrcLength));
+    }
+
+    public void printString(String label, String text) {
+        indent();
+        out.print(label);
+        out.print(": ");
+        out.print(text);
+        out.println();
+    }
+
+    public void printSymbol(String label, Symbol symbol) {
+        printSymbol(label, symbol, Details.FULL);
+    }
+
+    protected void printSymbol(String label, Symbol sym, Details details) {
+        if (sym == null) {
+            printNull(label);
+        } else {
+            switch (details) {
+            case SUMMARY:
+                printString(label, toString(sym));
+                break;
+
+            case FULL:
+                indent();
+                out.print(label);
+                out.println(": " +
+                        info(sym.getClass(),
+                            String.format("0x%x--%s", sym.kind, Kinds.kindName(sym)),
+                            sym.getKind())
+                        + " " + sym.name
+                        + " " + hashString(sym));
+
+                indent(+1);
+                if (showSrc) {
+                    JCTree tree = (JCTree) trees.getTree(sym);
+                    if (tree != null)
+                        printSource("src", tree);
+                }
+                printString("flags", String.format("0x%x--%s",
+                        sym.flags_field, Flags.toString(sym.flags_field)));
+                printObject("completer", sym.completer, Details.SUMMARY); // what if too long?
+                printSymbol("owner", sym.owner, Details.SUMMARY);
+                printType("type", sym.type, Details.SUMMARY);
+                printType("erasure", sym.erasure_field, Details.SUMMARY);
+                sym.accept(symVisitor, null);
+                printAnnotations("annotations", sym.getAnnotations(), Details.SUMMARY);
+                indent(-1);
+            }
+        }
+    }
+
+    protected String toString(Symbol sym) {
+        return (printer != null) ? printer.visit(sym, locale) : String.valueOf(sym);
+    }
+
+    protected void printTree(String label, JCTree tree) {
+        if (tree == null) {
+            printNull(label);
+        } else {
+            indent();
+            String ext;
+            try {
+                ext = tree.getKind().name();
+            } catch (Throwable t) {
+                ext = "n/a";
+            }
+            out.print(label + ": " + info(tree.getClass(), tree.getTag(), ext));
+            if (showPositions) {
+                // We can always get start position, but to get end position
+                // and/or line+offset, we would need a JCCompilationUnit
+                out.print(" pos:" + tree.pos);
+            }
+            if (showTreeTypes && tree.type != null)
+                out.print(" type:" + toString(tree.type));
+            Symbol sym;
+            if (showTreeSymbols && (sym = TreeInfo.symbolFor(tree)) != null)
+                out.print(" sym:" + toString(sym));
+            out.println();
+
+            indent(+1);
+            if (showSrc) {
+                indent();
+                out.println("src: " + Pretty.toSimpleString(tree, maxSrcLength));
+            }
+            tree.accept(treeVisitor);
+            indent(-1);
+        }
+    }
+
+    public void printType(String label, Type type) {
+        printType(label, type, Details.FULL);
+    }
+
+    protected void printType(String label, Type type, Details details) {
+        if (type == null)
+            printNull(label);
+        else {
+            switch (details) {
+                case SUMMARY:
+                    printString(label, toString(type));
+                    break;
+
+                case FULL:
+                    indent();
+                    out.print(label);
+                    out.println(": " + info(type.getClass(), type.getTag(), type.getKind())
+                            + " " + hashString(type));
+
+                    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);
+            }
+        }
+    }
+
+    protected String toString(Type type) {
+        return (printer != null) ? printer.visit(type, locale) : String.valueOf(type);
+    }
+
+    protected String hashString(Object obj) {
+        return String.format("#%x", obj.hashCode());
+    }
+
+    protected String info(Class<?> clazz, Object internal, Object external) {
+        return String.format("%s,%s,%s", clazz.getSimpleName(), internal, external);
+    }
+
+    private int indent = 0;
+
+    protected void indent() {
+        for (int i = 0; i < indent; i++) {
+            out.print("  ");
+        }
+    }
+
+    protected void indent(int n) {
+        indent += n;
+    }
+
+    protected Object getField(Object o, Class<?> clazz, String name) {
+        try {
+            Field f = clazz.getDeclaredField(name);
+            boolean prev = f.isAccessible();
+            f.setAccessible(true);
+            try {
+                return f.get(o);
+            } finally {
+                f.setAccessible(prev);
+            }
+        } catch (ReflectiveOperationException e) {
+            return e;
+        } catch (SecurityException e) {
+            return e;
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="JCTree visitor methods">
+
+    protected JCTree.Visitor treeVisitor = new TreeVisitor();
+
+    /**
+     * Default visitor class for JCTree (AST) objects.
+     */
+    public class TreeVisitor extends JCTree.Visitor {
+        @Override
+        public void visitTopLevel(JCCompilationUnit tree) {
+            printList("packageAnnotations", tree.packageAnnotations);
+            printTree("pid", tree.pid);
+            printList("defs", tree.defs);
+        }
+
+        @Override
+        public void visitImport(JCImport tree) {
+            printTree("qualid", tree.qualid);
+        }
+
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            printName("name", tree.name);
+            printTree("mods", tree.mods);
+            printList("typarams", tree.typarams);
+            printTree("extending", tree.extending);
+            printList("implementing", tree.implementing);
+            printList("defs", tree.defs);
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            printName("name", tree.name);
+            printTree("mods", tree.mods);
+            printTree("restype", tree.restype);
+            printList("typarams", tree.typarams);
+            printTree("recvparam", tree.recvparam);
+            printList("params", tree.params);
+            printList("thrown", tree.thrown);
+            printTree("defaultValue", tree.defaultValue);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            printName("name", tree.name);
+            printTree("mods", tree.mods);
+            printTree("vartype", tree.vartype);
+            printTree("init", tree.init);
+        }
+
+        @Override
+        public void visitSkip(JCSkip tree) {
+        }
+
+        @Override
+        public void visitBlock(JCBlock tree) {
+            printList("stats", tree.stats);
+        }
+
+        @Override
+        public void visitDoLoop(JCDoWhileLoop tree) {
+            printTree("body", tree.body);
+            printTree("cond", tree.cond);
+        }
+
+        @Override
+        public void visitWhileLoop(JCWhileLoop tree) {
+            printTree("cond", tree.cond);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitForLoop(JCForLoop tree) {
+            printList("init", tree.init);
+            printTree("cond", tree.cond);
+            printList("step", tree.step);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitForeachLoop(JCEnhancedForLoop tree) {
+            printTree("var", tree.var);
+            printTree("expr", tree.expr);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitLabelled(JCLabeledStatement tree) {
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitSwitch(JCSwitch tree) {
+            printTree("selector", tree.selector);
+            printList("cases", tree.cases);
+        }
+
+        @Override
+        public void visitCase(JCCase tree) {
+            printTree("pat", tree.pat);
+            printList("stats", tree.stats);
+        }
+
+        @Override
+        public void visitSynchronized(JCSynchronized tree) {
+            printTree("lock", tree.lock);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitTry(JCTry tree) {
+            printList("resources", tree.resources);
+            printTree("body", tree.body);
+            printList("catchers", tree.catchers);
+            printTree("finalizer", tree.finalizer);
+        }
+
+        @Override
+        public void visitCatch(JCCatch tree) {
+            printTree("param", tree.param);
+            printTree("body", tree.body);
+        }
+
+        @Override
+        public void visitConditional(JCConditional tree) {
+            printTree("cond", tree.cond);
+            printTree("truepart", tree.truepart);
+            printTree("falsepart", tree.falsepart);
+        }
+
+        @Override
+        public void visitIf(JCIf tree) {
+            printTree("cond", tree.cond);
+            printTree("thenpart", tree.thenpart);
+            printTree("elsepart", tree.elsepart);
+        }
+
+        @Override
+        public void visitExec(JCExpressionStatement tree) {
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitBreak(JCBreak tree) {
+            printName("label", tree.label);
+        }
+
+        @Override
+        public void visitContinue(JCContinue tree) {
+            printName("label", tree.label);
+        }
+
+        @Override
+        public void visitReturn(JCReturn tree) {
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitThrow(JCThrow tree) {
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitAssert(JCAssert tree) {
+            printTree("cond", tree.cond);
+            printTree("detail", tree.detail);
+        }
+
+        @Override
+        public void visitApply(JCMethodInvocation tree) {
+            printList("typeargs", tree.typeargs);
+            printTree("meth", tree.meth);
+            printList("args", tree.args);
+        }
+
+        @Override
+        public void visitNewClass(JCNewClass tree) {
+            printTree("encl", tree.encl);
+            printList("typeargs", tree.typeargs);
+            printTree("clazz", tree.clazz);
+            printList("args", tree.args);
+            printTree("def", tree.def);
+        }
+
+        @Override
+        public void visitNewArray(JCNewArray tree) {
+            printList("annotations", tree.annotations);
+            printTree("elemtype", tree.elemtype);
+            printList("dims", tree.dims);
+            printList("dimAnnotations", tree.dimAnnotations);
+            printList("elems", tree.elems);
+        }
+
+        @Override
+        public void visitLambda(JCLambda tree) {
+            printTree("body", tree.body);
+            printList("params", tree.params);
+        }
+
+        @Override
+        public void visitParens(JCParens tree) {
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitAssign(JCAssign tree) {
+            printTree("lhs", tree.lhs);
+            printTree("rhs", tree.rhs);
+        }
+
+        @Override
+        public void visitAssignop(JCAssignOp tree) {
+            printTree("lhs", tree.lhs);
+            printTree("rhs", tree.rhs);
+        }
+
+        @Override
+        public void visitUnary(JCUnary tree) {
+            printTree("arg", tree.arg);
+        }
+
+        @Override
+        public void visitBinary(JCBinary tree) {
+            printTree("lhs", tree.lhs);
+            printTree("rhs", tree.rhs);
+        }
+
+        @Override
+        public void visitTypeCast(JCTypeCast tree) {
+            printTree("clazz", tree.clazz);
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitTypeTest(JCInstanceOf tree) {
+            printTree("expr", tree.expr);
+            printTree("clazz", tree.clazz);
+        }
+
+        @Override
+        public void visitIndexed(JCArrayAccess tree) {
+            printTree("indexed", tree.indexed);
+            printTree("index", tree.index);
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            printTree("selected", tree.selected);
+        }
+
+        @Override
+        public void visitReference(JCMemberReference tree) {
+            printTree("expr", tree.expr);
+            printList("typeargs", tree.typeargs);
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            printName("name", tree.name);
+        }
+
+        @Override
+        public void visitLiteral(JCLiteral tree) {
+            printString("value", Pretty.toSimpleString(tree, 32));
+        }
+
+        @Override
+        public void visitTypeIdent(JCPrimitiveTypeTree tree) {
+            printString("typetag", tree.typetag.name());
+        }
+
+        @Override
+        public void visitTypeArray(JCArrayTypeTree tree) {
+            printTree("elemtype", tree.elemtype);
+        }
+
+        @Override
+        public void visitTypeApply(JCTypeApply tree) {
+            printTree("clazz", tree.clazz);
+            printList("arguments", tree.arguments);
+        }
+
+        @Override
+        public void visitTypeUnion(JCTypeUnion tree) {
+            printList("alternatives", tree.alternatives);
+        }
+
+        @Override
+        public void visitTypeIntersection(JCTypeIntersection tree) {
+            printList("bounds", tree.bounds);
+        }
+
+        @Override
+        public void visitTypeParameter(JCTypeParameter tree) {
+            printName("name", tree.name);
+            printList("annotations", tree.annotations);
+            printList("bounds", tree.bounds);
+        }
+
+        @Override
+        public void visitWildcard(JCWildcard tree) {
+            printTree("kind", tree.kind);
+            printTree("inner", tree.inner);
+        }
+
+        @Override
+        public void visitTypeBoundKind(TypeBoundKind tree) {
+            printString("kind", tree.kind.name());
+        }
+
+        @Override
+        public void visitModifiers(JCModifiers tree) {
+            printList("annotations", tree.annotations);
+            printString("flags", String.valueOf(Flags.asFlagSet(tree.flags)));
+        }
+
+        @Override
+        public void visitAnnotation(JCAnnotation tree) {
+            printTree("annotationType", tree.annotationType);
+            printList("args", tree.args);
+        }
+
+        @Override
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            printList("annotations", tree.annotations);
+            printTree("underlyingType", tree.underlyingType);
+        }
+
+        @Override
+        public void visitErroneous(JCErroneous tree) {
+            printList("errs", tree.errs);
+        }
+
+        @Override
+        public void visitLetExpr(LetExpr tree) {
+            printList("defs", tree.defs);
+            printTree("expr", tree.expr);
+        }
+
+        @Override
+        public void visitTree(JCTree tree) {
+            Assert.error();
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Symbol visitor">
+
+    protected Symbol.Visitor<Void,Void> symVisitor = new SymbolVisitor();
+
+    /**
+     * Default visitor class for Symbol objects.
+     * Note: each visitXYZ method ends by calling the corresponding
+     * visit method for its superclass.
+     */
+    class SymbolVisitor implements Symbol.Visitor<Void,Void> {
+        @Override
+        public Void visitClassSymbol(ClassSymbol sym, Void ignore) {
+            printName("fullname", sym.fullname);
+            printName("flatname", sym.flatname);
+            printScope("members", sym.members_field);
+            printFileObject("sourcefile", sym.sourcefile);
+            printFileObject("classfile", sym.classfile);
+            // trans-local?
+            // pool?
+            return visitTypeSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitMethodSymbol(MethodSymbol sym, Void ignore) {
+            // code
+            printList("params", sym.params);
+            printList("savedParameterNames", sym.savedParameterNames);
+            return visitSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitPackageSymbol(PackageSymbol sym, Void ignore) {
+            printName("fullname", sym.fullname);
+            printScope("members", sym.members_field);
+            printSymbol("package-info", sym.package_info, Details.SUMMARY);
+            return visitTypeSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitOperatorSymbol(OperatorSymbol sym, Void ignore) {
+            printInt("opcode", sym.opcode);
+            return visitMethodSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitVarSymbol(VarSymbol sym, Void ignore) {
+            printInt("pos", sym.pos);
+            printInt("adm", sym.adr);
+            // data is a private field, and the standard accessors may
+            // mutate it as part of lazy evaluation. Therefore, use
+            // reflection to get the raw data.
+            printObject("data", getField(sym, VarSymbol.class, "data"), Details.SUMMARY);
+            return visitSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitTypeSymbol(TypeSymbol sym, Void ignore) {
+            return visitSymbol(sym, null);
+        }
+
+        @Override
+        public Void visitSymbol(Symbol sym, Void ignore) {
+            return null;
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Type visitor">
+
+    protected Type.Visitor<Void,Void> typeVisitor = new TypeVisitor();
+
+    /**
+     * Default visitor class for Type objects.
+     * Note: each visitXYZ method ends by calling the corresponding
+     * visit method for its superclass.
+     */
+    public class TypeVisitor implements Type.Visitor<Void,Void> {
+        public Void visitAnnotatedType(AnnotatedType type, Void ignore) {
+            printList("typeAnnotations", type.typeAnnotations);
+            printType("underlyingType", type.underlyingType, Details.FULL);
+            return visitType(type, null);
+        }
+
+        public Void visitArrayType(ArrayType type, Void ignore) {
+            printType("elemType", type.elemtype, Details.FULL);
+            return visitType(type, null);
+        }
+
+        public Void visitCapturedType(CapturedType type, Void ignore) {
+            printType("wildcard", type.wildcard, Details.FULL);
+            return visitTypeVar(type, null);
+        }
+
+        public Void visitClassType(ClassType type, Void ignore) {
+            printType("outer", type.getEnclosingType(), Details.SUMMARY);
+            printList("typarams", type.typarams_field);
+            printList("allparams", type.allparams_field);
+            printType("supertype", type.supertype_field, Details.SUMMARY);
+            printList("interfaces", type.interfaces_field);
+            printList("allinterfaces", type.all_interfaces_field);
+            return visitType(type, null);
+        }
+
+        public Void visitErrorType(ErrorType type, Void ignore) {
+            printType("originalType", type.getOriginalType(), Details.FULL);
+            return visitClassType(type, null);
+        }
+
+        public Void visitForAll(ForAll type, Void ignore) {
+            printList("tvars", type.tvars);
+            return visitDelegatedType(type);
+        }
+
+        public Void visitMethodType(MethodType type, Void ignore) {
+            printList("argtypes", type.argtypes);
+            printType("restype", type.restype, Details.FULL);
+            printList("thrown", type.thrown);
+            return visitType(type, null);
+        }
+
+        public Void visitPackageType(PackageType type, Void ignore) {
+            return visitType(type, null);
+        }
+
+        public Void visitTypeVar(TypeVar type, Void ignore) {
+            // For TypeVars (and not subtypes), the bound should always be
+            // null or bot. So, only print the bound for subtypes of TypeVar,
+            // or if the bound is (erroneously) not null or bot.
+            if (!type.hasTag(TypeTag.TYPEVAR)
+                    || !(type.bound == null || type.bound.hasTag(TypeTag.BOT))) {
+                printType("bound", type.bound, Details.FULL);
+            }
+            printType("lower", type.lower, Details.FULL);
+            return visitType(type, null);
+        }
+
+        public Void visitUndetVar(UndetVar type, Void ignore) {
+            for (UndetVar.InferenceBound ib: UndetVar.InferenceBound.values())
+                printList("bounds." + ib, type.getBounds(ib));
+            printInt("declaredCount", type.declaredCount);
+            printType("inst", type.inst, Details.SUMMARY);
+            return visitDelegatedType(type);
+        }
+
+        public Void visitWildcardType(WildcardType type, Void ignore) {
+            printType("type", type.type, Details.SUMMARY);
+            printString("kind", type.kind.name());
+            printType("bound", type.bound, Details.SUMMARY);
+            return visitType(type, null);
+        }
+
+        protected Void visitDelegatedType(DelegatedType type) {
+            printType("qtype", type.qtype, Details.FULL);
+            return visitType(type, null);
+        }
+
+        public Void visitType(Type type, Void ignore) {
+            return null;
+        }
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Attribute (annotations) visitor">
+
+    protected Attribute.Visitor attrVisitor = new AttributeVisitor();
+
+    /**
+     * Default visitor class for Attribute (annotation) objects.
+     */
+    public class AttributeVisitor implements Attribute.Visitor {
+
+        public void visitConstant(Attribute.Constant a) {
+            printObject("value", a.value, Details.SUMMARY);
+            visitAttribute(a);
+        }
+
+        public void visitClass(Attribute.Class a) {
+            printObject("classType", a.classType, Details.SUMMARY);
+            visitAttribute(a);
+        }
+
+        public void visitCompound(Attribute.Compound a) {
+            if (a instanceof Attribute.TypeCompound) {
+                Attribute.TypeCompound ta = (Attribute.TypeCompound) a;
+                // consider a custom printer?
+                printObject("position", ta.position, Details.SUMMARY);
+            }
+            printObject("synthesized", a.isSynthesized(), Details.SUMMARY);
+            printList("values", a.values);
+            visitAttribute(a);
+        }
+
+        public void visitArray(Attribute.Array a) {
+            printList("values", Arrays.asList(a.values));
+            visitAttribute(a);
+        }
+
+        public void visitEnum(Attribute.Enum a) {
+            printSymbol("value", a.value, Details.SUMMARY);
+            visitAttribute(a);
+        }
+
+        public void visitError(Attribute.Error a) {
+            visitAttribute(a);
+        }
+
+        public void visitAttribute(Attribute a) {
+            printType("type", a.type, Details.SUMMARY);
+        }
+
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Utility front end">
+
+    /**
+     * Utility class to invoke DPrinter from the command line.
+     */
+    static class Main {
+        public static void main(String... args) throws IOException {
+            Main m = new Main();
+            PrintWriter out = new PrintWriter(System.out);
+            try {
+                if (args.length == 0)
+                    m.usage(out);
+                else
+                    m.run(out, args);
+            } finally {
+                out.flush();
+            }
+        }
+
+        void usage(PrintWriter out) {
+            out.println("Usage:");
+            out.println("  java " + Main.class.getName() + " mode [options] [javac-options]");
+            out.print("where mode is one of: ");
+            String sep = "";
+            for (Handler h: getHandlers().values()) {
+                out.print(sep);
+                out.print(h.name);
+                sep = ", ";
+            }
+            out.println();
+            out.println("and where options include:");
+            out.println("  -before PARSE|ENTER|ANALYZE|GENERATE|ANNOTATION_PROCESSING|ANNOTATION_PROCESSING_ROUND");
+            out.println("  -after PARSE|ENTER|ANALYZE|GENERATE|ANNOTATION_PROCESSING|ANNOTATION_PROCESSING_ROUND");
+            out.println("  -showPositions");
+            out.println("  -showSource");
+            out.println("  -showTreeSymbols");
+            out.println("  -showTreeTypes");
+            out.println("  -hideEmptyItems");
+            out.println("  -hideNulls");
+        }
+
+        void run(PrintWriter out, String... args) throws IOException {
+            JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+            StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+
+            // DPrinter options
+            final Set<TaskEvent.Kind> before = EnumSet.noneOf(TaskEvent.Kind.class);
+            final Set<TaskEvent.Kind> after = EnumSet.noneOf(TaskEvent.Kind.class);
+            boolean showPositions = false;
+            boolean showSource = false;
+            boolean showTreeSymbols = false;
+            boolean showTreeTypes = false;
+            boolean showEmptyItems = true;
+            boolean showNulls = true;
+
+            // javac options
+            Collection<String> options = new ArrayList<String>();
+            Collection<File> files = new ArrayList<File>();
+            String classpath = null;
+            String classoutdir = null;
+
+            final Handler h = getHandlers().get(args[0]);
+            if (h == null)
+                throw new IllegalArgumentException(args[0]);
+
+            for (int i = 1; i < args.length; i++) {
+                String arg = args[i];
+                if (arg.equals("-before") && i + 1 < args.length) {
+                    before.add(getKind(args[++i]));
+                } else if (arg.equals("-after") && i + 1 < args.length) {
+                    after.add(getKind(args[++i]));
+                } else if (arg.equals("-showPositions")) {
+                    showPositions = true;
+                } else if (arg.equals("-showSource")) {
+                    showSource = true;
+                } else if (arg.equals("-showTreeSymbols")) {
+                    showTreeSymbols = true;
+                } else if (arg.equals("-showTreeTypes")) {
+                    showTreeTypes = true;
+                } else if (arg.equals("-hideEmptyLists")) {
+                    showEmptyItems = false;
+                } else if (arg.equals("-hideNulls")) {
+                    showNulls = false;
+                } else if (arg.equals("-classpath") && i + 1 < args.length) {
+                    classpath = args[++i];
+                } else if (arg.equals("-d") && i + 1 < args.length) {
+                    classoutdir = args[++i];
+                } else if (arg.startsWith("-")) {
+                    int n = c.isSupportedOption(arg);
+                    if (n < 0) throw new IllegalArgumentException(arg);
+                    options.add(arg);
+                    while (n > 0) options.add(args[++i]);
+                } else if (arg.endsWith(".java")) {
+                    files.add(new File(arg));
+                }
+            }
+
+            if (classoutdir != null) {
+                fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(classoutdir)));
+            }
+
+            if (classpath != null) {
+                Collection<File> path = new ArrayList<File>();
+                for (String p: classpath.split(File.pathSeparator)) {
+                    if (p.isEmpty()) continue;
+                    File f = new File(p);
+                    if (f.exists()) path.add(f);
+                }
+                fm.setLocation(StandardLocation.CLASS_PATH, path);
+            }
+            Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjectsFromFiles(files);
+
+            JavacTask task = (JavacTask) c.getTask(out, fm, null, options, null, fos);
+            final Trees trees = Trees.instance(task);
+
+            final DPrinter dprinter = new DPrinter(out, trees);
+            dprinter.source(showSource)
+                    .emptyItems(showEmptyItems)
+                    .nulls(showNulls)
+                    .positions(showPositions)
+                    .treeSymbols(showTreeSymbols)
+                    .treeTypes(showTreeTypes);
+
+            if (before.isEmpty() && after.isEmpty()) {
+                if (h.name.equals("trees") && !showTreeSymbols && !showTreeTypes)
+                    after.add(TaskEvent.Kind.PARSE);
+                else
+                    after.add(TaskEvent.Kind.ANALYZE);
+            }
+
+            task.addTaskListener(new TaskListener() {
+                public void started(TaskEvent e) {
+                    if (before.contains(e.getKind()))
+                        handle(e);
+                }
+
+                public void finished(TaskEvent e) {
+                    if (after.contains(e.getKind()))
+                        handle(e);
+                }
+
+                private void handle(TaskEvent e) {
+                     switch (e.getKind()) {
+                         case PARSE:
+                         case ENTER:
+                             h.handle(e.getSourceFile().getName(),
+                                     (JCTree) e.getCompilationUnit(),
+                                     dprinter);
+                             break;
+
+                         default:
+                             TypeElement elem = e.getTypeElement();
+                             h.handle(elem.toString(),
+                                     (JCTree) trees.getTree(elem),
+                                     dprinter);
+                             break;
+                     }
+                }
+            });
+
+            task.call();
+        }
+
+        TaskEvent.Kind getKind(String s) {
+            return TaskEvent.Kind.valueOf(s.toUpperCase());
+        }
+
+        static protected abstract class Handler {
+            final String name;
+            Handler(String name) {
+                this.name = name;
+            }
+            abstract void handle(String label, JCTree tree, DPrinter dprinter);
+        }
+
+        Map<String,Handler> getHandlers() {
+            Map<String,Handler> map = new HashMap<String, Handler>();
+            for (Handler h: defaultHandlers) {
+                map.put(h.name, h);
+            }
+            return map;
+        }
+
+        protected final Handler[] defaultHandlers = {
+            new Handler("trees") {
+                @Override
+                void handle(String name, JCTree tree, DPrinter dprinter) {
+                    dprinter.printTree(name, tree);
+                    dprinter.out.println();
+                }
+            },
+
+            new Handler("symbols") {
+                @Override
+                void handle(String name, JCTree tree, final DPrinter dprinter) {
+                    TreeScanner ds = new TreeScanner() {
+                        @Override
+                        public void visitClassDef(JCClassDecl tree) {
+                            visitDecl(tree, tree.sym);
+                            super.visitClassDef(tree);
+                        }
+
+                        @Override
+                        public void visitMethodDef(JCMethodDecl tree) {
+                            visitDecl(tree, tree.sym);
+                            super.visitMethodDef(tree);
+                        }
+
+                        @Override
+                        public void visitVarDef(JCVariableDecl tree) {
+                            visitDecl(tree, tree.sym);
+                            super.visitVarDef(tree);
+                        }
+
+                        void visitDecl(JCTree tree, Symbol sym) {
+                            dprinter.printSymbol(sym.name.toString(), sym);
+                            dprinter.out.println();
+                        }
+                    };
+                    ds.scan(tree);
+                }
+            },
+
+            new Handler("types") {
+                @Override
+                void handle(String name, JCTree tree, final DPrinter dprinter) {
+                    TreeScanner ts = new TreeScanner() {
+                        @Override
+                        public void scan(JCTree tree) {
+                            if (tree == null) {
+                                return;
+                            }
+                            if (tree.type != null) {
+                                String label = Pretty.toSimpleString(tree);
+                                dprinter.printType(label, tree.type);
+                                dprinter.out.println();
+                            }
+                            super.scan(tree);
+                        }
+                    };
+                    ts.scan(tree);
+                }
+            }
+        };
+    }
+
+    // </editor-fold>
+
+}
diff --git a/test/tools/javac/lib/JavacTestingAbstractProcessor.java b/test/tools/javac/lib/JavacTestingAbstractProcessor.java
index 4960cac..67e824c 100644
--- a/test/tools/javac/lib/JavacTestingAbstractProcessor.java
+++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java
@@ -25,6 +25,7 @@ import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.util.*;
+import static javax.lang.model.SourceVersion.*;
 
 /**
  * An abstract annotation processor tailored to javac regression testing.
@@ -95,4 +96,164 @@ public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
         messager  = processingEnv.getMessager();
         options   = processingEnv.getOptions();
     }
+
+    /*
+     * The set of visitors below will directly extend the most recent
+     * corresponding platform visitor type.
+     */
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static abstract class AbstractAnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor8<R, P> {
+
+        /**
+         * Constructor for concrete subclasses to call.
+         */
+        protected AbstractAnnotationValueVisitor() {
+            super();
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static abstract class AbstractElementVisitor<R, P> extends AbstractElementVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses to call.
+         */
+        protected AbstractElementVisitor(){
+            super();
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static abstract class AbstractTypeVisitor<R, P> extends AbstractTypeVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses to call.
+         */
+        protected AbstractTypeVisitor() {
+            super();
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class ElementKindVisitor<R, P> extends ElementKindVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses; uses {@code null} for the
+         * default value.
+         */
+        protected ElementKindVisitor() {
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses; uses the argument for the
+         * default value.
+         *
+         * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+         */
+        protected ElementKindVisitor(R defaultValue) {
+            super(defaultValue);
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class ElementScanner<R, P> extends ElementScanner8<R, P> {
+        /**
+         * Constructor for concrete subclasses; uses {@code null} for the
+         * default value.
+         */
+        protected ElementScanner(){
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses; uses the argument for the
+         * default value.
+         */
+        protected ElementScanner(R defaultValue){
+            super(defaultValue);
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class SimpleAnnotationValueVisitor<R, P> extends SimpleAnnotationValueVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses; uses {@code null} for the
+         * default value.
+         */
+        protected SimpleAnnotationValueVisitor() {
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses; uses the argument for the
+         * default value.
+         *
+         * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+         */
+        protected SimpleAnnotationValueVisitor(R defaultValue) {
+            super(defaultValue);
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class SimpleElementVisitor<R, P> extends SimpleElementVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses; uses {@code null} for the
+         * default value.
+         */
+        protected SimpleElementVisitor(){
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses; uses the argument for the
+         * default value.
+         *
+         * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+         */
+        protected SimpleElementVisitor(R defaultValue){
+            super(defaultValue);
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class SimpleTypeVisitor<R, P> extends SimpleTypeVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses; uses {@code null} for the
+         * default value.
+         */
+        protected SimpleTypeVisitor(){
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses; uses the argument for the
+         * default value.
+         *
+         * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+         */
+        protected SimpleTypeVisitor(R defaultValue){
+            super(defaultValue);
+        }
+    }
+
+    @SupportedSourceVersion(RELEASE_8)
+    public static class TypeKindVisitor<R, P> extends TypeKindVisitor8<R, P> {
+        /**
+         * Constructor for concrete subclasses to call; uses {@code null}
+         * for the default value.
+         */
+        protected TypeKindVisitor() {
+            super(null);
+        }
+
+        /**
+         * Constructor for concrete subclasses to call; uses the argument
+         * for the default value.
+         *
+         * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+         */
+        protected TypeKindVisitor(R defaultValue) {
+            super(defaultValue);
+        }
+    }
 }
diff --git a/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java b/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java
new file mode 100644
index 0000000..3402985
--- /dev/null
+++ b/test/tools/javac/lib/JavacTestingAbstractThreadedTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * An abstract superclass for threaded tests.
+ *
+ * This class will try to read a property named test.concurrency.
+ * The property can be provided by passing this option to jtreg:
+ * -javaoption:-Dtest.concurrency=#
+ *
+ * If the property is not set the class will use a heuristic to determine the
+ * maximum number of threads that can be fired to execute a given test.
+ *
+ * This code will have to be revisited if jprt starts using concurrency for
+ * for running jtreg tests.
+ */
+public abstract class JavacTestingAbstractThreadedTest {
+
+    protected static AtomicInteger numberOfThreads = new AtomicInteger();
+
+    protected static int getThreadPoolSize() {
+        Integer testConc = Integer.getInteger("test.concurrency");
+        if (testConc != null) return testConc;
+        int cores = Runtime.getRuntime().availableProcessors();
+        numberOfThreads.set(Math.max(2, Math.min(8, cores / 2)));
+        return numberOfThreads.get();
+    }
+
+    protected static void checkAfterExec() throws InterruptedException {
+        checkAfterExec(true);
+    };
+
+    protected static boolean throwAssertionOnError = true;
+
+    protected static boolean printAll = false;
+
+    protected static StringWriter errSWriter = new StringWriter();
+    protected static PrintWriter errWriter = new PrintWriter(errSWriter);
+
+    protected static StringWriter outSWriter = new StringWriter();
+    protected static PrintWriter outWriter = new PrintWriter(outSWriter);
+
+    protected static void checkAfterExec(boolean printCheckCount)
+            throws InterruptedException {
+        pool.shutdown();
+        pool.awaitTermination(15, TimeUnit.MINUTES);
+        if (errCount.get() > 0) {
+            if (throwAssertionOnError) {
+                closePrinters();
+                System.err.println(errSWriter.toString());
+                throw new AssertionError(
+                    String.format("%d errors found", errCount.get()));
+            } else {
+                System.err.println(
+                        String.format("%d errors found", errCount.get()));
+            }
+        } else if (printCheckCount) {
+            outWriter.println("Total check executed: " + checkCount.get());
+        }
+        /*
+         * This output is for supporting debugging. It does not mean that a given
+         * test had executed that number of threads concurrently. The value printed
+         * here is the maximum possible amount.
+         */
+        closePrinters();
+        if (printAll) {
+            System.out.println(errSWriter.toString());
+            System.out.println(outSWriter.toString());
+        }
+        System.out.println("Total number of threads in thread pool: " +
+                numberOfThreads.get());
+    }
+
+    protected static void closePrinters() {
+        errWriter.close();
+        outWriter.close();
+    }
+
+    protected static void processException(Throwable t) {
+        errCount.incrementAndGet();
+        t.printStackTrace(errWriter);
+        pool.shutdown();
+    }
+
+    //number of checks executed
+    protected static AtomicInteger checkCount = new AtomicInteger();
+
+    //number of errors found while running combo tests
+    protected static AtomicInteger errCount = new AtomicInteger();
+
+    //create default shared JavaCompiler - reused across multiple compilations
+    protected static JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+    protected static ExecutorService pool = Executors.newFixedThreadPool(
+            getThreadPoolSize(), new ThreadFactory() {
+        @Override
+        public Thread newThread(Runnable r) {
+            Thread t = new Thread(r);
+            t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+                @Override
+                public void uncaughtException(Thread t, Throwable e) {
+                    pool.shutdown();
+                    errCount.incrementAndGet();
+                    e.printStackTrace(System.err);
+                }
+            });
+            return t;
+        }
+    });
+
+    /*
+     * File manager is not thread-safe so it cannot be re-used across multiple
+     * threads. However we cache per-thread FileManager to avoid excessive
+     * object creation
+     */
+    protected static final ThreadLocal<StandardJavaFileManager> fm =
+        new ThreadLocal<StandardJavaFileManager>() {
+            @Override protected StandardJavaFileManager initialValue() {
+                return comp.getStandardFileManager(null, null, null);
+            }
+        };
+
+}
diff --git a/test/tools/javac/lib/ToolBox.java b/test/tools/javac/lib/ToolBox.java
new file mode 100644
index 0000000..49a65b4
--- /dev/null
+++ b/test/tools/javac/lib/ToolBox.java
@@ -0,0 +1,977 @@
+/*
+ * 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.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+
+import sun.tools.jar.Main;
+
+import static java.nio.file.StandardCopyOption.*;
+
+/**
+ * Toolbox for jtreg tests.
+ */
+
+public class ToolBox {
+
+    public static final String lineSeparator = System.getProperty("line.separator");
+    public static final String jdkUnderTest = System.getProperty("test.jdk");
+    public static final Path javaBinary = Paths.get(jdkUnderTest, "bin", "java");
+    public static final Path javacBinary = Paths.get(jdkUnderTest, "bin", "javac");
+
+    public static final List<String> testToolVMOpts;
+    public static final List<String> testVMOpts;
+
+    private static final Charset defaultCharset = Charset.defaultCharset();
+
+    static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+    static {
+        String sysProp = System.getProperty("test.tool.vm.opts");
+        if (sysProp != null && sysProp.length() > 0) {
+            testToolVMOpts = Arrays.asList(sysProp.split("\\s+"));
+        } else {
+            testToolVMOpts = Collections.<String>emptyList();
+        }
+
+        sysProp = System.getProperty("test.vm.opts");
+        if (sysProp != null && sysProp.length() > 0) {
+            testVMOpts = Arrays.asList(sysProp.split("\\s+"));
+        } else {
+            testVMOpts = Collections.<String>emptyList();
+        }
+    }
+
+    /**
+     * The expected result of command-like method execution.
+     */
+    public enum Expect {SUCCESS, FAIL}
+
+    enum AcceptedParams {
+        EXPECT,
+        SOURCES,
+        OPTIONS,
+        STD_OUTPUT,
+        ERR_OUTPUT,
+        EXTRA_ENV,
+    }
+
+    enum OutputKind {STD, ERR}
+
+    /**
+     * Helper class to abstract the processing of command's output.
+     */
+    static abstract class WriterHelper {
+        OutputKind kind;
+        public abstract void pipeOutput(ProcessBuilder pb);
+        public abstract void readFromStream(Process p) throws IOException;
+        public abstract void addAll(Collection<? extends String> c) throws IOException;
+    }
+
+    /**
+     * Helper class for redirecting command's output to a file.
+     */
+    static class FileWriterHelper extends WriterHelper {
+        File file;
+
+        FileWriterHelper(File file, OutputKind kind) {
+            this.file = file;
+            this.kind = kind;
+        }
+
+        @Override
+        public void pipeOutput(ProcessBuilder pb) {
+            if (file != null) {
+                switch (kind) {
+                    case STD:
+                        pb.redirectInput(file);
+                        break;
+                    case ERR:
+                        pb.redirectError(file);
+                        break;
+                }
+            }
+        }
+
+        @Override
+        public void readFromStream(Process p) throws IOException {}
+
+        @Override
+        public void addAll(Collection<? extends String> c) throws IOException {
+            if (file.exists())
+                Files.write(file.toPath(), c, defaultCharset,
+                        StandardOpenOption.WRITE, StandardOpenOption.APPEND);
+            else
+                Files.write(file.toPath(), c, defaultCharset);
+        }
+    }
+
+    /**
+     * Helper class for redirecting command's output to a String list.
+     */
+    static class ListWriterHelper extends WriterHelper {
+        List<String> list;
+
+        public ListWriterHelper(List<String> list, OutputKind kind) {
+            this.kind = kind;
+            this.list = list;
+        }
+
+        @Override
+        public void pipeOutput(ProcessBuilder pb) {}
+
+        @Override
+        public void readFromStream(Process p) throws IOException {
+            BufferedReader br = null;
+            switch (kind) {
+                case STD:
+                    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                    break;
+                case ERR:
+                    br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+                    break;
+            }
+            String line;
+            while ((line = br.readLine()) != null) {
+                list.add(line);
+            }
+        }
+
+        public void addAll(Collection<? extends String> c) {
+            list.addAll(c);
+        }
+    }
+
+    /**
+     * Simple factory class for creating a WriterHelper instance.
+     */
+    static class WriterHelperFactory {
+        static WriterHelper make(File file, OutputKind kind) {
+            return new FileWriterHelper(file, kind);
+        }
+
+        static WriterHelper make(List<String> list, OutputKind kind) {
+            return new ListWriterHelper(list, kind);
+        }
+    }
+
+    /**
+     * A generic class for holding command's arguments.
+     */
+    public static abstract class GenericArgs <T extends GenericArgs> {
+        protected static List<Set<AcceptedParams>> minAcceptedParams;
+
+        protected Set<AcceptedParams> currentParams =
+                EnumSet.<AcceptedParams>noneOf(AcceptedParams.class);
+
+        protected Expect whatToExpect;
+        protected WriterHelper stdOutput;
+        protected WriterHelper errOutput;
+        protected List<String> args = new ArrayList<>();
+        protected String[] argsArr;
+
+        protected GenericArgs() {
+            set(Expect.SUCCESS);
+        }
+
+        public T set(Expect whatToExpt) {
+            currentParams.add(AcceptedParams.EXPECT);
+            this.whatToExpect = whatToExpt;
+            return (T)this;
+        }
+
+        public T setStdOutput(List<String> stdOutput) {
+            currentParams.add(AcceptedParams.STD_OUTPUT);
+            this.stdOutput = WriterHelperFactory.make(stdOutput, OutputKind.STD);
+            return (T)this;
+        }
+
+        public T setStdOutput(File output) {
+            currentParams.add(AcceptedParams.STD_OUTPUT);
+            this.stdOutput = WriterHelperFactory.make(output, OutputKind.STD);
+            return (T)this;
+        }
+
+        public T setErrOutput(List<String> errOutput) {
+            currentParams.add(AcceptedParams.ERR_OUTPUT);
+            this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+            return (T)this;
+        }
+
+        public T setErrOutput(File errOutput) {
+            currentParams.add(AcceptedParams.ERR_OUTPUT);
+            this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+            return (T)this;
+        }
+
+        public T setAllArgs(String... args) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.argsArr = args;
+            return (T) this;
+        }
+
+
+        public T appendArgs(String... args) {
+            appendArgs(Arrays.asList(args));
+            return (T)this;
+        }
+
+        public T appendArgs(Path... args) {
+            if (args != null) {
+                List<String> list = new ArrayList<>();
+                for (int i = 0; i < args.length; i++) {
+                    if (args[i] != null) {
+                        list.add(args[i].toString());
+                    }
+                }
+                appendArgs(list);
+            }
+            return (T)this;
+        }
+
+        public T appendArgs(List<String> args) {
+            if (args != null && args.size() > 0) {
+                currentParams.add(AcceptedParams.OPTIONS);
+                for (int i = 0; i < args.size(); i++) {
+                    if (args.get(i) != null) {
+                        this.args.add(args.get(i));
+                    }
+                }
+            }
+            return (T)this;
+        }
+
+        public T setOptions(List<String> options) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.args = options;
+            return (T)this;
+        }
+
+        public T setOptions(String... options) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.args = Arrays.asList(options);
+            return (T)this;
+        }
+
+        public boolean hasMinParams() {
+            for (Set<AcceptedParams> minSet : minAcceptedParams) {
+                if (currentParams.containsAll(minSet)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * A more specific class for holding javac-like command's arguments.
+     */
+    public static class JavaToolArgs extends GenericArgs<JavaToolArgs> {
+
+        static {
+            minAcceptedParams = new ArrayList<>();
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.SOURCES));
+        }
+
+        protected List<? extends JavaFileObject> sources;
+
+        public JavaToolArgs() {
+            super();
+        }
+
+        public JavaToolArgs(Expect whatToExpt) {
+            super.set(whatToExpt);
+        }
+
+        public JavaToolArgs setSources(List<? extends JavaFileObject> sources) {
+            currentParams.add(AcceptedParams.SOURCES);
+            this.sources = sources;
+            return this;
+        }
+
+        public JavaToolArgs setSources(JavaSource... sources) {
+            return setSources(Arrays.asList(sources));
+        }
+
+        public JavaToolArgs setSources(String... sources) {
+            List<JavaSource> javaSrcs = new ArrayList<>();
+            for (String source : sources) {
+                javaSrcs.add(new JavaSource(source));
+            }
+            return setSources(javaSrcs);
+        }
+    }
+
+    /**
+     * A more specific class for holding any command's arguments.
+     */
+    public static class AnyToolArgs extends GenericArgs<AnyToolArgs> {
+
+        static {
+            minAcceptedParams = new ArrayList<>();
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+        }
+
+        Map<String, String> extraEnv;
+
+        public AnyToolArgs() {
+            super();
+        }
+
+        public AnyToolArgs(Expect whatToExpt) {
+            set(whatToExpt);
+        }
+
+        public AnyToolArgs set(Map<String, String> extraEnv) {
+            currentParams.add(AcceptedParams.EXTRA_ENV);
+            this.extraEnv = extraEnv;
+            return this;
+        }
+    }
+
+    /**
+     * Custom exception for bad command execution.
+     */
+    public static class CommandExecutionException extends Exception {
+        CommandExecutionException(List<String> command, Expect whatToExpt) {
+            super(createMessage(command, whatToExpt));
+        }
+
+        CommandExecutionException(Expect whatToExpt, String... command) {
+            this(Arrays.asList(command), whatToExpt);
+        }
+
+        private static String createMessage(List<String> command, Expect whatToExpt) {
+            StringBuilder sb = new StringBuilder().append("Command : ");
+            sb.append(command.toString()).append(lineSeparator);
+            switch (whatToExpt) {
+                case SUCCESS:
+                    sb.append("    has unexpectedly failed");
+                    break;
+                case FAIL:
+                    sb.append("    has been unexpectedly successful");
+                    break;
+            }
+            return sb.toString();
+        }
+    }
+
+    /**
+     * Custom exception for not equal resources.
+     */
+    public static class ResourcesNotEqualException extends Exception {
+        public ResourcesNotEqualException(List<String> res1, List<String> res2) {
+            super(createMessage(res1, res2));
+        }
+
+        public ResourcesNotEqualException(String line1, String line2) {
+            super(createMessage(line1, line2));
+        }
+
+        public ResourcesNotEqualException(Path path1, Path path2) {
+            super(createMessage(path1, path2));
+        }
+
+        private static String createMessage(Path path1, Path path2) {
+            return new StringBuilder()
+                    .append("The resources provided for comparison in paths \n")
+                    .append(path1.toString()).append(" and \n")
+                    .append(path2.toString()).append("are different").toString();
+        }
+
+        private static String createMessage(String line1, String line2) {
+            return new StringBuilder()
+                    .append("The resources provided for comparison are different at lines: \n")
+                    .append(line1).append(" and \n")
+                    .append(line2).toString();
+        }
+
+        private static String createMessage(List<String> res1, List<String> res2) {
+            return new StringBuilder()
+                    .append("The resources provided for comparison are different: \n")
+                    .append("Resource 1 is: ").append(res1).append("\n and \n")
+                    .append("Resource 2 is: ").append(res2).append("\n").toString();
+        }
+    }
+
+    /**
+     * A javac compiler caller method.
+     */
+    public static int javac(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            if (params.argsArr != null) {
+                return genericJavaCMD(JavaCMD.JAVAC, params);
+            } else {
+                return genericJavaCMD(JavaCMD.JAVAC_API, params);
+            }
+        }
+        throw new AssertionError("javac command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A javap calling method.
+     */
+    public static String javap(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            List<String> list = new ArrayList<>();
+            params.setErrOutput(list);
+            genericJavaCMD(JavaCMD.JAVAP, params);
+            return listToString(list);
+        }
+        throw new AssertionError("javap command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A javah calling method.
+     */
+    public static int javah(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            return genericJavaCMD(JavaCMD.JAVAH, params);
+        }
+        throw new AssertionError("javah command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A enum class for langtools commands.
+     */
+    enum JavaCMD {
+        JAVAC {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javac.Main.compile(params.argsArr, pw);
+            }
+        },
+        JAVAC_API {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                JavacTask ct = (JavacTask)comp.getTask(pw, null, null,
+                        params.args, null, params.sources);
+                return ((JavacTaskImpl)ct).doCall().exitCode;
+            }
+
+            @Override
+            String getName() {
+                return "javac";
+            }
+
+            @Override
+            List<String> getExceptionMsgContent(JavaToolArgs params) {
+                List<String> result = super.getExceptionMsgContent(params);
+                for (JavaFileObject source : params.sources) {
+                    if (source instanceof JavaSource) {
+                        result.add(((JavaSource)source).name);
+                    }
+                }
+                return result;
+            }
+        },
+        JAVAH {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javah.Main.run(params.argsArr, pw);
+            }
+        },
+        JAVAP {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javap.Main.run(params.argsArr, pw);
+            }
+        };
+
+        abstract int run(JavaToolArgs params, PrintWriter pw);
+
+        String getName() {
+            return this.name().toLowerCase();
+        }
+
+        List<String> getExceptionMsgContent(JavaToolArgs params) {
+            List<String> result = new ArrayList<>();
+            result.add(getName());
+            result.addAll(params.argsArr != null ?
+                    Arrays.asList(params.argsArr) :
+                    params.args);
+            return result;
+        }
+    }
+
+    /**
+     * A helper method for executing langtools commands.
+     */
+    private static int genericJavaCMD(
+            JavaCMD cmd,
+            JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        int rc = 0;
+        StringWriter sw = null;
+        try (PrintWriter pw = (params.errOutput == null) ?
+                null : new PrintWriter(sw = new StringWriter())) {
+            rc = cmd.run(params, pw);
+        }
+        String out = (sw == null) ? null : sw.toString();
+
+        if (params.errOutput != null && (out != null) && !out.isEmpty()) {
+            params.errOutput.addAll(splitLines(out, lineSeparator));
+        }
+
+        if ( (rc == 0 && params.whatToExpect == Expect.SUCCESS) ||
+             (rc != 0 && params.whatToExpect == Expect.FAIL) ) {
+            return rc;
+        }
+
+        throw new CommandExecutionException(cmd.getExceptionMsgContent(params),
+                params.whatToExpect);
+    }
+
+    /**
+     * A jar calling method.
+     */
+    public static boolean jar(String... params) throws CommandExecutionException {
+        Main jarGenerator = new Main(System.out, System.err, "jar");
+        boolean result = jarGenerator.run(params);
+        if (!result) {
+            List<String> command = new ArrayList<>();
+            command.add("jar");
+            command.addAll(Arrays.asList(params));
+            throw new CommandExecutionException(command, Expect.SUCCESS);
+        }
+        return result;
+    }
+
+    /**
+     * A general command calling method.
+     */
+    public static int executeCommand(AnyToolArgs params)
+            throws CommandExecutionException, IOException, InterruptedException {
+        if (params.hasMinParams()) {
+            List<String> cmd = (params.args != null) ?
+                    params.args :
+                    Arrays.asList(params.argsArr);
+            return executeCommand(cmd, params.extraEnv, params.stdOutput,
+                    params.errOutput, params.whatToExpect);
+        }
+        throw new AssertionError("command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A helper method for calling a general command.
+     */
+    private static int executeCommand(
+            List<String> command,
+            Map<String, String> extraEnv,
+            WriterHelper stdOutput,
+            WriterHelper errOutput,
+            Expect whatToExpt)
+            throws IOException, InterruptedException, CommandExecutionException {
+        ProcessBuilder pb = new ProcessBuilder(command);
+
+        if (stdOutput != null) stdOutput.pipeOutput(pb);
+        if (errOutput != null) errOutput.pipeOutput(pb);
+
+        if (extraEnv != null) {
+            pb.environment().putAll(extraEnv);
+        }
+
+        Process p = pb.start();
+
+        if (stdOutput != null) stdOutput.readFromStream(p);
+        if (errOutput != null) errOutput.readFromStream(p);
+
+        int result = p.waitFor();
+        if ( (result == 0 && whatToExpt == Expect.SUCCESS) ||
+             (result != 0 && whatToExpt == Expect.FAIL) ) {
+            return result;
+        }
+
+        throw new CommandExecutionException(command, whatToExpt);
+    }
+
+    /**
+     * This set of methods can be used instead of diff when the only needed
+     * result is the equality or inequality of the two given resources.
+     *
+     * A resource can be a file or a String list.
+     */
+    public static void compareLines(Path aPath, Path otherPath, String encoding)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        compareLines(aPath, otherPath, encoding, false);
+    }
+
+    public static void compareLines(
+            Path aPath, Path otherPath, String encoding, boolean trim)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        Charset charset = encoding != null ?
+                Charset.forName(encoding) :
+                defaultCharset;
+        List<String> list1 = Files.readAllLines(aPath, charset);
+        List<String> list2 = Files.readAllLines(otherPath, charset);
+        compareLines(list1, list2, trim);
+    }
+
+    public static void compareLines(Path path, List<String> strings, String encoding)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        compareLines(path, strings, encoding, false);
+    }
+
+    public static void compareLines(Path path, List<String> strings,
+            String encoding, boolean trim)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        Charset charset = encoding != null ?
+                Charset.forName(encoding) :
+                defaultCharset;
+        List<String> list = Files.readAllLines(path, charset);
+        compareLines(list, strings, trim);
+    }
+
+    public static void compareLines(List<String> list1, List<String> list2)
+            throws ResourcesNotEqualException {
+        compareLines(list1, list2, false);
+    }
+
+    public static void compareLines(List<String> list1,
+            List<String> list2, boolean trim) throws ResourcesNotEqualException {
+        if ((list1 == list2) || (list1 == null && list2 == null)) return;
+        if (list1.size() != list2.size())
+            throw new ResourcesNotEqualException(list1, list2);
+        int i = 0;
+        int j = 0;
+        while (i < list1.size() &&
+               j < list2.size() &&
+               equals(list1.get(i), list2.get(j), trim)) {
+            i++; j++;
+        }
+        if (!(i == list1.size() && j == list2.size()))
+            throw new ResourcesNotEqualException(list1, list2);
+    }
+
+    private static boolean equals(String s1, String s2, boolean trim) {
+        return (trim ? s1.trim().equals(s2.trim()) : s1.equals(s2));
+    }
+
+    /**
+     * A set of simple grep-like methods, looks for regExpr in text.
+     * The content of text is split using the new line character as a pattern
+     * and later the regExpr is seek in every split line. If a match is found,
+     * the whole line is added to the result.
+     */
+    public static List<String> grep(String regExpr, String text, String sep) {
+        return grep(regExpr, splitLines(text, sep));
+    }
+
+    public static List<String> grep(String regExpr, List<String> text) {
+        List<String> result = new ArrayList<>();
+        Pattern pattern = Pattern.compile(regExpr);
+        for (String s : text) {
+            if (pattern.matcher(s).find()) {
+                result.add(s);
+            }
+        }
+        return result;
+    }
+
+    public static List<String> grep(String regExpr, File f)
+            throws IOException {
+        List<String> lines = Files.readAllLines(f.toPath(), defaultCharset);
+        return grep(regExpr, lines);
+    }
+
+    /**
+     * A touch-like method.
+     */
+    public static boolean touch(String fileName) {
+        File file = new File(fileName);
+        return touch(file);
+    }
+
+    public static boolean touch(File file) {
+        if (file.exists()) {
+            file.setLastModified(System.currentTimeMillis());
+            return true;
+        }
+        return false;
+    }
+
+    public static void createJavaFile(File outFile) throws IOException {
+        createJavaFile(outFile, null);
+    }
+
+    /**
+     * A method for creating a valid but very simple java file.
+     */
+    public static void createJavaFile(File outFile, File superClass)
+            throws IOException {
+        String srcStr = "public class " + getSimpleName(outFile) + " ";
+        if (superClass != null) {
+            srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " ");
+        }
+        srcStr = srcStr.concat("{}");
+        try (PrintWriter ps = new PrintWriter(new FileWriter(outFile))) {
+            ps.println(srcStr);
+        }
+    }
+
+    /**
+     * Creates a java file name given its source.
+     * The file is created in the working directory, creating a directory
+     * tree if there is a package declaration.
+     */
+    public static void createJavaFileFromSource(String source) throws IOException {
+        createJavaFileFromSource(null, source);
+    }
+
+    /**
+     * Creates a java file name given its source.
+     * The file is created in the working directory, creating a directory
+     * tree if there is a package declaration or the argument initialPath
+     * has a valid path.
+     *
+     * e.i. if initialPath is foo/ and the source is:
+     * package bar;
+     *
+     * public class bazz {}
+     *
+     * this method will create the file foo/bar/bazz.java in the working
+     * directory.
+     */
+    public static void createJavaFileFromSource(Path initialPath,
+            String source) throws IOException {
+        String fileName = getJavaFileNameFromSource(source);
+        String dirTree = getDirTreeFromSource(source);
+        Path path = (dirTree != null) ?
+                Paths.get(dirTree, fileName) :
+                Paths.get(fileName);
+        path = (initialPath != null) ?
+                initialPath.resolve(path):
+                path;
+        writeFile(path, source);
+    }
+
+    static Pattern publicClassPattern =
+            Pattern.compile("public\\s+(?:class|enum|interface){1}\\s+(\\w+)");
+    static Pattern packageClassPattern =
+            Pattern.compile("(?:class|enum|interface){1}\\s+(\\w+)");
+
+    /**
+     * Extracts the java file name from the class declaration.
+     * This method is intended for simple files and uses regular expressions,
+     * so comments matching the pattern can make the method fail.
+     */
+    private static String getJavaFileNameFromSource(String source) {
+        String className = null;
+        Matcher matcher = publicClassPattern.matcher(source);
+        if (matcher.find()) {
+            className = matcher.group(1) + ".java";
+        } else {
+            matcher = packageClassPattern.matcher(source);
+            if (matcher.find()) {
+                className = matcher.group(1) + ".java";
+            } else {
+                throw new AssertionError("Could not extract the java class " +
+                        "name from the provided source");
+            }
+        }
+        return className;
+    }
+
+    static Pattern packagePattern =
+            Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
+
+    /**
+     * Extracts the path from the package declaration if present.
+     * This method is intended for simple files and uses regular expressions,
+     * so comments matching the pattern can make the method fail.
+     */
+    private static String getDirTreeFromSource(String source) {
+        Matcher matcher = packagePattern.matcher(source);
+        return matcher.find() ?
+            matcher.group(1).replace(".", File.separator) :
+            null;
+    }
+
+    /**
+     * A method for creating a jar's manifest file with supplied data.
+     */
+    public static void mkManifestWithClassPath(String mainClass,
+            String... classes) throws IOException {
+        List <String> lines = new ArrayList<>();
+
+        StringBuilder sb = new StringBuilder("Class-Path: ".length() +
+                classes[0].length()).append("Class-Path: ").append(classes[0]);
+        for (int i = 1; i < classes.length; i++) {
+            sb.append(" ").append(classes[i]);
+        }
+        lines.add(sb.toString());
+        if (mainClass != null) {
+            lines.add(new StringBuilder("Main-Class: ".length() +
+                      mainClass.length())
+                      .append("Main-Class: ")
+                      .append(mainClass).toString());
+        }
+        Files.write(Paths.get("MANIFEST.MF"), lines, null);
+    }
+
+    /**
+     * A utility method to obtain the file name.
+     */
+    static String getSimpleName(File inFile) {
+        return inFile.toPath().getFileName().toString();
+    }
+
+    /**
+     * A method to write to a file, the directory tree is created if needed.
+     */
+    public static File writeFile(Path path, String body) throws IOException {
+        File result;
+        if (path.getParent() != null) {
+            Files.createDirectories(path.getParent());
+        }
+        try (FileWriter out = new FileWriter(result = path.toAbsolutePath().toFile())) {
+            out.write(body);
+        }
+        return result;
+    }
+
+    public static File writeFile(String path, String body) throws IOException {
+        return writeFile(Paths.get(path), body);
+    }
+
+    /**
+     * A rm-like method, the file is deleted only if it exists.
+     */
+    public static void rm(Path path) throws Exception {
+        Files.deleteIfExists(path);
+    }
+
+    public static void rm(String filename) throws Exception {
+        rm(Paths.get(filename));
+    }
+
+    public static void rm(File f) throws Exception {
+        rm(f.toPath());
+    }
+
+    /**
+     * Copy source file to destination file.
+     */
+    public static void copyFile(File destfile, File srcfile)
+        throws IOException {
+        copyFile(destfile.toPath(), srcfile.toPath());
+    }
+
+    public static void copyFile(Path destPath, Path srcPath)
+        throws IOException {
+        Files.createDirectories(destPath);
+        Files.copy(srcPath, destPath, REPLACE_EXISTING);
+    }
+
+    /**
+     * Splits a String using the System's line separator character as splitting point.
+     */
+    public static List<String> splitLines(String lines, String sep) {
+        return Arrays.asList(lines.split(sep));
+    }
+
+    /**
+     * Converts a String list into one String by appending the System's line separator
+     * character after each component.
+     */
+    private static String listToString(List<String> lines) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : lines) {
+            sb.append(s).append(lineSeparator);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Returns true if the OS is a Windows version.
+     */
+    public static boolean isWindows() {
+        String osName = System.getProperty("os.name");
+        return osName.toUpperCase().startsWith("WINDOWS");
+    }
+
+    /**
+     * Class representing an in-memory java source file. It is able to extract
+     * the file name from simple source codes using regular expressions.
+     */
+    public static class JavaSource extends SimpleJavaFileObject {
+        String source;
+        String name;
+
+        public JavaSource(String className, String source) {
+            super(URI.create(className),
+                    JavaFileObject.Kind.SOURCE);
+            this.name = className;
+            this.source = source;
+        }
+
+        public JavaSource(String source) {
+            super(URI.create(getJavaFileNameFromSource(source)),
+                    JavaFileObject.Kind.SOURCE);
+            this.name = getJavaFileNameFromSource(source);
+            this.source = source;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
diff --git a/test/tools/javac/limits/NestedClassConstructorArgs.java b/test/tools/javac/limits/NestedClassConstructorArgs.java
new file mode 100644
index 0000000..9b56b6f
--- /dev/null
+++ b/test/tools/javac/limits/NestedClassConstructorArgs.java
@@ -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 8014230
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main NestedClassConstructorArgs
+ */
+
+public class NestedClassConstructorArgs extends NumArgsTest {
+    private static final NumArgsTest.NestingDef[] nesting = {
+        classNesting("Inner")
+    };
+
+    private NestedClassConstructorArgs() {
+        super(253, "NestedClassConstructorArgs", "Inner", nesting);
+    }
+
+    public static void main(String... args) throws Exception {
+        new NestedClassConstructorArgs().runTest();
+    }
+}
+
diff --git a/test/tools/javac/limits/NestedClassMethodArgs.java b/test/tools/javac/limits/NestedClassMethodArgs.java
new file mode 100644
index 0000000..762ef18
--- /dev/null
+++ b/test/tools/javac/limits/NestedClassMethodArgs.java
@@ -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 8014230
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main NestedClassMethodArgs
+ */
+
+public class NestedClassMethodArgs extends NumArgsTest {
+    private static final NumArgsTest.NestingDef[] nesting = {
+        classNesting("Inner")
+    };
+
+    private NestedClassMethodArgs() {
+        super(254, "void", "test", "NestedClassMethodArgs", nesting);
+    }
+
+    public static void main(String... args) throws Exception {
+        new NestedClassMethodArgs().runTest();
+    }
+}
+
diff --git a/test/tools/javac/limits/NumArgs1.java b/test/tools/javac/limits/NumArgs1.java
deleted file mode 100644
index fe00904..0000000
--- a/test/tools/javac/limits/NumArgs1.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4309152
- * @summary Compiler silently generates bytecode that exceeds VM limits
- * @author gafter
- *
- * @compile/fail NumArgs1.java
- */
-
-class NumArgs1 {
-    void f(
-           // T1 this,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255,
-           int x256
-    ) {}
-
-    static
-    void g(
-           int x1,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255,
-           int x256
-    ) {}
-}
diff --git a/test/tools/javac/limits/NumArgs2.java b/test/tools/javac/limits/NumArgs2.java
deleted file mode 100644
index 7692a9b..0000000
--- a/test/tools/javac/limits/NumArgs2.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4309152
- * @summary Compiler silently generates bytecode that exceeds VM limits
- * @author gafter
- *
- * @compile NumArgs2.java
- */
-
-class NumArgs2 {
-    void f(
-           // This this,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255
-    ) {}
-
-    static
-    void g(
-           int x1,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255
-    ) {}
-}
diff --git a/test/tools/javac/limits/NumArgs3.java b/test/tools/javac/limits/NumArgs3.java
deleted file mode 100644
index c200b1a..0000000
--- a/test/tools/javac/limits/NumArgs3.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4309152
- * @summary Compiler silently generates bytecode that exceeds VM limits
- * @author gafter
- *
- * @compile/fail NumArgs3.java
- */
-
-class NumArgs3 {
-    void NumArgs3(
-           // T1 this,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255,
-           int x256
-    ) {}
-}
diff --git a/test/tools/javac/limits/NumArgs4.java b/test/tools/javac/limits/NumArgs4.java
deleted file mode 100644
index 73234dd..0000000
--- a/test/tools/javac/limits/NumArgs4.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2002, 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 4309152
- * @summary Compiler silently generates bytecode that exceeds VM limits
- * @author gafter
- *
- * @compile NumArgs4.java
- */
-
-class NumArgs4 {
-    void NumArgs4(
-           // T1 this,
-           int x2,
-           int x3,
-           int x4,
-           int x5,
-           int x6,
-           int x7,
-           int x8,
-           int x9,
-           int x10,
-           int x11,
-           int x12,
-           int x13,
-           int x14,
-           int x15,
-           int x16,
-           int x17,
-           int x18,
-           int x19,
-           int x20,
-           int x21,
-           int x22,
-           int x23,
-           int x24,
-           int x25,
-           int x26,
-           int x27,
-           int x28,
-           int x29,
-           int x30,
-           int x31,
-           int x32,
-           int x33,
-           int x34,
-           int x35,
-           int x36,
-           int x37,
-           int x38,
-           int x39,
-           int x40,
-           int x41,
-           int x42,
-           int x43,
-           int x44,
-           int x45,
-           int x46,
-           int x47,
-           int x48,
-           int x49,
-           int x50,
-           int x51,
-           int x52,
-           int x53,
-           int x54,
-           int x55,
-           int x56,
-           int x57,
-           int x58,
-           int x59,
-           int x60,
-           int x61,
-           int x62,
-           int x63,
-           int x64,
-           int x65,
-           int x66,
-           int x67,
-           int x68,
-           int x69,
-           int x70,
-           int x71,
-           int x72,
-           int x73,
-           int x74,
-           int x75,
-           int x76,
-           int x77,
-           int x78,
-           int x79,
-           int x80,
-           int x81,
-           int x82,
-           int x83,
-           int x84,
-           int x85,
-           int x86,
-           int x87,
-           int x88,
-           int x89,
-           int x90,
-           int x91,
-           int x92,
-           int x93,
-           int x94,
-           int x95,
-           int x96,
-           int x97,
-           int x98,
-           int x99,
-           int x100,
-           int x101,
-           int x102,
-           int x103,
-           int x104,
-           int x105,
-           int x106,
-           int x107,
-           int x108,
-           int x109,
-           int x110,
-           int x111,
-           int x112,
-           int x113,
-           int x114,
-           int x115,
-           int x116,
-           int x117,
-           int x118,
-           int x119,
-           int x120,
-           int x121,
-           int x122,
-           int x123,
-           int x124,
-           int x125,
-           int x126,
-           int x127,
-           int x128,
-           int x129,
-           int x130,
-           int x131,
-           int x132,
-           int x133,
-           int x134,
-           int x135,
-           int x136,
-           int x137,
-           int x138,
-           int x139,
-           int x140,
-           int x141,
-           int x142,
-           int x143,
-           int x144,
-           int x145,
-           int x146,
-           int x147,
-           int x148,
-           int x149,
-           int x150,
-           int x151,
-           int x152,
-           int x153,
-           int x154,
-           int x155,
-           int x156,
-           int x157,
-           int x158,
-           int x159,
-           int x160,
-           int x161,
-           int x162,
-           int x163,
-           int x164,
-           int x165,
-           int x166,
-           int x167,
-           int x168,
-           int x169,
-           int x170,
-           int x171,
-           int x172,
-           int x173,
-           int x174,
-           int x175,
-           int x176,
-           int x177,
-           int x178,
-           int x179,
-           int x180,
-           int x181,
-           int x182,
-           int x183,
-           int x184,
-           int x185,
-           int x186,
-           int x187,
-           int x188,
-           int x189,
-           int x190,
-           int x191,
-           int x192,
-           int x193,
-           int x194,
-           int x195,
-           int x196,
-           int x197,
-           int x198,
-           int x199,
-           int x200,
-           int x201,
-           int x202,
-           int x203,
-           int x204,
-           int x205,
-           int x206,
-           int x207,
-           int x208,
-           int x209,
-           int x210,
-           int x211,
-           int x212,
-           int x213,
-           int x214,
-           int x215,
-           int x216,
-           int x217,
-           int x218,
-           int x219,
-           int x220,
-           int x221,
-           int x222,
-           int x223,
-           int x224,
-           int x225,
-           int x226,
-           int x227,
-           int x228,
-           int x229,
-           int x230,
-           int x231,
-           int x232,
-           int x233,
-           int x234,
-           int x235,
-           int x236,
-           int x237,
-           int x238,
-           int x239,
-           int x240,
-           int x241,
-           int x242,
-           int x243,
-           int x244,
-           int x245,
-           int x246,
-           int x247,
-           int x248,
-           int x249,
-           int x250,
-           int x251,
-           int x252,
-           int x253,
-           int x254,
-           int x255
-    ) {}
-}
diff --git a/test/tools/javac/limits/NumArgsTest.java b/test/tools/javac/limits/NumArgsTest.java
new file mode 100644
index 0000000..751df98
--- /dev/null
+++ b/test/tools/javac/limits/NumArgsTest.java
@@ -0,0 +1,269 @@
+/*
+ * 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 com.sun.tools.javac.util.*;
+import com.sun.tools.javac.api.*;
+import com.sun.tools.javac.file.*;
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+
+// More general parameter limit testing framework, and designed so
+// that it could be expanded into a general limits-testing framework
+// in the future.
+public class NumArgsTest {
+
+    private static final NumArgsTest.NestingDef[] NO_NESTING = {};
+
+    // threshold is named as such because "threshold" args is expected
+    // to pass, and "threshold" + 1 args is expected to fail.
+    private final int threshold;
+    private final boolean isStaticMethod;
+    private final String result;
+    private final String testName;
+    private final String methodName;
+    private final NestingDef[] nesting;
+    private final File testdir;
+    private final JavacTool tool = JavacTool.create();
+    private final JavacFileManager fm =
+        tool.getStandardFileManager(null, null, null);
+    private int errors = 0;
+
+    public NumArgsTest(final int threshold,
+                       final boolean isStaticMethod,
+                       final String result,
+                       final String methodName,
+                       final String testName,
+                       final NestingDef[] nesting) {
+        this.threshold = threshold;
+        this.isStaticMethod = isStaticMethod;
+        this.result = result;
+        this.methodName = methodName;
+        this.testName = testName;
+        this.nesting = nesting;
+        testdir = new File(testName);
+        testdir.mkdir();
+    }
+
+    public NumArgsTest(final int threshold,
+                       final boolean isStaticMethod,
+                       final String result,
+                       final String methodName,
+                       final String testName) {
+        this(threshold, isStaticMethod, result, methodName,
+             testName, NO_NESTING);
+    }
+
+    public NumArgsTest(final int threshold,
+                       final String result,
+                       final String methodName,
+                       final String testName,
+                       final NestingDef[] nesting) {
+        this(threshold, false, result, methodName, testName, nesting);
+    }
+
+    public NumArgsTest(final int threshold,
+                       final String result,
+                       final String methodName,
+                       final String testName) {
+        this(threshold, false, result, methodName, testName, NO_NESTING);
+    }
+
+    public NumArgsTest(final int threshold,
+                       final String testName,
+                       final NestingDef[] nesting) {
+        this(threshold, null, null, testName, nesting);
+    }
+
+    public NumArgsTest(final int threshold,
+                       final String testName) {
+        this(threshold, null, null, testName, NO_NESTING);
+    }
+
+    public NumArgsTest(final int threshold,
+                       final String testName,
+                       final String constructorName,
+                       final NestingDef[] nesting) {
+        this(threshold, null, constructorName, testName, nesting);
+    }
+
+    protected void writeArgs(final int num, final PrintWriter stream)
+        throws IOException {
+        stream.print("int x1");
+        for(int i = 1; i < num; i++)
+            stream.print(", int x" + (i + 1));
+    }
+
+    protected void writeMethod(final int num,
+                               final String name,
+                               final PrintWriter stream)
+        throws IOException {
+        stream.write("public ");
+        if (isStaticMethod) stream.write("static ");
+        if (result == null)
+            stream.write("");
+        else {
+            stream.write(result);
+            stream.write(" ");
+        }
+        stream.write(name);
+        stream.write("(");
+        writeArgs(num, stream);
+        stream.write(") {}\n");
+    }
+
+    protected void writeJavaFile(final int num,
+                                 final boolean pass,
+                                 final PrintWriter stream)
+        throws IOException {
+        final String fullName = testName + (pass ? "Pass" : "Fail");
+        stream.write("public class ");
+        stream.write(fullName);
+        stream.write(" {\n");
+        for(int i = 0; i < nesting.length; i++)
+            nesting[i].writeBefore(stream);
+        if (null == methodName)
+            writeMethod(num, fullName, stream);
+        else
+            writeMethod(num, methodName, stream);
+        for(int i = nesting.length - 1; i >= 0; i--)
+            nesting[i].writeAfter(stream);
+        stream.write("}\n");
+    }
+
+    public void runTest() throws Exception {
+        // Run the pass test
+        final String passTestName = testName + "Pass.java";
+        final StringWriter passBody = new StringWriter();
+        final PrintWriter passStream = new PrintWriter(passBody);
+        final File passFile = new File(testdir, passTestName);
+        final FileWriter passWriter = new FileWriter(passFile);
+
+        writeJavaFile(threshold, true, passStream);
+        passStream.close();
+        passWriter.write(passBody.toString());
+        passWriter.close();
+
+        final StringWriter passSW = new StringWriter();
+        final String[] passArgs = { passFile.toString() };
+        final Iterable<? extends JavaFileObject> passFiles =
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(passFile));
+        final JavaCompiler.CompilationTask passTask =
+            tool.getTask(passSW, fm, null, null, null, passFiles);
+
+        if (!passTask.call()) {
+            errors++;
+            System.err.println("Compilation unexpectedly failed. Body:\n" +
+                               passBody);
+            System.err.println("Output:\n" + passSW.toString());
+        }
+
+        // Run the fail test
+        final String failTestName = testName + "Fail.java";
+        final StringWriter failBody = new StringWriter();
+        final PrintWriter failStream = new PrintWriter(failBody);
+        final File failFile = new File(testdir, failTestName);
+        final FileWriter failWriter = new FileWriter(failFile);
+
+        writeJavaFile(threshold + 1, false, failStream);
+        failStream.close();
+        failWriter.write(failBody.toString());
+        failWriter.close();
+
+        final StringWriter failSW = new StringWriter();
+        final TestDiagnosticHandler failDiag =
+            new TestDiagnosticHandler("compiler.err.limit.parameters");
+        final Iterable<? extends JavaFileObject> failFiles =
+            fm.getJavaFileObjectsFromFiles(Arrays.asList(failFile));
+        final JavaCompiler.CompilationTask failTask =
+            tool.getTask(failSW,
+                         tool.getStandardFileManager(null, null, null),
+                         failDiag,
+                         null,
+                         null,
+                         failFiles);
+
+        if (failTask.call()) {
+            errors++;
+            System.err.println("Compilation unexpectedly succeeded.");
+            System.err.println("Input:\n" + failBody);
+        }
+
+        if (!failDiag.sawError) {
+            errors++;
+            System.err.println("Did not see expected compile error.");
+        }
+
+        if (errors != 0)
+            throw new RuntimeException("Test failed with " +
+                                       errors + " errors");
+    }
+
+    public static NestingDef classNesting(final String name) {
+        return new NestedClassBuilder(name, false);
+    }
+
+    public static NestingDef classNesting(final String name,
+                                          final boolean isStatic) {
+        return new NestedClassBuilder(name, isStatic);
+    }
+
+    protected interface NestingDef {
+        public abstract void writeBefore(final PrintWriter stream);
+        public abstract void writeAfter(final PrintWriter stream);
+    }
+
+    private static class NestedClassBuilder implements NestingDef {
+        private final String name;
+        private final boolean isStatic;
+        public NestedClassBuilder(final String name, final boolean isStatic) {
+            this.name = name;
+            this.isStatic = isStatic;
+        }
+        public void writeBefore(final PrintWriter stream) {
+            stream.write("public ");
+            if (isStatic) stream.write("static");
+            stream.write(" class ");
+            stream.write(name);
+            stream.write(" {\n");
+        }
+        public void writeAfter(final PrintWriter stream) {
+            stream.write("}\n");
+        }
+    }
+
+    public class TestDiagnosticHandler<T> implements DiagnosticListener<T> {
+        public boolean sawError;
+        public final String target;
+
+        public TestDiagnosticHandler(final String target) {
+            this.target = target;
+        }
+
+        public void report(final Diagnostic<? extends T> diag) {
+            if (diag.getCode().equals(target))
+                sawError = true;
+        }
+    }
+
+}
diff --git a/test/tools/javac/limits/StaticNestedClassConstructorArgs.java b/test/tools/javac/limits/StaticNestedClassConstructorArgs.java
new file mode 100644
index 0000000..393a37b
--- /dev/null
+++ b/test/tools/javac/limits/StaticNestedClassConstructorArgs.java
@@ -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 8014230
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main StaticNestedClassConstructorArgs
+ */
+
+public class StaticNestedClassConstructorArgs extends NumArgsTest {
+    private static final NumArgsTest.NestingDef[] nesting = {
+        classNesting("StaticInner", true)
+    };
+
+    private StaticNestedClassConstructorArgs() {
+        super(254, "StaticNestedClassConstructorArgs", "StaticInner", nesting);
+    }
+
+    public static void main(String... args) throws Exception {
+        new StaticNestedClassConstructorArgs().runTest();
+    }
+}
+
diff --git a/test/tools/javac/limits/TopLevelClassConstructorArgs.java b/test/tools/javac/limits/TopLevelClassConstructorArgs.java
new file mode 100644
index 0000000..ee567d6
--- /dev/null
+++ b/test/tools/javac/limits/TopLevelClassConstructorArgs.java
@@ -0,0 +1,40 @@
+/*
+ * 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 4309152
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main TopLevelClassConstructorArgs
+ */
+
+public class TopLevelClassConstructorArgs extends NumArgsTest {
+    private TopLevelClassConstructorArgs() {
+        super(254, "TopLevelClassConstructorArgs");
+    }
+
+    public static void main(String... args) throws Exception {
+        new TopLevelClassConstructorArgs().runTest();
+    }
+}
diff --git a/test/tools/javac/limits/TopLevelClassMethodArgs.java b/test/tools/javac/limits/TopLevelClassMethodArgs.java
new file mode 100644
index 0000000..7ae66c9
--- /dev/null
+++ b/test/tools/javac/limits/TopLevelClassMethodArgs.java
@@ -0,0 +1,40 @@
+/*
+ * 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 4309152
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main TopLevelClassMethodArgs
+ */
+
+public class TopLevelClassMethodArgs extends NumArgsTest {
+    private TopLevelClassMethodArgs() {
+        super(254, "void", "test", "TopLevelClassMethodArgs");
+    }
+
+    public static void main(String... args) throws Exception {
+        new TopLevelClassMethodArgs().runTest();
+    }
+}
diff --git a/test/tools/javac/limits/TopLevelClassStaticMethodArgs.java b/test/tools/javac/limits/TopLevelClassStaticMethodArgs.java
new file mode 100644
index 0000000..f905157
--- /dev/null
+++ b/test/tools/javac/limits/TopLevelClassStaticMethodArgs.java
@@ -0,0 +1,40 @@
+/*
+ * 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 4309152
+ * @summary Compiler silently generates bytecode that exceeds VM limits
+ * @compile NumArgsTest.java
+ * @run main TopLevelClassStaticMethodArgs
+ */
+
+public class TopLevelClassStaticMethodArgs extends NumArgsTest {
+    private TopLevelClassStaticMethodArgs() {
+        super(255, true, "void", "test", "TopLevelClassStaticMethodArgs");
+    }
+
+    public static void main(String... args) throws Exception {
+        new TopLevelClassStaticMethodArgs().runTest();
+    }
+}
diff --git a/test/tools/javac/links/LinksTest.java b/test/tools/javac/links/LinksTest.java
new file mode 100644
index 0000000..6cdebb0
--- /dev/null
+++ b/test/tools/javac/links/LinksTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 4266026
+ * @summary javac no longer follows symlinks
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main LinksTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/links/links.sh
+public class LinksTest {
+
+    private static final String BSrc =
+        "package a;\n" +
+        "\n" +
+        "public class B {}";
+
+    private static final String TSrc =
+        "class T extends a.B {}";
+
+    public static void main(String args[])
+            throws Exception {
+//      mkdir tmp
+//      cp ${TESTSRC}/b/B.java tmp
+        ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc);
+
+        try {
+//        ln -s `pwd`/tmp "${TESTCLASSES}/a"
+            Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp"));
+            ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
+            ToolBox.JavaToolArgs javacArgs =
+                    new ToolBox.JavaToolArgs()
+                    .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
+            ToolBox.javac(javacArgs);
+        } catch (UnsupportedOperationException e) {
+            System.err.println("Symbolic links not supported on this system. The test can't finish");
+        }
+    }
+
+}
diff --git a/test/tools/javac/links/T.java b/test/tools/javac/links/T.java
deleted file mode 100644
index 359e9da..0000000
--- a/test/tools/javac/links/T.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2001, 2008, 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.
- */
-
-class T extends a.B {}
diff --git a/test/tools/javac/links/b/B.java b/test/tools/javac/links/b/B.java
deleted file mode 100644
index 391d54f..0000000
--- a/test/tools/javac/links/b/B.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2001, 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 a;
-
-public class B {}
diff --git a/test/tools/javac/links/links.sh b/test/tools/javac/links/links.sh
deleted file mode 100644
index 83d10c0..0000000
--- a/test/tools/javac/links/links.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2008, 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 4266026
-# @summary javac no longer follows symlinks
-#
-# @run shell links.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  * )
-    echo "Unrecognized system - test skipped."
-    exit 0;
-    ;;
-esac
-
-mkdir tmp
-cp ${TESTSRC}/b/B.java tmp
-
-rm -rf T.class B.class b/B.class "${TESTCLASSES}/a" "${TESTCLASSES}/classes"
-ln -s `pwd`/tmp "${TESTCLASSES}/a"
-mkdir "${TESTCLASSES}/classes"
-
-"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
diff --git a/test/tools/javac/literals/UnderscoreLiterals.java b/test/tools/javac/literals/UnderscoreLiterals.java
index 410450c..0e669ac 100644
--- a/test/tools/javac/literals/UnderscoreLiterals.java
+++ b/test/tools/javac/literals/UnderscoreLiterals.java
@@ -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
@@ -42,6 +42,12 @@ public class UnderscoreLiterals {
         test(1_0_0, 100);
         test(1__0__0, 100);
         test(123_456_789, 123456789);
+        test(2_147_483_647, Integer.MAX_VALUE);
+        test(-2_147_483_648, Integer.MIN_VALUE);
+        test(32_767, Short.MAX_VALUE);
+        test(-32_768, Short.MIN_VALUE);
+        test(1_2_7, Byte.MAX_VALUE);
+        test(-1_2_8, Byte.MIN_VALUE);
 
         // long
         test(1l, 1l);
@@ -51,6 +57,8 @@ public class UnderscoreLiterals {
         test(1_0_0l, 100l);
         test(1__0__0l, 100l);
         test(123_456_789l, 123456789l);
+        test(9_223_372_036_854_775_807l, Long.MAX_VALUE);
+        test(-9_223_372_036_854_775_808l, Long.MIN_VALUE);
 
         // float
         test(.1f, .1f);
@@ -80,6 +88,8 @@ public class UnderscoreLiterals {
         test(1_1.1_0_0f, 1_1.100f);
         test(1_1.1__0__0f, 1_1.100f);
         test(1_1.123_456_789f, 1_1.123456789f);
+        test(3.4_028_235E38f, Float.MAX_VALUE);
+        test(1.4E-4_5f, Float.MIN_VALUE);
 
         // double
         test(.1d, .1d);
@@ -109,6 +119,8 @@ public class UnderscoreLiterals {
         test(1_1.1_0_0d, 1_1.100d);
         test(1_1.1__0__0d, 1_1.100d);
         test(1_1.123_456_789d, 1_1.123456789d);
+        test(1.797_6_9_3_1_348_623_157E3_08, Double.MAX_VALUE);
+        test(4.9E-3_24, Double.MIN_VALUE);
 
         // binary
         test(0b1, 1);
@@ -118,6 +130,14 @@ public class UnderscoreLiterals {
         test(0b1_0_0, 4);
         test(0b1__0__0, 4);
         test(0b0001_0010_0011, 0x123);
+        test(0b111_1111_1111_1111_1111_1111_1111_1111, Integer.MAX_VALUE);
+        test(0b1000_0000_0000_0000_0000_0000_0000_0000, Integer.MIN_VALUE);
+        test(0b111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111l, Long.MAX_VALUE);
+        test(0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000l, Long.MIN_VALUE);
+        test(0b111_1111_1111_1111, Short.MAX_VALUE);
+        test((short)-0b1000_0000_0000_0000, Short.MIN_VALUE);
+        test(0b111_1111, Byte.MAX_VALUE);
+        test((byte)-0b1000_0000, Byte.MIN_VALUE);
 
         // octal
         test(01, 1);
@@ -133,6 +153,14 @@ public class UnderscoreLiterals {
         test(0_1_0_0, 64);
         test(0_1__0__0, 64);
         test(0_001_002_003, 01002003);
+        test(0177_7777_7777, Integer.MAX_VALUE);
+        test(-0200_0000_0000, Integer.MIN_VALUE);
+        test(077_77_77_77_77_7_77_77_77_77_77l, Long.MAX_VALUE);
+        test(-010_00_00_00_00_00_00_00_00_00_00l, Long.MIN_VALUE);
+        test((short)07_77_77, Short.MAX_VALUE);
+        test((short)-010_00_00, Short.MIN_VALUE);
+        test(01_77, Byte.MAX_VALUE);
+        test((byte)-02_00, Byte.MIN_VALUE);
 
         // hexadecimal
         test(0x1, 1);
@@ -142,6 +170,18 @@ public class UnderscoreLiterals {
         test(0x1_0_0, 256);
         test(0x1__0__0, 256);
         test(0x01_02_03_04, 0x1020304);
+        test(0x7f_ff_ff_ff, Integer.MAX_VALUE);
+        test(0x80_00_00_00, Integer.MIN_VALUE);
+        test(0x1.f_ff_ffep127f, Float.MAX_VALUE);
+        test(0x0.00_00_02p-126f, Float.MIN_VALUE);
+        test(0x1.f__ff_ff_ff_ff_ff_ffp1_023, Double.MAX_VALUE);
+        test(0x0.000_000_000_000_1p-1_022, Double.MIN_VALUE);
+        test(0x7f_ff_ff_ff_ff_ff_ff_ffl, Long.MAX_VALUE);
+        test(0x80_00_00_00_00_00_00_00l, Long.MIN_VALUE);
+        test(0x7f_ff, Short.MAX_VALUE);
+        test((short)0x80_00, Short.MIN_VALUE);
+        test(0x7_f, Byte.MAX_VALUE);
+        test((byte)0x8_0, Byte.MIN_VALUE);
 
         // misc
         long creditCardNumber = 1234_5678_9012_3456L;
diff --git a/test/tools/javac/main/Option_J_At_Test.java b/test/tools/javac/main/Option_J_At_Test.java
new file mode 100644
index 0000000..66246a5
--- /dev/null
+++ b/test/tools/javac/main/Option_J_At_Test.java
@@ -0,0 +1,70 @@
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+/*
+ * 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 8006037
+ * @summary extra space in javac -help for -J and @ options
+ */
+
+public class Option_J_At_Test {
+    public static void main(String... args) throws Exception {
+        new Option_J_At_Test().run();
+    }
+
+    void run() throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] help = { "-help" };
+        int rc = com.sun.tools.javac.Main.compile(help, pw);
+        pw.flush();
+        String out = sw.toString();
+        System.out.println(out);
+        check(out, "-J<flag>",     true);
+        check(out, "-J <flag>",    false);
+        check(out, "@<filename>",  true);
+        check(out, "@ <filename>", false);
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void check(String out, String text, boolean expect) {
+        if (out.contains(text) != expect) {
+            if (expect)
+                error("expected string not found: " + text);
+            else
+                error("unexpected string found: " + text);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javac/mandatoryWarnings/deprecated/Test.java b/test/tools/javac/mandatoryWarnings/deprecated/Test.java
index 28e3e2f..edaae6e 100644
--- a/test/tools/javac/mandatoryWarnings/deprecated/Test.java
+++ b/test/tools/javac/mandatoryWarnings/deprecated/Test.java
@@ -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
@@ -29,109 +29,19 @@
  * @bug 5047307
  * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:deprecation A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:deprecation A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:deprecation A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 1 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 2 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:deprecation -Xmaxwarns 3 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test5.out -XDrawDiagnostics -Xlint:deprecation  P.java Q.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test5b.out -XDrawDiagnostics -Xlint:deprecation -Xmaxwarns 2 P.java Q.java
  */
diff --git a/test/tools/javac/mandatoryWarnings/unchecked/Test.java b/test/tools/javac/mandatoryWarnings/unchecked/Test.java
index 6bce09f..434889c 100644
--- a/test/tools/javac/mandatoryWarnings/unchecked/Test.java
+++ b/test/tools/javac/mandatoryWarnings/unchecked/Test.java
@@ -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
@@ -29,95 +29,17 @@
  * @bug 5047307
  * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics -nowarn A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test1.out -XDrawDiagnostics -Xmaxwarns 1 A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics -nowarn A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test2.out -XDrawDiagnostics -Xmaxwarns 1 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3.out -XDrawDiagnostics -Xlint:unchecked A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test3b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4.out -XDrawDiagnostics -Xlint:unchecked A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4.out -XDrawDiagnostics -nowarn -Xlint:unchecked A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4b.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 1 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4c.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 2 A.java B.java
- */
-
-/*
- * @test
- * @bug 5047307
- * @summary javac -nowarn improperly suppresses JLS-mandated warnings
  * @compile/ref=Test4d.out -XDrawDiagnostics -nowarn -Xlint:unchecked -Xmaxwarns 3 A.java B.java
  */
diff --git a/test/tools/javac/meth/VarargsWarn.java b/test/tools/javac/meth/VarargsWarn.java
new file mode 100644
index 0000000..476617b
--- /dev/null
+++ b/test/tools/javac/meth/VarargsWarn.java
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8019340
+ * @summary varargs-related warnings are meaningless on signature-polymorphic methods such as MethodHandle.invokeExact
+ *
+ * @compile/fail/ref=VarargsWarn.out -XDrawDiagnostics -Werror VarargsWarn.java
+ */
+
+import java.lang.invoke.*;
+
+class VarargsWarn {
+    void test(MethodHandle mh) throws Throwable {
+        mh.invokeExact((Integer[])null);
+        mh.invoke((Integer[])null);
+        mh.invokeWithArguments((Integer[])null); //not a sig poly method - warning here!
+    }
+}
diff --git a/test/tools/javac/meth/VarargsWarn.out b/test/tools/javac/meth/VarargsWarn.out
new file mode 100644
index 0000000..13decfa
--- /dev/null
+++ b/test/tools/javac/meth/VarargsWarn.out
@@ -0,0 +1,4 @@
+VarargsWarn.java:15:32: compiler.warn.inexact.non-varargs.call: java.lang.Object, java.lang.Object[]
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java b/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java
index 38fcdcc..a0c0426 100644
--- a/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java
+++ b/test/tools/javac/multicatch/7030606/DisjunctiveTypeWellFormednessTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -23,21 +23,27 @@
 
 /*
  * @test
- * @bug 7030606
+ * @bug 7030606 8006694
  * @summary Project-coin: multi-catch types should be pairwise disjoint
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm DisjunctiveTypeWellFormednessTest
  */
 
-import com.sun.source.util.JavacTask;
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.net.URI;
 import java.util.Arrays;
 import javax.tools.Diagnostic;
-import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
 
-public class DisjunctiveTypeWellFormednessTest {
+public class DisjunctiveTypeWellFormednessTest
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     enum Alternative {
         EXCEPTION("Exception"),
@@ -92,40 +98,37 @@ public class DisjunctiveTypeWellFormednessTest {
     }
 
     public static void main(String... args) throws Exception {
-
-        //create default shared JavaCompiler - reused across multiple compilations
-        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
-
         for (Arity arity : Arity.values()) {
             for (Alternative a1 : Alternative.values()) {
                 if (arity == Arity.ONE) {
-                    new DisjunctiveTypeWellFormednessTest(a1).run(comp, fm);
+                    pool.execute(new DisjunctiveTypeWellFormednessTest(a1));
                     continue;
                 }
                 for (Alternative a2 : Alternative.values()) {
                     if (arity == Arity.TWO) {
-                        new DisjunctiveTypeWellFormednessTest(a1, a2).run(comp, fm);
+                        pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2));
                         continue;
                     }
                     for (Alternative a3 : Alternative.values()) {
                         if (arity == Arity.THREE) {
-                            new DisjunctiveTypeWellFormednessTest(a1, a2, a3).run(comp, fm);
+                            pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3));
                             continue;
                         }
                         for (Alternative a4 : Alternative.values()) {
                             if (arity == Arity.FOUR) {
-                                new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4).run(comp, fm);
+                                pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4));
                                 continue;
                             }
                             for (Alternative a5 : Alternative.values()) {
-                                new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5).run(comp, fm);
+                                pool.execute(new DisjunctiveTypeWellFormednessTest(a1, a2, a3, a4, a5));
                             }
                         }
                     }
                 }
             }
         }
+
+        checkAfterExec(false);
     }
 
     Alternative[] alternatives;
@@ -159,10 +162,16 @@ public class DisjunctiveTypeWellFormednessTest {
         }
     }
 
-    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+    @Override
+    public void run() {
+        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
                 null, null, Arrays.asList(source));
-        ct.analyze();
+        try {
+            ct.analyze();
+        } catch (Throwable t) {
+            processException(t);
+            return;
+        }
         check();
     }
 
@@ -202,4 +211,5 @@ public class DisjunctiveTypeWellFormednessTest {
             }
         }
     }
+
 }
diff --git a/test/tools/javac/multicatch/Neg06.out b/test/tools/javac/multicatch/Neg06.out
index 9b89d06..e4c5c4d 100644
--- a/test/tools/javac/multicatch/Neg06.out
+++ b/test/tools/javac/multicatch/Neg06.out
@@ -1,3 +1,3 @@
-Neg06.java:14:16: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.String, java.lang.Throwable
-Neg06.java:14:25: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Integer, java.lang.Throwable
+Neg06.java:14:16: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Throwable)
+Neg06.java:14:25: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Throwable)
 2 errors
diff --git a/test/tools/javac/multicatch/Neg07.out b/test/tools/javac/multicatch/Neg07.out
index f4712ba..32030e1 100644
--- a/test/tools/javac/multicatch/Neg07.out
+++ b/test/tools/javac/multicatch/Neg07.out
@@ -1,2 +1,2 @@
-Neg07.java:14:56: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Class<compiler.misc.type.captureof: 1, ? extends Neg07.ParentException>, java.lang.Class<? extends Neg07.HasFoo>
+Neg07.java:14:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class<compiler.misc.type.captureof: 1, ? extends Neg07.ParentException>, java.lang.Class<? extends Neg07.HasFoo>)
 1 error
diff --git a/test/tools/javac/multicatch/Pos11.java b/test/tools/javac/multicatch/Pos11.java
new file mode 100644
index 0000000..0d053d0
--- /dev/null
+++ b/test/tools/javac/multicatch/Pos11.java
@@ -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 {}
+
+}
+
diff --git a/test/tools/javac/multicatch/Pos12.java b/test/tools/javac/multicatch/Pos12.java
new file mode 100644
index 0000000..7b39b66
--- /dev/null
+++ b/test/tools/javac/multicatch/Pos12.java
@@ -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 {}
+}
+
diff --git a/test/tools/javac/multicatch/model/ModelChecker.java b/test/tools/javac/multicatch/model/ModelChecker.java
index 96c45e0..dcbd580 100644
--- a/test/tools/javac/multicatch/model/ModelChecker.java
+++ b/test/tools/javac/multicatch/model/ModelChecker.java
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6993963
+ * @bug 6993963 7025809
  * @summary Project Coin: Use precise exception analysis for effectively final catch parameters
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor ModelChecker
  * @compile -processor ModelChecker Model01.java
  */
@@ -107,7 +107,7 @@ public class ModelChecker extends JavacTestingAbstractProcessor {
             ; // Expected
         }
 
-        UnionType unionType = new SimpleTypeVisitor7<UnionType, Void>(){
+        UnionType unionType = new SimpleTypeVisitor<UnionType, Void>(){
             @Override
             protected UnionType defaultAction(TypeMirror e, Void p) {return null;}
 
diff --git a/test/tools/javac/nativeHeaders/NativeHeaderTest.java b/test/tools/javac/nativeHeaders/NativeHeaderTest.java
new file mode 100644
index 0000000..a14c71e
--- /dev/null
+++ b/test/tools/javac/nativeHeaders/NativeHeaderTest.java
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7150368 8003412 8000407
+ * @summary javac should include basic ability to generate native headers
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+
+public class NativeHeaderTest {
+    public static void main(String... args) throws Exception {
+        new NativeHeaderTest().run();
+    }
+
+    /** How to invoke javac. */
+    enum RunKind {
+        /** Use the command line entry point. */
+        CMD,
+        /** Use the JavaCompiler API. */
+        API
+    };
+
+    /** Which classes for which to generate headers. */
+    enum GenKind {
+        /** Just classes with native methods or the marker annotation. */
+        SIMPLE,
+        /** All appropriate classes within the top level class. */
+        FULL
+    };
+
+    // ---------- Test cases, invoked reflectively via run. ----------
+
+    @Test
+    void simpleTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { native void m(); }"));
+
+        Set<String> expect = createSet("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    @Test
+    void nestedClassTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { static class Inner { native void m(); } }"));
+
+        Set<String> expect = createSet("C_Inner.h");
+        if (gk == GenKind.FULL) expect.add("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    @Test
+    void localClassTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { native void m(); void m2() { class Local { } } }"));
+
+        Set<String> expect = createSet("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    @Test
+    void syntheticClassTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C {\n"
+                + "    private C() { }\n"
+                + "    class Inner extends C { native void m(); }\n"
+                + "}"));
+
+        Set<String> expect = createSet("C_Inner.h");
+        if (gk == GenKind.FULL) expect.add("C.h");
+
+        test(rk, gk, files, expect);
+
+        // double check the synthetic class was generated
+        checkEqual("generatedClasses",
+                createSet("C.class", "C$1.class", "C$Inner.class"),
+                createSet(classesDir.list()));
+    }
+
+    @Test
+    void annoTest(RunKind rk, GenKind gk) throws Exception {
+        List<File> files = new ArrayList<File>();
+        files.add(createFile("p/C.java",
+                "class C { @java.lang.annotation.Native public static final int i = 1907; }"));
+
+        Set<String> expect = createSet("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",
+                "class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }"));
+
+        Set<String> expect = createSet("C_Inner.h");
+        if (gk == GenKind.FULL) expect.add("C.h");
+
+        test(rk, gk, files, expect);
+    }
+
+    /**
+     * The worker method for each test case.
+     * Compile the files and verify that exactly the expected set of header files
+     * is generated.
+     */
+    void test(RunKind rk, GenKind gk, List<File> files, Set<String> expect) throws Exception {
+        List<String> args = new ArrayList<String>();
+        if (gk == GenKind.FULL)
+            args.add("-XDjavah:full");
+
+        switch (rk) {
+            case CMD:
+                args.add("-d");
+                args.add(classesDir.getPath());
+                args.add("-h");
+                args.add(headersDir.getPath());
+                for (File f: files)
+                    args.add(f.getPath());
+                int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]));
+                if (rc != 0)
+                    throw new Exception("compilation failed, rc=" + rc);
+                break;
+
+            case API:
+                fm.setLocation(StandardLocation.SOURCE_PATH, Arrays.asList(srcDir));
+                fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(classesDir));
+                fm.setLocation(StandardLocation.NATIVE_HEADER_OUTPUT, Arrays.asList(headersDir));
+                JavacTask task = javac.getTask(null, fm, null, args, null,
+                        fm.getJavaFileObjectsFromFiles(files));
+                if (!task.call())
+                    throw new Exception("compilation failed");
+                break;
+        }
+
+        Set<String> found = createSet(headersDir.list());
+        checkEqual("header files", expect, found);
+    }
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /** Combo test to run all test cases in all modes. */
+    void run() throws Exception {
+        javac = JavacTool.create();
+        fm = javac.getStandardFileManager(null, null, null);
+
+        for (RunKind rk: RunKind.values()) {
+            for (GenKind gk: GenKind.values()) {
+                for (Method m: getClass().getDeclaredMethods()) {
+                    Annotation a = m.getAnnotation(Test.class);
+                    if (a != null) {
+                        init(rk, gk, m.getName());
+                        try {
+                            m.invoke(this, new Object[] { rk, gk });
+                        } catch (InvocationTargetException e) {
+                            Throwable cause = e.getCause();
+                            throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                        }
+                        System.err.println();
+                    }
+                }
+            }
+        }
+        System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
+        if (errorCount > 0)
+            throw new Exception(errorCount + " errors found");
+    }
+
+    /**
+     * Init directories for a test case.
+     */
+    void init(RunKind rk, GenKind gk, String name) throws IOException {
+        System.err.println("Test " + rk + " " + gk + " " + name);
+        testCount++;
+
+        testDir = new File(rk.toString().toLowerCase() + "_" + gk.toString().toLowerCase() + "-" + name);
+        srcDir = new File(testDir, "src");
+        srcDir.mkdirs();
+        classesDir = new File(testDir, "classes");
+        classesDir.mkdirs();
+        headersDir = new File(testDir, "headers");
+        headersDir.mkdirs();
+    }
+
+    /** Create a source file with given body text. */
+    File createFile(String path, final String body) throws IOException {
+        File f = new File(srcDir, path);
+        f.getParentFile().mkdirs();
+        try (FileWriter out = new FileWriter(f)) {
+            out.write(body);
+        }
+        return f;
+    }
+
+    /** Convenience method to create a set of items. */
+    <T> Set<T> createSet(T... items) {
+        return new HashSet<T>(Arrays.asList(items));
+    }
+
+    /** Convenience method to check two values are equal, and report an error if not. */
+    <T> void checkEqual(String label, T expect, T found) {
+        if ((found == null) ? (expect == null) : found.equals(expect))
+            return;
+        System.err.println("Error: mismatch");
+        System.err.println("  expected: " + expect);
+        System.err.println("     found: " + found);
+        errorCount++;
+    }
+
+    // Shared across API test cases
+    JavacTool javac;
+    StandardJavaFileManager fm;
+
+    // Directories set up by init
+    File testDir;
+    File srcDir;
+    File classesDir;
+    File headersDir;
+
+    // Statistics
+    int testCount;
+    int errorCount;
+}
+
diff --git a/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java b/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java
new file mode 100644
index 0000000..a4a9ab6
--- /dev/null
+++ b/test/tools/javac/nativeHeaders/javahComparison/CompareTest.java
@@ -0,0 +1,169 @@
+/*
+ * 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
+ * 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 7150368 8003412 8000407
+ * @summary javac should include basic ability to generate native headers
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class CompareTest {
+    public static void main(String... args) throws Exception {
+        new CompareTest().run();
+    }
+
+    void run() throws Exception {
+        File srcDir = new File(System.getProperty("test.src"));
+        File classesDir = new File("classes");
+        classesDir.mkdirs();
+        File javacHeaders = new File("headers.javac");
+        javacHeaders.mkdirs();
+        File javahHeaders = new File("headers.javah");
+        javahHeaders.mkdirs();
+
+        List<String> javacArgs = new ArrayList<String>();
+        javacArgs.add("-d");
+        javacArgs.add(classesDir.getPath());
+        javacArgs.add("-h");
+        javacArgs.add(javacHeaders.getPath());
+        javacArgs.add("-XDjavah:full");
+
+        for (File f: srcDir.listFiles()) {
+            if (f.getName().matches("TestClass[0-9]+\\.java")) {
+                sourceFileCount++;
+                javacArgs.add(f.getPath());
+            }
+        }
+
+        int rc = com.sun.tools.javac.Main.compile(javacArgs.toArray(new String[javacArgs.size()]));
+        if (rc != 0)
+            throw new Exception("javac failed; rc=" + rc);
+
+        List<String> javahArgs = new ArrayList<String>();
+        javahArgs.add("-d");
+        javahArgs.add(javahHeaders.getPath());
+
+        for (File f: classesDir.listFiles()) {
+            if (f.getName().endsWith(".class")) {
+                javahArgs.add(inferBinaryName(f));
+            }
+        }
+
+        PrintWriter pw = new PrintWriter(System.out, true);
+        rc = com.sun.tools.javah.Main.run(javahArgs.toArray(new String[javahArgs.size()]), pw);
+        if (rc != 0)
+            throw new Exception("javah failed; rc=" + rc);
+
+        compare(javahHeaders, javacHeaders);
+
+        int javahHeaderCount = javahHeaders.list().length;
+        int javacHeaderCount = javacHeaders.list().length;
+
+        System.out.println(sourceFileCount + " .java files found");
+        System.out.println(javacHeaderCount + " .h files generated by javac");
+        System.out.println(javahHeaderCount + " .h files generated by javah");
+        System.out.println(compareCount + " header files compared");
+
+        if (javacHeaderCount != javahHeaderCount || javacHeaderCount != compareCount)
+            error("inconsistent counts");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    String inferBinaryName(File file) {
+        String name = file.getName();
+        return name.substring(0, name.length() - ".class".length()).replace("$", ".");
+    }
+
+    /** Compare two directories.
+     *  @param f1 The golden directory
+     *  @param f2 The directory to be compared
+     */
+    void compare(File f1, File f2) {
+        compare(f1, f2, null);
+    }
+
+    /** Compare two files or directories
+     *  @param f1 The golden directory
+     *  @param f2 The directory to be compared
+     *  @param p An optional path identifying a file within the two directories
+     */
+    void compare(File f1, File f2, String p) {
+        File f1p = (p == null ? f1 : new File(f1, p));
+        File f2p = (p == null ? f2 : new File(f2, p));
+        if (f1p.isDirectory() && f2p.isDirectory()) {
+            Set<String> children = new HashSet<String>();
+            children.addAll(Arrays.asList(f1p.list()));
+            children.addAll(Arrays.asList(f2p.list()));
+            for (String c: children) {
+                compare(f1, f2, new File(p, c).getPath()); // null-safe for p
+            }
+        }
+        else if (f1p.isFile() && f2p.isFile()) {
+            System.out.println("checking " + p);
+            compareCount++;
+            String s1 = read(f1p);
+            String s2 = read(f2p);
+            if (!s1.equals(s2)) {
+                System.out.println("File: " + f1p + "\n" + s1);
+                System.out.println("File: " + f2p + "\n" + s2);
+                error("Files differ: " + f1p + " " + f2p);
+            }
+        }
+        else if (f1p.exists() && !f2p.exists())
+            error("Only in " + f1 + ": " + p);
+        else if (f2p.exists() && !f1p.exists())
+            error("Only in " + f2 + ": " + p);
+        else
+            error("Files differ: " + f1p + " " + f2p);
+    }
+
+    private String read(File f) {
+        try {
+            return new String(Files.readAllBytes(f.toPath()));
+        } catch (IOException e) {
+            error("error reading " + f + ": " + e);
+            return "";
+        }
+    }
+
+    private void error(String msg) {
+        System.out.println(msg);
+        errors++;
+    }
+
+    private int errors;
+    private int compareCount;
+    private int sourceFileCount;
+}
diff --git a/test/tools/javac/nativeHeaders/javahComparison/TestClass1.java b/test/tools/javac/nativeHeaders/javahComparison/TestClass1.java
new file mode 100644
index 0000000..93b21ae
--- /dev/null
+++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass1.java
@@ -0,0 +1,475 @@
+/*
+ * 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 java.util.List;
+
+public class TestClass1 {
+    // simple types
+    byte b;
+    short s;
+    int i;
+    long l;
+    float f;
+    double d;
+    Object o;
+    String t;
+    List<String> g;
+
+    // constants
+    static final byte bc = 0;
+    static final short sc = 0;
+    static final int ic = 0;
+    static final long lc = 0;
+    static final float fc = 0;
+    static final double dc = 0;
+    static final Object oc = null;
+    static final String tc = "";
+    static final List<String> gc = null;
+
+    // simple arrays
+    byte[] ba;
+    short[] sa; // not handled corrected by javah v6
+    int[] ia;
+    long[] la;
+    float[] fa;
+    double[] da;
+    Object[] oa;
+    String[] ta;
+    List<String>[] ga;
+
+    // multidimensional arrays
+    byte[][] baa;
+    short[][] saa;
+    int[][] iaa;
+    long[][] laa;
+    float[][] faa;
+    double[][] daa;
+    Object[][] oaa;
+    String[][] taa;
+    List<String>[] gaa;
+
+    // simple Java methods
+    byte bm() { return 0; }
+    short sm() { return 0; }
+    int im() { return 0; }
+    long lm() { return 0; }
+    float fm() { return 0; }
+    double dm() { return 0; }
+    Object om() { return null; }
+    String tm() { return ""; }
+    List<String> gm() { return null; }
+    void vm() { }
+    byte[] bam() { return null; }
+    short[] sam() { return null; }
+    int[] iam() { return null; }
+    long[] lam() { return null; }
+    float[] fam() { return null; }
+    double[] dam() { return null; }
+    Object[] oam() { return null; }
+    String[] tam() { return null; }
+    List<String>[] gam() { return null; }
+    byte[][] baam() { return null; }
+    short[][] saam() { return null; }
+    int[][] iaam() { return null; }
+    long[][] laam() { return null; }
+    float[][] faam() { return null; }
+    double[][] daam() { return null; }
+    Object[][] oaam() { return null; }
+    String[][] taam() { return null; }
+    List<String>[] gaam() { return null; }
+
+    // simple native methods
+    native byte bmn();
+    native short smn();
+    native int imn();
+    native long lmn();
+    native float fmn();
+    native double dmn();
+    native Object omn();
+    native String tmn();
+    native List<String> gmn();
+    native void vmn();
+    native byte[] bamn();
+    native short[] samn();
+    native int[] iamn();
+    native long[] lamn();
+    native float[] famn();
+    native double[] damn();
+    native Object[] oamn();
+    native String[] tamn();
+    native List<String>[] gamn();
+    native byte[][] baamn();
+    native short[][] saamn();
+    native int[][] iaamn();
+    native long[][] laamn();
+    native float[][] faamn();
+    native double[][] daamn();
+    native Object[][] oaamn();
+    native String[][] taamn();
+    native List<String>[] gaamn();
+
+    // overloaded Java methods
+    byte bm1() { return 0; }
+    short sm1() { return 0; }
+    int im1() { return 0; }
+    long lm1() { return 0; }
+    float fm1() { return 0; }
+    double dm1() { return 0; }
+    Object om1() { return null; }
+    String tm1() { return ""; }
+    List<String> gm1() { return null; }
+    void vm1() { }
+
+    byte bm2(int i) { return 0; }
+    short sm2(int i) { return 0; }
+    int im2(int i) { return 0; }
+    long lm2(int i) { return 0; }
+    float fm2(int i) { return 0; }
+    double dm2(int i) { return 0; }
+    Object om2(int i) { return null; }
+    String tm2(int i) { return ""; }
+    List<String> gm2(int i) { return null; }
+    void vm2(int i) { }
+
+    // overloaded native methods
+    native byte bmn1();
+    native short smn1();
+    native int imn1();
+    native long lmn1();
+    native float fmn1();
+    native double dmn1();
+    native Object omn1();
+    native String tmn1();
+    native List<String> gmn1();
+    native void vmn1();
+
+    native byte bmn2(int i);
+    native short smn2(int i);
+    native int imn2(int i);
+    native long lmn2(int i);
+    native float fmn2(int i);
+    native double dmn2(int i);
+    native Object omn2(int i);
+    native String tmn2(int i);
+    native List<String> gmn2(int i);
+    native void vmn2(int i);
+
+    // arg types for Java methods
+    void mb(byte b) { }
+    void ms(short s) { }
+    void mi(int i) { }
+    void ml(long l) { }
+    void mf(float f) { }
+    void md(double d) { }
+    void mo(Object o) { }
+    void mt(String t) { }
+    void mg(List<String> g) { }
+
+    // arg types for native methods
+    native void mbn(byte b);
+    native void msn(short s);
+    native void min(int i);
+    native void mln(long l);
+    native void mfn(float f);
+    native void mdn(double d);
+    native void mon(Object o);
+    native void mtn(String t);
+    native void mgn(List<String> g);
+
+    static class Inner1 {
+        // simple types
+        byte b;
+        short s;
+        int i;
+        long l;
+        float f;
+        double d;
+        Object o;
+        String t;
+        List<String> g;
+
+        // constants
+        static final byte bc = 0;
+        static final short sc = 0;
+        static final int ic = 0;
+        static final long lc = 0;
+        static final float fc = 0;
+        static final double dc = 0;
+        static final Object oc = null;
+        static final String tc = "";
+        static final List<String> gc = null;
+
+        // simple arrays
+        byte[] ba;
+        // short[] sa; // not handled corrected by javah v6
+        int[] ia;
+        long[] la;
+        float[] fa;
+        double[] da;
+        Object[] oa;
+        String[] ta;
+        List<String>[] ga;
+
+        // multidimensional arrays
+        byte[][] baa;
+        short[][] saa;
+        int[][] iaa;
+        long[][] laa;
+        float[][] faa;
+        double[][] daa;
+        Object[][] oaa;
+        String[][] taa;
+        List<String>[] gaa;
+
+        // simple Java methods
+        byte bm() { return 0; }
+        short sm() { return 0; }
+        int im() { return 0; }
+        long lm() { return 0; }
+        float fm() { return 0; }
+        double dm() { return 0; }
+        Object om() { return null; }
+        String tm() { return ""; }
+        List<String> gm() { return null; }
+        void vm() { }
+
+        // simple native methods
+        native byte bmn();
+        native short smn();
+        native int imn();
+        native long lmn();
+        native float fmn();
+        native double dmn();
+        native Object omn();
+        native String tmn();
+        native List<String> gmn();
+        native void vmn();
+
+        // overloaded Java methods
+        byte bm1() { return 0; }
+        short sm1() { return 0; }
+        int im1() { return 0; }
+        long lm1() { return 0; }
+        float fm1() { return 0; }
+        double dm1() { return 0; }
+        Object om1() { return null; }
+        String tm1() { return ""; }
+        List<String> gm1() { return null; }
+        void vm1() { }
+
+        byte bm2(int i) { return 0; }
+        short sm2(int i) { return 0; }
+        int im2(int i) { return 0; }
+        long lm2(int i) { return 0; }
+        float fm2(int i) { return 0; }
+        double dm2(int i) { return 0; }
+        Object om2(int i) { return null; }
+        String tm2(int i) { return ""; }
+        List<String> gm2(int i) { return null; }
+        void vm2(int i) { }
+
+        // overloaded native methods
+        native byte bmn1();
+        native short smn1();
+        native int imn1();
+        native long lmn1();
+        native float fmn1();
+        native double dmn1();
+        native Object omn1();
+        native String tmn1();
+        native List<String> gmn1();
+        native void vmn1();
+
+        native byte bmn2(int i);
+        native short smn2(int i);
+        native int imn2(int i);
+        native long lmn2(int i);
+        native float fmn2(int i);
+        native double dmn2(int i);
+        native Object omn2(int i);
+        native String tmn2(int i);
+        native List<String> gmn2(int i);
+        native void vmn2(int i);
+
+        // arg types for Java methods
+        void mb(byte b) { }
+        void ms(short s) { }
+        void mi(int i) { }
+        void ml(long l) { }
+        void mf(float f) { }
+        void md(double d) { }
+        void mo(Object o) { }
+        void mt(String t) { }
+        void mg(List<String> g) { }
+
+        // arg types for native methods
+        native void mbn(byte b);
+        native void msn(short s);
+        native void min(int i);
+        native void mln(long l);
+        native void mfn(float f);
+        native void mdn(double d);
+        native void mon(Object o);
+        native void mtn(String t);
+        native void mgn(List<String> g);
+    }
+
+    class Inner2 {
+        // simple types
+        byte b;
+        short s;
+        int i;
+        long l;
+        float f;
+        double d;
+        Object o;
+        String t;
+        List<String> g;
+
+        // constants
+        static final byte bc = 0;
+        static final short sc = 0;
+        static final int ic = 0;
+        static final long lc = 0;
+        static final float fc = 0;
+        static final double dc = 0;
+        //static final Object oc = null;
+        static final String tc = "";
+        //static final List<String> gc = null;
+
+        // simple arrays
+        byte[] ba;
+        // short[] sa; // not handled corrected by javah v6
+        int[] ia;
+        long[] la;
+        float[] fa;
+        double[] da;
+        Object[] oa;
+        String[] ta;
+        List<String>[] ga;
+
+        // multidimensional arrays
+        byte[][] baa;
+        short[][] saa;
+        int[][] iaa;
+        long[][] laa;
+        float[][] faa;
+        double[][] daa;
+        Object[][] oaa;
+        String[][] taa;
+        List<String>[] gaa;
+
+        // simple Java methods
+        byte bm() { return 0; }
+        short sm() { return 0; }
+        int im() { return 0; }
+        long lm() { return 0; }
+        float fm() { return 0; }
+        double dm() { return 0; }
+        Object om() { return null; }
+        String tm() { return ""; }
+        List<String> gm() { return null; }
+        void vm() { }
+
+        // simple native methods
+        native byte bmn();
+        native short smn();
+        native int imn();
+        native long lmn();
+        native float fmn();
+        native double dmn();
+        native Object omn();
+        native String tmn();
+        native List<String> gmn();
+        native void vmn();
+
+        // overloaded Java methods
+        byte bm1() { return 0; }
+        short sm1() { return 0; }
+        int im1() { return 0; }
+        long lm1() { return 0; }
+        float fm1() { return 0; }
+        double dm1() { return 0; }
+        Object om1() { return null; }
+        String tm1() { return ""; }
+        List<String> gm1() { return null; }
+        void vm1() { }
+
+        byte bm2(int i) { return 0; }
+        short sm2(int i) { return 0; }
+        int im2(int i) { return 0; }
+        long lm2(int i) { return 0; }
+        float fm2(int i) { return 0; }
+        double dm2(int i) { return 0; }
+        Object om2(int i) { return null; }
+        String tm2(int i) { return ""; }
+        List<String> gm2(int i) { return null; }
+        void vm2(int i) { }
+
+        // overloaded native methods
+        native byte bmn1();
+        native short smn1();
+        native int imn1();
+        native long lmn1();
+        native float fmn1();
+        native double dmn1();
+        native Object omn1();
+        native String tmn1();
+        native List<String> gmn1();
+        native void vmn1();
+
+        native byte bmn2(int i);
+        native short smn2(int i);
+        native int imn2(int i);
+        native long lmn2(int i);
+        native float fmn2(int i);
+        native double dmn2(int i);
+        native Object omn2(int i);
+        native String tmn2(int i);
+        native List<String> gmn2(int i);
+        native void vmn2(int i);
+
+        // arg types for Java methods
+        void mb(byte b) { }
+        void ms(short s) { }
+        void mi(int i) { }
+        void ml(long l) { }
+        void mf(float f) { }
+        void md(double d) { }
+        void mo(Object o) { }
+        void mt(String t) { }
+        void mg(List<String> g) { }
+
+        // arg types for native methods
+        native void mbn(byte b);
+        native void msn(short s);
+        native void min(int i);
+        native void mln(long l);
+        native void mfn(float f);
+        native void mdn(double d);
+        native void mon(Object o);
+        native void mtn(String t);
+        native void mgn(List<String> g);
+    }
+
+}
diff --git a/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java b/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java
new file mode 100644
index 0000000..bb2c808
--- /dev/null
+++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass4.java
@@ -0,0 +1,50 @@
+/*
+ * 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 java.lang.annotation.Native;
+
+public class TestClass4 {
+    @Native
+    public static final byte b = 1;
+
+    @Native
+    public static final short s = 2;
+
+    @Native
+    public static final int i = 3;
+
+    @Native
+    public static final long l = 4;
+
+    @Native
+    public static final float f = 5.0f;
+
+    @Native
+    public static final double d = 6.0;
+
+    @Native
+    public static final Object o = null;
+
+    @Native
+    public static final String t = "8";
+}
diff --git a/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java b/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java
new file mode 100644
index 0000000..95388ab
--- /dev/null
+++ b/test/tools/javac/nativeHeaders/javahComparison/TestClass5.java
@@ -0,0 +1,60 @@
+/*
+ * 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 java.lang.annotation.Native;
+
+public class TestClass5 {
+    @Native
+    public static final int tc5 = 1;
+
+    public class Inner1 {
+        @Native
+        public static final int tc5i1 = 2;
+
+        public class Inner1A {
+            @Native
+            public static final int tc5i1i1a = 3;
+        }
+
+        public class Inner1B {
+            @Native
+            public static final int tc5i1i1b = 4;
+        }
+    }
+
+    public class Inner2 {
+        @Native
+        public static final int tc521 = 5;
+
+        public class Inner2A {
+            @Native
+            public static final int tc5i2i2a = 6;
+        }
+
+        public class Inner2B {
+            @Native
+            public static final int tc5i2i2b = 7;
+        }
+    }
+}
+
diff --git a/test/tools/javac/newlines/NewLineTest.java b/test/tools/javac/newlines/NewLineTest.java
new file mode 100644
index 0000000..27392f2
--- /dev/null
+++ b/test/tools/javac/newlines/NewLineTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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 4110560 4785453
+ * @summary portability : javac.properties
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NewLineTest
+ */
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.List;
+
+//original test: test/tools/javac/newlines/Newlines.sh
+public class NewLineTest {
+
+    public static void main(String args[]) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
+        File javacErrOutput = new File("output.txt");
+        ToolBox.AnyToolArgs cmdArgs =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .appendArgs(ToolBox.javacBinary)
+                .appendArgs(ToolBox.testToolVMOpts)
+                .appendArgs("-J-Dline.separator='@'")
+                .setErrOutput(javacErrOutput);
+        ToolBox.executeCommand(cmdArgs);
+
+//        result=`cat ${TMP1} | wc -l`
+//        if [ "$result" -eq 0 ] passed
+        List<String> lines = Files.readAllLines(javacErrOutput.toPath(),
+                Charset.defaultCharset());
+        if (lines.size() != 1) {
+            throw new AssertionError("The compiler output should have one line only");
+        }
+    }
+
+}
diff --git a/test/tools/javac/newlines/Newlines.sh b/test/tools/javac/newlines/Newlines.sh
deleted file mode 100644
index ccb30c6..0000000
--- a/test/tools/javac/newlines/Newlines.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#
-# Copyright (c) 2002, 2009, 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 4110560 4785453
-# @summary portability : javac.properties
-#
-# @run shell Newlines.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
-cat ${TMP1}
-result=`cat ${TMP1} | wc -l`
-if [ "$result" -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/options/T6949443.java b/test/tools/javac/options/T6949443.java
new file mode 100644
index 0000000..6a3be8a
--- /dev/null
+++ b/test/tools/javac/options/T6949443.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+/*
+ * @test
+ * @bug 6949443
+ * @summary VisitTree assertion triggered using -Xjcov on small sample program
+ * @compile -Xjcov T6949443.java
+ */
+
+public class T6949443 {
+    public static void main(String[] args) {
+        Integer i = 0;
+        i++;
+    }
+}
diff --git a/test/tools/javac/options/T7022337.java b/test/tools/javac/options/T7022337.java
index e69ac69..27be151 100644
--- a/test/tools/javac/options/T7022337.java
+++ b/test/tools/javac/options/T7022337.java
@@ -26,7 +26,7 @@
  * @test
  * @bug 7022337
  * @summary repeated warnings about bootclasspath not set
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor T7022337
  * @run main T7022337
  */
diff --git a/test/tools/javac/parser/7157165/T7157165.java b/test/tools/javac/parser/7157165/T7157165.java
new file mode 100644
index 0000000..e8cf054
--- /dev/null
+++ b/test/tools/javac/parser/7157165/T7157165.java
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7157165
+ *
+ * @summary Regression: code with disjunctive type crashes javac
+ * @compile/fail/ref=T7157165.out -XDrawDiagnostics T7157165.java
+ *
+ */
+
+class T7157165 {
+    Foo<? extends A|B> foo1 = null;
+}
diff --git a/test/tools/javac/parser/7157165/T7157165.out b/test/tools/javac/parser/7157165/T7157165.out
new file mode 100644
index 0000000..ed252df
--- /dev/null
+++ b/test/tools/javac/parser/7157165/T7157165.out
@@ -0,0 +1,4 @@
+T7157165.java:11:20: compiler.err.expected: >
+T7157165.java:11:21: compiler.err.expected: ';'
+T7157165.java:11:22: compiler.err.illegal.start.of.type
+3 errors
diff --git a/test/tools/javac/parser/8014643/T8014643.java b/test/tools/javac/parser/8014643/T8014643.java
new file mode 100644
index 0000000..ab4eaf2
--- /dev/null
+++ b/test/tools/javac/parser/8014643/T8014643.java
@@ -0,0 +1,41 @@
+/*
+ * 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 8014643
+ * @summary Parser regression in JDK 8 when compiling super.x
+ * @compile T8014643.java
+ */
+class T8014643 {
+
+    static class A {
+        int b = 1;
+    }
+
+    static class B extends A {
+        int b = 12;
+
+        int m() { return (super.b); }
+    }
+}
diff --git a/test/tools/javac/parser/JavacParserTest.java b/test/tools/javac/parser/JavacParserTest.java
new file mode 100644
index 0000000..1dd437a
--- /dev/null
+++ b/test/tools/javac/parser/JavacParserTest.java
@@ -0,0 +1,978 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7073631 7159445 7156633
+ * @summary tests error and diagnostics positions
+ * @author  Jan Lahoda
+ */
+
+import com.sun.source.tree.BinaryTree;
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.ModifiersTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.tree.WhileLoopTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreeScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.tree.JCTree;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Pattern;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class JavacParserTest extends TestCase {
+    static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+
+    private JavacParserTest(){}
+
+    public static void main(String... args) throws Exception {
+        new JavacParserTest().run(args);
+    }
+
+    class MyFileObject extends SimpleJavaFileObject {
+
+        private String text;
+
+        public MyFileObject(String text) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+    /*
+     * converts Windows to Unix style LFs for comparing strings
+     */
+    String normalize(String in) {
+        return in.replace(System.getProperty("line.separator"), "\n");
+    }
+
+    CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        return cut;
+    }
+
+    List<String> getErroneousTreeValues(ErroneousTree node) {
+
+        List<String> values = new ArrayList<>();
+        if (node.getErrorTrees() != null) {
+            for (Tree t : node.getErrorTrees()) {
+                values.add(t.toString());
+            }
+        } else {
+            throw new RuntimeException("ERROR: No Erroneous tree "
+                    + "has been created.");
+        }
+        return values;
+    }
+
+    @Test
+    void testPositionForSuperConstructorCalls() throws IOException {
+        assert tool != null;
+
+        String code = "package test; public class Test {public Test() {super();}}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        MethodTree method =
+                (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
+        ExpressionStatementTree es =
+                (ExpressionStatementTree) method.getBody().getStatements().get(0);
+
+        final int esStartPos = code.indexOf(es.toString());
+        final int esEndPos = esStartPos + es.toString().length();
+        assertEquals("testPositionForSuperConstructorCalls",
+                esStartPos, pos.getStartPosition(cut, es));
+        assertEquals("testPositionForSuperConstructorCalls",
+                esEndPos, pos.getEndPosition(cut, es));
+
+        MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
+
+        final int mitStartPos = code.indexOf(mit.toString());
+        final int mitEndPos = mitStartPos + mit.toString().length();
+        assertEquals("testPositionForSuperConstructorCalls",
+                mitStartPos, pos.getStartPosition(cut, mit));
+        assertEquals("testPositionForSuperConstructorCalls",
+                mitEndPos, pos.getEndPosition(cut, mit));
+
+        final int methodStartPos = mitStartPos;
+        final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length();
+        assertEquals("testPositionForSuperConstructorCalls",
+                methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
+        assertEquals("testPositionForSuperConstructorCalls",
+                methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
+    }
+
+    @Test
+    void testPositionForEnumModifiers() throws IOException {
+        final String theString = "public";
+        String code = "package test; " + theString + " enum Test {A;}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        ModifiersTree mt = clazz.getModifiers();
+        int spos = code.indexOf(theString);
+        int epos = spos + theString.length();
+        assertEquals("testPositionForEnumModifiers",
+                spos, pos.getStartPosition(cut, mt));
+        assertEquals("testPositionForEnumModifiers",
+                epos, pos.getEndPosition(cut, mt));
+    }
+
+    @Test
+    void testNewClassWithEnclosing() throws IOException {
+
+        final String theString = "Test.this.new d()";
+        String code = "package test; class Test { " +
+                "class d {} private void method() { " +
+                "Object o = " + theString + "; } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        ExpressionTree est =
+                ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
+
+        final int spos = code.indexOf(theString);
+        final int epos = spos + theString.length();
+        assertEquals("testNewClassWithEnclosing",
+                spos, pos.getStartPosition(cut, est));
+        assertEquals("testNewClassWithEnclosing",
+                epos, pos.getEndPosition(cut, est));
+    }
+
+    @Test
+    void testPreferredPositionForBinaryOp() throws IOException {
+
+        String code = "package test; public class Test {"
+                + "private void test() {"
+                + "Object o = null; boolean b = o != null && o instanceof String;"
+                + "} private Test() {}}";
+
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        MethodTree method = (MethodTree) clazz.getMembers().get(0);
+        VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
+        BinaryTree cond = (BinaryTree) condSt.getInitializer();
+
+        JCTree condJC = (JCTree) cond;
+        int condStartPos = code.indexOf("&&");
+        assertEquals("testPreferredPositionForBinaryOp",
+                condStartPos, condJC.pos);
+    }
+
+    @Test
+    void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
+
+        String code = "package test; class Test { " +
+                "private void method() { " +
+                "java.util.Set<String> s = null; for (a : s) {} } }";
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                errors.add(diagnostic);
+            }
+        }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        StatementTree forStatement =
+                ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
+
+        assertEquals("testErrorRecoveryForEnhancedForLoop142381",
+                Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
+        assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
+    }
+
+    @Test
+    void testPositionAnnotationNoPackage187551() throws IOException {
+
+        String code = "\n at interface Test {}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        Trees t = Trees.instance(ct);
+
+        assertEquals("testPositionAnnotationNoPackage187551",
+                1, t.getSourcePositions().getStartPosition(cut, clazz));
+    }
+
+    @Test
+    void testPositionsSane1() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? extends java.util.List<? extends String>> l; " +
+                "} }");
+    }
+
+    @Test
+    void testPositionsSane2() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? super java.util.List<? super String>> l; " +
+                "} }");
+    }
+
+    @Test
+    void testPositionsSane3() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? super java.util.List<?>> l; } }");
+    }
+
+    private void performPositionsSanityTest(String code) throws IOException {
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                errors.add(diagnostic);
+            }
+        }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        final Trees trees = Trees.instance(ct);
+
+        new TreeScanner<Void, Void>() {
+
+            private long parentStart = 0;
+            private long parentEnd = Integer.MAX_VALUE;
+
+            @Override
+            public Void scan(Tree node, Void p) {
+                if (node == null) {
+                    return null;
+                }
+
+                long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+                if (start == (-1)) {
+                    return null; // synthetic tree
+                }
+                assertTrue(node.toString() + ":" + start + "/" + parentStart,
+                        parentStart <= start);
+
+                long prevParentStart = parentStart;
+
+                parentStart = start;
+
+                long end = trees.getSourcePositions().getEndPosition(cut, node);
+
+                assertTrue(node.toString() + ":" + end + "/" + parentEnd,
+                        end <= parentEnd);
+
+                long prevParentEnd = parentEnd;
+
+                parentEnd = end;
+
+                super.scan(node, p);
+
+                parentStart = prevParentStart;
+                parentEnd = prevParentEnd;
+
+                return null;
+            }
+
+            private void assertTrue(String message, boolean b) {
+                if (!b) fail(message);
+            }
+        }.scan(cut, null);
+    }
+
+    @Test
+    void testCorrectWilcardPositions1() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { List<? extends List<? extends String>> l; } }",
+
+                Arrays.asList("List<? extends List<? extends String>> l;",
+                "List<? extends List<? extends String>>",
+                "List",
+                "? extends List<? extends String>",
+                "List<? extends String>",
+                "List",
+                "? extends String",
+                "String"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions2() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; "
+                + "class Test { private void method() { List<? super List<? super String>> l; } }",
+                Arrays.asList("List<? super List<? super String>> l;",
+                "List<? super List<? super String>>",
+                "List",
+                "? super List<? super String>",
+                "List<? super String>",
+                "List",
+                "? super String",
+                "String"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions3() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { List<? super List<?>> l; } }",
+
+                Arrays.asList("List<? super List<?>> l;",
+                "List<? super List<?>>",
+                "List",
+                "? super List<?>",
+                "List<?>",
+                "List",
+                "?"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions4() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { " +
+                "List<? extends List<? extends List<? extends String>>> l; } }",
+
+                Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
+                "List<? extends List<? extends List<? extends String>>>",
+                "List",
+                "? extends List<? extends List<? extends String>>",
+                "List<? extends List<? extends String>>",
+                "List",
+                "? extends List<? extends String>",
+                "List<? extends String>",
+                "List",
+                "? extends String",
+                "String"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions5() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { " +
+                "List<? extends List<? extends List<? extends String   >>> l; } }",
+                Arrays.asList("List<? extends List<? extends List<? extends String   >>> l;",
+                "List<? extends List<? extends List<? extends String   >>>",
+                "List",
+                "? extends List<? extends List<? extends String   >>",
+                "List<? extends List<? extends String   >>",
+                "List",
+                "? extends List<? extends String   >",
+                "List<? extends String   >",
+                "List",
+                "? extends String",
+                "String"));
+    }
+
+    void performWildcardPositionsTest(final String code,
+            List<String> golden) throws IOException {
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+                    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                        errors.add(diagnostic);
+                    }
+                }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        final List<String> content = new LinkedList<String>();
+        final Trees trees = Trees.instance(ct);
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void scan(Tree node, Void p) {
+                if (node == null) {
+                    return null;
+                }
+                long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+                if (start == (-1)) {
+                    return null; // synthetic tree
+                }
+                long end = trees.getSourcePositions().getEndPosition(cut, node);
+                String s = code.substring((int) start, (int) end);
+                content.add(s);
+
+                return super.scan(node, p);
+            }
+        }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
+
+        assertEquals("performWildcardPositionsTest",golden.toString(),
+                content.toString());
+    }
+
+    @Test
+    void testStartPositionForMethodWithoutModifiers() throws IOException {
+
+        String code = "package t; class Test { <T> void t() {} }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        MethodTree mt = (MethodTree) clazz.getMembers().get(0);
+        Trees t = Trees.instance(ct);
+        int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
+        int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
+
+        assertEquals("testStartPositionForMethodWithoutModifiers",
+                "<T> void t() {}", code.substring(start, end));
+    }
+
+    @Test
+    void testVariableInIfThen1() throws IOException {
+
+        String code = "package t; class Test { " +
+                "private static void t(String name) { " +
+                "if (name != null) String nn = name.trim(); } }";
+
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen1",
+                Arrays.<String>asList("compiler.err.variable.not.allowed"),
+                codes);
+    }
+
+    @Test
+   void testVariableInIfThen2() throws IOException {
+
+        String code = "package t; class Test { " +
+                "private static void t(String name) { " +
+                "if (name != null) class X {} } }";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen2",
+                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+    }
+
+    @Test
+    void testVariableInIfThen3() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t() { " +
+                "if (true) abstract class F {} }}";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen3",
+                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+    }
+
+    @Test
+    void testVariableInIfThen4() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t(String name) { " +
+                "if (name != null) interface X {} } }";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen4",
+                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+    }
+
+    @Test
+    void testVariableInIfThen5() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t() { " +
+                "if (true) } }";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen5",
+                Arrays.<String>asList("compiler.err.illegal.start.of.stmt"),
+                codes);
+    }
+
+    // see javac bug #6882235, NB bug #98234:
+    @Test
+    void testMissingExponent() throws IOException {
+
+        String code = "\nclass Test { { System.err.println(0e); } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        assertNotNull(ct.parse().iterator().next());
+    }
+
+    @Test
+    void testTryResourcePos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ try (java.io.InputStream in = null) { } } }";
+
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                if ("in".contentEquals(node.getName())) {
+                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+                    assertEquals("testTryResourcePos", "in = null) { } } }",
+                            code.substring(var.pos));
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+    }
+
+    @Test
+    void testVarPos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ java.io.InputStream in = null; } }";
+
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                if ("in".contentEquals(node.getName())) {
+                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+                    assertEquals("testVarPos","in = null; } }",
+                            code.substring(var.pos));
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+    }
+
+    // expected erroneous tree: int x = y;(ERROR);
+    @Test
+    void testOperatorMissingError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void method() { int x = y  z } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[z]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree:  String s = (ERROR);
+    @Test
+    void testMissingParenthesisError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void f() {String s = new String; } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[new String()]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: package test; (ERROR)(ERROR)
+    @Test
+    void testMissingClassError() throws IOException {
+
+        String code = "package Test; clas ErrorTest {  "
+                + "void f() {String s = new String(); } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[, clas]", "[]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
+    @Test
+    void testSwitchError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "int numDays; void m1(int i) { switchh {i} { case 1: "
+                + "numDays = 31; break; } } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: class ErrorTest {(ERROR)
+    @Test
+    void testMethodError() throws IOException {
+
+        String code = "package Test; class ErrorTest {  "
+                + "static final void f) {String s = new String(); } }";
+        CompilationUnitTree cut = cut = getCompilationUnitTree(code);
+
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(normalize(getErroneousTreeValues(node).toString()));
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testMethodError: The Erroneous tree "
+                + "error value: " + values
+                + " does not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    /*
+     * The following tests do not work just yet with nb-javac nor javac,
+     * they need further investigation, see CR: 7167356
+     */
+
+    void testPositionBrokenSource126732a() throws IOException {
+        String[] commands = new String[]{
+            "return Runnable()",
+            "do { } while (true)",
+            "throw UnsupportedOperationException()",
+            "assert true",
+            "1 + 1",};
+
+        for (String command : commands) {
+
+            String code = "package test;\n"
+                    + "public class Test {\n"
+                    + "    public static void test() {\n"
+                    + "        " + command + " {\n"
+                    + "                new Runnable() {\n"
+                    + "        };\n"
+                    + "    }\n"
+                    + "}";
+            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+                    null, null, Arrays.asList(new MyFileObject(code)));
+            CompilationUnitTree cut = ct.parse().iterator().next();
+
+            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+            MethodTree method = (MethodTree) clazz.getMembers().get(0);
+            List<? extends StatementTree> statements =
+                    method.getBody().getStatements();
+
+            StatementTree ret = statements.get(0);
+            StatementTree block = statements.get(1);
+
+            Trees t = Trees.instance(ct);
+            int len = code.indexOf(command + " {") + (command + " ").length();
+            assertEquals(command, len,
+                    t.getSourcePositions().getEndPosition(cut, ret));
+            assertEquals(command, len,
+                    t.getSourcePositions().getStartPosition(cut, block));
+        }
+    }
+
+    void testPositionBrokenSource126732b() throws IOException {
+        String[] commands = new String[]{
+            "break",
+            "break A",
+            "continue ",
+            "continue A",};
+
+        for (String command : commands) {
+
+            String code = "package test;\n"
+                    + "public class Test {\n"
+                    + "    public static void test() {\n"
+                    + "        while (true) {\n"
+                    + "            " + command + " {\n"
+                    + "                new Runnable() {\n"
+                    + "        };\n"
+                    + "        }\n"
+                    + "    }\n"
+                    + "}";
+
+            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+                    null, null, Arrays.asList(new MyFileObject(code)));
+            CompilationUnitTree cut = ct.parse().iterator().next();
+
+            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+            MethodTree method = (MethodTree) clazz.getMembers().get(0);
+            List<? extends StatementTree> statements =
+                    ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
+
+            StatementTree ret = statements.get(0);
+            StatementTree block = statements.get(1);
+
+            Trees t = Trees.instance(ct);
+            int len = code.indexOf(command + " {") + (command + " ").length();
+            assertEquals(command, len,
+                    t.getSourcePositions().getEndPosition(cut, ret));
+            assertEquals(command, len,
+                    t.getSourcePositions().getStartPosition(cut, block));
+        }
+    }
+
+    void testStartPositionEnumConstantInit() throws IOException {
+
+        String code = "package t; enum Test { AAA; }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
+        Trees t = Trees.instance(ct);
+        int start = (int) t.getSourcePositions().getStartPosition(cut,
+                enumAAA.getInitializer());
+
+        assertEquals("testStartPositionEnumConstantInit", -1, start);
+    }
+
+    void run(String[] args) throws Exception {
+        int passed = 0, failed = 0;
+        final Pattern p = (args != null && args.length > 0)
+                ? Pattern.compile(args[0])
+                : null;
+        for (Method m : this.getClass().getDeclaredMethods()) {
+            boolean selected = (p == null)
+                    ? m.isAnnotationPresent(Test.class)
+                    : p.matcher(m.getName()).matches();
+            if (selected) {
+                try {
+                    m.invoke(this, (Object[]) null);
+                    System.out.println(m.getName() + ": OK");
+                    passed++;
+                } catch (Throwable ex) {
+                    System.out.printf("Test %s failed: %s %n", m, ex.getCause());
+                    failed++;
+                }
+            }
+        }
+        System.out.printf("Passed: %d, Failed %d%n", passed, failed);
+        if (failed > 0) {
+            throw new RuntimeException("Tests failed: " + failed);
+        }
+        if (passed == 0 && failed == 0) {
+            throw new AssertionError("No test(s) selected: passed = " +
+                    passed + ", failed = " + failed + " ??????????");
+        }
+    }
+}
+
+abstract class TestCase {
+
+    void assertEquals(String message, int i, int pos) {
+        if (i != pos) {
+            fail(message);
+        }
+    }
+
+    void assertFalse(String message, boolean bvalue) {
+        if (bvalue == true) {
+            fail(message);
+        }
+    }
+
+    void assertEquals(String message, int i, long l) {
+        if (i != l) {
+            fail(message + ":" + i + ":" + l);
+        }
+    }
+
+    void assertEquals(String message, Object o1, Object o2) {
+        if (o1 != null && o2 != null && !o1.equals(o2)) {
+            fail(message);
+        }
+        if (o1 == null && o2 != null) {
+            fail(message);
+        }
+    }
+
+    void assertNotNull(Object o) {
+        if (o == null) {
+            fail();
+        }
+    }
+
+    void fail() {
+        fail("test failed");
+    }
+
+    void fail(String message) {
+        throw new RuntimeException(message);
+    }
+
+    /**
+     * Indicates that the annotated method is a test method.
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    public @interface Test {}
+}
diff --git a/test/tools/javac/parser/SingleCommaAnnotationValue.java b/test/tools/javac/parser/SingleCommaAnnotationValue.java
new file mode 100644
index 0000000..53a3a55
--- /dev/null
+++ b/test/tools/javac/parser/SingleCommaAnnotationValue.java
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 8012722
+ * @summary Single comma in array initializer should parse
+ * @compile SingleCommaAnnotationValue.java
+ */
+
+public class SingleCommaAnnotationValue {
+    @Foo({}) void a() { }
+    @Foo({,}) void b() { }
+    @Foo({0}) void c() { }
+    @Foo({0,}) void d() { }
+    @Foo({0,0}) void e() { }
+    @Foo({0,0,}) void f() { }
+}
+ at interface Foo { int[] value(); }
diff --git a/test/tools/javac/parser/SingleCommaAnnotationValueFail.java b/test/tools/javac/parser/SingleCommaAnnotationValueFail.java
new file mode 100644
index 0000000..4467d98
--- /dev/null
+++ b/test/tools/javac/parser/SingleCommaAnnotationValueFail.java
@@ -0,0 +1,36 @@
+/*
+ * 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 8012722
+ * @summary Single comma in array initializer should parse
+ * @compile/fail/ref=SingleCommaAnnotationValueFail.out -XDrawDiagnostics
+ * SingleCommaAnnotationValueFail.java
+ */
+
+public class SingleCommaAnnotationValueFail {
+    // Non-example
+    @Foo({,0}) void a() { }
+}
+ at interface Foo { int[] value(); }
diff --git a/test/tools/javac/parser/SingleCommaAnnotationValueFail.out b/test/tools/javac/parser/SingleCommaAnnotationValueFail.out
new file mode 100644
index 0000000..10a8f4d
--- /dev/null
+++ b/test/tools/javac/parser/SingleCommaAnnotationValueFail.out
@@ -0,0 +1,6 @@
+SingleCommaAnnotationValueFail.java:34:12: compiler.err.expected: '}'
+SingleCommaAnnotationValueFail.java:34:13: compiler.err.illegal.start.of.type
+SingleCommaAnnotationValueFail.java:34:14: compiler.err.expected: token.identifier
+SingleCommaAnnotationValueFail.java:34:15: compiler.err.expected: ';'
+SingleCommaAnnotationValueFail.java:34:21: compiler.err.invalid.meth.decl.ret.type.req
+5 errors
diff --git a/test/tools/javac/parser/T4881269.java b/test/tools/javac/parser/T4881269.java
new file mode 100644
index 0000000..8c5ca9b
--- /dev/null
+++ b/test/tools/javac/parser/T4881269.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 4881269
+ * @summary improve diagnostic for ill-formed tokens
+ * @compile/fail/ref=T4881269.out -XDrawDiagnostics T4881269.java
+ */
+
+public class T4881269 {
+    java.io..PrintStream s;
+    void m() { System.err..println(); }
+    void m(Object.. o) { }
+}
diff --git a/test/tools/javac/parser/T4881269.out b/test/tools/javac/parser/T4881269.out
new file mode 100644
index 0000000..b6b2698
--- /dev/null
+++ b/test/tools/javac/parser/T4881269.out
@@ -0,0 +1,9 @@
+T4881269.java:32:13: compiler.err.illegal.dot
+T4881269.java:33:27: compiler.err.illegal.dot
+T4881269.java:33:22: compiler.err.not.stmt
+T4881269.java:34:19: compiler.err.illegal.dot
+T4881269.java:34:20: compiler.err.expected: ';'
+T4881269.java:34:22: compiler.err.illegal.start.of.type
+T4881269.java:34:23: compiler.err.expected: token.identifier
+T4881269.java:34:25: compiler.err.expected: ';'
+8 errors
diff --git a/test/tools/javac/parser/netbeans/JavacParserTest.java b/test/tools/javac/parser/netbeans/JavacParserTest.java
deleted file mode 100644
index 79ce213..0000000
--- a/test/tools/javac/parser/netbeans/JavacParserTest.java
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * Copyright (c) 2011, 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 7073631
- * @summary tests error and diagnostics positions
- * @author  jan.lahoda at oracle.com
- */
-
-import com.sun.source.tree.BinaryTree;
-import com.sun.source.tree.BlockTree;
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.ExpressionStatementTree;
-import com.sun.source.tree.ExpressionTree;
-import com.sun.source.tree.MethodInvocationTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.ModifiersTree;
-import com.sun.source.tree.StatementTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.Tree.Kind;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.tree.JCTree;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.ToolProvider;
-
-public class JavacParserTest extends TestCase {
-    final JavaCompiler tool;
-    public JavacParserTest(String testName) {
-        tool = ToolProvider.getSystemJavaCompiler();
-        System.out.println("java.home=" + System.getProperty("java.home"));
-    }
-
-    static class MyFileObject extends SimpleJavaFileObject {
-
-        private String text;
-
-        public MyFileObject(String text) {
-            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            this.text = text;
-        }
-
-        @Override
-        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
-            return text;
-        }
-    }
-
-    public void testPositionForSuperConstructorCalls() throws IOException {
-        assert tool != null;
-
-        String code = "package test; public class Test {public Test() {super();}}";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
-        MethodTree method =
-                (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
-        ExpressionStatementTree es =
-                (ExpressionStatementTree) method.getBody().getStatements().get(0);
-
-        assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, es));
-        assertEquals("testPositionForSuperConstructorCalls",
-                80 - 24, pos.getEndPosition(cut, es));
-
-        MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
-
-        assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, mit));
-        assertEquals("testPositionForSuperConstructorCalls",
-                79 - 24, pos.getEndPosition(cut, mit));
-
-        assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
-        assertEquals("testPositionForSuperConstructorCalls",
-                77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
-
-    }
-
-    public void testPositionForEnumModifiers() throws IOException {
-
-        String code = "package test; public enum Test {A;}";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        ModifiersTree mt = clazz.getModifiers();
-
-        assertEquals("testPositionForEnumModifiers",
-                38 - 24, pos.getStartPosition(cut, mt));
-        assertEquals("testPositionForEnumModifiers",
-                44 - 24, pos.getEndPosition(cut, mt));
-    }
-
-    public void testNewClassWithEnclosing() throws IOException {
-
-
-        String code = "package test; class Test { " +
-                "class d {} private void method() { " +
-                "Object o = Test.this.new d(); } }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        ExpressionTree est =
-                ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
-
-        assertEquals("testNewClassWithEnclosing",
-                97 - 24, pos.getStartPosition(cut, est));
-        assertEquals("testNewClassWithEnclosing",
-                114 - 24, pos.getEndPosition(cut, est));
-    }
-
-    public void testPreferredPositionForBinaryOp() throws IOException {
-
-        String code = "package test; public class Test {" +
-                "private void test() {" +
-                "Object o = null; boolean b = o != null && o instanceof String;" +
-                "} private Test() {}}";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        MethodTree method = (MethodTree) clazz.getMembers().get(0);
-        VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
-        BinaryTree cond = (BinaryTree) condSt.getInitializer();
-
-        JCTree condJC = (JCTree) cond;
-
-        assertEquals("testNewClassWithEnclosing",
-                117 - 24, condJC.pos);
-    }
-
-    public void testPositionBrokenSource126732a() throws IOException {
-        String[] commands = new String[]{
-            "return Runnable()",
-            "do { } while (true)",
-            "throw UnsupportedOperationException()",
-            "assert true",
-            "1 + 1",};
-
-        for (String command : commands) {
-
-            String code = "package test;\n"
-                    + "public class Test {\n"
-                    + "    public static void test() {\n"
-                    + "        " + command + " {\n"
-                    + "                new Runnable() {\n"
-                    + "        };\n"
-                    + "    }\n"
-                    + "}";
-            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
-                    null, null, Arrays.asList(new MyFileObject(code)));
-            CompilationUnitTree cut = ct.parse().iterator().next();
-
-            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-            MethodTree method = (MethodTree) clazz.getMembers().get(0);
-            List<? extends StatementTree> statements =
-                    method.getBody().getStatements();
-
-            StatementTree ret = statements.get(0);
-            StatementTree block = statements.get(1);
-
-            Trees t = Trees.instance(ct);
-            int len = code.indexOf(command + " {") + (command + " ").length();
-            assertEquals(command, len,
-                    t.getSourcePositions().getEndPosition(cut, ret));
-            assertEquals(command, len,
-                    t.getSourcePositions().getStartPosition(cut, block));
-        }
-    }
-
-    public void testPositionBrokenSource126732b() throws IOException {
-        String[] commands = new String[]{
-            "break",
-            "break A",
-            "continue ",
-            "continue A",};
-
-        for (String command : commands) {
-
-            String code = "package test;\n"
-                    + "public class Test {\n"
-                    + "    public static void test() {\n"
-                    + "        while (true) {\n"
-                    + "            " + command + " {\n"
-                    + "                new Runnable() {\n"
-                    + "        };\n"
-                    + "        }\n"
-                    + "    }\n"
-                    + "}";
-
-            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
-                    null, null, Arrays.asList(new MyFileObject(code)));
-            CompilationUnitTree cut = ct.parse().iterator().next();
-
-            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-            MethodTree method = (MethodTree) clazz.getMembers().get(0);
-            List<? extends StatementTree> statements =
-                    ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
-
-            StatementTree ret = statements.get(0);
-            StatementTree block = statements.get(1);
-
-            Trees t = Trees.instance(ct);
-            int len = code.indexOf(command + " {") + (command + " ").length();
-            assertEquals(command, len,
-                    t.getSourcePositions().getEndPosition(cut, ret));
-            assertEquals(command, len,
-                    t.getSourcePositions().getStartPosition(cut, block));
-        }
-    }
-
-    public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
-
-        String code = "package test; class Test { " +
-                "private void method() { " +
-                "java.util.Set<String> s = null; for (a : s) {} } }";
-
-        final List<Diagnostic<? extends JavaFileObject>> errors =
-                new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
-                new DiagnosticListener<JavaFileObject>() {
-            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-                errors.add(diagnostic);
-            }
-        }, null, null, Arrays.asList(new MyFileObject(code)));
-
-        CompilationUnitTree cut = ct.parse().iterator().next();
-
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        StatementTree forStatement =
-                ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
-
-        assertEquals("testErrorRecoveryForEnhancedForLoop142381",
-                Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
-        assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
-    }
-
-    public void testPositionAnnotationNoPackage187551() throws IOException {
-
-        String code = "\n at interface Test {}";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        Trees t = Trees.instance(ct);
-
-        assertEquals("testPositionAnnotationNoPackage187551",
-                1, t.getSourcePositions().getStartPosition(cut, clazz));
-    }
-
-    public void testPositionsSane() throws IOException {
-        performPositionsSanityTest("package test; class Test { " +
-                "private void method() { " +
-                "java.util.List<? extends java.util.List<? extends String>> l; " +
-                "} }");
-        performPositionsSanityTest("package test; class Test { " +
-                "private void method() { " +
-                "java.util.List<? super java.util.List<? super String>> l; " +
-                "} }");
-        performPositionsSanityTest("package test; class Test { " +
-                "private void method() { " +
-                "java.util.List<? super java.util.List<?>> l; } }");
-    }
-
-    private void performPositionsSanityTest(String code) throws IOException {
-
-        final List<Diagnostic<? extends JavaFileObject>> errors =
-                new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
-                new DiagnosticListener<JavaFileObject>() {
-
-            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-                errors.add(diagnostic);
-            }
-        }, null, null, Arrays.asList(new MyFileObject(code)));
-
-        final CompilationUnitTree cut = ct.parse().iterator().next();
-        final Trees trees = Trees.instance(ct);
-
-        new TreeScanner<Void, Void>() {
-
-            private long parentStart = 0;
-            private long parentEnd = Integer.MAX_VALUE;
-
-            @Override
-            public Void scan(Tree node, Void p) {
-                if (node == null) {
-                    return null;
-                }
-
-                long start = trees.getSourcePositions().getStartPosition(cut, node);
-
-                if (start == (-1)) {
-                    return null; //synthetic tree
-                }
-                assertTrue(node.toString() + ":" + start + "/" + parentStart,
-                        parentStart <= start);
-
-                long prevParentStart = parentStart;
-
-                parentStart = start;
-
-                long end = trees.getSourcePositions().getEndPosition(cut, node);
-
-                assertTrue(node.toString() + ":" + end + "/" + parentEnd,
-                        end <= parentEnd);
-
-                long prevParentEnd = parentEnd;
-
-                parentEnd = end;
-
-                super.scan(node, p);
-
-                parentStart = prevParentStart;
-                parentEnd = prevParentEnd;
-
-                return null;
-            }
-
-            private void assertTrue(String message, boolean b) {
-                if (!b) fail(message);
-            }
-        }.scan(cut, null);
-    }
-
-    public void testCorrectWilcardPositions() throws IOException {
-        performWildcardPositionsTest("package test; import java.util.List; " +
-                "class Test { private void method() { List<? extends List<? extends String>> l; } }",
-
-                Arrays.asList("List<? extends List<? extends String>> l;",
-                "List<? extends List<? extends String>>",
-                "List",
-                "? extends List<? extends String>",
-                "List<? extends String>",
-                "List",
-                "? extends String",
-                "String"));
-        performWildcardPositionsTest("package test; import java.util.List; " +
-                "class Test { private void method() { List<? super List<? super String>> l; } }",
-
-                Arrays.asList("List<? super List<? super String>> l;",
-                "List<? super List<? super String>>",
-                "List",
-                "? super List<? super String>",
-                "List<? super String>",
-                "List",
-                "? super String",
-                "String"));
-        performWildcardPositionsTest("package test; import java.util.List; " +
-                "class Test { private void method() { List<? super List<?>> l; } }",
-
-                Arrays.asList("List<? super List<?>> l;",
-                "List<? super List<?>>",
-                "List",
-                "? super List<?>",
-                "List<?>",
-                "List",
-                "?"));
-        performWildcardPositionsTest("package test; import java.util.List; " +
-                "class Test { private void method() { " +
-                "List<? extends List<? extends List<? extends String>>> l; } }",
-
-                Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
-                "List<? extends List<? extends List<? extends String>>>",
-                "List",
-                "? extends List<? extends List<? extends String>>",
-                "List<? extends List<? extends String>>",
-                "List",
-                "? extends List<? extends String>",
-                "List<? extends String>",
-                "List",
-                "? extends String",
-                "String"));
-        performWildcardPositionsTest("package test; import java.util.List; " +
-                "class Test { private void method() { " +
-                "List<? extends List<? extends List<? extends String   >>> l; } }",
-                Arrays.asList("List<? extends List<? extends List<? extends String   >>> l;",
-                "List<? extends List<? extends List<? extends String   >>>",
-                "List",
-                "? extends List<? extends List<? extends String   >>",
-                "List<? extends List<? extends String   >>",
-                "List",
-                "? extends List<? extends String   >",
-                "List<? extends String   >",
-                "List",
-                "? extends String",
-                "String"));
-    }
-
-    public void performWildcardPositionsTest(final String code,
-            List<String> golden) throws IOException {
-
-        final List<Diagnostic<? extends JavaFileObject>> errors =
-                new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
-                new DiagnosticListener<JavaFileObject>() {
-                    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-                        errors.add(diagnostic);
-                    }
-                }, null, null, Arrays.asList(new MyFileObject(code)));
-
-        final CompilationUnitTree cut = ct.parse().iterator().next();
-        final List<String> content = new LinkedList<String>();
-        final Trees trees = Trees.instance(ct);
-
-        new TreeScanner<Void, Void>() {
-            @Override
-            public Void scan(Tree node, Void p) {
-                if (node == null) {
-                    return null;
-                }
-                long start = trees.getSourcePositions().getStartPosition(cut, node);
-
-                if (start == (-1)) {
-                    return null; //synthetic tree
-                }
-                long end = trees.getSourcePositions().getEndPosition(cut, node);
-                String s = code.substring((int) start, (int) end);
-                content.add(s);
-
-                return super.scan(node, p);
-            }
-        }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
-
-        assertEquals("performWildcardPositionsTest",golden.toString(),
-                content.toString());
-    }
-
-    public void testStartPositionForMethodWithoutModifiers() throws IOException {
-
-        String code = "package t; class Test { <T> void t() {} }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        MethodTree mt = (MethodTree) clazz.getMembers().get(0);
-        Trees t = Trees.instance(ct);
-        int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
-        int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
-
-        assertEquals("testStartPositionForMethodWithoutModifiers",
-                "<T> void t() {}", code.substring(start, end));
-    }
-
-    public void testStartPositionEnumConstantInit() throws IOException {
-
-        String code = "package t; enum Test { AAA; }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
-        VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
-        Trees t = Trees.instance(ct);
-        int start = (int) t.getSourcePositions().getStartPosition(cut,
-                enumAAA.getInitializer());
-
-        assertEquals("testStartPositionEnumConstantInit", -1, start);
-    }
-
-    public void testVariableInIfThen1() throws IOException {
-
-        String code = "package t; class Test { " +
-                "private static void t(String name) { " +
-                "if (name != null) String nn = name.trim(); } }";
-
-        DiagnosticCollector<JavaFileObject> coll =
-                new DiagnosticCollector<JavaFileObject>();
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
-                null, Arrays.asList(new MyFileObject(code)));
-
-        ct.parse();
-
-        List<String> codes = new LinkedList<String>();
-
-        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
-            codes.add(d.getCode());
-        }
-
-        assertEquals("testVariableInIfThen1",
-                Arrays.<String>asList("compiler.err.variable.not.allowed"),
-                codes);
-    }
-
-    public void testVariableInIfThen2() throws IOException {
-
-        String code = "package t; class Test { " +
-                "private static void t(String name) { " +
-                "if (name != null) class X {} } }";
-        DiagnosticCollector<JavaFileObject> coll =
-                new DiagnosticCollector<JavaFileObject>();
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
-                null, Arrays.asList(new MyFileObject(code)));
-
-        ct.parse();
-
-        List<String> codes = new LinkedList<String>();
-
-        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
-            codes.add(d.getCode());
-        }
-
-        assertEquals("testVariableInIfThen2",
-                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
-    }
-
-    public void testVariableInIfThen3() throws IOException {
-
-        String code = "package t; class Test { "+
-                "private static void t(String name) { " +
-                "if (name != null) abstract } }";
-        DiagnosticCollector<JavaFileObject> coll =
-                new DiagnosticCollector<JavaFileObject>();
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
-                null, Arrays.asList(new MyFileObject(code)));
-
-        ct.parse();
-
-        List<String> codes = new LinkedList<String>();
-
-        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
-            codes.add(d.getCode());
-        }
-
-        assertEquals("testVariableInIfThen3",
-                Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
-                codes);
-    }
-
-    //see javac bug #6882235, NB bug #98234:
-    public void testMissingExponent() throws IOException {
-
-        String code = "\nclass Test { { System.err.println(0e); } }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-
-        assertNotNull(ct.parse().iterator().next());
-    }
-
-    public void testTryResourcePos() throws IOException {
-
-        final String code = "package t; class Test { " +
-                "{ try (java.io.InputStream in = null) { } } }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-
-        new TreeScanner<Void, Void>() {
-            @Override
-            public Void visitVariable(VariableTree node, Void p) {
-                if ("in".contentEquals(node.getName())) {
-                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
-                    System.out.println(node.getName() + "," + var.pos);
-                    assertEquals("testTryResourcePos", "in = null) { } } }",
-                            code.substring(var.pos));
-                }
-                return super.visitVariable(node, p);
-            }
-        }.scan(cut, null);
-    }
-
-    public void testVarPos() throws IOException {
-
-        final String code = "package t; class Test { " +
-                "{ java.io.InputStream in = null; } }";
-
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitVariable(VariableTree node, Void p) {
-                if ("in".contentEquals(node.getName())) {
-                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
-                    assertEquals("testVarPos","in = null; } }",
-                            code.substring(var.pos));
-                }
-                return super.visitVariable(node, p);
-            }
-        }.scan(cut, null);
-    }
-
-    void testsNotWorking() throws IOException {
-
-        // Fails with nb-javac, needs further investigation
-        testPositionBrokenSource126732a();
-        testPositionBrokenSource126732b();
-
-        // Fails, these tests yet to be addressed
-        testVariableInIfThen1();
-        testVariableInIfThen2();
-        testPositionForEnumModifiers();
-        testStartPositionEnumConstantInit();
-    }
-    void testPositions() throws IOException {
-        testPositionsSane();
-        testCorrectWilcardPositions();
-        testPositionAnnotationNoPackage187551();
-        testPositionForSuperConstructorCalls();
-        testPreferredPositionForBinaryOp();
-        testStartPositionForMethodWithoutModifiers();
-        testVarPos();
-        testVariableInIfThen3();
-        testTryResourcePos();
-    }
-
-    public static void main(String... args) throws IOException {
-        JavacParserTest jpt = new JavacParserTest("JavacParserTest");
-        jpt.testPositions();
-        System.out.println("PASS");
-    }
-}
-
-abstract class TestCase {
-
-    void assertEquals(String message, int i, int pos) {
-        if (i != pos) {
-            fail(message);
-        }
-    }
-
-    void assertFalse(String message, boolean empty) {
-        throw new UnsupportedOperationException("Not yet implemented");
-    }
-
-    void assertEquals(String message, int i, long l) {
-        if (i != l) {
-            fail(message + ":" + i + ":" + l);
-        }
-    }
-
-    void assertEquals(String message, Object o1, Object o2) {
-        System.out.println(o1);
-        System.out.println(o2);
-        if (o1 != null && o2 != null && !o1.equals(o2)) {
-            fail(message);
-        }
-        if (o1 == null && o2 != null) {
-            fail(message);
-        }
-    }
-
-    void assertNotNull(Object o) {
-        if (o == null) {
-            fail();
-        }
-    }
-
-    void fail() {
-        fail("test failed");
-    }
-
-    void fail(String message) {
-        throw new RuntimeException(message);
-    }
-}
diff --git a/test/tools/javac/plugin/showtype/Identifiers.java b/test/tools/javac/plugin/showtype/Identifiers.java
new file mode 100644
index 0000000..9bcac67
--- /dev/null
+++ b/test/tools/javac/plugin/showtype/Identifiers.java
@@ -0,0 +1,7 @@
+/* /nodynamiccopyright */
+
+public class Identifiers {
+    public double E = Math.E;
+    public double PI = Math.PI;
+    public double PIE = PI + E;
+}
diff --git a/test/tools/javac/plugin/showtype/Identifiers.out b/test/tools/javac/plugin/showtype/Identifiers.out
new file mode 100644
index 0000000..d7d7d1b
--- /dev/null
+++ b/test/tools/javac/plugin/showtype/Identifiers.out
@@ -0,0 +1,21 @@
+Identifiers.java:3: Note: type is ()void
+public class Identifiers {
+       ^
+Identifiers.java:4: Note: type is double
+    public double E = Math.E;
+                          ^
+Identifiers.java:4: Note: type is java.lang.Math
+    public double E = Math.E;
+                      ^
+Identifiers.java:5: Note: type is double
+    public double PI = Math.PI;
+                           ^
+Identifiers.java:5: Note: type is java.lang.Math
+    public double PI = Math.PI;
+                       ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                        ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                             ^
diff --git a/test/tools/javac/plugin/showtype/Identifiers_PI.out b/test/tools/javac/plugin/showtype/Identifiers_PI.out
new file mode 100644
index 0000000..91b3b43
--- /dev/null
+++ b/test/tools/javac/plugin/showtype/Identifiers_PI.out
@@ -0,0 +1,6 @@
+Identifiers.java:5: Note: type is double
+    public double PI = Math.PI;
+                           ^
+Identifiers.java:6: Note: type is double
+    public double PIE = PI + E;
+                        ^
diff --git a/test/tools/javac/plugin/showtype/ShowTypePlugin.java b/test/tools/javac/plugin/showtype/ShowTypePlugin.java
new file mode 100644
index 0000000..4995a3d
--- /dev/null
+++ b/test/tools/javac/plugin/showtype/ShowTypePlugin.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ *
+ * 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 com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.MemberSelectTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Plugin;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import java.util.regex.Pattern;
+import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic.Kind;
+
+public class ShowTypePlugin implements Plugin {
+
+    public String getName() {
+        return "showtype";
+    }
+
+    public void init(JavacTask task, String... args) {
+        Pattern pattern = null;
+        if (args.length == 1)
+            pattern = Pattern.compile(args[0]);
+        task.addTaskListener(new PostAnalyzeTaskListener(task, pattern));
+    }
+
+    private static class PostAnalyzeTaskListener implements TaskListener {
+        private final ShowTypeTreeVisitor visitor;
+
+        PostAnalyzeTaskListener(JavacTask task, Pattern pattern) {
+            visitor = new ShowTypeTreeVisitor(task, pattern);
+        }
+
+        @Override
+        public void started(TaskEvent taskEvent) { }
+
+        @Override
+        public void finished(TaskEvent taskEvent) {
+            if (taskEvent.getKind().equals(TaskEvent.Kind.ANALYZE)) {
+                CompilationUnitTree compilationUnit = taskEvent.getCompilationUnit();
+                visitor.scan(compilationUnit, null);
+            }
+        }
+    }
+
+    private static class ShowTypeTreeVisitor extends TreePathScanner<Void, Void> {
+        private final Trees trees;
+        private final Pattern pattern;
+        private CompilationUnitTree currCompUnit;
+
+        ShowTypeTreeVisitor(JavacTask task, Pattern pattern) {
+            trees = Trees.instance(task);
+            this.pattern = pattern;
+        }
+
+        @Override
+        public Void visitCompilationUnit(CompilationUnitTree tree, Void ignore) {
+            currCompUnit = tree;
+            return super.visitCompilationUnit(tree, ignore);
+        }
+
+        @Override
+        public Void visitIdentifier(IdentifierTree tree, Void ignore) {
+            show(tree, tree.getName());
+            return super.visitIdentifier(tree, ignore);
+        }
+
+        @Override
+        public Void visitMemberSelect(MemberSelectTree tree, Void ignore) {
+            show(tree, tree.getIdentifier());
+            return super.visitMemberSelect(tree, ignore);
+        }
+
+        void show(Tree tree, CharSequence name) {
+            if (pattern == null || pattern.matcher(name).matches()) {
+                TypeMirror type = trees.getTypeMirror(getCurrentPath());
+                trees.printMessage(Kind.NOTE, "type is " + type, tree, currCompUnit);
+            }
+        }
+    }
+
+}
diff --git a/test/tools/javac/plugin/showtype/Test.java b/test/tools/javac/plugin/showtype/Test.java
new file mode 100644
index 0000000..b1a3b59
--- /dev/null
+++ b/test/tools/javac/plugin/showtype/Test.java
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+/**
+ *  @test
+ *  @bug 8001098 8004961 8004082
+ *  @summary Provide a simple light-weight "plug-in" mechanism for javac
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    final File testSrc;
+    final File pluginSrc;
+    final File pluginClasses ;
+    final File pluginJar;
+    final List<String> ref1;
+    final List<String> ref2;
+    final JavaCompiler compiler;
+    final StandardJavaFileManager fm;
+
+    Test() throws Exception {
+        testSrc = new File(System.getProperty("test.src"));
+        pluginSrc = new File(testSrc, "ShowTypePlugin.java");
+        pluginClasses = new File("plugin");
+        pluginJar = new File("plugin.jar");
+        ref1 = readFile(testSrc, "Identifiers.out");
+        ref2 = readFile(testSrc, "Identifiers_PI.out");
+        compiler = ToolProvider.getSystemJavaCompiler();
+        fm = compiler.getStandardFileManager(null, null, null);
+    }
+
+    void run() throws Exception {
+        // compile the plugin explicitly, to a non-standard directory
+        // so that we don't find it on the wrong path by accident
+        pluginClasses.mkdirs();
+        compile("-d", pluginClasses.getPath(), pluginSrc.getPath());
+        writeFile(new File(pluginClasses, "META-INF/services/com.sun.source.util.Plugin"),
+                "ShowTypePlugin\n");
+        jar("cf", pluginJar.getPath(), "-C", pluginClasses.getPath(), ".");
+
+        testCommandLine("-Xplugin:showtype", ref1);
+        testCommandLine("-Xplugin:showtype PI", ref2);
+        testAPI("-Xplugin:showtype", ref1);
+        testAPI("-Xplugin:showtype PI", ref2);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void testAPI(String opt, List<String> ref) throws Exception {
+        File identifiers = new File(testSrc, "Identifiers.java");
+        fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH, Arrays.asList(pluginJar));
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+        List<String> options = Arrays.asList(opt);
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(identifiers);
+
+        System.err.println("test api: " + options + " " + files);
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        boolean ok = compiler.getTask(pw, fm, null, options, null, files).call();
+        String out = sw.toString();
+        System.err.println(out);
+        if (!ok)
+            error("testCommandLine: compilation failed");
+        checkOutput(out, ref);
+    }
+
+    void testCommandLine(String opt, List<String> ref) {
+        File identifiers = new File(testSrc, "Identifiers.java");
+        String[] args = {
+            "-d", ".",
+            "-processorpath", pluginJar.getPath(),
+            opt,
+            identifiers.getPath() };
+
+        System.err.println("test command line: " + Arrays.asList(args));
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        String out = sw.toString();
+        System.err.println(out);
+        if (rc != 0)
+            error("testCommandLine: compilation failed");
+        checkOutput(out, ref);
+    }
+
+    private void checkOutput(String out, List<String> ref) {
+        List<String> lines = Arrays.asList(out
+                .replaceAll(".*?([A-Za-z.]+:[0-9]+: .*)", "$1") // remove file directory
+                .split("[\r\n]+"));                             // allow for newline formats
+        if (!lines.equals(ref)) {
+            error("unexpected output");
+        }
+    }
+
+    private void compile(String... args) throws Exception {
+        System.err.println("compile: " + Arrays.asList(args));
+        int rc = com.sun.tools.javac.Main.compile(args);
+        if (rc != 0)
+            throw new Exception("compiled failed, rc=" + rc);
+    }
+
+    private void jar(String... args) throws Exception {
+        System.err.println("jar: " + Arrays.asList(args));
+        boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar").run(args);
+        if (!ok)
+            throw new Exception("jar failed");
+    }
+
+    private List<String> readFile(File dir, String name) throws IOException {
+        return Files.readAllLines(new File(dir, name).toPath(), Charset.defaultCharset());
+    }
+
+    private void writeFile(File f, String body) throws IOException {
+        f.getParentFile().mkdirs();
+        try (FileWriter out = new FileWriter(f)) {
+            out.write(body);
+        }
+    }
+
+    private void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javac/policy/test3/Test.java b/test/tools/javac/policy/test3/Test.java
index d26ef8e..fafc872 100644
--- a/test/tools/javac/policy/test3/Test.java
+++ b/test/tools/javac/policy/test3/Test.java
@@ -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
@@ -123,47 +123,3 @@ public class Test {
 
     int errors;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-// These tests test the ability of the compiler to continue in the face of
-// errors, accordining to the shouldStopPolicy
-
-/* @ test /nodynamiccopyright/
- * @bug 6813059
- * @summary
- * @compile/fail/ref=flow.out       -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=FLOW       Test.java
-
- * @compile/fail/ref=default.out    -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy                                Test.java
- * @compile/fail/ref=enter.out      -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ENTER      Test.java
- * @compile/fail/ref=attr.out       -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=ATTR       Test.java
- * @compile/fail/ref=transtypes.out -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=TRANSTYPES Test.java
- * @compile/fail/ref=lower.out      -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=LOWER      Test.java
- * @compile/fail/ref=generate.out   -XDrawDiagnostics -XDcompilePolicy=byfile -XDverboseCompilePolicy -XDshouldStopPolicy=GENERATE   Test.java
- */
-
-/*
-class Test {
-    void m1() {
-        System.err.println("hello");
-        0 // syntax error
-        System.err.println("world");
-    }
-
-    void m2() {
-    }
-}
-
-class Test2 {
-}
-*/
-
diff --git a/test/tools/javac/positions/T6264029.out b/test/tools/javac/positions/T6264029.out
index a3e79ee..8ff58c6 100644
--- a/test/tools/javac/positions/T6264029.out
+++ b/test/tools/javac/positions/T6264029.out
@@ -1,3 +1,2 @@
-T6264029.java:15:19: compiler.warn.unchecked.call.mbr.of.raw.type: T6264029A(K), T6264029A
 T6264029.java:15:41: compiler.warn.unchecked.call.mbr.of.raw.type: T6264029A(K), T6264029A
-2 warnings
+1 warning
diff --git a/test/tools/javac/processing/6348499/T6348499.java b/test/tools/javac/processing/6348499/T6348499.java
index 25e2a07..dadcef2 100644
--- a/test/tools/javac/processing/6348499/T6348499.java
+++ b/test/tools/javac/processing/6348499/T6348499.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6441871
  * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor A
  * @run main T6348499
  */
@@ -47,6 +47,7 @@ public class T6348499 {
     public static void main(String... args) {
         String testSrc = System.getProperty("test.src", ".");
         String testClasses = System.getProperty("test.classes");
+        String testClassPath = System.getProperty("test.class.path", testClasses);
         String A_java = new File(testSrc, "A.java").getPath();
         JavacTool tool = JavacTool.create();
         MyDiagListener dl = new MyDiagListener();
@@ -55,7 +56,7 @@ public class T6348499 {
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
         Iterable<String> opts = Arrays.asList("-proc:only",
                                               "-processor", "A",
-                                              "-processorpath", testClasses);
+                                              "-processorpath", testClassPath);
         StringWriter out = new StringWriter();
         JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
         task.call();
diff --git a/test/tools/javac/processing/6359313/T6359313.java b/test/tools/javac/processing/6359313/T6359313.java
index 719ea12..0cbc48f 100644
--- a/test/tools/javac/processing/6359313/T6359313.java
+++ b/test/tools/javac/processing/6359313/T6359313.java
@@ -26,7 +26,7 @@
  * @bug     6359313
  * @summary error compiling annotated package
  * @author  Peter von der Ah\u00e9
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile T6359313.java
  * @compile -processor T6359313 package-info.java Foo.java
diff --git a/test/tools/javac/processing/6365040/T6365040.java b/test/tools/javac/processing/6365040/T6365040.java
index 0b1e0dc..1155841 100644
--- a/test/tools/javac/processing/6365040/T6365040.java
+++ b/test/tools/javac/processing/6365040/T6365040.java
@@ -26,7 +26,7 @@
  * @bug 6365040 6358129
  * @summary Test -processor foo,bar,baz
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile ProcFoo.java
  * @compile ProcBar.java
diff --git a/test/tools/javac/processing/6413690/T6413690.java b/test/tools/javac/processing/6413690/T6413690.java
index a4b2b3f..6126afb 100644
--- a/test/tools/javac/processing/6413690/T6413690.java
+++ b/test/tools/javac/processing/6413690/T6413690.java
@@ -26,7 +26,7 @@
  * @bug     6413690 6380018
  * @summary JavacProcessingEnvironment does not enter trees from preceding rounds
  * @author  Peter von der Ah\u00e9
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile T6413690.java
  * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java
diff --git a/test/tools/javac/processing/6414633/T6414633.java b/test/tools/javac/processing/6414633/T6414633.java
index 0ae3951..e6ee786 100644
--- a/test/tools/javac/processing/6414633/T6414633.java
+++ b/test/tools/javac/processing/6414633/T6414633.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6414633 6440109
  * @summary Only the first processor message at a source location is reported
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build    JavacTestingAbstractProcessor A T6414633
  * @run main T6414633
  */
@@ -43,20 +43,20 @@ public class T6414633 {
     public static void main(String... args) {
         String testSrc = System.getProperty("test.src", ".");
         String testClasses = System.getProperty("test.classes", ".");
+        String testClassPath = System.getProperty("test.class.path", testClasses);
 
         JavacTool tool = JavacTool.create();
         MyDiagListener dl = new MyDiagListener();
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
         try {
-            fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(testClasses)));
+            fm.setLocation(StandardLocation.CLASS_PATH, pathToFiles(testClassPath));
         } catch (IOException e) {
             throw new AssertionError(e);
         }
         Iterable<? extends JavaFileObject> files =
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
         String[] opts = { "-proc:only",
-                          "-processor", A.class.getName(),
-                          "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" };
+                          "-processor", A.class.getName() };
         JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
         task.call();
 
@@ -65,6 +65,15 @@ public class T6414633 {
             throw new AssertionError(dl.diags + " diagnostics reported");
     }
 
+    private static List<File> pathToFiles(String path) {
+        List<File> list = new ArrayList<File>();
+        for (String s: path.split(File.pathSeparator)) {
+            if (!s.isEmpty())
+                list.add(new File(s));
+        }
+        return list;
+    }
+
     private static class MyDiagListener implements DiagnosticListener<JavaFileObject>
     {
         public void report(Diagnostic d) {
diff --git a/test/tools/javac/processing/6430209/T6430209.java b/test/tools/javac/processing/6430209/T6430209.java
index 0f65f86..9ecc01d 100644
--- a/test/tools/javac/processing/6430209/T6430209.java
+++ b/test/tools/javac/processing/6430209/T6430209.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6441871
  * @summary spurious compiler error elicited by packageElement.getEnclosedElements()
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor b6341534
  * @run main T6430209
  */
diff --git a/test/tools/javac/processing/6499119/ClassProcessor.java b/test/tools/javac/processing/6499119/ClassProcessor.java
index b2b7203..1d53215 100644
--- a/test/tools/javac/processing/6499119/ClassProcessor.java
+++ b/test/tools/javac/processing/6499119/ClassProcessor.java
@@ -32,7 +32,7 @@ import javax.tools.Diagnostic.Kind;
  * @test
  * @bug 6499119
  * @summary Created package-info class file modeled improperly
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile ClassProcessor.java package-info.java
  * @compile/process -cp . -processor ClassProcessor -Akind=java  java.lang.Object
diff --git a/test/tools/javac/processing/6511613/clss41701.java b/test/tools/javac/processing/6511613/clss41701.java
index 670ae5e..0af3e06 100644
--- a/test/tools/javac/processing/6511613/clss41701.java
+++ b/test/tools/javac/processing/6511613/clss41701.java
@@ -26,7 +26,7 @@
  * @bug 6511613
  * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified
  *
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor DummyProcessor
  * @compile/fail clss41701.java
  * @compile/fail -processor DummyProcessor clss41701.java
diff --git a/test/tools/javac/processing/6512707/T6512707.java b/test/tools/javac/processing/6512707/T6512707.java
index 26c72f9..afe813b 100644
--- a/test/tools/javac/processing/6512707/T6512707.java
+++ b/test/tools/javac/processing/6512707/T6512707.java
@@ -26,7 +26,7 @@
  * @bug 6512707
  * @summary "incompatible types" after (unrelated) annotation processing
  * @author  Peter Runge
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile T6512707.java
  * @compile -processor T6512707 TestAnnotation.java
diff --git a/test/tools/javac/processing/6634138/T6634138.java b/test/tools/javac/processing/6634138/T6634138.java
index 54409e5..c42c7b0 100644
--- a/test/tools/javac/processing/6634138/T6634138.java
+++ b/test/tools/javac/processing/6634138/T6634138.java
@@ -26,7 +26,7 @@
  * @bug 6634138
  * @author  Joseph D. Darcy
  * @summary Verify source files output after processing is over are compiled
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile T6634138.java
  * @compile -processor T6634138 Dummy.java
diff --git a/test/tools/javac/processing/6994946/SemanticErrorTest.2.out b/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
index 3763278..5e68e1d 100644
--- a/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
+++ b/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
@@ -1,4 +1,3 @@
 SemanticErrorTest.java:11:46: compiler.err.repeated.interface
 - compiler.err.proc.messager: Deliberate Error
-SemanticErrorTest.java:11:46: compiler.err.repeated.interface
-2 errors
+2 errors
\ No newline at end of file
diff --git a/test/tools/javac/processing/6994946/SemanticErrorTest.java b/test/tools/javac/processing/6994946/SemanticErrorTest.java
index 43a0521..d720175 100644
--- a/test/tools/javac/processing/6994946/SemanticErrorTest.java
+++ b/test/tools/javac/processing/6994946/SemanticErrorTest.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 6994946
  * @summary option to specify only syntax errors as unrecoverable
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestProcessor
  * @compile/fail/ref=SemanticErrorTest.1.out -XDrawDiagnostics                                  -processor TestProcessor SemanticErrorTest.java
  * @compile/fail/ref=SemanticErrorTest.2.out -XDrawDiagnostics -XDonlySyntaxErrorsUnrecoverable -processor TestProcessor SemanticErrorTest.java
diff --git a/test/tools/javac/processing/6994946/SyntaxErrorTest.java b/test/tools/javac/processing/6994946/SyntaxErrorTest.java
index 44d67b6..be3ad3c 100644
--- a/test/tools/javac/processing/6994946/SyntaxErrorTest.java
+++ b/test/tools/javac/processing/6994946/SyntaxErrorTest.java
@@ -2,7 +2,7 @@
  * @test /nodynamiccopyright/
  * @bug 6994946
  * @summary option to specify only syntax errors as unrecoverable
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestProcessor
  * @compile/fail/ref=SyntaxErrorTest.out -XDrawDiagnostics                                  -processor TestProcessor SyntaxErrorTest.java
  * @compile/fail/ref=SyntaxErrorTest.out -XDrawDiagnostics -XDonlySyntaxErrorsUnrecoverable -processor TestProcessor SyntaxErrorTest.java
diff --git a/test/tools/javac/processing/T6920317.java b/test/tools/javac/processing/T6920317.java
index 1f00509..81e3914 100644
--- a/test/tools/javac/processing/T6920317.java
+++ b/test/tools/javac/processing/T6920317.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6920317
  * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail
- * @library ../lib
+ * @library /tools/javac/lib
  */
 
 import java.io.*;
@@ -156,7 +156,9 @@ public class T6920317 {
         String expect = null;
 
         opts.add("-processorpath");
-        opts.add(System.getProperty("test.classes"));
+        String testClasses = System.getProperty("test.classes");
+        String testClassPath = System.getProperty("test.class.path", testClasses);
+        opts.add(testClassPath);
         opts.add("-processor");
         opts.add(Processor.class.getName());
         opts.add("-proc:only");
diff --git a/test/tools/javac/processing/T7196462.java b/test/tools/javac/processing/T7196462.java
new file mode 100644
index 0000000..9bbee3f
--- /dev/null
+++ b/test/tools/javac/processing/T7196462.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ *
+ * 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 7196462
+ * @summary JavacProcessingEnvironment should tolerate BasicJavacTask
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor T7196462
+ * @compile/process -processor T7196462 T7196462.java
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import com.sun.source.util.*;
+
+public class T7196462 extends JavacTestingAbstractProcessor {
+    public boolean process(Set<? extends TypeElement> annos,RoundEnvironment rEnv) {
+        JavacTask t = JavacTask.instance(processingEnv);
+        System.err.println(t);
+        return true;
+    }
+}
diff --git a/test/tools/javac/processing/TestWarnErrorCount.java b/test/tools/javac/processing/TestWarnErrorCount.java
index 1292e31..ceadf5f 100644
--- a/test/tools/javac/processing/TestWarnErrorCount.java
+++ b/test/tools/javac/processing/TestWarnErrorCount.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @test
  * @bug 7022337
  * @summary repeated warnings about bootclasspath not set
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestWarnErrorCount
  * @run main TestWarnErrorCount
  */
@@ -327,7 +327,7 @@ public class TestWarnErrorCount extends JavacTestingAbstractProcessor {
             Writer out = fo.openWriter();
             try {
                 out.write("class " + name + " {\n"
-                        + (warn ? "    int i = (int) 0;\n" : "")
+                        + (warn ? "    void m() throws Exception { try (AutoCloseable ac = null) { } }" : "")
                         + (error ? "   ERROR\n" : "")
                         + "}\n");
             } finally {
diff --git a/test/tools/javac/processing/environment/TestSourceVersion.java b/test/tools/javac/processing/environment/TestSourceVersion.java
index 28118bb..fed84dc 100644
--- a/test/tools/javac/processing/environment/TestSourceVersion.java
+++ b/test/tools/javac/processing/environment/TestSourceVersion.java
@@ -26,7 +26,7 @@
  * @bug 6402506
  * @summary Test that getSourceVersion works properly
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestSourceVersion.java
  * @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java
diff --git a/test/tools/javac/processing/environment/round/TestContext.java b/test/tools/javac/processing/environment/round/TestContext.java
index deed692..5ba9116 100644
--- a/test/tools/javac/processing/environment/round/TestContext.java
+++ b/test/tools/javac/processing/environment/round/TestContext.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6988836
  * @summary A new JavacElements is created for each round of annotation processing
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestContext
  * @compile/process -processor TestContext -XprintRounds TestContext
  */
diff --git a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
index 0bf241b..6ba6ff6 100644
--- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
+++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java
@@ -26,15 +26,17 @@
  * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854
  * @summary Tests that getElementsAnnotatedWith works properly.
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestElementsAnnotatedWith.java
  * @compile InheritedAnnotation.java
+ * @compile TpAnno.java
  * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
  * @compile -processor TestElementsAnnotatedWith -proc:only BuriedAnnotations.java
  * @compile -processor TestElementsAnnotatedWith -proc:only Part1.java Part2.java
  * @compile -processor TestElementsAnnotatedWith -proc:only C2.java
  * @compile -processor TestElementsAnnotatedWith -proc:only Foo.java
+ * @compile -processor TestElementsAnnotatedWith -proc:only TypeParameterAnnotations.java
  * @compile Foo.java
  * @compile/process -processor TestElementsAnnotatedWith -proc:only Foo
  */
diff --git a/test/tools/javac/processing/environment/round/TpAnno.java b/test/tools/javac/processing/environment/round/TpAnno.java
new file mode 100644
index 0000000..c8cf52c
--- /dev/null
+++ b/test/tools/javac/processing/environment/round/TpAnno.java
@@ -0,0 +1,29 @@
+/*
+ * 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.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+ at Retention(RUNTIME)
+ at Target(ElementType.TYPE_PARAMETER)
+public @interface TpAnno {}
diff --git a/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java b/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java
new file mode 100644
index 0000000..0b3ef05
--- /dev/null
+++ b/test/tools/javac/processing/environment/round/TypeParameterAnnotations.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+/**
+ * Class to hold annotations for ElementsAnnotatedWithTest.
+ */
+
+ at AnnotatedElementInfo(annotationName="TpAnno",
+                      expectedSize=4,
+                      names={"T", "A", "B", "C"})
+public class TypeParameterAnnotations<@TpAnno T>  {
+    private <@TpAnno A> TypeParameterAnnotations(A a) {;}
+
+    public <@TpAnno B> void foo(B b) {return;}
+
+    public static <@TpAnno C> void bar(C b) {return;}
+}
diff --git a/test/tools/javac/processing/errors/TestErrorCount.java b/test/tools/javac/processing/errors/TestErrorCount.java
index 1f40ae8..d8c7abc 100644
--- a/test/tools/javac/processing/errors/TestErrorCount.java
+++ b/test/tools/javac/processing/errors/TestErrorCount.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6988079
  * @summary Errors reported via Messager.printMessage(ERROR,"error message") are not tallied correctly
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestErrorCount
  * @compile/fail/ref=TestErrorCount.out -XDrawDiagnostics -processor TestErrorCount TestErrorCount.java
  */
diff --git a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java
index cd42f6b..734844e 100644
--- a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java
+++ b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java
@@ -26,7 +26,7 @@
  * @bug 6403459
  * @summary Test that generating programs with syntax errors is a fatal condition
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile TestReturnCode.java
  * @compile TestFatalityOfParseErrors.java
diff --git a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java
index 53c9db3..d14ebc7 100644
--- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java
+++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java
@@ -26,7 +26,7 @@
  * @bug 6406212
  * @summary Test that annotation processor options with illegal syntax are rejected
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor CompileFail
  * @compile TestOptionSyntaxErrors.java
  * @run main CompileFail CMDERR -A TestOptionSyntaxErrors.java
diff --git a/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java
index bc094f3..fd81a31 100644
--- a/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java
+++ b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6988407
  * @summary javac crashes running processor on errant code; it used to print error message
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestParseErrors
  * @compile/fail/ref=TestParseErrors.out -XDrawDiagnostics -proc:only -processor TestParseErrors ParseErrors.java
  */
diff --git a/test/tools/javac/processing/errors/TestReturnCode.java b/test/tools/javac/processing/errors/TestReturnCode.java
index bcc84b2..bc8804b 100644
--- a/test/tools/javac/processing/errors/TestReturnCode.java
+++ b/test/tools/javac/processing/errors/TestReturnCode.java
@@ -26,7 +26,7 @@
  * @bug 6403468
  * @summary Test that an erroneous return code results from raising an error.
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor CompileFail
  * @compile TestReturnCode.java
  *
diff --git a/test/tools/javac/processing/filer/TestFilerConstraints.java b/test/tools/javac/processing/filer/TestFilerConstraints.java
index 8509fb2..0f467b5 100644
--- a/test/tools/javac/processing/filer/TestFilerConstraints.java
+++ b/test/tools/javac/processing/filer/TestFilerConstraints.java
@@ -26,7 +26,7 @@
  * @bug 6380018 6453386 6457283
  * @summary Test that the constraints guaranteed by the Filer and maintained
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build TestFilerConstraints
  * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java
  */
diff --git a/test/tools/javac/processing/filer/TestGetResource.java b/test/tools/javac/processing/filer/TestGetResource.java
index 5d56412..d7bbfb9 100644
--- a/test/tools/javac/processing/filer/TestGetResource.java
+++ b/test/tools/javac/processing/filer/TestGetResource.java
@@ -26,7 +26,7 @@
  * @bug 6380018 6449798
  * @summary Test Filer.getResource
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build  JavacTestingAbstractProcessor TestGetResource
  * @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java
  * @compile -processor TestGetResource -proc:only -Aphase=read  TestGetResource.java
diff --git a/test/tools/javac/processing/filer/TestGetResource2.java b/test/tools/javac/processing/filer/TestGetResource2.java
index 6ce067d..f773e9f 100644
--- a/test/tools/javac/processing/filer/TestGetResource2.java
+++ b/test/tools/javac/processing/filer/TestGetResource2.java
@@ -24,7 +24,7 @@
 /* @test
  * @bug 6929404
  * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
- * @library ../../lib
+ * @library /tools/javac/lib
  */
 
 import java.io.*;
diff --git a/test/tools/javac/processing/filer/TestInvalidRelativeNames.java b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java
index 4a0efd5..cc788bf 100644
--- a/test/tools/javac/processing/filer/TestInvalidRelativeNames.java
+++ b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6502392
  * @summary Invalid relative names for Filer.createResource and Filer.getResource
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestInvalidRelativeNames.java
  * @compile/process -processor TestInvalidRelativeNames java.lang.Object
diff --git a/test/tools/javac/processing/filer/TestLastRound.java b/test/tools/javac/processing/filer/TestLastRound.java
index 57c76af..adcba03 100644
--- a/test/tools/javac/processing/filer/TestLastRound.java
+++ b/test/tools/javac/processing/filer/TestLastRound.java
@@ -24,7 +24,7 @@
 /*
  * @test 6966604
  * @summary JavacFiler not correctly notified of lastRound
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestLastRound.java
  * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java
diff --git a/test/tools/javac/processing/filer/TestPackageInfo.java b/test/tools/javac/processing/filer/TestPackageInfo.java
index 651f9b7..3fef7ea 100644
--- a/test/tools/javac/processing/filer/TestPackageInfo.java
+++ b/test/tools/javac/processing/filer/TestPackageInfo.java
@@ -26,7 +26,7 @@
  * @bug 6380018 6392177 6993311
  * @summary Test the ability to create and process package-info.java files
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestPackageInfo.java
  * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java
diff --git a/test/tools/javac/processing/filer/TestValidRelativeNames.java b/test/tools/javac/processing/filer/TestValidRelativeNames.java
index 67d44e2..2ffcd83 100644
--- a/test/tools/javac/processing/filer/TestValidRelativeNames.java
+++ b/test/tools/javac/processing/filer/TestValidRelativeNames.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6999891
  * @summary Test valid relative names for Filer.createResource and Filer.getResource
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile TestValidRelativeNames.java
  * @compile/process -processor TestValidRelativeNames -Amode=create java.lang.Object
diff --git a/test/tools/javac/processing/loader/testClose/TestClose.java b/test/tools/javac/processing/loader/testClose/TestClose.java
new file mode 100644
index 0000000..4128a07
--- /dev/null
+++ b/test/tools/javac/processing/loader/testClose/TestClose.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7092965
+ * @summary javac should not close processorClassLoader before end of compilation
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.ClientCodeWrapper.Trusted;
+import com.sun.tools.javac.api.BasicJavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/*
+ * The test compiles an annotation processor and a helper class into a
+ * custom classes directory.
+ *
+ * It then uses them while compiling a dummy file, with the custom classes
+ * directory on the processor path, thus guaranteeing that references to
+ * these class are satisfied by the processor class loader.
+ *
+ * The annotation processor uses the javac TaskListener to run code
+ * after annotation processing has completed, to verify that the classloader
+ * is not closed until the end of the compilation.
+ */
+
+ at Trusted // avoids use of ClientCodeWrapper
+public class TestClose implements TaskListener {
+    public static final String annoProc =
+        "import java.util.*;\n" +
+        "import javax.annotation.processing.*;\n" +
+        "import javax.lang.model.*;\n" +
+        "import javax.lang.model.element.*;\n" +
+        "import com.sun.source.util.*;\n" +
+        "import com.sun.tools.javac.processing.*;\n" +
+        "import com.sun.tools.javac.util.*;\n" +
+        "@SupportedAnnotationTypes(\"*\")\n" +
+        "public class AnnoProc extends AbstractProcessor {\n" +
+        "    @Override\n" +
+        "    public SourceVersion getSupportedSourceVersion() {\n" +
+        "        return SourceVersion.latest();\n" +
+        "    }\n" +
+        "    @Override\n" +
+        "    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {\n" +
+        "        System.out.println(\"in AnnoProc.process\");\n" +
+        "        final ClassLoader cl = getClass().getClassLoader();\n" +
+        "        if (roundEnv.processingOver()) {\n" +
+        "            TestClose.add(processingEnv, new Runnable() {\n" +
+        "                public void run() {\n" +
+        "                    System.out.println(getClass().getName() + \": run()\");\n" +
+        "                    try {\n" +
+        "                        cl.loadClass(\"Callback\")\n" +
+        "                            .asSubclass(Runnable.class)\n" +
+        "                            .newInstance()\n" +
+        "                            .run();\n" +
+        "                    } catch (ReflectiveOperationException e) {\n" +
+        "                        throw new Error(e);\n" +
+        "                    }\n" +
+        "                }\n" +
+        "            });\n" +
+        "        }\n" +
+        "        return true;\n" +
+        "    }\n" +
+        "}\n";
+
+    public static final String callback =
+        "public class Callback implements Runnable {\n" +
+        "    public void run() {\n" +
+        "        System.out.println(getClass().getName() + \": run()\");\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String... args) throws Exception {
+        new TestClose().run();
+    }
+
+    void run() throws IOException {
+        JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+
+        File classes = new File("classes");
+        classes.mkdirs();
+        File extraClasses = new File("extraClasses");
+        extraClasses.mkdirs();
+
+        System.out.println("compiling classes to extraClasses");
+        {   // setup class in extraClasses
+            fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                    Collections.singleton(extraClasses));
+            List<? extends JavaFileObject> files = Arrays.asList(
+                    new MemFile("AnnoProc.java", annoProc),
+                    new MemFile("Callback.java", callback));
+            JavacTask task = tool.getTask(null, fm, null, null, null, files);
+            check(task.call());
+        }
+
+        System.out.println("compiling dummy to classes with anno processor");
+        {   // use that class in a TaskListener after processing has completed
+            PrintStream prev = System.out;
+            String out;
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            try (PrintStream ps = new PrintStream(baos)) {
+                System.setOut(ps);
+                File testClasses = new File(System.getProperty("test.classes"));
+                fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                        Collections.singleton(classes));
+                fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+                        Arrays.asList(extraClasses, testClasses));
+                List<? extends JavaFileObject> files = Arrays.asList(
+                        new MemFile("my://dummy", "class Dummy { }"));
+                List<String> options = Arrays.asList("-processor", "AnnoProc");
+                JavacTask task = tool.getTask(null, fm, null, options, null, files);
+                task.setTaskListener(this);
+                check(task.call());
+            } finally {
+                System.setOut(prev);
+                out = baos.toString();
+                if (!out.isEmpty())
+                    System.out.println(out);
+            }
+            check(out.contains("AnnoProc$1: run()"));
+            check(out.contains("Callback: run()"));
+        }
+    }
+
+    @Override
+    public void started(TaskEvent e) {
+        System.out.println("Started: " + e);
+    }
+
+    @Override
+    public void finished(TaskEvent e) {
+        System.out.println("Finished: " + e);
+        if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+            for (Runnable r: runnables) {
+                System.out.println("running " + r);
+                r.run();
+            }
+        }
+    }
+
+    void check(boolean b) {
+        if (!b)
+            throw new AssertionError();
+    }
+
+    public static void add(ProcessingEnvironment env, Runnable r) {
+        try {
+            JavacTask task = JavacTask.instance(env);
+            TaskListener l = ((BasicJavacTask) task).getTaskListeners().iterator().next();
+            // The TaskListener is an instanceof TestClose, but when using the
+            // default class loaders. the taskListener uses a different
+            // instance of Class<TestClose> than the anno processor.
+            // If you try to evaluate
+            //      TestClose tc = (TestClose) (l).
+            // you get the following somewhat confusing error:
+            //   java.lang.ClassCastException: TestClose cannot be cast to TestClose
+            // The workaround is to access the fields of TestClose with reflection.
+            Field f = l.getClass().getField("runnables");
+            @SuppressWarnings("unchecked")
+            List<Runnable> runnables = (List<Runnable>) f.get(l);
+            runnables.add(r);
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
+
+    public List<Runnable> runnables = new ArrayList<>();
+
+    class MemFile extends SimpleJavaFileObject {
+        public final String text;
+
+        MemFile(String name, String text) {
+            super(URI.create(name), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+
+        @Override
+        public String getName() {
+            return uri.toString();
+        }
+
+        @Override
+        public String getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+}
diff --git a/test/tools/javac/processing/loader/testClose/TestClose2.java b/test/tools/javac/processing/loader/testClose/TestClose2.java
new file mode 100644
index 0000000..0aee809
--- /dev/null
+++ b/test/tools/javac/processing/loader/testClose/TestClose2.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2011, 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 7092965
+ * @summary javac should not close processorClassLoader before end of compilation
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskEvent;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+ at SupportedAnnotationTypes("*")
+public class TestClose2 extends AbstractProcessor implements TaskListener {
+
+    public static void main(String... args) throws Exception {
+        new TestClose2().run();
+    }
+
+    void run() throws IOException {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+
+        JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+        final ClassLoader cl = getClass().getClassLoader();
+        Context c = new Context();
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null) {
+            @Override
+            protected ClassLoader getClassLoader(URL[] urls) {
+                return new URLClassLoader(urls, cl) {
+                    @Override
+                    public void close() throws IOException {
+                        System.err.println(getClass().getName() + " closing");
+                        TestClose2.this.closedCount++;
+                        TestClose2.this.closedIsLast = true;
+                        super.close();
+                    }
+                };
+            }
+        };
+
+        fm.setLocation(StandardLocation.CLASS_OUTPUT,
+                Collections.singleton(new File(".")));
+        fm.setLocation(StandardLocation.ANNOTATION_PROCESSOR_PATH,
+                Collections.singleton(testClasses));
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java"));
+        List<String> options = Arrays.asList(
+                "-processor", TestClose2.class.getName());
+
+        JavacTask task = tool.getTask(null, fm, null, options, null, files);
+        task.setTaskListener(this);
+
+        if (!task.call())
+            throw new Error("compilation failed");
+
+        if (closedCount == 0)
+            throw new Error("no closing message");
+        else if (closedCount > 1)
+            throw new Error(closedCount + " closed messages");
+
+        if (!closedIsLast)
+            throw new Error("closing message not last");
+    }
+
+    // AbstractProcessor methods
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        Messager messager = processingEnv.getMessager();
+        messager.printMessage(Diagnostic.Kind.NOTE, "processing");
+        return true;
+    }
+
+    // TaskListener methods
+
+    @Override
+    public void started(TaskEvent e) {
+        System.err.println("Started: " + e);
+        closedIsLast = false;
+    }
+
+    @Override
+    public void finished(TaskEvent e) {
+        System.err.println("Finished: " + e);
+        closedIsLast = false;
+    }
+
+    //
+
+    int closedCount = 0;
+    boolean closedIsLast = false;
+}
diff --git a/test/tools/javac/processing/messager/6362067/T6362067.java b/test/tools/javac/processing/messager/6362067/T6362067.java
index ef2cec8..d49c2e0 100644
--- a/test/tools/javac/processing/messager/6362067/T6362067.java
+++ b/test/tools/javac/processing/messager/6362067/T6362067.java
@@ -2,7 +2,7 @@
  * @test  /nodynamiccopyright/
  * @bug     6362067
  * @summary Messager methods do not print out source position information
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor T6362067
  * @compile -processor T6362067 -proc:only T6362067.java
  * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java
diff --git a/test/tools/javac/processing/messager/MessagerBasics.java b/test/tools/javac/processing/messager/MessagerBasics.java
index f7980c7..66a16c3 100644
--- a/test/tools/javac/processing/messager/MessagerBasics.java
+++ b/test/tools/javac/processing/messager/MessagerBasics.java
@@ -26,7 +26,7 @@
  * @bug     6341173 6341072
  * @summary Test presence of Messager methods
  * @author  Joseph D. Darcy
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile MessagerBasics.java
  * @compile -processor MessagerBasics -proc:only MessagerBasics.java
diff --git a/test/tools/javac/processing/messager/MessagerDiags.java b/test/tools/javac/processing/messager/MessagerDiags.java
new file mode 100644
index 0000000..6f333a3
--- /dev/null
+++ b/test/tools/javac/processing/messager/MessagerDiags.java
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 7166010
+ * @summary  warnings printed by annotation processors uses incorrect source
+ */
+import com.sun.source.util.JavacTask;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import static javax.tools.Diagnostic.Kind.*;
+import static javax.tools.JavaFileObject.Kind.*;
+
+ at SupportedSourceVersion(SourceVersion.RELEASE_6)
+ at SupportedAnnotationTypes("*")
+public class MessagerDiags extends AbstractProcessor {
+    static final String CNAME = "Test";
+    static final String TEST_JAVA = CNAME + ".java";
+    static final String TEST_JAVA_URI_NAME = "myfo:/" + TEST_JAVA;
+    static final String WRN_NO_SOURCE   = "warning without source";
+    static final String WRN_WITH_SOURCE = "warning with source";
+    static final String NONE = "<none>";
+    static final String[] EXPECTED = { NONE + ":-1--1:" + WRN_NO_SOURCE,
+                                       TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE,
+                                       NONE + ":-1--1:" + WRN_NO_SOURCE
+    };
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnv) {
+        Messager messager = processingEnv.getMessager();
+        for (Element e : roundEnv.getRootElements()) {
+            messager.printMessage(WARNING, WRN_NO_SOURCE);
+            messager.printMessage(WARNING, WRN_WITH_SOURCE, e);
+            messager.printMessage(WARNING, WRN_NO_SOURCE);
+        }
+        return false;
+    }
+
+    public static void main(String... args) throws IOException {
+        final String bootPath = System.getProperty("sun.boot.class.path");
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<>();
+        List<String> options = new LinkedList<>();
+        options.addAll(Arrays.asList("-bootclasspath",  bootPath,
+                        "-source", "1.6", "-classpath",
+                        System.getProperty("java.class.path")));
+        options.addAll(Arrays.asList("-processor",
+                       MessagerDiags.class.getName()));
+        JavacTask ct = (JavacTask)tool.getTask(null, null, dc, options, null,
+                        Arrays.asList(new MyFileObject("class " + CNAME + " {}")));
+        ct.analyze();
+
+        List<String> obtainedErrors = new ArrayList<>();
+
+        for (Diagnostic<? extends JavaFileObject> d : dc.getDiagnostics()) {
+            String dSource;
+            if (d.getSource() != null) {
+                dSource = d.getSource().toUri().getPath();
+                dSource = dSource.substring(dSource.lastIndexOf('/') + 1);
+            } else {
+                dSource = NONE;
+            }
+            obtainedErrors.add(dSource + ":" + d.getStartPosition() + "-" +
+                    d.getEndPosition() + ":" + d.getMessage(null));
+        }
+        List<String> expectedErrors = Arrays.asList(EXPECTED);
+        if (!expectedErrors.equals(obtainedErrors)) {
+            System.err.println("Expected: " + expectedErrors);
+            System.err.println("Obtained: " + obtainedErrors);
+            throw new AssertionError("Messages don't match");
+        }
+    }
+
+    static class MyFileObject extends SimpleJavaFileObject {
+        private String text;
+        public MyFileObject(String text) {
+            super(URI.create(TEST_JAVA_URI_NAME), SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+}
diff --git a/test/tools/javac/processing/model/6194785/T6194785.java b/test/tools/javac/processing/model/6194785/T6194785.java
index 11abd61..56ba141 100644
--- a/test/tools/javac/processing/model/6194785/T6194785.java
+++ b/test/tools/javac/processing/model/6194785/T6194785.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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
@@ -21,12 +21,12 @@
  * questions.
  */
 
-/**
+/*
  * @test
  * @bug     6194785
  * @summary ParameterDeclaration.getSimpleName does not return actual name from class files
  * @author  Peter von der Ah\u00e9
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile -g T6194785.java T6194785a.java
  * @compile -processor T6194785 foo.T6194785a T6194785.java
@@ -40,9 +40,8 @@ import static javax.tools.Diagnostic.Kind.*;
 
 public class T6194785 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
-                           RoundEnvironment roundEnvironment)
-    {
-        class Scan extends ElementScanner7<Void,Void> {
+                           RoundEnvironment roundEnvironment) {
+        class Scan extends ElementScanner<Void,Void> {
             @Override
             public Void visitExecutable(ExecutableElement e, Void ignored) {
                 for (VariableElement p : e.getParameters())
diff --git a/test/tools/javac/processing/model/6341534/T6341534.java b/test/tools/javac/processing/model/6341534/T6341534.java
index 2950909..fde6c96 100644
--- a/test/tools/javac/processing/model/6341534/T6341534.java
+++ b/test/tools/javac/processing/model/6341534/T6341534.java
@@ -27,7 +27,7 @@
  * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429)
  * @author  Steve Sides
  * @author  Peter von der Ahe
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile T6341534.java
  * @compile -proc:only -processor T6341534 dir/package-info.java
diff --git a/test/tools/javac/processing/model/TestSourceVersion.java b/test/tools/javac/processing/model/TestSourceVersion.java
new file mode 100644
index 0000000..44fbc33
--- /dev/null
+++ b/test/tools/javac/processing/model/TestSourceVersion.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, 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 7025809
+ * @summary Test latest and latestSupported
+ * @author  Joseph D. Darcy
+ */
+
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * Verify latest[Supported] behavior.
+ */
+public class TestSourceVersion {
+    public static void main(String... args) {
+        if (SourceVersion.latest() != RELEASE_8 ||
+            SourceVersion.latestSupported() != RELEASE_8)
+            throw new RuntimeException("Unexpected release value(s) found:\n" +
+                                       "latest:\t" + SourceVersion.latest() + "\n" +
+                                       "latestSupported:\t" + SourceVersion.latestSupported());
+    }
+}
diff --git a/test/tools/javac/processing/model/TestSymtabItems.java b/test/tools/javac/processing/model/TestSymtabItems.java
index b16826e..661dac4 100644
--- a/test/tools/javac/processing/model/TestSymtabItems.java
+++ b/test/tools/javac/processing/model/TestSymtabItems.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7021183
+ * @bug 7021183 7025809
  * @summary 269: assertion failure getting enclosing element of an undefined name
  */
 
@@ -37,9 +37,7 @@ import javax.lang.model.element.UnknownElementException;
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.type.UnknownTypeException;
-import javax.lang.model.util.ElementScanner7;
-import javax.lang.model.util.SimpleTypeVisitor7;
-import javax.lang.model.util.Types;
+import javax.lang.model.util.*;
 
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symtab;
@@ -112,7 +110,7 @@ public class TestSymtabItems {
 
     int errors;
 
-    class ElemPrinter extends ElementScanner7<Void, Void> {
+    class ElemPrinter extends ElementScanner8<Void, Void> {
         @Override
         public Void visitPackage(PackageElement e, Void p) {
             show("package", e);
diff --git a/test/tools/javac/processing/model/element/TestAnonClassNames.java b/test/tools/javac/processing/model/element/TestAnonClassNames.java
index df7e6d0..13fe97c 100644
--- a/test/tools/javac/processing/model/element/TestAnonClassNames.java
+++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -26,7 +26,7 @@
  * @bug 6449781 6930508
  * @summary Test that reported names of anonymous classes are non-null.
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestAnonSourceNames
  * @compile -processor TestAnonSourceNames TestAnonClassNames.java
  * @run main TestAnonClassNames
@@ -78,7 +78,7 @@ public class TestAnonClassNames {
         @Nesting(LOCAL)
         class LocalClass{};
 
-        Object o =  new /*@Nesting(ANONYMOUS)*/ Object() { // An anonymous annotated class
+        Object o =  new @Nesting(ANONYMOUS) Object() { // An anonymous annotated class
                 public String toString() {
                     return "I have no name!";
                 }
@@ -96,10 +96,9 @@ public class TestAnonClassNames {
         List<String> names = new ArrayList<String>();
         for(Class<?> clazz : classes) {
             String name = clazz.getName();
-            Nesting anno = clazz.getAnnotation(Nesting.class);
             System.out.format("%s is %s%n",
                               clazz.getName(),
-                              anno == null ? "(unset/ANONYMOUS)" : anno.value());
+                              clazz.getAnnotation(Nesting.class).value());
             testClassName(name);
             names.add(name);
         }
@@ -158,6 +157,7 @@ public class TestAnonClassNames {
     }
 }
 
+ at Target({ElementType.TYPE, ElementType.TYPE_USE})
 @Retention(RUNTIME)
 @interface Nesting {
     NestingKind value();
@@ -185,8 +185,8 @@ class ClassNameProber extends JavacTestingAbstractProcessor {
                                   typeElt.getQualifiedName().toString(),
                                   typeElt.getKind().toString(),
                                   nestingKind.toString());
-                Nesting anno = typeElt.getAnnotation(Nesting.class);
-                if ((anno == null ? NestingKind.ANONYMOUS : anno.value()) != nestingKind) {
+
+                if (typeElt.getAnnotation(Nesting.class).value() != nestingKind) {
                     throw new RuntimeException("Mismatch of expected and reported nesting kind.");
                 }
             }
diff --git a/test/tools/javac/processing/model/element/TestElement.java b/test/tools/javac/processing/model/element/TestElement.java
index 004a505..5bebfcb 100644
--- a/test/tools/javac/processing/model/element/TestElement.java
+++ b/test/tools/javac/processing/model/element/TestElement.java
@@ -26,7 +26,7 @@
  * @bug 6453386
  * @summary Test basic properties of javax.lang.element.Element
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestElement
  * @compile -processor TestElement -proc:only TestElement.java
  */
diff --git a/test/tools/javac/processing/model/element/TestExecutableElement.java b/test/tools/javac/processing/model/element/TestExecutableElement.java
new file mode 100644
index 0000000..35aae46
--- /dev/null
+++ b/test/tools/javac/processing/model/element/TestExecutableElement.java
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8005046 8011052
+ * @summary Test basic properties of javax.lang.element.Element
+ * @author  Joseph D. Darcy
+ * @library /tools/javac/lib
+ * @build   JavacTestingAbstractProcessor TestExecutableElement
+ * @compile -processor TestExecutableElement -proc:only TestExecutableElement.java
+ */
+
+import java.lang.annotation.*;
+import java.util.Formatter;
+import java.util.Set;
+import java.util.Objects;
+import java.util.regex.*;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import static javax.lang.model.util.ElementFilter.*;
+import static javax.tools.Diagnostic.Kind.*;
+import static javax.tools.StandardLocation.*;
+
+/**
+ * Test some basic workings of javax.lang.element.ExecutableElement
+ */
+public class TestExecutableElement extends JavacTestingAbstractProcessor implements ProviderOfDefault {
+    @IsDefault(false)
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnv) {
+        int errors = 0;
+        if (!roundEnv.processingOver()) {
+            boolean hasRun = false;
+            for (Element element : roundEnv.getRootElements()) {
+                for (ExecutableElement method : methodsIn(element.getEnclosedElements())) {
+                    hasRun = true;
+                    errors += checkIsDefault(method);
+                }
+            }
+
+            if (!hasRun) {
+                messager.printMessage(ERROR, "No test cases run; test fails.");
+            }
+        }
+        return true;
+    }
+
+    @IsDefault(false)
+    int checkIsDefault(ExecutableElement method) {
+        System.out.println("Testing " + method);
+        IsDefault expectedIsDefault = method.getAnnotation(IsDefault.class);
+
+        boolean expectedDefault = (expectedIsDefault != null) ?
+            expectedIsDefault.value() :
+            false;
+
+        boolean methodIsDefault = method.isDefault();
+
+        if (expectedDefault) {
+            if (!method.getModifiers().contains(Modifier.DEFAULT)) {
+                messager.printMessage(ERROR,
+                                      "Modifier \"default\" not present as expected.",
+                                      method);
+            }
+
+            // Check printing output
+            java.io.Writer stringWriter = new java.io.StringWriter();
+            eltUtils.printElements(stringWriter, method);
+            Pattern p = Pattern.compile(expectedIsDefault.expectedTextRegex(), Pattern.DOTALL);
+
+            if (! p.matcher(stringWriter.toString()).matches()) {
+                messager.printMessage(ERROR,
+                                      new Formatter().format("Unexpected printing ouptput:%n\tgot %s,%n\texpected pattern %s.",
+                                                             stringWriter.toString(),
+                                                             expectedIsDefault.expectedTextRegex()).toString(),
+                                      method);
+            }
+
+            System.out.println("\t" + stringWriter.toString());
+
+        } else {
+            if (method.getModifiers().contains(Modifier.DEFAULT)) {
+                messager.printMessage(ERROR,
+                                      "Modifier \"default\" present when not expected.",
+                                      method);
+            }
+        }
+
+        if (methodIsDefault != expectedDefault) {
+            messager.printMessage(ERROR,
+                                  new Formatter().format("Unexpected Executable.isDefault result: got ``%s'', expected ``%s''.",
+                                                         expectedDefault,
+                                                         methodIsDefault).toString(),
+                                  method);
+            return 1;
+        }
+        return 0;
+    }
+}
+
+/**
+ * Expected value of the ExecutableElement.isDefault method.
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+ at interface IsDefault {
+    boolean value();
+    String expectedTextRegex() default "";
+}
+
+/**
+ * Test interface to provide a default method.
+ */
+interface ProviderOfDefault {
+    @IsDefault(false)
+    boolean process(Set<? extends TypeElement> annotations,
+                    RoundEnvironment roundEnv);
+
+    @IsDefault(value=true, expectedTextRegex="\\s*@IsDefault\\(.*\\)\\s*default strictfp void quux\\(\\);\\s*$")
+    default strictfp void quux() {};
+}
diff --git a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
index ec1fe05..2ddcd10 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -24,11 +24,11 @@
 
 /*
  * @test
- * @bug 6639645 7026414
+ * @bug 6639645 7026414 7025809
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestMissingElement
- * @compile -proc:only -XprintRounds -processor TestMissingElement InvalidSource.java
+ * @compile/fail/ref=TestMissingElement.ref -proc:only -XprintRounds -XDrawDiagnostics -processor TestMissingElement InvalidSource.java
  */
 
 import java.util.*;
@@ -104,7 +104,7 @@ public class TestMissingElement extends JavacTestingAbstractProcessor {
     private String asString(TypeMirror t) {
         if (t == null)
             return "[typ:null]";
-        return t.accept(new SimpleTypeVisitor7<String, Void>() {
+        return t.accept(new SimpleTypeVisitor<String, Void>() {
             @Override
             public String defaultAction(TypeMirror t, Void ignore) {
                 return "[typ:" + t.toString() + "]";
@@ -135,7 +135,7 @@ public class TestMissingElement extends JavacTestingAbstractProcessor {
     private String asString(Element e) {
         if (e == null)
             return "[elt:null]";
-        return e.accept(new SimpleElementVisitor7<String, Void>() {
+        return e.accept(new SimpleElementVisitor<String, Void>() {
             @Override
             public String defaultAction(Element e, Void ignore) {
                 return "[elt:" + e.getKind() + " " + e.toString() + "]";
diff --git a/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref
new file mode 100644
index 0000000..4c31a10
--- /dev/null
+++ b/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.ref
@@ -0,0 +1,49 @@
+Round 1:
+	input files: {ExpectInterfaces, ExpectSupertype, OK, InvalidSource}
+	annotations: [ExpectSupertype, ExpectInterfaces]
+	last round: false
+Round 2:
+	input files: {}
+	annotations: []
+	last round: true
+InvalidSource.java:55:42: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:58:44: compiler.err.doesnt.exist: A
+InvalidSource.java:61:54: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.package, java.util, null)
+InvalidSource.java:64:47: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:67:44: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:70:46: compiler.err.doesnt.exist: A
+InvalidSource.java:73:55: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:76:59: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:79:46: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:79:49: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:82:44: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:85:46: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:88:50: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:91:45: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:91:48: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:94:49: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:97:51: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:97:57: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:100:49: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:103:51: compiler.err.cant.resolve.location: kindname.class, A, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:103:57: compiler.err.cant.resolve.location: kindname.class, B, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+InvalidSource.java:106:58: compiler.err.cant.resolve.location: kindname.class, X, , , (compiler.misc.location: kindname.class, InvalidSource, null)
+22 errors
+check supertype: InvalidSource.TestClassMissingClassA -- !:empty clss A!
+check supertype: InvalidSource.TestClassMissingClassAB -- !:empty clss (pkg A).B!
+check supertype: InvalidSource.TestClassMissingClass_juA -- !:empty clss (pkg java.util).A!
+check supertype: InvalidSource.TestClassTMissingClassAT -- !:empty clss A!<tvar T>
+check interfaces: InvalidSource.TestClassMissingIntfA -- !:empty intf A!
+check interfaces: InvalidSource.TestClassMissingIntfAB -- !:empty intf (pkg A).B!
+check interfaces: InvalidSource.TestClassMissingIntfAOK -- !:empty intf A!, intf OK
+check interfaces: InvalidSource.TestClassOKMissingIntfA -- intf OK, !:empty intf A!
+check interfaces: InvalidSource.TestClassMissingIntfA_B -- !:empty intf A!, !:empty intf B!
+check interfaces: InvalidSource.TestIntfMissingIntfA -- !:empty intf A!
+check interfaces: InvalidSource.TestIntfMissingIntfAOK -- !:empty intf A!, intf OK
+check interfaces: InvalidSource.TestIntfOKMissingIntfA -- intf OK, !:empty intf A!
+check interfaces: InvalidSource.TestIntfMissingIntfAB -- !:empty intf A!, !:empty intf B!
+check interfaces: InvalidSource.TestClassTMissingIntfAT -- !:empty intf A!<tvar T>
+check interfaces: InvalidSource.TestClassTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B!
+check interfaces: InvalidSource.TestIntfTMissingIntfAT -- !:empty intf A!<tvar T>
+check interfaces: InvalidSource.TestIntfTMissingIntfAT_B -- !:empty intf A!<tvar T>, !:empty intf B!
+check interfaces: InvalidSource.TestClassListMissingX -- intf (pkg java.util).List<!:empty clss X!>
\ No newline at end of file
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java
index 69bba3e..1702fc7 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingClass.java
  * @run main TestMissingClass
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java
index 6414de4..3887020 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @clean MissingGenericClass1
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingGenericClass1.java
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java
index 5619e1d..f842b8e 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @clean MissingGenericClass2
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingGenericClass2.java
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java
index 770630c..363dfe2 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @clean MissingGenericInterface1
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingGenericInterface1.java
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java
index 48f09f6..30343c4 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @clean MissingGenericInterface2
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingGenericInterface2.java
diff --git a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java
index 8f3bca9..e0dca46 100644
--- a/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java
+++ b/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6639645
  * @summary Modeling type implementing missing interfaces
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor Generator
  * @compile -XprintRounds -processor Generator TestMissingInterface.java
  * @run main TestMissingInterface
diff --git a/test/tools/javac/processing/model/element/TestNames.java b/test/tools/javac/processing/model/element/TestNames.java
index 1aec65e..14edc9e 100644
--- a/test/tools/javac/processing/model/element/TestNames.java
+++ b/test/tools/javac/processing/model/element/TestNames.java
@@ -26,7 +26,7 @@
  * @bug 6380016
  * @summary Test that the constraints guaranteed by the Filer and maintained
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestNames
  * @compile -processor TestNames -proc:only TestNames.java
  */
diff --git a/test/tools/javac/processing/model/element/TestPackageElement.java b/test/tools/javac/processing/model/element/TestPackageElement.java
index 4e0575b..1de5e3e 100644
--- a/test/tools/javac/processing/model/element/TestPackageElement.java
+++ b/test/tools/javac/processing/model/element/TestPackageElement.java
@@ -26,7 +26,7 @@
  * @bug 6449798 6399404
  * @summary Test basic workings of PackageElement
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestPackageElement
  * @compile -processor TestPackageElement -proc:only TestPackageElement.java
  */
diff --git a/test/tools/javac/processing/model/element/TestResourceElement.java b/test/tools/javac/processing/model/element/TestResourceElement.java
index a6e6de8..2ffe6a1 100644
--- a/test/tools/javac/processing/model/element/TestResourceElement.java
+++ b/test/tools/javac/processing/model/element/TestResourceElement.java
@@ -26,7 +26,7 @@
  * @bug 6967842
  * @summary Element not returned from tree API for ARM resource variables.
  * @author A. Sundararajan
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestResourceElement
  * @compile -processor TestResourceElement -proc:only TestResourceElement.java
  */
diff --git a/test/tools/javac/processing/model/element/TestResourceVariable.java b/test/tools/javac/processing/model/element/TestResourceVariable.java
index bd2c942..f36bcfb 100644
--- a/test/tools/javac/processing/model/element/TestResourceVariable.java
+++ b/test/tools/javac/processing/model/element/TestResourceVariable.java
@@ -23,10 +23,10 @@
 
 /*
  * @test
- * @bug  6911256 6964740 6967842 6961571
+ * @bug  6911256 6964740 6967842 6961571 7025809
  * @summary Test that the resource variable kind is appropriately set
  * @author  Joseph D. Darcy
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestResourceVariable
  * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
  */
@@ -44,8 +44,8 @@ import static javax.tools.Diagnostic.Kind.*;
 
 /**
  * Using the tree API, retrieve element representations of the
- * resource of an ARM block and verify their kind tags are set
- * appropriately.
+ * resource of a try-with-resources statement and verify their kind
+ * tags are set appropriately.
  */
 public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable {
     int resourceVariableCount = 0;
@@ -82,7 +82,7 @@ public class TestResourceVariable extends JavacTestingAbstractProcessor implemen
 
     /**
      * Verify that a resource variable modeled as an element behaves
-     * as expected under 6 and 7 specific visitors.
+     * as expected under 6 and latest specific visitors.
      */
     private static void testResourceVariable(Element element) {
         ElementVisitor visitor6 = new ElementKindVisitor6<Void, Void>() {};
@@ -94,7 +94,8 @@ public class TestResourceVariable extends JavacTestingAbstractProcessor implemen
             ; // Expected.
         }
 
-        ElementKindVisitor7 visitor7 = new ElementKindVisitor7<Object, Void>() {
+        ElementKindVisitor visitorLatest =
+            new ElementKindVisitor<Object, Void>() {
             @Override
             public Object visitVariableAsResourceVariable(VariableElement e,
                                                           Void p) {
@@ -102,7 +103,7 @@ public class TestResourceVariable extends JavacTestingAbstractProcessor implemen
             }
         };
 
-        if (visitor7.visit(element) == null) {
+        if (visitorLatest.visit(element) == null) {
             throw new RuntimeException("Null result of resource variable visitation.");
         }
     }
diff --git a/test/tools/javac/processing/model/element/TestTypeParameter.java b/test/tools/javac/processing/model/element/TestTypeParameter.java
index 9fc6aa2..a391be7 100644
--- a/test/tools/javac/processing/model/element/TestTypeParameter.java
+++ b/test/tools/javac/processing/model/element/TestTypeParameter.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6505047
  * @summary javax.lang.model.element.Element.getEnclosingElement() doesn't return null for type parameter
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestTypeParameter
  * @compile -processor TestTypeParameter -proc:only TestTypeParameter.java
  */
diff --git a/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java
new file mode 100644
index 0000000..d0b5cc8
--- /dev/null
+++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java
@@ -0,0 +1,190 @@
+/*
+ * 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 8011027
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
+ * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
+ */
+
+import java.util.*;
+import java.lang.annotation.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor {
+    int round = 0;
+
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (++round == 1) {
+            int found = (new Scanner()).scan(roundEnv.getRootElements(), null);
+            if (found == expect) {
+                ; //nop
+            } else {
+                error("unexpected number of results: expected " + expect
+                        + ", found " + found);
+            }
+
+        }
+        return true;
+    }
+
+    class Scanner extends JavacTestingAbstractProcessor.ElementScanner<Integer,Void> {
+        @Override
+        public Integer visitExecutable(ExecutableElement e, Void p) {
+            super.visitExecutable(e, p);
+            found += check(e, e.getTypeParameters());
+            return found;
+        }
+
+        @Override
+        public Integer visitType(TypeElement e, Void p) {
+            super.visitType(e, p);
+            found += check(e, e.getTypeParameters());
+            return found;
+        }
+
+        int found;
+    }
+
+    int check(Element e, List<? extends TypeParameterElement> typarams) {
+        if (typarams.isEmpty())
+            return 0;
+        if (typarams.size() != 1)
+            return 0;
+
+        for (TypeParameterElement tpe: typarams) {
+            boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors());
+            boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe));
+            boolean b3 = checkGetAnnotation(tpe);
+            boolean b4 = checkGetAnnotations(tpe);
+            return b1 && b2 && b3 && b4 ? 1 : 0;
+        }
+        return 0;
+    }
+
+    boolean checkAnnotationMirrors(TypeParameterElement tpe, List<? extends AnnotationMirror> l) {
+        if (l.size() != 3) {
+            error("To few annotations, got " + l.size() +
+                    ", should be 3", tpe);
+            return false;
+        }
+
+        AnnotationMirror m = l.get(0);
+        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) {
+            error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
+            return false;
+        }
+        m = l.get(1);
+        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) {
+            error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement());
+            return false;
+        }
+        m = l.get(2);
+        if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) {
+            error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement());
+            return false;
+        }
+        return true;
+    }
+
+    boolean checkGetAnnotation(TypeParameterElement tpe) {
+        Foo f = tpe.getAnnotation(Foo.class);
+        if (f == null)
+            error("Expecting @Foo to be present in getAnnotation()", tpe);
+
+        Bar b = tpe.getAnnotation(Bar.class);
+        if (b == null)
+            error("Expecting @Bar to be present in getAnnotation()", tpe);
+
+        Baz z = tpe.getAnnotation(Baz.class);
+        if (z == null)
+            error("Expecting @Baz to be present in getAnnotation()", tpe);
+
+        return f != null &&
+            b != null &&
+            z != null;
+    }
+
+    boolean checkGetAnnotations(TypeParameterElement tpe) {
+        Foo[] f = tpe.getAnnotationsByType(Foo.class);
+        if (f.length != 1) {
+            error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe);
+            return false;
+        }
+
+        Bar[] b = tpe.getAnnotationsByType(Bar.class);
+        if (b.length != 1) {
+            error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe);
+            return false;
+        }
+
+        Baz[] z = tpe.getAnnotationsByType(Baz.class);
+        if (z.length != 1) {
+            error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe);
+            return false;
+        }
+
+        return true;
+    }
+
+    void note(String msg) {
+        messager.printMessage(Diagnostic.Kind.NOTE, msg);
+    }
+
+    void note(String msg, Element e) {
+        messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
+    }
+
+    void error(String msg, Element e) {
+        messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
+    }
+
+    void error(String msg) {
+        messager.printMessage(Diagnostic.Kind.ERROR, msg);
+    }
+
+    // additional generic elements to test
+    <@Foo @Bar @Baz X> X m(X x) { return x; }
+
+    interface Intf<@Foo @Bar @Baz X> { X m() ; }
+
+    class Class<@Foo @Bar @Baz X> {
+        <@Foo @Bar @Baz Y> Class() { }
+    }
+
+    final int expect = 5;  // top level class, plus preceding examples
+}
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface Foo {}
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface Bar {}
+
+ at Target(ElementType.TYPE_PARAMETER)
+ at interface Baz {}
diff --git a/test/tools/javac/processing/model/element/TypeParamBounds.java b/test/tools/javac/processing/model/element/TypeParamBounds.java
index c09e12b..e8053b1 100644
--- a/test/tools/javac/processing/model/element/TypeParamBounds.java
+++ b/test/tools/javac/processing/model/element/TypeParamBounds.java
@@ -26,7 +26,7 @@
  * @bug     6423972
  * @summary Tests TypeParameter.getBounds.
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TypeParamBounds
  * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java
  */
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/ElementRepAnnoTester.java b/test/tools/javac/processing/model/element/repeatingAnnotations/ElementRepAnnoTester.java
new file mode 100644
index 0000000..3de12e6
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/ElementRepAnnoTester.java
@@ -0,0 +1,555 @@
+/*
+ * 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.Annotation;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.Elements;
+
+public class ElementRepAnnoTester extends JavacTestingAbstractProcessor {
+    // All methods to test.
+    final EnumSet<TestMethod> ALL_TEST_METHODS = EnumSet.allOf(TestMethod.class);
+    int count = 0;
+    int error = 0;
+
+    public boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        if (!roundEnv.processingOver()) {
+            List<String> superClass = Arrays.asList("A", "B", "C", "D", "E",
+                    "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P");
+            // Go through all test classes
+            for (Element element : roundEnv.getRootElements()) {
+                // For now, no testing super classes (TODO)
+                if (element.getKind() == ElementKind.CLASS
+                        && !superClass.contains(element.getSimpleName().toString())) {
+                    // Compare expected and actual values from methods.
+                    checkAnnoValues(element, ALL_TEST_METHODS);
+                    // Now, look for enclosed elements in test classes.
+                    for (Element elements : element.getEnclosedElements()) {
+                        // Look for Methods annotations.
+                        if (elements.getKind() == ElementKind.METHOD
+                                && elements.getSimpleName().toString().equals("testMethod")) {
+                            checkAnnoValues(elements, ALL_TEST_METHODS);
+                        }
+                        // Look for Field annotations.
+                        if (elements.getKind() == ElementKind.FIELD
+                                && elements.getSimpleName().toString().equals("testField")) {
+                            checkAnnoValues(elements, ALL_TEST_METHODS);
+                        }
+                    }
+                }
+            }
+
+            if (error != 0) {
+                System.out.println("Total tests : " + count);
+                System.out.println("Total test failures : " + error);
+                throw new RuntimeException();
+            } else {
+                System.out.println("ALL TESTS PASSED. " + count);
+            }
+        }
+        return true;
+    }
+
+    enum TestMethod {
+        getAnnotation,
+        getAnnotationsByType,
+        getAllAnnotationMirrors,
+        getAnnotationMirrors
+    }
+
+    protected void checkAnnoValues(Element element, EnumSet<TestMethod> testMethods) {
+        boolean baseAnnoPresent = false;
+        boolean conAnnoPresent = false;
+        ExpectedBase eb = null;
+        ExpectedContainer ec = null;
+        // Getting the expected values to compare with.
+        eb = element.getAnnotation(ExpectedBase.class);
+        ec = element.getAnnotation(ExpectedContainer.class);
+
+        if (eb == null) {
+            System.out.println("Did not find ExpectedBase Annotation in  "
+                    + element.getSimpleName().toString() + ", Test will exit");
+            throw new RuntimeException();
+        }
+        if (ec == null) {
+            System.out.println("Did not find ExpectedContainer Annotation in "
+                    + element.getSimpleName().toString() + " Test will exit");
+            throw new RuntimeException();
+        }
+        // Look if all test cases have ExpectedBase and ExpectedContainer values().
+        TypeMirror valueBase = null;
+        TypeMirror valueCon = null;
+
+        try {
+            eb.value();
+        } catch (MirroredTypeException mte) {
+            valueBase = mte.getTypeMirror();
+        }
+
+        try {
+            ec.value();
+        } catch (MirroredTypeException mte1) {
+            valueCon = mte1.getTypeMirror();
+        }
+
+        String expectedBaseAnno = valueBase.toString();
+        String expectedConAnno = valueCon.toString();
+
+        if (!expectedBaseAnno.equals("java.lang.annotation.Annotation")) {
+            baseAnnoPresent = true;
+        }
+        if (!expectedConAnno.equalsIgnoreCase("java.lang.annotation.Annotation")) {
+            conAnnoPresent = true;
+        }
+
+        // Look into TestMethod and compare method's output with expected values.
+        for (TestMethod testMethod : testMethods) {
+            boolean isBasePass = true;
+            boolean isConPass = true;
+
+            switch (testMethod) {
+                case getAnnotation:
+                    if (baseAnnoPresent) {
+                        count++;
+                        Annotation actualAnno = getAnnotationBase(element);
+                        String expectedAnno = eb.getAnnotation();
+                        isBasePass = compareAnnotation(actualAnno, expectedAnno);
+                    }
+                    if (conAnnoPresent) {
+                        count++;
+                        Annotation actualAnno = getAnnotationContainer(element);
+                        String expectedAnno = ec.getAnnotation();
+                        isConPass = compareAnnotation(actualAnno, expectedAnno);
+                    }
+                    if (!isBasePass || !isConPass) {
+                        System.out.println("FAIL in " + element.getSimpleName()
+                                + "-" + element.getKind()
+                                + " method: getAnnotation(class <T>)");
+                        error++;
+                    }
+                    break;
+
+                case getAnnotationMirrors:
+                    if (baseAnnoPresent) {
+                        count++;
+                        List<? extends AnnotationMirror> actualDeclAnnos =
+                                element.getAnnotationMirrors();
+                        String[] expectedAnnos = eb.getAnnotationMirrors();
+                        isBasePass = compareArrVals(actualDeclAnnos, expectedAnnos);
+                    }
+                    if (conAnnoPresent) {
+                        isConPass = true;
+                    }
+                    if (!isBasePass || !isConPass) {
+                        System.out.println("FAIL in " + element.getSimpleName()
+                                + "-" + element.getKind()
+                                + " method: getAnnotationMirrors()");
+                        error++;
+                    }
+                    break;
+
+                case getAnnotationsByType:
+                    if (baseAnnoPresent) {
+                        count++;
+                        Annotation[] actualAnnosArgs = getAnnotationsBase(element);
+                        String[] expectedAnnos = eb.getAnnotationsByType();
+                        isBasePass = compareArrVals(actualAnnosArgs, expectedAnnos);
+                    }
+                    if (conAnnoPresent) {
+                        count++;
+                        Annotation[] actualAnnosArgs = getAnnotationsContainer(element);
+                        String[] expectedAnnos = ec.getAnnotationsByType();
+                        isConPass = compareArrVals(actualAnnosArgs, expectedAnnos);
+                    }
+                    if (!isBasePass || !isConPass) {
+                        System.out.println("FAIL in " + element.getSimpleName()
+                                + "-" + element.getKind()
+                                + " method: getAnnotationsByType(class <T>)");
+                        error++;
+                    }
+                    break;
+
+                case getAllAnnotationMirrors:
+                    if (baseAnnoPresent) {
+                        count++;
+                        Elements elements = processingEnv.getElementUtils();
+                        List<? extends AnnotationMirror> actualAnnosMirrors =
+                                elements.getAllAnnotationMirrors(element);
+                        String[] expectedAnnos = eb.getAllAnnotationMirrors();
+                        isBasePass = compareArrVals(actualAnnosMirrors, expectedAnnos);
+                    }
+                    if (conAnnoPresent) {
+                        isConPass = true;
+                    }
+                    if (!isBasePass || !isConPass) {
+                        System.out.println("FAIL in " + element.getSimpleName()
+                                + "-" + element.getKind()
+                                + " method: getAllAnnotationMirrors(e)");
+                        error++;
+                    }
+                    break;
+            }
+        }
+    }
+    // Sort tests to be run with different anno processors.
+    final List<String> singularAnno = Arrays.asList(
+            "SingularBasicTest"
+            );
+    final List<String> singularInheritedAnno = Arrays.asList(
+            "SingularInheritedATest"
+            );
+    final List<String> repeatableAnno = Arrays.asList(
+            "RepeatableBasicTest",
+            "MixRepeatableAndOfficialContainerBasicTest",
+            "OfficialContainerBasicTest",
+            "RepeatableOfficialContainerBasicTest"
+            );
+    final List<String> repeatableInheritedAnno = Arrays.asList(
+            "RepeatableInheritedTest",
+            "RepeatableOverrideATest",
+            "RepeatableOverrideBTest",
+            "OfficialContainerInheritedTest",
+            "MixRepeatableAndOfficialContainerInheritedA1Test",
+            "MixRepeatableAndOfficialContainerInheritedB1Test",
+            "MixRepeatableAndOfficialContainerInheritedA2Test",
+            "MixRepeatableAndOfficialContainerInheritedB2Test"
+            );
+    final List<String> repeatableContainerInheritedAnno = Arrays.asList(
+            "RepeatableOfficialContainerInheritedTest"
+            );
+    final List<String> unofficialAnno = Arrays.asList(
+            "UnofficialContainerBasicTest",
+            "MixSingularAndUnofficialContainerBasicTest"
+            );
+    final List<String> unofficialInheritedAnno = Arrays.asList(
+            "UnofficialContainerInheritedTest",
+            "SingularInheritedBTest",
+            "MixSingularAndUnofficialContainerInheritedA1Test",
+            "MixSingularAndUnofficialContainerInheritedB1Test",
+            "MixSingularAndUnofficialContainerInheritedA2Test",
+            "MixSingularAndUnofficialContainerInheritedB2Test"
+            );
+    // Respective container annotation for the different test cases to test.
+    final List<String> repeatableAnnoContainer = repeatableAnno;
+    final List<String> repeatableInheritedAnnoContainer = repeatableInheritedAnno;
+    final List<String> repeatableContainerInheritedAnnoContainer =
+            repeatableContainerInheritedAnno;
+    final List<String> unofficialAnnoContainer = unofficialAnno;
+    final List<String> unofficialInheritedAnnoContainer = unofficialInheritedAnno;
+
+    // Variables to verify if all test cases have been run.
+    private Annotation specialAnno = new Annotation() {
+       @Override
+        public Class annotationType() {
+            return null;
+        }
+    };
+    private Annotation[] specialAnnoArray = new Annotation[1];
+    private List<AnnotationMirror> specialAnnoMirrors =
+            new java.util.ArrayList<AnnotationMirror>(2);
+
+    private Annotation getAnnotationBase(Element e) {
+        Annotation actualAnno = specialAnno;
+
+        if (singularAnno.contains(
+                e.getEnclosingElement().toString())
+                || singularAnno.contains(
+                e.getSimpleName().toString())
+                || unofficialAnno.contains(
+                e.getEnclosingElement().toString())
+                || unofficialAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(Foo.class);
+        }
+        if (singularInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || singularInheritedAnno.contains(
+                e.getSimpleName().toString())
+                || unofficialInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || unofficialInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(FooInherited.class);
+        }
+        if (repeatableAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(Bar.class);
+        }
+        if (repeatableInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(BarInherited.class);
+        }
+        if (repeatableContainerInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableContainerInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(BarInheritedContainer.class);
+        }
+        return actualAnno;
+    }
+
+    private Annotation getAnnotationContainer(Element e) {
+        Annotation actualAnno = specialAnno;
+
+        if (repeatableAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(BarContainer.class);
+        }
+        if (repeatableInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(BarInheritedContainer.class);
+        }
+        if (repeatableContainerInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableContainerInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(BarInheritedContainerContainer.class);
+        }
+        if (unofficialAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || unofficialAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(UnofficialContainer.class);
+        }
+        if (unofficialInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || unofficialInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnno = e.getAnnotation(UnofficialInheritedContainer.class);
+        }
+        return actualAnno;
+    }
+
+    private Annotation[] getAnnotationsBase(Element e) {
+        Annotation[] actualAnnosArgs = specialAnnoArray;
+
+        if (singularAnno.contains(
+                e.getEnclosingElement().toString())
+                || singularAnno.contains(
+                e.getSimpleName().toString())
+                || unofficialAnno.contains(
+                e.getEnclosingElement().toString())
+                || unofficialAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(Foo.class);
+        }
+        if (singularInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || singularInheritedAnno.contains(
+                e.getSimpleName().toString())
+                || unofficialInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || unofficialInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(FooInherited.class);
+        }
+        if (repeatableAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(Bar.class);
+        }
+        if (repeatableInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(BarInherited.class);
+        }
+        if (repeatableContainerInheritedAnno.contains(
+                e.getEnclosingElement().toString())
+                || repeatableContainerInheritedAnno.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainer.class);
+        }
+        return actualAnnosArgs;
+    }
+
+    private Annotation[] getAnnotationsContainer(Element e) {
+        Annotation[] actualAnnosArgs = specialAnnoArray;
+
+        if (repeatableAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(BarContainer.class);
+        }
+        if (repeatableInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainer.class);
+        }
+        if (repeatableContainerInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || repeatableContainerInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(BarInheritedContainerContainer.class);
+        }
+        if (unofficialAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || unofficialAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(UnofficialContainer.class);
+        }
+        if (unofficialInheritedAnnoContainer.contains(
+                e.getEnclosingElement().toString())
+                || unofficialInheritedAnnoContainer.contains(
+                e.getSimpleName().toString())) {
+            actualAnnosArgs = e.getAnnotationsByType(UnofficialInheritedContainer.class);
+        }
+        return actualAnnosArgs;
+    }
+
+    // Array comparison: Length should be same and all expected values
+    // should be present in actualAnnos[].
+    private boolean compareArrVals(Annotation[] actualAnnos, String[] expectedAnnos) {
+        // Look if test case was run.
+        if (actualAnnos == specialAnnoArray) {
+            return false; // no testcase matches
+        }
+        if (actualAnnos.length != expectedAnnos.length) {
+            System.out.println("Length not same. "
+                    + " actualAnnos length = " + actualAnnos.length
+                    + " expectedAnnos length = " + expectedAnnos.length);
+            printArrContents(actualAnnos);
+            printArrContents(expectedAnnos);
+            return false;
+        } else {
+            int i = 0;
+            String[] actualArr = new String[actualAnnos.length];
+            for (Annotation a : actualAnnos) {
+                actualArr[i++] = a.toString();
+            }
+            List<String> actualList = Arrays.asList(actualArr);
+            List<String> expectedList = Arrays.asList(expectedAnnos);
+
+            if (!actualList.containsAll(expectedList)) {
+                System.out.println("Array values are not same");
+                printArrContents(actualAnnos);
+                printArrContents(expectedAnnos);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    // Array comparison: Length should be same and all expected values
+    // should be present in actualAnnos List<?>.
+    private boolean compareArrVals(List<? extends AnnotationMirror> actualAnnos,
+            String[] expectedAnnos) {
+        // Look if test case was run.
+        if (actualAnnos == specialAnnoMirrors) {
+            return false; //no testcase run
+        }
+        if (actualAnnos.size() != expectedAnnos.length) {
+            System.out.println("Length not same. "
+                    + " actualAnnos length = " + actualAnnos.size()
+                    + " expectedAnnos length = " + expectedAnnos.length);
+            printArrContents(actualAnnos);
+            printArrContents(expectedAnnos);
+            return false;
+        } else {
+            int i = 0;
+            String[] actualArr = new String[actualAnnos.size()];
+            String annoTypeName = "";
+            for (AnnotationMirror annotationMirror : actualAnnos) {
+                if (annotationMirror.getAnnotationType().toString().contains("Expected")) {
+                    annoTypeName = annotationMirror.getAnnotationType().toString();
+                } else {
+                     annoTypeName = annotationMirror.toString();
+                }
+                actualArr[i++] = annoTypeName;
+            }
+            List<String> actualList = Arrays.asList(actualArr);
+            List<String> expectedList = Arrays.asList(expectedAnnos);
+
+            if (!actualList.containsAll(expectedList)) {
+                System.out.println("Array values are not same");
+                printArrContents(actualAnnos);
+                printArrContents(expectedAnnos);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private void printArrContents(Annotation[] actualAnnos) {
+        for (Annotation a : actualAnnos) {
+            System.out.println("actualAnnos values = " + a);
+        }
+    }
+
+    private void printArrContents(String[] expectedAnnos) {
+        for (String s : expectedAnnos) {
+            System.out.println("expectedAnnos values =  " + s);
+        }
+    }
+
+    private void printArrContents(List<? extends AnnotationMirror> actualAnnos) {
+        for (AnnotationMirror annotationMirror : actualAnnos) {
+            System.out.println("actualAnnos values = " + annotationMirror);
+        }
+    }
+
+    private boolean compareAnnotation(Annotation actualAnno, String expectedAnno) {
+        //String actualAnnoName = "";
+        boolean isSame = true;
+        // Look if test case was run.
+        if (actualAnno == specialAnno) {
+            return false; //no testcase run
+        }
+        if (actualAnno != null) {
+            if (!actualAnno.toString().equalsIgnoreCase(expectedAnno)) {
+                System.out.println("Anno did not match. "
+                        + " expectedAnno = " + expectedAnno
+                        + " actualAnno = " + actualAnno);
+                isSame = false;
+            } else {
+                isSame = true;
+            }
+        } else {
+            if (expectedAnno.compareToIgnoreCase("null") == 0) {
+                isSame = true;
+            } else {
+                System.out.println("Actual anno is null");
+                isSame = false;
+            }
+        }
+        return isSame;
+    }
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerBasicTest.java
new file mode 100644
index 0000000..c000729
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerBasicTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixRepeatableAndOfficialContainerBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Bar.class,
+        getAnnotation = "@Bar(value=0)",
+        getAnnotationsByType = {
+            "@Bar(value=0)",
+            "@Bar(value=1)",
+            "@Bar(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@Bar(0)",
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@Bar(0)",
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarContainer.class,
+        getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+        getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+ at Bar(value = 0)
+ at BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+class MixRepeatableAndOfficialContainerBasicTest {
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "@Bar(value=0)",
+            getAnnotationsByType = {
+                "@Bar(value=0)",
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@Bar(0)",
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Bar(0)",
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @Bar(value = 0)
+    @BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "@Bar(value=0)",
+            getAnnotationsByType = {
+                "@Bar(value=0)",
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@Bar(0)",
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Bar(0)",
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @Bar(value = 0)
+    @BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+    void testMethod() {}
+   }
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA1Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA1Test.java
new file mode 100644
index 0000000..8844cd1
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA1Test.java
@@ -0,0 +1,65 @@
+/*
+ * 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     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
+ */
+
+ at BarInherited(value = 0)
+class E {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=0)",
+        getAnnotationsByType = {
+            "@BarInherited(value=1)",
+            "@BarInherited(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInherited(0)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInheritedContainer(value = {@BarInherited(value = 1), @BarInherited(value = 2)})
+class MixRepeatableAndOfficialContainerInheritedA1Test extends E {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA2Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA2Test.java
new file mode 100644
index 0000000..5aa833e
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedA2Test.java
@@ -0,0 +1,67 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixRepeatableAndOfficialContainerInheritedA2Test.java
+ */
+
+ at BarInherited(value = 0)
+class N {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=3)",
+        getAnnotationsByType = {
+            "@BarInherited(value=1)",
+            "@BarInherited(value=2)",
+            "@BarInherited(value=3)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInherited(3)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInherited(3)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInheritedContainer(value = {@BarInherited(value = 1), @BarInherited(value = 2)})
+ at BarInherited(value = 3)
+class MixRepeatableAndOfficialContainerInheritedA2Test extends N {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB1Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB1Test.java
new file mode 100644
index 0000000..e2141da
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB1Test.java
@@ -0,0 +1,62 @@
+/*
+ * 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     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
+ */
+
+ at BarInheritedContainer(value = {@BarInherited(value = 1), @BarInherited(value = 2)})
+class M {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=0)",
+        getAnnotationsByType = {"@BarInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@BarInherited(0)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInherited(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInherited(value = 0)
+class MixRepeatableAndOfficialContainerInheritedB1Test extends M {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB2Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB2Test.java
new file mode 100644
index 0000000..fb6efb4
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixRepeatableAndOfficialContainerInheritedB2Test.java
@@ -0,0 +1,63 @@
+/*
+ * 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     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
+ */
+
+ at BarInheritedContainer(value = {@BarInherited(value = 1), @BarInherited(value = 2)})
+ at BarInherited(value = 3)
+class H {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=0)",
+        getAnnotationsByType = {"@BarInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@BarInherited(0)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInherited(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInherited(value = 0)
+class MixRepeatableAndOfficialContainerInheritedB2Test extends H {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerBasicTest.java
new file mode 100644
index 0000000..319a728
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerBasicTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only MixSingularAndUnofficialContainerBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Foo.class,
+        getAnnotation = "@Foo(value=0)",
+        getAnnotationsByType = {"@Foo(value=0)"},
+        getAllAnnotationMirrors = {
+            "@Foo(0)",
+            "@UnofficialContainer({@Foo(1), @Foo(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@Foo(0)",
+            "@UnofficialContainer({@Foo(1), @Foo(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialContainer.class,
+        getAnnotation = "@UnofficialContainer("
+        + "value=[@Foo(value=1), @Foo(value=2)])",
+        getAnnotationsByType = {"@UnofficialContainer("
+                + "value=[@Foo(value=1), @Foo(value=2)])"})
+ at Foo(value = 0)
+ at UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+class MixSingularAndUnofficialContainerBasicTest {
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "@Foo(value=0)",
+            getAnnotationsByType = {"@Foo(value=0)"},
+            getAllAnnotationMirrors = {
+                "@Foo(0)",
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Foo(0)",
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = UnofficialContainer.class,
+            getAnnotation = "@UnofficialContainer("
+            + "value=[@Foo(value=1), @Foo(value=2)])",
+            getAnnotationsByType = {"@UnofficialContainer("
+                    + "value=[@Foo(value=1), @Foo(value=2)])"})
+    @Foo(value = 0)
+    @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "@Foo(value=0)",
+            getAnnotationsByType = {"@Foo(value=0)"},
+            getAllAnnotationMirrors = {
+                "@Foo(0)",
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Foo(0)",
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = UnofficialContainer.class,
+            getAnnotation = "@UnofficialContainer("
+            + "value=[@Foo(value=1), @Foo(value=2)])",
+            getAnnotationsByType = {"@UnofficialContainer("
+                    + "value=[@Foo(value=1), @Foo(value=2)])"})
+    @Foo(value = 0)
+    @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+    void testMethod() {}
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA1Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA1Test.java
new file mode 100644
index 0000000..f21de09
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA1Test.java
@@ -0,0 +1,61 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixSingularAndUnofficialContainerInheritedA1Test.java
+ */
+
+ at FooInherited(value = 0)
+class L {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=0)",
+        getAnnotationsByType = {"@FooInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(0)",
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "@UnofficialInheritedContainer("
+        + "value=[@FooInherited(value=1), @FooInherited(value=2)])",
+        getAnnotationsByType = {"@UnofficialInheritedContainer("
+                + "value=[@FooInherited(value=1), @FooInherited(value=2)])"})
+ at UnofficialInheritedContainer(value = {@FooInherited(value = 1), @FooInherited(value = 2)})
+class MixSingularAndUnofficialContainerInheritedA1Test extends L {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA2Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA2Test.java
new file mode 100644
index 0000000..3354483
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedA2Test.java
@@ -0,0 +1,63 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixSingularAndUnofficialContainerInheritedA2Test.java
+ */
+
+ at FooInherited(value = 0)
+class K {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=3)",
+        getAnnotationsByType = {"@FooInherited(value=3)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(3)",
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "@FooInherited(3)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "@UnofficialInheritedContainer("
+        + "value=[@FooInherited(value=1), @FooInherited(value=2)])",
+        getAnnotationsByType = {"@UnofficialInheritedContainer("
+                + "value=[@FooInherited(value=1), @FooInherited(value=2)])"})
+ at UnofficialInheritedContainer(value = {@FooInherited(value = 1), @FooInherited(value = 2)})
+ at FooInherited(value = 3)
+class MixSingularAndUnofficialContainerInheritedA2Test extends K {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB1Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB1Test.java
new file mode 100644
index 0000000..12daba2
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB1Test.java
@@ -0,0 +1,61 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixSingularAndUnofficialContainerInheritedB1Test.java
+ */
+
+ at UnofficialInheritedContainer(value = {@FooInherited(value = 1), at FooInherited(value = 2)})
+class J {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=0)",
+        getAnnotationsByType = {"@FooInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(0)",
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@FooInherited(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "@UnofficialInheritedContainer("
+        + "value=[@FooInherited(value=1), @FooInherited(value=2)])",
+        getAnnotationsByType = {"@UnofficialInheritedContainer("
+                + "value=[@FooInherited(value=1), @FooInherited(value=2)])"})
+ at FooInherited(value = 0)
+class MixSingularAndUnofficialContainerInheritedB1Test extends J {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB2Test.java b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB2Test.java
new file mode 100644
index 0000000..9b4dbd3
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/MixSingularAndUnofficialContainerInheritedB2Test.java
@@ -0,0 +1,62 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * MixSingularAndUnofficialContainerInheritedB2Test.java
+ */
+
+ at UnofficialInheritedContainer(value = {@FooInherited(value = 1), @FooInherited(value = 2)})
+ at FooInherited(value = 3)
+class G {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=0)",
+        getAnnotationsByType = {"@FooInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(0)",
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@FooInherited(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "@UnofficialInheritedContainer("
+        + "value=[@FooInherited(value=1), @FooInherited(value=2)])",
+        getAnnotationsByType = {"@UnofficialInheritedContainer("
+                + "value=[@FooInherited(value=1), @FooInherited(value=2)])"})
+ at FooInherited(value = 0)
+class MixSingularAndUnofficialContainerInheritedB2Test extends G{}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerBasicTest.java
new file mode 100644
index 0000000..0b39e09
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerBasicTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only OfficialContainerBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Bar.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@Bar(value=1)",
+            "@Bar(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarContainer.class,
+        getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+        getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+ at BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+class OfficialContainerBasicTest {
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @BarContainer(value = {@Bar(value = 1), @Bar(value = 2)})
+    void testMethod() {}
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerInheritedTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerInheritedTest.java
new file mode 100644
index 0000000..8aa58b2
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/OfficialContainerInheritedTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only OfficialContainerInheritedTest.java
+ */
+
+ at BarInheritedContainer(value = {@BarInherited(value = 1), @BarInherited(value = 2)})
+class D {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@BarInherited(value=1)",
+            "@BarInherited(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+class OfficialContainerInheritedTest extends D {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableBasicTest.java
new file mode 100644
index 0000000..03eebd5
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableBasicTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only RepeatableBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Bar.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@Bar(value=1)",
+            "@Bar(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarContainer({@Bar(1), @Bar(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarContainer.class,
+        getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+        getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+ at Bar(value = 1)
+ at Bar(value = 2)
+class RepeatableBasicTest {
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @Bar(value = 1)
+    @Bar(value = 2)
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@Bar(value=1)",
+                "@Bar(value=2)"
+            },
+            getAllAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainer({@Bar(1), @Bar(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "@BarContainer(value=[@Bar(value=1), @Bar(value=2)])",
+            getAnnotationsByType = {"@BarContainer(value=[@Bar(value=1), @Bar(value=2)])"})
+    @Bar(value = 1)
+    @Bar(value = 2)
+    void testMethod() {}
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableInheritedTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableInheritedTest.java
new file mode 100644
index 0000000..2be810e
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableInheritedTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only RepeatableInheritedTest.java
+ */
+
+ at BarInherited(value = 1)
+ at BarInherited(value = 2)
+class I {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@BarInherited(value=1)",
+            "@BarInherited(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+class RepeatableInheritedTest extends I {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerBasicTest.java
new file mode 100644
index 0000000..2745a18
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerBasicTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only RepeatableOfficialContainerBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Bar.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {},
+        getAllAnnotationMirrors = {
+            "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarContainer.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@BarContainer(value=[@Bar(value=1)])",
+            "@BarContainer(value=[@Bar(value=2)])"})
+ at BarContainer(value = {@Bar(value = 1)})
+ at BarContainer(value = {@Bar(value = 2)})
+class RepeatableOfficialContainerBasicTest {
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {},
+            getAllAnnotationMirrors = {
+                "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@BarContainer(value=[@Bar(value=1)])",
+                "@BarContainer(value=[@Bar(value=2)])"})
+    @BarContainer(value = {@Bar(value = 1)})
+    @BarContainer(value = {@Bar(value = 2)})
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Bar.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {},
+            getAllAnnotationMirrors = {
+                "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@BarContainerContainer({@BarContainer({@Bar(1)}), @BarContainer({@Bar(2)})})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = BarContainer.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {
+                "@BarContainer(value=[@Bar(value=1)])",
+                "@BarContainer(value=[@Bar(value=2)])"})
+    @BarContainer(value = {@Bar(value = 1)})
+    @BarContainer(value = {@Bar(value = 2)})
+    void testMethod() {}
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerInheritedTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerInheritedTest.java
new file mode 100644
index 0000000..c375565
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOfficialContainerInheritedTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * RepeatableOfficialContainerInheritedTest.java
+ */
+
+ at BarInheritedContainer(value = {@BarInherited(value = 1)})
+ at BarInheritedContainer(value = {@BarInherited(value = 2)})
+class O {}
+
+ at ExpectedBase(
+        value = BarInheritedContainer.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {
+            "@BarInheritedContainer(value=[@BarInherited(value=1)])",
+            "@BarInheritedContainer(value=[@BarInherited(value=2)])"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInheritedContainerContainer("
+                + "{@BarInheritedContainer({@BarInherited(1)}),"
+                + " @BarInheritedContainer({@BarInherited(2)})})",
+                "ExpectedBase",
+                "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainerContainer.class,
+        getAnnotation = "@BarInheritedContainerContainer("
+        + "value=[@BarInheritedContainer(value=[@BarInherited(value=1)]),"
+        + " @BarInheritedContainer(value=[@BarInherited(value=2)])])",
+        getAnnotationsByType = {"@BarInheritedContainerContainer("
+                + "value=[@BarInheritedContainer(value=[@BarInherited(value=1)]),"
+        + " @BarInheritedContainer(value=[@BarInherited(value=2)])])"})
+class RepeatableOfficialContainerInheritedTest extends O {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideATest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideATest.java
new file mode 100644
index 0000000..395a2a6
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideATest.java
@@ -0,0 +1,62 @@
+/*
+ * 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     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
+ */
+
+ at BarInherited(value = 1)
+ at BarInherited(value = 2)
+class B {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=3)",
+        getAnnotationsByType = {"@BarInherited(value=3)"},
+        getAllAnnotationMirrors = {
+            "@BarInherited(3)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInherited(3)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInherited(value = 3)
+class RepeatableOverrideATest extends B {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideBTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideBTest.java
new file mode 100644
index 0000000..f16ec7a
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/RepeatableOverrideBTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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     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
+ */
+
+ at BarInherited(value = 0)
+class C {}
+
+ at ExpectedBase(
+        value = BarInherited.class,
+        getAnnotation = "@BarInherited(value=0)",
+        getAnnotationsByType = {
+            "@BarInherited(value=1)",
+            "@BarInherited(value=2)"
+        },
+        getAllAnnotationMirrors = {
+            "@BarInherited(0)",
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@BarInheritedContainer({@BarInherited(1), @BarInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = BarInheritedContainer.class,
+        getAnnotation = "@BarInheritedContainer("
+        + "value=[@BarInherited(value=1), @BarInherited(value=2)])",
+        getAnnotationsByType = {"@BarInheritedContainer("
+                + "value=[@BarInherited(value=1), @BarInherited(value=2)])"})
+ at BarInherited(value = 1)
+ at BarInherited(value = 2)
+class RepeatableOverrideBTest extends C {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/SingularBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularBasicTest.java
new file mode 100644
index 0000000..efed629
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularBasicTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only SingularBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Foo.class,
+        getAnnotation = "@Foo(value=0)",
+        getAnnotationsByType = {"@Foo(value=0)"},
+        getAllAnnotationMirrors = {
+            "@Foo(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@Foo(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer
+ at Foo(value = 0)
+public class SingularBasicTest {
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "@Foo(value=0)",
+            getAnnotationsByType = {"@Foo(value=0)"},
+            getAllAnnotationMirrors = {
+                "@Foo(0)",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Foo(0)",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer
+    @Foo(value = 0)
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "@Foo(value=0)",
+            getAnnotationsByType = {"@Foo(value=0)"},
+            getAllAnnotationMirrors = {
+                "@Foo(0)",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@Foo(0)",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer
+    @Foo(value = 0)
+    void testMethod() {
+    }
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedATest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedATest.java
new file mode 100644
index 0000000..c48c453
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedATest.java
@@ -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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only SingularInheritedATest.java
+ */
+
+ at FooInherited(value = 0)
+class A {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=0)",
+        getAnnotationsByType = {"@FooInherited(value=0)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(0)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer
+class SingularInheritedATest extends A {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedBTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedBTest.java
new file mode 100644
index 0000000..fb3a371
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/SingularInheritedBTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only SingularInheritedBTest.java
+ */
+
+ at FooInherited(value = 1)
+class P {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "@FooInherited(value=2)",
+        getAnnotationsByType = {"@FooInherited(value=2)"},
+        getAllAnnotationMirrors = {
+            "@FooInherited(2)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@FooInherited(2)",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {})
+ at FooInherited(value = 2)
+class SingularInheritedBTest extends P {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerBasicTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerBasicTest.java
new file mode 100644
index 0000000..33eac13
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerBasicTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only UnofficialContainerBasicTest.java
+ */
+
+ at ExpectedBase(
+        value = Foo.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {},
+        getAllAnnotationMirrors = {
+            "@UnofficialContainer({@Foo(1), @Foo(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "@UnofficialContainer({@Foo(1), @Foo(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialContainer.class,
+        getAnnotation = "@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])",
+        getAnnotationsByType = {"@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])"})
+ at UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+class UnofficialContainerBasicTest {
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {},
+            getAllAnnotationMirrors = {
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = UnofficialContainer.class,
+            getAnnotation = "@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])",
+            getAnnotationsByType = {"@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])"})
+    @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+    int testField = 0;
+
+    @ExpectedBase(
+            value = Foo.class,
+            getAnnotation = "null",
+            getAnnotationsByType = {},
+            getAllAnnotationMirrors = {
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            },
+            getAnnotationMirrors = {
+                "@UnofficialContainer({@Foo(1), @Foo(2)})",
+                "ExpectedBase",
+                "ExpectedContainer"
+            })
+    @ExpectedContainer(
+            value = UnofficialContainer.class,
+            getAnnotation = "@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])",
+            getAnnotationsByType = {"@UnofficialContainer(value=[@Foo(value=1), @Foo(value=2)])"})
+    @UnofficialContainer(value = {@Foo(value = 1), @Foo(value = 2)})
+    void testMethod() {}
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerInheritedTest.java b/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerInheritedTest.java
new file mode 100644
index 0000000..9fc3ba1
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/UnofficialContainerInheritedTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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     8004822
+ * @author  mnunez
+ * @summary Language model api test basics for repeating annotations
+ * @library /tools/javac/lib
+ * @library supportingAnnotations
+ * @build   JavacTestingAbstractProcessor ElementRepAnnoTester
+ * @compile -processor ElementRepAnnoTester -proc:only
+ * UnofficialContainerInheritedTest.java
+ */
+
+ at UnofficialInheritedContainer(value = {@FooInherited(value = 1), at FooInherited(value = 2)})
+class F {}
+
+ at ExpectedBase(
+        value = FooInherited.class,
+        getAnnotation = "null",
+        getAnnotationsByType = {},
+        getAllAnnotationMirrors = {
+            "@UnofficialInheritedContainer({@FooInherited(1), @FooInherited(2)})",
+            "ExpectedBase",
+            "ExpectedContainer"
+        },
+        getAnnotationMirrors = {
+            "ExpectedBase",
+            "ExpectedContainer"
+        })
+ at ExpectedContainer(
+        value = UnofficialInheritedContainer.class,
+        getAnnotation = "@UnofficialInheritedContainer("
+        + "value=[@FooInherited(value=1), @FooInherited(value=2)])",
+        getAnnotationsByType = {"@UnofficialInheritedContainer("
+                + "value=[@FooInherited(value=1), @FooInherited(value=2)])"})
+class UnofficialContainerInheritedTest extends F {}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Bar.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Bar.java
new file mode 100644
index 0000000..6eaf680
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Bar.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(BarContainer.class)
+public @interface Bar {
+    int value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainer.java
new file mode 100644
index 0000000..688042e
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainer.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Repeatable(BarContainerContainer.class)
+public @interface BarContainer {
+    Bar[] value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainerContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainerContainer.java
new file mode 100644
index 0000000..9285014
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarContainerContainer.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+public @interface BarContainerContainer {
+    BarContainer[] value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInherited.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInherited.java
new file mode 100644
index 0000000..e30d3de
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInherited.java
@@ -0,0 +1,33 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+ at Repeatable(BarInheritedContainer.class)
+public @interface BarInherited {
+    int value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainer.java
new file mode 100644
index 0000000..ee8cfdb
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainer.java
@@ -0,0 +1,33 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+ at Repeatable(BarInheritedContainerContainer.class)
+public @interface BarInheritedContainer {
+    BarInherited[] value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainerContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainerContainer.java
new file mode 100644
index 0000000..d814a50
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/BarInheritedContainerContainer.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+public @interface BarInheritedContainerContainer {
+    BarInheritedContainer[] value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedBase.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedBase.java
new file mode 100644
index 0000000..6cfc0f4
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedBase.java
@@ -0,0 +1,36 @@
+/*
+ * 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.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedBase {
+    Class<? extends Annotation> value() default Annotation.class;
+    String getAnnotation() default "";
+    String[] getAllAnnotationMirrors() default {};
+    String[] getAnnotationMirrors() default {};
+    // Java SE 8 methods.
+    String[] getAnnotationsByType() default {};
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedContainer.java
new file mode 100644
index 0000000..2e2d39b
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/ExpectedContainer.java
@@ -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.
+ */
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface ExpectedContainer {
+    Class<? extends Annotation> value() default Annotation.class;
+    String getAnnotation() default "";
+    // Java SE 8 methods.
+    String[] getAnnotationsByType() default {};
+    }
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Foo.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Foo.java
new file mode 100644
index 0000000..5a4acab
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/Foo.java
@@ -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.
+ */
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface Foo {
+    int value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/FooInherited.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/FooInherited.java
new file mode 100644
index 0000000..2681d1f
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/FooInherited.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+public @interface FooInherited {
+    int value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialContainer.java
new file mode 100644
index 0000000..06c8cbf
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialContainer.java
@@ -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.
+ */
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface UnofficialContainer {
+    Foo[] value();
+}
diff --git a/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialInheritedContainer.java b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialInheritedContainer.java
new file mode 100644
index 0000000..e862b92
--- /dev/null
+++ b/test/tools/javac/processing/model/element/repeatingAnnotations/supportingAnnotations/UnofficialInheritedContainer.java
@@ -0,0 +1,32 @@
+/*
+ * 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.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+ at Retention(RetentionPolicy.RUNTIME)
+ at Inherited
+public @interface UnofficialInheritedContainer {
+    FooInherited[] value();
+}
diff --git a/test/tools/javac/processing/model/type/BasicAnnoTests.java b/test/tools/javac/processing/model/type/BasicAnnoTests.java
new file mode 100644
index 0000000..0b0bd8e
--- /dev/null
+++ b/test/tools/javac/processing/model/type/BasicAnnoTests.java
@@ -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; }
+}
diff --git a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java
index 861014f..e90c046 100644
--- a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java
+++ b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java
@@ -26,7 +26,7 @@
  * @bug     6362178
  * @summary MirroredType[s]Exception shouldn't be created too eagerly
  * @author  Scott Seligman
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile -g OverEager.java
  * @compile -processor OverEager -proc:only OverEager.java
diff --git a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java
index e01ba01..274ca70 100644
--- a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java
+++ b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java
@@ -25,7 +25,7 @@
  * @test
  * @bug     6519115
  * @summary Verify MirroredTypeException vs MirroredTypesException is thrown
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile Plurality.java
  * @compile -processor Plurality -proc:only Plurality.java
diff --git a/test/tools/javac/processing/model/type/NoTypes.java b/test/tools/javac/processing/model/type/NoTypes.java
index d67dae1..b985d91 100644
--- a/test/tools/javac/processing/model/type/NoTypes.java
+++ b/test/tools/javac/processing/model/type/NoTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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,10 +23,10 @@
 
 /*
  * @test
- * @bug     6418666 6423973 6453386
+ * @bug     6418666 6423973 6453386 7025809
  * @summary Test the NoTypes: VOID, PACKAGE, NONE
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile -g NoTypes.java
  * @compile -processor NoTypes -proc:only NoTypes.java
@@ -75,7 +75,7 @@ public class NoTypes extends JavacTestingAbstractProcessor {
         verifyKind(NONE, types.getNoType(NONE));
 
         // The return type of a constructor or void method is VOID.
-        class Scanner extends ElementScanner7<Void, Void> {
+        class Scanner extends ElementScanner<Void, Void> {
             @Override
             public Void visitExecutable(ExecutableElement e, Void p) {
                 verifyKind(VOID, e.getReturnType());
@@ -89,11 +89,11 @@ public class NoTypes extends JavacTestingAbstractProcessor {
     }
 
     /**
-     * Verify that a NoType instance is of a particular kind,
-     * and that TypeKindVisitor7 properly dispatches on it.
+     * Verify that a NoType instance is of a particular kind, and that
+     * the latest TypeKindVisitor properly dispatches on it.
      */
     private void verifyKind(TypeKind kind, TypeMirror type) {
-        class Vis extends TypeKindVisitor7<TypeKind, Void> {
+        class Vis extends TypeKindVisitor<TypeKind, Void> {
             @Override
             public TypeKind visitNoTypeAsVoid(NoType t, Void p) {
                 return VOID;
@@ -111,9 +111,7 @@ public class NoTypes extends JavacTestingAbstractProcessor {
             throw new AssertionError();
     }
 
-
     // Fodder for the tests
-
     interface I {
     }
 
diff --git a/test/tools/javac/processing/model/type/TestUnionType.java b/test/tools/javac/processing/model/type/TestUnionType.java
index 0126057..d208a0c 100644
--- a/test/tools/javac/processing/model/type/TestUnionType.java
+++ b/test/tools/javac/processing/model/type/TestUnionType.java
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug     7029150
+ * @bug     7029150 7025809
  * @summary Test support for union types
- * @library ../../../lib
+ * @library /tools/javac/lib
  */
 
 import java.net.URI;
@@ -39,7 +39,6 @@ import javax.tools.*;
 import com.sun.source.tree.*;
 import com.sun.source.util.*;
 
-
 public class TestUnionType extends JavacTestingAbstractProcessor {
     enum TestKind {
         SingleType("E1", "E1",
@@ -194,7 +193,7 @@ public class TestUnionType extends JavacTestingAbstractProcessor {
         }
     }
 
-    class TypePrinter extends SimpleTypeVisitor7<String, Void> {
+    class TypePrinter extends SimpleTypeVisitor<String, Void> {
         @Override
         protected String defaultAction(TypeMirror tm, Void ignore) {
             return String.valueOf(tm.getKind());
diff --git a/test/tools/javac/processing/model/util/BinaryName.java b/test/tools/javac/processing/model/util/BinaryName.java
index 02445ff..8c99b54 100644
--- a/test/tools/javac/processing/model/util/BinaryName.java
+++ b/test/tools/javac/processing/model/util/BinaryName.java
@@ -26,7 +26,7 @@
  * @bug     6346251
  * @summary Test Elements.getBinaryName
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor BinaryName
  * @compile -processor BinaryName -proc:only BinaryName.java
  */
diff --git a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java
index 01782f3..152a5f0 100644
--- a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java
+++ b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java
@@ -26,7 +26,7 @@
  * @bug     6346506 6408241
  * @summary getTypeElement should tolerate a type that can't be found
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor GetTypeElemBadArg
  * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java
  */
diff --git a/test/tools/javac/processing/model/util/NoSupers.java b/test/tools/javac/processing/model/util/NoSupers.java
index 9967b40..97ae7f5 100644
--- a/test/tools/javac/processing/model/util/NoSupers.java
+++ b/test/tools/javac/processing/model/util/NoSupers.java
@@ -26,7 +26,7 @@
  * @bug     6346453
  * @summary directSupertypes should return empty list if arg has no supertypes
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor NoSupers
  * @compile -processor NoSupers -proc:only NoSupers.java
  */
diff --git a/test/tools/javac/processing/model/util/OverridesSpecEx.java b/test/tools/javac/processing/model/util/OverridesSpecEx.java
index 887c677..6adb1c3 100644
--- a/test/tools/javac/processing/model/util/OverridesSpecEx.java
+++ b/test/tools/javac/processing/model/util/OverridesSpecEx.java
@@ -26,7 +26,7 @@
  * @bug     6453386
  * @summary Verify that example code in Elements.overrides works as spec'ed.
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile -g OverridesSpecEx.java
  * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java
diff --git a/test/tools/javac/processing/model/util/TypesBadArg.java b/test/tools/javac/processing/model/util/TypesBadArg.java
index 6eadb57..76babe6 100644
--- a/test/tools/javac/processing/model/util/TypesBadArg.java
+++ b/test/tools/javac/processing/model/util/TypesBadArg.java
@@ -26,7 +26,7 @@
  * @bug     6345812
  * @summary Validate argument kinds in Types utilities
  * @author  Scott Seligman
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TypesBadArg
  * @compile -processor TypesBadArg -proc:only TypesBadArg.java
  */
diff --git a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java
index f409759..c9eae58 100644
--- a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java
+++ b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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 @@
  * @bug 6392818
  * @summary Tests Elements.isDeprecated(Element)
  * @author  Joseph D. Darcy
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile TestDeprecation.java
  * @compile -processor TestDeprecation -proc:only Dep1.java
@@ -68,7 +68,7 @@ public class TestDeprecation extends JavacTestingAbstractProcessor {
         return true;
     }
 
-    private class DeprecationChecker extends ElementScanner7<Boolean,Void> {
+    private class DeprecationChecker extends ElementScanner<Boolean,Void> {
         private Elements elementUtils;
         private boolean failure;
         DeprecationChecker() {
diff --git a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java
index db44b56..ee0b903 100644
--- a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java
+++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java
@@ -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
@@ -26,9 +26,9 @@
  * @bug     6346973
  * @summary directSupertypes(t) should not return t
  * @author  Scott Seligman
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor DirectSupersOfErr
- * @compile -processor DirectSupersOfErr -proc:only C1.java
+ * @compile/fail/ref=DirectSupersOfErr.ref -processor DirectSupersOfErr -proc:only -XDrawDiagnostics C1.java
  */
 
 import java.util.Set;
diff --git a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.ref b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.ref
new file mode 100644
index 0000000..8fe9c7e
--- /dev/null
+++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.ref
@@ -0,0 +1,2 @@
+C1.java:24:18: compiler.err.cant.resolve: kindname.class, Bogus, , 
+1 error
diff --git a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java
index 355b7d9..d4bcd3f 100644
--- a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java
+++ b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java
@@ -26,7 +26,7 @@
  * @bug 6471577 6517779
  * @summary Test Elements.getConstantExpression
  * @author  Joseph D. Darcy
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestGetConstantExpression
  * @compile -processor TestGetConstantExpression Foo.java
  */
diff --git a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java
index 6fbc24f..9ad7b43 100644
--- a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java
+++ b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java
@@ -26,7 +26,7 @@
  * @bug 6453386
  * @summary Test Elements.getPackageOf
  * @author  Joseph D. Darcy
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor TestGetPackageOf
  * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java
  */
diff --git a/test/tools/javac/processing/model/util/elements/TestIsFunctionalInterface.java b/test/tools/javac/processing/model/util/elements/TestIsFunctionalInterface.java
new file mode 100644
index 0000000..791b574
--- /dev/null
+++ b/test/tools/javac/processing/model/util/elements/TestIsFunctionalInterface.java
@@ -0,0 +1,115 @@
+/*
+ * 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 8007574
+ * @summary Test Elements.isFunctionalInterface
+ * @author  Joseph D. Darcy
+ * @library /tools/javac/lib
+ * @build   JavacTestingAbstractProcessor TestIsFunctionalInterface
+ * @compile -processor TestIsFunctionalInterface TestIsFunctionalInterface.java
+ */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import static javax.lang.model.util.ElementFilter.*;
+import static javax.tools.Diagnostic.Kind.*;
+import static javax.tools.StandardLocation.*;
+import java.io.*;
+
+/**
+ * Test basic workings of Elements.isFunctionalInterface
+ */
+public class TestIsFunctionalInterface extends JavacTestingAbstractProcessor {
+    private int count = 0;
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnv) {
+        if (!roundEnv.processingOver()) {
+            for(TypeElement type : typesIn(roundEnv.getElementsAnnotatedWith(ExpectedIsFunInt.class))) {
+                count++;
+                System.out.println(type);
+                if (elements.isFunctionalInterface(type) !=
+                    type.getAnnotation(ExpectedIsFunInt.class).value()) {
+                    messager.printMessage(ERROR,
+                                          "Mismatch between expected and computed isFunctionalInterface",
+                                          type);
+                }
+            }
+        } else {
+            if (count <= 0)
+                messager.printMessage(ERROR, "No types with ExpectedIsFunInt processed.");
+            }
+    return true;
+    }
+}
+
+ at interface ExpectedIsFunInt {
+    boolean value();
+}
+
+// Examples below from the lambda specification documents.
+
+ at ExpectedIsFunInt(false) // Equals is already an implicit member
+interface Foo1 { boolean equals(Object obj); }
+
+ at ExpectedIsFunInt(true) // Bar has one abstract non-Object method
+interface Bar1 extends Foo1 { int compare(String o1, String o2); }
+
+
+ at ExpectedIsFunInt(true) // Comparator has one abstract non-Object method
+interface LocalComparator<T> {
+ boolean equals(Object obj);
+ int compare(T o1, T o2);
+}
+
+ at ExpectedIsFunInt(false) // Method Object.clone is not public
+interface Foo2 {
+  int m();
+  Object clone();
+}
+
+interface X1 { int m(Iterable<String> arg); }
+interface Y1 { int m(Iterable<String> arg); }
+ at ExpectedIsFunInt(true) // Two methods, but they have the same signature
+interface Z1 extends X1, Y1 {}
+
+interface X2 { Iterable m(Iterable<String> arg); }
+interface Y2 { Iterable<String> m(Iterable arg); }
+ at ExpectedIsFunInt(true) // Y.m is a subsignature & return-type-substitutable
+interface Z2 extends X2, Y2 {}
+
+interface Action<T> {
+    T doit();
+}
+ at ExpectedIsFunInt(true)
+interface LocalExecutor { <T> T execute(Action<T> a); }
+
+interface X5 { <T> T execute(Action<T> a); }
+interface Y5 { <S> S execute(Action<S> a); }
+ at ExpectedIsFunInt(true) // Functional: signatures are "the same"
+interface Exec5 extends X5, Y5 {}
diff --git a/test/tools/javac/processing/model/util/filter/TestIterables.java b/test/tools/javac/processing/model/util/filter/TestIterables.java
index cbffcda..447cefc 100644
--- a/test/tools/javac/processing/model/util/filter/TestIterables.java
+++ b/test/tools/javac/processing/model/util/filter/TestIterables.java
@@ -26,7 +26,7 @@
  * @bug 6406164
  * @summary Test that ElementFilter iterable methods behave properly.
  * @author  Joseph D. Darcy
- * @library ../../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor
  * @compile TestIterables.java
  * @compile -processor TestIterables -proc:only Foo1.java
diff --git a/test/tools/javac/processing/options/testCommandLineClasses/Test.java b/test/tools/javac/processing/options/testCommandLineClasses/Test.java
index f9287e6..b610a14 100644
--- a/test/tools/javac/processing/options/testCommandLineClasses/Test.java
+++ b/test/tools/javac/processing/options/testCommandLineClasses/Test.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6930508
  * @summary Passing nested class names on javac command line interfere with subsequent name -> class lookup
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor p.NestedExamples Test
  * @run main Test
  */
diff --git a/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java b/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java
index c16ccc6..90a1445 100644
--- a/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java
+++ b/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6987384
  * @summary -XprintProcessorRoundsInfo message printed with different timing than previous
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor Test
  * @compile/fail/ref=Test.out -XDrawDiagnostics -XprintProcessorInfo -Werror -proc:only -processor Test Test.java
  */
diff --git a/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java
new file mode 100644
index 0000000..e9e60d4
--- /dev/null
+++ b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 6987384
+ * @summary -XprintProcessorRoundsInfo message printed with different timing than previous
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor Test TestWithXstdout
+ * @run main TestWithXstdout
+ */
+
+import java.io.*;
+import java.nio.charset.*;
+import java.nio.file.*;
+import java.util.*;
+
+public class TestWithXstdout {
+    public static void main(String... args) throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        String testClasses = System.getProperty("test.classes", ".");
+        String testClassPath = System.getProperty("test.class.path", testClasses);
+        File stdout = new File("stdout.out");
+        run_javac("-XDrawDiagnostics",
+                "-XprintProcessorInfo",
+                "-Werror",
+                "-proc:only",
+                "-processor",  "Test",
+                "-Xstdout", stdout.getPath(),
+                "-classpath", testClassPath,
+                new File(testSrc, "Test.java").getPath());
+        boolean ok = compare(stdout, new File(testSrc, "Test.out"));
+        if (!ok)
+            throw new Exception("differences found");
+    }
+
+    static void run_javac(String... args) throws IOException, InterruptedException {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javac = new File(new File(javaHome, "bin"), "javac");
+
+        List<String> opts = new ArrayList<>();
+        opts.add(javac.getPath());
+
+        String toolOpts = System.getProperty("test.tool.vm.opts");
+        if (toolOpts != null && !"".equals(toolOpts.trim())) {
+            opts.addAll(Arrays.asList(toolOpts.trim().split("[\\s]+")));
+        }
+        opts.addAll(Arrays.asList(args));
+        System.out.println("exec: " + opts);
+        ProcessBuilder pb = new ProcessBuilder(opts);
+        pb.redirectErrorStream();
+        Process p = pb.start();
+        try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+            String line;
+            while ((line = r.readLine()) != null)
+                System.out.println();
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            System.out.println("javac exited, rc=" + rc);
+    }
+
+    static boolean compare(File a, File b) throws IOException {
+        List<String> aLines = Files.readAllLines(a.toPath(), Charset.defaultCharset());
+        List<String> bLines = Files.readAllLines(b.toPath(), Charset.defaultCharset());
+        System.out.println(a + ": " + aLines.size() + " lines");
+        System.out.println(b + ": " + bLines.size() + " lines");
+        return aLines.equals(bLines);
+    }
+}
diff --git a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
index a5c0c2f..2646f23 100644
--- a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
+++ b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, 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 6376083 6376084 6458819
+ * @bug 6376083 6376084 6458819 7025784 7025786 7025789
  * @summary Test that warnings about source versions are output as expected.
  * @author  Joseph D. Darcy
  * @compile TestSourceVersionWarnings.java
@@ -35,7 +35,8 @@
  * @compile/ref=gold_sv_warn_5_6.out   -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_5 -source 1.6 -Xlint:-options HelloWorld.java
  * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options HelloWorld.java
  * @compile/ref=gold_unsp_warn.out     -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
- * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7                 HelloWorld.java
+ * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 -Xlint:-options HelloWorld.java
+ * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_8 -source 1.8                 HelloWorld.java
  */
 
 import java.util.Set;
@@ -51,7 +52,8 @@ import static javax.tools.Diagnostic.Kind.*;
 /**
  * This processor returns the supported source level as indicated by
  * the "SourceLevel" option; therefore, don't use
- * JavacTestingAbstractProcessor which returns the latest source level.
+ * JavacTestingAbstractProcessor which returns the latest source
+ * level.
  */
 @SupportedAnnotationTypes("*")
 @SupportedOptions("SourceVersion")
diff --git a/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java b/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java
index 6f8053d..c4adf67 100644
--- a/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java
+++ b/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 6986892
  * @summary confusing warning given after errors in annotation processing
- * @library ../../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor TestProcUseImplicitWarning
  * @clean C1 p.C2
  * @compile/fail/ref=err.out -XDrawDiagnostics -processor TestProcUseImplicitWarning -Aerror C1.java
diff --git a/test/tools/javac/processing/werror/WError1.java b/test/tools/javac/processing/werror/WError1.java
index 08cbe73..8824ae7 100644
--- a/test/tools/javac/processing/werror/WError1.java
+++ b/test/tools/javac/processing/werror/WError1.java
@@ -24,7 +24,7 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile WError1.java
  * @compile -proc:only -processor WError1 WError1.java
diff --git a/test/tools/javac/processing/werror/WErrorGen.java b/test/tools/javac/processing/werror/WErrorGen.java
index 383ee79..e6da212 100644
--- a/test/tools/javac/processing/werror/WErrorGen.java
+++ b/test/tools/javac/processing/werror/WErrorGen.java
@@ -24,7 +24,7 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile WErrorGen.java
  * @compile -proc:only -processor WErrorGen WErrorGen.java
diff --git a/test/tools/javac/processing/werror/WErrorLast.java b/test/tools/javac/processing/werror/WErrorLast.java
index 33578c8..f85aed6 100644
--- a/test/tools/javac/processing/werror/WErrorLast.java
+++ b/test/tools/javac/processing/werror/WErrorLast.java
@@ -24,7 +24,7 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build   JavacTestingAbstractProcessor
  * @compile WErrorLast.java
  * @compile -proc:only -processor WErrorLast WErrorLast.java
diff --git a/test/tools/javac/profiles/ProfileOptionTest.java b/test/tools/javac/profiles/ProfileOptionTest.java
new file mode 100644
index 0000000..eaae7d9
--- /dev/null
+++ b/test/tools/javac/profiles/ProfileOptionTest.java
@@ -0,0 +1,267 @@
+/*
+ * 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
+ * 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 8004182
+ * @summary Add support for profiles in javac
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.jvm.Target;
+
+
+public class ProfileOptionTest {
+    public static void main(String... args) throws Exception {
+        new ProfileOptionTest().run();
+    }
+
+    private final JavaCompiler javac = JavacTool.create();
+    private final StandardJavaFileManager fm = javac.getStandardFileManager(null, null, null);
+
+
+    // ---------- Test cases, invoked reflectively via run. ----------
+
+    @Test
+    void testInvalidProfile_CommandLine() throws Exception {
+        JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
+        String badName = "foo";
+        List<String> opts = Arrays.asList("-profile", badName);
+        StringWriter sw = new StringWriter();
+        try {
+            JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
+                Arrays.asList(fo));
+            throw new Exception("expected exception not thrown");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    @Test
+    void testInvalidProfile_API() throws Exception {
+        String badName = "foo";
+        String[] opts = { "-profile", badName };
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(opts, pw);
+
+        // sadly, command line errors are not (yet?) reported to
+        // the diag listener
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out.trim());
+
+        if (!out.contains("invalid profile: " + badName)) {
+            error("expected message not found");
+        }
+    }
+
+    @Test
+    void testTargetProfileCombinations() throws Exception {
+        JavaFileObject fo = new StringJavaFileObject("Test.java", "class Test { }");
+        for (Target t: Target.values()) {
+            switch (t) {
+                case JDK1_1: case JDK1_2: // no equivalent -source
+                    continue;
+            }
+
+            for (Profile p: Profile.values()) {
+                List<String> opts = new ArrayList<String>();
+                opts.addAll(Arrays.asList("-source", t.name, "-target", t.name));
+                opts.add("-Xlint:-options"); // dont warn about no -bootclasspath
+                if (p != Profile.DEFAULT)
+                    opts.addAll(Arrays.asList("-profile", p.name));
+                StringWriter sw = new StringWriter();
+                JavacTask task = (JavacTask) javac.getTask(sw, fm, null, opts, null,
+                        Arrays.asList(fo));
+                task.analyze();
+
+                // sadly, command line errors are not (yet?) reported to
+                // the diag listener
+                String out = sw.toString();
+                if (!out.isEmpty())
+                    System.err.println(out.trim());
+
+                switch (t) {
+                    case JDK1_8:
+                        if (!out.isEmpty())
+                            error("unexpected output from compiler");
+                        break;
+                    default:
+                        if (p != Profile.DEFAULT
+                                && !out.contains("profile " + p.name
+                                    + " is not valid for target release " + t.name)) {
+                            error("expected message not found");
+                        }
+                }
+            }
+        }
+    }
+
+    @Test
+    void testClassesInProfiles() throws Exception {
+        for (Profile p: Profile.values()) {
+            for (Map.Entry<Profile, List<JavaFileObject>> e: testClasses.entrySet()) {
+                for (JavaFileObject fo: e.getValue()) {
+                    DiagnosticCollector<JavaFileObject> dl =
+                            new DiagnosticCollector<JavaFileObject>();
+                    List<String> opts = (p == Profile.DEFAULT)
+                            ? Collections.<String>emptyList()
+                            : Arrays.asList("-profile", p.name);
+                    JavacTask task = (JavacTask) javac.getTask(null, fm, dl, opts, null,
+                            Arrays.asList(fo));
+                    task.analyze();
+
+                    List<String> expectDiagCodes = (p.value >= e.getKey().value)
+                            ? Collections.<String>emptyList()
+                            : Arrays.asList("compiler.err.not.in.profile");
+
+                    checkDiags(opts + " " + fo.getName(), dl.getDiagnostics(), expectDiagCodes);
+                }
+            }
+        }
+    }
+
+    Map<Profile, List<JavaFileObject>> testClasses =
+            new EnumMap<Profile, List<JavaFileObject>>(Profile.class);
+
+    void initTestClasses() {
+        // The following table assumes the existence of specific classes
+        // in specific profiles, as defined in the Java SE 8 spec.
+        init(Profile.COMPACT1,
+                java.lang.String.class);
+
+        init(Profile.COMPACT2,
+                javax.xml.XMLConstants.class);
+
+        init(Profile.COMPACT3,
+                javax.sql.rowset.Predicate.class,
+                com.sun.security.auth.PolicyFile.class); // specifically included in 3
+
+        init(Profile.DEFAULT,
+                java.beans.BeanInfo.class,
+                javax.management.remote.rmi._RMIServer_Stub.class); // specifically excluded in 3
+    }
+
+    void init(Profile p, Class<?>... classes) {
+        List<JavaFileObject> srcs = new ArrayList<JavaFileObject>();
+        for (Class<?> c: classes) {
+            String name = "T" + c.getSimpleName();
+            String src =
+                    "class T" + name + "{" + "\n" +
+                    "    Class<?> c = " + c.getName() + ".class;\n" +
+                    "}";
+            srcs.add(new StringJavaFileObject(name + ".java", src));
+        }
+        testClasses.put(p, srcs);
+    }
+
+    void checkDiags(String msg, List<Diagnostic<? extends JavaFileObject>> diags, List<String> expectDiagCodes) {
+        System.err.print(msg);
+        if (diags.isEmpty())
+            System.err.println(" OK");
+        else {
+            System.err.println();
+            System.err.println(diags);
+        }
+
+        List<String> foundDiagCodes = new ArrayList<String>();
+        for (Diagnostic<? extends JavaFileObject> d: diags)
+            foundDiagCodes.add(d.getCode());
+
+        if (!foundDiagCodes.equals(expectDiagCodes)) {
+            System.err.println("Found diag codes:    " + foundDiagCodes);
+            System.err.println("Expected diag codes: " + expectDiagCodes);
+            error("expected diagnostics not found");
+        }
+    }
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /** Run all test cases. */
+    void run() throws Exception {
+        initTestClasses();
+
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                System.err.println(m.getName());
+                try {
+                    m.invoke(this, new Object[] { });
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                System.err.println();
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    private static class StringJavaFileObject extends SimpleJavaFileObject {
+        StringJavaFileObject(String name, String text) {
+            super(URI.create(name), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean b) {
+            return text;
+        }
+        private String text;
+    }
+}
diff --git a/test/tools/javac/quid/T6999438.java b/test/tools/javac/quid/T6999438.java
index c42b1f7..8187eea 100644
--- a/test/tools/javac/quid/T6999438.java
+++ b/test/tools/javac/quid/T6999438.java
@@ -1,7 +1,7 @@
 /* @test /nodynamiccopyright/
  * @bug 6999438
  * @summary remove support for exotic identifiers from JDK 7
- * @compile/fail/ref=T6999438.out -XDrawDiagnostics -source 7 T6999438.java
+ * @compile/fail/ref=T6999438.out -XDrawDiagnostics T6999438.java
  */
 
 class Test {
diff --git a/test/tools/javac/quid/T6999438.out b/test/tools/javac/quid/T6999438.out
index cd62668..3527ae6 100644
--- a/test/tools/javac/quid/T6999438.out
+++ b/test/tools/javac/quid/T6999438.out
@@ -1,4 +1,4 @@
-T6999438.java:8:9: compiler.err.illegal.char: 35
+T6999438.java:8:9: compiler.err.illegal.char: #
 T6999438.java:8:10: compiler.err.illegal.start.of.type
 T6999438.java:8:25: compiler.err.expected: token.identifier
 T6999438.java:8:26: compiler.err.expected: ';'
diff --git a/test/tools/javac/resolve/Candidate.java b/test/tools/javac/resolve/Candidate.java
new file mode 100644
index 0000000..a36208b
--- /dev/null
+++ b/test/tools/javac/resolve/Candidate.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011, 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.ElementType;
+import java.lang.annotation.Target;
+
+ at Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
+ at interface Candidate {
+    /**
+     * the candidate position (line/col of the method call for which this candidate
+     * is a potential overload candidate)
+     */
+    Pos pos() default @Pos(userDefined=false);
+    /**
+     * resolution phases for which this candidate is applicable
+     */
+    Phase[] applicable() default { };
+    /**
+     * is this candidate the most specific (in the resolution phases for which it
+     * is also applicable)
+     */
+    boolean mostSpecific() default false;
+    /**
+     * this candidate inferred signature (in the resolution phases for which it
+     * is also applicable, in case it corresponds to a generic method)
+     */
+    String sig() default "";
+}
+
+enum Phase {
+    BASIC("BASIC"),
+    BOX("BOX"),
+    VARARGS("VARARITY");
+
+    final String javacString;
+
+    private Phase(String javacString) {
+        this.javacString = javacString;
+    }
+
+    static Phase fromString(String s) {
+        for (Phase phase : Phase.values()) {
+            if (phase.javacString.equals(s)) {
+                return phase;
+            }
+        }
+        throw new AssertionError("Invalid resolution phase string " + s);
+    }
+}
diff --git a/test/tools/javac/resolve/Pos.java b/test/tools/javac/resolve/Pos.java
new file mode 100644
index 0000000..953275b
--- /dev/null
+++ b/test/tools/javac/resolve/Pos.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, 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.ElementType;
+import java.lang.annotation.Target;
+
+ at Target(ElementType.ANNOTATION_TYPE)
+ at interface Pos {
+    long line() default -1;
+    long col() default -1;
+    boolean userDefined() default true;
+}
diff --git a/test/tools/javac/resolve/ResolveHarness.java b/test/tools/javac/resolve/ResolveHarness.java
new file mode 100644
index 0000000..5f761c3
--- /dev/null
+++ b/test/tools/javac/resolve/ResolveHarness.java
@@ -0,0 +1,505 @@
+/*
+ * Copyright (c) 2011, 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 7098660
+ * @summary Write better overload resolution/inference tests
+ * @library /tools/javac/lib
+ * @build JavacTestingAbstractProcessor ResolveHarness
+ * @run main ResolveHarness
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type.MethodType;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+import java.io.File;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import static javax.tools.StandardLocation.*;
+
+public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+    static int nerrors = 0;
+
+    static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+    static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+    public static void main(String[] args) throws Exception {
+        fm.setLocation(SOURCE_PATH,
+                Arrays.asList(new File(System.getProperty("test.src"), "tests")));
+        for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
+            new ResolveHarness(jfo).check();
+        }
+        if (nerrors > 0) {
+            throw new AssertionError("Errors were found");
+        }
+    }
+
+
+    JavaFileObject jfo;
+    DiagnosticProcessor[] diagProcessors;
+    Map<ElementKey, Candidate> candidatesMap = new HashMap<ElementKey, Candidate>();
+    Set<String> declaredKeys = new HashSet<>();
+    List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>();
+    List<ElementKey> seenCandidates = new ArrayList<>();
+    Map<String, String> predefTranslationMap = new HashMap<>();
+
+    protected ResolveHarness(JavaFileObject jfo) {
+        this.jfo = jfo;
+        this.diagProcessors = new DiagnosticProcessor[] {
+            new VerboseResolutionNoteProcessor(),
+            new VerboseDeferredInferenceNoteProcessor(),
+            new ErrorProcessor()
+        };
+        predefTranslationMap.put("+", "_plus");
+        predefTranslationMap.put("-", "_minus");
+        predefTranslationMap.put("~", "_not");
+        predefTranslationMap.put("++", "_plusplus");
+        predefTranslationMap.put("--", "_minusminus");
+        predefTranslationMap.put("!", "_bang");
+        predefTranslationMap.put("*", "_mul");
+        predefTranslationMap.put("/", "_div");
+        predefTranslationMap.put("%", "_mod");
+        predefTranslationMap.put("&", "_and");
+        predefTranslationMap.put("|", "_or");
+        predefTranslationMap.put("^", "_xor");
+        predefTranslationMap.put("<<", "_lshift");
+        predefTranslationMap.put(">>", "_rshift");
+        predefTranslationMap.put("<<<", "_lshiftshift");
+        predefTranslationMap.put(">>>", "_rshiftshift");
+        predefTranslationMap.put("<", "_lt");
+        predefTranslationMap.put(">", "_gt");
+        predefTranslationMap.put("<=", "_lteq");
+        predefTranslationMap.put(">=", "_gteq");
+        predefTranslationMap.put("==", "_eq");
+        predefTranslationMap.put("!=", "_neq");
+        predefTranslationMap.put("&&", "_andand");
+        predefTranslationMap.put("||", "_oror");
+    }
+
+    protected void check() throws Exception {
+        String[] options = {
+            "-XDshouldStopPolicy=ATTR",
+            "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"
+        };
+
+        AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };
+
+        @SuppressWarnings("unchecked")
+        DiagnosticListener<? super JavaFileObject>[] diagListeners =
+                new DiagnosticListener[] { new DiagnosticHandler(false), new DiagnosticHandler(true) };
+
+        for (int i = 0 ; i < options.length ; i ++) {
+            JavacTask ct = (JavacTask)comp.getTask(null, fm, diagListeners[i],
+                    Arrays.asList(options[i]), null, Arrays.asList(jfo));
+            if (processors[i] != null) {
+                ct.setProcessors(Collections.singleton(processors[i]));
+            }
+            ct.analyze();
+        }
+
+        //check diags
+        for (Diagnostic<? extends JavaFileObject> diag : diags) {
+            for (DiagnosticProcessor proc : diagProcessors) {
+                if (proc.matches(diag)) {
+                    proc.process(diag);
+                    break;
+                }
+            }
+        }
+        //check all candidates have been used up
+        for (Map.Entry<ElementKey, Candidate> entry : candidatesMap.entrySet()) {
+            if (!seenCandidates.contains(entry.getKey())) {
+                error("Redundant @Candidate annotation on method " + entry.getKey().elem + " sig = " + entry.getKey().elem.asType());
+            }
+        }
+    }
+
+    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+        diags.add(diagnostic);
+    }
+
+    Candidate getCandidateAtPos(Element methodSym, long line, long col) {
+        Candidate c = candidatesMap.get(new ElementKey(methodSym));
+        if (c != null) {
+            Pos pos = c.pos();
+            if (!pos.userDefined() ||
+                    (pos.line() == line && pos.col() == col)) {
+                seenCandidates.add(new ElementKey(methodSym));
+                return c;
+            }
+        } else {
+            error("Missing @Candidate annotation on method " + methodSym);
+        }
+        return null;
+    }
+
+    void checkSig(Candidate c, Element methodSym, MethodType mtype) {
+        if (c.sig().length() > 0 && !c.sig().equals(mtype.toString())) {
+            error("Inferred type mismatch for method: " + methodSym);
+        }
+    }
+
+    protected void error(String msg) {
+        nerrors++;
+        System.err.printf("Error occurred while checking file: %s\nreason: %s\n", jfo.getName(), msg);
+    }
+
+    /**
+     * Base class for diagnostic processor. It provides methods for matching and
+     * processing a given diagnostic object (overridden by subclasses).
+     */
+    abstract class DiagnosticProcessor {
+
+        List<String> codes;
+        Diagnostic.Kind kind;
+
+        public DiagnosticProcessor(Kind kind, String... codes) {
+            this.codes = Arrays.asList(codes);
+            this.kind = kind;
+        }
+
+        abstract void process(Diagnostic<? extends JavaFileObject> diagnostic);
+
+        boolean matches(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return (codes.isEmpty() || codes.contains(diagnostic.getCode())) &&
+                    diagnostic.getKind() == kind;
+        }
+
+        JCDiagnostic asJCDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic instanceof JCDiagnostic) {
+                return (JCDiagnostic)diagnostic;
+            } else if (diagnostic instanceof DiagnosticSourceUnwrapper) {
+                return ((DiagnosticSourceUnwrapper)diagnostic).d;
+            } else {
+                throw new AssertionError("Cannot convert diagnostic to JCDiagnostic: " + diagnostic.getClass().getName());
+            }
+        }
+
+        List<JCDiagnostic> subDiagnostics(Diagnostic<? extends JavaFileObject> diagnostic) {
+            JCDiagnostic diag = asJCDiagnostic(diagnostic);
+            if (diag instanceof JCDiagnostic.MultilineDiagnostic) {
+                return ((JCDiagnostic.MultilineDiagnostic)diag).getSubdiagnostics();
+            } else {
+                throw new AssertionError("Cannot extract subdiagnostics: " + diag.getClass().getName());
+            }
+        }
+    }
+
+    /**
+     * Processor for verbose resolution notes generated by javac. The processor
+     * checks that the diagnostic is associated with a method declared by
+     * a class annotated with the special @TraceResolve marker annotation. If
+     * that's the case, all subdiagnostics (one for each resolution candidate)
+     * are checked against the corresponding @Candidate annotations, using
+     * a VerboseCandidateSubdiagProcessor.
+     */
+    class VerboseResolutionNoteProcessor extends DiagnosticProcessor {
+
+        VerboseResolutionNoteProcessor() {
+            super(Kind.NOTE,
+                    "compiler.note.verbose.resolve.multi",
+                    "compiler.note.verbose.resolve.multi.1");
+        }
+
+        @Override
+        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
+            Element siteSym = getSiteSym(diagnostic);
+            if (siteSym.getSimpleName().length() != 0 &&
+                    ((Symbol)siteSym).outermostClass().getAnnotation(TraceResolve.class) == null) {
+                return;
+            }
+            int candidateIdx = 0;
+            for (JCDiagnostic d : subDiagnostics(diagnostic)) {
+                boolean isMostSpecific = candidateIdx++ == mostSpecific(diagnostic);
+                VerboseCandidateSubdiagProcessor subProc =
+                        new VerboseCandidateSubdiagProcessor(isMostSpecific, phase(diagnostic), success(diagnostic));
+                if (subProc.matches(d)) {
+                    subProc.process(d);
+                } else {
+                    throw new AssertionError("Bad subdiagnostic: " + d.getCode());
+                }
+            }
+        }
+
+        Element getSiteSym(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return (Element)asJCDiagnostic(diagnostic).getArgs()[1];
+        }
+
+        int mostSpecific(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return success(diagnostic) ?
+                    (Integer)asJCDiagnostic(diagnostic).getArgs()[2] : -1;
+        }
+
+        boolean success(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return diagnostic.getCode().equals("compiler.note.verbose.resolve.multi");
+        }
+
+        Phase phase(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return Phase.fromString(asJCDiagnostic(diagnostic).getArgs()[3].toString());
+        }
+    }
+
+    /**
+     * Processor for verbose resolution subdiagnostic notes generated by javac.
+     * The processor checks that the details of the overload candidate
+     * match against the info contained in the corresponding @Candidate
+     * annotation (if any).
+     */
+    class VerboseCandidateSubdiagProcessor extends DiagnosticProcessor {
+
+        boolean mostSpecific;
+        Phase phase;
+        boolean success;
+
+        public VerboseCandidateSubdiagProcessor(boolean mostSpecific, Phase phase, boolean success) {
+            super(Kind.OTHER,
+                    "compiler.misc.applicable.method.found",
+                    "compiler.misc.applicable.method.found.1",
+                    "compiler.misc.not.applicable.method.found");
+            this.mostSpecific = mostSpecific;
+            this.phase = phase;
+            this.success = success;
+        }
+
+        @Override
+        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
+            Symbol methodSym = (Symbol)methodSym(diagnostic);
+            if ((methodSym.flags() & Flags.GENERATEDCONSTR) != 0) {
+                //skip resolution of default constructor (put there by javac)
+                return;
+            }
+            Candidate c = getCandidateAtPos(methodSym,
+                    asJCDiagnostic(diagnostic).getLineNumber(),
+                    asJCDiagnostic(diagnostic).getColumnNumber());
+            if (c == null) {
+                return; //nothing to check
+            }
+
+            if (c.applicable().length == 0 && c.mostSpecific()) {
+                error("Inapplicable method cannot be most specific " + methodSym);
+            }
+
+            if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) {
+                error("Invalid candidate's applicability " + methodSym);
+            }
+
+            if (success) {
+                for (Phase p : c.applicable()) {
+                    if (phase.ordinal() < p.ordinal()) {
+                        error("Invalid phase " + p + " on method " + methodSym);
+                    }
+                }
+            }
+
+            if (Arrays.asList(c.applicable()).contains(phase)) { //applicable
+                if (c.mostSpecific() != mostSpecific) {
+                    error("Invalid most specific value for method " + methodSym + " " + new ElementKey(methodSym).key);
+                }
+                MethodType mtype = getSig(diagnostic);
+                if (mtype != null) {
+                    checkSig(c, methodSym, mtype);
+                }
+            }
+        }
+
+        boolean isApplicable(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return !diagnostic.getCode().equals("compiler.misc.not.applicable.method.found");
+        }
+
+        Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return (Element)asJCDiagnostic(diagnostic).getArgs()[1];
+        }
+
+        MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
+            JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
+            if (details == null) {
+                return null;
+            } else if (details instanceof JCDiagnostic) {
+                return details.getCode().equals("compiler.misc.full.inst.sig") ?
+                        (MethodType)details.getArgs()[0] : null;
+            } else {
+                throw new AssertionError("Bad diagnostic arg: " + details);
+            }
+        }
+    }
+
+    /**
+     * Processor for verbose deferred inference notes generated by javac. The
+     * processor checks that the inferred signature for a given generic method
+     * call corresponds to the one (if any) declared in the @Candidate annotation.
+     */
+    class VerboseDeferredInferenceNoteProcessor extends DiagnosticProcessor {
+
+        public VerboseDeferredInferenceNoteProcessor() {
+            super(Kind.NOTE, "compiler.note.deferred.method.inst");
+        }
+
+        @Override
+        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
+            Element methodSym = methodSym(diagnostic);
+            Candidate c = getCandidateAtPos(methodSym,
+                    asJCDiagnostic(diagnostic).getLineNumber(),
+                    asJCDiagnostic(diagnostic).getColumnNumber());
+            MethodType sig = sig(diagnostic);
+            if (c != null && sig != null) {
+                checkSig(c, methodSym, sig);
+            }
+        }
+
+        Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return (Element)asJCDiagnostic(diagnostic).getArgs()[0];
+        }
+
+        MethodType sig(Diagnostic<? extends JavaFileObject> diagnostic) {
+            return (MethodType)asJCDiagnostic(diagnostic).getArgs()[1];
+        }
+    }
+
+    /**
+     * Processor for all error diagnostics; if the error key is not declared in
+     * the test file header, the processor reports an error.
+     */
+    class ErrorProcessor extends DiagnosticProcessor {
+
+        public ErrorProcessor() {
+            super(Diagnostic.Kind.ERROR);
+        }
+
+        @Override
+        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (!declaredKeys.contains(diagnostic.getCode())) {
+                error("Unexpected compilation error key '" + diagnostic.getCode() + "'");
+            }
+        }
+    }
+
+    @SupportedAnnotationTypes({"Candidate","TraceResolve"})
+    class ResolveCandidateFinder extends JavacTestingAbstractProcessor {
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver())
+                return true;
+
+            TypeElement traceResolveAnno = elements.getTypeElement("TraceResolve");
+            TypeElement candidateAnno = elements.getTypeElement("Candidate");
+
+            if (!annotations.contains(traceResolveAnno)) {
+                error("no @TraceResolve annotation found in test class");
+            }
+
+            if (!annotations.contains(candidateAnno)) {
+                error("no @candidate annotation found in test class");
+            }
+
+            for (Element elem: roundEnv.getElementsAnnotatedWith(traceResolveAnno)) {
+                TraceResolve traceResolve = elem.getAnnotation(TraceResolve.class);
+                declaredKeys.addAll(Arrays.asList(traceResolve.keys()));
+            }
+
+            for (Element elem: roundEnv.getElementsAnnotatedWith(candidateAnno)) {
+                candidatesMap.put(new ElementKey(elem), elem.getAnnotation(Candidate.class));
+            }
+            return true;
+        }
+    }
+
+    class ElementKey {
+
+        String key;
+        Element elem;
+
+        public ElementKey(Element elem) {
+            this.elem = elem;
+            this.key = computeKey(elem);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof ElementKey) {
+                ElementKey other = (ElementKey)obj;
+                return other.key.equals(key);
+            }
+            return false;
+        }
+
+        @Override
+        public int hashCode() {
+            return key.hashCode();
+        }
+
+        String computeKey(Element e) {
+            String simpleName = e.getSimpleName().toString();
+            String opName = predefTranslationMap.get(simpleName);
+            String name = opName != null ? opName : simpleName;
+            return name + e.asType();
+        }
+
+        @Override
+        public String toString() {
+            return "Key{"+key+"}";
+        }
+    }
+
+    class DiagnosticHandler implements DiagnosticListener<JavaFileObject> {
+
+        boolean shouldRecordDiags;
+
+        DiagnosticHandler(boolean shouldRecordDiags) {
+            this.shouldRecordDiags = shouldRecordDiags;
+        }
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (shouldRecordDiags)
+                diags.add(diagnostic);
+        }
+
+    }
+}
diff --git a/test/tools/javac/resolve/TraceResolve.java b/test/tools/javac/resolve/TraceResolve.java
new file mode 100644
index 0000000..ddc8399
--- /dev/null
+++ b/test/tools/javac/resolve/TraceResolve.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, 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.ElementType;
+import java.lang.annotation.Target;
+
+ at Target(ElementType.TYPE)
+ at interface TraceResolve {
+    String[] keys() default {};
+}
diff --git a/test/tools/javac/resolve/tests/AbstractMerge.java b/test/tools/javac/resolve/tests/AbstractMerge.java
new file mode 100644
index 0000000..e6feb08
--- /dev/null
+++ b/test/tools/javac/resolve/tests/AbstractMerge.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+ at TraceResolve
+class AbstractMerge {
+
+    interface A {
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m1();
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m2();
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m3();
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m4();
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m5();
+        @Candidate(applicable=Phase.BASIC)
+        java.io.Serializable m6();
+    }
+
+    interface B {
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m1();
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m2();
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m3();
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m4();
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m5();
+        @Candidate(applicable=Phase.BASIC)
+        Cloneable m6();
+    }
+
+    interface C {
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m1();
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m2();
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m3();
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m4();
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m5();
+        @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+        Object[] m6();
+    }
+
+    interface ABC extends A, B, C { }
+    interface ACB extends A, C, B { }
+    interface BAC extends B, A, C { }
+    interface BCA extends B, C, A { }
+    interface CAB extends C, A, B { }
+    interface CBA extends C, B, A { }
+
+    {
+        ABC abc = null;
+        abc.m1();
+    }
+
+    {
+        ACB acb = null;
+        acb.m2();
+    }
+
+    {
+        BAC bac = null;
+        bac.m3();
+    }
+
+    {
+        BCA bca = null;
+        bca.m4();
+    }
+
+    {
+        CAB cab = null;
+        cab.m5();
+    }
+
+    {
+        CBA cba = null;
+        cba.m6();
+    }
+}
diff --git a/test/tools/javac/resolve/tests/AmbiguityPrecedence.java b/test/tools/javac/resolve/tests/AmbiguityPrecedence.java
new file mode 100644
index 0000000..a0d1b01
--- /dev/null
+++ b/test/tools/javac/resolve/tests/AmbiguityPrecedence.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+ at TraceResolve(keys={"compiler.err.ref.ambiguous"})
+class AmbiguityPrecedence {
+
+    @Candidate(applicable=Phase.BASIC)
+    static void m1(long l, int i) {}
+    @Candidate(applicable=Phase.BASIC)
+    static void m1(int i, long l) {}
+    @Candidate
+    static void m1(Integer i1, Integer i2) {}
+
+    @Candidate(applicable=Phase.BOX)
+    static void m2(Object o, Integer i) {}
+    @Candidate(applicable=Phase.BOX)
+    static void m2(Integer i, Object o) {}
+    @Candidate
+    static void m2(Integer... o) {}
+
+    {
+        m1(1, 1);
+        m2(1, 1);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/BoxedReturnTypeInference.java b/test/tools/javac/resolve/tests/BoxedReturnTypeInference.java
new file mode 100644
index 0000000..dcde256
--- /dev/null
+++ b/test/tools/javac/resolve/tests/BoxedReturnTypeInference.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class BoxedReturnTypeInference {
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true)
+    static <B> B m_byte() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true)
+    static <S> S m_short() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true)
+    static <I> I m_int() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true)
+    static <L> L m_long() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true)
+    static <F> F m_float() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true)
+    static <D> D m_double() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true)
+    static <C> C m_char() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true)
+    static <Z> Z m_bool() { return null; }
+
+    {
+        Byte b = m_byte();
+        Short s = m_short();
+        Integer i = m_int();
+        Long l = m_long();
+        Float f = m_float();
+        Double d = m_double();
+        Character c= m_char();
+        Boolean z = m_bool();
+    }
+}
diff --git a/test/tools/javac/resolve/tests/InnerOverOuter.java b/test/tools/javac/resolve/tests/InnerOverOuter.java
new file mode 100644
index 0000000..9bf72a3
--- /dev/null
+++ b/test/tools/javac/resolve/tests/InnerOverOuter.java
@@ -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.
+ */
+
+ at TraceResolve(keys={"compiler.err.cant.apply.symbol"})
+class Test {
+
+    //no annotation here - this should NOT even be considered!
+    void m(Integer i1, Integer i2) { }
+
+    //no annotation here - this should NOT even be considered!
+    void m(Object... o) { }
+
+    class Inner {
+        @Candidate
+        void m(String s) {
+            m(1, 1); //should fail
+        }
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java b/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java
new file mode 100644
index 0000000..a66da7e
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveBinopOverload.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+ at TraceResolve
+class PrimitiveBinopOverload {
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    int _plus(int x, int y) { return -1; }
+    @Candidate(applicable=Phase.BASIC)
+    long _plus(long x, long y) { return -1; }
+    @Candidate(applicable=Phase.BASIC)
+    float _plus(float x, float y) { return -1; }
+    @Candidate(applicable=Phase.BASIC)
+    double _plus(double x, double y) { return -1; }
+    //not a candidate
+    Object _plus(Object x, Object y) { return -1; }
+
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
+    int _minus(int x, int y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    long _minus(long x, long y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    float _minus(float x, float y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    double _minus(double x, double y) { return -1; }
+
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
+    int _mul(int x, int y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    long _mul(long x, long y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    float _mul(float x, float y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    double _mul(double x, double y) { return -1; }
+
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX }, mostSpecific=true)
+    int _div(int x, int y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    long _div(long x, long y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    float _div(float x, float y) { return -1; }
+    @Candidate(applicable= { Phase.BASIC, Phase.BOX })
+    double _div(double x, double y) { return -1; }
+
+    {
+        int i1 = 1 + 1;
+        int i2 = 5 - new Integer(3);
+        int i3 = new Integer(5) * 3;
+        int i4 = new Integer(6) / new Integer(2);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java
new file mode 100644
index 0000000..843169c
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class PrimitiveOverReference {
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_byte(byte b) {}
+    @Candidate
+    static void m_byte(Byte b) {}
+    @Candidate
+    static <B> void m_byte(B b) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_short(short s) {}
+    @Candidate
+    static void m_short(Short s) {}
+    @Candidate
+    static <S> void m_short(S s) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_int(int i) {}
+    @Candidate
+    static void m_int(Integer i) {}
+    @Candidate
+    static <I> void m_int(I i) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_long(long l) {}
+    @Candidate
+    static void m_long(Long l) {}
+    @Candidate
+    static <L> void m_long(L l) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_float(float f) {}
+    @Candidate
+    static void m_float(Float f) {}
+    @Candidate
+    static <F> void m_float(F f) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_double(double d) {}
+    @Candidate
+    static void m_double(Double d) {}
+    @Candidate
+    static <D> void m_double(D d) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_char(char c) {}
+    @Candidate
+    static void m_char(Character c) {}
+    @Candidate
+    static <C> void m_char(C c) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_bool(boolean z) {}
+    @Candidate
+    static void m_bool(Boolean z) {}
+    @Candidate
+    static <Z> void m_bool(Z z) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+        m_char('?');
+        m_bool(false);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java
new file mode 100644
index 0000000..a07909e
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class PrimitiveOverReference {
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_byte(byte b) {}
+    @Candidate
+    static void m_byte(Byte b) {}
+    @Candidate
+    static void m_byte(byte... b) {}
+    @Candidate
+    static void m_byte(Byte... b) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_short(short s) {}
+    @Candidate
+    static void m_short(Short s) {}
+    @Candidate
+    static void m_short(short... s) {}
+    @Candidate
+    static void m_short(Short... s) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_int(int i) {}
+    @Candidate
+    static void m_int(Integer i) {}
+    @Candidate
+    static void m_int(int... i) {}
+    @Candidate
+    static void m_int(Integer... i) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_long(long l) {}
+    @Candidate
+    static void m_long(Long l) {}
+    @Candidate
+    static void m_long(long... l) {}
+    @Candidate
+    static void m_long(Long... l) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_float(float f) {}
+    @Candidate
+    static void m_float(Float f) {}
+    @Candidate
+    static void m_float(float... f) {}
+    @Candidate
+    static void m_float(Float... f) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_double(double d) {}
+    @Candidate
+    static void m_double(Double d) {}
+    @Candidate
+    static void m_double(double... d) {}
+    @Candidate
+    static void m_double(Double... d) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_char(char c) {}
+    @Candidate
+    static void m_char(Character c) {}
+    @Candidate
+    static void m_char(char... c) {}
+    @Candidate
+    static void m_char(Character... c) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_bool(boolean z) {}
+    @Candidate
+    static void m_bool(Boolean z) {}
+    @Candidate
+    static void m_bool(boolean... z) {}
+    @Candidate
+    static void m_bool(Boolean... z) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+        m_char('?');
+        m_bool(false);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java
new file mode 100644
index 0000000..7d2a240
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve(keys={"compiler.err.ref.ambiguous"})
+class PrimitiveOverReferenceVarargsAmbiguous {
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_byte(byte... b) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_byte(Byte... b) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_short(short... s) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_short(Short... s) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_int(int... i) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_int(Integer... i) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_long(long... l) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_long(Long... l) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_float(float... f) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_float(Float... f) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_double(double... d) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_double(Double... d) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_char(char... c) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_char(Character... c) {}
+
+    @Candidate(applicable=Phase.VARARGS, mostSpecific=true)
+    static void m_bool(boolean... z) {}
+    @Candidate(applicable=Phase.VARARGS)
+    static void m_bool(Boolean... z) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+        m_char('?');
+        m_bool(false);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveOverload.java b/test/tools/javac/resolve/tests/PrimitiveOverload.java
new file mode 100644
index 0000000..752b697
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveOverload.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class PrimitiveOverload {
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_byte(byte b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_byte(short b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_byte(int b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_byte(long b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_byte(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_byte(double b) {}
+
+    @Candidate
+    static void m_short(byte b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_short(short b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_short(int b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_short(long b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_short(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_short(double b) {}
+
+    @Candidate
+    static void m_int(byte b) {}
+    @Candidate
+    static void m_int(short b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_int(int b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_int(long b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_int(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_int(double b) {}
+
+    @Candidate
+    static void m_long(byte b) {}
+    @Candidate
+    static void m_long(short b) {}
+    @Candidate
+    static void m_long(int b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_long(long b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_long(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_long(double b) {}
+
+    @Candidate
+    static void m_float(byte b) {}
+    @Candidate
+    static void m_float(short b) {}
+    @Candidate
+    static void m_float(int b) {}
+    @Candidate
+    static void m_float(long b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_float(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_float(double b) {}
+
+    @Candidate
+    static void m_double(byte b) {}
+    @Candidate
+    static void m_double(short b) {}
+    @Candidate
+    static void m_double(int b) {}
+    @Candidate
+    static void m_double(long b) {}
+    @Candidate
+    static void m_double(float b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_double(double b) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java b/test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java
new file mode 100644
index 0000000..04a1506
--- /dev/null
+++ b/test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class PrimitiveReturnTypeInference {
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true)
+    static <B> B m_byte() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true)
+    static <S> S m_short() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true)
+    static <I> I m_int() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true)
+    static <L> L m_long() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true)
+    static <F> F m_float() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true)
+    static <D> D m_double() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true)
+    static <C> C m_char() { return null; }
+
+    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true)
+    static <Z> Z m_bool() { return null; }
+
+    {
+        byte b = m_byte();
+        short s = m_short();
+        int i = m_int();
+        long l = m_long();
+        float f = m_float();
+        double d = m_double();
+        char c= m_char();
+        boolean z = m_bool();
+    }
+}
diff --git a/test/tools/javac/resolve/tests/ReferenceOverInferred.java b/test/tools/javac/resolve/tests/ReferenceOverInferred.java
new file mode 100644
index 0000000..ed68773
--- /dev/null
+++ b/test/tools/javac/resolve/tests/ReferenceOverInferred.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class PrimitiveOverInferred {
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_byte(Byte b) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Byte)void")
+    static <B> void m_byte(B b) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_short(Short s) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Short)void")
+    static <S> void m_short(S s) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_int(Integer i) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Integer)void")
+    static <I> void m_int(I i) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_long(Long l) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Long)void")
+    static <L> void m_long(L l) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_float(Float f) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Float)void")
+    static <F> void m_float(F f) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_double(Double d) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Double)void")
+    static <D> void m_double(D d) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_char(Character c) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Character)void")
+    static <C> void m_char(C c) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_bool(Boolean z) {}
+    @Candidate(applicable=Phase.BOX, sig="(java.lang.Boolean)void")
+    static <Z> void m_bool(Z z) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+        m_char('?');
+        m_bool(false);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/ReferenceOverVarargs.java b/test/tools/javac/resolve/tests/ReferenceOverVarargs.java
new file mode 100644
index 0000000..c089e2d
--- /dev/null
+++ b/test/tools/javac/resolve/tests/ReferenceOverVarargs.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class ReferenceOverVarargs {
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_byte(Byte b) {}
+    @Candidate
+    static void m_byte(byte... b) {}
+    @Candidate
+    static void m_byte(Byte... b) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_short(Short s) {}
+    @Candidate
+    static void m_short(short... s) {}
+    @Candidate
+    static void m_short(Short... s) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_int(Integer i) {}
+    @Candidate
+    static void m_int(int... i) {}
+    @Candidate
+    static void m_int(Integer... i) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_long(Long l) {}
+    @Candidate
+    static void m_long(long... l) {}
+    @Candidate
+    static void m_long(Long... l) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_float(Float f) {}
+    @Candidate
+    static void m_float(float... f) {}
+    @Candidate
+    static void m_float(Float... f) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_double(Double d) {}
+    @Candidate
+    static void m_double(double... d) {}
+    @Candidate
+    static void m_double(Double... d) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_char(Character c) {}
+    @Candidate
+    static void m_char(char... c) {}
+    @Candidate
+    static void m_char(Character... c) {}
+
+    @Candidate(applicable=Phase.BOX, mostSpecific=true)
+    static void m_bool(Boolean z) {}
+    @Candidate
+    static void m_bool(boolean... z) {}
+    @Candidate
+    static void m_bool(Boolean... z) {}
+
+    {
+        m_byte((byte)0);
+        m_short((short)0);
+        m_int(0);
+        m_long(0L);
+        m_float(0.0f);
+        m_double(0.0);
+        m_char('?');
+        m_bool(false);
+    }
+}
diff --git a/test/tools/javac/resolve/tests/ReferenceOverload.java b/test/tools/javac/resolve/tests/ReferenceOverload.java
new file mode 100644
index 0000000..578bc51
--- /dev/null
+++ b/test/tools/javac/resolve/tests/ReferenceOverload.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+ at TraceResolve
+class ReferenceOverload {
+
+    static class A {}
+    static class B extends A {}
+    static class C extends B {}
+    static class D extends C {}
+    static class E extends D {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_A(A a) {}
+    @Candidate
+    static void m_A(B a) {}
+    @Candidate
+    static void m_A(C a) {}
+    @Candidate
+    static void m_A(D a) {}
+    @Candidate
+    static void m_A(E a) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_B(A b) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_B(B b) {}
+    @Candidate
+    static void m_B(C b) {}
+    @Candidate
+    static void m_B(D b) {}
+    @Candidate
+    static void m_B(E b) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_C(A c) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_C(B c) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_C(C c) {}
+    @Candidate
+    static void m_C(D c) {}
+    @Candidate
+    static void m_C(E c) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_D(A d) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_D(B d) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_D(C d) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_D(D d) {}
+    @Candidate
+    static void m_D(E d) {}
+
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_E(A e) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_E(B e) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_E(C e) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
+    static void m_E(D e) {}
+    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
+    static void m_E(E e) {}
+
+    {
+        m_A((A)null);
+        m_B((B)null);
+        m_C((C)null);
+        m_D((D)null);
+        m_E((E)null);
+    }
+}
diff --git a/test/tools/javac/scope/7017664/CompoundScopeTest.java b/test/tools/javac/scope/7017664/CompoundScopeTest.java
index eda1836..075a750 100644
--- a/test/tools/javac/scope/7017664/CompoundScopeTest.java
+++ b/test/tools/javac/scope/7017664/CompoundScopeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -147,7 +147,7 @@ public class CompoundScopeTest {
         Scope createScope(int nelems) {
             Scope s = new Scope(symtab.noSymbol);
             for (int i = 0 ; i < nelems ; i++) {
-                Symbol sym = new TypeSymbol(0, names.fromString("s" + i), null, null);
+                Symbol sym = new TypeVariableSymbol(0, names.fromString("s" + i), null, null);
                 s.enter(sym);
                 elems = elems.prepend(sym);
                 List<Symbol> shadowed = shadowedMap.get(sym.name);
diff --git a/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java b/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java
index 231355f..304f858 100644
--- a/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java
+++ b/test/tools/javac/scope/7046348/EagerInterfaceCompletionTest.java
@@ -30,6 +30,7 @@
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.List;
 
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
@@ -43,13 +44,15 @@ public class EagerInterfaceCompletionTest {
 
     JavaCompiler javacTool;
     File testDir;
+    VersionKind versionKind;
     HierarchyKind hierarchyKind;
     TestKind testKind;
     ActionKind actionKind;
 
-    EagerInterfaceCompletionTest(JavaCompiler javacTool, File testDir,
+    EagerInterfaceCompletionTest(JavaCompiler javacTool, File testDir, VersionKind versionKind,
             HierarchyKind hierarchyKind, TestKind testKind, ActionKind actionKind) {
         this.javacTool = javacTool;
+        this.versionKind = versionKind;
         this.hierarchyKind = hierarchyKind;
         this.testDir = testDir;
         this.testKind = testKind;
@@ -62,7 +65,7 @@ public class EagerInterfaceCompletionTest {
         actionKind.doAction(this);
         DiagnosticChecker dc = new DiagnosticChecker();
         compile(dc, testKind.source);
-        if (testKind.completionFailure(actionKind, hierarchyKind) != dc.errorFound) {
+        if (testKind.completionFailure(versionKind, actionKind, hierarchyKind) != dc.errorFound) {
             if (dc.errorFound) {
                 error("Unexpected completion failure" +
                       "\nhierarhcyKind " + hierarchyKind +
@@ -80,7 +83,8 @@ public class EagerInterfaceCompletionTest {
     void compile(DiagnosticChecker dc, JavaSource... sources) {
         try {
             CompilationTask ct = javacTool.getTask(null, null, dc,
-                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp", testDir.getAbsolutePath()),
+                    Arrays.asList("-d", testDir.getAbsolutePath(), "-cp",
+                    testDir.getAbsolutePath(), versionKind.optsArr[0], versionKind.optsArr[1]),
                     null, Arrays.asList(sources));
             ct.call();
         }
@@ -108,12 +112,25 @@ public class EagerInterfaceCompletionTest {
         boolean errorFound = false;
 
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-            errorFound = true;
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
         }
     }
 
     //global declarations
 
+    enum VersionKind {
+        PRE_LAMBDA("-source", "7"),
+        LAMBDA("-source", "8");
+
+        String[] optsArr;
+
+        VersionKind(String... optsArr) {
+            this.optsArr = optsArr;
+        }
+    }
+
     enum HierarchyKind {
         INTERFACE("interface A { boolean f = false; void m(); }\n" +
                   "class B implements A { public void m() {} }"),
@@ -157,13 +174,14 @@ public class EagerInterfaceCompletionTest {
             this.source = new JavaSource("Test2.java", code);
         }
 
-        boolean completionFailure(ActionKind ak, HierarchyKind hk) {
+        boolean completionFailure(VersionKind vk, ActionKind ak, HierarchyKind hk) {
             switch (this) {
                 case ACCESS_ONLY:
                 case CONSTR: return ak == ActionKind.REMOVE_B;
                 case FIELD:
                 case SUPER: return true;
-                case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B;
+                case METHOD: return hk != HierarchyKind.INTERFACE || ak == ActionKind.REMOVE_B ||
+                        (hk == HierarchyKind.INTERFACE && ak == ActionKind.REMOVE_A && vk == VersionKind.LAMBDA);
                 default: throw new AssertionError("Unexpected test kind " + this);
             }
         }
@@ -173,12 +191,15 @@ public class EagerInterfaceCompletionTest {
         String SCRATCH_DIR = System.getProperty("user.dir");
         JavaCompiler javacTool = ToolProvider.getSystemJavaCompiler();
         int n = 0;
-        for (HierarchyKind hierarchyKind : HierarchyKind.values()) {
-            for (TestKind testKind : TestKind.values()) {
-                for (ActionKind actionKind : ActionKind.values()) {
-                    File testDir = new File(SCRATCH_DIR, "test"+n);
-                    new EagerInterfaceCompletionTest(javacTool, testDir, hierarchyKind, testKind, actionKind).test();
-                    n++;
+        for (VersionKind versionKind : VersionKind.values()) {
+            for (HierarchyKind hierarchyKind : HierarchyKind.values()) {
+                for (TestKind testKind : TestKind.values()) {
+                    for (ActionKind actionKind : ActionKind.values()) {
+                        File testDir = new File(SCRATCH_DIR, "test"+n);
+                        new EagerInterfaceCompletionTest(javacTool, testDir, versionKind,
+                                hierarchyKind, testKind, actionKind).test();
+                        n++;
+                    }
                 }
             }
         }
diff --git a/test/tools/javac/stackmap/StackMapTest.java b/test/tools/javac/stackmap/StackMapTest.java
new file mode 100644
index 0000000..8a07845
--- /dev/null
+++ b/test/tools/javac/stackmap/StackMapTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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 4955930
+ * @summary The "method0" StackMap attribute should have two entries instead of three
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -source 6 -target 6 StackMapTest.java
+ * @run main StackMapTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/stackmap/T4955930.sh
+public class StackMapTest {
+
+    class Test {
+        void method0(boolean aboolean) throws Exception {
+            label_0:
+            while (true) {
+                if (aboolean) ;
+                else break label_0;
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+//    "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
+
+//    "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
+        Path pathToClass = Paths.get(System.getProperty("test.classes"),
+                "StackMapTest$Test.class");
+        ToolBox.JavaToolArgs javapArgs =
+                new ToolBox.JavaToolArgs().setAllArgs("-v", pathToClass.toString());
+
+//        grep "StackMapTable: number_of_entries = 2" ${TMP1}
+        if (!ToolBox.javap(javapArgs).contains("StackMapTable: number_of_entries = 2"))
+            throw new AssertionError("The number of entries of the stack map "
+                    + "table should be equal to 2");
+    }
+
+}
diff --git a/test/tools/javac/stackmap/T4955930.java b/test/tools/javac/stackmap/T4955930.java
deleted file mode 100644
index 65022eb..0000000
--- a/test/tools/javac/stackmap/T4955930.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2005, 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 4955930
- * @summary The "method0" StackMap attribute should have two entries instead of three
- * @author wtao
- *
- * @run shell T4955930.sh
- */
-
-public class T4955930 {
-
-   void method0(boolean aboolean) throws Exception {
-      label_0:
-      while (true) {
-         if (aboolean) {
-            ;
-         }
-         else {
-            break label_0;
-         }
-         System.out.println("");
-      }
-   }
-}
diff --git a/test/tools/javac/stackmap/T4955930.sh b/test/tools/javac/stackmap/T4955930.sh
deleted file mode 100644
index 731ce80..0000000
--- a/test/tools/javac/stackmap/T4955930.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows_95 | Windows_98 | Windows_NT )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=T4955930.javap
-
-cp "${TESTSRC}${FS}T4955930.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
-result=$?
-if [ $result -ne 0 ]
-then
-    exit $result
-fi
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
-grep "StackMapTable: number_of_entries = 2" ${TMP1}
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javac/tree/AbstractTreeScannerTest.java b/test/tools/javac/tree/AbstractTreeScannerTest.java
index b0fe687..1d5ec84 100644
--- a/test/tools/javac/tree/AbstractTreeScannerTest.java
+++ b/test/tools/javac/tree/AbstractTreeScannerTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, 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
@@ -274,7 +274,7 @@ public abstract class AbstractTreeScannerTest {
         return fields;
     }
     // where
-    Map<Integer, Set<Field>> map = new HashMap<Integer,Set<Field>>();
+    Map<JCTree.Tag, Set<Field>> map = new HashMap<JCTree.Tag,Set<Field>>();
 
     /** Get the line number for the primary position for a tree.
      * The code is intended to be simple, although not necessarily efficient.
diff --git a/test/tools/javac/tree/DocCommentToplevelTest.java b/test/tools/javac/tree/DocCommentToplevelTest.java
new file mode 100644
index 0000000..2908a22
--- /dev/null
+++ b/test/tools/javac/tree/DocCommentToplevelTest.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7096014
+ * @summary Javac tokens should retain state
+ */
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import com.sun.tools.javac.tree.DocCommentTable;
+import com.sun.tools.javac.tree.JCTree;
+
+import java.net.URI;
+import java.util.*;
+import javax.tools.*;
+
+
+public class DocCommentToplevelTest {
+
+    enum PackageKind {
+        HAS_PKG("package pkg;"),
+        NO_PKG("");
+
+        String pkgStr;
+
+        PackageKind(String pkgStr) {
+            this.pkgStr = pkgStr;
+        }
+    }
+
+    enum ImportKind {
+        ZERO(""),
+        ONE("import java.lang.*;"),
+        TWO("import java.lang.*; import java.util.*;");
+
+        String importStr;
+
+        ImportKind(String importStr) {
+            this.importStr = importStr;
+        }
+    }
+
+    enum ModifierKind {
+        DEFAULT(""),
+        PUBLIC("public");
+
+        String modStr;
+
+        ModifierKind(String modStr) {
+            this.modStr = modStr;
+        }
+    }
+
+    enum ToplevelDocKind {
+        HAS_DOC("/** Toplevel! */"),
+        NO_DOC("");
+
+        String docStr;
+
+        ToplevelDocKind(String docStr) {
+            this.docStr = docStr;
+        }
+    }
+
+    static int errors;
+    static int checks;
+
+    public static void main(String... args) throws Exception {
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (PackageKind pk : PackageKind.values()) {
+            for (ImportKind ik : ImportKind.values()) {
+                for (ModifierKind mk1 : ModifierKind.values()) {
+                    for (ModifierKind mk2 : ModifierKind.values()) {
+                        for (ToplevelDocKind tdk : ToplevelDocKind.values()) {
+                            new DocCommentToplevelTest(pk, ik, mk1, mk2, tdk).run(comp, fm);
+                        }
+                    }
+                }
+            }
+        }
+
+        if (errors > 0)
+            throw new AssertionError(errors + " errors found");
+
+        System.out.println(checks + " checks were made");
+    }
+
+    PackageKind pk;
+    ImportKind ik;
+    ModifierKind mk1;
+    ModifierKind mk2;
+    ToplevelDocKind tdk;
+    JavaSource source;
+
+    DocCommentToplevelTest(PackageKind pk, ImportKind ik, ModifierKind mk1, ModifierKind mk2, ToplevelDocKind tdk) {
+        this.pk = pk;
+        this.ik = ik;
+        this.mk1 = mk1;
+        this.mk2 = mk2;
+        this.tdk = tdk;
+        source = new JavaSource();
+    }
+
+    void run(JavaCompiler comp, JavaFileManager fm) throws Exception {
+        JavacTask task = (JavacTask)comp.getTask(null, fm, null, Arrays.asList("-printsource"), null, Arrays.asList(source));
+        for (CompilationUnitTree cu: task.parse()) {
+            check(cu);
+        }
+    }
+
+    void check(CompilationUnitTree cu) {
+        checks++;
+
+        new TreeScanner<ClassTree,Void>() {
+
+            DocCommentTable docComments;
+
+            @Override
+            public ClassTree visitCompilationUnit(CompilationUnitTree node, Void unused) {
+                docComments = ((JCTree.JCCompilationUnit)node).docComments;
+                boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC &&
+                        (pk != PackageKind.NO_PKG || ik != ImportKind.ZERO);
+                boolean foundComment = docComments.hasComment((JCTree) node);
+                if (expectedComment != foundComment) {
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on toplevel");
+                }
+                return super.visitCompilationUnit(node, null);
+            }
+
+            @Override
+            public ClassTree visitClass(ClassTree node, Void unused) {
+                boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC &&
+                        pk == PackageKind.NO_PKG && ik == ImportKind.ZERO &&
+                        node.getSimpleName().toString().equals("First");
+                boolean foundComment = docComments.hasComment((JCTree) node);
+                if (expectedComment != foundComment) {
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on class " + node.getSimpleName());
+                }
+                return super.visitClass(node, unused);
+            }
+        }.scan(cu, null);
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        System.err.println("Source: " + source.source);
+        errors++;
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "#D\n#P\n#I\n" +
+                          "#M1 class First { }\n" +
+                          "#M2 class Second { }\n";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replace("#P", pk.pkgStr)
+                             .replace("#I", ik.importStr)
+                             .replace("#M1", mk1.modStr)
+                             .replace("#M2", mk2.modStr)
+                             .replace("#D", tdk.docStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
diff --git a/test/tools/javac/tree/MakeLiteralTest.java b/test/tools/javac/tree/MakeLiteralTest.java
index c205bf7..782a2cd 100644
--- a/test/tools/javac/tree/MakeLiteralTest.java
+++ b/test/tools/javac/tree/MakeLiteralTest.java
@@ -1,7 +1,5 @@
-
-
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -30,13 +28,14 @@
  */
 
 import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.TypeTag;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.tree.JCTree.JCLiteral;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.tree.TreeMaker;
-import static com.sun.tools.javac.code.TypeTags.*;
+import static com.sun.tools.javac.code.TypeTag.*;
 
 public class MakeLiteralTest {
     public static void main(String... args) throws Exception {
@@ -65,9 +64,9 @@ public class MakeLiteralTest {
             throw new Exception(errors + " errors found");
     }
 
-    void test(Object value, int tag, Type type, Object constValue) {
+    void test(Object value, TypeTag tag, Type type, Object constValue) {
         JCLiteral l = maker.Literal(value);
-        if (l.type.tag != tag)
+        if (!l.type.hasTag(tag))
             error("unexpected tag: " + l.getTag() + ": expected: " + tag);
         if (!types.isSameType(l.type, type))
             error("unexpected type: " + l.type + ": expected: " + type);
diff --git a/test/tools/javac/tree/PrettySimpleStringTest.java b/test/tools/javac/tree/PrettySimpleStringTest.java
new file mode 100644
index 0000000..2678830
--- /dev/null
+++ b/test/tools/javac/tree/PrettySimpleStringTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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 8006033
+ * @summary bug in Pretty.toSimpleString
+ */
+
+import java.io.File;
+
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.Pretty;
+
+public class PrettySimpleStringTest {
+    public static void main(String... args) throws Exception {
+        new PrettySimpleStringTest().run();
+    }
+
+    void run() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File thisFile = new File(testSrc, getClass().getName() + ".java");
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        JavacTask task = tool.getTask(null, fm, null, null, null,
+                fm.getJavaFileObjects(thisFile));
+        Iterable<? extends CompilationUnitTree> trees = task.parse();
+        CompilationUnitTree thisTree = trees.iterator().next();
+
+        {   // test default
+            String thisSrc = Pretty.toSimpleString((JCTree) thisTree);
+            System.err.println(thisSrc);
+            String expect = "import jav[...]} } }";
+            if (!thisSrc.equals(expect)) {
+                throw new Exception("unexpected result");
+            }
+        }
+
+        {   // test explicit length
+            String thisSrc = Pretty.toSimpleString((JCTree) thisTree, 32);
+            System.err.println(thisSrc);
+            String expect = "import java.io.Fil[...]; } } } }";
+            if (!thisSrc.equals(expect)) {
+                throw new Exception("unexpected result");
+            }
+        }
+    }
+}
diff --git a/test/tools/javac/tree/SourceTreeScannerTest.java b/test/tools/javac/tree/SourceTreeScannerTest.java
index a719202..e4cc3f8 100644
--- a/test/tools/javac/tree/SourceTreeScannerTest.java
+++ b/test/tools/javac/tree/SourceTreeScannerTest.java
@@ -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
diff --git a/test/tools/javac/tree/TestToString.java b/test/tools/javac/tree/TestToString.java
new file mode 100644
index 0000000..d5644bc
--- /dev/null
+++ b/test/tools/javac/tree/TestToString.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2011, 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 7080267
+ * @summary Call to toString() from an ExpressionStatementTree doesn't take in
+ *      consideration the ";" at the end
+ */
+
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.api.JavacTool;
+
+public class TestToString {
+    String[] statements = {
+        "i = i + 1;",
+        "i++;",
+        "m();",
+        ";",
+        "if (i == 0) return;",
+        "while (i > 0) i--;",
+        "{ }",
+        "{ i++; }",
+        "class C { }"
+    };
+
+    public static void main(String... args) throws Exception {
+        new TestToString().run();
+    }
+
+    void run() throws Exception {
+        for (String s: statements) {
+            test(s);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test(String stmt) throws IOException {
+        System.err.println("Test: " + stmt);
+        List<String> options = Collections.<String>emptyList();
+        List<? extends JavaFileObject> files = Arrays.asList(new JavaSource(stmt));
+        JavacTask t = tool.getTask(null, fm, null, options, null, files);
+        checkEqual(scan(t.parse()), stmt);
+    }
+
+    String scan(Iterable<? extends CompilationUnitTree> trees) {
+        class Scanner extends TreeScanner<Void,StringBuilder> {
+            String scan(Iterable<? extends Tree> trees) {
+                StringBuilder sb = new StringBuilder();
+                scan(trees, sb);
+                return sb.toString();
+            }
+            @Override
+            public Void scan(Tree tree, StringBuilder sb) {
+                if (print && tree instanceof StatementTree) {
+                    sb.append(PREFIX);
+                    sb.append(tree);
+                    sb.append(SUFFIX);
+                    return null;
+                } else {
+                    return super.scan(tree, sb);
+                }
+            }
+            @Override
+            public Void visitBlock(BlockTree tree, StringBuilder sb) {
+                print = true;
+                try {
+                    return super.visitBlock(tree, sb);
+                } finally {
+                    print = false;
+                }
+            }
+            boolean print = false;
+        }
+        return new Scanner().scan(trees);
+    }
+
+    void checkEqual(String found, String expect) {
+        boolean match = (found == null) ? (expect == null) :
+            expect.equals(found
+                .replaceAll("^\\Q" + PREFIX + "\\E\\s*", "")
+                .replaceAll("\\s*\\Q" + SUFFIX + "\\E$", "")
+                .replaceAll("\\s+", " "));
+
+        if (!match)
+            error("Mismatch: expected: " + expect + " found: " + found);
+    }
+
+
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    static final String PREFIX = "#<";
+    static final String SUFFIX = "#>";
+
+    JavacTool tool = JavacTool.create();
+    StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+    int errors = 0;
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        String source =
+                "class Test {\n" +
+                "    int i;\n" +
+                "    void m() {\n" +
+                "        #S\n" +
+                "    }\n" +
+                "}";
+
+        public JavaSource(String stmt) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = source.replace("#S", stmt);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
diff --git a/test/tools/javac/tree/TreeKindTest.java b/test/tools/javac/tree/TreeKindTest.java
index 608c45a..8497308 100644
--- a/test/tools/javac/tree/TreeKindTest.java
+++ b/test/tools/javac/tree/TreeKindTest.java
@@ -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
@@ -29,7 +29,7 @@
 
 import com.sun.source.tree.*;
 
-public class TreeKindTest{
+public class TreeKindTest {
     public static void main(String... args) {
         boolean ok = true;
 
@@ -108,6 +108,11 @@ public class TreeKindTest{
                 ok = ok & verify(k, i, i == ClassTree.class);
                 break;
 
+            case ANNOTATION:
+            case TYPE_ANNOTATION:
+                ok = ok & verify(k, i, i == AnnotationTree.class);
+                break;
+
             case OTHER:
                 ok = ok & verify(k, i, i == null);
                 break;
diff --git a/test/tools/javac/tree/TreePosTest.java b/test/tools/javac/tree/TreePosTest.java
index bb6e466..8fed3e5 100644
--- a/test/tools/javac/tree/TreePosTest.java
+++ b/test/tools/javac/tree/TreePosTest.java
@@ -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
@@ -73,13 +73,16 @@ import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCAnnotatedType;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCNewClass;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeScanner;
 
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.util.Position.NOPOS;
 
 /**
@@ -98,7 +101,8 @@ import static com.sun.tools.javac.util.Position.NOPOS;
  * @test
  * @bug 6919889
  * @summary assorted position errors in compiler syntax trees
- * @run main TreePosTest -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
+ * OLD: -q -r -ef ./tools/javac/typeAnnotations -ef ./tools/javap/typeAnnotations -et ANNOTATED_TYPE .
+ * @run main TreePosTest -q -r .
  */
 public class TreePosTest {
     /**
@@ -291,6 +295,14 @@ public class TreePosTest {
         errors++;
     }
 
+    /**
+     * Names for tree tags.
+     */
+    private static String getTagName(JCTree.Tag tag) {
+        String name = tag.name();
+        return (name == null) ? "??" : name;
+    }
+
     /** Number of files that have been analyzed. */
     int fileCount;
     /** Number of errors reported. */
@@ -312,8 +324,6 @@ public class TreePosTest {
     Set<File> excludeFiles = new HashSet<File>();
     /** Set of tag names to be excluded from analysis. */
     Set<String> excludeTags = new HashSet<String>();
-    /** Table of printable names for tree tag values. */
-    TagNames tagNames = new TagNames();
 
     /**
      * Main class for testing assertions concerning tree positions for tree nodes.
@@ -337,7 +347,7 @@ public class TreePosTest {
                 // there is no corresponding source text.
                 // Redundant semicolons in a class definition can cause empty
                 // initializer blocks with no positions.
-                if ((self.tag == JCTree.MODIFIERS || self.tag == JCTree.BLOCK)
+                if ((self.tag == MODIFIERS || self.tag == BLOCK)
                         && self.pos == NOPOS) {
                     // If pos is NOPOS, so should be the start and end positions
                     check("start == NOPOS", encl, self, self.start == NOPOS);
@@ -359,15 +369,24 @@ public class TreePosTest {
                     //    e.g.    int[][] a = new int[2][];
                     check("encl.start <= start", encl, self, encl.start <= self.start);
                     check("start <= pos", encl, self, self.start <= self.pos);
-                    if (!(self.tag == JCTree.TYPEARRAY
-                            && (encl.tag == JCTree.VARDEF ||
-                                encl.tag == JCTree.METHODDEF ||
-                                encl.tag == JCTree.TYPEARRAY))) {
+                    if (!( (self.tag == TYPEARRAY ||
+                            isAnnotatedArray(self.tree))
+                            && (encl.tag == VARDEF ||
+                                encl.tag == METHODDEF ||
+                                encl.tag == TYPEARRAY ||
+                                isAnnotatedArray(encl.tree))
+                           ||
+                            encl.tag == ANNOTATED_TYPE && self.tag == SELECT
+                         )) {
                         check("encl.pos <= start || end <= encl.pos",
                                 encl, self, encl.pos <= self.start || self.end <= encl.pos);
                     }
                     check("pos <= end", encl, self, self.pos <= self.end);
-                    if (!(self.tag == JCTree.TYPEARRAY && encl.tag == JCTree.TYPEARRAY)) {
+                    if (!( (self.tag == TYPEARRAY || isAnnotatedArray(self.tree)) &&
+                            (encl.tag == TYPEARRAY || isAnnotatedArray(encl.tree))
+                           ||
+                            encl.tag == MODIFIERS && self.tag == ANNOTATION
+                         ) ) {
                         check("end <= encl.end", encl, self, self.end <= encl.end);
                     }
                 }
@@ -379,6 +398,11 @@ public class TreePosTest {
             encl = prevEncl;
         }
 
+        private boolean isAnnotatedArray(JCTree tree) {
+            return tree.hasTag(ANNOTATED_TYPE) &&
+                            ((JCAnnotatedType)tree).underlyingType.hasTag(TYPEARRAY);
+        }
+
         @Override
         public void visitVarDef(JCVariableDecl tree) {
             // enum member declarations are desugared in the parser and have
@@ -388,7 +412,7 @@ public class TreePosTest {
             if ((tree.mods.flags & Flags.ENUM) != 0) {
                 scan(tree.mods);
                 if (tree.init != null) {
-                    if (tree.init.getTag() == JCTree.NEWCLASS) {
+                    if (tree.init.hasTag(NEWCLASS)) {
                         JCNewClass init = (JCNewClass) tree.init;
                         if (init.args != null && init.args.nonEmpty()) {
                             scan(init.args);
@@ -404,11 +428,11 @@ public class TreePosTest {
 
         boolean check(Info encl, Info self) {
             if (excludeTags.size() > 0) {
-                if (encl != null && excludeTags.contains(tagNames.get(encl.tag))
-                        || excludeTags.contains(tagNames.get(self.tag)))
+                if (encl != null && excludeTags.contains(getTagName(encl.tag))
+                        || excludeTags.contains(getTagName(self.tag)))
                     return false;
             }
-            return tags.size() == 0 || tags.contains(tagNames.get(self.tag));
+            return tags.size() == 0 || tags.contains(getTagName(self.tag));
         }
 
         void check(String label, Info encl, Info self, boolean ok) {
@@ -419,7 +443,8 @@ public class TreePosTest {
                     viewer.addEntry(sourcefile, label, encl, self);
                 }
 
-                String s = self.tree.toString();
+                String s = "encl: " + encl.tree.toString() +
+                        "  this: " + self.tree.toString();
                 String msg = sourcefile.getName() + ": " + label + ": " +
                         "encl:" + encl + " this:" + self + "\n" +
                         s.substring(0, Math.min(80, s.length())).replaceAll("[\r\n]+", " ");
@@ -428,7 +453,7 @@ public class TreePosTest {
         }
 
         JavaFileObject sourcefile;
-        Map<JCTree, Integer> endPosTable;
+        EndPosTable endPosTable;
         Info encl;
 
     }
@@ -439,13 +464,13 @@ public class TreePosTest {
     private class Info {
         Info() {
             tree = null;
-            tag = JCTree.ERRONEOUS;
+            tag = ERRONEOUS;
             start = 0;
             pos = 0;
             end = Integer.MAX_VALUE;
         }
 
-        Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
+        Info(JCTree tree, EndPosTable endPosTable) {
             this.tree = tree;
             tag = tree.getTag();
             start = TreeInfo.getStartPos(tree);
@@ -455,46 +480,17 @@ public class TreePosTest {
 
         @Override
         public String toString() {
-            return tagNames.get(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]";
+            return getTagName(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]";
         }
 
         final JCTree tree;
-        final int tag;
+        final JCTree.Tag tag;
         final int start;
         final int pos;
         final int end;
     }
 
     /**
-     * Names for tree tags.
-     * javac does not provide an API to convert tag values to strings, so this class uses
-     * reflection to determine names of public static final int values in JCTree.
-     */
-    private static class TagNames {
-        String get(int tag) {
-            if (map == null) {
-                map = new HashMap<Integer, String>();
-                Class c = JCTree.class;
-                for (Field f : c.getDeclaredFields()) {
-                    if (f.getType().equals(int.class)) {
-                        int mods = f.getModifiers();
-                        if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
-                            try {
-                                map.put(f.getInt(null), f.getName());
-                            } catch (IllegalAccessException e) {
-                            }
-                        }
-                    }
-                }
-            }
-            String name = map.get(tag);
-            return (name == null) ? "??" : name;
-        }
-
-        private Map<Integer, String> map;
-    }
-
-    /**
      * Thrown when errors are found parsing a java file.
      */
     private static class ParseException extends Exception {
@@ -719,7 +715,7 @@ public class TreePosTest {
 
             void setInfo(Info info) {
                 this.info = info;
-                tagName.setText(tagNames.get(info.tag));
+                tagName.setText(getTagName(info.tag));
                 start.setText(String.valueOf(info.start));
                 pos.setText(String.valueOf(info.pos));
                 end.setText(String.valueOf(info.end));
diff --git a/test/tools/javac/treeannotests/AnnoTreeTests.java b/test/tools/javac/treeannotests/AnnoTreeTests.java
new file mode 100644
index 0000000..0db46b5
--- /dev/null
+++ b/test/tools/javac/treeannotests/AnnoTreeTests.java
@@ -0,0 +1,44 @@
+/*
+ * 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
+ * @build DA TA Test TestProcessor
+ * @compile -proc:only -processor TestProcessor AnnoTreeTests.java
+ */
+
+ at Test(4)
+class AnnoTreeTests {
+    // primitive types
+    // @TA("int") int i1 = 0; // TODO: Only visible via ClassFile
+    long i2 = (@TA("long") long) 0;
+
+    // simple array types
+    // @DA("short") short[] a1; // TODO: Only visible via ClassFile
+    byte @TA("byte[]") [] a2;
+    float[] a3 = (@TA("float") float[]) null;
+    double[] a4 = (double @TA("double[]") []) null;
+
+    // multi-dimensional array types
+    // (still to come)
+}
diff --git a/test/tools/javac/treeannotests/TestProcessor.java b/test/tools/javac/treeannotests/TestProcessor.java
index f74cd3c..8b6c4ad 100644
--- a/test/tools/javac/treeannotests/TestProcessor.java
+++ b/test/tools/javac/treeannotests/TestProcessor.java
@@ -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
@@ -203,13 +203,16 @@ public class TestProcessor extends AbstractProcessor {
          * expression <i>name</i>=<i>value</i>.
          */
         String getStringValue(JCExpression e) {
-            if (e.getTag() == JCTree.ASSIGN)  {
+            if (e.hasTag(JCTree.Tag.ASSIGN)) {
                 JCAssign a = (JCAssign) e;
                 JCExpression rhs = a.rhs;
-                if (rhs.getTag() == JCTree.LITERAL) {
+                if (rhs.hasTag(JCTree.Tag.LITERAL)) {
                     JCLiteral l = (JCLiteral) rhs;
                     return (String) l.value;
                 }
+            } else if (e.hasTag(JCTree.Tag.LITERAL)) {
+                JCLiteral l = (JCLiteral) e;
+                return (String) l.value;
             }
             throw new IllegalArgumentException(e.toString());
         }
diff --git a/test/tools/javac/typeAnnotations/newlocations/BasicTest.java b/test/tools/javac/typeAnnotations/newlocations/BasicTest.java
deleted file mode 100644
index a5de459..0000000
--- a/test/tools/javac/typeAnnotations/newlocations/BasicTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-
-/*
- * Copyright (c) 2008, 2010, 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 6843077
- * @summary random tests for new locations
- * @author Matt Papi
- * @compile/fail/ref=BasicTest.out -XDrawDiagnostics BasicTest.java
- */
-
-import java.util.*;
-import java.io.*;
-
- at interface A {}
- at interface B {}
- at interface C {}
- at interface D {}
-
-//308: Test inverted to verify that type annotations can not be parsed yet.
-
-/**
- * Tests basic JSR 308 parser functionality. We don't really care about what
- * the parse tree looks like, just that these annotations can be parsed.
- */
-class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
-
-    void test() {
-
-        // Handle annotated class literals/cast types
-        Class<?> c = @A String.class;
-        Object o = (@A Object) "foo";
-
-        // Handle annotated "new" expressions (except arrays; see ArrayTest)
-        String s = new @A String("bar");
-
-        boolean b = o instanceof @A Object;
-
-
-        @A Map<@B List<@C String>, @D String> map =
-            new @A HashMap<@B List<@C String>, @D String>();
-
-        Class<? extends @A String> c2 = @A String.class;
-    }
-
-    // Handle receiver annotations
-    // Handle annotations on a qualified identifier list
-    void test2() @C @D throws @A IllegalArgumentException, @B IOException {
-
-    }
-
-    // Handle annotations on a varargs element type
-    void test3(Object @A... objs) {
-
-    }
-}
diff --git a/test/tools/javac/typeAnnotations/newlocations/BasicTest.out b/test/tools/javac/typeAnnotations/newlocations/BasicTest.out
deleted file mode 100644
index 9973f32..0000000
--- a/test/tools/javac/typeAnnotations/newlocations/BasicTest.out
+++ /dev/null
@@ -1,66 +0,0 @@
-BasicTest.java:47:27: compiler.err.illegal.start.of.type
-BasicTest.java:47:28: compiler.err.expected: '{'
-BasicTest.java:47:36: compiler.err.expected: token.identifier
-BasicTest.java:47:38: compiler.err.illegal.start.of.type
-BasicTest.java:47:45: compiler.err.expected: token.identifier
-BasicTest.java:47:47: compiler.err.expected: ';'
-BasicTest.java:47:62: compiler.err.expected: token.identifier
-BasicTest.java:47:84: compiler.err.expected: token.identifier
-BasicTest.java:52:22: compiler.err.illegal.start.of.expr
-BasicTest.java:52:31: compiler.err.expected: ';'
-BasicTest.java:52:37: compiler.err.expected: token.identifier
-BasicTest.java:53:21: compiler.err.illegal.start.of.expr
-BasicTest.java:53:23: compiler.err.expected: ';'
-BasicTest.java:53:30: compiler.err.expected: token.identifier
-BasicTest.java:53:32: compiler.err.illegal.start.of.type
-BasicTest.java:53:37: compiler.err.expected: token.identifier
-BasicTest.java:53:38: compiler.err.expected: ';'
-BasicTest.java:56:17: compiler.err.expected: token.identifier
-BasicTest.java:56:23: compiler.err.expected: token.identifier
-BasicTest.java:56:24: compiler.err.expected2: '(', '['
-BasicTest.java:56:25: compiler.err.expected: ';'
-BasicTest.java:56:27: compiler.err.invalid.meth.decl.ret.type.req
-BasicTest.java:56:34: compiler.err.illegal.start.of.type
-BasicTest.java:58:34: compiler.err.illegal.start.of.type
-BasicTest.java:61:16: compiler.err.illegal.start.of.type
-BasicTest.java:61:18: compiler.err.expected: ';'
-BasicTest.java:61:24: compiler.err.illegal.start.of.type
-BasicTest.java:61:26: compiler.err.expected: ';'
-BasicTest.java:61:33: compiler.err.expected: token.identifier
-BasicTest.java:61:34: compiler.err.illegal.start.of.type
-BasicTest.java:61:35: compiler.err.expected: token.identifier
-BasicTest.java:61:37: compiler.err.expected: ';'
-BasicTest.java:61:45: compiler.err.expected: token.identifier
-BasicTest.java:61:50: compiler.err.expected: token.identifier
-BasicTest.java:62:16: compiler.err.expected: token.identifier
-BasicTest.java:62:17: compiler.err.expected2: '(', '['
-BasicTest.java:62:18: compiler.err.expected: ';'
-BasicTest.java:62:28: compiler.err.illegal.start.of.type
-BasicTest.java:62:30: compiler.err.expected: ';'
-BasicTest.java:62:36: compiler.err.illegal.start.of.type
-BasicTest.java:62:38: compiler.err.expected: ';'
-BasicTest.java:62:45: compiler.err.expected: token.identifier
-BasicTest.java:62:46: compiler.err.illegal.start.of.type
-BasicTest.java:62:47: compiler.err.expected: token.identifier
-BasicTest.java:62:49: compiler.err.expected: ';'
-BasicTest.java:62:57: compiler.err.expected: token.identifier
-BasicTest.java:62:58: compiler.err.illegal.start.of.type
-BasicTest.java:62:59: compiler.err.expected: token.identifier
-BasicTest.java:64:25: compiler.err.illegal.start.of.type
-BasicTest.java:64:27: compiler.err.expected: ';'
-BasicTest.java:64:34: compiler.err.expected: token.identifier
-BasicTest.java:64:38: compiler.err.expected: token.identifier
-BasicTest.java:64:41: compiler.err.illegal.start.of.expr
-BasicTest.java:64:50: compiler.err.expected: ';'
-BasicTest.java:64:56: compiler.err.expected: token.identifier
-BasicTest.java:69:17: compiler.err.expected: ';'
-BasicTest.java:69:24: compiler.err.illegal.start.of.type
-BasicTest.java:69:30: compiler.err.expected: ';'
-BasicTest.java:69:59: compiler.err.expected: token.identifier
-BasicTest.java:69:74: compiler.err.expected: ';'
-BasicTest.java:74:22: compiler.err.expected: token.identifier
-BasicTest.java:74:24: compiler.err.expected: ';'
-BasicTest.java:74:25: compiler.err.illegal.start.of.type
-BasicTest.java:74:33: compiler.err.expected: ';'
-BasicTest.java:77:2: compiler.err.premature.eof
-65 errors
diff --git a/test/tools/javac/types/CastObjectToPrimitiveTest.out b/test/tools/javac/types/CastObjectToPrimitiveTest.out
index 0a4f9cd..f57047f 100644
--- a/test/tools/javac/types/CastObjectToPrimitiveTest.out
+++ b/test/tools/javac/types/CastObjectToPrimitiveTest.out
@@ -1,2 +1,2 @@
-CastObjectToPrimitiveTest.java:36:23: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Object, int
+CastObjectToPrimitiveTest.java:36:23: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Object, int)
 1 error
diff --git a/test/tools/javac/types/TestComparisons.java b/test/tools/javac/types/TestComparisons.java
new file mode 100644
index 0000000..46f267b
--- /dev/null
+++ b/test/tools/javac/types/TestComparisons.java
@@ -0,0 +1,362 @@
+/*
+ * 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 8013357
+ * @summary javac should correctly enforce binary comparison rules.
+ */
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.Symbol.*;
+import java.io.*;
+import java.lang.reflect.Array;
+import java.util.EnumSet;
+
+public class TestComparisons {
+
+    private int errors = 0;
+    private int testnum = 0;
+
+    static final File testdir = new File("8013357");
+
+    private enum CompareType {
+        BYTE_PRIM("byte"),
+        SHORT_PRIM("short"),
+        CHAR_PRIM("char"),
+        INTEGER_PRIM("int"),
+        LONG_PRIM("long"),
+        FLOAT_PRIM("float"),
+        DOUBLE_PRIM("double"),
+        BOOLEAN_PRIM("boolean"),
+
+        BYTE("Byte"),
+        SHORT("Short"),
+        CHAR("Character"),
+        INTEGER("Integer"),
+        LONG("Long"),
+        FLOAT("Float"),
+        DOUBLE("Double"),
+        BOOLEAN("Boolean"),
+
+        BYTE_SUPER("List<? super Byte>", true),
+        SHORT_SUPER("List<? super Short>", true),
+        CHAR_SUPER("List<? super Character>", true),
+        INTEGER_SUPER("List<? super Integer>", true),
+        LONG_SUPER("List<? super Long>", true),
+        FLOAT_SUPER("List<? super Float>", true),
+        DOUBLE_SUPER("List<? super Double>", true),
+        BOOLEAN_SUPER("List<? super Boolean>", true),
+
+        OBJECT("Object"),
+        NUMBER("Number"),
+        STRING("String");
+
+        public final boolean isList;
+        public final String name;
+
+        private CompareType(final String name, final boolean isList) {
+            this.isList = isList;
+            this.name = name;
+        }
+
+        private CompareType(final String name) {
+            this(name, false);
+        }
+    }
+
+    // The integers here refer to which subsection of JLS 15.21 is in
+    // effect.  0 means no comparison is allowed.
+    private static final int truthtab[][] = {
+        // byte, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // short, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // char, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // int, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // long, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // float, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // double, comparable to itself, any numeric type, or any boxed
+        // numeric type.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          1, 1, 1, 1, 1, 1, 1, 0, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // boolean, comparable only to itself and Boolean.
+        { 0, 0, 0, 0, 0, 0, 0, 2, // Primitives
+          0, 0, 0, 0, 0, 0, 0, 2, // Boxed primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Captures
+          0, 0, 0                 // Reference types
+        },
+        // Byte, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          3, 0, 0, 0, 0, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Short, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 3, 0, 0, 0, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Character, comparable to itself, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 0, 3, 0, 0, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 0, 0                 // Reference types
+        },
+        // Int, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 0, 0, 3, 0, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Long, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 0, 0, 0, 3, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Float, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 0, 0, 0, 0, 3, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Double, comparable to itself, Number, Object, any numeric primitive,
+        // and any captures.
+        { 1, 1, 1, 1, 1, 1, 1, 0, // Primitives
+          0, 0, 0, 0, 0, 0, 3, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // Boolean, to itself, any capture, Object, and boolean.
+        { 0, 0, 0, 0, 0, 0, 0, 2, // Primitives
+          0, 0, 0, 0, 0, 0, 0, 2, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 0, 0                 // Reference types
+        },
+        // Byte supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Short supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Character supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Integer supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Long supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Float supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Double supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Boolean supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Object, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 3                 // Reference types
+        },
+        // Number, comparable to Object, any of its subclasses.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          3, 3, 0, 3, 3, 3, 3, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 3, 0                 // Reference types
+        },
+        // String supertype wildcard, comparable to any reference type.
+        // and any captures.
+        { 0, 0, 0, 0, 0, 0, 0, 0, // Primitives
+          0, 0, 0, 0, 0, 0, 0, 0, // Boxed primitives
+          3, 3, 3, 3, 3, 3, 3, 3, // Captures
+          3, 0, 3                 // Reference types
+        }
+    };
+
+    private void assert_compile_fail(final File file, final String body) {
+        final String filename = file.getPath();
+        final String[] args = { filename };
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+        final int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        if (rc == 0) {
+            System.err.println("Compilation of " + file.getName() +
+                               " didn't fail as expected.\nFile:\n" +
+                               body + "\nOutput:\n" + sw.toString());
+            errors++;
+        }
+    }
+
+    private void assert_compile_succeed(final File file, final String body) {
+        final String filename = file.getPath();
+        final String[] args = { filename };
+        final StringWriter sw = new StringWriter();
+        final PrintWriter pw = new PrintWriter(sw);
+        final int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        if (rc != 0) {
+            System.err.println("Compilation of " + file.getName() +
+                               " didn't succeed as expected.\nFile:\n" +
+                               body + "\nOutput:\n" +
+                               sw.toString());
+            errors++;
+        }
+    }
+
+    private String makeBody(final int num,
+                            final CompareType left,
+                            final CompareType right) {
+        return "import java.util.List;\n" +
+            "public class Test" + num + " {\n" +
+            "    public boolean test(" + left.name +
+            " left, " + right.name + " right) {\n" +
+            "        return left" + (left.isList ? ".get(0)" : "") +
+            " == right" + (right.isList ? ".get(0)" : "") + ";\n" +
+            "    }\n" +
+            "}\n";
+    }
+
+    private File writeFile(final String filename,
+                           final String body)
+        throws IOException {
+        final File f = new File(testdir, filename);
+        f.getParentFile().mkdirs();
+        final FileWriter out = new FileWriter(f);
+        out.write(body);
+        out.close();
+        return f;
+    }
+
+    private void test(final CompareType left, final CompareType right)
+        throws IOException {
+        final int num = testnum++;
+        final String filename = "Test" + num + ".java";
+        final String body = makeBody(num, left, right);
+        final File file = writeFile(filename, body);
+        if (truthtab[left.ordinal()][right.ordinal()] != 0)
+            assert_compile_succeed(file, body);
+        else
+            assert_compile_fail(file, body);
+    }
+
+    void run() throws Exception {
+        testdir.mkdir();
+
+        for(CompareType left : CompareType.values())
+            for(CompareType right : CompareType.values())
+                test(left, right);
+
+        if (errors != 0)
+            throw new Exception("ObjectZeroCompare test failed with " +
+                                errors + " errors.");
+    }
+
+    public static void main(String... args) throws Exception {
+        new TestComparisons().run();
+    }
+}
diff --git a/test/tools/javac/types/TypeHarness.java b/test/tools/javac/types/TypeHarness.java
index 7233b54..a53d947 100644
--- a/test/tools/javac/types/TypeHarness.java
+++ b/test/tools/javac/types/TypeHarness.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -309,7 +309,7 @@ public class TypeHarness {
         }
 
         public TypeVar TypeVariable(Type bound) {
-            TypeSymbol tvsym = new TypeSymbol(0, syntheticName(), null, predef.noSymbol);
+            TypeSymbol tvsym = new TypeVariableSymbol(0, syntheticName(), null, predef.noSymbol);
             tvsym.type = new TypeVar(tvsym, bound, null);
             return (TypeVar)tvsym.type;
         }
diff --git a/test/tools/javac/unicode/SupplementaryJavaID6.java b/test/tools/javac/unicode/SupplementaryJavaID6.java
index 0752b6c..69b76ba 100644
--- a/test/tools/javac/unicode/SupplementaryJavaID6.java
+++ b/test/tools/javac/unicode/SupplementaryJavaID6.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, 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
@@ -21,12 +21,20 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 4914724 4973116 5014511
+ * @summary Ensure that a supplementary character can be used as part/whole of a
+ * class name on platforms that have Unicode aware filesystems.
+ * @run main SupplementaryJavaID6
+ */
+
 public class SupplementaryJavaID6 {
     public static void main(String[] s) {
-        new SupplementaryJavaID6();
+        new SupplementaryJavaID6().test();
     }
 
-    public SupplementaryJavaID6() {
+    void test() {
         \ud801\udc00 instance = new \ud801\udc00();
         instance.\ud801\udc01();
     }
diff --git a/test/tools/javac/unicode/SupplementaryJavaID6.sh b/test/tools/javac/unicode/SupplementaryJavaID6.sh
deleted file mode 100644
index 9f728bb..0000000
--- a/test/tools/javac/unicode/SupplementaryJavaID6.sh
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 4914724 4973116 5014511
-# @summary Ensure that a supplementary character can be used as part/whole of a class
-#          name on platforms that have Unicode aware filesystems.
-# @author Naoto Sato
-# @run shell SupplementaryJavaID6.sh SupplementaryJavaID6
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    if [ -d /usr/lib/locale/en_US.UTF-8 -o -d /usr/lib/locale/en_US.utf8 ]
-    then
-        ENV="env LANG=en_US.UTF-8"
-        PS=":"
-        FS="/"
-    else
-        echo "As there is no en_US.UTF-8 locale available on this system, the compilation of the test case may or may not fail.  Ignoring this test."
-        exit 0;
-    fi
-    ;;
-  Windows_98 | Windows_ME )
-    echo "As Windows 98/Me do not provide Unicode-aware file system, the compilation of the test case is expected to fail on these platforms.  Ignoring this test."
-    exit 0;
-    ;;
-  Windows* )
-    ENV=""
-    PS=";"
-    FS="\\"
-    ;;
-  CYGWIN* )
-    ENV=""
-    PS=";" # platform PS, not cygwin PS
-    FS="/"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# compile
-cp "${TESTSRC}${FS}$1.java" .
-${ENV} "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath ".${PS}${TESTSRC}" $1.java
-result=$?
-
-if [ $result -ne 0 ]
-then
-  echo "Failed"
-  exit $result
-fi
-
-# run
-${ENV} "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} $1 
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-
-# Cleanup
-${ENV} rm -f ./$1*.class
-
-exit $result
diff --git a/test/tools/javac/util/T6597678.java b/test/tools/javac/util/T6597678.java
index 81cadbc..6b25554 100644
--- a/test/tools/javac/util/T6597678.java
+++ b/test/tools/javac/util/T6597678.java
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @bug 6597678
+ * @bug 6597678 6449184
  * @summary Ensure Messages propogated between rounds
- * @library ../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor T6597678
  * @run main T6597678
  */
@@ -41,27 +41,30 @@ import javax.tools.Diagnostic;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JavacMessages;
+import com.sun.tools.javac.util.Log;
 
+ at SupportedOptions("WriterString")
 public class T6597678 extends JavacTestingAbstractProcessor {
     public static void main(String... args) throws Exception {
         new T6597678().run();
     }
 
-
     void run() throws Exception {
         String myName = T6597678.class.getSimpleName();
         File testSrc = new File(System.getProperty("test.src"));
         File file = new File(testSrc, myName + ".java");
 
-        compile(
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+
+        compile(sw, pw,
             "-proc:only",
             "-processor", myName,
+            "-AWriterString=" + pw.toString(),
             file.getPath());
     }
 
-    void compile(String... args) throws Exception {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
+    void compile(StringWriter sw, PrintWriter pw, String... args) throws Exception {
         int rc = com.sun.tools.javac.Main.compile(args, pw);
         pw.close();
         String out = sw.toString();
@@ -76,6 +79,10 @@ public class T6597678 extends JavacTestingAbstractProcessor {
     @Override
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
         Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
+        Log log = Log.instance(context);
+        PrintWriter noteOut = log.getWriter(Log.WriterKind.NOTICE);
+        PrintWriter warnOut = log.getWriter(Log.WriterKind.WARNING);
+        PrintWriter errOut  = log.getWriter(Log.WriterKind.ERROR);
         Locale locale = context.get(Locale.class);
         JavacMessages messages = context.get(JavacMessages.messagesKey);
 
@@ -83,9 +90,20 @@ public class T6597678 extends JavacTestingAbstractProcessor {
         if (round == 1) {
             initialLocale = locale;
             initialMessages = messages;
+            initialNoteWriter = noteOut;
+            initialWarnWriter = warnOut;
+            initialErrWriter  = errOut;
+
+            String writerStringOpt = options.get("WriterString").intern();
+            checkEqual("noteWriterString", noteOut.toString().intern(), writerStringOpt);
+            checkEqual("warnWriterString", warnOut.toString().intern(), writerStringOpt);
+            checkEqual("errWriterString",  errOut.toString().intern(),  writerStringOpt);
         } else {
             checkEqual("locale", locale, initialLocale);
             checkEqual("messages", messages, initialMessages);
+            checkEqual("noteWriter", noteOut, initialNoteWriter);
+            checkEqual("warnWriter", warnOut, initialWarnWriter);
+            checkEqual("errWriter",  errOut,  initialErrWriter);
         }
 
         return true;
@@ -102,4 +120,7 @@ public class T6597678 extends JavacTestingAbstractProcessor {
     int round = 0;
     Locale initialLocale;
     JavacMessages initialMessages;
+    PrintWriter initialNoteWriter;
+    PrintWriter initialWarnWriter;
+    PrintWriter initialErrWriter;
 }
diff --git a/test/tools/javac/util/context/T7021650.java b/test/tools/javac/util/context/T7021650.java
index 3a57eb5..5801b03 100644
--- a/test/tools/javac/util/context/T7021650.java
+++ b/test/tools/javac/util/context/T7021650.java
@@ -25,7 +25,7 @@
  * @test
  * @bug 7021650
  * @summary Fix Context issues
- * @library ../../lib
+ * @library /tools/javac/lib
  * @build JavacTestingAbstractProcessor T7021650
  * @run main T7021650
  */
@@ -101,13 +101,13 @@ public class T7021650 extends JavacTestingAbstractProcessor {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         Main m = new Main("javac", pw);
-        int rc = m.compile(args, context);
+        Main.Result res = m.compile(args, context);
         pw.close();
         String out = sw.toString();
         if (!out.isEmpty())
             System.err.println(out);
-        if (rc != 0)
-            throw new Exception("compilation failed unexpectedly: rc=" + rc);
+        if (!res.isOK())
+            throw new Exception("compilation failed unexpectedly: result=" + res);
     }
 
     void checkEqual(String label, int found, int expect) throws Exception {
diff --git a/test/tools/javac/varargs/6313164/T6313164.out b/test/tools/javac/varargs/6313164/T6313164.out
index 72c75b3..7b2de27 100644
--- a/test/tools/javac/varargs/6313164/T6313164.out
+++ b/test/tools/javac/varargs/6313164/T6313164.out
@@ -1,6 +1,6 @@
-T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
-T6313164.java:14:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
-T6313164.java:15:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:12:8: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:14:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:15:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
 - compiler.note.unchecked.filename: B.java
 - compiler.note.unchecked.recompile
 3 errors
diff --git a/test/tools/javac/varargs/6313164/T7175433.java b/test/tools/javac/varargs/6313164/T7175433.java
new file mode 100644
index 0000000..b4627eb
--- /dev/null
+++ b/test/tools/javac/varargs/6313164/T7175433.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ *
+ * 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 7175433 6313164
+ * @summary Inference cleanup: add helper class to handle inference variables
+ *
+ */
+
+import java.util.List;
+
+class Bar {
+
+    private class Foo { }
+
+    <Z> List<Z> m(Object... o) { T7175433.assertTrue(true); return null; }
+    <Z> List<Z> m(Foo... o) { T7175433.assertTrue(false); return null; }
+
+    Foo getFoo() { return null; }
+}
+
+public class T7175433 {
+
+    static int assertionCount;
+
+    static void assertTrue(boolean b) {
+        assertionCount++;
+        if (!b) {
+            throw new AssertionError();
+        }
+    }
+
+    public static void main(String[] args) {
+        Bar b = new Bar();
+        b.m(b.getFoo());
+        assertTrue(assertionCount == 1);
+    }
+}
diff --git a/test/tools/javac/varargs/7042566/T7042566.java b/test/tools/javac/varargs/7042566/T7042566.java
index 0f356fe..6ef014c 100644
--- a/test/tools/javac/varargs/7042566/T7042566.java
+++ b/test/tools/javac/varargs/7042566/T7042566.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -23,55 +23,65 @@
 
 /*
  * @test
- * @bug 7042566
+ * @bug 7042566 8006694
  * @summary Unambiguous varargs method calls flagged as ambiguous
+ *  temporarily workaround combo tests are causing time out in several platforms
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm T7042566
  */
 
-import com.sun.source.util.JavacTask;
-import com.sun.tools.classfile.Instruction;
-import com.sun.tools.classfile.Attribute;
-import com.sun.tools.classfile.ClassFile;
-import com.sun.tools.classfile.Code_attribute;
-import com.sun.tools.classfile.ConstantPool.*;
-import com.sun.tools.classfile.Method;
-import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.util.List;
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
 
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Locale;
+import java.util.concurrent.atomic.AtomicInteger;
 import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
-public class T7042566 {
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.util.List;
+
+public class T7042566
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     VarargsMethod m1;
     VarargsMethod m2;
     TypeConfiguration actuals;
 
-    T7042566(TypeConfiguration m1_conf, TypeConfiguration m2_conf, TypeConfiguration actuals) {
+    T7042566(TypeConfiguration m1_conf, TypeConfiguration m2_conf,
+            TypeConfiguration actuals) {
         this.m1 = new VarargsMethod(m1_conf);
         this.m2 = new VarargsMethod(m2_conf);
         this.actuals = actuals;
     }
 
-    void compileAndCheck() throws Exception {
+    @Override
+    public void run() {
+        int id = checkCount.incrementAndGet();
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-        JavaSource source = new JavaSource();
+        JavaSource source = new JavaSource(id);
         ErrorChecker ec = new ErrorChecker();
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), ec,
                 null, null, Arrays.asList(source));
         ct.call();
-        check(source, ec);
+        check(source, ec, id);
     }
 
-    void check(JavaSource source, ErrorChecker ec) {
-        checkCount++;
+    void check(JavaSource source, ErrorChecker ec, int id) {
         boolean resolutionError = false;
         VarargsMethod selectedMethod = null;
 
@@ -99,13 +109,13 @@ public class T7042566 {
                     "\nFound error: " + ec.errorFound +
                     "\nCompiler diagnostics:\n" + ec.printDiags());
         } else if (!resolutionError) {
-            verifyBytecode(selectedMethod, source);
+            verifyBytecode(selectedMethod, source, id);
         }
     }
 
-    void verifyBytecode(VarargsMethod selected, JavaSource source) {
-        bytecodeCheckCount++;
-        File compiledTest = new File("Test.class");
+    void verifyBytecode(VarargsMethod selected, JavaSource source, int id) {
+        bytecodeCheckCount.incrementAndGet();
+        File compiledTest = new File(String.format("Test%d.class", id));
         try {
             ClassFile cf = ClassFile.read(compiledTest);
             Method testMethod = null;
@@ -118,7 +128,8 @@ public class T7042566 {
             if (testMethod == null) {
                 throw new Error("Test method not found");
             }
-            Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code);
+            Code_attribute ea =
+                (Code_attribute)testMethod.attributes.get(Attribute.Code);
             if (testMethod == null) {
                 throw new Error("Code attribute for test() method not found");
             }
@@ -127,11 +138,12 @@ public class T7042566 {
                 if (i.getMnemonic().equals("invokevirtual")) {
                     int cp_entry = i.getUnsignedShort(1);
                     CONSTANT_Methodref_info methRef =
-                            (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
+                        (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
                     String type = methRef.getNameAndTypeInfo().getType();
                     String sig = selected.parameterTypes.bytecodeSigStr;
                     if (!type.contains(sig)) {
-                        throw new Error("Unexpected type method call: " + type + "" +
+                        throw new Error("Unexpected type method call: " +
+                                        type + "" +
                                         "\nfound: " + sig +
                                         "\n" + source.getCharContent(true));
                     }
@@ -146,7 +158,7 @@ public class T7042566 {
 
     class JavaSource extends SimpleJavaFileObject {
 
-        static final String source_template = "class Test {\n" +
+        static final String source_template = "class Test#ID {\n" +
                 "   #V1\n" +
                 "   #V2\n" +
                 "   void test() { m(#E); }\n" +
@@ -154,11 +166,13 @@ public class T7042566 {
 
         String source;
 
-        public JavaSource() {
-            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            source = source_template.replaceAll("#V1", m1.toString()).
-                    replaceAll("#V2", m2.toString()).
-                    replaceAll("#E", actuals.expressionListStr);
+        public JavaSource(int id) {
+            super(URI.create(String.format("myfo:/Test%d.java", id)),
+                    JavaFileObject.Kind.SOURCE);
+            source = source_template.replaceAll("#V1", m1.toString())
+                    .replaceAll("#V2", m2.toString())
+                    .replaceAll("#E", actuals.expressionListStr)
+                    .replaceAll("#ID", String.valueOf(id));
         }
 
         @Override
@@ -167,26 +181,17 @@ public class T7042566 {
         }
     }
 
-    /** global decls ***/
-
-    // Create a single file manager and reuse it for each compile to save time.
-    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
-
-    //statistics
-    static int checkCount = 0;
-    static int bytecodeCheckCount = 0;
-
     public static void main(String... args) throws Exception {
         for (TypeConfiguration tconf1 : TypeConfiguration.values()) {
             for (TypeConfiguration tconf2 : TypeConfiguration.values()) {
                 for (TypeConfiguration tconf3 : TypeConfiguration.values()) {
-                    new T7042566(tconf1, tconf2, tconf3).compileAndCheck();
+                    pool.execute(new T7042566(tconf1, tconf2, tconf3));
                 }
             }
         }
 
-        System.out.println("Total checks made: " + checkCount);
-        System.out.println("Bytecode checks made: " + bytecodeCheckCount);
+        outWriter.println("Bytecode checks made: " + bytecodeCheckCount.get());
+        checkAfterExec();
     }
 
     enum TypeKind {
@@ -326,14 +331,16 @@ public class T7042566 {
         }
     }
 
-    static class ErrorChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+    static class ErrorChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         boolean errorFound;
         List<String> errDiags = List.nil();
 
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
             if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
-                errDiags = errDiags.append(diagnostic.getMessage(Locale.getDefault()));
+                errDiags = errDiags
+                        .append(diagnostic.getMessage(Locale.getDefault()));
                 errorFound = true;
             }
         }
@@ -347,4 +354,8 @@ public class T7042566 {
             return buf.toString();
         }
     }
+
+    //number of bytecode checks made while running combo tests
+    static AtomicInteger bytecodeCheckCount = new AtomicInteger();
+
 }
diff --git a/test/tools/javac/varargs/7097436/T7097436.out b/test/tools/javac/varargs/7097436/T7097436.out
index 6428cdf..5e35910 100644
--- a/test/tools/javac/varargs/7097436/T7097436.out
+++ b/test/tools/javac/varargs/7097436/T7097436.out
@@ -1,6 +1,6 @@
 T7097436.java:13:20: compiler.warn.varargs.unsafe.use.varargs.param: ls
 T7097436.java:14:25: compiler.warn.varargs.unsafe.use.varargs.param: ls
-T7097436.java:15:20: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.util.List<java.lang.String>[], java.lang.String
-T7097436.java:16:26: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.util.List<java.lang.String>[], java.lang.Integer[]
+T7097436.java:15:20: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.util.List<java.lang.String>[], java.lang.String)
+T7097436.java:16:26: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.util.List<java.lang.String>[], java.lang.Integer[])
 2 errors
 2 warnings
diff --git a/test/tools/javac/varargs/warning/Warn4.java b/test/tools/javac/varargs/warning/Warn4.java
index df1b163..1a068c7 100644
--- a/test/tools/javac/varargs/warning/Warn4.java
+++ b/test/tools/javac/varargs/warning/Warn4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -23,13 +23,18 @@
 
 /**
  * @test
- * @bug     6945418 6993978
+ * @bug     6945418 6993978 8006694
  * @summary Project Coin: Simplified Varargs Method Invocation
+ *  temporarily workaround combo tests are causing time out in several platforms
  * @author  mcimadamore
- * @run main Warn4
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm Warn4
  */
-import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.api.JavacTool;
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Set;
@@ -38,16 +43,19 @@ import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
 
-public class Warn4 {
+public class Warn4
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     final static Warning[] error = null;
     final static Warning[] none = new Warning[] {};
     final static Warning[] vararg = new Warning[] { Warning.VARARGS };
     final static Warning[] unchecked = new Warning[] { Warning.UNCHECKED };
-    final static Warning[] both = new Warning[] { Warning.VARARGS, Warning.UNCHECKED };
+    final static Warning[] both =
+            new Warning[] { Warning.VARARGS, Warning.UNCHECKED };
 
     enum Warning {
         UNCHECKED("generic.array.creation"),
@@ -59,8 +67,10 @@ public class Warn4 {
             this.key = key;
         }
 
-        boolean isSuppressed(TrustMe trustMe, SourceLevel source, SuppressLevel suppressLevelClient,
-                SuppressLevel suppressLevelDecl, ModifierKind modKind) {
+        boolean isSuppressed(TrustMe trustMe, SourceLevel source,
+                SuppressLevel suppressLevelClient,
+                SuppressLevel suppressLevelDecl,
+                ModifierKind modKind) {
             switch(this) {
                 case VARARGS:
                     return source == SourceLevel.JDK_6 ||
@@ -68,7 +78,8 @@ public class Warn4 {
                             trustMe == TrustMe.TRUST;
                 case UNCHECKED:
                     return suppressLevelClient == SuppressLevel.UNCHECKED ||
-                        (trustMe == TrustMe.TRUST && modKind != ModifierKind.NONE && source == SourceLevel.JDK_7);
+                        (trustMe == TrustMe.TRUST && modKind !=
+                            ModifierKind.NONE && source == SourceLevel.JDK_7);
             }
 
             SuppressLevel supLev = this == VARARGS ?
@@ -172,13 +183,13 @@ public class Warn4 {
                             for (Signature vararg_meth : Signature.values()) {
                                 for (Signature client_meth : Signature.values()) {
                                     if (vararg_meth.isApplicableTo(client_meth)) {
-                                        test(sourceLevel,
+                                        pool.execute(new Warn4(sourceLevel,
                                                 trustMe,
                                                 suppressLevelClient,
                                                 suppressLevelDecl,
                                                 modKind,
                                                 vararg_meth,
-                                                client_meth);
+                                                client_meth));
                                     }
                                 }
                             }
@@ -187,63 +198,81 @@ public class Warn4 {
                 }
             }
         }
+
+        checkAfterExec();
     }
 
-    // Create a single file manager and reuse it for each compile to save time.
-    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+    SourceLevel sourceLevel;
+    TrustMe trustMe;
+    SuppressLevel suppressLevelClient;
+    SuppressLevel suppressLevelDecl;
+    ModifierKind modKind;
+    Signature vararg_meth;
+    Signature client_meth;
+    DiagnosticChecker diagChecker;
+
+    public Warn4(SourceLevel sourceLevel, TrustMe trustMe,
+            SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl,
+            ModifierKind modKind, Signature vararg_meth, Signature client_meth) {
+        this.sourceLevel = sourceLevel;
+        this.trustMe = trustMe;
+        this.suppressLevelClient = suppressLevelClient;
+        this.suppressLevelDecl = suppressLevelDecl;
+        this.modKind = modKind;
+        this.vararg_meth = vararg_meth;
+        this.client_meth = client_meth;
+        this.diagChecker = new DiagnosticChecker();
+    }
 
-    static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
-            SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
+    @Override
+    public void run() {
+        int id = checkCount.incrementAndGet();
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-        JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
-        DiagnosticChecker dc = new DiagnosticChecker();
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
+        JavaSource source = new JavaSource(id);
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), diagChecker,
                 Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
                 null, Arrays.asList(source));
-        ct.generate(); //to get mandatory notes
-        check(dc.warnings, sourceLevel,
-                new boolean[] {vararg_meth.giveUnchecked(client_meth),
-                               vararg_meth.giveVarargs(client_meth)},
-                source, trustMe, suppressLevelClient, suppressLevelDecl, modKind);
+        ct.call(); //to get mandatory notes
+        check(source, new boolean[] {vararg_meth.giveUnchecked(client_meth),
+                               vararg_meth.giveVarargs(client_meth)});
     }
 
-    static void check(Set<Warning> warnings, SourceLevel sourceLevel, boolean[] warnArr, JavaSource source,
-            TrustMe trustMe, SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl, ModifierKind modKind) {
+    void check(JavaSource source, boolean[] warnArr) {
         boolean badOutput = false;
         for (Warning wkind : Warning.values()) {
             boolean isSuppressed = wkind.isSuppressed(trustMe, sourceLevel,
                     suppressLevelClient, suppressLevelDecl, modKind);
-            System.out.println("SUPPRESSED = " + isSuppressed);
-            badOutput |= (warnArr[wkind.ordinal()] && !isSuppressed) != warnings.contains(wkind);
+            badOutput |= (warnArr[wkind.ordinal()] && !isSuppressed) !=
+                    diagChecker.warnings.contains(wkind);
         }
         if (badOutput) {
             throw new Error("invalid diagnostics for source:\n" +
                     source.getCharContent(true) +
                     "\nExpected unchecked warning: " + warnArr[0] +
                     "\nExpected unsafe vararg warning: " + warnArr[1] +
-                    "\nWarnings: " + warnings +
+                    "\nWarnings: " + diagChecker.warnings +
                     "\nSource level: " + sourceLevel);
         }
     }
 
-    static class JavaSource extends SimpleJavaFileObject {
+    class JavaSource extends SimpleJavaFileObject {
 
         String source;
 
-        public JavaSource(TrustMe trustMe, SuppressLevel suppressLevelClient, SuppressLevel suppressLevelDecl,
-                ModifierKind modKind, Signature vararg_meth, Signature client_meth) {
-            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+        public JavaSource(int id) {
+            super(URI.create(String.format("myfo:/Test%d.java", id)),
+                    JavaFileObject.Kind.SOURCE);
             String meth1 = vararg_meth.template.replace("#arity", "...");
             meth1 = meth1.replace("#name", "m");
             meth1 = meth1.replace("#body", "");
-            meth1 = trustMe.anno + "\n" + suppressLevelDecl.getSuppressAnno() + modKind.mod + meth1;
+            meth1 = trustMe.anno + "\n" + suppressLevelDecl.getSuppressAnno() +
+                    modKind.mod + meth1;
             String meth2 = client_meth.template.replace("#arity", "");
             meth2 = meth2.replace("#name", "test");
             meth2 = meth2.replace("#body", "m(arg);");
             meth2 = suppressLevelClient.getSuppressAnno() + meth2;
-            source = "import java.util.List;\n" +
-                     "class Test {\n" + meth1 +
-                     "\n" + meth2 + "\n}\n";
+            source = String.format("import java.util.List;\n" +
+                     "class Test%s {\n %s \n %s \n } \n", id, meth1, meth2);
         }
 
         @Override
@@ -252,7 +281,8 @@ public class Warn4 {
         }
     }
 
-    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+    static class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         Set<Warning> warnings = new HashSet<>();
 
@@ -267,4 +297,5 @@ public class Warn4 {
             }
         }
     }
+
 }
diff --git a/test/tools/javac/varargs/warning/Warn5.java b/test/tools/javac/varargs/warning/Warn5.java
index 966cefa..e45cd36 100644
--- a/test/tools/javac/varargs/warning/Warn5.java
+++ b/test/tools/javac/varargs/warning/Warn5.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -23,13 +23,18 @@
 
 /**
  * @test
- * @bug     6993978 7097436
+ * @bug     6993978 7097436 8006694
  * @summary Project Coin: Annotation to reduce varargs warnings
+ *  temporarily workaround combo tests are causing time out in several platforms
  * @author  mcimadamore
- * @run main Warn5
+ * @library ../../lib
+ * @build JavacTestingAbstractThreadedTest
+ * @run main/othervm Warn5
  */
-import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.api.JavacTool;
+
+// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
+// see JDK-8006746
+
 import java.net.URI;
 import java.util.Arrays;
 import java.util.EnumSet;
@@ -37,10 +42,12 @@ import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
+import com.sun.source.util.JavacTask;
 
-public class Warn5 {
+public class Warn5
+    extends JavacTestingAbstractThreadedTest
+    implements Runnable {
 
     enum XlintOption {
         NONE("none"),
@@ -161,9 +168,6 @@ public class Warn5 {
         REDUNDANT_SAFEVARARGS;
     }
 
-    // Create a single file manager and reuse it for each compile to save time.
-    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
-
     public static void main(String... args) throws Exception {
         for (SourceLevel sourceLevel : SourceLevel.values()) {
             for (XlintOption xlint : XlintOption.values()) {
@@ -173,14 +177,9 @@ public class Warn5 {
                             for (MethodKind methKind : MethodKind.values()) {
                                 for (SignatureKind sig : SignatureKind.values()) {
                                     for (BodyKind body : BodyKind.values()) {
-                                        new Warn5(sourceLevel,
-                                                xlint,
-                                                trustMe,
-                                                suppressLevel,
-                                                modKind,
-                                                methKind,
-                                                sig,
-                                                body).test();
+                                        pool.execute(new Warn5(sourceLevel,
+                                                xlint, trustMe, suppressLevel,
+                                                modKind, methKind, sig, body));
                                     }
                                 }
                             }
@@ -189,6 +188,8 @@ public class Warn5 {
                 }
             }
         }
+
+        checkAfterExec(false);
     }
 
     final SourceLevel sourceLevel;
@@ -202,7 +203,9 @@ public class Warn5 {
     final JavaSource source;
     final DiagnosticChecker dc;
 
-    public Warn5(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel, ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) {
+    public Warn5(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe,
+            SuppressLevel suppressLevel, ModifierKind modKind,
+            MethodKind methKind, SignatureKind sig, BodyKind body) {
         this.sourceLevel = sourceLevel;
         this.xlint = xlint;
         this.trustMe = trustMe;
@@ -215,24 +218,36 @@ public class Warn5 {
         this.dc = new DiagnosticChecker();
     }
 
-    void test() throws Exception {
+    @Override
+    public void run() {
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
-        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
-                Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
-        ct.analyze();
+        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), dc,
+                Arrays.asList(xlint.getXlintOption(),
+                    "-source", sourceLevel.sourceKey),
+                null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable t) {
+            processException(t);
+        }
         check();
     }
 
     void check() {
 
-        EnumSet<WarningKind> expectedWarnings = EnumSet.noneOf(WarningKind.class);
+        EnumSet<WarningKind> expectedWarnings =
+                EnumSet.noneOf(WarningKind.class);
 
         if (sourceLevel == SourceLevel.JDK_7 &&
                 trustMe == TrustMe.TRUST &&
                 suppressLevel != SuppressLevel.VARARGS &&
                 xlint != XlintOption.NONE &&
-                sig.isVarargs && !sig.isReifiableArg && body.hasAliasing &&
-                (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && modKind != ModifierKind.NONE))) {
+                sig.isVarargs &&
+                !sig.isReifiableArg &&
+                body.hasAliasing &&
+                (methKind == MethodKind.CONSTRUCTOR ||
+                (methKind == MethodKind.METHOD &&
+                modKind != ModifierKind.NONE))) {
             expectedWarnings.add(WarningKind.UNSAFE_BODY);
         }
 
@@ -247,7 +262,8 @@ public class Warn5 {
         if (sourceLevel == SourceLevel.JDK_7 &&
                 trustMe == TrustMe.TRUST &&
                 (!sig.isVarargs ||
-                (modKind == ModifierKind.NONE && methKind == MethodKind.METHOD))) {
+                (modKind == ModifierKind.NONE &&
+                methKind == MethodKind.METHOD))) {
             expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS);
         }
 
@@ -255,7 +271,8 @@ public class Warn5 {
                 trustMe == TrustMe.TRUST &&
                 xlint != XlintOption.NONE &&
                 suppressLevel != SuppressLevel.VARARGS &&
-                (modKind != ModifierKind.NONE || methKind == MethodKind.CONSTRUCTOR) &&
+                (modKind != ModifierKind.NONE ||
+                methKind == MethodKind.CONSTRUCTOR) &&
                 sig.isVarargs &&
                 sig.isReifiableArg) {
             expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS);
@@ -297,19 +314,23 @@ public class Warn5 {
         }
     }
 
-    class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+    class DiagnosticChecker
+        implements javax.tools.DiagnosticListener<JavaFileObject> {
 
         EnumSet<WarningKind> warnings = EnumSet.noneOf(WarningKind.class);
 
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
             if (diagnostic.getKind() == Diagnostic.Kind.WARNING) {
-                    if (diagnostic.getCode().contains("unsafe.use.varargs.param")) {
+                    if (diagnostic.getCode().
+                            contains("unsafe.use.varargs.param")) {
                         setWarning(WarningKind.UNSAFE_BODY);
-                    } else if (diagnostic.getCode().contains("redundant.trustme")) {
+                    } else if (diagnostic.getCode().
+                            contains("redundant.trustme")) {
                         setWarning(WarningKind.REDUNDANT_SAFEVARARGS);
                     }
             } else if (diagnostic.getKind() == Diagnostic.Kind.MANDATORY_WARNING &&
-                    diagnostic.getCode().contains("varargs.non.reifiable.type")) {
+                    diagnostic.getCode().
+                        contains("varargs.non.reifiable.type")) {
                 setWarning(WarningKind.UNSAFE_DECL);
             } else if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
                     diagnostic.getCode().contains("invalid.trustme")) {
@@ -319,7 +340,8 @@ public class Warn5 {
 
         void setWarning(WarningKind wk) {
             if (!warnings.add(wk)) {
-                throw new AssertionError("Duplicate warning of kind " + wk + " in source:\n" + source);
+                throw new AssertionError("Duplicate warning of kind " +
+                        wk + " in source:\n" + source);
             }
         }
 
@@ -327,4 +349,5 @@ public class Warn5 {
             return warnings.contains(wk);
         }
     }
+
 }
diff --git a/test/tools/javac/versions/check.sh b/test/tools/javac/versions/check.sh
index a32ac90..bc25f7d 100644
--- a/test/tools/javac/versions/check.sh
+++ b/test/tools/javac/versions/check.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 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
@@ -22,7 +22,7 @@
 #
 
 # @test
-# @bug 4981566 5028634 5094412 6304984
+# @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112
 # @summary Check interpretation of -target and -source options
 # @build CheckClassFileVersion
 # @run shell check.sh 
@@ -47,27 +47,39 @@ check() {
   "$JC" ${TESTTOOLVMOPTS} -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2
 }
 
+# check for all combinations of target values
+check_target() {
+  check $1 -source $2 -target $3
+  check $1 -source $2 -target 1.${3}
+}
+# check for all combinations of source and target values
+check_source_target() {
+  check_target $1 $2     $3
+  check_target $1 1.${2} $3
+}
+
 check 48.0 -source 1.4
 
 check 49.0 -source 1.4 -target 1.5
 check 49.0 -source 1.5 -target 1.5
 
-check 50.0 -source 1.4 -target 1.6
-check 50.0 -source 1.5 -target 1.6
-check 50.0 -source 1.6 -target 1.6
-check 50.0 -source 1.6 -target 6
-check 50.0 -source 6 -target 1.6
-check 50.0 -source 6 -target 6
+check_target        50.0 1.4 6
+check_target        50.0 1.5 6
+check_source_target 50.0 6   6
 
-check 51.0
-check 51.0 -source 1.5
-check 51.0 -source 1.6
-check 51.0 -source 6
-check 51.0 -source 1.7
-check 51.0 -source 7
-check 51.0 -target 1.7
-check 51.0 -target 7
+check_target        51.0 1.4 7
+check_target        51.0 1.5 7
+check_source_target 51.0 6   7
+check_source_target 51.0 7   7
 
+check_target        52.0 1.4 8
+check_target        52.0 1.5 8
+check_source_target 52.0 6   8
+check_source_target 52.0 7   8
+check_source_target 52.0 8   8
+
+# and finally the default with no options
+check 52.0
 
 # Check source versions
 
@@ -96,6 +108,7 @@ checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; }
 checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; }
 checksrc16() { checksrc15 $* ; }
 checksrc17() { checksrc15 $* ; }
+checksrc18() { checksrc15 $* ; }
 
 checksrc14 -source 1.4
 checksrc14 -source 1.4 -target 1.5
@@ -108,16 +121,24 @@ checksrc16 -source 6
 checksrc16 -source 1.6 -target 1.6
 checksrc16 -source 6 -target 6
 
-checksrc17
-checksrc17 -target 1.7
-checksrc17 -target 7
 checksrc17 -source 1.7
 checksrc17 -source 7
 checksrc17 -source 1.7 -target 1.7
 checksrc17 -source 7 -target 7
 
+checksrc18
+checksrc18 -target 1.8
+checksrc18 -target 8
+checksrc18 -source 1.8
+checksrc18 -source 8
+checksrc18 -source 1.8 -target 1.8
+checksrc18 -source 8 -target 8
+
 fail -source 1.5 -target 1.4 $TC/X.java
 fail -source 1.6 -target 1.4 $TC/X.java
 fail -source 6   -target 1.4 $TC/X.java
 fail -source 1.6 -target 1.5 $TC/X.java
 fail -source 6   -target 1.5 $TC/X.java
+fail -source 7   -target 1.6 $TC/X.java
+fail -source 8   -target 1.6 $TC/X.java
+fail -source 8   -target 1.7 $TC/X.java
diff --git a/test/tools/javac/warnings/6594914/Auxiliary.java b/test/tools/javac/warnings/6594914/Auxiliary.java
new file mode 100644
index 0000000..e9c8816
--- /dev/null
+++ b/test/tools/javac/warnings/6594914/Auxiliary.java
@@ -0,0 +1,5 @@
+import java.io.StringBufferInputStream;
+
+public class Auxiliary {
+
+}
diff --git a/test/tools/javac/warnings/6594914/ExplicitCompilation.out b/test/tools/javac/warnings/6594914/ExplicitCompilation.out
new file mode 100644
index 0000000..3dff792
--- /dev/null
+++ b/test/tools/javac/warnings/6594914/ExplicitCompilation.out
@@ -0,0 +1,2 @@
+Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
+1 warning
diff --git a/test/tools/javac/warnings/6594914/ImplicitCompilation.java b/test/tools/javac/warnings/6594914/ImplicitCompilation.java
new file mode 100644
index 0000000..6bf4156
--- /dev/null
+++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.java
@@ -0,0 +1,13 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8020586
+ * @summary Warnings in the imports section should be attributed to the correct source file
+ * @clean Auxiliary ImplicitCompilation
+ * @compile/ref=ImplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation -sourcepath . ImplicitCompilation.java
+ * @clean Auxiliary ImplicitCompilation
+ * @compile/ref=ExplicitCompilation.out -XDrawDiagnostics -Xlint:deprecation ImplicitCompilation.java Auxiliary.java
+ */
+
+public class ImplicitCompilation {
+    private Auxiliary a;
+}
diff --git a/test/tools/javac/warnings/6594914/ImplicitCompilation.out b/test/tools/javac/warnings/6594914/ImplicitCompilation.out
new file mode 100644
index 0000000..3dff792
--- /dev/null
+++ b/test/tools/javac/warnings/6594914/ImplicitCompilation.out
@@ -0,0 +1,2 @@
+Auxiliary.java:1:15: compiler.warn.has.been.deprecated: java.io.StringBufferInputStream, java.io
+1 warning
diff --git a/test/tools/javac/warnings/7090499/T7090499.java b/test/tools/javac/warnings/7090499/T7090499.java
new file mode 100644
index 0000000..205a7fa
--- /dev/null
+++ b/test/tools/javac/warnings/7090499/T7090499.java
@@ -0,0 +1,37 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7094099
+ * @summary -Xlint:rawtypes
+ * @compile/fail/ref=T7090499.out -XDrawDiagnostics -Xlint:rawtypes T7090499.java
+ */
+
+
+class T7090499<E> {
+
+    static class B<X> {}
+
+    class A<X> {
+        class X {}
+        class Z<Y> {}
+    }
+
+    T7090499 t = new T7090499() { //raw warning (2)
+
+        A.X x1;//raw warning
+        A.Z z1;//raw warning
+
+        T7090499.B<Integer> b1;//ok
+        T7090499.B b2;//raw warning
+
+        A<String>.X x2;//ok
+        A<String>.Z<Integer> z2;//ok
+        A<B>.Z<A<B>> z3;//raw warning (2)
+
+        void test(Object arg1, B arg2) {//raw warning
+            boolean b = arg1 instanceof A;//ok
+            Object a = (A)arg1;//ok
+            A a2 = new A() {};//raw warning (2)
+            a2.new Z() {};//raw warning
+        }
+    };
+}
diff --git a/test/tools/javac/warnings/7090499/T7090499.out b/test/tools/javac/warnings/7090499/T7090499.out
new file mode 100644
index 0000000..1ff9e16
--- /dev/null
+++ b/test/tools/javac/warnings/7090499/T7090499.out
@@ -0,0 +1,17 @@
+T7090499.java:18:5: compiler.warn.raw.class.use: T7090499, T7090499<E>
+T7090499.java:18:22: compiler.warn.raw.class.use: T7090499, T7090499<E>
+T7090499.java:20:10: compiler.warn.raw.class.use: T7090499.A.X, T7090499<E>.A<X>.X
+T7090499.java:21:10: compiler.warn.raw.class.use: T7090499.A.Z, T7090499<E>.A<X>.Z<Y>
+T7090499.java:24:17: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:26:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:27:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:28:18: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:28:17: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:28:11: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:28:10: compiler.err.improperly.formed.type.inner.raw.param
+T7090499.java:30:32: compiler.warn.raw.class.use: T7090499.B, T7090499.B<X>
+T7090499.java:33:13: compiler.warn.raw.class.use: T7090499.A, T7090499<E>.A<X>
+T7090499.java:33:24: compiler.warn.raw.class.use: T7090499.A, T7090499<E>.A<X>
+T7090499.java:34:20: compiler.warn.raw.class.use: T7090499.A.Z, T7090499<E>.A<X>.Z<Y>
+4 errors
+11 warnings
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.java b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.java
new file mode 100644
index 0000000..d5c3660
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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 7153951
+ * @compile ClassUsingAnotherAuxiliary.java NotAClassName.java
+ * @compile -Xlint:auxiliaryclass ClassUsingAnotherAuxiliary.java NotAClassName.java
+ * @compile/fail/ref=ClassUsingAnotherAuxiliary.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAnotherAuxiliary.java NotAClassName.java
+ */
+
+class ClassUsingAnotherAuxiliary {
+    AnAuxiliaryClass ahem;
+}
+
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.out b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.out
new file mode 100644
index 0000000..5df6bdb
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAnotherAuxiliary.out
@@ -0,0 +1,4 @@
+ClassUsingAnotherAuxiliary.java:33:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AnAuxiliaryClass, NotAClassName.java
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary.java b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary.java
new file mode 100644
index 0000000..605eb80
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ *
+ * 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 7153951
+ * @clean ClassUsingAuxiliary ClassWithAuxiliary AuxiliaryClass ClassWithAuxiliary$NotAnAuxiliaryClass ClassWithAuxiliary$NotAnAuxiliaryClassEither
+ * @run compile ClassUsingAuxiliary.java ClassWithAuxiliary.java
+ * @run compile/fail/ref=ClassUsingAuxiliary1.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAuxiliary.java ClassWithAuxiliary.java
+ * @run compile/fail/ref=ClassUsingAuxiliary2.out -XDrawDiagnostics -Werror -Xlint:auxiliaryclass ClassUsingAuxiliary.java
+ */
+
+class ClassUsingAuxiliary {
+    AuxiliaryClass ahem;
+}
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary1.out b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary1.out
new file mode 100644
index 0000000..d319c0b
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary1.out
@@ -0,0 +1,4 @@
+ClassUsingAuxiliary.java:34:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AuxiliaryClass, ClassWithAuxiliary.java
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary2.out b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary2.out
new file mode 100644
index 0000000..d319c0b
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassUsingAuxiliary2.out
@@ -0,0 +1,4 @@
+ClassUsingAuxiliary.java:34:5: compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file: AuxiliaryClass, ClassWithAuxiliary.java
+- compiler.err.warnings.and.werror
+1 error
+1 warning
diff --git a/test/tools/javac/warnings/AuxiliaryClass/ClassWithAuxiliary.java b/test/tools/javac/warnings/AuxiliaryClass/ClassWithAuxiliary.java
new file mode 100644
index 0000000..ac3b86c
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/ClassWithAuxiliary.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+public class ClassWithAuxiliary {
+    public static class NotAnAuxiliaryClass { }
+    public class NotAnAuxiliaryClassEither { }
+}
+
+// Auxiliary class that cannot be found through implicit compilation.
+class AuxiliaryClass {
+}
diff --git a/test/tools/javac/warnings/AuxiliaryClass/NotAClassName.java b/test/tools/javac/warnings/AuxiliaryClass/NotAClassName.java
new file mode 100644
index 0000000..67feedd
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/NotAClassName.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+class AnAuxiliaryClass {
+}
diff --git a/test/tools/javac/warnings/AuxiliaryClass/SelfClassWithAux.java b/test/tools/javac/warnings/AuxiliaryClass/SelfClassWithAux.java
new file mode 100644
index 0000000..398315d
--- /dev/null
+++ b/test/tools/javac/warnings/AuxiliaryClass/SelfClassWithAux.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ * 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 that an auxiliary class referenced from its own source file,
+ * does not trigger the warning. Such code does not prevent implicit
+ * compilation. Also test that references to inner classes do not trigger the warning.
+ */
+
+/*
+ * @test
+ * @bug 7153951
+ * @run compile -Werror -Xlint:auxiliaryclass SelfClassWithAux.java ClassWithAuxiliary.java
+ * @run compile -Werror -Xlint:auxiliaryclass SelfClassWithAux.java
+ */
+
+class SelfClassWithAux {
+    AuxClass aux;
+    ClassWithAuxiliary.NotAnAuxiliaryClass alfa;
+    ClassWithAuxiliary.NotAnAuxiliaryClassEither beta;
+}
+
+class AuxClass {
+    AuxClass aux;
+}
diff --git a/test/tools/javadoc/6958836/Test.java b/test/tools/javadoc/6958836/Test.java
index b14949f..41746f7 100644
--- a/test/tools/javadoc/6958836/Test.java
+++ b/test/tools/javadoc/6958836/Test.java
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6958836
+ * @bug 6958836 8002168
  * @summary javadoc should support -Xmaxerrs and -Xmaxwarns
  */
 
@@ -61,6 +61,7 @@ public class Test {
         // Force en_US locale in lieu of something like -XDrawDiagnostics.
         // For some reason, this must be the first option when used.
         opts.addAll(list("-locale", "en_US"));
+        opts.add("-Xdoclint:none");
         opts.addAll(list("-classpath", System.getProperty("test.src")));
         opts.addAll(list("-d", testOutDir.getPath()));
         opts.addAll(testOpts);
diff --git a/test/tools/javadoc/6964914/Test.java b/test/tools/javadoc/6964914/Test.java
index 92362af..751f295 100644
--- a/test/tools/javadoc/6964914/Test.java
+++ b/test/tools/javadoc/6964914/Test.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 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
@@ -45,6 +45,7 @@ public class Test {
     void javadoc(String path, String expect) {
         File testSrc = new File(System.getProperty("test.src"));
         String[] args = {
+            "-Xdoclint:none",
             "-source", "1.4", // enables certain Parser warnings
             "-bootclasspath", System.getProperty("sun.boot.class.path"),
             "-classpath", ".",
diff --git a/test/tools/javadoc/6964914/TestStdDoclet.java b/test/tools/javadoc/6964914/TestStdDoclet.java
index 9714557..ce6a39f 100644
--- a/test/tools/javadoc/6964914/TestStdDoclet.java
+++ b/test/tools/javadoc/6964914/TestStdDoclet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 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
@@ -57,6 +57,7 @@ public class TestStdDoclet {
         Process p = new ProcessBuilder()
             .command(javadoc.getPath(),
                 "-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
+                "-Xdoclint:none",
                 "-package",
                 new File(testSrc, thisClassName + ".java").getPath())
             .redirectErrorStream(true)
diff --git a/test/tools/javadoc/CheckResourceKeys.java b/test/tools/javadoc/CheckResourceKeys.java
new file mode 100644
index 0000000..b3de88f
--- /dev/null
+++ b/test/tools/javadoc/CheckResourceKeys.java
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+/*
+ * @test
+ * @bug 8000612
+ * @summary need test program to validate javadoc resource bundles
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.tools.classfile.*;
+
+/**
+ * Compare string constants in javadoc classes against keys in javadoc resource bundles.
+ */
+public class CheckResourceKeys {
+    /**
+     * Main program.
+     * Options:
+     * -finddeadkeys
+     *      look for keys in resource bundles that are no longer required
+     * -findmissingkeys
+     *      look for keys in resource bundles that are missing
+     *
+     * @throws Exception if invoked by jtreg and errors occur
+     */
+    public static void main(String... args) throws Exception {
+        CheckResourceKeys c = new CheckResourceKeys();
+        if (c.run(args))
+            return;
+
+        if (is_jtreg())
+            throw new Exception(c.errors + " errors occurred");
+        else
+            System.exit(1);
+    }
+
+    static boolean is_jtreg() {
+        return (System.getProperty("test.src") != null);
+    }
+
+    /**
+     * Main entry point.
+     */
+    boolean run(String... args) throws Exception {
+        boolean findDeadKeys = false;
+        boolean findMissingKeys = false;
+
+        if (args.length == 0) {
+            if (is_jtreg()) {
+                findDeadKeys = true;
+                findMissingKeys = true;
+            } else {
+                System.err.println("Usage: java CheckResourceKeys <options>");
+                System.err.println("where options include");
+                System.err.println("  -finddeadkeys      find keys in resource bundles which are no longer required");
+                System.err.println("  -findmissingkeys   find keys in resource bundles that are required but missing");
+                return true;
+            }
+        } else {
+            for (String arg: args) {
+                if (arg.equalsIgnoreCase("-finddeadkeys"))
+                    findDeadKeys = true;
+                else if (arg.equalsIgnoreCase("-findmissingkeys"))
+                    findMissingKeys = true;
+                else
+                    error("bad option: " + arg);
+            }
+        }
+
+        if (errors > 0)
+            return false;
+
+        Set<String> codeKeys = getCodeKeys();
+        Set<String> resourceKeys = getResourceKeys();
+
+        System.err.println("found " + codeKeys.size() + " keys in code");
+        System.err.println("found " + resourceKeys.size() + " keys in resource bundles");
+
+        if (findDeadKeys)
+            findDeadKeys(codeKeys, resourceKeys);
+
+        if (findMissingKeys)
+            findMissingKeys(codeKeys, resourceKeys);
+
+        return (errors == 0);
+    }
+
+    /**
+     * Find keys in resource bundles which are probably no longer required.
+     * A key is required if there is a string in the code that is a resource key,
+     * or if the key is well-known according to various pragmatic rules.
+     */
+    void findDeadKeys(Set<String> codeKeys, Set<String> resourceKeys) {
+        for (String rk: resourceKeys) {
+            if (codeKeys.contains(rk))
+                continue;
+
+            error("Resource key not found in code: " + rk);
+        }
+    }
+
+    /**
+     * For all strings in the code that look like they might be
+     * a resource key, verify that a key exists.
+     */
+    void findMissingKeys(Set<String> codeKeys, Set<String> resourceKeys) {
+        for (String ck: codeKeys) {
+            if (resourceKeys.contains(ck))
+                continue;
+            error("No resource for \"" + ck + "\"");
+        }
+    }
+
+    /**
+     * Get the set of strings from (most of) the javadoc classfiles.
+     */
+    Set<String> getCodeKeys() throws IOException {
+        Set<String> results = new TreeSet<String>();
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        JavaFileManager fm = c.getStandardFileManager(null, null, null);
+        JavaFileManager.Location javadocLoc = findJavadocLocation(fm);
+        String[] pkgs = {
+            "com.sun.tools.doclets",
+            "com.sun.tools.javadoc"
+        };
+        for (String pkg: pkgs) {
+            for (JavaFileObject fo: fm.list(javadocLoc,
+                    pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
+                String name = fo.getName();
+                // ignore resource files
+                if (name.matches(".*resources.[A-Za-z_0-9]+\\.class.*"))
+                    continue;
+                scan(fo, results);
+            }
+        }
+
+        // special handling for code strings synthesized in
+        // com.sun.tools.doclets.internal.toolkit.util.Util.getTypeName
+        String[] extras = {
+            "AnnotationType", "Class", "Enum", "Error", "Exception", "Interface"
+        };
+        for (String s: extras) {
+            if (results.contains("doclet." + s))
+                results.add("doclet." + s.toLowerCase());
+        }
+
+        // special handling for code strings synthesized in
+        // com.sun.tools.javadoc.Messager
+        results.add("javadoc.error.msg");
+        results.add("javadoc.note.msg");
+        results.add("javadoc.note.pos.msg");
+        results.add("javadoc.warning.msg");
+
+        return results;
+    }
+
+    // depending on how the test is run, javadoc may be on bootclasspath or classpath
+    JavaFileManager.Location findJavadocLocation(JavaFileManager fm) {
+        JavaFileManager.Location[] locns =
+            { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH };
+        try {
+            for (JavaFileManager.Location l: locns) {
+                JavaFileObject fo = fm.getJavaFileForInput(l,
+                    "com.sun.tools.javadoc.Main", JavaFileObject.Kind.CLASS);
+                if (fo != null) {
+                    System.err.println("found javadoc in " + l);
+                    return l;
+                }
+            }
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+        throw new IllegalStateException("Cannot find javadoc");
+    }
+
+    /**
+     * Get the set of strings from a class file.
+     * Only strings that look like they might be a resource key are returned.
+     */
+    void scan(JavaFileObject fo, Set<String> results) throws IOException {
+        //System.err.println("scan " + fo.getName());
+        InputStream in = fo.openInputStream();
+        try {
+            ClassFile cf = ClassFile.read(in);
+            for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) {
+                if (cpinfo.getTag() == ConstantPool.CONSTANT_Utf8) {
+                    String v = ((ConstantPool.CONSTANT_Utf8_info) cpinfo).value;
+                    if (v.matches("(doclet|main|javadoc|tag)\\.[A-Za-z0-9-_.]+"))
+                        results.add(v);
+                }
+            }
+        } catch (ConstantPoolException ignore) {
+        } finally {
+            in.close();
+        }
+    }
+
+    /**
+     * Get the set of keys from the javadoc resource bundles.
+     */
+    Set<String> getResourceKeys() {
+        String[] names = {
+                "com.sun.tools.doclets.formats.html.resources.standard",
+                "com.sun.tools.doclets.internal.toolkit.resources.doclets",
+                "com.sun.tools.javadoc.resources.javadoc",
+        };
+        Set<String> results = new TreeSet<String>();
+        for (String name : names) {
+            ResourceBundle b = ResourceBundle.getBundle(name);
+            results.addAll(b.keySet());
+        }
+        return results;
+    }
+
+    /**
+     * Report an error.
+     */
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javadoc/MaxWarns.java b/test/tools/javadoc/MaxWarns.java
new file mode 100644
index 0000000..93b870f
--- /dev/null
+++ b/test/tools/javadoc/MaxWarns.java
@@ -0,0 +1,112 @@
+/*
+ * 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 8005644
+ * @summary set default max errs and max warns
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class MaxWarns {
+    public static void main(String... args) throws Exception {
+        new MaxWarns().run();
+    }
+
+    void run() throws Exception {
+        final int defaultMaxWarns = 100;
+        final int genWarns = 150;
+        File f = genSrc(genWarns);
+        String out = javadoc(f);
+        check(out, defaultMaxWarns);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    File genSrc(int count) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        sb.append("package p;\n")
+            .append("public class C {\n")
+            .append("    /**\n");
+        for (int i = 0; i < count; i++)
+            sb.append("     * @param i").append(i).append(" does not exist!\n");
+        sb.append("     */\n")
+            .append("    public void m() { }\n")
+            .append("}\n");
+        File srcDir = new File("src");
+        srcDir.mkdirs();
+        File f = new File(srcDir, "C.java");
+        try (FileWriter fw = new FileWriter(f)) {
+            fw.write(sb.toString());
+        }
+        return f;
+    }
+
+    String javadoc(File f) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { "-Xdoclint:none", "-d", "api", f.getPath() };
+        int rc = com.sun.tools.javadoc.Main.execute("javadoc", pw, pw, pw,
+                com.sun.tools.doclets.standard.Standard.class.getName(), args);
+        pw.flush();
+        return sw.toString();
+    }
+
+    void check(String out, int count) {
+        System.err.println(out);
+        Pattern warn = Pattern.compile("warning - @param argument \"i[0-9]+\" is not a parameter name");
+        Matcher m = warn.matcher(out);
+        int n = 0;
+        for (int start = 0; m.find(start); start = m.start() + 1) {
+            n++;
+        }
+        if (n != count)
+            error("unexpected number of warnings reported: " + n + "; expected: " + count);
+
+        Pattern warnCount = Pattern.compile("(?ms).*^([0-9]+) warnings$.*");
+        m = warnCount.matcher(out);
+        if (m.matches()) {
+            n = Integer.parseInt(m.group(1));
+            if (n != count)
+                error("unexpected number of warnings reported: " + n + "; expected: " + count);
+        } else
+            error("total count not found");
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
+
diff --git a/test/tools/javadoc/T4696488.java b/test/tools/javadoc/T4696488.java
new file mode 100644
index 0000000..0c7a7c8
--- /dev/null
+++ b/test/tools/javadoc/T4696488.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ * 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 com.sun.tools.doclets.internal.toolkit.Configuration;
+
+/**
+ * @test
+ * @bug     4696488
+ * @summary javadoc doesn't handle UNC paths for destination directory
+ * @author  Jesse Glick
+ * @run main T4696488 T4696488.java
+ */
+public class T4696488 {
+
+    public static void main(String... args) {
+        System.setProperty("file.separator", "/");
+        assertAddTrailingFileSep("/path/to/dir", "/path/to/dir/");
+        assertAddTrailingFileSep("/path/to/dir/", "/path/to/dir/");
+        assertAddTrailingFileSep("/path/to/dir//", "/path/to/dir/");
+        System.setProperty("file.separator", "\\");
+        assertAddTrailingFileSep("C:\\path\\to\\dir", "C:\\path\\to\\dir\\");
+        assertAddTrailingFileSep("C:\\path\\to\\dir\\", "C:\\path\\to\\dir\\");
+        assertAddTrailingFileSep("C:\\path\\to\\dir\\\\", "C:\\path\\to\\dir\\");
+        assertAddTrailingFileSep("\\\\server\\share\\path\\to\\dir", "\\\\server\\share\\path\\to\\dir\\");
+        assertAddTrailingFileSep("\\\\server\\share\\path\\to\\dir\\", "\\\\server\\share\\path\\to\\dir\\");
+        assertAddTrailingFileSep("\\\\server\\share\\path\\to\\dir\\\\", "\\\\server\\share\\path\\to\\dir\\");
+    }
+
+    private static void assertAddTrailingFileSep(String input, String expectedOutput) {
+        String output = Configuration.addTrailingFileSep(input);
+        if (!expectedOutput.equals(output)) {
+            throw new Error("expected " + expectedOutput + " but was " + output);
+        }
+    }
+
+}
diff --git a/test/tools/javadoc/T6551367.java b/test/tools/javadoc/T6551367.java
index 04e6bdc..f82e7ca 100644
--- a/test/tools/javadoc/T6551367.java
+++ b/test/tools/javadoc/T6551367.java
@@ -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
@@ -46,7 +46,7 @@ public class T6551367 extends com.sun.tools.doclets.standard.Standard {
             File source = new File(testSrc, file);
             int rc = execute("javadoc", "T6551367",
               T6551367.class.getClassLoader(),
-              new String[]{source.getPath(), "-d", destDir.getAbsolutePath()});
+              new String[]{"-Xdoclint:none", source.getPath(), "-d", destDir.getAbsolutePath()});
             if (rc != 0)
                 throw new Error("unexpected exit from javadoc: " + rc);
         }
diff --git a/test/tools/javadoc/api/basic/APITest.java b/test/tools/javadoc/api/basic/APITest.java
new file mode 100644
index 0000000..358b6b3
--- /dev/null
+++ b/test/tools/javadoc/api/basic/APITest.java
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ *
+ * 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.io.File;
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+
+/*
+ * Superclass with utility methods for API tests.
+ */
+class APITest {
+    protected APITest() { }
+
+    /** Marker annotation for test cases. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /** Invoke all methods annotated with @Test. */
+    protected void run() throws Exception {
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                testCount++;
+                testName = m.getName();
+                System.err.println("test: " + testName);
+                try {
+                    m.invoke(this, new Object[] { });
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                System.err.println();
+            }
+        }
+
+        if (testCount == 0)
+            error("no tests found");
+
+        StringBuilder summary = new StringBuilder();
+        if (testCount != 1)
+            summary.append(testCount).append(" tests");
+        if (errorCount > 0) {
+            if (summary.length() > 0) summary.append(", ");
+            summary.append(errorCount).append(" errors");
+        }
+        System.err.println(summary);
+        if (errorCount > 0)
+            throw new Exception(errorCount + " errors found");
+    }
+
+    /**
+     * Create a directory in which to store generated doc files.
+     * Avoid using the default (current) directory, so that we can
+     * be sure that javadoc is writing in the intended location,
+     * not a default location.
+     */
+    protected File getOutDir() {
+        File dir = new File(testName);
+        dir.mkdirs();
+        return dir;
+    }
+
+    /**
+     * Create a directory in which to store generated doc files.
+     * Avoid using the default (current) directory, so that we can
+     * be sure that javadoc is writing in the intended location,
+     * not a default location.
+     */
+    protected File getOutDir(String path) {
+        File dir = new File(testName, path);
+        dir.mkdirs();
+        return dir;
+    }
+
+    protected JavaFileObject createSimpleJavaFileObject() {
+        return createSimpleJavaFileObject("pkg/C", "package pkg; public class C { }");
+    }
+
+    protected JavaFileObject createSimpleJavaFileObject(final String binaryName, final String content) {
+        return new SimpleJavaFileObject(
+                URI.create("myfo:///" + binaryName + ".java"), JavaFileObject.Kind.SOURCE) {
+            @Override
+            public CharSequence getCharContent(boolean ignoreEncoding) {
+                return content;
+            }
+        };
+    }
+
+    protected void checkFiles(File dir, Set<String> expectFiles) {
+        Set<File> files = new HashSet<File>();
+        listFiles(dir, files);
+        Set<String> foundFiles = new HashSet<String>();
+        URI dirURI = dir.toURI();
+        for (File f: files)
+            foundFiles.add(dirURI.relativize(f.toURI()).getPath());
+        checkFiles(foundFiles, expectFiles, dir);
+    }
+
+    protected void checkFiles(Path dir, Set<String> expectFiles) throws IOException {
+        Set<Path> files = new HashSet<Path>();
+        listFiles(dir, files);
+        Set<String> foundFiles = new HashSet<String>();
+        for (Path f: files) {
+            foundFiles.add(dir.relativize(f).toString().replace(f.getFileSystem().getSeparator(), "/"));
+        }
+        checkFiles(foundFiles, expectFiles, dir);
+    }
+
+    private void checkFiles(Set<String> foundFiles, Set<String> expectFiles, Object where) {
+        if (!foundFiles.equals(expectFiles)) {
+            Set<String> missing = new TreeSet<String>(expectFiles);
+            missing.removeAll(foundFiles);
+            if (!missing.isEmpty())
+                error("the following files were not found in " + where + ": " + missing);
+            Set<String> unexpected = new TreeSet<String>(foundFiles);
+            unexpected.removeAll(expectFiles);
+            if (!unexpected.isEmpty())
+                error("the following unexpected files were found in " + where + ": " + unexpected);
+        }
+    }
+
+    protected void listFiles(File dir, Set<File> files) {
+        for (File f: dir.listFiles()) {
+            if (f.isDirectory())
+                listFiles(f, files);
+            else if (f.isFile())
+                files.add(f);
+        }
+    }
+
+    private void listFiles(Path dir, Set<Path> files) throws IOException {
+        for (Path f: Files.newDirectoryStream(dir)) {
+            if (Files.isDirectory(f))
+                listFiles(f, files);
+            else if (Files.isRegularFile(f))
+                files.add(f);
+        }
+    }
+
+    protected void error(String msg) {
+        System.err.println("Error: " + msg);
+        errorCount++;
+    }
+
+    protected int testCount;
+    protected int errorCount;
+
+    protected String testName;
+
+    /**
+     * Standard files generated by processing a documented class pkg.C.
+     */
+    protected static Set<String> standardExpectFiles = new HashSet<String>(Arrays.asList(
+        "allclasses-frame.html",
+        "allclasses-noframe.html",
+        "constant-values.html",
+        "deprecated-list.html",
+        "help-doc.html",
+        "index-all.html",
+        "index.html",
+        "overview-tree.html",
+        "package-list",
+        "pkg/C.html",
+        "pkg/package-frame.html",
+        "pkg/package-summary.html",
+        "pkg/package-tree.html",
+        "resources/background.gif",
+        "resources/tab.gif",
+        "resources/activetitlebar_end.gif",
+        "resources/activetitlebar.gif",
+        "resources/titlebar_end.gif",
+        "resources/titlebar.gif",
+        "script.js",
+        "stylesheet.css"
+    ));
+}
+
diff --git a/test/tools/javadoc/api/basic/DocletPathTest.java b/test/tools/javadoc/api/basic/DocletPathTest.java
new file mode 100644
index 0000000..daf40cc
--- /dev/null
+++ b/test/tools/javadoc/api/basic/DocletPathTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main DocletPathTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for locating a doclet via the file manager's DOCLET_PATH.
+ */
+public class DocletPathTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new DocletPathTest().run();
+    }
+
+    /**
+     * Verify that an alternate doclet can be specified, and located via
+     * the file manager's DOCLET_PATH.
+     */
+    @Test
+    public void testDocletPath() throws Exception {
+        JavaFileObject docletSrc =
+                createSimpleJavaFileObject("DocletOnDocletPath", docletSrcText);
+        File docletDir = getOutDir("classes");
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
+        cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(docletDir));
+        Iterable<? extends JavaFileObject> cfiles = Arrays.asList(docletSrc);
+        if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+            throw new Exception("cannot compile doclet");
+
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir("api");
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        fm.setLocation(DocumentationTool.Location.DOCLET_PATH, Arrays.asList(docletDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-doclet", "DocletOnDocletPath");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+        boolean ok = t.call();
+        String out = sw.toString();
+        System.err.println(">>" + out + "<<");
+        if (ok) {
+            if (out.contains(TEST_STRING)) {
+                System.err.println("doclet executed as expected");
+            } else {
+                error("test string not found in doclet output");
+            }
+        } else {
+            error("task failed");
+        }
+    }
+
+    private static final String TEST_STRING = "DocletOnDocletPath found and running";
+
+    private static final String docletSrcText =
+        "import com.sun.javadoc.*;\n" +
+        "public class DocletOnDocletPath {\n" +
+        "    public static boolean start(RootDoc doc) {\n" +
+        "        doc.printNotice(\"" + TEST_STRING + "\");\n" +
+        "        return true;\n" +
+        "    }\n" +
+        "    public static int optionLength(String option) { return 0; }\n" +
+        "    public static boolean validOptions(String options[][],\n" +
+        "            DocErrorReporter reporter) { return true; }\n" +
+        "    public static LanguageVersion languageVersion() {\n" +
+        "        return LanguageVersion.JAVA_1_1;\n" +
+        "    }\n" +
+        "}\n";
+}
+
diff --git a/test/tools/javadoc/api/basic/GetSourceVersionsTest.java b/test/tools/javadoc/api/basic/GetSourceVersionsTest.java
new file mode 100644
index 0000000..1af7393
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetSourceVersionsTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetSourceVersionsTest
+ */
+
+import java.util.EnumSet;
+import java.util.Set;
+import javax.lang.model.SourceVersion;
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getSourceVersions method.
+ */
+public class GetSourceVersionsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetSourceVersionsTest().run();
+    }
+
+    /**
+     * Verify getSourceVersions.
+     */
+    @Test
+    public void testRun() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        Set<SourceVersion> found = tool.getSourceVersions();
+        Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
+        if (!expect.equals(found)) {
+            System.err.println("expect: " + expect);
+            System.err.println(" found: " + expect);
+            error("unexpected versions");
+        }
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java b/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java
new file mode 100644
index 0000000..fafc028
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_DiagListenerTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_DiagListenerTest
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  diagnosticListener  parameter.
+ */
+public class GetTask_DiagListenerTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_DiagListenerTest().run();
+    }
+
+    /**
+     * Verify that a diagnostic listener can be specified.
+     * Note that messages from the tool and doclet are imperfectly modeled
+     * because the DocErrorReporter API works in terms of localized strings
+     * and file:line positions. Therefore, messages reported via DocErrorReporter
+     * and simply wrapped and passed through.
+     */
+    @Test
+    public void testDiagListener() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", "package pkg; public error { }");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        DocumentationTask t = tool.getTask(null, fm, dc, null, null, files);
+        if (t.call()) {
+            throw new Exception("task succeeded unexpectedly");
+        } else {
+            List<String> diagCodes = new ArrayList<String>();
+            for (Diagnostic d: dc.getDiagnostics()) {
+                System.err.println(d);
+                diagCodes.add(d.getCode());
+            }
+            List<String> expect = Arrays.asList(
+                    "javadoc.note.msg",         // Loading source file
+                    "compiler.err.expected3",   // class, interface, or enum expected
+                    "javadoc.note.msg");        // 1 error
+            if (!diagCodes.equals(expect))
+                throw new Exception("unexpected diagnostics occurred");
+            System.err.println("diagnostics received as expected");
+        }
+    }
+
+}
+
diff --git a/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java b/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java
new file mode 100644
index 0000000..c508504
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_DocletClassTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_DocletClassTest
+ */
+
+import com.sun.javadoc.DocErrorReporter;
+import com.sun.javadoc.LanguageVersion;
+import com.sun.javadoc.RootDoc;
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Random;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  docletClass  parameter.
+ */
+public class GetTask_DocletClassTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_DocletClassTest().run();
+    }
+
+    /**
+     * Verify that an alternate doclet can be specified.
+     *
+     * There is no standard interface or superclass for a doclet;
+     * the only requirement is that it provides static methods that
+     * can be invoked via reflection. So, for now, the doclet is
+     * specified as a class.
+     * Because we cannot create and use a unique instance of the class,
+     * we verify that the doclet has been called by having it record
+     * (in a static field!) the comment from the last time it was invoked,
+     * which is randomly generated each time the test is run.
+     */
+    @Test
+    public void testDoclet() throws Exception {
+        Random r = new Random();
+        int key = r.nextInt();
+        JavaFileObject srcFile = createSimpleJavaFileObject(
+                "pkg/C",
+                "package pkg; /** " + key + "*/ public class C { }");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, TestDoclet.class, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            if (TestDoclet.lastCaller.equals(String.valueOf(key)))
+                System.err.println("found expected key: " + key);
+            else
+                error("Expected key not found");
+            checkFiles(outDir, Collections.<String>emptySet());
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    public static class TestDoclet {
+        static String lastCaller;
+        public static boolean start(RootDoc root) {
+            lastCaller = root.classNamed("pkg.C").commentText().trim();
+            return true;
+        }
+
+        public static int optionLength(String option) {
+            return 0;  // default is option unknown
+        }
+
+        public static boolean validOptions(String options[][],
+                DocErrorReporter reporter) {
+            return true;  // default is options are valid
+        }
+
+        public static LanguageVersion languageVersion() {
+            return LanguageVersion.JAVA_1_1;
+        }
+    }
+
+    /**
+     * Verify that exceptions from a doclet are thrown as expected.
+     */
+    @Test
+    public void testBadDoclet() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, BadDoclet.class, null, files);
+        try {
+            t.call();
+            error("call completed without exception");
+        } catch (RuntimeException e) {
+            Throwable c = e.getCause();
+            if (c.getClass() == UnexpectedError.class)
+                System.err.println("exception caught as expected: " + c);
+            else
+                throw e;
+        }
+    }
+
+    public static class UnexpectedError extends Error { }
+
+    public static class BadDoclet {
+        public static boolean start(RootDoc root) {
+            throw new UnexpectedError();
+        }
+
+        public static int optionLength(String option) {
+            return 0;  // default is option unknown
+        }
+
+        public static boolean validOptions(String options[][],
+                DocErrorReporter reporter) {
+            return true;  // default is options are valid
+        }
+
+        public static LanguageVersion languageVersion() {
+            return LanguageVersion.JAVA_1_1;
+        }
+    }
+
+}
+
diff --git a/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java b/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java
new file mode 100644
index 0000000..4532e61
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_FileManagerTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Set;
+
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+import javax.tools.ToolProvider;
+
+import com.sun.tools.javac.nio.JavacPathFileManager;
+import com.sun.tools.javac.nio.PathFileManager;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * Tests for DocumentationTool.getTask  fileManager  parameter.
+ */
+public class GetTask_FileManagerTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_FileManagerTest().run();
+    }
+
+    /**
+     * Verify that an alternate file manager can be specified:
+     * in this case, a PathFileManager.
+     */
+    @Test
+    public void testFileManager() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        PathFileManager fm = new JavacPathFileManager(new Context(), false, null);
+        Path outDir = getOutDir().toPath();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify that exceptions from a bad file manager are thrown as expected.
+     */
+    @Test
+    public void testBadFileManager() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        PathFileManager fm = new JavacPathFileManager(new Context(), false, null) {
+            @Override
+            public Iterable<JavaFileObject> list(Location location,
+                    String packageName,
+                    Set<Kind> kinds,
+                    boolean recurse)
+                    throws IOException {
+                throw new UnexpectedError();
+            }
+        };
+        Path outDir = getOutDir().toPath();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        try {
+            t.call();
+            error("call completed without exception");
+        } catch (RuntimeException e) {
+            Throwable c = e.getCause();
+            if (c.getClass() == UnexpectedError.class)
+                System.err.println("exception caught as expected: " + c);
+            else
+                throw e;
+        }
+    }
+
+    public static class UnexpectedError extends Error { }
+
+}
diff --git a/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java b/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java
new file mode 100644
index 0000000..fc3cd14
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_FileObjectsTest.java
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_FileObjectsTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  fileObjects  parameter.
+ */
+public class GetTask_FileObjectsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_FileObjectsTest().run();
+    }
+
+    /**
+     * Verify that expected output files are written via the file manager,
+     * for a source file read from the file system with StandardJavaFileManager.
+     */
+    @Test
+    public void testStandardFileObject() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.java");
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify that expected output files are written via the file manager,
+     * for an in-memory file object.
+     */
+    @Test
+    public void testMemoryFileObject() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    /**
+     * Verify bad file object is handled correctly.
+     */
+    @Test
+    public void testBadFileObject() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.class");  // unacceptable file kind
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(srcFile);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (IllegalArgumentException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+    /**
+     * Verify null is handled correctly.
+     */
+    @Test
+    public void testNull() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList((JavaFileObject) null);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+}
+
diff --git a/test/tools/javadoc/api/basic/GetTask_OptionsTest.java b/test/tools/javadoc/api/basic/GetTask_OptionsTest.java
new file mode 100644
index 0000000..c6da9c8
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_OptionsTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_OptionsTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  options  parameter.
+ */
+public class GetTask_OptionsTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_OptionsTest().run();
+    }
+
+    /**
+     * Verify that expected output files are written for given options.
+     */
+    @Test
+    public void testNoIndex() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-noindex");
+        DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            Set<String> expectFiles = new TreeSet<String>(standardExpectFiles);
+            expectFiles.remove("index-all.html");
+            checkFiles(outDir, expectFiles);
+        } else {
+            error("task failed");
+        }
+    }
+
+    /**
+     * Verify null is handled correctly.
+     */
+    @Test
+    public void testNull() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<String> options = Arrays.asList((String) null);
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        try {
+            DocumentationTask t = tool.getTask(null, fm, null, null, options, files);
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+
+}
+
diff --git a/test/tools/javadoc/api/basic/GetTask_WriterTest.java b/test/tools/javadoc/api/basic/GetTask_WriterTest.java
new file mode 100644
index 0000000..389b8d6
--- /dev/null
+++ b/test/tools/javadoc/api/basic/GetTask_WriterTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main GetTask_WriterTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Arrays;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.getTask  writer  parameter.
+ */
+public class GetTask_WriterTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new GetTask_WriterTest().run();
+    }
+
+    /**
+     * Verify that a writer can be provided.
+     */
+    @Test
+    public void testWriter() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            checkFiles(outDir, standardExpectFiles);
+            String out = sw.toString();
+            System.err.println(">>" + out + "<<");
+            for (String f: standardExpectFiles) {
+                String f1 = f.replace('/', File.separatorChar);
+                if (f1.endsWith(".html") && !out.contains(f1))
+                    throw new Exception("expected string not found: " + f1);
+            }
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/IsSupportedOptionTest.java b/test/tools/javadoc/api/basic/IsSupportedOptionTest.java
new file mode 100644
index 0000000..f10c957
--- /dev/null
+++ b/test/tools/javadoc/api/basic/IsSupportedOptionTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main IsSupportedOptionTest
+ */
+
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.usSupportedOption method.
+ */
+public class IsSupportedOptionTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new IsSupportedOptionTest().run();
+    }
+
+    /**
+     * Verify that isSupportedOption method can be invoked.
+     */
+    @Test
+    public void test() throws Exception {
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        check(tool, "-sourcepath", 1);
+        check(tool, "-verbose", 0);
+        check(tool, "-ZZZ", -1);
+
+        try {
+            check(tool, null, -1);
+            error("null was accepted without exception");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    private void check(DocumentationTool tool, String option, int numArgs) {
+        System.err.println("check " + option);
+        int n = tool.isSupportedOption(option);
+        if (n != numArgs)
+            error("unexpected result for option: " + option + ": " + n);
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/JavadocTaskImplTest.java b/test/tools/javadoc/api/basic/JavadocTaskImplTest.java
new file mode 100644
index 0000000..9a372cd
--- /dev/null
+++ b/test/tools/javadoc/api/basic/JavadocTaskImplTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main JavadocTaskImplTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.Messager;
+import com.sun.tools.javadoc.api.JavadocTaskImpl;
+
+/**
+ *  Misc tests for JavacTaskImpl.
+ */
+public class JavadocTaskImplTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new JavadocTaskImplTest().run();
+    }
+
+    @Test
+    public void testRawCall() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+
+        @SuppressWarnings("rawtypes")
+        Callable t = tool.getTask(null, fm, null, null, null, files);
+
+        if (t.call() == Boolean.TRUE) {
+            System.err.println("task succeeded");
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    @Test
+    public void testDirectAccess1() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Context c = new Context();
+        Messager.preRegister(c, "javadoc");
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        DocumentationTask t = new JavadocTaskImpl(c, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+
+    @Test
+    public void testDirectAccess2() throws Exception {
+        JavaFileObject srcFile = null; // error, provokes NPE
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Context c = new Context();
+        Messager.preRegister(c, "javadoc");
+        StandardJavaFileManager fm = new JavacFileManager(c, true, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        try {
+            DocumentationTask t = new JavadocTaskImpl(c, null, null, files);;
+            error("getTask succeeded, no exception thrown");
+        } catch (NullPointerException e) {
+            System.err.println("exception caught as expected: " + e);
+        }
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/RunTest.java b/test/tools/javadoc/api/basic/RunTest.java
new file mode 100644
index 0000000..380f5b6
--- /dev/null
+++ b/test/tools/javadoc/api/basic/RunTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 6493690 8007490
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main RunTest
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+import javax.tools.DocumentationTool;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for DocumentationTool.run method.
+ */
+public class RunTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new RunTest().run();
+    }
+
+    /**
+     * Verify that run method can be invoked.
+     */
+    @Test
+    public void testRunOK() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.java");
+        File outDir = getOutDir();
+        String[] args = { "-d", outDir.getPath(), srcFile.getPath() };
+
+        ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        int rc = tool.run(null, stdout, stderr, args);
+        System.err.println("stdout >>" + stdout.toString() + "<<");
+        System.err.println("stderr >>" + stderr.toString() + "<<");
+
+        if (rc == 0) {
+            System.err.println("call succeeded");
+            checkFiles(outDir, standardExpectFiles);
+            String out = stdout.toString();
+            for (String f: standardExpectFiles) {
+                String f1 = f.replace('/', File.separatorChar);
+                if (f1.endsWith(".html") && !out.contains(f1))
+                    error("expected string not found: " + f1);
+            }
+        } else {
+            error("call failed");
+        }
+    }
+
+    /**
+     * Verify that run method can be invoked.
+     */
+    @Test
+    public void testRunFail() throws Exception {
+        File outDir = getOutDir();
+        String badfile = "badfile.java";
+        String[] args = { "-d", outDir.getPath(), badfile };
+
+        ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        int rc = tool.run(null, stdout, stderr, args);
+        System.err.println("stdout >>" + stdout.toString() + "<<");
+        System.err.println("stderr >>" + stderr.toString() + "<<");
+
+        if (rc == 0) {
+            error("call succeeded unexpectedly");
+        } else {
+            String err = stderr.toString();
+            if (err.contains(badfile))
+                System.err.println("call failed as expected");
+            else
+                error("expected diagnostic not found");
+        }
+    }
+
+    /**
+     * Verify that null args are accepted.
+     */
+    @Test
+    public void testNullArgs() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File srcFile = new File(testSrc, "pkg/C.java");
+        File outDir = getOutDir();
+        String[] args = { "-d", outDir.getPath(), srcFile.getPath() };
+
+        ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+        PrintStream prevStdout = System.out;
+        System.setOut(new PrintStream(stdout));
+
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        PrintStream prevStderr = System.err;
+        System.setErr(new PrintStream(stderr));
+
+        int rc ;
+        try {
+            DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+            rc = tool.run(null, null, null, args);
+        } finally {
+            System.setOut(prevStdout);
+            System.setErr(prevStderr);
+        }
+
+        System.err.println("stdout >>" + stdout.toString() + "<<");
+        System.err.println("stderr >>" + stderr.toString() + "<<");
+
+        if (rc == 0) {
+            System.err.println("call succeeded");
+            checkFiles(outDir, standardExpectFiles);
+            String out = stdout.toString();
+            for (String f: standardExpectFiles) {
+                String f1 = f.replace('/', File.separatorChar);
+                if (f1.endsWith(".html") && !out.contains(f1))
+                    error("expected string not found: " + f1);
+            }
+        } else {
+            error("call failed");
+        }
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/TagletPathTest.java b/test/tools/javadoc/api/basic/TagletPathTest.java
new file mode 100644
index 0000000..52dd5c8
--- /dev/null
+++ b/test/tools/javadoc/api/basic/TagletPathTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main TagletPathTest
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for locating a doclet via the file manager's DOCLET_PATH.
+ */
+public class TagletPathTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new TagletPathTest().run();
+    }
+
+    /**
+     * Verify that a taglet can be specified, and located via
+     * the file manager's TAGLET_PATH.
+     */
+    @Test
+    public void testTagletPath() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File tagletSrcFile = new File(testSrc, "taglets/UnderlineTaglet.java");
+        File tagletDir = getOutDir("classes");
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager cfm = compiler.getStandardFileManager(null, null, null);
+        cfm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tagletDir));
+        Iterable<? extends JavaFileObject> cfiles = cfm.getJavaFileObjects(tagletSrcFile);
+        if (!compiler.getTask(null, cfm, null, null, null, cfiles).call())
+            throw new Exception("cannot compile taglet");
+
+        JavaFileObject srcFile = createSimpleJavaFileObject("pkg/C", testSrcText);
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir("api");
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        fm.setLocation(DocumentationTool.Location.TAGLET_PATH, Arrays.asList(tagletDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        Iterable<String> options = Arrays.asList("-taglet", "UnderlineTaglet");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        DocumentationTask t = tool.getTask(pw, fm, null, null, options, files);
+        boolean ok = t.call();
+        String out = sw.toString();
+        System.err.println(">>" + out + "<<");
+        if (ok) {
+            File f = new File(outDir, "pkg/C.html");
+            List<String> doc = Files.readAllLines(f.toPath(), Charset.defaultCharset());
+            for (String line: doc) {
+                if (line.contains("<u>" + TEST_STRING + "</u>")) {
+                    System.err.println("taglet executed as expected");
+                    return;
+                }
+            }
+            error("expected text not found in output " + f);
+        } else {
+            error("task failed");
+        }
+    }
+
+    static final String TEST_STRING = "xyzzy";
+    static final String testSrcText =
+            "package pkg;\n" +
+            "/** {@underline " + TEST_STRING + "} */\n" +
+            "public class C { }";
+}
+
diff --git a/test/tools/javadoc/api/basic/Task_reuseTest.java b/test/tools/javadoc/api/basic/Task_reuseTest.java
new file mode 100644
index 0000000..5bda0d3
--- /dev/null
+++ b/test/tools/javadoc/api/basic/Task_reuseTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ *
+ * 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 6493690
+ * @summary javadoc should have a javax.tools.Tool service provider
+ * @build APITest
+ * @run main Task_reuseTest
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Locale;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+/**
+ * Tests for reusing a documentation task.
+ */
+public class Task_reuseTest extends APITest {
+    public static void main(String... args) throws Exception {
+        new Task_reuseTest().run();
+    }
+
+    /**
+     * Verify that call can only be called once.
+     */
+    @Test
+    public void testReuse() throws Exception {
+        DocumentationTask t = getAndRunTask();
+        try {
+            t.call();
+            error("task was reused without exception");
+        } catch (IllegalStateException e) {
+            System.err.println("caught exception " + e);
+        }
+    }
+
+    /**
+     * Verify that cannot update task after call
+     */
+    @Test
+    public void testUpdateSetLocale() throws Exception {
+        DocumentationTask t = getAndRunTask();
+        try {
+            t.setLocale(Locale.getDefault());
+            error("task was reused without exception");
+        } catch (IllegalStateException e) {
+            System.err.println("caught exception " + e);
+        }
+    }
+
+    private DocumentationTask getAndRunTask() throws Exception {
+        JavaFileObject srcFile = createSimpleJavaFileObject();
+        DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        File outDir = getOutDir();
+        fm.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(outDir));
+        Iterable<? extends JavaFileObject> files = Arrays.asList(srcFile);
+        DocumentationTask t = tool.getTask(null, fm, null, null, null, files);
+        if (t.call()) {
+            System.err.println("task succeeded");
+            return t;
+        } else {
+            throw new Exception("task failed");
+        }
+    }
+}
+
diff --git a/test/tools/javadoc/api/basic/pkg/C.java b/test/tools/javadoc/api/basic/pkg/C.java
new file mode 100644
index 0000000..74383c0
--- /dev/null
+++ b/test/tools/javadoc/api/basic/pkg/C.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ * 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 C { }
+
diff --git a/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java b/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java
new file mode 100644
index 0000000..426b0db
--- /dev/null
+++ b/test/tools/javadoc/api/basic/taglets/UnderlineTaglet.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2002, 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.
+ *
+ * -Redistribution 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
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
+ * DAMAGES OR LIABILITIES  SUFFERED BY LICENSEE AS A RESULT OF OR
+ * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
+ * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
+ * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
+ * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
+ * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
+ * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that Software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ */
+
+import com.sun.tools.doclets.Taglet;
+import com.sun.javadoc.*;
+import java.util.Map;
+
+/**
+ * A sample Inline Taglet representing {@underline ...}. This tag can
+ * be used in any kind of {@link com.sun.javadoc.Doc}.
+ * The text is underlined.  For example,
+ * "@underline UNDERLINE ME" would be shown as: <u>UNDERLINE ME</u>.
+ *
+ * @author Jamie Ho
+ * @since 1.4
+ */
+
+public class UnderlineTaglet implements Taglet {
+
+    private static final String NAME = "underline";
+
+    /**
+     * Return the name of this custom tag.
+     */
+    public String getName() {
+        return NAME;
+    }
+
+    /**
+     * @return true since this tag can be used in a field
+     *         doc comment
+     */
+    public boolean inField() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a constructor
+     *         doc comment
+     */
+    public boolean inConstructor() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a method
+     *         doc comment
+     */
+    public boolean inMethod() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in an overview
+     *         doc comment
+     */
+    public boolean inOverview() {
+        return true;
+    }
+
+    /**
+     * @return true since this tag can be used in a package
+     *         doc comment
+     */
+    public boolean inPackage() {
+        return true;
+    }
+
+    /**
+     * @return true since this
+     */
+    public boolean inType() {
+        return true;
+    }
+
+    /**
+     * Will return true since this is an inline tag.
+     * @return true since this is an inline tag.
+     */
+
+    public boolean isInlineTag() {
+        return true;
+    }
+
+    /**
+     * Register this Taglet.
+     * @param tagletMap  the map to register this tag to.
+     */
+    public static void register(Map tagletMap) {
+       UnderlineTaglet tag = new UnderlineTaglet();
+       Taglet t = (Taglet) tagletMap.get(tag.getName());
+       if (t != null) {
+           tagletMap.remove(tag.getName());
+       }
+       tagletMap.put(tag.getName(), tag);
+    }
+
+    /**
+     * Given the <code>Tag</code> representation of this custom
+     * tag, return its string representation.
+     * @param tag he <code>Tag</code> representation of this custom tag.
+     */
+    public String toString(Tag tag) {
+        return "<u>" + tag.text() + "</u>";
+    }
+
+    /**
+     * This method should not be called since arrays of inline tags do not
+     * exist.  Method {@link #tostring(Tag)} should be used to convert this
+     * inline tag to a string.
+     * @param tags the array of <code>Tag</code>s representing of this custom tag.
+     */
+    public String toString(Tag[] tags) {
+        return null;
+    }
+}
+
diff --git a/test/tools/javadoc/doclint/DocLintTest.java b/test/tools/javadoc/doclint/DocLintTest.java
new file mode 100644
index 0000000..346b457
--- /dev/null
+++ b/test/tools/javadoc/doclint/DocLintTest.java
@@ -0,0 +1,255 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8004834 8007610
+ * @summary Add doclint support into javadoc
+ */
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.tools.Diagnostic;
+import javax.tools.DocumentationTool;
+import javax.tools.DocumentationTool.DocumentationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import static javax.tools.Diagnostic.Kind.*;
+
+import com.sun.tools.javac.main.Main;
+
+public class DocLintTest {
+    public static void main(String... args) throws Exception {
+        new DocLintTest().run();
+    }
+
+    DocumentationTool javadoc;
+    StandardJavaFileManager fm;
+    JavaFileObject file;
+
+    final String code =
+        /* 01 */    "/** Class comment. */\n" +
+        /* 02 */    "public class Test {\n" +
+        /* 03 */    "    /** Method comment. */\n" +
+        /* 04 */    "    public void method() { }\n" +
+        /* 05 */    "\n" +
+        /* 06 */    "    /** Syntax < error. */\n" +
+        /* 07 */    "    private void syntaxError() { }\n" +
+        /* 08 */    "\n" +
+        /* 09 */    "    /** @see DoesNotExist */\n" +
+        /* 10 */    "    protected void referenceError() { }\n" +
+        /* 11 */    "\n" +
+        /* 12 */    "    /** @return */\n" +
+        /* 13 */    "    public int emptyReturn() { return 0; }\n" +
+        /* 14 */    "}\n";
+
+    private final String rawDiags = "-XDrawDiagnostics";
+
+    private enum Message {
+        // doclint messages
+        DL_ERR6(ERROR, "Test.java:6:16: compiler.err.proc.messager: malformed HTML"),
+        DL_ERR9(ERROR, "Test.java:9:14: compiler.err.proc.messager: reference not found"),
+        DL_WRN12(WARNING, "Test.java:12:9: compiler.warn.proc.messager: no description for @return"),
+
+        // doclint messages when -XDrawDiagnostics is not in effect
+        DL_ERR9A(ERROR, "Test.java:9: error: reference not found"),
+        DL_WRN12A(WARNING, "Test.java:12: warning: no description for @return"),
+
+        // javadoc messages about bad content: these should only appear when doclint is disabled
+        JD_WRN10(WARNING, "Test.java:10: warning - Tag @see: reference not found: DoesNotExist"),
+        JD_WRN13(WARNING, "Test.java:13: warning - @return tag has no arguments."),
+
+        // javadoc messages for bad options
+        OPT_BADARG(ERROR, "javadoc: error - Invalid argument for -Xdoclint option"),
+        OPT_BADQUAL(ERROR, "javadoc: error - Access qualifiers not permitted for -Xdoclint arguments");
+
+        final Diagnostic.Kind kind;
+        final String text;
+
+        static Message get(String text) {
+            for (Message m: values()) {
+                if (m.text.equals(text))
+                    return m;
+            }
+            return null;
+        }
+
+        Message(Diagnostic.Kind kind, String text) {
+            this.kind = kind;
+            this.text = text;
+        }
+
+        @Override
+        public String toString() {
+            return "[" + kind + ",\"" + text + "\"]";
+        }
+    }
+
+    void run() throws Exception {
+        javadoc = ToolProvider.getSystemDocumentationTool();
+        fm = javadoc.getStandardFileManager(null, null, null);
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(new File(".")));
+        file = new SimpleJavaFileObject(URI.create("Test.java"), JavaFileObject.Kind.SOURCE) {
+            @Override
+            public CharSequence getCharContent(boolean ignoreEncoding) {
+                return code;
+            }
+        };
+
+        test(Collections.<String>emptyList(),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR9A, Message.DL_WRN12A));
+
+        test(Arrays.asList(rawDiags),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
+
+        test(Arrays.asList("-Xdoclint:none"),
+                Main.Result.OK,
+                EnumSet.of(Message.JD_WRN10, Message.JD_WRN13));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR9, Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:all/public"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.OPT_BADQUAL));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:all", "-public"),
+                Main.Result.OK,
+                EnumSet.of(Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:syntax"),
+                Main.Result.OK,
+                EnumSet.of(Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-private"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR6, Message.DL_ERR9, Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:syntax", "-private"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR6, Message.DL_WRN12));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:reference"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.DL_ERR9));
+
+        test(Arrays.asList(rawDiags, "-Xdoclint:badarg"),
+                Main.Result.ERROR,
+                EnumSet.of(Message.OPT_BADARG));
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(List<String> opts, Main.Result expectResult, Set<Message> expectMessages) {
+        System.err.println("test: " + opts);
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        List<JavaFileObject> files = Arrays.asList(file);
+        try {
+            DocumentationTask t = javadoc.getTask(pw, fm, null, null, opts, files);
+            boolean ok = t.call();
+            pw.close();
+            String out = sw.toString().replaceAll("[\r\n]+", "\n");
+            if (!out.isEmpty())
+                System.err.println(out);
+            if (ok && expectResult != Main.Result.OK) {
+                error("Compilation succeeded unexpectedly");
+            } else if (!ok && expectResult != Main.Result.ERROR) {
+                error("Compilation failed unexpectedly");
+            } else
+                check(out, expectMessages);
+        } catch (IllegalArgumentException e) {
+            System.err.println(e);
+            String expectOut = expectMessages.iterator().next().text;
+            if (expectResult != Main.Result.CMDERR)
+                error("unexpected exception caught");
+            else if (!e.getMessage().equals(expectOut)) {
+                error("unexpected exception message: "
+                        + e.getMessage()
+                        + " expected: " + expectOut);
+            }
+        }
+
+//        if (errors > 0)
+//            throw new Error("stop");
+    }
+
+    private void check(String out, Set<Message> expect) {
+        Pattern ignore = Pattern.compile("^(Building|Constructing|Generating|Loading|Standard|Starting| ) .*");
+        Pattern stats = Pattern.compile("^([1-9]+) (error|warning)(s?)");
+        Set<Message> found = EnumSet.noneOf(Message.class);
+        int e = 0, w = 0;
+        for (String line: out.split("[\r\n]+")) {
+            if (ignore.matcher(line).matches())
+                continue;
+
+            Matcher s = stats.matcher(line);
+            if (s.matches()) {
+                int i = Integer.valueOf(s.group(1));
+                if (s.group(2).equals("error"))
+                    e++;
+                else
+                    w++;
+                continue;
+            }
+
+            Message m = Message.get(line);
+            if (m == null)
+                error("Unexpected line: " + line);
+            else
+                found.add(m);
+        }
+        for (Message m: expect) {
+            if (!found.contains(m))
+                error("expected message not found: " + m.text);
+        }
+        for (Message m: found) {
+            if (!expect.contains(m))
+                error("unexpected message found: " + m.text);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javadoc/doclint/ImplicitHeadersTest.java b/test/tools/javadoc/doclint/ImplicitHeadersTest.java
new file mode 100644
index 0000000..d39816d
--- /dev/null
+++ b/test/tools/javadoc/doclint/ImplicitHeadersTest.java
@@ -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 8006346
+ * @summary doclint should make allowance for headers generated by standard doclet
+ */
+
+import java.io.File;
+
+/**
+ * <h3> Header </h3>
+ */
+public class ImplicitHeadersTest {
+    public static void main(String... args) {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testFile = new File(testSrc, ImplicitHeadersTest.class.getSimpleName() + ".java");
+        String[] javadocArgs = { "-d", "out", testFile.getPath() };
+        int rc = com.sun.tools.javadoc.Main.execute(javadocArgs);
+        if (rc != 0)
+            throw new Error("unexpected exit: rc=" + rc);
+    }
+}
+
diff --git a/test/tools/javah/6257087/T6257087.java b/test/tools/javah/6257087/T6257087.java
new file mode 100644
index 0000000..27b538f
--- /dev/null
+++ b/test/tools/javah/6257087/T6257087.java
@@ -0,0 +1,76 @@
+/*
+ * 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 6257087
+ * @summary javah doesn't produce proper signatures for inner class native methods
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main T6257087
+ */
+
+import java.nio.file.Paths;
+
+public class T6257087 {
+
+    private static final String fooBarGoldenFile =
+        "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+        "#include <jni.h>\n" +
+        "/* Header for class foo_bar */\n" +
+        "\n" +
+        "#ifndef _Included_foo_bar\n" +
+        "#define _Included_foo_bar\n" +
+        "#ifdef __cplusplus\n" +
+        "extern \"C\" {\n" +
+        "#endif\n" +
+        "/*\n" +
+        " * Class:     foo_bar\n" +
+        " * Method:    aardvark\n" +
+        " * Signature: ()V\n" +
+        " */\n" +
+        "JNIEXPORT void JNICALL Java_foo_00024bar_aardvark\n" +
+        "  (JNIEnv *, jobject);\n" +
+        "\n" +
+        "#ifdef __cplusplus\n" +
+        "}\n" +
+        "#endif\n" +
+        "#endif";
+
+    public static void main(String[] args) throws Exception {
+        ToolBox.JavaToolArgs javahArgs =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-cp", System.getProperty("test.classes"), "foo");
+        ToolBox.javah(javahArgs);
+
+        ToolBox.compareLines(Paths.get("foo_bar.h"),
+                ToolBox.splitLines(fooBarGoldenFile, "\n"), null, true);
+    }
+
+}
+
+class foo {
+    class bar {
+        public native void aardvark();
+    }
+}
diff --git a/test/tools/javah/6257087/foo.java b/test/tools/javah/6257087/foo.java
deleted file mode 100644
index ad70057..0000000
--- a/test/tools/javah/6257087/foo.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2006, 2007, 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.
- */
-
-
-class foo {
-    class bar {
-        public native void aardvark();
-    }
-}
diff --git a/test/tools/javah/6257087/foo.sh b/test/tools/javah/6257087/foo.sh
deleted file mode 100644
index e141e62..0000000
--- a/test/tools/javah/6257087/foo.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2006, 2009, 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 6257087
-# @run shell foo.sh
-
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=":"
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java" 
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
-diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javah/6257087/foo_bar.h b/test/tools/javah/6257087/foo_bar.h
deleted file mode 100644
index 32ec950..0000000
--- a/test/tools/javah/6257087/foo_bar.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class foo_bar */
-
-#ifndef _Included_foo_bar
-#define _Included_foo_bar
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     foo_bar
- * Method:    aardvark
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_foo_00024bar_aardvark
-  (JNIEnv *, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/test/tools/javah/ConstMacroTest.sh b/test/tools/javah/ConstMacroTest.sh
deleted file mode 100644
index b8a7a3c..0000000
--- a/test/tools/javah/ConstMacroTest.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4786406 4781221 4780341 6214324
-
-# Validates rewritten javah handling of class defined constants
-# and ensures that the appropriate macro definitions are placed
-# in the generated header file.
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-EXPECTED_JAVAH_OUT_FILE=SubClassConsts.out
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=":"
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
- esac
-
-GENERATED_HEADER_FILE=SubClassConsts.h
-HEADER_FILE_FILTERED=SubClassConsts.h.linefeed-filtered
-
-rm -rf SuperClassConsts.class SubClassConsts.class
-
-cp "${TESTSRC}${FS}SuperClassConsts.java" .
-cp "${TESTSRC}${FS}SubClassConsts.java" .
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
-
-diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
-result=$?
-rm ${GENERATED_HEADER_FILE}
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javah/MissingParamClassException.java b/test/tools/javah/MissingParamClassException.java
deleted file mode 100644
index 75f0a9d..0000000
--- a/test/tools/javah/MissingParamClassException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * ParamClassTest has a native method param which subclasses
- * this class
- *
- */
-
-public class MissingParamClassException extends Exception {
-    public MissingParamClassException() {
-        System.out.println("MissingParamClassException constructor called");
-    }
-}
diff --git a/test/tools/javah/MissingParamClassTest.sh b/test/tools/javah/MissingParamClassTest.sh
deleted file mode 100644
index 4796ac7..0000000
--- a/test/tools/javah/MissingParamClassTest.sh
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4942232
-
-#
-# Verifies that javah won't attempt to generate a header file
-# if a native method in a supplied class contains a parameter
-# type whose corresponding class is missing or not in the 
-# classpath
-
-TMP1=OUTPUT.txt
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    PS=":"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
- esac
-
-GENERATED_HEADER_FILE=ParamClassTest.h
-
-rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
-rm -f ${TMP1}
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-# Before running javah remove dependent class file
-rm -f MissingParamClassException.class 
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
-     echo "1-- Failed: $GENERATED_HEADER_FILE found"
-     rc=1
-fi
-if [ ! -s ${TMP1} ]; then
-     echo "1-- Failed: ${TMP1} is empty"
-     rc=1
-fi
-
-# Clean out work dir
-rm -f MissingParamClassException.class ParamClassTest.class
-rm -f $GENERATED_HEADER_FILE $TMP1 
-
-# Re-compile everything
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-
-# Before re-run of javah remove dependent class file Param.class 
-rm -f Param.class
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
-     echo "2-- Failed: $GENERATED_HEADER_FILE found"
-     rc=1
-fi
-if [ ! -s ${TMP1} ]; then
-     echo "2-- Failed: ${TMP1} is empty"
-     rc=1
-fi
-
-if [ "$rc" = "" ]; then
-    echo Passed
-else
-    echo Failed
-    exit 1
-fi
diff --git a/test/tools/javah/ParamClassTest.java b/test/tools/javah/ParamClassTest.java
deleted file mode 100644
index 363255c..0000000
--- a/test/tools/javah/ParamClassTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Class containing a native method which contains a native
- * method with non primitive type
- */
-
-public class ParamClassTest {
-    public native void method(Param s);
-
-    public static void main(String args[]) {
-    }
-}
-
-class Param extends MissingParamClassException {
-    Param() {
-        System.out.println("Param constructor");
-    }
-}
diff --git a/test/tools/javah/SubClassConsts.java b/test/tools/javah/SubClassConsts.java
deleted file mode 100644
index f57b346..0000000
--- a/test/tools/javah/SubClassConsts.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Subclass defines its own set of constants
- * It is itself serializable by virtue of extending SuperClassConsts
- *
- */
-public class SubClassConsts extends SuperClassConsts {
-
-    private final static int SUB_INT_CONSTANT = 2;
-    private final static double SUB_DOUBLE_CONSTANT = 2.25;
-    private final static float SUB_FLOAT_CONSTANT = 7.90f;
-    private final static boolean SUB_BOOLEAN_CONSTANT = true;
-
-    public SubClassConsts(String p) {
-        super(p);
-    }
-}
diff --git a/test/tools/javah/SubClassConsts.out b/test/tools/javah/SubClassConsts.out
deleted file mode 100644
index 16424eb..0000000
--- a/test/tools/javah/SubClassConsts.out
+++ /dev/null
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755LL
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/test/tools/javah/SubClassConsts.win b/test/tools/javah/SubClassConsts.win
deleted file mode 100644
index 4f8d569..0000000
--- a/test/tools/javah/SubClassConsts.win
+++ /dev/null
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755i64
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/test/tools/javah/SuperClassConsts.java b/test/tools/javah/SuperClassConsts.java
deleted file mode 100644
index 984b116..0000000
--- a/test/tools/javah/SuperClassConsts.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * Parent class implements serializable and provides static initializers
- * for a bunch of primitive type class constants
- * (required for regtest 4786406, 4780341)
- */
-
-import java.io.*;
-
-public class SuperClassConsts implements Serializable {
-
-    // Define class constant values, base class is serializable
-
-    private static final long serialVersionUID = 6733861379283244755L;
-    public static final int SUPER_INT_CONSTANT = 3;
-    public final static float SUPER_FLOAT_CONSTANT = 99.3f;
-    public final static double SUPER_DOUBLE_CONSTANT  = 33.2;
-    public final static boolean SUPER_BOOLEAN_CONSTANT  = false;
-
-    // A token instance field
-    int instanceField;
-
-    public SuperClassConsts(String p) {
-    }
-
-    public native int numValues();
-
-    private void writeObject(ObjectOutputStream s)
-        throws IOException
-    {
-        System.err.println("writing state");
-    }
-
-    /**
-     * readObject is called to restore the state of the FilePermission from
-     * a stream.
-     */
-    private void readObject(ObjectInputStream s)
-         throws IOException, ClassNotFoundException
-    {
-        System.err.println("reading back state");
-    }
-}
diff --git a/test/tools/javah/T4942232/MissingParamClassTest.java b/test/tools/javah/T4942232/MissingParamClassTest.java
new file mode 100644
index 0000000..5315e3b
--- /dev/null
+++ b/test/tools/javah/T4942232/MissingParamClassTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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 4942232
+ * @summary Verifies that javah won't attempt to generate a header file if a
+ * native method in a supplied class contains a parameter type whose corresponding
+ * class is missing or not in the classpath
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile MissingParamClassTest.java
+ * @clean MissingParamClassException
+ * @run main MissingParamClassTest
+ * @run compile MissingParamClassTest.java
+ * @clean Param
+ * @run main MissingParamClassTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javah/MissingParamClassTest.sh
+public class MissingParamClassTest {
+
+    public static void main(String[] args) throws Exception {
+        //first steps done now by jtreg
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
+//rm -f MissingParamClassException.class
+
+//"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
+        List<String> errOutput = new ArrayList<>();
+        ToolBox.JavaToolArgs javahParams =
+            new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+            .setAllArgs("-classpath", System.getProperty("test.classes"), "ParamClassTest")
+            .setErrOutput(errOutput);
+        ToolBox.javah(javahParams);
+
+//if [ -f $GENERATED_HEADER_FILE ]; then  fail
+//if [ ! -s ${TMP1} ]; then fail
+        if (Files.exists(Paths.get("ParamClassTest.h")) || errOutput.size() == 0)
+            throw new AssertionError("The only output generated by javah must be an error message");
+        //jtreg again
+//rm -f MissingParamClassException.class ParamClassTest.class
+//rm -f $GENERATED_HEADER_FILE $TMP1
+    }
+
+}
+
+class MissingParamClassException extends Exception {
+    public MissingParamClassException() {
+        System.out.println("MissingParamClassException constructor called");
+    }
+}
+
+class ParamClassTest {
+    public native void method(Param s);
+
+    public static void main(String args[]) {
+    }
+}
+
+class Param extends MissingParamClassException {
+    Param() {
+        System.out.println("Param constructor");
+    }
+}
diff --git a/test/tools/javah/constMacroTest/ConstMacroTest.java b/test/tools/javah/constMacroTest/ConstMacroTest.java
new file mode 100644
index 0000000..88b31f6
--- /dev/null
+++ b/test/tools/javah/constMacroTest/ConstMacroTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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 4786406 4781221 4780341 6214324
+ * @summary Validates rewritten javah handling of class defined constants and
+ * ensures that the appropriate macro definitions are placed in the generated
+ * header file.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ConstMacroTest
+ */
+
+import java.io.*;
+import java.nio.file.Paths;
+
+//original test: test/tools/javah/ConstMacroTest.sh
+public class ConstMacroTest {
+
+    private static final String subClassConstsGoldenFileTemplate =
+        "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+        "#include <jni.h>\n" +
+        "/* Header for class SubClassConsts */\n" +
+        "\n" +
+        "#ifndef _Included_SubClassConsts\n" +
+        "#define _Included_SubClassConsts\n" +
+        "#ifdef __cplusplus\n" +
+        "extern \"C\" {\n" +
+        "#endif\n" +
+        "#undef SubClassConsts_serialVersionUID\n" +
+        "#define SubClassConsts_serialVersionUID 6733861379283244755%s\n" +
+        "#undef SubClassConsts_SUPER_INT_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" +
+        "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f\n" +
+        "#undef SubClassConsts_SUPER_DOUBLE_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2\n" +
+        "#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L\n" +
+        "#undef SubClassConsts_SUB_INT_CONSTANT\n" +
+        "#define SubClassConsts_SUB_INT_CONSTANT 2L\n" +
+        "#undef SubClassConsts_SUB_DOUBLE_CONSTANT\n" +
+        "#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25\n" +
+        "#undef SubClassConsts_SUB_FLOAT_CONSTANT\n" +
+        "#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f\n" +
+        "#undef SubClassConsts_SUB_BOOLEAN_CONSTANT\n" +
+        "#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L\n" +
+        "#ifdef __cplusplus\n" +
+        "}\n" +
+        "#endif\n" +
+        "#endif";
+
+    private static final String serialVersionUIDSuffix =
+            ToolBox.isWindows() ? "i64" : "LL"; ;
+
+    public static void main(String[] args) throws Exception {
+        //first steps are now done by jtreg
+//        cp "${TESTSRC}${FS}SuperClassConsts.java" .
+//        cp "${TESTSRC}${FS}SubClassConsts.java" .
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
+
+//        "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
+        ToolBox.JavaToolArgs successParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-cp", System.getProperty("test.classes"), "SubClassConsts");
+        ToolBox.javah(successParams);
+
+//        diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
+        String subClassConstGoldenFile = String.format(subClassConstsGoldenFileTemplate,
+                serialVersionUIDSuffix);
+        ToolBox.compareLines(Paths.get("SubClassConsts.h"),
+                ToolBox.splitLines(subClassConstGoldenFile, "\n"), null, true);
+    }
+
+}
+
+class SuperClassConsts implements Serializable {
+    // Define class constant values, base class is serializable
+    private static final long serialVersionUID = 6733861379283244755L;
+    public static final int SUPER_INT_CONSTANT = 3;
+    public final static float SUPER_FLOAT_CONSTANT = 99.3f;
+    public final static double SUPER_DOUBLE_CONSTANT  = 33.2;
+    public final static boolean SUPER_BOOLEAN_CONSTANT  = false;
+    // A token instance field
+    int instanceField;
+
+    public native int numValues();
+}
+
+class SubClassConsts extends SuperClassConsts {
+    private final static int SUB_INT_CONSTANT = 2;
+    private final static double SUB_DOUBLE_CONSTANT = 2.25;
+    private final static float SUB_FLOAT_CONSTANT = 7.90f;
+    private final static boolean SUB_BOOLEAN_CONSTANT = true;
+}
diff --git a/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java b/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java
new file mode 100644
index 0000000..33c823a
--- /dev/null
+++ b/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java
@@ -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 4798312
+ * @summary In Windows, javap doesnt load classes from rt.jar
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavapShouldLoadClassesFromRTJarTest
+ */
+public class JavapShouldLoadClassesFromRTJarTest {
+
+    public static void main(String[] args) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs().
+                setAllArgs("-v", "java.lang.String");
+        if (ToolBox.javap(params).isEmpty())
+            throw new AssertionError("javap generated no output");
+    }
+
+}
diff --git a/test/tools/javap/4866831/PublicInterfaceTest.java b/test/tools/javap/4866831/PublicInterfaceTest.java
new file mode 100644
index 0000000..d9021b4
--- /dev/null
+++ b/test/tools/javap/4866831/PublicInterfaceTest.java
@@ -0,0 +1,52 @@
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/*
+ * 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 4866831
+ * @summary Verify that javap marks public interfaces as public
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main PublicInterfaceTest
+ */
+
+//original test: test/tools/javap/PublicInterfaceTest.sh
+public class PublicInterfaceTest {
+    public interface Test {}
+
+    public static void main(String[] args) throws Exception {
+//        "$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
+        Path pathToClass = Paths.get(System.getProperty("test.classes"),
+                "PublicInterfaceTest$Test.class");
+        ToolBox.JavaToolArgs javapParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs(pathToClass.toString());
+        if (!ToolBox.javap(javapParams).contains("public"))
+            throw new AssertionError("The javap output does not contain \"public\"");
+    }
+
+}
diff --git a/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java b/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java
new file mode 100644
index 0000000..84e4f73
--- /dev/null
+++ b/test/tools/javap/8006334/JavapTaskCtorFailWithNPE.java
@@ -0,0 +1,84 @@
+/*
+ * 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 8006334
+ * @summary javap: JavapTask constructor breaks with null pointer exception if
+ * parameter options is null
+ */
+
+import java.io.File;
+import java.util.Arrays;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Locale;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import com.sun.tools.javap.JavapFileManager;
+import com.sun.tools.javap.JavapTask;
+
+public class JavapTaskCtorFailWithNPE {
+
+    //we will also check the output just to confirm that we get the expected one
+    private static final String expOutput =
+        "Compiled from \"JavapTaskCtorFailWithNPE.java\"\n" +
+        "public class JavapTaskCtorFailWithNPE {\n" +
+        "  public JavapTaskCtorFailWithNPE();\n" +
+        "  public static void main(java.lang.String[]);\n" +
+        "}\n";
+
+    public static void main(String[] args) {
+        new JavapTaskCtorFailWithNPE().run();
+    }
+
+    private void run() {
+        File classToCheck = new File(System.getProperty("test.classes"),
+            getClass().getSimpleName() + ".class");
+
+        DiagnosticCollector<JavaFileObject> dc =
+                new DiagnosticCollector<JavaFileObject>();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavaFileManager fm = JavapFileManager.create(dc, pw);
+        JavapTask t = new JavapTask(pw, fm, dc, null,
+                Arrays.asList(classToCheck.getPath()));
+        if (t.run() != 0)
+            throw new Error("javap failed unexpectedly");
+
+        List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
+        for (Diagnostic<? extends JavaFileObject> d: diags) {
+            if (d.getKind() == Diagnostic.Kind.ERROR)
+                throw new AssertionError(d.getMessage(Locale.ENGLISH));
+        }
+        String lineSep = System.getProperty("line.separator");
+        String out = sw.toString().replace(lineSep, "\n");
+        if (!out.equals(expOutput)) {
+            throw new AssertionError("The output is not equal to the one expected");
+        }
+    }
+
+}
diff --git a/test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java b/test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java
new file mode 100644
index 0000000..709d8cb
--- /dev/null
+++ b/test/tools/javap/8007907/JavapReturns0AfterClassNotFoundTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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 8007907
+ * @summary javap, method com.sun.tools.javap.Main.run returns 0 even in case
+ * of class not found error
+ */
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+public class JavapReturns0AfterClassNotFoundTest {
+
+    static final String fileNotFoundErrorMsg =
+            "Error: class not found: Unexisting.class";
+    static final String exitCodeClassNotFoundAssertionMsg =
+            "Javap's exit code for class not found should be 1";
+    static final String classNotFoundMsgAssertionMsg =
+            "Javap's error message for class not found is incorrect";
+
+    public static void main(String args[]) throws Exception {
+        new JavapReturns0AfterClassNotFoundTest().run();
+    }
+
+    void run() throws IOException {
+        check(exitCodeClassNotFoundAssertionMsg, classNotFoundMsgAssertionMsg,
+                fileNotFoundErrorMsg, "-v", "Unexisting.class");
+    }
+
+    void check(String exitCodeAssertionMsg, String errMsgAssertionMsg,
+            String expectedErrMsg, String... params) {
+        int result;
+        StringWriter s;
+        String out;
+        try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+            result = com.sun.tools.javap.Main.run(params, pw);
+            //no line separator, no problem
+            out = s.toString().trim();
+        }
+        if (result != 1) {
+            System.out.println("actual exit code " + result);
+            throw new AssertionError(exitCodeAssertionMsg);
+        }
+
+        if (!out.equals(expectedErrMsg)) {
+            System.out.println("actual " + out);
+            System.out.println("expected " + expectedErrMsg);
+            throw new AssertionError(errMsgAssertionMsg);
+        }
+    }
+
+}
diff --git a/test/tools/javap/DescriptorTest.java b/test/tools/javap/DescriptorTest.java
new file mode 100644
index 0000000..595b8c2
--- /dev/null
+++ b/test/tools/javap/DescriptorTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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     8007052
+ * @summary javap should include the descriptor for a method in verbose mode
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+public class DescriptorTest {
+    public static void main(String... args) throws Exception {
+        new DescriptorTest().run();
+    }
+
+    void run() throws Exception {
+        File srcDir = new File("src");
+        srcDir.mkdirs();
+        File classesDir = new File("classes");
+        classesDir.mkdirs();
+
+        File f = writeFile(new File(srcDir, "E.java"), "enum E { A, B }");
+        javac("-d", classesDir.getPath(), f.getPath());
+        String out = javap("-p", "-v", new File(classesDir, "E.class").getPath());
+        Pattern expect = Pattern.compile("\\Qprivate E();\\E\\s+\\Qdescriptor: (Ljava/lang/String;I)V\\E");
+        checkContains(out, expect);
+    }
+
+    File writeFile(File f, String body) throws IOException {
+        try (FileWriter out = new FileWriter(f)) {
+            out.write(body);
+        }
+        return f;
+    }
+
+    void javac(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.flush();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("compilation failed");
+    }
+
+    String javap(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        pw.flush();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("javap failed");
+        return out;
+    }
+
+    void checkContains(String s, Pattern p) throws Exception {
+        if (!p.matcher(s).find())
+            throw new Exception("expected pattern not found: " + p);
+    }
+}
diff --git a/test/tools/javap/MethodParameters.java b/test/tools/javap/MethodParameters.java
new file mode 100644
index 0000000..940724b
--- /dev/null
+++ b/test/tools/javap/MethodParameters.java
@@ -0,0 +1,174 @@
+/*
+ * 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 8004727 8005647
+ * @summary javac should generate method parameters correctly.
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class MethodParameters {
+
+    static final String Foo_name = "Foo";
+    static final String Foo_contents =
+        ("public class Foo {\n" +
+         "  Foo() {}\n" +
+         "  Foo(int i) {}\n" +
+         "  void foo0() {}\n" +
+         "  void foo2(int j, int k) {}\n" +
+         "}").replaceAll(" +", " ");
+
+    static final String Init0_expected =
+        ("  Foo();\n" +
+         "    descriptor: ()V\n" +
+         "    flags: \n" +
+         "    Code:\n" +
+         "      stack=1, locals=1, args_size=1\n" +
+         "         0: aload_0       \n" +
+         "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
+         "         4: return        \n" +
+         "      LineNumberTable:\n" +
+         "        line 2: 0").replaceAll(" +", " ");
+
+    static final String Init1_expected =
+        ("  Foo(int);\n" +
+         "    descriptor: (I)V\n" +
+         "    flags: \n" +
+         "    Code:\n" +
+         "      stack=1, locals=2, args_size=2\n" +
+         "         0: aload_0       \n" +
+         "         1: invokespecial #1                  // Method java/lang/Object.\"<init>\":()V\n" +
+         "         4: return        \n" +
+         "      LineNumberTable:\n" +
+         "        line 3: 0\n" +
+         "    MethodParameters:\n" +
+         "      Name                                Flags\n" +
+         "      i").replaceAll(" +", " ");
+
+    static final String foo0_expected =
+        ("  void foo0();\n" +
+         "    descriptor: ()V\n" +
+         "    flags: \n" +
+         "    Code:\n" +
+         "      stack=0, locals=1, args_size=1\n" +
+         "         0: return        \n" +
+         "      LineNumberTable:\n" +
+         "        line 4: 0").replaceAll(" +", " ");
+
+    static final String foo2_expected =
+        ("  void foo2(int, int);\n" +
+         "    descriptor: (II)V\n" +
+         "    flags: \n" +
+         "    Code:\n" +
+         "      stack=0, locals=3, args_size=3\n" +
+         "         0: return        \n" +
+         "      LineNumberTable:\n" +
+         "        line 5: 0\n" +
+         "    MethodParameters:\n" +
+         "      Name                                Flags\n" +
+         "      j                              \n" +
+         "      k").replaceAll(" +", " ");
+
+    static final File classesdir = new File("methodparameters");
+    static final String separator = System.getProperty("line.separator");
+
+    public static void main(String... args) throws Exception {
+        new MethodParameters().run();
+    }
+
+    void run() throws Exception {
+        classesdir.mkdir();
+        final File Foo_java =
+            writeFile(classesdir, Foo_name + ".java", Foo_contents);
+        compile("-parameters", "-d", classesdir.getPath(), Foo_java.getPath());
+        System.out.println("Run javap");
+        String output =
+            javap("-c", "-verbose", "-classpath",
+                  classesdir.getPath(), Foo_name);
+        String normalized =
+            output.replaceAll(separator, "\n").replaceAll(" +", " ");
+
+        if (!normalized.contains(Init0_expected))
+            error("Bad output for zero-parameter constructor.  Expected\n" +
+                  Init0_expected + "\n" + "but got\n" + normalized);
+        if (!normalized.contains(Init1_expected))
+           error("Bad output for one-parameter constructor.  Expected\n" +
+                 Init1_expected + "\n" + "but got\n" + normalized);
+        if (!normalized.contains(foo0_expected))
+           error("Bad output for zero-parameter method.  Expected\n" +
+                 foo0_expected + "\n" + "but got\n" + normalized);
+        if (!normalized.contains(foo2_expected))
+           error("Bad output for two-parameter method  Expected\n" +
+                 foo2_expected + "\n" + "but got\n" + normalized);
+
+        if (0 != errors)
+            throw new Exception("MethodParameters test failed with " +
+                                errors + " errors");
+    }
+
+    String javap(String... args) {
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter(sw);
+        //sun.tools.javap.Main.entry(args);
+        int rc = com.sun.tools.javap.Main.run(args, out);
+        if (rc != 0)
+            throw new Error("javap failed. rc=" + rc);
+        out.close();
+        System.out.println(sw);
+        return sw.toString();
+    }
+
+    String compile(String... args) throws Exception {
+        System.err.println("compile: " + Arrays.asList(args));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            error("compilation failed, rc=" + rc);
+        return out;
+    }
+
+    File writeFile(File dir, String path, String body) throws IOException {
+        File f = new File(dir, path);
+        f.getParentFile().mkdirs();
+        FileWriter out = new FileWriter(f);
+        out.write(body);
+        out.close();
+        return f;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+}
diff --git a/test/tools/javap/NotPackagePrivateInterface.java b/test/tools/javap/NotPackagePrivateInterface.java
deleted file mode 100644
index fd3fc6c..0000000
--- a/test/tools/javap/NotPackagePrivateInterface.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 2007, 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.
- */
-
-
-/*
- * This class is used by PublicInterfaceTest.sh to generate a class
- * file with a public interface to verify javap will output the
- * "public" modifier for such interfaces.  (At the vm level, the only
- * access control properties an interface can can have are public and
- * package private.)
- */
-
-public interface NotPackagePrivateInterface {
-}
diff --git a/test/tools/javap/PublicInterfaceTest.sh b/test/tools/javap/PublicInterfaceTest.sh
deleted file mode 100644
index 0d8d441..0000000
--- a/test/tools/javap/PublicInterfaceTest.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2007, 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 4866831
-# @build NotPackagePrivateInterface
-# @run shell PublicInterfaceTest.sh
-# @summary Verify that javap marks public interfaces as public
-# @author Joseph D. Darcy
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAP="${TESTJAVA}/bin/javap"
-
-"$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
-
-# If the exit status of grep is 0, then "public" was correctly found
-# in the output of javap.
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-	exit 0;
-        ;;
-
-        * )
-        echo "The javap tool did not output \"public\" for a public interface."
-        exit 1
-esac
diff --git a/test/tools/javap/T4777949.java b/test/tools/javap/T4777949.java
index 4dcc551..af81b2b 100644
--- a/test/tools/javap/T4777949.java
+++ b/test/tools/javap/T4777949.java
@@ -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
@@ -87,11 +87,11 @@ public class T4777949 {
         PrintWriter pw = new PrintWriter(sw);
         JavaFileManager fm = JavapFileManager.create(dc, pw);
         JavapTask t = new JavapTask(pw, fm, dc, args, classes);
-        boolean ok = t.run();
+        int ok = t.run();
 
         List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
 
-        if (!ok)
+        if (ok != 0)
             error("javap failed unexpectedly");
 
         System.err.println("args=" + args + " classes=" + classes + "\n"
diff --git a/test/tools/javap/T7186925.java b/test/tools/javap/T7186925.java
new file mode 100644
index 0000000..6d56904
--- /dev/null
+++ b/test/tools/javap/T7186925.java
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ * 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 7186925
+ * @summary JavapTask passes null to java.io.Writer
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.tools.javap.*;
+
+public class T7186925
+{
+    public static void main(String... args) {
+        new T7186925().run();
+    }
+
+    void run() {
+        verify("java.lang.Object");
+        if (errors > 0)
+            throw new Error(errors + " found.");
+    }
+
+    void verify(String className) {
+        try {
+            JavaFileManager fileManager = JavapFileManager.create(null, null);
+            JavaFileObject fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
+            if (fo == null) {
+                error("Can't find " + className);
+            } else {
+                JavapTask t = new JavapTask(null, fileManager, null);
+                t.handleOptions(new String[] { "-sysinfo", className });
+                JavapTask.ClassFileInfo cfInfo = t.read(fo);
+                expectEqual(cfInfo.cf.byteLength(), cfInfo.size);
+            }
+        } catch (NullPointerException ee) {
+            ee.printStackTrace();
+            error("Exception: " + ee);
+        } catch (Exception ee) {
+            System.err.println("Caught exception: " + ee);
+        }
+    }
+
+    void expectEqual(int found, int expected) {
+        if (found != expected)
+            error("bad value found: " + found + " expected: " + expected);
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/javap/T7190862.java b/test/tools/javap/T7190862.java
new file mode 100644
index 0000000..8a40ac4
--- /dev/null
+++ b/test/tools/javap/T7190862.java
@@ -0,0 +1,156 @@
+
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7190862 7109747
+ * @summary javap shows an incorrect type for operands if the 'wide' prefix is used
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javap.JavapFileManager;
+import com.sun.tools.javap.JavapTask;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class T7190862 {
+
+    enum TypeWideInstructionMap {
+        INT("int", new String[]{"istore_w", "iload_w"}),
+        LONG("long", new String[]{"lstore_w", "lload_w"}),
+        FLOAT("float", new String[]{"fstore_w", "fload_w"}),
+        DOUBLE("double", new String[]{"dstore_w", "dload_w"}),
+        OBJECT("Object", new String[]{"astore_w", "aload_w"});
+
+        String type;
+        String[] instructions;
+
+        TypeWideInstructionMap(String type, String[] instructions) {
+            this.type = type;
+            this.instructions = instructions;
+        }
+    }
+
+    JavaSource source;
+
+    public static void main(String[] args) {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        new T7190862().run(comp);
+    }
+
+    private void run(JavaCompiler comp) {
+        String code;
+        for (TypeWideInstructionMap typeInstructionMap: TypeWideInstructionMap.values()) {
+            if (typeInstructionMap != TypeWideInstructionMap.OBJECT) {
+                code = createWideLocalSource(typeInstructionMap.type, 300);
+            } else {
+                code = createWideLocalSourceForObject(300);
+            }
+            source = new JavaSource(code);
+            compile(comp);
+            check(typeInstructionMap.instructions);
+        }
+
+        //an extra test for the iinc instruction
+        code = createIincSource();
+        source = new JavaSource(code);
+        compile(comp);
+        check(new String[]{"iinc_w"});
+    }
+
+    private void compile(JavaCompiler comp) {
+        JavacTask ct = (JavacTask)comp.getTask(null, null, null, null, null, Arrays.asList(source));
+        try {
+            if (!ct.call()) {
+                throw new AssertionError("Error thrown when compiling the following source:\n" + source.getCharContent(true));
+            }
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when compiling the following source:\n" + source.getCharContent(true));
+        }
+    }
+
+    private void check(String[] instructions) {
+        String out = javap(Arrays.asList("-c"), Arrays.asList("Test.class"));
+        for (String line: out.split(System.getProperty("line.separator"))) {
+            line = line.trim();
+            for (String instruction: instructions) {
+                if (line.contains(instruction) && line.contains("#")) {
+                    throw new Error("incorrect type for operands for instruction " + instruction);
+                }
+            }
+        }
+    }
+
+    private String javap(List<String> args, List<String> classes) {
+        DiagnosticCollector<JavaFileObject> dc = new DiagnosticCollector<JavaFileObject>();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavaFileManager fm = JavapFileManager.create(dc, pw);
+        JavapTask t = new JavapTask(pw, fm, dc, args, classes);
+        if (t.run() != 0)
+            throw new Error("javap failed unexpectedly");
+
+        List<Diagnostic<? extends JavaFileObject>> diags = dc.getDiagnostics();
+        for (Diagnostic<? extends JavaFileObject> d: diags) {
+            if (d.getKind() == Diagnostic.Kind.ERROR)
+                throw new Error(d.getMessage(Locale.ENGLISH));
+        }
+        return sw.toString();
+
+    }
+
+    private String createWideLocalSource(String type, int numberOfVars) {
+        String result = "    " + type + " x0 = 0;\n";
+        for (int i = 1; i < numberOfVars; i++) {
+            result += "        " + type + " x" + i + " = x" + (i - 1) + " + 1;\n";
+        }
+        return result;
+    }
+
+    private String createWideLocalSourceForObject(int numberOfVars) {
+        String result = "    Object x0 = new Object();\n";
+        for (int i = 1; i < numberOfVars; i++) {
+            result += "        Object x" + i + " = x0;\n";
+        }
+        return result;
+    }
+
+    private String createIincSource() {
+        return "    int i = 0;\n"
+                + "        i += 1;\n"
+                + "        i += 51;\n"
+                + "        i += 101;\n"
+                + "        i += 151;\n";
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "    public static void main(String[] args)\n" +
+                          "    {\n" +
+                          "        #C" +
+                          "    }\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource(String code) {
+            super(URI.create("Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#C", code);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
diff --git a/test/tools/javap/output/RepeatingTypeAnnotations.java b/test/tools/javap/output/RepeatingTypeAnnotations.java
new file mode 100644
index 0000000..f78bf12
--- /dev/null
+++ b/test/tools/javap/output/RepeatingTypeAnnotations.java
@@ -0,0 +1,427 @@
+/*
+ * 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 8005220
+ * @summary javap must display repeating annotations
+ */
+import java.io.*;
+import java.util.*;
+
+/**
+ * This class extends the abstract {@link Tester} test-driver, and
+ * encapusulates a number of test-case classes (i.e. classes extending
+ * this class and annotated with {@code TestCase}).
+ * <p>
+ * By default (no argument), this test runs all test-cases, except
+ * if annotated with {@code ignore}.
+ * <p>
+ * Individual test cases can be executed using a run action.
+ * <p>
+ * Example: @run main RepeatingTypeAnnotations RepeatingTypeAnnotations$TC4
+ * <p>
+ * Note: when specific test-cases are run, additional debug output is
+ * produced to help debugging. Test annotated with {@code ignore}
+ * can be executed explicitly.
+ */
+public class RepeatingTypeAnnotations extends Tester {
+
+    /**
+     * Main method instantiates test and run test-cases.
+     */
+    public static void main(String... args) throws Exception {
+        Tester tester = new RepeatingTypeAnnotations();
+        tester.run(args);
+    }
+
+    /**
+     * Testcases are classes extending {@code RepeatingTypeAnnotations},
+     * and calling {@link setSrc}, followed by one or more invocations
+     * of {@link verify} in the body of the constructor.
+     */
+    public RepeatingTypeAnnotations() {
+        setSrc(new TestSource(template));
+    }
+
+    /**
+     * Common template for test cases. The line TESTCASE is
+     * replaced with the specific lines of individual tests.
+     */
+    private static final String[] template = {
+        "import java.lang.annotation.*;",
+        "class Test {",
+        "    @Repeatable(As.class)",
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.CLASS)",
+        "    @interface A {",
+        "        Class f() default int.class;",
+        "    }",
+
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.CLASS)",
+        "    @interface As { A[] value(); }",
+
+        "    @Repeatable(Bs.class)",
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.CLASS)",
+        "    @interface B {",
+        "        Class f() default int.class;",
+        "    }",
+
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.CLASS)",
+        "    @interface Bs { B[] value(); }",
+
+        "    @Repeatable(Cs.class)",
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.RUNTIME)",
+        "    @interface C {",
+        "        Class f() default int.class;",
+        "    }",
+
+        "    @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})",
+        "    @Retention(RetentionPolicy.RUNTIME)",
+        "    @interface Cs { C[] value(); }",
+        "TESTCASE",
+        "}"
+    };
+
+    /*
+     * The test cases covers annotation in the following locations:
+     * - static and non-static fields
+     * - local variables
+     * - constructor and method return type and parameter types
+     * - casts in class and method contexts.
+     * For the above locations the test-cases covers:
+     * - single annotation type
+     * - two annotation types with same retention
+     * - two annotation types with different retention
+     * - three annotation types, two of same retention, one different.
+     */
+
+    @TestCase
+    public static class TC1 extends RepeatingTypeAnnotations {
+        public TC1() {
+            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",
+                   "0: #25(#26=[@#27(),@#27(),@#27()]): CAST, offset=5, type_index=0");
+        }
+    }
+
+    @TestCase
+    public static class TC2 extends RepeatingTypeAnnotations {
+        public TC2() {
+            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",
+                   "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(" /* TC3 */ ",
+                   "    static String so = \"hello world\";",
+                   "    public @A @A @C Object o = (@B @C @B String) Test.so;");
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #25(): FIELD",
+                   "0: #27(#28=[@#29(),@#29()]): FIELD",
+                   "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(" /* TC4 */ ",
+                   "    static String so = \"hello world\";",
+                   "    public @A @B @C Object o = (@C @B @A String) Test.so;");
+            verify("RuntimeInvisibleTypeAnnotations",
+                   "RuntimeVisibleTypeAnnotations",
+                   "0: #25(): FIELD",
+                   "0: #27(): FIELD",
+                   "1: #28(): FIELD",
+                   "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
+    public static class TC5 extends RepeatingTypeAnnotations {
+        public TC5() {
+            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",
+                   "0: #36(#26=[@#37(),@#37(),@#37()]): CAST, offset=5, type_index=0");
+        }
+    }
+
+    @TestCase
+    public static class TC6 extends RepeatingTypeAnnotations {
+        public TC6() {
+            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",
+                   "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(" /* TC7 */ ",
+                   "    static String so = \"hello world\";",
+                   "    public static @A @A @C Object o = (@B @C @B String) Test.so;");
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #25(): FIELD",
+                   "0: #27(#28=[@#29(),@#29()]): FIELD",
+                   "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(" /* TC8 */ ",
+                   "    static String so = \"hello world\";",
+                   "    public static @A @B @C Object o = (@C @B @A String) Test.so;");
+
+            verify("RuntimeVisibleTypeAnnotations",
+                   "RuntimeInvisibleTypeAnnotations",
+                   "0: #25(): FIELD",
+                   "0: #27(): FIELD",
+                   "1: #28(): FIELD",
+                   "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
+    public static class TC9 extends RepeatingTypeAnnotations {
+        public TC9() {
+            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()]): 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(" /* 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()]): 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(" /* 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("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(" /* 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("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",
+                   "0: #36(): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "1: #37(): METHOD_FORMAL_PARAMETER, param_index=0",
+                   "2: #36(): METHOD_FORMAL_PARAMETER, param_index=1");
+        }
+    }
+
+    @TestCase
+    public static class TC13 extends RepeatingTypeAnnotations {
+        public TC13() {
+            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()]): 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(" /* 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(#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(" /* 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(
+                    "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(" /* 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(
+                    "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",
+                    "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"
+                  );
+        }
+    }
+}
diff --git a/test/tools/javap/output/Tester.java b/test/tools/javap/output/Tester.java
new file mode 100644
index 0000000..d6103c5
--- /dev/null
+++ b/test/tools/javap/output/Tester.java
@@ -0,0 +1,389 @@
+/*
+ * 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.io.*;
+import java.util.*;
+import java.lang.annotation.*;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * {@code Tester} is an abstract test-driver that provides the logic
+ * to execute test-cases, grouped by test classes.
+ * A test class is a main class extending this class, that instantiate
+ * itself, and calls the {@link run} method, passing any command line
+ * arguments.
+ * <p>
+ * The {@code run} method, expects arguments to identify test-case classes.
+ * A test-case class is a class extending the test class, and annotated
+ * with {@code TestCase}.
+ * <p>
+ * If no test-cases are specified, the test class directory is searched for
+ * co-located test-case classes (i.e. any class extending the test class,
+ * annotated with  {@code TestCase}).
+ * <p>
+ * Besides serving to group test-cases, extending the driver allow
+ * setting up a test-case template, and possibly overwrite default
+ * test-driver behaviour.
+ */
+public abstract class Tester {
+
+    private static boolean debug = false;
+    private static final PrintStream out = System.err;
+    private static final PrintStream err = System.err;
+
+
+    protected void run(String... args) throws Exception {
+
+        final File classesdir = new File(System.getProperty("test.classes", "."));
+
+        String[] classNames = args;
+
+        // If no test-cases are specified, we regard all co-located classes
+        // as potential test-cases.
+        if (args.length == 0) {
+            final String pattern =  ".*\\.class";
+            final File classFiles[] = classesdir.listFiles(new FileFilter() {
+                    public boolean accept(File f) {
+                        return f.getName().matches(pattern);
+                    }
+                });
+            ArrayList<String> names = new ArrayList<String>(classFiles.length);
+            for (File f : classFiles) {
+                String fname = f.getName();
+                names.add(fname.substring(0, fname.length() -6));
+            }
+            classNames = names.toArray(new String[names.size()]);
+        } else {
+            debug = true;
+        }
+        // Test-cases must extend the driver type, and be marked
+        // @TestCase. Other arguments (classes) are ignored.
+        // Test-cases are instantiated, and thereby executed.
+        for (String clname : classNames) {
+            try {
+                final Class tclass = Class.forName(clname);
+                if  (!getClass().isAssignableFrom(tclass)) continue;
+                TestCase anno = (TestCase) tclass.getAnnotation(TestCase.class);
+                if (anno == null) continue;
+                if (!debug) {
+                    ignore i = (ignore) tclass.getAnnotation(ignore.class);
+                    if (i != null) {
+                        out.println("Ignore: " + clname);
+                        ignored++;
+                        continue;
+                    }
+                }
+                out.println("TestCase: " + clname);
+                cases++;
+                Tester tc = (Tester) tclass.getConstructor().newInstance();
+                if (tc.errors > 0) {
+                    error("" + tc.errors + " test points failed in " + clname);
+                    errors += tc.errors - 1;
+                    fcases++;
+                }
+            } catch(ReflectiveOperationException roe) {
+                error("Warning: " + clname + " - ReflectiveOperationException");
+                roe.printStackTrace(err);
+            } catch(Exception unknown) {
+                error("Warning: " + clname + " - uncaught exception");
+                unknown.printStackTrace(err);
+            }
+        }
+
+        String imsg = ignored > 0 ? " (" +  ignored + " ignored)" : "";
+        if (errors > 0)
+            throw new Error(errors + " error, in " + fcases + " of " + cases + " test-cases" + imsg);
+        else
+            err.println("" + cases + " test-cases executed" + imsg + ", no errors");
+    }
+
+
+    /**
+     * Test-cases must be marked with the {@code TestCase} annotation,
+     * as well as extend {@code Tester} (or an driver extension
+     * specified as the first argument to the {@code main()} method.
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface TestCase { }
+
+    /**
+     * Individual test-cases failing due to product bugs, may temporarily
+     * be excluded by marking them like this, (where "at-" is replaced by "@")
+     * at-ignore // 1234567: bug synopsis
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface ignore { }
+
+    /**
+     * Test-cases are classes extending {@code Tester}, and
+     * calling {@link setSrc}, followed by one or more invocations
+     * of {@link verify} in the body of the constructor.
+     * <p>
+     * Sets a default test-case template, which is empty except
+     * for a key of {@code "TESTCASE"}.
+     * Subclasses will typically call {@code setSrc(TestSource)}
+     * to setup a useful test-case template.
+     */
+    public Tester() {
+        this.testCase = this.getClass().getName();
+        src = new TestSource("TESTCASE");
+    }
+
+    /**
+     * Set the top-level source template.
+     */
+    protected Tester setSrc(TestSource src) {
+        this.src = src;
+        return this;
+    }
+
+    /**
+     * Convenience method for calling {@code innerSrc("TESTCASE", ...)}.
+     */
+    protected Tester setSrc(String... lines) {
+        return innerSrc("TESTCASE", lines);
+    }
+
+    /**
+     * Convenience method for calling {@code innerSrc(key, new TestSource(...))}.
+     */
+    protected Tester innerSrc(String key, String... lines) {
+        return innerSrc(key, new TestSource(lines));
+    }
+
+    /**
+     * Specialize the testcase template, setting replacement content
+     * for the specified key.
+     */
+    protected Tester innerSrc(String key, TestSource content) {
+        if (src == null) {
+            src = new TestSource(key);
+        }
+        src.setInner(key, content);
+        return this;
+    }
+
+    /**
+     * On the first invocation, call {@code execute()} to compile
+     * the test-case source and process the resulting class(se)
+     * into verifiable output.
+     * <p>
+     * Verify that the output matches each of the regular expressions
+     * given as argument.
+     * <p>
+     * Any failure to match constitutes a test failure, but doesn't
+     * abort the test-case.
+     * <p>
+     * Any exception (e.g. bad regular expression syntax) results in
+     * a test failure, and aborts the test-case.
+     */
+    protected void verify(String... expect) {
+        if (!didExecute) {
+            try {
+                execute();
+            } catch(Exception ue) {
+                throw new Error(ue);
+            } finally {
+                didExecute = true;
+            }
+        }
+        if (output == null) {
+            error("output is null");
+            return;
+        }
+        for (String e: expect) {
+            // Escape regular expressions (to allow input to be literals).
+            // Notice, characters to be escaped are themselves identified
+            // using regular expressions
+            String rc[] = { "(", ")", "[", "]", "{", "}", "$" };
+            for (String c : rc) {
+                e = e.replace(c, "\\" + c);
+            }
+            // DEBUG: Uncomment this to test modulo constant pool index.
+            // e = e.replaceAll("#[0-9]{2}", "#[0-9]{2}");
+            if (!output.matches("(?s).*" + e + ".*")) {
+                if (!didPrint) {
+                    out.println(output);
+                    didPrint = true;
+                }
+                error("not matched: '" + e + "'");
+            } else if(debug) {
+                out.println("matched: '" + e + "'");
+            }
+        }
+    }
+
+    /**
+     * Calls {@code writeTestFile()} to write out the test-case source
+     * content to a file, then call {@code compileTestFile()} to
+     * compile it, and finally run the {@link process} method to produce
+     * verifiable output. The default {@code process} method runs javap.
+     * <p>
+     * If an exception occurs, it results in a test failure, and
+     * aborts the test-case.
+     */
+    protected void execute() throws IOException {
+        err.println("TestCase: " + testCase);
+        writeTestFile();
+        compileTestFile();
+        process();
+    }
+
+    /**
+     * Generate java source from test-case.
+     * TBD: change to use javaFileObject, possibly make
+     * this class extend JavaFileObject.
+     */
+    protected void writeTestFile() throws IOException {
+        javaFile = new File("Test.java");
+        FileWriter fw = new FileWriter(javaFile);
+        BufferedWriter bw = new BufferedWriter(fw);
+        PrintWriter pw = new PrintWriter(bw);
+        for (String line : src) {
+            pw.println(line);
+            if (debug) out.println(line);
+        }
+        pw.close();
+    }
+
+    /**
+     * Compile the Java source code.
+     */
+    protected void compileTestFile() {
+        String path = javaFile.getPath();
+        String params[] =  { "-source", "1.8", "-g", path };
+        int rc = com.sun.tools.javac.Main.compile(params);
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        classFile = new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+
+    /**
+     * Process class file to generate output for verification.
+     * The default implementation simply runs javap. This might be
+     * overwritten to generate output in a different manner.
+     */
+    protected void process() {
+        String testClasses = "."; //System.getProperty("test.classes", ".");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { "-v", "-classpath", testClasses, "Test" };
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        if (rc != 0)
+            throw new Error("javap failed. rc=" + rc);
+        pw.close();
+        output = sw.toString();
+        if (debug) {
+            out.println(output);
+            didPrint = true;
+        }
+
+    }
+
+
+    private String testCase;
+    private TestSource src;
+    private File javaFile = null;
+    private File classFile = null;
+    private String output = null;
+    private boolean didExecute = false;
+    private boolean didPrint = false;
+
+
+    protected void error(String msg) {
+        err.println("Error: " + msg);
+        errors++;
+    }
+
+    private int cases;
+    private int fcases;
+    private int errors;
+    private int ignored;
+
+    /**
+     * The TestSource class provides a simple container for
+     * test cases. It contains an array of source code lines,
+     * where zero or more lines may be markers for nested lines.
+     * This allows representing templates, with specialization.
+     * <P>
+     * This may be generalized to support more advance combo
+     * tests, but presently it's only used with a static template,
+     * and one level of specialization.
+     */
+    public class TestSource implements Iterable<String> {
+
+        private String[] lines;
+        private Hashtable<String, TestSource> innerSrc;
+
+        public TestSource(String... lines) {
+            this.lines = lines;
+            innerSrc = new Hashtable<String, TestSource>();
+        }
+
+        public void setInner(String key, TestSource inner) {
+            innerSrc.put(key, inner);
+        }
+
+        public void setInner(String key, String... lines) {
+            innerSrc.put(key, new TestSource(lines));
+        }
+
+        public Iterator<String> iterator() {
+            return new LineIterator();
+        }
+
+        private class LineIterator implements Iterator<String> {
+
+            int nextLine = 0;
+            Iterator<String> innerIt = null;
+
+            public  boolean hasNext() {
+                return nextLine < lines.length;
+            }
+
+            public String next() {
+                if (!hasNext()) throw new NoSuchElementException();
+                String str = lines[nextLine];
+                TestSource inner = innerSrc.get(str);
+                if (inner == null) {
+                    nextLine++;
+                    return str;
+                }
+                if (innerIt == null) {
+                    innerIt = inner.iterator();
+                }
+                if (innerIt.hasNext()) {
+                    return innerIt.next();
+                }
+                innerIt = null;
+                nextLine++;
+                return next();
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        }
+    }
+}
diff --git a/test/tools/javap/pathsep.sh b/test/tools/javap/pathsep.sh
deleted file mode 100644
index f34da2a..0000000
--- a/test/tools/javap/pathsep.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4798312
-# @summary In Windows, javap doesnt load classes from rt.jar
-# @author gafter
-#
-# @run shell pathsep.sh
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
-result=$?
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
diff --git a/test/tools/javap/stackmap/StackmapTest.java b/test/tools/javap/stackmap/StackmapTest.java
new file mode 100644
index 0000000..81664be
--- /dev/null
+++ b/test/tools/javap/stackmap/StackmapTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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 6271292
+ * @summary Verify that javap prints StackMapTable attribute contents
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main StackmapTest
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javap/stackmap/T6271292.sh
+public class StackmapTest {
+
+    private static final String TestSrc =
+        "public class Test extends SuperClass {\n" +
+        "    public static void main(String[] args) {\n" +
+        "        new SuperClass((args[0].equals(\"0\")) ? 0 : 1)\n" +
+        "            .test();\n" +
+        "    }\n" +
+        "    Test(boolean b) {\n" +
+        "        super(b ? 1 : 2);\n" +
+        "    }\n" +
+        "}\n" +
+        "class SuperClass {\n" +
+        "    double d;\n" +
+        "    SuperClass(double dd) { d = dd; }\n" +
+        "    double test() {\n" +
+        "        if (d == 0)\n" +
+        "            return d;\n" +
+        "        else\n" +
+        "            return d > 0 ? d++ : d--;\n" +
+        "    }\n" +
+        "}\n";
+
+    private static final String goldenOut =
+        "frame_type = 255 /* full_frame */\n" +
+        "frame_type = 255 /* full_frame */\n" +
+        "frame_type = 73 /* same_locals_1_stack_item */\n" +
+        "frame_type = 255 /* full_frame */\n" +
+        "offset_delta = 19\n" +
+        "offset_delta = 0\n" +
+        "offset_delta = 2\n" +
+        "stack = [ uninitialized 0, uninitialized 0 ]\n" +
+        "stack = [ uninitialized 0, uninitialized 0, double ]\n" +
+        "stack = [ this ]\n" +
+        "stack = [ this, double ]\n" +
+        "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+        "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+        "locals = [ this, int ]\n";
+
+    public static void main(String[] args) throws Exception {
+        //        @compile T6271292.java
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs().setSources(TestSrc);
+        ToolBox.javac(javacParams);
+
+//        "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
+        ToolBox.JavaToolArgs javapParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-v", "Test.class");
+        String out = ToolBox.javap(javapParams);
+        List<String> grepResult = ToolBox.grep("frame_type", out,
+                ToolBox.lineSeparator);
+        grepResult.addAll(ToolBox.grep("offset_delta", out, ToolBox.lineSeparator));
+        grepResult.addAll(ToolBox.grep("stack = ", out, ToolBox.lineSeparator));
+        grepResult.addAll(ToolBox.grep("locals = ", out, ToolBox.lineSeparator));
+        List<String> goldenList = Arrays.asList(goldenOut.split("\n"));
+
+//        diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
+        ToolBox.compareLines(goldenList, grepResult, true);
+    }
+
+}
diff --git a/test/tools/javap/stackmap/T6271292.java b/test/tools/javap/stackmap/T6271292.java
deleted file mode 100644
index bf4b4a5..0000000
--- a/test/tools/javap/stackmap/T6271292.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2005, 2007, 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.
- */
-
-
-public class T6271292 extends SuperClass {
-
-    public static void main(String[] args) {
-        SuperClass s = new SuperClass((args[0].equals("0")) ? 0 : 1);
-        s.test();
-    }
-    T6271292(boolean b) {
-        super(b ? 1 : 2);
-    }
-}
-
-class SuperClass {
-    double d;
-    SuperClass(double dd) { d = dd; }
-
-    double test() {
-        if (d == 0) {
-            return d;
-        } else if (d > 0) {
-            return d++;
-        } else {
-            return d--;
-        }
-    }
-}
diff --git a/test/tools/javap/stackmap/T6271292.out b/test/tools/javap/stackmap/T6271292.out
deleted file mode 100644
index ed0f7ca..0000000
--- a/test/tools/javap/stackmap/T6271292.out
+++ /dev/null
@@ -1,14 +0,0 @@
-   frame_type = 255 /* full_frame */
-   frame_type = 255 /* full_frame */
-   frame_type = 73 /* same_locals_1_stack_item */
-   frame_type = 255 /* full_frame */
-     offset_delta = 19
-     offset_delta = 0
-     offset_delta = 2
-     stack = [ uninitialized 0, uninitialized 0 ]
-     stack = [ uninitialized 0, uninitialized 0, double ]
-     stack = [ this ]
-     stack = [ this, double ]
-     locals = [ class "[Ljava/lang/String;" ]
-     locals = [ class "[Ljava/lang/String;" ]
-     locals = [ this, int ]
diff --git a/test/tools/javap/stackmap/T6271292.sh b/test/tools/javap/stackmap/T6271292.sh
deleted file mode 100644
index 15c1b54..0000000
--- a/test/tools/javap/stackmap/T6271292.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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 6271292
-# @compile T6271292.java
-# @run shell T6271292.sh
-# @summary Verify that javap prints StackMapTable attribute contents
-# @author Wei Tao
-    
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTSRC="%s"' "${TESTSRC}" >&2 ; echo >&2
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTJAVA="%s"' "${TESTJAVA}" >&2 ; echo >&2
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTCLASSES="%s"' "${TESTCLASSES}" >&2 ; echo >&2
-printf 'CLASSPATH="%s"' "${CLASSPATH}" >&2 ; echo >&2
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-JAVAPFILE=T6271292.javap
-OUTFILE=outfile
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
-result="$?"
-if [ "$result" -ne 0 ] 
-then
-  exit "$result"
-fi
-
-grep "frame_type" "${JAVAPFILE}" > "${OUTFILE}"
-grep "offset_delta" "${JAVAPFILE}" >> "${OUTFILE}"
-grep "stack = " "${JAVAPFILE}" >> "${OUTFILE}"
-grep "locals = " "${JAVAPFILE}" >> "${OUTFILE}"
-diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
-result="$?"
-if [ "$result" -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit "$result"
-
-
diff --git a/test/tools/javap/typeAnnotations/JSR175Annotations.java b/test/tools/javap/typeAnnotations/JSR175Annotations.java
new file mode 100644
index 0000000..3504cb5
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/JSR175Annotations.java
@@ -0,0 +1,152 @@
+/*
+ * 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
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test JSR175Annotations
+ * @bug 6843077
+ * @summary test that only type annotations are recorded as such in classfile
+ */
+
+public class JSR175Annotations {
+    public static void main(String[] args) throws Exception {
+        new JSR175Annotations().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    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, 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;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.*;");
+        out.println("abstract class Test { ");
+        out.println("  @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})");
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @interface A { }");
+        out.println("  @A String m;");
+        out.println("  @A String method(@A String a) {");
+        out.println("    return a;");
+        out.println("  }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/NewArray.java b/test/tools/javap/typeAnnotations/NewArray.java
new file mode 100644
index 0000000..b562ac5
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/NewArray.java
@@ -0,0 +1,140 @@
+/*
+ * 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
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test NewArray
+ * @bug 6843077
+ * @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();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method 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, Method m, String name, boolean visible) {
+        Attribute attr = null;
+        Code_attribute cAttr = null;
+        RuntimeTypeAnnotations_attribute tAttr = 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;
+                tAttr = (RuntimeTypeAnnotations_attribute)attr;
+                all += tAttr.annotations.length;
+                if (visible)
+                    visibles += tAttr.annotations.length;
+                else
+                    invisibles += tAttr.annotations.length;
+               }
+        }
+    }
+
+    File writeTestFile() throws IOException {
+      File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.*;");
+        out.println("import java.util.*;");
+        out.println("class Test { ");
+        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();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 9;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/Presence.java b/test/tools/javap/typeAnnotations/Presence.java
new file mode 100644
index 0000000..8dad8fc
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/Presence.java
@@ -0,0 +1,218 @@
+/*
+ * 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
+ * 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.io.*;
+import java.lang.annotation.ElementType;
+
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Presence
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class Presence {
+    public static void main(String[] args) throws Exception {
+        new Presence().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        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);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        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) {
+        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) {
+            attr = m.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;
+        }
+        // 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
+    // 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 {
+        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 TestPresence<@TestPresence.A T extends @TestPresence.A List<@TestPresence.A String>> { ");
+        out.println("  @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})");
+        out.println("  @interface A { }");
+
+        out.println("  Map<@A String, Map<@A String, @A String>> f1;");
+
+        out.println("  <@A TM extends @A List<@A String>>");
+        out.println("  Map<@A String, @A List<@A String>>");
+        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;");
+        out.println("    @A String @A [] [] @A[] lc3 = null;");
+        out.println("    List<? extends @A List<@A String>> lc4 = null;");
+        out.println("    Object lc5 = (@A List<@A String>) null;");
+        out.println("    boolean lc6 = lc1 instanceof @A String;");
+        out.println("    boolean lc7 = lc5 instanceof @A String @A [] @A [];");
+        out.println("    new @A ArrayList<@A String>();");
+        out.println("    Object lc8 = new @A String @A [4];");
+        out.println("    try {");
+        out.println("      Object lc10 = int.class;");
+        out.println("    } catch (@A Exception e) { e.toString(); }");
+        out.println("    return null;");
+        out.println("  }");
+        out.println("  void vararg1(String @A ... t) { } ");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 38;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/PresenceInner.java b/test/tools/javap/typeAnnotations/PresenceInner.java
new file mode 100644
index 0000000..1b85920
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/PresenceInner.java
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test PresenceInner
+ * @bug 6843077
+ * @summary test that annotations in inner types count only once
+ */
+
+public class PresenceInner {
+    public static void main(String[] args) throws Exception {
+        new PresenceInner().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        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);
+        }
+
+        // counts are zero when vising outer class
+        countAnnotations(0);
+
+        // visit inner class
+        File innerFile = new File("Test$1Inner.class");
+        ClassFile icf = ClassFile.read(innerFile);
+        test(icf);
+        for (Field f : icf.fields) {
+            test(cf, f);
+        }
+        for (Method m: icf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations(1);
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        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;
+        }
+    }
+
+    // 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 {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+
+        out.println("import java.lang.annotation.*;");
+        out.println("class Test {");
+        out.println("  void method() {");
+        out.println("    class Inner<T extends @A Object> { }");
+        out.println("  }");
+        out.println("}");
+        out.println("@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})");
+        out.println("@interface A { }");
+        out.close();
+        System.out.println(f.getAbsolutePath());
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations(int expected_invisibles) {
+        int expected_visibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/T6855990.java b/test/tools/javap/typeAnnotations/T6855990.java
new file mode 100644
index 0000000..bc24eda
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/T6855990.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+
+/*
+ * @test
+ * @bug 6855990
+ * @summary InstructionDetailWriter should support new 308 annotations attribute
+ */
+
+public class T6855990 {
+    public static void main(String[] args) throws Exception {
+        new T6855990().run();
+    }
+
+    public void run() throws Exception {
+        @Simple String[] args = { "-c", "-XDdetails:typeAnnotations", "T6855990" };
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        System.out.println(out);
+        if (out.indexOf("@Simple: LOCAL_VARIABLE") == -1)
+            throw new Exception("expected output not found");
+    }
+}
+
+ at interface Simple { }
+
diff --git a/test/tools/javap/typeAnnotations/TypeCasts.java b/test/tools/javap/typeAnnotations/TypeCasts.java
new file mode 100644
index 0000000..c9c3f92
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/TypeCasts.java
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test
+ * @bug 6843077
+ * @summary test that typecasts annotation are emitted if only the cast
+ *          expression is optimized away
+ */
+
+public class TypeCasts {
+    public static void main(String[] args) throws Exception {
+        new TypeCasts().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method 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, Method m, String name, boolean visible) {
+        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;
+               }
+        }
+    }
+
+
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        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) @interface A { }");
+
+        out.println("  void emit() {");
+        out.println("    Object o = null;");
+        out.println("    String s = null;");
+
+        out.println("    String a0 = (@A String)o;");
+        out.println("    Object a1 = (@A Object)o;");
+
+        out.println("    String b0 = (@A String)s;");
+        out.println("    Object b1 = (@A Object)s;");
+        out.println("  }");
+
+        out.println("  void alldeadcode() {");
+        out.println("    Object o = null;");
+
+        out.println("    if (false) {");
+        out.println("      String a0 = (@A String)o;");
+        out.println("    }");
+        out.println("  }");
+
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 4;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/Visibility.java b/test/tools/javap/typeAnnotations/Visibility.java
new file mode 100644
index 0000000..9fe348b
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/Visibility.java
@@ -0,0 +1,145 @@
+/*
+ * 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
+ * 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.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Visibility
+ * @bug 6843077
+ * @summary test that type annotations are recorded in the classfile
+ */
+
+public class Visibility {
+    public static void main(String[] args) throws Exception {
+        new Visibility().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method 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, 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;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.ElementType;");
+        out.println("import java.lang.annotation.Retention;");
+        out.println("import java.lang.annotation.RetentionPolicy;");
+        out.println("import java.lang.annotation.Target;");
+        out.println("abstract class Test { ");
+        // visible annotations: RUNTIME
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @Target(ElementType.TYPE_USE)");
+        out.println("  @interface A { }");
+        out.println("  void visible(@A Test this) { }");
+
+        // invisible annotations: CLASS
+        out.println("  @Retention(RetentionPolicy.CLASS)");
+        out.println("  @Target(ElementType.TYPE_USE)");
+        out.println("  @interface B { }");
+        out.println("  void invisible(@B Test this) { }");
+
+        // source annotations
+        out.println("  @Retention(RetentionPolicy.SOURCE)");
+        out.println("  @Target(ElementType.TYPE_USE)");
+        out.println("  @interface C { }");
+        out.println("  void source(@C Test this) { }");
+
+        // default visibility: CLASS
+        out.println("  @Target(ElementType.TYPE_USE)");
+        out.println("  @interface D { }");
+        out.println("  void def(@D Test this) { }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+      int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_all = 3, expected_visibles = 1, expected_invisibles = 2;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/javap/typeAnnotations/Wildcards.java b/test/tools/javap/typeAnnotations/Wildcards.java
new file mode 100644
index 0000000..7e011b2
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/Wildcards.java
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Wildcards
+ * @bug 6843077
+ * @summary test that annotations target wildcards get emitted to classfile
+ */
+public class Wildcards {
+    public static void main(String[] args) throws Exception {
+        new Wildcards().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        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);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        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;
+        }
+    }
+
+    // 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 {
+      File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        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("  List<? extends @A Number> f;");
+
+        out.println("  List<? extends @A Object> test(List<? extends @A Number> p) {");
+        out.println("    List<? extends @A Object> l;");    // not counted... gets optimized away
+        out.println("    return null;");
+        out.println(" }");
+        out.println("}");
+
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.8", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 3;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
diff --git a/test/tools/jdeps/Basic.java b/test/tools/jdeps/Basic.java
new file mode 100644
index 0000000..e68875b
--- /dev/null
+++ b/test/tools/jdeps/Basic.java
@@ -0,0 +1,213 @@
+/*
+ * 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.
+ *
+ * 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 8003562 8005428
+ * @summary Basic tests for jdeps tool
+ * @build Test p.Foo
+ * @run main Basic
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.regex.*;
+
+public class Basic {
+    private static boolean symbolFileExist = initProfiles();
+    private static boolean initProfiles() {
+        // check if ct.sym exists; if not use the profiles.properties file
+        Path home = Paths.get(System.getProperty("java.home"));
+        if (home.endsWith("jre")) {
+            home = home.getParent();
+        }
+        Path ctsym = home.resolve("lib").resolve("ct.sym");
+        boolean symbolExists = ctsym.toFile().exists();
+        if (!symbolExists) {
+            Path testSrcProfiles =
+                Paths.get(System.getProperty("test.src", "."), "profiles.properties");
+            if (!testSrcProfiles.toFile().exists())
+                throw new Error(testSrcProfiles + " does not exist");
+            System.out.format("%s doesn't exist.%nUse %s to initialize profiles info%n",
+                ctsym, testSrcProfiles);
+            System.setProperty("jdeps.profiles", testSrcProfiles.toString());
+        }
+        return symbolExists;
+    }
+
+    public static void main(String... args) throws Exception {
+        int errors = 0;
+        errors += new Basic().run();
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    int run() throws IOException {
+        File testDir = new File(System.getProperty("test.classes", "."));
+        // test a .class file
+        test(new File(testDir, "Test.class"),
+             new String[] {"java.lang", "p"},
+             new String[] {"compact1", "not found"});
+        // test a directory
+        test(new File(testDir, "p"),
+             new String[] {"java.lang", "java.util", "java.lang.management"},
+             new String[] {"compact1", "compact1", "compact3"});
+        // test class-level dependency output
+        test(new File(testDir, "Test.class"),
+             new String[] {"java.lang.Object", "p.Foo"},
+             new String[] {"compact1", "not found"},
+             new String[] {"-V", "class"});
+        // test -p option
+        test(new File(testDir, "Test.class"),
+             new String[] {"p.Foo"},
+             new String[] {"not found"},
+             new String[] {"--verbose-level=class", "-p", "p"});
+        // test -e option
+        test(new File(testDir, "Test.class"),
+             new String[] {"p.Foo"},
+             new String[] {"not found"},
+             new String[] {"-V", "class", "-e", "p\\..*"});
+        test(new File(testDir, "Test.class"),
+             new String[] {"java.lang"},
+             new String[] {"compact1"},
+             new String[] {"-V", "package", "-e", "java\\.lang\\..*"});
+        // test -classpath and wildcard options
+        test(null,
+             new String[] {"com.sun.tools.jdeps", "java.lang", "java.util",
+                           "java.util.regex", "java.io", "java.nio.file",
+                           "java.lang.management"},
+             new String[] {(symbolFileExist? "not found" : "JDK internal API (classes)"),
+                           "compact1", "compact1", "compact1",
+                           "compact1", "compact1", "compact3"},
+             new String[] {"--classpath", testDir.getPath(), "*"});
+        /* Temporary disable this test case.  Test.class has a dependency
+         * on java.lang.String on certain windows machine (8008479).
+         // -v shows intra-dependency
+         test(new File(testDir, "Test.class"),
+              new String[] {"java.lang.Object", "p.Foo"},
+              new String[] {"compact1", testDir.getName()},
+              new String[] {"-v", "--classpath", testDir.getPath(), "Test.class"});
+        */
+        return errors;
+    }
+
+    void test(File file, String[] expect, String[] profiles) {
+        test(file, expect, profiles, new String[0]);
+    }
+
+    void test(File file, String[] expect, String[] profiles, String[] options) {
+        List<String> args = new ArrayList<>(Arrays.asList(options));
+        if (file != null) {
+            args.add(file.getPath());
+        }
+        List<String> argsWithDashP = new ArrayList<>();
+        argsWithDashP.add("-P");
+        argsWithDashP.addAll(args);
+        // test without -P
+        checkResult("dependencies", expect, jdeps(args.toArray(new String[0])).keySet());
+        // test with -P
+        checkResult("profiles", expect, profiles, jdeps(argsWithDashP.toArray(new String[0])));
+    }
+
+    Map<String,String> jdeps(String... args) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        System.err.println("jdeps " + Arrays.toString(args));
+        int rc = com.sun.tools.jdeps.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Error("jdeps failed: rc=" + rc);
+        return findDeps(out);
+    }
+
+    // Pattern used to parse lines
+    private static Pattern linePattern = Pattern.compile(".*\r?\n");
+    private static Pattern pattern = Pattern.compile("\\s+ -> (\\S+) +(.*)");
+
+    // Use the linePattern to break the given String into lines, applying
+    // the pattern to each line to see if we have a match
+    private static Map<String,String> findDeps(String out) {
+        Map<String,String> result = new HashMap<>();
+        Matcher lm = linePattern.matcher(out);  // Line matcher
+        Matcher pm = null;                      // Pattern matcher
+        int lines = 0;
+        while (lm.find()) {
+            lines++;
+            CharSequence cs = lm.group();       // The current line
+            if (pm == null)
+                pm = pattern.matcher(cs);
+            else
+                pm.reset(cs);
+            if (pm.find())
+                result.put(pm.group(1), pm.group(2).trim());
+            if (lm.end() == out.length())
+                break;
+        }
+        return result;
+    }
+
+    void checkResult(String label, String[] expect, Collection<String> found) {
+        List<String> list = Arrays.asList(expect);
+        if (!isEqual(list, found))
+            error("Unexpected " + label + " found: '" + found + "', expected: '" + list + "'");
+    }
+
+    void checkResult(String label, String[] expect, String[] profiles, Map<String,String> result) {
+        if (expect.length != profiles.length)
+            error("Invalid expected names and profiles");
+
+        // check the dependencies
+        checkResult(label, expect, result.keySet());
+        // check profile information
+        checkResult(label, profiles, result.values());
+        for (int i=0; i < expect.length; i++) {
+            String profile = result.get(expect[i]);
+            if (!profile.equals(profiles[i]))
+                error("Unexpected profile: '" + profile + "', expected: '" + profiles[i] + "'");
+        }
+    }
+
+    boolean isEqual(List<String> expected, Collection<String> found) {
+        if (expected.size() != found.size())
+            return false;
+
+        List<String> list = new ArrayList<>(found);
+        list.removeAll(expected);
+        return list.isEmpty();
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/test/tools/jdeps/Test.java b/test/tools/jdeps/Test.java
new file mode 100644
index 0000000..8adc7b4
--- /dev/null
+++ b/test/tools/jdeps/Test.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+public class Test {
+    public void test() {
+        p.Foo f = new p.Foo();
+    }
+}
diff --git a/test/tools/jdeps/p/Foo.java b/test/tools/jdeps/p/Foo.java
new file mode 100644
index 0000000..c9ec3cb
--- /dev/null
+++ b/test/tools/jdeps/p/Foo.java
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * 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;
+
+import java.util.List;
+import java.util.Collections;
+public class Foo {
+    public static List foo() {
+        return Collections.emptyList();
+    }
+
+    public Foo() {
+        // compact3
+        java.lang.management.ManagementFactory.getRuntimeMXBean();
+    }
+}
diff --git a/test/tools/jdeps/profiles.properties b/test/tools/jdeps/profiles.properties
new file mode 100644
index 0000000..f00bb4a
--- /dev/null
+++ b/test/tools/jdeps/profiles.properties
@@ -0,0 +1,263 @@
+# This properties file is used for testing a JDK development build.
+# No need to keep this properties file up to date as long as it covers
+# the APIs used by the jdeps regression test.
+profile.1.name = compact1
+profile.1.packages = \
+    java.io \
+    java.lang \
+    java.lang.annotation \
+    java.lang.invoke \
+    java.lang.ref \
+    java.lang.reflect \
+    java.math \
+    java.net \
+    java.nio \
+    java.nio.channels \
+    java.nio.channels.spi \
+    java.nio.charset \
+    java.nio.charset.spi \
+    java.nio.file \
+    java.nio.file.attribute \
+    java.nio.file.spi \
+    java.security \
+    java.security.cert \
+    java.security.interfaces \
+    java.security.spec \
+    java.text \
+    java.text.spi \
+    java.util \
+    java.util.concurrent \
+    java.util.concurrent.atomic \
+    java.util.concurrent.locks \
+    java.util.jar \
+    java.util.logging \
+    java.util.regex \
+    java.util.spi \
+    java.util.zip \
+    javax.crypto \
+    javax.crypto.interfaces \
+    javax.crypto.spec \
+    javax.security.auth \
+    javax.security.auth.callback \
+    javax.security.auth.login \
+    javax.security.auth.spi \
+    javax.security.auth.x500 \
+    javax.net \
+    javax.net.ssl \
+    javax.security.cert \
+    \
+    com.sun.net.ssl \
+    com.sun.nio.file \
+    com.sun.nio.sctp \
+    com.sun.security.auth \
+    com.sun.security.auth.login
+
+profile.2.name = compact2
+profile.2.packages = \
+    java.sql \
+    javax.sql \
+    javax.xml \
+    javax.xml.datatype \
+    javax.xml.namespace \
+    javax.xml.parsers \
+    javax.xml.stream \
+    javax.xml.stream.events \
+    javax.xml.stream.util \
+    javax.xml.transform \
+    javax.xml.transform.dom \
+    javax.xml.transform.sax \
+    javax.xml.transform.stax \
+    javax.xml.transform.stream \
+    javax.xml.validation \
+    javax.xml.xpath \
+    org.w3c.dom \
+    org.w3c.dom.bootstrap \
+    org.w3c.dom.events \
+    org.w3c.dom.ls \
+    org.xml.sax \
+    org.xml.sax.ext \
+    org.xml.sax.helpers \
+    java.rmi \
+    java.rmi.activation \
+    java.rmi.dgc \
+    java.rmi.registry \
+    java.rmi.server \
+    javax.rmi.ssl \
+    javax.transaction \
+    javax.transaction.xa \
+    \
+    com.sun.net.httpserver \
+    com.sun.net.httpserver.spi
+
+profile.3.name = compact3
+profile.3.packages = \
+    java.lang.instrument \
+    java.lang.management \
+    java.security.acl \
+    java.util.prefs \
+    javax.management \
+    javax.management.loading \
+    javax.management.modelmbean \
+    javax.management.monitor \
+    javax.management.openmbean \
+    javax.management.relation \
+    javax.management.remote \
+    javax.management.remote.rmi \
+    javax.management.timer \
+    javax.naming \
+    javax.naming.directory \
+    javax.naming.event \
+    javax.naming.ldap \
+    javax.naming.spi \
+    javax.sql.rowset \
+    javax.sql.rowset.serial \
+    javax.sql.rowset.spi \
+    javax.security.auth.kerberos \
+    javax.security.sasl \
+    javax.script \
+    javax.smartcardio \
+    javax.xml.crypto \
+    javax.xml.crypto.dom \
+    javax.xml.crypto.dsig \
+    javax.xml.crypto.dsig.dom \
+    javax.xml.crypto.dsig.keyinfo \
+    javax.xml.crypto.dsig.spec \
+    javax.annotation.processing \
+    javax.lang.model \
+    javax.lang.model.element \
+    javax.lang.model.type \
+    javax.lang.model.util \
+    javax.tools \
+    javax.tools.annotation \
+    org.ietf.jgss \
+    \
+    com.sun.management \
+    com.sun.security.auth.callback \
+    com.sun.security.auth.module \
+    com.sun.security.jgss
+
+profile.4.name = Full JRE
+profile.4.packages = \
+    java.applet \
+    java.awt \
+    java.awt.color \
+    java.awt.datatransfer \
+    java.awt.dnd \
+    java.awt.dnd.peer \
+    java.awt.event \
+    java.awt.font \
+    java.awt.geom \
+    java.awt.im \
+    java.awt.im.spi \
+    java.awt.image \
+    java.awt.image.renderable \
+    java.awt.peer \
+    java.awt.print \
+    java.beans \
+    java.beans.beancontext \
+    javax.accessibility \
+    javax.imageio \
+    javax.imageio.event \
+    javax.imageio.metadata \
+    javax.imageio.plugins.bmp \
+    javax.imageio.plugins.jpeg \
+    javax.imageio.spi \
+    javax.imageio.stream \
+    javax.print \
+    javax.print.attribute \
+    javax.print.attribute.standard \
+    javax.print.event \
+    javax.sound.midi \
+    javax.sound.midi.spi \
+    javax.sound.sampled \
+    javax.sound.sampled.spi \
+    javax.swing \
+    javax.swing.border \
+    javax.swing.colorchooser \
+    javax.swing.event \
+    javax.swing.filechooser \
+    javax.swing.plaf \
+    javax.swing.plaf.basic \
+    javax.swing.plaf.metal \
+    javax.swing.plaf.multi \
+    javax.swing.plaf.nimbus \
+    javax.swing.plaf.synth \
+    javax.swing.table \
+    javax.swing.text \
+    javax.swing.text.html \
+    javax.swing.text.html.parser \
+    javax.swing.text.rtf \
+    javax.swing.tree \
+    javax.swing.undo \
+    javax.activation \
+    javax.jws \
+    javax.jws.soap \
+    javax.rmi \
+    javax.rmi.CORBA \
+    javax.xml.bind \
+    javax.xml.bind.annotation \
+    javax.xml.bind.annotation.adapters \
+    javax.xml.bind.attachment \
+    javax.xml.bind.helpers \
+    javax.xml.bind.util \
+    javax.xml.soap \
+    javax.xml.ws \
+    javax.xml.ws.handler \
+    javax.xml.ws.handler.soap \
+    javax.xml.ws.http \
+    javax.xml.ws.soap \
+    javax.xml.ws.spi \
+    javax.xml.ws.spi.http \
+    javax.xml.ws.wsaddressing \
+    javax.annotation \
+    org.omg.CORBA \
+    org.omg.CORBA.DynAnyPackage \
+    org.omg.CORBA.ORBPackage \
+    org.omg.CORBA.TypeCodePackage \
+    org.omg.CORBA.portable \
+    org.omg.CORBA_2_3 \
+    org.omg.CORBA_2_3.portable \
+    org.omg.CosNaming \
+    org.omg.CosNaming.NamingContextExtPackage \
+    org.omg.CosNaming.NamingContextPackage \
+    org.omg.Dynamic \
+    org.omg.DynamicAny \
+    org.omg.DynamicAny.DynAnyFactoryPackage \
+    org.omg.DynamicAny.DynAnyPackage \
+    org.omg.IOP \
+    org.omg.IOP.CodecFactoryPackage \
+    org.omg.IOP.CodecPackage \
+    org.omg.Messaging \
+    org.omg.PortableInterceptor \
+    org.omg.PortableInterceptor.ORBInitInfoPackage \
+    org.omg.PortableServer \
+    org.omg.PortableServer.CurrentPackage \
+    org.omg.PortableServer.POAManagerPackage \
+    org.omg.PortableServer.POAPackage \
+    org.omg.PortableServer.ServantLocatorPackage \
+    org.omg.PortableServer.portable \
+    org.omg.SendingContext \
+    org.omg.stub.java.rmi \
+    org.omg.stub.javax.management.remote.rmi
+
+# Remaining JDK supported API
+profile.5.name = JDK tools
+profile.5.packages = \
+    com.sun.jdi \
+    com.sun.jdi.connect \
+    com.sun.jdi.connect.spi \
+    com.sun.jdi.event \
+    com.sun.jdi.request \
+    com.sun.javadoc \
+    com.sun.tools.doclets \
+    com.sun.tools.doctree \
+    com.sun.source.tree \
+    com.sun.source.util \
+    com.sun.tools.attach \
+    com.sun.tools.attach.spi \
+    com.sun.tools.jconsole \
+    com.sun.tools.javac \
+    com.sun.tools.javah \
+    com.sun.tools.javap \
+    com.sun.tools.javadoc \
+    com.sun.servicetag
diff --git a/test/tools/sjavac/SJavac.java b/test/tools/sjavac/SJavac.java
new file mode 100644
index 0000000..1c8d612
--- /dev/null
+++ b/test/tools/sjavac/SJavac.java
@@ -0,0 +1,573 @@
+/*
+ * 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.util.*;
+import java.io.*;
+import java.net.*;
+import java.nio.file.*;
+import java.nio.file.attribute.*;
+import java.nio.charset.*;
+
+import com.sun.tools.sjavac.Main;
+
+public
+class SJavac {
+
+    public static void main(String... args) throws Exception {
+        SJavac s = new SJavac();
+        s.test();
+    }
+
+    FileSystem defaultfs = FileSystems.getDefault();
+
+    // Where to put generated sources that will
+    // test aspects of sjavac, ie JTWork/scratch/gensrc
+    Path gensrc;
+    // More gensrc dirs are used to test merging of serveral source roots.
+    Path gensrc2;
+    Path gensrc3;
+
+    // Where to put compiled classes.
+    Path bin;
+    // Where to put c-header files.
+    Path headers;
+
+    // The sjavac compiler.
+    Main main = new Main();
+
+    // Remember the previous bin and headers state here.
+    Map<String,Long> previous_bin_state;
+    Map<String,Long> previous_headers_state;
+
+    public void test() throws Exception {
+        gensrc = defaultfs.getPath("gensrc");
+        gensrc2 = defaultfs.getPath("gensrc2");
+        gensrc3 = defaultfs.getPath("gensrc3");
+        bin = defaultfs.getPath("bin");
+        headers = defaultfs.getPath("headers");
+
+        Files.createDirectory(gensrc);
+        Files.createDirectory(gensrc2);
+        Files.createDirectory(gensrc3);
+        Files.createDirectory(bin);
+        Files.createDirectory(headers);
+
+        initialCompile();
+        incrementalCompileNoChanges();
+        incrementalCompileDroppingClasses();
+        incrementalCompileWithChange();
+        incrementalCompileDropAllNatives();
+        incrementalCompileAddNative();
+        incrementalCompileChangeNative();
+        compileWithOverrideSource();
+        compileWithInvisibleSources();
+        compileCircularSources();
+
+        delete(gensrc);
+        delete(gensrc2);
+        delete(gensrc3);
+        delete(bin);
+    }
+
+    void initialCompile() throws Exception {
+        System.out.println("\nInitial compile of gensrc.");
+        System.out.println("----------------------------");
+        populate(gensrc,
+            "alfa/AINT.java",
+            "package alfa; public interface AINT { void aint(); }",
+
+            "alfa/A.java",
+            "package alfa; public class A implements AINT { "+
+                 "public final static int DEFINITION = 17; public void aint() { } }",
+
+            "alfa/AA.java",
+            "package alfa;"+
+            "// A package private class, not contributing to the public api.\n"+
+            "class AA {"+
+            "   // A properly nested static inner class.\n"+
+            "    static class AAA { }\n"+
+            "    // A properly nested inner class.\n"+
+            "    class AAAA { }\n"+
+            "    Runnable foo() {\n"+
+            "        // A proper anonymous class.\n"+
+            "        return new Runnable() { public void run() { } };\n"+
+            "    }\n"+
+            "    AAA aaa;\n"+
+            "    AAAA aaaa;\n"+
+            "    AAAAA aaaaa;\n"+
+            "}\n"+
+            "class AAAAA {\n"+
+            "    // A bad auxiliary class, but no one is referencing it\n"+
+            "    // from outside of this source file, therefore it is ok.\n"+
+            "}\n",
+
+            "beta/BINT.java",
+            "package beta;public interface BINT { void foo(); }",
+
+            "beta/B.java",
+            "package beta; import alfa.A; public class B {"+
+            "private int b() { return A.DEFINITION; } native void foo(); }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        previous_bin_state = collectState(bin);
+        previous_headers_state = collectState(headers);
+    }
+
+    void incrementalCompileNoChanges() throws Exception {
+        System.out.println("\nTesting that no change in sources implies no change in binaries.");
+        System.out.println("------------------------------------------------------------------");
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyEqual(new_bin_state, previous_bin_state);
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyEqual(previous_headers_state, new_headers_state);
+    }
+
+    void incrementalCompileDroppingClasses() throws Exception {
+        System.out.println("\nTesting that deleting AA.java deletes all");
+        System.out.println("generated inner class as well as AA.class");
+        System.out.println("-----------------------------------------");
+        removeFrom(gensrc, "alfa/AA.java");
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyThatFilesHaveBeenRemoved(previous_bin_state, new_bin_state,
+                                       "bin/alfa/AA$1.class",
+                                       "bin/alfa/AA$AAAA.class",
+                                       "bin/alfa/AA$AAA.class",
+                                       "bin/alfa/AAAAA.class",
+                                       "bin/alfa/AA.class");
+
+        previous_bin_state = new_bin_state;
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyEqual(previous_headers_state, new_headers_state);
+    }
+
+    void incrementalCompileWithChange() throws Exception {
+        System.out.println("\nNow update the A.java file with a new timestamps and");
+        System.out.println("new final static definition. This should trigger a recompile,");
+        System.out.println("not only of alfa, but also beta.");
+        System.out.println("But check that the generated native header was not updated!");
+        System.out.println("Since we did not modify the native api of B.");
+        System.out.println("-------------------------------------------------------------");
+
+        populate(gensrc,"alfa/A.java",
+                       "package alfa; public class A implements AINT { "+
+                 "public final static int DEFINITION = 18; public void aint() { } private void foo() { } }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+
+        verifyNewerFiles(previous_bin_state, new_bin_state,
+                         "bin/alfa/A.class",
+                         "bin/alfa/AINT.class",
+                         "bin/beta/B.class",
+                         "bin/beta/BINT.class",
+                         "bin/javac_state");
+        previous_bin_state = new_bin_state;
+
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyEqual(new_headers_state, previous_headers_state);
+    }
+
+    void incrementalCompileDropAllNatives() throws Exception {
+        System.out.println("\nNow update the B.java file with one less native method,");
+        System.out.println("ie it has no longer any methods!");
+        System.out.println("Verify that beta_B.h is removed!");
+        System.out.println("---------------------------------------------------------");
+
+        populate(gensrc,"beta/B.java",
+                       "package beta; import alfa.A; public class B {"+
+                       "private int b() { return A.DEFINITION; } }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyNewerFiles(previous_bin_state, new_bin_state,
+                         "bin/beta/B.class",
+                         "bin/beta/BINT.class",
+                         "bin/javac_state");
+        previous_bin_state = new_bin_state;
+
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyThatFilesHaveBeenRemoved(previous_headers_state, new_headers_state,
+                                       "headers/beta_B.h");
+        previous_headers_state = new_headers_state;
+    }
+
+    void incrementalCompileAddNative() throws Exception {
+        System.out.println("\nNow update the B.java file with a final static annotated with @Native.");
+        System.out.println("Verify that beta_B.h is added again!");
+        System.out.println("------------------------------------------------------------------------");
+
+        populate(gensrc,"beta/B.java",
+                       "package beta; import alfa.A; public class B {"+
+                       "private int b() { return A.DEFINITION; } "+
+                 "@java.lang.annotation.Native final static int alfa = 42; }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyNewerFiles(previous_bin_state, new_bin_state,
+                         "bin/beta/B.class",
+                         "bin/beta/BINT.class",
+                         "bin/javac_state");
+        previous_bin_state = new_bin_state;
+
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyThatFilesHaveBeenAdded(previous_headers_state, new_headers_state,
+                                     "headers/beta_B.h");
+        previous_headers_state = new_headers_state;
+    }
+
+    void incrementalCompileChangeNative() throws Exception {
+        System.out.println("\nNow update the B.java file with a new value for the final static"+
+                           " annotated with @Native.");
+        System.out.println("Verify that beta_B.h is rewritten again!");
+        System.out.println("-------------------------------------------------------------------");
+
+        populate(gensrc,"beta/B.java",
+                       "package beta; import alfa.A; public class B {"+
+                       "private int b() { return A.DEFINITION; } "+
+                 "@java.lang.annotation.Native final static int alfa = 43; }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false", "--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyNewerFiles(previous_bin_state, new_bin_state,
+                         "bin/beta/B.class",
+                         "bin/beta/BINT.class",
+                         "bin/javac_state");
+        previous_bin_state = new_bin_state;
+
+        Map<String,Long> new_headers_state = collectState(headers);
+        verifyNewerFiles(previous_headers_state, new_headers_state,
+                         "headers/beta_B.h");
+        previous_headers_state = new_headers_state;
+    }
+
+    void compileWithOverrideSource() throws Exception {
+        System.out.println("\nNow verify that we can override sources to be compiled.");
+        System.out.println("Compile gensrc and gensrc2. However do not compile broken beta.B in gensrc,");
+        System.out.println("only compile ok beta.B in gensrc2.");
+        System.out.println("---------------------------------------------------------------------------");
+
+        delete(gensrc);
+        delete(gensrc2);
+        delete(bin);
+        previous_bin_state = collectState(bin);
+
+        populate(gensrc,"alfa/A.java",
+                 "package alfa; import beta.B; import gamma.C; public class A { B b; C c; }",
+                 "beta/B.java",
+                 "package beta; public class B { broken",
+                 "gamma/C.java",
+                 "package gamma; public class C { }");
+
+        populate(gensrc2,
+                 "beta/B.java",
+                 "package beta; public class B { }");
+
+        compile("-x", "beta", "gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
+                                     "bin/alfa/A.class",
+                                     "bin/beta/B.class",
+                                     "bin/gamma/C.class",
+                                     "bin/javac_state");
+
+        System.out.println("----- Compile with exluded beta went well!");
+        delete(bin);
+        compileExpectFailure("gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1",
+                             "--server:portfile=testserver,background=false");
+
+        System.out.println("----- Compile without exluded beta failed, as expected! Good!");
+        delete(bin);
+    }
+
+    void compileWithInvisibleSources() throws Exception {
+        System.out.println("\nNow verify that we can make sources invisible to linking (sourcepath).");
+        System.out.println("Compile gensrc and link against gensrc2 and gensrc3, however");
+        System.out.println("gensrc2 contains broken code in beta.B, thus we must exclude that package");
+        System.out.println("fortunately gensrc3 contains a proper beta.B.");
+        System.out.println("------------------------------------------------------------------------");
+
+        // Start with a fresh gensrcs and bin.
+        delete(gensrc);
+        delete(gensrc2);
+        delete(gensrc3);
+        delete(bin);
+        previous_bin_state = collectState(bin);
+
+        populate(gensrc,"alfa/A.java",
+                 "package alfa; import beta.B; import gamma.C; public class A { B b; C c; }");
+        populate(gensrc2,"beta/B.java",
+                 "package beta; public class B { broken",
+                 "gamma/C.java",
+                 "package gamma; public class C { }");
+        populate(gensrc3, "beta/B.java",
+                 "package beta; public class B { }");
+
+        compile("gensrc", "-x", "beta", "-sourcepath", "gensrc2",
+                "-sourcepath", "gensrc3", "-d", "bin", "-h", "headers", "-j", "1",
+                "--server:portfile=testserver,background=false");
+
+        System.out.println("The first compile went well!");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
+                                     "bin/alfa/A.class",
+                                     "bin/javac_state");
+
+        System.out.println("----- Compile with exluded beta went well!");
+        delete(bin);
+        compileExpectFailure("gensrc", "-sourcepath", "gensrc2", "-sourcepath", "gensrc3",
+                             "-d", "bin", "-h", "headers", "-j", "1",
+                             "--server:portfile=testserver,background=false");
+
+        System.out.println("----- Compile without exluded beta failed, as expected! Good!");
+        delete(bin);
+    }
+
+    void compileCircularSources() throws Exception {
+        System.out.println("\nNow verify that circular sources split on multiple cores can be compiled.");
+        System.out.println("---------------------------------------------------------------------------");
+
+        // Start with a fresh gensrcs and bin.
+        delete(gensrc);
+        delete(gensrc2);
+        delete(gensrc3);
+        delete(bin);
+        previous_bin_state = collectState(bin);
+
+        populate(gensrc,"alfa/A.java",
+                 "package alfa; public class A { beta.B b; }",
+                 "beta/B.java",
+                 "package beta; public class B { gamma.C c; }",
+                 "gamma/C.java",
+                 "package gamma; public class C { alfa.A a; }");
+
+        compile("gensrc", "-d", "bin", "-h", "headers", "-j", "3",
+                "--server:portfile=testserver,background=false","--log=debug");
+        Map<String,Long> new_bin_state = collectState(bin);
+        verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,
+                                     "bin/alfa/A.class",
+                                     "bin/beta/B.class",
+                                     "bin/gamma/C.class",
+                                     "bin/javac_state");
+        delete(bin);
+    }
+
+    void removeFrom(Path dir, String... args) throws IOException {
+        for (String filename : args) {
+            Path p = dir.resolve(filename);
+            Files.delete(p);
+        }
+    }
+
+    void populate(Path src, String... args) throws IOException {
+        if (!Files.exists(src)) {
+            Files.createDirectory(src);
+        }
+        String[] a = args;
+        for (int i = 0; i<a.length; i+=2) {
+            String filename = a[i];
+            String content = a[i+1];
+            Path p = src.resolve(filename);
+            Files.createDirectories(p.getParent());
+            PrintWriter out = new PrintWriter(Files.newBufferedWriter(p,
+                                                                      Charset.defaultCharset()));
+            out.println(content);
+            out.close();
+        }
+    }
+
+    void delete(Path root) throws IOException {
+        if (!Files.exists(root)) return;
+        Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
+                 @Override
+                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
+                 {
+                     Files.delete(file);
+                     return FileVisitResult.CONTINUE;
+                 }
+
+                 @Override
+                 public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException
+                 {
+                     if (e == null) {
+                         if (!dir.equals(root)) Files.delete(dir);
+                         return FileVisitResult.CONTINUE;
+                     } else {
+                         // directory iteration failed
+                         throw e;
+                     }
+                 }
+            });
+    }
+
+    void compile(String... args) throws Exception {
+        int rc = main.go(args, System.out, System.err);
+        if (rc != 0) throw new Exception("Error during compile!");
+
+        // Wait a second, to get around the (temporary) problem with
+        // second resolution in the Java file api. But do not do this
+        // on windows where the timestamps work.
+        long in_a_sec = System.currentTimeMillis()+1000;
+        while (in_a_sec > System.currentTimeMillis()) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+
+    void compileExpectFailure(String... args) throws Exception {
+        int rc = main.go(args, System.out, System.err);
+        if (rc == 0) throw new Exception("Expected error during compile! Did not fail!");
+    }
+
+    Map<String,Long> collectState(Path dir) throws IOException
+    {
+        final Map<String,Long> files = new HashMap<>();
+        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+                 @Override
+                 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+                   throws IOException
+                 {
+                     files.put(file.toString(),new Long(Files.getLastModifiedTime(file).toMillis()));
+                     return FileVisitResult.CONTINUE;
+                 }
+            });
+        return files;
+    }
+
+    void verifyThatFilesHaveBeenRemoved(Map<String,Long> from,
+                                        Map<String,Long> to,
+                                        String... args) throws Exception {
+
+        Set<String> froms = from.keySet();
+        Set<String> tos = to.keySet();
+
+        if (froms.equals(tos)) {
+            throw new Exception("Expected new state to have fewer files than previous state!");
+        }
+
+        for (String t : tos) {
+            if (!froms.contains(t)) {
+                throw new Exception("Expected "+t+" to exist in previous state!");
+            }
+        }
+
+        for (String f : args) {
+            f = f.replace("/", File.separator);
+            if (!froms.contains(f)) {
+                throw new Exception("Expected "+f+" to exist in previous state!");
+            }
+            if (tos.contains(f)) {
+                throw new Exception("Expected "+f+" to have been removed from the new state!");
+            }
+        }
+
+        if (froms.size() - args.length != tos.size()) {
+            throw new Exception("There are more removed files than the expected list!");
+        }
+    }
+
+    void verifyThatFilesHaveBeenAdded(Map<String,Long> from,
+                                      Map<String,Long> to,
+                                      String... args) throws Exception {
+
+        Set<String> froms = from.keySet();
+        Set<String> tos = to.keySet();
+
+        if (froms.equals(tos)) {
+            throw new Exception("Expected new state to have more files than previous state!");
+        }
+
+        for (String t : froms) {
+            if (!tos.contains(t)) {
+                throw new Exception("Expected "+t+" to exist in new state!");
+            }
+        }
+
+        for (String f : args) {
+            f = f.replace("/", File.separator);
+            if (!tos.contains(f)) {
+                throw new Exception("Expected "+f+" to have been added to new state!");
+            }
+            if (froms.contains(f)) {
+                throw new Exception("Expected "+f+" to not exist in previous state!");
+            }
+        }
+
+        if (froms.size() + args.length != tos.size()) {
+            throw new Exception("There are more added files than the expected list!");
+        }
+    }
+
+    void verifyNewerFiles(Map<String,Long> from,
+                          Map<String,Long> to,
+                          String... args) throws Exception {
+        if (!from.keySet().equals(to.keySet())) {
+            throw new Exception("Expected the set of files to be identical!");
+        }
+        Set<String> files = new HashSet<String>();
+        for (String s : args) {
+            files.add(s.replace("/", File.separator));
+        }
+        for (String fn : from.keySet()) {
+            long f = from.get(fn);
+            long t = to.get(fn);
+            if (files.contains(fn)) {
+                if (t <= f) {
+                    throw new Exception("Expected "+fn+" to have a more recent timestamp!");
+                }
+            } else {
+                if (t != f) {
+                    throw new Exception("Expected "+fn+" to have the same timestamp!");
+                }
+            }
+        }
+    }
+
+    String print(Map<String,Long> m) {
+        StringBuilder b = new StringBuilder();
+        Set<String> keys = m.keySet();
+        for (String k : keys) {
+            b.append(k+" "+m.get(k)+"\n");
+        }
+        return b.toString();
+    }
+
+    void verifyEqual(Map<String,Long> from, Map<String,Long> to) throws Exception {
+        if (!from.equals(to)) {
+            System.out.println("FROM---"+print(from));
+            System.out.println("TO-----"+print(to));
+            throw new Exception("The dir should not differ! But it does!");
+        }
+    }
+}
diff --git a/test/tools/sjavac/SJavacWrapper.java b/test/tools/sjavac/SJavacWrapper.java
new file mode 100644
index 0000000..bba27eb
--- /dev/null
+++ b/test/tools/sjavac/SJavacWrapper.java
@@ -0,0 +1,67 @@
+/*
+ * 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 Test all aspects of sjavac.
+ *
+ * @bug 8004658
+ * @summary Add internal smart javac wrapper to solve JEP 139
+ *
+ * @run main SJavacWrapper
+ */
+
+import java.io.*;
+import java.lang.reflect.Method;
+import java.net.*;
+
+
+public
+class SJavacWrapper {
+
+    public static void main(String... args) throws Exception {
+        URL url = SJavacWrapper.class.getClassLoader().getResource("com/sun/tools/sjavac/Main.class");
+        if (url == null) {
+            // No sjavac in the classpath.
+            System.out.println("sjavac not available: pass by default");
+            return;
+        }
+
+        File testSrc = new File(System.getProperty("test.src"));
+        File sjavac_java = new File(testSrc, "SJavac.java");
+        File testClasses = new File(System.getProperty("test.classes"));
+        File sjavac_class = new File(testClasses, "SJavac.class");
+        if (sjavac_class.lastModified() < sjavac_java.lastModified()) {
+            String[] javac_args = { "-d", testClasses.getPath(), sjavac_java.getPath() };
+            System.err.println("Recompiling SJavac.java");
+            int rc = com.sun.tools.javac.Main.compile(javac_args);
+            if (rc != 0)
+                throw new Exception("compilation failed");
+        }
+
+        Class<?> sjavac = Class.forName("SJavac");
+        Method sjavac_main = sjavac.getMethod("main", String[].class);
+        sjavac_main.invoke(null, new Object[] { args });
+    }
+
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libnb-javaparser-java.git



More information about the pkg-java-commits mailing list